From fb630b5a9af86c71602803297634ec291eeedee0 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Tue, 1 Jun 2021 11:28:46 -0400 Subject: [PATCH] chore: manage docs as a workspace - Add `./docs` as a workspace - Reinstate `./docs/package.json` to manage docs deps - Ignore `docs/content` markdown source folder from published tarball - Tweaked `make docs` to use `npm run` to run docs build step - Tweaked "bundle and gitignore" script to ignore symlinks in nm folder - Removed outdated `package.json` comment Relates to: https://github.com/npm/statusboard/issues/362 PR-URL: https://github.com/npm/cli/pull/3342 Credit: @ruyadorno Close: #3342 Reviewed-by: @wraithgar --- .npmignore | 4 ++++ Makefile | 2 +- docs/package.json | 19 +++++++++++++++ node_modules/.gitignore | 1 + package-lock.json | 36 ++++++++++++++++++++++------ package.json | 16 ++++--------- scripts/bundle-and-gitignore-deps.js | 2 +- 7 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 docs/package.json diff --git a/.npmignore b/.npmignore index 9d02b99f91b39..ae91e6482791f 100644 --- a/.npmignore +++ b/.npmignore @@ -27,6 +27,10 @@ docs/nav.yml docs/config.json docs/dockhand.js docs/template.html +docs/package.json +docs/node_modules +# docs source files are required by `npm help-search` do not exclude those +!docs/content/ # don't ignore .npmignore files # these are used in some tests. diff --git a/Makefile b/Makefile index d35cbbf5f3b6b..280e38f3619e2 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ $(version_mandocs): package.json htmldocs: dev-deps node bin/npm-cli.js rebuild - cd docs && node dockhand.js >&2 + node bin/npm-cli.js run -w docs build clean: docs-clean gitclean diff --git a/docs/package.json b/docs/package.json new file mode 100644 index 0000000000000..e48785bdba923 --- /dev/null +++ b/docs/package.json @@ -0,0 +1,19 @@ +{ + "name": "docs", + "description": "The npm cli documentation", + "version": "1.0.0", + "scripts": { + "build": "node dockhand" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/cli" + }, + "devDependencies": { + "@mdx-js/mdx": "^1.6.22", + "cmark-gfm": "^0.8.3", + "jsdom": "^16.4.0", + "marked-man": "^0.7.0", + "yaml": "^1.10.0" + } +} diff --git a/node_modules/.gitignore b/node_modules/.gitignore index a1aae51f99877..3c43d85884307 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -94,6 +94,7 @@ package-lock.json /detab /detect-libc /docopt +/docs /doctrine /domexception /end-of-stream diff --git a/package-lock.json b/package-lock.json index ac1cb7e2e0d81..f2e24facf80fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,6 +77,9 @@ "write-file-atomic" ], "license": "Artistic-2.0", + "workspaces": [ + "docs" + ], "dependencies": { "@npmcli/arborist": "^2.6.1", "@npmcli/ci-detect": "^1.2.0", @@ -151,23 +154,28 @@ "npx": "bin/npx-cli.js" }, "devDependencies": { - "@mdx-js/mdx": "^1.6.22", - "cmark-gfm": "^0.8.5", "eslint": "^7.26.0", "eslint-plugin-import": "^2.23.4", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.0", "eslint-plugin-standard": "^5.0.0", - "jsdom": "^16.5.2", - "licensee": "^8.1.0", - "marked-man": "^0.7.0", - "tap": "^15.0.9", - "yaml": "^1.10.2" + "licensee": "^8.2.0", + "tap": "^15.0.9" }, "engines": { "node": ">=10" } }, + "docs": { + "version": "1.0.0", + "devDependencies": { + "@mdx-js/mdx": "^1.6.22", + "cmark-gfm": "^0.8.3", + "jsdom": "^16.4.0", + "marked-man": "^0.7.0", + "yaml": "^1.10.0" + } + }, "node_modules/@babel/code-frame": { "version": "7.12.13", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", @@ -2230,6 +2238,10 @@ "node": ">=0.10.0" } }, + "node_modules/docs": { + "resolved": "docs", + "link": true + }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -11933,6 +11945,16 @@ "integrity": "sha1-so6eIiDaXsSffqW7JKR3h0Be6xE=", "dev": true }, + "docs": { + "version": "file:docs", + "requires": { + "@mdx-js/mdx": "^1.6.22", + "cmark-gfm": "^0.8.3", + "jsdom": "^16.4.0", + "marked-man": "^0.7.0", + "yaml": "^1.10.0" + } + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", diff --git a/package.json b/package.json index 7df43589334ef..7f870a76bcff9 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "version": "7.15.1", "name": "npm", "description": "a package manager for JavaScript", + "workspaces": [ + "docs" + ], "keywords": [ "install", "modules", @@ -180,18 +183,13 @@ "write-file-atomic" ], "devDependencies": { - "@mdx-js/mdx": "^1.6.22", - "cmark-gfm": "^0.8.5", "eslint": "^7.26.0", "eslint-plugin-import": "^2.23.4", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.0", "eslint-plugin-standard": "^5.0.0", - "jsdom": "^16.5.2", - "licensee": "^8.1.0", - "marked-man": "^0.7.0", - "tap": "^15.0.9", - "yaml": "^1.10.2" + "licensee": "^8.2.0", + "tap": "^15.0.9" }, "scripts": { "dumpconf": "env | grep npm | sort | uniq", @@ -212,10 +210,6 @@ "resetdeps": "bash scripts/resetdeps.sh", "smoke-tests": "tap smoke-tests/index.js" }, - "//": [ - "XXX temporarily only run unit tests while v7 beta is in progress", - "Remove the 'files' below once we're done porting old tests over" - ], "tap": { "test-env": [ "LC_ALL=sk" diff --git a/scripts/bundle-and-gitignore-deps.js b/scripts/bundle-and-gitignore-deps.js index 691deb91661ea..b15720c0340a4 100644 --- a/scripts/bundle-and-gitignore-deps.js +++ b/scripts/bundle-and-gitignore-deps.js @@ -10,7 +10,7 @@ const shouldIgnore = [] arb.loadVirtual().then(tree => { for (const [name, node] of tree.children.entries()) { - if (node.dev) { + if (node.dev || node.isLink) { console.error('ignore', node.name) shouldIgnore.push(node.name) } else if (tree.edgesOut.has(node.name)) {