runbay 0.1.4 → 0.1.6

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/out/main/index.js +34 -8
  2. package/package.json +1 -1
package/out/main/index.js CHANGED
@@ -56,8 +56,9 @@ function cachedIcon(key, candidates) {
56
56
  }
57
57
  async function resolve(key, candidates) {
58
58
  const cacheDir = node_path.join(electron.app.getPath("userData"), "icon-cache");
59
- const cacheFile = node_path.join(cacheDir, node_crypto.createHash("sha1").update(`v2:${key}`).digest("hex"));
60
- if (node_fs.existsSync(cacheFile)) return toDataUrl(node_fs.readFileSync(cacheFile));
59
+ const cacheFile = node_path.join(cacheDir, node_crypto.createHash("sha1").update(`v3:${key}`).digest("hex"));
60
+ if (node_fs.existsSync(cacheFile) && Date.now() - node_fs.statSync(cacheFile).mtimeMs < 7 * 24 * 36e5)
61
+ return toDataUrl(node_fs.readFileSync(cacheFile));
61
62
  for (const url of await candidates()) {
62
63
  const buf = await download(url);
63
64
  if (buf) {
@@ -171,6 +172,23 @@ async function readJsonSafe(file2) {
171
172
  async function readPackageJson(dir) {
172
173
  return readJsonSafe(node_path.join(dir, "package.json"));
173
174
  }
175
+ function repoUrl(pkg) {
176
+ const repo = pkg.repository;
177
+ const raw = typeof repo === "string" ? repo : typeof repo?.url === "string" ? repo.url : void 0;
178
+ if (!raw) return void 0;
179
+ let url = raw.trim().replace(/^git\+/, "");
180
+ const ssh = url.match(/^ssh:\/\/git@([^/]+)\/(.+)$/);
181
+ if (ssh) url = `https://${ssh[1]}/${ssh[2]}`;
182
+ const scp = url.match(/^git@([^:/]+)[:/](.+)$/);
183
+ if (scp) url = `https://${scp[1]}/${scp[2]}`;
184
+ url = url.replace(/\.git$/, "").replace(/\/+$/, "");
185
+ try {
186
+ const parsed = new URL(url);
187
+ return parsed.protocol === "https:" || parsed.protocol === "http:" ? url : void 0;
188
+ } catch {
189
+ return void 0;
190
+ }
191
+ }
174
192
  async function readPkgMeta(dir, pkgName) {
175
193
  const pkg = dir ? await readPackageJson(dir) ?? {} : {};
176
194
  const binField = pkg.bin;
@@ -178,7 +196,7 @@ async function readPkgMeta(dir, pkgName) {
178
196
  return {
179
197
  version: typeof pkg.version === "string" ? pkg.version : void 0,
180
198
  description: typeof pkg.description === "string" ? pkg.description : void 0,
181
- homepage: typeof pkg.homepage === "string" ? pkg.homepage : void 0,
199
+ homepage: typeof pkg.homepage === "string" ? pkg.homepage : repoUrl(pkg),
182
200
  bins
183
201
  };
184
202
  }
@@ -591,7 +609,8 @@ function applyIgnored(apps2) {
591
609
  }
592
610
  async function listProvider(provider, onBatch) {
593
611
  const outdatedPromise = provider.checkOutdated ? provider.checkOutdated().catch(() => ({})) : Promise.resolve({});
594
- const apps2 = await provider.list();
612
+ const self = electron.app.getAppPath().toLowerCase();
613
+ const apps2 = (await provider.list()).filter((a) => a.path?.toLowerCase() !== self);
595
614
  applyIgnored(apps2);
596
615
  onBatch?.(apps2);
597
616
  const outdated = await outdatedPromise;
@@ -697,13 +716,17 @@ async function applySelfUpdate() {
697
716
  return { state: "done", message: `Updated to ${target} — restart to apply` };
698
717
  }
699
718
  if (!await installedGlobally()) {
700
- return { state: "manual", message: `npm install -g ${PKG}@latest` };
719
+ return { state: "manual", message: `npm install -g ${PKG}@${target}` };
701
720
  }
702
721
  const root = await globalRoot();
703
722
  const shim = node_path.join(node_path.dirname(root), `${PKG}.cmd`);
704
723
  const script = node_path.join(electron.app.getPath("userData"), "update.cmd");
724
+ const vbs = node_path.join(electron.app.getPath("userData"), "update-hidden.vbs");
705
725
  const log = node_path.join(electron.app.getPath("userData"), "update.log");
706
- const install = `call npm install -g ${PKG}@latest${registryFlag}`;
726
+ const appDir = electron.app.getAppPath();
727
+ const electronExe = node_path.join(appDir, "node_modules", "electron", "dist", "electron.exe");
728
+ const relaunch = node_fs.existsSync(electronExe) ? `start "" "${electronExe}" "${appDir}"` : `start "" "${shim}"`;
729
+ const install = `call npm install -g ${PKG}@${target}${registryFlag}`;
707
730
  const body = [
708
731
  "@echo off",
709
732
  "ping -n 5 127.0.0.1 >nul",
@@ -714,13 +737,16 @@ async function applySelfUpdate() {
714
737
  // le registre met parfois une minute à propager une publication prouvée
715
738
  `${install} --prefer-online >> "${log}" 2>&1`,
716
739
  ")",
717
- `start "" "${shim}"`,
740
+ relaunch,
741
+ `del "${vbs}"`,
718
742
  'del "%~f0"',
719
743
  ""
720
744
  ].join("\r\n");
721
745
  try {
746
+ node_fs.writeFileSync(vbs, `CreateObject("WScript.Shell").Run """${script}""", 0, False\r
747
+ `);
722
748
  node_fs.writeFileSync(script, body);
723
- node_child_process.spawn(`"${script}"`, { detached: true, stdio: "ignore", windowsHide: true, shell: true }).unref();
749
+ node_child_process.spawn("wscript.exe", [vbs], { stdio: "ignore" }).unref();
724
750
  } catch (err) {
725
751
  return { state: "error", message: err instanceof Error ? err.message : String(err) };
726
752
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runbay",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Not an installer. A launcher. Detect, launch, update and uninstall apps installed from the command line (npm, pnpm, yarn, bun, scoop) — in one modern window.",
5
5
  "main": "./out/main/index.js",
6
6
  "bin": {