@naseej/blox 0.1.27 → 0.1.29

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 +22 -20
  2. package/package.json +1 -1
package/dist/run.js CHANGED
@@ -31,7 +31,7 @@ var option = (flags, description) => {
31
31
  };
32
32
 
33
33
  // package.json
34
- var version = "0.1.27";
34
+ var version = "0.1.29";
35
35
 
36
36
  // src/commands/add/index.ts
37
37
  var import_fs_extra7 = __toESM(require("fs-extra"));
@@ -52,6 +52,7 @@ var import_node_path4 = __toESM(require("path"));
52
52
  var import_dayjs = __toESM(require("dayjs"));
53
53
  var import_fs_extra4 = __toESM(require("fs-extra"));
54
54
  var import_klaw = __toESM(require("klaw"));
55
+ var import_merge = __toESM(require("lodash/merge"));
55
56
  var import_ms = __toESM(require("ms"));
56
57
 
57
58
  // src/config/runtime.ts
@@ -366,10 +367,13 @@ var getAvailableTemplates = async () => {
366
367
  if (file.path.endsWith(".json")) {
367
368
  const data = import_fs_extra4.default.readJSONSync(file.path);
368
369
  Object.keys(data.templates || {}).forEach((templ) => {
369
- templates[templ] = {
370
- ...data.templates[templ],
371
- source: data.templates[templ]?.source || `${data.baseUrl}/template-${templ}`
372
- };
370
+ const source = data.templates[templ]?.source || `${data.baseUrl}/template-${templ}`;
371
+ const template = { ...data.templates[templ], source };
372
+ if (templates[templ]?.source === source) {
373
+ templates[templ] = (0, import_merge.default)(templates[templ], template);
374
+ } else {
375
+ templates[templ] = template;
376
+ }
373
377
  Object.keys(templates[templ].blocks || {}).forEach((blockName) => {
374
378
  const block = templates[templ]?.blocks?.[blockName];
375
379
  if (block && !block.source) {
@@ -395,11 +399,6 @@ var getAvailableBlocks = async (templateInfo) => {
395
399
  return blocks;
396
400
  };
397
401
 
398
- // src/services/updater.ts
399
- var import_node_path6 = __toESM(require("path"));
400
- var import_fs_extra6 = __toESM(require("fs-extra"));
401
- var import_merge = __toESM(require("lodash/merge"));
402
-
403
402
  // src/services/template.ts
404
403
  var import_node_path5 = __toESM(require("path"));
405
404
  var import_ejs = __toESM(require("ejs"));
@@ -457,6 +456,11 @@ function getUsedBlocks() {
457
456
  return blocks;
458
457
  }
459
458
 
459
+ // src/services/updater.ts
460
+ var import_node_path6 = __toESM(require("path"));
461
+ var import_fs_extra6 = __toESM(require("fs-extra"));
462
+ var import_merge2 = __toESM(require("lodash/merge"));
463
+
460
464
  // src/shared/prompts/index.ts
461
465
  var import_prompts4 = require("@clack/prompts");
462
466
  var checkIfCanceled = (value) => {
@@ -500,7 +504,7 @@ async function updateFromRemote(name, source = "", ignore = [], destPath = ".")
500
504
  if (!basedOnInfo.bases) {
501
505
  basedOnInfo.bases = {};
502
506
  }
503
- basedOnInfo.bases = (0, import_merge.default)(basedOnInfo.bases, { [baseName]: baseInfo });
507
+ basedOnInfo.bases = (0, import_merge2.default)(basedOnInfo.bases, { [baseName]: baseInfo });
504
508
  };
505
509
  if (!baseFrom) {
506
510
  updateBase();
@@ -601,20 +605,17 @@ async function updateBlock(block, blocks) {
601
605
  debug(`${block} already updated`);
602
606
  return;
603
607
  }
604
- const blockInfo = blocks[block];
608
+ const blockDef = blocks[block];
609
+ const blockPath = import_node_path7.default.join(blocksDir, block);
605
610
  await runTask({ start: `Update block: ${block}`, end: `Updated block: ${block}` }, async () => {
606
- if (!blockInfo) {
611
+ if (!blockDef) {
607
612
  error("Selected block not available, try to sync registries", false);
608
613
  return;
609
614
  }
610
- await updateFromRemote(
611
- block,
612
- blockInfo.source,
613
- blockInfo.ignore,
614
- import_node_path7.default.join(blocksDir, block)
615
- );
615
+ await updateFromRemote(block, blockDef.source, blockDef.ignore, blockPath);
616
616
  updatedBlocks.add(block);
617
617
  });
618
+ const blockInfo = getTemplateInfo(blockPath);
618
619
  for (const dep of blockInfo?.dependencies || []) {
619
620
  debug(`${block} has dependency on ${dep.name}, will be updated`);
620
621
  await updateBlock(dep.name, blocks);
@@ -650,7 +651,8 @@ var addBlock = async (block, blocks) => {
650
651
  debug(`${block} already exists, will be updated`);
651
652
  await updateBlock(block, blocks);
652
653
  }
653
- for (const dep of blockDef?.dependencies || []) {
654
+ const blockInfo = getTemplateInfo(blockPath);
655
+ for (const dep of blockInfo?.dependencies || []) {
654
656
  await addBlock(dep.name, blocks);
655
657
  }
656
658
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naseej/blox",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "blox cli",
5
5
  "bin": {
6
6
  "blox": "./bin/run"