@realtimex/signals-pp-cli 0.2.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,22 @@
1
+ # @realtimex/signals-pp-cli
2
+
3
+ Signals Printing Press CLI for terminal agents. Installs the platform-native `signals-pp-cli` binary via optional npm platform packages.
4
+
5
+ ## Usage
6
+
7
+ Pin the CLI version to the running Signals Local App:
8
+
9
+ ```bash
10
+ export SIGNALS_BASE_URL="http://127.0.0.1:3010"
11
+ CLI_VERSION="$(curl -sf "$SIGNALS_BASE_URL/api/health" | jq -r .cliVersion)"
12
+ npx --yes @realtimex/signals-pp-cli@"$CLI_VERSION" health
13
+ npx --yes @realtimex/signals-pp-cli@"$CLI_VERSION" import contacts --file workflow-runs/<runId>/contacts.csv --dedupe --workflow-run-id <runId> --template-id <templateId>
14
+ ```
15
+
16
+ Or use the workspace skill bootstrap script:
17
+
18
+ ```bash
19
+ .claude/skills/realtimex-signals/scripts/run-signals-pp-cli.sh health
20
+ ```
21
+
22
+ Do not rely on a stale global `signals-pp-cli` on `PATH` without checking `cliVersion` from `/api/health`.
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require("child_process");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ const MAIN_PACKAGE_NAME = "@realtimex/signals-pp-cli";
7
+ const binaryName = process.platform === "win32" ? "signals-pp-cli.exe" : "signals-pp-cli";
8
+ const platformPackageName =
9
+ "@realtimex/signals-pp-cli-" + process.platform + "-" + process.arch;
10
+
11
+ function readPackageVersion(packageJsonPath) {
12
+ try {
13
+ return JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version || null;
14
+ } catch (_) {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ function installedCliVersion() {
20
+ try {
21
+ const packageJsonPath = path.resolve(__dirname, "..", "package.json");
22
+ return readPackageVersion(packageJsonPath);
23
+ } catch (_) {
24
+ return null;
25
+ }
26
+ }
27
+
28
+ function warnVersionMismatch(expectedVersion) {
29
+ const installed = installedCliVersion();
30
+ if (!expectedVersion || !installed || expectedVersion === installed) return;
31
+ console.error(
32
+ "warning: " +
33
+ MAIN_PACKAGE_NAME +
34
+ " is " +
35
+ installed +
36
+ " but the running Signals Local App expects cliVersion " +
37
+ expectedVersion +
38
+ ". Prefer: npx --yes " +
39
+ MAIN_PACKAGE_NAME +
40
+ "@" +
41
+ expectedVersion +
42
+ " <command>",
43
+ );
44
+ }
45
+
46
+ async function readHealthCliVersion() {
47
+ if (process.env.SIGNALS_PP_CLI_VERSION_CHECK === "0") return null;
48
+ const baseUrl = String(process.env.SIGNALS_BASE_URL || "").trim().replace(/\/+$/, "");
49
+ if (!baseUrl) return null;
50
+ try {
51
+ const response = await fetch(baseUrl + "/api/health", {
52
+ method: "GET",
53
+ signal: AbortSignal.timeout(3000),
54
+ });
55
+ if (!response.ok) return null;
56
+ const body = await response.json();
57
+ return typeof body.cliVersion === "string" ? body.cliVersion : null;
58
+ } catch (_) {
59
+ return null;
60
+ }
61
+ }
62
+
63
+ function resolveBinaryPath() {
64
+ try {
65
+ return path.join(
66
+ path.dirname(require.resolve(platformPackageName + "/package.json")),
67
+ "bin",
68
+ binaryName,
69
+ );
70
+ } catch (error) {
71
+ const localPackagePath = path.resolve(
72
+ __dirname,
73
+ "..",
74
+ "..",
75
+ "packages",
76
+ process.platform + "-" + process.arch,
77
+ "package.json",
78
+ );
79
+ if (fs.existsSync(localPackagePath)) {
80
+ return path.join(path.dirname(localPackagePath), "bin", binaryName);
81
+ }
82
+ console.error(
83
+ "Unsupported platform for " + MAIN_PACKAGE_NAME + ": " + process.platform + "/" + process.arch,
84
+ );
85
+ console.error("Expected optional package: " + platformPackageName);
86
+ process.exit(1);
87
+ }
88
+ }
89
+
90
+ async function main() {
91
+ const expectedVersion = await readHealthCliVersion();
92
+ warnVersionMismatch(expectedVersion);
93
+
94
+ const binaryPath = resolveBinaryPath();
95
+ const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
96
+ if (result.error) {
97
+ console.error(result.error.message);
98
+ process.exit(1);
99
+ }
100
+ process.exit(result.status == null ? 1 : result.status);
101
+ }
102
+
103
+ main().catch((error) => {
104
+ console.error(error instanceof Error ? error.message : String(error));
105
+ process.exit(1);
106
+ });
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@realtimex/signals-pp-cli",
3
+ "version": "0.2.1",
4
+ "description": "Signals Printing Press CLI for terminal agents",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "signals-pp-cli": "./bin/signals-pp-cli.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "README.md"
12
+ ],
13
+ "optionalDependencies": {
14
+ "@realtimex/signals-pp-cli-darwin-arm64": "0.2.1",
15
+ "@realtimex/signals-pp-cli-darwin-x64": "0.2.1",
16
+ "@realtimex/signals-pp-cli-linux-arm64": "0.2.1",
17
+ "@realtimex/signals-pp-cli-linux-x64": "0.2.1"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ }
22
+ }