@naseej/blox 1.2.1 → 1.2.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 +53 -21
- package/package.json +1 -1
- package/readme.md +3 -0
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.2.
|
|
34
|
+
var version = "1.2.3";
|
|
35
35
|
|
|
36
36
|
// src/commands/add/index.ts
|
|
37
37
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
@@ -351,11 +351,6 @@ var text = async (opts) => {
|
|
|
351
351
|
checkIfCanceled(value);
|
|
352
352
|
return value;
|
|
353
353
|
};
|
|
354
|
-
var confirm = async (opts) => {
|
|
355
|
-
const value = await (0, import_prompts3.confirm)(opts);
|
|
356
|
-
checkIfCanceled(value);
|
|
357
|
-
return value;
|
|
358
|
-
};
|
|
359
354
|
var textList = async (opts) => {
|
|
360
355
|
opts.message = `${opts.message} ${fmt.gray('(separated with ",")')}`;
|
|
361
356
|
const value = await (0, import_prompts3.text)(opts);
|
|
@@ -895,6 +890,46 @@ var conf = command("conf").description("Set blox global config").alias("c").opti
|
|
|
895
890
|
}
|
|
896
891
|
});
|
|
897
892
|
|
|
893
|
+
// src/commands/detach/index.ts
|
|
894
|
+
var detach = command("detach").description("Migrate blox schema").option("--basic", "run detach only").action(async ({ basic }) => {
|
|
895
|
+
try {
|
|
896
|
+
if (!basic) {
|
|
897
|
+
await syncRegistries();
|
|
898
|
+
await migrateAll();
|
|
899
|
+
}
|
|
900
|
+
const bloxFile = getBloxFile();
|
|
901
|
+
const { name, bases } = bloxFile.definition;
|
|
902
|
+
if (!bases) throw new Error("No bases found");
|
|
903
|
+
let base = bases[0]?.name;
|
|
904
|
+
if (bases.length > 1) {
|
|
905
|
+
base = await select({
|
|
906
|
+
message: "Select base to be used",
|
|
907
|
+
options: bases.map((b) => ({
|
|
908
|
+
value: b.name,
|
|
909
|
+
label: b.name
|
|
910
|
+
}))
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
if (!base) throw new Error("No bases selected");
|
|
914
|
+
const availableTemplates = await getAvailableTemplates();
|
|
915
|
+
const baseTemplate = availableTemplates[base];
|
|
916
|
+
if (!baseTemplate) throw new Error("Base not found in registries");
|
|
917
|
+
await git.updateRemote(base, baseTemplate.source);
|
|
918
|
+
const baseCommit = bloxFile.checkpoints[base]?.commit;
|
|
919
|
+
if (!baseCommit) throw new Error("Base commit not found");
|
|
920
|
+
const remoteBaseBloxFile = (await migrateOnRemote(base, baseCommit)).output[".blox"];
|
|
921
|
+
bloxFile.definition = remoteBaseBloxFile.definition;
|
|
922
|
+
delete bloxFile.checkpoints[name];
|
|
923
|
+
saveBloxFile(bloxFile);
|
|
924
|
+
} catch (e) {
|
|
925
|
+
if (!isDebugMode()) {
|
|
926
|
+
import_prompts2.log.warn("Error happened, Will rollback changes");
|
|
927
|
+
await git.rollback();
|
|
928
|
+
}
|
|
929
|
+
error(e);
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
|
|
898
933
|
// src/commands/init/index.ts
|
|
899
934
|
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
900
935
|
var init2 = command("init").description("Init new app").alias("i").option("-n, --name <name>", "App name").option("-t, --template <template>", "Template to use").action(async ({ name, template }) => {
|
|
@@ -957,7 +992,7 @@ var migrateSchema = command("migrate").description("Migrate blox schema").action
|
|
|
957
992
|
});
|
|
958
993
|
|
|
959
994
|
// src/commands/update/index.ts
|
|
960
|
-
var
|
|
995
|
+
var import_prompts15 = require("@clack/prompts");
|
|
961
996
|
|
|
962
997
|
// src/commands/update/utils.ts
|
|
963
998
|
var import_node_path10 = __toESM(require("path"));
|
|
@@ -1022,13 +1057,10 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1022
1057
|
hasMergeConflicts = errorMessage.includes("with conflicts");
|
|
1023
1058
|
}
|
|
1024
1059
|
if (hasMergeConflicts) {
|
|
1025
|
-
|
|
1026
|
-
message: "Please resolve conflicts
|
|
1060
|
+
await select({
|
|
1061
|
+
message: "Please resolve conflicts press enter",
|
|
1062
|
+
options: [{ value: true, label: "continue" }]
|
|
1027
1063
|
});
|
|
1028
|
-
if (!shouldContinue) {
|
|
1029
|
-
await deletePatchFile();
|
|
1030
|
-
throw new Error("Failed to solve conflicts");
|
|
1031
|
-
}
|
|
1032
1064
|
}
|
|
1033
1065
|
if (changes.trim() !== "") {
|
|
1034
1066
|
logWarningSection(
|
|
@@ -1066,6 +1098,7 @@ async function updateApp({
|
|
|
1066
1098
|
ignore: templateDef.ignore
|
|
1067
1099
|
});
|
|
1068
1100
|
if (!toAppCommit) return;
|
|
1101
|
+
if (!templateDef.bases?.length) return;
|
|
1069
1102
|
for (const block of usedBlocks) {
|
|
1070
1103
|
const blockRegistryData = availableBlocks[block.name];
|
|
1071
1104
|
if (!blockRegistryData) return;
|
|
@@ -1073,11 +1106,10 @@ async function updateApp({
|
|
|
1073
1106
|
const blockPath = import_node_path10.default.join(blocksDir, block.name);
|
|
1074
1107
|
const currentBloxFile = getBloxFile(blockPath);
|
|
1075
1108
|
const remoteBloxFile = (await migrateOnRemote(block.name, toAppCommit, blockPath)).output[".blox"];
|
|
1076
|
-
const blockFromCommit = currentBloxFile.checkpoints[block.name]?.commit;
|
|
1077
|
-
const blockToCommit = remoteBloxFile.checkpoints[block.name]?.commit;
|
|
1078
|
-
if (!
|
|
1079
|
-
if (blockFromCommit
|
|
1080
|
-
if (await git.isCommitOlder(blockFromCommit, blockToCommit)) {
|
|
1109
|
+
const blockFromCommit = currentBloxFile.checkpoints?.[block.name]?.commit;
|
|
1110
|
+
const blockToCommit = remoteBloxFile.checkpoints?.[block.name]?.commit;
|
|
1111
|
+
if (!blockToCommit || blockFromCommit === blockToCommit) continue;
|
|
1112
|
+
if (!blockFromCommit || await git.isCommitOlder(blockFromCommit, blockToCommit)) {
|
|
1081
1113
|
saveBloxFile(remoteBloxFile, blockPath);
|
|
1082
1114
|
} else {
|
|
1083
1115
|
logWarningSection(
|
|
@@ -1129,7 +1161,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1129
1161
|
option("-s, --scope <scope>", "Scope of update").default("all").choices(["app", "bases", "block", "all"])
|
|
1130
1162
|
).option("-b, --block <name>", "Block to update, valid only with scope block").action(async (args) => {
|
|
1131
1163
|
if (await git.hasUncommittedChanges()) {
|
|
1132
|
-
|
|
1164
|
+
import_prompts15.log.warn(fmt.yellow("Make sure to commit any changes first"));
|
|
1133
1165
|
return;
|
|
1134
1166
|
}
|
|
1135
1167
|
await migrateAll(true);
|
|
@@ -1170,7 +1202,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1170
1202
|
await checkVersionsCompatibility();
|
|
1171
1203
|
} catch (e) {
|
|
1172
1204
|
if (!isDebugMode()) {
|
|
1173
|
-
|
|
1205
|
+
import_prompts15.log.warn("Error happened, Will rollback changes");
|
|
1174
1206
|
await git.rollback();
|
|
1175
1207
|
}
|
|
1176
1208
|
error(e);
|
|
@@ -1188,7 +1220,7 @@ var upgrade = command("upgrade").description("Upgrade blox cli to latest version
|
|
|
1188
1220
|
});
|
|
1189
1221
|
|
|
1190
1222
|
// src/commands/index.ts
|
|
1191
|
-
var commands = [init2, add2, update2, conf, upgrade, migrateSchema];
|
|
1223
|
+
var commands = [init2, add2, update2, conf, upgrade, migrateSchema, detach];
|
|
1192
1224
|
|
|
1193
1225
|
// bin/run.ts
|
|
1194
1226
|
async function main() {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -33,6 +33,9 @@ Commands:
|
|
|
33
33
|
blox add Add block to app [alias: a]
|
|
34
34
|
blox update Update app/block [alias: u]
|
|
35
35
|
blox conf Set blox global config [alias: c]
|
|
36
|
+
blox upgrade Upgrade blox cli to latest version
|
|
37
|
+
blox migrate Migrate blox schema
|
|
38
|
+
blox detach Detach to base
|
|
36
39
|
|
|
37
40
|
Options:
|
|
38
41
|
-V, --version Show version number [boolean]
|