@naseej/blox 0.1.22 → 0.1.23

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 +31 -4
  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.22";
34
+ var version = "0.1.23";
35
35
 
36
36
  // src/commands/add/index.ts
37
37
  var import_fs_extra7 = __toESM(require("fs-extra"));
@@ -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
- readFileFromRemote
265
+ readFileFromRemote,
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
- let basedOnInfo = getBasedOnInfo(destPath);
491
+ const basedOnInfo = getBasedOnInfo(destPath);
483
492
  const remoteBloxFile = await git.readFileFromRemote(name, ".blox");
484
- basedOnInfo = (0, import_merge.default)(basedOnInfo, remoteBloxFile);
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naseej/blox",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "blox cli",
5
5
  "bin": {
6
6
  "blox": "./bin/run"