@glyphlang/glyph 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/glyph.js +27 -0
- package/bin/resolve.js +63 -0
- package/package.json +35 -0
package/bin/glyph.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Launcher for the `glyph` CLI distributed on npm. The Rust compiler is a
|
|
5
|
+
// prebuilt binary shipped in a per-platform optional dependency
|
|
6
|
+
// (`@glyphlang/<platform>`); this thin shim resolves the right one and forwards
|
|
7
|
+
// argv to it, inheriting stdio and propagating the exit code. The model mirrors
|
|
8
|
+
// esbuild/swc: no postinstall download, no curl-pipe-bash.
|
|
9
|
+
|
|
10
|
+
const { spawnSync } = require("child_process");
|
|
11
|
+
const { resolveBinary } = require("./resolve.js");
|
|
12
|
+
|
|
13
|
+
let binary;
|
|
14
|
+
try {
|
|
15
|
+
binary = resolveBinary();
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error(err.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
22
|
+
if (result.error) {
|
|
23
|
+
console.error(`glyph: failed to launch the compiler: ${result.error.message}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
// A process killed by a signal has a null status; treat that as a failure.
|
|
27
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/bin/resolve.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Map the running platform to the `@glyphlang/<platform>` package that ships its
|
|
4
|
+
// prebuilt binary, and resolve the binary's path. Kept separate from the
|
|
5
|
+
// launcher (`glyph.js`) so the mapping and resolution can be unit-tested
|
|
6
|
+
// without spawning the compiler.
|
|
7
|
+
|
|
8
|
+
const PLATFORM_PACKAGES = {
|
|
9
|
+
"darwin-x64": "@glyphlang/darwin-x64",
|
|
10
|
+
"darwin-arm64": "@glyphlang/darwin-arm64",
|
|
11
|
+
"linux-x64": "@glyphlang/linux-x64",
|
|
12
|
+
"linux-arm64": "@glyphlang/linux-arm64",
|
|
13
|
+
"win32-x64": "@glyphlang/win32-x64",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** The platform package name for `<platform>-<arch>`, or undefined if unsupported. */
|
|
17
|
+
function packageForPlatform(platform, arch) {
|
|
18
|
+
return PLATFORM_PACKAGES[`${platform}-${arch}`];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The binary filename on this platform (Windows carries the `.exe` suffix). */
|
|
22
|
+
function binaryName(platform) {
|
|
23
|
+
return platform === "win32" ? "glyph.exe" : "glyph";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the absolute path of the glyph binary for the current platform.
|
|
28
|
+
*
|
|
29
|
+
* `GLYPH_BINARY` overrides everything (development and CI smoke tests). Options
|
|
30
|
+
* are injectable so the resolution logic is testable: `resolve` defaults to
|
|
31
|
+
* `require.resolve`, `platform`/`arch` to `process.*`, `env` to `process.env`.
|
|
32
|
+
* Throws a descriptive error when the platform is unsupported or the matching
|
|
33
|
+
* optional dependency was not installed.
|
|
34
|
+
*/
|
|
35
|
+
function resolveBinary({
|
|
36
|
+
platform = process.platform,
|
|
37
|
+
arch = process.arch,
|
|
38
|
+
resolve = require.resolve,
|
|
39
|
+
env = process.env,
|
|
40
|
+
} = {}) {
|
|
41
|
+
if (env.GLYPH_BINARY) {
|
|
42
|
+
return env.GLYPH_BINARY;
|
|
43
|
+
}
|
|
44
|
+
const pkg = packageForPlatform(platform, arch);
|
|
45
|
+
if (!pkg) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`glyph: no prebuilt binary for ${platform}-${arch}. ` +
|
|
48
|
+
`Supported platforms: ${Object.keys(PLATFORM_PACKAGES).join(", ")}. ` +
|
|
49
|
+
`Build from source: https://github.com/chadetov/glyph.`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return resolve(`${pkg}/bin/${binaryName(platform)}`);
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`glyph: the platform package ${pkg} is not installed. ` +
|
|
57
|
+
`This usually means optional dependencies were skipped during install; ` +
|
|
58
|
+
`reinstall with \`npm install glyph\` (without --no-optional / --omit=optional).`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = { PLATFORM_PACKAGES, packageForPlatform, binaryName, resolveBinary };
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glyphlang/glyph",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Glyph compiler: a statically typed language that transpiles to TypeScript, designed so AI agents can read, write, and modify code safely.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"glyph": "bin/glyph.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/glyph.js",
|
|
10
|
+
"bin/resolve.js"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"optionalDependencies": {
|
|
16
|
+
"@glyphlang/darwin-x64": "0.1.0",
|
|
17
|
+
"@glyphlang/darwin-arm64": "0.1.0",
|
|
18
|
+
"@glyphlang/linux-x64": "0.1.0",
|
|
19
|
+
"@glyphlang/linux-arm64": "0.1.0",
|
|
20
|
+
"@glyphlang/win32-x64": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/chadetov/glyph.git"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT OR Apache-2.0",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"glyph",
|
|
29
|
+
"typescript",
|
|
30
|
+
"compiler",
|
|
31
|
+
"language",
|
|
32
|
+
"transpiler",
|
|
33
|
+
"ai-agents"
|
|
34
|
+
]
|
|
35
|
+
}
|