@goodpuppies/workman 0.9.4 → 0.9.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Workman
2
2
 
3
- Workman 0.9.4: the compiler, language server, REPL, test runner, TypeScript 7.1 content mapper and Vite/Bun integrations.
3
+ Workman 0.9.5: the compiler, language server, REPL, test runner, TypeScript 7.1 content mapper and Vite/Bun integrations.
4
4
 
5
5
  Install optional dependencies to obtain the platform binary, which embeds the Deno runtime, tsrs (TypeScript 7.1 reflection), and esbuild (for running programs that import `node_modules` packages); no separate Deno installation is needed. Node is required for the CLI and mapper launcher; Bun can use the integration directly.
6
6
 
package/bin/resolve.cjs CHANGED
@@ -2,17 +2,35 @@ const path = require("node:path");
2
2
  const fs = require("node:fs");
3
3
  const manifest = require("../package.json");
4
4
 
5
- exports.resolveBinary = function () {
6
- const key = `${process.platform}-${process.arch}`;
7
- const names = {
8
- "linux-x64": "linux-x64",
9
- "linux-arm64": "linux-arm64",
10
- "darwin-x64": "darwin-x64",
11
- "darwin-arm64": "darwin-arm64",
12
- "win32-x64": "win32-x64",
13
- "win32-arm64": "win32-arm64",
14
- };
15
- const suffix = names[key];
5
+ const PREBUILT_TARGETS = {
6
+ "linux-x64": "linux-x64",
7
+ "linux-arm64": "linux-arm64",
8
+ "darwin-x64": "darwin-x64",
9
+ "darwin-arm64": "darwin-arm64",
10
+ "win32-x64": "win32-x64",
11
+ "win32-arm64": "win32-arm64",
12
+ };
13
+
14
+ function findDeno(env = process.env, platform = process.platform) {
15
+ const override = env.WORKMAN_DENO_PATH && env.WORKMAN_DENO_PATH.trim();
16
+ if (override && fs.existsSync(override)) return override;
17
+ const exe = platform === "win32" ? "deno.exe" : "deno";
18
+ const pathValue = env.PATH || env.Path || "";
19
+ for (const dir of pathValue.split(path.delimiter)) {
20
+ if (!dir) continue;
21
+ const candidate = path.join(dir, exe);
22
+ try {
23
+ if (fs.statSync(candidate).isFile()) return candidate;
24
+ } catch {
25
+ // continue
26
+ }
27
+ }
28
+ return undefined;
29
+ }
30
+
31
+ exports.resolveBinary = function (platform = process.platform, arch = process.arch) {
32
+ const key = `${platform}-${arch}`;
33
+ const suffix = PREBUILT_TARGETS[key];
16
34
  if (!suffix) throw new Error(`Workman has no prebuilt binary for ${key}`);
17
35
  const name = `${manifest.name}-${suffix}`;
18
36
  let metadata;
@@ -23,15 +41,42 @@ exports.resolveBinary = function () {
23
41
  `Missing ${name}@${manifest.version}. Install optional dependencies; Linux binaries require glibc.`,
24
42
  );
25
43
  }
26
- const platform = JSON.parse(fs.readFileSync(metadata, "utf8"));
27
- if (platform.version !== manifest.version) {
44
+ const platformPkg = JSON.parse(fs.readFileSync(metadata, "utf8"));
45
+ if (platformPkg.version !== manifest.version) {
28
46
  throw new Error(
29
- `Workman binary version mismatch: expected ${manifest.version}, found ${platform.version} at ${metadata}.\n` +
47
+ `Workman binary version mismatch: expected ${manifest.version}, found ${platformPkg.version} at ${metadata}.\n` +
30
48
  `Your package manager left an older optional dependency installed. Fix with:\n` +
31
49
  ` bun install -g ${name}@${manifest.version}\n` +
32
50
  `or:\n` +
33
51
  ` npm install -g ${manifest.name}@${manifest.version}`,
34
52
  );
35
53
  }
36
- return path.join(path.dirname(metadata), "bin", process.platform === "win32" ? "wm.exe" : "wm");
54
+ return path.join(path.dirname(metadata), "bin", platform === "win32" ? "wm.exe" : "wm");
55
+ };
56
+
57
+ exports.resolveCommand = function (options = {}) {
58
+ const platform = options.platform ?? process.platform;
59
+ const arch = options.arch ?? process.arch;
60
+ const env = options.env ?? process.env;
61
+ const key = `${platform}-${arch}`;
62
+ if (PREBUILT_TARGETS[key]) {
63
+ return { command: exports.resolveBinary(platform, arch), args: [] };
64
+ }
65
+ const deno = findDeno(env, platform);
66
+ if (deno) {
67
+ return {
68
+ command: deno,
69
+ args: [
70
+ "run",
71
+ "-A",
72
+ "--no-config",
73
+ "--minimum-dependency-age=0",
74
+ `jsr:${manifest.name}@${manifest.version}`,
75
+ ],
76
+ };
77
+ }
78
+ throw new Error(
79
+ `Workman has no prebuilt binary for ${key}, and 'deno' was not found on PATH. ` +
80
+ `Install Deno (e.g. 'pkg install deno' in Termux) to run Workman via JSR.`,
81
+ );
37
82
  };
package/bin/wm.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  const { spawn } = require("node:child_process");
3
3
  try {
4
- const binary = require("./resolve.cjs").resolveBinary();
5
- const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
4
+ const { command, args } = require("./resolve.cjs").resolveCommand();
5
+ const child = spawn(command, [...args, ...process.argv.slice(2)], { stdio: "inherit" });
6
6
  for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => child.kill(signal));
7
7
  child.on("error", (error) => {
8
8
  console.error(error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodpuppies/workman",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "type": "module",
5
5
  "description": "Workman language tools and experimental TypeScript content mapper",
6
6
  "license": "MIT",
@@ -49,11 +49,11 @@
49
49
  }
50
50
  },
51
51
  "optionalDependencies": {
52
- "@goodpuppies/workman-linux-x64": "0.9.4",
53
- "@goodpuppies/workman-linux-arm64": "0.9.4",
54
- "@goodpuppies/workman-darwin-x64": "0.9.4",
55
- "@goodpuppies/workman-darwin-arm64": "0.9.4",
56
- "@goodpuppies/workman-win32-x64": "0.9.4",
57
- "@goodpuppies/workman-win32-arm64": "0.9.4"
52
+ "@goodpuppies/workman-linux-x64": "0.9.5",
53
+ "@goodpuppies/workman-linux-arm64": "0.9.5",
54
+ "@goodpuppies/workman-darwin-x64": "0.9.5",
55
+ "@goodpuppies/workman-darwin-arm64": "0.9.5",
56
+ "@goodpuppies/workman-win32-x64": "0.9.5",
57
+ "@goodpuppies/workman-win32-arm64": "0.9.5"
58
58
  }
59
59
  }
@@ -2,11 +2,15 @@ import { execFile } from "node:child_process";
2
2
  import { promisify } from "node:util";
3
3
  import { createRequire } from "node:module";
4
4
  const run = promisify(execFile);
5
- const { resolveBinary } = createRequire(import.meta.url)("../../bin/resolve.cjs");
5
+ const { resolveCommand } = createRequire(import.meta.url)("../../bin/resolve.cjs");
6
6
 
7
7
  export async function compileWorkman(path, options = {}) {
8
8
  try {
9
- const { stdout } = await run(options.compilerPath ?? resolveBinary(), [
9
+ const invocation = options.compilerPath
10
+ ? { command: options.compilerPath, args: [] }
11
+ : resolveCommand();
12
+ const { stdout } = await run(invocation.command, [
13
+ ...invocation.args,
10
14
  "compile-library-json",
11
15
  path,
12
16
  ], {