@bhooai/nexus-cli 2.0.1 → 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,26 +1,32 @@
1
- {
2
- "name": "@bhooai/nexus-cli",
3
- "version": "2.0.1",
4
- "description": "BhooAI Nexus v2 CLI — init, dev, build, test, scaffolding, plugins, queue, db.",
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "./src/index.ts",
8
- "bin": {
9
- "nexus": "./bin/nexus.js"
10
- },
11
- "scripts": {
12
- "typecheck": "tsc --noEmit"
13
- },
14
- "dependencies": {
15
- "@bhooai/nexus-core": "^2.0.1",
16
- "tsx": "^4.19.0",
17
- "zod": "^3.23.8"
18
- },
19
- "devDependencies": {
20
- "@types/node": "^22.5.0",
21
- "typescript": "^5.6.2"
22
- },
23
- "publishConfig": {
24
- "access": "public"
25
- }
26
- }
1
+ {
2
+ "name": "@bhooai/nexus-cli",
3
+ "version": "2.0.2",
4
+ "description": "BhooAI Nexus v2 CLI init, dev, build, test, scaffolding, plugins, queue, db.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./src/index.ts",
8
+ "bin": {
9
+ "nexus": "./bin/nexus.js"
10
+ },
11
+ "files": [
12
+ "src/",
13
+ "bin/",
14
+ "templates/"
15
+ ],
16
+ "scripts": {
17
+ "typecheck": "tsc --noEmit"
18
+ },
19
+ "dependencies": {
20
+ "@bhooai/nexus-core": "^2.0.1",
21
+ "@bhooai/nexus-examples": "^2.0.1",
22
+ "tsx": "^4.19.0",
23
+ "zod": "^3.23.8"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.5.0",
27
+ "typescript": "^5.6.2"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }
@@ -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. Summary
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 install
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]';
@@ -8,7 +8,7 @@
8
8
  "build": "vite build"
9
9
  },
10
10
  "dependencies": {
11
- "@bhooai/nexus-admin": "^2.0.0",
11
+ "@bhooai/nexus-admin": "^2.0.1",
12
12
  "react": "^18.3.1",
13
13
  "react-dom": "^18.3.1"
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import '@bhooai/nexus-admin/style.css';
2
- import NexusAdmin from '@bhooai/nexus-admin';
2
+ import { App as NexusAdmin } from '@bhooai/nexus-admin';
3
3
  import React from 'react';
4
4
  import { createRoot } from 'react-dom/client';
5
5
 
@@ -15,19 +15,20 @@
15
15
  "up": "nexus up"
16
16
  },
17
17
  "dependencies": {
18
- "@bhooai/nexus-core": "^2.0.0",
19
- "@bhooai/nexus-auth": "^2.0.0",
20
- "@bhooai/nexus-data": "^2.0.0",
21
- "@bhooai/nexus-cache": "^2.0.0",
22
- "@bhooai/nexus-realtime": "^2.0.0",
23
- "@bhooai/nexus-payments": "^2.0.0",
24
- "@bhooai/nexus-email": "^2.0.0",
25
- "@bhooai/nexus-ai-client": "^2.0.0",
26
- "@bhooai/nexus-graphql": "^2.0.0",
27
- "@bhooai/nexus-telemetry": "^2.0.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",
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src",
6
- "composite": false
7
- },
8
- "include": ["src/**/*"],
9
- "exclude": ["dist/**", "node_modules/**"]
10
- }