@naseej/blox 1.2.1 → 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 +45 -5
- 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"));
|
|
@@ -1129,7 +1169,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1129
1169
|
option("-s, --scope <scope>", "Scope of update").default("all").choices(["app", "bases", "block", "all"])
|
|
1130
1170
|
).option("-b, --block <name>", "Block to update, valid only with scope block").action(async (args) => {
|
|
1131
1171
|
if (await git.hasUncommittedChanges()) {
|
|
1132
|
-
|
|
1172
|
+
import_prompts15.log.warn(fmt.yellow("Make sure to commit any changes first"));
|
|
1133
1173
|
return;
|
|
1134
1174
|
}
|
|
1135
1175
|
await migrateAll(true);
|
|
@@ -1170,7 +1210,7 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
|
|
|
1170
1210
|
await checkVersionsCompatibility();
|
|
1171
1211
|
} catch (e) {
|
|
1172
1212
|
if (!isDebugMode()) {
|
|
1173
|
-
|
|
1213
|
+
import_prompts15.log.warn("Error happened, Will rollback changes");
|
|
1174
1214
|
await git.rollback();
|
|
1175
1215
|
}
|
|
1176
1216
|
error(e);
|
|
@@ -1188,7 +1228,7 @@ var upgrade = command("upgrade").description("Upgrade blox cli to latest version
|
|
|
1188
1228
|
});
|
|
1189
1229
|
|
|
1190
1230
|
// src/commands/index.ts
|
|
1191
|
-
var commands = [init2, add2, update2, conf, upgrade, migrateSchema];
|
|
1231
|
+
var commands = [init2, add2, update2, conf, upgrade, migrateSchema, detach];
|
|
1192
1232
|
|
|
1193
1233
|
// bin/run.ts
|
|
1194
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]
|