@socketsecurity/cli-with-sentry 0.14.102 → 0.14.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/arborist-helpers.d.ts +69 -0
- package/dist/module-sync/cli.js +1614 -1180
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/index.d.ts +1 -1
- package/dist/module-sync/package-environment.d.ts +7 -7
- package/dist/module-sync/semver.d.ts +16 -0
- package/dist/module-sync/shadow-npm-inject.js +445 -431
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/shadow-npm-paths.d.ts +23 -2
- package/dist/module-sync/shadow-npm-paths.js +135 -76
- package/dist/module-sync/shadow-npm-paths.js.map +1 -1
- package/dist/module-sync/vendor.js +25199 -25208
- package/dist/module-sync/vendor.js.map +1 -1
- package/dist/require/cli.js +1614 -1180
- package/dist/require/cli.js.map +1 -1
- package/dist/require/shadow-npm-inject.js +445 -431
- package/dist/require/shadow-npm-inject.js.map +1 -1
- package/dist/require/shadow-npm-paths.d.ts +23 -2
- package/dist/require/shadow-npm-paths.js +135 -76
- package/dist/require/shadow-npm-paths.js.map +1 -1
- package/package.json +7 -7
- package/dist/module-sync/shared.d.ts +0 -11
- package/dist/module-sync/types.d.ts +0 -27
package/dist/module-sync/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ function _socketInterop(e) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const process$1 = require('node:process')
|
|
15
|
-
const require$$0$
|
|
15
|
+
const require$$0$1 = require('node:url')
|
|
16
16
|
const vendor = require('./vendor.js')
|
|
17
17
|
const debug = require('@socketsecurity/registry/lib/debug')
|
|
18
18
|
const logger = require('@socketsecurity/registry/lib/logger')
|
|
@@ -26,11 +26,11 @@ const objects = require('@socketsecurity/registry/lib/objects')
|
|
|
26
26
|
const path = require('@socketsecurity/registry/lib/path')
|
|
27
27
|
const regexps = require('@socketsecurity/registry/lib/regexps')
|
|
28
28
|
const words = require('@socketsecurity/registry/lib/words')
|
|
29
|
-
const
|
|
29
|
+
const fs$1 = require('node:fs')
|
|
30
30
|
const shadowBin = require('./shadow-bin.js')
|
|
31
31
|
const prompts = require('@socketsecurity/registry/lib/prompts')
|
|
32
32
|
const shadowNpmPaths = require('./shadow-npm-paths.js')
|
|
33
|
-
const require$$0
|
|
33
|
+
const require$$0 = require('node:util')
|
|
34
34
|
const arrays = require('@socketsecurity/registry/lib/arrays')
|
|
35
35
|
const registry = require('@socketsecurity/registry')
|
|
36
36
|
const npm = require('@socketsecurity/registry/lib/npm')
|
|
@@ -347,7 +347,7 @@ function renderJson(data) {
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
function renderMarkdown(data, days, repoSlug) {
|
|
350
|
-
return vendor.
|
|
350
|
+
return vendor.html`
|
|
351
351
|
# Socket Alert Analytics
|
|
352
352
|
|
|
353
353
|
These are the Socket.dev stats are analytics for the ${repoSlug ? `${repoSlug} repo` : 'org'} of the past ${days} days
|
|
@@ -387,7 +387,7 @@ ${[
|
|
|
387
387
|
]
|
|
388
388
|
]
|
|
389
389
|
.map(
|
|
390
|
-
([title, table]) => vendor.
|
|
390
|
+
([title, table]) => vendor.html`
|
|
391
391
|
## ${title}
|
|
392
392
|
|
|
393
393
|
${table}
|
|
@@ -900,7 +900,7 @@ function emitBanner(name) {
|
|
|
900
900
|
logger.logger.error(getAsciiHeader(name))
|
|
901
901
|
}
|
|
902
902
|
function getAsciiHeader(command) {
|
|
903
|
-
const cliVersion = '0.14.
|
|
903
|
+
const cliVersion = '0.14.104:da4a527:b9e86b3d:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
904
904
|
const nodeVersion = process$1.version
|
|
905
905
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
906
906
|
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
|
|
@@ -923,8 +923,8 @@ function getAsciiHeader(command) {
|
|
|
923
923
|
return ` ${body}\n`
|
|
924
924
|
}
|
|
925
925
|
|
|
926
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
927
|
-
const config$
|
|
926
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$I } = constants
|
|
927
|
+
const config$L = {
|
|
928
928
|
commandName: 'analytics',
|
|
929
929
|
description: `Look up analytics data`,
|
|
930
930
|
hidden: false,
|
|
@@ -979,14 +979,14 @@ const config$K = {
|
|
|
979
979
|
`
|
|
980
980
|
}
|
|
981
981
|
const cmdAnalytics = {
|
|
982
|
-
description: config$
|
|
983
|
-
hidden: config$
|
|
984
|
-
run: run$
|
|
982
|
+
description: config$L.description,
|
|
983
|
+
hidden: config$L.hidden,
|
|
984
|
+
run: run$L
|
|
985
985
|
}
|
|
986
|
-
async function run$
|
|
986
|
+
async function run$L(argv, importMeta, { parentName }) {
|
|
987
987
|
const cli = meowOrExit({
|
|
988
988
|
argv,
|
|
989
|
-
config: config$
|
|
989
|
+
config: config$L,
|
|
990
990
|
importMeta,
|
|
991
991
|
parentName
|
|
992
992
|
})
|
|
@@ -1041,7 +1041,7 @@ async function run$K(argv, importMeta, { parentName }) {
|
|
|
1041
1041
|
return
|
|
1042
1042
|
}
|
|
1043
1043
|
if (cli.flags['dryRun']) {
|
|
1044
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
1044
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$I)
|
|
1045
1045
|
return
|
|
1046
1046
|
}
|
|
1047
1047
|
assert(assertScope(scope))
|
|
@@ -1216,8 +1216,8 @@ async function handleAuditLog({ logType, orgSlug, outputKind, page, perPage }) {
|
|
|
1216
1216
|
})
|
|
1217
1217
|
}
|
|
1218
1218
|
|
|
1219
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
1220
|
-
const config$
|
|
1219
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$H } = constants
|
|
1220
|
+
const config$K = {
|
|
1221
1221
|
commandName: 'audit-log',
|
|
1222
1222
|
description: 'Look up the audit log for an organization',
|
|
1223
1223
|
hidden: false,
|
|
@@ -1262,14 +1262,14 @@ const config$J = {
|
|
|
1262
1262
|
`
|
|
1263
1263
|
}
|
|
1264
1264
|
const cmdAuditLog = {
|
|
1265
|
-
description: config$
|
|
1266
|
-
hidden: config$
|
|
1267
|
-
run: run$
|
|
1265
|
+
description: config$K.description,
|
|
1266
|
+
hidden: config$K.hidden,
|
|
1267
|
+
run: run$K
|
|
1268
1268
|
}
|
|
1269
|
-
async function run$
|
|
1269
|
+
async function run$K(argv, importMeta, { parentName }) {
|
|
1270
1270
|
const cli = meowOrExit({
|
|
1271
1271
|
argv,
|
|
1272
|
-
config: config$
|
|
1272
|
+
config: config$K,
|
|
1273
1273
|
importMeta,
|
|
1274
1274
|
parentName
|
|
1275
1275
|
})
|
|
@@ -1306,7 +1306,7 @@ async function run$J(argv, importMeta, { parentName }) {
|
|
|
1306
1306
|
return
|
|
1307
1307
|
}
|
|
1308
1308
|
if (cli.flags['dryRun']) {
|
|
1309
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
1309
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$H)
|
|
1310
1310
|
return
|
|
1311
1311
|
}
|
|
1312
1312
|
await handleAuditLog({
|
|
@@ -1322,7 +1322,7 @@ const {
|
|
|
1322
1322
|
NPM: NPM$g,
|
|
1323
1323
|
NPX: NPX$3,
|
|
1324
1324
|
PACKAGE_LOCK_JSON,
|
|
1325
|
-
PNPM: PNPM$
|
|
1325
|
+
PNPM: PNPM$a,
|
|
1326
1326
|
YARN: YARN$1,
|
|
1327
1327
|
YARN_LOCK
|
|
1328
1328
|
} = constants
|
|
@@ -1331,7 +1331,7 @@ const nodejsPlatformTypes = new Set([
|
|
|
1331
1331
|
'js',
|
|
1332
1332
|
'nodejs',
|
|
1333
1333
|
NPM$g,
|
|
1334
|
-
PNPM$
|
|
1334
|
+
PNPM$a,
|
|
1335
1335
|
'ts',
|
|
1336
1336
|
'tsx',
|
|
1337
1337
|
'typescript'
|
|
@@ -1346,9 +1346,9 @@ async function runCycloneDX(yargvWithYes) {
|
|
|
1346
1346
|
if (
|
|
1347
1347
|
yargv.type !== YARN$1 &&
|
|
1348
1348
|
nodejsPlatformTypes.has(yargv.type) &&
|
|
1349
|
-
|
|
1349
|
+
fs$1.existsSync(`./${YARN_LOCK}`)
|
|
1350
1350
|
) {
|
|
1351
|
-
if (
|
|
1351
|
+
if (fs$1.existsSync(`./${PACKAGE_LOCK_JSON}`)) {
|
|
1352
1352
|
yargv.type = NPM$g
|
|
1353
1353
|
} else {
|
|
1354
1354
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
@@ -1369,16 +1369,16 @@ async function runCycloneDX(yargvWithYes) {
|
|
|
1369
1369
|
await shadowBin(NPX$3, [
|
|
1370
1370
|
...yesArgs,
|
|
1371
1371
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_CYCLONEDX_CDXGEN_VERSION']".
|
|
1372
|
-
`@cyclonedx/cdxgen@${'11.2.
|
|
1372
|
+
`@cyclonedx/cdxgen@${'11.2.4'}`,
|
|
1373
1373
|
...argvToArray(yargv)
|
|
1374
1374
|
])
|
|
1375
1375
|
if (cleanupPackageLock) {
|
|
1376
1376
|
try {
|
|
1377
|
-
await
|
|
1377
|
+
await fs$1.promises.rm(`./${PACKAGE_LOCK_JSON}`)
|
|
1378
1378
|
} catch {}
|
|
1379
1379
|
}
|
|
1380
1380
|
const fullOutputPath = path$1.join(process$1.cwd(), yargv.output)
|
|
1381
|
-
if (
|
|
1381
|
+
if (fs$1.existsSync(fullOutputPath)) {
|
|
1382
1382
|
logger.logger.log(
|
|
1383
1383
|
vendor.yoctocolorsCjsExports.cyanBright(`${yargv.output} created!`)
|
|
1384
1384
|
)
|
|
@@ -1436,7 +1436,7 @@ function isHelpFlag(cmdArg) {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
|
|
1438
1438
|
// import { meowOrExit } from '../../utils/meow-with-subcommands'
|
|
1439
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
1439
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$G } = constants
|
|
1440
1440
|
|
|
1441
1441
|
// TODO: convert yargs to meow. Or convert all the other things to yargs.
|
|
1442
1442
|
const toLower = arg => arg.toLowerCase()
|
|
@@ -1552,7 +1552,7 @@ const yargsConfig = {
|
|
|
1552
1552
|
'spec-version'
|
|
1553
1553
|
]
|
|
1554
1554
|
}
|
|
1555
|
-
const config$
|
|
1555
|
+
const config$J = {
|
|
1556
1556
|
commandName: 'cdxgen',
|
|
1557
1557
|
description: 'Create an SBOM with CycloneDX generator (cdxgen)',
|
|
1558
1558
|
hidden: false,
|
|
@@ -1568,16 +1568,16 @@ const config$I = {
|
|
|
1568
1568
|
`
|
|
1569
1569
|
}
|
|
1570
1570
|
const cmdCdxgen = {
|
|
1571
|
-
description: config$
|
|
1572
|
-
hidden: config$
|
|
1573
|
-
run: run$
|
|
1571
|
+
description: config$J.description,
|
|
1572
|
+
hidden: config$J.hidden,
|
|
1573
|
+
run: run$J
|
|
1574
1574
|
}
|
|
1575
|
-
async function run$
|
|
1575
|
+
async function run$J(argv, importMeta, { parentName }) {
|
|
1576
1576
|
const cli = meowOrExit({
|
|
1577
1577
|
allowUnknownFlags: true,
|
|
1578
1578
|
// Don't let meow take over --help.
|
|
1579
1579
|
argv: argv.filter(a => !isHelpFlag(a)),
|
|
1580
|
-
config: config$
|
|
1580
|
+
config: config$J,
|
|
1581
1581
|
importMeta,
|
|
1582
1582
|
parentName
|
|
1583
1583
|
})
|
|
@@ -1599,7 +1599,7 @@ async function run$I(argv, importMeta, { parentName }) {
|
|
|
1599
1599
|
return
|
|
1600
1600
|
}
|
|
1601
1601
|
if (cli.flags['dryRun']) {
|
|
1602
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
1602
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$G)
|
|
1603
1603
|
return
|
|
1604
1604
|
}
|
|
1605
1605
|
if (yargv.output === undefined) {
|
|
@@ -2447,8 +2447,8 @@ async function handleCI() {
|
|
|
2447
2447
|
})
|
|
2448
2448
|
}
|
|
2449
2449
|
|
|
2450
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
2451
|
-
const config$
|
|
2450
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$F } = constants
|
|
2451
|
+
const config$I = {
|
|
2452
2452
|
commandName: 'ci',
|
|
2453
2453
|
description:
|
|
2454
2454
|
'Create a new scan and report whether it passes your security policy',
|
|
@@ -2468,19 +2468,19 @@ const config$H = {
|
|
|
2468
2468
|
`
|
|
2469
2469
|
}
|
|
2470
2470
|
const cmdCI = {
|
|
2471
|
-
description: config$
|
|
2472
|
-
hidden: config$
|
|
2473
|
-
run: run$
|
|
2471
|
+
description: config$I.description,
|
|
2472
|
+
hidden: config$I.hidden,
|
|
2473
|
+
run: run$I
|
|
2474
2474
|
}
|
|
2475
|
-
async function run$
|
|
2475
|
+
async function run$I(argv, importMeta, { parentName }) {
|
|
2476
2476
|
const cli = meowOrExit({
|
|
2477
2477
|
argv,
|
|
2478
|
-
config: config$
|
|
2478
|
+
config: config$I,
|
|
2479
2479
|
importMeta,
|
|
2480
2480
|
parentName
|
|
2481
2481
|
})
|
|
2482
2482
|
if (cli.flags['dryRun']) {
|
|
2483
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
2483
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$F)
|
|
2484
2484
|
return
|
|
2485
2485
|
}
|
|
2486
2486
|
await handleCI()
|
|
@@ -2727,8 +2727,8 @@ async function handleConfigAuto({ key, outputKind }) {
|
|
|
2727
2727
|
await outputConfigAuto(key, result, outputKind)
|
|
2728
2728
|
}
|
|
2729
2729
|
|
|
2730
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
2731
|
-
const config$
|
|
2730
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$E } = constants
|
|
2731
|
+
const config$H = {
|
|
2732
2732
|
commandName: 'auto',
|
|
2733
2733
|
description: 'Automatically discover and set the correct value config item',
|
|
2734
2734
|
hidden: false,
|
|
@@ -2759,14 +2759,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
|
|
|
2759
2759
|
`
|
|
2760
2760
|
}
|
|
2761
2761
|
const cmdConfigAuto = {
|
|
2762
|
-
description: config$
|
|
2763
|
-
hidden: config$
|
|
2764
|
-
run: run$
|
|
2762
|
+
description: config$H.description,
|
|
2763
|
+
hidden: config$H.hidden,
|
|
2764
|
+
run: run$H
|
|
2765
2765
|
}
|
|
2766
|
-
async function run$
|
|
2766
|
+
async function run$H(argv, importMeta, { parentName }) {
|
|
2767
2767
|
const cli = meowOrExit({
|
|
2768
2768
|
argv,
|
|
2769
|
-
config: config$
|
|
2769
|
+
config: config$H,
|
|
2770
2770
|
importMeta,
|
|
2771
2771
|
parentName
|
|
2772
2772
|
})
|
|
@@ -2792,7 +2792,7 @@ async function run$G(argv, importMeta, { parentName }) {
|
|
|
2792
2792
|
return
|
|
2793
2793
|
}
|
|
2794
2794
|
if (cli.flags['dryRun']) {
|
|
2795
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
2795
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$E)
|
|
2796
2796
|
return
|
|
2797
2797
|
}
|
|
2798
2798
|
await handleConfigAuto({
|
|
@@ -2846,8 +2846,8 @@ async function handleConfigGet({ key, outputKind }) {
|
|
|
2846
2846
|
await outputConfigGet(key, value, readOnly, outputKind)
|
|
2847
2847
|
}
|
|
2848
2848
|
|
|
2849
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
2850
|
-
const config$
|
|
2849
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$D } = constants
|
|
2850
|
+
const config$G = {
|
|
2851
2851
|
commandName: 'get',
|
|
2852
2852
|
description: 'Get the value of a local CLI config item',
|
|
2853
2853
|
hidden: false,
|
|
@@ -2873,14 +2873,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
|
|
|
2873
2873
|
`
|
|
2874
2874
|
}
|
|
2875
2875
|
const cmdConfigGet = {
|
|
2876
|
-
description: config$
|
|
2877
|
-
hidden: config$
|
|
2878
|
-
run: run$
|
|
2876
|
+
description: config$G.description,
|
|
2877
|
+
hidden: config$G.hidden,
|
|
2878
|
+
run: run$G
|
|
2879
2879
|
}
|
|
2880
|
-
async function run$
|
|
2880
|
+
async function run$G(argv, importMeta, { parentName }) {
|
|
2881
2881
|
const cli = meowOrExit({
|
|
2882
2882
|
argv,
|
|
2883
|
-
config: config$
|
|
2883
|
+
config: config$G,
|
|
2884
2884
|
importMeta,
|
|
2885
2885
|
parentName
|
|
2886
2886
|
})
|
|
@@ -2906,7 +2906,7 @@ async function run$F(argv, importMeta, { parentName }) {
|
|
|
2906
2906
|
return
|
|
2907
2907
|
}
|
|
2908
2908
|
if (cli.flags['dryRun']) {
|
|
2909
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
2909
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$D)
|
|
2910
2910
|
return
|
|
2911
2911
|
}
|
|
2912
2912
|
await handleConfigGet({
|
|
@@ -2968,8 +2968,8 @@ async function outputConfigList({ full, outputKind }) {
|
|
|
2968
2968
|
}
|
|
2969
2969
|
}
|
|
2970
2970
|
|
|
2971
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
2972
|
-
const config$
|
|
2971
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$C } = constants
|
|
2972
|
+
const config$F = {
|
|
2973
2973
|
commandName: 'list',
|
|
2974
2974
|
description: 'Show all local CLI config items and their values',
|
|
2975
2975
|
hidden: false,
|
|
@@ -3000,14 +3000,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
|
|
|
3000
3000
|
`
|
|
3001
3001
|
}
|
|
3002
3002
|
const cmdConfigList = {
|
|
3003
|
-
description: config$
|
|
3004
|
-
hidden: config$
|
|
3005
|
-
run: run$
|
|
3003
|
+
description: config$F.description,
|
|
3004
|
+
hidden: config$F.hidden,
|
|
3005
|
+
run: run$F
|
|
3006
3006
|
}
|
|
3007
|
-
async function run$
|
|
3007
|
+
async function run$F(argv, importMeta, { parentName }) {
|
|
3008
3008
|
const cli = meowOrExit({
|
|
3009
3009
|
argv,
|
|
3010
|
-
config: config$
|
|
3010
|
+
config: config$F,
|
|
3011
3011
|
importMeta,
|
|
3012
3012
|
parentName
|
|
3013
3013
|
})
|
|
@@ -3024,7 +3024,7 @@ async function run$E(argv, importMeta, { parentName }) {
|
|
|
3024
3024
|
return
|
|
3025
3025
|
}
|
|
3026
3026
|
if (cli.flags['dryRun']) {
|
|
3027
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
3027
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$C)
|
|
3028
3028
|
return
|
|
3029
3029
|
}
|
|
3030
3030
|
await outputConfigList({
|
|
@@ -3069,8 +3069,8 @@ async function handleConfigSet({ key, outputKind, value }) {
|
|
|
3069
3069
|
await outputConfigSet(key, value, readOnly, outputKind)
|
|
3070
3070
|
}
|
|
3071
3071
|
|
|
3072
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
3073
|
-
const config$
|
|
3072
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$B } = constants
|
|
3073
|
+
const config$E = {
|
|
3074
3074
|
commandName: 'set',
|
|
3075
3075
|
description: 'Update the value of a local CLI config item',
|
|
3076
3076
|
hidden: false,
|
|
@@ -3101,14 +3101,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
|
|
|
3101
3101
|
`
|
|
3102
3102
|
}
|
|
3103
3103
|
const cmdConfigSet = {
|
|
3104
|
-
description: config$
|
|
3105
|
-
hidden: config$
|
|
3106
|
-
run: run$
|
|
3104
|
+
description: config$E.description,
|
|
3105
|
+
hidden: config$E.hidden,
|
|
3106
|
+
run: run$E
|
|
3107
3107
|
}
|
|
3108
|
-
async function run$
|
|
3108
|
+
async function run$E(argv, importMeta, { parentName }) {
|
|
3109
3109
|
const cli = meowOrExit({
|
|
3110
3110
|
argv,
|
|
3111
|
-
config: config$
|
|
3111
|
+
config: config$E,
|
|
3112
3112
|
importMeta,
|
|
3113
3113
|
parentName
|
|
3114
3114
|
})
|
|
@@ -3143,7 +3143,7 @@ async function run$D(argv, importMeta, { parentName }) {
|
|
|
3143
3143
|
return
|
|
3144
3144
|
}
|
|
3145
3145
|
if (cli.flags['dryRun']) {
|
|
3146
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
3146
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$B)
|
|
3147
3147
|
return
|
|
3148
3148
|
}
|
|
3149
3149
|
await handleConfigSet({
|
|
@@ -3175,8 +3175,8 @@ async function handleConfigUnset({ key, outputKind }) {
|
|
|
3175
3175
|
await outputConfigUnset(key, outputKind)
|
|
3176
3176
|
}
|
|
3177
3177
|
|
|
3178
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
3179
|
-
const config$
|
|
3178
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$A } = constants
|
|
3179
|
+
const config$D = {
|
|
3180
3180
|
commandName: 'unset',
|
|
3181
3181
|
description: 'Clear the value of a local CLI config item',
|
|
3182
3182
|
hidden: false,
|
|
@@ -3202,14 +3202,14 @@ ${Array.from(shadowNpmInject.supportedConfigKeys.entries())
|
|
|
3202
3202
|
`
|
|
3203
3203
|
}
|
|
3204
3204
|
const cmdConfigUnset = {
|
|
3205
|
-
description: config$
|
|
3206
|
-
hidden: config$
|
|
3207
|
-
run: run$
|
|
3205
|
+
description: config$D.description,
|
|
3206
|
+
hidden: config$D.hidden,
|
|
3207
|
+
run: run$D
|
|
3208
3208
|
}
|
|
3209
|
-
async function run$
|
|
3209
|
+
async function run$D(argv, importMeta, { parentName }) {
|
|
3210
3210
|
const cli = meowOrExit({
|
|
3211
3211
|
argv,
|
|
3212
|
-
config: config$
|
|
3212
|
+
config: config$D,
|
|
3213
3213
|
importMeta,
|
|
3214
3214
|
parentName
|
|
3215
3215
|
})
|
|
@@ -3235,7 +3235,7 @@ async function run$C(argv, importMeta, { parentName }) {
|
|
|
3235
3235
|
return
|
|
3236
3236
|
}
|
|
3237
3237
|
if (cli.flags['dryRun']) {
|
|
3238
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
3238
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$A)
|
|
3239
3239
|
return
|
|
3240
3240
|
}
|
|
3241
3241
|
await handleConfigUnset({
|
|
@@ -3362,8 +3362,8 @@ async function handleDependencies({ limit, offset, outputKind }) {
|
|
|
3362
3362
|
})
|
|
3363
3363
|
}
|
|
3364
3364
|
|
|
3365
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
3366
|
-
const config$
|
|
3365
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$z } = constants
|
|
3366
|
+
const config$C = {
|
|
3367
3367
|
commandName: 'dependencies',
|
|
3368
3368
|
description:
|
|
3369
3369
|
'Search for any dependency that is being used in your organization',
|
|
@@ -3400,14 +3400,14 @@ const config$B = {
|
|
|
3400
3400
|
`
|
|
3401
3401
|
}
|
|
3402
3402
|
const cmdScanCreate$1 = {
|
|
3403
|
-
description: config$
|
|
3404
|
-
hidden: config$
|
|
3405
|
-
run: run$
|
|
3403
|
+
description: config$C.description,
|
|
3404
|
+
hidden: config$C.hidden,
|
|
3405
|
+
run: run$C
|
|
3406
3406
|
}
|
|
3407
|
-
async function run$
|
|
3407
|
+
async function run$C(argv, importMeta, { parentName }) {
|
|
3408
3408
|
const cli = meowOrExit({
|
|
3409
3409
|
argv,
|
|
3410
|
-
config: config$
|
|
3410
|
+
config: config$C,
|
|
3411
3411
|
importMeta,
|
|
3412
3412
|
parentName
|
|
3413
3413
|
})
|
|
@@ -3435,7 +3435,7 @@ async function run$B(argv, importMeta, { parentName }) {
|
|
|
3435
3435
|
return
|
|
3436
3436
|
}
|
|
3437
3437
|
if (cli.flags['dryRun']) {
|
|
3438
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
3438
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$z)
|
|
3439
3439
|
return
|
|
3440
3440
|
}
|
|
3441
3441
|
await handleDependencies({
|
|
@@ -3445,7 +3445,7 @@ async function run$B(argv, importMeta, { parentName }) {
|
|
|
3445
3445
|
})
|
|
3446
3446
|
}
|
|
3447
3447
|
|
|
3448
|
-
async function fetchDiffScan({ after, before, orgSlug }) {
|
|
3448
|
+
async function fetchDiffScan$1({ after, before, orgSlug }) {
|
|
3449
3449
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
3450
3450
|
|
|
3451
3451
|
// Lazily access constants.spinner.
|
|
@@ -3468,7 +3468,7 @@ async function fetchDiffScan({ after, before, orgSlug }) {
|
|
|
3468
3468
|
return result
|
|
3469
3469
|
}
|
|
3470
3470
|
|
|
3471
|
-
async function outputDiffScan(result, { depth, file, outputKind }) {
|
|
3471
|
+
async function outputDiffScan$1(result, { depth, file, outputKind }) {
|
|
3472
3472
|
const dashboardUrl = result.diff_report_url
|
|
3473
3473
|
const dashboardMessage = dashboardUrl
|
|
3474
3474
|
? `\n View this diff scan in the Socket dashboard: ${vendor.yoctocolorsCjsExports.cyan(dashboardUrl)}`
|
|
@@ -3490,7 +3490,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
|
|
|
3490
3490
|
}
|
|
3491
3491
|
if (file && file !== '-') {
|
|
3492
3492
|
logger.logger.log(`Writing json to \`${file}\``)
|
|
3493
|
-
|
|
3493
|
+
fs$1.writeFile(file, JSON.stringify(result, null, 2), err => {
|
|
3494
3494
|
if (err) {
|
|
3495
3495
|
logger.logger.fail(`Writing to \`${file}\` failed...`)
|
|
3496
3496
|
logger.logger.error(err)
|
|
@@ -3513,7 +3513,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
|
|
|
3513
3513
|
|
|
3514
3514
|
logger.logger.log('Diff scan result:')
|
|
3515
3515
|
logger.logger.log(
|
|
3516
|
-
require$$0
|
|
3516
|
+
require$$0.inspect(result, {
|
|
3517
3517
|
showHidden: false,
|
|
3518
3518
|
depth: depth > 0 ? depth : null,
|
|
3519
3519
|
colors: true,
|
|
@@ -3526,7 +3526,7 @@ async function outputDiffScan(result, { depth, file, outputKind }) {
|
|
|
3526
3526
|
logger.logger.log(dashboardMessage)
|
|
3527
3527
|
}
|
|
3528
3528
|
|
|
3529
|
-
async function handleDiffScan({
|
|
3529
|
+
async function handleDiffScan$1({
|
|
3530
3530
|
after,
|
|
3531
3531
|
before,
|
|
3532
3532
|
depth,
|
|
@@ -3534,7 +3534,7 @@ async function handleDiffScan({
|
|
|
3534
3534
|
orgSlug,
|
|
3535
3535
|
outputKind
|
|
3536
3536
|
}) {
|
|
3537
|
-
const data = await fetchDiffScan({
|
|
3537
|
+
const data = await fetchDiffScan$1({
|
|
3538
3538
|
after,
|
|
3539
3539
|
before,
|
|
3540
3540
|
orgSlug
|
|
@@ -3542,15 +3542,15 @@ async function handleDiffScan({
|
|
|
3542
3542
|
if (!data) {
|
|
3543
3543
|
return
|
|
3544
3544
|
}
|
|
3545
|
-
await outputDiffScan(data, {
|
|
3545
|
+
await outputDiffScan$1(data, {
|
|
3546
3546
|
depth,
|
|
3547
3547
|
file,
|
|
3548
3548
|
outputKind
|
|
3549
3549
|
})
|
|
3550
3550
|
}
|
|
3551
3551
|
|
|
3552
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
3553
|
-
const config$
|
|
3552
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y } = constants
|
|
3553
|
+
const config$B = {
|
|
3554
3554
|
commandName: 'get',
|
|
3555
3555
|
description: 'Get a diff scan for an organization',
|
|
3556
3556
|
hidden: false,
|
|
@@ -3609,14 +3609,14 @@ const config$A = {
|
|
|
3609
3609
|
`
|
|
3610
3610
|
}
|
|
3611
3611
|
const cmdDiffScanGet = {
|
|
3612
|
-
description: config$
|
|
3613
|
-
hidden: config$
|
|
3614
|
-
run: run$
|
|
3612
|
+
description: config$B.description,
|
|
3613
|
+
hidden: config$B.hidden,
|
|
3614
|
+
run: run$B
|
|
3615
3615
|
}
|
|
3616
|
-
async function run$
|
|
3616
|
+
async function run$B(argv, importMeta, { parentName }) {
|
|
3617
3617
|
const cli = meowOrExit({
|
|
3618
3618
|
argv,
|
|
3619
|
-
config: config$
|
|
3619
|
+
config: config$B,
|
|
3620
3620
|
importMeta,
|
|
3621
3621
|
parentName
|
|
3622
3622
|
})
|
|
@@ -3664,11 +3664,14 @@ async function run$A(argv, importMeta, { parentName }) {
|
|
|
3664
3664
|
if (wasBadInput) {
|
|
3665
3665
|
return
|
|
3666
3666
|
}
|
|
3667
|
+
logger.logger.fail(
|
|
3668
|
+
'Warning: this command is deprecated in favor of `socket scan diff` and will be removed in the next major bump.'
|
|
3669
|
+
)
|
|
3667
3670
|
if (cli.flags['dryRun']) {
|
|
3668
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
3671
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$y)
|
|
3669
3672
|
return
|
|
3670
3673
|
}
|
|
3671
|
-
await handleDiffScan({
|
|
3674
|
+
await handleDiffScan$1({
|
|
3672
3675
|
before: String(before || ''),
|
|
3673
3676
|
after: String(after || ''),
|
|
3674
3677
|
depth: Number(depth),
|
|
@@ -3708,7 +3711,45 @@ function formatBranchName(str) {
|
|
|
3708
3711
|
function getPkgNameFromPurlObj(purlObj) {
|
|
3709
3712
|
return `${purlObj.namespace ? `${purlObj.namespace}/` : ''}${purlObj.name}`
|
|
3710
3713
|
}
|
|
3711
|
-
|
|
3714
|
+
function getBaseGitBranch() {
|
|
3715
|
+
// Lazily access constants.ENV[GITHUB_REF_NAME].
|
|
3716
|
+
return (
|
|
3717
|
+
constants.ENV[GITHUB_REF_NAME] ??
|
|
3718
|
+
// GitHub defaults to branch name "main"
|
|
3719
|
+
// https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch
|
|
3720
|
+
'main'
|
|
3721
|
+
)
|
|
3722
|
+
}
|
|
3723
|
+
function getSocketBranchName(purl, newVersion, workspaceName) {
|
|
3724
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3725
|
+
const maybeWorkspaceName = workspaceName
|
|
3726
|
+
? `${formatBranchName(workspaceName)}-`
|
|
3727
|
+
: ''
|
|
3728
|
+
const maybeNamespace = purlObj.namespace
|
|
3729
|
+
? `${formatBranchName(purlObj.namespace)}-`
|
|
3730
|
+
: ''
|
|
3731
|
+
const fullName = `${maybeWorkspaceName}${maybeNamespace}${formatBranchName(purlObj.name)}`
|
|
3732
|
+
return `socket-fix-${fullName}-${formatBranchName(newVersion)}`
|
|
3733
|
+
}
|
|
3734
|
+
function getSocketPullRequestTitle(purl, newVersion, workspaceName) {
|
|
3735
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3736
|
+
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3737
|
+
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
3738
|
+
return `Bump ${pkgName} from ${purlObj.version} to ${newVersion}${workspaceDetails}`
|
|
3739
|
+
}
|
|
3740
|
+
function getSocketPullRequestBody(purl, newVersion, workspaceName) {
|
|
3741
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3742
|
+
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3743
|
+
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
3744
|
+
return `Bumps [${pkgName}](https://socket.dev/${purlObj.type}/package/${pkgName}) from ${purlObj.version} to ${newVersion}${workspaceDetails}.`
|
|
3745
|
+
}
|
|
3746
|
+
function getSocketCommitMessage(purl, newVersion, workspaceName) {
|
|
3747
|
+
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3748
|
+
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3749
|
+
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
3750
|
+
return `socket: Bump ${pkgName} from ${purlObj.version} to ${newVersion}${workspaceDetails}`
|
|
3751
|
+
}
|
|
3752
|
+
async function gitBranchExists(branch, cwd = process.cwd()) {
|
|
3712
3753
|
try {
|
|
3713
3754
|
await spawn.spawn(
|
|
3714
3755
|
'git',
|
|
@@ -3722,8 +3763,12 @@ async function branchExists(branch, cwd = process.cwd()) {
|
|
|
3722
3763
|
} catch {}
|
|
3723
3764
|
return false
|
|
3724
3765
|
}
|
|
3725
|
-
async function
|
|
3766
|
+
async function gitCheckoutBaseBranchIfAvailable(
|
|
3767
|
+
baseBranch,
|
|
3768
|
+
cwd = process.cwd()
|
|
3769
|
+
) {
|
|
3726
3770
|
try {
|
|
3771
|
+
await gitHardReset()
|
|
3727
3772
|
await spawn.spawn('git', ['fetch', '--depth=1', 'origin', baseBranch], {
|
|
3728
3773
|
cwd
|
|
3729
3774
|
})
|
|
@@ -3741,12 +3786,12 @@ async function checkoutBaseBranchIfAvailable(baseBranch, cwd = process.cwd()) {
|
|
|
3741
3786
|
debug.debugLog(e)
|
|
3742
3787
|
}
|
|
3743
3788
|
}
|
|
3744
|
-
async function
|
|
3789
|
+
async function gitCreateAndPushBranchIfNeeded(
|
|
3745
3790
|
branch,
|
|
3746
3791
|
commitMsg,
|
|
3747
3792
|
cwd = process.cwd()
|
|
3748
3793
|
) {
|
|
3749
|
-
if (await
|
|
3794
|
+
if (await gitBranchExists(branch, cwd)) {
|
|
3750
3795
|
logger.logger.warn(`Branch "${branch}" already exists. Skipping creation.`)
|
|
3751
3796
|
return false
|
|
3752
3797
|
}
|
|
@@ -3764,37 +3809,20 @@ async function createAndPushBranchIfNeeded(
|
|
|
3764
3809
|
})
|
|
3765
3810
|
return true
|
|
3766
3811
|
}
|
|
3767
|
-
function
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
// GitHub defaults to branch name "main"
|
|
3772
|
-
// https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch
|
|
3773
|
-
'main'
|
|
3774
|
-
)
|
|
3775
|
-
}
|
|
3776
|
-
function getSocketBranchName(purl, toVersion) {
|
|
3777
|
-
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3778
|
-
const namespace = formatBranchName(purlObj.namespace ?? '')
|
|
3779
|
-
const name = formatBranchName(purlObj.name)
|
|
3780
|
-
const version = formatBranchName(toVersion)
|
|
3781
|
-
const fullName = `${namespace ? `${namespace}-` : ''}${name}`
|
|
3782
|
-
return `socket-fix-${fullName}-${version}`
|
|
3783
|
-
}
|
|
3784
|
-
function getSocketPullRequestTitle(purl, toVersion) {
|
|
3785
|
-
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3786
|
-
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3787
|
-
return `Bump ${pkgName} from ${purlObj.version} to ${toVersion}`
|
|
3788
|
-
}
|
|
3789
|
-
function getSocketPullRequestBody(purl, toVersion) {
|
|
3790
|
-
const purlObj = packageurlJs.PackageURL.fromString(purl)
|
|
3791
|
-
const pkgName = getPkgNameFromPurlObj(purlObj)
|
|
3792
|
-
return `Bumps [${pkgName}](https://socket.dev/${purlObj.type}/package/${pkgName}) from ${purlObj.version} to ${toVersion}.`
|
|
3812
|
+
async function gitHardReset(cwd = process.cwd()) {
|
|
3813
|
+
await spawn.spawn('git', ['reset', '--hard'], {
|
|
3814
|
+
cwd
|
|
3815
|
+
})
|
|
3793
3816
|
}
|
|
3794
|
-
function
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3817
|
+
async function isInGitRepo(cwd = process.cwd()) {
|
|
3818
|
+
try {
|
|
3819
|
+
await spawn.spawn('git', ['rev-parse', '--is-inside-work-tree'], {
|
|
3820
|
+
cwd,
|
|
3821
|
+
stdio: 'ignore'
|
|
3822
|
+
})
|
|
3823
|
+
return true
|
|
3824
|
+
} catch {}
|
|
3825
|
+
return false
|
|
3798
3826
|
}
|
|
3799
3827
|
|
|
3800
3828
|
const { GITHUB_ACTIONS, GITHUB_REPOSITORY, SOCKET_SECURITY_GITHUB_PAT } =
|
|
@@ -3835,7 +3863,7 @@ async function enableAutoMerge({ node_id: prId, number: prNumber }) {
|
|
|
3835
3863
|
const octokitGraphql = getOctokitGraphql()
|
|
3836
3864
|
try {
|
|
3837
3865
|
await octokitGraphql(
|
|
3838
|
-
`
|
|
3866
|
+
vendor.html`
|
|
3839
3867
|
mutation EnableAutoMerge($pullRequestId: ID!) {
|
|
3840
3868
|
enablePullRequestAutoMerge(input: {
|
|
3841
3869
|
pullRequestId: $pullRequestId,
|
|
@@ -3859,7 +3887,9 @@ async function enableAutoMerge({ node_id: prId, number: prNumber }) {
|
|
|
3859
3887
|
} catch (e) {
|
|
3860
3888
|
let message = `Failed to enable auto-merge for PR #${prNumber}`
|
|
3861
3889
|
if (e instanceof vendor.GraphqlResponseError && e.errors) {
|
|
3862
|
-
const details = e.errors
|
|
3890
|
+
const details = e.errors
|
|
3891
|
+
.map(({ message }) => ` - ${message.trim()}`)
|
|
3892
|
+
.join('\n')
|
|
3863
3893
|
message += `:\n${details}`
|
|
3864
3894
|
}
|
|
3865
3895
|
logger.logger.error(message)
|
|
@@ -3884,9 +3914,13 @@ async function openGitHubPullRequest(
|
|
|
3884
3914
|
baseBranch,
|
|
3885
3915
|
branch,
|
|
3886
3916
|
purl,
|
|
3887
|
-
|
|
3888
|
-
|
|
3917
|
+
newVersion,
|
|
3918
|
+
options
|
|
3889
3919
|
) {
|
|
3920
|
+
const { cwd = process.cwd(), workspaceName } = {
|
|
3921
|
+
__proto__: null,
|
|
3922
|
+
...options
|
|
3923
|
+
}
|
|
3890
3924
|
// Lazily access constants.ENV[GITHUB_ACTIONS].
|
|
3891
3925
|
if (constants.ENV[GITHUB_ACTIONS]) {
|
|
3892
3926
|
// Lazily access constants.ENV[SOCKET_SECURITY_GITHUB_PAT].
|
|
@@ -3903,10 +3937,10 @@ async function openGitHubPullRequest(
|
|
|
3903
3937
|
return await octokit.pulls.create({
|
|
3904
3938
|
owner,
|
|
3905
3939
|
repo,
|
|
3906
|
-
title: getSocketPullRequestTitle(purl,
|
|
3940
|
+
title: getSocketPullRequestTitle(purl, newVersion, workspaceName),
|
|
3907
3941
|
head: branch,
|
|
3908
3942
|
base: baseBranch,
|
|
3909
|
-
body: getSocketPullRequestBody(purl,
|
|
3943
|
+
body: getSocketPullRequestBody(purl, newVersion, workspaceName)
|
|
3910
3944
|
})
|
|
3911
3945
|
} catch (e) {
|
|
3912
3946
|
let message = `Failed to open pull request`
|
|
@@ -3916,7 +3950,7 @@ async function openGitHubPullRequest(
|
|
|
3916
3950
|
const details = restErrors
|
|
3917
3951
|
.map(
|
|
3918
3952
|
restErr =>
|
|
3919
|
-
`- ${restErr.message ?? `${restErr.resource}.${restErr.field} (${restErr.code})`}`
|
|
3953
|
+
`- ${restErr.message?.trim() ?? `${restErr.resource}.${restErr.field} (${restErr.code})`}`
|
|
3920
3954
|
)
|
|
3921
3955
|
.join('\n')
|
|
3922
3956
|
message += `:\n${details}`
|
|
@@ -3942,17 +3976,17 @@ async function install$1(idealTree, options) {
|
|
|
3942
3976
|
await arb2.reify()
|
|
3943
3977
|
}
|
|
3944
3978
|
async function npmFix(
|
|
3945
|
-
|
|
3946
|
-
{ autoMerge, cwd, rangeStyle, spinner, test, testScript }
|
|
3979
|
+
pkgEnvDetails,
|
|
3980
|
+
{ autoMerge, cwd, purls, rangeStyle, spinner, test, testScript }
|
|
3947
3981
|
) {
|
|
3948
3982
|
spinner?.start()
|
|
3949
3983
|
const arb = new shadowNpmInject.SafeArborist({
|
|
3950
|
-
path:
|
|
3984
|
+
path: pkgEnvDetails.pkgPath,
|
|
3951
3985
|
...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
3952
3986
|
})
|
|
3953
3987
|
// Calling arb.reify() creates the arb.diff object and nulls-out arb.idealTree.
|
|
3954
3988
|
await arb.reify()
|
|
3955
|
-
const
|
|
3989
|
+
const alertMapOptions = {
|
|
3956
3990
|
consolidate: true,
|
|
3957
3991
|
include: {
|
|
3958
3992
|
existing: true,
|
|
@@ -3960,17 +3994,27 @@ async function npmFix(
|
|
|
3960
3994
|
upgradable: false
|
|
3961
3995
|
},
|
|
3962
3996
|
nothrow: true
|
|
3963
|
-
}
|
|
3997
|
+
}
|
|
3998
|
+
const alertsMap = purls.length
|
|
3999
|
+
? await shadowNpmInject.getAlertsMapFromPurls(purls, alertMapOptions)
|
|
4000
|
+
: await shadowNpmInject.getAlertsMapFromArborist(arb, alertMapOptions)
|
|
3964
4001
|
const infoByPkg = shadowNpmInject.getCveInfoByAlertsMap(alertsMap)
|
|
3965
4002
|
if (!infoByPkg) {
|
|
3966
4003
|
spinner?.stop()
|
|
3967
4004
|
return
|
|
3968
4005
|
}
|
|
3969
|
-
|
|
3970
|
-
editable: true
|
|
3971
|
-
})
|
|
4006
|
+
|
|
3972
4007
|
// Lazily access constants.ENV[CI].
|
|
3973
4008
|
const isCi = constants.ENV[CI$1]
|
|
4009
|
+
const { pkgPath: rootPath } = pkgEnvDetails
|
|
4010
|
+
const { 0: isRepo, 1: workspacePkgJsonPaths } = await Promise.all([
|
|
4011
|
+
isInGitRepo(cwd),
|
|
4012
|
+
shadowNpmPaths.globWorkspace(pkgEnvDetails)
|
|
4013
|
+
])
|
|
4014
|
+
const pkgJsonPaths = [
|
|
4015
|
+
pkgEnvDetails.editablePkgJson.filename,
|
|
4016
|
+
...workspacePkgJsonPaths
|
|
4017
|
+
]
|
|
3974
4018
|
await arb.buildIdealTree()
|
|
3975
4019
|
for (const { 0: name, 1: infos } of infoByPkg) {
|
|
3976
4020
|
const hasUpgrade = !!registry.getManifestData(NPM$f, name)
|
|
@@ -3978,25 +4022,26 @@ async function npmFix(
|
|
|
3978
4022
|
spinner?.info(`Skipping ${name}. Socket Optimize package exists.`)
|
|
3979
4023
|
continue
|
|
3980
4024
|
}
|
|
3981
|
-
const
|
|
3982
|
-
shadowNpmInject
|
|
3983
|
-
.findPackageNodes(arb.idealTree, name)
|
|
3984
|
-
.map(n => `${n.name}@${n.version}`)
|
|
4025
|
+
const oldVersions = arrays.arrayUnique(
|
|
4026
|
+
shadowNpmInject.findPackageNodes(arb.idealTree, name).map(n => n.version)
|
|
3985
4027
|
)
|
|
3986
4028
|
const packument =
|
|
3987
|
-
|
|
4029
|
+
oldVersions.length && infos.length
|
|
3988
4030
|
? // eslint-disable-next-line no-await-in-loop
|
|
3989
4031
|
await packages.fetchPackagePackument(name)
|
|
3990
4032
|
: null
|
|
3991
4033
|
if (!packument) {
|
|
3992
4034
|
continue
|
|
3993
4035
|
}
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4036
|
+
const failedSpecs = new Set()
|
|
4037
|
+
const fixedSpecs = new Set()
|
|
4038
|
+
const installedSpecs = new Set()
|
|
4039
|
+
const testedSpecs = new Set()
|
|
4040
|
+
const unavailableSpecs = new Set()
|
|
4041
|
+
const revertedSpecs = new Set()
|
|
4042
|
+
for (const oldVersion of oldVersions) {
|
|
4043
|
+
const oldSpec = `${name}@${oldVersion}`
|
|
4044
|
+
const oldPurl = `pkg:npm/${oldSpec}`
|
|
4000
4045
|
for (const {
|
|
4001
4046
|
firstPatchedVersionIdentifier,
|
|
4002
4047
|
vulnerableVersionRange
|
|
@@ -4008,7 +4053,7 @@ async function npmFix(
|
|
|
4008
4053
|
const node = shadowNpmInject.findPackageNode(
|
|
4009
4054
|
arb.idealTree,
|
|
4010
4055
|
name,
|
|
4011
|
-
|
|
4056
|
+
oldVersion
|
|
4012
4057
|
)
|
|
4013
4058
|
if (!node) {
|
|
4014
4059
|
continue
|
|
@@ -4016,124 +4061,170 @@ async function npmFix(
|
|
|
4016
4061
|
if (
|
|
4017
4062
|
!shadowNpmInject.updateNode(node, packument, vulnerableVersionRange)
|
|
4018
4063
|
) {
|
|
4019
|
-
|
|
4064
|
+
if (!unavailableSpecs.has(oldSpec)) {
|
|
4065
|
+
unavailableSpecs.add(oldSpec)
|
|
4066
|
+
spinner?.fail(`No update available for ${oldSpec}`)
|
|
4067
|
+
}
|
|
4020
4068
|
continue
|
|
4021
4069
|
}
|
|
4022
|
-
const
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
: false
|
|
4040
|
-
const revertData = {
|
|
4041
|
-
...(editablePkgJson.content.dependencies
|
|
4042
|
-
? {
|
|
4043
|
-
dependencies: editablePkgJson.content.dependencies
|
|
4044
|
-
}
|
|
4045
|
-
: undefined),
|
|
4046
|
-
...(editablePkgJson.content.optionalDependencies
|
|
4047
|
-
? {
|
|
4048
|
-
optionalDependencies:
|
|
4049
|
-
editablePkgJson.content.optionalDependencies
|
|
4050
|
-
}
|
|
4051
|
-
: undefined),
|
|
4052
|
-
...(editablePkgJson.content.peerDependencies
|
|
4053
|
-
? {
|
|
4054
|
-
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4055
|
-
}
|
|
4056
|
-
: undefined)
|
|
4057
|
-
}
|
|
4058
|
-
spinner?.info(`Installing ${toSpec}`)
|
|
4059
|
-
const baseBranch = getBaseBranch()
|
|
4060
|
-
|
|
4061
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4062
|
-
await checkoutBaseBranchIfAvailable(baseBranch, cwd)
|
|
4063
|
-
let error
|
|
4064
|
-
let errored = false
|
|
4065
|
-
let installed = false
|
|
4066
|
-
let saved = false
|
|
4067
|
-
try {
|
|
4068
|
-
shadowNpmInject.updatePackageJsonFromNode(
|
|
4069
|
-
editablePkgJson,
|
|
4070
|
-
arb.idealTree,
|
|
4071
|
-
node,
|
|
4072
|
-
toVersion,
|
|
4070
|
+
for (const pkgJsonPath of pkgJsonPaths) {
|
|
4071
|
+
const isWorkspaceRoot =
|
|
4072
|
+
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4073
|
+
const workspaceName = isWorkspaceRoot
|
|
4074
|
+
? ''
|
|
4075
|
+
: path$1.relative(rootPath, path$1.dirname(pkgJsonPath))
|
|
4076
|
+
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
4077
|
+
const editablePkgJson = isWorkspaceRoot
|
|
4078
|
+
? pkgEnvDetails.editablePkgJson
|
|
4079
|
+
: // eslint-disable-next-line no-await-in-loop
|
|
4080
|
+
await packages.readPackageJson(pkgJsonPath, {
|
|
4081
|
+
editable: true
|
|
4082
|
+
})
|
|
4083
|
+
const newVersion = node.package.version
|
|
4084
|
+
const newVersionRange = shadowNpmInject.applyRange(
|
|
4085
|
+
oldVersion,
|
|
4086
|
+
newVersion,
|
|
4073
4087
|
rangeStyle
|
|
4074
4088
|
)
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4089
|
+
const newSpec = `${name}@${newVersionRange}`
|
|
4090
|
+
const newSpecKey = `${workspaceName ? `${workspaceName}>` : ''}${newSpec}`
|
|
4091
|
+
const branch = isCi
|
|
4092
|
+
? getSocketBranchName(oldPurl, newVersion, workspaceName)
|
|
4093
|
+
: ''
|
|
4094
|
+
const { owner, repo } = isCi
|
|
4095
|
+
? getGitHubEnvRepoInfo()
|
|
4096
|
+
: {
|
|
4097
|
+
owner: '',
|
|
4098
|
+
repo: ''
|
|
4099
|
+
}
|
|
4100
|
+
const shouldOpenPr = isCi
|
|
4101
|
+
? // eslint-disable-next-line no-await-in-loop
|
|
4102
|
+
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4103
|
+
: false
|
|
4104
|
+
const revertData = {
|
|
4105
|
+
...(editablePkgJson.content.dependencies
|
|
4106
|
+
? {
|
|
4107
|
+
dependencies: editablePkgJson.content.dependencies
|
|
4108
|
+
}
|
|
4109
|
+
: undefined),
|
|
4110
|
+
...(editablePkgJson.content.optionalDependencies
|
|
4111
|
+
? {
|
|
4112
|
+
optionalDependencies:
|
|
4113
|
+
editablePkgJson.content.optionalDependencies
|
|
4114
|
+
}
|
|
4115
|
+
: undefined),
|
|
4116
|
+
...(editablePkgJson.content.peerDependencies
|
|
4117
|
+
? {
|
|
4118
|
+
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4119
|
+
}
|
|
4120
|
+
: undefined)
|
|
4091
4121
|
}
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
if (!errored && shouldOpenPr) {
|
|
4099
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4100
|
-
await createAndPushBranchIfNeeded(
|
|
4101
|
-
branch,
|
|
4102
|
-
getSocketCommitMessage(fromPurl, toVersion),
|
|
4103
|
-
cwd
|
|
4104
|
-
)
|
|
4122
|
+
if (!installedSpecs.has(newSpecKey)) {
|
|
4123
|
+
testedSpecs.add(newSpecKey)
|
|
4124
|
+
spinner?.info(`Installing ${newSpec}${workspaceDetails}`)
|
|
4125
|
+
}
|
|
4126
|
+
const baseBranch = getBaseGitBranch()
|
|
4127
|
+
|
|
4105
4128
|
// eslint-disable-next-line no-await-in-loop
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4129
|
+
await gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)
|
|
4130
|
+
let error
|
|
4131
|
+
let errored = false
|
|
4132
|
+
let installed = false
|
|
4133
|
+
let saved = false
|
|
4134
|
+
try {
|
|
4135
|
+
shadowNpmInject.updatePackageJsonFromNode(
|
|
4136
|
+
editablePkgJson,
|
|
4137
|
+
arb.idealTree,
|
|
4138
|
+
node,
|
|
4139
|
+
newVersion,
|
|
4140
|
+
rangeStyle
|
|
4141
|
+
)
|
|
4116
4142
|
// eslint-disable-next-line no-await-in-loop
|
|
4117
|
-
await
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
if (errored || isCi) {
|
|
4121
|
-
if (errored) {
|
|
4122
|
-
spinner?.error(`Reverting ${toSpec}`, error)
|
|
4123
|
-
}
|
|
4124
|
-
if (saved) {
|
|
4125
|
-
editablePkgJson.update(revertData)
|
|
4143
|
+
if (await editablePkgJson.save()) {
|
|
4144
|
+
saved = true
|
|
4145
|
+
}
|
|
4126
4146
|
// eslint-disable-next-line no-await-in-loop
|
|
4127
|
-
await
|
|
4147
|
+
await install$1(arb.idealTree, {
|
|
4148
|
+
cwd
|
|
4149
|
+
})
|
|
4150
|
+
installed = true
|
|
4151
|
+
if (test) {
|
|
4152
|
+
if (!testedSpecs.has(newSpecKey)) {
|
|
4153
|
+
testedSpecs.add(newSpecKey)
|
|
4154
|
+
spinner?.info(`Testing ${newSpec}${workspaceDetails}`)
|
|
4155
|
+
}
|
|
4156
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4157
|
+
await npm.runScript(testScript, [], {
|
|
4158
|
+
spinner,
|
|
4159
|
+
stdio: 'ignore'
|
|
4160
|
+
})
|
|
4161
|
+
}
|
|
4162
|
+
if (!fixedSpecs.has(newSpecKey)) {
|
|
4163
|
+
fixedSpecs.add(newSpecKey)
|
|
4164
|
+
spinner?.successAndStop(`Fixed ${name}${workspaceDetails}`)
|
|
4165
|
+
spinner?.start()
|
|
4166
|
+
}
|
|
4167
|
+
} catch (e) {
|
|
4168
|
+
error = e
|
|
4169
|
+
errored = true
|
|
4128
4170
|
}
|
|
4129
|
-
if (
|
|
4171
|
+
if (!errored && shouldOpenPr) {
|
|
4130
4172
|
// eslint-disable-next-line no-await-in-loop
|
|
4131
|
-
await
|
|
4173
|
+
await gitCreateAndPushBranchIfNeeded(
|
|
4174
|
+
branch,
|
|
4175
|
+
getSocketCommitMessage(oldPurl, newVersion, workspaceName),
|
|
4132
4176
|
cwd
|
|
4133
|
-
|
|
4177
|
+
)
|
|
4178
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4179
|
+
const prResponse = await openGitHubPullRequest(
|
|
4180
|
+
owner,
|
|
4181
|
+
repo,
|
|
4182
|
+
baseBranch,
|
|
4183
|
+
branch,
|
|
4184
|
+
oldPurl,
|
|
4185
|
+
newVersion,
|
|
4186
|
+
{
|
|
4187
|
+
cwd,
|
|
4188
|
+
workspaceName
|
|
4189
|
+
}
|
|
4190
|
+
)
|
|
4191
|
+
if (prResponse && autoMerge) {
|
|
4192
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4193
|
+
await enableAutoMerge(prResponse.data)
|
|
4194
|
+
}
|
|
4134
4195
|
}
|
|
4135
|
-
if (errored) {
|
|
4136
|
-
|
|
4196
|
+
if (errored || isCi) {
|
|
4197
|
+
if (errored) {
|
|
4198
|
+
if (!revertedSpecs.has(newSpecKey)) {
|
|
4199
|
+
revertedSpecs.add(newSpecKey)
|
|
4200
|
+
spinner?.error(`Reverting ${newSpec}${workspaceDetails}`, error)
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
if (isRepo) {
|
|
4204
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4205
|
+
await gitHardReset(cwd)
|
|
4206
|
+
}
|
|
4207
|
+
if (saved) {
|
|
4208
|
+
editablePkgJson.update(revertData)
|
|
4209
|
+
if (!isRepo) {
|
|
4210
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4211
|
+
await editablePkgJson.save()
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
if (!isRepo && installed) {
|
|
4215
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4216
|
+
await install$1(revertTree, {
|
|
4217
|
+
cwd
|
|
4218
|
+
})
|
|
4219
|
+
}
|
|
4220
|
+
if (errored) {
|
|
4221
|
+
if (!failedSpecs.has(newSpecKey)) {
|
|
4222
|
+
failedSpecs.add(newSpecKey)
|
|
4223
|
+
spinner?.failAndStop(
|
|
4224
|
+
`Update failed for ${oldSpec}${workspaceDetails}`
|
|
4225
|
+
)
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4137
4228
|
}
|
|
4138
4229
|
}
|
|
4139
4230
|
}
|
|
@@ -4142,78 +4233,6 @@ async function npmFix(
|
|
|
4142
4233
|
spinner?.stop()
|
|
4143
4234
|
}
|
|
4144
4235
|
|
|
4145
|
-
async function getAlertsMapFromPnpmLockfile(lockfile, options_) {
|
|
4146
|
-
const options = {
|
|
4147
|
-
__proto__: null,
|
|
4148
|
-
consolidate: false,
|
|
4149
|
-
nothrow: false,
|
|
4150
|
-
...options_
|
|
4151
|
-
}
|
|
4152
|
-
const include = {
|
|
4153
|
-
__proto__: null,
|
|
4154
|
-
actions: undefined,
|
|
4155
|
-
blocked: true,
|
|
4156
|
-
critical: true,
|
|
4157
|
-
cve: true,
|
|
4158
|
-
existing: false,
|
|
4159
|
-
unfixable: true,
|
|
4160
|
-
upgradable: false,
|
|
4161
|
-
...options.include
|
|
4162
|
-
}
|
|
4163
|
-
const { spinner } = options
|
|
4164
|
-
const depTypes = vendor.libExports$2.detectDepTypes(lockfile)
|
|
4165
|
-
const pkgIds = Object.keys(depTypes)
|
|
4166
|
-
let { length: remaining } = pkgIds
|
|
4167
|
-
const alertsByPkgId = new Map()
|
|
4168
|
-
if (!remaining) {
|
|
4169
|
-
return alertsByPkgId
|
|
4170
|
-
}
|
|
4171
|
-
const getText = () => `Looking up data for ${remaining} packages`
|
|
4172
|
-
spinner?.start(getText())
|
|
4173
|
-
const sockSdk = await shadowNpmInject.setupSdk(
|
|
4174
|
-
shadowNpmInject.getPublicToken()
|
|
4175
|
-
)
|
|
4176
|
-
const toAlertsMapOptions = {
|
|
4177
|
-
overrides: lockfile.overrides,
|
|
4178
|
-
consolidate: options.consolidate,
|
|
4179
|
-
include,
|
|
4180
|
-
spinner
|
|
4181
|
-
}
|
|
4182
|
-
for await (const batchResult of sockSdk.batchPackageStream(
|
|
4183
|
-
{
|
|
4184
|
-
alerts: 'true',
|
|
4185
|
-
compact: 'true',
|
|
4186
|
-
fixable: include.unfixable ? 'false' : 'true'
|
|
4187
|
-
},
|
|
4188
|
-
{
|
|
4189
|
-
components: pkgIds.map(id => ({
|
|
4190
|
-
purl: `pkg:npm/${id}`
|
|
4191
|
-
}))
|
|
4192
|
-
}
|
|
4193
|
-
)) {
|
|
4194
|
-
if (batchResult.success) {
|
|
4195
|
-
await shadowNpmInject.addArtifactToAlertsMap(
|
|
4196
|
-
batchResult.data,
|
|
4197
|
-
alertsByPkgId,
|
|
4198
|
-
toAlertsMapOptions
|
|
4199
|
-
)
|
|
4200
|
-
} else if (!options.nothrow) {
|
|
4201
|
-
const statusCode = batchResult.status ?? 'unknown'
|
|
4202
|
-
const statusMessage = batchResult.error ?? 'No status message'
|
|
4203
|
-
throw new Error(
|
|
4204
|
-
`Socket API server error (${statusCode}): ${statusMessage}`
|
|
4205
|
-
)
|
|
4206
|
-
}
|
|
4207
|
-
remaining -= 1
|
|
4208
|
-
if (spinner && remaining > 0) {
|
|
4209
|
-
spinner.start()
|
|
4210
|
-
spinner.setText(getText())
|
|
4211
|
-
}
|
|
4212
|
-
}
|
|
4213
|
-
spinner?.stop()
|
|
4214
|
-
return alertsByPkgId
|
|
4215
|
-
}
|
|
4216
|
-
|
|
4217
4236
|
const {
|
|
4218
4237
|
NPM: NPM$e,
|
|
4219
4238
|
SOCKET_CLI_SAFE_BIN,
|
|
@@ -4304,7 +4323,7 @@ function safeNpmInstall(options) {
|
|
|
4304
4323
|
return spawnPromise
|
|
4305
4324
|
}
|
|
4306
4325
|
|
|
4307
|
-
const { NPM: NPM$d, PNPM: PNPM$
|
|
4326
|
+
const { NPM: NPM$d, PNPM: PNPM$9 } = constants
|
|
4308
4327
|
function runAgentInstall(pkgEnvDetails, options) {
|
|
4309
4328
|
const { agent, agentExecPath } = pkgEnvDetails
|
|
4310
4329
|
// All package managers support the "install" command.
|
|
@@ -4323,7 +4342,7 @@ function runAgentInstall(pkgEnvDetails, options) {
|
|
|
4323
4342
|
...options
|
|
4324
4343
|
}
|
|
4325
4344
|
const skipNodeHardenFlags =
|
|
4326
|
-
agent === PNPM$
|
|
4345
|
+
agent === PNPM$9 && pkgEnvDetails.agentVersion.major < 11
|
|
4327
4346
|
return spawn.spawn(agentExecPath, ['install', ...args], {
|
|
4328
4347
|
spinner,
|
|
4329
4348
|
stdio: 'inherit',
|
|
@@ -4343,7 +4362,7 @@ function runAgentInstall(pkgEnvDetails, options) {
|
|
|
4343
4362
|
})
|
|
4344
4363
|
}
|
|
4345
4364
|
|
|
4346
|
-
const { CI, NPM: NPM$c, OVERRIDES: OVERRIDES$2, PNPM: PNPM$
|
|
4365
|
+
const { CI, NPM: NPM$c, OVERRIDES: OVERRIDES$2, PNPM: PNPM$8 } = constants
|
|
4347
4366
|
async function getActualTree(cwd = process.cwd()) {
|
|
4348
4367
|
const arb = new shadowNpmInject.SafeArborist({
|
|
4349
4368
|
path: cwd,
|
|
@@ -4365,15 +4384,18 @@ async function install(pkgEnvDetails, options) {
|
|
|
4365
4384
|
}
|
|
4366
4385
|
async function pnpmFix(
|
|
4367
4386
|
pkgEnvDetails,
|
|
4368
|
-
{ autoMerge, cwd, rangeStyle, spinner, test, testScript }
|
|
4387
|
+
{ autoMerge, cwd, purls, rangeStyle, spinner, test, testScript }
|
|
4369
4388
|
) {
|
|
4370
|
-
const lockfile = await vendor.libExports$3.readWantedLockfile(
|
|
4371
|
-
|
|
4372
|
-
|
|
4389
|
+
const lockfile = await vendor.libExports$3.readWantedLockfile(
|
|
4390
|
+
pkgEnvDetails.pkgPath,
|
|
4391
|
+
{
|
|
4392
|
+
ignoreIncompatible: false
|
|
4393
|
+
}
|
|
4394
|
+
)
|
|
4373
4395
|
if (!lockfile) {
|
|
4374
4396
|
return
|
|
4375
4397
|
}
|
|
4376
|
-
const
|
|
4398
|
+
const alertMapOptions = {
|
|
4377
4399
|
consolidate: true,
|
|
4378
4400
|
include: {
|
|
4379
4401
|
existing: true,
|
|
@@ -4381,42 +4403,61 @@ async function pnpmFix(
|
|
|
4381
4403
|
upgradable: false
|
|
4382
4404
|
},
|
|
4383
4405
|
nothrow: true
|
|
4384
|
-
}
|
|
4406
|
+
}
|
|
4407
|
+
const alertsMap = purls.length
|
|
4408
|
+
? await shadowNpmInject.getAlertsMapFromPurls(purls, alertMapOptions)
|
|
4409
|
+
: await shadowNpmInject.getAlertsMapFromPnpmLockfile(
|
|
4410
|
+
lockfile,
|
|
4411
|
+
alertMapOptions
|
|
4412
|
+
)
|
|
4385
4413
|
const infoByPkg = shadowNpmInject.getCveInfoByAlertsMap(alertsMap)
|
|
4386
4414
|
if (!infoByPkg) {
|
|
4387
4415
|
return
|
|
4388
4416
|
}
|
|
4389
4417
|
spinner?.start()
|
|
4390
|
-
|
|
4391
|
-
editable: true
|
|
4392
|
-
})
|
|
4418
|
+
|
|
4393
4419
|
// Lazily access constants.ENV[CI].
|
|
4394
4420
|
const isCi = constants.ENV[CI]
|
|
4395
|
-
|
|
4421
|
+
const { pkgPath: rootPath } = pkgEnvDetails
|
|
4422
|
+
const {
|
|
4423
|
+
0: isRepo,
|
|
4424
|
+
1: workspacePkgJsonPaths,
|
|
4425
|
+
2: initialTree
|
|
4426
|
+
} = await Promise.all([
|
|
4427
|
+
isInGitRepo(cwd),
|
|
4428
|
+
shadowNpmPaths.globWorkspace(pkgEnvDetails),
|
|
4429
|
+
getActualTree(cwd)
|
|
4430
|
+
])
|
|
4431
|
+
const pkgJsonPaths = [
|
|
4432
|
+
pkgEnvDetails.editablePkgJson.filename,
|
|
4433
|
+
...workspacePkgJsonPaths
|
|
4434
|
+
]
|
|
4435
|
+
let actualTree = initialTree
|
|
4396
4436
|
for (const { 0: name, 1: infos } of infoByPkg) {
|
|
4397
4437
|
if (registry.getManifestData(NPM$c, name)) {
|
|
4398
4438
|
spinner?.info(`Skipping ${name}. Socket Optimize package exists.`)
|
|
4399
4439
|
continue
|
|
4400
4440
|
}
|
|
4401
|
-
const
|
|
4402
|
-
shadowNpmInject
|
|
4403
|
-
.findPackageNodes(actualTree, name)
|
|
4404
|
-
.map(n => `${n.name}@${n.version}`)
|
|
4441
|
+
const oldVersions = arrays.arrayUnique(
|
|
4442
|
+
shadowNpmInject.findPackageNodes(actualTree, name).map(n => n.version)
|
|
4405
4443
|
)
|
|
4406
4444
|
const packument =
|
|
4407
|
-
|
|
4445
|
+
oldVersions.length && infos.length
|
|
4408
4446
|
? // eslint-disable-next-line no-await-in-loop
|
|
4409
4447
|
await packages.fetchPackagePackument(name)
|
|
4410
4448
|
: null
|
|
4411
4449
|
if (!packument) {
|
|
4412
4450
|
continue
|
|
4413
4451
|
}
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4452
|
+
const failedSpecs = new Set()
|
|
4453
|
+
const fixedSpecs = new Set()
|
|
4454
|
+
const installedSpecs = new Set()
|
|
4455
|
+
const testedSpecs = new Set()
|
|
4456
|
+
const unavailableSpecs = new Set()
|
|
4457
|
+
const revertedSpecs = new Set()
|
|
4458
|
+
for (const oldVersion of oldVersions) {
|
|
4459
|
+
const oldSpec = `${name}@${oldVersion}`
|
|
4460
|
+
const oldPurl = `pkg:npm/${oldSpec}`
|
|
4420
4461
|
for (const {
|
|
4421
4462
|
firstPatchedVersionIdentifier,
|
|
4422
4463
|
vulnerableVersionRange
|
|
@@ -4424,167 +4465,224 @@ async function pnpmFix(
|
|
|
4424
4465
|
const node = shadowNpmInject.findPackageNode(
|
|
4425
4466
|
actualTree,
|
|
4426
4467
|
name,
|
|
4427
|
-
|
|
4468
|
+
oldVersion
|
|
4428
4469
|
)
|
|
4429
4470
|
if (!node) {
|
|
4430
4471
|
continue
|
|
4431
4472
|
}
|
|
4432
4473
|
const availableVersions = Object.keys(packument.versions)
|
|
4433
|
-
const
|
|
4474
|
+
const newVersion = shadowNpmInject.findBestPatchVersion(
|
|
4434
4475
|
node,
|
|
4435
4476
|
availableVersions,
|
|
4436
4477
|
vulnerableVersionRange
|
|
4437
4478
|
)
|
|
4438
|
-
const
|
|
4439
|
-
? packument.versions[
|
|
4479
|
+
const newVersionPackument = newVersion
|
|
4480
|
+
? packument.versions[newVersion]
|
|
4440
4481
|
: undefined
|
|
4441
|
-
if (!(
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
const oldPnpm = editablePkgJson.content[PNPM$9]
|
|
4446
|
-
const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
|
|
4447
|
-
const oldOverrides = oldPnpm?.[OVERRIDES$2]
|
|
4448
|
-
const oldOverridesCount = oldOverrides
|
|
4449
|
-
? Object.keys(oldOverrides).length
|
|
4450
|
-
: 0
|
|
4451
|
-
const overrideKey = `${name}@${vulnerableVersionRange}`
|
|
4452
|
-
const toVersionRange = shadowNpmInject.applyRange(
|
|
4453
|
-
oldOverrides?.[overrideKey] ?? fromVersion,
|
|
4454
|
-
toVersion,
|
|
4455
|
-
rangeStyle
|
|
4456
|
-
)
|
|
4457
|
-
const toSpec = `${name}@${toVersionRange}`
|
|
4458
|
-
const branch = isCi ? getSocketBranchName(fromPurl, toVersion) : ''
|
|
4459
|
-
const { owner, repo } = isCi
|
|
4460
|
-
? getGitHubEnvRepoInfo()
|
|
4461
|
-
: {
|
|
4462
|
-
owner: '',
|
|
4463
|
-
repo: ''
|
|
4464
|
-
}
|
|
4465
|
-
const shouldOpenPr = isCi
|
|
4466
|
-
? // eslint-disable-next-line no-await-in-loop
|
|
4467
|
-
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4468
|
-
: false
|
|
4469
|
-
const updateData = {
|
|
4470
|
-
[PNPM$9]: {
|
|
4471
|
-
...oldPnpm,
|
|
4472
|
-
[OVERRIDES$2]: {
|
|
4473
|
-
[overrideKey]: toVersionRange,
|
|
4474
|
-
...oldOverrides
|
|
4475
|
-
}
|
|
4482
|
+
if (!(newVersion && newVersionPackument)) {
|
|
4483
|
+
if (!unavailableSpecs.has(oldSpec)) {
|
|
4484
|
+
unavailableSpecs.add(oldSpec)
|
|
4485
|
+
spinner?.fail(`No update available for ${oldSpec}`)
|
|
4476
4486
|
}
|
|
4487
|
+
continue
|
|
4477
4488
|
}
|
|
4478
|
-
const
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4489
|
+
for (const pkgJsonPath of pkgJsonPaths) {
|
|
4490
|
+
const isWorkspaceRoot =
|
|
4491
|
+
pkgJsonPath === pkgEnvDetails.editablePkgJson.filename
|
|
4492
|
+
const workspaceName = isWorkspaceRoot
|
|
4493
|
+
? ''
|
|
4494
|
+
: path$1.relative(rootPath, path$1.dirname(pkgJsonPath))
|
|
4495
|
+
const workspaceDetails = workspaceName ? ` in ${workspaceName}` : ''
|
|
4496
|
+
const editablePkgJson = isWorkspaceRoot
|
|
4497
|
+
? pkgEnvDetails.editablePkgJson
|
|
4498
|
+
: // eslint-disable-next-line no-await-in-loop
|
|
4499
|
+
await packages.readPackageJson(pkgJsonPath, {
|
|
4500
|
+
editable: true
|
|
4501
|
+
})
|
|
4502
|
+
const oldPnpm = editablePkgJson.content[PNPM$8]
|
|
4503
|
+
const oldPnpmKeyCount = oldPnpm ? Object.keys(oldPnpm).length : 0
|
|
4504
|
+
const oldOverrides = oldPnpm?.[OVERRIDES$2]
|
|
4505
|
+
const oldOverridesCount = oldOverrides
|
|
4506
|
+
? Object.keys(oldOverrides).length
|
|
4507
|
+
: 0
|
|
4508
|
+
const overrideKey = `${name}@${vulnerableVersionRange}`
|
|
4509
|
+
const newVersionRange = shadowNpmInject.applyRange(
|
|
4510
|
+
oldOverrides?.[overrideKey] ?? oldVersion,
|
|
4511
|
+
newVersion,
|
|
4512
|
+
rangeStyle
|
|
4513
|
+
)
|
|
4514
|
+
const newSpec = `${name}@${newVersionRange}`
|
|
4515
|
+
const newSpecKey = `${workspaceName ? `${workspaceName}>` : ''}${newSpec}`
|
|
4516
|
+
const branch = isCi
|
|
4517
|
+
? getSocketBranchName(oldPurl, newVersion, workspaceName)
|
|
4518
|
+
: ''
|
|
4519
|
+
const baseBranch = isCi ? getBaseGitBranch() : ''
|
|
4520
|
+
const { owner, repo } = isCi
|
|
4521
|
+
? getGitHubEnvRepoInfo()
|
|
4522
|
+
: {
|
|
4523
|
+
owner: '',
|
|
4524
|
+
repo: ''
|
|
4500
4525
|
}
|
|
4501
|
-
|
|
4502
|
-
|
|
4526
|
+
const shouldOpenPr = isCi
|
|
4527
|
+
? // eslint-disable-next-line no-await-in-loop
|
|
4528
|
+
!(await doesPullRequestExistForBranch(owner, repo, branch))
|
|
4529
|
+
: false
|
|
4530
|
+
const updateData = isWorkspaceRoot
|
|
4503
4531
|
? {
|
|
4504
|
-
|
|
4532
|
+
[PNPM$8]: {
|
|
4533
|
+
...oldPnpm,
|
|
4534
|
+
[OVERRIDES$2]: {
|
|
4535
|
+
[overrideKey]: newVersionRange,
|
|
4536
|
+
...oldOverrides
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4505
4539
|
}
|
|
4506
|
-
:
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
stdio: 'ignore'
|
|
4541
|
-
})
|
|
4542
|
-
}
|
|
4543
|
-
spinner?.successAndStop(`Fixed ${name}`)
|
|
4544
|
-
spinner?.start()
|
|
4545
|
-
} catch (e) {
|
|
4546
|
-
error = e
|
|
4547
|
-
errored = true
|
|
4548
|
-
}
|
|
4549
|
-
if (!errored && shouldOpenPr) {
|
|
4550
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4551
|
-
await createAndPushBranchIfNeeded(
|
|
4552
|
-
branch,
|
|
4553
|
-
getSocketCommitMessage(fromPurl, toVersion),
|
|
4554
|
-
cwd
|
|
4555
|
-
)
|
|
4556
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4557
|
-
const prResponse = await openGitHubPullRequest(
|
|
4558
|
-
owner,
|
|
4559
|
-
repo,
|
|
4560
|
-
baseBranch,
|
|
4561
|
-
branch,
|
|
4562
|
-
fromPurl,
|
|
4563
|
-
toVersion,
|
|
4564
|
-
cwd
|
|
4565
|
-
)
|
|
4566
|
-
if (prResponse && autoMerge) {
|
|
4567
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4568
|
-
await enableAutoMerge(prResponse.data)
|
|
4540
|
+
: {}
|
|
4541
|
+
const revertData = {
|
|
4542
|
+
...(isWorkspaceRoot
|
|
4543
|
+
? {
|
|
4544
|
+
[PNPM$8]: oldPnpmKeyCount
|
|
4545
|
+
? {
|
|
4546
|
+
...oldPnpm,
|
|
4547
|
+
[OVERRIDES$2]:
|
|
4548
|
+
oldOverridesCount === 1
|
|
4549
|
+
? undefined
|
|
4550
|
+
: {
|
|
4551
|
+
[overrideKey]: undefined,
|
|
4552
|
+
...oldOverrides
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
: undefined
|
|
4556
|
+
}
|
|
4557
|
+
: {}),
|
|
4558
|
+
...(editablePkgJson.content.dependencies
|
|
4559
|
+
? {
|
|
4560
|
+
dependencies: editablePkgJson.content.dependencies
|
|
4561
|
+
}
|
|
4562
|
+
: undefined),
|
|
4563
|
+
...(editablePkgJson.content.optionalDependencies
|
|
4564
|
+
? {
|
|
4565
|
+
optionalDependencies:
|
|
4566
|
+
editablePkgJson.content.optionalDependencies
|
|
4567
|
+
}
|
|
4568
|
+
: undefined),
|
|
4569
|
+
...(editablePkgJson.content.peerDependencies
|
|
4570
|
+
? {
|
|
4571
|
+
peerDependencies: editablePkgJson.content.peerDependencies
|
|
4572
|
+
}
|
|
4573
|
+
: undefined)
|
|
4569
4574
|
}
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
spinner?.error(`Reverting ${toSpec}`, error)
|
|
4575
|
+
if (!installedSpecs.has(newSpecKey)) {
|
|
4576
|
+
installedSpecs.add(newSpecKey)
|
|
4577
|
+
spinner?.info(`Installing ${newSpec}${workspaceDetails}`)
|
|
4574
4578
|
}
|
|
4575
|
-
if (
|
|
4576
|
-
editablePkgJson.update(revertData)
|
|
4579
|
+
if (isCi) {
|
|
4577
4580
|
// eslint-disable-next-line no-await-in-loop
|
|
4578
|
-
await
|
|
4581
|
+
await gitCheckoutBaseBranchIfAvailable(baseBranch, cwd)
|
|
4579
4582
|
}
|
|
4580
|
-
|
|
4583
|
+
let error
|
|
4584
|
+
let errored = false
|
|
4585
|
+
let installed = false
|
|
4586
|
+
let saved = false
|
|
4587
|
+
try {
|
|
4588
|
+
editablePkgJson.update(updateData)
|
|
4589
|
+
shadowNpmInject.updatePackageJsonFromNode(
|
|
4590
|
+
editablePkgJson,
|
|
4591
|
+
actualTree,
|
|
4592
|
+
node,
|
|
4593
|
+
newVersion,
|
|
4594
|
+
rangeStyle
|
|
4595
|
+
)
|
|
4596
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4597
|
+
if (!(await editablePkgJson.save())) {
|
|
4598
|
+
continue
|
|
4599
|
+
}
|
|
4600
|
+
saved = true
|
|
4581
4601
|
// eslint-disable-next-line no-await-in-loop
|
|
4582
4602
|
actualTree = await install(pkgEnvDetails, {
|
|
4583
4603
|
spinner
|
|
4584
4604
|
})
|
|
4605
|
+
installed = true
|
|
4606
|
+
if (test) {
|
|
4607
|
+
if (!testedSpecs.has(newSpecKey)) {
|
|
4608
|
+
testedSpecs.add(newSpecKey)
|
|
4609
|
+
spinner?.info(`Testing ${newSpec}${workspaceDetails}`)
|
|
4610
|
+
}
|
|
4611
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4612
|
+
await npm.runScript(testScript, [], {
|
|
4613
|
+
spinner,
|
|
4614
|
+
stdio: 'ignore'
|
|
4615
|
+
})
|
|
4616
|
+
}
|
|
4617
|
+
if (!fixedSpecs.has(newSpecKey)) {
|
|
4618
|
+
fixedSpecs.add(newSpecKey)
|
|
4619
|
+
spinner?.successAndStop(`Fixed ${name}${workspaceDetails}`)
|
|
4620
|
+
spinner?.start()
|
|
4621
|
+
}
|
|
4622
|
+
} catch (e) {
|
|
4623
|
+
error = e
|
|
4624
|
+
errored = true
|
|
4625
|
+
}
|
|
4626
|
+
if (!errored && shouldOpenPr) {
|
|
4627
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4628
|
+
await gitCreateAndPushBranchIfNeeded(
|
|
4629
|
+
branch,
|
|
4630
|
+
getSocketCommitMessage(oldPurl, newVersion, workspaceName),
|
|
4631
|
+
cwd
|
|
4632
|
+
)
|
|
4633
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4634
|
+
const prResponse = await openGitHubPullRequest(
|
|
4635
|
+
owner,
|
|
4636
|
+
repo,
|
|
4637
|
+
baseBranch,
|
|
4638
|
+
branch,
|
|
4639
|
+
oldPurl,
|
|
4640
|
+
newVersion,
|
|
4641
|
+
{
|
|
4642
|
+
cwd,
|
|
4643
|
+
workspaceName
|
|
4644
|
+
}
|
|
4645
|
+
)
|
|
4646
|
+
if (prResponse && autoMerge) {
|
|
4647
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4648
|
+
await enableAutoMerge(prResponse.data)
|
|
4649
|
+
}
|
|
4585
4650
|
}
|
|
4586
|
-
if (errored) {
|
|
4587
|
-
|
|
4651
|
+
if (errored || isCi) {
|
|
4652
|
+
if (errored) {
|
|
4653
|
+
if (!revertedSpecs.has(newSpecKey)) {
|
|
4654
|
+
revertedSpecs.add(newSpecKey)
|
|
4655
|
+
spinner?.error(`Reverting ${newSpec}${workspaceDetails}`, error)
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
if (isRepo) {
|
|
4659
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4660
|
+
await gitHardReset(cwd)
|
|
4661
|
+
}
|
|
4662
|
+
if (saved) {
|
|
4663
|
+
editablePkgJson.update(revertData)
|
|
4664
|
+
if (!isRepo) {
|
|
4665
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4666
|
+
await editablePkgJson.save()
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
if (isRepo) {
|
|
4670
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4671
|
+
actualTree = await getActualTree(cwd)
|
|
4672
|
+
} else if (installed) {
|
|
4673
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4674
|
+
actualTree = await install(pkgEnvDetails, {
|
|
4675
|
+
spinner
|
|
4676
|
+
})
|
|
4677
|
+
}
|
|
4678
|
+
if (errored) {
|
|
4679
|
+
if (!failedSpecs.has(newSpecKey)) {
|
|
4680
|
+
failedSpecs.add(newSpecKey)
|
|
4681
|
+
spinner?.failAndStop(
|
|
4682
|
+
`Update failed for ${oldSpec}${workspaceDetails}`
|
|
4683
|
+
)
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4588
4686
|
}
|
|
4589
4687
|
}
|
|
4590
4688
|
}
|
|
@@ -4593,6 +4691,29 @@ async function pnpmFix(
|
|
|
4593
4691
|
spinner?.stop()
|
|
4594
4692
|
}
|
|
4595
4693
|
|
|
4694
|
+
const CMD_NAME$1 = 'socket fix'
|
|
4695
|
+
function assignDefaultFixOptions(options) {
|
|
4696
|
+
if (options.autoPilot === undefined) {
|
|
4697
|
+
options.autoPilot = false
|
|
4698
|
+
}
|
|
4699
|
+
if (options.autoMerge === undefined) {
|
|
4700
|
+
options.autoMerge = !!options.autoPilot
|
|
4701
|
+
}
|
|
4702
|
+
if (options.cwd === undefined) {
|
|
4703
|
+
options.cwd = process.cwd()
|
|
4704
|
+
}
|
|
4705
|
+
if (options.rangeStyle === undefined) {
|
|
4706
|
+
options.rangeStyle = 'preserve'
|
|
4707
|
+
}
|
|
4708
|
+
if (options.test === undefined) {
|
|
4709
|
+
options.test = !!options.autoPilot || !!options.testScript
|
|
4710
|
+
}
|
|
4711
|
+
if (options.testScript === undefined) {
|
|
4712
|
+
options.testScript = 'test'
|
|
4713
|
+
}
|
|
4714
|
+
return options
|
|
4715
|
+
}
|
|
4716
|
+
|
|
4596
4717
|
const {
|
|
4597
4718
|
BINARY_LOCK_EXT,
|
|
4598
4719
|
BUN: BUN$5,
|
|
@@ -4601,7 +4722,7 @@ const {
|
|
|
4601
4722
|
NPM: NPM$b,
|
|
4602
4723
|
NPM_BUGGY_OVERRIDES_PATCHED_VERSION: NPM_BUGGY_OVERRIDES_PATCHED_VERSION$1,
|
|
4603
4724
|
PACKAGE_JSON,
|
|
4604
|
-
PNPM: PNPM$
|
|
4725
|
+
PNPM: PNPM$7,
|
|
4605
4726
|
VLT: VLT$5,
|
|
4606
4727
|
YARN,
|
|
4607
4728
|
YARN_BERRY: YARN_BERRY$5,
|
|
@@ -4610,7 +4731,7 @@ const {
|
|
|
4610
4731
|
const AGENTS = new Set([
|
|
4611
4732
|
BUN$5,
|
|
4612
4733
|
NPM$b,
|
|
4613
|
-
PNPM$
|
|
4734
|
+
PNPM$7,
|
|
4614
4735
|
YARN_BERRY$5,
|
|
4615
4736
|
YARN_CLASSIC$6,
|
|
4616
4737
|
VLT$5
|
|
@@ -4618,7 +4739,7 @@ const AGENTS = new Set([
|
|
|
4618
4739
|
const binByAgent = new Map([
|
|
4619
4740
|
[BUN$5, BUN$5],
|
|
4620
4741
|
[NPM$b, NPM$b],
|
|
4621
|
-
[PNPM$
|
|
4742
|
+
[PNPM$7, PNPM$7],
|
|
4622
4743
|
[YARN_BERRY$5, YARN],
|
|
4623
4744
|
[YARN_CLASSIC$6, YARN],
|
|
4624
4745
|
[VLT$5, VLT$5]
|
|
@@ -4626,7 +4747,7 @@ const binByAgent = new Map([
|
|
|
4626
4747
|
async function getAgentExecPath(agent) {
|
|
4627
4748
|
const binName = binByAgent.get(agent)
|
|
4628
4749
|
return (
|
|
4629
|
-
(await vendor.libExports$
|
|
4750
|
+
(await vendor.libExports$2(binName, {
|
|
4630
4751
|
nothrow: true
|
|
4631
4752
|
})) ?? binName
|
|
4632
4753
|
)
|
|
@@ -4660,8 +4781,8 @@ const LOCKS = {
|
|
|
4660
4781
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson
|
|
4661
4782
|
'npm-shrinkwrap.json': NPM$b,
|
|
4662
4783
|
'package-lock.json': NPM$b,
|
|
4663
|
-
'pnpm-lock.yaml': PNPM$
|
|
4664
|
-
'pnpm-lock.yml': PNPM$
|
|
4784
|
+
'pnpm-lock.yaml': PNPM$7,
|
|
4785
|
+
'pnpm-lock.yml': PNPM$7,
|
|
4665
4786
|
[`yarn${LOCK_EXT$1}`]: YARN_CLASSIC$6,
|
|
4666
4787
|
'vlt-lock.json': VLT$5,
|
|
4667
4788
|
// Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
|
|
@@ -4708,7 +4829,7 @@ const readLockFileByAgent = (() => {
|
|
|
4708
4829
|
})
|
|
4709
4830
|
],
|
|
4710
4831
|
[NPM$b, defaultReader],
|
|
4711
|
-
[PNPM$
|
|
4832
|
+
[PNPM$7, defaultReader],
|
|
4712
4833
|
[VLT$5, defaultReader],
|
|
4713
4834
|
[YARN_BERRY$5, defaultReader],
|
|
4714
4835
|
[YARN_CLASSIC$6, defaultReader]
|
|
@@ -4732,7 +4853,7 @@ async function detectPackageEnvironment({
|
|
|
4732
4853
|
cwd
|
|
4733
4854
|
})
|
|
4734
4855
|
const pkgPath =
|
|
4735
|
-
pkgJsonPath &&
|
|
4856
|
+
pkgJsonPath && fs$1.existsSync(pkgJsonPath)
|
|
4736
4857
|
? path$1.dirname(pkgJsonPath)
|
|
4737
4858
|
: undefined
|
|
4738
4859
|
const editablePkgJson = pkgPath
|
|
@@ -4860,6 +4981,7 @@ async function detectPackageEnvironment({
|
|
|
4860
4981
|
agentExecPath,
|
|
4861
4982
|
agentSupported,
|
|
4862
4983
|
agentVersion,
|
|
4984
|
+
editablePkgJson,
|
|
4863
4985
|
features: {
|
|
4864
4986
|
npmBuggyOverrides
|
|
4865
4987
|
},
|
|
@@ -4869,7 +4991,6 @@ async function detectPackageEnvironment({
|
|
|
4869
4991
|
nodeSupported,
|
|
4870
4992
|
nodeVersion,
|
|
4871
4993
|
npmExecPath,
|
|
4872
|
-
pkgJson: editablePkgJson,
|
|
4873
4994
|
pkgPath,
|
|
4874
4995
|
pkgRequirements: {
|
|
4875
4996
|
agent: pkgAgentRange ?? `>=${pkgMinAgentVersion}`,
|
|
@@ -4993,15 +5114,14 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
|
|
|
4993
5114
|
return details
|
|
4994
5115
|
}
|
|
4995
5116
|
|
|
4996
|
-
const { NPM: NPM$a, PNPM: PNPM$
|
|
4997
|
-
const CMD_NAME$2 = 'socket fix'
|
|
5117
|
+
const { NPM: NPM$a, PNPM: PNPM$6 } = constants
|
|
4998
5118
|
async function runFix(options_) {
|
|
4999
|
-
const options =
|
|
5119
|
+
const options = assignDefaultFixOptions({
|
|
5000
5120
|
__proto__: null,
|
|
5001
5121
|
...options_
|
|
5002
5122
|
})
|
|
5003
5123
|
const pkgEnvDetails = await detectAndValidatePackageEnvironment(options.cwd, {
|
|
5004
|
-
cmdName: CMD_NAME$
|
|
5124
|
+
cmdName: CMD_NAME$1,
|
|
5005
5125
|
logger: logger.logger
|
|
5006
5126
|
})
|
|
5007
5127
|
if (!pkgEnvDetails) {
|
|
@@ -5011,13 +5131,13 @@ async function runFix(options_) {
|
|
|
5011
5131
|
const { agent } = pkgEnvDetails
|
|
5012
5132
|
if (agent === NPM$a) {
|
|
5013
5133
|
await npmFix(pkgEnvDetails, options)
|
|
5014
|
-
} else if (agent === PNPM$
|
|
5134
|
+
} else if (agent === PNPM$6) {
|
|
5015
5135
|
await pnpmFix(pkgEnvDetails, options)
|
|
5016
5136
|
}
|
|
5017
5137
|
}
|
|
5018
5138
|
|
|
5019
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
5020
|
-
const config$
|
|
5139
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x } = constants
|
|
5140
|
+
const config$A = {
|
|
5021
5141
|
commandName: 'fix',
|
|
5022
5142
|
description: 'Fix "fixable" Socket alerts',
|
|
5023
5143
|
hidden: true,
|
|
@@ -5033,10 +5153,17 @@ const config$z = {
|
|
|
5033
5153
|
default: false,
|
|
5034
5154
|
description: `Enable auto-merge for pull requests that Socket opens.\n See ${vendor.terminalLinkExports('GitHub documentation', 'https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository')} for managing auto-merge for pull requests in your repository.`
|
|
5035
5155
|
},
|
|
5156
|
+
purl: {
|
|
5157
|
+
type: 'string',
|
|
5158
|
+
default: [],
|
|
5159
|
+
description: `User provided PURL to fix`,
|
|
5160
|
+
isMultiple: true,
|
|
5161
|
+
shortFlag: 'p'
|
|
5162
|
+
},
|
|
5036
5163
|
rangeStyle: {
|
|
5037
5164
|
type: 'string',
|
|
5038
5165
|
default: 'preserve',
|
|
5039
|
-
description: vendor.
|
|
5166
|
+
description: vendor.html`
|
|
5040
5167
|
Define how updated dependency versions should be written in package.json.
|
|
5041
5168
|
Available styles:
|
|
5042
5169
|
* caret - Use ^ range for compatible updates (e.g. ^1.2.3)
|
|
@@ -5067,14 +5194,14 @@ const config$z = {
|
|
|
5067
5194
|
`
|
|
5068
5195
|
}
|
|
5069
5196
|
const cmdFix = {
|
|
5070
|
-
description: config$
|
|
5071
|
-
hidden: config$
|
|
5072
|
-
run: run$
|
|
5197
|
+
description: config$A.description,
|
|
5198
|
+
hidden: config$A.hidden,
|
|
5199
|
+
run: run$A
|
|
5073
5200
|
}
|
|
5074
|
-
async function run$
|
|
5201
|
+
async function run$A(argv, importMeta, { parentName }) {
|
|
5075
5202
|
const cli = meowOrExit({
|
|
5076
5203
|
argv,
|
|
5077
|
-
config: config$
|
|
5204
|
+
config: config$A,
|
|
5078
5205
|
importMeta,
|
|
5079
5206
|
parentName
|
|
5080
5207
|
})
|
|
@@ -5088,7 +5215,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
5088
5215
|
return
|
|
5089
5216
|
}
|
|
5090
5217
|
if (cli.flags['dryRun']) {
|
|
5091
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
5218
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$x)
|
|
5092
5219
|
return
|
|
5093
5220
|
}
|
|
5094
5221
|
|
|
@@ -5097,6 +5224,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
5097
5224
|
await runFix({
|
|
5098
5225
|
autoMerge: Boolean(cli.flags['autoMerge']),
|
|
5099
5226
|
autoPilot: Boolean(cli.flags['autoPilot']),
|
|
5227
|
+
purls: Array.isArray(cli.flags['purl']) ? cli.flags['purl'] : [],
|
|
5100
5228
|
spinner,
|
|
5101
5229
|
rangeStyle: cli.flags['rangeStyle'] ?? undefined,
|
|
5102
5230
|
test: Boolean(cli.flags['test']),
|
|
@@ -5197,7 +5325,7 @@ function outputPackageInfo(
|
|
|
5197
5325
|
return
|
|
5198
5326
|
}
|
|
5199
5327
|
if (outputKind === 'markdown') {
|
|
5200
|
-
logger.logger.log(vendor.
|
|
5328
|
+
logger.logger.log(vendor.html`
|
|
5201
5329
|
# Package report for ${pkgName}
|
|
5202
5330
|
|
|
5203
5331
|
Package report card:
|
|
@@ -5290,11 +5418,12 @@ async function handlePackageInfo({
|
|
|
5290
5418
|
}
|
|
5291
5419
|
}
|
|
5292
5420
|
|
|
5293
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
5294
|
-
const config$
|
|
5421
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
|
|
5422
|
+
const config$z = {
|
|
5295
5423
|
commandName: 'info',
|
|
5296
5424
|
description: 'Look up info regarding a package',
|
|
5297
|
-
hidden:
|
|
5425
|
+
hidden: true,
|
|
5426
|
+
// Deprecated
|
|
5298
5427
|
flags: {
|
|
5299
5428
|
...commonFlags,
|
|
5300
5429
|
...outputFlags,
|
|
@@ -5315,14 +5444,14 @@ const config$y = {
|
|
|
5315
5444
|
`
|
|
5316
5445
|
}
|
|
5317
5446
|
const cmdInfo = {
|
|
5318
|
-
description: config$
|
|
5319
|
-
hidden: config$
|
|
5320
|
-
run: run$
|
|
5447
|
+
description: config$z.description,
|
|
5448
|
+
hidden: config$z.hidden,
|
|
5449
|
+
run: run$z
|
|
5321
5450
|
}
|
|
5322
|
-
async function run$
|
|
5451
|
+
async function run$z(argv, importMeta, { parentName }) {
|
|
5323
5452
|
const cli = meowOrExit({
|
|
5324
5453
|
argv,
|
|
5325
|
-
config: config$
|
|
5454
|
+
config: config$z,
|
|
5326
5455
|
importMeta,
|
|
5327
5456
|
parentName
|
|
5328
5457
|
})
|
|
@@ -5360,11 +5489,11 @@ async function run$y(argv, importMeta, { parentName }) {
|
|
|
5360
5489
|
const pkgVersion =
|
|
5361
5490
|
versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1)
|
|
5362
5491
|
if (cli.flags['dryRun']) {
|
|
5363
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
5492
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$w)
|
|
5364
5493
|
return
|
|
5365
5494
|
}
|
|
5366
5495
|
await handlePackageInfo({
|
|
5367
|
-
commandName: `${parentName} ${config$
|
|
5496
|
+
commandName: `${parentName} ${config$z.commandName}`,
|
|
5368
5497
|
includeAllIssues: Boolean(all),
|
|
5369
5498
|
outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
|
|
5370
5499
|
pkgName,
|
|
@@ -5440,7 +5569,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
5440
5569
|
logger.logger.success(
|
|
5441
5570
|
`API credentials ${previousPersistedToken === apiToken ? 'refreshed' : previousPersistedToken ? 'updated' : 'set'}`
|
|
5442
5571
|
)
|
|
5443
|
-
if (
|
|
5572
|
+
if (shadowNpmInject.isReadOnlyConfig()) {
|
|
5444
5573
|
logger.logger.log('')
|
|
5445
5574
|
logger.logger.warn(
|
|
5446
5575
|
'Note: config is in read-only mode, at least one key was overridden through flag/env, so the login was not persisted!'
|
|
@@ -5451,8 +5580,8 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
5451
5580
|
}
|
|
5452
5581
|
}
|
|
5453
5582
|
|
|
5454
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
5455
|
-
const config$
|
|
5583
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v } = constants
|
|
5584
|
+
const config$y = {
|
|
5456
5585
|
commandName: 'login',
|
|
5457
5586
|
description: 'Socket API login',
|
|
5458
5587
|
hidden: false,
|
|
@@ -5485,21 +5614,21 @@ const config$x = {
|
|
|
5485
5614
|
`
|
|
5486
5615
|
}
|
|
5487
5616
|
const cmdLogin = {
|
|
5488
|
-
description: config$
|
|
5489
|
-
hidden: config$
|
|
5490
|
-
run: run$
|
|
5617
|
+
description: config$y.description,
|
|
5618
|
+
hidden: config$y.hidden,
|
|
5619
|
+
run: run$y
|
|
5491
5620
|
}
|
|
5492
|
-
async function run$
|
|
5621
|
+
async function run$y(argv, importMeta, { parentName }) {
|
|
5493
5622
|
const cli = meowOrExit({
|
|
5494
5623
|
argv,
|
|
5495
|
-
config: config$
|
|
5624
|
+
config: config$y,
|
|
5496
5625
|
importMeta,
|
|
5497
5626
|
parentName
|
|
5498
5627
|
})
|
|
5499
5628
|
const apiBaseUrl = cli.flags['apiBaseUrl']
|
|
5500
5629
|
const apiProxy = cli.flags['apiProxy']
|
|
5501
5630
|
if (cli.flags['dryRun']) {
|
|
5502
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
5631
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$v)
|
|
5503
5632
|
return
|
|
5504
5633
|
}
|
|
5505
5634
|
if (!isInteractive()) {
|
|
@@ -5521,7 +5650,7 @@ function attemptLogout() {
|
|
|
5521
5650
|
try {
|
|
5522
5651
|
applyLogout()
|
|
5523
5652
|
logger.logger.success('Successfully logged out')
|
|
5524
|
-
if (
|
|
5653
|
+
if (shadowNpmInject.isReadOnlyConfig()) {
|
|
5525
5654
|
logger.logger.log('')
|
|
5526
5655
|
logger.logger.warn(
|
|
5527
5656
|
'Note: config is in read-only mode, at least one key was overridden through flag/env, so the logout was not persisted!'
|
|
@@ -5532,8 +5661,8 @@ function attemptLogout() {
|
|
|
5532
5661
|
}
|
|
5533
5662
|
}
|
|
5534
5663
|
|
|
5535
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
5536
|
-
const config$
|
|
5664
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u } = constants
|
|
5665
|
+
const config$x = {
|
|
5537
5666
|
commandName: 'logout',
|
|
5538
5667
|
description: 'Socket API logout',
|
|
5539
5668
|
hidden: false,
|
|
@@ -5548,42 +5677,60 @@ const config$w = {
|
|
|
5548
5677
|
`
|
|
5549
5678
|
}
|
|
5550
5679
|
const cmdLogout = {
|
|
5551
|
-
description: config$
|
|
5552
|
-
hidden: config$
|
|
5553
|
-
run: run$
|
|
5680
|
+
description: config$x.description,
|
|
5681
|
+
hidden: config$x.hidden,
|
|
5682
|
+
run: run$x
|
|
5554
5683
|
}
|
|
5555
|
-
async function run$
|
|
5684
|
+
async function run$x(argv, importMeta, { parentName }) {
|
|
5556
5685
|
const cli = meowOrExit({
|
|
5557
5686
|
argv,
|
|
5558
|
-
config: config$
|
|
5687
|
+
config: config$x,
|
|
5559
5688
|
importMeta,
|
|
5560
5689
|
parentName
|
|
5561
5690
|
})
|
|
5562
5691
|
if (cli.flags['dryRun']) {
|
|
5563
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
5692
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$u)
|
|
5564
5693
|
return
|
|
5565
5694
|
}
|
|
5566
5695
|
attemptLogout()
|
|
5567
5696
|
}
|
|
5568
5697
|
|
|
5569
|
-
async function convertGradleToMaven(target, bin,
|
|
5570
|
-
// Lazily access constants.spinner.
|
|
5571
|
-
const { spinner } = constants
|
|
5572
|
-
const rbin = path$1.resolve(bin)
|
|
5573
|
-
const rtarget = path$1.resolve(target)
|
|
5698
|
+
async function convertGradleToMaven(target, bin, cwd, verbose, gradleOpts) {
|
|
5574
5699
|
if (verbose) {
|
|
5575
|
-
logger.logger.
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5700
|
+
logger.logger.log('[VERBOSE] Resolving:', [cwd, bin])
|
|
5701
|
+
}
|
|
5702
|
+
const rbin = path$1.resolve(cwd, bin)
|
|
5703
|
+
if (verbose) {
|
|
5704
|
+
logger.logger.log('[VERBOSE] Resolving:', [cwd, target])
|
|
5705
|
+
}
|
|
5706
|
+
const rtarget = path$1.resolve(cwd, target)
|
|
5707
|
+
const binExists = fs$1.existsSync(rbin)
|
|
5708
|
+
const targetExists = fs$1.existsSync(rtarget)
|
|
5709
|
+
logger.logger.group('gradle2maven:')
|
|
5710
|
+
if (verbose || debug.isDebug()) {
|
|
5711
|
+
logger.logger.log(
|
|
5712
|
+
`[VERBOSE] - Absolute bin path: \`${rbin}\` (${binExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`
|
|
5713
|
+
)
|
|
5714
|
+
logger.logger.log(
|
|
5715
|
+
`[VERBOSE] - Absolute target path: \`${rtarget}\` (${targetExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`
|
|
5716
|
+
)
|
|
5579
5717
|
} else {
|
|
5580
|
-
logger.logger.
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5718
|
+
logger.logger.log(`- executing: \`${rbin}\``)
|
|
5719
|
+
if (!binExists) {
|
|
5720
|
+
logger.logger.warn(
|
|
5721
|
+
'Warning: It appears the executable could not be found at this location. An error might be printed later because of that.'
|
|
5722
|
+
)
|
|
5723
|
+
}
|
|
5724
|
+
logger.logger.log(`- src dir: \`${rtarget}\``)
|
|
5725
|
+
if (!targetExists) {
|
|
5726
|
+
logger.logger.warn(
|
|
5727
|
+
'Warning: It appears the src dir could not be found at this location. An error might be printed later because of that.'
|
|
5728
|
+
)
|
|
5729
|
+
}
|
|
5584
5730
|
}
|
|
5731
|
+
logger.logger.groupEnd()
|
|
5585
5732
|
try {
|
|
5586
|
-
// Run
|
|
5733
|
+
// Run gradlew with the init script we provide which should yield zero or more
|
|
5587
5734
|
// pom files. We have to figure out where to store those pom files such that
|
|
5588
5735
|
// we can upload them and predict them through the GitHub API. We could do a
|
|
5589
5736
|
// .socket folder. We could do a socket.pom.gz with all the poms, although
|
|
@@ -5593,26 +5740,23 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
|
|
|
5593
5740
|
const initLocation = path$1.join(constants.rootDistPath, 'init.gradle')
|
|
5594
5741
|
const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom']
|
|
5595
5742
|
if (verbose) {
|
|
5596
|
-
logger.logger.log('[VERBOSE] Executing:', bin, commandArgs)
|
|
5743
|
+
logger.logger.log('[VERBOSE] Executing:', [bin], ', args:', commandArgs)
|
|
5597
5744
|
}
|
|
5598
|
-
|
|
5599
|
-
`Converting gradle to maven from \`${bin}\` on \`${target}
|
|
5745
|
+
logger.logger.log(
|
|
5746
|
+
`Converting gradle to maven from \`${bin}\` on \`${target}\` ...`
|
|
5600
5747
|
)
|
|
5601
|
-
const output = await
|
|
5602
|
-
cwd: target || '.'
|
|
5603
|
-
})
|
|
5604
|
-
spinner.stop()
|
|
5748
|
+
const output = await execGradleWithSpinner(rbin, commandArgs, rtarget, cwd)
|
|
5605
5749
|
if (verbose) {
|
|
5606
5750
|
logger.logger.group('[VERBOSE] gradle stdout:')
|
|
5607
5751
|
logger.logger.log(output)
|
|
5608
5752
|
logger.logger.groupEnd()
|
|
5609
5753
|
}
|
|
5610
|
-
if (output.
|
|
5754
|
+
if (output.code !== 0) {
|
|
5611
5755
|
process.exitCode = 1
|
|
5612
|
-
logger.logger.fail(
|
|
5756
|
+
logger.logger.fail(`Gradle exited with exit code ${output.code}`)
|
|
5613
5757
|
// (In verbose mode, stderr was printed above, no need to repeat it)
|
|
5614
5758
|
if (!verbose) {
|
|
5615
|
-
logger.logger.group('
|
|
5759
|
+
logger.logger.group('stderr:')
|
|
5616
5760
|
logger.logger.error(output.stderr)
|
|
5617
5761
|
logger.logger.groupEnd()
|
|
5618
5762
|
}
|
|
@@ -5624,41 +5768,15 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
|
|
|
5624
5768
|
logger.logger.log('- ', fn)
|
|
5625
5769
|
return fn
|
|
5626
5770
|
})
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
// 'There were no errors from sbt but could not find the location of resulting .pom file either'
|
|
5632
|
-
// )
|
|
5633
|
-
// // eslint-disable-next-line n/no-process-exit
|
|
5634
|
-
// process.exit(1)
|
|
5635
|
-
// }
|
|
5636
|
-
//
|
|
5637
|
-
// // Move the pom file to ...? initial cwd? loc will be an absolute path, or dump to stdout
|
|
5638
|
-
// if (out === '-') {
|
|
5639
|
-
// spinner.start('Result:\n```')
|
|
5640
|
-
// spinner.log(await safeReadFile(loc))
|
|
5641
|
-
// spinner.log('```')
|
|
5642
|
-
// spinner.successAndStop(`OK`)
|
|
5643
|
-
// } else {
|
|
5644
|
-
// spinner.start()
|
|
5645
|
-
// if (verbose) {
|
|
5646
|
-
// spinner.log(
|
|
5647
|
-
// `Moving manifest file from \`${loc.replace(/^\/home\/[^/]*?\//, '~/')}\` to \`${out}\``
|
|
5648
|
-
// )
|
|
5649
|
-
// } else {
|
|
5650
|
-
// spinner.log('Moving output pom file')
|
|
5651
|
-
// }
|
|
5652
|
-
// // TODO: do we prefer fs-extra? renaming can be gnarly on windows and fs-extra's version is better
|
|
5653
|
-
// await renamep(loc, out)
|
|
5654
|
-
// spinner.successAndStop(`OK. File should be available in \`${out}\``)
|
|
5655
|
-
// }
|
|
5771
|
+
logger.logger.log('')
|
|
5772
|
+
logger.logger.log(
|
|
5773
|
+
'Next step is to generate a Scan by running the `socket scan create` command on the same directory'
|
|
5774
|
+
)
|
|
5656
5775
|
} catch (e) {
|
|
5657
5776
|
process.exitCode = 1
|
|
5658
|
-
spinner.stop()
|
|
5659
5777
|
logger.logger.fail(
|
|
5660
|
-
'There was an unexpected error while
|
|
5661
|
-
(verbose ? '' : '
|
|
5778
|
+
'There was an unexpected error while generating manifests' +
|
|
5779
|
+
(verbose ? '' : ' (use --verbose for details)')
|
|
5662
5780
|
)
|
|
5663
5781
|
if (verbose) {
|
|
5664
5782
|
logger.logger.group('[VERBOSE] error:')
|
|
@@ -5667,9 +5785,39 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
|
|
|
5667
5785
|
}
|
|
5668
5786
|
}
|
|
5669
5787
|
}
|
|
5788
|
+
async function execGradleWithSpinner(bin, commandArgs, target, cwd) {
|
|
5789
|
+
// Lazily access constants.spinner.
|
|
5790
|
+
const { spinner } = constants
|
|
5791
|
+
let pass = false
|
|
5792
|
+
try {
|
|
5793
|
+
spinner.start(
|
|
5794
|
+
`Running gradlew... (this can take a while, it depends on how long gradlew has to run)`
|
|
5795
|
+
)
|
|
5796
|
+
const output = await spawn.spawn(bin, commandArgs, {
|
|
5797
|
+
// We can pipe the output through to have the user see the result
|
|
5798
|
+
// of running gradlew, but then we can't (easily) gather the output
|
|
5799
|
+
// to discover the generated files... probably a flag we should allow?
|
|
5800
|
+
// stdio: isDebug() ? 'inherit' : undefined,
|
|
5801
|
+
cwd: target || cwd
|
|
5802
|
+
})
|
|
5803
|
+
pass = true
|
|
5804
|
+
const { code, stderr, stdout } = output
|
|
5805
|
+
return {
|
|
5806
|
+
code,
|
|
5807
|
+
stdout,
|
|
5808
|
+
stderr
|
|
5809
|
+
}
|
|
5810
|
+
} finally {
|
|
5811
|
+
if (pass) {
|
|
5812
|
+
spinner.successAndStop('Completed gradlew execution')
|
|
5813
|
+
} else {
|
|
5814
|
+
spinner.failAndStop('There was an error while trying to run gradlew.')
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5670
5818
|
|
|
5671
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
5672
|
-
const config$
|
|
5819
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$t } = constants
|
|
5820
|
+
const config$w = {
|
|
5673
5821
|
commandName: 'gradle',
|
|
5674
5822
|
description:
|
|
5675
5823
|
'[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Gradle/Java/Kotlin/etc project',
|
|
@@ -5690,16 +5838,6 @@ const config$v = {
|
|
|
5690
5838
|
description:
|
|
5691
5839
|
'Additional options to pass on to ./gradlew, see `./gradlew --help`'
|
|
5692
5840
|
},
|
|
5693
|
-
out: {
|
|
5694
|
-
type: 'string',
|
|
5695
|
-
default: './socket.pom.xml',
|
|
5696
|
-
description:
|
|
5697
|
-
'Path of output file; where to store the resulting manifest, see also --stdout'
|
|
5698
|
-
},
|
|
5699
|
-
stdout: {
|
|
5700
|
-
type: 'boolean',
|
|
5701
|
-
description: 'Print resulting pom.xml to stdout (supersedes --out)'
|
|
5702
|
-
},
|
|
5703
5841
|
task: {
|
|
5704
5842
|
type: 'string',
|
|
5705
5843
|
default: 'all',
|
|
@@ -5744,20 +5882,20 @@ const config$v = {
|
|
|
5744
5882
|
`
|
|
5745
5883
|
}
|
|
5746
5884
|
const cmdManifestGradle = {
|
|
5747
|
-
description: config$
|
|
5748
|
-
hidden: config$
|
|
5749
|
-
run: run$
|
|
5885
|
+
description: config$w.description,
|
|
5886
|
+
hidden: config$w.hidden,
|
|
5887
|
+
run: run$w
|
|
5750
5888
|
}
|
|
5751
|
-
async function run$
|
|
5889
|
+
async function run$w(argv, importMeta, { parentName }) {
|
|
5752
5890
|
const cli = meowOrExit({
|
|
5753
5891
|
argv,
|
|
5754
|
-
config: config$
|
|
5892
|
+
config: config$w,
|
|
5755
5893
|
importMeta,
|
|
5756
5894
|
parentName
|
|
5757
5895
|
})
|
|
5758
5896
|
const verbose = Boolean(cli.flags['verbose'])
|
|
5759
5897
|
if (verbose) {
|
|
5760
|
-
logger.logger.group('- ', parentName, config$
|
|
5898
|
+
logger.logger.group('- ', parentName, config$w.commandName, ':')
|
|
5761
5899
|
logger.logger.group('- flags:', cli.flags)
|
|
5762
5900
|
logger.logger.groupEnd()
|
|
5763
5901
|
logger.logger.log('- input:', cli.input)
|
|
@@ -5778,7 +5916,7 @@ async function run$v(argv, importMeta, { parentName }) {
|
|
|
5778
5916
|
},
|
|
5779
5917
|
{
|
|
5780
5918
|
nook: true,
|
|
5781
|
-
test: cli.input.length
|
|
5919
|
+
test: cli.input.length <= 1,
|
|
5782
5920
|
message: 'Can only accept one DIR (make sure to escape spaces!)',
|
|
5783
5921
|
pass: 'ok',
|
|
5784
5922
|
fail: 'received ' + cli.input.length
|
|
@@ -5787,24 +5925,12 @@ async function run$v(argv, importMeta, { parentName }) {
|
|
|
5787
5925
|
if (wasBadInput) {
|
|
5788
5926
|
return
|
|
5789
5927
|
}
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
bin = cli.flags['bin']
|
|
5793
|
-
} else {
|
|
5794
|
-
bin = path$1.join(target, 'gradlew')
|
|
5795
|
-
}
|
|
5796
|
-
let out = './socket.pom.xml'
|
|
5797
|
-
if (cli.flags['out']) {
|
|
5798
|
-
out = cli.flags['out']
|
|
5799
|
-
}
|
|
5800
|
-
if (cli.flags['stdout']) {
|
|
5801
|
-
out = '-'
|
|
5802
|
-
}
|
|
5928
|
+
const { bin = path$1.join(target, 'gradlew'), cwd = process.cwd() } =
|
|
5929
|
+
cli.flags
|
|
5803
5930
|
if (verbose) {
|
|
5804
5931
|
logger.logger.group()
|
|
5805
5932
|
logger.logger.log('- target:', target)
|
|
5806
5933
|
logger.logger.log('- gradle bin:', bin)
|
|
5807
|
-
logger.logger.log('- out:', out)
|
|
5808
5934
|
logger.logger.groupEnd()
|
|
5809
5935
|
}
|
|
5810
5936
|
let gradleOpts = []
|
|
@@ -5815,10 +5941,16 @@ async function run$v(argv, importMeta, { parentName }) {
|
|
|
5815
5941
|
.filter(Boolean)
|
|
5816
5942
|
}
|
|
5817
5943
|
if (cli.flags['dryRun']) {
|
|
5818
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
5944
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$t)
|
|
5819
5945
|
return
|
|
5820
5946
|
}
|
|
5821
|
-
await convertGradleToMaven(
|
|
5947
|
+
await convertGradleToMaven(
|
|
5948
|
+
target,
|
|
5949
|
+
String(bin),
|
|
5950
|
+
String(cwd),
|
|
5951
|
+
verbose,
|
|
5952
|
+
gradleOpts
|
|
5953
|
+
)
|
|
5822
5954
|
}
|
|
5823
5955
|
|
|
5824
5956
|
async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
|
|
@@ -5924,8 +6056,8 @@ async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
|
|
|
5924
6056
|
}
|
|
5925
6057
|
}
|
|
5926
6058
|
|
|
5927
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
5928
|
-
const config$
|
|
6059
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$s } = constants
|
|
6060
|
+
const config$v = {
|
|
5929
6061
|
commandName: 'scala',
|
|
5930
6062
|
description:
|
|
5931
6063
|
"[beta] Generate a manifest file (`pom.xml`) from Scala's `build.sbt` file",
|
|
@@ -6000,20 +6132,20 @@ const config$u = {
|
|
|
6000
6132
|
`
|
|
6001
6133
|
}
|
|
6002
6134
|
const cmdManifestScala = {
|
|
6003
|
-
description: config$
|
|
6004
|
-
hidden: config$
|
|
6005
|
-
run: run$
|
|
6135
|
+
description: config$v.description,
|
|
6136
|
+
hidden: config$v.hidden,
|
|
6137
|
+
run: run$v
|
|
6006
6138
|
}
|
|
6007
|
-
async function run$
|
|
6139
|
+
async function run$v(argv, importMeta, { parentName }) {
|
|
6008
6140
|
const cli = meowOrExit({
|
|
6009
6141
|
argv,
|
|
6010
|
-
config: config$
|
|
6142
|
+
config: config$v,
|
|
6011
6143
|
importMeta,
|
|
6012
6144
|
parentName
|
|
6013
6145
|
})
|
|
6014
6146
|
const verbose = Boolean(cli.flags['verbose'])
|
|
6015
6147
|
if (verbose) {
|
|
6016
|
-
logger.logger.group('- ', parentName, config$
|
|
6148
|
+
logger.logger.group('- ', parentName, config$v.commandName, ':')
|
|
6017
6149
|
logger.logger.group('- flags:', cli.flags)
|
|
6018
6150
|
logger.logger.groupEnd()
|
|
6019
6151
|
logger.logger.log('- input:', cli.input)
|
|
@@ -6034,7 +6166,7 @@ async function run$u(argv, importMeta, { parentName }) {
|
|
|
6034
6166
|
},
|
|
6035
6167
|
{
|
|
6036
6168
|
nook: true,
|
|
6037
|
-
test: cli.input.length
|
|
6169
|
+
test: cli.input.length <= 1,
|
|
6038
6170
|
message: 'Can only accept one DIR (make sure to escape spaces!)',
|
|
6039
6171
|
pass: 'ok',
|
|
6040
6172
|
fail: 'received ' + cli.input.length
|
|
@@ -6069,14 +6201,14 @@ async function run$u(argv, importMeta, { parentName }) {
|
|
|
6069
6201
|
.filter(Boolean)
|
|
6070
6202
|
}
|
|
6071
6203
|
if (cli.flags['dryRun']) {
|
|
6072
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6204
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$s)
|
|
6073
6205
|
return
|
|
6074
6206
|
}
|
|
6075
6207
|
await convertSbtToMaven(target, bin, out, verbose, sbtOpts)
|
|
6076
6208
|
}
|
|
6077
6209
|
|
|
6078
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
6079
|
-
const config$
|
|
6210
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$r } = constants
|
|
6211
|
+
const config$u = {
|
|
6080
6212
|
commandName: 'auto',
|
|
6081
6213
|
description: 'Auto-detect build and attempt to generate manifest file',
|
|
6082
6214
|
hidden: false,
|
|
@@ -6106,21 +6238,21 @@ const config$t = {
|
|
|
6106
6238
|
`
|
|
6107
6239
|
}
|
|
6108
6240
|
const cmdManifestAuto = {
|
|
6109
|
-
description: config$
|
|
6110
|
-
hidden: config$
|
|
6111
|
-
run: run$
|
|
6241
|
+
description: config$u.description,
|
|
6242
|
+
hidden: config$u.hidden,
|
|
6243
|
+
run: run$u
|
|
6112
6244
|
}
|
|
6113
|
-
async function run$
|
|
6245
|
+
async function run$u(argv, importMeta, { parentName }) {
|
|
6114
6246
|
const cli = meowOrExit({
|
|
6115
6247
|
argv,
|
|
6116
|
-
config: config$
|
|
6248
|
+
config: config$u,
|
|
6117
6249
|
importMeta,
|
|
6118
6250
|
parentName
|
|
6119
6251
|
})
|
|
6120
6252
|
const verbose = !!cli.flags['verbose']
|
|
6121
6253
|
const cwd = cli.flags['cwd'] ?? process.cwd()
|
|
6122
6254
|
if (verbose) {
|
|
6123
|
-
logger.logger.group('- ', parentName, config$
|
|
6255
|
+
logger.logger.group('- ', parentName, config$u.commandName, ':')
|
|
6124
6256
|
logger.logger.group('- flags:', cli.flags)
|
|
6125
6257
|
logger.logger.groupEnd()
|
|
6126
6258
|
logger.logger.log('- input:', cli.input)
|
|
@@ -6132,7 +6264,7 @@ async function run$t(argv, importMeta, { parentName }) {
|
|
|
6132
6264
|
subArgs.push('--verbose')
|
|
6133
6265
|
}
|
|
6134
6266
|
const dir = cwd
|
|
6135
|
-
if (
|
|
6267
|
+
if (fs$1.existsSync(path$1.join(dir, 'build.sbt'))) {
|
|
6136
6268
|
logger.logger.log(
|
|
6137
6269
|
'Detected a Scala sbt build, running default Scala generator...'
|
|
6138
6270
|
)
|
|
@@ -6141,7 +6273,7 @@ async function run$t(argv, importMeta, { parentName }) {
|
|
|
6141
6273
|
}
|
|
6142
6274
|
subArgs.push(dir)
|
|
6143
6275
|
if (cli.flags['dryRun']) {
|
|
6144
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6276
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$r)
|
|
6145
6277
|
return
|
|
6146
6278
|
}
|
|
6147
6279
|
await cmdManifestScala.run(subArgs, importMeta, {
|
|
@@ -6149,7 +6281,7 @@ async function run$t(argv, importMeta, { parentName }) {
|
|
|
6149
6281
|
})
|
|
6150
6282
|
return
|
|
6151
6283
|
}
|
|
6152
|
-
if (
|
|
6284
|
+
if (fs$1.existsSync(path$1.join(dir, 'gradlew'))) {
|
|
6153
6285
|
logger.logger.log(
|
|
6154
6286
|
'Detected a gradle build, running default gradle generator...'
|
|
6155
6287
|
)
|
|
@@ -6158,7 +6290,7 @@ async function run$t(argv, importMeta, { parentName }) {
|
|
|
6158
6290
|
subArgs.push(cwd)
|
|
6159
6291
|
}
|
|
6160
6292
|
if (cli.flags['dryRun']) {
|
|
6161
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6293
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$r)
|
|
6162
6294
|
return
|
|
6163
6295
|
}
|
|
6164
6296
|
await cmdManifestGradle.run(subArgs, importMeta, {
|
|
@@ -6167,7 +6299,7 @@ async function run$t(argv, importMeta, { parentName }) {
|
|
|
6167
6299
|
return
|
|
6168
6300
|
}
|
|
6169
6301
|
if (cli.flags['dryRun']) {
|
|
6170
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6302
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$r)
|
|
6171
6303
|
return
|
|
6172
6304
|
}
|
|
6173
6305
|
|
|
@@ -6175,7 +6307,7 @@ async function run$t(argv, importMeta, { parentName }) {
|
|
|
6175
6307
|
vendor
|
|
6176
6308
|
.meow(
|
|
6177
6309
|
`
|
|
6178
|
-
$ ${parentName} ${config$
|
|
6310
|
+
$ ${parentName} ${config$u.commandName}
|
|
6179
6311
|
|
|
6180
6312
|
Unfortunately this script did not discover a supported language in the
|
|
6181
6313
|
current folder.
|
|
@@ -6189,21 +6321,21 @@ async function run$t(argv, importMeta, { parentName }) {
|
|
|
6189
6321
|
`,
|
|
6190
6322
|
{
|
|
6191
6323
|
argv: [],
|
|
6192
|
-
description: config$
|
|
6324
|
+
description: config$u.description,
|
|
6193
6325
|
importMeta
|
|
6194
6326
|
}
|
|
6195
6327
|
)
|
|
6196
6328
|
.showHelp()
|
|
6197
6329
|
}
|
|
6198
6330
|
|
|
6199
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
6331
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$q } = constants
|
|
6200
6332
|
|
|
6201
6333
|
// TODO: we may want to dedupe some pieces for all gradle languages. I think it
|
|
6202
6334
|
// makes sense to have separate commands for them and I think it makes
|
|
6203
6335
|
// sense for the help panels to note the requested language, rather than
|
|
6204
6336
|
// `socket manifest kotlin` to print help screens with `gradle` as the
|
|
6205
6337
|
// command. Room for improvement.
|
|
6206
|
-
const config$
|
|
6338
|
+
const config$t = {
|
|
6207
6339
|
commandName: 'kotlin',
|
|
6208
6340
|
description:
|
|
6209
6341
|
'[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Kotlin project',
|
|
@@ -6224,16 +6356,6 @@ const config$s = {
|
|
|
6224
6356
|
description:
|
|
6225
6357
|
'Additional options to pass on to ./gradlew, see `./gradlew --help`'
|
|
6226
6358
|
},
|
|
6227
|
-
out: {
|
|
6228
|
-
type: 'string',
|
|
6229
|
-
default: './socket.pom.xml',
|
|
6230
|
-
description:
|
|
6231
|
-
'Path of output file; where to store the resulting manifest, see also --stdout'
|
|
6232
|
-
},
|
|
6233
|
-
stdout: {
|
|
6234
|
-
type: 'boolean',
|
|
6235
|
-
description: 'Print resulting pom.xml to stdout (supersedes --out)'
|
|
6236
|
-
},
|
|
6237
6359
|
task: {
|
|
6238
6360
|
type: 'string',
|
|
6239
6361
|
default: 'all',
|
|
@@ -6278,20 +6400,20 @@ const config$s = {
|
|
|
6278
6400
|
`
|
|
6279
6401
|
}
|
|
6280
6402
|
const cmdManifestKotlin = {
|
|
6281
|
-
description: config$
|
|
6282
|
-
hidden: config$
|
|
6283
|
-
run: run$
|
|
6403
|
+
description: config$t.description,
|
|
6404
|
+
hidden: config$t.hidden,
|
|
6405
|
+
run: run$t
|
|
6284
6406
|
}
|
|
6285
|
-
async function run$
|
|
6407
|
+
async function run$t(argv, importMeta, { parentName }) {
|
|
6286
6408
|
const cli = meowOrExit({
|
|
6287
6409
|
argv,
|
|
6288
|
-
config: config$
|
|
6410
|
+
config: config$t,
|
|
6289
6411
|
importMeta,
|
|
6290
6412
|
parentName
|
|
6291
6413
|
})
|
|
6292
6414
|
const verbose = Boolean(cli.flags['verbose'])
|
|
6293
6415
|
if (verbose) {
|
|
6294
|
-
logger.logger.group('- ', parentName, config$
|
|
6416
|
+
logger.logger.group('- ', parentName, config$t.commandName, ':')
|
|
6295
6417
|
logger.logger.group('- flags:', cli.flags)
|
|
6296
6418
|
logger.logger.groupEnd()
|
|
6297
6419
|
logger.logger.log('- input:', cli.input)
|
|
@@ -6312,7 +6434,7 @@ async function run$s(argv, importMeta, { parentName }) {
|
|
|
6312
6434
|
},
|
|
6313
6435
|
{
|
|
6314
6436
|
nook: true,
|
|
6315
|
-
test: cli.input.length
|
|
6437
|
+
test: cli.input.length <= 1,
|
|
6316
6438
|
message: 'Can only accept one DIR (make sure to escape spaces!)',
|
|
6317
6439
|
pass: 'ok',
|
|
6318
6440
|
fail: 'received ' + cli.input.length
|
|
@@ -6321,24 +6443,12 @@ async function run$s(argv, importMeta, { parentName }) {
|
|
|
6321
6443
|
if (wasBadInput) {
|
|
6322
6444
|
return
|
|
6323
6445
|
}
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
bin = cli.flags['bin']
|
|
6327
|
-
} else {
|
|
6328
|
-
bin = path$1.join(target, 'gradlew')
|
|
6329
|
-
}
|
|
6330
|
-
let out = './socket.pom.xml'
|
|
6331
|
-
if (cli.flags['out']) {
|
|
6332
|
-
out = cli.flags['out']
|
|
6333
|
-
}
|
|
6334
|
-
if (cli.flags['stdout']) {
|
|
6335
|
-
out = '-'
|
|
6336
|
-
}
|
|
6446
|
+
const { bin = path$1.join(target, 'gradlew'), cwd = process.cwd() } =
|
|
6447
|
+
cli.flags
|
|
6337
6448
|
if (verbose) {
|
|
6338
6449
|
logger.logger.group()
|
|
6339
6450
|
logger.logger.log('- target:', target)
|
|
6340
6451
|
logger.logger.log('- gradle bin:', bin)
|
|
6341
|
-
logger.logger.log('- out:', out)
|
|
6342
6452
|
logger.logger.groupEnd()
|
|
6343
6453
|
}
|
|
6344
6454
|
let gradleOpts = []
|
|
@@ -6349,13 +6459,19 @@ async function run$s(argv, importMeta, { parentName }) {
|
|
|
6349
6459
|
.filter(Boolean)
|
|
6350
6460
|
}
|
|
6351
6461
|
if (cli.flags['dryRun']) {
|
|
6352
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6462
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$q)
|
|
6353
6463
|
return
|
|
6354
6464
|
}
|
|
6355
|
-
await convertGradleToMaven(
|
|
6465
|
+
await convertGradleToMaven(
|
|
6466
|
+
target,
|
|
6467
|
+
String(bin),
|
|
6468
|
+
String(cwd),
|
|
6469
|
+
verbose,
|
|
6470
|
+
gradleOpts
|
|
6471
|
+
)
|
|
6356
6472
|
}
|
|
6357
6473
|
|
|
6358
|
-
const config$
|
|
6474
|
+
const config$s = {
|
|
6359
6475
|
commandName: 'manifest',
|
|
6360
6476
|
description: 'Generate a dependency manifest for given file or dir',
|
|
6361
6477
|
hidden: false,
|
|
@@ -6364,11 +6480,11 @@ const config$r = {
|
|
|
6364
6480
|
}
|
|
6365
6481
|
}
|
|
6366
6482
|
const cmdManifest = {
|
|
6367
|
-
description: config$
|
|
6368
|
-
hidden: config$
|
|
6369
|
-
run: run$
|
|
6483
|
+
description: config$s.description,
|
|
6484
|
+
hidden: config$s.hidden,
|
|
6485
|
+
run: run$s
|
|
6370
6486
|
}
|
|
6371
|
-
async function run$
|
|
6487
|
+
async function run$s(argv, importMeta, { parentName }) {
|
|
6372
6488
|
await meowWithSubcommands(
|
|
6373
6489
|
{
|
|
6374
6490
|
auto: cmdManifestAuto,
|
|
@@ -6380,15 +6496,15 @@ async function run$r(argv, importMeta, { parentName }) {
|
|
|
6380
6496
|
argv,
|
|
6381
6497
|
aliases: {
|
|
6382
6498
|
yolo: {
|
|
6383
|
-
description: config$
|
|
6499
|
+
description: config$s.description,
|
|
6384
6500
|
hidden: true,
|
|
6385
6501
|
argv: ['auto']
|
|
6386
6502
|
}
|
|
6387
6503
|
},
|
|
6388
|
-
description: config$
|
|
6504
|
+
description: config$s.description,
|
|
6389
6505
|
importMeta,
|
|
6390
|
-
flags: config$
|
|
6391
|
-
name: `${parentName} ${config$
|
|
6506
|
+
flags: config$s.flags,
|
|
6507
|
+
name: `${parentName} ${config$s.commandName}`
|
|
6392
6508
|
}
|
|
6393
6509
|
)
|
|
6394
6510
|
}
|
|
@@ -6400,8 +6516,8 @@ async function wrapNpm(argv) {
|
|
|
6400
6516
|
await shadowBin(NPM$8, argv)
|
|
6401
6517
|
}
|
|
6402
6518
|
|
|
6403
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
6404
|
-
const config$
|
|
6519
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$p, NPM: NPM$7 } = constants
|
|
6520
|
+
const config$r = {
|
|
6405
6521
|
commandName: 'npm',
|
|
6406
6522
|
description: `${NPM$7} wrapper functionality`,
|
|
6407
6523
|
hidden: false,
|
|
@@ -6414,20 +6530,20 @@ const config$q = {
|
|
|
6414
6530
|
`
|
|
6415
6531
|
}
|
|
6416
6532
|
const cmdNpm = {
|
|
6417
|
-
description: config$
|
|
6418
|
-
hidden: config$
|
|
6419
|
-
run: run$
|
|
6533
|
+
description: config$r.description,
|
|
6534
|
+
hidden: config$r.hidden,
|
|
6535
|
+
run: run$r
|
|
6420
6536
|
}
|
|
6421
|
-
async function run$
|
|
6537
|
+
async function run$r(argv, importMeta, { parentName }) {
|
|
6422
6538
|
const cli = meowOrExit({
|
|
6423
6539
|
allowUnknownFlags: true,
|
|
6424
6540
|
argv,
|
|
6425
|
-
config: config$
|
|
6541
|
+
config: config$r,
|
|
6426
6542
|
importMeta,
|
|
6427
6543
|
parentName
|
|
6428
6544
|
})
|
|
6429
6545
|
if (cli.flags['dryRun']) {
|
|
6430
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6546
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$p)
|
|
6431
6547
|
return
|
|
6432
6548
|
}
|
|
6433
6549
|
await wrapNpm(argv)
|
|
@@ -6440,8 +6556,8 @@ async function wrapNpx(argv) {
|
|
|
6440
6556
|
await shadowBin(NPX$2, argv)
|
|
6441
6557
|
}
|
|
6442
6558
|
|
|
6443
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
6444
|
-
const config$
|
|
6559
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$o, NPX: NPX$1 } = constants
|
|
6560
|
+
const config$q = {
|
|
6445
6561
|
commandName: 'npx',
|
|
6446
6562
|
description: `${NPX$1} wrapper functionality`,
|
|
6447
6563
|
hidden: false,
|
|
@@ -6454,27 +6570,27 @@ const config$p = {
|
|
|
6454
6570
|
`
|
|
6455
6571
|
}
|
|
6456
6572
|
const cmdNpx = {
|
|
6457
|
-
description: config$
|
|
6458
|
-
hidden: config$
|
|
6459
|
-
run: run$
|
|
6573
|
+
description: config$q.description,
|
|
6574
|
+
hidden: config$q.hidden,
|
|
6575
|
+
run: run$q
|
|
6460
6576
|
}
|
|
6461
|
-
async function run$
|
|
6577
|
+
async function run$q(argv, importMeta, { parentName }) {
|
|
6462
6578
|
const cli = meowOrExit({
|
|
6463
6579
|
allowUnknownFlags: true,
|
|
6464
6580
|
argv,
|
|
6465
|
-
config: config$
|
|
6581
|
+
config: config$q,
|
|
6466
6582
|
importMeta,
|
|
6467
6583
|
parentName
|
|
6468
6584
|
})
|
|
6469
6585
|
if (cli.flags['dryRun']) {
|
|
6470
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6586
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$o)
|
|
6471
6587
|
return
|
|
6472
6588
|
}
|
|
6473
6589
|
await wrapNpx(argv)
|
|
6474
6590
|
}
|
|
6475
6591
|
|
|
6476
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
6477
|
-
const config$
|
|
6592
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$n } = constants
|
|
6593
|
+
const config$p = {
|
|
6478
6594
|
commandName: 'oops',
|
|
6479
6595
|
description: 'Trigger an intentional error (for development)',
|
|
6480
6596
|
hidden: true,
|
|
@@ -6489,19 +6605,19 @@ const config$o = {
|
|
|
6489
6605
|
`
|
|
6490
6606
|
}
|
|
6491
6607
|
const cmdOops = {
|
|
6492
|
-
description: config$
|
|
6493
|
-
hidden: config$
|
|
6494
|
-
run: run$
|
|
6608
|
+
description: config$p.description,
|
|
6609
|
+
hidden: config$p.hidden,
|
|
6610
|
+
run: run$p
|
|
6495
6611
|
}
|
|
6496
|
-
async function run$
|
|
6612
|
+
async function run$p(argv, importMeta, { parentName }) {
|
|
6497
6613
|
const cli = meowOrExit({
|
|
6498
6614
|
argv,
|
|
6499
|
-
config: config$
|
|
6615
|
+
config: config$p,
|
|
6500
6616
|
importMeta,
|
|
6501
6617
|
parentName
|
|
6502
6618
|
})
|
|
6503
6619
|
if (cli.flags['dryRun']) {
|
|
6504
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
6620
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$n)
|
|
6505
6621
|
return
|
|
6506
6622
|
}
|
|
6507
6623
|
throw new Error('This error was intentionally left blank')
|
|
@@ -6510,7 +6626,7 @@ async function run$o(argv, importMeta, { parentName }) {
|
|
|
6510
6626
|
const {
|
|
6511
6627
|
BUN: BUN$4,
|
|
6512
6628
|
NPM: NPM$6,
|
|
6513
|
-
PNPM: PNPM$
|
|
6629
|
+
PNPM: PNPM$5,
|
|
6514
6630
|
VLT: VLT$4,
|
|
6515
6631
|
YARN_BERRY: YARN_BERRY$4,
|
|
6516
6632
|
YARN_CLASSIC: YARN_CLASSIC$5
|
|
@@ -6524,19 +6640,19 @@ function matchQueryCmdStdout(stdout, name) {
|
|
|
6524
6640
|
const depsIncludesByAgent = new Map([
|
|
6525
6641
|
[BUN$4, matchLsCmdViewHumanStdout],
|
|
6526
6642
|
[NPM$6, matchQueryCmdStdout],
|
|
6527
|
-
[PNPM$
|
|
6643
|
+
[PNPM$5, matchQueryCmdStdout],
|
|
6528
6644
|
[VLT$4, matchQueryCmdStdout],
|
|
6529
6645
|
[YARN_BERRY$4, matchLsCmdViewHumanStdout],
|
|
6530
6646
|
[YARN_CLASSIC$5, matchLsCmdViewHumanStdout]
|
|
6531
6647
|
])
|
|
6532
6648
|
|
|
6533
|
-
function getDependencyEntries(
|
|
6649
|
+
function getDependencyEntries(pkgEnvDetails) {
|
|
6534
6650
|
const {
|
|
6535
6651
|
dependencies,
|
|
6536
6652
|
devDependencies,
|
|
6537
6653
|
optionalDependencies,
|
|
6538
6654
|
peerDependencies
|
|
6539
|
-
} = editablePkgJson.content
|
|
6655
|
+
} = pkgEnvDetails.editablePkgJson.content
|
|
6540
6656
|
return [
|
|
6541
6657
|
[
|
|
6542
6658
|
'dependencies',
|
|
@@ -6581,14 +6697,14 @@ const {
|
|
|
6581
6697
|
BUN: BUN$3,
|
|
6582
6698
|
NPM: NPM$5,
|
|
6583
6699
|
OVERRIDES: OVERRIDES$1,
|
|
6584
|
-
PNPM: PNPM$
|
|
6700
|
+
PNPM: PNPM$4,
|
|
6585
6701
|
RESOLUTIONS: RESOLUTIONS$1,
|
|
6586
6702
|
VLT: VLT$3,
|
|
6587
6703
|
YARN_BERRY: YARN_BERRY$3,
|
|
6588
6704
|
YARN_CLASSIC: YARN_CLASSIC$4
|
|
6589
6705
|
} = constants
|
|
6590
|
-
function getOverridesDataBun(
|
|
6591
|
-
const overrides = editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
|
|
6706
|
+
function getOverridesDataBun(pkgEnvDetails) {
|
|
6707
|
+
const overrides = pkgEnvDetails.editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
|
|
6592
6708
|
return {
|
|
6593
6709
|
type: YARN_BERRY$3,
|
|
6594
6710
|
overrides
|
|
@@ -6597,8 +6713,8 @@ function getOverridesDataBun(editablePkgJson) {
|
|
|
6597
6713
|
|
|
6598
6714
|
// npm overrides documentation:
|
|
6599
6715
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
|
|
6600
|
-
function getOverridesDataNpm(
|
|
6601
|
-
const overrides = editablePkgJson.content?.[OVERRIDES$1] ?? {}
|
|
6716
|
+
function getOverridesDataNpm(pkgEnvDetails) {
|
|
6717
|
+
const overrides = pkgEnvDetails.editablePkgJson.content?.[OVERRIDES$1] ?? {}
|
|
6602
6718
|
return {
|
|
6603
6719
|
type: NPM$5,
|
|
6604
6720
|
overrides
|
|
@@ -6607,15 +6723,16 @@ function getOverridesDataNpm(editablePkgJson) {
|
|
|
6607
6723
|
|
|
6608
6724
|
// pnpm overrides documentation:
|
|
6609
6725
|
// https://pnpm.io/package_json#pnpmoverrides
|
|
6610
|
-
function getOverridesDataPnpm(
|
|
6611
|
-
const overrides =
|
|
6726
|
+
function getOverridesDataPnpm(pkgEnvDetails) {
|
|
6727
|
+
const overrides =
|
|
6728
|
+
pkgEnvDetails.editablePkgJson.content?.[PNPM$4]?.[OVERRIDES$1] ?? {}
|
|
6612
6729
|
return {
|
|
6613
|
-
type: PNPM$
|
|
6730
|
+
type: PNPM$4,
|
|
6614
6731
|
overrides
|
|
6615
6732
|
}
|
|
6616
6733
|
}
|
|
6617
|
-
function getOverridesDataVlt(
|
|
6618
|
-
const overrides = editablePkgJson.content?.[OVERRIDES$1] ?? {}
|
|
6734
|
+
function getOverridesDataVlt(pkgEnvDetails) {
|
|
6735
|
+
const overrides = pkgEnvDetails.editablePkgJson.content?.[OVERRIDES$1] ?? {}
|
|
6619
6736
|
return {
|
|
6620
6737
|
type: VLT$3,
|
|
6621
6738
|
overrides
|
|
@@ -6624,8 +6741,8 @@ function getOverridesDataVlt(editablePkgJson) {
|
|
|
6624
6741
|
|
|
6625
6742
|
// Yarn resolutions documentation:
|
|
6626
6743
|
// https://yarnpkg.com/configuration/manifest#resolutions
|
|
6627
|
-
function getOverridesDataYarn(
|
|
6628
|
-
const overrides = editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
|
|
6744
|
+
function getOverridesDataYarn(pkgEnvDetails) {
|
|
6745
|
+
const overrides = pkgEnvDetails.editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
|
|
6629
6746
|
return {
|
|
6630
6747
|
type: YARN_BERRY$3,
|
|
6631
6748
|
overrides
|
|
@@ -6634,8 +6751,8 @@ function getOverridesDataYarn(editablePkgJson) {
|
|
|
6634
6751
|
|
|
6635
6752
|
// Yarn resolutions documentation:
|
|
6636
6753
|
// https://classic.yarnpkg.com/en/docs/selective-version-resolutions
|
|
6637
|
-
function getOverridesDataYarnClassic(
|
|
6638
|
-
const overrides = editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
|
|
6754
|
+
function getOverridesDataYarnClassic(pkgEnvDetails) {
|
|
6755
|
+
const overrides = pkgEnvDetails.editablePkgJson.content?.[RESOLUTIONS$1] ?? {}
|
|
6639
6756
|
return {
|
|
6640
6757
|
type: YARN_CLASSIC$4,
|
|
6641
6758
|
overrides
|
|
@@ -6644,62 +6761,12 @@ function getOverridesDataYarnClassic(editablePkgJson) {
|
|
|
6644
6761
|
const overridesDataByAgent = new Map([
|
|
6645
6762
|
[BUN$3, getOverridesDataBun],
|
|
6646
6763
|
[NPM$5, getOverridesDataNpm],
|
|
6647
|
-
[PNPM$
|
|
6764
|
+
[PNPM$4, getOverridesDataPnpm],
|
|
6648
6765
|
[VLT$3, getOverridesDataVlt],
|
|
6649
6766
|
[YARN_BERRY$3, getOverridesDataYarn],
|
|
6650
6767
|
[YARN_CLASSIC$4, getOverridesDataYarnClassic]
|
|
6651
6768
|
])
|
|
6652
6769
|
|
|
6653
|
-
const { PNPM: PNPM$4 } = constants
|
|
6654
|
-
const PNPM_WORKSPACE = `${PNPM$4}-workspace`
|
|
6655
|
-
async function getWorkspaceGlobs(agent, pkgPath, editablePkgJson) {
|
|
6656
|
-
let workspacePatterns
|
|
6657
|
-
if (agent === PNPM$4) {
|
|
6658
|
-
for (const workspacePath of [
|
|
6659
|
-
path$1.join(pkgPath, `${PNPM_WORKSPACE}.yaml`),
|
|
6660
|
-
path$1.join(pkgPath, `${PNPM_WORKSPACE}.yml`)
|
|
6661
|
-
]) {
|
|
6662
|
-
// eslint-disable-next-line no-await-in-loop
|
|
6663
|
-
const yml = await shadowNpmInject.safeReadFile(workspacePath)
|
|
6664
|
-
if (yml) {
|
|
6665
|
-
try {
|
|
6666
|
-
workspacePatterns = vendor.distExports$1.parse(yml)?.packages
|
|
6667
|
-
} catch {}
|
|
6668
|
-
if (workspacePatterns) {
|
|
6669
|
-
break
|
|
6670
|
-
}
|
|
6671
|
-
}
|
|
6672
|
-
}
|
|
6673
|
-
} else {
|
|
6674
|
-
workspacePatterns = editablePkgJson.content['workspaces']
|
|
6675
|
-
}
|
|
6676
|
-
return Array.isArray(workspacePatterns)
|
|
6677
|
-
? workspacePatterns
|
|
6678
|
-
.filter(strings.isNonEmptyString)
|
|
6679
|
-
.map(workspacePatternToGlobPattern)
|
|
6680
|
-
: undefined
|
|
6681
|
-
}
|
|
6682
|
-
function workspacePatternToGlobPattern(workspace) {
|
|
6683
|
-
const { length } = workspace
|
|
6684
|
-
if (!length) {
|
|
6685
|
-
return ''
|
|
6686
|
-
}
|
|
6687
|
-
// If the workspace ends with "/"
|
|
6688
|
-
if (workspace.charCodeAt(length - 1) === 47 /*'/'*/) {
|
|
6689
|
-
return `${workspace}/*/package.json`
|
|
6690
|
-
}
|
|
6691
|
-
// If the workspace ends with "/**"
|
|
6692
|
-
if (
|
|
6693
|
-
workspace.charCodeAt(length - 1) === 42 /*'*'*/ &&
|
|
6694
|
-
workspace.charCodeAt(length - 2) === 42 /*'*'*/ &&
|
|
6695
|
-
workspace.charCodeAt(length - 3) === 47 /*'/'*/
|
|
6696
|
-
) {
|
|
6697
|
-
return `${workspace}/*/**/package.json`
|
|
6698
|
-
}
|
|
6699
|
-
// Things like "packages/a" or "packages/*"
|
|
6700
|
-
return `${workspace}/package.json`
|
|
6701
|
-
}
|
|
6702
|
-
|
|
6703
6770
|
const {
|
|
6704
6771
|
BUN: BUN$2,
|
|
6705
6772
|
LOCK_EXT,
|
|
@@ -6817,22 +6884,22 @@ async function npmQuery(npmExecPath, cwd) {
|
|
|
6817
6884
|
} catch {}
|
|
6818
6885
|
return cleanupQueryStdout(stdout)
|
|
6819
6886
|
}
|
|
6820
|
-
async function lsBun(
|
|
6887
|
+
async function lsBun(pkgEnvDetails, cwd) {
|
|
6821
6888
|
try {
|
|
6822
6889
|
// Bun does not support filtering by production packages yet.
|
|
6823
6890
|
// https://github.com/oven-sh/bun/issues/8283
|
|
6824
6891
|
return (
|
|
6825
|
-
await spawn.spawn(agentExecPath, ['pm', 'ls', '--all'], {
|
|
6892
|
+
await spawn.spawn(pkgEnvDetails.agentExecPath, ['pm', 'ls', '--all'], {
|
|
6826
6893
|
cwd
|
|
6827
6894
|
})
|
|
6828
6895
|
).stdout
|
|
6829
6896
|
} catch {}
|
|
6830
6897
|
return ''
|
|
6831
6898
|
}
|
|
6832
|
-
async function lsNpm(
|
|
6833
|
-
return await npmQuery(agentExecPath, cwd)
|
|
6899
|
+
async function lsNpm(pkgEnvDetails, cwd) {
|
|
6900
|
+
return await npmQuery(pkgEnvDetails.agentExecPath, cwd)
|
|
6834
6901
|
}
|
|
6835
|
-
async function lsPnpm(
|
|
6902
|
+
async function lsPnpm(pkgEnvDetails, cwd, options) {
|
|
6836
6903
|
const npmExecPath = options?.npmExecPath
|
|
6837
6904
|
if (npmExecPath && npmExecPath !== NPM$3) {
|
|
6838
6905
|
const result = await npmQuery(npmExecPath, cwd)
|
|
@@ -6844,7 +6911,7 @@ async function lsPnpm(agentExecPath, cwd, options) {
|
|
|
6844
6911
|
try {
|
|
6845
6912
|
stdout = (
|
|
6846
6913
|
await spawn.spawn(
|
|
6847
|
-
agentExecPath,
|
|
6914
|
+
pkgEnvDetails.agentExecPath,
|
|
6848
6915
|
// Pnpm uses the alternative spelling of parsable.
|
|
6849
6916
|
// https://en.wiktionary.org/wiki/parsable
|
|
6850
6917
|
['ls', '--parseable', '--prod', '--depth', 'Infinity'],
|
|
@@ -6856,13 +6923,13 @@ async function lsPnpm(agentExecPath, cwd, options) {
|
|
|
6856
6923
|
} catch {}
|
|
6857
6924
|
return parsableToQueryStdout(stdout)
|
|
6858
6925
|
}
|
|
6859
|
-
async function lsVlt(
|
|
6926
|
+
async function lsVlt(pkgEnvDetails, cwd) {
|
|
6860
6927
|
let stdout = ''
|
|
6861
6928
|
try {
|
|
6862
6929
|
// See https://docs.vlt.sh/cli/commands/list#options.
|
|
6863
6930
|
stdout = (
|
|
6864
6931
|
await spawn.spawn(
|
|
6865
|
-
agentExecPath,
|
|
6932
|
+
pkgEnvDetails.agentExecPath,
|
|
6866
6933
|
['ls', '--view', 'human', ':not(.dev)'],
|
|
6867
6934
|
{
|
|
6868
6935
|
cwd
|
|
@@ -6872,14 +6939,14 @@ async function lsVlt(agentExecPath, cwd) {
|
|
|
6872
6939
|
} catch {}
|
|
6873
6940
|
return cleanupQueryStdout(stdout)
|
|
6874
6941
|
}
|
|
6875
|
-
async function lsYarnBerry(
|
|
6942
|
+
async function lsYarnBerry(pkgEnvDetails, cwd) {
|
|
6876
6943
|
try {
|
|
6877
6944
|
return (
|
|
6878
6945
|
// Yarn Berry does not support filtering by production packages yet.
|
|
6879
6946
|
// https://github.com/yarnpkg/berry/issues/5117
|
|
6880
6947
|
(
|
|
6881
6948
|
await spawn.spawn(
|
|
6882
|
-
agentExecPath,
|
|
6949
|
+
pkgEnvDetails.agentExecPath,
|
|
6883
6950
|
['info', '--recursive', '--name-only'],
|
|
6884
6951
|
{
|
|
6885
6952
|
cwd
|
|
@@ -6890,14 +6957,14 @@ async function lsYarnBerry(agentExecPath, cwd) {
|
|
|
6890
6957
|
} catch {}
|
|
6891
6958
|
return ''
|
|
6892
6959
|
}
|
|
6893
|
-
async function lsYarnClassic(
|
|
6960
|
+
async function lsYarnClassic(pkgEnvDetails, cwd) {
|
|
6894
6961
|
try {
|
|
6895
6962
|
// However, Yarn Classic does support it.
|
|
6896
6963
|
// https://github.com/yarnpkg/yarn/releases/tag/v1.0.0
|
|
6897
6964
|
// > Fix: Excludes dev dependencies from the yarn list output when the
|
|
6898
6965
|
// environment is production
|
|
6899
6966
|
return (
|
|
6900
|
-
await spawn.spawn(agentExecPath, ['list', '--prod'], {
|
|
6967
|
+
await spawn.spawn(pkgEnvDetails.agentExecPath, ['list', '--prod'], {
|
|
6901
6968
|
cwd
|
|
6902
6969
|
})
|
|
6903
6970
|
).stdout.trim()
|
|
@@ -6913,6 +6980,8 @@ const lsByAgent = new Map([
|
|
|
6913
6980
|
[YARN_CLASSIC$2, lsYarnClassic]
|
|
6914
6981
|
])
|
|
6915
6982
|
|
|
6983
|
+
const CMD_NAME = 'socket optimize'
|
|
6984
|
+
|
|
6916
6985
|
const {
|
|
6917
6986
|
BUN,
|
|
6918
6987
|
NPM: NPM$2,
|
|
@@ -7042,14 +7111,14 @@ function updatePkgJsonField(editablePkgJson, field, value) {
|
|
|
7042
7111
|
`${JSON.stringify(Object.fromEntries(entries), null, 2)}\n`
|
|
7043
7112
|
)
|
|
7044
7113
|
}
|
|
7045
|
-
function updateOverridesField(
|
|
7046
|
-
updatePkgJsonField(editablePkgJson, OVERRIDES, overrides)
|
|
7114
|
+
function updateOverridesField(pkgEnvDetails, overrides) {
|
|
7115
|
+
updatePkgJsonField(pkgEnvDetails.editablePkgJson, OVERRIDES, overrides)
|
|
7047
7116
|
}
|
|
7048
|
-
function updateResolutionsField(
|
|
7049
|
-
updatePkgJsonField(editablePkgJson, RESOLUTIONS, overrides)
|
|
7117
|
+
function updateResolutionsField(pkgEnvDetails, overrides) {
|
|
7118
|
+
updatePkgJsonField(pkgEnvDetails.editablePkgJson, RESOLUTIONS, overrides)
|
|
7050
7119
|
}
|
|
7051
|
-
function updatePnpmField(
|
|
7052
|
-
updatePkgJsonField(editablePkgJson, PNPM$1, overrides)
|
|
7120
|
+
function updatePnpmField(pkgEnvDetails, overrides) {
|
|
7121
|
+
updatePkgJsonField(pkgEnvDetails.editablePkgJson, PNPM$1, overrides)
|
|
7053
7122
|
}
|
|
7054
7123
|
const updateManifestByAgent = new Map([
|
|
7055
7124
|
[BUN, updateResolutionsField],
|
|
@@ -7061,12 +7130,10 @@ const updateManifestByAgent = new Map([
|
|
|
7061
7130
|
])
|
|
7062
7131
|
|
|
7063
7132
|
const { NPM: NPM$1, PNPM, YARN_CLASSIC } = constants
|
|
7064
|
-
const CMD_NAME$1 = 'socket optimize'
|
|
7065
7133
|
const manifestNpmOverrides = registry.getManifestData(NPM$1)
|
|
7066
|
-
async function addOverrides(
|
|
7134
|
+
async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
7067
7135
|
const {
|
|
7068
7136
|
agent,
|
|
7069
|
-
agentExecPath,
|
|
7070
7137
|
lockName,
|
|
7071
7138
|
lockSrc,
|
|
7072
7139
|
npmExecPath,
|
|
@@ -7082,27 +7149,19 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
|
7082
7149
|
addedInWorkspaces: new Set(),
|
|
7083
7150
|
updated: new Set(),
|
|
7084
7151
|
updatedInWorkspaces: new Set(),
|
|
7085
|
-
warnedPnpmWorkspaceRequiresNpm: false
|
|
7152
|
+
warnedPnpmWorkspaceRequiresNpm: false,
|
|
7153
|
+
workspacePkgJsonPaths: await shadowNpmPaths.globWorkspace(pkgEnvDetails)
|
|
7086
7154
|
}
|
|
7087
7155
|
} = {
|
|
7088
7156
|
__proto__: null,
|
|
7089
7157
|
...options
|
|
7090
7158
|
}
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
const workspaceName = path$1.relative(rootPath, pkgPath)
|
|
7098
|
-
const workspaceGlobs = await getWorkspaceGlobs(
|
|
7099
|
-
agent,
|
|
7100
|
-
pkgPath,
|
|
7101
|
-
editablePkgJson
|
|
7102
|
-
)
|
|
7103
|
-
const isRoot = pkgPath === rootPath
|
|
7104
|
-
const isLockScanned = isRoot && !prod
|
|
7105
|
-
const isWorkspace = !!workspaceGlobs
|
|
7159
|
+
const isWorkspace = state.workspacePkgJsonPaths.length > 0
|
|
7160
|
+
const isWorkspaceRoot = pkgPath === rootPath
|
|
7161
|
+
const isLockScanned = isWorkspaceRoot && !prod
|
|
7162
|
+
const workspaceName = isWorkspaceRoot
|
|
7163
|
+
? ''
|
|
7164
|
+
: path$1.relative(rootPath, pkgPath)
|
|
7106
7165
|
if (
|
|
7107
7166
|
isWorkspace &&
|
|
7108
7167
|
agent === PNPM &&
|
|
@@ -7113,25 +7172,25 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
|
7113
7172
|
state.warnedPnpmWorkspaceRequiresNpm = true
|
|
7114
7173
|
logger?.warn(
|
|
7115
7174
|
cmdPrefixMessage(
|
|
7116
|
-
CMD_NAME
|
|
7175
|
+
CMD_NAME,
|
|
7117
7176
|
`${agent} workspace support requires \`npm ls\`, falling back to \`${agent} list\``
|
|
7118
7177
|
)
|
|
7119
7178
|
)
|
|
7120
7179
|
}
|
|
7121
7180
|
const overridesDataObjects = []
|
|
7122
|
-
if (editablePkgJson.content['private']
|
|
7123
|
-
overridesDataObjects.push(overridesDataByAgent.get(agent)(
|
|
7181
|
+
if (isWorkspace || pkgEnvDetails.editablePkgJson.content['private']) {
|
|
7182
|
+
overridesDataObjects.push(overridesDataByAgent.get(agent)(pkgEnvDetails))
|
|
7124
7183
|
} else {
|
|
7125
7184
|
overridesDataObjects.push(
|
|
7126
|
-
overridesDataByAgent.get(NPM$1)(
|
|
7127
|
-
overridesDataByAgent.get(YARN_CLASSIC)(
|
|
7185
|
+
overridesDataByAgent.get(NPM$1)(pkgEnvDetails),
|
|
7186
|
+
overridesDataByAgent.get(YARN_CLASSIC)(pkgEnvDetails)
|
|
7128
7187
|
)
|
|
7129
7188
|
}
|
|
7130
7189
|
spinner?.setText(
|
|
7131
7190
|
`Adding overrides${workspaceName ? ` to ${workspaceName}` : ''}...`
|
|
7132
7191
|
)
|
|
7133
7192
|
const depAliasMap = new Map()
|
|
7134
|
-
const depEntries = getDependencyEntries(
|
|
7193
|
+
const depEntries = getDependencyEntries(pkgEnvDetails)
|
|
7135
7194
|
const manifestEntries = manifestNpmOverrides.filter(({ 1: data }) =>
|
|
7136
7195
|
vendor.semverExports.satisfies(
|
|
7137
7196
|
// Roughly check Node range as semver.coerce will strip leading
|
|
@@ -7182,7 +7241,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
|
7182
7241
|
depAliasMap.set(origPkgName, thisSpec)
|
|
7183
7242
|
}
|
|
7184
7243
|
}
|
|
7185
|
-
if (
|
|
7244
|
+
if (isWorkspaceRoot) {
|
|
7186
7245
|
// The AgentDepsIncludesFn and AgentLockIncludesFn types overlap in their
|
|
7187
7246
|
// first two parameters. AgentLockIncludesFn accepts an optional third
|
|
7188
7247
|
// parameter which AgentDepsIncludesFn will ignore so we cast thingScanner
|
|
@@ -7192,7 +7251,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
|
7192
7251
|
: depsIncludesByAgent.get(agent)
|
|
7193
7252
|
const thingToScan = isLockScanned
|
|
7194
7253
|
? lockSrc
|
|
7195
|
-
: await lsByAgent.get(agent)(
|
|
7254
|
+
: await lsByAgent.get(agent)(pkgEnvDetails, pkgPath, {
|
|
7196
7255
|
npmExecPath
|
|
7197
7256
|
})
|
|
7198
7257
|
// Chunk package names to process them in parallel 3 at a time.
|
|
@@ -7258,28 +7317,21 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
|
7258
7317
|
)
|
|
7259
7318
|
}
|
|
7260
7319
|
})
|
|
7261
|
-
if (
|
|
7262
|
-
const workspacePkgJsonPaths = await vendor.distExports.glob(
|
|
7263
|
-
workspaceGlobs,
|
|
7264
|
-
{
|
|
7265
|
-
absolute: true,
|
|
7266
|
-
cwd: pkgPath,
|
|
7267
|
-
ignore: ['**/node_modules/**', '**/bower_components/**']
|
|
7268
|
-
}
|
|
7269
|
-
)
|
|
7320
|
+
if (isWorkspace) {
|
|
7270
7321
|
// Chunk package names to process them in parallel 3 at a time.
|
|
7271
7322
|
await promises.pEach(
|
|
7272
|
-
workspacePkgJsonPaths,
|
|
7323
|
+
state.workspacePkgJsonPaths,
|
|
7273
7324
|
3,
|
|
7274
7325
|
async workspacePkgJsonPath => {
|
|
7275
7326
|
const otherState = await addOverrides(
|
|
7276
|
-
path$1.dirname(workspacePkgJsonPath),
|
|
7277
7327
|
pkgEnvDetails,
|
|
7328
|
+
path$1.dirname(workspacePkgJsonPath),
|
|
7278
7329
|
{
|
|
7279
7330
|
logger,
|
|
7280
7331
|
pin,
|
|
7281
7332
|
prod,
|
|
7282
|
-
spinner
|
|
7333
|
+
spinner,
|
|
7334
|
+
state
|
|
7283
7335
|
}
|
|
7284
7336
|
)
|
|
7285
7337
|
for (const key of [
|
|
@@ -7296,14 +7348,14 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
|
|
|
7296
7348
|
)
|
|
7297
7349
|
}
|
|
7298
7350
|
if (state.added.size > 0 || state.updated.size > 0) {
|
|
7299
|
-
editablePkgJson.update(Object.fromEntries(depEntries))
|
|
7351
|
+
pkgEnvDetails.editablePkgJson.update(Object.fromEntries(depEntries))
|
|
7300
7352
|
for (const { overrides, type } of overridesDataObjects) {
|
|
7301
7353
|
updateManifestByAgent.get(type)(
|
|
7302
|
-
|
|
7354
|
+
pkgEnvDetails,
|
|
7303
7355
|
objects.toSortedObject(overrides)
|
|
7304
7356
|
)
|
|
7305
7357
|
}
|
|
7306
|
-
await editablePkgJson.save()
|
|
7358
|
+
await pkgEnvDetails.editablePkgJson.save()
|
|
7307
7359
|
}
|
|
7308
7360
|
return state
|
|
7309
7361
|
}
|
|
@@ -7349,7 +7401,6 @@ async function updateLockfile(pkgEnvDetails, options) {
|
|
|
7349
7401
|
}
|
|
7350
7402
|
}
|
|
7351
7403
|
|
|
7352
|
-
const CMD_NAME = 'socket optimize'
|
|
7353
7404
|
function createActionMessage(verb, overrideCount, workspaceCount) {
|
|
7354
7405
|
return `${verb} ${overrideCount} Socket.dev optimized ${words.pluralize('override', overrideCount)}${workspaceCount ? ` in ${workspaceCount} ${words.pluralize('workspace', workspaceCount)}` : ''}`
|
|
7355
7406
|
}
|
|
@@ -7365,7 +7416,7 @@ async function applyOptimization(cwd, pin, prod) {
|
|
|
7365
7416
|
// Lazily access constants.spinner.
|
|
7366
7417
|
const { spinner } = constants
|
|
7367
7418
|
spinner.start('Socket optimizing...')
|
|
7368
|
-
const state = await addOverrides(pkgEnvDetails
|
|
7419
|
+
const state = await addOverrides(pkgEnvDetails, pkgEnvDetails.pkgPath, {
|
|
7369
7420
|
logger: logger.logger,
|
|
7370
7421
|
pin,
|
|
7371
7422
|
prod,
|
|
@@ -7398,8 +7449,8 @@ async function applyOptimization(cwd, pin, prod) {
|
|
|
7398
7449
|
}
|
|
7399
7450
|
}
|
|
7400
7451
|
|
|
7401
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
7402
|
-
const config$
|
|
7452
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$m } = constants
|
|
7453
|
+
const config$o = {
|
|
7403
7454
|
commandName: 'optimize',
|
|
7404
7455
|
description: 'Optimize dependencies with @socketregistry overrides',
|
|
7405
7456
|
hidden: false,
|
|
@@ -7429,20 +7480,20 @@ const config$n = {
|
|
|
7429
7480
|
`
|
|
7430
7481
|
}
|
|
7431
7482
|
const cmdOptimize = {
|
|
7432
|
-
description: config$
|
|
7433
|
-
hidden: config$
|
|
7434
|
-
run: run$
|
|
7483
|
+
description: config$o.description,
|
|
7484
|
+
hidden: config$o.hidden,
|
|
7485
|
+
run: run$o
|
|
7435
7486
|
}
|
|
7436
|
-
async function run$
|
|
7487
|
+
async function run$o(argv, importMeta, { parentName }) {
|
|
7437
7488
|
const cli = meowOrExit({
|
|
7438
7489
|
argv,
|
|
7439
|
-
config: config$
|
|
7490
|
+
config: config$o,
|
|
7440
7491
|
importMeta,
|
|
7441
7492
|
parentName
|
|
7442
7493
|
})
|
|
7443
7494
|
const cwd = process.cwd()
|
|
7444
7495
|
if (cli.flags['dryRun']) {
|
|
7445
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
7496
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$m)
|
|
7446
7497
|
return
|
|
7447
7498
|
}
|
|
7448
7499
|
await applyOptimization(
|
|
@@ -7543,8 +7594,8 @@ async function handleOrganizationList(outputKind = 'text') {
|
|
|
7543
7594
|
await outputOrganizationList(data, outputKind)
|
|
7544
7595
|
}
|
|
7545
7596
|
|
|
7546
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
7547
|
-
const config$
|
|
7597
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$l } = constants
|
|
7598
|
+
const config$n = {
|
|
7548
7599
|
commandName: 'list',
|
|
7549
7600
|
description: 'List organizations associated with the API key used',
|
|
7550
7601
|
hidden: false,
|
|
@@ -7561,18 +7612,18 @@ const config$m = {
|
|
|
7561
7612
|
- Permissions: none (does need a token)
|
|
7562
7613
|
|
|
7563
7614
|
Options
|
|
7564
|
-
${getFlagListOutput(config$
|
|
7615
|
+
${getFlagListOutput(config$n.flags, 6)}
|
|
7565
7616
|
`
|
|
7566
7617
|
}
|
|
7567
7618
|
const cmdOrganizationList = {
|
|
7568
|
-
description: config$
|
|
7569
|
-
hidden: config$
|
|
7570
|
-
run: run$
|
|
7619
|
+
description: config$n.description,
|
|
7620
|
+
hidden: config$n.hidden,
|
|
7621
|
+
run: run$n
|
|
7571
7622
|
}
|
|
7572
|
-
async function run$
|
|
7623
|
+
async function run$n(argv, importMeta, { parentName }) {
|
|
7573
7624
|
const cli = meowOrExit({
|
|
7574
7625
|
argv,
|
|
7575
|
-
config: config$
|
|
7626
|
+
config: config$n,
|
|
7576
7627
|
importMeta,
|
|
7577
7628
|
parentName
|
|
7578
7629
|
})
|
|
@@ -7600,7 +7651,7 @@ async function run$m(argv, importMeta, { parentName }) {
|
|
|
7600
7651
|
return
|
|
7601
7652
|
}
|
|
7602
7653
|
if (cli.flags['dryRun']) {
|
|
7603
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
7654
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$l)
|
|
7604
7655
|
return
|
|
7605
7656
|
}
|
|
7606
7657
|
await handleOrganizationList(json ? 'json' : markdown ? 'markdown' : 'text')
|
|
@@ -7644,8 +7695,7 @@ async function outputLicensePolicy(data, outputKind) {
|
|
|
7644
7695
|
logger.logger.log('This is the license policy for your organization:')
|
|
7645
7696
|
logger.logger.log('')
|
|
7646
7697
|
const rules = data.license_policy
|
|
7647
|
-
|
|
7648
|
-
const entries = Object.entries(rules)
|
|
7698
|
+
const entries = rules ? Object.entries(rules) : []
|
|
7649
7699
|
const mapped = entries.map(([key, value]) => [
|
|
7650
7700
|
key,
|
|
7651
7701
|
value.allowed ? ' yes' : ' no'
|
|
@@ -7663,10 +7713,10 @@ async function handleLicensePolicy(orgSlug, outputKind) {
|
|
|
7663
7713
|
await outputLicensePolicy(data, outputKind)
|
|
7664
7714
|
}
|
|
7665
7715
|
|
|
7666
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
7716
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$k } = constants
|
|
7667
7717
|
|
|
7668
7718
|
// TODO: secret toplevel alias `socket license policy`?
|
|
7669
|
-
const config$
|
|
7719
|
+
const config$m = {
|
|
7670
7720
|
commandName: 'license',
|
|
7671
7721
|
description: 'Retrieve the license policy of an organization',
|
|
7672
7722
|
hidden: true,
|
|
@@ -7683,7 +7733,7 @@ const config$l = {
|
|
|
7683
7733
|
- Permissions: license-policy:read
|
|
7684
7734
|
|
|
7685
7735
|
Options
|
|
7686
|
-
${getFlagListOutput(config$
|
|
7736
|
+
${getFlagListOutput(config$m.flags, 6)}
|
|
7687
7737
|
|
|
7688
7738
|
Your API token will need the \`license-policy:read\` permission otherwise
|
|
7689
7739
|
the request will fail with an authentication error.
|
|
@@ -7694,14 +7744,14 @@ const config$l = {
|
|
|
7694
7744
|
`
|
|
7695
7745
|
}
|
|
7696
7746
|
const cmdOrganizationPolicyLicense = {
|
|
7697
|
-
description: config$
|
|
7698
|
-
hidden: config$
|
|
7699
|
-
run: run$
|
|
7747
|
+
description: config$m.description,
|
|
7748
|
+
hidden: config$m.hidden,
|
|
7749
|
+
run: run$m
|
|
7700
7750
|
}
|
|
7701
|
-
async function run$
|
|
7751
|
+
async function run$m(argv, importMeta, { parentName }) {
|
|
7702
7752
|
const cli = meowOrExit({
|
|
7703
7753
|
argv,
|
|
7704
|
-
config: config$
|
|
7754
|
+
config: config$m,
|
|
7705
7755
|
importMeta,
|
|
7706
7756
|
parentName
|
|
7707
7757
|
})
|
|
@@ -7738,7 +7788,7 @@ async function run$l(argv, importMeta, { parentName }) {
|
|
|
7738
7788
|
return
|
|
7739
7789
|
}
|
|
7740
7790
|
if (cli.flags['dryRun']) {
|
|
7741
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
7791
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$k)
|
|
7742
7792
|
return
|
|
7743
7793
|
}
|
|
7744
7794
|
await handleLicensePolicy(
|
|
@@ -7790,7 +7840,7 @@ async function outputSecurityPolicy(data, outputKind) {
|
|
|
7790
7840
|
)
|
|
7791
7841
|
logger.logger.log('')
|
|
7792
7842
|
const rules = data.securityPolicyRules
|
|
7793
|
-
const entries = Object.entries(rules)
|
|
7843
|
+
const entries = rules ? Object.entries(rules) : []
|
|
7794
7844
|
const mapped = entries.map(([key, value]) => [key, value.action])
|
|
7795
7845
|
mapped.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
7796
7846
|
logger.logger.log(mdTableOfPairs(mapped, ['name', 'action']))
|
|
@@ -7805,10 +7855,10 @@ async function handleSecurityPolicy(orgSlug, outputKind) {
|
|
|
7805
7855
|
await outputSecurityPolicy(data, outputKind)
|
|
7806
7856
|
}
|
|
7807
7857
|
|
|
7808
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
7858
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$j } = constants
|
|
7809
7859
|
|
|
7810
7860
|
// TODO: secret toplevel alias `socket security policy`?
|
|
7811
|
-
const config$
|
|
7861
|
+
const config$l = {
|
|
7812
7862
|
commandName: 'security',
|
|
7813
7863
|
description: 'Retrieve the security policy of an organization',
|
|
7814
7864
|
hidden: true,
|
|
@@ -7825,7 +7875,7 @@ const config$k = {
|
|
|
7825
7875
|
- Permissions: security-policy:read
|
|
7826
7876
|
|
|
7827
7877
|
Options
|
|
7828
|
-
${getFlagListOutput(config$
|
|
7878
|
+
${getFlagListOutput(config$l.flags, 6)}
|
|
7829
7879
|
|
|
7830
7880
|
Your API token will need the \`security-policy:read\` permission otherwise
|
|
7831
7881
|
the request will fail with an authentication error.
|
|
@@ -7836,14 +7886,14 @@ const config$k = {
|
|
|
7836
7886
|
`
|
|
7837
7887
|
}
|
|
7838
7888
|
const cmdOrganizationPolicyPolicy = {
|
|
7839
|
-
description: config$
|
|
7840
|
-
hidden: config$
|
|
7841
|
-
run: run$
|
|
7889
|
+
description: config$l.description,
|
|
7890
|
+
hidden: config$l.hidden,
|
|
7891
|
+
run: run$l
|
|
7842
7892
|
}
|
|
7843
|
-
async function run$
|
|
7893
|
+
async function run$l(argv, importMeta, { parentName }) {
|
|
7844
7894
|
const cli = meowOrExit({
|
|
7845
7895
|
argv,
|
|
7846
|
-
config: config$
|
|
7896
|
+
config: config$l,
|
|
7847
7897
|
importMeta,
|
|
7848
7898
|
parentName
|
|
7849
7899
|
})
|
|
@@ -7880,7 +7930,7 @@ async function run$k(argv, importMeta, { parentName }) {
|
|
|
7880
7930
|
return
|
|
7881
7931
|
}
|
|
7882
7932
|
if (cli.flags['dryRun']) {
|
|
7883
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
7933
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$j)
|
|
7884
7934
|
return
|
|
7885
7935
|
}
|
|
7886
7936
|
await handleSecurityPolicy(
|
|
@@ -7966,8 +8016,8 @@ async function handleQuota(outputKind = 'text') {
|
|
|
7966
8016
|
await outputQuota(data, outputKind)
|
|
7967
8017
|
}
|
|
7968
8018
|
|
|
7969
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
7970
|
-
const config$
|
|
8019
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$i } = constants
|
|
8020
|
+
const config$k = {
|
|
7971
8021
|
commandName: 'quota',
|
|
7972
8022
|
description: 'List organizations associated with the API key used',
|
|
7973
8023
|
hidden: true,
|
|
@@ -7980,18 +8030,18 @@ const config$j = {
|
|
|
7980
8030
|
$ ${command}
|
|
7981
8031
|
|
|
7982
8032
|
Options
|
|
7983
|
-
${getFlagListOutput(config$
|
|
8033
|
+
${getFlagListOutput(config$k.flags, 6)}
|
|
7984
8034
|
`
|
|
7985
8035
|
}
|
|
7986
8036
|
const cmdOrganizationQuota = {
|
|
7987
|
-
description: config$
|
|
7988
|
-
hidden: config$
|
|
7989
|
-
run: run$
|
|
8037
|
+
description: config$k.description,
|
|
8038
|
+
hidden: config$k.hidden,
|
|
8039
|
+
run: run$k
|
|
7990
8040
|
}
|
|
7991
|
-
async function run$
|
|
8041
|
+
async function run$k(argv, importMeta, { parentName }) {
|
|
7992
8042
|
const cli = meowOrExit({
|
|
7993
8043
|
argv,
|
|
7994
|
-
config: config$
|
|
8044
|
+
config: config$k,
|
|
7995
8045
|
importMeta,
|
|
7996
8046
|
parentName
|
|
7997
8047
|
})
|
|
@@ -8019,7 +8069,7 @@ async function run$j(argv, importMeta, { parentName }) {
|
|
|
8019
8069
|
return
|
|
8020
8070
|
}
|
|
8021
8071
|
if (cli.flags['dryRun']) {
|
|
8022
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
8072
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$i)
|
|
8023
8073
|
return
|
|
8024
8074
|
}
|
|
8025
8075
|
await handleQuota(json ? 'json' : markdown ? 'markdown' : 'text')
|
|
@@ -8360,8 +8410,8 @@ function parsePackageSpecifiers(ecosystem, pkgs) {
|
|
|
8360
8410
|
}
|
|
8361
8411
|
}
|
|
8362
8412
|
|
|
8363
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
8364
|
-
const config$
|
|
8413
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$h } = constants
|
|
8414
|
+
const config$j = {
|
|
8365
8415
|
commandName: 'score',
|
|
8366
8416
|
description:
|
|
8367
8417
|
'[beta] Look up score for one package which reflects all of its transitive dependencies as well',
|
|
@@ -8404,14 +8454,14 @@ const config$i = {
|
|
|
8404
8454
|
`
|
|
8405
8455
|
}
|
|
8406
8456
|
const cmdPackageScore = {
|
|
8407
|
-
description: config$
|
|
8408
|
-
hidden: config$
|
|
8409
|
-
run: run$
|
|
8457
|
+
description: config$j.description,
|
|
8458
|
+
hidden: config$j.hidden,
|
|
8459
|
+
run: run$j
|
|
8410
8460
|
}
|
|
8411
|
-
async function run$
|
|
8461
|
+
async function run$j(argv, importMeta, { parentName }) {
|
|
8412
8462
|
const cli = meowOrExit({
|
|
8413
8463
|
argv,
|
|
8414
|
-
config: config$
|
|
8464
|
+
config: config$j,
|
|
8415
8465
|
importMeta,
|
|
8416
8466
|
parentName
|
|
8417
8467
|
})
|
|
@@ -8452,7 +8502,7 @@ async function run$i(argv, importMeta, { parentName }) {
|
|
|
8452
8502
|
return
|
|
8453
8503
|
}
|
|
8454
8504
|
if (cli.flags['dryRun']) {
|
|
8455
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
8505
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$h)
|
|
8456
8506
|
return
|
|
8457
8507
|
}
|
|
8458
8508
|
await handlePurlDeepScore(
|
|
@@ -8517,7 +8567,7 @@ function outputPurlsShallowScore(purls, packageData, outputKind) {
|
|
|
8517
8567
|
return true // not found
|
|
8518
8568
|
})
|
|
8519
8569
|
if (outputKind === 'markdown') {
|
|
8520
|
-
logger.logger.log(vendor.
|
|
8570
|
+
logger.logger.log(vendor.html`
|
|
8521
8571
|
# Shallow Package Report
|
|
8522
8572
|
|
|
8523
8573
|
This report contains the response for requesting data on some package url(s).
|
|
@@ -8658,8 +8708,8 @@ async function handlePurlsShallowScore({ outputKind, purls }) {
|
|
|
8658
8708
|
outputPurlsShallowScore(purls, packageData.data, outputKind)
|
|
8659
8709
|
}
|
|
8660
8710
|
|
|
8661
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
8662
|
-
const config$
|
|
8711
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$g } = constants
|
|
8712
|
+
const config$i = {
|
|
8663
8713
|
commandName: 'shallow',
|
|
8664
8714
|
description:
|
|
8665
8715
|
'[beta] Look up info regarding one or more packages but not their transitives',
|
|
@@ -8702,21 +8752,21 @@ const config$h = {
|
|
|
8702
8752
|
`
|
|
8703
8753
|
}
|
|
8704
8754
|
const cmdPackageShallow = {
|
|
8705
|
-
description: config$
|
|
8706
|
-
hidden: config$
|
|
8755
|
+
description: config$i.description,
|
|
8756
|
+
hidden: config$i.hidden,
|
|
8707
8757
|
alias: {
|
|
8708
8758
|
shallowScore: {
|
|
8709
|
-
description: config$
|
|
8759
|
+
description: config$i.description,
|
|
8710
8760
|
hidden: true,
|
|
8711
8761
|
argv: []
|
|
8712
8762
|
}
|
|
8713
8763
|
},
|
|
8714
|
-
run: run$
|
|
8764
|
+
run: run$i
|
|
8715
8765
|
}
|
|
8716
|
-
async function run$
|
|
8766
|
+
async function run$i(argv, importMeta, { parentName }) {
|
|
8717
8767
|
const cli = meowOrExit({
|
|
8718
8768
|
argv,
|
|
8719
|
-
config: config$
|
|
8769
|
+
config: config$i,
|
|
8720
8770
|
importMeta,
|
|
8721
8771
|
parentName
|
|
8722
8772
|
})
|
|
@@ -8749,7 +8799,7 @@ async function run$h(argv, importMeta, { parentName }) {
|
|
|
8749
8799
|
return
|
|
8750
8800
|
}
|
|
8751
8801
|
if (cli.flags['dryRun']) {
|
|
8752
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
8802
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$g)
|
|
8753
8803
|
return
|
|
8754
8804
|
}
|
|
8755
8805
|
await handlePurlsShallowScore({
|
|
@@ -8801,8 +8851,8 @@ async function runRawNpm(argv) {
|
|
|
8801
8851
|
await spawnPromise
|
|
8802
8852
|
}
|
|
8803
8853
|
|
|
8804
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
8805
|
-
const config$
|
|
8854
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$f, NPM } = constants
|
|
8855
|
+
const config$h = {
|
|
8806
8856
|
commandName: 'raw-npm',
|
|
8807
8857
|
description: `Temporarily disable the Socket ${NPM} wrapper`,
|
|
8808
8858
|
hidden: false,
|
|
@@ -8816,20 +8866,20 @@ const config$g = {
|
|
|
8816
8866
|
`
|
|
8817
8867
|
}
|
|
8818
8868
|
const cmdRawNpm = {
|
|
8819
|
-
description: config$
|
|
8820
|
-
hidden: config$
|
|
8821
|
-
run: run$
|
|
8869
|
+
description: config$h.description,
|
|
8870
|
+
hidden: config$h.hidden,
|
|
8871
|
+
run: run$h
|
|
8822
8872
|
}
|
|
8823
|
-
async function run$
|
|
8873
|
+
async function run$h(argv, importMeta, { parentName }) {
|
|
8824
8874
|
const cli = meowOrExit({
|
|
8825
8875
|
allowUnknownFlags: true,
|
|
8826
8876
|
argv,
|
|
8827
|
-
config: config$
|
|
8877
|
+
config: config$h,
|
|
8828
8878
|
importMeta,
|
|
8829
8879
|
parentName
|
|
8830
8880
|
})
|
|
8831
8881
|
if (cli.flags['dryRun']) {
|
|
8832
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
8882
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$f)
|
|
8833
8883
|
return
|
|
8834
8884
|
}
|
|
8835
8885
|
await runRawNpm(argv)
|
|
@@ -8851,8 +8901,8 @@ async function runRawNpx(argv) {
|
|
|
8851
8901
|
await spawnPromise
|
|
8852
8902
|
}
|
|
8853
8903
|
|
|
8854
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
8855
|
-
const config$
|
|
8904
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$e, NPX } = constants
|
|
8905
|
+
const config$g = {
|
|
8856
8906
|
commandName: 'raw-npx',
|
|
8857
8907
|
description: `Temporarily disable the Socket ${NPX} wrapper`,
|
|
8858
8908
|
hidden: false,
|
|
@@ -8866,26 +8916,26 @@ const config$f = {
|
|
|
8866
8916
|
`
|
|
8867
8917
|
}
|
|
8868
8918
|
const cmdRawNpx = {
|
|
8869
|
-
description: config$
|
|
8870
|
-
hidden: config$
|
|
8871
|
-
run: run$
|
|
8919
|
+
description: config$g.description,
|
|
8920
|
+
hidden: config$g.hidden,
|
|
8921
|
+
run: run$g
|
|
8872
8922
|
}
|
|
8873
|
-
async function run$
|
|
8923
|
+
async function run$g(argv, importMeta, { parentName }) {
|
|
8874
8924
|
const cli = meowOrExit({
|
|
8875
8925
|
allowUnknownFlags: true,
|
|
8876
8926
|
argv,
|
|
8877
|
-
config: config$
|
|
8927
|
+
config: config$g,
|
|
8878
8928
|
importMeta,
|
|
8879
8929
|
parentName
|
|
8880
8930
|
})
|
|
8881
8931
|
if (cli.flags['dryRun']) {
|
|
8882
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
8932
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$e)
|
|
8883
8933
|
return
|
|
8884
8934
|
}
|
|
8885
8935
|
await runRawNpx(argv)
|
|
8886
8936
|
}
|
|
8887
8937
|
|
|
8888
|
-
const config$
|
|
8938
|
+
const config$f = {
|
|
8889
8939
|
commandName: 'create',
|
|
8890
8940
|
description: '[Deprecated] Create a project report',
|
|
8891
8941
|
hidden: false,
|
|
@@ -8899,14 +8949,14 @@ const config$e = {
|
|
|
8899
8949
|
`
|
|
8900
8950
|
}
|
|
8901
8951
|
const cmdReportCreate = {
|
|
8902
|
-
description: config$
|
|
8903
|
-
hidden: config$
|
|
8904
|
-
run: run$
|
|
8952
|
+
description: config$f.description,
|
|
8953
|
+
hidden: config$f.hidden,
|
|
8954
|
+
run: run$f
|
|
8905
8955
|
}
|
|
8906
|
-
async function run$
|
|
8956
|
+
async function run$f(argv, importMeta, { parentName }) {
|
|
8907
8957
|
meowOrExit({
|
|
8908
8958
|
argv,
|
|
8909
|
-
config: config$
|
|
8959
|
+
config: config$f,
|
|
8910
8960
|
importMeta,
|
|
8911
8961
|
parentName
|
|
8912
8962
|
})
|
|
@@ -8916,7 +8966,7 @@ async function run$e(argv, importMeta, { parentName }) {
|
|
|
8916
8966
|
process.exitCode = 1
|
|
8917
8967
|
}
|
|
8918
8968
|
|
|
8919
|
-
const config$
|
|
8969
|
+
const config$e = {
|
|
8920
8970
|
commandName: 'view',
|
|
8921
8971
|
description: '[Deprecated] View a project report',
|
|
8922
8972
|
hidden: false,
|
|
@@ -8930,14 +8980,14 @@ const config$d = {
|
|
|
8930
8980
|
`
|
|
8931
8981
|
}
|
|
8932
8982
|
const cmdReportView = {
|
|
8933
|
-
description: config$
|
|
8934
|
-
hidden: config$
|
|
8935
|
-
run: run$
|
|
8983
|
+
description: config$e.description,
|
|
8984
|
+
hidden: config$e.hidden,
|
|
8985
|
+
run: run$e
|
|
8936
8986
|
}
|
|
8937
|
-
async function run$
|
|
8987
|
+
async function run$e(argv, importMeta, { parentName }) {
|
|
8938
8988
|
meowOrExit({
|
|
8939
8989
|
argv,
|
|
8940
|
-
config: config$
|
|
8990
|
+
config: config$e,
|
|
8941
8991
|
importMeta,
|
|
8942
8992
|
parentName
|
|
8943
8993
|
})
|
|
@@ -9024,8 +9074,8 @@ async function handleCreateRepo({
|
|
|
9024
9074
|
await outputCreateRepo()
|
|
9025
9075
|
}
|
|
9026
9076
|
|
|
9027
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
9028
|
-
const config$
|
|
9077
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$d } = constants
|
|
9078
|
+
const config$d = {
|
|
9029
9079
|
commandName: 'create',
|
|
9030
9080
|
description: 'Create a repository in an organization',
|
|
9031
9081
|
hidden: false,
|
|
@@ -9078,14 +9128,14 @@ const config$c = {
|
|
|
9078
9128
|
`
|
|
9079
9129
|
}
|
|
9080
9130
|
const cmdReposCreate = {
|
|
9081
|
-
description: config$
|
|
9082
|
-
hidden: config$
|
|
9083
|
-
run: run$
|
|
9131
|
+
description: config$d.description,
|
|
9132
|
+
hidden: config$d.hidden,
|
|
9133
|
+
run: run$d
|
|
9084
9134
|
}
|
|
9085
|
-
async function run$
|
|
9135
|
+
async function run$d(argv, importMeta, { parentName }) {
|
|
9086
9136
|
const cli = meowOrExit({
|
|
9087
9137
|
argv,
|
|
9088
|
-
config: config$
|
|
9138
|
+
config: config$d,
|
|
9089
9139
|
importMeta,
|
|
9090
9140
|
parentName
|
|
9091
9141
|
})
|
|
@@ -9120,7 +9170,7 @@ async function run$c(argv, importMeta, { parentName }) {
|
|
|
9120
9170
|
return
|
|
9121
9171
|
}
|
|
9122
9172
|
if (cli.flags['dryRun']) {
|
|
9123
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
9173
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$d)
|
|
9124
9174
|
return
|
|
9125
9175
|
}
|
|
9126
9176
|
await handleCreateRepo({
|
|
@@ -9149,8 +9199,8 @@ async function handleDeleteRepo(orgSlug, repoName) {
|
|
|
9149
9199
|
spinner.successAndStop('Repository deleted successfully')
|
|
9150
9200
|
}
|
|
9151
9201
|
|
|
9152
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
9153
|
-
const config$
|
|
9202
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$c } = constants
|
|
9203
|
+
const config$c = {
|
|
9154
9204
|
commandName: 'del',
|
|
9155
9205
|
description: 'Delete a repository in an organization',
|
|
9156
9206
|
hidden: false,
|
|
@@ -9173,14 +9223,14 @@ const config$b = {
|
|
|
9173
9223
|
`
|
|
9174
9224
|
}
|
|
9175
9225
|
const cmdReposDel = {
|
|
9176
|
-
description: config$
|
|
9177
|
-
hidden: config$
|
|
9178
|
-
run: run$
|
|
9226
|
+
description: config$c.description,
|
|
9227
|
+
hidden: config$c.hidden,
|
|
9228
|
+
run: run$c
|
|
9179
9229
|
}
|
|
9180
|
-
async function run$
|
|
9230
|
+
async function run$c(argv, importMeta, { parentName }) {
|
|
9181
9231
|
const cli = meowOrExit({
|
|
9182
9232
|
argv,
|
|
9183
|
-
config: config$
|
|
9233
|
+
config: config$c,
|
|
9184
9234
|
importMeta,
|
|
9185
9235
|
parentName
|
|
9186
9236
|
})
|
|
@@ -9215,7 +9265,7 @@ async function run$b(argv, importMeta, { parentName }) {
|
|
|
9215
9265
|
return
|
|
9216
9266
|
}
|
|
9217
9267
|
if (cli.flags['dryRun']) {
|
|
9218
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
9268
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$c)
|
|
9219
9269
|
return
|
|
9220
9270
|
}
|
|
9221
9271
|
await handleDeleteRepo(orgSlug, repoName)
|
|
@@ -9304,8 +9354,8 @@ async function handleListRepos({
|
|
|
9304
9354
|
await outputListRepos(data, outputKind)
|
|
9305
9355
|
}
|
|
9306
9356
|
|
|
9307
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
9308
|
-
const config$
|
|
9357
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$b } = constants
|
|
9358
|
+
const config$b = {
|
|
9309
9359
|
commandName: 'list',
|
|
9310
9360
|
description: 'List repositories in an organization',
|
|
9311
9361
|
hidden: false,
|
|
@@ -9352,14 +9402,14 @@ const config$a = {
|
|
|
9352
9402
|
`
|
|
9353
9403
|
}
|
|
9354
9404
|
const cmdReposList = {
|
|
9355
|
-
description: config$
|
|
9356
|
-
hidden: config$
|
|
9357
|
-
run: run$
|
|
9405
|
+
description: config$b.description,
|
|
9406
|
+
hidden: config$b.hidden,
|
|
9407
|
+
run: run$b
|
|
9358
9408
|
}
|
|
9359
|
-
async function run$
|
|
9409
|
+
async function run$b(argv, importMeta, { parentName }) {
|
|
9360
9410
|
const cli = meowOrExit({
|
|
9361
9411
|
argv,
|
|
9362
|
-
config: config$
|
|
9412
|
+
config: config$b,
|
|
9363
9413
|
importMeta,
|
|
9364
9414
|
parentName
|
|
9365
9415
|
})
|
|
@@ -9396,7 +9446,7 @@ async function run$a(argv, importMeta, { parentName }) {
|
|
|
9396
9446
|
return
|
|
9397
9447
|
}
|
|
9398
9448
|
if (cli.flags['dryRun']) {
|
|
9399
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
9449
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$b)
|
|
9400
9450
|
return
|
|
9401
9451
|
}
|
|
9402
9452
|
await handleListRepos({
|
|
@@ -9466,8 +9516,8 @@ async function handleUpdateRepo({
|
|
|
9466
9516
|
await outputUpdateRepo()
|
|
9467
9517
|
}
|
|
9468
9518
|
|
|
9469
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
9470
|
-
const config$
|
|
9519
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$a } = constants
|
|
9520
|
+
const config$a = {
|
|
9471
9521
|
commandName: 'update',
|
|
9472
9522
|
description: 'Update a repository in an organization',
|
|
9473
9523
|
hidden: false,
|
|
@@ -9520,14 +9570,14 @@ const config$9 = {
|
|
|
9520
9570
|
`
|
|
9521
9571
|
}
|
|
9522
9572
|
const cmdReposUpdate = {
|
|
9523
|
-
description: config$
|
|
9524
|
-
hidden: config$
|
|
9525
|
-
run: run$
|
|
9573
|
+
description: config$a.description,
|
|
9574
|
+
hidden: config$a.hidden,
|
|
9575
|
+
run: run$a
|
|
9526
9576
|
}
|
|
9527
|
-
async function run$
|
|
9577
|
+
async function run$a(argv, importMeta, { parentName }) {
|
|
9528
9578
|
const cli = meowOrExit({
|
|
9529
9579
|
argv,
|
|
9530
|
-
config: config$
|
|
9580
|
+
config: config$a,
|
|
9531
9581
|
importMeta,
|
|
9532
9582
|
parentName
|
|
9533
9583
|
})
|
|
@@ -9562,7 +9612,7 @@ async function run$9(argv, importMeta, { parentName }) {
|
|
|
9562
9612
|
return
|
|
9563
9613
|
}
|
|
9564
9614
|
if (cli.flags['dryRun']) {
|
|
9565
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
9615
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$a)
|
|
9566
9616
|
return
|
|
9567
9617
|
}
|
|
9568
9618
|
await handleUpdateRepo({
|
|
@@ -9664,8 +9714,8 @@ async function handleViewRepo(orgSlug, repoName, outputKind) {
|
|
|
9664
9714
|
await outputViewRepo(data, outputKind)
|
|
9665
9715
|
}
|
|
9666
9716
|
|
|
9667
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
9668
|
-
const config$
|
|
9717
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$9 } = constants
|
|
9718
|
+
const config$9 = {
|
|
9669
9719
|
commandName: 'view',
|
|
9670
9720
|
description: 'View repositories in an organization',
|
|
9671
9721
|
hidden: false,
|
|
@@ -9694,14 +9744,14 @@ const config$8 = {
|
|
|
9694
9744
|
`
|
|
9695
9745
|
}
|
|
9696
9746
|
const cmdReposView = {
|
|
9697
|
-
description: config$
|
|
9698
|
-
hidden: config$
|
|
9699
|
-
run: run$
|
|
9747
|
+
description: config$9.description,
|
|
9748
|
+
hidden: config$9.hidden,
|
|
9749
|
+
run: run$9
|
|
9700
9750
|
}
|
|
9701
|
-
async function run$
|
|
9751
|
+
async function run$9(argv, importMeta, { parentName }) {
|
|
9702
9752
|
const cli = meowOrExit({
|
|
9703
9753
|
argv,
|
|
9704
|
-
config: config$
|
|
9754
|
+
config: config$9,
|
|
9705
9755
|
importMeta,
|
|
9706
9756
|
parentName
|
|
9707
9757
|
})
|
|
@@ -9744,7 +9794,7 @@ async function run$8(argv, importMeta, { parentName }) {
|
|
|
9744
9794
|
return
|
|
9745
9795
|
}
|
|
9746
9796
|
if (cli.flags['dryRun']) {
|
|
9747
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$
|
|
9797
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$9)
|
|
9748
9798
|
return
|
|
9749
9799
|
}
|
|
9750
9800
|
await handleViewRepo(
|
|
@@ -9839,8 +9889,8 @@ async function suggestTarget() {
|
|
|
9839
9889
|
}
|
|
9840
9890
|
}
|
|
9841
9891
|
|
|
9842
|
-
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$
|
|
9843
|
-
const config$
|
|
9892
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$8 } = constants
|
|
9893
|
+
const config$8 = {
|
|
9844
9894
|
commandName: 'create',
|
|
9845
9895
|
description: 'Create a scan',
|
|
9846
9896
|
hidden: false,
|
|
@@ -9946,6 +9996,9 @@ const config$7 = {
|
|
|
9946
9996
|
When a FILE is given only that FILE is targeted. Otherwise any eligible
|
|
9947
9997
|
files in the given DIR will be considered.
|
|
9948
9998
|
|
|
9999
|
+
The --repo and --branch flags tell Socket to associate this Scan with that
|
|
10000
|
+
repo/branch. The names will show up on your dashboard on the Socket website.
|
|
10001
|
+
|
|
9949
10002
|
Note: for a first run you probably want to set --defaultBranch to indicate
|
|
9950
10003
|
the default branch name, like "main" or "master".
|
|
9951
10004
|
|
|
@@ -9960,14 +10013,14 @@ const config$7 = {
|
|
|
9960
10013
|
`
|
|
9961
10014
|
}
|
|
9962
10015
|
const cmdScanCreate = {
|
|
9963
|
-
description: config$
|
|
9964
|
-
hidden: config$
|
|
9965
|
-
run: run$
|
|
10016
|
+
description: config$8.description,
|
|
10017
|
+
hidden: config$8.hidden,
|
|
10018
|
+
run: run$8
|
|
9966
10019
|
}
|
|
9967
|
-
async function run$
|
|
10020
|
+
async function run$8(argv, importMeta, { parentName }) {
|
|
9968
10021
|
const cli = meowOrExit({
|
|
9969
10022
|
argv,
|
|
9970
|
-
config: config$
|
|
10023
|
+
config: config$8,
|
|
9971
10024
|
importMeta,
|
|
9972
10025
|
parentName
|
|
9973
10026
|
})
|
|
@@ -10019,154 +10072,484 @@ async function run$7(argv, importMeta, { parentName }) {
|
|
|
10019
10072
|
if (suggestion) {
|
|
10020
10073
|
orgSlug = suggestion
|
|
10021
10074
|
}
|
|
10022
|
-
updatedInput = true
|
|
10075
|
+
updatedInput = true
|
|
10076
|
+
}
|
|
10077
|
+
}
|
|
10078
|
+
if (updatedInput && orgSlug && targets?.length) {
|
|
10079
|
+
logger.logger.error(
|
|
10080
|
+
'Note: You can invoke this command next time to skip the interactive questions:'
|
|
10081
|
+
)
|
|
10082
|
+
logger.logger.error('```')
|
|
10083
|
+
logger.logger.error(
|
|
10084
|
+
` socket scan create [other flags...] ${defaultOrgSlug ? '' : orgSlug} ${targets.join(' ')}`
|
|
10085
|
+
)
|
|
10086
|
+
logger.logger.error('```\n')
|
|
10087
|
+
}
|
|
10088
|
+
const wasBadInput = handleBadInput(
|
|
10089
|
+
{
|
|
10090
|
+
nook: !!defaultOrgSlug,
|
|
10091
|
+
test: !!orgSlug && orgSlug !== '.',
|
|
10092
|
+
message: 'Org name as the first argument',
|
|
10093
|
+
pass: 'ok',
|
|
10094
|
+
fail:
|
|
10095
|
+
orgSlug === '.'
|
|
10096
|
+
? 'dot is an invalid org, most likely you forgot the org name here?'
|
|
10097
|
+
: 'missing'
|
|
10098
|
+
},
|
|
10099
|
+
{
|
|
10100
|
+
test: !!targets.length,
|
|
10101
|
+
message: 'At least one TARGET (e.g. `.` or `./package.json`)',
|
|
10102
|
+
pass: 'ok',
|
|
10103
|
+
fail: 'missing (or perhaps you forgot the org slug?)'
|
|
10104
|
+
},
|
|
10105
|
+
{
|
|
10106
|
+
nook: true,
|
|
10107
|
+
test: !json || !markdown,
|
|
10108
|
+
message: 'The json and markdown flags cannot be both set, pick one',
|
|
10109
|
+
pass: 'ok',
|
|
10110
|
+
fail: 'omit one'
|
|
10111
|
+
},
|
|
10112
|
+
{
|
|
10113
|
+
nook: true,
|
|
10114
|
+
test: !!apiToken,
|
|
10115
|
+
message: 'This command requires an API token for access',
|
|
10116
|
+
pass: 'ok',
|
|
10117
|
+
fail: 'missing (try `socket login`)'
|
|
10118
|
+
},
|
|
10119
|
+
{
|
|
10120
|
+
nook: true,
|
|
10121
|
+
test: !pendingHead || !tmp,
|
|
10122
|
+
message: 'Can not use --pendingHead and --tmp at the same time',
|
|
10123
|
+
pass: 'ok',
|
|
10124
|
+
fail: 'remove at least one flag'
|
|
10125
|
+
},
|
|
10126
|
+
{
|
|
10127
|
+
nook: true,
|
|
10128
|
+
test: !pendingHead || !!branchName,
|
|
10129
|
+
message: 'When --pendingHead is set, --branch is mandatory',
|
|
10130
|
+
pass: 'ok',
|
|
10131
|
+
fail: 'missing branch name'
|
|
10132
|
+
},
|
|
10133
|
+
{
|
|
10134
|
+
nook: true,
|
|
10135
|
+
test: !defaultBranch || !!branchName,
|
|
10136
|
+
message: 'When --defaultBranch is set, --branch is mandatory',
|
|
10137
|
+
pass: 'ok',
|
|
10138
|
+
fail: 'missing branch name'
|
|
10139
|
+
}
|
|
10140
|
+
)
|
|
10141
|
+
if (wasBadInput) {
|
|
10142
|
+
return
|
|
10143
|
+
}
|
|
10144
|
+
|
|
10145
|
+
// Note exiting earlier to skirt a hidden auth requirement
|
|
10146
|
+
if (dryRun) {
|
|
10147
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$8)
|
|
10148
|
+
return
|
|
10149
|
+
}
|
|
10150
|
+
await handleCreateNewScan({
|
|
10151
|
+
branchName: branchName,
|
|
10152
|
+
commitHash: (commitHash && String(commitHash)) || '',
|
|
10153
|
+
commitMessage: (commitMessage && String(commitMessage)) || '',
|
|
10154
|
+
committers: (committers && String(committers)) || '',
|
|
10155
|
+
cwd,
|
|
10156
|
+
defaultBranch: Boolean(defaultBranch),
|
|
10157
|
+
orgSlug,
|
|
10158
|
+
outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
|
|
10159
|
+
pendingHead: Boolean(pendingHead),
|
|
10160
|
+
pullRequest: Number(pullRequest),
|
|
10161
|
+
readOnly: Boolean(readOnly),
|
|
10162
|
+
repoName: repoName,
|
|
10163
|
+
report,
|
|
10164
|
+
targets,
|
|
10165
|
+
tmp: Boolean(tmp)
|
|
10166
|
+
})
|
|
10167
|
+
}
|
|
10168
|
+
|
|
10169
|
+
async function fetchDeleteOrgFullScan(orgSlug, scanId) {
|
|
10170
|
+
const sockSdk = await shadowNpmInject.setupSdk()
|
|
10171
|
+
|
|
10172
|
+
// Lazily access constants.spinner.
|
|
10173
|
+
const { spinner } = constants
|
|
10174
|
+
spinner.start('Requesting the scan to be deleted...')
|
|
10175
|
+
const result = await handleApiCall(
|
|
10176
|
+
sockSdk.deleteOrgFullScan(orgSlug, scanId),
|
|
10177
|
+
'Deleting scan'
|
|
10178
|
+
)
|
|
10179
|
+
spinner.successAndStop('Received response for deleting a scan.')
|
|
10180
|
+
if (!result.success) {
|
|
10181
|
+
handleUnsuccessfulApiResponse('deleteOrgFullScan', result)
|
|
10182
|
+
}
|
|
10183
|
+
return result.data
|
|
10184
|
+
}
|
|
10185
|
+
|
|
10186
|
+
async function outputDeleteScan(_data) {
|
|
10187
|
+
logger.logger.success('Scan deleted successfully')
|
|
10188
|
+
}
|
|
10189
|
+
|
|
10190
|
+
async function handleDeleteScan(orgSlug, scanId) {
|
|
10191
|
+
const data = await fetchDeleteOrgFullScan(orgSlug, scanId)
|
|
10192
|
+
if (!data) {
|
|
10193
|
+
return
|
|
10194
|
+
}
|
|
10195
|
+
await outputDeleteScan()
|
|
10196
|
+
}
|
|
10197
|
+
|
|
10198
|
+
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$7 } = constants
|
|
10199
|
+
const config$7 = {
|
|
10200
|
+
commandName: 'del',
|
|
10201
|
+
description: 'Delete a scan',
|
|
10202
|
+
hidden: false,
|
|
10203
|
+
flags: {
|
|
10204
|
+
...commonFlags,
|
|
10205
|
+
...outputFlags
|
|
10206
|
+
},
|
|
10207
|
+
help: (command, config) => `
|
|
10208
|
+
Usage
|
|
10209
|
+
$ ${command} <org slug> <scan ID>
|
|
10210
|
+
|
|
10211
|
+
API Token Requirements
|
|
10212
|
+
- Quota: 1 unit
|
|
10213
|
+
- Permissions: full-scans:delete
|
|
10214
|
+
|
|
10215
|
+
Options
|
|
10216
|
+
${getFlagListOutput(config.flags, 6)}
|
|
10217
|
+
|
|
10218
|
+
Examples
|
|
10219
|
+
$ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
10220
|
+
`
|
|
10221
|
+
}
|
|
10222
|
+
const cmdScanDel = {
|
|
10223
|
+
description: config$7.description,
|
|
10224
|
+
hidden: config$7.hidden,
|
|
10225
|
+
run: run$7
|
|
10226
|
+
}
|
|
10227
|
+
async function run$7(argv, importMeta, { parentName }) {
|
|
10228
|
+
const cli = meowOrExit({
|
|
10229
|
+
argv,
|
|
10230
|
+
config: config$7,
|
|
10231
|
+
importMeta,
|
|
10232
|
+
parentName
|
|
10233
|
+
})
|
|
10234
|
+
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
10235
|
+
const orgSlug = defaultOrgSlug || cli.input[0] || ''
|
|
10236
|
+
const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
|
|
10237
|
+
const apiToken = shadowNpmInject.getDefaultToken()
|
|
10238
|
+
const wasBadInput = handleBadInput(
|
|
10239
|
+
{
|
|
10240
|
+
nook: !!defaultOrgSlug,
|
|
10241
|
+
test: !!orgSlug && orgSlug !== '.',
|
|
10242
|
+
message: 'Org name as the first argument',
|
|
10243
|
+
pass: 'ok',
|
|
10244
|
+
fail:
|
|
10245
|
+
orgSlug === '.'
|
|
10246
|
+
? 'dot is an invalid org, most likely you forgot the org name here?'
|
|
10247
|
+
: 'missing'
|
|
10248
|
+
},
|
|
10249
|
+
{
|
|
10250
|
+
test: !!scanId,
|
|
10251
|
+
message: 'Scan ID to delete',
|
|
10252
|
+
pass: 'ok',
|
|
10253
|
+
fail: 'missing'
|
|
10254
|
+
},
|
|
10255
|
+
{
|
|
10256
|
+
nook: true,
|
|
10257
|
+
test: !!apiToken,
|
|
10258
|
+
message:
|
|
10259
|
+
'You need to be logged in to use this command. See `socket login`.',
|
|
10260
|
+
pass: 'ok',
|
|
10261
|
+
fail: 'missing API token'
|
|
10262
|
+
}
|
|
10263
|
+
)
|
|
10264
|
+
if (wasBadInput) {
|
|
10265
|
+
return
|
|
10266
|
+
}
|
|
10267
|
+
if (cli.flags['dryRun']) {
|
|
10268
|
+
logger.logger.log(DRY_RUN_BAIL_TEXT$7)
|
|
10269
|
+
return
|
|
10270
|
+
}
|
|
10271
|
+
await handleDeleteScan(orgSlug, scanId)
|
|
10272
|
+
}
|
|
10273
|
+
|
|
10274
|
+
async function fetchDiffScan({ id1, id2, orgSlug }) {
|
|
10275
|
+
const apiToken = shadowNpmInject.getDefaultToken()
|
|
10276
|
+
|
|
10277
|
+
// Lazily access constants.spinner.
|
|
10278
|
+
const { spinner } = constants
|
|
10279
|
+
logger.logger.error('Scan ID 1:', id1)
|
|
10280
|
+
logger.logger.error('Scan ID 2:', id2)
|
|
10281
|
+
spinner.start('Fetching scan diff... (this may take a while)')
|
|
10282
|
+
const response = await queryApi(
|
|
10283
|
+
`orgs/${orgSlug}/full-scans/diff?before=${encodeURIComponent(id1)}&after=${encodeURIComponent(id2)}`,
|
|
10284
|
+
apiToken || ''
|
|
10285
|
+
)
|
|
10286
|
+
spinner.successAndStop('Received scan diff response')
|
|
10287
|
+
if (!response.ok) {
|
|
10288
|
+
const err = await handleApiError(response.status)
|
|
10289
|
+
logger.logger.fail(failMsgWithBadge(response.statusText, err))
|
|
10290
|
+
return
|
|
10291
|
+
}
|
|
10292
|
+
const result = await handleApiCall(
|
|
10293
|
+
await response.json(),
|
|
10294
|
+
'Deserializing json'
|
|
10295
|
+
)
|
|
10296
|
+
return result
|
|
10297
|
+
}
|
|
10298
|
+
|
|
10299
|
+
const SOCKET_SBOM_URL_PREFIX$1 =
|
|
10300
|
+
'https://socket.dev/dashboard/org/SocketDev/sbom/'
|
|
10301
|
+
async function outputDiffScan(result, { depth, file, outputKind }) {
|
|
10302
|
+
const dashboardUrl = result.diff_report_url
|
|
10303
|
+
const dashboardMessage = dashboardUrl
|
|
10304
|
+
? `\n View this diff scan in the Socket dashboard: ${vendor.yoctocolorsCjsExports.cyan(dashboardUrl)}`
|
|
10305
|
+
: ''
|
|
10306
|
+
|
|
10307
|
+
// When forcing json, or dumping to file, serialize to string such that it
|
|
10308
|
+
// won't get truncated. The only way to dump the full raw JSON to stdout is
|
|
10309
|
+
// to use `--json --file -` (the dash is a standard notation for stdout)
|
|
10310
|
+
if (outputKind === 'json' || file) {
|
|
10311
|
+
let json
|
|
10312
|
+
try {
|
|
10313
|
+
json = JSON.stringify(result, null, 2)
|
|
10314
|
+
} catch (e) {
|
|
10315
|
+
process.exitCode = 1
|
|
10316
|
+
// Most likely caused by a circular reference (or OOM)
|
|
10317
|
+
logger.logger.fail('There was a problem converting the data to JSON')
|
|
10318
|
+
logger.logger.error(e)
|
|
10319
|
+
return
|
|
10320
|
+
}
|
|
10321
|
+
if (file && file !== '-') {
|
|
10322
|
+
logger.logger.log(`Writing json to \`${file}\``)
|
|
10323
|
+
fs$1.writeFile(file, JSON.stringify(result, null, 2), err => {
|
|
10324
|
+
if (err) {
|
|
10325
|
+
logger.logger.fail(`Writing to \`${file}\` failed...`)
|
|
10326
|
+
logger.logger.error(err)
|
|
10327
|
+
} else {
|
|
10328
|
+
logger.logger.log(`Data successfully written to \`${file}\``)
|
|
10329
|
+
}
|
|
10330
|
+
logger.logger.error(dashboardMessage)
|
|
10331
|
+
})
|
|
10332
|
+
} else {
|
|
10333
|
+
// TODO: expose different method for writing to stderr when simply dodging stdout
|
|
10334
|
+
logger.logger.error(`\n Diff scan result: \n`)
|
|
10335
|
+
logger.logger.log(json)
|
|
10336
|
+
logger.logger.error(dashboardMessage)
|
|
10337
|
+
}
|
|
10338
|
+
return
|
|
10339
|
+
}
|
|
10340
|
+
if (outputKind === 'markdown') {
|
|
10341
|
+
logger.logger.log('# Scan diff result')
|
|
10342
|
+
logger.logger.log('')
|
|
10343
|
+
logger.logger.log(
|
|
10344
|
+
'This Socket.dev report shows the changes between two scans:'
|
|
10345
|
+
)
|
|
10346
|
+
logger.logger.log(
|
|
10347
|
+
`- [${result.before.id}](${SOCKET_SBOM_URL_PREFIX$1}${result.before.id})`
|
|
10348
|
+
)
|
|
10349
|
+
logger.logger.log(
|
|
10350
|
+
`- [${result.after.id}](${SOCKET_SBOM_URL_PREFIX$1}${result.after.id})`
|
|
10351
|
+
)
|
|
10352
|
+
logger.logger.log('')
|
|
10353
|
+
logger.logger.log(
|
|
10354
|
+
`You can [view this report in your dashboard](${result.diff_report_url})`
|
|
10355
|
+
)
|
|
10356
|
+
logger.logger.log('')
|
|
10357
|
+
logger.logger.log('## Changes')
|
|
10358
|
+
logger.logger.log('')
|
|
10359
|
+
logger.logger.log(
|
|
10360
|
+
`- directDependenciesChanged: ${result.directDependenciesChanged}`
|
|
10361
|
+
)
|
|
10362
|
+
logger.logger.log(`- Added packages: ${result.artifacts.added.length}`)
|
|
10363
|
+
if (result.artifacts.added.length > 0) {
|
|
10364
|
+
result.artifacts.added.slice(0, 10).forEach(artifact => {
|
|
10365
|
+
logger.logger.log(
|
|
10366
|
+
` - ${artifact.type} ${artifact.name}@${artifact.version}`
|
|
10367
|
+
)
|
|
10368
|
+
})
|
|
10369
|
+
if (result.artifacts.added.length > 10) {
|
|
10370
|
+
logger.logger.log(
|
|
10371
|
+
` ... and ${result.artifacts.added.length - 10} more`
|
|
10372
|
+
)
|
|
10373
|
+
}
|
|
10374
|
+
}
|
|
10375
|
+
logger.logger.log(`- Removed packages: ${result.artifacts.removed.length}`)
|
|
10376
|
+
if (result.artifacts.removed.length > 0) {
|
|
10377
|
+
result.artifacts.removed.slice(0, 10).forEach(artifact => {
|
|
10378
|
+
logger.logger.log(
|
|
10379
|
+
` - ${artifact.type} ${artifact.name}@${artifact.version}`
|
|
10380
|
+
)
|
|
10381
|
+
})
|
|
10382
|
+
if (result.artifacts.removed.length > 10) {
|
|
10383
|
+
logger.logger.log(
|
|
10384
|
+
` ... and ${result.artifacts.removed.length - 10} more`
|
|
10385
|
+
)
|
|
10386
|
+
}
|
|
10387
|
+
}
|
|
10388
|
+
logger.logger.log(
|
|
10389
|
+
`- Replaced packages: ${result.artifacts.replaced.length}`
|
|
10390
|
+
)
|
|
10391
|
+
if (result.artifacts.replaced.length > 0) {
|
|
10392
|
+
result.artifacts.replaced.slice(0, 10).forEach(artifact => {
|
|
10393
|
+
logger.logger.log(
|
|
10394
|
+
` - ${artifact.type} ${artifact.name}@${artifact.version}`
|
|
10395
|
+
)
|
|
10396
|
+
})
|
|
10397
|
+
if (result.artifacts.replaced.length > 10) {
|
|
10398
|
+
logger.logger.log(
|
|
10399
|
+
` ... and ${result.artifacts.replaced.length - 10} more`
|
|
10400
|
+
)
|
|
10401
|
+
}
|
|
10402
|
+
}
|
|
10403
|
+
logger.logger.log(`- Updated packages: ${result.artifacts.updated.length}`)
|
|
10404
|
+
if (result.artifacts.updated.length > 0) {
|
|
10405
|
+
result.artifacts.updated.slice(0, 10).forEach(artifact => {
|
|
10406
|
+
logger.logger.log(
|
|
10407
|
+
` - ${artifact.type} ${artifact.name}@${artifact.version}`
|
|
10408
|
+
)
|
|
10409
|
+
})
|
|
10410
|
+
if (result.artifacts.updated.length > 10) {
|
|
10411
|
+
logger.logger.log(
|
|
10412
|
+
` ... and ${result.artifacts.updated.length - 10} more`
|
|
10413
|
+
)
|
|
10414
|
+
}
|
|
10415
|
+
}
|
|
10416
|
+
logger.logger.log(
|
|
10417
|
+
`- Unchanged packages: ${result.artifacts.unchanged.length}`
|
|
10418
|
+
)
|
|
10419
|
+
if (result.artifacts.unchanged.length > 0) {
|
|
10420
|
+
result.artifacts.unchanged.slice(0, 10).forEach(artifact => {
|
|
10421
|
+
logger.logger.log(
|
|
10422
|
+
` - ${artifact.type} ${artifact.name}@${artifact.version}`
|
|
10423
|
+
)
|
|
10424
|
+
})
|
|
10425
|
+
if (result.artifacts.unchanged.length > 10) {
|
|
10426
|
+
logger.logger.log(
|
|
10427
|
+
` ... and ${result.artifacts.unchanged.length - 10} more`
|
|
10428
|
+
)
|
|
10429
|
+
}
|
|
10023
10430
|
}
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
logger.logger.
|
|
10027
|
-
|
|
10431
|
+
logger.logger.log('')
|
|
10432
|
+
logger.logger.log(`## Scan ${result.before.id}`)
|
|
10433
|
+
logger.logger.log('')
|
|
10434
|
+
logger.logger.log(
|
|
10435
|
+
'This Scan was considered to be the "base" / "from" / "before" Scan.'
|
|
10028
10436
|
)
|
|
10029
|
-
logger.logger.
|
|
10030
|
-
|
|
10031
|
-
|
|
10437
|
+
logger.logger.log('')
|
|
10438
|
+
for (const [key, value] of Object.entries(result.before)) {
|
|
10439
|
+
if (key === 'pull_request' && !value) {
|
|
10440
|
+
continue
|
|
10441
|
+
}
|
|
10442
|
+
if (!['id', 'organization_id', 'repository_id'].includes(key)) {
|
|
10443
|
+
logger.logger.group(
|
|
10444
|
+
`- ${key === 'repository_slug' ? 'repo' : key === 'organization_slug' ? 'org' : key}: ${value}`
|
|
10445
|
+
)
|
|
10446
|
+
logger.logger.groupEnd()
|
|
10447
|
+
}
|
|
10448
|
+
}
|
|
10449
|
+
logger.logger.log('')
|
|
10450
|
+
logger.logger.log(`## Scan ${result.after.id}`)
|
|
10451
|
+
logger.logger.log('')
|
|
10452
|
+
logger.logger.log(
|
|
10453
|
+
'This Scan was considered to be the "head" / "to" / "after" Scan.'
|
|
10032
10454
|
)
|
|
10033
|
-
logger.logger.
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
: 'missing'
|
|
10045
|
-
},
|
|
10046
|
-
{
|
|
10047
|
-
test: !!targets.length,
|
|
10048
|
-
message: 'At least one TARGET (e.g. `.` or `./package.json`)',
|
|
10049
|
-
pass: 'ok',
|
|
10050
|
-
fail: 'missing (or perhaps you forgot the org slug?)'
|
|
10051
|
-
},
|
|
10052
|
-
{
|
|
10053
|
-
nook: true,
|
|
10054
|
-
test: !json || !markdown,
|
|
10055
|
-
message: 'The json and markdown flags cannot be both set, pick one',
|
|
10056
|
-
pass: 'ok',
|
|
10057
|
-
fail: 'omit one'
|
|
10058
|
-
},
|
|
10059
|
-
{
|
|
10060
|
-
nook: true,
|
|
10061
|
-
test: !!apiToken,
|
|
10062
|
-
message: 'This command requires an API token for access',
|
|
10063
|
-
pass: 'ok',
|
|
10064
|
-
fail: 'missing (try `socket login`)'
|
|
10065
|
-
},
|
|
10066
|
-
{
|
|
10067
|
-
nook: true,
|
|
10068
|
-
test: !pendingHead || !tmp,
|
|
10069
|
-
message: 'Can not use --pendingHead and --tmp at the same time',
|
|
10070
|
-
pass: 'ok',
|
|
10071
|
-
fail: 'remove at least one flag'
|
|
10072
|
-
},
|
|
10073
|
-
{
|
|
10074
|
-
nook: true,
|
|
10075
|
-
test: !pendingHead || !!branchName,
|
|
10076
|
-
message: 'When --pendingHead is set, --branch is mandatory',
|
|
10077
|
-
pass: 'ok',
|
|
10078
|
-
fail: 'missing branch name'
|
|
10079
|
-
},
|
|
10080
|
-
{
|
|
10081
|
-
nook: true,
|
|
10082
|
-
test: !defaultBranch || !!branchName,
|
|
10083
|
-
message: 'When --defaultBranch is set, --branch is mandatory',
|
|
10084
|
-
pass: 'ok',
|
|
10085
|
-
fail: 'missing branch name'
|
|
10455
|
+
logger.logger.log('')
|
|
10456
|
+
for (const [key, value] of Object.entries(result.after)) {
|
|
10457
|
+
if (key === 'pull_request' && !value) {
|
|
10458
|
+
continue
|
|
10459
|
+
}
|
|
10460
|
+
if (!['id', 'organization_id', 'repository_id'].includes(key)) {
|
|
10461
|
+
logger.logger.group(
|
|
10462
|
+
`- ${key === 'repository_slug' ? 'repo' : key === 'organization_slug' ? 'org' : key}: ${value}`
|
|
10463
|
+
)
|
|
10464
|
+
logger.logger.groupEnd()
|
|
10465
|
+
}
|
|
10086
10466
|
}
|
|
10087
|
-
|
|
10088
|
-
if (wasBadInput) {
|
|
10089
|
-
return
|
|
10090
|
-
}
|
|
10091
|
-
|
|
10092
|
-
// Note exiting earlier to skirt a hidden auth requirement
|
|
10093
|
-
if (dryRun) {
|
|
10094
|
-
logger.logger.log(DRY_RUN_BAIL_TEXT$7)
|
|
10467
|
+
logger.logger.log('')
|
|
10095
10468
|
return
|
|
10096
10469
|
}
|
|
10097
|
-
await handleCreateNewScan({
|
|
10098
|
-
branchName: branchName,
|
|
10099
|
-
commitHash: (commitHash && String(commitHash)) || '',
|
|
10100
|
-
commitMessage: (commitMessage && String(commitMessage)) || '',
|
|
10101
|
-
committers: (committers && String(committers)) || '',
|
|
10102
|
-
cwd,
|
|
10103
|
-
defaultBranch: Boolean(defaultBranch),
|
|
10104
|
-
orgSlug,
|
|
10105
|
-
outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
|
|
10106
|
-
pendingHead: Boolean(pendingHead),
|
|
10107
|
-
pullRequest: Number(pullRequest),
|
|
10108
|
-
readOnly: Boolean(readOnly),
|
|
10109
|
-
repoName: repoName,
|
|
10110
|
-
report,
|
|
10111
|
-
targets,
|
|
10112
|
-
tmp: Boolean(tmp)
|
|
10113
|
-
})
|
|
10114
|
-
}
|
|
10115
10470
|
|
|
10116
|
-
|
|
10117
|
-
|
|
10471
|
+
// In this case neither the --json nor the --file flag was passed
|
|
10472
|
+
// Dump the JSON to CLI and let NodeJS deal with truncation
|
|
10118
10473
|
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10474
|
+
logger.logger.log('Diff scan result:')
|
|
10475
|
+
logger.logger.log(
|
|
10476
|
+
require$$0.inspect(result, {
|
|
10477
|
+
showHidden: false,
|
|
10478
|
+
depth: depth > 0 ? depth : null,
|
|
10479
|
+
colors: true,
|
|
10480
|
+
maxArrayLength: null
|
|
10481
|
+
})
|
|
10125
10482
|
)
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
return result.data
|
|
10131
|
-
}
|
|
10132
|
-
|
|
10133
|
-
async function outputDeleteScan(_data) {
|
|
10134
|
-
logger.logger.success('Scan deleted successfully')
|
|
10483
|
+
logger.logger.error(
|
|
10484
|
+
`\n 📝 To display the detailed report in the terminal, use the --json flag. For a friendlier report, use the --markdown flag.\n`
|
|
10485
|
+
)
|
|
10486
|
+
logger.logger.log(dashboardMessage)
|
|
10135
10487
|
}
|
|
10136
10488
|
|
|
10137
|
-
async function
|
|
10138
|
-
const data = await
|
|
10489
|
+
async function handleDiffScan({ depth, file, id1, id2, orgSlug, outputKind }) {
|
|
10490
|
+
const data = await fetchDiffScan({
|
|
10491
|
+
id1,
|
|
10492
|
+
id2,
|
|
10493
|
+
orgSlug
|
|
10494
|
+
})
|
|
10139
10495
|
if (!data) {
|
|
10140
10496
|
return
|
|
10141
10497
|
}
|
|
10142
|
-
await
|
|
10498
|
+
await outputDiffScan(data, {
|
|
10499
|
+
depth,
|
|
10500
|
+
file,
|
|
10501
|
+
outputKind
|
|
10502
|
+
})
|
|
10143
10503
|
}
|
|
10144
10504
|
|
|
10145
10505
|
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$6 } = constants
|
|
10506
|
+
const SOCKET_SBOM_URL_PREFIX =
|
|
10507
|
+
'https://socket.dev/dashboard/org/SocketDev/sbom/'
|
|
10146
10508
|
const config$6 = {
|
|
10147
|
-
commandName: '
|
|
10148
|
-
description: '
|
|
10509
|
+
commandName: 'diff',
|
|
10510
|
+
description: 'See what changed between two Scans',
|
|
10149
10511
|
hidden: false,
|
|
10150
10512
|
flags: {
|
|
10151
10513
|
...commonFlags,
|
|
10152
|
-
...outputFlags
|
|
10514
|
+
...outputFlags,
|
|
10515
|
+
depth: {
|
|
10516
|
+
type: 'number',
|
|
10517
|
+
default: 2,
|
|
10518
|
+
description:
|
|
10519
|
+
'Max depth of JSON to display before truncating, use zero for no limit (without --json/--file)'
|
|
10520
|
+
},
|
|
10521
|
+
file: {
|
|
10522
|
+
type: 'string',
|
|
10523
|
+
shortFlag: 'f',
|
|
10524
|
+
default: '',
|
|
10525
|
+
description:
|
|
10526
|
+
'Path to a local file where the output should be saved. Use `-` to force stdout.'
|
|
10527
|
+
}
|
|
10153
10528
|
},
|
|
10154
10529
|
help: (command, config) => `
|
|
10155
10530
|
Usage
|
|
10156
|
-
$ ${command} <org slug> <
|
|
10531
|
+
$ ${command} <org slug> <ID1> <ID2>
|
|
10157
10532
|
|
|
10158
10533
|
API Token Requirements
|
|
10159
10534
|
- Quota: 1 unit
|
|
10160
|
-
- Permissions: full-scans:
|
|
10535
|
+
- Permissions: full-scans:list
|
|
10536
|
+
|
|
10537
|
+
This command displays the package changes between two scans. The full output
|
|
10538
|
+
can be pretty large depending on the size of your repo and time range. It is
|
|
10539
|
+
best stored to disk (with --json) to be further analyzed by other tools.
|
|
10540
|
+
|
|
10541
|
+
Note: First Scan ID is assumed to be the older ID. This is only relevant for
|
|
10542
|
+
the added/removed list (similar to diffing two files with git).
|
|
10161
10543
|
|
|
10162
10544
|
Options
|
|
10163
10545
|
${getFlagListOutput(config.flags, 6)}
|
|
10164
10546
|
|
|
10165
10547
|
Examples
|
|
10166
|
-
$ ${command}
|
|
10548
|
+
$ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
|
|
10549
|
+
$ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1 --json
|
|
10167
10550
|
`
|
|
10168
10551
|
}
|
|
10169
|
-
const
|
|
10552
|
+
const cmdScanDiff = {
|
|
10170
10553
|
description: config$6.description,
|
|
10171
10554
|
hidden: config$6.hidden,
|
|
10172
10555
|
run: run$6
|
|
@@ -10178,27 +10561,46 @@ async function run$6(argv, importMeta, { parentName }) {
|
|
|
10178
10561
|
importMeta,
|
|
10179
10562
|
parentName
|
|
10180
10563
|
})
|
|
10564
|
+
const { depth, file, json, markdown } = cli.flags
|
|
10181
10565
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
10182
10566
|
const orgSlug = defaultOrgSlug || cli.input[0] || ''
|
|
10183
|
-
|
|
10567
|
+
let id1 = cli.input[defaultOrgSlug ? 0 : 1] || ''
|
|
10568
|
+
let id2 = cli.input[defaultOrgSlug ? 1 : 2] || ''
|
|
10569
|
+
if (id1.startsWith(SOCKET_SBOM_URL_PREFIX)) {
|
|
10570
|
+
id1 = id1.slice(SOCKET_SBOM_URL_PREFIX.length)
|
|
10571
|
+
}
|
|
10572
|
+
if (id2.startsWith(SOCKET_SBOM_URL_PREFIX)) {
|
|
10573
|
+
id2 = id2.slice(SOCKET_SBOM_URL_PREFIX.length)
|
|
10574
|
+
}
|
|
10184
10575
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
10185
10576
|
const wasBadInput = handleBadInput(
|
|
10186
10577
|
{
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10578
|
+
test: !!(id1 && id2),
|
|
10579
|
+
message:
|
|
10580
|
+
'Specify two Scan IDs.\nA Scan ID looks like `aaa0aa0a-aaaa-0000-0a0a-0000000a00a0`.',
|
|
10190
10581
|
pass: 'ok',
|
|
10191
10582
|
fail:
|
|
10192
|
-
|
|
10193
|
-
? '
|
|
10194
|
-
:
|
|
10583
|
+
!id1 && !id2
|
|
10584
|
+
? 'missing both Scan IDs'
|
|
10585
|
+
: !id2
|
|
10586
|
+
? 'missing second Scan ID'
|
|
10587
|
+
: 'missing first Scan ID' // Not sure how this can happen but ok.
|
|
10195
10588
|
},
|
|
10196
10589
|
{
|
|
10197
|
-
test: !!
|
|
10198
|
-
|
|
10590
|
+
test: !!orgSlug,
|
|
10591
|
+
nook: true,
|
|
10592
|
+
message: 'Org name as the first argument',
|
|
10199
10593
|
pass: 'ok',
|
|
10200
10594
|
fail: 'missing'
|
|
10201
10595
|
},
|
|
10596
|
+
{
|
|
10597
|
+
nook: true,
|
|
10598
|
+
test: !json || !markdown,
|
|
10599
|
+
message:
|
|
10600
|
+
'The `--json` and `--markdown` flags can not be used at the same time',
|
|
10601
|
+
pass: 'ok',
|
|
10602
|
+
fail: 'bad'
|
|
10603
|
+
},
|
|
10202
10604
|
{
|
|
10203
10605
|
nook: true,
|
|
10204
10606
|
test: !!apiToken,
|
|
@@ -10215,15 +10617,24 @@ async function run$6(argv, importMeta, { parentName }) {
|
|
|
10215
10617
|
logger.logger.log(DRY_RUN_BAIL_TEXT$6)
|
|
10216
10618
|
return
|
|
10217
10619
|
}
|
|
10218
|
-
await
|
|
10620
|
+
await handleDiffScan({
|
|
10621
|
+
id1: String(id1 || ''),
|
|
10622
|
+
id2: String(id2 || ''),
|
|
10623
|
+
depth: Number(depth),
|
|
10624
|
+
orgSlug,
|
|
10625
|
+
outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
|
|
10626
|
+
file: String(file || '')
|
|
10627
|
+
})
|
|
10219
10628
|
}
|
|
10220
10629
|
|
|
10221
10630
|
async function fetchListScans({
|
|
10631
|
+
branch,
|
|
10222
10632
|
direction,
|
|
10223
10633
|
from_time,
|
|
10224
10634
|
orgSlug,
|
|
10225
10635
|
page,
|
|
10226
10636
|
per_page,
|
|
10637
|
+
repo,
|
|
10227
10638
|
sort
|
|
10228
10639
|
}) {
|
|
10229
10640
|
const sockSdk = await shadowNpmInject.setupSdk()
|
|
@@ -10233,6 +10644,16 @@ async function fetchListScans({
|
|
|
10233
10644
|
spinner.start('Fetching list of scans...')
|
|
10234
10645
|
const result = await handleApiCall(
|
|
10235
10646
|
sockSdk.getOrgFullScanList(orgSlug, {
|
|
10647
|
+
...(branch
|
|
10648
|
+
? {
|
|
10649
|
+
branch
|
|
10650
|
+
}
|
|
10651
|
+
: {}),
|
|
10652
|
+
...(repo
|
|
10653
|
+
? {
|
|
10654
|
+
repo
|
|
10655
|
+
}
|
|
10656
|
+
: {}),
|
|
10236
10657
|
sort,
|
|
10237
10658
|
direction,
|
|
10238
10659
|
per_page: String(per_page),
|
|
@@ -10264,6 +10685,10 @@ async function outputListScans(data, outputKind) {
|
|
|
10264
10685
|
field: 'report_url',
|
|
10265
10686
|
name: vendor.yoctocolorsCjsExports.magenta('Scan URL')
|
|
10266
10687
|
},
|
|
10688
|
+
{
|
|
10689
|
+
field: 'repo',
|
|
10690
|
+
name: vendor.yoctocolorsCjsExports.magenta('Repo')
|
|
10691
|
+
},
|
|
10267
10692
|
{
|
|
10268
10693
|
field: 'branch',
|
|
10269
10694
|
name: vendor.yoctocolorsCjsExports.magenta('Branch')
|
|
@@ -10287,6 +10712,7 @@ async function outputListScans(data, outputKind) {
|
|
|
10287
10712
|
day: 'numeric'
|
|
10288
10713
|
})
|
|
10289
10714
|
: '',
|
|
10715
|
+
repo: d.repo,
|
|
10290
10716
|
branch: d.branch
|
|
10291
10717
|
}
|
|
10292
10718
|
})
|
|
@@ -10294,20 +10720,24 @@ async function outputListScans(data, outputKind) {
|
|
|
10294
10720
|
}
|
|
10295
10721
|
|
|
10296
10722
|
async function handleListScans({
|
|
10723
|
+
branch,
|
|
10297
10724
|
direction,
|
|
10298
10725
|
from_time,
|
|
10299
10726
|
orgSlug,
|
|
10300
10727
|
outputKind,
|
|
10301
10728
|
page,
|
|
10302
10729
|
per_page,
|
|
10730
|
+
repo,
|
|
10303
10731
|
sort
|
|
10304
10732
|
}) {
|
|
10305
10733
|
const data = await fetchListScans({
|
|
10734
|
+
branch,
|
|
10306
10735
|
direction,
|
|
10307
10736
|
from_time,
|
|
10308
10737
|
orgSlug,
|
|
10309
10738
|
page,
|
|
10310
10739
|
per_page,
|
|
10740
|
+
repo,
|
|
10311
10741
|
sort
|
|
10312
10742
|
})
|
|
10313
10743
|
if (!data) {
|
|
@@ -10324,12 +10754,9 @@ const config$5 = {
|
|
|
10324
10754
|
flags: {
|
|
10325
10755
|
...commonFlags,
|
|
10326
10756
|
...outputFlags,
|
|
10327
|
-
|
|
10757
|
+
branch: {
|
|
10328
10758
|
type: 'string',
|
|
10329
|
-
|
|
10330
|
-
default: 'created_at',
|
|
10331
|
-
description:
|
|
10332
|
-
'Sorting option (`name` or `created_at`) - default is `created_at`'
|
|
10759
|
+
description: 'Filter to show only scans with this branch name'
|
|
10333
10760
|
},
|
|
10334
10761
|
direction: {
|
|
10335
10762
|
type: 'string',
|
|
@@ -10337,11 +10764,11 @@ const config$5 = {
|
|
|
10337
10764
|
default: 'desc',
|
|
10338
10765
|
description: 'Direction option (`desc` or `asc`) - Default is `desc`'
|
|
10339
10766
|
},
|
|
10340
|
-
|
|
10341
|
-
type: '
|
|
10342
|
-
shortFlag: '
|
|
10343
|
-
default:
|
|
10344
|
-
description: '
|
|
10767
|
+
fromTime: {
|
|
10768
|
+
type: 'string',
|
|
10769
|
+
shortFlag: 'f',
|
|
10770
|
+
default: '',
|
|
10771
|
+
description: 'From time - as a unix timestamp'
|
|
10345
10772
|
},
|
|
10346
10773
|
page: {
|
|
10347
10774
|
type: 'number',
|
|
@@ -10349,11 +10776,22 @@ const config$5 = {
|
|
|
10349
10776
|
default: 1,
|
|
10350
10777
|
description: 'Page number - Default is 1'
|
|
10351
10778
|
},
|
|
10352
|
-
|
|
10779
|
+
perPage: {
|
|
10780
|
+
type: 'number',
|
|
10781
|
+
shortFlag: 'pp',
|
|
10782
|
+
default: 30,
|
|
10783
|
+
description: 'Results per page - Default is 30'
|
|
10784
|
+
},
|
|
10785
|
+
repo: {
|
|
10353
10786
|
type: 'string',
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10787
|
+
description: 'Filter to show only scans with this repository name'
|
|
10788
|
+
},
|
|
10789
|
+
sort: {
|
|
10790
|
+
type: 'string',
|
|
10791
|
+
shortFlag: 's',
|
|
10792
|
+
default: 'created_at',
|
|
10793
|
+
description:
|
|
10794
|
+
'Sorting option (`name` or `created_at`) - default is `created_at`'
|
|
10357
10795
|
},
|
|
10358
10796
|
untilTime: {
|
|
10359
10797
|
type: 'string',
|
|
@@ -10389,7 +10827,7 @@ async function run$5(argv, importMeta, { parentName }) {
|
|
|
10389
10827
|
importMeta,
|
|
10390
10828
|
parentName
|
|
10391
10829
|
})
|
|
10392
|
-
const { json, markdown } = cli.flags
|
|
10830
|
+
const { branch, json, markdown, repo } = cli.flags
|
|
10393
10831
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
10394
10832
|
const orgSlug = defaultOrgSlug || cli.input[0] || ''
|
|
10395
10833
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
@@ -10428,12 +10866,14 @@ async function run$5(argv, importMeta, { parentName }) {
|
|
|
10428
10866
|
return
|
|
10429
10867
|
}
|
|
10430
10868
|
await handleListScans({
|
|
10869
|
+
branch: branch ? String(branch) : '',
|
|
10431
10870
|
direction: String(cli.flags['direction'] || ''),
|
|
10432
10871
|
from_time: String(cli.flags['fromTime'] || ''),
|
|
10433
10872
|
orgSlug,
|
|
10434
10873
|
outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
|
|
10435
10874
|
page: Number(cli.flags['page'] || 1),
|
|
10436
10875
|
per_page: Number(cli.flags['perPage'] || 30),
|
|
10876
|
+
repo: repo ? String(repo) : '',
|
|
10437
10877
|
sort: String(cli.flags['sort'] || '')
|
|
10438
10878
|
})
|
|
10439
10879
|
}
|
|
@@ -10923,6 +11363,7 @@ const cmdScan = {
|
|
|
10923
11363
|
create: cmdScanCreate,
|
|
10924
11364
|
list: cmdScanList,
|
|
10925
11365
|
del: cmdScanDel,
|
|
11366
|
+
diff: cmdScanDiff,
|
|
10926
11367
|
metadata: cmdScanMetadata,
|
|
10927
11368
|
report: cmdScanReport,
|
|
10928
11369
|
view: cmdScanView
|
|
@@ -11291,7 +11732,7 @@ async function run$1(argv, importMeta, { parentName }) {
|
|
|
11291
11732
|
}
|
|
11292
11733
|
|
|
11293
11734
|
function addSocketWrapper(file) {
|
|
11294
|
-
return
|
|
11735
|
+
return fs$1.appendFile(
|
|
11295
11736
|
file,
|
|
11296
11737
|
'alias npm="socket npm"\nalias npx="socket npx"\n',
|
|
11297
11738
|
err => {
|
|
@@ -11300,7 +11741,7 @@ function addSocketWrapper(file) {
|
|
|
11300
11741
|
}
|
|
11301
11742
|
// TODO: pretty sure you need to source the file or restart
|
|
11302
11743
|
// any terminal session before changes are reflected.
|
|
11303
|
-
logger.logger.log(vendor.
|
|
11744
|
+
logger.logger.log(vendor.html`
|
|
11304
11745
|
The alias was added to ${file}. Running 'npm install' will now be wrapped in Socket's "safe npm" 🎉
|
|
11305
11746
|
If you want to disable it at any time, run \`socket wrapper --disable\`
|
|
11306
11747
|
`)
|
|
@@ -11309,7 +11750,7 @@ If you want to disable it at any time, run \`socket wrapper --disable\`
|
|
|
11309
11750
|
}
|
|
11310
11751
|
|
|
11311
11752
|
function checkSocketWrapperSetup(file) {
|
|
11312
|
-
const fileContent =
|
|
11753
|
+
const fileContent = fs$1.readFileSync(file, 'utf8')
|
|
11313
11754
|
const linesWithSocketAlias = fileContent
|
|
11314
11755
|
.split('\n')
|
|
11315
11756
|
.filter(
|
|
@@ -11328,11 +11769,10 @@ async function postinstallWrapper() {
|
|
|
11328
11769
|
// Lazily access constants.bashRcPath and constants.zshRcPath.
|
|
11329
11770
|
const { bashRcPath, zshRcPath } = constants
|
|
11330
11771
|
const socketWrapperEnabled =
|
|
11331
|
-
(
|
|
11332
|
-
|
|
11333
|
-
(require$$0.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath))
|
|
11772
|
+
(fs$1.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath)) ||
|
|
11773
|
+
(fs$1.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath))
|
|
11334
11774
|
if (!socketWrapperEnabled) {
|
|
11335
|
-
await installSafeNpm(vendor.
|
|
11775
|
+
await installSafeNpm(vendor.html`
|
|
11336
11776
|
The Socket CLI is now successfully installed! 🎉
|
|
11337
11777
|
|
|
11338
11778
|
To better protect yourself against supply-chain attacks, our "safe npm" wrapper can warn you about malicious packages whenever you run 'npm install'.
|
|
@@ -11357,10 +11797,10 @@ async function installSafeNpm(query) {
|
|
|
11357
11797
|
// Lazily access constants.bashRcPath and constants.zshRcPath.
|
|
11358
11798
|
const { bashRcPath, zshRcPath } = constants
|
|
11359
11799
|
try {
|
|
11360
|
-
if (
|
|
11800
|
+
if (fs$1.existsSync(bashRcPath)) {
|
|
11361
11801
|
addSocketWrapper(bashRcPath)
|
|
11362
11802
|
}
|
|
11363
|
-
if (
|
|
11803
|
+
if (fs$1.existsSync(zshRcPath)) {
|
|
11364
11804
|
addSocketWrapper(zshRcPath)
|
|
11365
11805
|
}
|
|
11366
11806
|
} catch (e) {
|
|
@@ -11372,7 +11812,7 @@ async function installSafeNpm(query) {
|
|
|
11372
11812
|
}
|
|
11373
11813
|
|
|
11374
11814
|
function removeSocketWrapper(file) {
|
|
11375
|
-
return
|
|
11815
|
+
return fs$1.readFile(file, 'utf8', function (err, data) {
|
|
11376
11816
|
if (err) {
|
|
11377
11817
|
logger.logger.fail('There was an error removing the alias:')
|
|
11378
11818
|
logger.logger.error(err)
|
|
@@ -11384,7 +11824,7 @@ function removeSocketWrapper(file) {
|
|
|
11384
11824
|
l => l !== 'alias npm="socket npm"' && l !== 'alias npx="socket npx"'
|
|
11385
11825
|
)
|
|
11386
11826
|
const updatedFileContent = linesWithoutSocketAlias.join('\n')
|
|
11387
|
-
|
|
11827
|
+
fs$1.writeFile(file, updatedFileContent, function (err) {
|
|
11388
11828
|
if (err) {
|
|
11389
11829
|
logger.logger.error(err)
|
|
11390
11830
|
return
|
|
@@ -11472,27 +11912,21 @@ async function run(argv, importMeta, { parentName }) {
|
|
|
11472
11912
|
// Lazily access constants.bashRcPath and constants.zshRcPath.
|
|
11473
11913
|
const { bashRcPath, zshRcPath } = constants
|
|
11474
11914
|
if (enable) {
|
|
11475
|
-
if (
|
|
11476
|
-
require$$0.existsSync(bashRcPath) &&
|
|
11477
|
-
!checkSocketWrapperSetup(bashRcPath)
|
|
11478
|
-
) {
|
|
11915
|
+
if (fs$1.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
|
|
11479
11916
|
addSocketWrapper(bashRcPath)
|
|
11480
11917
|
}
|
|
11481
|
-
if (
|
|
11482
|
-
require$$0.existsSync(zshRcPath) &&
|
|
11483
|
-
!checkSocketWrapperSetup(zshRcPath)
|
|
11484
|
-
) {
|
|
11918
|
+
if (fs$1.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
|
|
11485
11919
|
addSocketWrapper(zshRcPath)
|
|
11486
11920
|
}
|
|
11487
11921
|
} else {
|
|
11488
|
-
if (
|
|
11922
|
+
if (fs$1.existsSync(bashRcPath)) {
|
|
11489
11923
|
removeSocketWrapper(bashRcPath)
|
|
11490
11924
|
}
|
|
11491
|
-
if (
|
|
11925
|
+
if (fs$1.existsSync(zshRcPath)) {
|
|
11492
11926
|
removeSocketWrapper(zshRcPath)
|
|
11493
11927
|
}
|
|
11494
11928
|
}
|
|
11495
|
-
if (!
|
|
11929
|
+
if (!fs$1.existsSync(bashRcPath) && !fs$1.existsSync(zshRcPath)) {
|
|
11496
11930
|
logger.logger.fail(
|
|
11497
11931
|
'There was an issue setting up the alias in your bash profile'
|
|
11498
11932
|
)
|
|
@@ -11506,7 +11940,7 @@ void (async () => {
|
|
|
11506
11940
|
await vendor.updater({
|
|
11507
11941
|
name: SOCKET_CLI_BIN_NAME,
|
|
11508
11942
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
11509
|
-
version: '0.14.
|
|
11943
|
+
version: '0.14.104',
|
|
11510
11944
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
11511
11945
|
})
|
|
11512
11946
|
try {
|
|
@@ -11543,7 +11977,7 @@ void (async () => {
|
|
|
11543
11977
|
argv: process$1.argv.slice(2),
|
|
11544
11978
|
name: SOCKET_CLI_BIN_NAME,
|
|
11545
11979
|
importMeta: {
|
|
11546
|
-
url: `${require$$0$
|
|
11980
|
+
url: `${require$$0$1.pathToFileURL(__filename)}`
|
|
11547
11981
|
}
|
|
11548
11982
|
}
|
|
11549
11983
|
)
|
|
@@ -11574,5 +12008,5 @@ void (async () => {
|
|
|
11574
12008
|
await shadowNpmInject.captureException(e)
|
|
11575
12009
|
}
|
|
11576
12010
|
})()
|
|
11577
|
-
//# debugId=
|
|
12011
|
+
//# debugId=efb43bfa-f612-4c54-a458-2dcec93289cb
|
|
11578
12012
|
//# sourceMappingURL=cli.js.map
|