Skip to content

Add v1 org discovery to all commands that need it #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
301 changes: 298 additions & 3 deletions src/commands/analytics/cmd-analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
$ socket analytics --scope=repo --repo=test-repo --time=30"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 48 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should support --help: `analytics --help --config {}`

Error: Snapshot `socket analytics > should support --help: `analytics --help --config {}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> - |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted>" + |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher." ❯ src/commands/analytics/cmd-analytics.test.ts:48:32

Check failure on line 48 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should support --help: `analytics --help --config {}`

Error: Snapshot `socket analytics > should support --help: `analytics --help --config {}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> - |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted>" + |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher." ❯ src/commands/analytics/cmd-analytics.test.ts:48:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
Expand All @@ -66,7 +66,7 @@
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`""`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 69 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should require args with just dry-run: `analytics --dry-run --config {}`

Error: Snapshot `socket analytics > should require args with just dry-run: `analytics --dry-run --config {}` 2` mismatched - Expected + Received @@ -1,10 +1,12 @@ " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> - |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[31m\xd7\x1b[39m \x1b[41m\x1b[1m\x1b[37m Input error: \x1b[39m\x1b[22m\x1b[49m \x1b[1mPlease review the input requirements and try again\x1b[22m - The time filter must either be 7, 30 or 90 (\x1b[32mok\x1b[39m) ❯ src/commands/analytics/cmd-analytics.test.ts:69:32

Check failure on line 69 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should require args with just dry-run: `analytics --dry-run --config {}`

Error: Snapshot `socket analytics > should require args with just dry-run: `analytics --dry-run --config {}` 2` mismatched - Expected + Received @@ -1,10 +1,12 @@ " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> - |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[31m\xd7\x1b[39m \x1b[41m\x1b[1m\x1b[37m Input error: \x1b[39m\x1b[22m\x1b[49m \x1b[1mPlease review the input requirements and try again\x1b[22m - The time filter must either be 7, 30 or 90 (\x1b[32mok\x1b[39m) ❯ src/commands/analytics/cmd-analytics.test.ts:69:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
Expand All @@ -75,8 +75,6 @@

