@bhooai/nexus-cli 2.0.0 → 2.0.2
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/bin/nexus.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* BhooAI Nexus CLI entry (standalone @bhooai/nexus-cli).
|
|
4
|
+
*
|
|
5
|
+
* Self-contained ESM shim: loads the TypeScript source via tsx (which
|
|
6
|
+
* rewrites .js import specifiers to .ts). No build step required.
|
|
7
|
+
*/
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
|
|
15
|
+
async function main() {
|
|
16
|
+
const srcEntry = join(__dirname, '..', 'src', 'index.ts');
|
|
17
|
+
const distEntry = join(__dirname, '..', 'dist', 'index.js');
|
|
18
|
+
const { tsImport } = await import('tsx/esm/api');
|
|
19
|
+
const entry = existsSync(srcEntry) ? srcEntry : distEntry;
|
|
20
|
+
const mod = await tsImport(pathToFileURL(entry).href, import.meta.url);
|
|
21
|
+
const cmd = process.argv[2] ?? 'help';
|
|
22
|
+
const rest = process.argv.slice(3);
|
|
23
|
+
await mod.run(cmd, rest);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isUserCancel(err) {
|
|
27
|
+
if (!err) return false;
|
|
28
|
+
if (err.name === 'AbortError') return true;
|
|
29
|
+
return err instanceof Error && /aborted with ctrl\+c/i.test(err.message);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
main().catch((err) => {
|
|
33
|
+
if (isUserCancel(err)) process.exit(130);
|
|
34
|
+
console.error(err?.stack ?? err);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bhooai/nexus-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "BhooAI Nexus v2 CLI — init, dev, build, test, scaffolding, plugins, queue, db.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -8,16 +8,25 @@
|
|
|
8
8
|
"bin": {
|
|
9
9
|
"nexus": "./bin/nexus.js"
|
|
10
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src/",
|
|
13
|
+
"bin/",
|
|
14
|
+
"templates/"
|
|
15
|
+
],
|
|
11
16
|
"scripts": {
|
|
12
17
|
"typecheck": "tsc --noEmit"
|
|
13
18
|
},
|
|
14
19
|
"dependencies": {
|
|
15
|
-
"@bhooai/nexus-core": "^2.0.
|
|
20
|
+
"@bhooai/nexus-core": "^2.0.1",
|
|
21
|
+
"@bhooai/nexus-examples": "^2.0.1",
|
|
16
22
|
"tsx": "^4.19.0",
|
|
17
23
|
"zod": "^3.23.8"
|
|
18
24
|
},
|
|
19
25
|
"devDependencies": {
|
|
20
26
|
"@types/node": "^22.5.0",
|
|
21
27
|
"typescript": "^5.6.2"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
22
31
|
}
|
|
23
32
|
}
|
package/src/commands/init.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { mkdir, writeFile, cp, readFile, readdir } from 'node:fs/promises';
|
|
10
10
|
import { existsSync } from 'node:fs';
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
11
12
|
import { join, resolve, dirname, basename } from 'node:path';
|
|
12
13
|
import { fileURLToPath } from 'node:url';
|
|
13
14
|
import type { CommandContext } from '../dispatcher.js';
|
|
@@ -147,14 +148,28 @@ export async function run(ctx: CommandContext): Promise<void> {
|
|
|
147
148
|
await writeFile(envPath, envContent, 'utf-8');
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
// 5.
|
|
151
|
+
// 5. Install dependencies (unless --no-install)
|
|
152
|
+
const skipInstall = !!args.flags['no-install'];
|
|
153
|
+
if (skipInstall) {
|
|
154
|
+
console.log(`\n( --no-install given — run \`npm install\` in ${targetDir} manually. )`);
|
|
155
|
+
} else {
|
|
156
|
+
console.log(`\nInstalling dependencies in ${targetDir}...\n`);
|
|
157
|
+
const code = await runNpmInstall(targetDir);
|
|
158
|
+
if (code !== 0) {
|
|
159
|
+
console.error('\n✗ npm install failed — run it manually inside the project.');
|
|
160
|
+
process.exitCode = code ?? 1;
|
|
161
|
+
} else {
|
|
162
|
+
console.log('\n✓ Dependencies installed.');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 6. Summary
|
|
151
167
|
console.log(`
|
|
152
168
|
✓ Project scaffolded at ${targetDir}
|
|
153
169
|
|
|
154
170
|
Next steps:
|
|
155
171
|
cd ${targetDirArg === '.' ? '.' : targetDirArg}
|
|
156
|
-
npm
|
|
157
|
-
npx nexus dev
|
|
172
|
+
npm run dev
|
|
158
173
|
|
|
159
174
|
Ports allocated:
|
|
160
175
|
Backend : ${backendPort}
|
|
@@ -164,6 +179,22 @@ Ports allocated:
|
|
|
164
179
|
`);
|
|
165
180
|
}
|
|
166
181
|
|
|
182
|
+
/** Run `npm install` in a directory; returns the exit code. */
|
|
183
|
+
function runNpmInstall(dir: string): Promise<number> {
|
|
184
|
+
return new Promise((resolve) => {
|
|
185
|
+
const child = spawn('npm', ['install', '--no-audit', '--no-fund'], {
|
|
186
|
+
cwd: dir,
|
|
187
|
+
stdio: 'inherit',
|
|
188
|
+
shell: process.platform === 'win32',
|
|
189
|
+
});
|
|
190
|
+
child.on('error', (err) => {
|
|
191
|
+
console.error('✗ Failed to spawn npm install:', err.message);
|
|
192
|
+
resolve(1);
|
|
193
|
+
});
|
|
194
|
+
child.on('exit', (code) => resolve(code ?? 1));
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
167
198
|
async function listExamples(): Promise<string[]> {
|
|
168
199
|
const dir = EXAMPLES_DIR;
|
|
169
200
|
if (!existsSync(dir)) return [];
|
|
@@ -252,4 +283,4 @@ ${vars.aiProviders.map((p) => `NEXUS_AI_${p.toUpperCase()}_API_KEY=`).join('\n')
|
|
|
252
283
|
}
|
|
253
284
|
|
|
254
285
|
export const description = 'Scaffold a new Nexus project (quick or interactive)';
|
|
255
|
-
export const usage = 'nexus init [dir] [--example <name>] [--interactive] [--name <name>]';
|
|
286
|
+
export const usage = 'nexus init [dir] [--example <name>] [--interactive] [--name <name>] [--no-install]';
|
|
@@ -15,19 +15,20 @@
|
|
|
15
15
|
"up": "nexus up"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@bhooai/nexus-core": "^2.0.
|
|
19
|
-
"@bhooai/nexus-auth": "^2.0.
|
|
20
|
-
"@bhooai/nexus-data": "^2.0.
|
|
21
|
-
"@bhooai/nexus-cache": "^2.0.
|
|
22
|
-
"@bhooai/nexus-realtime": "^2.0.
|
|
23
|
-
"@bhooai/nexus-payments": "^2.0.
|
|
24
|
-
"@bhooai/nexus-email": "^2.0.
|
|
25
|
-
"@bhooai/nexus-ai-client": "^2.0.
|
|
26
|
-
"@bhooai/nexus-graphql": "^2.0.
|
|
27
|
-
"@bhooai/nexus-telemetry": "^2.0.
|
|
18
|
+
"@bhooai/nexus-core": "^2.0.1",
|
|
19
|
+
"@bhooai/nexus-auth": "^2.0.1",
|
|
20
|
+
"@bhooai/nexus-data": "^2.0.1",
|
|
21
|
+
"@bhooai/nexus-cache": "^2.0.1",
|
|
22
|
+
"@bhooai/nexus-realtime": "^2.0.1",
|
|
23
|
+
"@bhooai/nexus-payments": "^2.0.1",
|
|
24
|
+
"@bhooai/nexus-email": "^2.0.1",
|
|
25
|
+
"@bhooai/nexus-ai-client": "^2.0.1",
|
|
26
|
+
"@bhooai/nexus-graphql": "^2.0.1",
|
|
27
|
+
"@bhooai/nexus-telemetry": "^2.0.1",
|
|
28
28
|
"tsx": "^4.19.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"bhooai-nexus": "^2.0.1",
|
|
31
32
|
"@types/node": "^22.5.0",
|
|
32
33
|
"typescript": "^5.6.2",
|
|
33
34
|
"react": "^18.3.1",
|