@naseej/blox 1.2.3 → 1.3.0
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 +57 -13
- 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 = "1.
|
|
34
|
+
var version = "1.3.0";
|
|
35
35
|
|
|
36
36
|
// src/commands/add/index.ts
|
|
37
37
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
@@ -125,7 +125,7 @@ var logWarningSection = (title, content) => {
|
|
|
125
125
|
const line = fmt.yellow("=".repeat(82));
|
|
126
126
|
console2.log("\n" + line);
|
|
127
127
|
console2.log(fmt.bold(fmt.yellow("\u25B2 " + title)));
|
|
128
|
-
content && console2.log(content);
|
|
128
|
+
content && console2.log("\n" + content);
|
|
129
129
|
console2.log(line + "\n");
|
|
130
130
|
};
|
|
131
131
|
var normalizeLogMessage = (content) => {
|
|
@@ -181,7 +181,11 @@ var clone = (repoUrl, options, shellOptions = {}) => {
|
|
|
181
181
|
var resetToCommit = async (commit2, cwd = ".") => {
|
|
182
182
|
await $("git", ["reset --hard", `${commit2}`], { cwd });
|
|
183
183
|
};
|
|
184
|
+
var updatedRemotes = /* @__PURE__ */ new Set();
|
|
184
185
|
var updateRemote = async (name, source, shellOptions = {}) => {
|
|
186
|
+
const remoteId = `${name}:${source}`;
|
|
187
|
+
if (updatedRemotes.has(remoteId)) return;
|
|
188
|
+
updatedRemotes.add(remoteId);
|
|
185
189
|
debug("updateRemote");
|
|
186
190
|
debug({ name, source });
|
|
187
191
|
try {
|
|
@@ -532,7 +536,10 @@ var updateLocalConfig = (config) => {
|
|
|
532
536
|
|
|
533
537
|
// src/services/registry.ts
|
|
534
538
|
var registriesDataPath = import_node_path7.default.join(appPaths.data, "registries");
|
|
539
|
+
var upeToDate = false;
|
|
535
540
|
var syncRegistries = async () => {
|
|
541
|
+
if (upeToDate) return;
|
|
542
|
+
upeToDate = true;
|
|
536
543
|
debug("Sync registries");
|
|
537
544
|
import_fs_extra6.default.ensureDirSync(registriesDataPath);
|
|
538
545
|
const config = getLocalConfig();
|
|
@@ -659,6 +666,9 @@ function updateCheckpoint(name, checkpoint, cwd = ".") {
|
|
|
659
666
|
info.checkpoints[name] = checkpoint;
|
|
660
667
|
saveBloxFile(info, cwd);
|
|
661
668
|
}
|
|
669
|
+
function getUsedBlocksDef() {
|
|
670
|
+
return getUsedBlocks().map((b) => b.definition);
|
|
671
|
+
}
|
|
662
672
|
function getUsedBlocks() {
|
|
663
673
|
debug("Get used blocks");
|
|
664
674
|
const blocks = [];
|
|
@@ -667,8 +677,8 @@ function getUsedBlocks() {
|
|
|
667
677
|
if (!file.isDirectory()) {
|
|
668
678
|
return;
|
|
669
679
|
}
|
|
670
|
-
const blockDef =
|
|
671
|
-
if (blockDef) {
|
|
680
|
+
const blockDef = getBloxFile(import_node_path8.default.join(blocksDir, file.name));
|
|
681
|
+
if (blockDef && blockDef.definition) {
|
|
672
682
|
blocks.push(blockDef);
|
|
673
683
|
}
|
|
674
684
|
});
|
|
@@ -683,11 +693,13 @@ function processDependencyVersion(dep) {
|
|
|
683
693
|
return dep;
|
|
684
694
|
}
|
|
685
695
|
function processTemplate(def) {
|
|
696
|
+
debug("processTemplate");
|
|
686
697
|
if (!def.version) def.version = 0;
|
|
687
698
|
Object.values(def.bases || {}).forEach(processDependencyVersion);
|
|
688
699
|
return def;
|
|
689
700
|
}
|
|
690
701
|
function processBases(info) {
|
|
702
|
+
debug("processBases");
|
|
691
703
|
if (!info || !info.checkpoints) return {};
|
|
692
704
|
Object.values(info.checkpoints).forEach((base) => {
|
|
693
705
|
if (!base.version) base.version = 0;
|
|
@@ -695,6 +707,7 @@ function processBases(info) {
|
|
|
695
707
|
return info.checkpoints;
|
|
696
708
|
}
|
|
697
709
|
function processBlocks(defs) {
|
|
710
|
+
debug("processBlocks");
|
|
698
711
|
defs.forEach((def) => {
|
|
699
712
|
if (!def.version) def.version = 0;
|
|
700
713
|
def.dependencies?.forEach(processDependencyVersion);
|
|
@@ -757,8 +770,9 @@ async function _checkVersionsCompatibility(template, usedBlocks, basesVersion) {
|
|
|
757
770
|
}
|
|
758
771
|
}
|
|
759
772
|
async function checkVersionsCompatibility() {
|
|
773
|
+
debug("checkVersionsCompatibility");
|
|
760
774
|
const template = processTemplate(getTemplateDef());
|
|
761
|
-
const usedBlocks = processBlocks(
|
|
775
|
+
const usedBlocks = processBlocks(getUsedBlocksDef());
|
|
762
776
|
const basesVersion = processBases(getBloxFile());
|
|
763
777
|
basesVersion[template.name] = { version: template.version, commit: "" };
|
|
764
778
|
await _checkVersionsCompatibility(template, usedBlocks, basesVersion);
|
|
@@ -1037,7 +1051,6 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1037
1051
|
const patchFilePath = import_node_path9.default.join(dir, "diff.patch");
|
|
1038
1052
|
ignore2.push(".blox", "**/.blox");
|
|
1039
1053
|
await git.createPatch(fromCommit, toCommit, patchFilePath, ignore2);
|
|
1040
|
-
const changes = await git.getChangesLog(fromCommit, toCommit);
|
|
1041
1054
|
const deletePatchFile = async () => {
|
|
1042
1055
|
if (!isDebugMode()) {
|
|
1043
1056
|
await import_fs_extra10.default.unlink(patchFilePath);
|
|
@@ -1062,12 +1075,6 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1062
1075
|
options: [{ value: true, label: "continue" }]
|
|
1063
1076
|
});
|
|
1064
1077
|
}
|
|
1065
|
-
if (changes.trim() !== "") {
|
|
1066
|
-
logWarningSection(
|
|
1067
|
-
"These is the changes from last update, make sure to review for breaking changes",
|
|
1068
|
-
changes.replace(/BREAKING CHANGE/gi, fmt.red("BREAKING CHANGE"))
|
|
1069
|
-
);
|
|
1070
|
-
}
|
|
1071
1078
|
await deletePatchFile();
|
|
1072
1079
|
bloxFile.checkpoints[name] = { commit: toCommit };
|
|
1073
1080
|
if (bloxFile.definition.name === name) {
|
|
@@ -1155,6 +1162,40 @@ async function updateBlock(block, blocks) {
|
|
|
1155
1162
|
});
|
|
1156
1163
|
});
|
|
1157
1164
|
}
|
|
1165
|
+
async function getCurrentCheckpoints() {
|
|
1166
|
+
const bloxFile = getBloxFile();
|
|
1167
|
+
let checkpoints = { ...bloxFile.checkpoints };
|
|
1168
|
+
for (const block of getUsedBlocks()) {
|
|
1169
|
+
checkpoints = { ...checkpoints, ...block.checkpoints };
|
|
1170
|
+
}
|
|
1171
|
+
return checkpoints;
|
|
1172
|
+
}
|
|
1173
|
+
async function printChangeLog(startCheckpoints, endCheckpoints) {
|
|
1174
|
+
const allChanges = [];
|
|
1175
|
+
for (const name of Object.keys(startCheckpoints)) {
|
|
1176
|
+
const fromCommit = startCheckpoints[name]?.commit;
|
|
1177
|
+
const toCommit = endCheckpoints[name]?.commit;
|
|
1178
|
+
if (!fromCommit || !toCommit) continue;
|
|
1179
|
+
if (fromCommit === toCommit) continue;
|
|
1180
|
+
const changes = await git.getChangesLog(fromCommit, toCommit);
|
|
1181
|
+
if (changes.trim() !== "") {
|
|
1182
|
+
allChanges.push(`${fmt.bold(fmt.bgYellow(name))}:
|
|
1183
|
+
|
|
1184
|
+
${changes}`);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
if (allChanges.length) {
|
|
1188
|
+
logWarningSection(
|
|
1189
|
+
`ChangeLog, These is the changes from last update, make sure to review for breaking changes`,
|
|
1190
|
+
allChanges.join(`
|
|
1191
|
+
${fmt.gray("-".repeat(82))}
|
|
1192
|
+
|
|
1193
|
+
`).replace(/BREAKING CHANGE/gi, fmt.red("BREAKING CHANGE"))
|
|
1194
|
+
);
|
|
1195
|
+
} else {
|
|
1196
|
+
import_prompts2.log.success("already up to date");
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1158
1199
|
|
|
1159
1200
|
// src/commands/update/index.ts
|
|
1160
1201
|
var update2 = command("update").description("Update app/block").alias("u").addOption(
|
|
@@ -1166,10 +1207,11 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1166
1207
|
}
|
|
1167
1208
|
await migrateAll(true);
|
|
1168
1209
|
await syncRegistries();
|
|
1210
|
+
const startCheckpoints = await getCurrentCheckpoints();
|
|
1169
1211
|
const templateDef = getTemplateDef();
|
|
1170
1212
|
const availableBlocks = await getAvailableBlocks(templateDef);
|
|
1171
1213
|
const templates = await getAvailableTemplates();
|
|
1172
|
-
const usedBlocks =
|
|
1214
|
+
const usedBlocks = getUsedBlocksDef();
|
|
1173
1215
|
try {
|
|
1174
1216
|
if (["app", "all"].includes(args.scope)) {
|
|
1175
1217
|
await updateApp({ templateDef, templates, usedBlocks, availableBlocks });
|
|
@@ -1200,6 +1242,8 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1200
1242
|
await updateBlock(blockDef.name, availableBlocks);
|
|
1201
1243
|
}
|
|
1202
1244
|
await checkVersionsCompatibility();
|
|
1245
|
+
const endCheckpoints = await getCurrentCheckpoints();
|
|
1246
|
+
await printChangeLog(startCheckpoints, endCheckpoints);
|
|
1203
1247
|
} catch (e) {
|
|
1204
1248
|
if (!isDebugMode()) {
|
|
1205
1249
|
import_prompts15.log.warn("Error happened, Will rollback changes");
|