@socketsecurity/cli-with-sentry 0.14.148 → 0.14.149
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/cli.js +329 -99
- package/dist/cli.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/shadow-npm-inject.js +15 -8
- package/dist/shadow-npm-inject.js.map +1 -1
- package/package.json +19 -19
package/dist/cli.js
CHANGED
|
@@ -904,11 +904,17 @@ function emitBanner(name) {
|
|
|
904
904
|
logger.logger.error(getAsciiHeader(name))
|
|
905
905
|
}
|
|
906
906
|
function getAsciiHeader(command) {
|
|
907
|
-
const cliVersion = '0.14.
|
|
907
|
+
const cliVersion = '0.14.149:e5f0cba:2e3185e5:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
908
908
|
const nodeVersion = process$1.version
|
|
909
909
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
910
910
|
const defaultOrg = shadowNpmInject.getConfigValue('defaultOrg')
|
|
911
911
|
const readOnlyConfig = shadowNpmInject.isReadOnlyConfig() ? '*' : '.'
|
|
912
|
+
const v1test = shadowNpmInject.isTestingV1() ? ' (is testing v1)' : ''
|
|
913
|
+
const feedback = shadowNpmInject.isTestingV1()
|
|
914
|
+
? vendor.yoctocolorsCjsExports.green(
|
|
915
|
+
' (Thank you for testing the v1 bump! Please send us any feedback you might have!)\n'
|
|
916
|
+
)
|
|
917
|
+
: ''
|
|
912
918
|
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
|
|
913
919
|
const relCwd = path.normalizePath(
|
|
914
920
|
process$1
|
|
@@ -923,10 +929,10 @@ function getAsciiHeader(command) {
|
|
|
923
929
|
)
|
|
924
930
|
const body = `
|
|
925
931
|
_____ _ _ /---------------
|
|
926
|
-
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
|
|
932
|
+
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}${v1test}
|
|
927
933
|
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}${defaultOrg ? `, default org: ${defaultOrg}` : ''}
|
|
928
934
|
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart()
|
|
929
|
-
return ` ${body}\n`
|
|
935
|
+
return ` ${body}\n${feedback}`
|
|
930
936
|
}
|
|
931
937
|
|
|
932
938
|
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$J } = constants
|
|
@@ -9411,6 +9417,45 @@ async function handleCreateRepo({
|
|
|
9411
9417
|
await outputCreateRepo()
|
|
9412
9418
|
}
|
|
9413
9419
|
|
|
9420
|
+
async function suggestOrgSlug() {
|
|
9421
|
+
const sockSdk = await shadowNpmInject.setupSdk()
|
|
9422
|
+
const result = await handleApiCall(
|
|
9423
|
+
sockSdk.getOrganizations(),
|
|
9424
|
+
'looking up organizations'
|
|
9425
|
+
)
|
|
9426
|
+
// Ignore a failed request here. It was not the primary goal of
|
|
9427
|
+
// running this command and reporting it only leads to end-user confusion.
|
|
9428
|
+
if (result.success) {
|
|
9429
|
+
const proceed = await prompts.select({
|
|
9430
|
+
message:
|
|
9431
|
+
'Missing org name; do you want to use any of these orgs for this scan?',
|
|
9432
|
+
choices: [
|
|
9433
|
+
...Object.values(result.data.organizations).map(org => {
|
|
9434
|
+
const slug = org.name ?? 'undefined'
|
|
9435
|
+
return {
|
|
9436
|
+
name: `Yes [${slug}]`,
|
|
9437
|
+
value: slug,
|
|
9438
|
+
description: `Use "${slug}" as the organization`
|
|
9439
|
+
}
|
|
9440
|
+
}),
|
|
9441
|
+
{
|
|
9442
|
+
name: 'No',
|
|
9443
|
+
value: '',
|
|
9444
|
+
description:
|
|
9445
|
+
'Do not use any of these organizations (will end in a no-op)'
|
|
9446
|
+
}
|
|
9447
|
+
]
|
|
9448
|
+
})
|
|
9449
|
+
if (proceed) {
|
|
9450
|
+
return proceed
|
|
9451
|
+
}
|
|
9452
|
+
} else {
|
|
9453
|
+
logger.logger.fail(
|
|
9454
|
+
'Failed to lookup organization list from API, unable to suggest'
|
|
9455
|
+
)
|
|
9456
|
+
}
|
|
9457
|
+
}
|
|
9458
|
+
|
|
9414
9459
|
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$d } = constants
|
|
9415
9460
|
const config$d = {
|
|
9416
9461
|
commandName: 'create',
|
|
@@ -9418,11 +9463,28 @@ const config$d = {
|
|
|
9418
9463
|
hidden: false,
|
|
9419
9464
|
flags: {
|
|
9420
9465
|
...commonFlags,
|
|
9421
|
-
|
|
9466
|
+
defaultBranch: {
|
|
9422
9467
|
type: 'string',
|
|
9423
|
-
shortFlag: '
|
|
9468
|
+
shortFlag: 'b',
|
|
9469
|
+
default: 'main',
|
|
9470
|
+
description: 'Repository default branch'
|
|
9471
|
+
},
|
|
9472
|
+
homepage: {
|
|
9473
|
+
type: 'string',
|
|
9474
|
+
shortFlag: 'h',
|
|
9424
9475
|
default: '',
|
|
9425
|
-
description: 'Repository
|
|
9476
|
+
description: 'Repository url'
|
|
9477
|
+
},
|
|
9478
|
+
interactive: {
|
|
9479
|
+
type: 'boolean',
|
|
9480
|
+
default: true,
|
|
9481
|
+
description:
|
|
9482
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
9483
|
+
},
|
|
9484
|
+
org: {
|
|
9485
|
+
type: 'string',
|
|
9486
|
+
description:
|
|
9487
|
+
'Force override the organization slug, overrides the default org from config'
|
|
9426
9488
|
},
|
|
9427
9489
|
repoDescription: {
|
|
9428
9490
|
type: 'string',
|
|
@@ -9430,17 +9492,11 @@ const config$d = {
|
|
|
9430
9492
|
default: '',
|
|
9431
9493
|
description: 'Repository description'
|
|
9432
9494
|
},
|
|
9433
|
-
|
|
9495
|
+
repoName: {
|
|
9434
9496
|
type: 'string',
|
|
9435
|
-
shortFlag: '
|
|
9497
|
+
shortFlag: 'n',
|
|
9436
9498
|
default: '',
|
|
9437
|
-
description: 'Repository
|
|
9438
|
-
},
|
|
9439
|
-
defaultBranch: {
|
|
9440
|
-
type: 'string',
|
|
9441
|
-
shortFlag: 'b',
|
|
9442
|
-
default: 'main',
|
|
9443
|
-
description: 'Repository default branch'
|
|
9499
|
+
description: 'Repository name'
|
|
9444
9500
|
},
|
|
9445
9501
|
visibility: {
|
|
9446
9502
|
type: 'string',
|
|
@@ -9451,7 +9507,7 @@ const config$d = {
|
|
|
9451
9507
|
},
|
|
9452
9508
|
help: (command, config) => `
|
|
9453
9509
|
Usage
|
|
9454
|
-
$ ${command} <org slug> --repo-name=<name>
|
|
9510
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
9455
9511
|
|
|
9456
9512
|
API Token Requirements
|
|
9457
9513
|
- Quota: 1 unit
|
|
@@ -9461,7 +9517,7 @@ const config$d = {
|
|
|
9461
9517
|
${getFlagListOutput(config.flags, 6)}
|
|
9462
9518
|
|
|
9463
9519
|
Examples
|
|
9464
|
-
$ ${command} FakeOrg --repoName=test-repo
|
|
9520
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg --repoName=test-repo'}
|
|
9465
9521
|
`
|
|
9466
9522
|
}
|
|
9467
9523
|
const cmdReposCreate = {
|
|
@@ -9476,21 +9532,51 @@ async function run$d(argv, importMeta, { parentName }) {
|
|
|
9476
9532
|
importMeta,
|
|
9477
9533
|
parentName
|
|
9478
9534
|
})
|
|
9479
|
-
const repoName = cli.flags['repoName']
|
|
9480
9535
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9481
|
-
const
|
|
9536
|
+
const interactive = cli.flags['interactive']
|
|
9537
|
+
const dryRun = cli.flags['dryRun']
|
|
9538
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
9539
|
+
if (!orgSlug) {
|
|
9540
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
9541
|
+
// ask from server
|
|
9542
|
+
logger.logger.error(
|
|
9543
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
9544
|
+
)
|
|
9545
|
+
logger.logger.error(
|
|
9546
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
9547
|
+
)
|
|
9548
|
+
if (dryRun) {
|
|
9549
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
9550
|
+
} else if (!interactive) {
|
|
9551
|
+
logger.logger.fail(
|
|
9552
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
9553
|
+
)
|
|
9554
|
+
} else {
|
|
9555
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
9556
|
+
}
|
|
9557
|
+
} else {
|
|
9558
|
+
orgSlug = cli.input[0] || ''
|
|
9559
|
+
}
|
|
9560
|
+
}
|
|
9561
|
+
const repoNameFlag = cli.flags['repoName']
|
|
9562
|
+
const repoName =
|
|
9563
|
+
(shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
|
|
9482
9564
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9483
9565
|
const wasBadInput = handleBadInput(
|
|
9484
9566
|
{
|
|
9485
9567
|
nook: true,
|
|
9486
9568
|
test: !!orgSlug,
|
|
9487
|
-
message:
|
|
9569
|
+
message: shadowNpmInject.isTestingV1()
|
|
9570
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
9571
|
+
: 'Org name must be the first argument',
|
|
9488
9572
|
pass: 'ok',
|
|
9489
9573
|
fail: 'missing'
|
|
9490
9574
|
},
|
|
9491
9575
|
{
|
|
9492
9576
|
test: !!repoName,
|
|
9493
|
-
message:
|
|
9577
|
+
message: shadowNpmInject.isTestingV1()
|
|
9578
|
+
? 'Repository name as first argument'
|
|
9579
|
+
: 'Repository name using --repoName',
|
|
9494
9580
|
pass: 'ok',
|
|
9495
9581
|
fail: 'missing'
|
|
9496
9582
|
},
|
|
@@ -9501,12 +9587,19 @@ async function run$d(argv, importMeta, { parentName }) {
|
|
|
9501
9587
|
'You need to be logged in to use this command. See `socket login`.',
|
|
9502
9588
|
pass: 'ok',
|
|
9503
9589
|
fail: 'missing API token'
|
|
9590
|
+
},
|
|
9591
|
+
{
|
|
9592
|
+
nook: true,
|
|
9593
|
+
test: !shadowNpmInject.isTestingV1() || !repoNameFlag,
|
|
9594
|
+
message: 'In v1 the first arg should be the repo, not the flag',
|
|
9595
|
+
pass: 'ok',
|
|
9596
|
+
fail: 'received --repo-name flag'
|
|
9504
9597
|
}
|
|
9505
9598
|
)
|
|
9506
9599
|
if (wasBadInput) {
|
|
9507
9600
|
return
|
|
9508
9601
|
}
|
|
9509
|
-
if (
|
|
9602
|
+
if (dryRun) {
|
|
9510
9603
|
logger.logger.log(DRY_RUN_BAIL_TEXT$d)
|
|
9511
9604
|
return
|
|
9512
9605
|
}
|
|
@@ -9542,11 +9635,22 @@ const config$c = {
|
|
|
9542
9635
|
description: 'Delete a repository in an organization',
|
|
9543
9636
|
hidden: false,
|
|
9544
9637
|
flags: {
|
|
9545
|
-
...commonFlags
|
|
9638
|
+
...commonFlags,
|
|
9639
|
+
interactive: {
|
|
9640
|
+
type: 'boolean',
|
|
9641
|
+
default: true,
|
|
9642
|
+
description:
|
|
9643
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
9644
|
+
},
|
|
9645
|
+
org: {
|
|
9646
|
+
type: 'string',
|
|
9647
|
+
description:
|
|
9648
|
+
'Force override the organization slug, overrides the default org from config'
|
|
9649
|
+
}
|
|
9546
9650
|
},
|
|
9547
9651
|
help: (command, config) => `
|
|
9548
9652
|
Usage
|
|
9549
|
-
$ ${command} <org slug>
|
|
9653
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
9550
9654
|
|
|
9551
9655
|
API Token Requirements
|
|
9552
9656
|
- Quota: 1 unit
|
|
@@ -9556,7 +9660,7 @@ const config$c = {
|
|
|
9556
9660
|
${getFlagListOutput(config.flags, 6)}
|
|
9557
9661
|
|
|
9558
9662
|
Examples
|
|
9559
|
-
$ ${command} FakeOrg test-repo
|
|
9663
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg test-repo'}
|
|
9560
9664
|
`
|
|
9561
9665
|
}
|
|
9562
9666
|
const cmdReposDel = {
|
|
@@ -9572,20 +9676,51 @@ async function run$c(argv, importMeta, { parentName }) {
|
|
|
9572
9676
|
parentName
|
|
9573
9677
|
})
|
|
9574
9678
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9575
|
-
const
|
|
9576
|
-
const
|
|
9679
|
+
const interactive = cli.flags['interactive']
|
|
9680
|
+
const dryRun = cli.flags['dryRun']
|
|
9681
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
9682
|
+
if (!orgSlug) {
|
|
9683
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
9684
|
+
// ask from server
|
|
9685
|
+
logger.logger.error(
|
|
9686
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
9687
|
+
)
|
|
9688
|
+
logger.logger.error(
|
|
9689
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
9690
|
+
)
|
|
9691
|
+
if (dryRun) {
|
|
9692
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
9693
|
+
} else if (!interactive) {
|
|
9694
|
+
logger.logger.fail(
|
|
9695
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
9696
|
+
)
|
|
9697
|
+
} else {
|
|
9698
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
9699
|
+
}
|
|
9700
|
+
} else {
|
|
9701
|
+
orgSlug = cli.input[0] || ''
|
|
9702
|
+
}
|
|
9703
|
+
}
|
|
9704
|
+
const repoName =
|
|
9705
|
+
(defaultOrgSlug || shadowNpmInject.isTestingV1()
|
|
9706
|
+
? cli.input[0]
|
|
9707
|
+
: cli.input[1]) || ''
|
|
9577
9708
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9578
9709
|
const wasBadInput = handleBadInput(
|
|
9579
9710
|
{
|
|
9580
9711
|
nook: true,
|
|
9581
9712
|
test: !!orgSlug,
|
|
9582
|
-
message:
|
|
9713
|
+
message: shadowNpmInject.isTestingV1()
|
|
9714
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
9715
|
+
: 'Org name must be the first argument',
|
|
9583
9716
|
pass: 'ok',
|
|
9584
9717
|
fail: 'missing'
|
|
9585
9718
|
},
|
|
9586
9719
|
{
|
|
9587
9720
|
test: !!repoName,
|
|
9588
|
-
message:
|
|
9721
|
+
message: shadowNpmInject.isTestingV1()
|
|
9722
|
+
? 'Repository name as first argument'
|
|
9723
|
+
: 'Repository name using --repoName',
|
|
9589
9724
|
pass: 'ok',
|
|
9590
9725
|
fail: 'missing'
|
|
9591
9726
|
},
|
|
@@ -9601,7 +9736,7 @@ async function run$c(argv, importMeta, { parentName }) {
|
|
|
9601
9736
|
if (wasBadInput) {
|
|
9602
9737
|
return
|
|
9603
9738
|
}
|
|
9604
|
-
if (
|
|
9739
|
+
if (dryRun) {
|
|
9605
9740
|
logger.logger.log(DRY_RUN_BAIL_TEXT$c)
|
|
9606
9741
|
return
|
|
9607
9742
|
}
|
|
@@ -9709,6 +9844,17 @@ const config$b = {
|
|
|
9709
9844
|
default: 'desc',
|
|
9710
9845
|
description: 'Direction option'
|
|
9711
9846
|
},
|
|
9847
|
+
interactive: {
|
|
9848
|
+
type: 'boolean',
|
|
9849
|
+
default: true,
|
|
9850
|
+
description:
|
|
9851
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
9852
|
+
},
|
|
9853
|
+
org: {
|
|
9854
|
+
type: 'string',
|
|
9855
|
+
description:
|
|
9856
|
+
'Force override the organization slug, overrides the default org from config'
|
|
9857
|
+
},
|
|
9712
9858
|
perPage: {
|
|
9713
9859
|
type: 'number',
|
|
9714
9860
|
shortFlag: 'pp',
|
|
@@ -9725,7 +9871,7 @@ const config$b = {
|
|
|
9725
9871
|
},
|
|
9726
9872
|
help: (command, config) => `
|
|
9727
9873
|
Usage
|
|
9728
|
-
$ ${command} <org slug>
|
|
9874
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '' : '<org slug>'}
|
|
9729
9875
|
|
|
9730
9876
|
API Token Requirements
|
|
9731
9877
|
- Quota: 1 unit
|
|
@@ -9735,7 +9881,7 @@ const config$b = {
|
|
|
9735
9881
|
${getFlagListOutput(config.flags, 6)}
|
|
9736
9882
|
|
|
9737
9883
|
Examples
|
|
9738
|
-
$ ${command}
|
|
9884
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '' : '<org slug>'}
|
|
9739
9885
|
`
|
|
9740
9886
|
}
|
|
9741
9887
|
const cmdReposList = {
|
|
@@ -9752,13 +9898,39 @@ async function run$b(argv, importMeta, { parentName }) {
|
|
|
9752
9898
|
})
|
|
9753
9899
|
const { json, markdown } = cli.flags
|
|
9754
9900
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9755
|
-
const
|
|
9901
|
+
const interactive = cli.flags['interactive']
|
|
9902
|
+
const dryRun = cli.flags['dryRun']
|
|
9903
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
9904
|
+
if (!orgSlug) {
|
|
9905
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
9906
|
+
// ask from server
|
|
9907
|
+
logger.logger.error(
|
|
9908
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
9909
|
+
)
|
|
9910
|
+
logger.logger.error(
|
|
9911
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
9912
|
+
)
|
|
9913
|
+
if (dryRun) {
|
|
9914
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
9915
|
+
} else if (!interactive) {
|
|
9916
|
+
logger.logger.fail(
|
|
9917
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
9918
|
+
)
|
|
9919
|
+
} else {
|
|
9920
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
9921
|
+
}
|
|
9922
|
+
} else {
|
|
9923
|
+
orgSlug = cli.input[0] || ''
|
|
9924
|
+
}
|
|
9925
|
+
}
|
|
9756
9926
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9757
9927
|
const wasBadInput = handleBadInput(
|
|
9758
9928
|
{
|
|
9759
9929
|
nook: true,
|
|
9760
9930
|
test: !!orgSlug,
|
|
9761
|
-
message:
|
|
9931
|
+
message: shadowNpmInject.isTestingV1()
|
|
9932
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
9933
|
+
: 'Org name must be the first argument',
|
|
9762
9934
|
pass: 'ok',
|
|
9763
9935
|
fail: 'missing'
|
|
9764
9936
|
},
|
|
@@ -9860,6 +10032,29 @@ const config$a = {
|
|
|
9860
10032
|
hidden: false,
|
|
9861
10033
|
flags: {
|
|
9862
10034
|
...commonFlags,
|
|
10035
|
+
defaultBranch: {
|
|
10036
|
+
type: 'string',
|
|
10037
|
+
shortFlag: 'b',
|
|
10038
|
+
default: 'main',
|
|
10039
|
+
description: 'Repository default branch'
|
|
10040
|
+
},
|
|
10041
|
+
homepage: {
|
|
10042
|
+
type: 'string',
|
|
10043
|
+
shortFlag: 'h',
|
|
10044
|
+
default: '',
|
|
10045
|
+
description: 'Repository url'
|
|
10046
|
+
},
|
|
10047
|
+
interactive: {
|
|
10048
|
+
type: 'boolean',
|
|
10049
|
+
default: true,
|
|
10050
|
+
description:
|
|
10051
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
10052
|
+
},
|
|
10053
|
+
org: {
|
|
10054
|
+
type: 'string',
|
|
10055
|
+
description:
|
|
10056
|
+
'Force override the organization slug, overrides the default org from config'
|
|
10057
|
+
},
|
|
9863
10058
|
repoName: {
|
|
9864
10059
|
type: 'string',
|
|
9865
10060
|
shortFlag: 'n',
|
|
@@ -9872,18 +10067,6 @@ const config$a = {
|
|
|
9872
10067
|
default: '',
|
|
9873
10068
|
description: 'Repository description'
|
|
9874
10069
|
},
|
|
9875
|
-
homepage: {
|
|
9876
|
-
type: 'string',
|
|
9877
|
-
shortFlag: 'h',
|
|
9878
|
-
default: '',
|
|
9879
|
-
description: 'Repository url'
|
|
9880
|
-
},
|
|
9881
|
-
defaultBranch: {
|
|
9882
|
-
type: 'string',
|
|
9883
|
-
shortFlag: 'b',
|
|
9884
|
-
default: 'main',
|
|
9885
|
-
description: 'Repository default branch'
|
|
9886
|
-
},
|
|
9887
10070
|
visibility: {
|
|
9888
10071
|
type: 'string',
|
|
9889
10072
|
shortFlag: 'v',
|
|
@@ -9893,7 +10076,7 @@ const config$a = {
|
|
|
9893
10076
|
},
|
|
9894
10077
|
help: (command, config) => `
|
|
9895
10078
|
Usage
|
|
9896
|
-
$ ${command} <org slug> --repo-name=<name>
|
|
10079
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
9897
10080
|
|
|
9898
10081
|
API Token Requirements
|
|
9899
10082
|
- Quota: 1 unit
|
|
@@ -9903,7 +10086,7 @@ const config$a = {
|
|
|
9903
10086
|
${getFlagListOutput(config.flags, 6)}
|
|
9904
10087
|
|
|
9905
10088
|
Examples
|
|
9906
|
-
$ ${command} FakeOrg
|
|
10089
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg test-repo'}
|
|
9907
10090
|
`
|
|
9908
10091
|
}
|
|
9909
10092
|
const cmdReposUpdate = {
|
|
@@ -9918,21 +10101,51 @@ async function run$a(argv, importMeta, { parentName }) {
|
|
|
9918
10101
|
importMeta,
|
|
9919
10102
|
parentName
|
|
9920
10103
|
})
|
|
9921
|
-
const repoName = cli.flags['repoName']
|
|
9922
10104
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9923
|
-
const
|
|
10105
|
+
const interactive = cli.flags['interactive']
|
|
10106
|
+
const dryRun = cli.flags['dryRun']
|
|
10107
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
10108
|
+
if (!orgSlug) {
|
|
10109
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
10110
|
+
// ask from server
|
|
10111
|
+
logger.logger.error(
|
|
10112
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
10113
|
+
)
|
|
10114
|
+
logger.logger.error(
|
|
10115
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
10116
|
+
)
|
|
10117
|
+
if (dryRun) {
|
|
10118
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
10119
|
+
} else if (!interactive) {
|
|
10120
|
+
logger.logger.fail(
|
|
10121
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
10122
|
+
)
|
|
10123
|
+
} else {
|
|
10124
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
10125
|
+
}
|
|
10126
|
+
} else {
|
|
10127
|
+
orgSlug = cli.input[0] || ''
|
|
10128
|
+
}
|
|
10129
|
+
}
|
|
10130
|
+
const repoNameFlag = cli.flags['repoName']
|
|
10131
|
+
const repoName =
|
|
10132
|
+
(shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
|
|
9924
10133
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9925
10134
|
const wasBadInput = handleBadInput(
|
|
9926
10135
|
{
|
|
9927
10136
|
nook: true,
|
|
9928
10137
|
test: !!orgSlug,
|
|
9929
|
-
message:
|
|
10138
|
+
message: shadowNpmInject.isTestingV1()
|
|
10139
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
10140
|
+
: 'Org name must be the first argument',
|
|
9930
10141
|
pass: 'ok',
|
|
9931
10142
|
fail: 'missing'
|
|
9932
10143
|
},
|
|
9933
10144
|
{
|
|
9934
10145
|
test: !!repoName,
|
|
9935
|
-
message:
|
|
10146
|
+
message: shadowNpmInject.isTestingV1()
|
|
10147
|
+
? 'Repository name as first argument'
|
|
10148
|
+
: 'Repository name using --repoName',
|
|
9936
10149
|
pass: 'ok',
|
|
9937
10150
|
fail: 'missing'
|
|
9938
10151
|
},
|
|
@@ -9943,6 +10156,13 @@ async function run$a(argv, importMeta, { parentName }) {
|
|
|
9943
10156
|
'You need to be logged in to use this command. See `socket login`.',
|
|
9944
10157
|
pass: 'ok',
|
|
9945
10158
|
fail: 'missing API token'
|
|
10159
|
+
},
|
|
10160
|
+
{
|
|
10161
|
+
nook: true,
|
|
10162
|
+
test: !shadowNpmInject.isTestingV1() || !repoNameFlag,
|
|
10163
|
+
message: 'In v1 the first arg should be the repo, not the flag',
|
|
10164
|
+
pass: 'ok',
|
|
10165
|
+
fail: 'received --repo-name flag'
|
|
9946
10166
|
}
|
|
9947
10167
|
)
|
|
9948
10168
|
if (wasBadInput) {
|
|
@@ -10059,6 +10279,17 @@ const config$9 = {
|
|
|
10059
10279
|
flags: {
|
|
10060
10280
|
...commonFlags,
|
|
10061
10281
|
...outputFlags,
|
|
10282
|
+
interactive: {
|
|
10283
|
+
type: 'boolean',
|
|
10284
|
+
default: true,
|
|
10285
|
+
description:
|
|
10286
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
10287
|
+
},
|
|
10288
|
+
org: {
|
|
10289
|
+
type: 'string',
|
|
10290
|
+
description:
|
|
10291
|
+
'Force override the organization slug, overrides the default org from config'
|
|
10292
|
+
},
|
|
10062
10293
|
repoName: {
|
|
10063
10294
|
description: 'The repository to check',
|
|
10064
10295
|
default: '',
|
|
@@ -10067,7 +10298,7 @@ const config$9 = {
|
|
|
10067
10298
|
},
|
|
10068
10299
|
help: (command, config) => `
|
|
10069
10300
|
Usage
|
|
10070
|
-
$ ${command} <org slug> --repo-name=<name>
|
|
10301
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
10071
10302
|
|
|
10072
10303
|
API Token Requirements
|
|
10073
10304
|
- Quota: 1 unit
|
|
@@ -10077,7 +10308,7 @@ const config$9 = {
|
|
|
10077
10308
|
${getFlagListOutput(config.flags, 6)}
|
|
10078
10309
|
|
|
10079
10310
|
Examples
|
|
10080
|
-
$ ${command} FakeOrg
|
|
10311
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg test-repo'}
|
|
10081
10312
|
`
|
|
10082
10313
|
}
|
|
10083
10314
|
const cmdReposView = {
|
|
@@ -10092,21 +10323,52 @@ async function run$9(argv, importMeta, { parentName }) {
|
|
|
10092
10323
|
importMeta,
|
|
10093
10324
|
parentName
|
|
10094
10325
|
})
|
|
10095
|
-
const { json, markdown
|
|
10326
|
+
const { json, markdown } = cli.flags
|
|
10096
10327
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
10097
|
-
const
|
|
10328
|
+
const interactive = cli.flags['interactive']
|
|
10329
|
+
const dryRun = cli.flags['dryRun']
|
|
10330
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
10331
|
+
if (!orgSlug) {
|
|
10332
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
10333
|
+
// ask from server
|
|
10334
|
+
logger.logger.error(
|
|
10335
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
10336
|
+
)
|
|
10337
|
+
logger.logger.error(
|
|
10338
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
10339
|
+
)
|
|
10340
|
+
if (dryRun) {
|
|
10341
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
10342
|
+
} else if (!interactive) {
|
|
10343
|
+
logger.logger.fail(
|
|
10344
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
10345
|
+
)
|
|
10346
|
+
} else {
|
|
10347
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
10348
|
+
}
|
|
10349
|
+
} else {
|
|
10350
|
+
orgSlug = cli.input[0] || ''
|
|
10351
|
+
}
|
|
10352
|
+
}
|
|
10353
|
+
const repoNameFlag = cli.flags['repoName']
|
|
10354
|
+
const repoName =
|
|
10355
|
+
(shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
|
|
10098
10356
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
10099
10357
|
const wasBadInput = handleBadInput(
|
|
10100
10358
|
{
|
|
10101
10359
|
nook: true,
|
|
10102
10360
|
test: !!orgSlug,
|
|
10103
|
-
message:
|
|
10361
|
+
message: shadowNpmInject.isTestingV1()
|
|
10362
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
10363
|
+
: 'Org name must be the first argument',
|
|
10104
10364
|
pass: 'ok',
|
|
10105
10365
|
fail: 'missing'
|
|
10106
10366
|
},
|
|
10107
10367
|
{
|
|
10108
10368
|
test: !!repoName,
|
|
10109
|
-
message:
|
|
10369
|
+
message: shadowNpmInject.isTestingV1()
|
|
10370
|
+
? 'Repository name as first argument'
|
|
10371
|
+
: 'Repository name using --repoName',
|
|
10110
10372
|
pass: 'ok',
|
|
10111
10373
|
fail: 'missing'
|
|
10112
10374
|
},
|
|
@@ -10125,6 +10387,13 @@ async function run$9(argv, importMeta, { parentName }) {
|
|
|
10125
10387
|
'You need to be logged in to use this command. See `socket login`.',
|
|
10126
10388
|
pass: 'ok',
|
|
10127
10389
|
fail: 'missing API token'
|
|
10390
|
+
},
|
|
10391
|
+
{
|
|
10392
|
+
nook: true,
|
|
10393
|
+
test: !shadowNpmInject.isTestingV1() || !repoNameFlag,
|
|
10394
|
+
message: 'In v1 the first arg should be the repo, not the flag',
|
|
10395
|
+
pass: 'ok',
|
|
10396
|
+
fail: 'received --repo-name flag'
|
|
10128
10397
|
}
|
|
10129
10398
|
)
|
|
10130
10399
|
if (wasBadInput) {
|
|
@@ -10163,45 +10432,6 @@ const cmdRepos = {
|
|
|
10163
10432
|
}
|
|
10164
10433
|
}
|
|
10165
10434
|
|
|
10166
|
-
async function suggestOrgSlug() {
|
|
10167
|
-
const sockSdk = await shadowNpmInject.setupSdk()
|
|
10168
|
-
const result = await handleApiCall(
|
|
10169
|
-
sockSdk.getOrganizations(),
|
|
10170
|
-
'looking up organizations'
|
|
10171
|
-
)
|
|
10172
|
-
// Ignore a failed request here. It was not the primary goal of
|
|
10173
|
-
// running this command and reporting it only leads to end-user confusion.
|
|
10174
|
-
if (result.success) {
|
|
10175
|
-
const proceed = await prompts.select({
|
|
10176
|
-
message:
|
|
10177
|
-
'Missing org name; do you want to use any of these orgs for this scan?',
|
|
10178
|
-
choices: [
|
|
10179
|
-
...Object.values(result.data.organizations).map(org => {
|
|
10180
|
-
const slug = org.name ?? 'undefined'
|
|
10181
|
-
return {
|
|
10182
|
-
name: `Yes [${slug}]`,
|
|
10183
|
-
value: slug,
|
|
10184
|
-
description: `Use "${slug}" as the organization`
|
|
10185
|
-
}
|
|
10186
|
-
}),
|
|
10187
|
-
{
|
|
10188
|
-
name: 'No',
|
|
10189
|
-
value: '',
|
|
10190
|
-
description:
|
|
10191
|
-
'Do not use any of these organizations (will end in a no-op)'
|
|
10192
|
-
}
|
|
10193
|
-
]
|
|
10194
|
-
})
|
|
10195
|
-
if (proceed) {
|
|
10196
|
-
return proceed
|
|
10197
|
-
}
|
|
10198
|
-
} else {
|
|
10199
|
-
logger.logger.fail(
|
|
10200
|
-
'Failed to lookup organization list from API, unable to suggest'
|
|
10201
|
-
)
|
|
10202
|
-
}
|
|
10203
|
-
}
|
|
10204
|
-
|
|
10205
10435
|
async function suggestTarget() {
|
|
10206
10436
|
// We could prefill this with sub-dirs of the current
|
|
10207
10437
|
// dir ... but is that going to be useful?
|
|
@@ -12278,7 +12508,7 @@ void (async () => {
|
|
|
12278
12508
|
await vendor.updater({
|
|
12279
12509
|
name: SOCKET_CLI_BIN_NAME,
|
|
12280
12510
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
12281
|
-
version: '0.14.
|
|
12511
|
+
version: '0.14.149',
|
|
12282
12512
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
12283
12513
|
})
|
|
12284
12514
|
try {
|
|
@@ -12346,5 +12576,5 @@ void (async () => {
|
|
|
12346
12576
|
await shadowNpmInject.captureException(e)
|
|
12347
12577
|
}
|
|
12348
12578
|
})()
|
|
12349
|
-
//# debugId=
|
|
12579
|
+
//# debugId=b16c9682-c6cb-499e-9433-037f8e571bc1
|
|
12350
12580
|
//# sourceMappingURL=cli.js.map
|