@naseej/blox 0.1.8 → 0.1.10

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.
Files changed (3) hide show
  1. package/dist/run.js +35 -16
  2. package/package.json +1 -1
  3. package/readme.md +13 -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 = "0.1.8";
34
+ var version = "0.1.10";
35
35
 
36
36
  // src/services/git.ts
37
37
  var import_node_path = __toESM(require("path"));
@@ -41,7 +41,7 @@ var import_fs_extra = __toESM(require("fs-extra"));
41
41
  var import_node_child_process = require("child_process");
42
42
 
43
43
  // src/shared/logger.ts
44
- var console = __toESM(require("console"));
44
+ var console2 = __toESM(require("console"));
45
45
  var import_prompts = require("@clack/prompts");
46
46
 
47
47
  // src/config/runtime.ts
@@ -61,15 +61,15 @@ var debug = (message) => {
61
61
  if (typeof message === "string") {
62
62
  import_prompts.log.warn(message.trim());
63
63
  } else {
64
- console.log(JSON.stringify(message));
64
+ console2.log(JSON.stringify(message));
65
65
  }
66
66
  };
67
67
  var logWarningSection = (title, content) => {
68
68
  const line = fmt.yellow("=".repeat(82));
69
- console.log("\n" + line);
70
- console.log(fmt.bold(fmt.yellow("\u25B2 " + title)));
71
- content && console.log(content);
72
- console.log(line + "\n");
69
+ console2.log("\n" + line);
70
+ console2.log(fmt.bold(fmt.yellow("\u25B2 " + title)));
71
+ content && console2.log(content);
72
+ console2.log(line + "\n");
73
73
  };
74
74
 
75
75
  // src/services/shell.ts
@@ -557,21 +557,30 @@ async function updateFromRemote(name, source = "", destPath = ".") {
557
557
  const patchFilePath = import_node_path5.default.join(destPath, "diff.patch");
558
558
  await git.createPatch(fromCommit, toCommit, patchFilePath);
559
559
  const changes = await git.getChangesLog(fromCommit, toCommit);
560
+ const deletePatchFile = async () => {
561
+ if (!isDebugMode()) {
562
+ await import_fs_extra6.default.unlink(patchFilePath);
563
+ }
564
+ debug("make sure to delete the patch file after you're done with it.");
565
+ };
566
+ try {
567
+ await git.applyPatch(patchFilePath, destPath);
568
+ } catch (e) {
569
+ const errorMessage = `${e}`;
570
+ if (errorMessage.includes("error:")) {
571
+ await deletePatchFile();
572
+ console.log(`${e}`.replace("error:", fmt.red("error:")));
573
+ error("Failed to apply changes.");
574
+ }
575
+ }
560
576
  if (changes.trim() !== "") {
561
577
  logWarningSection(
562
578
  "These is the changes from last update, make sure to review for breaking changes",
563
579
  changes
564
580
  );
565
581
  }
566
- try {
567
- await git.applyPatch(patchFilePath, destPath);
568
- } catch {
569
- }
582
+ await deletePatchFile();
570
583
  updateBasedOnInfo({ commit: toCommit }, destPath);
571
- if (!isDebugMode()) {
572
- await import_fs_extra6.default.unlink(patchFilePath);
573
- }
574
- debug("make sure to delete the patch file after you're done with it.");
575
584
  }
576
585
 
577
586
  // src/commands/update/index.ts
@@ -609,8 +618,18 @@ var update2 = command("update").description("Update app/block").alias("u").addOp
609
618
  }
610
619
  });
611
620
 
621
+ // src/commands/upgrade/index.ts
622
+ var upgrade = command("upgrade").description("Upgrade blox cli to latest version").action(async () => {
623
+ try {
624
+ await $("npm", ["i", "-g", "@naseej/blox"]);
625
+ import_prompts2.log.success("Blox updated successfully.");
626
+ } catch (e) {
627
+ error(e);
628
+ }
629
+ });
630
+
612
631
  // src/commands/index.ts
613
- var commands = [init2, add, update2, sync, conf];
632
+ var commands = [init2, add, update2, sync, conf, upgrade];
614
633
 
615
634
  // bin/run.ts
616
635
  import_extra_typings2.program.name("blox").version(version);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naseej/blox",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "blox cli",
5
5
  "bin": {
6
6
  "blox": "./bin/run"
package/readme.md CHANGED
@@ -51,6 +51,7 @@ Options:
51
51
  * [update](#update)
52
52
  * [sync](#sync)
53
53
  * [conf](#conf)
54
+ * [upgrade](#upgrade)
54
55
 
55
56
  #### init
56
57
 
@@ -129,6 +130,18 @@ Options:
129
130
  -r, --registries Remote registries urls
130
131
  ```
131
132
 
133
+ #### upgrade
134
+
135
+ ```sh
136
+ blox upgrade
137
+ ```
138
+
139
+ ```
140
+ blox upgrade
141
+
142
+ Upgrade blox cli to latest version
143
+ ```
144
+
132
145
  ### Docs
133
146
 
134
147
  - [Design](./docs/design.md)