@dekaruntime/dsc 0.0.0 → 0.53.4
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/bin.js +30 -0
- package/launcher-core.js +150 -0
- package/package.json +28 -5
- package/README.md +0 -1
package/bin.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// @dekaruntime/dsc: a thin wrapper that resolves and execs the platform
|
|
5
|
+
// binary installed via optionalDependencies. Standalone compiler-only
|
|
6
|
+
// install (editor tooling, CI type-checking) -- see npm/deka/bin.js for the
|
|
7
|
+
// deka launcher, which bundles its own sibling dsc for runtime correctness
|
|
8
|
+
// and does not depend on this package for that.
|
|
9
|
+
//
|
|
10
|
+
// Kept intentionally requireable-without-side-effects (guarded by the
|
|
11
|
+
// require.main check below) so tests can exercise main() directly.
|
|
12
|
+
const core = require('./launcher-core');
|
|
13
|
+
|
|
14
|
+
function main() {
|
|
15
|
+
return core.run({
|
|
16
|
+
family: 'dsc',
|
|
17
|
+
platformPackagePrefix: '@dekaruntime/dsc',
|
|
18
|
+
binaryName: 'dsc',
|
|
19
|
+
launcherDir: __dirname,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (require.main === module) {
|
|
24
|
+
main().catch((err) => {
|
|
25
|
+
console.error(`dsc: ${err.message}`);
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = { main };
|
package/launcher-core.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Shared launcher logic for the @dekaruntime/deka and @dekaruntime/dsc
|
|
4
|
+
// wrappers. This exact file is duplicated byte-for-byte at
|
|
5
|
+
// npm/dsc/launcher-core.js -- see test/launcher-core-parity.test.js, which
|
|
6
|
+
// fails the build if the two copies drift. It is duplicated rather than
|
|
7
|
+
// imported because each package must be self-contained once published: npm
|
|
8
|
+
// only packs files inside a package's own directory, so a launcher cannot
|
|
9
|
+
// `require('../deka/launcher-core')` after install.
|
|
10
|
+
const os = require('os');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const { spawn } = require('child_process');
|
|
14
|
+
|
|
15
|
+
// Platforms deka and dsc publish prebuilt binaries for today. Anything else
|
|
16
|
+
// (Windows included) gets a clear message instead of a stack trace --
|
|
17
|
+
// see https://github.com/dekaruntime/deka/issues/1092.
|
|
18
|
+
const SUPPORTED_PLATFORMS = new Set(['darwin-arm64', 'darwin-x64', 'linux-x64']);
|
|
19
|
+
|
|
20
|
+
function platformKey(platform = os.platform(), arch = os.arch()) {
|
|
21
|
+
return `${platform}-${arch}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isSupportedPlatform(key) {
|
|
25
|
+
return SUPPORTED_PLATFORMS.has(key);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function unsupportedPlatformMessage(family, key) {
|
|
29
|
+
return [
|
|
30
|
+
`${family}: unsupported platform "${key}".`,
|
|
31
|
+
'Prebuilt binaries are published for darwin-arm64, darwin-x64 and linux-x64 only.',
|
|
32
|
+
'Windows support is tracked at https://github.com/dekaruntime/deka/issues/1092.',
|
|
33
|
+
].join('\n');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Resolve the installed directory of a platform package (e.g.
|
|
37
|
+
// @dekaruntime/deka-darwin-arm64). Tries standard module resolution first --
|
|
38
|
+
// this covers both local installs and the common global-install layout,
|
|
39
|
+
// where npm links the platform package as a sibling of the launcher. Falls
|
|
40
|
+
// back to a manual check under the launcher's own node_modules, because npm
|
|
41
|
+
// sometimes nests optionalDependencies there instead (the case tana's
|
|
42
|
+
// bin.js was written to handle).
|
|
43
|
+
function resolvePlatformPackageDir(pkgName, launcherDir, overrides = {}) {
|
|
44
|
+
const resolve = overrides.resolve || require.resolve;
|
|
45
|
+
const existsSync = overrides.existsSync || fs.existsSync;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
return path.dirname(resolve(`${pkgName}/package.json`));
|
|
49
|
+
} catch {
|
|
50
|
+
// Fall through to the nesting fallback below.
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const nested = path.join(launcherDir, 'node_modules', pkgName);
|
|
54
|
+
if (existsSync(path.join(nested, 'package.json'))) {
|
|
55
|
+
return nested;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Run the resolved platform binary, forwarding argv, stdio, SIGINT/SIGTERM
|
|
62
|
+
// and the exit code. Returns a promise that resolves once the child has
|
|
63
|
+
// exited (or could not be started), after process.exitCode has been set --
|
|
64
|
+
// callers should not call process.exit() themselves, so stdio has a chance
|
|
65
|
+
// to flush.
|
|
66
|
+
function run(opts) {
|
|
67
|
+
const {
|
|
68
|
+
family,
|
|
69
|
+
platformPackagePrefix,
|
|
70
|
+
binaryName,
|
|
71
|
+
launcherDir,
|
|
72
|
+
platform,
|
|
73
|
+
arch,
|
|
74
|
+
argv = process.argv.slice(2),
|
|
75
|
+
extraEnv,
|
|
76
|
+
resolveDir,
|
|
77
|
+
} = opts;
|
|
78
|
+
|
|
79
|
+
const key = platformKey(platform, arch);
|
|
80
|
+
|
|
81
|
+
if (!isSupportedPlatform(key)) {
|
|
82
|
+
console.error(unsupportedPlatformMessage(family, key));
|
|
83
|
+
process.exitCode = 1;
|
|
84
|
+
return Promise.resolve({ code: 1, signal: null });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const pkgName = `${platformPackagePrefix}-${key}`;
|
|
88
|
+
const pkgDir = resolveDir
|
|
89
|
+
? resolveDir(pkgName, launcherDir)
|
|
90
|
+
: resolvePlatformPackageDir(pkgName, launcherDir);
|
|
91
|
+
|
|
92
|
+
if (!pkgDir) {
|
|
93
|
+
console.error(`${family}: could not locate ${pkgName}. Try reinstalling ${family}.`);
|
|
94
|
+
process.exitCode = 1;
|
|
95
|
+
return Promise.resolve({ code: 1, signal: null });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const binaryPath = path.join(pkgDir, 'bin', binaryName);
|
|
99
|
+
if (!fs.existsSync(binaryPath)) {
|
|
100
|
+
console.error(`${family}: ${binaryPath} is missing. Try reinstalling ${family}.`);
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
return Promise.resolve({ code: 1, signal: null });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const env = extraEnv ? extraEnv(pkgDir, process.env) : process.env;
|
|
106
|
+
|
|
107
|
+
return new Promise((resolvePromise) => {
|
|
108
|
+
const child = spawn(binaryPath, argv, { stdio: 'inherit', env });
|
|
109
|
+
|
|
110
|
+
const forward = (signal) => {
|
|
111
|
+
child.kill(signal);
|
|
112
|
+
};
|
|
113
|
+
process.on('SIGINT', forward);
|
|
114
|
+
process.on('SIGTERM', forward);
|
|
115
|
+
|
|
116
|
+
const cleanup = () => {
|
|
117
|
+
process.removeListener('SIGINT', forward);
|
|
118
|
+
process.removeListener('SIGTERM', forward);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
child.on('error', (err) => {
|
|
122
|
+
cleanup();
|
|
123
|
+
console.error(`${family}: failed to launch ${binaryPath}: ${err.message}`);
|
|
124
|
+
process.exitCode = 1;
|
|
125
|
+
resolvePromise({ code: 1, signal: null });
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
child.on('exit', (code, signal) => {
|
|
129
|
+
cleanup();
|
|
130
|
+
if (signal) {
|
|
131
|
+
// POSIX/bash convention: 128 + signal number. Deterministic and
|
|
132
|
+
// matches what a shell reports for a signal-terminated process.
|
|
133
|
+
const signalNumber = os.constants.signals[signal];
|
|
134
|
+
process.exitCode = signalNumber ? 128 + signalNumber : 1;
|
|
135
|
+
} else {
|
|
136
|
+
process.exitCode = code === null ? 1 : code;
|
|
137
|
+
}
|
|
138
|
+
resolvePromise({ code: process.exitCode, signal });
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = {
|
|
144
|
+
SUPPORTED_PLATFORMS,
|
|
145
|
+
platformKey,
|
|
146
|
+
isSupportedPlatform,
|
|
147
|
+
unsupportedPlatformMessage,
|
|
148
|
+
resolvePlatformPackageDir,
|
|
149
|
+
run,
|
|
150
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dekaruntime/dsc",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "0.53.4",
|
|
4
|
+
"description": "dsc compiler launcher. Resolves and execs the platform binary installed via optionalDependencies. Install this on its own for editor tooling or CI type-checking without the deka runtime.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"dsc": "bin.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin.js",
|
|
10
|
+
"launcher-core.js"
|
|
11
|
+
],
|
|
12
|
+
"optionalDependencies": {
|
|
13
|
+
"@dekaruntime/dsc-darwin-arm64": "0.53.4",
|
|
14
|
+
"@dekaruntime/dsc-darwin-x64": "0.53.4",
|
|
15
|
+
"@dekaruntime/dsc-linux-x64": "0.53.4"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
19
|
+
},
|
|
6
20
|
"repository": {
|
|
7
21
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/dekaruntime/create-deka-app.git"
|
|
22
|
+
"url": "git+https://github.com/dekaruntime/create-deka-app.git",
|
|
23
|
+
"directory": "npm/dsc"
|
|
9
24
|
},
|
|
10
|
-
"homepage": "https://deka.gg"
|
|
25
|
+
"homepage": "https://deka.gg",
|
|
26
|
+
"bugs": "https://github.com/dekaruntime/deka/issues",
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"deka",
|
|
30
|
+
"dekascript",
|
|
31
|
+
"compiler",
|
|
32
|
+
"cli"
|
|
33
|
+
]
|
|
11
34
|
}
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Placeholder. Real contents are published by CI from dekaruntime/create-deka-app.
|