@coder/aegis 0.1.0
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/aegis.mjs +68 -0
- package/lib/index.js +1065 -0
- package/lib/types/builder.d.ts +144 -0
- package/lib/types/bundle.d.ts +33 -0
- package/lib/types/cli.d.ts +2 -0
- package/lib/types/embedded-cli.d.ts +2 -0
- package/lib/types/graders.d.ts +22 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/layout.d.ts +23 -0
- package/lib/types/schema.d.ts +148 -0
- package/package.json +32 -0
package/bin/aegis.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Launcher shim for the @coder/aegis package (coder/aegis#228, #231).
|
|
3
|
+
// Zero runtime dependencies: resolves the Go binary for the current platform
|
|
4
|
+
// and execs it, propagating exit codes and signal death.
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
|
|
12
|
+
const SUPPORTED = ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64", "win32-x64"];
|
|
13
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
14
|
+
const exeSuffix = process.platform === "win32" ? ".exe" : "";
|
|
15
|
+
|
|
16
|
+
const binDir = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const binaryName = `aegis-${platformKey}${exeSuffix}`;
|
|
18
|
+
|
|
19
|
+
// Ordered binary resolution candidates:
|
|
20
|
+
// 1. Registry split layout (coder/aegis#231): per-platform package installed
|
|
21
|
+
// as an exact-pinned optionalDependency. resolve() throws when the package
|
|
22
|
+
// is absent (platform mismatch or --omit=optional install).
|
|
23
|
+
// 2. Fat preview layout (coder/aegis#228): CI-injected sibling binary.
|
|
24
|
+
const candidates = [
|
|
25
|
+
() => {
|
|
26
|
+
try {
|
|
27
|
+
return createRequire(import.meta.url).resolve(`@coder/aegis-${platformKey}/bin/aegis${exeSuffix}`);
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
() => (existsSync(path.join(binDir, binaryName)) ? path.join(binDir, binaryName) : null),
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const binPath = candidates.map((resolve) => resolve()).find((p) => p !== null);
|
|
36
|
+
if (binPath === undefined) {
|
|
37
|
+
console.error(
|
|
38
|
+
`aegis: no binary for platform "${platformKey}" (looked for the @coder/aegis-${platformKey} package and a bundled ${binaryName}).\n` +
|
|
39
|
+
`Supported platforms: ${SUPPORTED.join(", ")}.\n` +
|
|
40
|
+
"Registry installs fetch the platform binary via optionalDependencies: installing with --omit=optional (or --no-optional) skips it. " +
|
|
41
|
+
"Library imports of @coder/aegis still work without it; reinstall with optional dependencies enabled to use the CLI.",
|
|
42
|
+
);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const child = spawn(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
47
|
+
|
|
48
|
+
// Forward termination signals delivered directly to the shim (e.g. a CI
|
|
49
|
+
// timeout or process manager killing the node wrapper) so long-running
|
|
50
|
+
// commands like `aegis serve` are not orphaned. Terminal Ctrl-C already
|
|
51
|
+
// signals the whole foreground process group; this covers direct kills.
|
|
52
|
+
for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
53
|
+
process.on(sig, () => child.kill(sig));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
child.on("error", (err) => {
|
|
57
|
+
console.error(`aegis: failed to launch ${binPath}: ${err.message}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
});
|
|
60
|
+
child.on("exit", (status, signal) => {
|
|
61
|
+
if (signal) {
|
|
62
|
+
// Conventional 128+N when resolvable; exact re-raise semantics
|
|
63
|
+
// (especially on Windows) are deliberately not attempted.
|
|
64
|
+
const signalNumber = os.constants.signals[signal];
|
|
65
|
+
process.exit(typeof signalNumber === "number" ? 128 + signalNumber : 1);
|
|
66
|
+
}
|
|
67
|
+
process.exit(status ?? 1);
|
|
68
|
+
});
|