@tiara-stack/tsgo-effect 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/tsgo-effect.mjs +94 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +44 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
- package/vendor/linux-x64/tsgo +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const executableName = process.platform === "win32" ? "tsgo.exe" : "tsgo";
|
|
8
|
+
const packageRoot = findPackageRoot(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
const binaryPath = resolveBinary();
|
|
11
|
+
|
|
12
|
+
if (process.argv.includes("--print-path")) {
|
|
13
|
+
console.log(binaryPath);
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
18
|
+
stdio: "inherit",
|
|
19
|
+
env: process.env,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (result.error) {
|
|
23
|
+
throw result.error;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
process.exit(result.status ?? 1);
|
|
27
|
+
|
|
28
|
+
function resolveBinary() {
|
|
29
|
+
/** @type {string[]} */
|
|
30
|
+
const candidates = [];
|
|
31
|
+
for (const candidate of [
|
|
32
|
+
process.env.TIARA_TSGO_EFFECT_PATH,
|
|
33
|
+
process.env.TIARA_TSGO_PATH,
|
|
34
|
+
join(packageRoot, "vendor", `${process.platform}-${process.arch}`, executableName),
|
|
35
|
+
findUp(process.cwd(), join("native", "typescript-go", "built", "local", executableName)),
|
|
36
|
+
findUp(packageRoot, join("native", "typescript-go", "built", "local", executableName)),
|
|
37
|
+
]) {
|
|
38
|
+
if (candidate) {
|
|
39
|
+
candidates.push(candidate);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const binaryPath = candidates.find((path) => existsSync(path));
|
|
44
|
+
if (!binaryPath) {
|
|
45
|
+
console.error(
|
|
46
|
+
[
|
|
47
|
+
"Unable to locate tsgo-effect.",
|
|
48
|
+
"Build native/typescript-go/built/local/tsgo or install a platform package that provides vendor binaries.",
|
|
49
|
+
"Set TIARA_TSGO_EFFECT_PATH to override the binary path.",
|
|
50
|
+
].join(" "),
|
|
51
|
+
);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return binaryPath;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} start
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
function findPackageRoot(start) {
|
|
63
|
+
let directory = dirname(start);
|
|
64
|
+
while (true) {
|
|
65
|
+
if (existsSync(join(directory, "package.json"))) {
|
|
66
|
+
return directory;
|
|
67
|
+
}
|
|
68
|
+
const parent = dirname(directory);
|
|
69
|
+
if (parent === directory) {
|
|
70
|
+
return resolve(".");
|
|
71
|
+
}
|
|
72
|
+
directory = parent;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} start
|
|
78
|
+
* @param {string} relativePath
|
|
79
|
+
* @returns {string | undefined}
|
|
80
|
+
*/
|
|
81
|
+
function findUp(start, relativePath) {
|
|
82
|
+
let directory = resolve(start);
|
|
83
|
+
while (true) {
|
|
84
|
+
const candidate = join(directory, relativePath);
|
|
85
|
+
if (existsSync(candidate)) {
|
|
86
|
+
return candidate;
|
|
87
|
+
}
|
|
88
|
+
const parent = dirname(directory);
|
|
89
|
+
if (parent === directory) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
directory = parent;
|
|
93
|
+
}
|
|
94
|
+
}
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const executableName = process.platform === "win32" ? "tsgo.exe" : "tsgo";
|
|
6
|
+
const packageRoot = findPackageRoot(fileURLToPath(import.meta.url));
|
|
7
|
+
const resolveTsgoEffectPath = () => {
|
|
8
|
+
const binaryPath = [
|
|
9
|
+
process.env.TIARA_TSGO_EFFECT_PATH,
|
|
10
|
+
process.env.TIARA_TSGO_PATH,
|
|
11
|
+
join(packageRoot, "vendor", `${process.platform}-${process.arch}`, executableName),
|
|
12
|
+
findUp(process.cwd(), join("native", "typescript-go", "built", "local", executableName)),
|
|
13
|
+
findUp(packageRoot, join("native", "typescript-go", "built", "local", executableName))
|
|
14
|
+
].filter((path) => Boolean(path)).find((path) => existsSync(path));
|
|
15
|
+
if (!binaryPath) throw new Error([
|
|
16
|
+
"Unable to locate tsgo-effect.",
|
|
17
|
+
"Build native/typescript-go/built/local/tsgo or install a platform package that provides vendor binaries.",
|
|
18
|
+
"Set TIARA_TSGO_EFFECT_PATH to override the binary path."
|
|
19
|
+
].join(" "));
|
|
20
|
+
return binaryPath;
|
|
21
|
+
};
|
|
22
|
+
function findPackageRoot(start) {
|
|
23
|
+
let directory = dirname(start);
|
|
24
|
+
while (true) {
|
|
25
|
+
if (existsSync(join(directory, "package.json"))) return directory;
|
|
26
|
+
const parent = dirname(directory);
|
|
27
|
+
if (parent === directory) return resolve(".");
|
|
28
|
+
directory = parent;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function findUp(start, relativePath) {
|
|
32
|
+
let directory = resolve(start);
|
|
33
|
+
while (true) {
|
|
34
|
+
const candidate = join(directory, relativePath);
|
|
35
|
+
if (existsSync(candidate)) return candidate;
|
|
36
|
+
const parent = dirname(directory);
|
|
37
|
+
if (parent === directory) return;
|
|
38
|
+
directory = parent;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { resolveTsgoEffectPath };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst executableName = process.platform === \"win32\" ? \"tsgo.exe\" : \"tsgo\";\n\nconst packageRoot = findPackageRoot(fileURLToPath(import.meta.url));\n\nexport const resolveTsgoEffectPath = (): string => {\n const candidates = [\n process.env.TIARA_TSGO_EFFECT_PATH,\n process.env.TIARA_TSGO_PATH,\n join(packageRoot, \"vendor\", `${process.platform}-${process.arch}`, executableName),\n findUp(process.cwd(), join(\"native\", \"typescript-go\", \"built\", \"local\", executableName)),\n findUp(packageRoot, join(\"native\", \"typescript-go\", \"built\", \"local\", executableName)),\n ].filter((path): path is string => Boolean(path));\n\n const binaryPath = candidates.find((path) => existsSync(path));\n if (!binaryPath) {\n throw new Error(\n [\n \"Unable to locate tsgo-effect.\",\n \"Build native/typescript-go/built/local/tsgo or install a platform package that provides vendor binaries.\",\n \"Set TIARA_TSGO_EFFECT_PATH to override the binary path.\",\n ].join(\" \"),\n );\n }\n\n return binaryPath;\n};\n\nfunction findPackageRoot(start: string): string {\n let directory = dirname(start);\n while (true) {\n if (existsSync(join(directory, \"package.json\"))) {\n return directory;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n return resolve(\".\");\n }\n directory = parent;\n }\n}\n\nfunction findUp(start: string, relativePath: string): string | undefined {\n let directory = resolve(start);\n while (true) {\n const candidate = join(directory, relativePath);\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n return undefined;\n }\n directory = parent;\n }\n}\n"],"mappings":";;;;AAIA,MAAM,iBAAiB,QAAQ,aAAa,UAAU,aAAa;AAEnE,MAAM,cAAc,gBAAgB,cAAc,OAAO,KAAK,GAAG,CAAC;AAElE,MAAa,8BAAsC;CASjD,MAAM,aARa;EACjB,QAAQ,IAAI;EACZ,QAAQ,IAAI;EACZ,KAAK,aAAa,UAAU,GAAG,QAAQ,SAAS,GAAG,QAAQ,QAAQ,cAAc;EACjF,OAAO,QAAQ,IAAI,GAAG,KAAK,UAAU,iBAAiB,SAAS,SAAS,cAAc,CAAC;EACvF,OAAO,aAAa,KAAK,UAAU,iBAAiB,SAAS,SAAS,cAAc,CAAC;CACvF,CAAC,CAAC,QAAQ,SAAyB,QAAQ,IAAI,CAEnB,CAAC,CAAC,MAAM,SAAS,WAAW,IAAI,CAAC;CAC7D,IAAI,CAAC,YACH,MAAM,IAAI,MACR;EACE;EACA;EACA;CACF,CAAC,CAAC,KAAK,GAAG,CACZ;CAGF,OAAO;AACT;AAEA,SAAS,gBAAgB,OAAuB;CAC9C,IAAI,YAAY,QAAQ,KAAK;CAC7B,OAAO,MAAM;EACX,IAAI,WAAW,KAAK,WAAW,cAAc,CAAC,GAC5C,OAAO;EAET,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WACb,OAAO,QAAQ,GAAG;EAEpB,YAAY;CACd;AACF;AAEA,SAAS,OAAO,OAAe,cAA0C;CACvE,IAAI,YAAY,QAAQ,KAAK;CAC7B,OAAO,MAAM;EACX,MAAM,YAAY,KAAK,WAAW,YAAY;EAC9C,IAAI,WAAW,SAAS,GACtB,OAAO;EAET,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WACb;EAEF,YAAY;CACd;AACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tiara-stack/tsgo-effect",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Patched tsgo compiler binary for Tiara Stack tooling.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/tiara-stack/native-tooling.git",
|
|
9
|
+
"directory": "packages/tsgo-effect"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"tsgo-effect": "bin/tsgo-effect.mjs"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"dist",
|
|
17
|
+
"vendor"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.mts",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./bin/tsgo-effect": "./bin/tsgo-effect.mjs",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "vp pack",
|
|
33
|
+
"format": "vp fmt --check",
|
|
34
|
+
"format:apply": "vp fmt",
|
|
35
|
+
"lint": "vp lint src bin",
|
|
36
|
+
"test": "echo 'no tests defined'"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "catalog:",
|
|
40
|
+
"vite": "catalog:",
|
|
41
|
+
"vite-plus": "catalog:"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
Binary file
|