From 2c3392b1e5f6c9e36967fc7690f5399d0f3df6bb Mon Sep 17 00:00:00 2001 From: cenfun Date: Fri, 22 Mar 2024 12:33:55 +0800 Subject: [PATCH] remove build-docs --- README.md | 14 ++++---- package.json | 5 ++- scripts/build-docs.js | 74 ------------------------------------------- test/package.json | 4 +-- 4 files changed, 10 insertions(+), 87 deletions(-) delete mode 100644 scripts/build-docs.js diff --git a/README.md b/README.md index 2a05029f..9e6967ae 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,11 @@ await coverageReport.generate(); // const { CoverageReport } = require('monocart-coverage-reports'); // const coverageReport = new CoverageReport(coverageOptions); ``` -- [example v8](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-v8.js) -- [example istanbul](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-istanbul.js) +- [example v8](./test/test-v8.js) +- [example istanbul](./test/test-istanbul.js) ## Default Options -- [lib/default/options.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/lib/default/options.js) +- [lib/default/options.js](./lib/default/options.js) - `reports` [Available Reports](#available-reports) - `entryFilter` and `sourceFilter` [Using `entryFilter` and `sourceFilter` to filter the results for V8 report](#using-entryfilter-and-sourcefilter-to-filter-the-results-for-v8-report) - `sourcePath` [Resolve `sourcePath` for the Source Files](#resolve-sourcepath-for-the-source-files) @@ -84,7 +84,7 @@ await coverageReport.generate(); - `logging` [Debug for Coverage and Sourcemap](#debug-for-coverage-and-sourcemap) - `onEnd` [onEnd Hook](#onend-hook) -- Declaration [lib/index.d.ts](https://github.com/cenfun/monocart-coverage-reports/blob/main/lib/index.d.ts) +- Declaration [lib/index.d.ts](./lib/index.d.ts) ## Available Reports @@ -216,17 +216,17 @@ coverageReport.cleanCache(); ## Collecting Istanbul Coverage Data - Instrumenting source code > Before collecting Istanbul coverage data, It requires your source code is instrumented with Istanbul - - webpack: [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul), example: [webpack.config-istanbul.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/webpack.config-istanbul.js) + - webpack: [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul), example: [webpack.config-istanbul.js](./test/webpack.config-istanbul.js) - rollup: [rollup-plugin-istanbul](https://github.com/artberri/rollup-plugin-istanbul) - vite: [vite-plugin-istanbul](https://github.com/ifaxity/vite-plugin-istanbul) - Browser - - Collecting coverage data from `window.__coverage__`, example: [test-istanbul.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-istanbul.js) + - Collecting coverage data from `window.__coverage__`, example: [test-istanbul.js](./test/test-istanbul.js) - Node.js - Collecting coverage data from `global.__coverage__` ## Collecting V8 Coverage Data - For source code: enable `sourcemap` and do not compress/minify: - - [webpack](https://webpack.js.org/configuration/): `devtool: source-map` and `mode: development`, example [webpack.config-v8.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/webpack.config-v8.js) + - [webpack](https://webpack.js.org/configuration/): `devtool: source-map` and `mode: development`, example [webpack.config-v8.js](./test/webpack.config-v8.js) - [rollup](https://rollupjs.org/configuration-options/): `sourcemap: true` - [vite](https://vitejs.dev/config/build-options.html): `sourcemap: true` and `minify: false` - [esbuild](https://esbuild.github.io/api/): `sourcemap: true` and `minify: false` diff --git a/package.json b/package.json index 45c4c00c..20003d17 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ }, "types": "./lib/index.d.ts", "scripts": { - "build-docs": "node ./scripts/build-docs.js", "build-test": "node ./scripts/build-test.js", "build": "sf lint && sf b -p && npm run build-test", "test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js", @@ -51,7 +50,7 @@ "test-merge": "node ./test/test-merge.js", "test-merge-istanbul": "node ./test/test-merge-istanbul.js", "test-client": "node ./test/test-client.js", - "test-all": "npm run test-node && npm run test-browser && npm run test-cli && npm run test-tsx && npm run test-merge && npm run build-docs", + "test-all": "npm run test-node && npm run test-browser && npm run test-cli && npm run test-tsx && npm run test-merge", "test": "npx mcr npm run test-all -c test/mcr.config.mcr.js", "test:snap": "cross-env TEST_SNAPSHOT=true npm run test", "dev": "sf d v8", @@ -95,4 +94,4 @@ "tsx": "^4.7.1", "ws": "^8.16.0" } -} +} \ No newline at end of file diff --git a/scripts/build-docs.js b/scripts/build-docs.js deleted file mode 100644 index 5f0e53a0..00000000 --- a/scripts/build-docs.js +++ /dev/null @@ -1,74 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const { marked } = require('marked'); - -const Util = require('../lib/utils/util.js'); - -const buildDocs = () => { - - console.log('build docs ...'); - - const assetsDir = path.resolve(__dirname, '../docs/assets'); - if (!fs.existsSync(assetsDir)) { - fs.mkdirSync(assetsDir, { - recursive: true - }); - } - - // copy assets - Util.forEachFile('./assets', [], (filename, fileDir) => { - fs.copyFileSync( - path.resolve(fileDir, filename), - path.resolve(assetsDir, filename) - ); - }); - - // copy css - fs.copyFileSync( - path.resolve(__dirname, '../node_modules/github-markdown-css/github-markdown.css'), - path.resolve(assetsDir, 'github-markdown.css') - ); - - const markdownTemplate = fs.readFileSync(path.resolve(__dirname, 'template/markdown.html'), { - encoding: 'utf-8' - }); - - // add target="_blank" for link - const renderer = new marked.Renderer(); - renderer.link = function(href, title, text) { - const link = marked.Renderer.prototype.link.apply(this, arguments); - if (href.startsWith('#')) { - return link; - } - return link.replace('