@naseej/blox 1.6.3 → 1.7.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.
Files changed (2) hide show
  1. package/dist/run.js +216 -161
  2. package/package.json +5 -2
package/dist/run.js CHANGED
@@ -57,6 +57,8 @@ var defaultConfig = {
57
57
  var bloxFilePath = ".blox";
58
58
  var blocksDir = "blocks";
59
59
  var defaultBranch = "main";
60
+ var CURRENT_SCHEMA_VERSION = 1;
61
+ var SCHEMA_BASE_URL = "https://raw.githubusercontent.com/Naseej-its/blox/main/schemas";
60
62
 
61
63
  // src/shared/logger.ts
62
64
  var console2 = __toESM(require("console"));
@@ -199,18 +201,69 @@ var checkForCliUpdate = async (currentVersion, argv = []) => {
199
201
  };
200
202
 
201
203
  // package.json
202
- var version = "1.6.3";
204
+ var version = "1.7.0";
203
205
 
204
206
  // src/commands/add/index.ts
205
- var import_fs_extra10 = __toESM(require("fs-extra"));
207
+ var import_fs_extra11 = __toESM(require("fs-extra"));
206
208
 
207
209
  // src/migrations/index.ts
208
- var import_node_path10 = __toESM(require("path"));
209
- var import_fs_extra7 = __toESM(require("fs-extra"));
210
+ var import_node_path11 = __toESM(require("path"));
211
+ var import_fs_extra8 = __toESM(require("fs-extra"));
212
+
213
+ // src/migrations/updateSchemaUrls.ts
214
+ var import_node_path3 = __toESM(require("path"));
215
+ var import_fs_extra3 = __toESM(require("fs-extra"));
216
+ async function updateSchemaUrls(cwd = ".") {
217
+ const locations = [
218
+ { filePath: import_node_path3.default.join(cwd, bloxFilePath), type: "template" },
219
+ ...readBlockPaths(cwd).map((filePath) => ({ filePath, type: "block" }))
220
+ ];
221
+ let anyChanged = false;
222
+ for (const { filePath, type } of locations) {
223
+ const changed = rewriteIfStale(filePath, type);
224
+ anyChanged = anyChanged || changed;
225
+ }
226
+ if (anyChanged) {
227
+ import_prompts2.log.warn(fmt.yellow("Schema URLs updated to v" + CURRENT_SCHEMA_VERSION));
228
+ }
229
+ return anyChanged;
230
+ }
231
+ function readBlockPaths(cwd) {
232
+ const dir = import_node_path3.default.join(cwd, blocksDir);
233
+ if (!import_fs_extra3.default.existsSync(dir)) return [];
234
+ return import_fs_extra3.default.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => import_node_path3.default.join(dir, e.name, bloxFilePath));
235
+ }
236
+ function rewriteIfStale(filePath, type) {
237
+ if (!import_fs_extra3.default.existsSync(filePath)) return false;
238
+ let raw;
239
+ try {
240
+ raw = import_fs_extra3.default.readJSONSync(filePath);
241
+ } catch {
242
+ debug(`updateSchemaUrls: skipping unreadable file ${filePath}`);
243
+ return false;
244
+ }
245
+ const existingSchema = raw["$schema"];
246
+ const schemaVersion = typeof raw["schemaVersion"] === "number" ? raw["schemaVersion"] : CURRENT_SCHEMA_VERSION;
247
+ const expectedSchemaUrl = buildSchemaUrl(type, schemaVersion);
248
+ if (existingSchema === expectedSchemaUrl) {
249
+ return false;
250
+ }
251
+ const { $schema: _previousSchema, ...rest } = raw;
252
+ const updated = {
253
+ $schema: expectedSchemaUrl,
254
+ ...rest
255
+ };
256
+ import_fs_extra3.default.writeFileSync(filePath, JSON.stringify(updated, null, 2));
257
+ debug(`updateSchemaUrls: updated ${filePath} \u2192 ${expectedSchemaUrl}`);
258
+ return true;
259
+ }
260
+ function buildSchemaUrl(type, generation = CURRENT_SCHEMA_VERSION) {
261
+ return `${SCHEMA_BASE_URL}/v${generation}/${type}.json`;
262
+ }
210
263
 
211
264
  // src/migrations/utils.ts
212
- var import_node_path9 = __toESM(require("path"));
213
- var import_fs_extra6 = __toESM(require("fs-extra"));
265
+ var import_node_path10 = __toESM(require("path"));
266
+ var import_fs_extra7 = __toESM(require("fs-extra"));
214
267
 
215
268
  // src/migrations/list/v1.ts
