Skip to content

Commit

Permalink
Merge pull request #70 from SocketDev/fixups
Browse files Browse the repository at this point in the history
fixups
  • Loading branch information
bmeck authored Aug 7, 2023
2 parents c8b16d3 + 65b2797 commit 15c3297
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/commands/report/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function setupCommand (name, description, argv, importMeta) {
...validationFlags,
debug: {
type: 'boolean',
alias: 'd',
shortFlag: 'd',
default: false,
description: 'Output debug information',
},
Expand All @@ -97,7 +97,7 @@ async function setupCommand (name, description, argv, importMeta) {
},
view: {
type: 'boolean',
alias: 'v',
shortFlag: 'v',
default: false,
description: 'Will wait for and return the created report'
},
Expand Down
4 changes: 2 additions & 2 deletions lib/flags/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { prepareFlags } from '../utils/flags.js'
export const outputFlags = prepareFlags({
json: {
type: 'boolean',
alias: 'j',
shortFlag: 'j',
default: false,
description: 'Output result as json',
},
markdown: {
type: 'boolean',
alias: 'm',
shortFlag: 'm',
default: false,
description: 'Output result as markdown',
},
Expand Down
2 changes: 1 addition & 1 deletion lib/shadow/link.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ function installLinks (realDirname, binname) {
process.env['PATH']
}`
}
return npmpath
return binpath
}
module.exports = installLinks
35 changes: 26 additions & 9 deletions lib/shadow/npm-injection.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// THIS MUST BE CJS TO WORK WITH --require
'use strict'

const events = require('events')
const fs = require('fs')
const path = require('path')
const https = require('https')
const events = require('events')
const path = require('path')
const rl = require('readline')
const { PassThrough } = require('stream')

const oraPromise = import('ora')
const isInteractivePromise = import('is-interactive')
const chalkPromise = import('chalk')
Expand Down Expand Up @@ -38,10 +39,20 @@ const pubTokenPromise = sdkPromise.then(({ getDefaultKey, FREE_API_KEY }) => get
const apiKeySettingsPromise = sdkPromise.then(async ({ setupSdk }) => {
const sdk = await setupSdk()
const orgResult = await sdk.getOrganizations()
if (!orgResult.success) throw new Error('failed to fetch organizations info')
if (!orgResult.success) {
throw new Error('Failed to fetch organizations info: ' + orgResult.error.message)
}
const orgs = Object.values(orgResult.data.organizations)
const result = await sdk.postSettings(orgs.map(id => ({ organization: id })))
if (!result.success) throw new Error('failed to fetch API key settings')
const settingsSelectors = []
for (const org of orgs) {
if (org) {
settingsSelectors.push({ organization: org.id })
}
}
const result = await sdk.postSettings(settingsSelectors)
if (!result.success) {
throw new Error('Failed to fetch API key settings: ' + result.error.message)
}
return {
orgs,
settings: result.data
Expand Down Expand Up @@ -277,7 +288,12 @@ class SafeArborist extends Arborist {
return this[kRiskyReify](...args)
}
args[0] ??= {}
const old = { ...args[0] }
const old = {
...args[0],
dryRun: false,
save: Boolean(args[0].save ?? true),
saveBundle: Boolean(args[0].saveBundle ?? false)
}
// @ts-expect-error types are wrong
args[0].dryRun = true
args[0].save = false
Expand Down Expand Up @@ -348,6 +364,7 @@ class SafeArborist extends Arborist {
}
return true
}
// eslint-disable-next-line
return false
})
if (proceed) {
Expand Down Expand Up @@ -493,9 +510,9 @@ async function packagesHaveRiskyIssues (registry, pkgs, ora = null, input, outpu
}
for (const issue of (pkgData.value?.issues ?? [])) {
if (rules[issue.type]) {
if ((typeof rules[issue.type] == 'boolean' && rules[issue.type]) || rules[issue.type].action === 'error') {
if ((typeof rules[issue.type] === 'boolean' && rules[issue.type]) || rules[issue.type].action === 'error') {
failures.push(issue)
} else if (rules[issue.type].action == 'warn') {
} else if (rules[issue.type].action === 'warn') {
warns.push(issue)
}
}
Expand Down Expand Up @@ -590,7 +607,7 @@ async function createTTYServer (colorLevel) {
const bufs = []
conn.on('data', function awaitCapture (chunk) {
bufs.push(chunk)
const lineBuff = Buffer.concat(bufs)
let lineBuff = Buffer.concat(bufs)
try {
if (!captured) {
const EOL = lineBuff.indexOf('\n'.charCodeAt(0))
Expand Down

0 comments on commit 15c3297

Please sign in to comment.