@naseej/blox 0.1.21 → 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.
- package/dist/run.js +48 -3
- package/package.json +4 -2
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.23";
|
|
35
35
|
|
|
36
36
|
// src/commands/add/index.ts
|
|
37
37
|
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
@@ -171,6 +171,27 @@ var updateRemote = async (name, source, shellOptions = {}) => {
|
|
|
171
171
|
});
|
|
172
172
|
await $("git", ["fetch", name], { ...defaultShellOptions, ...shellOptions });
|
|
173
173
|
};
|
|
174
|
+
var readFileFromRemote = async (remote, file) => {
|
|
175
|
+
try {
|
|
176
|
+
let content = "";
|
|
177
|
+
await $("git", ["show", `${remote}/main:${file}`], {
|
|
178
|
+
onStdout: (text2) => {
|
|
179
|
+
content = text2;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return JSON.parse(content);
|
|
183
|
+
} catch {
|
|
184
|
+
return {};
|
|
185
|
+
}
|
|
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
|
+
};
|
|
174
195
|
var update = (shellOptions = {}) => {
|
|
175
196
|
return $("git", ["pull", "--progress"], { ...defaultShellOptions, ...shellOptions });
|
|
176
197
|
};
|
|
@@ -240,7 +261,9 @@ var git = {
|
|
|
240
261
|
createPatch,
|
|
241
262
|
getChangesLog,
|
|
242
263
|
applyPatch,
|
|
243
|
-
updateRemote
|
|
264
|
+
updateRemote,
|
|
265
|
+
readFileFromRemote,
|
|
266
|
+
isCommitOlder
|
|
244
267
|
};
|
|
245
268
|
|
|
246
269
|
// src/shared/spinner.ts
|
|
@@ -375,6 +398,7 @@ var getAvailableBlocks = async (templateInfo) => {
|
|
|
375
398
|
// src/services/updater.ts
|
|
376
399
|
var import_node_path6 = __toESM(require("path"));
|
|
377
400
|
var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
401
|
+
var import_merge = __toESM(require("lodash/merge"));
|
|
378
402
|
|
|
379
403
|
// src/services/template.ts
|
|
380
404
|
var import_node_path5 = __toESM(require("path"));
|
|
@@ -405,7 +429,7 @@ function getBasedOnInfo(cwd = ".") {
|
|
|
405
429
|
}
|
|
406
430
|
function saveBasedOnInfo(info, cwd = ".") {
|
|
407
431
|
debug("Save info");
|
|
408
|
-
import_fs_extra5.default.
|
|
432
|
+
import_fs_extra5.default.writeFileSync(import_node_path5.default.join(cwd, basedOnFile), JSON.stringify(info, null, 2));
|
|
409
433
|
}
|
|
410
434
|
function updateBasedOnInfo(updates, cwd = ".") {
|
|
411
435
|
const info = getBasedOnInfo(cwd);
|
|
@@ -465,6 +489,26 @@ var textList = async (opts) => {
|
|
|
465
489
|
async function updateFromRemote(name, source = "", ignore = [], destPath = ".") {
|
|
466
490
|
debug("Updating from remote");
|
|
467
491
|
const basedOnInfo = getBasedOnInfo(destPath);
|
|
492
|
+
const remoteBloxFile = await git.readFileFromRemote(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
|
+
}
|
|
468
512
|
const fromBasedCommit = basedOnInfo.bases?.[name]?.commit;
|
|
469
513
|
const fromCommit = fromBasedCommit || basedOnInfo.commit;
|
|
470
514
|
if (!fromCommit) {
|
|
@@ -479,6 +523,7 @@ async function updateFromRemote(name, source = "", ignore = [], destPath = ".")
|
|
|
479
523
|
return;
|
|
480
524
|
}
|
|
481
525
|
const patchFilePath = import_node_path6.default.join(destPath, "diff.patch");
|
|
526
|
+
ignore.push("./.blox");
|
|
482
527
|
await git.createPatch(fromCommit, toCommit, patchFilePath, ignore);
|
|
483
528
|
const changes = await git.getChangesLog(fromCommit, toCommit);
|
|
484
529
|
const deletePatchFile = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naseej/blox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "blox cli",
|
|
5
5
|
"bin": {
|
|
6
6
|
"blox": "./bin/run"
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@types/fs-extra": "11.0.4",
|
|
42
42
|
"@types/ms": "0.7.34",
|
|
43
43
|
"@types/ejs": "3.1.5",
|
|
44
|
+
"@types/lodash": "4.17.20",
|
|
44
45
|
"eslint": "^8.57.0",
|
|
45
46
|
"vitest": "2.1.8",
|
|
46
47
|
"prettier": "^3.2.5",
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
"@commander-js/extra-typings": "12.1.0",
|
|
70
71
|
"commander": "12.1.0",
|
|
71
72
|
"ms": "2.1.3",
|
|
72
|
-
"dayjs": "1.11.13"
|
|
73
|
+
"dayjs": "1.11.13",
|
|
74
|
+
"lodash": "^4.17.21"
|
|
73
75
|
}
|
|
74
76
|
}
|