Skip to content

Commit b92e0e8

Browse files
authored
Merge pull request #60 from SocketDev/warn-safe-npm
"warn" action for `socket npm`
2 parents 4cfe9ee + 717ed07 commit b92e0e8

18 files changed

+986
-893
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ jobs:
2424
with:
2525
no-lockfile: true
2626
npm-test-script: 'test-ci'
27-
node-versions: '14,16,18,19'
27+
# Node 16 has a SegFault from C8 when using --test
28+
node-versions: '18,19'
2829
# We currently have some issues on Windows that will have to wait to be fixed
2930
# os: 'ubuntu-latest,windows-latest'
3031
os: 'ubuntu-latest'

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"prettier-config-x-standard"

lib/commands/login/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export const login = {
4343
if (!isInteractive()) {
4444
throw new InputError('cannot prompt for credentials in a non-interactive shell')
4545
}
46+
/**
47+
* @type {{ apiKey: string }}
48+
*/
4649
const result = await prompts({
4750
type: 'password',
4851
name: 'apiKey',
@@ -91,6 +94,9 @@ export const login = {
9194
let enforcedOrgs = []
9295

9396
if (enforcedChoices.length > 1) {
97+
/**
98+
* @type { {id: string} }
99+
*/
94100
const { id } = await prompts({
95101
type: 'select',
96102
name: 'id',
@@ -104,6 +110,9 @@ export const login = {
104110
})
105111
if (id) enforcedOrgs = [id]
106112
} else if (enforcedChoices.length) {
113+
/**
114+
* @type { {confirmOrg: boolean} }
115+
*/
107116
const { confirmOrg } = await prompts({
108117
type: 'confirm',
109118
name: 'confirmOrg',
@@ -112,7 +121,10 @@ export const login = {
112121
onState: promptAbortHandler
113122
})
114123
if (confirmOrg) {
115-
enforcedOrgs = [enforcedChoices[0]?.value]
124+
const existing = /** @type {undefined | {value: string}} */(enforcedChoices[0])
125+
if (existing) {
126+
enforcedOrgs = [existing.value]
127+
}
116128
}
117129
}
118130
// MUST DO all updateSetting ON SAME TICK TO AVOID PARTIAL WRITE

lib/commands/report/create.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ async function setupCommand (name, description, argv, importMeta) {
118118
119119
Options
120120
${printFlagList({
121-
'--all': 'Include all issues',
122-
'--debug': 'Output debug information',
123-
'--dry-run': 'Only output what will be done without actually doing it',
124-
'--json': 'Output result as json',
125-
'--markdown': 'Output result as markdown',
126-
'--strict': 'Exits with an error code if any matching issues are found',
127-
'--view': 'Will wait for and return the created report'
121+
'all': 'Include all issues',
122+
'debug': 'Output debug information',
123+
'dry-run': 'Only output what will be done without actually doing it',
124+
'json': 'Output result as json',
125+
'markdown': 'Output result as markdown',
126+
'strict': 'Exits with an error code if any matching issues are found',
127+
'view': 'Will wait for and return the created report'
128128
}, 6)}
129129
130130
Examples
@@ -185,9 +185,11 @@ async function setupCommand (name, description, argv, importMeta) {
185185
.then(res => {
186186
if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, ora())
187187
return res.data
188-
}).catch(cause => {
189-
throw new ErrorWithCause('Failed getting supported files for report', { cause })
190-
})
188+
}).catch(
189+
/** @type {(cause: Error) => never} */
190+
(cause) => {
191+
throw new ErrorWithCause('Failed getting supported files for report', { cause })
192+
})
191193

192194
const packagePaths = await getPackageFiles(cwd, cli.input, config, supportedFiles, debugLog)
193195

0 commit comments

Comments
 (0)