\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[1m\\x1b[37m Input error: \\x1b[39m\\x1b[22m\\x1b[49m \\x1b[1mPlease review the input requirements and try again\\x1b[22m

- Scope must be "repo" or "org" (\\x1b[32mok\\x1b[39m)

- The time filter must either be 7, 30 or 90 (\\x1b[32mok\\x1b[39m)

- You need to be logged in to use this command. See \`socket login\`. (\\x1b[31mmissing API token\\x1b[39m)"
Expand All @@ -89,7 +87,6 @@
cmdit(
[
'analytics',
'boo',
'--scope',
'org',
'--repo',
Expand All @@ -102,7 +99,7 @@
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 102 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should require args with just dry-run: `analytics --scope org --repo bar --dry-run --config {"apiToken":"anything"}`

Error: Snapshot `socket analytics > should require args with just dry-run: `analytics --scope org --repo bar --dry-run --config {"apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> - |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted>" + |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher." ❯ src/commands/analytics/cmd-analytics.test.ts:102:32

Check failure on line 102 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should require args with just dry-run: `analytics --scope org --repo bar --dry-run --config {"apiToken":"anything"}`

Error: Snapshot `socket analytics > should require args with just dry-run: `analytics --scope org --repo bar --dry-run --config {"apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> - |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted>" + |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher." ❯ src/commands/analytics/cmd-analytics.test.ts:102:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
Expand All @@ -113,4 +110,302 @@
expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
['analytics', '--help', '--config', '{"isTestingV1": true}'],
'should support --help in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(
`
"Look up analytics data

Usage
$ socket analytics [ org | repo <reponame>] [time]

API Token Requirements
- Quota: 1 unit
- Permissions: report:write

The scope is either org or repo level, defaults to org.

When scope is repo, a repo slug must be given as well.

The time argument must be number 7, 30, or 90 and defaults to 7.

Options
--file Filepath to save output. Only valid with --json/--markdown. Defaults to stdout.
--help Print this help
--json Output result as json
--markdown Output result as markdown
--repo Name of the repository. Only valid when scope=repo
--scope Scope of the analytics data - either 'org' or 'repo', default: org
--time Time filter - either 7, 30 or 90, default: 7

Examples
$ socket analytics org 7
$ socket analytics repo test-repo 30
$ socket analytics 90"
`
)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 151 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should support --help in v1: `analytics --help --config {"isTestingV1": true}`

Error: Snapshot `socket analytics > should support --help in v1: `analytics --help --config {"isTestingV1": true}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:151:32

Check failure on line 151 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should support --help in v1: `analytics --help --config {"isTestingV1": true}`

Error: Snapshot `socket analytics > should support --help in v1: `analytics --help --config {"isTestingV1": true}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:151:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'help should exit with code 2').toBe(2)
expect(stderr, 'banner includes base command').toContain(
'`socket analytics`'
)
}
)

cmdit(
[
'analytics',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should run to dryrun without args in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 179 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should run to dryrun without args in v1: `analytics --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should run to dryrun without args in v1: `analytics --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:179:32

Check failure on line 179 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should run to dryrun without args in v1: `analytics --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should run to dryrun without args in v1: `analytics --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:179:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
[
'analytics',
'org',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should accept org arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 205 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept org arg in v1: `analytics org --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept org arg in v1: `analytics org --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:205:32

Check failure on line 205 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept org arg in v1: `analytics org --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept org arg in v1: `analytics org --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:205:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
[
'analytics',
'repo',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should ask for repo name with repo arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`""`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 231 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should ask for repo name with repo arg in v1: `analytics repo --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should ask for repo name with repo arg in v1: `analytics repo --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received @@ -1,10 +1,12 @@ " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m \x1b[31m\xd7\x1b[39m \x1b[41m\x1b[1m\x1b[37m Input error: \x1b[39m\x1b[22m\x1b[49m \x1b[1mPlease review the input requirements and try again\x1b[22m - Scope must be "repo" or "org" (\x1b[32mok\x1b[39m) ❯ src/commands/analytics/cmd-analytics.test.ts:231:32

Check failure on line 231 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should ask for repo name with repo arg in v1: `analytics repo --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should ask for repo name with repo arg in v1: `analytics repo --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received @@ -1,10 +1,12 @@ " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m \x1b[31m\xd7\x1b[39m \x1b[41m\x1b[1m\x1b[37m Input error: \x1b[39m\x1b[22m\x1b[49m \x1b[1mPlease review the input requirements and try again\x1b[22m - Scope must be "repo" or "org" (\x1b[32mok\x1b[39m) ❯ src/commands/analytics/cmd-analytics.test.ts:231:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m
\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[1m\\x1b[37m Input error: \\x1b[39m\\x1b[22m\\x1b[49m \\x1b[1mPlease review the input requirements and try again\\x1b[22m

- Scope must be "repo" or "org" (\\x1b[32mok\\x1b[39m)

- When scope=repo, repo name should be the second argument (\\x1b[31mmissing\\x1b[39m)

- The time filter must either be 7, 30 or 90 (\\x1b[32mok\\x1b[39m)"
`)

expect(code, 'dry-run should exit with code 2 if missing input').toBe(2)
}
)

cmdit(
[
'analytics',
'repo',
'daname',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should accept repo with arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 265 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept repo with arg in v1: `analytics repo daname --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept repo with arg in v1: `analytics repo daname --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:265:32

Check failure on line 265 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept repo with arg in v1: `analytics repo daname --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept repo with arg in v1: `analytics repo daname --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:265:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
[
'analytics',
'7',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should accept time 7 arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 291 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept time 7 arg in v1: `analytics 7 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept time 7 arg in v1: `analytics 7 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:291:32

Check failure on line 291 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept time 7 arg in v1: `analytics 7 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept time 7 arg in v1: `analytics 7 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:291:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
[
'analytics',
'30',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should accept time 30 arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`

Check failure on line 317 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, ubuntu-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept time 30 arg in v1: `analytics 30 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept time 30 arg in v1: `analytics 30 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:317:32

Check failure on line 317 in src/commands/analytics/cmd-analytics.test.ts

View workflow job for this annotation

GitHub Actions / Tests / Test (18, windows-latest)

src/commands/analytics/cmd-analytics.test.ts > socket analytics > should accept time 30 arg in v1: `analytics 30 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}`

Error: Snapshot `socket analytics > should accept time 30 arg in v1: `analytics 30 --dry-run --config {"isTestingV1": true, "apiToken":"anything"}` 2` mismatched - Expected + Received " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1) |__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted> |_____|___|___|_,_|___|_|.dev | Command: `socket analytics`, cwd: <redacted> + \x1b[1m \x1b[31mWarning:\x1b[39m NodeJS version 19 and lower will be \x1b[31munsupported\x1b[39m after April 30th. + \x1b[22m Soon after that the Socket CLI will require NodeJS version 20 or higher. \x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!) \x1b[39m" ❯ src/commands/analytics/cmd-analytics.test.ts:317:32
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
[
'analytics',
'90',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should accept time 90 arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
[
'analytics',
'org',
'7',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should accept org and time arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)

cmdit(
[
'analytics',
'repo',
'slowpo',
'30',
'--dry-run',
'--config',
'{"isTestingV1": true, "apiToken":"anything"}'
],
'should accept repo and time arg in v1',
async cmd => {
const { code, stderr, stdout } = await invokeNpm(entryPath, cmd)
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
"
_____ _ _ /---------------
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted> (is testing v1)
|__ | * | _| '_| -_| _| | Node: <redacted>, API token set: <redacted>
|_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: <redacted>
\\x1b[32m (Thank you for testing the v1 bump! Please send us any feedback you might have!)
\\x1b[39m"
`)

expect(code, 'dry-run should exit with code 0 if input ok').toBe(0)
}
)
})
Loading
Loading