mygo-cli 0.1.1 → 0.1.2

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/index.js +27 -2
  2. package/package.json +7 -7
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  import { execFileSync } from "node:child_process";
7
7
  import { accessSync, chmodSync, constants, existsSync, readFileSync } from "node:fs";
8
8
  import { createRequire } from "node:module";
9
- import { dirname, join } from "node:path";
9
+ import { basename, dirname, join, sep } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
11
 
12
12
  const require = createRequire(import.meta.url);
@@ -53,7 +53,7 @@ export function binaryPath() {
53
53
  } catch {
54
54
  throw new Error(
55
55
  `mygo-cli: ${pkg}, the package with the mygo binary of this platform, is not installed. ` +
56
- `Reinstall mygo-cli without omitting optional dependencies, or install the CLI with Go: ${goInstall}`,
56
+ `${reinstallHint(pkg)} Or install the CLI with Go: ${goInstall}`,
57
57
  );
58
58
  }
59
59
  const bin = join(dir, "bin", exe);
@@ -76,6 +76,31 @@ export function defineConfig(config) {
76
76
  return config;
77
77
  }
78
78
 
79
+ /**
80
+ * Says how to install pkg, the missing package of the mygo binary. Package
81
+ * managers skip an optional dependency they fail to fetch, as when npm does
82
+ * not serve it yet, and bun keeps skipping it while bun.lock lacks it, even
83
+ * with --force.
84
+ */
85
+ function reinstallHint(pkg) {
86
+ // The directory whose node_modules holds mygo-cli, at any depth.
87
+ const i = here.indexOf(`${sep}node_modules${sep}`);
88
+ const root = i < 0 ? here : here.slice(0, i);
89
+ const runner = basename(root).startsWith("bunx-") ? "bunx" : basename(dirname(root)) === "_npx" ? "npx" : "";
90
+ if (runner) {
91
+ return `${runner} installed mygo-cli without it in ${root}: remove that directory, then run ${runner} again.`;
92
+ }
93
+ const lockfile = join(root, "bun.lock");
94
+ let lock = "";
95
+ try {
96
+ lock = readFileSync(lockfile, "utf8");
97
+ } catch {}
98
+ if (lock && !lock.includes(`"${pkg}": [`)) {
99
+ return `bun installed mygo-cli without it, and does so again while ${lockfile} lacks it, even with --force: remove that file, then install again.`;
100
+ }
101
+ return "Reinstall mygo-cli without omitting optional dependencies.";
102
+ }
103
+
79
104
  /** Reports whether dir is a checkout of the MyGo repository. */
80
105
  function isCheckout(dir) {
81
106
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mygo-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "The mygo command line tool: create, develop and package MyGo desktop apps",
5
5
  "keywords": [
6
6
  "mygo",
@@ -40,11 +40,11 @@
40
40
  "test": "bun test"
41
41
  },
42
42
  "optionalDependencies": {
43
- "@egoist/mygo-cli-darwin-arm64": "0.1.1",
44
- "@egoist/mygo-cli-darwin-x64": "0.1.1",
45
- "@egoist/mygo-cli-linux-arm64": "0.1.1",
46
- "@egoist/mygo-cli-linux-x64": "0.1.1",
47
- "@egoist/mygo-cli-win32-arm64": "0.1.1",
48
- "@egoist/mygo-cli-win32-x64": "0.1.1"
43
+ "@egoist/mygo-cli-darwin-arm64": "0.1.2",
44
+ "@egoist/mygo-cli-darwin-x64": "0.1.2",
45
+ "@egoist/mygo-cli-linux-arm64": "0.1.2",
46
+ "@egoist/mygo-cli-linux-x64": "0.1.2",
47
+ "@egoist/mygo-cli-win32-arm64": "0.1.2",
48
+ "@egoist/mygo-cli-win32-x64": "0.1.2"
49
49
  }
50
50
  }