@naseej/blox 1.3.1 → 1.3.3
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 +46 -21
- 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.3.
|
|
34
|
+
var version = "1.3.3";
|
|
35
35
|
|
|
36
36
|
// src/commands/add/index.ts
|
|
37
37
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
@@ -253,7 +253,7 @@ var createPatch = async (fromCommit, toCommit, outputPath, ignore2 = []) => {
|
|
|
253
253
|
">",
|
|
254
254
|
outputPath,
|
|
255
255
|
"--",
|
|
256
|
-
...ignore2.map((file) => `
|
|
256
|
+
...ignore2.map((file) => `":(exclude)${file}"`)
|
|
257
257
|
]);
|
|
258
258
|
};
|
|
259
259
|
var getChangesLog = async (fromCommit, toCommit) => {
|
|
@@ -1049,7 +1049,8 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
1051
|
const patchFilePath = import_node_path9.default.join(dir, "diff.patch");
|
|
1052
|
-
|
|
1052
|
+
const remoteIgnore = remoteBloxFile.definition?.ignore || [];
|
|
1053
|
+
ignore2.push(...remoteIgnore, ".blox", "**/.blox");
|
|
1053
1054
|
await git.createPatch(fromCommit, toCommit, patchFilePath, ignore2);
|
|
1054
1055
|
const deletePatchFile = async () => {
|
|
1055
1056
|
if (!isDebugMode()) {
|
|
@@ -1064,7 +1065,17 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1064
1065
|
const errorMessage = `${e}`;
|
|
1065
1066
|
if (errorMessage.includes("error:")) {
|
|
1066
1067
|
await deletePatchFile();
|
|
1067
|
-
console.log(
|
|
1068
|
+
console.log(errorMessage.replace("error:", fmt.red("error:")));
|
|
1069
|
+
if (errorMessage.includes("does not exist in index")) {
|
|
1070
|
+
logWarningSection(
|
|
1071
|
+
"Some files has changes in remote but were deleted, \n if you want to skip them pass this arg to update command:",
|
|
1072
|
+
fmt.cyan(
|
|
1073
|
+
`--ignore ${[
|
|
1074
|
+
...errorMessage.matchAll(/error: (.*): does not exist in index/g)
|
|
1075
|
+
].map((m) => `"${name}:${m[1]}"`).join(",")}`
|
|
1076
|
+
)
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1068
1079
|
throw new Error("Failed to apply changes.");
|
|
1069
1080
|
}
|
|
1070
1081
|
hasMergeConflicts = errorMessage.includes("with conflicts");
|
|
@@ -1091,7 +1102,8 @@ async function updateApp({
|
|
|
1091
1102
|
templateDef,
|
|
1092
1103
|
templates,
|
|
1093
1104
|
usedBlocks,
|
|
1094
|
-
availableBlocks
|
|
1105
|
+
availableBlocks,
|
|
1106
|
+
ignore: ignore2
|
|
1095
1107
|
}) {
|
|
1096
1108
|
await runTask({ start: "Update App", end: "Updated App" }, async () => {
|
|
1097
1109
|
const template = templates[templateDef.name];
|
|
@@ -1102,7 +1114,7 @@ async function updateApp({
|
|
|
1102
1114
|
const toAppCommit = await updateFromRemote({
|
|
1103
1115
|
name: templateDef.name,
|
|
1104
1116
|
source: template.source,
|
|
1105
|
-
ignore:
|
|
1117
|
+
ignore: ignore2
|
|
1106
1118
|
});
|
|
1107
1119
|
if (!toAppCommit) return;
|
|
1108
1120
|
if (!templateDef.bases?.length) return;
|
|
@@ -1126,7 +1138,7 @@ async function updateApp({
|
|
|
1126
1138
|
}
|
|
1127
1139
|
});
|
|
1128
1140
|
}
|
|
1129
|
-
async function updateAppBases(templateDef, templates) {
|
|
1141
|
+
async function updateAppBases(templateDef, templates, ignore2) {
|
|
1130
1142
|
for (const base of templateDef.bases || []) {
|
|
1131
1143
|
await runTask(
|
|
1132
1144
|
{ start: `Update App base: ${base.name}`, end: `Updated App base: ${base.name}` },
|
|
@@ -1136,19 +1148,14 @@ async function updateAppBases(templateDef, templates) {
|
|
|
1136
1148
|
error("Selected template not available in registries");
|
|
1137
1149
|
return;
|
|
1138
1150
|
}
|
|
1139
|
-
await updateFromRemote({
|
|
1140
|
-
name: base.name,
|
|
1141
|
-
source: template.source,
|
|
1142
|
-
ignore: templateDef.ignore
|
|
1143
|
-
});
|
|
1151
|
+
await updateFromRemote({ name: base.name, source: template.source, ignore: ignore2 });
|
|
1144
1152
|
}
|
|
1145
1153
|
);
|
|
1146
1154
|
}
|
|
1147
1155
|
}
|
|
1148
|
-
async function updateBlock(block, blocks) {
|
|
1156
|
+
async function updateBlock(block, blocks, ignore2) {
|
|
1149
1157
|
const blockRegistryData = blocks[block];
|
|
1150
1158
|
const blockPath = import_node_path10.default.join(blocksDir, block);
|
|
1151
|
-
const blockDef = getBlockDef(blockPath);
|
|
1152
1159
|
await runTask({ start: `Update block: ${block}`, end: `Updated block: ${block}` }, async () => {
|
|
1153
1160
|
if (!blockRegistryData) {
|
|
1154
1161
|
error(`Selected block: ${block} not available in registries`, false);
|
|
@@ -1157,8 +1164,8 @@ async function updateBlock(block, blocks) {
|
|
|
1157
1164
|
await updateFromRemote({
|
|
1158
1165
|
name: block,
|
|
1159
1166
|
source: blockRegistryData.source,
|
|
1160
|
-
|
|
1161
|
-
|
|
1167
|
+
dir: blockPath,
|
|
1168
|
+
ignore: ignore2
|
|
1162
1169
|
});
|
|
1163
1170
|
});
|
|
1164
1171
|
}
|
|
@@ -1200,7 +1207,7 @@ ${fmt.gray("-".repeat(82))}
|
|
|
1200
1207
|
// src/commands/update/index.ts
|
|
1201
1208
|
var update2 = command("update").description("Update app/block").alias("u").addOption(
|
|
1202
1209
|
option("-s, --scope <scope>", "Scope of update").default("all").choices(["app", "bases", "block", "all"])
|
|
1203
|
-
).option("-b, --block <name>", "Block to update, valid only with scope block").action(async (args) => {
|
|
1210
|
+
).option("--ignore <list...>", 'Files ignore list scoped by name i.e "repo:file"').option("-b, --block <name>", "Block to update, valid only with scope block").action(async (args) => {
|
|
1204
1211
|
if (await git.hasUncommittedChanges()) {
|
|
1205
1212
|
import_prompts15.log.warn(fmt.yellow("Make sure to commit any changes first"));
|
|
1206
1213
|
return;
|
|
@@ -1212,16 +1219,34 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1212
1219
|
const availableBlocks = await getAvailableBlocks(templateDef);
|
|
1213
1220
|
const templates = await getAvailableTemplates();
|
|
1214
1221
|
const usedBlocks = getUsedBlocksDef();
|
|
1222
|
+
const ignoresByName = {};
|
|
1223
|
+
for (const ignore2 of args.ignore || []) {
|
|
1224
|
+
const [repo, pattern] = ignore2.split(":");
|
|
1225
|
+
if (!repo || !pattern) {
|
|
1226
|
+
error("Invalid ignore pattern");
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
if (!ignoresByName[repo]) {
|
|
1230
|
+
ignoresByName[repo] = [];
|
|
1231
|
+
}
|
|
1232
|
+
ignoresByName[repo].push(pattern);
|
|
1233
|
+
}
|
|
1215
1234
|
try {
|
|
1216
1235
|
if (["app", "all"].includes(args.scope)) {
|
|
1217
|
-
await updateApp({
|
|
1236
|
+
await updateApp({
|
|
1237
|
+
templateDef,
|
|
1238
|
+
templates,
|
|
1239
|
+
usedBlocks,
|
|
1240
|
+
availableBlocks,
|
|
1241
|
+
ignore: ignoresByName[templateDef.name]
|
|
1242
|
+
});
|
|
1218
1243
|
}
|
|
1219
1244
|
if (["bases", "all"].includes(args.scope)) {
|
|
1220
|
-
await updateAppBases(templateDef, templates);
|
|
1245
|
+
await updateAppBases(templateDef, templates, ignoresByName[templateDef.name]);
|
|
1221
1246
|
}
|
|
1222
1247
|
if (args.scope === "all") {
|
|
1223
1248
|
for (const block of usedBlocks) {
|
|
1224
|
-
await updateBlock(block.name, availableBlocks);
|
|
1249
|
+
await updateBlock(block.name, availableBlocks, ignoresByName[block.name]);
|
|
1225
1250
|
}
|
|
1226
1251
|
}
|
|
1227
1252
|
if (args.scope === "block") {
|
|
@@ -1239,7 +1264,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1239
1264
|
error("Selected block not used in app");
|
|
1240
1265
|
return;
|
|
1241
1266
|
}
|
|
1242
|
-
await updateBlock(blockDef.name, availableBlocks);
|
|
1267
|
+
await updateBlock(blockDef.name, availableBlocks, ignoresByName[blockDef.name]);
|
|
1243
1268
|
}
|
|
1244
1269
|
await checkVersionsCompatibility();
|
|
1245
1270
|
const endCheckpoints = await getCurrentCheckpoints();
|