216
269
  var v1 = {
@@ -247,8 +300,8 @@ var migrationsList = [v1];
247
300
 
248
301
  // src/services/git.ts
249
302
  var import_node_os = __toESM(require("os"));
250
- var import_node_path8 = __toESM(require("path"));
251
- var import_fs_extra5 = __toESM(require("fs-extra"));
303
+ var import_node_path9 = __toESM(require("path"));
304
+ var import_fs_extra6 = __toESM(require("fs-extra"));
252
305
 
253
306
  // src/services/shell.ts
254
307
  var import_cross_spawn = __toESM(require("cross-spawn"));
@@ -337,14 +390,14 @@ var looksLikeDirectory = (pattern) => {
337
390
  };
338
391
 
339
392
  // src/shared/utils/gitignoreMatcher.ts
340
- var import_node_path3 = __toESM(require("path"));
393
+ var import_node_path4 = __toESM(require("path"));
341
394
  var import_ignore = __toESM(require("ignore"));
342
395
  var createGitignoreMatcher = (patterns) => {
343
396
  const cleaned = patterns.map((p) => p.trim()).filter((p) => p && !p.startsWith("#"));
344
397
  return (0, import_ignore.default)().add(cleaned);
345
398
  };
346
399
  var toIgnorePath = (repoRelativePath) => {
347
- let p = repoRelativePath.split(import_node_path3.default.sep).join("/");
400
+ let p = repoRelativePath.split(import_node_path4.default.sep).join("/");
348
401
  if (p.startsWith("./")) p = p.slice(2);
349
402
  return p;
350
403
  };
@@ -401,9 +454,9 @@ function openUrlInBrowser(url) {
401
454
  }
402
455
 
403
456
  // src/shared/utils/isBloxConfigFile.ts
404
- var import_node_path4 = __toESM(require("path"));
457
+ var import_node_path5 = __toESM(require("path"));
405
458
  function isBloxConfigFile(file) {
406
- const normalized = file.split(import_node_path4.default.sep).join("/");
459
+ const normalized = file.split(import_node_path5.default.sep).join("/");
407
460
  return normalized === bloxFilePath || normalized.endsWith(`/${bloxFilePath}`);
408
461
  }
409
462
 
@@ -423,40 +476,40 @@ function omitKeys(value, keysToOmit) {
423
476
  var normalizeCommitRef = (commit2) => commit2.trim().replace(/\r/g, "").replace(/^"+|"+$/g, "");
424
477
 
425
478
  // src/shared/utils/isBlockDirectory.ts
426
- var import_node_path5 = __toESM(require("path"));
427
- var import_fs_extra3 = __toESM(require("fs-extra"));
479
+ var import_node_path6 = __toESM(require("path"));
480
+ var import_fs_extra4 = __toESM(require("fs-extra"));
428
481
  function isBlockDirectory(blockDir) {
429
- const bloxPath = import_node_path5.default.join(blockDir, bloxFilePath);
430
- if (!import_fs_extra3.default.existsSync(bloxPath)) {
482
+ const bloxPath = import_node_path6.default.join(blockDir, bloxFilePath);
483
+ if (!import_fs_extra4.default.existsSync(bloxPath)) {
431
484
  return false;
432
485
  }
433
486
  try {
434
- return import_fs_extra3.default.statSync(bloxPath).isFile();
487
+ return import_fs_extra4.default.statSync(bloxPath).isFile();
435
488
  } catch {
436
489
  return false;
437
490
  }
438
491
  }
439
492
 
440
493
  // src/services/template.ts
441
- var import_node_path6 = __toESM(require("path"));
494
+ var import_node_path7 = __toESM(require("path"));
442
495
  var import_ejs = __toESM(require("ejs"));
443
- var import_fs_extra4 = __toESM(require("fs-extra"));
496
+ var import_fs_extra5 = __toESM(require("fs-extra"));
444
497
  var import_klaw = __toESM(require("klaw"));
445
498
  async function replacePlaceholders(dir, context) {
446
499
  debug("Replace placeholders");
447
500
  for await (const file of (0, import_klaw.default)(dir)) {
448
501
  if (!file.stats.isFile()) continue;
449
- const ext = import_node_path6.default.extname(file.path).toLowerCase();
502
+ const ext = import_node_path7.default.extname(file.path).toLowerCase();
450
503
  if (isBinaryFile(ext)) {
451
504
  continue;
452
505
  }
453
- const templateContent = import_fs_extra4.default.readFileSync(file.path, "utf8");
506
+ const templateContent = import_fs_extra5.default.readFileSync(file.path, "utf8");
454
507
  if (!templateContent.includes("<%")) {
455
508
  continue;
456
509
  }
457
510
  try {
458
511
  const rendered = import_ejs.default.render(templateContent, context);
459
- import_fs_extra4.default.writeFileSync(file.path, rendered, "utf8");
512
+ import_fs_extra5.default.writeFileSync(file.path, rendered, "utf8");
460
513
  } catch (err) {
461
514
  console.error("\u274C Error rendering EJS for file:", file.path);
462
515
  throw err;
@@ -477,7 +530,7 @@ function getBlockDef(cwd = ".") {
477
530
  }
478
531
  function getBloxFile(cwd = ".") {
479
532
  try {
480
- const file = import_fs_extra4.default.readJSONSync(import_node_path6.default.join(cwd, bloxFilePath));
533
+ const file = import_fs_extra5.default.readJSONSync(import_node_path7.default.join(cwd, bloxFilePath));
481
534
  if (!file.checkpoints) {
482
535
  file.checkpoints = {};
483
536
  }
@@ -488,7 +541,7 @@ function getBloxFile(cwd = ".") {
488
541
  }
489
542
  function saveBloxFile(info, cwd = ".") {
490
543
  debug("Save info");
491
- import_fs_extra4.default.writeFileSync(import_node_path6.default.join(cwd, bloxFilePath), JSON.stringify(info, null, 2));
544
+ import_fs_extra5.default.writeFileSync(import_node_path7.default.join(cwd, bloxFilePath), JSON.stringify(info, null, 2));
492
545
  }
493
546
  function updateCheckpoint(name, checkpoint, cwd = ".") {
494
547
  const info = getBloxFile(cwd);
@@ -504,12 +557,12 @@ function getUsedBlocksDef() {
504
557
  function getUsedBlocks() {
505
558
  debug("Get used blocks");
506
559
  const blocks = [];
507
- if (import_fs_extra4.default.existsSync(blocksDir)) {
508
- import_fs_extra4.default.readdirSync(blocksDir, { withFileTypes: true }).forEach((file) => {
560
+ if (import_fs_extra5.default.existsSync(blocksDir)) {
561
+ import_fs_extra5.default.readdirSync(blocksDir, { withFileTypes: true }).forEach((file) => {
509
562
  if (!file.isDirectory()) {
510
563
  return;
511
564
  }
512
- const blockDef = getBloxFile(import_node_path6.default.join(blocksDir, file.name));
565
+ const blockDef = getBloxFile(import_node_path7.default.join(blocksDir, file.name));
513
566
  if (blockDef && blockDef.definition) {
514
567
  blocks.push(blockDef);
515
568
  }
@@ -577,9 +630,9 @@ async function runLifecycleHookWithTask(cwd, hook, message) {
577
630
  }
578
631
 
579
632
  // src/services/path.ts
580
- var import_node_path7 = __toESM(require("path"));
633
+ var import_node_path8 = __toESM(require("path"));
581
634
  var normalizePath = (_path) => {
582
- return _path.split(import_node_path7.default.sep).join("/");
635
+ return _path.split(import_node_path8.default.sep).join("/");
583
636
  };
584
637
 
585
638
  // src/services/git.ts
@@ -610,16 +663,16 @@ var getRemoteWorktree = async (remote, commit2) => {
610
663
  return remoteWorktrees.get(key);
611
664
  }
612
665
  const tmpDir = import_node_os.default.tmpdir();
613
- const worktreeDir = import_node_path8.default.join(tmpDir, "blox-cli-worktrees", remote, commit2);
666
+ const worktreeDir = import_node_path9.default.join(tmpDir, "blox-cli-worktrees", remote, commit2);
614
667
  try {
615
668
  await $("git", ["worktree", "prune"]);
616
669
  } catch {
617
670
  }
618
- if (await import_fs_extra5.default.pathExists(worktreeDir)) {
671
+ if (await import_fs_extra6.default.pathExists(worktreeDir)) {
619
672
  try {
620
673
  await $("git", ["worktree", "remove", "--force", worktreeDir]);
621
674
  } catch {
622
- await import_fs_extra5.default.remove(worktreeDir);
675
+ await import_fs_extra6.default.remove(worktreeDir);
623
676
  try {
624
677
  await $("git", ["worktree", "prune"]);
625
678
  } catch {
@@ -735,8 +788,8 @@ var update = (shellOptions = {}) => {
735
788
  var getLatestCommitFromRemote = async (remote, branch) => {
736
789
  return getLatestCommit(`${remote}/${branch}`);
737
790
  };
738
- var getLatestCommitFromPath = async (path23) => {
739
- return getLatestCommit("HEAD", path23);
791
+ var getLatestCommitFromPath = async (path24) => {
792
+ return getLatestCommit("HEAD", path24);
740
793
  };
741
794
  var getLatestCommit = async (rev, cwd = ".") => {
742
795
  debug(`Get latest commit for rev: ${rev} and cwd: ${cwd}`);
@@ -760,7 +813,7 @@ var getChangesLog = async (fromCommit, toCommit) => {
760
813
  };
761
814
  var unInit = (cwd) => {
762
815
  debug("UnInit");
763
- return import_fs_extra5.default.remove(import_node_path8.default.join(cwd, ".git"));
816
+ return import_fs_extra6.default.remove(import_node_path9.default.join(cwd, ".git"));
764
817
  };
765
818
  var init = async (cwd) => {
766
819
  debug("Init");
@@ -877,11 +930,11 @@ var createBranch = async (branch, from, cwd = ".") => {
877
930
  var push = async (remote, branch, cwd = ".") => {
878
931
  await $("git", ["push", "--progress", remote, `refs/heads/${branch}`], { cwd });
879
932
  };
880
- var checkoutFile = async (path23, ref, cwd = ".") => {
933
+ var checkoutFile = async (path24, ref, cwd = ".") => {
881
934
  const args = ["checkout"];
882
935
  if (ref) args.push(ref);
883
936
  else args.push("HEAD");
884
- args.push("--", path23);
937
+ args.push("--", path24);
885
938
  await $("git", args, { cwd });
886
939
  };
887
940
  var pathExistsAsBlobInRev = async (rev, filePath, cwd = ".") => {
@@ -943,10 +996,10 @@ var cherryPick = async (commitHash, subtree, noCommit, cwd = ".") => {
943
996
  args.push(normalizeCommitRef(commitHash));
944
997
  await $("git", args, { cwd });
945
998
  };
946
- var reset = async (path23, hard, cwd = ".") => {
999
+ var reset = async (path24, hard, cwd = ".") => {
947
1000
  const args = ["reset"];
948
1001
  if (hard) args.push("--hard");
949
- if (path23) args.push(path23);
1002
+ if (path24) args.push(path24);
950
1003
  await $("git", args, { cwd });
951
1004
  };
952
1005
  var commitAll = async (message, cwd = ".") => {
@@ -1129,26 +1182,28 @@ async function migrate(name, { getPath = (f) => f, read, write }) {
1129
1182
  }
1130
1183
  function migrateOnLocal(name, cwd = ".") {
1131
1184
  return migrate(name, {
1132
- getPath: (file) => import_node_path9.default.join(cwd, file),
1133
- read: import_fs_extra6.default.readJson,
1134
- write: import_fs_extra6.default.writeFile
1185
+ getPath: (file) => import_node_path10.default.join(cwd, file),
1186
+ read: import_fs_extra7.default.readJson,
1187
+ write: import_fs_extra7.default.writeFile
1135
1188
  });
1136
1189
  }
1137
1190
  function migrateOnRemote(name, commit2, cwd) {
1138
1191
  return migrate(name, {
1139
1192
  read: (file) => git.readJsonFromCommit(commit2, file),
1140
- getPath: cwd ? (file) => import_node_path9.default.join(cwd, file) : void 0
1193
+ getPath: cwd ? (file) => import_node_path10.default.join(cwd, file) : void 0
1141
1194
  });
1142
1195
  }
1143
1196
 
1144
1197
  // src/migrations/index.ts
1145
1198
  async function migrateAll(autoCommit) {
1146
1199
  let filesChanged = (await migrateOnLocal("app")).filesChanged;
1147
- const blocks = import_fs_extra7.default.existsSync(blocksDir) ? import_fs_extra7.default.readdirSync(blocksDir) : [];
1200
+ const blocks = import_fs_extra8.default.existsSync(blocksDir) ? import_fs_extra8.default.readdirSync(blocksDir) : [];
1148
1201
  for (const block of blocks) {
1149
- const res = await migrateOnLocal(block, import_node_path10.default.join(blocksDir, block));
1202
+ const res = await migrateOnLocal(block, import_node_path11.default.join(blocksDir, block));
1150
1203
  filesChanged = filesChanged || res.filesChanged;
1151
1204
  }
1205
+ const urlsChanged = await updateSchemaUrls(".");
1206
+ filesChanged = filesChanged || urlsChanged;
1152
1207
  if (autoCommit && filesChanged && await git.hasUncommittedChanges()) {
1153
1208
  import_prompts2.log.warn(fmt.yellow(`Migrations done and will be commited`));
1154
1209
  await git.add(".");
@@ -1157,8 +1212,8 @@ async function migrateAll(autoCommit) {
1157
1212
  }
1158
1213
 
1159
1214
  // src/services/fs.ts
1160
- var import_node_path11 = __toESM(require("path"));
1161
- var import_fs_extra8 = __toESM(require("fs-extra"));
1215
+ var import_node_path12 = __toESM(require("path"));
1216
+ var import_fs_extra9 = __toESM(require("fs-extra"));
1162
1217
  var import_ignore2 = __toESM(require("ignore"));
1163
1218
  var import_klaw2 = __toESM(require("klaw"));
1164
1219
  var filterBlacklisted = (item) => {
@@ -1167,22 +1222,22 @@ var filterBlacklisted = (item) => {
1167
1222
  var deletePattern = async (cwd, patterns = []) => {
1168
1223
  const ig = (0, import_ignore2.default)().add(patterns);
1169
1224
  for await (const file of (0, import_klaw2.default)(cwd, { filter: filterBlacklisted })) {
1170
- const relativePath = import_node_path11.default.relative(cwd, file.path);
1225
+ const relativePath = import_node_path12.default.relative(cwd, file.path);
1171
1226
  if (relativePath && ig.ignores(relativePath)) {
1172
- if (!await import_fs_extra8.default.exists(file.path)) {
1227
+ if (!await import_fs_extra9.default.exists(file.path)) {
1173
1228
  continue;
1174
1229
  }
1175
1230
  debug(`deleting: ${relativePath}`);
1176
- await import_fs_extra8.default.remove(file.path);
1231
+ await import_fs_extra9.default.remove(file.path);
1177
1232
  }
1178
1233
  }
1179
1234
  };
1180
1235
 
1181
1236
  // src/services/registry.ts
1182
- var import_node_path12 = __toESM(require("path"));
1183
- var import_fs_extra9 = __toESM(require("fs-extra"));
1237
+ var import_node_path13 = __toESM(require("path"));
1238
+ var import_fs_extra10 = __toESM(require("fs-extra"));
1184
1239
  var import_merge = __toESM(require("lodash/merge"));
1185
- var registriesDataPath = import_node_path12.default.join(appPaths.data, "registries");
1240
+ var registriesDataPath = import_node_path13.default.join(appPaths.data, "registries");
1186
1241
  var upeToDate = false;
1187
1242
  var cacheDirNameForRegistry = (registry) => {
1188
1243
  return encodeURIComponent(registry).replace(/%/g, "_");
@@ -1191,27 +1246,27 @@ var getConfiguredRegistryDirs = () => {
1191
1246
  const config = getLocalConfig();
1192
1247
  return config.registries.map((registry) => ({
1193
1248
  registry,
1194
- dir: import_node_path12.default.join(registriesDataPath, cacheDirNameForRegistry(registry))
1249
+ dir: import_node_path13.default.join(registriesDataPath, cacheDirNameForRegistry(registry))
1195
1250
  }));
1196
1251
  };
1197
1252
  var syncRegistries = async (branch) => {
1198
1253
  if (upeToDate) return;
1199
1254
  upeToDate = true;
1200
1255
  debug("Sync registries");
1201
- import_fs_extra9.default.ensureDirSync(registriesDataPath);
1256
+ import_fs_extra10.default.ensureDirSync(registriesDataPath);
1202
1257
  const config = getLocalConfig();
1203
1258
  return await runTask("Update registries", async () => {
1204
1259
  await Promise.all(
1205
1260
  config.registries.map(async (registry) => {
1206
1261
  debug(`update registry: ${registry}`);
1207
1262
  const repoName = cacheDirNameForRegistry(registry);
1208
- const repoDir = import_node_path12.default.join(registriesDataPath, repoName);
1209
- if (!import_fs_extra9.default.existsSync(repoDir)) {
1263
+ const repoDir = import_node_path13.default.join(registriesDataPath, repoName);
1264
+ if (!import_fs_extra10.default.existsSync(repoDir)) {
1210
1265
  await git.clone(registry, repoName, branch, {
1211
1266
  cwd: registriesDataPath,
1212
1267
  depth: 1
1213
1268
  });
1214
- } else if (import_fs_extra9.default.existsSync(import_node_path12.default.join(repoDir, ".git"))) {
1269
+ } else if (import_fs_extra10.default.existsSync(import_node_path13.default.join(repoDir, ".git"))) {
1215
1270
  await git.update({ cwd: repoDir });
1216
1271
  } else {
1217
1272
  debug(`local registry`);
@@ -1224,9 +1279,9 @@ var getAvailableTemplates = async () => {
1224
1279
  debug("Get available templates");
1225
1280
  const templates = {};
1226
1281
  for (const { dir } of getConfiguredRegistryDirs()) {
1227
- const indexPath = import_node_path12.default.join(dir, "index.json");
1228
- if (import_fs_extra9.default.existsSync(indexPath)) {
1229
- const data = import_fs_extra9.default.readJSONSync(indexPath);
1282
+ const indexPath = import_node_path13.default.join(dir, "index.json");
1283
+ if (import_fs_extra10.default.existsSync(indexPath)) {
1284
+ const data = import_fs_extra10.default.readJSONSync(indexPath);
1230
1285
  Object.entries(data.templates || {}).forEach(([templateName, template]) => {
1231
1286
  if (!template.source) {
1232
1287
  template.source = `/template-${templateName}`;
@@ -1267,17 +1322,17 @@ var getAvailableBlocks = async (templateInfo) => {
1267
1322
  };
1268
1323
  var getAvailableVersions = async (source) => {
1269
1324
  for (const { dir } of getConfiguredRegistryDirs()) {
1270
- const indexPath = import_node_path12.default.join(dir, "index.json");
1271
- if (!import_fs_extra9.default.existsSync(indexPath)) continue;
1272
- const registryData = import_fs_extra9.default.readJSONSync(indexPath);
1273
- const versionDirPath = import_node_path12.default.join(dir, "versions");
1325
+ const indexPath = import_node_path13.default.join(dir, "index.json");
1326
+ if (!import_fs_extra10.default.existsSync(indexPath)) continue;
1327
+ const registryData = import_fs_extra10.default.readJSONSync(indexPath);
1328
+ const versionDirPath = import_node_path13.default.join(dir, "versions");
1274
1329
  const versionsFilePaths = [
1275
- import_node_path12.default.join(versionDirPath, `${source.replace(`${registryData.baseUrl}/`, "")}.json`),
1276
- import_node_path12.default.join(versionDirPath, `${encodeURIComponent(source)}.json`)
1330
+ import_node_path13.default.join(versionDirPath, `${source.replace(`${registryData.baseUrl}/`, "")}.json`),
1331
+ import_node_path13.default.join(versionDirPath, `${encodeURIComponent(source)}.json`)
1277
1332
  ];
1278
1333
  for (const versionsFile of versionsFilePaths) {
1279
- if (import_fs_extra9.default.existsSync(versionsFile)) {
1280
- return import_fs_extra9.default.readJSONSync(versionsFile);
1334
+ if (import_fs_extra10.default.existsSync(versionsFile)) {
1335
+ return import_fs_extra10.default.readJSONSync(versionsFile);
1281
1336
  }
1282
1337
  }
1283
1338
  }
@@ -1414,7 +1469,7 @@ var addBlock = async (block, blocks, branch, destination) => {
1414
1469
  }
1415
1470
  const blockPath = `blocks/${destination}`;
1416
1471
  let newBlockAdded = false;
1417
- if (!import_fs_extra10.default.existsSync(blockPath)) {
1472
+ if (!import_fs_extra11.default.existsSync(blockPath)) {
1418
1473
  newBlockAdded = true;
1419
1474
  await runTask(
1420
1475
  { start: `Fetching block: ${block}`, end: `Added block: ${block}` },
@@ -1543,7 +1598,7 @@ var ContributionTargetType = /* @__PURE__ */ ((ContributionTargetType2) => {
1543
1598
  })(ContributionTargetType || {});
1544
1599
 
1545
1600
  // src/services/contribute/utils/bloxCheckpoint.ts
1546
- var import_node_path13 = __toESM(require("path"));
1601
+ var import_node_path14 = __toESM(require("path"));
1547
1602
  function getCheckpointForTarget(cwd, target) {
1548
1603
  const bloxDir = getBloxDirForTarget(cwd, target);
1549
1604
  const blox = getBloxFile(bloxDir);
@@ -1553,7 +1608,7 @@ function getCheckpointForTarget(cwd, target) {
1553
1608
  }
1554
1609
  function getBloxDirForTarget(cwd, target) {
1555
1610
  if (target.type === "block" /* BLOCK */) {
1556
- return import_node_path13.default.join(cwd, blocksDir, target.name);
1611
+ return import_node_path14.default.join(cwd, blocksDir, target.name);
1557
1612
  }
1558
1613
  return cwd;
1559
1614
  }
@@ -1823,28 +1878,28 @@ ${prUrl}` : "\nPush completed.")
1823
1878
  };
1824
1879
 
1825
1880
  // src/services/contribute/services/CommitApplierService.ts
1826
- var import_node_path15 = __toESM(require("path"));
1827
- var import_fs_extra12 = __toESM(require("fs-extra"));
1881
+ var import_node_path16 = __toESM(require("path"));
1882
+ var import_fs_extra13 = __toESM(require("fs-extra"));
1828
1883
 
1829
1884
  // src/services/contribute/config/index.ts
1830
1885
  var tempRepoName = "tmp";
1831
1886
  var bloxConfigControlledKeys = ["checkpoints", "project"];
1832
1887
 
1833
1888
  // src/services/contribute/utils/getExcludedPrefixesForTarget.ts
1834
- var import_node_path14 = __toESM(require("path"));
1835
- var import_fs_extra11 = __toESM(require("fs-extra"));
1889
+ var import_node_path15 = __toESM(require("path"));
1890
+ var import_fs_extra12 = __toESM(require("fs-extra"));
1836
1891
  function getExcludedPrefixesForTarget(target, cwd) {
1837
1892
  if (target.type === "block" /* BLOCK */) {
1838
1893
  return [];
1839
1894
  }
1840
1895
  const excluded = [];
1841
- const blocksPath = import_node_path14.default.join(cwd, blocksDir);
1842
- if (import_fs_extra11.default.existsSync(blocksPath)) {
1843
- const entries = import_fs_extra11.default.readdirSync(blocksPath, { withFileTypes: true });
1896
+ const blocksPath = import_node_path15.default.join(cwd, blocksDir);
1897
+ if (import_fs_extra12.default.existsSync(blocksPath)) {
1898
+ const entries = import_fs_extra12.default.readdirSync(blocksPath, { withFileTypes: true });
1844
1899
  for (const entry of entries) {
1845
1900
  if (!entry.isDirectory()) continue;
1846
- const blockBloxFile = import_node_path14.default.join(blocksPath, entry.name, bloxFilePath);
1847
- if (import_fs_extra11.default.existsSync(blockBloxFile)) {
1901
+ const blockBloxFile = import_node_path15.default.join(blocksPath, entry.name, bloxFilePath);
1902
+ if (import_fs_extra12.default.existsSync(blockBloxFile)) {
1848
1903
  excluded.push(normalizePath(`${blocksDir}/${entry.name}/`));
1849
1904
  }
1850
1905
  }
@@ -2022,8 +2077,8 @@ ${e instanceof Error ? e.message : String(e)}`);
2022
2077
  }
2023
2078
  const withoutGovernedKeys = omitKeys(stagedJson, bloxConfigControlledKeys);
2024
2079
  try {
2025
- const outPath = import_node_path15.default.join(tmpRepoCwd, file);
2026
- await import_fs_extra12.default.outputFile(outPath, JSON.stringify(withoutGovernedKeys, null, 2));
2080
+ const outPath = import_node_path16.default.join(tmpRepoCwd, file);
2081
+ await import_fs_extra13.default.outputFile(outPath, JSON.stringify(withoutGovernedKeys, null, 2));
2027
2082
  await git.add(file, tmpRepoCwd);
2028
2083
  } catch (e) {
2029
2084
  this.logger.warn("apply.commit.blox_merge_fallback", {
@@ -2137,13 +2192,13 @@ var CommitSelectorService = class {
2137
2192
  };
2138
2193
 
2139
2194
  // src/services/contribute/utils/discoverContributionTargets.ts
2140
- var import_node_path16 = __toESM(require("path"));
2141
- var import_fs_extra13 = __toESM(require("fs-extra"));
2195
+ var import_node_path17 = __toESM(require("path"));
2196
+ var import_fs_extra14 = __toESM(require("fs-extra"));
2142
2197
  var readBloxFileIfExists = (cwd) => {
2143
- const p = import_node_path16.default.join(cwd, bloxFilePath);
2144
- if (!import_fs_extra13.default.existsSync(p)) return;
2198
+ const p = import_node_path17.default.join(cwd, bloxFilePath);
2199
+ if (!import_fs_extra14.default.existsSync(p)) return;
2145
2200
  try {
2146
- return import_fs_extra13.default.readJSONSync(p);
2201
+ return import_fs_extra14.default.readJSONSync(p);
2147
2202
  } catch {
2148
2203
  return;
2149
2204
  }
@@ -2171,13 +2226,13 @@ var discoverContributionTargets = (cwd) => {
2171
2226
  });
2172
2227
  }
2173
2228
  }
2174
- const blocksPath = import_node_path16.default.join(cwd, blocksDir);
2175
- if (import_fs_extra13.default.existsSync(blocksPath)) {
2176
- const entries = import_fs_extra13.default.readdirSync(blocksPath, { withFileTypes: true });
2229
+ const blocksPath = import_node_path17.default.join(cwd, blocksDir);
2230
+ if (import_fs_extra14.default.existsSync(blocksPath)) {
2231
+ const entries = import_fs_extra14.default.readdirSync(blocksPath, { withFileTypes: true });
2177
2232
  for (const entry of entries) {
2178
2233
  if (!entry.isDirectory()) continue;
2179
2234
  const blockName = entry.name;
2180
- const blockBlox = readBloxFileIfExists(import_node_path16.default.join(blocksPath, blockName));
2235
+ const blockBlox = readBloxFileIfExists(import_node_path17.default.join(blocksPath, blockName));
2181
2236
  if (!blockBlox?.definition?.name) continue;
2182
2237
  const def = blockBlox.definition;
2183
2238
  const templateName = def.templates?.[0]?.name || appTemplateName;
@@ -2460,8 +2515,8 @@ ${fmt.cyan(createPageUrl)}
2460
2515
 
2461
2516
  // src/services/contribute/services/TmpRepoService.ts
2462
2517
  var import_node_os2 = require("os");
2463
- var import_node_path17 = __toESM(require("path"));
2464
- var import_fs_extra14 = __toESM(require("fs-extra"));
2518
+ var import_node_path18 = __toESM(require("path"));
2519
+ var import_fs_extra15 = __toESM(require("fs-extra"));
2465
2520
  var TmpRepoService = class {
2466
2521
  constructor(logger) {
2467
2522
  this.logger = logger;
@@ -2478,7 +2533,7 @@ var TmpRepoService = class {
2478
2533
  }
2479
2534
  async getTmpDir(target) {
2480
2535
  const slug = `${target.type}-${target.name}`.replace(/[^a-zA-Z0-9._-]+/g, "-");
2481
- return import_node_path17.default.join((0, import_node_os2.homedir)(), bloxFilePath, tempRepoName, slug);
2536
+ return import_node_path18.default.join((0, import_node_os2.homedir)(), bloxFilePath, tempRepoName, slug);
2482
2537
  }
2483
2538
  async prepare(opts) {
2484
2539
  const taskSpinner = spinner();
@@ -2490,7 +2545,7 @@ var TmpRepoService = class {
2490
2545
  repoUrl: opts.repoUrl,
2491
2546
  branch: opts.branch
2492
2547
  });
2493
- if (await import_fs_extra14.default.pathExists(dir)) {
2548
+ if (await import_fs_extra15.default.pathExists(dir)) {
2494
2549
  this.logger.debug(`${tempRepoName} reuse_tmp_local_repo`, { dir });
2495
2550
  try {
2496
2551
  await this.refreshExistingTmpRepo(dir, opts.branch);
@@ -2501,10 +2556,10 @@ var TmpRepoService = class {
2501
2556
  dir,
2502
2557
  message: e instanceof Error ? e.message : String(e)
2503
2558
  });
2504
- await import_fs_extra14.default.remove(dir);
2559
+ await import_fs_extra15.default.remove(dir);
2505
2560
  }
2506
2561
  }
2507
- await import_fs_extra14.default.ensureDir(import_node_path17.default.dirname(dir));
2562
+ await import_fs_extra15.default.ensureDir(import_node_path18.default.dirname(dir));
2508
2563
  await git.clone(opts.repoUrl, dir, opts.branch);
2509
2564
  taskSpinner.stop("Prepared tmp repo");
2510
2565
  return dir;
@@ -2592,7 +2647,7 @@ var detach = command("detach").description("Migrate blox schema").option("--basi
2592
2647
  });
2593
2648
 
2594
2649
  // src/commands/init/index.ts
2595
- var import_fs_extra15 = __toESM(require("fs-extra"));
2650
+ var import_fs_extra16 = __toESM(require("fs-extra"));
2596
2651
  var init2 = command("init").description("Init new app").alias("i").option("-n, --name <name>", "App name").option("-t, --template <template>", "Template to use").option("--branch <name>", "branch name").action(async ({ name, template, branch }) => {
2597
2652
  await syncRegistries();
2598
2653
  try {
@@ -2633,8 +2688,8 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
2633
2688
  task.stop(`App initialized in ${name}`);
2634
2689
  await runLifecycleHookWithTask(name || "", "init", "Run template init");
2635
2690
  } catch (e) {
2636
- if (name && import_fs_extra15.default.existsSync(name)) {
2637
- await import_fs_extra15.default.remove(name);
2691
+ if (name && import_fs_extra16.default.existsSync(name)) {
2692
+ await import_fs_extra16.default.remove(name);
2638
2693
  }
2639
2694
  error(e);
2640
2695
  }
@@ -2654,30 +2709,30 @@ var migrateSchema = command("migrate").description("Migrate blox schema").action
2654
2709
  });
2655
2710
 
2656
2711
  // src/commands/remove/index.ts
2657
- var import_node_path18 = __toESM(require("path"));
2658
- var import_fs_extra16 = __toESM(require("fs-extra"));
2659
- var blocksAbsolutePath = () => import_node_path18.default.resolve(process.cwd(), blocksDir);
2712
+ var import_node_path19 = __toESM(require("path"));
2713
+ var import_fs_extra17 = __toESM(require("fs-extra"));
2714
+ var blocksAbsolutePath = () => import_node_path19.default.resolve(process.cwd(), blocksDir);
2660
2715
  function listInstalledBlockRelPaths() {
2661
2716
  const root = blocksAbsolutePath();
2662
- if (!import_fs_extra16.default.existsSync(root)) {
2717
+ if (!import_fs_extra17.default.existsSync(root)) {
2663
2718
  return [];
2664
2719
  }
2665
2720
  const paths2 = [];
2666
- for (const entry of import_fs_extra16.default.readdirSync(root, { withFileTypes: true })) {
2721
+ for (const entry of import_fs_extra17.default.readdirSync(root, { withFileTypes: true })) {
2667
2722
  if (!entry.isDirectory()) {
2668
2723
  continue;
2669
2724
  }
2670
- const abs = import_node_path18.default.join(root, entry.name);
2725
+ const abs = import_node_path19.default.join(root, entry.name);
2671
2726
  if (!isBlockDirectory(abs)) {
2672
2727
  continue;
2673
2728
  }
2674
- paths2.push(import_node_path18.default.join(blocksDir, entry.name));
2729
+ paths2.push(import_node_path19.default.join(blocksDir, entry.name));
2675
2730
  }
2676
2731
  return paths2;
2677
2732
  }
2678
2733
  function getInstalledBlockSelectOptions() {
2679
2734
  return listInstalledBlockRelPaths().map((rel) => {
2680
- const folder = import_node_path18.default.basename(rel);
2735
+ const folder = import_node_path19.default.basename(rel);
2681
2736
  const def = getBlockDef(rel);
2682
2737
  const label = def?.name && def.name !== folder ? `${def.name} (${folder})` : folder;
2683
2738
  return { value: folder, label, hint: def?.name };
@@ -2685,7 +2740,7 @@ function getInstalledBlockSelectOptions() {
2685
2740
  }
2686
2741
  function assertNoDependents(blockPathAbs, targetBlockName) {
2687
2742
  for (const rel of listInstalledBlockRelPaths()) {
2688
- const abs = import_node_path18.default.resolve(process.cwd(), rel);
2743
+ const abs = import_node_path19.default.resolve(process.cwd(), rel);
2689
2744
  if (abs === blockPathAbs) {
2690
2745
  continue;
2691
2746
  }
@@ -2701,19 +2756,19 @@ function assertNoDependents(blockPathAbs, targetBlockName) {
2701
2756
  }
2702
2757
  function assertUnderBlocksRoot(blockPathAbs) {
2703
2758
  const root = blocksAbsolutePath();
2704
- const rel = import_node_path18.default.relative(root, blockPathAbs);
2705
- if (!rel || rel.startsWith("..") || import_node_path18.default.isAbsolute(rel)) {
2759
+ const rel = import_node_path19.default.relative(root, blockPathAbs);
2760
+ if (!rel || rel.startsWith("..") || import_node_path19.default.isAbsolute(rel)) {
2706
2761
  throw new Error("Block path escapes the blocks directory");
2707
2762
  }
2708
2763
  }
2709
2764
  async function removeBlock(block, blocks, force = false) {
2710
2765
  const reg = blocks[block];
2711
2766
  const destination = reg ? reg.destination ?? block : block;
2712
- const blockPathRel = import_node_path18.default.join(blocksDir, destination);
2713
- const blockPathAbs = import_node_path18.default.resolve(process.cwd(), blockPathRel);
2767
+ const blockPathRel = import_node_path19.default.join(blocksDir, destination);
2768
+ const blockPathAbs = import_node_path19.default.resolve(process.cwd(), blockPathRel);
2714
2769
  assertUnderBlocksRoot(blockPathAbs);
2715
- if (!import_fs_extra16.default.existsSync(blockPathAbs) || !isBlockDirectory(blockPathAbs)) {
2716
- throw new Error(`Block is not installed at ${import_node_path18.default.relative(process.cwd(), blockPathAbs)}`);
2770
+ if (!import_fs_extra17.default.existsSync(blockPathAbs) || !isBlockDirectory(blockPathAbs)) {
2771
+ throw new Error(`Block is not installed at ${import_node_path19.default.relative(process.cwd(), blockPathAbs)}`);
2717
2772
  }
2718
2773
  const targetDef = getBlockDef(blockPathRel);
2719
2774
  if (!targetDef?.name) {
@@ -2725,7 +2780,7 @@ async function removeBlock(block, blocks, force = false) {
2725
2780
  await runLifecycleHookWithTask(blockPathRel, "remove", "Run block remove");
2726
2781
  await runTask("Remove block files", async () => {
2727
2782
  assertUnderBlocksRoot(blockPathAbs);
2728
- await import_fs_extra16.default.remove(blockPathAbs);
2783
+ await import_fs_extra17.default.remove(blockPathAbs);
2729
2784
  });
2730
2785
  return true;
2731
2786
  }
@@ -2783,17 +2838,17 @@ var remove = command("remove").description("Remove block from app").alias("rm").
2783
2838
  // src/commands/skills/index.ts
2784
2839
  var import_node_crypto = require("crypto");
2785
2840
  var import_node_os3 = __toESM(require("os"));
2786
- var import_node_path20 = __toESM(require("path"));
2841
+ var import_node_path21 = __toESM(require("path"));
2787
2842
  var import_cross_spawn2 = __toESM(require("cross-spawn"));
2788
- var import_fs_extra18 = __toESM(require("fs-extra"));
2843
+ var import_fs_extra19 = __toESM(require("fs-extra"));
2789
2844
 
2790
2845
  // src/commands/skills/constants.ts
2791
2846
  var SKILLS_REPO_URL = "https://tfs.aas.com.sa/Medad/BLOX/_git/cli";
2792
2847
  var SKILLS_TEMP_ROOT_PREFIX = "blox-skills";
2793
2848
 
2794
2849
  // src/commands/skills/utils/cliCompatibility.ts
2795
- var import_node_path19 = __toESM(require("path"));
2796
- var import_fs_extra17 = __toESM(require("fs-extra"));
2850
+ var import_node_path20 = __toESM(require("path"));
2851
+ var import_fs_extra18 = __toESM(require("fs-extra"));
2797
2852
  var import_semver = __toESM(require("semver"));
2798
2853
  var SKILLS_CLI_COMPATIBILITY_COMMANDS = ["add", "update"];
2799
2854
  function getSkillscommandIndex(args, subcommand) {
@@ -2817,18 +2872,18 @@ function getAddCommandIndex(args) {
2817
2872
  return getSkillscommandIndex(args, "add");
2818
2873
  }
2819
2874
  async function loadSkillsData(cloneRoot) {
2820
- const skillsDir = import_node_path19.default.join(cloneRoot, "skills");
2821
- if (!await import_fs_extra17.default.pathExists(skillsDir)) {
2875
+ const skillsDir = import_node_path20.default.join(cloneRoot, "skills");
2876
+ if (!await import_fs_extra18.default.pathExists(skillsDir)) {
2822
2877
  return [];
2823
2878
  }
2824
- const entries = await import_fs_extra17.default.readdir(skillsDir, { withFileTypes: true });
2879
+ const entries = await import_fs_extra18.default.readdir(skillsDir, { withFileTypes: true });
2825
2880
  const manifests = await Promise.all(
2826
2881
  entries.filter((entry) => entry.isDirectory()).map(async (entry) => {
2827
- const filePath = import_node_path19.default.join(skillsDir, entry.name, "skill.json");
2828
- if (!await import_fs_extra17.default.pathExists(filePath)) {
2882
+ const filePath = import_node_path20.default.join(skillsDir, entry.name, "skill.json");
2883
+ if (!await import_fs_extra18.default.pathExists(filePath)) {
2829
2884
  return null;
2830
2885
  }
2831
- const raw = await import_fs_extra17.default.readJson(filePath);
2886
+ const raw = await import_fs_extra18.default.readJson(filePath);
2832
2887
  const range = raw.cliCompatibility?.trim();
2833
2888
  if (!range) {
2834
2889
  return null;
@@ -2879,8 +2934,8 @@ var skills = command("skills").description("Install, update, and manage BLOX CLI
2879
2934
  async function runSkills() {
2880
2935
  const idx = process.argv.indexOf("skills");
2881
2936
  const args = idx === -1 ? [] : process.argv.slice(idx + 1);
2882
- const tempDir = import_node_path20.default.join(import_node_os3.default.tmpdir(), `${SKILLS_TEMP_ROOT_PREFIX}-${(0, import_node_crypto.randomUUID)()}`);
2883
- await import_fs_extra18.default.mkdir(tempDir);
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);
2884
2939
  let exitCode = 1;
2885
2940
  try {
2886
2941
  await git.clone(SKILLS_REPO_URL, tempDir);
@@ -2899,11 +2954,11 @@ async function runSkills() {
2899
2954
  }
2900
2955
  }
2901
2956
  }
2902
- const finalArgs = injectRepoPathIfAdd(args, import_node_path20.default.resolve(tempDir));
2957
+ const finalArgs = injectRepoPathIfAdd(args, import_node_path21.default.resolve(tempDir));
2903
2958
  exitCode = await runSkillsCommand(finalArgs, process.cwd());
2904
2959
  } finally {
2905
2960
  try {
2906
- await import_fs_extra18.default.remove(tempDir);
2961
+ await import_fs_extra19.default.remove(tempDir);
2907
2962
  } catch {
2908
2963
  debug(`Failed to cleanup temp dir: ${tempDir}`);
2909
2964
  }
@@ -2937,11 +2992,11 @@ function runSkillsCommand(args, cwd) {
2937
2992
  var import_prompts23 = require("@clack/prompts");
2938
2993
 
2939
2994
  // src/commands/update/utils.ts
2940
- var import_node_path22 = __toESM(require("path"));
2995
+ var import_node_path23 = __toESM(require("path"));
2941
2996
 
2942
2997
  // src/services/updater.ts
2943
- var import_node_path21 = __toESM(require("path"));
2944
- var import_fs_extra19 = __toESM(require("fs-extra"));
2998
+ var import_node_path22 = __toESM(require("path"));
2999
+ var import_fs_extra20 = __toESM(require("fs-extra"));
2945
3000
  var import_klaw3 = __toESM(require("klaw"));
2946
3001
  async function updateFromRemote({
2947
3002
  name,
@@ -2988,9 +3043,9 @@ async function updateFromRemote({
2988
3043
  const remoteIgnore = remoteBloxFile.definition?.ignore || [];
2989
3044
  const projectIgnore = bloxFile.project?.ignore || [];
2990
3045
  ignore3.push(...remoteIgnore, ...projectIgnore, bloxFilePath, `**/${bloxFilePath}`);
2991
- const gitIgnorePath = import_node_path21.default.join(dir, ".gitignore");
2992
- if (await import_fs_extra19.default.pathExists(gitIgnorePath)) {
2993
- const gitIgnoreContent = await import_fs_extra19.default.readFile(gitIgnorePath, "utf8");
3046
+ const gitIgnorePath = import_node_path22.default.join(dir, ".gitignore");
3047
+ if (await import_fs_extra20.default.pathExists(gitIgnorePath)) {
3048
+ const gitIgnoreContent = await import_fs_extra20.default.readFile(gitIgnorePath, "utf8");
2994
3049
  const gitIgnorePatterns = gitIgnoreContent.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
2995
3050
  ignore3.push(...gitIgnorePatterns);
2996
3051
  debug(`Added ${gitIgnorePatterns.length} patterns from .gitignore`);
@@ -3002,14 +3057,14 @@ async function updateFromRemote({
3002
3057
  if (hard) {
3003
3058
  const getAllFiles = async (d) => {
3004
3059
  const files = [];
3005
- if (await import_fs_extra19.default.pathExists(d)) {
3060
+ if (await import_fs_extra20.default.pathExists(d)) {
3006
3061
  for await (const file of (0, import_klaw3.default)(d)) {
3007
3062
  if (file.path.includes("/.git/") || file.path.endsWith("/.git") || file.path.includes("\\.git\\") || file.path.endsWith("\\.git"))
3008
3063
  continue;
3009
3064
  if (file.path.includes("/node_modules/") || file.path.includes("\\node_modules\\"))
3010
3065
  continue;
3011
3066
  if (file.stats.isFile()) {
3012
- files.push(import_node_path21.default.relative(d, file.path));
3067
+ files.push(import_node_path22.default.relative(d, file.path));
3013
3068
  }
3014
3069
  }
3015
3070
  }
@@ -3028,23 +3083,23 @@ async function updateFromRemote({
3028
3083
  for (const file of filesToProcess) {
3029
3084
  if (file === ".git" || file.startsWith(".git/") || file.startsWith(".git\\")) continue;
3030
3085
  if (ignoredMatcher.ignores(toIgnorePath(file))) continue;
3031
- const localPath = import_node_path21.default.join(dir, file);
3032
- const basePath = import_node_path21.default.join(baseDir, file);
3033
- const remotePath = import_node_path21.default.join(remoteDir, file);
3034
- const existsLocal = await import_fs_extra19.default.pathExists(localPath);
3035
- const existsBase = await import_fs_extra19.default.pathExists(basePath);
3036
- const existsRemote = await import_fs_extra19.default.pathExists(remotePath);
3037
- const ext = import_node_path21.default.extname(file);
3086
+ const localPath = import_node_path22.default.join(dir, file);
3087
+ const basePath = import_node_path22.default.join(baseDir, file);
3088
+ const remotePath = import_node_path22.default.join(remoteDir, file);
3089
+ const existsLocal = await import_fs_extra20.default.pathExists(localPath);
3090
+ const existsBase = await import_fs_extra20.default.pathExists(basePath);
3091
+ const existsRemote = await import_fs_extra20.default.pathExists(remotePath);
3092
+ const ext = import_node_path22.default.extname(file);
3038
3093
  const isBinary = isBinaryFile(ext);
3039
3094
  if (existsRemote) {
3040
- await import_fs_extra19.default.ensureDir(import_node_path21.default.dirname(localPath));
3095
+ await import_fs_extra20.default.ensureDir(import_node_path22.default.dirname(localPath));
3041
3096
  }
3042
3097
  if (hard) {
3043
3098
  if (existsRemote) {
3044
- await import_fs_extra19.default.copy(remotePath, localPath, { overwrite: true });
3099
+ await import_fs_extra20.default.copy(remotePath, localPath, { overwrite: true });
3045
3100
  debug(`Hard update: Overwrote ${file}`);
3046
3101
  } else if (existsLocal) {
3047
- await import_fs_extra19.default.remove(localPath);
3102
+ await import_fs_extra20.default.remove(localPath);
3048
3103
  debug(`Hard update: Removed ${file}`);
3049
3104
  }
3050
3105
  continue;
@@ -3053,29 +3108,29 @@ async function updateFromRemote({
3053
3108
  if (existsLocal) {
3054
3109
  if (isBinary) {
3055
3110
  debug(`Binary collision: ${file}, overwriting.`);
3056
- await import_fs_extra19.default.copy(remotePath, localPath, { overwrite: true });
3111
+ await import_fs_extra20.default.copy(remotePath, localPath, { overwrite: true });
3057
3112
  logWarningSection(`Overwrote binary file collision: ${file}`);
3058
3113
  } else {
3059
- const emptyBase = import_node_path21.default.join(baseDir, `${file}.empty`);
3060
- await import_fs_extra19.default.ensureFile(emptyBase);
3114
+ const emptyBase = import_node_path22.default.join(baseDir, `${file}.empty`);
3115
+ await import_fs_extra20.default.ensureFile(emptyBase);
3061
3116
  const result = await git.mergeFile(localPath, emptyBase, remotePath);
3062
3117
  if (!result) {
3063
3118
  hasConflicts2 = true;
3064
3119
  conflictFiles.push(file);
3065
3120
  }
3066
- await import_fs_extra19.default.remove(emptyBase);
3121
+ await import_fs_extra20.default.remove(emptyBase);
3067
3122
  }
3068
3123
  } else {
3069
- await import_fs_extra19.default.copy(remotePath, localPath);
3124
+ await import_fs_extra20.default.copy(remotePath, localPath);
3070
3125
  }
3071
3126
  continue;
3072
3127
  }
3073
3128
  if (existsBase && !existsRemote) {
3074
3129
  if (existsLocal) {
3075
- const localBuffer = await import_fs_extra19.default.readFile(localPath);
3076
- const baseBuffer = await import_fs_extra19.default.readFile(basePath);
3130
+ const localBuffer = await import_fs_extra20.default.readFile(localPath);
3131
+ const baseBuffer = await import_fs_extra20.default.readFile(basePath);
3077
3132
  if (localBuffer.equals(baseBuffer)) {
3078
- await import_fs_extra19.default.remove(localPath);
3133
+ await import_fs_extra20.default.remove(localPath);
3079
3134
  } else {
3080
3135
  logWarningSection(
3081
3136
  `File ${file} was deleted in remote but modified locally. Kept local version.`
@@ -3086,7 +3141,7 @@ async function updateFromRemote({
3086
3141
  }
3087
3142
  if (existsBase && existsRemote) {
3088
3143
  if (!existsLocal) {
3089
- await import_fs_extra19.default.copy(remotePath, localPath);
3144
+ await import_fs_extra20.default.copy(remotePath, localPath);
3090
3145
  logWarningSection(
3091
3146
  `File restored: ${file}`,
3092
3147
  `This file was deleted locally but updated in the remote block.
@@ -3095,7 +3150,7 @@ It has been recreated to apply upstream changes.`
3095
3150
  continue;
3096
3151
  }
3097
3152
  if (isBinary) {
3098
- await import_fs_extra19.default.copy(remotePath, localPath, { overwrite: true });
3153
+ await import_fs_extra20.default.copy(remotePath, localPath, { overwrite: true });
3099
3154
  logWarningSection(`Updated binary file: ${file} (overwritten)`);
3100
3155
  } else {
3101
3156
  const result = await git.mergeFile(localPath, basePath, remotePath);
@@ -3172,7 +3227,7 @@ async function updateApp({
3172
3227
  continue;
3173
3228
  }
3174
3229
  await git.updateRemote(block.name, blockRegistryData.source);
3175
- const blockPath = import_node_path22.default.join(blocksDir, block.name);
3230
+ const blockPath = import_node_path23.default.join(blocksDir, block.name);
3176
3231
  const currentBloxFile = getBloxFile(blockPath);
3177
3232
  const remoteBloxFile = (await migrateOnRemote(block.name, toAppCommit, blockPath)).output[".blox"];
3178
3233
  const blockFromCommit = currentBloxFile.checkpoints?.[block.name]?.commit;
@@ -3219,7 +3274,7 @@ async function updateAppBases(templateDef, templates, ignore3, hard = false) {
3219
3274
  }
3220
3275
  async function updateBlock(block, blocks, ignore3, hard = false) {
3221
3276
  const blockRegistryData = blocks[block];
3222
- const blockPath = import_node_path22.default.join(blocksDir, block);
3277
+ const blockPath = import_node_path23.default.join(blocksDir, block);
3223
3278
  let updated = false;
3224
3279
  let shouldContinue = true;
3225
3280
  await runTask({ start: `Update block: ${block}`, end: `Updated block: ${block}` }, async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naseej/blox",
3
- "version": "1.6.3",
3
+ "version": "1.7.0",
4
4
  "description": "blox cli",
5
5
  "bin": {
6
6
  "blox": "./bin/run"
@@ -28,6 +28,8 @@
28
28
  "lint:stage": "yarn lint -- -c .eslintrc.staging.cjs",
29
29
  "watch": "tsc --watch",
30
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",
31
33
  "prepare": "husky",
32
34
  "postinstall": "patch-package"
33
35
  },
@@ -80,6 +82,7 @@
80
82
  "klaw": "^4.1.0",
81
83
  "lodash": "^4.17.21",
82
84
  "ms": "2.1.3",
83
- "semver": "^7.7.4"
85
+ "semver": "^7.7.4",
86
+ "zod": "^4.4.3"
84
87
  }
85
88
  }