@nimbus-sh/cli 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -29,8 +29,9 @@ Scaffolds a Nimbus-powered Workers project. `.` uses the current directory.
29
29
  nimbus init my-nimbus
30
30
  cd my-nimbus
31
31
  npm install
32
- wrangler secret put JWT_SECRET
33
- wrangler deploy
32
+ CLOUDFLARE_ACCOUNT_ID=<account-id> npx @nimbus-sh/cli setup cloudflare --name my-nimbus
33
+ npx wrangler secret put JWT_SECRET
34
+ npx wrangler deploy
34
35
  ```
35
36
 
36
37
  ### `create-nimbus-app <name>`
@@ -41,8 +42,9 @@ Scaffolds a new Nimbus-powered Workers project.
41
42
  create-nimbus-app my-nimbus
42
43
  cd my-nimbus
43
44
  npm install
44
- wrangler secret put JWT_SECRET
45
- wrangler deploy
45
+ CLOUDFLARE_ACCOUNT_ID=<account-id> npx @nimbus-sh/cli setup cloudflare --name my-nimbus
46
+ npx wrangler secret put JWT_SECRET
47
+ npx wrangler deploy
46
48
  ```
47
49
 
48
50
  Flags:
@@ -53,6 +55,27 @@ Flags:
53
55
  | `--template <name>` | `worker-only` | Only `worker-only` ships in v0.1. |
54
56
  | `--force` | off | Overwrite existing directory. |
55
57
 
58
+ ### `nimbus setup cloudflare`
59
+
60
+ Creates the R2 buckets referenced by the scaffolded `wrangler.jsonc` and
61
+ uploads the Python, Ruby, and clang runtime catalog.
62
+
63
+ ```bash
64
+ CLOUDFLARE_ACCOUNT_ID=<account-id> npx @nimbus-sh/cli setup cloudflare --name my-nimbus
65
+ ```
66
+
67
+ If Wrangler reports Cloudflare R2 error `10042`, enable R2 in the
68
+ Cloudflare Dashboard once for the account, then rerun the setup command.
69
+
70
+ Flags:
71
+
72
+ | Flag | Default | What |
73
+ |---|---|---|
74
+ | `--name <worker-name>` | required | Worker name and default bucket prefix. |
75
+ | `--bucket-prefix <prefix>` | `--name` | Prefix for npm cache buckets. |
76
+ | `--runtime-bucket <bucket>` | `nimbus-runtime-cache-public` | Runtime catalog/blob bucket. |
77
+ | `--skip-runtimes` | off | Create buckets only. |
78
+
56
79
  ### `nimbus token mint`
57
80
 
