Skip to content

Commit 5fc516b

Browse files
lukekarryswraithgar
authored andcommitted
chore: update snapshot tests for new docs
1 parent f375300 commit 5fc516b

29 files changed

+4585
-5914
lines changed

.github/workflows/ci-docs.yml renamed to .github/workflows/ci-npmcli-docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is automatically added by @npmcli/template-oss. Do not edit.
22

3-
name: CI - docs
3+
name: CI - @npmcli/docs
44

55
on:
66
workflow_dispatch:
@@ -71,9 +71,9 @@ jobs:
7171
- name: Reset Deps
7272
run: node . run resetdeps
7373
- name: Lint
74-
run: node . run lint --ignore-scripts -w docs
74+
run: node . run lint --ignore-scripts -w @npmcli/docs
7575
- name: Post Lint
76-
run: node . run postlint --ignore-scripts -w docs
76+
run: node . run postlint --ignore-scripts -w @npmcli/docs
7777

7878
test:
7979
name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
@@ -114,7 +114,7 @@ jobs:
114114
- name: Add Problem Matcher
115115
run: echo "::add-matcher::.github/matchers/tap.json"
116116
- name: Test
117-
run: node . test --ignore-scripts -w docs
117+
run: node . test --ignore-scripts -w @npmcli/docs
118118
- name: Check Git Status
119119
if: matrix && matrix.platform.os != 'windows-latest'
120120
run: node scripts/git-dirty.js

