@naseej/blox 0.1.4 → 0.1.5

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 (2) hide show
  1. package/dist/run.js +28 -10
  2. package/package.json +1 -1
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.4";
34
+ var version = "0.1.5";
35
35
 
36
36
  // src/services/git.ts
37
37
  var import_node_path = __toESM(require("path"));
@@ -106,6 +106,22 @@ var clone = (repoUrl, options, shellOptions = {}) => {
106
106
  ...shellOptions
107
107
  });
108
108
  };
109
+ var updateRemote = async (name, source, shellOptions = {}) => {
110
+ debug("updateRemote");
111
+ debug({ name, source });
112
+ try {
113
+ await $("git", ["remote", "add", name, source], {
114
+ ...defaultShellOptions,
115
+ ...shellOptions
116
+ });
117
+ } catch {
118
+ }
119
+ await $("git", ["remote", "set-url", name, source], {
120
+ ...defaultShellOptions,
121
+ ...shellOptions
122
+ });
123
+ await $("git", ["fetch", name], { ...defaultShellOptions, ...shellOptions });
124
+ };
109
125
  var update = (shellOptions = {}) => {
110
126
  return $("git", ["pull", "--progress"], { ...defaultShellOptions, ...shellOptions });
111
127
  };
@@ -120,17 +136,17 @@ var getLatestCommit = async (cwd) => {
120
136
  });
121
137
  return commit.replace(/\n/g, "");
122
138
  };
123
- var patchesDir = ".update_patches";
139
+ var patchFileName = "diff.patch";
124
140
  var createPatch = async (cwd, fromCommit, toCommit) => {
125
- return $("git", ["format-patch", "-o", patchesDir, `${fromCommit}..${toCommit}`], { cwd });
141
+ return $("git", ["diff", fromCommit, toCommit, ">", patchFileName], { cwd });
126
142
  };
127
- var applyPatch = (patchs, cwd = ".") => {
143
+ var applyPatch = (patch, cwd = ".") => {
128
144
  const args = ["apply", "-3"];
129
145
  if (cwd != ".") {
130
146
  args.push("--directory");
131
147
  args.push(cwd);
132
148
  }
133
- args.push(`${patchs}/*.patch`);
149
+ args.push(patch);
134
150
  return $("git", args);
135
151
  };
136
152
  var unInit = (cwd) => {
@@ -151,7 +167,8 @@ var git = {
151
167
  init,
152
168
  getLatestCommit,
153
169
  createPatch,
154
- applyPatch
170
+ applyPatch,
171
+ updateRemote
155
172
  };
156
173
 
157
174
  // src/services/registry.ts
@@ -514,20 +531,21 @@ async function updateFromRemote(name, source = "", destPath = ".") {
514
531
  import_fs_extra6.default.ensureDirSync(appPaths.temp);
515
532
  const tmpClone = import_node_path5.default.join(appPaths.temp, name);
516
533
  await import_fs_extra6.default.remove(tmpClone);
534
+ await git.updateRemote(name, source);
517
535
  await git.clone(source, name, { cwd: appPaths.temp });
518
536
  const fromCommit = getBasedOnInfo(destPath).commit;
519
537
  const toCommit = await git.getLatestCommit(tmpClone);
520
538
  debug({ fromCommit, toCommit });
521
539
  await git.createPatch(tmpClone, fromCommit, toCommit);
522
- const patchDirPath = import_node_path5.default.join(destPath, patchesDir);
523
- import_fs_extra6.default.moveSync(import_node_path5.default.join(tmpClone, patchesDir), patchDirPath);
540
+ const patchFilePath = import_node_path5.default.join(destPath, patchFileName);
541
+ import_fs_extra6.default.moveSync(import_node_path5.default.join(tmpClone, patchFileName), patchFilePath);
524
542
  try {
525
- await git.applyPatch(patchDirPath, destPath);
543
+ await git.applyPatch(patchFilePath, destPath);
526
544
  } catch {
527
545
  }
528
546
  updateBasedOnInfo({ commit: toCommit }, destPath);
529
547
  if (!isDebugMode()) {
530
- await import_fs_extra6.default.remove(patchDirPath);
548
+ await import_fs_extra6.default.unlink(patchFilePath);
531
549
  }
532
550
  await import_fs_extra6.default.remove(tmpClone);
533
551
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naseej/blox",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "blox cli",
5
5
  "bin": {
6
6
  "blox": "./bin/run"