Skip to content

Commit

Permalink
wip: more test conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 9, 2024
1 parent 9ab0826 commit 4677f8b
Show file tree
Hide file tree
Showing 39 changed files with 1,339 additions and 1,416 deletions.
2 changes: 1 addition & 1 deletion lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Init extends BaseCommand {
// to create a workspace package.json file or its folders
const { content: pkg } = await PackageJson.normalize(this.npm.localPrefix).catch(err => {
if (err.code === 'ENOENT') {
log.warn('Missing package.json. Try with `--include-workspace-root`.')
log.warn('', 'Missing package.json. Try with `--include-workspace-root`.')
}
throw err
})
Expand Down
5 changes: 3 additions & 2 deletions lib/commands/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Ping extends BaseCommand {
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
log.notice('PING', cleanRegistry)
const start = Date.now()
const details = await pingUtil({ ...this.npm.flatOptions })
let details = await pingUtil({ ...this.npm.flatOptions })
details = { a: 1, b: 2 }
const time = Date.now() - start
log.notice('PONG', `${time}ms`)
if (this.npm.config.get('json')) {
Expand All @@ -22,7 +23,7 @@ class Ping extends BaseCommand {
details,
}, null, 2))
} else if (Object.keys(details).length) {
log.notice('PONG', `${JSON.stringify(details, null, 2)}`)
log.notice('PONG', JSON.stringify(details, null, 2))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ class Npm {
}

outputBuffer (arg) {
this.#display.outputBuffer.push(arg)
this.#display.outputBuffer(arg)
}

flushOutput (jsonError) {
Expand Down
8 changes: 2 additions & 6 deletions lib/utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,11 @@ const cleanControl = createCleaner((output) => {
})

const formatWithOptions = ({ prefix = [], eol = '\n', ...options }, ...args) => {
const prefixStr = prefix.filter(p => p != null).join(' ')
const pre = prefix.filter(p => p != null).join(' ')
return baseFormatWithOptions(options, ...args)
.trim()
.split(/\r?\n/)
.map(cleanControl)
.reduce((lines, line) =>
lines += prefixStr + (prefixStr && line ? ' ' : '') + line + eol,
''
)
.reduce((acc, l) => `${acc}${pre}${pre && l ? ' ' : ''}${l}${eol}`, '')
}

const format = (...args) => formatWithOptions({}, ...args)
Expand Down
21 changes: 0 additions & 21 deletions tap-snapshots/test/lib/commands/audit.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ exports[`test/lib/commands/audit.js TAP audit signatures ignores optional depend
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures json output with invalid and missing signatures > must match snapshot 1`] = `
Expand Down Expand Up @@ -131,14 +130,12 @@ exports[`test/lib/commands/audit.js TAP audit signatures multiple registries wit
audited 2 packages in xxx
2 packages have verified registry signatures
`

exports[`test/lib/commands/audit.js TAP audit signatures omit dev dependencies with missing signature > must match snapshot 1`] = `
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures output details about missing signatures > must match snapshot 1`] = `
Expand All @@ -157,7 +154,6 @@ audited 1 package in xxx
@npmcli/arborist@1.0.14 (https://verdaccio-clone.org/)
Someone might have tampered with this package since it was published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures third-party registry with keys and missing signatures errors > must match snapshot 1`] = `
Expand All @@ -172,21 +168,18 @@ exports[`test/lib/commands/audit.js TAP audit signatures third-party registry wi
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures third-party registry with sub-path (trailing slash) > must match snapshot 1`] = `
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures third-party registry with sub-path > must match snapshot 1`] = `
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures with both invalid and missing signatures > must match snapshot 1`] = `
Expand All @@ -201,14 +194,12 @@ async@1.1.1 (https://registry.npmjs.org/)
kms-demo@1.0.0 (https://registry.npmjs.org/)
Someone might have tampered with this package since it was published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures with bundled and peer deps and no signatures > must match snapshot 1`] = `
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures with invalid attestations > must match snapshot 1`] = `
Expand All @@ -219,7 +210,6 @@ audited 1 package in xxx
sigstore@1.0.0 (https://registry.npmjs.org/)
Someone might have tampered with this package since it was published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures with invalid signatures > must match snapshot 1`] = `
Expand All @@ -230,7 +220,6 @@ audited 1 package in xxx
kms-demo@1.0.0 (https://registry.npmjs.org/)
Someone might have tampered with this package since it was published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures with invalid signtaures and color output enabled > must match snapshot 1`] = `
Expand All @@ -241,14 +230,12 @@ audited 1 package in xxx
kms-demo@1.0.0 (https://registry.npmjs.org/)
Someone might have tampered with this package since it was published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures with key fallback to legacy API > must match snapshot 1`] = `
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures with keys but missing signature > must match snapshot 1`] = `
Expand All @@ -268,7 +255,6 @@ sigstore@1.0.0 (https://registry.npmjs.org/)
tuf-js@1.0.0 (https://registry.npmjs.org/)
Someone might have tampered with these packages since they were published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures with multiple invalid signatures > must match snapshot 1`] = `
Expand All @@ -280,7 +266,6 @@ async@1.1.1 (https://registry.npmjs.org/)
kms-demo@1.0.0 (https://registry.npmjs.org/)
Someone might have tampered with these packages since they were published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures with multiple missing signatures > must match snapshot 1`] = `
Expand All @@ -302,7 +287,6 @@ audited 3 packages in xxx
node-fetch@1.6.0 (https://registry.npmjs.org/)
Someone might have tampered with this package since it was published on the registry!
`

exports[`test/lib/commands/audit.js TAP audit signatures with valid and missing signatures > must match snapshot 1`] = `
Expand All @@ -321,35 +305,30 @@ audited 1 package in xxx
1 package has a verified registry signature
1 package has a verified attestation
`

exports[`test/lib/commands/audit.js TAP audit signatures with valid signatures > must match snapshot 1`] = `
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures with valid signatures using alias > must match snapshot 1`] = `
audited 1 package in xxx
1 package has a verified registry signature
`

exports[`test/lib/commands/audit.js TAP audit signatures workspaces verifies registry deps and ignores local workspace deps > must match snapshot 1`] = `
audited 3 packages in xxx
3 packages have verified registry signatures
`

exports[`test/lib/commands/audit.js TAP audit signatures workspaces verifies registry deps when filtering by workspace name > must match snapshot 1`] = `
audited 2 packages in xxx
2 packages have verified registry signatures
`

exports[`test/lib/commands/audit.js TAP fallback audit > must match snapshot 1`] = `
Expand Down
Loading

0 comments on commit 4677f8b

Please sign in to comment.