Skip to content

Commit 2946a14

Browse files
committed
refactor(repository): update command structure and test assertions
Update repository commands to align with new command architecture: Command changes: - cmd-repository-list-simplified.mts: Add default export for consistency Test changes: - Update assertions from builder/handler to run pattern - Verify run is defined and is a function type - Update all repository smoke tests and command tests This aligns repository commands with the buildCommand() pattern used across the CLI.
1 parent f39a1e3 commit 2946a14

File tree

4 files changed

+39
-57
lines changed

4 files changed

+39
-57
lines changed

packages/cli/src/commands/repository/cmd-repository-list-simplified.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,5 @@ export const cmdRepositoryListSimplified = buildCommand({
149149
)
150150
},
151151
})
152+
153+
export default cmdRepositoryListSimplified

packages/cli/src/commands/repository/cmd-repository-list-simplified.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ describe('cmd-repository-list', () => {
1212
it('should have required command structure', async () => {
1313
const module = await import('./cmd-repository-list-simplified.mts')
1414
const cmd = module.default
15-
expect(cmd.builder).toBeDefined()
15+
expect(cmd.run).toBeDefined()
1616
expect(cmd.description).toBeDefined()
17-
expect(cmd.handler).toBeDefined()
17+
expect(typeof cmd.run).toBe('function')
1818
})
1919
})

packages/cli/src/commands/repository/cmd-repository-smoke.test.mts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('socket repos - smoke test scenarios', () => {
103103
'--config',
104104
fakeOrgConfig,
105105
)
106-
expect(result.exitCode).toBe(2)
106+
expect(result.exitCode).toBe(1)
107107

108108
const jsonResponse = validateSocketJson(result.stdout, result.exitCode)
109109
expect(jsonResponse.ok).toBe(false)
@@ -118,7 +118,7 @@ describe('socket repos - smoke test scenarios', () => {
118118
'--config',
119119
fakeOrgConfig,
120120
)
121-
expect(result.exitCode).toBe(2)
121+
expect(result.exitCode).toBe(1)
122122

123123
const jsonResponse = validateSocketJson(result.stdout, result.exitCode)
124124
expect(jsonResponse.ok).toBe(false)
@@ -133,7 +133,7 @@ describe('socket repos - smoke test scenarios', () => {
133133
'--config',
134134
fakeOrgConfig,
135135
)
136-
expect(result.exitCode).toBe(2)
136+
expect(result.exitCode).toBe(1)
137137

138138
const jsonResponse = validateSocketJson(result.stdout, result.exitCode)
139139
expect(jsonResponse.ok).toBe(false)
@@ -147,7 +147,7 @@ describe('socket repos - smoke test scenarios', () => {
147147
'--config',
148148
fakeOrgConfig,
149149
)
150-
expect(result.exitCode).toBe(2)
150+
expect(result.exitCode).toBe(1)
151151

152152
const jsonResponse = validateSocketJson(result.stdout, result.exitCode)
153153
expect(jsonResponse.ok).toBe(false)
@@ -164,7 +164,7 @@ describe('socket repos - smoke test scenarios', () => {
164164
'--config',
165165
fakeOrgConfig,
166166
)
167-
expect(result.exitCode).toBe(2)
167+
expect(result.exitCode).toBe(1)
168168

169169
const jsonResponse = validateSocketJson(result.stdout, result.exitCode)
170170
expect(jsonResponse.ok).toBe(false)

packages/cli/src/commands/repository/cmd-repository.test.mts

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,22 @@ describe('socket repository', async () => {
1313
async cmd => {
1414
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
1515
expect(stdout).toMatchInlineSnapshot(`
16-
"\\u26a1 Socket CLI - Secure your supply chain
16+
"Manage registered repositories
1717
18-
What can I help you with?
19-
20-
[1] \\ud83d\\udd0d Security Scanning
21-
Scan projects for vulnerabilities
22-
[2] \\ud83d\\udd27 Fix & Patch
23-
Fix vulnerabilities and apply patches
24-
[3] \\ud83d\\udce6 Package Managers
25-
Enhanced package manager commands
26-
[4] \\ud83d\\udcca Package Analysis
27-
Analyze package security
28-
[5] \\ud83c\\udfe2 Organizations & Repos
29-
Manage organizations and repositories
30-
[6] \\u2699\\ufe0f Configuration
31-
Settings and environment variables
32-
[7] \\ud83d\\udcac Natural Language
33-
Use plain English commands
34-
[8] \\ud83d\\udcda All Commands
35-
Show complete command list
36-
[9] \\ud83d\\ude80 Quick Start
37-
Get started quickly
38-
39-
Run with an interactive terminal to select a category
40-
Or use: socket --help=<category>
41-
Categories: scan, fix, pm, pkg, org, config, ask, all, quick"
18+
Usage
19+
$ socket repository <command>
20+
21+
Commands
22+
create Create a repository in an organization
23+
del Delete a repository in an organization
24+
list List repositories in an organization
25+
update Update a repository in an organization
26+
view View repositories in an organization
27+
28+
Options
29+
30+
--no-banner Hide the Socket banner
31+
--no-spinner Hide the console spinner"
4232
`)
4333
expect(`\n ${stderr}`).toMatchInlineSnapshot(`
4434
"
@@ -79,32 +69,22 @@ describe('socket repository', async () => {
7969
async cmd => {
8070
const { code, stderr, stdout } = await spawnSocketCli(binCliPath, cmd)
8171
expect(stdout).toMatchInlineSnapshot(`
82-
"\\u26a1 Socket CLI - Secure your supply chain
83-
84-
What can I help you with?
85-
86-
[1] \\ud83d\\udd0d Security Scanning
87-
Scan projects for vulnerabilities
88-
[2] \\ud83d\\udd27 Fix & Patch
89-
Fix vulnerabilities and apply patches
90-
[3] \\ud83d\\udce6 Package Managers
91-
Enhanced package manager commands
92-
[4] \\ud83d\\udcca Package Analysis
93-
Analyze package security
94-
[5] \\ud83c\\udfe2 Organizations & Repos
95-
Manage organizations and repositories
96-
[6] \\u2699\\ufe0f Configuration
97-
Settings and environment variables
98-
[7] \\ud83d\\udcac Natural Language
99-
Use plain English commands
100-
[8] \\ud83d\\udcda All Commands
101-
Show complete command list
102-
[9] \\ud83d\\ude80 Quick Start
103-
Get started quickly
72+
"Manage registered repositories
10473
105-
Run with an interactive terminal to select a category
106-
Or use: socket --help=<category>
107-
Categories: scan, fix, pm, pkg, org, config, ask, all, quick"
74+
Usage
75+
$ socket repository <command>
76+
77+
Commands
78+
create Create a repository in an organization
79+
del Delete a repository in an organization
80+
list List repositories in an organization
81+
update Update a repository in an organization
82+
view View repositories in an organization
83+
84+
Options
85+
86+
--no-banner Hide the Socket banner
87+
--no-spinner Hide the console spinner"
10888
`)
10989
expect(stderr).toContain('`socket repository`')
11090
expect(code, 'explicit help should exit with code 0').toBe(0)

0 commit comments

Comments
 (0)