@naseej/blox 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/run.js +50 -28
- package/package.json +1 -1
package/dist/run.js
CHANGED
|
@@ -581,7 +581,7 @@ var sync = command("sync").description("Sync local registry with remote updates"
|
|
|
581
581
|
}
|
|
582
582
|
});
|
|
583
583
|
|
|
584
|
-
// src/commands/update/
|
|
584
|
+
// src/commands/update/utils.ts
|
|
585
585
|
var import_node_path7 = __toESM(require("path"));
|
|
586
586
|
|
|
587
587
|
// src/services/updater.ts
|
|
@@ -627,43 +627,65 @@ async function updateFromRemote(name, source = "", destPath = ".") {
|
|
|
627
627
|
updateBasedOnInfo({ commit: toCommit }, destPath);
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
// src/commands/update/utils.ts
|
|
631
|
+
async function updateAPP(templateInfo) {
|
|
632
|
+
await runTask("update app", async () => {
|
|
633
|
+
const templates = await getAvailableTemplates();
|
|
634
|
+
const template = templates[templateInfo.name];
|
|
635
|
+
if (!template) {
|
|
636
|
+
error("Selected template not available, try to sync registries");
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
await updateFromRemote(templateInfo.name, template.source);
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
async function updateBlock(block, blockInfo) {
|
|
643
|
+
await runTask(`update block: ${block.name}`, async () => {
|
|
644
|
+
if (!blockInfo) {
|
|
645
|
+
error("Selected block not available, try to sync registries", false);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
await updateFromRemote(block.name, blockInfo.source, import_node_path7.default.join(blocksDir, block.name));
|
|
649
|
+
if (blockInfo.dependencies?.length) {
|
|
650
|
+
import_prompts2.log.warn(
|
|
651
|
+
`${block.name} has deps ${JSON.stringify(blockInfo.dependencies)}, may need to be updated`
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
|
|
630
657
|
// src/commands/update/index.ts
|
|
631
658
|
var update2 = command("update").description("Update app/block").alias("u").addOption(
|
|
632
659
|
option("-s, --scope <scope>", "Scope of update").default("all").choices(["app", "block", "all"])
|
|
633
660
|
).option("-b, --block <name>", "Block to update, valid only with scope block").option("-i, --interactive", "Select version in interactive mode").action(async (args) => {
|
|
634
661
|
const templateInfo = getTemplateInfo();
|
|
635
662
|
if (["all", "app"].includes(args.scope)) {
|
|
636
|
-
await
|
|
637
|
-
const templates = await getAvailableTemplates();
|
|
638
|
-
const template = templates[templateInfo.name];
|
|
639
|
-
if (!template) {
|
|
640
|
-
error("Selected template not available, try to sync registries");
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
await updateFromRemote(templateInfo.name, template.source);
|
|
644
|
-
});
|
|
663
|
+
await updateAPP(templateInfo);
|
|
645
664
|
}
|
|
665
|
+
if (args.scope === "app") return;
|
|
666
|
+
const availableBlocks = await getAvailableBlocks(templateInfo.name);
|
|
667
|
+
const usedBlocks = getUsedBlocks();
|
|
646
668
|
if (args.scope === "all") {
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
);
|
|
660
|
-
if (blockInfo.dependencies?.length) {
|
|
661
|
-
import_prompts2.log.warn(
|
|
662
|
-
`${block.name} has deps ${JSON.stringify(blockInfo.dependencies)}, may need to be updated`
|
|
663
|
-
);
|
|
664
|
-
}
|
|
669
|
+
for (const block of usedBlocks) {
|
|
670
|
+
await updateBlock(block, availableBlocks[block.name]);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (args.scope === "block") {
|
|
674
|
+
if (!args.block) {
|
|
675
|
+
args.block = await select({
|
|
676
|
+
message: "Select block to be updated",
|
|
677
|
+
options: usedBlocks.map((block2) => ({
|
|
678
|
+
value: block2.name,
|
|
679
|
+
label: block2.name
|
|
680
|
+
}))
|
|
665
681
|
});
|
|
666
682
|
}
|
|
683
|
+
const block = usedBlocks.find((block2) => block2.name === args.block);
|
|
684
|
+
if (!block) {
|
|
685
|
+
error("Selected block not used in app");
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
await updateBlock(block, availableBlocks[block.name]);
|
|
667
689
|
}
|
|
668
690
|
});
|
|
669
691
|
|