DEPENDENCIES.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ graph LR;
117117
npm-->npmcli-arborist["@npmcli/arborist"];
118118
npm-->npmcli-ci-detect["@npmcli/ci-detect"];
119119
npm-->npmcli-config["@npmcli/config"];
120+
npm-->npmcli-docs["@npmcli/docs"];
120121
npm-->npmcli-eslint-config["@npmcli/eslint-config"];
121122
npm-->npmcli-fs["@npmcli/fs"];
122123
npm-->npmcli-git["@npmcli/git"];
@@ -193,6 +194,10 @@ graph LR;
193194
npmcli-config-->proc-log;
194195
npmcli-config-->read-package-json-fast;
195196
npmcli-config-->semver;
197+
npmcli-docs-->ignore-walk;
198+
npmcli-docs-->npmcli-eslint-config["@npmcli/eslint-config"];
199+
npmcli-docs-->npmcli-fs["@npmcli/fs"];
200+
npmcli-docs-->npmcli-template-oss["@npmcli/template-oss"];
196201
npmcli-fs-->semver;
197202
npmcli-git-->npm-pick-manifest;
198203
npmcli-git-->npmcli-promise-spawn["@npmcli/promise-spawn"];
@@ -388,19 +393,6 @@ graph LR;
388393
detab-->repeat-string;
389394
dezalgo-->asap;
390395
dezalgo-->wrappy;
391-
docs-->cmark-gfm;
392-
docs-->front-matter;
393-
docs-->ignore-walk;
394-
docs-->isaacs-string-locale-compare["@isaacs/string-locale-compare"];
395-
docs-->jsdom;
396-
docs-->marked-man;
397-
docs-->mdx-js-mdx["@mdx-js/mdx"];
398-
docs-->mkdirp;
399-
docs-->npmcli-eslint-config["@npmcli/eslint-config"];
400-
docs-->npmcli-fs["@npmcli/fs"];
401-
docs-->npmcli-template-oss["@npmcli/template-oss"];
402-
docs-->tap;
403-
docs-->yaml;
404396
domexception-->webidl-conversions;
405397
encoding-->iconv-lite;
406398
end-of-stream-->once;
@@ -701,7 +693,6 @@ graph LR;
701693
npm-->cli-columns;
702694
npm-->cli-table3;
703695
npm-->columnify;
704-
npm-->docs;
705696
npm-->fastest-levenshtein;
706697
npm-->fs-minipass;
707698
npm-->glob;
@@ -745,6 +736,7 @@ graph LR;
745736
npm-->npmcli-arborist["@npmcli/arborist"];
746737
npm-->npmcli-ci-detect["@npmcli/ci-detect"];
747738
npm-->npmcli-config["@npmcli/config"];
739+
npm-->npmcli-docs["@npmcli/docs"];
748740
npm-->npmcli-eslint-config["@npmcli/eslint-config"];
749741
npm-->npmcli-fs["@npmcli/fs"];
750742
npm-->npmcli-git["@npmcli/git"];
@@ -855,6 +847,19 @@ graph LR;
855847
npmcli-config-->semver;
856848
npmcli-config-->walk-up-path;
857849
npmcli-disparity-colors-->ansi-styles;
850+
npmcli-docs-->cmark-gfm;
851+
npmcli-docs-->front-matter;
852+
npmcli-docs-->ignore-walk;
853+
npmcli-docs-->isaacs-string-locale-compare["@isaacs/string-locale-compare"];
854+
npmcli-docs-->jsdom;
855+
npmcli-docs-->marked-man;
856+
npmcli-docs-->mdx-js-mdx["@mdx-js/mdx"];
857+
npmcli-docs-->mkdirp;
858+
npmcli-docs-->npmcli-eslint-config["@npmcli/eslint-config"];
859+
npmcli-docs-->npmcli-fs["@npmcli/fs"];
860+
npmcli-docs-->npmcli-template-oss["@npmcli/template-oss"];
861+
npmcli-docs-->tap;
862+
npmcli-docs-->yaml;
858863
npmcli-fs-->gar-promisify["@gar/promisify"];
859864
npmcli-fs-->semver;
860865
npmcli-git-->lru-cache;
@@ -1109,6 +1114,6 @@ packages higher up the chain.
11091114
- pacote, libnpmaccess, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, npm-profile
11101115
- npm-registry-fetch, libnpmversion
11111116
- @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json
1112-
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, npm-packlist, read-package-json, @npmcli/query, readdir-scoped-modules, promzard
1113-
- npm-bundled, read-package-json-fast, @npmcli/fs, unique-filename, @npmcli/promise-spawn, npm-install-checks, npm-package-arg, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, dezalgo, read
1114-
- npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, semver, @npmcli/move-file, fs-minipass, infer-owner, ssri, unique-slug, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, ignore-walk, minipass-fetch, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, wrappy, treeverse, @npmcli/eslint-config, @npmcli/template-oss, minify-registry-metadata, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, ini, npm-audit-report, npm-user-validate
1117+
- @npmcli/docs, @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, npm-packlist, read-package-json, @npmcli/query, readdir-scoped-modules, promzard
1118+
- @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, @npmcli/promise-spawn, npm-install-checks, npm-package-arg, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, dezalgo, read
1119+
- semver, ignore-walk, @npmcli/eslint-config, @npmcli/template-oss, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, @npmcli/move-file, fs-minipass, infer-owner, ssri, unique-slug, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, wrappy, treeverse, minify-registry-metadata, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, ini, npm-audit-report, npm-user-validate

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "docs",
2+
"name": "@npmcli/docs",
33
"description": "The npm cli documentation",
44
"version": "1.0.0",
55
"private": true,
@@ -36,7 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"@npmcli/eslint-config": "^3.1.0",
39-
"@npmcli/template-oss": "4.5.1",
39+
"@npmcli/template-oss": "4.7.1",
4040
"tap": "^16.0.1"
4141
},
4242
"author": "GitHub Inc.",

lib/commands/completion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const fs = require('@npmcli/fs')
3333
const nopt = require('nopt')
3434

3535
const { definitions, shorthands } = require('../utils/config/index.js')
36-
const { aliases, cmdList, plumbing } = require('../utils/cmd-list.js')
36+
const { aliases, commands, plumbing } = require('../utils/cmd-list.js')
3737
const aliasNames = Object.keys(aliases)
38-
const fullList = cmdList.concat(aliasNames).filter(c => !plumbing.includes(c))
38+
const fullList = commands.concat(aliasNames).filter(c => !plumbing.includes(c))
3939
const configNames = Object.keys(definitions)
4040
const shorthandNames = Object.keys(shorthands)
4141
const allConfs = configNames.concat(shorthandNames)

lib/commands/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { getContents, logTar } = require('../utils/tar.js')
1616
// keys that npm supports in .npmrc files and elsewhere. We *may* want to
1717
// revisit this at some point, and have a minimal set that's a SemVer-major
1818
// change that ought to get a RFC written on it.
19-
const flatten = require('../utils/config/flatten.js')
19+
const { flatten } = require('../utils/config/index.js')
2020

2121
// this is the only case in the CLI where we want to use the old full slow
2222
// 'read-package-json' module, because we want to pull in all the defaults and

lib/commands/unpublish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path')
66
const util = require('util')
77
const readJson = util.promisify(require('read-package-json'))
88

