@joule-sh/code 0.20.1 → 0.21.0

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/README.md CHANGED
@@ -23,16 +23,12 @@ as an optional dependency and skips everywhere it does not apply:
23
23
  | `linux-x64` | `@joule-sh/code-linux-x64` |
24
24
  | `darwin-x64` | `@joule-sh/code-darwin-x64` |
25
25
  | `darwin-arm64` | `@joule-sh/code-darwin-arm64` |
26
+ | `win32-x64` | `@joule-sh/code-win32-x64` |
26
27
 
27
28
  Every one of them carries the garbage collector it needs, so there is nothing
28
29
  to install alongside. The Linux binary is linked statically against musl and
29
30
  needs nothing at all from the machine it lands on.
30
31
 
31
- **There is no Windows build yet.** Installing here prints a message saying so
32
- and pointing at
33
- [#173](https://github.com/joule-sh/code/issues/173). Until that lands, joule
34
- runs on Windows inside WSL.
35
-
36
32
  ## If npm skipped the binary
37
33
 
38
34
  npm has a [long-standing bug](https://github.com/npm/cli/issues/4828) where it
package/lib/download.js CHANGED
@@ -34,7 +34,7 @@ function checkIntegrity(bytes, integrity) {
34
34
  }
35
35
 
36
36
  function untar(tarball, into) {
37
- const result = spawnSync("tar", ["-xzf", tarball, "-C", into], { encoding: "utf8" });
37
+ const result = spawnSync("tar", ["--force-local", "-xzf", tarball, "-C", into], { encoding: "utf8" });
38
38
  if (result.error) { return "could not run tar: " + result.error.message; }
39
39
  if (result.status !== 0) { return "tar exited " + result.status + ": " + (result.stderr || "").trim(); }
40
40
  return "";
package/lib/platform.js CHANGED
@@ -3,7 +3,6 @@
3
3
  const REPO = "https://github.com/joule-sh/code";
4
4
  const SCOPE = "@joule-sh";
5
5
  const WRAPPER = SCOPE + "/code";
6
- const WINDOWS_ISSUE = REPO + "/issues/173";
7
6
  const NPM_BUG = "https://github.com/npm/cli/issues/4828";
8
7
  const OVERRIDE = "JOULE_BINARY_PATH";
9
8
 
@@ -11,6 +10,7 @@ const BUILT = {
11
10
  "linux-x64": SCOPE + "/code-linux-x64",
12
11
  "darwin-x64": SCOPE + "/code-darwin-x64",
13
12
  "darwin-arm64": SCOPE + "/code-darwin-arm64",
13
+ "win32-x64": SCOPE + "/code-win32-x64",
14
14
  };
15
15
 
16
16
  const BINARIES = ["joule", "relay", "joule-daemon"];
@@ -32,12 +32,12 @@ function isWindows(id) {
32
32
  return id.startsWith("win32-");
33
33
  }
34
34
 
35
- function windowsNotice() {
36
- return [
37
- "joule: there is no Windows build of joule yet, so there is no binary for this package to install here.",
38
- " " + WINDOWS_ISSUE + " is the ticket for the Windows binary; watch that rather than this package.",
39
- " Until it lands, joule runs on Windows through WSL: open a WSL shell and install it from inside there.",
40
- ].join("\n");
35
+ function exeSuffix(id) {
36
+ return isWindows(id) ? ".exe" : "";
37
+ }
38
+
39
+ function binaryFile(name, id) {
40
+ return name + exeSuffix(id);
41
41
  }
42
42
 
43
43
  function unsupportedNotice(id) {
@@ -63,7 +63,6 @@ function missingNotice(id, version) {
63
63
  }
64
64
 
65
65
  function notice(id, version) {
66
- if (isWindows(id)) { return windowsNotice(); }
67
66
  if (packageFor(id) === "") { return unsupportedNotice(id); }
68
67
  return missingNotice(id, version);
69
68
  }
@@ -72,7 +71,6 @@ module.exports = {
72
71
  REPO,
73
72
  SCOPE,
74
73
  WRAPPER,
75
- WINDOWS_ISSUE,
76
74
  OVERRIDE,
77
75
  BINARIES,
78
76
  COMMANDS,
@@ -80,7 +78,8 @@ module.exports = {
80
78
  packageFor,
81
79
  supported,
82
80
  isWindows,
83
- windowsNotice,
81
+ exeSuffix,
82
+ binaryFile,
84
83
  unsupportedNotice,
85
84
  missingNotice,
86
85
  notice,
@@ -19,10 +19,11 @@ function warn(message) {
19
19
  console.error(message);
20
20
  }
21
21
 
22
- function makeExecutable(dir) {
22
+ function makeExecutable(dir, id) {
23
23
  const changed = [];
24
+ if (platform.isWindows(id)) { return changed; }
24
25
  for (const name of platform.BINARIES) {
25
- const file = path.join(dir, name);
26
+ const file = path.join(dir, platform.binaryFile(name, id));
26
27
  if (!fs.existsSync(file)) { continue; }
27
28
  const mode = fs.statSync(file).mode & 0o777;
28
29
  const wanted = mode | 0o111;
@@ -72,10 +73,10 @@ function restore() {
72
73
  for (const command of platform.COMMANDS) { writeCommand(command, ""); }
73
74
  }
74
75
 
75
- function smoke(dir) {
76
+ function smoke(dir, id) {
76
77
  const failures = [];
77
78
  for (const name of platform.BINARIES) {
78
- const file = path.join(dir, name);
79
+ const file = path.join(dir, platform.binaryFile(name, id));
79
80
  if (!fs.existsSync(file)) { failures.push(name + " is missing from " + dir); continue; }
80
81
  const result = spawnSync(file, ["--version"], { encoding: "utf8" });
81
82
  if (result.error) { failures.push(name + " will not run: " + result.error.message); continue; }
@@ -106,10 +107,6 @@ async function obtain(id) {
106
107
  }
107
108
 
108
109
  async function main(id) {
109
- if (platform.isWindows(id)) {
110
- warn(platform.windowsNotice());
111
- return 1;
112
- }
113
110
  if (platform.packageFor(id) === "") {
114
111
  warn(platform.unsupportedNotice(id));
115
112
  return 1;
@@ -120,7 +117,7 @@ async function main(id) {
120
117
  warn(platform.notice(id, resolve.selfVersion()));
121
118
  return 1;
122
119
  }
123
- const changed = makeExecutable(found.dir);
120
+ const changed = makeExecutable(found.dir, id);
124
121
  if (changed.length > 0) {
125
122
  say("joule: restored the execute bit on " + changed.join(", ") + ", which an npm tarball does not carry reliably.");
126
123
  }
@@ -134,7 +131,7 @@ async function main(id) {
134
131
  const unsigned = adHocSign(found.dir);
135
132
  for (const failure of unsigned) { warn("joule: " + failure); }
136
133
  }
137
- const broken = smoke(found.dir);
134
+ const broken = smoke(found.dir, id);
138
135
  if (broken.length > 0) {
139
136
  restore();
140
137
  for (const failure of broken) { warn("joule: " + failure); }
@@ -143,7 +140,7 @@ async function main(id) {
143
140
  return 1;
144
141
  }
145
142
  for (const command of platform.COMMANDS) {
146
- writeCommand(command, path.join(found.dir, command));
143
+ writeCommand(command, platform.isWindows(id) ? "" : path.join(found.dir, command));
147
144
  }
148
145
  say("joule: " + found.source + " installed to " + found.dir + ", and " + platform.COMMANDS.join(" and ") + " point at it.");
149
146
  return 0;
package/lib/resolve.js CHANGED
@@ -32,9 +32,9 @@ function packageDir(pkg) {
32
32
  }
33
33
  }
34
34
 
35
- function holdsBinaries(dir) {
35
+ function holdsBinaries(dir, id) {
36
36
  if (dir === "") { return false; }
37
- return platform.BINARIES.every((name) => fs.existsSync(path.join(dir, name)));
37
+ return platform.BINARIES.every((name) => fs.existsSync(path.join(dir, platform.binaryFile(name, id))));
38
38
  }
39
39
 
40
40
  function vendorDir() {
@@ -42,16 +42,15 @@ function vendorDir() {
42
42
  }
43
43
 
44
44
  function binaryDir(id) {
45
- if (platform.isWindows(id)) { return { dir: "", source: "" }; }
46
45
  const override = overrideDir();
47
46
  if (override !== "") { return { dir: override, source: platform.OVERRIDE }; }
48
47
  const pkg = platform.packageFor(id);
49
48
  if (pkg !== "") {
50
49
  const installed = path.join(packageDir(pkg), "bin");
51
- if (holdsBinaries(installed)) { return { dir: installed, source: pkg }; }
50
+ if (holdsBinaries(installed, id)) { return { dir: installed, source: pkg }; }
52
51
  }
53
52
  const vendored = path.join(VENDOR, "bin");
54
- if (holdsBinaries(vendored)) { return { dir: vendored, source: "vendor" }; }
53
+ if (holdsBinaries(vendored, id)) { return { dir: vendored, source: "vendor" }; }
55
54
  return { dir: "", source: "" };
56
55
  }
57
56
 
@@ -60,7 +59,7 @@ function binaryPath(name, id) {
60
59
  if (found.dir === "") {
61
60
  throw new Error(platform.notice(id, selfVersion()));
62
61
  }
63
- const file = path.join(found.dir, name);
62
+ const file = path.join(found.dir, platform.binaryFile(name, id));
64
63
  if (!fs.existsSync(file)) {
65
64
  throw new Error("joule: " + found.source + " has no " + name + " in " + found.dir + ".");
66
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joule-sh/code",
3
- "version": "0.20.1",
3
+ "version": "0.21.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,8 +37,9 @@
37
37
  "postinstall": "node lib/postinstall.js"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@joule-sh/code-linux-x64": "0.20.1",
41
- "@joule-sh/code-darwin-x64": "0.20.1",
42
- "@joule-sh/code-darwin-arm64": "0.20.1"
40
+ "@joule-sh/code-linux-x64": "0.21.0",
41
+ "@joule-sh/code-darwin-x64": "0.21.0",
42
+ "@joule-sh/code-darwin-arm64": "0.21.0",
43
+ "@joule-sh/code-win32-x64": "0.21.0"
43
44
  }
44
45
  }