@nexical/cli 0.1.7 → 0.11.0

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.
Files changed (241) hide show
  1. package/.github/workflows/deploy.yml +3 -3
  2. package/GEMINI.md +193 -0
  3. package/README.md +317 -104
  4. package/dist/chunk-JYASTIIW.js +42 -0
  5. package/dist/chunk-JYASTIIW.js.map +1 -0
  6. package/dist/chunk-LZ3YQWAR.js +2204 -0
  7. package/dist/chunk-LZ3YQWAR.js.map +1 -0
  8. package/dist/chunk-OKXOCNXP.js +105 -0
  9. package/dist/chunk-OKXOCNXP.js.map +1 -0
  10. package/dist/chunk-OYFWMYPG.js +52 -0
  11. package/dist/chunk-OYFWMYPG.js.map +1 -0
  12. package/dist/chunk-WKERTCM6.js +74 -0
  13. package/dist/chunk-WKERTCM6.js.map +1 -0
  14. package/dist/index.js +32 -5
  15. package/dist/index.js.map +1 -1
  16. package/dist/src/commands/init.d.ts +11 -0
  17. package/dist/src/commands/init.js +89 -0
  18. package/dist/src/commands/init.js.map +1 -0
  19. package/dist/src/commands/module/add.d.ts +14 -0
  20. package/dist/src/commands/module/add.js +136 -0
  21. package/dist/src/commands/module/add.js.map +1 -0
  22. package/dist/src/commands/module/list.d.ts +10 -0
  23. package/dist/src/commands/module/list.js +73 -0
  24. package/dist/src/commands/module/list.js.map +1 -0
  25. package/dist/src/commands/module/remove.d.ts +12 -0
  26. package/dist/src/commands/module/remove.js +71 -0
  27. package/dist/src/commands/module/remove.js.map +1 -0
  28. package/dist/src/commands/module/update.d.ts +11 -0
  29. package/dist/src/commands/module/update.js +52 -0
  30. package/dist/src/commands/module/update.js.map +1 -0
  31. package/dist/src/commands/run.d.ts +11 -0
  32. package/dist/src/commands/run.js +93 -0
  33. package/dist/src/commands/run.js.map +1 -0
  34. package/dist/src/commands/{login.d.ts → setup.d.ts} +2 -2
  35. package/dist/src/commands/setup.js +62 -0
  36. package/dist/src/commands/setup.js.map +1 -0
  37. package/dist/src/utils/discovery.d.ts +13 -0
  38. package/dist/src/utils/discovery.js +9 -0
  39. package/dist/src/utils/git.d.ts +16 -0
  40. package/dist/src/utils/git.js +29 -0
  41. package/dist/src/utils/git.js.map +1 -0
  42. package/dist/src/utils/url-resolver.d.ts +15 -0
  43. package/dist/src/utils/url-resolver.js +9 -0
  44. package/dist/src/utils/url-resolver.js.map +1 -0
  45. package/index.ts +29 -5
  46. package/package.json +32 -30
  47. package/src/commands/init.ts +86 -0
  48. package/src/commands/module/add.ts +169 -0
  49. package/src/commands/module/list.ts +69 -0
  50. package/src/commands/module/remove.ts +74 -0
  51. package/src/commands/module/update.ts +50 -0
  52. package/src/commands/run.ts +98 -0
  53. package/src/commands/setup.ts +74 -0
  54. package/src/utils/discovery.ts +134 -0
  55. package/src/utils/git.ts +65 -0
  56. package/src/utils/url-resolver.ts +57 -0
  57. package/test/e2e/lifecycle.e2e.test.ts +153 -0
  58. package/test/integration/commands/init.integration.test.ts +85 -0
  59. package/test/integration/commands/module.integration.test.ts +144 -0
  60. package/test/integration/commands/run.integration.test.ts +90 -0
  61. package/test/integration/utils/command-loading.integration.test.ts +80 -0
  62. package/test/unit/commands/init.test.ts +153 -0
  63. package/test/unit/commands/module/add.test.ts +262 -0
  64. package/test/unit/commands/module/list.test.ts +115 -0
  65. package/test/unit/commands/module/remove.test.ts +89 -0
  66. package/test/unit/commands/module/update.test.ts +91 -0
  67. package/test/unit/commands/run.test.ts +252 -0
  68. package/test/unit/commands/setup.test.ts +169 -0
  69. package/test/unit/utils/command-discovery.test.ts +176 -0
  70. package/test/unit/utils/git.test.ts +152 -0
  71. package/test/unit/utils/integration-helpers.test.ts +72 -0
  72. package/test/unit/utils/url-resolver.test.ts +39 -0
  73. package/test/utils/integration-helpers.ts +66 -0
  74. package/vitest.e2e.config.ts +0 -1
  75. package/dist/chunk-JDRAVUKK.js +0 -48
  76. package/dist/chunk-JDRAVUKK.js.map +0 -1
  77. package/dist/src/commands/admin/create-user.d.ts +0 -15
  78. package/dist/src/commands/admin/create-user.js +0 -49
  79. package/dist/src/commands/admin/create-user.js.map +0 -1
  80. package/dist/src/commands/branch/create.d.ts +0 -19
  81. package/dist/src/commands/branch/create.js +0 -59
  82. package/dist/src/commands/branch/create.js.map +0 -1
  83. package/dist/src/commands/branch/delete.d.ts +0 -15
  84. package/dist/src/commands/branch/delete.js +0 -50
  85. package/dist/src/commands/branch/delete.js.map +0 -1
  86. package/dist/src/commands/branch/get.d.ts +0 -15
  87. package/dist/src/commands/branch/get.js +0 -53
  88. package/dist/src/commands/branch/get.js.map +0 -1
  89. package/dist/src/commands/branch/list.d.ts +0 -15
  90. package/dist/src/commands/branch/list.js +0 -51
  91. package/dist/src/commands/branch/list.js.map +0 -1
  92. package/dist/src/commands/job/get.d.ts +0 -15
  93. package/dist/src/commands/job/get.js +0 -62
  94. package/dist/src/commands/job/get.js.map +0 -1
  95. package/dist/src/commands/job/list.d.ts +0 -15
  96. package/dist/src/commands/job/list.js +0 -57
  97. package/dist/src/commands/job/list.js.map +0 -1
  98. package/dist/src/commands/job/logs.d.ts +0 -15
  99. package/dist/src/commands/job/logs.js +0 -67
  100. package/dist/src/commands/job/logs.js.map +0 -1
  101. package/dist/src/commands/job/trigger.d.ts +0 -19
  102. package/dist/src/commands/job/trigger.js +0 -74
  103. package/dist/src/commands/job/trigger.js.map +0 -1
  104. package/dist/src/commands/login.js +0 -31
  105. package/dist/src/commands/login.js.map +0 -1
  106. package/dist/src/commands/project/create.d.ts +0 -24
  107. package/dist/src/commands/project/create.js +0 -63
  108. package/dist/src/commands/project/create.js.map +0 -1
  109. package/dist/src/commands/project/delete.d.ts +0 -20
  110. package/dist/src/commands/project/delete.js +0 -58
  111. package/dist/src/commands/project/delete.js.map +0 -1
  112. package/dist/src/commands/project/get.d.ts +0 -15
  113. package/dist/src/commands/project/get.js +0 -49
  114. package/dist/src/commands/project/get.js.map +0 -1
  115. package/dist/src/commands/project/list.d.ts +0 -15
  116. package/dist/src/commands/project/list.js +0 -45
  117. package/dist/src/commands/project/list.js.map +0 -1
  118. package/dist/src/commands/project/update.d.ts +0 -19
  119. package/dist/src/commands/project/update.js +0 -66
  120. package/dist/src/commands/project/update.js.map +0 -1
  121. package/dist/src/commands/team/create.d.ts +0 -19
  122. package/dist/src/commands/team/create.js +0 -45
  123. package/dist/src/commands/team/create.js.map +0 -1
  124. package/dist/src/commands/team/delete.d.ts +0 -20
  125. package/dist/src/commands/team/delete.js +0 -52
  126. package/dist/src/commands/team/delete.js.map +0 -1
  127. package/dist/src/commands/team/get.d.ts +0 -15
  128. package/dist/src/commands/team/get.js +0 -42
  129. package/dist/src/commands/team/get.js.map +0 -1
  130. package/dist/src/commands/team/list.d.ts +0 -8
  131. package/dist/src/commands/team/list.js +0 -30
  132. package/dist/src/commands/team/list.js.map +0 -1
  133. package/dist/src/commands/team/member/invite.d.ts +0 -20
  134. package/dist/src/commands/team/member/invite.js +0 -54
  135. package/dist/src/commands/team/member/invite.js.map +0 -1
  136. package/dist/src/commands/team/member/remove.d.ts +0 -15
  137. package/dist/src/commands/team/member/remove.js +0 -43
  138. package/dist/src/commands/team/member/remove.js.map +0 -1
  139. package/dist/src/commands/team/update.d.ts +0 -19
  140. package/dist/src/commands/team/update.js +0 -55
  141. package/dist/src/commands/team/update.js.map +0 -1
  142. package/dist/src/commands/token/generate.d.ts +0 -19
  143. package/dist/src/commands/token/generate.js +0 -48
  144. package/dist/src/commands/token/generate.js.map +0 -1
  145. package/dist/src/commands/token/list.d.ts +0 -8
  146. package/dist/src/commands/token/list.js +0 -31
  147. package/dist/src/commands/token/list.js.map +0 -1
  148. package/dist/src/commands/token/revoke.d.ts +0 -15
  149. package/dist/src/commands/token/revoke.js +0 -38
  150. package/dist/src/commands/token/revoke.js.map +0 -1
  151. package/dist/src/commands/whoami.d.ts +0 -8
  152. package/dist/src/commands/whoami.js +0 -26
  153. package/dist/src/commands/whoami.js.map +0 -1
  154. package/dist/src/utils/nexical-client.d.ts +0 -10
  155. package/dist/src/utils/nexical-client.js +0 -12
  156. package/src/commands/admin/create-user.ts +0 -46
  157. package/src/commands/branch/create.ts +0 -57
  158. package/src/commands/branch/delete.ts +0 -47
  159. package/src/commands/branch/get.ts +0 -50
  160. package/src/commands/branch/list.ts +0 -50
  161. package/src/commands/job/get.ts +0 -59
  162. package/src/commands/job/list.ts +0 -56
  163. package/src/commands/job/logs.ts +0 -67
  164. package/src/commands/job/trigger.ts +0 -73
  165. package/src/commands/login.ts +0 -31
  166. package/src/commands/project/create.ts +0 -61
  167. package/src/commands/project/delete.ts +0 -56
  168. package/src/commands/project/get.ts +0 -46
  169. package/src/commands/project/list.ts +0 -44
  170. package/src/commands/project/update.ts +0 -63
  171. package/src/commands/team/create.ts +0 -43
  172. package/src/commands/team/delete.ts +0 -50
  173. package/src/commands/team/get.ts +0 -39
  174. package/src/commands/team/list.ts +0 -26
  175. package/src/commands/team/member/invite.ts +0 -56
  176. package/src/commands/team/member/remove.ts +0 -40
  177. package/src/commands/team/update.ts +0 -53
  178. package/src/commands/token/generate.ts +0 -45
  179. package/src/commands/token/list.ts +0 -27
  180. package/src/commands/token/revoke.ts +0 -35
  181. package/src/commands/whoami.ts +0 -21
  182. package/src/utils/nexical-client.ts +0 -47
  183. package/test/e2e/auth.e2e.test.ts +0 -46
  184. package/test/e2e/job-workflow.e2e.test.ts +0 -33
  185. package/test/e2e/project-lifecycle.e2e.test.ts +0 -48
  186. package/test/e2e/setup.ts +0 -237
  187. package/test/e2e/utils.ts +0 -33
  188. package/test/integration/commands/admin/create-user.test.ts +0 -51
  189. package/test/integration/commands/branch/create.test.ts +0 -51
  190. package/test/integration/commands/branch/delete.test.ts +0 -43
  191. package/test/integration/commands/branch/get.test.ts +0 -49
  192. package/test/integration/commands/branch/list.test.ts +0 -47
  193. package/test/integration/commands/job/get.test.ts +0 -54
  194. package/test/integration/commands/job/list.test.ts +0 -47
  195. package/test/integration/commands/job/logs.test.ts +0 -47
  196. package/test/integration/commands/job/trigger.test.ts +0 -57
  197. package/test/integration/commands/login.test.ts +0 -62
  198. package/test/integration/commands/project/create.test.ts +0 -53
  199. package/test/integration/commands/project/delete.test.ts +0 -43
  200. package/test/integration/commands/project/get.test.ts +0 -51
  201. package/test/integration/commands/project/list.test.ts +0 -47
  202. package/test/integration/commands/project/update.test.ts +0 -53
  203. package/test/integration/commands/team/create.test.ts +0 -53
  204. package/test/integration/commands/team/delete.test.ts +0 -43
  205. package/test/integration/commands/team/get.test.ts +0 -50
  206. package/test/integration/commands/team/list.test.ts +0 -47
  207. package/test/integration/commands/team/member/invite.test.ts +0 -46
  208. package/test/integration/commands/team/member/remove.test.ts +0 -43
  209. package/test/integration/commands/team/update.test.ts +0 -50
  210. package/test/integration/commands/token/generate.test.ts +0 -51
  211. package/test/integration/commands/token/list.test.ts +0 -47
  212. package/test/integration/commands/token/revoke.test.ts +0 -43
  213. package/test/integration/commands/whoami.test.ts +0 -49
  214. package/test/unit/commands/admin/create-user.test.ts +0 -51
  215. package/test/unit/commands/branch/create.test.ts +0 -57
  216. package/test/unit/commands/branch/delete.test.ts +0 -49
  217. package/test/unit/commands/branch/get.test.ts +0 -67
  218. package/test/unit/commands/branch/list.test.ts +0 -62
  219. package/test/unit/commands/job/get.test.ts +0 -76
  220. package/test/unit/commands/job/list.test.ts +0 -62
  221. package/test/unit/commands/job/logs.test.ts +0 -60
  222. package/test/unit/commands/job/trigger.test.ts +0 -75
  223. package/test/unit/commands/login.test.ts +0 -64
  224. package/test/unit/commands/project/create.test.ts +0 -64
  225. package/test/unit/commands/project/delete.test.ts +0 -72
  226. package/test/unit/commands/project/get.test.ts +0 -73
  227. package/test/unit/commands/project/list.test.ts +0 -62
  228. package/test/unit/commands/project/update.test.ts +0 -58
  229. package/test/unit/commands/team/create.test.ts +0 -68
  230. package/test/unit/commands/team/delete.test.ts +0 -71
  231. package/test/unit/commands/team/get.test.ts +0 -70
  232. package/test/unit/commands/team/list.test.ts +0 -56
  233. package/test/unit/commands/team/member/invite.test.ts +0 -52
  234. package/test/unit/commands/team/member/remove.test.ts +0 -49
  235. package/test/unit/commands/team/update.test.ts +0 -63
  236. package/test/unit/commands/token/generate.test.ts +0 -65
  237. package/test/unit/commands/token/list.test.ts +0 -58
  238. package/test/unit/commands/token/revoke.test.ts +0 -49
  239. package/test/unit/commands/whoami.test.ts +0 -49
  240. package/test/unit/utils/nexical-client.test.ts +0 -113
  241. /package/dist/src/utils/{nexical-client.js.map → discovery.js.map} +0 -0
