@naseej/blox 1.4.2 → 1.4.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 +28 -22
- package/package.json +1 -1
- package/readme.md +5 -0
package/dist/run.js
CHANGED
|
@@ -39,6 +39,7 @@ var defaultConfig = {
|
|
|
39
39
|
};
|
|
40
40
|
var bloxFilePath = ".blox";
|
|
41
41
|
var blocksDir = "blocks";
|
|
42
|
+
var defaultBranch = "main";
|
|
42
43
|
|
|
43
44
|
// src/shared/logger.ts
|
|
44
45
|
var console2 = __toESM(require("console"));
|
|
@@ -179,7 +180,7 @@ var checkForCliUpdate = async (currentVersion) => {
|
|
|
179
180
|
};
|
|
180
181
|
|
|
181
182
|
// package.json
|
|
182
|
-
var version = "1.4.
|
|
183
|
+
var version = "1.4.3";
|
|
183
184
|
|
|
184
185
|
// src/commands/add/index.ts
|
|
185
186
|
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
@@ -276,8 +277,8 @@ var checkAuth = (message) => {
|
|
|
276
277
|
var defaultShellOptions = {
|
|
277
278
|
onStdout: checkAuth
|
|
278
279
|
};
|
|
279
|
-
var clone = (repoUrl, options, shellOptions = {}) => {
|
|
280
|
-
return $("git", ["clone", "--progress", repoUrl, options], {
|
|
280
|
+
var clone = (repoUrl, options, branch = defaultBranch, shellOptions = {}) => {
|
|
281
|
+
return $("git", ["clone", "--progress", repoUrl, "--branch", branch, options], {
|
|
281
282
|
...defaultShellOptions,
|
|
282
283
|
...shellOptions
|
|
283
284
|
});
|
|
@@ -318,8 +319,8 @@ var readJsonFromCommit = async (commit2, file) => {
|
|
|
318
319
|
return {};
|
|
319
320
|
}
|
|
320
321
|
};
|
|
321
|
-
var readJsonFromRemote = async (remote, file, commit2) => {
|
|
322
|
-
return readJsonFromCommit(commit2 || `${remote}
|
|
322
|
+
var readJsonFromRemote = async (remote, file, branch = defaultBranch, commit2) => {
|
|
323
|
+
return readJsonFromCommit(commit2 || `${remote}/${branch}`, file);
|
|
323
324
|
};
|
|
324
325
|
var isCommitOlder = async (a, b) => {
|
|
325
326
|
try {
|
|
@@ -332,8 +333,8 @@ var isCommitOlder = async (a, b) => {
|
|
|
332
333
|
var update = (shellOptions = {}) => {
|
|
333
334
|
return $("git", ["pull", "--progress"], { ...defaultShellOptions, ...shellOptions });
|
|
334
335
|
};
|
|
335
|
-
var getLatestCommitFromRemote = async (remote) => {
|
|
336
|
-
return getLatestCommit(`${remote}
|
|
336
|
+
var getLatestCommitFromRemote = async (remote, branch) => {
|
|
337
|
+
return getLatestCommit(`${remote}/${branch}`);
|
|
337
338
|
};
|
|
338
339
|
var getLatestCommitFromPath = async (path12) => {
|
|
339
340
|
return getLatestCommit("HEAD", path12);
|
|
@@ -387,7 +388,7 @@ var init = async (cwd) => {
|
|
|
387
388
|
await $("git", ["init"], { cwd });
|
|
388
389
|
await $("git", ["add", "."], { cwd });
|
|
389
390
|
await $("git", ["commit", "-m", "init"], { cwd });
|
|
390
|
-
await $("git", ["branch", "-m",
|
|
391
|
+
await $("git", ["branch", "-m", defaultBranch], { cwd });
|
|
391
392
|
};
|
|
392
393
|
var add = async (toAdd) => {
|
|
393
394
|
debug(`Git Add: ${toAdd}`);
|
|
@@ -620,7 +621,7 @@ async function runTask(message, task) {
|
|
|
620
621
|
// src/services/registry.ts
|
|
621
622
|
var registriesDataPath = import_node_path8.default.join(appPaths.data, "registries");
|
|
622
623
|
var upeToDate = false;
|
|
623
|
-
var syncRegistries = async () => {
|
|
624
|
+
var syncRegistries = async (branch) => {
|
|
624
625
|
if (upeToDate) return;
|
|
625
626
|
upeToDate = true;
|
|
626
627
|
debug("Sync registries");
|
|
@@ -633,7 +634,7 @@ var syncRegistries = async () => {
|
|
|
633
634
|
const repoName = registry.split("/").pop() || "";
|
|
634
635
|
const repoDir = import_node_path8.default.join(registriesDataPath, repoName);
|
|
635
636
|
if (!import_fs_extra7.default.existsSync(repoDir)) {
|
|
636
|
-
await git.clone(registry, "--depth 1", { cwd: registriesDataPath });
|
|
637
|
+
await git.clone(registry, "--depth 1", branch, { cwd: registriesDataPath });
|
|
637
638
|
} else if (import_fs_extra7.default.existsSync(import_node_path8.default.join(repoDir, ".git"))) {
|
|
638
639
|
await git.update({ cwd: repoDir });
|
|
639
640
|
} else {
|
|
@@ -942,15 +943,18 @@ function runInitScript(cwd) {
|
|
|
942
943
|
}
|
|
943
944
|
|
|
944
945
|
// src/commands/add/index.ts
|
|
945
|
-
var addBlock = async (block, blocks) => {
|
|
946
|
-
const blockPath = `blocks/${block}`;
|
|
946
|
+
var addBlock = async (block, blocks, branch, destination) => {
|
|
947
947
|
const blockRegistryData = blocks[block];
|
|
948
|
+
if (!destination) {
|
|
949
|
+
destination = blockRegistryData?.destination || block;
|
|
950
|
+
}
|
|
951
|
+
const blockPath = `blocks/${destination}`;
|
|
948
952
|
if (!import_fs_extra9.default.existsSync(blockPath)) {
|
|
949
953
|
await runTask(
|
|
950
954
|
{ start: `Fetching block: ${block}`, end: `Added block: ${block}` },
|
|
951
955
|
async () => {
|
|
952
956
|
const blockSource = blockRegistryData?.source || "";
|
|
953
|
-
await git.clone(blockSource, blockPath);
|
|
957
|
+
await git.clone(blockSource, blockPath, branch);
|
|
954
958
|
let commit2 = await selectVersion(blockSource);
|
|
955
959
|
if (commit2) {
|
|
956
960
|
await git.resetToCommit(commit2, blockPath);
|
|
@@ -962,7 +966,7 @@ var addBlock = async (block, blocks) => {
|
|
|
962
966
|
await migrateAll();
|
|
963
967
|
const def = getBlockDef(blockPath);
|
|
964
968
|
await deletePattern(blockPath, def.ignore);
|
|
965
|
-
updateCheckpoint(block, { commit: commit2 }, blockPath);
|
|
969
|
+
updateCheckpoint(block, { commit: commit2, branch }, blockPath);
|
|
966
970
|
}
|
|
967
971
|
);
|
|
968
972
|
await runTask("Run init script", async () => runInitScript(blockPath));
|
|
@@ -974,7 +978,7 @@ var addBlock = async (block, blocks) => {
|
|
|
974
978
|
await addBlock(dep.name, blocks);
|
|
975
979
|
}
|
|
976
980
|
};
|
|
977
|
-
var add2 = command("add").description("Add block to app").alias("a").argument("[block]", "Block to be added").action(async (block) => {
|
|
981
|
+
var add2 = command("add").description("Add block to app").alias("a").argument("[block]", "Block to be added").option("--branch <name>", "branch name").option("--dest <name>", "destination dir").action(async (block, { branch, dest }) => {
|
|
978
982
|
if (await git.hasUncommittedChanges()) {
|
|
979
983
|
import_prompts2.log.warn(fmt.yellow("Make sure to commit any changes first"));
|
|
980
984
|
return;
|
|
@@ -997,7 +1001,7 @@ var add2 = command("add").description("Add block to app").alias("a").argument("[
|
|
|
997
1001
|
if (!blocks[block]) {
|
|
998
1002
|
error("Selected block not available in registries");
|
|
999
1003
|
}
|
|
1000
|
-
await addBlock(block, blocks);
|
|
1004
|
+
await addBlock(block, blocks, branch, dest);
|
|
1001
1005
|
await checkVersionsCompatibility();
|
|
1002
1006
|
} catch (e) {
|
|
1003
1007
|
if (!isDebugMode()) {
|
|
@@ -1073,7 +1077,7 @@ var detach = command("detach").description("Migrate blox schema").option("--basi
|
|
|
1073
1077
|
|
|
1074
1078
|
// src/commands/init/index.ts
|
|
1075
1079
|
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
1076
|
-
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 }) => {
|
|
1080
|
+
var init2 = command("init").description("Init new app").alias("i").option("-n, --name <name>", "App name").option("-t, --template <template>", "Template to use").option("--branch <name>", "branch name").action(async ({ name, template, branch }) => {
|
|
1077
1081
|
await syncRegistries();
|
|
1078
1082
|
try {
|
|
1079
1083
|
if (!name) {
|
|
@@ -1096,7 +1100,7 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
|
|
|
1096
1100
|
const task = spinner();
|
|
1097
1101
|
task.start(`Fetch template`);
|
|
1098
1102
|
const templateSource = templates[template]?.source || "";
|
|
1099
|
-
await git.clone(templateSource, name);
|
|
1103
|
+
await git.clone(templateSource, name, branch);
|
|
1100
1104
|
let commit2 = await selectVersion(templateSource);
|
|
1101
1105
|
if (commit2) {
|
|
1102
1106
|
await git.resetToCommit(commit2, name);
|
|
@@ -1108,7 +1112,7 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
|
|
|
1108
1112
|
const def = getTemplateDef(name);
|
|
1109
1113
|
await deletePattern(name, def.ignore);
|
|
1110
1114
|
await replacePlaceholders(name, { app: { name } });
|
|
1111
|
-
updateCheckpoint(def.name, { commit: commit2 }, name);
|
|
1115
|
+
updateCheckpoint(def.name, { commit: commit2, branch }, name);
|
|
1112
1116
|
await git.init(name);
|
|
1113
1117
|
task.stop(`App initialized in ${name}`);
|
|
1114
1118
|
await runTask("Run init script", async () => runInitScript(name || ""));
|
|
@@ -1146,16 +1150,18 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1146
1150
|
debug("Updating from remote");
|
|
1147
1151
|
await git.updateRemote(name, source);
|
|
1148
1152
|
const bloxFile = getBloxFile(dir);
|
|
1149
|
-
const
|
|
1153
|
+
const checkpoint = bloxFile.checkpoints[name];
|
|
1154
|
+
const fromCommit = checkpoint?.commit;
|
|
1150
1155
|
if (!fromCommit) {
|
|
1151
1156
|
debug("Skip update, no fromCommit found");
|
|
1152
1157
|
return;
|
|
1153
1158
|
}
|
|
1159
|
+
const branch = checkpoint?.branch || defaultBranch;
|
|
1154
1160
|
let toCommit = await selectVersion(source, fromCommit);
|
|
1155
1161
|
if (!toCommit) {
|
|
1156
|
-
toCommit = await git.getLatestCommitFromRemote(name);
|
|
1162
|
+
toCommit = await git.getLatestCommitFromRemote(name, branch);
|
|
1157
1163
|
}
|
|
1158
|
-
debug({ fromCommit, toCommit });
|
|
1164
|
+
debug({ fromCommit, toCommit, branch });
|
|
1159
1165
|
if (fromCommit == toCommit) {
|
|
1160
1166
|
debug("No new version");
|
|
1161
1167
|
return;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -69,6 +69,7 @@ Init new app
|
|
|
69
69
|
Options:
|
|
70
70
|
-n, --name App name
|
|
71
71
|
-t, --template Template to use
|
|
72
|
+
--branch, branch name to use
|
|
72
73
|
```
|
|
73
74
|
|
|
74
75
|
#### add
|
|
@@ -84,6 +85,10 @@ Add block to app
|
|
|
84
85
|
|
|
85
86
|
Params:
|
|
86
87
|
block Block name (Optional)
|
|
88
|
+
|
|
89
|
+
Options:
|
|
90
|
+
--branch, branch name to use
|
|
91
|
+
--dest, destination dir
|
|
87
92
|
```
|
|
88
93
|
|
|
89
94
|
#### update
|