@naseej/blox 1.10.0 → 1.11.0
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/run.js +3083 -1178
- package/dist/sdk.js +40 -0
- package/package.json +1 -1
- package/readme.md +278 -19
package/dist/sdk.js
CHANGED
|
@@ -64,6 +64,10 @@ var import_prompts = require("@clack/prompts");
|
|
|
64
64
|
var import_extra_typings = require("@commander-js/extra-typings");
|
|
65
65
|
var import_extra_typings2 = require("@commander-js/extra-typings");
|
|
66
66
|
|
|
67
|
+
// src/config/mode.ts
|
|
68
|
+
var nonInteractiveFlag = false;
|
|
69
|
+
var isNonInteractive = () => nonInteractiveFlag || !process.stdin.isTTY;
|
|
70
|
+
|
|
67
71
|
// src/config/runtime.ts
|
|
68
72
|
var isDebugMode = () => !!import_extra_typings2.program.opts()?.debug;
|
|
69
73
|
var isMinimalMode = () => !!import_extra_typings2.program.opts()?.minimal;
|
|
@@ -127,6 +131,38 @@ ${combined}`;
|
|
|
127
131
|
|
|
128
132
|
// src/shared/prompts/index.ts
|
|
129
133
|
var import_prompts3 = require("@clack/prompts");
|
|
134
|
+
|
|
135
|
+
// src/shared/errors.ts
|
|
136
|
+
var exitCodes = {
|
|
137
|
+
SUCCESS: 0,
|
|
138
|
+
GENERAL: 1,
|
|
139
|
+
USAGE: 2,
|
|
140
|
+
NOT_FOUND: 3,
|
|
141
|
+
AUTH: 4,
|
|
142
|
+
CONFLICT: 5,
|
|
143
|
+
APPROVAL_REQUIRED: 6
|
|
144
|
+
};
|
|
145
|
+
var CliError = class extends Error {
|
|
146
|
+
constructor(message, code, exitCode = exitCodes.GENERAL, suggestion, details) {
|
|
147
|
+
super(message);
|
|
148
|
+
this.code = code;
|
|
149
|
+
this.exitCode = exitCode;
|
|
150
|
+
this.suggestion = suggestion;
|
|
151
|
+
this.details = details;
|
|
152
|
+
this.name = "CliError";
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/shared/prompts/index.ts
|
|
157
|
+
var assertInteractive = (kind) => {
|
|
158
|
+
if (isNonInteractive()) {
|
|
159
|
+
throw new CliError(
|
|
160
|
+
`Cannot prompt for "${kind}" in non-interactive mode. Provide the required arguments instead.`,
|
|
161
|
+
"PROMPT_IN_NON_INTERACTIVE",
|
|
162
|
+
exitCodes.USAGE
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
130
166
|
var checkIfCanceled = (value) => {
|
|
131
167
|
if ((0, import_prompts3.isCancel)(value)) {
|
|
132
168
|
(0, import_prompts3.cancel)();
|
|
@@ -134,21 +170,25 @@ var checkIfCanceled = (value) => {
|
|
|
134
170
|
}
|
|
135
171
|
};
|
|
136
172
|
var select = async (opts) => {
|
|
173
|
+
assertInteractive(opts.message);
|
|
137
174
|
const value = await (0, import_prompts3.select)(opts);
|
|
138
175
|
checkIfCanceled(value);
|
|
139
176
|
return value;
|
|
140
177
|
};
|
|
141
178
|
var text = async (opts) => {
|
|
179
|
+
assertInteractive(opts.message);
|
|
142
180
|
const value = await (0, import_prompts3.text)(opts);
|
|
143
181
|
checkIfCanceled(value);
|
|
144
182
|
return value;
|
|
145
183
|
};
|
|
146
184
|
var confirm = async (opts) => {
|
|
185
|
+
assertInteractive(opts.message);
|
|
147
186
|
const value = await (0, import_prompts3.confirm)(opts);
|
|
148
187
|
checkIfCanceled(value);
|
|
149
188
|
return value;
|
|
150
189
|
};
|
|
151
190
|
var multiselect = async (opts) => {
|
|
191
|
+
assertInteractive(opts.message);
|
|
152
192
|
const value = await (0, import_prompts3.multiselect)(opts);
|
|
153
193
|
checkIfCanceled(value);
|
|
154
194
|
return value;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -41,8 +41,8 @@ Global flags:
|
|
|
41
41
|
Available commands:
|
|
42
42
|
|
|
43
43
|
- `blox init`: initialize a new app
|
|
44
|
-
- `blox add`: add one or more blocks
|
|
45
|
-
- `blox remove`: remove one or more installed blocks
|
|
44
|
+
- `blox add`: add one or more blocks or applications
|
|
45
|
+
- `blox remove`: remove one or more installed blocks or applications
|
|
46
46
|
- `blox update`: update the app, bases, or blocks
|
|
47
47
|
- `blox conf`: set global BLOX configuration
|
|
48
48
|
- `blox contribute`: contribute changes back to template, base, or block repositories
|
|
@@ -52,6 +52,48 @@ Available commands:
|
|
|
52
52
|
- `blox skills`: run BLOX CLI skills commands
|
|
53
53
|
- `blox doctor`: diagnose and optionally repair BLOX workspace issues
|
|
54
54
|
|
|
55
|
+
## Projects with applications
|
|
56
|
+
|
|
57
|
+
A BLOX project can contain complete applications vendored under `apps/` inside a single repository. Each application is a full BLOX project with its own `.blox`, configuration, dependencies, and `blocks/` directory:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
my-project/
|
|
61
|
+
├── .blox
|
|
62
|
+
├── blocks/ # shared root blocks
|
|
63
|
+
└── apps/
|
|
64
|
+
├── web/
|
|
65
|
+
│ ├── .blox
|
|
66
|
+
│ └── blocks/ # web-specific blocks
|
|
67
|
+
└── api/
|
|
68
|
+
├── .blox
|
|
69
|
+
└── blocks/
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Key behaviors:
|
|
73
|
+
|
|
74
|
+
- There is one Git repository at the workspace root — applications do not have nested repositories.
|
|
75
|
+
- Commands run inside `apps/<name>` automatically scope to that application; `--app <name>` scopes them from the workspace root.
|
|
76
|
+
- Applications are added and removed like blocks: `blox add app/web` materializes an application under `apps/`; `blox remove app/web` removes it.
|
|
77
|
+
- Block dependencies resolve in the owning scope: application blocks resolve same-application blocks first, then root shared blocks; root blocks only resolve other root blocks.
|
|
78
|
+
- `blox update` at the workspace root updates the root project and every application sequentially; `--app <name>` restricts it to one application.
|
|
79
|
+
- Registries declare applications in a nested `apps` map on the template entry, mirroring `blocks`:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"templates": {
|
|
84
|
+
"fullstack": {
|
|
85
|
+
"apps": {
|
|
86
|
+
"web": {
|
|
87
|
+
"source": "/template-web",
|
|
88
|
+
"destination": "web",
|
|
89
|
+
"blocks": { "auth": {} }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
55
97
|
### init
|
|
56
98
|
|
|
57
99
|
Initialize a new app.
|
|
@@ -67,31 +109,53 @@ Important options:
|
|
|
67
109
|
- `-n, --name`: app name
|
|
68
110
|
- `-t, --template`: template to use
|
|
69
111
|
- `--branch`: branch name to use
|
|
112
|
+
- `--non-interactive`: run without prompts; `--name` and `--template` are required
|
|
113
|
+
- `--json`: emit a structured JSON result on stdout
|
|
114
|
+
|
|
115
|
+
Important notes:
|
|
116
|
+
|
|
117
|
+
- Non-interactive runs select the latest available version automatically.
|
|
118
|
+
|
|
119
|
+
Examples:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
blox init --non-interactive --name my-app --template my-template
|
|
123
|
+
blox init --non-interactive --name my-app --template my-template --json
|
|
124
|
+
```
|
|
70
125
|
|
|
71
126
|
### add
|
|
72
127
|
|
|
73
|
-
Add one or more blocks to
|
|
128
|
+
Add one or more blocks or applications to a project.
|
|
74
129
|
|
|
75
130
|
Usage:
|
|
76
131
|
|
|
77
132
|
```sh
|
|
78
|
-
blox add [
|
|
133
|
+
blox add [components]
|
|
79
134
|
```
|
|
80
135
|
|
|
81
136
|
Example:
|
|
82
137
|
|
|
83
138
|
```sh
|
|
84
139
|
blox add components applet-template
|
|
140
|
+
blox add app/web
|
|
141
|
+
blox add components --app web
|
|
142
|
+
blox add --non-interactive --json components
|
|
85
143
|
```
|
|
86
144
|
|
|
87
145
|
Important options:
|
|
88
146
|
|
|
147
|
+
- `--app <name>`: add blocks inside the application `apps/<name>` instead of the root project
|
|
89
148
|
- `--branch`: branch name (applies to all selected blocks)
|
|
90
149
|
- `--dest`: destination directory (applies to all selected blocks)
|
|
150
|
+
- `--replace`: replace an existing block destination without prompting
|
|
151
|
+
- `--rewrite-deps`: update dependent blocks to reference the replaced block without prompting
|
|
152
|
+
- `--non-interactive`: run without prompts; `blocks` arguments are required
|
|
153
|
+
- `--json`: emit a structured JSON result on stdout
|
|
91
154
|
|
|
92
155
|
Important notes:
|
|
93
156
|
|
|
94
|
-
-
|
|
157
|
+
- Component arguments may be qualified with a `block/` or `app/` prefix (for example `blox add app/web`). Unqualified names resolve to blocks first, then applications; a name that exists as both must be qualified. When `--app` is used or the command runs inside an application directory, arguments resolve to that application's blocks.
|
|
158
|
+
- If `components` are omitted, BLOX prompts with a multiselect from available blocks and applications. Non-interactive runs require `components` arguments and never prompt: existing destinations are skipped unless `--replace` is passed, and dependent blocks are only repointed with `--rewrite-deps`.
|
|
95
159
|
- Installed blocks are marked in the list and skipped if selected again, including blocks installed under a custom destination.
|
|
96
160
|
- Blocks are processed sequentially in the order provided.
|
|
97
161
|
- A failed block does not stop the remaining selections or roll back successful additions.
|
|
@@ -101,29 +165,37 @@ Important notes:
|
|
|
101
165
|
|
|
102
166
|
### remove
|
|
103
167
|
|
|
104
|
-
Remove one or more installed blocks.
|
|
168
|
+
Remove one or more installed blocks or applications.
|
|
105
169
|
|
|
106
170
|
Usage:
|
|
107
171
|
|
|
108
172
|
```sh
|
|
109
|
-
blox remove [
|
|
173
|
+
blox remove [components]
|
|
110
174
|
```
|
|
111
175
|
|
|
112
176
|
Example:
|
|
113
177
|
|
|
114
178
|
```sh
|
|
115
179
|
blox remove components applet-template
|
|
180
|
+
blox remove app/web
|
|
181
|
+
blox remove components --app web
|
|
182
|
+
blox remove --non-interactive --json components
|
|
116
183
|
```
|
|
117
184
|
|
|
118
185
|
Important options:
|
|
119
186
|
|
|
187
|
+
- `--app <name>`: remove blocks inside the application `apps/<name>` instead of the root project
|
|
120
188
|
- `-f, --force`: remove even when other blocks depend on them
|
|
189
|
+
- `--non-interactive`: run without prompts; `components` arguments are required
|
|
190
|
+
- `--json`: emit a structured JSON result on stdout
|
|
121
191
|
|
|
122
192
|
Important notes:
|
|
123
193
|
|
|
124
|
-
-
|
|
194
|
+
- Component arguments may be qualified with a `block/` or `app/` prefix (for example `blox remove app/web`). Unqualified names resolve to installed blocks first, then installed applications.
|
|
195
|
+
- If `components` are omitted, BLOX prompts with a multiselect from installed blocks and applications.
|
|
125
196
|
- You can pass registry keys or installed folder names under `blocks/`.
|
|
126
|
-
- Only directories under `blocks/` containing a valid `.blox` file are treated as removable blocks.
|
|
197
|
+
- Only directories under `blocks/` containing a valid `.blox` file are treated as removable blocks. Applications are `apps/<name>` directories containing a `.blox` file.
|
|
198
|
+
- Removing a root block checks dependents across the root and every application's blocks; removing an application block checks dependents only within the same application.
|
|
127
199
|
- Blocks are processed sequentially in the order provided.
|
|
128
200
|
|
|
129
201
|
### update
|
|
@@ -136,17 +208,42 @@ Usage:
|
|
|
136
208
|
blox update
|
|
137
209
|
```
|
|
138
210
|
|
|
211
|
+
Examples:
|
|
212
|
+
|
|
213
|
+
```sh
|
|
214
|
+
# Interactive: prompts for confirmation and conflict resolution
|
|
215
|
+
blox update -s block
|
|
216
|
+
|
|
217
|
+
# Non-interactive: update everything, no prompts
|
|
218
|
+
blox update --non-interactive
|
|
219
|
+
|
|
220
|
+
# Non-interactive: allow updates that contain breaking changes
|
|
221
|
+
blox update --non-interactive --allow-breaking
|
|
222
|
+
|
|
223
|
+
# Non-interactive: single block with structured JSON output
|
|
224
|
+
blox update --non-interactive -s block -b my-block --json
|
|
225
|
+
|
|
226
|
+
# Update only the web application and its blocks
|
|
227
|
+
blox update --app web
|
|
228
|
+
```
|
|
229
|
+
|
|
139
230
|
Important options:
|
|
140
231
|
|
|
232
|
+
- `--app <name>`: restrict the update to the application `apps/<name>` and its blocks. Without `--app`, the whole workspace (root project plus every application) is updated sequentially.
|
|
141
233
|
- `-s, --scope`: `app`, `bases`, `block`, or `all` (default: `all`)
|
|
142
234
|
- `-b, --block`: block to update (valid only when `--scope block`)
|
|
143
235
|
- `--ignore <list...>`: ignore patterns scoped by repo name, for example `repo:file`
|
|
144
236
|
- `--hard`: overwrite local changes during update
|
|
237
|
+
- `--allow-breaking`: authorize applying updates that contain breaking changes (required in non-interactive mode)
|
|
238
|
+
- `--non-interactive`: run without prompts; missing inputs fail instead of prompting
|
|
239
|
+
- `--json`: emit a structured JSON result on stdout
|
|
145
240
|
|
|
146
241
|
Important notes:
|
|
147
242
|
|
|
148
243
|
- You may need to resolve merge conflicts.
|
|
149
244
|
- If a template, base, or block is missing from the registry, BLOX prompts you to continue or stop.
|
|
245
|
+
- When an update contains breaking changes, BLOX lists them with their migration instructions and asks for confirmation. Non-interactive runs require `--allow-breaking` and otherwise stop before applying changes.
|
|
246
|
+
- BLOX runs non-interactively automatically when stdin is not a terminal (CI, agents, piped input).
|
|
150
247
|
|
|
151
248
|
### contribute
|
|
152
249
|
|
|
@@ -158,21 +255,70 @@ Usage:
|
|
|
158
255
|
blox contribute
|
|
159
256
|
```
|
|
160
257
|
|
|
258
|
+
Examples:
|
|
259
|
+
|
|
260
|
+
```sh
|
|
261
|
+
# Interactive: supplied flags are reused, missing inputs are prompted for
|
|
262
|
+
blox contribute --title "migrate template to pnpm"
|
|
263
|
+
|
|
264
|
+
# Non-interactive: all inputs supplied up front
|
|
265
|
+
blox contribute --non-interactive \
|
|
266
|
+
--commits abc123,def456 \
|
|
267
|
+
--targets template/ui-app-composable \
|
|
268
|
+
--commit-type build \
|
|
269
|
+
--title "migrate template to pnpm"
|
|
270
|
+
|
|
271
|
+
# Non-interactive: breaking-change contribution with JSON output
|
|
272
|
+
blox contribute --non-interactive --json \
|
|
273
|
+
--commits abc123 \
|
|
274
|
+
--targets block/auth \
|
|
275
|
+
--commit-type feat \
|
|
276
|
+
--title "drop legacy auth" \
|
|
277
|
+
--breaking \
|
|
278
|
+
--breaking-summary "Removed legacy auth API" \
|
|
279
|
+
--breaking-migration "Install pnpm 12.7.0 and run pnpm install"
|
|
280
|
+
|
|
281
|
+
# Non-interactive: multiple commits, comma- or whitespace-separated
|
|
282
|
+
blox contribute --non-interactive \
|
|
283
|
+
--commits "abc123 def456" \
|
|
284
|
+
--targets base/Base-A \
|
|
285
|
+
--commit-type build \
|
|
286
|
+
--title "migrate template to pnpm"
|
|
287
|
+
|
|
288
|
+
# Non-interactive: append commits to an existing contribution branch
|
|
289
|
+
blox contribute --non-interactive --existing \
|
|
290
|
+
--commits abc123 \
|
|
291
|
+
--targets template/ui-app-composable \
|
|
292
|
+
--title "migrate template to pnpm" \
|
|
293
|
+
--branch fix/migrate-template-to-pnpm
|
|
294
|
+
```
|
|
295
|
+
|
|
161
296
|
Important options:
|
|
162
297
|
|
|
163
298
|
- `--existing`: add changes to an existing contribution branch
|
|
164
299
|
- `--title <title>`: contribution title
|
|
165
300
|
- `--description <text>`: contribution description
|
|
166
|
-
- `--commits <commits>`:
|
|
167
|
-
- `--
|
|
301
|
+
- `--commits <commits>`: commit hashes from the app repo, separated by commas or whitespace
|
|
302
|
+
- `--targets <list>`: comma-separated contribution targets as `type/name` (e.g. `template/ui-app,block/auth`)
|
|
168
303
|
- `--type <type>`: target type (`template`, `base`, or `block`)
|
|
169
304
|
- `--name <name>`: target name (used with `--type`)
|
|
305
|
+
- `--commit-type <type>`: conventional commit type for new contributions
|
|
306
|
+
- `--breaking`: mark the contribution as a breaking change
|
|
307
|
+
- `--breaking-summary <summary>`: breaking-change summary (required with `--breaking`)
|
|
308
|
+
- `--breaking-migration <instructions>`: migration instructions (required with `--breaking`)
|
|
309
|
+
- `--branch <name>`: existing contribution branch (used with `--existing`)
|
|
310
|
+
- `--force`: bypass safety pre-flight checks
|
|
311
|
+
- `--non-interactive`: run without prompts; missing inputs fail instead of prompting
|
|
312
|
+
- `--json`: emit a machine-readable JSON result on stdout
|
|
170
313
|
|
|
171
314
|
Important notes:
|
|
172
315
|
|
|
173
|
-
- Without a matching `--type` and `--name`, BLOX lets you select one or more available targets. Press `s` in the target list to search.
|
|
316
|
+
- Without a matching `--type` and `--name`, or `--targets`, BLOX lets you select one or more available targets. Press `s` in the target list to search.
|
|
174
317
|
- When both flags match a discovered target, BLOX skips target selection. If the match is not found or only one flag is provided, BLOX warns and shows the available targets.
|
|
175
318
|
- If a selected target has no registry source, BLOX reports it as skipped and continues with the remaining targets.
|
|
319
|
+
- Commit hashes must appear in the current app repo `HEAD` history; interactive selection lists commits from that same history.
|
|
320
|
+
- Non-interactive runs require every input up front: `--commits`, a target (`--targets` or `--type` + `--name`), `--title`, `--commit-type` (new contributions), `--branch` (`--existing`), and `--breaking-summary` + `--breaking-migration` when `--breaking` is set. Missing arguments are reported together with a non-zero exit code.
|
|
321
|
+
- If a non-interactive contribution hits merge conflicts, BLOX preserves the temporary workspace and reports how to finish the contribution manually (or to re-run interactively); it never opens an IDE or waits for input.
|
|
176
322
|
|
|
177
323
|
### conf
|
|
178
324
|
|
|
@@ -186,7 +332,15 @@ blox conf
|
|
|
186
332
|
|
|
187
333
|
Important options:
|
|
188
334
|
|
|
189
|
-
- `-r, --registries`: remote registry URLs
|
|
335
|
+
- `-r, --registries`: remote registry URLs (required in non-interactive mode)
|
|
336
|
+
- `--non-interactive`: run without prompts
|
|
337
|
+
- `--json`: emit a structured JSON result on stdout
|
|
338
|
+
|
|
339
|
+
Example:
|
|
340
|
+
|
|
341
|
+
```sh
|
|
342
|
+
blox conf --non-interactive --json --registries https://example.com/registry.git
|
|
343
|
+
```
|
|
190
344
|
|
|
191
345
|
### detach
|
|
192
346
|
|
|
@@ -201,6 +355,15 @@ blox detach
|
|
|
201
355
|
Important options:
|
|
202
356
|
|
|
203
357
|
- `--basic`: run detach only, without registry sync and migration first
|
|
358
|
+
- `--base <name>`: base to detach (required in non-interactive mode when the app declares more than one base)
|
|
359
|
+
- `--non-interactive`: run without prompts
|
|
360
|
+
- `--json`: emit a structured JSON result on stdout
|
|
361
|
+
|
|
362
|
+
Example:
|
|
363
|
+
|
|
364
|
+
```sh
|
|
365
|
+
blox detach --non-interactive --base my-base --json
|
|
366
|
+
```
|
|
204
367
|
|
|
205
368
|
### upgrade
|
|
206
369
|
|
|
@@ -209,9 +372,12 @@ Upgrade BLOX CLI to the latest version.
|
|
|
209
372
|
Usage:
|
|
210
373
|
|
|
211
374
|
```sh
|
|
212
|
-
blox upgrade
|
|
375
|
+
blox upgrade --non-interactive
|
|
376
|
+
blox upgrade --non-interactive --json
|
|
213
377
|
```
|
|
214
378
|
|
|
379
|
+
With `--json`, the successful result is `{ "success": true, "data": { "upgraded": true } }`.
|
|
380
|
+
|
|
215
381
|
### migrate
|
|
216
382
|
|
|
217
383
|
Migrate BLOX schema.
|
|
@@ -219,9 +385,12 @@ Migrate BLOX schema.
|
|
|
219
385
|
Usage:
|
|
220
386
|
|
|
221
387
|
```sh
|
|
222
|
-
blox migrate
|
|
388
|
+
blox migrate --non-interactive
|
|
389
|
+
blox migrate --non-interactive --json
|
|
223
390
|
```
|
|
224
391
|
|
|
392
|
+
With `--json`, the successful result is `{ "success": true, "data": { "migrated": true } }`.
|
|
393
|
+
|
|
225
394
|
### skills
|
|
226
395
|
|
|
227
396
|
Install and manage BLOX CLI skills (wraps `npx skills`).
|
|
@@ -236,6 +405,7 @@ Important notes:
|
|
|
236
405
|
|
|
237
406
|
- For `blox skills add`, BLOX injects the BLOX skills repository URL when you do not provide one.
|
|
238
407
|
- BLOX forwards the remaining arguments to `npx skills`.
|
|
408
|
+
- `blox skills` does not support the shared `--non-interactive` or `--json` flags; use options supported by the wrapped Skills CLI.
|
|
239
409
|
|
|
240
410
|
### doctor
|
|
241
411
|
|
|
@@ -251,6 +421,15 @@ blox doctor --fix
|
|
|
251
421
|
Options:
|
|
252
422
|
|
|
253
423
|
- `--fix`: attempt automatic repairs for findings that support them, then revalidate
|
|
424
|
+
- `--non-interactive`: run without prompts
|
|
425
|
+
- `--json`: emit the full report (diagnostics, repairs, check errors) as JSON on stdout
|
|
426
|
+
|
|
427
|
+
Examples:
|
|
428
|
+
|
|
429
|
+
```sh
|
|
430
|
+
blox doctor --non-interactive
|
|
431
|
+
blox doctor --non-interactive --fix --json
|
|
432
|
+
```
|
|
254
433
|
|
|
255
434
|
Exit codes:
|
|
256
435
|
|
|
@@ -260,6 +439,86 @@ Exit codes:
|
|
|
260
439
|
|
|
261
440
|
## Features
|
|
262
441
|
|
|
442
|
+
### Non-interactive Use and JSON Output
|
|
443
|
+
|
|
444
|
+
All commands except `blox skills` support two independent flags:
|
|
445
|
+
|
|
446
|
+
- **`--non-interactive`** controls interaction: nothing is ever prompted; missing required arguments are reported together and the command exits non-zero.
|
|
447
|
+
- **`--json`** controls output format: the CLI writes one JSON envelope to stdout while prompts, progress, warnings, and diagnostics go to stderr.
|
|
448
|
+
|
|
449
|
+
The flags combine freely:
|
|
450
|
+
|
|
451
|
+
| Invocation | Input behavior | Output behavior |
|
|
452
|
+
| -------------------------- | ------------------- | --------------- |
|
|
453
|
+
| (default) | prompts when needed | human-readable |
|
|
454
|
+
| `--json` | prompts when needed | JSON result |
|
|
455
|
+
| `--non-interactive` | never prompts | human-readable |
|
|
456
|
+
| `--non-interactive --json` | never prompts | JSON result |
|
|
457
|
+
|
|
458
|
+
Non-interactive mode activates when `--non-interactive` is passed, or automatically whenever stdin is not a terminal (CI pipelines, agents, piped input) — prompting is impossible without a TTY regardless of flags. On a terminal, `--json` alone still prompts normally and emits the structured result once the command completes.
|
|
459
|
+
|
|
460
|
+
Use `--non-interactive` when a script or agent must avoid prompts. Supply the command's required flags explicitly; the command stops with an error when required information is missing. Required inputs per command:
|
|
461
|
+
|
|
462
|
+
| Command | Required in non-interactive mode |
|
|
463
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
464
|
+
| `init` | `--name`, `--template` |
|
|
465
|
+
| `add` | `blocks` arguments |
|
|
466
|
+
| `remove` | `blocks` arguments |
|
|
467
|
+
| `conf` | `--registries` |
|
|
468
|
+
| `detach` | `--base` (only when the app declares more than one base) |
|
|
469
|
+
| `update` | `--block` when `--scope block`; `--allow-breaking` to apply breaking changes |
|
|
470
|
+
| `contribute` | `--commits`, a target (`--targets` or `--type` + `--name`), `--title`, `--commit-type` (new contributions), `--branch` (`--existing`), `--breaking-summary` + `--breaking-migration` when `--breaking` |
|
|
471
|
+
| `migrate`, `upgrade`, `doctor` | none |
|
|
472
|
+
|
|
473
|
+
Decisions that would prompt interactively are authorized through explicit flags instead: `add --replace` / `add --rewrite-deps`, `update --allow-breaking`, `contribute --breaking*`.
|
|
474
|
+
|
|
475
|
+
Use `--json` when a script or agent needs a structured result. The CLI writes one JSON envelope to stdout; progress, warnings, and diagnostics go to stderr. For fully unattended automation, combine it with `--non-interactive`. Parse stdout as JSON and check the process exit code—JSON success does not replace checking command-level failures.
|
|
476
|
+
|
|
477
|
+
Successful result shapes differ by command. `update` returns update status and failed blocks:
|
|
478
|
+
|
|
479
|
+
```json
|
|
480
|
+
{
|
|
481
|
+
"success": true,
|
|
482
|
+
"data": {
|
|
483
|
+
"updated": true,
|
|
484
|
+
"stoppedEarly": false,
|
|
485
|
+
"failedBlocks": []
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
`contribute` reports a result for each requested target; fields such as `branch`, `prUrl`, `skipped`, and `error` depend on the result:
|
|
491
|
+
|
|
492
|
+
```json
|
|
493
|
+
{
|
|
494
|
+
"success": true,
|
|
495
|
+
"data": {
|
|
496
|
+
"results": [
|
|
497
|
+
{
|
|
498
|
+
"target": { "type": "base", "name": "Base-A" },
|
|
499
|
+
"success": true,
|
|
500
|
+
"branch": "build/migrate-template-to-pnpm",
|
|
501
|
+
"prUrl": "https://example.com/owner/repo/pull/123"
|
|
502
|
+
}
|
|
503
|
+
]
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Errors use a `{ "success": false, "error": { ... } }` envelope with a code, message, and optional suggestion or details. For example, missing required flags include their names in `error.details.missingFlags`.
|
|
509
|
+
|
|
510
|
+
Exit code conventions:
|
|
511
|
+
|
|
512
|
+
| Code | Meaning |
|
|
513
|
+
| ---- | ---------------------------------------------------------------------------- |
|
|
514
|
+
| `0` | Success |
|
|
515
|
+
| `1` | General failure |
|
|
516
|
+
| `2` | Missing or invalid arguments |
|
|
517
|
+
| `3` | Resource not found |
|
|
518
|
+
| `4` | Permission or authorization failure |
|
|
519
|
+
| `5` | Contribution merge conflicts |
|
|
520
|
+
| `6` | Required approval missing (e.g. breaking changes without `--allow-breaking`) |
|
|
521
|
+
|
|
263
522
|
### Ignore Policy
|
|
264
523
|
|
|
265
524
|
Ignore rules tell BLOX which files or paths to skip.
|
|
@@ -278,9 +537,9 @@ Example root `.blox` configuration:
|
|
|
278
537
|
|
|
279
538
|
```json
|
|
280
539
|
{
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
540
|
+
"project": {
|
|
541
|
+
"ignore": ["applet-core", "dist/**", "*.generated.ts"]
|
|
542
|
+
}
|
|
284
543
|
}
|
|
285
544
|
```
|
|
286
545
|
|
|
@@ -332,7 +591,7 @@ npm install -D @naseej/blox
|
|
|
332
591
|
Import only from the SDK subpath:
|
|
333
592
|
|
|
334
593
|
```ts
|
|
335
|
-
import { input } from
|
|
594
|
+
import { input } from "@naseej/blox/sdk";
|
|
336
595
|
```
|
|
337
596
|
|
|
338
597
|
SDK API reference:
|