@naseej/blox 0.1.19 → 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 +62 -24
- 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"));
|
|
@@ -191,8 +191,15 @@ var getLatestCommit = async (rev, cwd = ".") => {
|
|
|
191
191
|
});
|
|
192
192
|
return commit.replace(/\n/g, "");
|
|
193
193
|
};
|
|
194
|
-
var createPatch = async (fromCommit, toCommit, outputPath) => {
|
|
195
|
-
return $("git", [
|
|
194
|
+
var createPatch = async (fromCommit, toCommit, outputPath, ignore = []) => {
|
|
195
|
+
return $("git", [
|
|
196
|
+
"diff",
|
|
197
|
+
fromCommit,
|
|
198
|
+
toCommit,
|
|
199
|
+
">",
|
|
200
|
+
outputPath,
|
|
201
|
+
...ignore.map((file) => `':!${file}'`)
|
|
202
|
+
]);
|
|
196
203
|
};
|
|
197
204
|
var getChangesLog = async (fromCommit, toCommit) => {
|
|
198
205
|
let changes = "";
|
|
@@ -352,11 +359,15 @@ var getAvailableTemplates = async () => {
|
|
|
352
359
|
debug(templates);
|
|
353
360
|
return templates;
|
|
354
361
|
};
|
|
355
|
-
var getAvailableBlocks = async (
|
|
362
|
+
var getAvailableBlocks = async (templateInfo) => {
|
|
356
363
|
debug("Get available blocks");
|
|
357
364
|
const templates = await getAvailableTemplates();
|
|
358
|
-
const template = templates[
|
|
365
|
+
const template = templates[templateInfo.name];
|
|
359
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
|
+
}
|
|
360
371
|
debug(blocks);
|
|
361
372
|
return blocks;
|
|
362
373
|
};
|
|
@@ -451,11 +462,16 @@ var textList = async (opts) => {
|
|
|
451
462
|
};
|
|
452
463
|
|
|
453
464
|
// src/services/updater.ts
|
|
454
|
-
async function updateFromRemote(name, source = "", destPath = ".") {
|
|
465
|
+
async function updateFromRemote(name, source = "", ignore = [], destPath = ".") {
|
|
455
466
|
debug("Updating from remote");
|
|
456
|
-
|
|
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
|
+
}
|
|
457
474
|
await git.updateRemote(name, source);
|
|
458
|
-
const fromCommit = getBasedOnInfo(destPath).commit;
|
|
459
475
|
const toCommit = await git.getLatestCommitFromRemote(name);
|
|
460
476
|
debug({ fromCommit, toCommit });
|
|
461
477
|
if (fromCommit == toCommit) {
|
|
@@ -463,7 +479,7 @@ async function updateFromRemote(name, source = "", destPath = ".") {
|
|
|
463
479
|
return;
|
|
464
480
|
}
|
|
465
481
|
const patchFilePath = import_node_path6.default.join(destPath, "diff.patch");
|
|
466
|
-
await git.createPatch(fromCommit, toCommit, patchFilePath);
|
|
482
|
+
await git.createPatch(fromCommit, toCommit, patchFilePath, ignore);
|
|
467
483
|
const changes = await git.getChangesLog(fromCommit, toCommit);
|
|
468
484
|
const deletePatchFile = async () => {
|
|
469
485
|
if (!isDebugMode()) {
|
|
@@ -488,20 +504,45 @@ async function updateFromRemote(name, source = "", destPath = ".") {
|
|
|
488
504
|
);
|
|
489
505
|
}
|
|
490
506
|
await deletePatchFile();
|
|
491
|
-
|
|
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);
|
|
492
520
|
}
|
|
493
521
|
|
|
494
522
|
// src/commands/update/utils.ts
|
|
495
523
|
async function updateAPP(templateInfo) {
|
|
524
|
+
const templates = await getAvailableTemplates();
|
|
496
525
|
await runTask({ start: "Update App", end: "Updated App" }, async () => {
|
|
497
|
-
const templates = await getAvailableTemplates();
|
|
498
526
|
const template = templates[templateInfo.name];
|
|
499
527
|
if (!template) {
|
|
500
528
|
error("Selected template not available, try to sync registries");
|
|
501
529
|
return;
|
|
502
530
|
}
|
|
503
|
-
await updateFromRemote(templateInfo.name, template.source);
|
|
531
|
+
await updateFromRemote(templateInfo.name, template.source, templateInfo.ignore);
|
|
504
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
|
+
}
|
|
505
546
|
}
|
|
506
547
|
var updatedBlocks = /* @__PURE__ */ new Set();
|
|
507
548
|
async function updateBlock(block, blocks) {
|
|
@@ -515,7 +556,12 @@ async function updateBlock(block, blocks) {
|
|
|
515
556
|
error("Selected block not available, try to sync registries", false);
|
|
516
557
|
return;
|
|
517
558
|
}
|
|
518
|
-
await updateFromRemote(
|
|
559
|
+
await updateFromRemote(
|
|
560
|
+
block,
|
|
561
|
+
blockInfo.source,
|
|
562
|
+
blockInfo.ignore,
|
|
563
|
+
import_node_path7.default.join(blocksDir, block)
|
|
564
|
+
);
|
|
519
565
|
updatedBlocks.add(block);
|
|
520
566
|
});
|
|
521
567
|
for (const dep of blockInfo?.dependencies || []) {
|
|
@@ -561,7 +607,7 @@ var add = command("add").description("Add block to app").alias("a").argument("[b
|
|
|
561
607
|
await syncRegistries(false, false);
|
|
562
608
|
try {
|
|
563
609
|
const templateInfo = getTemplateInfo();
|
|
564
|
-
const blocks = await getAvailableBlocks(templateInfo
|
|
610
|
+
const blocks = await getAvailableBlocks(templateInfo);
|
|
565
611
|
if (!block) {
|
|
566
612
|
block = await select({
|
|
567
613
|
message: "Select template to be used",
|
|
@@ -638,15 +684,7 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
|
|
|
638
684
|
const commit = await git.getLatestCommitFromPath(name);
|
|
639
685
|
await git.unInit(name);
|
|
640
686
|
await replacePlaceholders(name, { app: { name } });
|
|
641
|
-
|
|
642
|
-
try {
|
|
643
|
-
basedOnInfo = getBasedOnInfo(name);
|
|
644
|
-
} catch (e) {
|
|
645
|
-
debug(`${e}`);
|
|
646
|
-
}
|
|
647
|
-
if (!basedOnInfo?.commit) {
|
|
648
|
-
saveBasedOnInfo({ commit }, name);
|
|
649
|
-
}
|
|
687
|
+
updateBasedOnInfo({ commit }, name);
|
|
650
688
|
await git.init(name);
|
|
651
689
|
await runInitScript(name);
|
|
652
690
|
task.stop(`App initialized in ${name}`);
|
|
@@ -674,7 +712,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
674
712
|
await updateAPP(templateInfo);
|
|
675
713
|
}
|
|
676
714
|
if (args.scope === "app") return;
|
|
677
|
-
const availableBlocks = await getAvailableBlocks(templateInfo
|
|
715
|
+
const availableBlocks = await getAvailableBlocks(templateInfo);
|
|
678
716
|
const usedBlocks = getUsedBlocks();
|
|
679
717
|
if (args.scope === "all") {
|
|
680
718
|
for (const block of usedBlocks) {
|