@naseej/blox 1.2.0 → 1.2.2
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 +69 -42
- 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.2";
|
|
35
35
|
|
|
36
36
|
// src/commands/add/index.ts
|
|
37
37
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
@@ -895,6 +895,46 @@ var conf = command("conf").description("Set blox global config").alias("c").opti
|
|
|
895
895
|
}
|
|
896
896
|
});
|
|
897
897
|
|
|
898
|
+
// src/commands/detach/index.ts
|
|
899
|
+
var detach = command("detach").description("Migrate blox schema").option("--basic", "run detach only").action(async ({ basic }) => {
|
|
900
|
+
try {
|
|
901
|
+
if (!basic) {
|
|
902
|
+
await syncRegistries();
|
|
903
|
+
await migrateAll();
|
|
904
|
+
}
|
|
905
|
+
const bloxFile = getBloxFile();
|
|
906
|
+
const { name, bases } = bloxFile.definition;
|
|
907
|
+
if (!bases) throw new Error("No bases found");
|
|
908
|
+
let base = bases[0]?.name;
|
|
909
|
+
if (bases.length > 1) {
|
|
910
|
+
base = await select({
|
|
911
|
+
message: "Select base to be used",
|
|
912
|
+
options: bases.map((b) => ({
|
|
913
|
+
value: b.name,
|
|
914
|
+
label: b.name
|
|
915
|
+
}))
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
if (!base) throw new Error("No bases selected");
|
|
919
|
+
const availableTemplates = await getAvailableTemplates();
|
|
920
|
+
const baseTemplate = availableTemplates[base];
|
|
921
|
+
if (!baseTemplate) throw new Error("Base not found in registries");
|
|
922
|
+
await git.updateRemote(base, baseTemplate.source);
|
|
923
|
+
const baseCommit = bloxFile.checkpoints[base]?.commit;
|
|
924
|
+
if (!baseCommit) throw new Error("Base commit not found");
|
|
925
|
+
const remoteBaseBloxFile = (await migrateOnRemote(base, baseCommit)).output[".blox"];
|
|
926
|
+
bloxFile.definition = remoteBaseBloxFile.definition;
|
|
927
|
+
delete bloxFile.checkpoints[name];
|
|
928
|
+
saveBloxFile(bloxFile);
|
|
929
|
+
} catch (e) {
|
|
930
|
+
if (!isDebugMode()) {
|
|
931
|
+
import_prompts2.log.warn("Error happened, Will rollback changes");
|
|
932
|
+
await git.rollback();
|
|
933
|
+
}
|
|
934
|
+
error(e);
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
|
|
898
938
|
// src/commands/init/index.ts
|
|
899
939
|
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
900
940
|
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 +997,7 @@ var migrateSchema = command("migrate").description("Migrate blox schema").action
|
|
|
957
997
|
});
|
|
958
998
|
|
|
959
999
|
// src/commands/update/index.ts
|
|
960
|
-
var
|
|
1000
|
+
var import_prompts15 = require("@clack/prompts");
|
|
961
1001
|
|
|
962
1002
|
// src/commands/update/utils.ts
|
|
963
1003
|
var import_node_path10 = __toESM(require("path"));
|
|
@@ -1048,31 +1088,6 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1048
1088
|
}
|
|
1049
1089
|
|
|
1050
1090
|
// src/commands/update/utils.ts
|
|
1051
|
-
async function updateAppBlocks({
|
|
1052
|
-
toAppCommit,
|
|
1053
|
-
usedBlocks,
|
|
1054
|
-
availableBlocks
|
|
1055
|
-
}) {
|
|
1056
|
-
for (const block of usedBlocks) {
|
|
1057
|
-
const blockRegistryData = availableBlocks[block.name];
|
|
1058
|
-
if (!blockRegistryData) return;
|
|
1059
|
-
await git.updateRemote(block.name, blockRegistryData.source);
|
|
1060
|
-
const blockPath = import_node_path10.default.join(blocksDir, block.name);
|
|
1061
|
-
const currentBloxFile = getBloxFile(blockPath);
|
|
1062
|
-
const remoteBloxFile = (await migrateOnRemote(block.name, toAppCommit, blockPath)).output[".blox"];
|
|
1063
|
-
const blockFromCommit = currentBloxFile.checkpoints[block.name]?.commit;
|
|
1064
|
-
const blockToCommit = remoteBloxFile.checkpoints[block.name]?.commit;
|
|
1065
|
-
if (!blockFromCommit || !blockToCommit) continue;
|
|
1066
|
-
if (blockFromCommit === blockToCommit) continue;
|
|
1067
|
-
if (await git.isCommitOlder(blockFromCommit, blockToCommit)) {
|
|
1068
|
-
saveBloxFile(remoteBloxFile, blockPath);
|
|
1069
|
-
} else {
|
|
1070
|
-
logWarningSection(
|
|
1071
|
-
`${block.name} is newer in project than template, make sure no breaking changes`
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
1091
|
async function updateApp({
|
|
1077
1092
|
templateDef,
|
|
1078
1093
|
templates,
|
|
@@ -1091,15 +1106,28 @@ async function updateApp({
|
|
|
1091
1106
|
ignore: templateDef.ignore
|
|
1092
1107
|
});
|
|
1093
1108
|
if (!toAppCommit) return;
|
|
1094
|
-
|
|
1109
|
+
for (const block of usedBlocks) {
|
|
1110
|
+
const blockRegistryData = availableBlocks[block.name];
|
|
1111
|
+
if (!blockRegistryData) return;
|
|
1112
|
+
await git.updateRemote(block.name, blockRegistryData.source);
|
|
1113
|
+
const blockPath = import_node_path10.default.join(blocksDir, block.name);
|
|
1114
|
+
const currentBloxFile = getBloxFile(blockPath);
|
|
1115
|
+
const remoteBloxFile = (await migrateOnRemote(block.name, toAppCommit, blockPath)).output[".blox"];
|
|
1116
|
+
const blockFromCommit = currentBloxFile.checkpoints[block.name]?.commit;
|
|
1117
|
+
const blockToCommit = remoteBloxFile.checkpoints[block.name]?.commit;
|
|
1118
|
+
if (!blockFromCommit || !blockToCommit) continue;
|
|
1119
|
+
if (blockFromCommit === blockToCommit) continue;
|
|
1120
|
+
if (await git.isCommitOlder(blockFromCommit, blockToCommit)) {
|
|
1121
|
+
saveBloxFile(remoteBloxFile, blockPath);
|
|
1122
|
+
} else {
|
|
1123
|
+
logWarningSection(
|
|
1124
|
+
`${block.name} is newer in project than template, make sure no breaking changes`
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1095
1128
|
});
|
|
1096
1129
|
}
|
|
1097
|
-
async function updateAppBases({
|
|
1098
|
-
templateDef,
|
|
1099
|
-
templates,
|
|
1100
|
-
usedBlocks,
|
|
1101
|
-
availableBlocks
|
|
1102
|
-
}) {
|
|
1130
|
+
async function updateAppBases(templateDef, templates) {
|
|
1103
1131
|
for (const base of templateDef.bases || []) {
|
|
1104
1132
|
await runTask(
|
|
1105
1133
|
{ start: `Update App base: ${base.name}`, end: `Updated App base: ${base.name}` },
|
|
@@ -1109,12 +1137,11 @@ async function updateAppBases({
|
|
|
1109
1137
|
error("Selected template not available in registries");
|
|
1110
1138
|
return;
|
|
1111
1139
|
}
|
|
1112
|
-
|
|
1140
|
+
await updateFromRemote({
|
|
1113
1141
|
name: base.name,
|
|
1114
|
-
source: template.source
|
|
1142
|
+
source: template.source,
|
|
1143
|
+
ignore: templateDef.ignore
|
|
1115
1144
|
});
|
|
1116
|
-
if (!toAppCommit) return;
|
|
1117
|
-
await updateAppBlocks({ toAppCommit, usedBlocks, availableBlocks });
|
|
1118
1145
|
}
|
|
1119
1146
|
);
|
|
1120
1147
|
}
|
|
@@ -1142,7 +1169,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1142
1169
|
option("-s, --scope <scope>", "Scope of update").default("all").choices(["app", "bases", "block", "all"])
|
|
1143
1170
|
).option("-b, --block <name>", "Block to update, valid only with scope block").action(async (args) => {
|
|
1144
1171
|
if (await git.hasUncommittedChanges()) {
|
|
1145
|
-
|
|
1172
|
+
import_prompts15.log.warn(fmt.yellow("Make sure to commit any changes first"));
|
|
1146
1173
|
return;
|
|
1147
1174
|
}
|
|
1148
1175
|
await migrateAll(true);
|
|
@@ -1156,7 +1183,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1156
1183
|
await updateApp({ templateDef, templates, usedBlocks, availableBlocks });
|
|
1157
1184
|
}
|
|
1158
1185
|
if (["bases", "all"].includes(args.scope)) {
|
|
1159
|
-
await updateAppBases(
|
|
1186
|
+
await updateAppBases(templateDef, templates);
|
|
1160
1187
|
}
|
|
1161
1188
|
if (args.scope === "all") {
|
|
1162
1189
|
for (const block of usedBlocks) {
|
|
@@ -1183,7 +1210,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1183
1210
|
await checkVersionsCompatibility();
|
|
1184
1211
|
} catch (e) {
|
|
1185
1212
|
if (!isDebugMode()) {
|
|
1186
|
-
|
|
1213
|
+
import_prompts15.log.warn("Error happened, Will rollback changes");
|
|
1187
1214
|
await git.rollback();
|
|
1188
1215
|
}
|
|
1189
1216
|
error(e);
|
|
@@ -1201,7 +1228,7 @@ var upgrade = command("upgrade").description("Upgrade blox cli to latest version
|
|
|
1201
1228
|
});
|
|
1202
1229
|
|
|
1203
1230
|
// src/commands/index.ts
|
|
1204
|
-
var commands = [init2, add2, update2, conf, upgrade, migrateSchema];
|
|
1231
|
+
var commands = [init2, add2, update2, conf, upgrade, migrateSchema, detach];
|
|
1205
1232
|
|
|
1206
1233
|
// bin/run.ts
|
|
1207
1234
|
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]
|