@nexical/cli 0.11.19 → 0.11.20
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.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/test/unit/commands/prompt.test.ts +40 -24
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\nimport { CLI, findProjectRoot } from '@nexical/cli-core';\nimport { fileURLToPath } from 'node:url';\nimport { discoverCommandDirectories } from './src/utils/discovery.js';\nimport pkg from './package.json';\nimport path from 'node:path';\nimport { filterCommandDirectories } from './src/utils/filter.js';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst commandName = 'nexical';\nconst projectRoot = (await findProjectRoot(commandName, process.cwd())) || process.cwd();\nconst coreCommandsDir = path.resolve(__dirname, './src/commands');\nconst additionalCommands = discoverCommandDirectories(projectRoot);\n\nconst filteredAdditional = filterCommandDirectories(additionalCommands, coreCommandsDir);\n\nconst app = new CLI({\n version: pkg.version,\n commandName: commandName,\n searchDirectories: [...new Set([coreCommandsDir, ...filteredAdditional])],\n});\napp.start();\n","{\n \"name\": \"@nexical/cli\",\n \"version\": \"0.11.
|
|
1
|
+
{"version":3,"sources":["../index.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\nimport { CLI, findProjectRoot } from '@nexical/cli-core';\nimport { fileURLToPath } from 'node:url';\nimport { discoverCommandDirectories } from './src/utils/discovery.js';\nimport pkg from './package.json';\nimport path from 'node:path';\nimport { filterCommandDirectories } from './src/utils/filter.js';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst commandName = 'nexical';\nconst projectRoot = (await findProjectRoot(commandName, process.cwd())) || process.cwd();\nconst coreCommandsDir = path.resolve(__dirname, './src/commands');\nconst additionalCommands = discoverCommandDirectories(projectRoot);\n\nconst filteredAdditional = filterCommandDirectories(additionalCommands, coreCommandsDir);\n\nconst app = new CLI({\n version: pkg.version,\n commandName: commandName,\n searchDirectories: [...new Set([coreCommandsDir, ...filteredAdditional])],\n});\napp.start();\n","{\n \"name\": \"@nexical/cli\",\n \"version\": \"0.11.20\",\n \"license\": \"Apache-2.0\",\n \"type\": \"module\",\n \"bin\": {\n \"nexical\": \"./dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"start\": \"node dist/index.js\",\n \"test\": \"npm run test:unit && npm run test:integration && npm run test:e2e\",\n \"test:unit\": \"vitest run --config vitest.config.ts --coverage\",\n \"test:integration\": \"vitest run --config vitest.integration.config.ts\",\n \"test:e2e\": \"npm run build && vitest run --config vitest.e2e.config.ts\",\n \"test:watch\": \"vitest\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint .\",\n \"lint:fix\": \"eslint . --fix\",\n \"prepare\": \"husky\"\n },\n \"lint-staged\": {\n \"**/*\": [\n \"prettier --write --ignore-unknown\"\n ],\n \"**/*.{js,jsx,ts,tsx,astro}\": [\n \"eslint --fix\"\n ]\n },\n \"dependencies\": {\n \"@nexical/ai\": \"^0.1.5\",\n \"@nexical/cli-core\": \"^0.1.16\",\n \"dotenv\": \"^17.3.1\",\n \"fast-glob\": \"^3.3.3\",\n \"glob\": \"^13.0.5\",\n \"jiti\": \"^2.6.1\",\n \"minimist\": \"^1.2.8\",\n \"yaml\": \"^2.8.2\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.2\",\n \"@types/fs-extra\": \"^11.0.4\",\n \"@types/minimist\": \"^1.2.5\",\n \"@types/node\": \"^25.3.0\",\n \"@types/nunjucks\": \"^3.2.6\",\n \"@vitest/coverage-v8\": \"^4.0.18\",\n \"eslint\": \"^9.39.2\",\n \"eslint-config-prettier\": \"^10.1.8\",\n \"eslint-plugin-astro\": \"^1.6.0\",\n \"eslint-plugin-jsx-a11y\": \"^6.10.2\",\n \"eslint-plugin-react\": \"^7.37.5\",\n \"eslint-plugin-react-hooks\": \"^7.0.1\",\n \"execa\": \"^9.6.1\",\n \"fs-extra\": \"^11.3.3\",\n \"globals\": \"^17.3.0\",\n \"husky\": \"^9.1.7\",\n \"lint-staged\": \"^16.2.7\",\n \"prettier\": \"^3.8.1\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\",\n \"typescript-eslint\": \"^8.56.0\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA,SAAS,KAAK,uBAAuB;AACrC,SAAS,qBAAqB;;;ACF9B;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,KAAO;AAAA,IACL,SAAW;AAAA,EACb;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,QAAU;AAAA,IACV,MAAQ;AAAA,IACR,YAAY;AAAA,IACZ,SAAW;AAAA,EACb;AAAA,EACA,eAAe;AAAA,IACb,QAAQ;AAAA,MACN;AAAA,IACF;AAAA,IACA,8BAA8B;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AAAA,EACA,cAAgB;AAAA,IACd,eAAe;AAAA,IACf,qBAAqB;AAAA,IACrB,QAAU;AAAA,IACV,aAAa;AAAA,IACb,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,UAAY;AAAA,IACZ,MAAQ;AAAA,EACV;AAAA,EACA,iBAAmB;AAAA,IACjB,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,uBAAuB;AAAA,IACvB,QAAU;AAAA,IACV,0BAA0B;AAAA,IAC1B,uBAAuB;AAAA,IACvB,0BAA0B;AAAA,IAC1B,uBAAuB;AAAA,IACvB,6BAA6B;AAAA,IAC7B,OAAS;AAAA,IACT,YAAY;AAAA,IACZ,SAAW;AAAA,IACX,OAAS;AAAA,IACT,eAAe;AAAA,IACf,UAAY;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,YAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,QAAU;AAAA,EACZ;AACF;;;AD5DA,OAAO,UAAU;AAGjB,IAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAE7D,IAAM,cAAc;AACpB,IAAM,cAAe,MAAM,gBAAgB,aAAa,QAAQ,IAAI,CAAC,KAAM,QAAQ,IAAI;AACvF,IAAM,kBAAkB,KAAK,QAAQ,WAAW,gBAAgB;AAChE,IAAM,qBAAqB,2BAA2B,WAAW;AAEjE,IAAM,qBAAqB,yBAAyB,oBAAoB,eAAe;AAEvF,IAAM,MAAM,IAAI,IAAI;AAAA,EAClB,SAAS,gBAAI;AAAA,EACb;AAAA,EACA,mBAAmB,CAAC,GAAG,oBAAI,IAAI,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,CAAC;AAC1E,CAAC;AACD,IAAI,MAAM;","names":[]}
|
package/package.json
CHANGED
|
@@ -37,8 +37,10 @@ describe('PromptCommand', () => {
|
|
|
37
37
|
vi.spyOn(command, 'error').mockImplementation(() => {});
|
|
38
38
|
|
|
39
39
|
// Default fs mocks
|
|
40
|
-
vi.
|
|
41
|
-
vi.
|
|
40
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockResolvedValue(false);
|
|
41
|
+
vi.mocked(
|
|
42
|
+
fs.readFile as unknown as (p: string, e: string) => Promise<string>,
|
|
43
|
+
).mockResolvedValue('');
|
|
42
44
|
|
|
43
45
|
// Default PromptRunner mock
|
|
44
46
|
vi.mocked(PromptRunner.run).mockResolvedValue(0);
|
|
@@ -107,9 +109,11 @@ describe('PromptCommand', () => {
|
|
|
107
109
|
});
|
|
108
110
|
|
|
109
111
|
it('should include generator agents prompts if they exist', async () => {
|
|
110
|
-
vi.
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockImplementation(
|
|
113
|
+
async (p: string | Buffer | URL) => {
|
|
114
|
+
return (p as string).includes('packages/generator/prompts/agents');
|
|
115
|
+
},
|
|
116
|
+
);
|
|
113
117
|
|
|
114
118
|
await command.run({ promptName: 'test-prompt' });
|
|
115
119
|
|
|
@@ -120,9 +124,11 @@ describe('PromptCommand', () => {
|
|
|
120
124
|
});
|
|
121
125
|
|
|
122
126
|
it('should resolve frontend module context', async () => {
|
|
123
|
-
vi.
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockImplementation(
|
|
128
|
+
async (p: string | Buffer | URL) => {
|
|
129
|
+
return (p as string).includes('apps/frontend/modules/test-module');
|
|
130
|
+
},
|
|
131
|
+
);
|
|
126
132
|
|
|
127
133
|
await command.run({ promptName: 'test-prompt', module: 'test-module' });
|
|
128
134
|
|
|
@@ -138,9 +144,11 @@ describe('PromptCommand', () => {
|
|
|
138
144
|
});
|
|
139
145
|
|
|
140
146
|
it('should resolve backend module context', async () => {
|
|
141
|
-
vi.
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockImplementation(
|
|
148
|
+
async (p: string | Buffer | URL) => {
|
|
149
|
+
return (p as string).includes('apps/backend/modules/test-module');
|
|
150
|
+
},
|
|
151
|
+
);
|
|
144
152
|
|
|
145
153
|
await command.run({ promptName: 'test-prompt', m: 'test-module' });
|
|
146
154
|
|
|
@@ -156,7 +164,7 @@ describe('PromptCommand', () => {
|
|
|
156
164
|
});
|
|
157
165
|
|
|
158
166
|
it('should fail if module not found', async () => {
|
|
159
|
-
vi.mocked(fs.pathExists).mockResolvedValue(false);
|
|
167
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockResolvedValue(false);
|
|
160
168
|
|
|
161
169
|
await command.run({ promptName: 'test-prompt', module: 'missing-module' });
|
|
162
170
|
|
|
@@ -167,10 +175,12 @@ describe('PromptCommand', () => {
|
|
|
167
175
|
});
|
|
168
176
|
|
|
169
177
|
it('should load AI config from nexical.yaml', async () => {
|
|
170
|
-
vi.
|
|
171
|
-
(p as string).includes('nexical.yaml'),
|
|
178
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockImplementation(
|
|
179
|
+
async (p: string | Buffer | URL) => (p as string).includes('nexical.yaml'),
|
|
172
180
|
);
|
|
173
|
-
vi.
|
|
181
|
+
vi.mocked(
|
|
182
|
+
fs.readFile as unknown as (p: string, e: string) => Promise<string>,
|
|
183
|
+
).mockResolvedValue('ai:\n provider: vertex');
|
|
174
184
|
vi.mocked(YAML.parse).mockReturnValue({ ai: { provider: 'vertex' } });
|
|
175
185
|
|
|
176
186
|
await command.run({ promptName: 'test-prompt' });
|
|
@@ -183,10 +193,12 @@ describe('PromptCommand', () => {
|
|
|
183
193
|
});
|
|
184
194
|
|
|
185
195
|
it('should handle missing AI config in nexical.yaml', async () => {
|
|
186
|
-
vi.
|
|
187
|
-
(p as string).includes('nexical.yaml'),
|
|
196
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockImplementation(
|
|
197
|
+
async (p: string | Buffer | URL) => (p as string).includes('nexical.yaml'),
|
|
188
198
|
);
|
|
189
|
-
vi.
|
|
199
|
+
vi.mocked(
|
|
200
|
+
fs.readFile as unknown as (p: string, e: string) => Promise<string>,
|
|
201
|
+
).mockResolvedValue('name: my-project');
|
|
190
202
|
vi.mocked(YAML.parse).mockReturnValue({ name: 'my-project' });
|
|
191
203
|
|
|
192
204
|
await command.run({ promptName: 'test-prompt' });
|
|
@@ -199,10 +211,12 @@ describe('PromptCommand', () => {
|
|
|
199
211
|
});
|
|
200
212
|
|
|
201
213
|
it('should handle falsy YAML parse result', async () => {
|
|
202
|
-
vi.
|
|
203
|
-
(p as string).includes('nexical.yaml'),
|
|
214
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockImplementation(
|
|
215
|
+
async (p: string | Buffer | URL) => (p as string).includes('nexical.yaml'),
|
|
204
216
|
);
|
|
205
|
-
vi.
|
|
217
|
+
vi.mocked(
|
|
218
|
+
fs.readFile as unknown as (p: string, e: string) => Promise<string>,
|
|
219
|
+
).mockResolvedValue('');
|
|
206
220
|
vi.mocked(YAML.parse).mockReturnValue(null);
|
|
207
221
|
|
|
208
222
|
await command.run({ promptName: 'test-prompt' });
|
|
@@ -215,10 +229,12 @@ describe('PromptCommand', () => {
|
|
|
215
229
|
});
|
|
216
230
|
|
|
217
231
|
it('should handle nexical.yaml parse errors', async () => {
|
|
218
|
-
vi.
|
|
219
|
-
(p as string).includes('nexical.yaml'),
|
|
232
|
+
vi.mocked<(p: string) => Promise<boolean>>(fs.pathExists).mockImplementation(
|
|
233
|
+
async (p: string | Buffer | URL) => (p as string).includes('nexical.yaml'),
|
|
220
234
|
);
|
|
221
|
-
vi.
|
|
235
|
+
vi.mocked(
|
|
236
|
+
fs.readFile as unknown as (p: string, e: string) => Promise<string>,
|
|
237
|
+
).mockResolvedValue('invalid: yaml: :');
|
|
222
238
|
vi.mocked(YAML.parse).mockImplementation(() => {
|
|
223
239
|
throw new Error('parse error');
|
|
224
240
|
});
|