@naseej/blox 1.9.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 +5463 -1670
- package/dist/sdk.js +40 -0
- package/package.json +2 -2
- package/readme.md +300 -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naseej/blox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "blox cli",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./sdk": {
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"simple-git": "^4.0.2",
|
|
73
73
|
"tsup": "^8.0.2",
|
|
74
74
|
"tsx": "4.19.2",
|
|
75
|
-
"typescript": "^5.7.2",
|
|
76
75
|
"vite-tsconfig-paths": "^5.1.4",
|
|
77
76
|
"vitest": "2.1.8"
|
|
78
77
|
},
|
|
@@ -82,6 +81,7 @@
|
|
|
82
81
|
"@commander-js/extra-typings": "12.1.0",
|
|
83
82
|
"ansis": "3.3.2",
|
|
84
83
|
"commander": "12.1.0",
|
|
84
|
+
"typescript": "^5.7.2",
|
|
85
85
|
"cross-spawn": "^7.0.6",
|
|
86
86
|
"dayjs": "1.11.13",
|
|
87
87
|
"ejs": "^3.1.10",
|
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
|
|
@@ -50,6 +50,49 @@ Available commands:
|
|
|
50
50
|
- `blox migrate`: migrate BLOX schema state
|
|
51
51
|
- `blox upgrade`: upgrade BLOX CLI
|
|
52
52
|
- `blox skills`: run BLOX CLI skills commands
|
|
53
|
+
- `blox doctor`: diagnose and optionally repair BLOX workspace issues
|
|
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
|
+
```
|
|
53
96
|
|
|
54
97
|
### init
|
|
55
98
|
|
|
@@ -66,31 +109,53 @@ Important options:
|
|
|
66
109
|
- `-n, --name`: app name
|
|
67
110
|
- `-t, --template`: template to use
|
|
68
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
|
+
```
|
|
69
125
|
|
|
70
126
|
### add
|
|
71
127
|
|
|
72
|
-
Add one or more blocks to
|
|
128
|
+
Add one or more blocks or applications to a project.
|
|
73
129
|
|
|
74
130
|
Usage:
|
|
75
131
|
|
|
76
132
|
```sh
|
|
77
|
-
blox add [
|
|
133
|
+
blox add [components]
|
|
78
134
|
```
|
|
79
135
|
|
|
80
136
|
Example:
|
|
81
137
|
|
|
82
138
|
```sh
|
|
83
139
|
blox add components applet-template
|
|
140
|
+
blox add app/web
|
|
141
|
+
blox add components --app web
|
|
142
|
+
blox add --non-interactive --json components
|
|
84
143
|
```
|
|
85
144
|
|
|
86
145
|
Important options:
|
|
87
146
|
|
|
147
|
+
- `--app <name>`: add blocks inside the application `apps/<name>` instead of the root project
|
|
88
148
|
- `--branch`: branch name (applies to all selected blocks)
|
|
89
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
|
|
90
154
|
|
|
91
155
|
Important notes:
|
|
92
156
|
|
|
93
|
-
-
|
|
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`.
|
|
94
159
|
- Installed blocks are marked in the list and skipped if selected again, including blocks installed under a custom destination.
|
|
95
160
|
- Blocks are processed sequentially in the order provided.
|
|
96
161
|
- A failed block does not stop the remaining selections or roll back successful additions.
|
|
@@ -100,29 +165,37 @@ Important notes:
|
|
|
100
165
|
|
|
101
166
|
### remove
|
|
102
167
|
|
|
103
|
-
Remove one or more installed blocks.
|
|
168
|
+
Remove one or more installed blocks or applications.
|
|
104
169
|
|
|
105
170
|
Usage:
|
|
106
171
|
|
|
107
172
|
```sh
|
|
108
|
-
blox remove [
|
|
173
|
+
blox remove [components]
|
|
109
174
|
```
|
|
110
175
|
|
|
111
176
|
Example:
|
|
112
177
|
|
|
113
178
|
```sh
|
|
114
179
|
blox remove components applet-template
|
|
180
|
+
blox remove app/web
|
|
181
|
+
blox remove components --app web
|
|
182
|
+
blox remove --non-interactive --json components
|
|
115
183
|
```
|
|
116
184
|
|
|
117
185
|
Important options:
|
|
118
186
|
|
|
187
|
+
- `--app <name>`: remove blocks inside the application `apps/<name>` instead of the root project
|
|
119
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
|
|
120
191
|
|
|
121
192
|
Important notes:
|
|
122
193
|
|
|
123
|
-
-
|
|
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.
|
|
124
196
|
- You can pass registry keys or installed folder names under `blocks/`.
|
|
125
|
-
- 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.
|
|
126
199
|
- Blocks are processed sequentially in the order provided.
|
|
127
200
|
|
|
128
201
|
### update
|
|
@@ -135,17 +208,42 @@ Usage:
|
|
|
135
208
|
blox update
|
|
136
209
|
```
|
|
137
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
|
+
|
|
138
230
|
Important options:
|
|
139
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.
|
|
140
233
|
- `-s, --scope`: `app`, `bases`, `block`, or `all` (default: `all`)
|
|
141
234
|
- `-b, --block`: block to update (valid only when `--scope block`)
|
|
142
235
|
- `--ignore <list...>`: ignore patterns scoped by repo name, for example `repo:file`
|
|
143
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
|
|
144
240
|
|
|
145
241
|
Important notes:
|
|
146
242
|
|
|
147
243
|
- You may need to resolve merge conflicts.
|
|
148
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).
|
|
149
247
|
|
|
150
248
|
### contribute
|
|
151
249
|
|
|
@@ -157,21 +255,70 @@ Usage:
|
|
|
157
255
|
blox contribute
|
|
158
256
|
```
|
|
159
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
|
+
|
|
160
296
|
Important options:
|
|
161
297
|
|
|
162
298
|
- `--existing`: add changes to an existing contribution branch
|
|
163
299
|
- `--title <title>`: contribution title
|
|
164
300
|
- `--description <text>`: contribution description
|
|
165
|
-
- `--commits <commits>`:
|
|
166
|
-
- `--
|
|
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`)
|
|
167
303
|
- `--type <type>`: target type (`template`, `base`, or `block`)
|
|
168
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
|
|
169
313
|
|
|
170
314
|
Important notes:
|
|
171
315
|
|
|
172
|
-
- 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.
|
|
173
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.
|
|
174
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.
|
|
175
322
|
|
|
176
323
|
### conf
|
|
177
324
|
|
|
@@ -185,7 +332,15 @@ blox conf
|
|
|
185
332
|
|
|
186
333
|
Important options:
|
|
187
334
|
|
|
188
|
-
- `-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
|
+
```
|
|
189
344
|
|
|
190
345
|
### detach
|
|
191
346
|
|
|
@@ -200,6 +355,15 @@ blox detach
|
|
|
200
355
|
Important options:
|
|
201
356
|
|
|
202
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
|
+
```
|
|
203
367
|
|
|
204
368
|
### upgrade
|
|
205
369
|
|
|
@@ -208,9 +372,12 @@ Upgrade BLOX CLI to the latest version.
|
|
|
208
372
|
Usage:
|
|
209
373
|
|
|
210
374
|
```sh
|
|
211
|
-
blox upgrade
|
|
375
|
+
blox upgrade --non-interactive
|
|
376
|
+
blox upgrade --non-interactive --json
|
|
212
377
|
```
|
|
213
378
|
|
|
379
|
+
With `--json`, the successful result is `{ "success": true, "data": { "upgraded": true } }`.
|
|
380
|
+
|
|
214
381
|
### migrate
|
|
215
382
|
|
|
216
383
|
Migrate BLOX schema.
|
|
@@ -218,9 +385,12 @@ Migrate BLOX schema.
|
|
|
218
385
|
Usage:
|
|
219
386
|
|
|
220
387
|
```sh
|
|
221
|
-
blox migrate
|
|
388
|
+
blox migrate --non-interactive
|
|
389
|
+
blox migrate --non-interactive --json
|
|
222
390
|
```
|
|
223
391
|
|
|
392
|
+
With `--json`, the successful result is `{ "success": true, "data": { "migrated": true } }`.
|
|
393
|
+
|
|
224
394
|
### skills
|
|
225
395
|
|
|
226
396
|
Install and manage BLOX CLI skills (wraps `npx skills`).
|
|
@@ -235,9 +405,120 @@ Important notes:
|
|
|
235
405
|
|
|
236
406
|
- For `blox skills add`, BLOX injects the BLOX skills repository URL when you do not provide one.
|
|
237
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.
|
|
409
|
+
|
|
410
|
+
### doctor
|
|
411
|
+
|
|
412
|
+
Run diagnostic checks against the workspace and report findings as invalid, outdated, or informational. Ships with a `schema.validation` check that validates `.blox` files against the current schema; new checks plug into the same pipeline.
|
|
413
|
+
|
|
414
|
+
Usage:
|
|
415
|
+
|
|
416
|
+
```sh
|
|
417
|
+
blox doctor
|
|
418
|
+
blox doctor --fix
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Options:
|
|
422
|
+
|
|
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
|
+
```
|
|
433
|
+
|
|
434
|
+
Exit codes:
|
|
435
|
+
|
|
436
|
+
- `0`: checks completed with no unresolved invalid findings
|
|
437
|
+
- `1`: invalid findings remain, or a repair failed
|
|
438
|
+
- `2`: a check could not complete reliably
|
|
238
439
|
|
|
239
440
|
## Features
|
|
240
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
|
+
|
|
241
522
|
### Ignore Policy
|
|
242
523
|
|
|
243
524
|
Ignore rules tell BLOX which files or paths to skip.
|
|
@@ -256,9 +537,9 @@ Example root `.blox` configuration:
|
|
|
256
537
|
|
|
257
538
|
```json
|
|
258
539
|
{
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
540
|
+
"project": {
|
|
541
|
+
"ignore": ["applet-core", "dist/**", "*.generated.ts"]
|
|
542
|
+
}
|
|
262
543
|
}
|
|
263
544
|
```
|
|
264
545
|
|
|
@@ -310,7 +591,7 @@ npm install -D @naseej/blox
|
|
|
310
591
|
Import only from the SDK subpath:
|
|
311
592
|
|
|
312
593
|
```ts
|
|
313
|
-
import { input } from
|
|
594
|
+
import { input } from "@naseej/blox/sdk";
|
|
314
595
|
```
|
|
315
596
|
|
|
316
597
|
SDK API reference:
|