@@ -1,60 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import JobsLogsCommand from '../../../../src/commands/job/logs.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('JobsLogsCommand', () => {
9
- let command: JobsLogsCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- jobs: {
17
- getLogs: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new JobsLogsCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'warn').mockImplementation(() => { });
25
- vi.spyOn(command, 'error').mockImplementation(() => { });
26
- });
27
-
28
- it('should display logs successfully', async () => {
29
- mockClient.jobs.getLogs.mockResolvedValue([
30
- { timestamp: '2023-01-01T10:00:00Z', level: 'info', message: 'Starting job' },
31
- { timestamp: '2023-01-01T10:00:01Z', level: 'warn', message: 'Slow network' },
32
- { timestamp: '2023-01-01T10:00:02Z', level: 'error', message: 'Failed to connect' }
33
- ]);
34
-
35
- await command.run({ teamId: '1', projectId: '2', branchId: '3', jobId: '4' });
36
-
37
- expect(mockClient.jobs.getLogs).toHaveBeenCalledWith(1, 2, 3, 4);
38
- expect(command.info).toHaveBeenCalledWith('Logs for Job 4:');
39
-
40
- // Timestamps will be converted to locale string, so exact match depends on timezone.
41
- // We can just check that info, warn, error were called.
42
- expect(command.info).toHaveBeenCalledWith(expect.stringContaining('Starting job'));
43
- expect(command.warn).toHaveBeenCalledWith(expect.stringContaining('Slow network'));
44
- expect(command.error).toHaveBeenCalledWith(expect.stringContaining('Failed to connect'));
45
- });
46
-
47
- it('should validate IDs', async () => {
48
- await command.run({ teamId: '1', projectId: '2', branchId: '3', jobId: 'invalid' });
49
- expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
50
- expect(mockClient.jobs.getLogs).not.toHaveBeenCalled();
51
- });
52
-
53
- it('should handle logs failure', async () => {
54
- mockClient.jobs.getLogs.mockRejectedValue(new Error('Logs not available'));
55
-
56
- await command.run({ teamId: '1', projectId: '2', branchId: '3', jobId: '4' });
57
-
58
- expect(command.error).toHaveBeenCalledWith('Failed to get logs: Logs not available');
59
- });
60
- });
@@ -1,75 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import JobsTriggerCommand from '../../../../src/commands/job/trigger.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('JobsTriggerCommand', () => {
9
- let command: JobsTriggerCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- jobs: {
17
- create: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new JobsTriggerCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'success').mockImplementation(() => { });
25
- vi.spyOn(command, 'error').mockImplementation(() => { });
26
- });
27
-
28
- it('should trigger job successfully', async () => {
29
- mockClient.jobs.create.mockResolvedValue({
30
- id: '100',
31
- status: 'pending'
32
- });
33
-
34
- await command.run({
35
- teamId: '1',
36
- projectId: '2',
37
- branchId: '3',
38
- type: 'deploy',
39
- input: '{"env":"prod"}'
40
- });
41
-
42
- expect(mockClient.jobs.create).toHaveBeenCalledWith(1, 2, 3, {
43
- type: 'deploy',
44
- inputs: { env: 'prod' }
45
- });
46
- expect(command.success).toHaveBeenCalledWith('Job 100 triggered successfully!');
47
- expect(command.info).toHaveBeenCalledWith('Status: pending');
48
- });
49
-
50
- it('should handle invalid JSON input', async () => {
51
- await command.run({
52
- teamId: '1',
53
- projectId: '2',
54
- branchId: '3',
55
- type: 'deploy',
56
- input: '{invalid-json'
57
- });
58
-
59
- expect(command.error).toHaveBeenCalledWith('Invalid JSON inputs.');
60
- expect(mockClient.jobs.create).not.toHaveBeenCalled();
61
- });
62
-
63
- it('should validate IDs', async () => {
64
- await command.run({ teamId: 'invalid', projectId: '2', branchId: '3', type: 'deploy' });
65
- expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
66
- });
67
-
68
- it('should handle trigger failure', async () => {
69
- mockClient.jobs.create.mockRejectedValue(new Error('Quota exceeded'));
70
-
71
- await command.run({ teamId: '1', projectId: '2', branchId: '3', type: 'deploy' });
72
-
73
- expect(command.error).toHaveBeenCalledWith('Failed to trigger job: Quota exceeded');
74
- });
75
- });
@@ -1,64 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import LoginCommand from '../../../src/commands/login.js';
4
- import { getClient, saveToken } from '../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../src/utils/nexical-client.js');
7
-
8
- describe('LoginCommand', () => {
9
- let command: LoginCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- auth: {
17
- authenticateDevice: vi.fn(),
18
- },
19
- users: {
20
- me: vi.fn(),
21
- },
22
- setToken: vi.fn(),
23
- };
24
- vi.mocked(getClient).mockReturnValue(mockClient);
25
-
26
- command = new LoginCommand([], {} as any);
27
- vi.spyOn(command, 'info').mockImplementation(() => { });
28
- vi.spyOn(command, 'notice').mockImplementation(() => { });
29
- vi.spyOn(command, 'success').mockImplementation(() => { });
30
- vi.spyOn(command, 'error').mockImplementation(() => { });
31
- });
32
-
33
- it('should authenticate successfully', async () => {
34
- mockClient.auth.authenticateDevice.mockImplementation(async (_clientId: string, callback: any) => {
35
- callback('USER-CODE', 'https://verify.url');
36
- return 'new-token';
37
- });
38
- mockClient.users.me.mockResolvedValue({ fullName: 'Test User', email: 'test@example.com' });
39
-
40
- await command.run();
41
-
42
- expect(command.info).toHaveBeenCalledWith('Starting device authentication...');
43
- expect(mockClient.auth.authenticateDevice).toHaveBeenCalledWith('nexical-cli', expect.any(Function));
44
-
45
- // Verify callback interaction via implicit check or spy if feasible,
46
- // but here we know the callback is called because we mocked implementation calling it.
47
- expect(command.notice).toHaveBeenCalledWith('Please visit: https://verify.url');
48
- expect(command.notice).toHaveBeenCalledWith('And enter code: USER-CODE');
49
-
50
- expect(saveToken).toHaveBeenCalledWith('new-token');
51
- expect(mockClient.setToken).toHaveBeenCalledWith('new-token');
52
- expect(mockClient.users.me).toHaveBeenCalled();
53
- expect(command.success).toHaveBeenCalledWith('Successfully logged in as Test User (test@example.com)');
54
- });
55
-
56
- it('should handle authentication failure', async () => {
57
- mockClient.auth.authenticateDevice.mockRejectedValue(new Error('Auth failed'));
58
-
59
- await command.run();
60
-
61
- expect(command.error).toHaveBeenCalledWith('Login failed: Auth failed');
62
- expect(saveToken).not.toHaveBeenCalled();
63
- });
64
- });
@@ -1,64 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import ProjectsCreateCommand from '../../../../src/commands/project/create.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('ProjectsCreateCommand', () => {
9
- let command: ProjectsCreateCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- projects: {
17
- create: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new ProjectsCreateCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'success').mockImplementation(() => { });
25
- vi.spyOn(command, 'error').mockImplementation(() => { });
26
- });
27
-
28
- it('should create project successfully', async () => {
29
- mockClient.projects.create.mockResolvedValue({
30
- name: 'New Project',
31
- id: '200'
32
- });
33
-
34
- await command.run({
35
- teamId: '1',
36
- name: 'New Project',
37
- repo: 'http://repo.git',
38
- prod: 'http://prod.url',
39
- mode: 'managed'
40
- });
41
-
42
- expect(mockClient.projects.create).toHaveBeenCalledWith(1, {
43
- name: 'New Project',
44
- repoUrl: 'http://repo.git',
45
- productionUrl: 'http://prod.url'
46
- });
47
- expect(command.success).toHaveBeenCalledWith('Project "New Project" set up successfully!');
48
- expect(command.info).toHaveBeenCalledWith('ID: 200');
49
- });
50
-
51
- it('should validate Team ID', async () => {
52
- await command.run({ teamId: 'invalid', name: 'New Project' });
53
- expect(command.error).toHaveBeenCalledWith('Team ID must be a number.');
54
- expect(mockClient.projects.create).not.toHaveBeenCalled();
55
- });
56
-
57
- it('should handle creation failure', async () => {
58
- mockClient.projects.create.mockRejectedValue(new Error('Name taken'));
59
-
60
- await command.run({ teamId: '1', name: 'New Project' });
61
-
62
- expect(command.error).toHaveBeenCalledWith('Failed to create project: Name taken');
63
- });
64
- });
@@ -1,72 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import ProjectsDeleteCommand from '../../../../src/commands/project/delete.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('ProjectsDeleteCommand', () => {
9
- let command: ProjectsDeleteCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- projects: {
17
- delete: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new ProjectsDeleteCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'success').mockImplementation(() => { });
25
- vi.spyOn(command, 'error').mockImplementation(() => { });
26
- // Mock prompt method which is likely on BaseCommand prototype or instance
27
- (command as any).prompt = vi.fn();
28
- });
29
-
30
- it('should delete project successfully with confirmation', async () => {
31
- mockClient.projects.delete.mockResolvedValue({});
32
- (command as any).prompt.mockResolvedValue('yes');
33
-
34
- await command.run({ teamId: '1', projectId: '2', confirm: false });
35
-
36
- expect((command as any).prompt).toHaveBeenCalled();
37
- expect(mockClient.projects.delete).toHaveBeenCalledWith(1, 2);
38
- expect(command.success).toHaveBeenCalledWith('Project 2 deleted.');
39
- });
40
-
41
- it('should delete project successfully with --confirm flag', async () => {
42
- mockClient.projects.delete.mockResolvedValue({});
43
-
44
- await command.run({ teamId: '1', projectId: '2', confirm: true });
45
-
46
- expect((command as any).prompt).not.toHaveBeenCalled();
47
- expect(mockClient.projects.delete).toHaveBeenCalledWith(1, 2);
48
- expect(command.success).toHaveBeenCalledWith('Project 2 deleted.');
49
- });
50
-
51
- it('should abort deletion if user says no', async () => {
52
- (command as any).prompt.mockResolvedValue('no');
53
-
54
- await command.run({ teamId: '1', projectId: '2', confirm: false });
55
-
56
- expect(mockClient.projects.delete).not.toHaveBeenCalled();
57
- expect(command.info).toHaveBeenCalledWith('Aborted.');
58
- });
59
-
60
- it('should validate IDs', async () => {
61
- await command.run({ teamId: 'invalid', projectId: '2' });
62
- expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
63
- });
64
-
65
- it('should handle deletion failure', async () => {
66
- mockClient.projects.delete.mockRejectedValue(new Error('Project not found'));
67
-
68
- await command.run({ teamId: '1', projectId: '2', confirm: true });
69
-
70
- expect(command.error).toHaveBeenCalledWith('Failed to delete project: Project not found');
71
- });
72
- });
@@ -1,73 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import ProjectsGetCommand from '../../../../src/commands/project/get.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('ProjectsGetCommand', () => {
9
- let command: ProjectsGetCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- projects: {
17
- get: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new ProjectsGetCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'error').mockImplementation(() => { });
25
- });
26
-
27
- it('should get project details successfully', async () => {
28
- mockClient.projects.get.mockResolvedValue({
29
- id: '200',
30
- name: 'My Project',
31
- repoUrl: 'http://repo.git',
32
- productionUrl: 'http://prod.url',
33
- mode: 'managed'
34
- });
35
-
36
- await command.run({ teamId: '1', projectId: '200' });
37
-
38
- expect(mockClient.projects.get).toHaveBeenCalledWith(1, 200);
39
- expect(command.info).toHaveBeenCalledWith('Project Details:');
40
- expect(command.info).toHaveBeenCalledWith(' ID: 200');
41
- expect(command.info).toHaveBeenCalledWith(' Name: My Project');
42
- expect(command.info).toHaveBeenCalledWith(' Repo: http://repo.git');
43
- expect(command.info).toHaveBeenCalledWith(' Prod: http://prod.url');
44
- expect(command.info).toHaveBeenCalledWith(' Mode: managed');
45
- });
46
-
47
- it('should display defaults for missing urls', async () => {
48
- mockClient.projects.get.mockResolvedValue({
49
- id: '200',
50
- name: 'My Project',
51
- mode: 'self_hosted'
52
- });
53
-
54
- await command.run({ teamId: '1', projectId: '200' });
55
-
56
- expect(command.info).toHaveBeenCalledWith(' Repo: N/A');
57
- expect(command.info).toHaveBeenCalledWith(' Prod: N/A');
58
- });
59
-
60
- it('should validate IDs', async () => {
61
- await command.run({ teamId: 'invalid', projectId: '200' });
62
- expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
63
- expect(mockClient.projects.get).not.toHaveBeenCalled();
64
- });
65
-
66
- it('should handle get failure', async () => {
67
- mockClient.projects.get.mockRejectedValue(new Error('Project not found'));
68
-
69
- await command.run({ teamId: '1', projectId: '200' });
70
-
71
- expect(command.error).toHaveBeenCalledWith('Failed to get project: Project not found');
72
- });
73
- });
@@ -1,62 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import ProjectsListCommand from '../../../../src/commands/project/list.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('ProjectsListCommand', () => {
9
- let command: ProjectsListCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- projects: {
17
- list: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new ProjectsListCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'error').mockImplementation(() => { });
25
- });
26
-
27
- it('should list projects successfully', async () => {
28
- mockClient.projects.list.mockResolvedValue([
29
- { id: '200', name: 'Project A', repoUrl: 'http://a.git' },
30
- { id: '201', name: 'Project B' }
31
- ]);
32
-
33
- await command.run({ teamId: '1' });
34
-
35
- expect(mockClient.projects.list).toHaveBeenCalledWith(1);
36
- expect(command.info).toHaveBeenCalledWith('Projects in Team 1:');
37
- expect(command.info).toHaveBeenCalledWith('- Project A (ID: 200) [http://a.git]');
38
- expect(command.info).toHaveBeenCalledWith('- Project B (ID: 201) [No Repo]');
39
- });
40
-
41
- it('should handle empty list', async () => {
42
- mockClient.projects.list.mockResolvedValue([]);
43
-
44
- await command.run({ teamId: '1' });
45
-
46
- expect(command.info).toHaveBeenCalledWith('No projects found in team 1.');
47
- });
48
-
49
- it('should validate Team ID', async () => {
50
- await command.run({ teamId: 'invalid' });
51
- expect(command.error).toHaveBeenCalledWith('Team ID must be a number.');
52
- expect(mockClient.projects.list).not.toHaveBeenCalled();
53
- });
54
-
55
- it('should handle list failure', async () => {
56
- mockClient.projects.list.mockRejectedValue(new Error('Network error'));
57
-
58
- await command.run({ teamId: '1' });
59
-
60
- expect(command.error).toHaveBeenCalledWith('Failed to list projects: Network error');
61
- });
62
- });
@@ -1,58 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import ProjectsUpdateCommand from '../../../../src/commands/project/update.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('ProjectsUpdateCommand', () => {
9
- let command: ProjectsUpdateCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- projects: {
17
- update: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new ProjectsUpdateCommand([], {} as any);
23
- vi.spyOn(command, 'success').mockImplementation(() => { });
24
- vi.spyOn(command, 'error').mockImplementation(() => { });
25
- });
26
-
27
- it('should update project successfully', async () => {
28
- mockClient.projects.update.mockResolvedValue({ id: '200' });
29
-
30
- await command.run({
31
- teamId: '1',
32
- projectId: '200',
33
- name: 'Updated Name',
34
- repo: 'http://new.git'
35
- });
36
-
37
- expect(mockClient.projects.update).toHaveBeenCalledWith(1, 200, {
38
- name: 'Updated Name',
39
- repoUrl: 'http://new.git',
40
- productionUrl: undefined,
41
- });
42
- expect(command.success).toHaveBeenCalledWith('Project 200 updated!');
43
- });
44
-
45
- it('should validate IDs', async () => {
46
- await command.run({ teamId: 'invalid', projectId: '200' });
47
- expect(command.error).toHaveBeenCalledWith('IDs must be numbers.');
48
- expect(mockClient.projects.update).not.toHaveBeenCalled();
49
- });
50
-
51
- it('should handle update failure', async () => {
52
- mockClient.projects.update.mockRejectedValue(new Error('Not found'));
53
-
54
- await command.run({ teamId: '1', projectId: '200' });
55
-
56
- expect(command.error).toHaveBeenCalledWith('Failed to update project: Not found');
57
- });
58
- });
@@ -1,68 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import TeamsCreateCommand from '../../../../src/commands/team/create.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('TeamsCreateCommand', () => {
9
- let command: TeamsCreateCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- teams: {
17
- create: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new TeamsCreateCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'success').mockImplementation(() => { });
25
- vi.spyOn(command, 'error').mockImplementation(() => { });
26
- });
27
-
28
- it('should create team successfully', async () => {
29
- mockClient.teams.create.mockResolvedValue({
30
- name: 'My Team',
31
- id: '1',
32
- slug: 'my-team'
33
- });
34
-
35
- await command.run({ name: 'My Team' });
36
-
37
- expect(mockClient.teams.create).toHaveBeenCalledWith({
38
- name: 'My Team',
39
- slug: 'my-team' // derived slug
40
- });
41
- expect(command.success).toHaveBeenCalledWith('Team "My Team" created successfully!');
42
- expect(command.info).toHaveBeenCalledWith('ID: 1');
43
- expect(command.info).toHaveBeenCalledWith('Slug: my-team');
44
- });
45
-
46
- it('should create team with custom slug', async () => {
47
- mockClient.teams.create.mockResolvedValue({
48
- name: 'My Team',
49
- id: '1',
50
- slug: 'custom-slug'
51
- });
52
-
53
- await command.run({ name: 'My Team', slug: 'custom-slug' });
54
-
55
- expect(mockClient.teams.create).toHaveBeenCalledWith({
56
- name: 'My Team',
57
- slug: 'custom-slug'
58
- });
59
- });
60
-
61
- it('should handle creation failure', async () => {
62
- mockClient.teams.create.mockRejectedValue(new Error('Slug taken'));
63
-
64
- await command.run({ name: 'My Team' });
65
-
66
- expect(command.error).toHaveBeenCalledWith('Failed to create team: Slug taken');
67
- });
68
- });
@@ -1,71 +0,0 @@
1
-
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import TeamsDeleteCommand from '../../../../src/commands/team/delete.js';
4
- import { getClient } from '../../../../src/utils/nexical-client.js';
5
-
6
- vi.mock('../../../../src/utils/nexical-client.js');
7
-
8
- describe('TeamsDeleteCommand', () => {
9
- let command: TeamsDeleteCommand;
10
- let mockClient: any;
11
-
12
- beforeEach(() => {
13
- vi.resetAllMocks();
14
-
15
- mockClient = {
16
- teams: {
17
- delete: vi.fn(),
18
- },
19
- };
20
- vi.mocked(getClient).mockReturnValue(mockClient);
21
-
22
- command = new TeamsDeleteCommand([], {} as any);
23
- vi.spyOn(command, 'info').mockImplementation(() => { });
24
- vi.spyOn(command, 'success').mockImplementation(() => { });
25
- vi.spyOn(command, 'error').mockImplementation(() => { });
26
- (command as any).prompt = vi.fn();
27
- });
28
-
29
- it('should delete team successfully with confirmation', async () => {
30
- mockClient.teams.delete.mockResolvedValue({});
31
- (command as any).prompt.mockResolvedValue('yes');
32
-
33
- await command.run({ teamId: '1', confirm: false });
34
-
35
- expect((command as any).prompt).toHaveBeenCalled();
36
- expect(mockClient.teams.delete).toHaveBeenCalledWith(1);
37
- expect(command.success).toHaveBeenCalledWith('Team 1 deleted.');
38
- });
39
-
40
- it('should delete team successfully with --confirm flag', async () => {
41
- mockClient.teams.delete.mockResolvedValue({});
42
-
43
- await command.run({ teamId: '1', confirm: true });
44
-
45
- expect((command as any).prompt).not.toHaveBeenCalled();
46
- expect(mockClient.teams.delete).toHaveBeenCalledWith(1);
47
- expect(command.success).toHaveBeenCalledWith('Team 1 deleted.');
48
- });
49
-
50
- it('should abort deletion if user says no', async () => {
51
- (command as any).prompt.mockResolvedValue('no');
52
-
53
- await command.run({ teamId: '1', confirm: false });
54
-
55
- expect(mockClient.teams.delete).not.toHaveBeenCalled();
56
- expect(command.info).toHaveBeenCalledWith('Aborted.');
57
- });
58
-
59
- it('should validate Team ID', async () => {
60
- await command.run({ teamId: 'invalid' });
61
- expect(command.error).toHaveBeenCalledWith('Team ID must be a number.');
62
- });
63
-
64
- it('should handle deletion failure', async () => {
65
- mockClient.teams.delete.mockRejectedValue(new Error('Team not found'));
66
-
67
- await command.run({ teamId: '1', confirm: true });
68
-
69
- expect(command.error).toHaveBeenCalledWith('Failed to delete team: Team not found');
70
- });
71
- });