9-
const flatten = require('../utils/config/flatten.js')
9+
const { flatten } = require('../utils/config/index.js')
1010
const getIdentity = require('../utils/get-identity.js')
1111
const log = require('../utils/log-shim')
1212
const otplease = require('../utils/otplease.js')

lib/utils/cmd-list.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const abbrev = require('abbrev')
2+
const localeCompare = require('@isaacs/string-locale-compare')('en')
23

34
// plumbing should not have any aliases
45
const aliases = {
@@ -69,8 +70,7 @@ const aliases = {
6970
}
7071

7172
// these are filenames in .
72-
// Keep these sorted so that lib/utils/npm-usage.js outputs in order
73-
const cmdList = [
73+
const commands = [
7474
'access',
7575
'adduser',
7676
'audit',
@@ -141,11 +141,13 @@ const cmdList = [
141141
]
142142

143143
const plumbing = ['birthday', 'help-search']
144-
const abbrevs = abbrev(cmdList.concat(Object.keys(aliases)))
144+
const allCommands = [...commands, ...plumbing].sort(localeCompare)
145+
const abbrevs = abbrev(commands.concat(Object.keys(aliases)))
145146

146147
module.exports = {
147148
abbrevs,
148149
aliases,
149-
cmdList,
150+
commands,
150151
plumbing,
152+
allCommands,
151153
}

lib/utils/config/describe-all.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

lib/utils/config/flatten.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

lib/utils/config/index.js

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1-
const flatten = require('./flatten.js')
21
const definitions = require('./definitions.js')
3-
const describeAll = require('./describe-all.js')
2+
3+
// use the defined flattening function, and copy over any scoped
4+
// registries and registry-specific "nerfdart" configs verbatim
5+
//
6+
// TODO: make these getters so that we only have to make dirty
7+
// the thing that changed, and then flatten the fields that
8+
// could have changed when a config.set is called.
9+
//
10+
// TODO: move nerfdart auth stuff into a nested object that
11+
// is only passed along to paths that end up calling npm-registry-fetch.
12+
const flatten = (obj, flat = {}) => {
13+
for (const [key, val] of Object.entries(obj)) {
14+
const def = definitions[key]
15+
if (def && def.flatten) {
16+
def.flatten(key, obj, flat)
17+
} else if (/@.*:registry$/i.test(key) || /^\/\//.test(key)) {
18+
flat[key] = val
19+
}
20+
}
21+
22+
// XXX make this the bin/npm-cli.js file explicitly instead
23+
// otherwise using npm programmatically is a bit of a pain.
24+
flat.npmBin = require.main ? require.main.filename
25+
: /* istanbul ignore next - not configurable property */ undefined
26+
flat.nodeBin = process.env.NODE || process.execPath
27+
28+
// XXX should this be sha512? is it even relevant?
29+
flat.hashAlgorithm = 'sha1'
30+
31+
return flat
32+
}
433

534
// aliases where they get expanded into a completely different thing
635
// these are NOT supported in the environment or npmrc files, only
@@ -26,30 +55,24 @@ const shorthands = {
2655
readonly: ['--read-only'],
2756
reg: ['--registry'],
2857
iwr: ['--include-workspace-root'],
29-
}
30-
31-
for (const [key, { short }] of Object.entries(definitions)) {
32-
if (!short) {
33-
continue
34-
}
35-
// can be either an array or string
36-
for (const s of [].concat(short)) {
37-
shorthands[s] = [`--${key}`]
38-
}
58+
...Object.entries(definitions).reduce((acc, [key, { short = [] }]) => {
59+
// can be either an array or string
60+
for (const s of [].concat(short)) {
61+
acc[s] = [`--${key}`]
62+
}
63+
return acc
64+
}, {}),
3965
}
4066

4167
module.exports = {
4268
get defaults () {
4369
// NB: 'default' is a reserved word
44-
return Object.entries(definitions).map(([key, { default: def }]) => {
45-
return [key, def]
46-
}).reduce((defaults, [key, def]) => {
47-
defaults[key] = def
48-
return defaults
70+
return Object.entries(definitions).reduce((acc, [key, { default: d }]) => {
71+
acc[key] = d
72+
return acc
4973
}, {})
5074
},
5175
definitions,
5276
flatten,
5377
shorthands,
54-
describeAll,
5578
}

0 commit comments

Comments
 (0)