@naseej/blox 1.6.1 → 1.6.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/bin/run.ts +1 -1
- package/dist/run.js +124 -44
- package/package.json +1 -1
- package/readme.md +235 -178
package/bin/run.ts
CHANGED
|
@@ -11,7 +11,7 @@ async function main() {
|
|
|
11
11
|
cli.option('-d, --debug', 'work in debug mode');
|
|
12
12
|
cli.option('-m, --minimal', 'work in minimal mode');
|
|
13
13
|
|
|
14
|
-
await checkForCliUpdate(version);
|
|
14
|
+
await checkForCliUpdate(version, process.argv.slice(2));
|
|
15
15
|
|
|
16
16
|
commands.forEach((cmd) => cli.addCommand(cmd));
|
|
17
17
|
cli.parse();
|
package/dist/run.js
CHANGED
|
@@ -164,7 +164,21 @@ var compareVersions = (a, b) => {
|
|
|
164
164
|
}
|
|
165
165
|
return 0;
|
|
166
166
|
};
|
|
167
|
-
var
|
|
167
|
+
var _getInvokedCommand = (argv) => {
|
|
168
|
+
for (const token of argv) {
|
|
169
|
+
if (token === "--") {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
if (!token.startsWith("-")) {
|
|
173
|
+
return token;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
};
|
|
178
|
+
var checkForCliUpdate = async (currentVersion, argv = []) => {
|
|
179
|
+
if (_getInvokedCommand(argv) === "upgrade") {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
168
182
|
const cache = readCache();
|
|
169
183
|
const now = Date.now();
|
|
170
184
|
if (now - cache.lastChecked < checkIntervalMs) {
|
|
@@ -185,7 +199,7 @@ var checkForCliUpdate = async (currentVersion) => {
|
|
|
185
199
|
};
|
|
186
200
|
|
|
187
201
|
// package.json
|
|
188
|
-
var version = "1.6.
|
|
202
|
+
var version = "1.6.3";
|
|
189
203
|
|
|
190
204
|
// src/commands/add/index.ts
|
|
191
205
|
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
@@ -908,6 +922,16 @@ var listCommits = async (limit, skip, cwd = ".") => {
|
|
|
908
922
|
return { hash, subject: subjectRaw.trim() };
|
|
909
923
|
});
|
|
910
924
|
};
|
|
925
|
+
var listCommitsOldestFirst = async (cwd = ".") => {
|
|
926
|
+
let out = "";
|
|
927
|
+
await $("git", ["log", "--reverse", "--pretty=format:%H", "HEAD"], {
|
|
928
|
+
cwd,
|
|
929
|
+
onStdout: (text2) => {
|
|
930
|
+
out += text2;
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
return out.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
934
|
+
};
|
|
911
935
|
var fetchCommit = async (fromRepo, commit2, cwd = ".") => {
|
|
912
936
|
const ref = normalizeCommitRef(commit2);
|
|
913
937
|
await $("git", ["fetch", fromRepo, `+${ref}:FETCH_HEAD`], { cwd });
|
|
@@ -986,6 +1010,7 @@ var git = {
|
|
|
986
1010
|
checkoutFile,
|
|
987
1011
|
revertPathToHead,
|
|
988
1012
|
listCommits,
|
|
1013
|
+
listCommitsOldestFirst,
|
|
989
1014
|
fetchCommit,
|
|
990
1015
|
cherryPick,
|
|
991
1016
|
reset,
|
|
@@ -1162,6 +1187,13 @@ var upeToDate = false;
|
|
|
1162
1187
|
var cacheDirNameForRegistry = (registry) => {
|
|
1163
1188
|
return encodeURIComponent(registry).replace(/%/g, "_");
|
|
1164
1189
|
};
|
|
1190
|
+
var getConfiguredRegistryDirs = () => {
|
|
1191
|
+
const config = getLocalConfig();
|
|
1192
|
+
return config.registries.map((registry) => ({
|
|
1193
|
+
registry,
|
|
1194
|
+
dir: import_node_path12.default.join(registriesDataPath, cacheDirNameForRegistry(registry))
|
|
1195
|
+
}));
|
|
1196
|
+
};
|
|
1165
1197
|
var syncRegistries = async (branch) => {
|
|
1166
1198
|
if (upeToDate) return;
|
|
1167
1199
|
upeToDate = true;
|
|
@@ -1191,9 +1223,8 @@ var syncRegistries = async (branch) => {
|
|
|
1191
1223
|
var getAvailableTemplates = async () => {
|
|
1192
1224
|
debug("Get available templates");
|
|
1193
1225
|
const templates = {};
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
const indexPath = import_node_path12.default.join(registriesDataPath, registry, "index.json");
|
|
1226
|
+
for (const { dir } of getConfiguredRegistryDirs()) {
|
|
1227
|
+
const indexPath = import_node_path12.default.join(dir, "index.json");
|
|
1197
1228
|
if (import_fs_extra9.default.existsSync(indexPath)) {
|
|
1198
1229
|
const data = import_fs_extra9.default.readJSONSync(indexPath);
|
|
1199
1230
|
Object.entries(data.templates || {}).forEach(([templateName, template]) => {
|
|
@@ -1235,13 +1266,11 @@ var getAvailableBlocks = async (templateInfo) => {
|
|
|
1235
1266
|
return blocks;
|
|
1236
1267
|
};
|
|
1237
1268
|
var getAvailableVersions = async (source) => {
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1240
|
-
const registryPath = import_node_path12.default.join(registriesDataPath, registry);
|
|
1241
|
-
const indexPath = import_node_path12.default.join(registryPath, "index.json");
|
|
1269
|
+
for (const { dir } of getConfiguredRegistryDirs()) {
|
|
1270
|
+
const indexPath = import_node_path12.default.join(dir, "index.json");
|
|
1242
1271
|
if (!import_fs_extra9.default.existsSync(indexPath)) continue;
|
|
1243
1272
|
const registryData = import_fs_extra9.default.readJSONSync(indexPath);
|
|
1244
|
-
const versionDirPath = import_node_path12.default.join(
|
|
1273
|
+
const versionDirPath = import_node_path12.default.join(dir, "versions");
|
|
1245
1274
|
const versionsFilePaths = [
|
|
1246
1275
|
import_node_path12.default.join(versionDirPath, `${source.replace(`${registryData.baseUrl}/`, "")}.json`),
|
|
1247
1276
|
import_node_path12.default.join(versionDirPath, `${encodeURIComponent(source)}.json`)
|
|
@@ -1576,7 +1605,7 @@ var ContributionWorkflow = class {
|
|
|
1576
1605
|
await this.assertAppRepoClean();
|
|
1577
1606
|
const target = await this.targetSelector.selectTargetInteractive();
|
|
1578
1607
|
const mode = flags.existing ? "existing" : "new";
|
|
1579
|
-
const { title, description } = await this.
|
|
1608
|
+
const { title, description } = await this.promptContributionMeta(flags);
|
|
1580
1609
|
const commits = await this.resolveCommitsFromFlags(flags);
|
|
1581
1610
|
const branch = await this.resolveContributionBranch({ mode, target, title });
|
|
1582
1611
|
return this.run({
|
|
@@ -1663,19 +1692,17 @@ var ContributionWorkflow = class {
|
|
|
1663
1692
|
);
|
|
1664
1693
|
}
|
|
1665
1694
|
}
|
|
1666
|
-
async
|
|
1667
|
-
let title = flags.title;
|
|
1668
|
-
let description = flags.description;
|
|
1669
|
-
if (
|
|
1670
|
-
|
|
1671
|
-
title
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
description = await text({ message: "Description (optional)", defaultValue: "" });
|
|
1678
|
-
}
|
|
1695
|
+
async promptContributionMeta(flags) {
|
|
1696
|
+
let title = flags.title?.trim();
|
|
1697
|
+
let description = flags.description?.trim();
|
|
1698
|
+
if (!title) {
|
|
1699
|
+
title = await text({
|
|
1700
|
+
message: "Contribution title (conventional commit style recommended)",
|
|
1701
|
+
validate: (v) => v.trim() ? void 0 : "Title is required"
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
if (description === void 0) {
|
|
1705
|
+
description = await text({ message: "Description (optional)", defaultValue: "" });
|
|
1679
1706
|
}
|
|
1680
1707
|
return { title, description };
|
|
1681
1708
|
}
|
|
@@ -1833,6 +1860,23 @@ function getPathPrefixToStrip(target) {
|
|
|
1833
1860
|
return "";
|
|
1834
1861
|
}
|
|
1835
1862
|
|
|
1863
|
+
// src/services/contribute/utils/orderCommitsOldestToNewest.ts
|
|
1864
|
+
var orderCommitsOldestToNewest = (commits, history) => {
|
|
1865
|
+
const historyIndex = new Map(history.map((commit2, index) => [commit2, index]));
|
|
1866
|
+
const uniqueCommits = [...new Set(commits)];
|
|
1867
|
+
const missingCommits = uniqueCommits.filter((commit2) => !historyIndex.has(commit2));
|
|
1868
|
+
if (missingCommits.length) {
|
|
1869
|
+
throw new Error(
|
|
1870
|
+
`Unable to order commits because these hashes were not found in repo history: ${missingCommits.join(", ")}`
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1873
|
+
return uniqueCommits.sort((left, right) => {
|
|
1874
|
+
const leftIndex = historyIndex.get(left);
|
|
1875
|
+
const rightIndex = historyIndex.get(right);
|
|
1876
|
+
return leftIndex - rightIndex;
|
|
1877
|
+
});
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1836
1880
|
// src/services/contribute/utils/shouldExcludeFile.ts
|
|
1837
1881
|
function shouldExcludeFile(file, excludedPrefixes) {
|
|
1838
1882
|
const f = normalizePath(file);
|
|
@@ -1859,7 +1903,9 @@ var CommitApplierService = class {
|
|
|
1859
1903
|
projectIgnore
|
|
1860
1904
|
});
|
|
1861
1905
|
prepareSpinner.stop("Prepared apply commits");
|
|
1862
|
-
|
|
1906
|
+
const history = await git.listCommitsOldestFirst(opts.appRepoCwd);
|
|
1907
|
+
const orderedCommits = orderCommitsOldestToNewest(opts.commits, history);
|
|
1908
|
+
for (const commit2 of orderedCommits) {
|
|
1863
1909
|
await this.applySingleCommit(
|
|
1864
1910
|
opts,
|
|
1865
1911
|
subtreePath,
|
|
@@ -3081,6 +3127,12 @@ It has been recreated to apply upstream changes.`
|
|
|
3081
3127
|
}
|
|
3082
3128
|
|
|
3083
3129
|
// src/commands/update/utils.ts
|
|
3130
|
+
async function confirmContinueWhenMissing(itemType, name) {
|
|
3131
|
+
return confirm({
|
|
3132
|
+
message: `${itemType}: ${name} does not exist in registries. Continue updating remaining parts?`,
|
|
3133
|
+
initialValue: true
|
|
3134
|
+
});
|
|
3135
|
+
}
|
|
3084
3136
|
async function updateApp({
|
|
3085
3137
|
templateDef,
|
|
3086
3138
|
templates,
|
|
@@ -3090,10 +3142,14 @@ async function updateApp({
|
|
|
3090
3142
|
hard = false
|
|
3091
3143
|
}) {
|
|
3092
3144
|
let updated = false;
|
|
3145
|
+
let shouldContinue = true;
|
|
3093
3146
|
await runTask({ start: "Update App", end: "Updated App" }, async () => {
|
|
3094
3147
|
const template = templates[templateDef.name];
|
|
3095
3148
|
if (!template) {
|
|
3096
|
-
|
|
3149
|
+
shouldContinue = await confirmContinueWhenMissing(
|
|
3150
|
+
"template" /* TEMPLATE */,
|
|
3151
|
+
templateDef.name
|
|
3152
|
+
);
|
|
3097
3153
|
return;
|
|
3098
3154
|
}
|
|
3099
3155
|
const toAppCommit = await updateFromRemote({
|
|
@@ -3107,7 +3163,14 @@ async function updateApp({
|
|
|
3107
3163
|
if (!templateDef.bases?.length) return;
|
|
3108
3164
|
for (const block of usedBlocks) {
|
|
3109
3165
|
const blockRegistryData = availableBlocks[block.name];
|
|
3110
|
-
if (!blockRegistryData)
|
|
3166
|
+
if (!blockRegistryData) {
|
|
3167
|
+
shouldContinue = await confirmContinueWhenMissing(
|
|
3168
|
+
"block" /* BLOCK */,
|
|
3169
|
+
block.name
|
|
3170
|
+
);
|
|
3171
|
+
if (!shouldContinue) return;
|
|
3172
|
+
continue;
|
|
3173
|
+
}
|
|
3111
3174
|
await git.updateRemote(block.name, blockRegistryData.source);
|
|
3112
3175
|
const blockPath = import_node_path22.default.join(blocksDir, block.name);
|
|
3113
3176
|
const currentBloxFile = getBloxFile(blockPath);
|
|
@@ -3124,17 +3187,21 @@ async function updateApp({
|
|
|
3124
3187
|
}
|
|
3125
3188
|
}
|
|
3126
3189
|
});
|
|
3127
|
-
return updated;
|
|
3190
|
+
return { updated, shouldContinue };
|
|
3128
3191
|
}
|
|
3129
3192
|
async function updateAppBases(templateDef, templates, ignore3, hard = false) {
|
|
3130
3193
|
let updated = false;
|
|
3194
|
+
let shouldContinue = true;
|
|
3131
3195
|
for (const base of templateDef.bases || []) {
|
|
3132
3196
|
await runTask(
|
|
3133
3197
|
{ start: `Update App base: ${base.name}`, end: `Updated App base: ${base.name}` },
|
|
3134
3198
|
async () => {
|
|
3135
3199
|
const template = templates[base.name];
|
|
3136
3200
|
if (!template) {
|
|
3137
|
-
|
|
3201
|
+
shouldContinue = await confirmContinueWhenMissing(
|
|
3202
|
+
"base" /* BASE */,
|
|
3203
|
+
base.name
|
|
3204
|
+
);
|
|
3138
3205
|
return;
|
|
3139
3206
|
}
|
|
3140
3207
|
const toCommit = await updateFromRemote({
|
|
@@ -3146,16 +3213,18 @@ async function updateAppBases(templateDef, templates, ignore3, hard = false) {
|
|
|
3146
3213
|
if (toCommit) updated = true;
|
|
3147
3214
|
}
|
|
3148
3215
|
);
|
|
3216
|
+
if (!shouldContinue) break;
|
|
3149
3217
|
}
|
|
3150
|
-
return updated;
|
|
3218
|
+
return { updated, shouldContinue };
|
|
3151
3219
|
}
|
|
3152
3220
|
async function updateBlock(block, blocks, ignore3, hard = false) {
|
|
3153
3221
|
const blockRegistryData = blocks[block];
|
|
3154
3222
|
const blockPath = import_node_path22.default.join(blocksDir, block);
|
|
3155
3223
|
let updated = false;
|
|
3224
|
+
let shouldContinue = true;
|
|
3156
3225
|
await runTask({ start: `Update block: ${block}`, end: `Updated block: ${block}` }, async () => {
|
|
3157
3226
|
if (!blockRegistryData) {
|
|
3158
|
-
|
|
3227
|
+
shouldContinue = await confirmContinueWhenMissing("block" /* BLOCK */, block);
|
|
3159
3228
|
return;
|
|
3160
3229
|
}
|
|
3161
3230
|
const toCommit = await updateFromRemote({
|
|
@@ -3170,7 +3239,7 @@ async function updateBlock(block, blocks, ignore3, hard = false) {
|
|
|
3170
3239
|
if (updated) {
|
|
3171
3240
|
await runLifecycleHookWithTask(blockPath, "update", "Run block update");
|
|
3172
3241
|
}
|
|
3173
|
-
return updated;
|
|
3242
|
+
return { updated, shouldContinue };
|
|
3174
3243
|
}
|
|
3175
3244
|
async function getCurrentCheckpoints() {
|
|
3176
3245
|
const bloxFile = getBloxFile();
|
|
@@ -3236,8 +3305,9 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
3236
3305
|
}
|
|
3237
3306
|
try {
|
|
3238
3307
|
let hasUpdate = false;
|
|
3308
|
+
let shouldContinue = true;
|
|
3239
3309
|
if (["app", "all"].includes(args.scope)) {
|
|
3240
|
-
const
|
|
3310
|
+
const appResult = await updateApp({
|
|
3241
3311
|
templateDef,
|
|
3242
3312
|
templates,
|
|
3243
3313
|
usedBlocks,
|
|
@@ -3245,29 +3315,35 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
3245
3315
|
ignore: ignoresByName[templateDef.name],
|
|
3246
3316
|
hard: args.hard
|
|
3247
3317
|
});
|
|
3248
|
-
hasUpdate = hasUpdate ||
|
|
3318
|
+
hasUpdate = hasUpdate || appResult.updated;
|
|
3319
|
+
shouldContinue = appResult.shouldContinue;
|
|
3249
3320
|
}
|
|
3250
|
-
if (["bases", "all"].includes(args.scope)) {
|
|
3251
|
-
const
|
|
3321
|
+
if (shouldContinue && ["bases", "all"].includes(args.scope)) {
|
|
3322
|
+
const basesResult = await updateAppBases(
|
|
3252
3323
|
templateDef,
|
|
3253
3324
|
templates,
|
|
3254
3325
|
ignoresByName[templateDef.name],
|
|
3255
3326
|
args.hard
|
|
3256
3327
|
);
|
|
3257
|
-
hasUpdate = hasUpdate ||
|
|
3328
|
+
hasUpdate = hasUpdate || basesResult.updated;
|
|
3329
|
+
shouldContinue = basesResult.shouldContinue;
|
|
3258
3330
|
}
|
|
3259
|
-
if (args.scope === "all") {
|
|
3331
|
+
if (shouldContinue && args.scope === "all") {
|
|
3260
3332
|
for (const block of usedBlocks) {
|
|
3261
|
-
const
|
|
3333
|
+
const blockResult = await updateBlock(
|
|
3262
3334
|
block.name,
|
|
3263
3335
|
availableBlocks,
|
|
3264
3336
|
ignoresByName[block.name],
|
|
3265
3337
|
args.hard
|
|
3266
3338
|
);
|
|
3267
|
-
hasUpdate = hasUpdate ||
|
|
3339
|
+
hasUpdate = hasUpdate || blockResult.updated;
|
|
3340
|
+
if (!blockResult.shouldContinue) {
|
|
3341
|
+
shouldContinue = false;
|
|
3342
|
+
break;
|
|
3343
|
+
}
|
|
3268
3344
|
}
|
|
3269
3345
|
}
|
|
3270
|
-
if (args.scope === "block") {
|
|
3346
|
+
if (shouldContinue && args.scope === "block") {
|
|
3271
3347
|
if (!args.block) {
|
|
3272
3348
|
args.block = await select({
|
|
3273
3349
|
message: "Select block to be updated",
|
|
@@ -3282,13 +3358,17 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
3282
3358
|
error("Selected block not used in app");
|
|
3283
3359
|
return;
|
|
3284
3360
|
}
|
|
3285
|
-
const
|
|
3361
|
+
const blockResult = await updateBlock(
|
|
3286
3362
|
blockDef.name,
|
|
3287
3363
|
availableBlocks,
|
|
3288
3364
|
ignoresByName[blockDef.name],
|
|
3289
3365
|
args.hard
|
|
3290
3366
|
);
|
|
3291
|
-
hasUpdate = hasUpdate ||
|
|
3367
|
+
hasUpdate = hasUpdate || blockResult.updated;
|
|
3368
|
+
shouldContinue = blockResult.shouldContinue;
|
|
3369
|
+
}
|
|
3370
|
+
if (!shouldContinue) {
|
|
3371
|
+
import_prompts23.log.warn(fmt.yellow("Stopped updating remaining parts by user choice"));
|
|
3292
3372
|
}
|
|
3293
3373
|
if (hasUpdate) {
|
|
3294
3374
|
await runLifecycleHookWithTask(".", "update", "Run template update");
|
|
@@ -3337,7 +3417,7 @@ async function main() {
|
|
|
3337
3417
|
import_extra_typings2.program.name("blox").version(version);
|
|
3338
3418
|
import_extra_typings2.program.option("-d, --debug", "work in debug mode");
|
|
3339
3419
|
import_extra_typings2.program.option("-m, --minimal", "work in minimal mode");
|
|
3340
|
-
await checkForCliUpdate(version);
|
|
3420
|
+
await checkForCliUpdate(version, process.argv.slice(2));
|
|
3341
3421
|
commands.forEach((cmd) => import_extra_typings2.program.addCommand(cmd));
|
|
3342
3422
|
import_extra_typings2.program.parse();
|
|
3343
3423
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,284 +1,341 @@
|
|
|
1
1
|
# BLOX CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
BLOX CLI helps you bootstrap, manage, update, and contribute BLOX-based apps and blocks.
|
|
4
|
+
|
|
5
|
+
## Content
|
|
6
|
+
|
|
7
|
+
- [BLOX CLI](#blox-cli)
|
|
8
|
+
- [Content](#content)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Quick Start](#quick-start)
|
|
11
|
+
- [Commands](#commands)
|
|
12
|
+
- [init](#init)
|
|
13
|
+
- [add](#add)
|
|
14
|
+
- [remove](#remove)
|
|
15
|
+
- [update](#update)
|
|
16
|
+
- [contribute](#contribute)
|
|
17
|
+
- [conf](#conf)
|
|
18
|
+
- [upgrade](#upgrade)
|
|
19
|
+
- [migrate](#migrate)
|
|
20
|
+
- [skills](#skills)
|
|
21
|
+
- [Features](#features)
|
|
22
|
+
- [Ignore Policy](#ignore-policy)
|
|
23
|
+
- [Lifecycle Hooks](#lifecycle-hooks)
|
|
24
|
+
- [Skills](#skills-1)
|
|
25
|
+
- [Installing Skills](#installing-skills)
|
|
26
|
+
- [CLI Compatibility](#cli-compatibility)
|
|
27
|
+
- [Common Commands](#common-commands)
|
|
28
|
+
- [Compatibility](#compatibility)
|
|
29
|
+
- [Create new template](#create-new-template)
|
|
30
|
+
- [1 - Initialize from an existing template](#1---initialize-from-an-existing-template)
|
|
31
|
+
- [2 - Update `.blox` configuration](#2---update-blox-configuration)
|
|
32
|
+
- [3 - Publish and register the template](#3---publish-and-register-the-template)
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Install globally with npm:
|
|
4
37
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
38
|
+
```sh
|
|
39
|
+
npm install -g patch-package @naseej/blox
|
|
40
|
+
```
|
|
8
41
|
|
|
9
|
-
|
|
42
|
+
Notes:
|
|
10
43
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```
|
|
44
|
+
- Ensure npm is available in your `PATH`.
|
|
45
|
+
- Use minimal mode (`-m`, `--minimal`) if spinners interfere with interactive input.
|
|
14
46
|
|
|
15
|
-
|
|
47
|
+
## Quick Start
|
|
16
48
|
|
|
17
|
-
|
|
49
|
+
Start with the core commands:
|
|
18
50
|
|
|
19
51
|
```sh
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
BLOX CLI
|
|
25
|
-
|
|
26
|
-
Commands:
|
|
27
|
-
blox init Init new app [alias: i]
|
|
28
|
-
blox add Add block to app [alias: a]
|
|
29
|
-
blox remove Remove block from app [alias: rm]
|
|
30
|
-
blox update Update app/block [alias: u]
|
|
31
|
-
blox contribute Contribute changes to template/base/block repos [alias: cb]
|
|
32
|
-
blox conf Set blox global config [alias: c]
|
|
33
|
-
blox upgrade Upgrade blox cli to latest version
|
|
34
|
-
blox migrate Migrate blox schema
|
|
35
|
-
blox detach Detach to base
|
|
36
|
-
blox skills Install and manage BLOX CLI skills (wraps npx skills)
|
|
37
|
-
|
|
38
|
-
Options:
|
|
39
|
-
-V, --version Show version number [boolean]
|
|
40
|
-
-h, --help Show help [boolean]
|
|
41
|
-
-d, --debug Works in debug mode [boolean]
|
|
42
|
-
-m, --minimal Works in minimal mode [boolean]
|
|
52
|
+
blox --help
|
|
53
|
+
blox init
|
|
54
|
+
blox add
|
|
55
|
+
blox update
|
|
43
56
|
```
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
## Commands
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
Other available command:
|
|
48
61
|
|
|
49
|
-
-
|
|
50
|
-
- [add](#add)
|
|
51
|
-
- [remove](#remove)
|
|
52
|
-
- [update](#update)
|
|
53
|
-
- [contribute](#contribute)
|
|
54
|
-
- [conf](#conf)
|
|
55
|
-
- [upgrade](#upgrade)
|
|
56
|
-
- [migrate](#migrate)
|
|
57
|
-
- [skills](#installing-blox-cli-skills)
|
|
62
|
+
- `blox detach`: detach to base
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
### init
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
Initialize a new app.
|
|
62
67
|
|
|
63
|
-
|
|
68
|
+
Usage:
|
|
64
69
|
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
"project": {
|
|
68
|
-
"ignore": ["applet-core", "dist/**", "*.generated.ts"]
|
|
69
|
-
}
|
|
70
|
-
}
|
|
70
|
+
```sh
|
|
71
|
+
blox init
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
Important options:
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
- `-n, --name`: app name
|
|
77
|
+
- `-t, --template`: template to use
|
|
78
|
+
- `--branch`: branch name to use
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
- `project.ignore`: local to your app (you control it).
|
|
80
|
+
### add
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
Add one or more blocks to an app.
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
- local project ignore (`project.ignore` in your local `.blox`)
|
|
84
|
-
- local `.gitignore`
|
|
85
|
-
- command option `--ignore` (when provided)
|
|
84
|
+
Usage:
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
```sh
|
|
87
|
+
blox add [blocks]
|
|
88
|
+
```
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
Example:
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
```sh
|
|
93
|
+
blox add components applet-template
|
|
94
|
+
```
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
- each **block** (`blocks/<name>/.blox`)
|
|
96
|
+
Important options:
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
- `--branch`: branch name (applies to all selected blocks)
|
|
99
|
+
- `--dest`: destination directory (applies to all selected blocks)
|
|
99
100
|
|
|
100
|
-
|
|
101
|
+
Important notes:
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
| `init` | Runs after`blox init` finishes creating the app. | Runs after a new block is cloned and initialized, before its dependencies are added. |
|
|
105
|
-
| `add` | Runs once per `blox add` command, but only if at least one new block was added (including dependencies). | Runs when the block is added , right after the `init` hook for that new block, still before dependencies. |
|
|
106
|
-
| `update` | After `blox update` when the **root template** or a **base** or a **block** remote actually advanced (new commit applied). | Only when that block’s remote actually advanced (new commit). Skipped if already up to date. |
|
|
107
|
-
| `remove` | After `blox remove` actually removed a block in that run. | Runs before the block is deleted, while its files still exist. |
|
|
103
|
+
- If `blocks` are omitted, BLOX prompts with a multiselect from available blocks.
|
|
104
|
+
- Blocks are processed sequentially in the order provided.
|
|
108
105
|
|
|
109
|
-
|
|
106
|
+
### remove
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
blox init --help
|
|
113
|
-
```
|
|
108
|
+
Remove one or more installed blocks.
|
|
114
109
|
|
|
115
|
-
|
|
116
|
-
blox init
|
|
110
|
+
Usage:
|
|
117
111
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Options:
|
|
121
|
-
-n, --name App name
|
|
122
|
-
-t, --template Template to use
|
|
123
|
-
--branch, branch name to use
|
|
112
|
+
```sh
|
|
113
|
+
blox remove [blocks]
|
|
124
114
|
```
|
|
125
115
|
|
|
126
|
-
|
|
116
|
+
Example:
|
|
127
117
|
|
|
128
118
|
```sh
|
|
129
|
-
|
|
119
|
+
blox remove components applet-template
|
|
130
120
|
```
|
|
131
121
|
|
|
132
|
-
|
|
133
|
-
blox add [blocks]
|
|
122
|
+
Important options:
|
|
134
123
|
|
|
135
|
-
|
|
124
|
+
- `-f, --force`: remove even when other blocks depend on them
|
|
136
125
|
|
|
137
|
-
|
|
138
|
-
blocks Block names separated by space (optional; if omitted, prompts with multiselect from available blocks)
|
|
126
|
+
Important notes:
|
|
139
127
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
- You can add multiple blocks in one command, for example: `blox add components applet-template`.
|
|
128
|
+
- If `blocks` are omitted, BLOX prompts with a multiselect from installed blocks.
|
|
129
|
+
- You can pass registry keys or installed folder names under `blocks/`.
|
|
130
|
+
- Only directories under `blocks/` containing a valid `.blox` file are treated as removable blocks.
|
|
146
131
|
- Blocks are processed sequentially in the order provided.
|
|
147
132
|
|
|
148
|
-
|
|
133
|
+
### update
|
|
134
|
+
|
|
135
|
+
Update the app, bases, or specific blocks.
|
|
136
|
+
|
|
137
|
+
Usage:
|
|
149
138
|
|
|
150
139
|
```sh
|
|
151
|
-
|
|
140
|
+
blox update
|
|
152
141
|
```
|
|
153
142
|
|
|
154
|
-
|
|
155
|
-
blox remove [blocks]
|
|
143
|
+
Important options:
|
|
156
144
|
|
|
157
|
-
|
|
145
|
+
- `-s, --scope`: `app`, `bases`, `block`, or `all` (default: `all`)
|
|
146
|
+
- `-b, --block`: block to update (valid only when `--scope block`)
|
|
158
147
|
|
|
159
|
-
|
|
160
|
-
blocks Blocks to remove separated by space — registry keys or installed folder names under blocks/ (optional; prompts with multiselect from installed blocks)
|
|
148
|
+
Important notes:
|
|
161
149
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
```
|
|
150
|
+
- You may need to resolve merge conflicts.
|
|
151
|
+
- If a template, base, or block is missing from the registry, BLOX prompts you to continue or stop.
|
|
165
152
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
153
|
+
### contribute
|
|
154
|
+
|
|
155
|
+
Contribute app changes back to template/base/block repositories.
|
|
169
156
|
|
|
170
|
-
|
|
157
|
+
Usage:
|
|
171
158
|
|
|
172
159
|
```sh
|
|
173
|
-
|
|
160
|
+
blox contribute
|
|
174
161
|
```
|
|
175
162
|
|
|
176
|
-
|
|
177
|
-
blox update
|
|
163
|
+
Important options:
|
|
178
164
|
|
|
179
|
-
|
|
165
|
+
- `--existing`: add changes to an existing contribution branch
|
|
166
|
+
- `--title <title>`: contribution title
|
|
167
|
+
- `--description <text>`: contribution description
|
|
168
|
+
- `--commits <commits>`: comma-separated commit hashes from the app repo
|
|
169
|
+
- `--force`: bypass safety pre-flight checks
|
|
170
|
+
- `--type <type>`: target type (`template`, `base`, or `block`)
|
|
171
|
+
- `--name <name>`: target name (used with `--type`)
|
|
180
172
|
|
|
181
|
-
|
|
182
|
-
-s, --scope Scope of update [choices: "app", "bases", "block", "all"] [default: "all"]
|
|
183
|
-
-b, --block Block to update, valid only with scope block
|
|
184
|
-
```
|
|
173
|
+
### conf
|
|
185
174
|
|
|
186
|
-
|
|
175
|
+
Set global BLOX configuration.
|
|
187
176
|
|
|
188
|
-
|
|
177
|
+
Usage:
|
|
189
178
|
|
|
190
179
|
```sh
|
|
191
|
-
|
|
180
|
+
blox conf
|
|
192
181
|
```
|
|
193
182
|
|
|
194
|
-
|
|
195
|
-
blox contribute
|
|
183
|
+
Important options:
|
|
196
184
|
|
|
197
|
-
|
|
185
|
+
- `-r, --registries`: remote registry URLs
|
|
198
186
|
|
|
199
|
-
|
|
200
|
-
--existing Add changes to an existing contribution branch
|
|
201
|
-
--title <title> Contribution title
|
|
202
|
-
--description <text> Contribution description
|
|
203
|
-
--commits <commits> Comma-separated commit hashes from the app repo
|
|
204
|
-
--force Bypass safety pre-flight checks
|
|
205
|
-
--type <type> Target: template | base | block
|
|
206
|
-
--name <name> Target name (with --type)
|
|
207
|
-
```
|
|
187
|
+
### upgrade
|
|
208
188
|
|
|
209
|
-
|
|
189
|
+
Upgrade BLOX CLI to the latest version.
|
|
210
190
|
|
|
211
|
-
|
|
212
|
-
blox sync --help
|
|
213
|
-
```
|
|
191
|
+
Usage:
|
|
214
192
|
|
|
193
|
+
```sh
|
|
194
|
+
blox upgrade
|
|
215
195
|
```
|
|
216
|
-
blox conf
|
|
217
196
|
|
|
218
|
-
|
|
197
|
+
### migrate
|
|
219
198
|
|
|
220
|
-
|
|
221
|
-
-r, --registries Remote registries urls
|
|
222
|
-
```
|
|
199
|
+
Migrate BLOX schema.
|
|
223
200
|
|
|
224
|
-
|
|
201
|
+
Usage:
|
|
225
202
|
|
|
226
203
|
```sh
|
|
227
|
-
|
|
204
|
+
blox migrate
|
|
228
205
|
```
|
|
229
206
|
|
|
230
|
-
|
|
231
|
-
blox upgrade
|
|
207
|
+
### skills
|
|
232
208
|
|
|
233
|
-
|
|
234
|
-
```
|
|
209
|
+
Install and manage BLOX CLI skills (wraps `npx skills`).
|
|
235
210
|
|
|
236
|
-
|
|
211
|
+
Usage:
|
|
237
212
|
|
|
238
213
|
```sh
|
|
239
|
-
|
|
214
|
+
blox skills <command> [options]
|
|
240
215
|
```
|
|
241
216
|
|
|
242
|
-
|
|
243
|
-
blox migrate
|
|
217
|
+
Important notes:
|
|
244
218
|
|
|
245
|
-
|
|
246
|
-
|
|
219
|
+
- BLOX clones the BLOX CLI skills repository, runs `npx skills` with your arguments, then cleans up.
|
|
220
|
+
- No repository URL is required.
|
|
247
221
|
|
|
248
|
-
##
|
|
222
|
+
## Features
|
|
249
223
|
|
|
250
|
-
|
|
224
|
+
### Ignore Policy
|
|
251
225
|
|
|
252
|
-
|
|
226
|
+
Ignore rules tell BLOX which files or paths to skip.
|
|
253
227
|
|
|
254
|
-
|
|
228
|
+
Template-level ignore:
|
|
255
229
|
|
|
256
|
-
|
|
230
|
+
- Defined in `definition.ignore`.
|
|
231
|
+
- Comes from template/block maintainers.
|
|
257
232
|
|
|
258
|
-
|
|
233
|
+
App-level ignore:
|
|
259
234
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
```
|
|
235
|
+
- Defined in `project.ignore`.
|
|
236
|
+
- Local to your app and controlled by you.
|
|
263
237
|
|
|
264
|
-
|
|
238
|
+
Example root `.blox` configuration:
|
|
265
239
|
|
|
266
|
-
```
|
|
267
|
-
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"project": {
|
|
243
|
+
"ignore": ["applet-core", "dist/**", "*.generated.ts"]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
268
246
|
```
|
|
269
247
|
|
|
270
|
-
|
|
248
|
+
How ignore sources are combined:
|
|
249
|
+
|
|
250
|
+
- `blox update` combines patterns from:
|
|
251
|
+
- remote template ignore (`definition.ignore`)
|
|
252
|
+
- local project ignore (`project.ignore` in local `.blox`)
|
|
253
|
+
- local `.gitignore`
|
|
254
|
+
- command option `--ignore` (when provided)
|
|
255
|
+
- `blox contribute` also respects local `project.ignore`.
|
|
256
|
+
- Local `project.ignore` is project-owned and is not replaced by remote template ignore during update.
|
|
257
|
+
|
|
258
|
+
### Lifecycle Hooks
|
|
259
|
+
|
|
260
|
+
Lifecycle hooks are optional shell commands defined in `.blox` files.
|
|
261
|
+
|
|
262
|
+
Where hooks can be defined:
|
|
263
|
+
|
|
264
|
+
- Root template: `.blox` at app root
|
|
265
|
+
- Each block: `blocks/<name>/.blox`
|
|
266
|
+
|
|
267
|
+
Supported hooks:
|
|
268
|
+
|
|
269
|
+
- `init`
|
|
270
|
+
- `add`
|
|
271
|
+
- `update`
|
|
272
|
+
- `remove`
|
|
273
|
+
|
|
274
|
+
When hooks run:
|
|
275
|
+
|
|
276
|
+
| Hook | Template (root `.blox`) | Block (`blocks/.../.blox`) |
|
|
277
|
+
| -------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
|
|
278
|
+
| `init` | Runs after `blox init` finishes creating the app. | Runs after a new block is cloned and initialized, before its dependencies are added. |
|
|
279
|
+
| `add` | Runs once per `blox add` command, only if at least one new block was added (including dependencies). | Runs when the block is added, right after that new block's `init` hook, still before dependencies. |
|
|
280
|
+
| `update` | Runs after `blox update` when the root template, a base, or a block remote actually advanced (new commit applied). | Runs only when that block's remote actually advanced (new commit). Skipped if already up to date. |
|
|
281
|
+
| `remove` | Runs after `blox remove` actually removed a block in that run. | Runs before the block is deleted, while its files still exist. |
|
|
282
|
+
|
|
283
|
+
### Skills
|
|
284
|
+
|
|
285
|
+
#### Installing Skills
|
|
286
|
+
|
|
287
|
+
Use `blox skills` to run the Skills CLI against the BLOX CLI skills repository.
|
|
288
|
+
|
|
289
|
+
Behavior:
|
|
290
|
+
|
|
291
|
+
- BLOX executes `npx skills` with all arguments passed after `skills`.
|
|
292
|
+
- BLOX handles cloning and cleanup automatically.
|
|
293
|
+
|
|
294
|
+
#### CLI Compatibility
|
|
295
|
+
|
|
296
|
+
Skills declare a `cliCompatibility` range in `skill.json` (npm semver).
|
|
297
|
+
|
|
298
|
+
For `blox skills add` and `blox skills update`:
|
|
299
|
+
|
|
300
|
+
- BLOX checks whether your installed CLI version satisfies the required range.
|
|
301
|
+
- If not, BLOX shows the required range and your current version.
|
|
302
|
+
- You can choose to continue or exit and run `blox upgrade` first.
|
|
303
|
+
|
|
304
|
+
#### Common Commands
|
|
271
305
|
|
|
272
306
|
```bash
|
|
307
|
+
blox skills add
|
|
308
|
+
blox skills add -a cursor -y
|
|
273
309
|
blox skills add -a cursor -a claude-code -y
|
|
310
|
+
blox skills list
|
|
274
311
|
```
|
|
275
312
|
|
|
276
|
-
|
|
313
|
+
#### Compatibility
|
|
277
314
|
|
|
278
|
-
|
|
279
|
-
|
|
315
|
+
Skills are not tied to a specific editor or product. They work across tools that support skill-style instructions, and metadata marks agents as `generic` for broad use.
|
|
316
|
+
|
|
317
|
+
### Create new template
|
|
318
|
+
|
|
319
|
+
Create a new template by starting from an existing one, updating its metadata, then publishing it.
|
|
320
|
+
|
|
321
|
+
#### 1 - Initialize from an existing template
|
|
322
|
+
|
|
323
|
+
Create a new project using the template you want to build on.
|
|
324
|
+
|
|
325
|
+
Example:
|
|
326
|
+
|
|
327
|
+
```sh
|
|
328
|
+
blox init -n my-template -t existing-template
|
|
280
329
|
```
|
|
281
330
|
|
|
282
|
-
|
|
331
|
+
#### 2 - Update `.blox` configuration
|
|
332
|
+
|
|
333
|
+
Edit your project's `.blox` file to describe the new template.
|
|
334
|
+
|
|
335
|
+
- Set `definition.name` to your new template name.
|
|
336
|
+
- Keep the original template in the `bases` list so you can continue receiving updates from it.
|
|
337
|
+
|
|
338
|
+
#### 3 - Publish and register the template
|
|
283
339
|
|
|
284
|
-
|
|
340
|
+
- Push the template project to a remote repository.
|
|
341
|
+
- Add that repository to a BLOX registry (Or any custom registry) so BLOX CLI can discover and use your template.
|