@nestbox-ai/cli 1.0.48 → 1.0.49

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 (100) hide show
  1. package/package.json +7 -1
  2. package/.github/workflows/generate-client.yml +0 -43
  3. package/.github/workflows/test.yml +0 -54
  4. package/.nestboxrc +0 -5
  5. package/src/commands/agent/apiUtils.ts +0 -113
  6. package/src/commands/agent/create.ts +0 -271
  7. package/src/commands/agent/deploy.ts +0 -523
  8. package/src/commands/agent/index.ts +0 -8
  9. package/src/commands/agent/list.ts +0 -104
  10. package/src/commands/agent/remove.ts +0 -103
  11. package/src/commands/agent/yaml-schema.ts +0 -57
  12. package/src/commands/agent.ts +0 -21
  13. package/src/commands/auth/index.ts +0 -3
  14. package/src/commands/auth/login.ts +0 -184
  15. package/src/commands/auth/logout.ts +0 -110
  16. package/src/commands/auth.ts +0 -12
  17. package/src/commands/compute/apiUtils.ts +0 -28
  18. package/src/commands/compute/create.ts +0 -195
  19. package/src/commands/compute/delete.ts +0 -147
  20. package/src/commands/compute/index.ts +0 -7
  21. package/src/commands/compute/list.ts +0 -117
  22. package/src/commands/compute.ts +0 -19
  23. package/src/commands/document/apiUtils.ts +0 -22
  24. package/src/commands/document/collectionCreate.ts +0 -46
  25. package/src/commands/document/collectionDelete.ts +0 -45
  26. package/src/commands/document/collectionGet.ts +0 -47
  27. package/src/commands/document/collectionList.ts +0 -52
  28. package/src/commands/document/collectionUpdate.ts +0 -53
  29. package/src/commands/document/docAdd.ts +0 -56
  30. package/src/commands/document/docDelete.ts +0 -47
  31. package/src/commands/document/docGet.ts +0 -49
  32. package/src/commands/document/docSearch.ts +0 -70
  33. package/src/commands/document/docUpdate.ts +0 -56
  34. package/src/commands/document/docUploadFile.ts +0 -55
  35. package/src/commands/document/index.ts +0 -17
  36. package/src/commands/document.ts +0 -48
  37. package/src/commands/generate/project.ts +0 -199
  38. package/src/commands/generate.ts +0 -15
  39. package/src/commands/image/apiUtils.ts +0 -22
  40. package/src/commands/image/display.ts +0 -34
  41. package/src/commands/image/index.ts +0 -4
  42. package/src/commands/image/list.ts +0 -61
  43. package/src/commands/image.ts +0 -15
  44. package/src/commands/project/add.ts +0 -47
  45. package/src/commands/project/apiUtils.ts +0 -20
  46. package/src/commands/project/index.ts +0 -5
  47. package/src/commands/project/list.ts +0 -78
  48. package/src/commands/project/use.ts +0 -45
  49. package/src/commands/project.ts +0 -19
  50. package/src/index.ts +0 -39
  51. package/src/types/agentType.ts +0 -7
  52. package/src/types/agentYaml.ts +0 -107
  53. package/src/types/auth.ts +0 -12
  54. package/src/types/statusMapping.ts +0 -8
  55. package/src/utils/agent.ts +0 -170
  56. package/src/utils/api.ts +0 -64
  57. package/src/utils/auth.ts +0 -140
  58. package/src/utils/config.ts +0 -37
  59. package/src/utils/error.ts +0 -168
  60. package/src/utils/plopGenerator.ts +0 -133
  61. package/src/utils/project.ts +0 -88
  62. package/src/utils/user.ts +0 -28
  63. package/src/utils/validation.ts +0 -22
  64. package/templates/base-js/index.js.hbs +0 -30
  65. package/templates/base-js/nestbox-agents.yaml.hbs +0 -12
  66. package/templates/base-js/package.json +0 -15
  67. package/templates/base-py/main.py.hbs +0 -42
  68. package/templates/base-py/nestbox-agents.yaml.hbs +0 -12
  69. package/templates/base-py/pyproject.toml +0 -19
  70. package/templates/base-ts/eslint.config.mjs +0 -27
  71. package/templates/base-ts/nestbox-agents.yaml.hbs +0 -12
  72. package/templates/base-ts/nestbox.config.json +0 -9
  73. package/templates/base-ts/package.json +0 -24
  74. package/templates/base-ts/src/index.ts.hbs +0 -29
  75. package/templates/base-ts/tsconfig.json +0 -14
  76. package/templates/chatbot-js/index.js.hbs +0 -18
  77. package/templates/chatbot-js/package-lock.json +0 -1571
  78. package/templates/chatbot-js/package.json +0 -15
  79. package/templates/chatbot-py/main.py.hbs +0 -42
  80. package/templates/chatbot-py/nestbox-agents.yaml.hbs +0 -12
  81. package/templates/chatbot-py/pyproject.toml +0 -19
  82. package/templates/chatbot-ts/eslint.config.mjs +0 -27
  83. package/templates/chatbot-ts/package.json +0 -24
  84. package/templates/chatbot-ts/src/index.ts.hbs +0 -18
  85. package/templates/chatbot-ts/tsconfig.json +0 -14
  86. package/test/README.md +0 -52
  87. package/test/agent.test.ts +0 -154
  88. package/test/auth.test.ts +0 -71
  89. package/test/compute.test.ts +0 -135
  90. package/test/document.test.ts +0 -217
  91. package/test/generate.test.ts +0 -67
  92. package/test/image.test.ts +0 -107
  93. package/test/mocks.ts +0 -122
  94. package/test/project.test.ts +0 -108
  95. package/test/setup.ts +0 -121
  96. package/tsconfig.json +0 -118
  97. package/vitest.config.d.ts +0 -2
  98. package/vitest.config.js +0 -23
  99. package/vitest.config.js.map +0 -1
  100. package/vitest.config.ts +0 -21
