@nickderobertis/allowlister-remote-plugin 0.5.0 → 0.6.1

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/install.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // Post-install step: link the native binary directly onto the command path.
1
+ // Post-install step: link the native binaries directly onto the command path.
2
2
  //
3
3
  // npm has already installed the one platform package that matches this host
4
4
  // (the others are skipped by their `os`/`cpu` fields). On macOS and Linux we
@@ -8,6 +8,10 @@
8
8
  // spawned per invocation, which matters because allowlister can call the plugin
9
9
  // hundreds of times in a single agent session.
10
10
  //
11
+ // We also drop the `allowlister-remote-daemon` binary next to it in the same
12
+ // `bin/` directory so the plugin's sibling lookup (`resolve_daemon_bin`) finds
13
+ // the daemon it auto-starts without it having to be separately on PATH.
14
+ //
11
15
  // On Windows npm generates `.cmd`/`.ps1` shims that invoke the launcher through
12
16
  // Node, so replacing the target in place would break them; we keep the JS
13
17
  // launcher there instead. Either way, if anything goes wrong we leave the
@@ -17,7 +21,7 @@ import { chmodSync, copyFileSync, existsSync, readFileSync, realpathSync } from
17
21
  import { createRequire } from "node:module";
18
22
  import { basename, dirname, join } from "node:path";
19
23
  import { fileURLToPath } from "node:url";
20
- import { binarySpecifier } from "./lib/platform.mjs";
24
+ import { binarySpecifier, daemonSpecifier } from "./lib/platform.mjs";
21
25
 
22
26
  const require = createRequire(import.meta.url);
23
27
  // Resolve symlinks so a workspace link does not make us look like an install.
@@ -65,8 +69,13 @@ if (inWorkspaceCheckout(here)) {
65
69
  const onPath = join(here, "bin", "allowlister-remote-plugin");
66
70
  copyFileSync(native, onPath);
67
71
  chmodSync(onPath, 0o755);
72
+ // Place the daemon next to the plugin so its sibling lookup succeeds.
73
+ const daemon = require.resolve(daemonSpecifier());
74
+ const daemonOnPath = join(here, "bin", "allowlister-remote-daemon");
75
+ copyFileSync(daemon, daemonOnPath);
76
+ chmodSync(daemonOnPath, 0o755);
68
77
  console.log(
69
- "allowlister-remote-plugin: linked the native binary directly onto the command path",
78
+ "allowlister-remote-plugin: linked the native plugin and daemon binaries directly onto the command path",
70
79
  );
71
80
  }
