@ts-runtypes/bin 0.9.3 → 0.11.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/README.md +20 -24
- package/lib/index.d.ts +4 -2
- package/lib/index.js +45 -4
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
# ts-runtypes
|
|
1
|
+
# @ts-runtypes/bin
|
|
2
2
|
|
|
3
|
-
Platform launcher for the
|
|
3
|
+
Platform launcher for the **RunTypes** compiler binary.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
You normally never install this directly:
|
|
6
|
+
[`@ts-runtypes/devtools`](https://www.npmjs.com/package/@ts-runtypes/devtools)
|
|
7
|
+
depends on it and uses it to locate the binary for the host it is running on. The
|
|
8
|
+
binary itself rides as a per-platform optional dependency named
|
|
9
|
+
`@ts-runtypes/binary-<os>-<arch>`, so your package manager downloads only the one
|
|
10
|
+
your machine needs. This package ships **zero runtime dependencies**.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
and calls `getExePath()` to locate the binary.
|
|
12
|
+
## Documentation
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Install, guides, and the factory reference live at
|
|
15
|
+
**[runtypes.pages.dev](https://runtypes.pages.dev/)**.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
- [Quick start](https://runtypes.pages.dev/introduction/quick-start)
|
|
18
|
+
- [Built on typescript-go](https://runtypes.pages.dev/introduction/built-on-typescript-go)
|
|
19
|
+
- [Source and issues](https://github.com/MionKit/ts-run-types)
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
+
## Status
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
`ts-runtypes-binary-*` package is installed (unsupported platform, or the
|
|
24
|
-
optional dependency was skipped).
|
|
23
|
+
Experimental.
|
|
25
24
|
|
|
26
|
-
##
|
|
25
|
+
## License
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Execs the resolved binary with the given arguments (forwarding stdio and exit
|
|
33
|
-
code).
|
|
27
|
+
Proprietary — all rights reserved. No use, copying, or distribution without prior
|
|
28
|
+
written authorization. See
|
|
29
|
+
[LICENSE](https://github.com/MionKit/ts-run-types/blob/main/LICENSE).
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Returns the absolute path to the ts-runtypes resolver binary for the host
|
|
2
|
-
// platform
|
|
3
|
-
//
|
|
2
|
+
// platform. The `RT_BIN` environment variable overrides the lookup (it must
|
|
3
|
+
// name an executable file, or the call throws); otherwise this resolves the
|
|
4
|
+
// matching `@ts-runtypes/binary-<os>-<arch>` optional dependency (or the
|
|
5
|
+
// locally built `bin/ts-runtypes` inside this repo).
|
|
4
6
|
// Throws when no compatible binary is installed.
|
|
5
7
|
export declare function getExePath(): string;
|
package/lib/index.js
CHANGED
|
@@ -7,10 +7,45 @@ import {fileURLToPath} from 'node:url';
|
|
|
7
7
|
// directory (and of the locally built dev binary at <repo>/bin/).
|
|
8
8
|
const EXE_BASENAME = 'ts-runtypes';
|
|
9
9
|
|
|
10
|
+
// Env var that points the launcher at a specific resolver build, overriding
|
|
11
|
+
// both lookups below. It is the ONLY escape hatch the lint lane has (the
|
|
12
|
+
// bundler plugins additionally take an explicit `binary` option, which wins
|
|
13
|
+
// over this), so a consumer can validate an unpublished build, bisect a
|
|
14
|
+
// resolver regression, or run a vendored binary in an air-gapped install.
|
|
15
|
+
const OVERRIDE_ENV = 'RT_BIN';
|
|
16
|
+
|
|
10
17
|
function exeName() {
|
|
11
18
|
return process.platform === 'win32' ? `${EXE_BASENAME}.exe` : EXE_BASENAME;
|
|
12
19
|
}
|
|
13
20
|
|
|
21
|
+
// Reads the RT_BIN override, returning null when it is unset or empty (an
|
|
22
|
+
// empty value is a no-op rather than an error, so `RT_BIN=` in a .env file
|
|
23
|
+
// behaves like not setting it at all). A value that does not name an
|
|
24
|
+
// executable file throws instead of falling through to the normal lookups —
|
|
25
|
+
// a typo must fail loudly, never silently run a DIFFERENT binary than asked.
|
|
26
|
+
function overrideExe() {
|
|
27
|
+
const raw = process.env[OVERRIDE_ENV];
|
|
28
|
+
if (!raw || raw.trim() === '') return null;
|
|
29
|
+
const exe = path.resolve(raw.trim());
|
|
30
|
+
let stats;
|
|
31
|
+
try {
|
|
32
|
+
stats = fs.statSync(exe);
|
|
33
|
+
} catch {
|
|
34
|
+
throw new Error(`[ts-runtypes-bin] ${OVERRIDE_ENV}=${raw} does not exist (resolved to ${exe}).`);
|
|
35
|
+
}
|
|
36
|
+
if (!stats.isFile()) {
|
|
37
|
+
throw new Error(`[ts-runtypes-bin] ${OVERRIDE_ENV}=${raw} is not a file (resolved to ${exe}).`);
|
|
38
|
+
}
|
|
39
|
+
if (process.platform !== 'win32') {
|
|
40
|
+
try {
|
|
41
|
+
fs.accessSync(exe, fs.constants.X_OK);
|
|
42
|
+
} catch {
|
|
43
|
+
throw new Error(`[ts-runtypes-bin] ${OVERRIDE_ENV}=${raw} is not executable (resolved to ${exe}); chmod +x it.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return exe;
|
|
47
|
+
}
|
|
48
|
+
|
|
14
49
|
// Resolves the absolute path of a package's package.json without importing it.
|
|
15
50
|
// import.meta.resolve is sync on Node >= 20.6 / 18.19; older runtimes fall back
|
|
16
51
|
// to createRequire. We resolve package.json (always present) rather than the
|
|
@@ -24,11 +59,17 @@ function resolvePackageJson(specifier) {
|
|
|
24
59
|
}
|
|
25
60
|
|
|
26
61
|
// Returns the absolute path to the ts-runtypes resolver binary for the host
|
|
27
|
-
// platform.
|
|
28
|
-
// `@ts-runtypes/binary-<platform>-<arch
|
|
29
|
-
// falls back to the locally built
|
|
30
|
-
//
|
|
62
|
+
// platform. `RT_BIN` wins when set; otherwise, in an installed tree it locates
|
|
63
|
+
// the matching optional dependency `@ts-runtypes/binary-<platform>-<arch>`, and
|
|
64
|
+
// inside this repo's source tree it falls back to the locally built
|
|
65
|
+
// `bin/ts-runtypes`. Throws a clear error when neither is available
|
|
66
|
+
// (unsupported platform, or the optional dep was skipped).
|
|
31
67
|
export function getExePath() {
|
|
68
|
+
const overridden = overrideExe();
|
|
69
|
+
if (overridden) {
|
|
70
|
+
return process.platform === 'win32' && overridden.length >= 248 ? `\\\\?\\${overridden}` : overridden;
|
|
71
|
+
}
|
|
72
|
+
|
|
32
73
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
33
74
|
const normalized = here.replace(/\\/g, '/');
|
|
34
75
|
const platformKey = `${process.platform}-${process.arch}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-runtypes/bin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Platform launcher for the ts-runtypes resolver binary. Resolves and execs the prebuilt native binary for the host platform; the binary itself rides as a per-platform optional dependency. Ships zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"tsgo": "5a37e89",
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@ts-runtypes/binary-linux-x64": "0.
|
|
36
|
-
"@ts-runtypes/binary-linux-arm64": "0.
|
|
37
|
-
"@ts-runtypes/binary-linux-arm": "0.
|
|
38
|
-
"@ts-runtypes/binary-darwin-x64": "0.
|
|
39
|
-
"@ts-runtypes/binary-darwin-arm64": "0.
|
|
40
|
-
"@ts-runtypes/binary-win32-x64": "0.
|
|
41
|
-
"@ts-runtypes/binary-win32-arm64": "0.
|
|
35
|
+
"@ts-runtypes/binary-linux-x64": "0.11.0",
|
|
36
|
+
"@ts-runtypes/binary-linux-arm64": "0.11.0",
|
|
37
|
+
"@ts-runtypes/binary-linux-arm": "0.11.0",
|
|
38
|
+
"@ts-runtypes/binary-darwin-x64": "0.11.0",
|
|
39
|
+
"@ts-runtypes/binary-darwin-arm64": "0.11.0",
|
|
40
|
+
"@ts-runtypes/binary-win32-x64": "0.11.0",
|
|
41
|
+
"@ts-runtypes/binary-win32-arm64": "0.11.0"
|
|
42
42
|
}
|
|
43
43
|
}
|