@naseej/blox 1.10.0 → 1.12.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 +3430 -1226
- package/dist/sdk.js +40 -0
- package/package.json +1 -1
- package/readme.md +283 -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,52 @@ 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 act as a workspace containing complete applications under `apps/`. The workspace is itself a full BLOX template with its own Git repository, and every application is an independent BLOX project with its own Git repository, `.blox`, configuration, dependencies, and `blocks/` directory:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
my-project/
|
|
61
|
+
├── .git/
|
|
62
|
+
├── .blox
|
|
63
|
+
├── .gitignore # ignores apps/<name> directories
|
|
64
|
+
├── blocks/ # workspace root blocks
|
|
65
|
+
└── apps/
|
|
66
|
+
├── web/
|
|
67
|
+
│ ├── .git/
|
|
68
|
+
│ ├── .blox
|
|
69
|
+
│ └── blocks/ # web-specific blocks
|
|
70
|
+
└── api/
|
|
71
|
+
├── .git/
|
|
72
|
+
├── .blox
|
|
73
|
+
└── blocks/
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Key behaviors:
|
|
77
|
+
|
|
78
|
+
- The workspace and every application are independent Git repositories. Application directories are added to the workspace `.gitignore`, so the root repository never tracks them.
|
|
79
|
+
- Commands run inside `apps/<name>` automatically scope to that application; `--app <name>` scopes them from the workspace root.
|
|
80
|
+
- Applications are added and removed like blocks: `blox add app/web` materializes an application under `apps/`; `blox remove app/web` removes it.
|
|
81
|
+
- Blocks resolve only within their owning scope: application blocks resolve same-application blocks; root blocks only resolve other root blocks. There are no shared blocks between the workspace and its applications.
|
|
82
|
+
- `blox update` at the workspace root updates the root project and every application sequentially; `--app <name>` restricts it to one application.
|
|
83
|
+
- `blox contribute` at the workspace root contributes the workspace template; `--app <name>` contributes only that application's repository.
|
|
84
|
+
- Registries declare applications as an `apps` array on the template entry; each entry references an existing template in the registry:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"templates": {
|
|
89
|
+
"fullstack": {
|
|
90
|
+
"apps": [
|
|
91
|
+
{ "template": "web-template", "name": "web", "version": 1 },
|
|
92
|
+
{ "template": "api-service" }
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`template` (required) names the template that provides the application's source and block catalog; `name` (optional) is the application name inside the workspace and defaults to the template name; `version` (optional) pins a requested major version, otherwise the latest available version is used.
|
|
100
|
+
|
|
55
101
|
### init
|
|
56
102
|
|
|
57
103
|
Initialize a new app.
|
|
@@ -67,31 +113,53 @@ Important options:
|
|
|
67
113
|
- `-n, --name`: app name
|
|
68
114
|
- `-t, --template`: template to use
|
|
69
115
|
- `--branch`: branch name to use
|
|
116
|
+
- `--non-interactive`: run without prompts; `--name` and `--template` are required
|
|
117
|
+
- `--json`: emit a structured JSON result on stdout
|
|
118
|
+
|
|
119
|
+
Important notes:
|
|
120
|
+
|
|
121
|
+
- Non-interactive runs select the latest available version automatically.
|
|
122
|
+
|
|
123
|
+
Examples:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
blox init --non-interactive --name my-app --template my-template
|
|
127
|
+
blox init --non-interactive --name my-app --template my-template --json
|
|
128
|
+
```
|
|
70
129
|
|
|
71
130
|
### add
|
|
72
131
|
|
|
73
|
-
Add one or more blocks to
|
|
132
|
+
Add one or more blocks or applications to a project.
|
|
74
133
|
|
|
75
134
|
Usage:
|
|
76
135
|
|
|
77
136
|
```sh
|
|
78
|
-
blox add [
|
|
137
|
+
blox add [components]
|
|
79
138
|
```
|
|
80
139
|
|
|
81
140
|
Example:
|
|
82
141
|
|
|
83
142
|
```sh
|
|
84
143
|
blox add components applet-template
|
|
144
|
+
blox add app/web
|
|
145
|
+
blox add components --app web
|
|
146
|
+
blox add --non-interactive --json components
|
|
85
147
|
```
|
|
86
148
|
|
|
87
149
|
Important options:
|
|
88
150
|
|
|
151
|
+
- `--app <name>`: add blocks inside the application `apps/<name>` instead of the root project
|
|
89
152
|
- `--branch`: branch name (applies to all selected blocks)
|
|
90
153
|
- `--dest`: destination directory (applies to all selected blocks)
|
|
154
|
+
- `--replace`: replace an existing block destination without prompting
|
|
155
|
+
- `--rewrite-deps`: update dependent blocks to reference the replaced block without prompting
|
|
156
|
+
- `--non-interactive`: run without prompts; `blocks` arguments are required
|
|
157
|
+
- `--json`: emit a structured JSON result on stdout
|
|
91
158
|
|
|
92
159
|
Important notes:
|
|
93
160
|
|
|
94
|
-
-
|
|
161
|
+
- 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.
|
|
162
|
+
- 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
163
|
- Installed blocks are marked in the list and skipped if selected again, including blocks installed under a custom destination.
|
|
96
164
|
- Blocks are processed sequentially in the order provided.
|
|
97
165
|
- A failed block does not stop the remaining selections or roll back successful additions.
|
|
@@ -101,29 +169,37 @@ Important notes:
|
|
|
101
169
|
|
|
102
170
|
### remove
|
|
103
171
|
|
|
104
|
-
Remove one or more installed blocks.
|
|
172
|
+
Remove one or more installed blocks or applications.
|
|
105
173
|
|
|
106
174
|
Usage:
|
|
107
175
|
|
|
108
176
|
```sh
|
|
109
|
-
blox remove [
|
|
177
|
+
blox remove [components]
|
|
110
178
|
```
|
|
111
179
|
|
|
112
180
|
Example:
|
|
113
181
|
|
|
114
182
|
```sh
|
|
115
183
|
blox remove components applet-template
|
|
184
|
+
blox remove app/web
|
|
185
|
+
blox remove components --app web
|
|
186
|
+
blox remove --non-interactive --json components
|
|
116
187
|
```
|
|
117
188
|
|
|
118
189
|
Important options:
|
|
119
190
|
|
|
191
|
+
- `--app <name>`: remove blocks inside the application `apps/<name>` instead of the root project
|
|
120
192
|
- `-f, --force`: remove even when other blocks depend on them
|
|
193
|
+
- `--non-interactive`: run without prompts; `components` arguments are required
|
|
194
|
+
- `--json`: emit a structured JSON result on stdout
|
|
121
195
|
|
|
122
196
|
Important notes:
|
|
123
197
|
|
|
124
|
-
-
|
|
198
|
+
- 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.
|
|
199
|
+
- If `components` are omitted, BLOX prompts with a multiselect from installed blocks and applications.
|
|
125
200
|
- 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.
|
|
201
|
+
- Only directories under `blocks/` containing a valid `.blox` file are treated as removable blocks. Applications are `apps/<name>` directories containing a `.blox` file.
|
|
202
|
+
- Removing a block checks dependents within the same project scope only (the workspace root, or the application it belongs to).
|
|
127
203
|
- Blocks are processed sequentially in the order provided.
|
|
128
204
|
|
|
129
205
|
### update
|
|
@@ -136,17 +212,42 @@ Usage:
|
|
|
136
212
|
blox update
|
|
137
213
|
```
|
|
138
214
|
|
|
215
|
+
Examples:
|
|
216
|
+
|
|
217
|
+
```sh
|
|
218
|
+
# Interactive: prompts for confirmation and conflict resolution
|
|
219
|
+
blox update -s block
|
|
220
|
+
|
|
221
|
+
# Non-interactive: update everything, no prompts
|
|
222
|
+
blox update --non-interactive
|
|
223
|
+
|
|
224
|
+
# Non-interactive: allow updates that contain breaking changes
|
|
225
|
+
blox update --non-interactive --allow-breaking
|
|
226
|
+
|
|
227
|
+
# Non-interactive: single block with structured JSON output
|
|
228
|
+
blox update --non-interactive -s block -b my-block --json
|
|
229
|
+
|
|
230
|
+
# Update only the web application and its blocks
|
|
231
|
+
blox update --app web
|
|
232
|
+
```
|
|
233
|
+
|
|
139
234
|
Important options:
|
|
140
235
|
|
|
236
|
+
- `--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
237
|
- `-s, --scope`: `app`, `bases`, `block`, or `all` (default: `all`)
|
|
142
238
|
- `-b, --block`: block to update (valid only when `--scope block`)
|
|
143
239
|
- `--ignore <list...>`: ignore patterns scoped by repo name, for example `repo:file`
|
|
144
240
|
- `--hard`: overwrite local changes during update
|
|
241
|
+
- `--allow-breaking`: authorize applying updates that contain breaking changes (required in non-interactive mode)
|
|
242
|
+
- `--non-interactive`: run without prompts; missing inputs fail instead of prompting
|
|
243
|
+
- `--json`: emit a structured JSON result on stdout
|
|
145
244
|
|
|
146
245
|
Important notes:
|
|
147
246
|
|
|
148
247
|
- You may need to resolve merge conflicts.
|
|
149
248
|
- If a template, base, or block is missing from the registry, BLOX prompts you to continue or stop.
|
|
249
|
+
- 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.
|
|
250
|
+
- BLOX runs non-interactively automatically when stdin is not a terminal (CI, agents, piped input).
|
|
150
251
|
|
|
151
252
|
### contribute
|
|
152
253
|
|
|
@@ -158,21 +259,71 @@ Usage:
|
|
|
158
259
|
blox contribute
|
|
159
260
|
```
|
|
160
261
|
|
|
262
|
+
Examples:
|
|
263
|
+
|
|
264
|
+
```sh
|
|
265
|
+
# Interactive: supplied flags are reused, missing inputs are prompted for
|
|
266
|
+
blox contribute --title "migrate template to pnpm"
|
|
267
|
+
|
|
268
|
+
# Non-interactive: all inputs supplied up front
|
|
269
|
+
blox contribute --non-interactive \
|
|
270
|
+
--commits abc123,def456 \
|
|
271
|
+
--targets template/ui-app-composable \
|
|
272
|
+
--commit-type build \
|
|
273
|
+
--title "migrate template to pnpm"
|
|
274
|
+
|
|
275
|
+
# Non-interactive: breaking-change contribution with JSON output
|
|
276
|
+
blox contribute --non-interactive --json \
|
|
277
|
+
--commits abc123 \
|
|
278
|
+
--targets block/auth \
|
|
279
|
+
--commit-type feat \
|
|
280
|
+
--title "drop legacy auth" \
|
|
281
|
+
--breaking \
|
|
282
|
+
--breaking-summary "Removed legacy auth API" \
|
|
283
|
+
--breaking-migration "Install pnpm 12.7.0 and run pnpm install"
|
|
284
|
+
|
|
285
|
+
# Non-interactive: multiple commits, comma- or whitespace-separated
|
|
286
|
+
blox contribute --non-interactive \
|
|
287
|
+
--commits "abc123 def456" \
|
|
288
|
+
--targets base/Base-A \
|
|
289
|
+
--commit-type build \
|
|
290
|
+
--title "migrate template to pnpm"
|
|
291
|
+
|
|
292
|
+
# Non-interactive: append commits to an existing contribution branch
|
|
293
|
+
blox contribute --non-interactive --existing \
|
|
294
|
+
--commits abc123 \
|
|
295
|
+
--targets template/ui-app-composable \
|
|
296
|
+
--title "migrate template to pnpm" \
|
|
297
|
+
--branch fix/migrate-template-to-pnpm
|
|
298
|
+
```
|
|
299
|
+
|
|
161
300
|
Important options:
|
|
162
301
|
|
|
163
302
|
- `--existing`: add changes to an existing contribution branch
|
|
164
303
|
- `--title <title>`: contribution title
|
|
165
304
|
- `--description <text>`: contribution description
|
|
166
|
-
- `--commits <commits>`:
|
|
167
|
-
- `--
|
|
305
|
+
- `--commits <commits>`: commit hashes from the app repo, separated by commas or whitespace
|
|
306
|
+
- `--targets <list>`: comma-separated contribution targets as `type/name` (e.g. `template/ui-app,block/auth`)
|
|
168
307
|
- `--type <type>`: target type (`template`, `base`, or `block`)
|
|
169
308
|
- `--name <name>`: target name (used with `--type`)
|
|
309
|
+
- `--commit-type <type>`: conventional commit type for new contributions
|
|
310
|
+
- `--breaking`: mark the contribution as a breaking change
|
|
311
|
+
- `--breaking-summary <summary>`: breaking-change summary (required with `--breaking`)
|
|
312
|
+
- `--breaking-migration <instructions>`: migration instructions (required with `--breaking`)
|
|
313
|
+
- `--branch <name>`: existing contribution branch (used with `--existing`)
|
|
314
|
+
- `--app <name>`: contribute the application `apps/<name>` repository instead of the workspace; inside an application directory this is implicit
|
|
315
|
+
- `--force`: bypass safety pre-flight checks
|
|
316
|
+
- `--non-interactive`: run without prompts; missing inputs fail instead of prompting
|
|
317
|
+
- `--json`: emit a machine-readable JSON result on stdout
|
|
170
318
|
|
|
171
319
|
Important notes:
|
|
172
320
|
|
|
173
|
-
- Without a matching `--type` and `--name`, BLOX lets you select one or more available targets. Press `s` in the target list to search.
|
|
321
|
+
- 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
322
|
- 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
323
|
- If a selected target has no registry source, BLOX reports it as skipped and continues with the remaining targets.
|
|
324
|
+
- Commit hashes must appear in the current app repo `HEAD` history; interactive selection lists commits from that same history.
|
|
325
|
+
- 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.
|
|
326
|
+
- 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
327
|
|
|
177
328
|
### conf
|
|
178
329
|
|
|
@@ -186,7 +337,15 @@ blox conf
|
|
|
186
337
|
|
|
187
338
|
Important options:
|
|
188
339
|
|
|
189
|
-
- `-r, --registries`: remote registry URLs
|
|
340
|
+
- `-r, --registries`: remote registry URLs (required in non-interactive mode)
|
|
341
|
+
- `--non-interactive`: run without prompts
|
|
342
|
+
- `--json`: emit a structured JSON result on stdout
|
|
343
|
+
|
|
344
|
+
Example:
|
|
345
|
+
|
|
346
|
+
```sh
|
|
347
|
+
blox conf --non-interactive --json --registries https://example.com/registry.git
|
|
348
|
+
```
|
|
190
349
|
|
|
191
350
|
### detach
|
|
192
351
|
|
|
@@ -201,6 +360,15 @@ blox detach
|
|
|
201
360
|
Important options:
|
|
202
361
|
|
|
203
362
|
- `--basic`: run detach only, without registry sync and migration first
|
|
363
|
+
- `--base <name>`: base to detach (required in non-interactive mode when the app declares more than one base)
|
|
364
|
+
- `--non-interactive`: run without prompts
|
|
365
|
+
- `--json`: emit a structured JSON result on stdout
|
|
366
|
+
|
|
367
|
+
Example:
|
|
368
|
+
|
|
369
|
+
```sh
|
|
370
|
+
blox detach --non-interactive --base my-base --json
|
|
371
|
+
```
|
|
204
372
|
|
|
205
373
|
### upgrade
|
|
206
374
|
|
|
@@ -209,9 +377,12 @@ Upgrade BLOX CLI to the latest version.
|
|
|
209
377
|
Usage:
|
|
210
378
|
|
|
211
379
|
```sh
|
|
212
|
-
blox upgrade
|
|
380
|
+
blox upgrade --non-interactive
|
|
381
|
+
blox upgrade --non-interactive --json
|
|
213
382
|
```
|
|
214
383
|
|
|
384
|
+
With `--json`, the successful result is `{ "success": true, "data": { "upgraded": true } }`.
|
|
385
|
+
|
|
215
386
|
### migrate
|
|
216
387
|
|
|
217
388
|
Migrate BLOX schema.
|
|
@@ -219,9 +390,12 @@ Migrate BLOX schema.
|
|
|
219
390
|
Usage:
|
|
220
391
|
|
|
221
392
|
```sh
|
|
222
|
-
blox migrate
|
|
393
|
+
blox migrate --non-interactive
|
|
394
|
+
blox migrate --non-interactive --json
|
|
223
395
|
```
|
|
224
396
|
|
|
397
|
+
With `--json`, the successful result is `{ "success": true, "data": { "migrated": true } }`.
|
|
398
|
+
|
|
225
399
|
### skills
|
|
226
400
|
|
|
227
401
|
Install and manage BLOX CLI skills (wraps `npx skills`).
|
|
@@ -236,6 +410,7 @@ Important notes:
|
|
|
236
410
|
|
|
237
411
|
- For `blox skills add`, BLOX injects the BLOX skills repository URL when you do not provide one.
|
|
238
412
|
- BLOX forwards the remaining arguments to `npx skills`.
|
|
413
|
+
- `blox skills` does not support the shared `--non-interactive` or `--json` flags; use options supported by the wrapped Skills CLI.
|
|
239
414
|
|
|
240
415
|
### doctor
|
|
241
416
|
|
|
@@ -251,6 +426,15 @@ blox doctor --fix
|
|
|
251
426
|
Options:
|
|
252
427
|
|
|
253
428
|
- `--fix`: attempt automatic repairs for findings that support them, then revalidate
|
|
429
|
+
- `--non-interactive`: run without prompts
|
|
430
|
+
- `--json`: emit the full report (diagnostics, repairs, check errors) as JSON on stdout
|
|
431
|
+
|
|
432
|
+
Examples:
|
|
433
|
+
|
|
434
|
+
```sh
|
|
435
|
+
blox doctor --non-interactive
|
|
436
|
+
blox doctor --non-interactive --fix --json
|
|
437
|
+
```
|
|
254
438
|
|
|
255
439
|
Exit codes:
|
|
256
440
|
|
|
@@ -260,6 +444,86 @@ Exit codes:
|
|
|
260
444
|
|
|
261
445
|
## Features
|
|
262
446
|
|
|
447
|
+
### Non-interactive Use and JSON Output
|
|
448
|
+
|
|
449
|
+
All commands except `blox skills` support two independent flags:
|
|
450
|
+
|
|
451
|
+
- **`--non-interactive`** controls interaction: nothing is ever prompted; missing required arguments are reported together and the command exits non-zero.
|
|
452
|
+
- **`--json`** controls output format: the CLI writes one JSON envelope to stdout while prompts, progress, warnings, and diagnostics go to stderr.
|
|
453
|
+
|
|
454
|
+
The flags combine freely:
|
|
455
|
+
|
|
456
|
+
| Invocation | Input behavior | Output behavior |
|
|
457
|
+
| -------------------------- | ------------------- | --------------- |
|
|
458
|
+
| (default) | prompts when needed | human-readable |
|
|
459
|
+
| `--json` | prompts when needed | JSON result |
|
|
460
|
+
| `--non-interactive` | never prompts | human-readable |
|
|
461
|
+
| `--non-interactive --json` | never prompts | JSON result |
|
|
462
|
+
|
|
463
|
+
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.
|
|
464
|
+
|
|
465
|
+
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:
|
|
466
|
+
|
|
467
|
+
| Command | Required in non-interactive mode |
|
|
468
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
469
|
+
| `init` | `--name`, `--template` |
|
|
470
|
+
| `add` | `blocks` arguments |
|
|
471
|
+
| `remove` | `blocks` arguments |
|
|
472
|
+
| `conf` | `--registries` |
|
|
473
|
+
| `detach` | `--base` (only when the app declares more than one base) |
|
|
474
|
+
| `update` | `--block` when `--scope block`; `--allow-breaking` to apply breaking changes |
|
|
475
|
+
| `contribute` | `--commits`, a target (`--targets` or `--type` + `--name`), `--title`, `--commit-type` (new contributions), `--branch` (`--existing`), `--breaking-summary` + `--breaking-migration` when `--breaking` |
|
|
476
|
+
| `migrate`, `upgrade`, `doctor` | none |
|
|
477
|
+
|
|
478
|
+
Decisions that would prompt interactively are authorized through explicit flags instead: `add --replace` / `add --rewrite-deps`, `update --allow-breaking`, `contribute --breaking*`.
|
|
479
|
+
|
|
480
|
+
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.
|
|
481
|
+
|
|
482
|
+
Successful result shapes differ by command. `update` returns update status and failed blocks:
|
|
483
|
+
|
|
484
|
+
```json
|
|
485
|
+
{
|
|
486
|
+
"success": true,
|
|
487
|
+
"data": {
|
|
488
|
+
"updated": true,
|
|
489
|
+
"stoppedEarly": false,
|
|
490
|
+
"failedBlocks": []
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
`contribute` reports a result for each requested target; fields such as `branch`, `prUrl`, `skipped`, and `error` depend on the result:
|
|
496
|
+
|
|
497
|
+
```json
|
|
498
|
+
{
|
|
499
|
+
"success": true,
|
|
500
|
+
"data": {
|
|
501
|
+
"results": [
|
|
502
|
+
{
|
|
503
|
+
"target": { "type": "base", "name": "Base-A" },
|
|
504
|
+
"success": true,
|
|
505
|
+
"branch": "build/migrate-template-to-pnpm",
|
|
506
|
+
"prUrl": "https://example.com/owner/repo/pull/123"
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
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`.
|
|
514
|
+
|
|
515
|
+
Exit code conventions:
|
|
516
|
+
|
|
517
|
+
| Code | Meaning |
|
|
518
|
+
| ---- | ---------------------------------------------------------------------------- |
|
|
519
|
+
| `0` | Success |
|
|
520
|
+
| `1` | General failure |
|
|
521
|
+
| `2` | Missing or invalid arguments |
|
|
522
|
+
| `3` | Resource not found |
|
|
523
|
+
| `4` | Permission or authorization failure |
|
|
524
|
+
| `5` | Contribution merge conflicts |
|
|
525
|
+
| `6` | Required approval missing (e.g. breaking changes without `--allow-breaking`) |
|
|
526
|
+
|
|
263
527
|
### Ignore Policy
|
|
264
528
|
|
|
265
529
|
Ignore rules tell BLOX which files or paths to skip.
|
|
@@ -278,9 +542,9 @@ Example root `.blox` configuration:
|
|
|
278
542
|
|
|
279
543
|
```json
|
|
280
544
|
{
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
545
|
+
"project": {
|
|
546
|
+
"ignore": ["applet-core", "dist/**", "*.generated.ts"]
|
|
547
|
+
}
|
|
284
548
|
}
|
|
285
549
|
```
|
|
286
550
|
|
|
@@ -332,7 +596,7 @@ npm install -D @naseej/blox
|
|
|
332
596
|
Import only from the SDK subpath:
|
|
333
597
|
|
|
334
598
|
```ts
|
|
335
|
-
import { input } from
|
|
599
|
+
import { input } from "@naseej/blox/sdk";
|
|
336
600
|
```
|
|
337
601
|
|
|
338
602
|
SDK API reference:
|