socket 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/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:5a035429: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
|
|
@@ -9407,6 +9413,45 @@ async function handleCreateRepo({
|
|
|
9407
9413
|
await outputCreateRepo()
|
|
9408
9414
|
}
|
|
9409
9415
|
|
|
9416
|
+
async function suggestOrgSlug() {
|
|
9417
|
+
const sockSdk = await shadowNpmInject.setupSdk()
|
|
9418
|
+
const result = await handleApiCall(
|
|
9419
|
+
sockSdk.getOrganizations(),
|
|
9420
|
+
'looking up organizations'
|
|
9421
|
+
)
|
|
9422
|
+
// Ignore a failed request here. It was not the primary goal of
|
|
9423
|
+
// running this command and reporting it only leads to end-user confusion.
|
|
9424
|
+
if (result.success) {
|
|
9425
|
+
const proceed = await prompts.select({
|
|
9426
|
+
message:
|
|
9427
|
+
'Missing org name; do you want to use any of these orgs for this scan?',
|
|
9428
|
+
choices: [
|
|
9429
|
+
...Object.values(result.data.organizations).map(org => {
|
|
9430
|
+
const slug = org.name ?? 'undefined'
|
|
9431
|
+
return {
|
|
9432
|
+
name: `Yes [${slug}]`,
|
|
9433
|
+
value: slug,
|
|
9434
|
+
description: `Use "${slug}" as the organization`
|
|
9435
|
+
}
|
|
9436
|
+
}),
|
|
9437
|
+
{
|
|
9438
|
+
name: 'No',
|
|
9439
|
+
value: '',
|
|
9440
|
+
description:
|
|
9441
|
+
'Do not use any of these organizations (will end in a no-op)'
|
|
9442
|
+
}
|
|
9443
|
+
]
|
|
9444
|
+
})
|
|
9445
|
+
if (proceed) {
|
|
9446
|
+
return proceed
|
|
9447
|
+
}
|
|
9448
|
+
} else {
|
|
9449
|
+
logger.logger.fail(
|
|
9450
|
+
'Failed to lookup organization list from API, unable to suggest'
|
|
9451
|
+
)
|
|
9452
|
+
}
|
|
9453
|
+
}
|
|
9454
|
+
|
|
9410
9455
|
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$d } = constants
|
|
9411
9456
|
const config$d = {
|
|
9412
9457
|
commandName: 'create',
|
|
@@ -9414,11 +9459,28 @@ const config$d = {
|
|
|
9414
9459
|
hidden: false,
|
|
9415
9460
|
flags: {
|
|
9416
9461
|
...commonFlags,
|
|
9417
|
-
|
|
9462
|
+
defaultBranch: {
|
|
9418
9463
|
type: 'string',
|
|
9419
|
-
shortFlag: '
|
|
9464
|
+
shortFlag: 'b',
|
|
9465
|
+
default: 'main',
|
|
9466
|
+
description: 'Repository default branch'
|
|
9467
|
+
},
|
|
9468
|
+
homepage: {
|
|
9469
|
+
type: 'string',
|
|
9470
|
+
shortFlag: 'h',
|
|
9420
9471
|
default: '',
|
|
9421
|
-
description: 'Repository
|
|
9472
|
+
description: 'Repository url'
|
|
9473
|
+
},
|
|
9474
|
+
interactive: {
|
|
9475
|
+
type: 'boolean',
|
|
9476
|
+
default: true,
|
|
9477
|
+
description:
|
|
9478
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
9479
|
+
},
|
|
9480
|
+
org: {
|
|
9481
|
+
type: 'string',
|
|
9482
|
+
description:
|
|
9483
|
+
'Force override the organization slug, overrides the default org from config'
|
|
9422
9484
|
},
|
|
9423
9485
|
repoDescription: {
|
|
9424
9486
|
type: 'string',
|
|
@@ -9426,17 +9488,11 @@ const config$d = {
|
|
|
9426
9488
|
default: '',
|
|
9427
9489
|
description: 'Repository description'
|
|
9428
9490
|
},
|
|
9429
|
-
|
|
9491
|
+
repoName: {
|
|
9430
9492
|
type: 'string',
|
|
9431
|
-
shortFlag: '
|
|
9493
|
+
shortFlag: 'n',
|
|
9432
9494
|
default: '',
|
|
9433
|
-
description: 'Repository
|
|
9434
|
-
},
|
|
9435
|
-
defaultBranch: {
|
|
9436
|
-
type: 'string',
|
|
9437
|
-
shortFlag: 'b',
|
|
9438
|
-
default: 'main',
|
|
9439
|
-
description: 'Repository default branch'
|
|
9495
|
+
description: 'Repository name'
|
|
9440
9496
|
},
|
|
9441
9497
|
visibility: {
|
|
9442
9498
|
type: 'string',
|
|
@@ -9447,7 +9503,7 @@ const config$d = {
|
|
|
9447
9503
|
},
|
|
9448
9504
|
help: (command, config) => `
|
|
9449
9505
|
Usage
|
|
9450
|
-
$ ${command} <org slug> --repo-name=<name>
|
|
9506
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
9451
9507
|
|
|
9452
9508
|
API Token Requirements
|
|
9453
9509
|
- Quota: 1 unit
|
|
@@ -9457,7 +9513,7 @@ const config$d = {
|
|
|
9457
9513
|
${getFlagListOutput(config.flags, 6)}
|
|
9458
9514
|
|
|
9459
9515
|
Examples
|
|
9460
|
-
$ ${command} FakeOrg --repoName=test-repo
|
|
9516
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg --repoName=test-repo'}
|
|
9461
9517
|
`
|
|
9462
9518
|
}
|
|
9463
9519
|
const cmdReposCreate = {
|
|
@@ -9472,21 +9528,51 @@ async function run$d(argv, importMeta, { parentName }) {
|
|
|
9472
9528
|
importMeta,
|
|
9473
9529
|
parentName
|
|
9474
9530
|
})
|
|
9475
|
-
const repoName = cli.flags['repoName']
|
|
9476
9531
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9477
|
-
const
|
|
9532
|
+
const interactive = cli.flags['interactive']
|
|
9533
|
+
const dryRun = cli.flags['dryRun']
|
|
9534
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
9535
|
+
if (!orgSlug) {
|
|
9536
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
9537
|
+
// ask from server
|
|
9538
|
+
logger.logger.error(
|
|
9539
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
9540
|
+
)
|
|
9541
|
+
logger.logger.error(
|
|
9542
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
9543
|
+
)
|
|
9544
|
+
if (dryRun) {
|
|
9545
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
9546
|
+
} else if (!interactive) {
|
|
9547
|
+
logger.logger.fail(
|
|
9548
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
9549
|
+
)
|
|
9550
|
+
} else {
|
|
9551
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
9552
|
+
}
|
|
9553
|
+
} else {
|
|
9554
|
+
orgSlug = cli.input[0] || ''
|
|
9555
|
+
}
|
|
9556
|
+
}
|
|
9557
|
+
const repoNameFlag = cli.flags['repoName']
|
|
9558
|
+
const repoName =
|
|
9559
|
+
(shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
|
|
9478
9560
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9479
9561
|
const wasBadInput = handleBadInput(
|
|
9480
9562
|
{
|
|
9481
9563
|
nook: true,
|
|
9482
9564
|
test: !!orgSlug,
|
|
9483
|
-
message:
|
|
9565
|
+
message: shadowNpmInject.isTestingV1()
|
|
9566
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
9567
|
+
: 'Org name must be the first argument',
|
|
9484
9568
|
pass: 'ok',
|
|
9485
9569
|
fail: 'missing'
|
|
9486
9570
|
},
|
|
9487
9571
|
{
|
|
9488
9572
|
test: !!repoName,
|
|
9489
|
-
message:
|
|
9573
|
+
message: shadowNpmInject.isTestingV1()
|
|
9574
|
+
? 'Repository name as first argument'
|
|
9575
|
+
: 'Repository name using --repoName',
|
|
9490
9576
|
pass: 'ok',
|
|
9491
9577
|
fail: 'missing'
|
|
9492
9578
|
},
|
|
@@ -9497,12 +9583,19 @@ async function run$d(argv, importMeta, { parentName }) {
|
|
|
9497
9583
|
'You need to be logged in to use this command. See `socket login`.',
|
|
9498
9584
|
pass: 'ok',
|
|
9499
9585
|
fail: 'missing API token'
|
|
9586
|
+
},
|
|
9587
|
+
{
|
|
9588
|
+
nook: true,
|
|
9589
|
+
test: !shadowNpmInject.isTestingV1() || !repoNameFlag,
|
|
9590
|
+
message: 'In v1 the first arg should be the repo, not the flag',
|
|
9591
|
+
pass: 'ok',
|
|
9592
|
+
fail: 'received --repo-name flag'
|
|
9500
9593
|
}
|
|
9501
9594
|
)
|
|
9502
9595
|
if (wasBadInput) {
|
|
9503
9596
|
return
|
|
9504
9597
|
}
|
|
9505
|
-
if (
|
|
9598
|
+
if (dryRun) {
|
|
9506
9599
|
logger.logger.log(DRY_RUN_BAIL_TEXT$d)
|
|
9507
9600
|
return
|
|
9508
9601
|
}
|
|
@@ -9538,11 +9631,22 @@ const config$c = {
|
|
|
9538
9631
|
description: 'Delete a repository in an organization',
|
|
9539
9632
|
hidden: false,
|
|
9540
9633
|
flags: {
|
|
9541
|
-
...commonFlags
|
|
9634
|
+
...commonFlags,
|
|
9635
|
+
interactive: {
|
|
9636
|
+
type: 'boolean',
|
|
9637
|
+
default: true,
|
|
9638
|
+
description:
|
|
9639
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
9640
|
+
},
|
|
9641
|
+
org: {
|
|
9642
|
+
type: 'string',
|
|
9643
|
+
description:
|
|
9644
|
+
'Force override the organization slug, overrides the default org from config'
|
|
9645
|
+
}
|
|
9542
9646
|
},
|
|
9543
9647
|
help: (command, config) => `
|
|
9544
9648
|
Usage
|
|
9545
|
-
$ ${command} <org slug>
|
|
9649
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
9546
9650
|
|
|
9547
9651
|
API Token Requirements
|
|
9548
9652
|
- Quota: 1 unit
|
|
@@ -9552,7 +9656,7 @@ const config$c = {
|
|
|
9552
9656
|
${getFlagListOutput(config.flags, 6)}
|
|
9553
9657
|
|
|
9554
9658
|
Examples
|
|
9555
|
-
$ ${command} FakeOrg test-repo
|
|
9659
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg test-repo'}
|
|
9556
9660
|
`
|
|
9557
9661
|
}
|
|
9558
9662
|
const cmdReposDel = {
|
|
@@ -9568,20 +9672,51 @@ async function run$c(argv, importMeta, { parentName }) {
|
|
|
9568
9672
|
parentName
|
|
9569
9673
|
})
|
|
9570
9674
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9571
|
-
const
|
|
9572
|
-
const
|
|
9675
|
+
const interactive = cli.flags['interactive']
|
|
9676
|
+
const dryRun = cli.flags['dryRun']
|
|
9677
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
9678
|
+
if (!orgSlug) {
|
|
9679
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
9680
|
+
// ask from server
|
|
9681
|
+
logger.logger.error(
|
|
9682
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
9683
|
+
)
|
|
9684
|
+
logger.logger.error(
|
|
9685
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
9686
|
+
)
|
|
9687
|
+
if (dryRun) {
|
|
9688
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
9689
|
+
} else if (!interactive) {
|
|
9690
|
+
logger.logger.fail(
|
|
9691
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
9692
|
+
)
|
|
9693
|
+
} else {
|
|
9694
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
9695
|
+
}
|
|
9696
|
+
} else {
|
|
9697
|
+
orgSlug = cli.input[0] || ''
|
|
9698
|
+
}
|
|
9699
|
+
}
|
|
9700
|
+
const repoName =
|
|
9701
|
+
(defaultOrgSlug || shadowNpmInject.isTestingV1()
|
|
9702
|
+
? cli.input[0]
|
|
9703
|
+
: cli.input[1]) || ''
|
|
9573
9704
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9574
9705
|
const wasBadInput = handleBadInput(
|
|
9575
9706
|
{
|
|
9576
9707
|
nook: true,
|
|
9577
9708
|
test: !!orgSlug,
|
|
9578
|
-
message:
|
|
9709
|
+
message: shadowNpmInject.isTestingV1()
|
|
9710
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
9711
|
+
: 'Org name must be the first argument',
|
|
9579
9712
|
pass: 'ok',
|
|
9580
9713
|
fail: 'missing'
|
|
9581
9714
|
},
|
|
9582
9715
|
{
|
|
9583
9716
|
test: !!repoName,
|
|
9584
|
-
message:
|
|
9717
|
+
message: shadowNpmInject.isTestingV1()
|
|
9718
|
+
? 'Repository name as first argument'
|
|
9719
|
+
: 'Repository name using --repoName',
|
|
9585
9720
|
pass: 'ok',
|
|
9586
9721
|
fail: 'missing'
|
|
9587
9722
|
},
|
|
@@ -9597,7 +9732,7 @@ async function run$c(argv, importMeta, { parentName }) {
|
|
|
9597
9732
|
if (wasBadInput) {
|
|
9598
9733
|
return
|
|
9599
9734
|
}
|
|
9600
|
-
if (
|
|
9735
|
+
if (dryRun) {
|
|
9601
9736
|
logger.logger.log(DRY_RUN_BAIL_TEXT$c)
|
|
9602
9737
|
return
|
|
9603
9738
|
}
|
|
@@ -9705,6 +9840,17 @@ const config$b = {
|
|
|
9705
9840
|
default: 'desc',
|
|
9706
9841
|
description: 'Direction option'
|
|
9707
9842
|
},
|
|
9843
|
+
interactive: {
|
|
9844
|
+
type: 'boolean',
|
|
9845
|
+
default: true,
|
|
9846
|
+
description:
|
|
9847
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
9848
|
+
},
|
|
9849
|
+
org: {
|
|
9850
|
+
type: 'string',
|
|
9851
|
+
description:
|
|
9852
|
+
'Force override the organization slug, overrides the default org from config'
|
|
9853
|
+
},
|
|
9708
9854
|
perPage: {
|
|
9709
9855
|
type: 'number',
|
|
9710
9856
|
shortFlag: 'pp',
|
|
@@ -9721,7 +9867,7 @@ const config$b = {
|
|
|
9721
9867
|
},
|
|
9722
9868
|
help: (command, config) => `
|
|
9723
9869
|
Usage
|
|
9724
|
-
$ ${command} <org slug>
|
|
9870
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '' : '<org slug>'}
|
|
9725
9871
|
|
|
9726
9872
|
API Token Requirements
|
|
9727
9873
|
- Quota: 1 unit
|
|
@@ -9731,7 +9877,7 @@ const config$b = {
|
|
|
9731
9877
|
${getFlagListOutput(config.flags, 6)}
|
|
9732
9878
|
|
|
9733
9879
|
Examples
|
|
9734
|
-
$ ${command}
|
|
9880
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '' : '<org slug>'}
|
|
9735
9881
|
`
|
|
9736
9882
|
}
|
|
9737
9883
|
const cmdReposList = {
|
|
@@ -9748,13 +9894,39 @@ async function run$b(argv, importMeta, { parentName }) {
|
|
|
9748
9894
|
})
|
|
9749
9895
|
const { json, markdown } = cli.flags
|
|
9750
9896
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9751
|
-
const
|
|
9897
|
+
const interactive = cli.flags['interactive']
|
|
9898
|
+
const dryRun = cli.flags['dryRun']
|
|
9899
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
9900
|
+
if (!orgSlug) {
|
|
9901
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
9902
|
+
// ask from server
|
|
9903
|
+
logger.logger.error(
|
|
9904
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
9905
|
+
)
|
|
9906
|
+
logger.logger.error(
|
|
9907
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
9908
|
+
)
|
|
9909
|
+
if (dryRun) {
|
|
9910
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
9911
|
+
} else if (!interactive) {
|
|
9912
|
+
logger.logger.fail(
|
|
9913
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
9914
|
+
)
|
|
9915
|
+
} else {
|
|
9916
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
9917
|
+
}
|
|
9918
|
+
} else {
|
|
9919
|
+
orgSlug = cli.input[0] || ''
|
|
9920
|
+
}
|
|
9921
|
+
}
|
|
9752
9922
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9753
9923
|
const wasBadInput = handleBadInput(
|
|
9754
9924
|
{
|
|
9755
9925
|
nook: true,
|
|
9756
9926
|
test: !!orgSlug,
|
|
9757
|
-
message:
|
|
9927
|
+
message: shadowNpmInject.isTestingV1()
|
|
9928
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
9929
|
+
: 'Org name must be the first argument',
|
|
9758
9930
|
pass: 'ok',
|
|
9759
9931
|
fail: 'missing'
|
|
9760
9932
|
},
|
|
@@ -9856,6 +10028,29 @@ const config$a = {
|
|
|
9856
10028
|
hidden: false,
|
|
9857
10029
|
flags: {
|
|
9858
10030
|
...commonFlags,
|
|
10031
|
+
defaultBranch: {
|
|
10032
|
+
type: 'string',
|
|
10033
|
+
shortFlag: 'b',
|
|
10034
|
+
default: 'main',
|
|
10035
|
+
description: 'Repository default branch'
|
|
10036
|
+
},
|
|
10037
|
+
homepage: {
|
|
10038
|
+
type: 'string',
|
|
10039
|
+
shortFlag: 'h',
|
|
10040
|
+
default: '',
|
|
10041
|
+
description: 'Repository url'
|
|
10042
|
+
},
|
|
10043
|
+
interactive: {
|
|
10044
|
+
type: 'boolean',
|
|
10045
|
+
default: true,
|
|
10046
|
+
description:
|
|
10047
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
10048
|
+
},
|
|
10049
|
+
org: {
|
|
10050
|
+
type: 'string',
|
|
10051
|
+
description:
|
|
10052
|
+
'Force override the organization slug, overrides the default org from config'
|
|
10053
|
+
},
|
|
9859
10054
|
repoName: {
|
|
9860
10055
|
type: 'string',
|
|
9861
10056
|
shortFlag: 'n',
|
|
@@ -9868,18 +10063,6 @@ const config$a = {
|
|
|
9868
10063
|
default: '',
|
|
9869
10064
|
description: 'Repository description'
|
|
9870
10065
|
},
|
|
9871
|
-
homepage: {
|
|
9872
|
-
type: 'string',
|
|
9873
|
-
shortFlag: 'h',
|
|
9874
|
-
default: '',
|
|
9875
|
-
description: 'Repository url'
|
|
9876
|
-
},
|
|
9877
|
-
defaultBranch: {
|
|
9878
|
-
type: 'string',
|
|
9879
|
-
shortFlag: 'b',
|
|
9880
|
-
default: 'main',
|
|
9881
|
-
description: 'Repository default branch'
|
|
9882
|
-
},
|
|
9883
10066
|
visibility: {
|
|
9884
10067
|
type: 'string',
|
|
9885
10068
|
shortFlag: 'v',
|
|
@@ -9889,7 +10072,7 @@ const config$a = {
|
|
|
9889
10072
|
},
|
|
9890
10073
|
help: (command, config) => `
|
|
9891
10074
|
Usage
|
|
9892
|
-
$ ${command} <org slug> --repo-name=<name>
|
|
10075
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
9893
10076
|
|
|
9894
10077
|
API Token Requirements
|
|
9895
10078
|
- Quota: 1 unit
|
|
@@ -9899,7 +10082,7 @@ const config$a = {
|
|
|
9899
10082
|
${getFlagListOutput(config.flags, 6)}
|
|
9900
10083
|
|
|
9901
10084
|
Examples
|
|
9902
|
-
$ ${command} FakeOrg
|
|
10085
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg test-repo'}
|
|
9903
10086
|
`
|
|
9904
10087
|
}
|
|
9905
10088
|
const cmdReposUpdate = {
|
|
@@ -9914,21 +10097,51 @@ async function run$a(argv, importMeta, { parentName }) {
|
|
|
9914
10097
|
importMeta,
|
|
9915
10098
|
parentName
|
|
9916
10099
|
})
|
|
9917
|
-
const repoName = cli.flags['repoName']
|
|
9918
10100
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
9919
|
-
const
|
|
10101
|
+
const interactive = cli.flags['interactive']
|
|
10102
|
+
const dryRun = cli.flags['dryRun']
|
|
10103
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
10104
|
+
if (!orgSlug) {
|
|
10105
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
10106
|
+
// ask from server
|
|
10107
|
+
logger.logger.error(
|
|
10108
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
10109
|
+
)
|
|
10110
|
+
logger.logger.error(
|
|
10111
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
10112
|
+
)
|
|
10113
|
+
if (dryRun) {
|
|
10114
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
10115
|
+
} else if (!interactive) {
|
|
10116
|
+
logger.logger.fail(
|
|
10117
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
10118
|
+
)
|
|
10119
|
+
} else {
|
|
10120
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
10121
|
+
}
|
|
10122
|
+
} else {
|
|
10123
|
+
orgSlug = cli.input[0] || ''
|
|
10124
|
+
}
|
|
10125
|
+
}
|
|
10126
|
+
const repoNameFlag = cli.flags['repoName']
|
|
10127
|
+
const repoName =
|
|
10128
|
+
(shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
|
|
9920
10129
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
9921
10130
|
const wasBadInput = handleBadInput(
|
|
9922
10131
|
{
|
|
9923
10132
|
nook: true,
|
|
9924
10133
|
test: !!orgSlug,
|
|
9925
|
-
message:
|
|
10134
|
+
message: shadowNpmInject.isTestingV1()
|
|
10135
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
10136
|
+
: 'Org name must be the first argument',
|
|
9926
10137
|
pass: 'ok',
|
|
9927
10138
|
fail: 'missing'
|
|
9928
10139
|
},
|
|
9929
10140
|
{
|
|
9930
10141
|
test: !!repoName,
|
|
9931
|
-
message:
|
|
10142
|
+
message: shadowNpmInject.isTestingV1()
|
|
10143
|
+
? 'Repository name as first argument'
|
|
10144
|
+
: 'Repository name using --repoName',
|
|
9932
10145
|
pass: 'ok',
|
|
9933
10146
|
fail: 'missing'
|
|
9934
10147
|
},
|
|
@@ -9939,6 +10152,13 @@ async function run$a(argv, importMeta, { parentName }) {
|
|
|
9939
10152
|
'You need to be logged in to use this command. See `socket login`.',
|
|
9940
10153
|
pass: 'ok',
|
|
9941
10154
|
fail: 'missing API token'
|
|
10155
|
+
},
|
|
10156
|
+
{
|
|
10157
|
+
nook: true,
|
|
10158
|
+
test: !shadowNpmInject.isTestingV1() || !repoNameFlag,
|
|
10159
|
+
message: 'In v1 the first arg should be the repo, not the flag',
|
|
10160
|
+
pass: 'ok',
|
|
10161
|
+
fail: 'received --repo-name flag'
|
|
9942
10162
|
}
|
|
9943
10163
|
)
|
|
9944
10164
|
if (wasBadInput) {
|
|
@@ -10055,6 +10275,17 @@ const config$9 = {
|
|
|
10055
10275
|
flags: {
|
|
10056
10276
|
...commonFlags,
|
|
10057
10277
|
...outputFlags,
|
|
10278
|
+
interactive: {
|
|
10279
|
+
type: 'boolean',
|
|
10280
|
+
default: true,
|
|
10281
|
+
description:
|
|
10282
|
+
'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
10283
|
+
},
|
|
10284
|
+
org: {
|
|
10285
|
+
type: 'string',
|
|
10286
|
+
description:
|
|
10287
|
+
'Force override the organization slug, overrides the default org from config'
|
|
10288
|
+
},
|
|
10058
10289
|
repoName: {
|
|
10059
10290
|
description: 'The repository to check',
|
|
10060
10291
|
default: '',
|
|
@@ -10063,7 +10294,7 @@ const config$9 = {
|
|
|
10063
10294
|
},
|
|
10064
10295
|
help: (command, config) => `
|
|
10065
10296
|
Usage
|
|
10066
|
-
$ ${command} <org slug> --repo-name=<name>
|
|
10297
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug> --repo-name=<name>'}
|
|
10067
10298
|
|
|
10068
10299
|
API Token Requirements
|
|
10069
10300
|
- Quota: 1 unit
|
|
@@ -10073,7 +10304,7 @@ const config$9 = {
|
|
|
10073
10304
|
${getFlagListOutput(config.flags, 6)}
|
|
10074
10305
|
|
|
10075
10306
|
Examples
|
|
10076
|
-
$ ${command} FakeOrg
|
|
10307
|
+
$ ${command} ${shadowNpmInject.isTestingV1() ? 'test-repo' : 'FakeOrg test-repo'}
|
|
10077
10308
|
`
|
|
10078
10309
|
}
|
|
10079
10310
|
const cmdReposView = {
|
|
@@ -10088,21 +10319,52 @@ async function run$9(argv, importMeta, { parentName }) {
|
|
|
10088
10319
|
importMeta,
|
|
10089
10320
|
parentName
|
|
10090
10321
|
})
|
|
10091
|
-
const { json, markdown
|
|
10322
|
+
const { json, markdown } = cli.flags
|
|
10092
10323
|
const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
|
|
10093
|
-
const
|
|
10324
|
+
const interactive = cli.flags['interactive']
|
|
10325
|
+
const dryRun = cli.flags['dryRun']
|
|
10326
|
+
let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
|
|
10327
|
+
if (!orgSlug) {
|
|
10328
|
+
if (shadowNpmInject.isTestingV1()) {
|
|
10329
|
+
// ask from server
|
|
10330
|
+
logger.logger.error(
|
|
10331
|
+
'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
|
|
10332
|
+
)
|
|
10333
|
+
logger.logger.error(
|
|
10334
|
+
'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
|
|
10335
|
+
)
|
|
10336
|
+
if (dryRun) {
|
|
10337
|
+
logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
|
|
10338
|
+
} else if (!interactive) {
|
|
10339
|
+
logger.logger.fail(
|
|
10340
|
+
'Skipping auto-discovery of org when interactive = false'
|
|
10341
|
+
)
|
|
10342
|
+
} else {
|
|
10343
|
+
orgSlug = (await suggestOrgSlug()) || ''
|
|
10344
|
+
}
|
|
10345
|
+
} else {
|
|
10346
|
+
orgSlug = cli.input[0] || ''
|
|
10347
|
+
}
|
|
10348
|
+
}
|
|
10349
|
+
const repoNameFlag = cli.flags['repoName']
|
|
10350
|
+
const repoName =
|
|
10351
|
+
(shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
|
|
10094
10352
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
10095
10353
|
const wasBadInput = handleBadInput(
|
|
10096
10354
|
{
|
|
10097
10355
|
nook: true,
|
|
10098
10356
|
test: !!orgSlug,
|
|
10099
|
-
message:
|
|
10357
|
+
message: shadowNpmInject.isTestingV1()
|
|
10358
|
+
? 'Org name by default setting, --org, or auto-discovered'
|
|
10359
|
+
: 'Org name must be the first argument',
|
|
10100
10360
|
pass: 'ok',
|
|
10101
10361
|
fail: 'missing'
|
|
10102
10362
|
},
|
|
10103
10363
|
{
|
|
10104
10364
|
test: !!repoName,
|
|
10105
|
-
message:
|
|
10365
|
+
message: shadowNpmInject.isTestingV1()
|
|
10366
|
+
? 'Repository name as first argument'
|
|
10367
|
+
: 'Repository name using --repoName',
|
|
10106
10368
|
pass: 'ok',
|
|
10107
10369
|
fail: 'missing'
|
|
10108
10370
|
},
|
|
@@ -10121,6 +10383,13 @@ async function run$9(argv, importMeta, { parentName }) {
|
|
|
10121
10383
|
'You need to be logged in to use this command. See `socket login`.',
|
|
10122
10384
|
pass: 'ok',
|
|
10123
10385
|
fail: 'missing API token'
|
|
10386
|
+
},
|
|
10387
|
+
{
|
|
10388
|
+
nook: true,
|
|
10389
|
+
test: !shadowNpmInject.isTestingV1() || !repoNameFlag,
|
|
10390
|
+
message: 'In v1 the first arg should be the repo, not the flag',
|
|
10391
|
+
pass: 'ok',
|
|
10392
|
+
fail: 'received --repo-name flag'
|
|
10124
10393
|
}
|
|
10125
10394
|
)
|
|
10126
10395
|
if (wasBadInput) {
|
|
@@ -10159,45 +10428,6 @@ const cmdRepos = {
|
|
|
10159
10428
|
}
|
|
10160
10429
|
}
|
|
10161
10430
|
|
|
10162
|
-
async function suggestOrgSlug() {
|
|
10163
|
-
const sockSdk = await shadowNpmInject.setupSdk()
|
|
10164
|
-
const result = await handleApiCall(
|
|
10165
|
-
sockSdk.getOrganizations(),
|
|
10166
|
-
'looking up organizations'
|
|
10167
|
-
)
|
|
10168
|
-
// Ignore a failed request here. It was not the primary goal of
|
|
10169
|
-
// running this command and reporting it only leads to end-user confusion.
|
|
10170
|
-
if (result.success) {
|
|
10171
|
-
const proceed = await prompts.select({
|
|
10172
|
-
message:
|
|
10173
|
-
'Missing org name; do you want to use any of these orgs for this scan?',
|
|
10174
|
-
choices: [
|
|
10175
|
-
...Object.values(result.data.organizations).map(org => {
|
|
10176
|
-
const slug = org.name ?? 'undefined'
|
|
10177
|
-
return {
|
|
10178
|
-
name: `Yes [${slug}]`,
|
|
10179
|
-
value: slug,
|
|
10180
|
-
description: `Use "${slug}" as the organization`
|
|
10181
|
-
}
|
|
10182
|
-
}),
|
|
10183
|
-
{
|
|
10184
|
-
name: 'No',
|
|
10185
|
-
value: '',
|
|
10186
|
-
description:
|
|
10187
|
-
'Do not use any of these organizations (will end in a no-op)'
|
|
10188
|
-
}
|
|
10189
|
-
]
|
|
10190
|
-
})
|
|
10191
|
-
if (proceed) {
|
|
10192
|
-
return proceed
|
|
10193
|
-
}
|
|
10194
|
-
} else {
|
|
10195
|
-
logger.logger.fail(
|
|
10196
|
-
'Failed to lookup organization list from API, unable to suggest'
|
|
10197
|
-
)
|
|
10198
|
-
}
|
|
10199
|
-
}
|
|
10200
|
-
|
|
10201
10431
|
async function suggestTarget() {
|
|
10202
10432
|
// We could prefill this with sub-dirs of the current
|
|
10203
10433
|
// dir ... but is that going to be useful?
|
|
@@ -12274,7 +12504,7 @@ void (async () => {
|
|
|
12274
12504
|
await vendor.updater({
|
|
12275
12505
|
name: SOCKET_CLI_BIN_NAME,
|
|
12276
12506
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
12277
|
-
version: '0.14.
|
|
12507
|
+
version: '0.14.149',
|
|
12278
12508
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
12279
12509
|
})
|
|
12280
12510
|
try {
|
|
@@ -12342,5 +12572,5 @@ void (async () => {
|
|
|
12342
12572
|
await shadowNpmInject.captureException(e)
|
|
12343
12573
|
}
|
|
12344
12574
|
})()
|
|
12345
|
-
//# debugId=
|
|
12575
|
+
//# debugId=f345cafe-75b2-4c4f-8efd-1c13139d9917
|
|
12346
12576
|
//# sourceMappingURL=cli.js.map
|