@naseej/blox 0.1.20 → 0.1.21
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 +44 -18
- 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.
|
|
34
|
+
var version = "0.1.21";
|
|
35
35
|
|
|
36
36
|
// src/commands/add/index.ts
|
|
37
37
|
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
@@ -359,11 +359,15 @@ var getAvailableTemplates = async () => {
|
|
|
359
359
|
debug(templates);
|
|
360
360
|
return templates;
|
|
361
361
|
};
|
|
362
|
-
var getAvailableBlocks = async (
|
|
362
|
+
var getAvailableBlocks = async (templateInfo) => {
|
|
363
363
|
debug("Get available blocks");
|
|
364
364
|
const templates = await getAvailableTemplates();
|
|
365
|
-
const template = templates[
|
|
365
|
+
const template = templates[templateInfo.name];
|
|
366
366
|
const blocks = template?.blocks || {};
|
|
367
|
+
for (const base of templateInfo.bases || []) {
|
|
368
|
+
const baseTemplate = templates[base.name];
|
|
369
|
+
Object.entries(baseTemplate?.blocks || {}).forEach(([k, v]) => blocks[k] = v);
|
|
370
|
+
}
|
|
367
371
|
debug(blocks);
|
|
368
372
|
return blocks;
|
|
369
373
|
};
|
|
@@ -460,9 +464,14 @@ var textList = async (opts) => {
|
|
|
460
464
|
// src/services/updater.ts
|
|
461
465
|
async function updateFromRemote(name, source = "", ignore = [], destPath = ".") {
|
|
462
466
|
debug("Updating from remote");
|
|
463
|
-
|
|
467
|
+
const basedOnInfo = getBasedOnInfo(destPath);
|
|
468
|
+
const fromBasedCommit = basedOnInfo.bases?.[name]?.commit;
|
|
469
|
+
const fromCommit = fromBasedCommit || basedOnInfo.commit;
|
|
470
|
+
if (!fromCommit) {
|
|
471
|
+
debug("Skip update, no fromCommit found");
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
464
474
|
await git.updateRemote(name, source);
|
|
465
|
-
const fromCommit = getBasedOnInfo(destPath).commit;
|
|
466
475
|
const toCommit = await git.getLatestCommitFromRemote(name);
|
|
467
476
|
debug({ fromCommit, toCommit });
|
|
468
477
|
if (fromCommit == toCommit) {
|
|
@@ -495,13 +504,25 @@ async function updateFromRemote(name, source = "", ignore = [], destPath = ".")
|
|
|
495
504
|
);
|
|
496
505
|
}
|
|
497
506
|
await deletePatchFile();
|
|
498
|
-
|
|
507
|
+
if (fromBasedCommit) {
|
|
508
|
+
if (!basedOnInfo.bases) {
|
|
509
|
+
basedOnInfo.bases = {};
|
|
510
|
+
}
|
|
511
|
+
if (!basedOnInfo.bases[name]) {
|
|
512
|
+
basedOnInfo.bases[name] = { commit: toCommit };
|
|
513
|
+
} else {
|
|
514
|
+
basedOnInfo.bases[name].commit = toCommit;
|
|
515
|
+
}
|
|
516
|
+
} else {
|
|
517
|
+
basedOnInfo.commit = toCommit;
|
|
518
|
+
}
|
|
519
|
+
saveBasedOnInfo(basedOnInfo, destPath);
|
|
499
520
|
}
|
|
500
521
|
|
|
501
522
|
// src/commands/update/utils.ts
|
|
502
523
|
async function updateAPP(templateInfo) {
|
|
524
|
+
const templates = await getAvailableTemplates();
|
|
503
525
|
await runTask({ start: "Update App", end: "Updated App" }, async () => {
|
|
504
|
-
const templates = await getAvailableTemplates();
|
|
505
526
|
const template = templates[templateInfo.name];
|
|
506
527
|
if (!template) {
|
|
507
528
|
error("Selected template not available, try to sync registries");
|
|
@@ -509,6 +530,19 @@ async function updateAPP(templateInfo) {
|
|
|
509
530
|
}
|
|
510
531
|
await updateFromRemote(templateInfo.name, template.source, templateInfo.ignore);
|
|
511
532
|
});
|
|
533
|
+
for (const base of templateInfo.bases || []) {
|
|
534
|
+
await runTask(
|
|
535
|
+
{ start: `Update App base: ${base.name}`, end: `Updated App base: ${base.name}` },
|
|
536
|
+
async () => {
|
|
537
|
+
const template = templates[base.name];
|
|
538
|
+
if (!template) {
|
|
539
|
+
error("Selected template not available, try to sync registries");
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
await updateFromRemote(base.name, template.source, []);
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
}
|
|
512
546
|
}
|
|
513
547
|
var updatedBlocks = /* @__PURE__ */ new Set();
|
|
514
548
|
async function updateBlock(block, blocks) {
|
|
@@ -573,7 +607,7 @@ var add = command("add").description("Add block to app").alias("a").argument("[b
|
|
|
573
607
|
await syncRegistries(false, false);
|
|
574
608
|
try {
|
|
575
609
|
const templateInfo = getTemplateInfo();
|
|
576
|
-
const blocks = await getAvailableBlocks(templateInfo
|
|
610
|
+
const blocks = await getAvailableBlocks(templateInfo);
|
|
577
611
|
if (!block) {
|
|
578
612
|
block = await select({
|
|
579
613
|
message: "Select template to be used",
|
|
@@ -650,15 +684,7 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
|
|
|
650
684
|
const commit = await git.getLatestCommitFromPath(name);
|
|
651
685
|
await git.unInit(name);
|
|
652
686
|
await replacePlaceholders(name, { app: { name } });
|
|
653
|
-
|
|
654
|
-
try {
|
|
655
|
-
basedOnInfo = getBasedOnInfo(name);
|
|
656
|
-
} catch (e) {
|
|
657
|
-
debug(`${e}`);
|
|
658
|
-
}
|
|
659
|
-
if (!basedOnInfo?.commit) {
|
|
660
|
-
saveBasedOnInfo({ commit }, name);
|
|
661
|
-
}
|
|
687
|
+
updateBasedOnInfo({ commit }, name);
|
|
662
688
|
await git.init(name);
|
|
663
689
|
await runInitScript(name);
|
|
664
690
|
task.stop(`App initialized in ${name}`);
|
|
@@ -686,7 +712,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
686
712
|
await updateAPP(templateInfo);
|
|
687
713
|
}
|
|
688
714
|
if (args.scope === "app") return;
|
|
689
|
-
const availableBlocks = await getAvailableBlocks(templateInfo
|
|
715
|
+
const availableBlocks = await getAvailableBlocks(templateInfo);
|
|
690
716
|
const usedBlocks = getUsedBlocks();
|
|
691
717
|
if (args.scope === "all") {
|
|
692
718
|
for (const block of usedBlocks) {
|