@naseej/blox 1.4.2 → 1.4.4
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 +29 -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.4";
|
|
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);
|
|
@@ -352,6 +353,7 @@ var getLatestCommit = async (rev, cwd = ".") => {
|
|
|
352
353
|
var createPatch = async (fromCommit, toCommit, outputPath, ignore2 = []) => {
|
|
353
354
|
return $("git", [
|
|
354
355
|
"diff",
|
|
356
|
+
"--binary",
|
|
355
357
|
fromCommit,
|
|
356
358
|
toCommit,
|
|
357
359
|
">",
|
|
@@ -387,7 +389,7 @@ var init = async (cwd) => {
|
|
|
387
389
|
await $("git", ["init"], { cwd });
|
|
388
390
|
await $("git", ["add", "."], { cwd });
|
|
389
391
|
await $("git", ["commit", "-m", "init"], { cwd });
|
|
390
|
-
await $("git", ["branch", "-m",
|
|
392
|
+
await $("git", ["branch", "-m", defaultBranch], { cwd });
|
|
391
393
|
};
|
|
392
394
|
var add = async (toAdd) => {
|
|
393
395
|
debug(`Git Add: ${toAdd}`);
|
|
@@ -620,7 +622,7 @@ async function runTask(message, task) {
|
|
|
620
622
|
// src/services/registry.ts
|
|
621
623
|
var registriesDataPath = import_node_path8.default.join(appPaths.data, "registries");
|
|
622
624
|
var upeToDate = false;
|
|
623
|
-
var syncRegistries = async () => {
|
|
625
|
+
var syncRegistries = async (branch) => {
|
|
624
626
|
if (upeToDate) return;
|
|
625
627
|
upeToDate = true;
|
|
626
628
|
debug("Sync registries");
|
|
@@ -633,7 +635,7 @@ var syncRegistries = async () => {
|
|
|
633
635
|
const repoName = registry.split("/").pop() || "";
|
|
634
636
|
const repoDir = import_node_path8.default.join(registriesDataPath, repoName);
|
|
635
637
|
if (!import_fs_extra7.default.existsSync(repoDir)) {
|
|
636
|
-
await git.clone(registry, "--depth 1", { cwd: registriesDataPath });
|
|
638
|
+
await git.clone(registry, "--depth 1", branch, { cwd: registriesDataPath });
|
|
637
639
|
} else if (import_fs_extra7.default.existsSync(import_node_path8.default.join(repoDir, ".git"))) {
|
|
638
640
|
await git.update({ cwd: repoDir });
|
|
639
641
|
} else {
|
|
@@ -942,15 +944,18 @@ function runInitScript(cwd) {
|
|
|
942
944
|
}
|
|
943
945
|
|
|
944
946
|
// src/commands/add/index.ts
|
|
945
|
-
var addBlock = async (block, blocks) => {
|
|
946
|
-
const blockPath = `blocks/${block}`;
|
|
947
|
+
var addBlock = async (block, blocks, branch, destination) => {
|
|
947
948
|
const blockRegistryData = blocks[block];
|
|
949
|
+
if (!destination) {
|
|
950
|
+
destination = blockRegistryData?.destination || block;
|
|
951
|
+
}
|
|
952
|
+
const blockPath = `blocks/${destination}`;
|
|
948
953
|
if (!import_fs_extra9.default.existsSync(blockPath)) {
|
|
949
954
|
await runTask(
|
|
950
955
|
{ start: `Fetching block: ${block}`, end: `Added block: ${block}` },
|
|
951
956
|
async () => {
|
|
952
957
|
const blockSource = blockRegistryData?.source || "";
|
|
953
|
-
await git.clone(blockSource, blockPath);
|
|
958
|
+
await git.clone(blockSource, blockPath, branch);
|
|
954
959
|
let commit2 = await selectVersion(blockSource);
|
|
955
960
|
if (commit2) {
|
|
956
961
|
await git.resetToCommit(commit2, blockPath);
|
|
@@ -962,7 +967,7 @@ var addBlock = async (block, blocks) => {
|
|
|
962
967
|
await migrateAll();
|
|
963
968
|
const def = getBlockDef(blockPath);
|
|
964
969
|
await deletePattern(blockPath, def.ignore);
|
|
965
|
-
updateCheckpoint(block, { commit: commit2 }, blockPath);
|
|
970
|
+
updateCheckpoint(block, { commit: commit2, branch }, blockPath);
|
|
966
971
|
}
|
|
967
972
|
);
|
|
968
973
|
await runTask("Run init script", async () => runInitScript(blockPath));
|
|
@@ -974,7 +979,7 @@ var addBlock = async (block, blocks) => {
|
|
|
974
979
|
await addBlock(dep.name, blocks);
|
|
975
980
|
}
|
|
976
981
|
};
|
|
977
|
-
var add2 = command("add").description("Add block to app").alias("a").argument("[block]", "Block to be added").action(async (block) => {
|
|
982
|
+
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
983
|
if (await git.hasUncommittedChanges()) {
|
|
979
984
|
import_prompts2.log.warn(fmt.yellow("Make sure to commit any changes first"));
|
|
980
985
|
return;
|
|
@@ -997,7 +1002,7 @@ var add2 = command("add").description("Add block to app").alias("a").argument("[
|
|
|
997
1002
|
if (!blocks[block]) {
|
|
998
1003
|
error("Selected block not available in registries");
|
|
999
1004
|
}
|
|
1000
|
-
await addBlock(block, blocks);
|
|
1005
|
+
await addBlock(block, blocks, branch, dest);
|
|
1001
1006
|
await checkVersionsCompatibility();
|
|
1002
1007
|
} catch (e) {
|
|
1003
1008
|
if (!isDebugMode()) {
|
|
@@ -1073,7 +1078,7 @@ var detach = command("detach").description("Migrate blox schema").option("--basi
|
|
|
1073
1078
|
|
|
1074
1079
|
// src/commands/init/index.ts
|
|
1075
1080
|
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 }) => {
|
|
1081
|
+
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
1082
|
await syncRegistries();
|
|
1078
1083
|
try {
|
|
1079
1084
|
if (!name) {
|
|
@@ -1096,7 +1101,7 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
|
|
|
1096
1101
|
const task = spinner();
|
|
1097
1102
|
task.start(`Fetch template`);
|
|
1098
1103
|
const templateSource = templates[template]?.source || "";
|
|
1099
|
-
await git.clone(templateSource, name);
|
|
1104
|
+
await git.clone(templateSource, name, branch);
|
|
1100
1105
|
let commit2 = await selectVersion(templateSource);
|
|
1101
1106
|
if (commit2) {
|
|
1102
1107
|
await git.resetToCommit(commit2, name);
|
|
@@ -1108,7 +1113,7 @@ var init2 = command("init").description("Init new app").alias("i").option("-n, -
|
|
|
1108
1113
|
const def = getTemplateDef(name);
|
|
1109
1114
|
await deletePattern(name, def.ignore);
|
|
1110
1115
|
await replacePlaceholders(name, { app: { name } });
|
|
1111
|
-
updateCheckpoint(def.name, { commit: commit2 }, name);
|
|
1116
|
+
updateCheckpoint(def.name, { commit: commit2, branch }, name);
|
|
1112
1117
|
await git.init(name);
|
|
1113
1118
|
task.stop(`App initialized in ${name}`);
|
|
1114
1119
|
await runTask("Run init script", async () => runInitScript(name || ""));
|
|
@@ -1146,16 +1151,18 @@ async function updateFromRemote({ name, source = "", ignore: ignore2 = [], dir =
|
|
|
1146
1151
|
debug("Updating from remote");
|
|
1147
1152
|
await git.updateRemote(name, source);
|
|
1148
1153
|
const bloxFile = getBloxFile(dir);
|
|
1149
|
-
const
|
|
1154
|
+
const checkpoint = bloxFile.checkpoints[name];
|
|
1155
|
+
const fromCommit = checkpoint?.commit;
|
|
1150
1156
|
if (!fromCommit) {
|
|
1151
1157
|
debug("Skip update, no fromCommit found");
|
|
1152
1158
|
return;
|
|
1153
1159
|
}
|
|
1160
|
+
const branch = checkpoint?.branch || defaultBranch;
|
|
1154
1161
|
let toCommit = await selectVersion(source, fromCommit);
|
|
1155
1162
|
if (!toCommit) {
|
|
1156
|
-
toCommit = await git.getLatestCommitFromRemote(name);
|
|
1163
|
+
toCommit = await git.getLatestCommitFromRemote(name, branch);
|
|
1157
1164
|
}
|
|
1158
|
-
debug({ fromCommit, toCommit });
|
|
1165
|
+
debug({ fromCommit, toCommit, branch });
|
|
1159
1166
|
if (fromCommit == toCommit) {
|
|
1160
1167
|
debug("No new version");
|
|
1161
1168
|
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
|