58
81
  ```bash
package/dist/bin.js CHANGED
@@ -21,6 +21,7 @@
21
21
  import { mintToken, verifyTokenCmd } from './commands/token.js';
22
22
  import { syncRuntimes, listRuntimes } from './commands/runtime-sync.js';
23
23
  import { newSession } from './commands/session.js';
24
+ import { setupCloudflare } from './commands/setup.js';
24
25
  import { CLI_VERSION } from './version.js';
25
26
  const verbs = {
26
27
  token: {
@@ -34,6 +35,9 @@ const verbs = {
34
35
  session: {
35
36
  new: newSession,
36
37
  },
38
+ setup: {
39
+ cloudflare: setupCloudflare,
40
+ },
37
41
  };
38
42
  async function main(argv) {
39
43
  if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h') {
@@ -64,6 +68,7 @@ Usage:
64
68
  nimbus runtime sync [--bucket <name>] [runtime[@version]...]
65
69
  nimbus runtime list
66
70
  nimbus session new [--endpoint <url>]
71
+ nimbus setup cloudflare --name <worker-name>
67
72
  nimbus init [directory]
68
73
 
69
74
  For embedder scaffolding:
@@ -4,7 +4,7 @@
4
4
  * v0.1 ships a single template: `worker-only`. The scaffolder writes:
5
5
  *
6
6
  * <project>/
7
- * ├── package.json — deps: @nimbus-sh/worker, @nimbus-sh/sdk
7
+ * ├── package.json — deps: @nimbus-sh/sdk, @nimbus-sh/worker
8
8
  * ├── wrangler.jsonc — the canonical 28-LOC embedder snippet
9
9
  * ├── src/
10
10
  * │ └── index.ts — 6 LOC default-export
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/commands/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAiF9D"}
1
+ {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/commands/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsF9D"}
@@ -4,7 +4,7 @@
4
4
  * v0.1 ships a single template: `worker-only`. The scaffolder writes:
5
5
  *
6
6
  * <project>/
7
- * ├── package.json — deps: @nimbus-sh/worker, @nimbus-sh/sdk
7
+ * ├── package.json — deps: @nimbus-sh/sdk, @nimbus-sh/worker
8
8
  * ├── wrangler.jsonc — the canonical 28-LOC embedder snippet
9
9
  * ├── src/
10
10
  * │ └── index.ts — 6 LOC default-export
@@ -79,6 +79,7 @@ Options:
79
79
  nextSteps: [
80
80
  `cd ${projectName}`,
81
81
  'npm install',
82
+ `CLOUDFLARE_ACCOUNT_ID=<account-id> npx @nimbus-sh/cli setup cloudflare --name ${wranglerName}`,
82
83
  'npx wrangler secret put JWT_SECRET',
83
84
  'npx wrangler deploy',
84
85
  ],
@@ -89,11 +90,15 @@ Options:
89
90
  Next steps:
90
91
  cd ${projectName}
91
92
  npm install
93
+ CLOUDFLARE_ACCOUNT_ID=<account-id> npx @nimbus-sh/cli setup cloudflare --name ${wranglerName}
92
94
  npx wrangler secret put JWT_SECRET # paste a 32+ char hex secret
93
95
  npx wrangler deploy
94
96
 
95
- Deploy will provision the DO + R2 buckets on first run. Visit the
96
- returned URL and hit "Launch" to mint a session.
97
+ If setup reports Cloudflare R2 error 10042, enable R2 in the Cloudflare
98
+ Dashboard once for this account, then rerun the setup command.
99
+
100
+ Deploy will provision the Durable Object on first run. Visit the returned
101
+ URL and hit "Launch" to mint a session.
97
102
 
98
103
  Docs: https://github.com/AshishKumar4/Nimbus#readme
99
104
  `);
@@ -112,8 +117,8 @@ function renderPackageJson(name) {
112
117
  typecheck: 'tsc --noEmit',
113
118
  },
114
119
  dependencies: {
115
- '@nimbus-sh/worker': '^0.1.0',
116
- '@nimbus-sh/sdk': '^0.1.0',
120
+ '@nimbus-sh/worker': '^0.1.1',
121
+ '@nimbus-sh/sdk': '^0.1.1',
117
122
  },
118
123
  devDependencies: {
119
124
  '@cloudflare/workers-types': '^4.20250327.0',
@@ -185,7 +190,7 @@ function renderIndexTs() {
185
190
  NimbusDOStub,
186
191
  CirrusHmrRPC,
187
192
  createNimbusHandler,
188
- } from '@nimbus-sh/worker';
193
+ } from '@nimbus-sh/sdk/worker';
189
194
 
190
195
  // Re-export the DO class + every RPC class so wrangler's
191
196
  // \`durable_objects.bindings[].class_name\` lookup + \`enable_ctx_exports\`
@@ -229,12 +234,16 @@ A Nimbus-powered Cloudflare Worker.
229
234
 
