@truenine/memory-sync-cli 2026.10422.10749 → 2026.10423.10401

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.
Files changed (2) hide show
  1. package/bin/tnmsc.js +148 -0
  2. package/package.json +10 -6
package/bin/tnmsc.js ADDED
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const {spawnSync} = require('node:child_process');
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
7
+
8
+ const PACKAGE_NAME = '@truenine/memory-sync-cli';
9
+ const BINARY_NAME = 'tnmsc';
10
+ const SUPPORTED_TARGETS = [
11
+ 'linux-x64-gnu',
12
+ 'linux-arm64-gnu',
13
+ 'darwin-x64',
14
+ 'darwin-arm64',
15
+ 'win32-x64-msvc',
16
+ ].join(', ');
17
+
18
+ const PLATFORM_PACKAGES = {
19
+ darwin: {
20
+ arm64: '@truenine/memory-sync-cli-darwin-arm64',
21
+ x64: '@truenine/memory-sync-cli-darwin-x64',
22
+ },
23
+ linux: {
24
+ arm64: '@truenine/memory-sync-cli-linux-arm64-gnu',
25
+ x64: '@truenine/memory-sync-cli-linux-x64-gnu',
26
+ },
27
+ win32: {
28
+ x64: '@truenine/memory-sync-cli-win32-x64-msvc',
29
+ },
30
+ };
31
+
32
+ function fail(message) {
33
+ console.error(`${PACKAGE_NAME}: ${message}`);
34
+ process.exit(1);
35
+ }
36
+
37
+ function detectLinuxLibc() {
38
+ const report = process.report;
39
+ if (report == null || typeof report.getReport !== 'function') {
40
+ return 'unknown';
41
+ }
42
+
43
+ const header = report.getReport()?.header;
44
+ if (header == null || typeof header !== 'object') {
45
+ return 'unknown';
46
+ }
47
+
48
+ if (header.glibcVersionRuntime || header.glibcVersionCompiler) {
49
+ return 'glibc';
50
+ }
51
+
52
+ return 'unknown';
53
+ }
54
+
55
+ function resolvePlatformPackageName() {
56
+ const archMap = PLATFORM_PACKAGES[process.platform];
57
+ if (archMap == null) {
58
+ fail(
59
+ `Unsupported platform ${process.platform}/${process.arch}. Supported npm targets: ${SUPPORTED_TARGETS}.`,
60
+ );
61
+ }
62
+
63
+ const packageName = archMap[process.arch];
64
+ if (packageName == null) {
65
+ fail(
66
+ `Unsupported architecture ${process.platform}/${process.arch}. Supported npm targets: ${SUPPORTED_TARGETS}.`,
67
+ );
68
+ }
69
+
70
+ if (process.platform === 'linux' && detectLinuxLibc() !== 'glibc') {
71
+ fail(
72
+ 'Linux npm binaries currently require glibc. musl/Alpine environments are not supported by the published packages.',
73
+ );
74
+ }
75
+
76
+ return packageName;
77
+ }
78
+
79
+ function readJson(filePath) {
80
+ try {
81
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
82
+ } catch (error) {
83
+ fail(`Failed to read ${filePath}: ${error.message}`);
84
+ }
85
+ }
86
+
87
+ function resolveBinaryPath(packageName) {
88
+ let manifestPath;
89
+ try {
90
+ manifestPath = require.resolve(`${packageName}/package.json`);
91
+ } catch (error) {
92
+ fail(
93
+ `Missing optional native package ${packageName}. Reinstall ${PACKAGE_NAME} on a supported platform so npm can fetch the matching binary package. Original error: ${error.message}`,
94
+ );
95
+ }
96
+
97
+ const manifest = readJson(manifestPath);
98
+ const packageDir = path.dirname(manifestPath);
99
+ const binField = manifest.bin;
100
+ let relativeBinaryPath;
101
+
102
+ if (typeof binField === 'string') {
103
+ relativeBinaryPath = binField;
104
+ } else if (binField != null && typeof binField === 'object') {
105
+ if (typeof binField[BINARY_NAME] === 'string') {
106
+ relativeBinaryPath = binField[BINARY_NAME];
107
+ } else {
108
+ relativeBinaryPath = Object.values(binField).find(value => typeof value === 'string');
109
+ }
110
+ }
111
+
112
+ if (typeof relativeBinaryPath !== 'string' || relativeBinaryPath.length === 0) {
113
+ fail(`Package ${packageName} does not declare a ${BINARY_NAME} binary entry.`);
114
+ }
115
+
116
+ const binaryPath = path.resolve(packageDir, relativeBinaryPath);
117
+ if (!fs.existsSync(binaryPath)) {
118
+ fail(
119
+ `Native binary ${binaryPath} is missing from ${packageName}. Reinstall ${PACKAGE_NAME} and try again.`,
120
+ );
121
+ }
122
+
123
+ return binaryPath;
124
+ }
125
+
126
+ function runNativeBinary(binaryPath) {
127
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
128
+ env: process.env,
129
+ stdio: 'inherit',
130
+ });
131
+
132
+ if (result.error != null) {
133
+ fail(`Failed to launch ${binaryPath}: ${result.error.message}`);
134
+ }
135
+
136
+ if (typeof result.status === 'number') {
137
+ process.exit(result.status);
138
+ }
139
+
140
+ if (result.signal != null) {
141
+ process.kill(process.pid, result.signal);
142
+ return;
143
+ }
144
+
145
+ process.exit(1);
146
+ }
147
+
148
+ runNativeBinary(resolveBinaryPath(resolvePlatformPackageName()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truenine/memory-sync-cli",
3
- "version": "2026.10422.10749",
3
+ "version": "2026.10423.10401",
4
4
  "description": "TrueNine Memory Synchronization CLI metadata package",
5
5
  "author": "TrueNine",
6
6
  "license": "AGPL-3.0-only",
@@ -10,11 +10,15 @@
10
10
  "url": "git+https://github.com/TrueNine/memory-sync.git",
11
11
  "directory": "cli"
12
12
  },
13
+ "bin": {
14
+ "tnmsc": "./bin/tnmsc.js"
15
+ },
13
16
  "exports": {
14
17
  "./schema.json": "./schema/tnmsc.schema.json",
15
18
  "./package.json": "./package.json"
16
19
  },
17
20
  "files": [
21
+ "bin/tnmsc.js",
18
22
  "schema/tnmsc.schema.json"
19
23
  ],
20
24
  "publishConfig": {
@@ -22,11 +26,11 @@
22
26
  "registry": "https://registry.npmjs.org/"
23
27
  },
24
28
  "optionalDependencies": {
25
- "@truenine/memory-sync-cli-darwin-arm64": "2026.10422.10749",
26
- "@truenine/memory-sync-cli-darwin-x64": "2026.10422.10749",
27
- "@truenine/memory-sync-cli-linux-arm64-gnu": "2026.10422.10749",
28
- "@truenine/memory-sync-cli-linux-x64-gnu": "2026.10422.10749",
29
- "@truenine/memory-sync-cli-win32-x64-msvc": "2026.10422.10749"
29
+ "@truenine/memory-sync-cli-darwin-arm64": "2026.10423.10401",
30
+ "@truenine/memory-sync-cli-darwin-x64": "2026.10423.10401",
31
+ "@truenine/memory-sync-cli-linux-arm64-gnu": "2026.10423.10401",
32
+ "@truenine/memory-sync-cli-linux-x64-gnu": "2026.10423.10401",
33
+ "@truenine/memory-sync-cli-win32-x64-msvc": "2026.10423.10401"
30
34
  },
31
35
  "scripts": {
32
36
  "build": "cargo build --release --manifest-path Cargo.toml",