Skip to content

Commit 2502718

Browse files
authored
Merge branch 'main' into polish_usage
2 parents a08cdae + 1ff9a26 commit 2502718

17 files changed

+113
-66
lines changed

src/commands/repos/cmd-repos-create.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('socket repos create', async () => {
7272
7373
- Org name as the first argument (\\x1b[31mmissing\\x1b[39m)
7474
75-
- Repository name using --repoNam (\\x1b[31minvalid\\x1b[39m)
75+
- Repository name using --repoNam (\\x1b[31mmissing\\x1b[39m)
7676
7777
- You need to be logged in to use this command. See \`socket login\`. (\\x1b[31mmissing API token\\x1b[39m)"
7878
`)

src/commands/repos/cmd-repos-create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function run(
101101
test: repoName,
102102
message: 'Repository name using --repoNam',
103103
pass: 'ok',
104-
fail: typeof repoName !== 'string' ? 'missing' : 'invalid'
104+
fail: 'missing'
105105
},
106106
{
107107
nook: true,

src/commands/repos/cmd-repos-del.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('socket repos del', async () => {
6767
6868
- Org name as the first argument (\\x1b[31mmissing\\x1b[39m)
6969
70-
- Repository name argument (\\x1b[31minvalid\\x1b[39m)
70+
- Repository name argument (\\x1b[31mmissing\\x1b[39m)
7171
7272
- You need to be logged in to use this command. See \`socket login\`. (\\x1b[31mmissing API token\\x1b[39m)"
7373
`)

src/commands/repos/cmd-repos-del.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function run(
7171
test: repoName,
7272
message: 'Repository name argument',
7373
pass: 'ok',
74-
fail: typeof repoName !== 'string' ? 'missing' : 'invalid'
74+
fail: 'missing'
7575
},
7676
{
7777
nook: true,

src/commands/repos/cmd-repos-update.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('socket repos update', async () => {
7272
7373
- Org name as the first argument (\\x1b[31mmissing\\x1b[39m)
7474
75-
- Repository name using --repoName (\\x1b[31minvalid\\x1b[39m)
75+
- Repository name using --repoName (\\x1b[31mmissing\\x1b[39m)
7676
7777
- You need to be logged in to use this command. See \`socket login\`. (\\x1b[31mmissing API token\\x1b[39m)"
7878
`)

src/commands/repos/cmd-repos-update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function run(
101101
test: repoName,
102102
message: 'Repository name using --repoName',
103103
pass: 'ok',
104-
fail: typeof repoName !== 'string' ? 'missing' : 'invalid'
104+
fail: 'missing'
105105
},
106106
{
107107
nook: true,

src/commands/repos/cmd-repos-view.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('socket repos view', async () => {
7070
7171
- Org name as the first argument (\\x1b[31mmissing\\x1b[39m)
7272
73-
- Repository name using --repoName (\\x1b[31minvalid\\x1b[39m)
73+
- Repository name using --repoName (\\x1b[31mmissing\\x1b[39m)
7474
7575
- You need to be logged in to use this command. See \`socket login\`. (\\x1b[31mmissing API token\\x1b[39m)"
7676
`)

src/commands/repos/cmd-repos-view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async function run(
7878
test: repoName,
7979
message: 'Repository name using --repoName',
8080
pass: 'ok',
81-
fail: typeof repoName !== 'string' ? 'missing' : 'invalid'
81+
fail: 'missing'
8282
},
8383
{
8484
nook: true,

src/commands/scan/cmd-scan-create.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ describe('socket scan create', async () => {
6363
--repo Repository name
6464
--report Wait for the scan creation to complete, then basically run \`socket scan report\` on it
6565
--tmp Set the visibility (true/false) of the scan in your dashboard
66-
--view Will wait for and return the created scan details. Use --no-view to disable.
6766
6867
Examples
6968
$ socket scan create --repo=test-repo --branch=main FakeOrg ./package.json"

src/commands/scan/cmd-scan-create.ts

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ const config: CliCommandConfig = {
2222
flags: {
2323
...commonFlags,
2424
...outputFlags,
25-
repo: {
26-
type: 'string',
27-
shortFlag: 'r',
28-
default: 'socket-default-repository',
29-
description: 'Repository name'
30-
},
3125
branch: {
3226
type: 'string',
3327
shortFlag: 'b',
@@ -46,6 +40,12 @@ const config: CliCommandConfig = {
4640
default: '',
4741
description: 'Commit hash'
4842
},
43+
committers: {
44+
type: 'string',
45+
shortFlag: 'c',
46+
default: '',
47+
description: 'Committers'
48+
},
4949
cwd: {
5050
type: 'string',
5151
description: 'working directory, defaults to process.cwd()'
@@ -56,34 +56,34 @@ const config: CliCommandConfig = {
5656
description:
5757
'Set the default branch of the repository to the branch of this full-scan. Should only need to be done once, for example for the "main" or "master" branch.'
5858
},
59-
pendingHead: {
59+
dryRun: {
6060
type: 'boolean',
61-
default: true,
6261
description:
63-
'Designate this full-scan as the latest scan of a given branch. This must be set to have it show up in the dashboard.'
62+
'Run input validation part of command without any concrete side effects'
6463
},
65-
dryRun: {
64+
pendingHead: {
6665
type: 'boolean',
66+
default: true,
6767
description:
68-
'run input validation part of command without any concrete side effects'
68+
'Designate this full-scan as the latest scan of a given branch. This must be set to have it show up in the dashboard.'
6969
},
7070
pullRequest: {
7171
type: 'number',
7272
shortFlag: 'pr',
7373
description: 'Commit hash'
7474
},
75-
committers: {
76-
type: 'string',
77-
shortFlag: 'c',
78-
default: '',
79-
description: 'Committers'
80-
},
8175
readOnly: {
8276
type: 'boolean',
8377
default: false,
8478
description:
8579
'Similar to --dry-run except it can read from remote, stops before it would create an actual report'
8680
},
81+
repo: {
82+
type: 'string',
83+
shortFlag: 'r',
84+
default: 'socket-default-repository',
85+
description: 'Repository name'
86+
},
8787
report: {
8888
type: 'boolean',
8989
default: false,
@@ -96,13 +96,6 @@ const config: CliCommandConfig = {
9696
default: false,
9797
description:
9898
'Set the visibility (true/false) of the scan in your dashboard'
99-
},
100-
view: {
101-
type: 'boolean',
102-
shortFlag: 'v',
103-
default: true,
104-
description:
105-
'Will wait for and return the created scan details. Use --no-view to disable.'
10699
}
107100
},
108101
// TODO: your project's "socket.yml" file's "projectIgnorePaths"
@@ -162,24 +155,32 @@ async function run(
162155

163156
const {
164157
branch: branchName = '',
158+
commitHash,
159+
commitMessage,
160+
committers,
165161
cwd: cwdOverride,
166162
defaultBranch,
167163
dryRun,
168164
json,
169165
markdown,
170166
pendingHead,
167+
pullRequest,
171168
readOnly,
172169
repo: repoName = '',
173170
report,
174171
tmp
175172
} = cli.flags as {
176173
branch: string
177174
cwd: string
175+
commitHash: string
176+
commitMessage: string
177+
committers: string
178178
defaultBranch: boolean
179179
dryRun: boolean
180180
json: boolean
181181
markdown: boolean
182182
pendingHead: boolean
183+
pullRequest: number
183184
readOnly: boolean
184185
repo: string
185186
report: boolean
@@ -235,17 +236,20 @@ async function run(
235236

236237
const wasBadInput = handleBadInput(
237238
{
238-
nook: true,
239-
test: orgSlug,
239+
nook: !!defaultOrgSlug,
240+
test: orgSlug && orgSlug !== '.',
240241
message: 'Org name as the first argument',
241242
pass: 'ok',
242-
fail: 'missing'
243+
fail:
244+
orgSlug === '.'
245+
? 'dot is an invalid org, most likely you forgot the org name here?'
246+
: 'missing'
243247
},
244248
{
245249
test: targets.length,
246250
message: 'At least one TARGET (e.g. `.` or `./package.json`)',
247251
pass: 'ok',
248-
fail: 'missing'
252+
fail: 'missing (or perhaps you forgot the org slug?)'
249253
},
250254
{
251255
nook: true,
@@ -257,9 +261,9 @@ async function run(
257261
{
258262
nook: true,
259263
test: apiToken,
260-
message: 'This command requires an API token for access`)',
264+
message: 'This command requires an API token for access',
261265
pass: 'ok',
262-
fail: 'missing'
266+
fail: 'missing (try `socket login`)'
263267
}
264268
)
265269
if (wasBadInput) {
@@ -274,12 +278,15 @@ async function run(
274278

275279
await handleCreateNewScan({
276280
branchName: branchName as string,
277-
commitMessage: (cli.flags['commitMessage'] as string | undefined) ?? '',
281+
commitHash: (commitHash && String(commitHash)) || '',
282+
commitMessage: (commitMessage && String(commitMessage)) || '',
283+
committers: (committers && String(committers)) || '',
278284
cwd,
279285
defaultBranch: Boolean(defaultBranch),
280286
orgSlug,
281287
outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
282288
pendingHead: Boolean(pendingHead),
289+
pullRequest: Number(pullRequest),
283290
readOnly: Boolean(readOnly),
284291
repoName: repoName,
285292
report,

0 commit comments

Comments
 (0)