pinkcollab 0.1.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/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # PinkCollab
2
+
3
+ This package installs the prebuilt [PinkCollab Gateway](https://github.com/3xian/PinkCollab) for the current operating system and CPU architecture. A Rust toolchain is not required.
4
+
5
+ ```sh
6
+ npm install -g pinkcollab
7
+ pinkcollab init --workspace /absolute/path/to/projects
8
+ pinkcollab status
9
+ pinkcollab serve
10
+ ```
11
+
12
+ Oh My Pi (OMP) remains a separate dependency; `omp --version` must work before the Gateway can run tasks.
13
+
14
+ Supported targets are macOS arm64/x64, Linux arm64/x64, and Windows x64. The platform binary is delivered through an optional `@pinkcollab/gateway-*` dependency selected by npm.
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const path = require("node:path");
6
+ const { spawn } = require("node:child_process");
7
+ const PLATFORMS = require("../platforms.json");
8
+
9
+ const PLATFORM_BY_ID = new Map(
10
+ PLATFORMS.map((platform) => [platform.id, platform]),
11
+ );
12
+
13
+ function resolveGatewayBinary(
14
+ platform = process.platform,
15
+ arch = process.arch,
16
+ resolvePackage = require.resolve,
17
+ ) {
18
+ const target = `${platform}-${arch}`;
19
+ const definition = PLATFORM_BY_ID.get(target);
20
+
21
+ if (!definition) {
22
+ const supported = PLATFORMS.map(({ id }) => id).join(", ");
23
+ throw new Error(
24
+ `PinkCollab does not provide a Gateway binary for ${target}. ` +
25
+ `Supported platforms: ${supported}.`,
26
+ );
27
+ }
28
+
29
+ let manifestPath;
30
+ try {
31
+ manifestPath = resolvePackage(`${definition.package}/package.json`);
32
+ } catch (error) {
33
+ const detail = error instanceof Error ? `\n${error.message}` : "";
34
+ throw new Error(
35
+ `The optional platform package ${definition.package} is not installed. ` +
36
+ "Reinstall with optional dependencies enabled, for example: " +
37
+ "npm install -g pinkcollab --include=optional" +
38
+ detail,
39
+ );
40
+ }
41
+
42
+ return path.join(path.dirname(manifestPath), "bin", definition.binary);
43
+ }
44
+
45
+ function run(binaryPath, args = process.argv.slice(2), spawnChild = spawn) {
46
+ const child = spawnChild(binaryPath, args, { stdio: "inherit" });
47
+ const signals = ["SIGINT", "SIGTERM"];
48
+ const handlers = new Map();
49
+
50
+ for (const signal of signals) {
51
+ const handler = () => {
52
+ try {
53
+ child.kill(signal);
54
+ } catch {
55
+ // The child may already have exited between the signal and this handler.
56
+ }
57
+ };
58
+ handlers.set(signal, handler);
59
+ process.once(signal, handler);
60
+ }
61
+
62
+ const removeSignalHandlers = () => {
63
+ for (const [signal, handler] of handlers) {
64
+ process.removeListener(signal, handler);
65
+ }
66
+ };
67
+
68
+ child.once("error", (error) => {
69
+ removeSignalHandlers();
70
+ console.error(
71
+ `pinkcollab: failed to start ${binaryPath}: ${error.message}`,
72
+ );
73
+ process.exitCode = 1;
74
+ });
75
+
76
+ child.once("exit", (code, signal) => {
77
+ removeSignalHandlers();
78
+ if (signal) {
79
+ try {
80
+ process.kill(process.pid, signal);
81
+ } catch {
82
+ process.exitCode = 1;
83
+ }
84
+ return;
85
+ }
86
+ process.exitCode = code ?? 1;
87
+ });
88
+
89
+ return child;
90
+ }
91
+
92
+ function main() {
93
+ try {
94
+ run(resolveGatewayBinary());
95
+ } catch (error) {
96
+ console.error(
97
+ `pinkcollab: ${error instanceof Error ? error.message : error}`,
98
+ );
99
+ process.exitCode = 1;
100
+ }
101
+ }
102
+
103
+ if (require.main === module) {
104
+ main();
105
+ }
106
+
107
+ module.exports = { PLATFORMS, resolveGatewayBinary, run };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "pinkcollab",
3
+ "version": "0.1.1",
4
+ "description": "Install and run the PinkCollab Gateway without a Rust toolchain",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/3xian/PinkCollab.git",
9
+ "directory": "npm/pinkcollab"
10
+ },
11
+ "homepage": "https://3xian.github.io/PinkCollab/",
12
+ "bugs": "https://github.com/3xian/PinkCollab/issues",
13
+ "bin": {
14
+ "pinkcollab": "./bin/pinkcollab.js"
15
+ },
16
+ "files": [
17
+ "bin",
18
+ "platforms.json"
19
+ ],
20
+ "engines": {
21
+ "node": ">=18"
22
+ },
23
+ "scripts": {
24
+ "test": "node --test test/*.test.js"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "provenance": true
29
+ },
30
+ "optionalDependencies": {
31
+ "@pinkcollab/gateway-darwin-arm64": "0.1.1",
32
+ "@pinkcollab/gateway-darwin-x64": "0.1.1",
33
+ "@pinkcollab/gateway-linux-arm64": "0.1.1",
34
+ "@pinkcollab/gateway-linux-x64": "0.1.1",
35
+ "@pinkcollab/gateway-win32-x64": "0.1.1"
36
+ }
37
+ }
package/platforms.json ADDED
@@ -0,0 +1,47 @@
1
+ [
2
+ {
3
+ "id": "darwin-arm64",
4
+ "package": "@pinkcollab/gateway-darwin-arm64",
5
+ "os": "darwin",
6
+ "cpu": "arm64",
7
+ "runner": "macos-15",
8
+ "target": "aarch64-apple-darwin",
9
+ "binary": "pinkcollab-gateway"
10
+ },
11
+ {
12
+ "id": "darwin-x64",
13
+ "package": "@pinkcollab/gateway-darwin-x64",
14
+ "os": "darwin",
15
+ "cpu": "x64",
16
+ "runner": "macos-15-intel",
17
+ "target": "x86_64-apple-darwin",
18
+ "binary": "pinkcollab-gateway"
19
+ },
20
+ {
21
+ "id": "linux-arm64",
22
+ "package": "@pinkcollab/gateway-linux-arm64",
23
+ "os": "linux",
24
+ "cpu": "arm64",
25
+ "runner": "ubuntu-24.04-arm",
26
+ "target": "aarch64-unknown-linux-musl",
27
+ "binary": "pinkcollab-gateway"
28
+ },
29
+ {
30
+ "id": "linux-x64",
31
+ "package": "@pinkcollab/gateway-linux-x64",
32
+ "os": "linux",
33
+ "cpu": "x64",
34
+ "runner": "ubuntu-24.04",
35
+ "target": "x86_64-unknown-linux-musl",
36
+ "binary": "pinkcollab-gateway"
37
+ },
38
+ {
39
+ "id": "win32-x64",
40
+ "package": "@pinkcollab/gateway-win32-x64",
41
+ "os": "win32",
42
+ "cpu": "x64",
43
+ "runner": "windows-2022",
44
+ "target": "x86_64-pc-windows-msvc",
45
+ "binary": "pinkcollab-gateway.exe"
46
+ }
47
+ ]