@naseej/blox 1.7.0 → 1.8.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.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/run.js CHANGED
@@ -201,7 +201,7 @@ var checkForCliUpdate = async (currentVersion, argv = []) => {
201
201
  };
202
202
 
203
203
  // package.json
204
- var version = "1.7.0";
204
+ var version = "1.8.0";
205
205
 
206
206
  // src/commands/add/index.ts
207
207
  var import_fs_extra11 = __toESM(require("fs-extra"));
@@ -577,12 +577,22 @@ var import_prompts3 = require("@clack/prompts");
577
577
  var spinner = () => {
578
578
  const s = (0, import_prompts3.spinner)();
579
579
  const minimal = isMinimalMode() || isDebugMode();
580
+ const stop = (msg = "error", code) => {
581
+ minimal ? code ? import_prompts2.log.error(msg) : import_prompts2.log.step(msg || "success") : s.stop(code ? fmt.red(msg) : fmt.green(msg), code);
582
+ };
580
583
  return {
581
584
  start: (msg) => {
582
585
  minimal ? import_prompts2.log.step(`${msg || "start"}...`) : s.start(msg);
583
586
  },
584
- stop: (msg = "error", code) => {
585
- minimal ? code ? import_prompts2.log.error(msg) : import_prompts2.log.step(msg || "success") : s.stop(code ? fmt.red(msg) : fmt.green(msg), code);
587
+ stop,
588
+ success: (msg = "success") => {
589
+ stop(msg, 0);
590
+ },
591
+ fail: (msg = "error", code = 1) => {
592
+ stop(msg, code);
593
+ },
594
+ finish: (msg = "success") => {
595
+ stop(msg, 0);
586
596
  },
587
597
  message: (msg) => {
588
598
  minimal ? import_prompts2.log.message(msg) : s.message(msg);
@@ -614,11 +624,14 @@ function getLifecycleHookScript(cwd, hook) {
614
624
  }
615
625
  async function runLifecycleHookScript(cwd, script) {
616
626
  const isWin = process.platform === "win32";
627
+ const onStdout = (data) => {
628
+ process.stdout.write(data);
629
+ };
617
630
  if (isWin) {
618
- await $("cmd.exe", ["/d", "/s", "/c", script], { cwd });
631
+ await $("cmd.exe", ["/d", "/s", "/c", script], { cwd, onStdout });
619
632
  return;
620
633
  }
621
- await $("/bin/sh", ["-lc", script], { cwd });
634
+ await $("/bin/sh", ["-lc", script], { cwd, onStdout });
622
635
  }
623
636
  async function runLifecycleHookWithTask(cwd, hook, message) {
624
637
  const script = getLifecycleHookScript(cwd, hook);
@@ -1019,15 +1032,30 @@ var getUnmergedFiles = async (cwd = ".") => {
1019
1032
  var fetchRepo = async (cwd = ".") => {
1020
1033
  await $("git", ["fetch", "--progress", "origin"], { cwd });
1021
1034
  };
1022
- var getStagedFiles = async (cwd = ".") => {
1035
+ var getChangedFilesFromHead = async (cwd = ".") => {
1023
1036
  let out = "";
1024
- await $("git", ["diff", "--cached", "--name-only"], {
1037
+ await $("git", ["diff", "--name-status", "-z", "HEAD"], {
1025
1038
  cwd,
1026
1039
  onStdout: (text2) => {
1027
1040
  out += text2;
1028
1041
  }
1029
1042
  });
1030
- return out.split("\n").map((l) => l.trim()).filter(Boolean);
1043
+ const entries = out.split("\0").filter(Boolean);
1044
+ const files = /* @__PURE__ */ new Set();
1045
+ for (let i = 0; i < entries.length; ) {
1046
+ const status = entries[i++] || "";
1047
+ const code = status.trim().toUpperCase();
1048
+ if (code.startsWith("R") || code.startsWith("C")) {
1049
+ const oldPath = entries[i++];
1050
+ const newPath = entries[i++];
1051
+ if (oldPath) files.add(oldPath);
1052
+ if (newPath) files.add(newPath);
1053
+ continue;
1054
+ }
1055
+ const file = entries[i++];
1056
+ if (file) files.add(file);
1057
+ }
1058
+ return [...files];
1031
1059
  };
1032
1060
  var git = {
1033
1061
  clone,
@@ -1070,7 +1098,7 @@ var git = {
1070
1098
  commitAll,
1071
1099
  getUnmergedFiles,
1072
1100
  fetchRepo,
1073
- getStagedFiles
1101
+ getChangedFilesFromHead
1074
1102
  };
1075
1103
 
1076
1104
  // src/shared/prompts/index.ts
@@ -1246,7 +1274,7 @@ var getConfiguredRegistryDirs = () => {
1246
1274
  const config = getLocalConfig();
1247
1275
  return config.registries.map((registry) => ({
1248
1276
  registry,
1249
- dir: import_node_path13.default.join(registriesDataPath, cacheDirNameForRegistry(registry))
1277
+ dir: import_node_path13.default.isAbsolute(registry) ? registry : import_node_path13.default.join(registriesDataPath, cacheDirNameForRegistry(registry))
1250
1278
  }));
1251
1279
  };
1252
1280
  var syncRegistries = async (branch) => {
@@ -1259,6 +1287,10 @@ var syncRegistries = async (branch) => {
1259
1287
  await Promise.all(
1260
1288
  config.registries.map(async (registry) => {
1261
1289
  debug(`update registry: ${registry}`);
1290
+ if (import_node_path13.default.isAbsolute(registry)) {
1291
+ debug(`local registry (absolute path): ${registry}`);
1292
+ return;
1293
+ }
1262
1294
  const repoName = cacheDirNameForRegistry(registry);
1263
1295
  const repoDir = import_node_path13.default.join(registriesDataPath, repoName);
1264
1296
  if (!import_fs_extra10.default.existsSync(repoDir)) {
@@ -1266,10 +1298,26 @@ var syncRegistries = async (branch) => {
1266
1298
  cwd: registriesDataPath,
1267
1299
  depth: 1
1268
1300
  });
1269
- } else if (import_fs_extra10.default.existsSync(import_node_path13.default.join(repoDir, ".git"))) {
1301
+ return;
1302
+ }
1303
+ if (!import_fs_extra10.default.existsSync(import_node_path13.default.join(repoDir, ".git"))) {
1304
+ debug(`local registry: ${registry}`);
1305
+ return;
1306
+ }
1307
+ try {
1270
1308
  await git.update({ cwd: repoDir });
1271
- } else {
1272
- debug(`local registry`);
1309
+ } catch (e) {
1310
+ const hasConflicts2 = await git.hasConflicts(repoDir);
1311
+ if (hasConflicts2) {
1312
+ debug(`Registry has conflicts, recreating: ${registry}`);
1313
+ await import_fs_extra10.default.remove(repoDir);
1314
+ await git.clone(registry, repoName, branch, {
1315
+ cwd: registriesDataPath,
1316
+ depth: 1
1317
+ });
1318
+ return;
1319
+ }
1320
+ import_prompts2.log.error(`Failed to update registry: ${e}`);
1273
1321
  }
1274
1322
  })
1275
1323
  );
@@ -1297,10 +1345,11 @@ var getAvailableTemplates = async () => {
1297
1345
  block.source = data.baseUrl + block.source;
1298
1346
  }
1299
1347
  });
1348
+ const resolvedTemplate = template;
1300
1349
  if (templates[templateName]) {
1301
- templates[templateName] = (0, import_merge.default)(templates[templateName], template);
1350
+ templates[templateName] = (0, import_merge.default)(templates[templateName], resolvedTemplate);
1302
1351
  } else {
1303
- templates[templateName] = template;
1352
+ templates[templateName] = resolvedTemplate;
1304
1353
  }
1305
1354
  });
1306
1355
  }
@@ -2019,9 +2068,9 @@ ${e instanceof Error ? e.message : String(e)}`);
2019
2068
  }
2020
2069
  }
2021
2070
  async revertExcludedStagedFiles(tmpRepoCwd, commit2, exclusion, projectIgnoreMatcher, target) {
2022
- const stagedFiles = await git.getStagedFiles(tmpRepoCwd);
2071
+ const changedFromHeadFiles = await git.getChangedFilesFromHead(tmpRepoCwd);
2023
2072
  const unmergedFiles = await git.getUnmergedFiles(tmpRepoCwd);
2024
- const allTouchedFiles = [.../* @__PURE__ */ new Set([...stagedFiles, ...unmergedFiles])];
2073
+ const allTouchedFiles = [.../* @__PURE__ */ new Set([...changedFromHeadFiles, ...unmergedFiles])];
2025
2074
  for (const file of allTouchedFiles) {
2026
2075
  const isBloxFile = isBloxConfigFile(file);
2027
2076
  const isExcludedByTarget = shouldExcludeFile(file, exclusion);
@@ -2140,54 +2189,75 @@ ${opts.description}`;
2140
2189
  };
2141
2190
 
2142
2191
  // src/services/contribute/services/CommitSelectorService.ts
2192
+ var NAV_PREV = "__prev__";
2193
+ var NAV_NEXT = "__next__";
2194
+ var NAV_FINISH = "__finish__";
2143
2195
  var CommitSelectorService = class {
2144
2196
  constructor(logger) {
2145
2197
  this.logger = logger;
2146
2198
  }
2147
2199
  async selectCommitsInteractive(opts) {
2148
- const selected = [];
2200
+ const selected = /* @__PURE__ */ new Set();
2201
+ const pages = /* @__PURE__ */ new Map();
2149
2202
  let page = 0;
2150
- let hasMore = true;
2151
- while (hasMore) {
2152
- const commits = await git.listCommits(UI_PAGE_SIZE, page * UI_PAGE_SIZE, opts.cwd);
2203
+ while (true) {
2204
+ let commits = pages.get(page);
2205
+ if (!commits) {
2206
+ commits = await git.listCommits(UI_PAGE_SIZE, page * UI_PAGE_SIZE, opts.cwd);
2207
+ pages.set(page, commits);
2208
+ }
2153
2209
  if (!commits.length) {
2154
2210
  if (page === 0) {
2155
2211
  throw new Error("No commits found in app repository.");
2156
2212
  }
2157
- break;
2213
+ page -= 1;
2214
+ continue;
2158
2215
  }
2216
+ const initialValues = commits.filter((c) => selected.has(c.hash)).map((c) => c.hash);
2159
2217
  const value = await multiselect({
2160
2218
  message: `Select commits (Press <space> to select, <enter> to continue) ${fmt.gray(`(page ${page + 1})`)}`,
2161
2219
  options: commits.map((c) => ({
2162
2220
  value: c.hash,
2163
2221
  label: `${c.hash.slice(0, 7)} ${c.subject}`
2164
2222
  })),
2165
- required: true
2223
+ initialValues,
2224
+ required: false
2166
2225
  });
2167
- for (const h of value) {
2168
- if (!selected.includes(h)) {
2169
- selected.push(h);
2226
+ for (const c of commits) {
2227
+ if (value.includes(c.hash)) {
2228
+ selected.add(c.hash);
2229
+ } else {
2230
+ selected.delete(c.hash);
2170
2231
  }
2171
2232
  }
2172
- hasMore = commits.length === UI_PAGE_SIZE;
2173
- if (!hasMore) {
2174
- break;
2175
- }
2176
- const loadMore = await confirm({
2177
- message: "Load next page of commits?",
2178
- initialValue: false
2233
+ const hasPrev = page > 0;
2234
+ const hasNext = commits.length === UI_PAGE_SIZE;
2235
+ const navigation = await select({
2236
+ message: `${selected.size} commit(s) selected. Choose an action:`,
2237
+ options: [
2238
+ ...hasPrev ? [{ label: "Previous page", value: NAV_PREV }] : [],
2239
+ ...hasNext ? [{ label: "Next page", value: NAV_NEXT }] : [],
2240
+ { label: "Finish selection", value: NAV_FINISH }
2241
+ ]
2179
2242
  });
2180
- if (!loadMore) {
2181
- break;
2243
+ if (navigation === NAV_PREV) {
2244
+ page -= 1;
2245
+ continue;
2182
2246
  }
2183
- page += 1;
2184
- }
2185
- if (!selected.length) {
2186
- throw new Error("No commits selected.");
2247
+ if (navigation === NAV_NEXT) {
2248
+ page += 1;
2249
+ continue;
2250
+ }
2251
+ if (!selected.size) {
2252
+ this.logger.warn("You must select at least one commit before finishing.");
2253
+ continue;
2254
+ }
2255
+ break;
2187
2256
  }
2188
- this.logger.debug("commits.selected", { count: selected.length });
2189
- this.logger.info(`${selected.length} Commits selected`);
2190
- return selected;
2257
+ const result = Array.from(selected);
2258
+ this.logger.debug("commits.selected", { count: result.length });
2259
+ this.logger.info(`${result.length} Commits selected`);
2260
+ return result;
2191
2261
  }
2192
2262
  };
2193
2263
 
@@ -2294,9 +2364,7 @@ var ContributionTargetSelector = class {
2294
2364
  const start = page * pageSize;
2295
2365
  const slice = filtered.slice(start, start + pageSize);
2296
2366
  const value = await select({
2297
- message: `Select contribution target ${fmt.gray(
2298
- `(page ${page + 1}/${maxPage + 1})`
2299
- )}`,
2367
+ message: `Select contribution target ${fmt.gray(`(page ${page + 1}/${maxPage + 1})`)}`,
2300
2368
  options: buildTargetPageSelectOptions(slice, page, maxPage)
2301
2369
  });
2302
2370
  if (value === TARGET_SELECT_PAGE.PREV) {
@@ -2532,7 +2600,9 @@ var TmpRepoService = class {
2532
2600
  await git.update({ cwd: dir });
2533
2601
  }
2534
2602
  async getTmpDir(target) {
2535
- const slug = `${target.type}-${target.name}`.replace(/[^a-zA-Z0-9._-]+/g, "-");
2603
+ const isBlock = target.type === "block" /* BLOCK */;
2604
+ const slugParts = isBlock && target.templateName ? [target.type, target.templateName, target.name] : [target.type, target.name];
2605
+ const slug = slugParts.join("-").replace(/[^a-zA-Z0-9._-]+/g, "-");
2536
2606
  return import_node_path18.default.join((0, import_node_os2.homedir)(), bloxFilePath, tempRepoName, slug);
2537
2607
  }
2538
2608
  async prepare(opts) {
@@ -2594,6 +2664,11 @@ var contribute = command("contribute").description("Contribute changes back to t
2594
2664
  option("--type <type>", "target type").choices(Object.values(ContributionTargetType))
2595
2665
  ).option("--name <name>", "target name").action(async (flags) => {
2596
2666
  try {
2667
+ if (await git.hasUncommittedChanges()) {
2668
+ throw new Error(
2669
+ "Make sure to commit or stash any changes in the app repo before contributing."
2670
+ );
2671
+ }
2597
2672
  await migrateAll(true);
2598
2673
  await syncRegistries();
2599
2674
  const workflow = await buildContributionWorkflow({
@@ -2843,8 +2918,7 @@ var import_cross_spawn2 = __toESM(require("cross-spawn"));
2843
2918
  var import_fs_extra19 = __toESM(require("fs-extra"));
2844
2919
 
2845
2920
  // src/commands/skills/constants.ts
2846
- var SKILLS_REPO_URL = "https://tfs.aas.com.sa/Medad/BLOX/_git/cli";
2847
- var SKILLS_TEMP_ROOT_PREFIX = "blox-skills";
2921
+ var SKILLS_REPO_URL = "https://github.com/Naseej-its/blox.git";
2848
2922
 
2849
2923
  // src/commands/skills/utils/cliCompatibility.ts
2850
2924
  var import_node_path20 = __toESM(require("path"));
@@ -2934,12 +3008,11 @@ var skills = command("skills").description("Install, update, and manage BLOX CLI
2934
3008
  async function runSkills() {
2935
3009
  const idx = process.argv.indexOf("skills");
2936
3010
  const args = idx === -1 ? [] : process.argv.slice(idx + 1);
2937
- const tempDir = import_node_path21.default.join(import_node_os3.default.tmpdir(), `${SKILLS_TEMP_ROOT_PREFIX}-${(0, import_node_crypto.randomUUID)()}`);
2938
- await import_fs_extra19.default.mkdir(tempDir);
2939
- let exitCode = 1;
2940
- try {
2941
- await git.clone(SKILLS_REPO_URL, tempDir);
2942
- if (needsCliCompatibilityCheck(args)) {
3011
+ if (needsCliCompatibilityCheck(args)) {
3012
+ const tempDir = import_node_path21.default.join(import_node_os3.default.tmpdir(), `blox-skills-compat-${(0, import_node_crypto.randomUUID)()}`);
3013
+ await import_fs_extra19.default.mkdir(tempDir);
3014
+ try {
3015
+ await git.clone(SKILLS_REPO_URL, tempDir);
2943
3016
  const skills2 = await loadSkillsData(tempDir);
2944
3017
  const cliVersion = getBloxCliVersion();
2945
3018
  const uncompatibleSkill = getFirstIncompatibleSkill(skills2, cliVersion);
@@ -2953,19 +3026,18 @@ async function runSkills() {
2953
3026
  return 1;
2954
3027
  }
2955
3028
  }
2956
- }
2957
- const finalArgs = injectRepoPathIfAdd(args, import_node_path21.default.resolve(tempDir));
2958
- exitCode = await runSkillsCommand(finalArgs, process.cwd());
2959
- } finally {
2960
- try {
2961
- await import_fs_extra19.default.remove(tempDir);
2962
- } catch {
2963
- debug(`Failed to cleanup temp dir: ${tempDir}`);
3029
+ } finally {
3030
+ try {
3031
+ await import_fs_extra19.default.remove(tempDir);
3032
+ } catch {
3033
+ debug(`Failed to cleanup temp dir: ${tempDir}`);
3034
+ }
2964
3035
  }
2965
3036
  }
2966
- return exitCode;
3037
+ const finalArgs = injectRepoUrlIfAdd(args, SKILLS_REPO_URL);
3038
+ return runSkillsCommand(finalArgs, process.cwd());
2967
3039
  }
2968
- function injectRepoPathIfAdd(args, repoPath) {
3040
+ function injectRepoUrlIfAdd(args, repoPath) {
2969
3041
  const addIndex = getAddCommandIndex(args);
2970
3042
  if (addIndex === -1) return args;
2971
3043
  const next = args[addIndex + 1];
@@ -3249,7 +3321,10 @@ async function updateAppBases(templateDef, templates, ignore3, hard = false) {
3249
3321
  let shouldContinue = true;
3250
3322
  for (const base of templateDef.bases || []) {
3251
3323
  await runTask(
3252
- { start: `Update App base: ${base.name}`, end: `Updated App base: ${base.name}` },
3324
+ {
3325
+ start: `Update App base: ${base.name}`,
3326
+ end: `Updated App base: ${base.name}`
3327
+ },
3253
3328
  async () => {
3254
3329
  const template = templates[base.name];
3255
3330
  if (!template) {
@@ -3276,11 +3351,11 @@ async function updateBlock(block, blocks, ignore3, hard = false) {
3276
3351
  const blockRegistryData = blocks[block];
3277
3352
  const blockPath = import_node_path23.default.join(blocksDir, block);
3278
3353
  let updated = false;
3279
- let shouldContinue = true;
3280
- await runTask({ start: `Update block: ${block}`, end: `Updated block: ${block}` }, async () => {
3354
+ try {
3281
3355
  if (!blockRegistryData) {
3282
- shouldContinue = await confirmContinueWhenMissing("block" /* BLOCK */, block);
3283
- return;
3356
+ throw new Error(
3357
+ `${"block" /* BLOCK */}: ${block} does not exist in registries.`
3358
+ );
3284
3359
  }
3285
3360
  const toCommit = await updateFromRemote({
3286
3361
  name: block,
@@ -3289,18 +3364,64 @@ async function updateBlock(block, blocks, ignore3, hard = false) {
3289
3364
  ignore: ignore3,
3290
3365
  hard
3291
3366
  });
3292
- if (toCommit) updated = true;
3293
- });
3294
- if (updated) {
3295
- await runLifecycleHookWithTask(blockPath, "update", "Run block update");
3367
+ if (toCommit) {
3368
+ updated = true;
3369
+ }
3370
+ return {
3371
+ block,
3372
+ updated,
3373
+ shouldContinue: true
3374
+ };
3375
+ } catch (error2) {
3376
+ return {
3377
+ block,
3378
+ updated,
3379
+ shouldContinue: true,
3380
+ error: error2
3381
+ };
3296
3382
  }
3297
- return { updated, shouldContinue };
3383
+ }
3384
+ async function updateBlocks(blocks, availableBlocks, ignoresByName, hard = false) {
3385
+ if (blocks.length === 0) {
3386
+ return [];
3387
+ }
3388
+ if (blocks.length === 1) {
3389
+ const block = blocks[0];
3390
+ if (!block) {
3391
+ return [];
3392
+ }
3393
+ let result;
3394
+ await runTask(
3395
+ {
3396
+ start: `Update block: ${block}`,
3397
+ end: `Updated block: ${block}`
3398
+ },
3399
+ async () => {
3400
+ result = await updateBlock(block, availableBlocks, ignoresByName[block], hard);
3401
+ }
3402
+ );
3403
+ return result ? [result] : [];
3404
+ }
3405
+ const blockNames = blocks.join(", ");
3406
+ import_prompts2.log.info(`Update blocks: ${blockNames}`);
3407
+ const results = await Promise.all(
3408
+ blocks.map((block) => updateBlock(block, availableBlocks, ignoresByName[block], hard))
3409
+ );
3410
+ import_prompts2.log.success(`Updated blocks: ${blockNames}`);
3411
+ return results;
3412
+ }
3413
+ async function runBlockUpdateHook(block) {
3414
+ const blockPath = import_node_path23.default.join(blocksDir, block);
3415
+ await runLifecycleHookWithTask(blockPath, "update", "Run block update");
3298
3416
  }
3299
3417
  async function getCurrentCheckpoints() {
3300
3418
  const bloxFile = getBloxFile();
3301
3419
  let checkpoints = { ...bloxFile.checkpoints };
3302
3420
  for (const block of getUsedBlocks()) {
3303
- checkpoints = { ...checkpoints, ...block.checkpoints };
3421
+ checkpoints = {
3422
+ ...checkpoints,
3423
+ ...block.checkpoints
3424
+ };
3304
3425
  }
3305
3426
  return checkpoints;
3306
3427
  }
@@ -3320,7 +3441,7 @@ ${changes}`);
3320
3441
  }
3321
3442
  if (allChanges.length) {
3322
3443
  logWarningSection(
3323
- `ChangeLog, These is the changes from last update, make sure to review for breaking changes`,
3444
+ "ChangeLog, These is the changes from last update, make sure to review for breaking changes",
3324
3445
  allChanges.join(`
3325
3446
  ${fmt.gray("-".repeat(82))}
3326
3447
 
@@ -3384,17 +3505,50 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
3384
3505
  shouldContinue = basesResult.shouldContinue;
3385
3506
  }
3386
3507
  if (shouldContinue && args.scope === "all") {
3387
- for (const block of usedBlocks) {
3388
- const blockResult = await updateBlock(
3389
- block.name,
3508
+ const missingBlocks = usedBlocks.filter((block) => !availableBlocks[block.name]);
3509
+ for (const block of missingBlocks) {
3510
+ const shouldUpdateRemaining = await select({
3511
+ message: `${block.name} does not exist in registries. Continue updating remaining parts?`,
3512
+ options: [
3513
+ {
3514
+ value: true,
3515
+ label: "Continue"
3516
+ },
3517
+ {
3518
+ value: false,
3519
+ label: "Stop"
3520
+ }
3521
+ ]
3522
+ });
3523
+ if (!shouldUpdateRemaining) {
3524
+ shouldContinue = false;
3525
+ break;
3526
+ }
3527
+ }
3528
+ if (shouldContinue) {
3529
+ const blocksToUpdate = usedBlocks.filter((block) => availableBlocks[block.name]).map((block) => block.name);
3530
+ const blockResults = await updateBlocks(
3531
+ blocksToUpdate,
3390
3532
  availableBlocks,
3391
- ignoresByName[block.name],
3533
+ ignoresByName,
3392
3534
  args.hard
3393
3535
  );
3394
- hasUpdate = hasUpdate || blockResult.updated;
3395
- if (!blockResult.shouldContinue) {
3396
- shouldContinue = false;
3397
- break;
3536
+ hasUpdate = hasUpdate || blockResults.some((result) => result.updated);
3537
+ const failedBlocks = blockResults.filter((result) => result.error);
3538
+ if (failedBlocks.length) {
3539
+ import_prompts23.log.warn(
3540
+ fmt.yellow(
3541
+ `${failedBlocks.length} block update${failedBlocks.length === 1 ? "" : "s"} failed.`
3542
+ )
3543
+ );
3544
+ for (const result of failedBlocks) {
3545
+ import_prompts23.log.error(fmt.red(`${result.block}: ${getErrorMessage(result.error)}`));
3546
+ }
3547
+ await waitForConflictResolution();
3548
+ }
3549
+ for (const result of blockResults) {
3550
+ if (!result.updated) continue;
3551
+ await runBlockUpdateHook(result.block);
3398
3552
  }
3399
3553
  }
3400
3554
  }
@@ -3413,14 +3567,24 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
3413
3567
  error("Selected block not used in app");
3414
3568
  return;
3415
3569
  }
3416
- const blockResult = await updateBlock(
3417
- blockDef.name,
3570
+ const [blockResult] = await updateBlocks(
3571
+ [blockDef.name],
3418
3572
  availableBlocks,
3419
- ignoresByName[blockDef.name],
3573
+ ignoresByName,
3420
3574
  args.hard
3421
3575
  );
3576
+ if (!blockResult) {
3577
+ return;
3578
+ }
3579
+ if (blockResult.error) {
3580
+ import_prompts23.log.error(fmt.red(`${blockDef.name}: ${getErrorMessage(blockResult.error)}`));
3581
+ await waitForConflictResolution();
3582
+ }
3422
3583
  hasUpdate = hasUpdate || blockResult.updated;
3423
3584
  shouldContinue = blockResult.shouldContinue;
3585
+ if (blockResult.updated) {
3586
+ await runBlockUpdateHook(blockDef.name);
3587
+ }
3424
3588
  }
3425
3589
  if (!shouldContinue) {
3426
3590
  import_prompts23.log.warn(fmt.yellow("Stopped updating remaining parts by user choice"));
@@ -3441,6 +3605,31 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
3441
3605
  await git.cleanUpWorktrees();
3442
3606
  }
3443
3607
  });
3608
+ function getErrorMessage(error2) {
3609
+ if (error2 instanceof Error) {
3610
+ return error2.message;
3611
+ }
3612
+ return String(error2);
3613
+ }
3614
+ async function waitForConflictResolution() {
3615
+ import_prompts23.log.warn(
3616
+ fmt.yellow(
3617
+ [
3618
+ "",
3619
+ "Block update conflicts/errors detected.",
3620
+ "Resolve the conflicts in the affected blocks, then press Enter to continue.",
3621
+ ""
3622
+ ].join("\n")
3623
+ )
3624
+ );
3625
+ await new Promise((resolve) => {
3626
+ process.stdin.resume();
3627
+ process.stdin.once("data", () => {
3628
+ process.stdin.pause();
3629
+ resolve();
3630
+ });
3631
+ });
3632
+ }
3444
3633
 
3445
3634
  // src/commands/upgrade/index.ts
3446
3635
  var upgrade = command("upgrade").description("Upgrade blox cli to latest version").action(async () => {
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { SelectOptions, ConfirmOptions, TextOptions, MultiSelectOptions } from '@clack/prompts';
2
+ import { CopyOptions as CopyOptions$1 } from 'fs-extra';
3
+
4
+ declare const select: <Value>(opts: SelectOptions<Value>) => Promise<Value>;
5
+ declare const confirm: (opts: ConfirmOptions) => Promise<boolean>;
6
+
7
+ type InputOptions = TextOptions;
8
+ type ConfirmPromptOptions = ConfirmOptions;
9
+ type SelectPromptOptions<Value> = SelectOptions<Value>;
10
+ type MultiSelectPromptOptions<Value> = MultiSelectOptions<Value>;
11
+ interface WriteJsonOptions {
12
+ spaces?: number;
13
+ }
14
+ interface CopyOptions {
15
+ overwrite?: CopyOptions$1['overwrite'];
16
+ filter?: CopyOptions$1['filter'];
17
+ }
18
+ type JsonUpdater<T> = (current: T) => T | void | Promise<T | void>;
19
+ interface ExecOptions {
20
+ cwd?: string;
21
+ shell?: boolean;
22
+ onStdout?: (data: string) => void;
23
+ }
24
+ interface ExecResult {
25
+ code: number | null;
26
+ stdout: string;
27
+ stderr: string;
28
+ }
29
+
30
+ declare const input: (opts: InputOptions) => Promise<string>;
31
+ declare const multiSelect: <Value>(opts: MultiSelectPromptOptions<Value>) => Promise<Value[]>;
32
+
33
+ declare const log: {
34
+ info: (message: string) => void;
35
+ success: (message: string) => void;
36
+ warn: (message: string) => void;
37
+ error: (message: string) => void;
38
+ };
39
+ declare const spinner: () => {
40
+ start: (msg?: string) => void;
41
+ stop: (msg?: string, code?: number) => void;
42
+ success: (msg?: string) => void;
43
+ fail: (msg?: string, code?: number) => void;
44
+ finish: (msg?: string) => void;
45
+ message: (msg: string) => void;
46
+ };
47
+ declare const exists: (targetPath: string) => Promise<boolean>;
48
+ declare const readJson: <T = unknown>(targetPath: string) => Promise<T>;
49
+ declare const writeJson: (targetPath: string, data: unknown, options?: WriteJsonOptions) => Promise<void>;
50
+ declare const mkdir: (targetPath: string) => Promise<void>;
51
+ declare const copy: (sourcePath: string, destinationPath: string, options?: CopyOptions) => Promise<void>;
52
+ declare const remove: (targetPath: string) => Promise<void>;
53
+ declare const move: (sourcePath: string, destinationPath: string) => Promise<void>;
54
+ declare const updateJson: <T = unknown>(targetPath: string, updater: JsonUpdater<T>) => Promise<void>;
55
+ declare const exec: (command: string, args?: string[], options?: ExecOptions) => Promise<ExecResult>;
56
+ declare const join: (...segments: string[]) => string;
57
+ declare const resolve: (...segments: string[]) => string;
58
+
59
+ export { type ConfirmPromptOptions, type CopyOptions, type ExecOptions, type ExecResult, type InputOptions, type JsonUpdater, type MultiSelectPromptOptions, type SelectPromptOptions, type WriteJsonOptions, confirm, copy, exec, exists, input, join, log, mkdir, move, multiSelect, readJson, remove, resolve, select, spinner, updateJson, writeJson };
package/dist/sdk.js ADDED
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/sdk/index.ts
31
+ var sdk_exports = {};
32
+ __export(sdk_exports, {
33
+ confirm: () => confirm,
34
+ copy: () => copy,
35
+ exec: () => exec,
36
+ exists: () => exists,
37
+ input: () => input,
38
+ join: () => join,
39
+ log: () => log5,
40
+ mkdir: () => mkdir,
41
+ move: () => move,
42
+ multiSelect: () => multiSelect,
43
+ readJson: () => readJson,
44
+ remove: () => remove,
45
+ resolve: () => resolve,
46
+ select: () => select,
47
+ spinner: () => spinner2,
48
+ updateJson: () => updateJson,
49
+ writeJson: () => writeJson
50
+ });
51
+ module.exports = __toCommonJS(sdk_exports);
52
+ var import_node_path = __toESM(require("path"));
53
+ var import_prompts5 = require("@clack/prompts");
54
+ var import_fs_extra = __toESM(require("fs-extra"));
55
+
56
+ // src/services/shell.ts
57
+ var import_cross_spawn = __toESM(require("cross-spawn"));
58
+
59
+ // src/shared/logger.ts
60
+ var console = __toESM(require("console"));
61
+ var import_prompts = require("@clack/prompts");
62
+
63
+ // src/shared/command/index.ts
64
+ var import_extra_typings = require("@commander-js/extra-typings");
65
+ var import_extra_typings2 = require("@commander-js/extra-typings");
66
+
67
+ // src/config/runtime.ts
68
+ var isDebugMode = () => !!import_extra_typings2.program.opts()?.debug;
69
+ var isMinimalMode = () => !!import_extra_typings2.program.opts()?.minimal;
70
+
71
+ // src/shared/terminal/index.ts
72
+ var import_ansis = __toESM(require("ansis"));
73
+ var fmt = import_ansis.default;
74
+
75
+ // src/shared/logger.ts
76
+ var import_prompts2 = require("@clack/prompts");
77
+ var debug = (message) => {
78
+ if (!isDebugMode()) {
79
+ return;
80
+ }
81
+ if (typeof message === "string") {
82
+ import_prompts.log.warn(message.trim());
83
+ } else {
84
+ console.log(JSON.stringify(message));
85
+ }
86
+ };
87
+
88
+ // src/services/shell.ts
89
+ var $ = async (bin, options = [], { cwd, onStdout, shell = false } = {}) => {
90
+ debug(`Command executed: "${bin} ${options.join(" ")}" with cwd = ${cwd}`);
91
+ return new Promise(function(resolve2, reject) {
92
+ const child = (0, import_cross_spawn.default)(bin, options, { cwd, shell, stdio: ["pipe", "pipe", "pipe"] });
93
+ let stdout = "";
94
+ let stderr = "";
95
+ child.stdout?.on("data", (data) => {
96
+ const str = data.toString();
97
+ stdout += str;
98
+ try {
99
+ onStdout && onStdout(str);
100
+ } catch (e) {
101
+ reject(e);
102
+ }
103
+ });
104
+ child.stderr?.on("data", (data) => {
105
+ stderr += data.toString();
106
+ });
107
+ child.on("close", function(code) {
108
+ if (code) {
109
+ const combined = (stdout + "\n" + stderr).trim();
110
+ const msg = `Command "${bin} ${options.join(" ")}" failed (code ${code}).
111
+ ${combined}`;
112
+ const err = new Error(msg);
113
+ err.code = code;
114
+ err.stdout = stdout;
115
+ err.stderr = stderr;
116
+ err.combined = combined;
117
+ reject(err);
118
+ } else {
119
+ resolve2({ code, stdout, stderr });
120
+ }
121
+ });
122
+ child.on("error", function(err) {
123
+ reject(err);
124
+ });
125
+ });
126
+ };
127
+
128
+ // src/shared/prompts/index.ts
129
+ var import_prompts3 = require("@clack/prompts");
130
+ var checkIfCanceled = (value) => {
131
+ if ((0, import_prompts3.isCancel)(value)) {
132
+ (0, import_prompts3.cancel)();
133
+ process.exit(0);
134
+ }
135
+ };
136
+ var select = async (opts) => {
137
+ const value = await (0, import_prompts3.select)(opts);
138
+ checkIfCanceled(value);
139
+ return value;
140
+ };
141
+ var text = async (opts) => {
142
+ const value = await (0, import_prompts3.text)(opts);
143
+ checkIfCanceled(value);
144
+ return value;
145
+ };
146
+ var confirm = async (opts) => {
147
+ const value = await (0, import_prompts3.confirm)(opts);
148
+ checkIfCanceled(value);
149
+ return value;
150
+ };
151
+ var multiselect = async (opts) => {
152
+ const value = await (0, import_prompts3.multiselect)(opts);
153
+ checkIfCanceled(value);
154
+ return value;
155
+ };
156
+
157
+ // src/shared/spinner.ts
158
+ var import_prompts4 = require("@clack/prompts");
159
+ var spinner = () => {
160
+ const s = (0, import_prompts4.spinner)();
161
+ const minimal = isMinimalMode() || isDebugMode();
162
+ const stop = (msg = "error", code) => {
163
+ minimal ? code ? import_prompts2.log.error(msg) : import_prompts2.log.step(msg || "success") : s.stop(code ? fmt.red(msg) : fmt.green(msg), code);
164
+ };
165
+ return {
166
+ start: (msg) => {
167
+ minimal ? import_prompts2.log.step(`${msg || "start"}...`) : s.start(msg);
168
+ },
169
+ stop,
170
+ success: (msg = "success") => {
171
+ stop(msg, 0);
172
+ },
173
+ fail: (msg = "error", code = 1) => {
174
+ stop(msg, code);
175
+ },
176
+ finish: (msg = "success") => {
177
+ stop(msg, 0);
178
+ },
179
+ message: (msg) => {
180
+ minimal ? import_prompts2.log.message(msg) : s.message(msg);
181
+ }
182
+ };
183
+ };
184
+
185
+ // src/sdk/index.ts
186
+ var input = (opts) => text(opts);
187
+ var multiSelect = (opts) => {
188
+ return multiselect(opts);
189
+ };
190
+ var log5 = {
191
+ info: import_prompts5.log.info,
192
+ success: import_prompts5.log.success,
193
+ warn: import_prompts5.log.warn,
194
+ error: import_prompts5.log.error
195
+ };
196
+ var spinner2 = () => spinner();
197
+ var exists = async (targetPath) => {
198
+ return import_fs_extra.default.pathExists(targetPath);
199
+ };
200
+ var readJson = async (targetPath) => {
201
+ return import_fs_extra.default.readJson(targetPath);
202
+ };
203
+ var writeJson = async (targetPath, data, options = {}) => {
204
+ const { spaces = 2 } = options;
205
+ await import_fs_extra.default.outputJson(targetPath, data, { spaces });
206
+ };
207
+ var mkdir = async (targetPath) => {
208
+ await import_fs_extra.default.ensureDir(targetPath);
209
+ };
210
+ var copy = async (sourcePath, destinationPath, options = {}) => {
211
+ const { overwrite = true, filter } = options;
212
+ await import_fs_extra.default.copy(sourcePath, destinationPath, {
213
+ overwrite,
214
+ errorOnExist: false,
215
+ ...filter ? { filter } : {}
216
+ });
217
+ };
218
+ var remove = async (targetPath) => {
219
+ await import_fs_extra.default.remove(targetPath);
220
+ };
221
+ var move = async (sourcePath, destinationPath) => {
222
+ await import_fs_extra.default.move(sourcePath, destinationPath);
223
+ };
224
+ var updateJson = async (targetPath, updater) => {
225
+ const current = await readJson(targetPath);
226
+ const updated = await updater(current);
227
+ await writeJson(targetPath, updated === void 0 ? current : updated);
228
+ };
229
+ var exec = async (command, args = [], options = {}) => {
230
+ const result = await $(command, args, options);
231
+ return {
232
+ code: result.code,
233
+ stdout: result.stdout,
234
+ stderr: result.stderr
235
+ };
236
+ };
237
+ var join = (...segments) => {
238
+ return import_node_path.default.join(...segments);
239
+ };
240
+ var resolve = (...segments) => {
241
+ return import_node_path.default.resolve(...segments);
242
+ };
243
+ // Annotate the CommonJS export names for ESM import in node:
244
+ 0 && (module.exports = {
245
+ confirm,
246
+ copy,
247
+ exec,
248
+ exists,
249
+ input,
250
+ join,
251
+ log,
252
+ mkdir,
253
+ move,
254
+ multiSelect,
255
+ readJson,
256
+ remove,
257
+ resolve,
258
+ select,
259
+ spinner,
260
+ updateJson,
261
+ writeJson
262
+ });
package/package.json CHANGED
@@ -1,88 +1,90 @@
1
1
  {
2
- "name": "@naseej/blox",
3
- "version": "1.7.0",
4
- "description": "blox cli",
5
- "bin": {
6
- "blox": "./bin/run"
7
- },
8
- "directories": {
9
- "lib": "src",
10
- "bin": "bin"
11
- },
12
- "files": [
13
- "dist",
14
- "bin"
15
- ],
16
- "scripts": {
17
- "build": "tsup-node",
18
- "build:watch": "tsup-node --watch",
19
- "clean": "rm -rf dist",
20
- "commitlint": "commitlint --edit",
21
- "compile": "tsc",
22
- "start": "tsx ./bin/run.ts",
23
- "start:node": "node ./bin/run",
24
- "test": "playwright test",
25
- "test:watch": "playwright test --ui",
26
- "lint": "eslint \"*/**/*.{js,ts,tsx}\" --quiet --fix",
27
- "lint:fix": "eslint \"*/**/*.{js,ts,tsx}\" --fix",
28
- "lint:stage": "yarn lint -- -c .eslintrc.staging.cjs",
29
- "watch": "tsc --watch",
30
- "type-check": "tsc --noEmit",
31
- "generate:schema": "tsx --tsconfig tsconfig.scripts.json scripts/generate-schema.ts",
32
- "check:schema": "tsx --tsconfig tsconfig.scripts.json scripts/check-schema.ts",
33
- "prepare": "husky",
34
- "postinstall": "patch-package"
35
- },
36
- "devDependencies": {
37
- "@playwright/test": "^1.59.1",
38
- "@tsconfig/node20": "^20.1.4",
39
- "@types/cross-spawn": "^6.0.6",
40
- "@types/ejs": "3.1.5",
41
- "@types/fs-extra": "11.0.4",
42
- "@types/klaw": "^3.0.6",
43
- "@types/lodash": "4.17.20",
44
- "@types/ms": "0.7.34",
45
- "@types/node": "^20.12.12",
46
- "@types/prompts": "^2.4.9",
47
- "@types/semver": "^7.7.1",
48
- "@types/signale": "^1.4.7",
49
- "@types/yargs": "^17.0.32",
50
- "@typescript-eslint/eslint-plugin": "^8.17.0",
51
- "@typescript-eslint/parser": "^8.17.0",
52
- "cli-docs-generator": "^1.0.7",
53
- "eslint": "^8.57.0",
54
- "eslint-config-prettier": "^8.10.0",
55
- "eslint-import-resolver-typescript": "^3.6.1",
56
- "eslint-plugin-import": "^2.29.1",
57
- "eslint-plugin-prettier": "^5.1.3",
58
- "eslint-plugin-react": "^7.34.1",
59
- "eslint-plugin-unused-imports": "^4.1.4",
60
- "execa": "^9.6.1",
61
- "husky": "^9.1.7",
62
- "node-pty": "^1.1.0",
63
- "patch-package": "^8.0.0",
64
- "prettier": "^3.2.5",
65
- "tsup": "^8.0.2",
66
- "tsx": "4.19.2",
67
- "typescript": "^5.7.2",
68
- "vite-tsconfig-paths": "^5.1.4",
69
- "vitest": "2.1.8"
70
- },
71
- "dependencies": {
72
- "@clack/prompts": "^0.8.2",
73
- "@commander-js/extra-typings": "12.1.0",
74
- "ansis": "3.3.2",
75
- "commander": "12.1.0",
76
- "cross-spawn": "^7.0.6",
77
- "dayjs": "1.11.13",
78
- "ejs": "^3.1.10",
79
- "env-paths": "^2.2.1",
80
- "fs-extra": "^11.2.0",
81
- "ignore": "^7.0.5",
82
- "klaw": "^4.1.0",
83
- "lodash": "^4.17.21",
84
- "ms": "2.1.3",
85
- "semver": "^7.7.4",
86
- "zod": "^4.4.3"
87
- }
2
+ "name": "@naseej/blox",
3
+ "version": "1.8.0",
4
+ "description": "blox cli",
5
+ "exports": {
6
+ "./sdk": {
7
+ "types": "./dist/sdk.d.ts",
8
+ "default": "./dist/sdk.js"
9
+ },
10
+ "./package.json": "./package.json"
11
+ },
12
+ "bin": {
13
+ "blox": "./bin/run"
14
+ },
15
+ "directories": {
16
+ "lib": "src",
17
+ "bin": "bin"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "bin"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsup-node",
25
+ "build:watch": "tsup-node --watch",
26
+ "clean": "rm -rf dist",
27
+ "commitlint": "commitlint --edit",
28
+ "compile": "tsc",
29
+ "start": "tsx ./bin/run.ts",
30
+ "start:node": "node ./bin/run",
31
+ "test": "tsx --tsconfig tsconfig.scripts.json scripts/run-tests.ts",
32
+ "test:watch": "playwright test --ui",
33
+ "lint": "oxlint",
34
+ "lint:fix": "oxlint --fix",
35
+ "lint:stage": "oxlint",
36
+ "format": "oxfmt",
37
+ "format:check": "oxfmt --check",
38
+ "watch": "tsc --watch",
39
+ "type-check": "tsc --noEmit",
40
+ "generate:schema": "tsx --tsconfig tsconfig.scripts.json scripts/generate-schema.ts",
41
+ "check:schema": "tsx --tsconfig tsconfig.scripts.json scripts/check-schema.ts",
42
+ "prepare": "husky",
43
+ "postinstall": "patch-package"
44
+ },
45
+ "devDependencies": {
46
+ "@playwright/test": "^1.59.1",
47
+ "@tsconfig/node20": "^20.1.4",
48
+ "@types/cross-spawn": "^6.0.6",
49
+ "@types/ejs": "3.1.5",
50
+ "@types/fs-extra": "11.0.4",
51
+ "@types/klaw": "^3.0.6",
52
+ "@types/lodash": "4.17.20",
53
+ "@types/ms": "0.7.34",
54
+ "@types/node": "^20.12.12",
55
+ "@types/prompts": "^2.4.9",
56
+ "@types/semver": "^7.7.1",
57
+ "@types/signale": "^1.4.7",
58
+ "@types/yargs": "^17.0.32",
59
+ "cli-docs-generator": "^1.0.7",
60
+ "execa": "^9.6.1",
61
+ "husky": "^9.1.7",
62
+ "node-pty": "^1.1.0",
63
+ "oxfmt": "^0.68.0",
64
+ "oxlint": "^1.83.0",
65
+ "patch-package": "^8.0.0",
66
+ "tsup": "^8.0.2",
67
+ "tsx": "4.19.2",
68
+ "typescript": "^5.7.2",
69
+ "vite-tsconfig-paths": "^5.1.4",
70
+ "vitest": "2.1.8"
71
+ },
72
+ "dependencies": {
73
+ "@clack/prompts": "^0.8.2",
74
+ "@commander-js/extra-typings": "12.1.0",
75
+ "ansis": "3.3.2",
76
+ "commander": "12.1.0",
77
+ "cross-spawn": "^7.0.6",
78
+ "dayjs": "1.11.13",
79
+ "ejs": "^3.1.10",
80
+ "env-paths": "^2.2.1",
81
+ "fs-extra": "^11.2.0",
82
+ "ignore": "^7.0.5",
83
+ "json-schema-to-typescript": "^15.0.4",
84
+ "klaw": "^4.1.0",
85
+ "lodash": "^4.17.21",
86
+ "ms": "2.1.3",
87
+ "semver": "^7.7.4",
88
+ "zod": "^4.4.3"
89
+ }
88
90
  }
package/readme.md CHANGED
@@ -4,32 +4,7 @@ BLOX CLI helps you bootstrap, manage, update, and contribute BLOX-based apps and
4
4
 
5
5
  ## Content
6
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)
7
+ [[_TOC_]]
33
8
 
34
9
  ## Installation
35
10
 
@@ -216,7 +191,7 @@ blox skills <command> [options]
216
191
 
217
192
  Important notes:
218
193
 
219
- - BLOX clones the BLOX CLI skills repository, runs `npx skills` with your arguments, then cleans up.
194
+ - BLOX passes the BLOX content URL directly to Skills CLI for `add` flows.
220
195
  - No repository URL is required.
221
196
 
222
197
  ## Features
@@ -248,10 +223,10 @@ Example root `.blox` configuration:
248
223
  How ignore sources are combined:
249
224
 
250
225
  - `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)
226
+ - remote template ignore (`definition.ignore`)
227
+ - local project ignore (`project.ignore` in local `.blox`)
228
+ - local `.gitignore`
229
+ - command option `--ignore` (when provided)
255
230
  - `blox contribute` also respects local `project.ignore`.
256
231
  - Local `project.ignore` is project-owned and is not replaced by remote template ignore during update.
257
232
 
@@ -280,6 +255,34 @@ When hooks run:
280
255
  | `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
256
  | `remove` | Runs after `blox remove` actually removed a block in that run. | Runs before the block is deleted, while its files still exist. |
282
257
 
258
+ ### Blox SDK
259
+
260
+ Use the SDK when a template needs custom interactive behavior and you can run it inside lifecycle hooks.
261
+
262
+ Install in the template project:
263
+
264
+ ```sh
265
+ npm install -D @naseej/blox
266
+ ```
267
+
268
+ Import only from the SDK subpath:
269
+
270
+ ```ts
271
+ import { input } from '@naseej/blox/sdk';
272
+ ```
273
+
274
+ SDK API reference:
275
+
276
+ | Category | API | Notes |
277
+ | --------------- | --------------------------------------------------------- | ----------------------------------------------------- |
278
+ | Prompts | `input`, `confirm`, `select`, `multiSelect` | Interactive CLI prompts. |
279
+ | Logging | `log.info`, `log.success`, `log.warn`, `log.error` | Consistent BLOX output formatting. |
280
+ | Spinner | `spinner().start`, `spinner().message`, `spinner().stop` | Existing spinner API remains stable. |
281
+ | Spinner aliases | `spinner().success`, `spinner().fail`, `spinner().finish` | Semantic aliases for completion states. |
282
+ | Filesystem | `exists`, `mkdir`, `copy`, `move`, `remove` | Thin cross-platform file helpers. |
283
+ | JSON | `readJson`, `writeJson`, `updateJson` | Stable JSON read/write plus read-modify-write helper. |
284
+ | Process/path | `exec`, `join`, `resolve` | Shell execution and path helpers. |
285
+
283
286
  ### Skills
284
287
 
285
288
  #### Installing Skills
@@ -289,7 +292,7 @@ Use `blox skills` to run the Skills CLI against the BLOX CLI skills repository.
289
292
  Behavior:
290
293
 
291
294
  - BLOX executes `npx skills` with all arguments passed after `skills`.
292
- - BLOX handles cloning and cleanup automatically.
295
+ - BLOX uses the BLOX content URL directly as the skills source .
293
296
 
294
297
  #### CLI Compatibility
295
298
 
@@ -314,7 +317,7 @@ blox skills list
314
317
 
315
318
  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
319
 
317
- ### Create new template
320
+ ## Create new template
318
321
 
319
322
  Create a new template by starting from an existing one, updating its metadata, then publishing it.
320
323