72
81
  } catch (error) {
package/lib/platform.mjs CHANGED
@@ -1,40 +1,42 @@
1
1
  // Shared resolution for the per-platform native binary packages.
2
2
  //
3
- // Each supported platform ships the native `allowlister-remote-plugin` binary in
4
- // its own npm package (declared as an optional dependency of this package). npm
5
- // installs only the package whose `os`/`cpu` match the host, so resolving the
6
- // binary is a matter of mapping the running platform/arch onto that package and
7
- // asking Node where it landed in `node_modules`.
3
+ // Each supported platform ships two native binaries in its own npm package
4
+ // (declared as an optional dependency of this package): the
5
+ // `allowlister-remote-plugin` binary and the `allowlister-remote-daemon` it
6
+ // auto-starts. npm installs only the package whose `os`/`cpu` match the host, so
7
+ // resolving a binary is a matter of mapping the running platform/arch onto that
8
+ // package and asking Node where it landed in `node_modules`. The `.exe`
9
+ // extension on Windows is appended per-binary via `suffix`.
8
10
 
9
11
  const PLATFORM_PACKAGES = new Map([
10
- [
11
- "darwin-arm64",
12
- { pkg: "allowlister-remote-plugin-darwin-arm64", file: "allowlister-remote-plugin" },
13
- ],
14
- ["linux-x64", { pkg: "allowlister-remote-plugin-linux-x64", file: "allowlister-remote-plugin" }],
15
- [
16
- "win32-x64",
17
- { pkg: "allowlister-remote-plugin-win32-x64", file: "allowlister-remote-plugin.exe" },
18
- ],
12
+ ["darwin-arm64", { pkg: "allowlister-remote-plugin-darwin-arm64", suffix: "" }],
13
+ ["linux-x64", { pkg: "allowlister-remote-plugin-linux-x64", suffix: "" }],
14
+ ["win32-x64", { pkg: "allowlister-remote-plugin-win32-x64", suffix: ".exe" }],
19
15
  ]);
20
16
 
21
17
  const SCOPE = "@nickderobertis";
22
18
 
23
19
  /**
24
20
  * Describe the platform package for a given platform/arch, throwing for any
25
- * combination we do not publish a binary for.
21
+ * combination we do not publish a binary for. `file` is the plugin binary's
22
+ * name (with the platform's `.exe` suffix); `daemonFile` is the daemon's.
26
23
  */
27
24
  export function platformPackage(platform = process.platform, arch = process.arch) {
28
25
  const entry = PLATFORM_PACKAGES.get(`${platform}-${arch}`);
29
26
  if (!entry) {
30
27
  throw new Error(`Unsupported platform: ${platform}-${arch}`);
31
28
  }
32
- return { name: `${SCOPE}/${entry.pkg}`, file: entry.file };
29
+ return {
30
+ name: `${SCOPE}/${entry.pkg}`,
31
+ file: `allowlister-remote-plugin${entry.suffix}`,
32
+ daemonFile: `allowlister-remote-daemon${entry.suffix}`,
33
+ };
33
34
  }
34
35
 
35
36
  /**
36
- * The bare specifier Node uses to locate the native binary inside the installed
37
- * platform package, e.g. `@nickderobertis/allowlister-remote-plugin-linux-x64/bin/allowlister-remote-plugin`.
37
+ * The bare specifier Node uses to locate the native plugin binary inside the
38
+ * installed platform package, e.g.
39
+ * `@nickderobertis/allowlister-remote-plugin-linux-x64/bin/allowlister-remote-plugin`.
38
40
  */
39
41
  export function binarySpecifier(platform = process.platform, arch = process.arch) {
40
42
  const { name, file } = platformPackage(platform, arch);
@@ -42,9 +44,19 @@ export function binarySpecifier(platform = process.platform, arch = process.arch
42
44
  }
43
45
 
44
46
  /**
45
- * Resolve the absolute path to the native binary using the caller's `require`
46
- * (created with `createRequire(import.meta.url)`). Throws if the matching
47
- * platform package is not installed.
47
+ * The bare specifier Node uses to locate the native daemon binary inside the
48
+ * installed platform package, e.g.
49
+ * `@nickderobertis/allowlister-remote-plugin-linux-x64/bin/allowlister-remote-daemon`.
50
+ */
51
+ export function daemonSpecifier(platform = process.platform, arch = process.arch) {
52
+ const { name, daemonFile } = platformPackage(platform, arch);
53
+ return `${name}/bin/${daemonFile}`;
54
+ }
55
+
56
+ /**
57
+ * Resolve the absolute path to the native plugin binary using the caller's
58
+ * `require` (created with `createRequire(import.meta.url)`). Throws if the
59
+ * matching platform package is not installed.
48
60
  */
49
61
  export function resolveNativeBinary(require, platform = process.platform, arch = process.arch) {
50
62
  return require.resolve(binarySpecifier(platform, arch));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nickderobertis/allowlister-remote-plugin",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "npm installer for the allowlister remote dynamic approval plugin",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -28,8 +28,8 @@
28
28
  "node": ">=20"
29
29
  },
30
30
  "optionalDependencies": {
31
- "@nickderobertis/allowlister-remote-plugin-darwin-arm64": "0.5.0",
32
- "@nickderobertis/allowlister-remote-plugin-linux-x64": "0.5.0",
33
- "@nickderobertis/allowlister-remote-plugin-win32-x64": "0.5.0"
31
+ "@nickderobertis/allowlister-remote-plugin-darwin-arm64": "0.6.1",
32
+ "@nickderobertis/allowlister-remote-plugin-linux-x64": "0.6.1",
33
+ "@nickderobertis/allowlister-remote-plugin-win32-x64": "0.6.1"
34
34
  }
35
35
  }