Skip to content

Commit 15c3297

Browse files
authored
Merge pull request #70 from SocketDev/fixups
fixups
2 parents c8b16d3 + 65b2797 commit 15c3297

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

lib/commands/report/create.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async function setupCommand (name, description, argv, importMeta) {
8686
...validationFlags,
8787
debug: {
8888
type: 'boolean',
89-
alias: 'd',
89+
shortFlag: 'd',
9090
default: false,
9191
description: 'Output debug information',
9292
},
@@ -97,7 +97,7 @@ async function setupCommand (name, description, argv, importMeta) {
9797
},
9898
view: {
9999
type: 'boolean',
100-
alias: 'v',
100+
shortFlag: 'v',
101101
default: false,
102102
description: 'Will wait for and return the created report'
103103
},

lib/flags/output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { prepareFlags } from '../utils/flags.js'
33
export const outputFlags = prepareFlags({
44
json: {
55
type: 'boolean',
6-
alias: 'j',
6+
shortFlag: 'j',
77
default: false,
88
description: 'Output result as json',
99
},
1010
markdown: {
1111
type: 'boolean',
12-
alias: 'm',
12+
shortFlag: 'm',
1313
default: false,
1414
description: 'Output result as markdown',
1515
},

lib/shadow/link.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ function installLinks (realDirname, binname) {
4545
process.env['PATH']
4646
}`
4747
}
48-
return npmpath
48+
return binpath
4949
}
5050
module.exports = installLinks

lib/shadow/npm-injection.cjs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// THIS MUST BE CJS TO WORK WITH --require
33
'use strict'
44

5+
const events = require('events')
56
const fs = require('fs')
6-
const path = require('path')
77
const https = require('https')
8-
const events = require('events')
8+
const path = require('path')
99
const rl = require('readline')
1010
const { PassThrough } = require('stream')
11+
1112
const oraPromise = import('ora')
1213
const isInteractivePromise = import('is-interactive')
1314
const chalkPromise = import('chalk')
@@ -38,10 +39,20 @@ const pubTokenPromise = sdkPromise.then(({ getDefaultKey, FREE_API_KEY }) => get
3839
const apiKeySettingsPromise = sdkPromise.then(async ({ setupSdk }) => {
3940
const sdk = await setupSdk()
4041
const orgResult = await sdk.getOrganizations()
41-
if (!orgResult.success) throw new Error('failed to fetch organizations info')
42+
if (!orgResult.success) {
43+
throw new Error('Failed to fetch organizations info: ' + orgResult.error.message)
44+
}
4245
const orgs = Object.values(orgResult.data.organizations)
43-
const result = await sdk.postSettings(orgs.map(id => ({ organization: id })))
44-
if (!result.success) throw new Error('failed to fetch API key settings')
46+
const settingsSelectors = []
47+
for (const org of orgs) {
48+
if (org) {
49+
settingsSelectors.push({ organization: org.id })
50+
}
51+
}
52+
const result = await sdk.postSettings(settingsSelectors)
53+
if (!result.success) {
54+
throw new Error('Failed to fetch API key settings: ' + result.error.message)
55+
}
4556
return {
4657
orgs,
4758
settings: result.data
@@ -277,7 +288,12 @@ class SafeArborist extends Arborist {
277288
return this[kRiskyReify](...args)
278289
}
279290
args[0] ??= {}
280-
const old = { ...args[0] }
291+
const old = {
292+
...args[0],
293+
dryRun: false,
294+
save: Boolean(args[0].save ?? true),
295+
saveBundle: Boolean(args[0].saveBundle ?? false)
296+
}
281297
// @ts-expect-error types are wrong
282298
args[0].dryRun = true
283299
args[0].save = false
@@ -348,6 +364,7 @@ class SafeArborist extends Arborist {
348364
}
349365
return true
350366
}
367+
// eslint-disable-next-line
351368
return false
352369
})
353370
if (proceed) {
@@ -493,9 +510,9 @@ async function packagesHaveRiskyIssues (registry, pkgs, ora = null, input, outpu
493510
}
494511
for (const issue of (pkgData.value?.issues ?? [])) {
495512
if (rules[issue.type]) {
496-
if ((typeof rules[issue.type] == 'boolean' && rules[issue.type]) || rules[issue.type].action === 'error') {
513+
if ((typeof rules[issue.type] === 'boolean' && rules[issue.type]) || rules[issue.type].action === 'error') {
497514
failures.push(issue)
498-
} else if (rules[issue.type].action == 'warn') {
515+
} else if (rules[issue.type].action === 'warn') {
499516
warns.push(issue)
500517
}
501518
}
@@ -590,7 +607,7 @@ async function createTTYServer (colorLevel) {
590607
const bufs = []
591608
conn.on('data', function awaitCapture (chunk) {
592609
bufs.push(chunk)
593-
const lineBuff = Buffer.concat(bufs)
610+
let lineBuff = Buffer.concat(bufs)
594611
try {
595612
if (!captured) {
596613
const EOL = lineBuff.indexOf('\n'.charCodeAt(0))

0 commit comments

Comments
 (0)