230
235
  \`\`\`bash
231
236
  npm install
237
+ CLOUDFLARE_ACCOUNT_ID=<account-id> npx @nimbus-sh/cli setup cloudflare --name ${wranglerName}
232
238
  npx wrangler secret put JWT_SECRET # paste a 32+ char hex secret
233
239
  npx wrangler deploy
234
240
  \`\`\`
235
241
 
236
242
  Then visit the URL wrangler prints. Click "Launch" to mint a session.
237
243
 
244
+ If setup reports Cloudflare R2 error 10042, enable R2 in the Cloudflare
245
+ Dashboard once for this account, then rerun the setup command.
246
+
238
247
  ## Custom auth
239
248
 
240
249
  By default tokens are enforced (\`JWT_SECRET\` set). To mint:
@@ -261,7 +270,7 @@ import { NimbusTerminal } from '@nimbus-sh/react';
261
270
  Edit \`src/index.ts\`:
262
271
 
263
272
  \`\`\`ts
264
- import { NimbusSession, createNimbusHandler } from '@nimbus-sh/worker';
273
+ import { NimbusSession, createNimbusHandler } from '@nimbus-sh/sdk/worker';
265
274
  import { issueNimbusToken } from '@nimbus-sh/sdk/token';
266
275
 
267
276
  export { NimbusSession };
@@ -0,0 +1,2 @@
1
+ export declare function setupCloudflare(args: string[]): Promise<number>;
2
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAUA,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAmDrE"}
@@ -0,0 +1,119 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { syncRuntimes } from './runtime-sync.js';
3
+ export async function setupCloudflare(args) {
4
+ if (args[0] === '--help' || args[0] === '-h') {
5
+ printHelp();
6
+ return 0;
7
+ }
8
+ const opts = parseFlags(args);
9
+ if (!opts.name) {
10
+ process.stderr.write('nimbus setup cloudflare: --name <worker-name> required\n');
11
+ printHelp();
12
+ return 64;
13
+ }
14
+ if (!process.env.CLOUDFLARE_ACCOUNT_ID) {
15
+ process.stderr.write('nimbus setup cloudflare: CLOUDFLARE_ACCOUNT_ID env var required\n');
16
+ return 78;
17
+ }
18
+ const prefix = opts.bucketPrefix || opts.name;
19
+ const runtimeBucket = opts.runtimeBucket || 'nimbus-runtime-cache-public';
20
+ const buckets = [
21
+ `${prefix}-npm-cache`,
22
+ `${prefix}-npm-packument-cache`,
23
+ runtimeBucket,
24
+ ];
25
+ process.stderr.write(`nimbus: preparing Cloudflare account for ${opts.name}\n`);
26
+ for (const bucket of buckets) {
27
+ const code = await runWrangler(['r2', 'bucket', 'create', bucket], {
28
+ okOnAlreadyExists: true,
29
+ });
30
+ if (code !== 0) {
31
+ process.stderr.write('nimbus setup cloudflare: R2 bucket setup failed. If Wrangler printed code 10042, enable R2 in the Cloudflare Dashboard and rerun this command.\n');
32
+ return code;
33
+ }
34
+ }
35
+ if (!opts.skipRuntimes) {
36
+ const code = await syncRuntimes(['--bucket', runtimeBucket, 'clang', 'python', 'ruby']);
37
+ if (code !== 0)
38
+ return code;
39
+ }
40
+ process.stdout.write(JSON.stringify({
41
+ ok: true,
42
+ worker: opts.name,
43
+ buckets,
44
+ runtimeBucket,
45
+ runtimesSynced: !opts.skipRuntimes,
46
+ }) + '\n');
47
+ return 0;
48
+ }
49
+ function parseFlags(args) {
50
+ const out = { skipRuntimes: false };
51
+ for (let i = 0; i < args.length; i++) {
52
+ const a = args[i];
53
+ if (a === '--name') {
54
+ out.name = args[++i] || '';
55
+ continue;
56
+ }
57
+ if (a === '--bucket-prefix') {
58
+ out.bucketPrefix = args[++i] || '';
59
+ continue;
60
+ }
61
+ if (a === '--runtime-bucket') {
62
+ out.runtimeBucket = args[++i] || '';
63
+ continue;
64
+ }
65
+ if (a === '--skip-runtimes') {
66
+ out.skipRuntimes = true;
67
+ continue;
68
+ }
69
+ }
70
+ return out;
71
+ }
72
+ function runWrangler(args, opts = {}) {
73
+ return new Promise((resolveExit) => {
74
+ const child = spawn('npx', ['wrangler', ...args], {
75
+ env: process.env,
76
+ shell: process.platform === 'win32',
77
+ stdio: ['ignore', 'pipe', 'pipe'],
78
+ });
79
+ let combined = '';
80
+ child.stdout.on('data', (chunk) => {
81
+ const text = String(chunk);
82
+ combined += text;
83
+ process.stderr.write(text);
84
+ });
85
+ child.stderr.on('data', (chunk) => {
86
+ const text = String(chunk);
87
+ combined += text;
88
+ process.stderr.write(text);
89
+ });
90
+ child.on('exit', (code) => {
91
+ if (code === 0)
92
+ return resolveExit(0);
93
+ if (opts.okOnAlreadyExists && /already exists|bucket.*exists/i.test(combined)) {
94
+ return resolveExit(0);
95
+ }
96
+ return resolveExit(code ?? 1);
97
+ });
98
+ child.on('error', (e) => {
99
+ process.stderr.write(`nimbus setup cloudflare: failed to run wrangler: ${e.message}\n`);
100
+ resolveExit(70);
101
+ });
102
+ });
103
+ }
104
+ function printHelp() {
105
+ process.stdout.write(`nimbus setup cloudflare
106
+
107
+ Usage:
108
+ nimbus setup cloudflare --name <worker-name>
109
+
110
+ Options:
111
+ --name <worker-name> Deployed Cloudflare Worker name. Required.
112
+ --bucket-prefix <prefix> Prefix for npm cache buckets. Defaults to --name.
113
+ --runtime-bucket <bucket> Runtime cache bucket. Defaults to nimbus-runtime-cache-public.
114
+ --skip-runtimes Create buckets only; do not upload Python/Ruby/clang runtime blobs.
115
+
116
+ Env:
117
+ CLOUDFLARE_ACCOUNT_ID Cloudflare account to prepare. Required.
118
+ `);
119
+ }
package/dist/index.d.ts CHANGED
@@ -11,5 +11,6 @@
11
11
  */
12
12
  export { mintToken } from './commands/token.js';
13
13
  export { syncRuntimes } from './commands/runtime-sync.js';
14
+ export { setupCloudflare } from './commands/setup.js';
14
15
  export { scaffold } from './commands/scaffold.js';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -11,4 +11,5 @@
11
11
  */
12
12
  export { mintToken } from './commands/token.js';
13
13
  export { syncRuntimes } from './commands/runtime-sync.js';
14
+ export { setupCloudflare } from './commands/setup.js';
14
15
  export { scaffold } from './commands/scaffold.js';
package/dist/version.d.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  * `require('./package.json')` because that breaks under bun's
4
4
  * single-file binary mode.
5
5
  */
6
- export declare const CLI_VERSION = "0.1.1";
6
+ export declare const CLI_VERSION = "0.1.3";
7
7
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * `require('./package.json')` because that breaks under bun's
4
4
  * single-file binary mode.
5
5
  */
6
- export const CLI_VERSION = '0.1.1';
6
+ export const CLI_VERSION = '0.1.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimbus-sh/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Nimbus CLI — `create-nimbus-app` scaffolder + `token mint` + `runtime sync`.",
5
5
  "homepage": "https://github.com/AshishKumar4/Nimbus",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "typecheck": "tsc --noEmit"
37
37
  },
38
38
  "dependencies": {
39
- "@nimbus-sh/sdk": "^0.1.0",
40
- "@nimbus-sh/worker": "^0.1.0"
39
+ "@nimbus-sh/sdk": "^0.1.1",
40
+ "@nimbus-sh/worker": "^0.1.1"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=20"