@naseej/blox 0.1.22 → 0.1.24
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 +36 -9
- 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.24";
|
|
35
35
|
|
|
36
36
|
// src/commands/add/index.ts
|
|
37
37
|
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
@@ -171,7 +171,7 @@ var updateRemote = async (name, source, shellOptions = {}) => {
|
|
|
171
171
|
});
|
|
172
172
|
await $("git", ["fetch", name], { ...defaultShellOptions, ...shellOptions });
|
|
173
173
|
};
|
|
174
|
-
var
|
|
174
|
+
var readJsonFromRemote = async (remote, file) => {
|
|
175
175
|
try {
|
|
176
176
|
let content = "";
|
|
177
177
|
await $("git", ["show", `${remote}/main:${file}`], {
|
|
@@ -184,6 +184,14 @@ var readFileFromRemote = async (remote, file) => {
|
|
|
184
184
|
return {};
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
|
+
var isCommitOlder = async (a, b) => {
|
|
188
|
+
try {
|
|
189
|
+
await $("git", ["merge-base --is-ancestor", a, b]);
|
|
190
|
+
return true;
|
|
191
|
+
} catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
187
195
|
var update = (shellOptions = {}) => {
|
|
188
196
|
return $("git", ["pull", "--progress"], { ...defaultShellOptions, ...shellOptions });
|
|
189
197
|
};
|
|
@@ -254,7 +262,8 @@ var git = {
|
|
|
254
262
|
getChangesLog,
|
|
255
263
|
applyPatch,
|
|
256
264
|
updateRemote,
|
|
257
|
-
|
|
265
|
+
readJsonFromRemote,
|
|
266
|
+
isCommitOlder
|
|
258
267
|
};
|
|
259
268
|
|
|
260
269
|
// src/shared/spinner.ts
|
|
@@ -479,9 +488,27 @@ var textList = async (opts) => {
|
|
|
479
488
|
// src/services/updater.ts
|
|
480
489
|
async function updateFromRemote(name, source = "", ignore = [], destPath = ".") {
|
|
481
490
|
debug("Updating from remote");
|
|
482
|
-
|
|
483
|
-
const remoteBloxFile = await git.
|
|
484
|
-
|
|
491
|
+
const basedOnInfo = getBasedOnInfo(destPath);
|
|
492
|
+
const remoteBloxFile = await git.readJsonFromRemote(name, ".blox");
|
|
493
|
+
for (const [baseName, baseInfo] of Object.entries(remoteBloxFile.bases || {})) {
|
|
494
|
+
const baseFrom = basedOnInfo.bases?.[baseName]?.commit;
|
|
495
|
+
const updateBase = () => {
|
|
496
|
+
if (!basedOnInfo.bases) {
|
|
497
|
+
basedOnInfo.bases = {};
|
|
498
|
+
}
|
|
499
|
+
basedOnInfo.bases = (0, import_merge.default)(basedOnInfo.bases, { [baseName]: baseInfo });
|
|
500
|
+
};
|
|
501
|
+
if (!baseFrom) {
|
|
502
|
+
updateBase();
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const baseTo = baseInfo.commit;
|
|
506
|
+
if (await git.isCommitOlder(baseFrom, baseTo)) {
|
|
507
|
+
updateBase();
|
|
508
|
+
} else {
|
|
509
|
+
debug(`Skip base info update, ${baseName} is newer in project than template`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
485
512
|
const fromBasedCommit = basedOnInfo.bases?.[name]?.commit;
|
|
486
513
|
const fromCommit = fromBasedCommit || basedOnInfo.commit;
|
|
487
514
|
if (!fromCommit) {
|
|
@@ -518,7 +545,7 @@ async function updateFromRemote(name, source = "", ignore = [], destPath = ".")
|
|
|
518
545
|
if (changes.trim() !== "") {
|
|
519
546
|
logWarningSection(
|
|
520
547
|
"These is the changes from last update, make sure to review for breaking changes",
|
|
521
|
-
changes
|
|
548
|
+
changes.replace(/BREAKING CHANGE/gi, fmt.red("BREAKING CHANGE"))
|
|
522
549
|
);
|
|
523
550
|
}
|
|
524
551
|
await deletePatchFile();
|
|
@@ -610,9 +637,9 @@ var addBlock = async (block, blocks) => {
|
|
|
610
637
|
await git.unInit(blockPath);
|
|
611
638
|
await replacePlaceholders(blockPath, {});
|
|
612
639
|
saveBasedOnInfo({ commit }, blockPath);
|
|
613
|
-
await runInitScript(blockPath);
|
|
614
640
|
}
|
|
615
641
|
);
|
|
642
|
+
await runTask("Run init script", async () => runInitScript(blockPath));
|
|
616
643
|
} else {
|
|
617
644
|
debug(`${block} already exists, will be updated`);
|
|
618
645
|
await updateBlock(block, blocks);
|
|
@@ -704,8 +731,8 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
|
|
|
704
731
|
await replacePlaceholders(name, { app: { name } });
|
|
705
732
|
updateBasedOnInfo({ commit }, name);
|
|
706
733
|
await git.init(name);
|
|
707
|
-
await runInitScript(name);
|
|
708
734
|
task.stop(`App initialized in ${name}`);
|
|
735
|
+
await runTask("Run init script", async () => runInitScript(name || ""));
|
|
709
736
|
} catch (e) {
|
|
710
737
|
error(e);
|
|
711
738
|
}
|