@@ -1,15 +0,0 @@
1
- {
2
- "name": "chatbot",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "author": "",
9
- "license": "ISC",
10
- "description": "",
11
- "dependencies": {
12
- "@nestbox-ai/functions": "^2.0.0",
13
- "ollama": "^0.5.14"
14
- }
15
- }
@@ -1,42 +0,0 @@
1
- from nestbox_ai_functions import use_chatbot
2
- from openai import OpenAI
3
-
4
- MODEL_NAME = "openai/gpt-oss-20b"
5
-
6
- client = OpenAI(
7
- base_url="http://localhost:8000/v1",
8
- api_key="sk-xxxxxx"
9
- )
10
-
11
- @use_chatbot
12
- async def {{agentName}}(context, events):
13
- try:
14
- response = client.chat.completions.create(
15
- model=MODEL_NAME,
16
- messages=context.messages,
17
- stream=False,
18
- )
19
-
20
- result = (
21
- response.choices[0].message.content
22
- if response.choices
23
- else None
24
- )
25
-
26
- if not result:
27
- await events.emitQueryFailed({
28
- "data": {
29
- "error": "No response from model"
30
- }
31
- })
32
- else:
33
- await events.emitQueryCompleted({
34
- "data": result
35
- })
36
-
37
- except Exception as e:
38
- await events.emitQueryFailed({
39
- "data": {
40
- "error": str(e)
41
- }
42
- })
@@ -1,12 +0,0 @@
1
- agents:
2
- - name: {{ agentNameInYaml }}
3
- description: Our new agent {{ agentNameInYaml }} that uses the nestbox API
4
- entry: {{agentName}}
5
- inputSchema:
6
- type: object
7
- properties:
8
- content:
9
- type: string
10
- description: The content of the input as string
11
- minLength: 10
12
- maxLength: 5000
@@ -1,19 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "app"
7
- version = "1.0.0"
8
- description = "Nestbox AI Python Agent"
9
- requires-python = ">=3.9"
10
-
11
- dependencies = [
12
- "nestbox-ai-functions>=2.0.3",
13
- "openai>=1.40.0",
14
- "httpx>=0.27.0",
15
- "anyio>=4.0.0"
16
- ]
17
-
18
- [tool.setuptools]
19
- packages = ["."]
@@ -1,27 +0,0 @@
1
- import tsParser from "@typescript-eslint/parser";
2
- import eslintPluginTs from "@typescript-eslint/eslint-plugin";
3
-
4
- export default [
5
- {
6
- files: ["**/*.ts"],
7
- languageOptions: {
8
- parser: tsParser,
9
- parserOptions: {
10
- ecmaVersion: "latest",
11
- sourceType: "module",
12
- },
13
- },
14
- plugins: {
15
- "@typescript-eslint": eslintPluginTs,
16
- },
17
- rules: {
18
- ...eslintPluginTs.configs.recommended.rules,
19
- // Optional custom rules:
20
- // '@typescript-eslint/no-explicit-any': 'warn',
21
- // '@typescript-eslint/explicit-function-return-type': 'off',
22
- },
23
- },
24
- {
25
- ignores: ["dist/", "node_modules/"],
26
- },
27
- ];
@@ -1,24 +0,0 @@
1
- {
2
- "name": "app-ts",
3
- "version": "1.0.0",
4
- "main": "dist/index.js",
5
- "scripts": {
6
- "build": "tsc",
7
- "start": "node dist/index.js",
8
- "dev": "ts-node src/index.ts",
9
- "lint": "eslint ."
10
- },
11
- "author": "",
12
- "license": "ISC",
13
- "description": "",
14
- "dependencies": {
15
- "@nestbox-ai/functions": "^2.0.0",
16
- "ollama": "^0.5.15"
17
- },
18
- "devDependencies": {
19
- "@typescript-eslint/eslint-plugin": "^8.31.0",
20
- "@typescript-eslint/parser": "^8.31.0",
21
- "eslint": "^9.25.1",
22
- "typescript": "^5.8.3"
23
- }
24
- }
@@ -1,18 +0,0 @@
1
- import { ChatContext, ChatEvents, useChatbot } from "@nestbox-ai/functions";
2
- import { Ollama } from "ollama";
3
-
4
- const ollama = new Ollama();
5
-
6
- export const {{agentName}} = useChatbot(
7
- async (context: ChatContext, events: ChatEvents) => {
8
- const response = await ollama.chat({
9
- messages: context.messages,
10
- model: "gemma3:27b",
11
- stream: false,
12
- });
13
- const result = response.response;
14
-
15
- events.emitQueryCompleted({ data: result });
16
- }
17
- );
18
-
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
4
- "module": "commonjs", /* Specify what module code is generated. */
5
- "rootDir": "./src",
6
- "outDir": "./dist",
7
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
8
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
9
- "strict": true, /* Enable all strict type-checking options. */
10
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
11
- },
12
- "include": ["src"],
13
- "exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"],
14
- }
package/test/README.md DELETED
@@ -1,52 +0,0 @@
1
- # Test Suite Summary
2
-
3
- This directory contains comprehensive unit tests for all CLI commands in the nestbox-ai-cli-tools project.
4
-
5
- ## Test Files Created
6
-
7
- - **auth.test.ts** - Tests for authentication commands (login, logout)
8
- - **projects.test.ts** - Tests for project management commands (project use, project add, list)
9
- - **compute.test.ts** - Tests for compute instance management commands (compute list, create, delete)
10
- - **document.test.ts** - Tests for document management commands (doc and collection subcommands)
11
- - **image.test.ts** - Tests for image management commands (image list)
12
- - **agent.test.ts** - Tests for agent management commands (agent list, remove, deploy, generate, create)
13
-
14
- ## What the Tests Cover
15
-
16
- Each test file verifies:
17
-
18
- 1. **Command Registration** - Ensures all commands and subcommands are properly registered
19
- 2. **Command Structure** - Validates command names, descriptions, and hierarchy
20
- 3. **Options and Arguments** - Checks that expected command-line options are available
21
- 4. **Action Functions** - Verifies that action handlers are properly attached
22
-
23
- ## Test Strategy
24
-
25
- The tests focus on **command registration and structure validation** rather than execution logic. This approach:
26
-
27
- - Ensures the CLI interface remains stable
28
- - Validates command-line argument parsing
29
- - Verifies help text and descriptions
30
- - Doesn't require mocking complex external APIs
31
- - Runs quickly and reliably
32
-
33
- ## Running Tests
34
-
35
- ```bash
36
- # Run all tests
37
- npm test
38
-
39
- # Run tests with coverage
40
- npm run coverage
41
-
42
- # Run specific test file
43
- npm test auth.test.ts
44
- ```
45
-
46
- ## Test Framework
47
-
48
- - **Vitest** - Fast unit test runner with TypeScript support
49
- - **Commander.js** - CLI framework being tested
50
- - **Mock Strategy** - External dependencies are mocked to isolate command registration logic
51
-
52
- All tests are passing and provide confidence that the CLI command structure is working correctly.
@@ -1,154 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { Command } from "commander";
3
- import { registerAgentCommands } from "../src/commands/agent";
4
-
5
- describe("Agent Commands", () => {
6
- let program: Command;
7
-
8
- beforeEach(() => {
9
- program = new Command();
10
- vi.clearAllMocks();
11
- });
12
-
13
- describe("registerAgentCommands", () => {
14
- it("should register agent command group", () => {
15
- registerAgentCommands(program);
16
-
17
- const commands = program.commands;
18
- const agentCommand = commands.find(cmd => cmd.name() === "agent");
19
-
20
- expect(agentCommand).toBeDefined();
21
- expect(agentCommand?.description()).toBe("Manage Nestbox agents");
22
- });
23
-
24
- it("should register agent list subcommand", () => {
25
- registerAgentCommands(program);
26
-
27
- const agentCommand = program.commands.find(
28
- cmd => cmd.name() === "agent"
29
- );
30
- const subCommands = agentCommand?.commands || [];
31
- const listCommand = subCommands.find(cmd => cmd.name() === "list");
32
-
33
- expect(listCommand).toBeDefined();
34
- expect(listCommand?.description()).toBe(
35
- "List all AI agents associated with the authenticated user"
36
- );
37
-
38
- // Check options
39
- const options = listCommand?.options || [];
40
- const projectOption = options.find(opt => opt.long === "--project");
41
- expect(projectOption).toBeDefined();
42
- expect(projectOption?.description).toBe(
43
- "Project name (defaults to the current project)"
44
- );
45
- });
46
-
47
- it("should register agent remove subcommand", () => {
48
- registerAgentCommands(program);
49
-
50
- const agentCommand = program.commands.find(
51
- cmd => cmd.name() === "agent"
52
- );
53
- const subCommands = agentCommand?.commands || [];
54
- const removeCommand = subCommands.find(
55
- cmd => cmd.name() === "remove"
56
- );
57
-
58
- expect(removeCommand).toBeDefined();
59
- expect(removeCommand?.description()).toBe("Remove an AI agent");
60
-
61
- // Check options
62
- const options = removeCommand?.options || [];
63
- const agentOption = options.find(opt => opt.long === "--agent");
64
- const projectOption = options.find(opt => opt.long === "--project");
65
-
66
- expect(agentOption).toBeDefined();
67
- expect(projectOption).toBeDefined();
68
- });
69
-
70
- it("should register agent deploy subcommand", () => {
71
- registerAgentCommands(program);
72
-
73
- const agentCommand = program.commands.find(
74
- cmd => cmd.name() === "agent"
75
- );
76
- const subCommands = agentCommand?.commands || [];
77
- const deployCommand = subCommands.find(
78
- cmd => cmd.name() === "deploy"
79
- );
80
-
81
- expect(deployCommand).toBeDefined();
82
- expect(deployCommand?.description()).toBe(
83
- "Deploy an AI agent to the Nestbox platform"
84
- );
85
-
86
- // Check options
87
- const options = deployCommand?.options || [];
88
- const projectOption = options.find(opt => opt.long === "--project");
89
- const agentOption = options.find(opt => opt.long === "--agent");
90
- const instanceOption = options.find(
91
- opt => opt.long === "--instance"
92
- );
93
-
94
- expect(projectOption).toBeDefined();
95
- expect(agentOption).toBeDefined();
96
- expect(instanceOption).toBeDefined();
97
- });
98
-
99
- it("should register agent create subcommand", () => {
100
- registerAgentCommands(program);
101
-
102
- const agentCommand = program.commands.find(
103
- cmd => cmd.name() === "agent"
104
- );
105
- const subCommands = agentCommand?.commands || [];
106
- const createCommand = subCommands.find(
107
- cmd => cmd.name() === "create"
108
- );
109
-
110
- expect(createCommand).toBeDefined();
111
- expect(createCommand?.description()).toBe(
112
- "Create an agent with direct arguments or YAML."
113
- );
114
-
115
- // Check that it has optional arguments (in command name: "create [firstArg] [secondArg]")
116
- expect(createCommand?.name()).toBe("create");
117
-
118
- // Check options
119
- const options = createCommand?.options || [];
120
- const projectOption = options.find(opt => opt.long === "--project");
121
-
122
- expect(projectOption).toBeDefined();
123
- });
124
-
125
- it("should have all expected agent subcommands", () => {
126
- registerAgentCommands(program);
127
-
128
- const agentCommand = program.commands.find(
129
- cmd => cmd.name() === "agent"
130
- );
131
- const subCommandNames =
132
- agentCommand?.commands.map(cmd => cmd.name()) || [];
133
-
134
- expect(subCommandNames).toContain("list");
135
- expect(subCommandNames).toContain("remove");
136
- expect(subCommandNames).toContain("deploy");
137
- expect(subCommandNames).toContain("create");
138
- expect(subCommandNames).toHaveLength(4);
139
- });
140
-
141
- it("should have proper action functions for all subcommands", () => {
142
- registerAgentCommands(program);
143
-
144
- const agentCommand = program.commands.find(
145
- cmd => cmd.name() === "agent"
146
- );
147
- const subCommands = agentCommand?.commands || [];
148
-
149
- subCommands.forEach(cmd => {
150
- expect(typeof cmd.action).toBe("function");
151
- });
152
- });
153
- });
154
- });
package/test/auth.test.ts DELETED
@@ -1,71 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { Command } from 'commander';
3
- import { registerAuthCommands } from '../src/commands/auth';
4
-
5
- describe('Auth Commands', () => {
6
- let program: Command;
7
-
8
- beforeEach(() => {
9
- program = new Command();
10
- vi.clearAllMocks();
11
- });
12
-
13
- describe('registerAuthCommands', () => {
14
- it('should register login command with correct parameters', () => {
15
- registerAuthCommands(program);
16
-
17
- const commands = program.commands;
18
- const loginCommand = commands.find(cmd => cmd.name() === 'login');
19
-
20
- expect(loginCommand).toBeDefined();
21
- expect(loginCommand?.description()).toBe('Login using Google SSO');
22
-
23
- // Check if the command expects a domain argument (it's in the command name)
24
- expect(loginCommand?.name()).toBe('login');
25
- });
26
-
27
- it('should register logout command with correct parameters', () => {
28
- registerAuthCommands(program);
29
-
30
- const commands = program.commands;
31
- const logoutCommand = commands.find(cmd => cmd.name() === 'logout');
32
-
33
- expect(logoutCommand).toBeDefined();
34
- expect(logoutCommand?.description()).toBe('Logout from Nestbox platform');
35
-
36
- // Check if the command has an optional domain argument (it's in the command name)
37
- expect(logoutCommand?.name()).toBe('logout');
38
- });
39
-
40
- it('should register all expected auth commands', () => {
41
- registerAuthCommands(program);
42
-
43
- const commandNames = program.commands.map(cmd => cmd.name());
44
- expect(commandNames).toContain('login');
45
- expect(commandNames).toContain('logout');
46
- expect(commandNames).toHaveLength(2);
47
- });
48
-
49
- it('should have proper command structure for login', () => {
50
- registerAuthCommands(program);
51
-
52
- const loginCommand = program.commands.find(cmd => cmd.name() === 'login');
53
-
54
- // Verify command properties
55
- expect(loginCommand?.name()).toBe('login');
56
- expect(loginCommand?.description()).toBe('Login using Google SSO');
57
- expect(typeof loginCommand?.action).toBe('function');
58
- });
59
-
60
- it('should have proper command structure for logout', () => {
61
- registerAuthCommands(program);
62
-
63
- const logoutCommand = program.commands.find(cmd => cmd.name() === 'logout');
64
-
65
- // Verify command properties
66
- expect(logoutCommand?.name()).toBe('logout');
67
- expect(logoutCommand?.description()).toBe('Logout from Nestbox platform');
68
- expect(typeof logoutCommand?.action).toBe('function');
69
- });
70
- });
71
- });
@@ -1,135 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { Command } from 'commander';
3
- import { registerComputeProgram } from '../src/commands/compute';
4
-
5
- describe('Compute Commands', () => {
6
- let program: Command;
7
-
8
- beforeEach(() => {
9
- program = new Command();
10
- vi.clearAllMocks();
11
- });
12
-
13
- describe('registerComputeProgram', () => {
14
- it('should register compute command group', () => {
15
- registerComputeProgram(program);
16
-
17
- const commands = program.commands;
18
- const computeCommand = commands.find(cmd => cmd.name() === 'compute');
19
-
20
- expect(computeCommand).toBeDefined();
21
- expect(computeCommand?.description()).toBe('Manage Nestbox computes');
22
- });
23
-
24
- it('should register compute list subcommand', () => {
25
- registerComputeProgram(program);
26
-
27
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
28
- const subCommands = computeCommand?.commands || [];
29
- const listCommand = subCommands.find(cmd => cmd.name() === 'list');
30
-
31
- expect(listCommand).toBeDefined();
32
- expect(listCommand?.description()).toBe('List all compute instances');
33
-
34
- // Check options
35
- const options = listCommand?.options || [];
36
- const projectOption = options.find(opt => opt.long === '--project');
37
- expect(projectOption).toBeDefined();
38
- expect(projectOption?.description).toBe('Project ID or name (defaults to the current project)');
39
- });
40
-
41
- it('should register compute create subcommand', () => {
42
- registerComputeProgram(program);
43
-
44
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
45
- const subCommands = computeCommand?.commands || [];
46
- const createCommand = subCommands.find(cmd => cmd.name() === 'create');
47
-
48
- expect(createCommand).toBeDefined();
49
- expect(createCommand?.description()).toBe('Create a new compute instance');
50
-
51
- // Check options
52
- const options = createCommand?.options || [];
53
- const projectOption = options.find(opt => opt.long === '--project');
54
- const imageOption = options.find(opt => opt.long === '--image');
55
-
56
- expect(projectOption).toBeDefined();
57
- expect(imageOption).toBeDefined();
58
- });
59
-
60
- it('should register compute delete subcommand', () => {
61
- registerComputeProgram(program);
62
-
63
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
64
- const subCommands = computeCommand?.commands || [];
65
- const deleteCommand = subCommands.find(cmd => cmd.name() === 'delete');
66
-
67
- expect(deleteCommand).toBeDefined();
68
- expect(deleteCommand?.description()).toBe('Delete one or more compute instances');
69
-
70
- // Check options
71
- const options = deleteCommand?.options || [];
72
- const projectOption = options.find(opt => opt.long === '--project');
73
- const forceOption = options.find(opt => opt.long === '--force');
74
-
75
- expect(projectOption).toBeDefined();
76
- expect(forceOption).toBeDefined();
77
- });
78
-
79
- it('should have all expected compute subcommands', () => {
80
- registerComputeProgram(program);
81
-
82
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
83
- const subCommandNames = computeCommand?.commands.map(cmd => cmd.name()) || [];
84
-
85
- expect(subCommandNames).toContain('list');
86
- expect(subCommandNames).toContain('create');
87
- expect(subCommandNames).toContain('delete');
88
- expect(subCommandNames).toHaveLength(3);
89
- });
90
-
91
- it('should have proper action functions for all subcommands', () => {
92
- registerComputeProgram(program);
93
-
94
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
95
- const subCommands = computeCommand?.commands || [];
96
-
97
- subCommands.forEach(cmd => {
98
- expect(typeof cmd.action).toBe('function');
99
- });
100
- });
101
-
102
- it('should register compute list command with correct structure', () => {
103
- registerComputeProgram(program);
104
-
105
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
106
- const listCommand = computeCommand?.commands.find(cmd => cmd.name() === 'list');
107
-
108
- expect(listCommand?.name()).toBe('list');
109
- expect(listCommand?.description()).toBe('List all compute instances');
110
- expect(typeof listCommand?.action).toBe('function');
111
- });
112
-
113
- it('should register compute create command with correct structure', () => {
114
- registerComputeProgram(program);
115
-
116
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
117
- const createCommand = computeCommand?.commands.find(cmd => cmd.name() === 'create');
118
-
119
- expect(createCommand?.name()).toBe('create');
120
- expect(createCommand?.description()).toBe('Create a new compute instance');
121
- expect(typeof createCommand?.action).toBe('function');
122
- });
123
-
124
- it('should register compute delete command with correct structure', () => {
125
- registerComputeProgram(program);
126
-
127
- const computeCommand = program.commands.find(cmd => cmd.name() === 'compute');
128
- const deleteCommand = computeCommand?.commands.find(cmd => cmd.name() === 'delete');
129
-
130
- expect(deleteCommand?.name()).toBe('delete');
131
- expect(deleteCommand?.description()).toBe('Delete one or more compute instances');
132
- expect(typeof deleteCommand?.action).toBe('function');
133
- });
134
- });
135
- });