typeslayer 0.1.8 → 0.1.9
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/typeslayer.js +54 -54
- package/package.json +51 -51
- package/scripts/postinstall.js +106 -106
package/bin/typeslayer.js
CHANGED
|
@@ -14,68 +14,68 @@ const userCwd = process.cwd();
|
|
|
14
14
|
|
|
15
15
|
// Get the binary path based on platform
|
|
16
16
|
const getBinaryInfo = () => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const plat = platform();
|
|
18
|
+
const architecture = arch();
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
let platformDir, binaryName;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
if (plat === "linux" && architecture === "x64") {
|
|
23
|
+
platformDir = "linux-x64";
|
|
24
|
+
binaryName = "typeslayer";
|
|
25
|
+
} else if (plat === "darwin" && architecture === "arm64") {
|
|
26
|
+
platformDir = "darwin-arm64";
|
|
27
|
+
binaryName = "typeslayer";
|
|
28
|
+
} else if (plat === "win32" && architecture === "x64") {
|
|
29
|
+
platformDir = "win32-x64";
|
|
30
|
+
binaryName = "typeslayer.exe";
|
|
31
|
+
} else {
|
|
32
|
+
throw new Error(`Unsupported platform: ${plat}-${architecture}`);
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
return {
|
|
36
|
+
path: join(__dirname, "..", "binaries", platformDir, binaryName),
|
|
37
|
+
platform: `${plat}-${architecture}`,
|
|
38
|
+
};
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
try {
|
|
42
|
-
|
|
42
|
+
const binaryInfo = getBinaryInfo();
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
if (!existsSync(binaryInfo.path)) {
|
|
45
|
+
console.error(
|
|
46
|
+
`\n⚠️ Binary not found for ${binaryInfo.platform}. Attempting download...`,
|
|
47
|
+
);
|
|
48
|
+
const postinstallPath = join(__dirname, "..", "scripts", "postinstall.js");
|
|
49
|
+
const res = spawnSync(process.execPath, [postinstallPath], {
|
|
50
|
+
stdio: "inherit",
|
|
51
|
+
env: process.env,
|
|
52
|
+
});
|
|
53
|
+
if (res.status !== 0) {
|
|
54
|
+
console.error("\n❌ Failed to download platform binary.");
|
|
55
|
+
}
|
|
56
|
+
if (!existsSync(binaryInfo.path)) {
|
|
57
|
+
console.error(
|
|
58
|
+
`\n❌ Binary still unavailable at ${binaryInfo.path}. Please check the release assets or your network.`,
|
|
59
|
+
);
|
|
60
|
+
console.error(
|
|
61
|
+
"You can manually download from: https://github.com/dimitropoulos/typeslayer/releases",
|
|
62
|
+
);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
const proc = spawn(binaryInfo.path, [], {
|
|
68
|
+
stdio: "inherit",
|
|
69
|
+
env: {
|
|
70
|
+
...process.env,
|
|
71
|
+
USER_CWD: userCwd,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
proc.on("exit", code => {
|
|
76
|
+
process.exit(code || 0);
|
|
77
|
+
});
|
|
78
78
|
} catch (error) {
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
console.error("Error:", error.message);
|
|
80
|
+
process.exit(1);
|
|
81
81
|
}
|
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
2
|
+
"name": "typeslayer",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "Slay your TypeScript types",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"typescript",
|
|
9
|
+
"ts",
|
|
10
|
+
"tauri",
|
|
11
|
+
"desktop",
|
|
12
|
+
"benchmarking",
|
|
13
|
+
"performance"
|
|
14
|
+
],
|
|
15
|
+
"author": "Dimitri Mitropoulos",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/dimitropoulos/typeslayer.git",
|
|
20
|
+
"directory": "packages/typeslayer"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/dimitropoulos/typeslayer/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/dimitropoulos/typeslayer#readme",
|
|
26
|
+
"bin": {
|
|
27
|
+
"typeslayer": "bin/typeslayer.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"bin",
|
|
31
|
+
"scripts"
|
|
32
|
+
],
|
|
33
|
+
"os": [
|
|
34
|
+
"linux",
|
|
35
|
+
"darwin",
|
|
36
|
+
"win32"
|
|
37
|
+
],
|
|
38
|
+
"cpu": [
|
|
39
|
+
"x64",
|
|
40
|
+
"arm64"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=24.0.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"postinstall": "node scripts/postinstall.js"
|
|
47
|
+
},
|
|
48
|
+
"optionalDependencies": {
|
|
49
|
+
"@typeslayer/linux-x64": "0.1.9",
|
|
50
|
+
"@typeslayer/darwin-arm64": "0.1.9",
|
|
51
|
+
"@typeslayer/win32-x64": "0.1.9"
|
|
52
|
+
}
|
|
53
53
|
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -15,116 +15,116 @@ const PACKAGE_VERSION = process.env.npm_package_version;
|
|
|
15
15
|
|
|
16
16
|
// Allow CI or callers to skip binary download (release assets may not exist yet in same run)
|
|
17
17
|
if (process.env.TYPESLAYER_SKIP_POSTINSTALL) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
console.log(
|
|
19
|
+
"⏭️ Skipping typeslayer binary download (TYPESLAYER_SKIP_POSTINSTALL set).",
|
|
20
|
+
);
|
|
21
|
+
process.exit(0);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const getBinaryInfo = () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
const plat = platform();
|
|
26
|
+
const architecture = arch();
|
|
27
|
+
|
|
28
|
+
let platformDir, binaryName, npmPackage;
|
|
29
|
+
|
|
30
|
+
if (plat === "linux" && architecture === "x64") {
|
|
31
|
+
platformDir = "linux-x64";
|
|
32
|
+
binaryName = "typeslayer";
|
|
33
|
+
npmPackage = "@typeslayer/linux-x64";
|
|
34
|
+
} else if (plat === "darwin" && architecture === "arm64") {
|
|
35
|
+
platformDir = "darwin-arm64";
|
|
36
|
+
binaryName = "typeslayer";
|
|
37
|
+
npmPackage = "@typeslayer/darwin-arm64";
|
|
38
|
+
} else if (plat === "win32" && architecture === "x64") {
|
|
39
|
+
platformDir = "win32-x64";
|
|
40
|
+
binaryName = "typeslayer.exe";
|
|
41
|
+
npmPackage = "@typeslayer/win32-x64";
|
|
42
|
+
} else {
|
|
43
|
+
console.warn(`⚠️ Platform ${plat}-${architecture} is not supported`);
|
|
44
|
+
process.exit(0); // Don't fail the install, just skip
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { platformDir, binaryName, npmPackage };
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
(async () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
51
|
+
try {
|
|
52
|
+
const { platformDir, binaryName, npmPackage } = getBinaryInfo();
|
|
53
|
+
const binariesDir = join(__dirname, "..", "binaries", platformDir);
|
|
54
|
+
const binaryPath = join(binariesDir, binaryName);
|
|
55
|
+
|
|
56
|
+
// Skip if binary already exists
|
|
57
|
+
if (existsSync(binaryPath)) {
|
|
58
|
+
console.log("✅ Binary already present, skipping download");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Create directory if it doesn't exist
|
|
63
|
+
mkdirSync(binariesDir, { recursive: true });
|
|
64
|
+
|
|
65
|
+
// First, try to use the optionalDependency (esbuild pattern)
|
|
66
|
+
// This is the primary mechanism - npm installs the right platform package automatically
|
|
67
|
+
let binaryFound = false;
|
|
68
|
+
try {
|
|
69
|
+
const optionalPkgPath = require.resolve(`${npmPackage}/package.json`);
|
|
70
|
+
const optionalBinaryPath = join(dirname(optionalPkgPath), binaryName);
|
|
71
|
+
if (existsSync(optionalBinaryPath)) {
|
|
72
|
+
console.log(`📦 Using ${npmPackage} from optionalDependencies...`);
|
|
73
|
+
const fs = await import("node:fs/promises");
|
|
74
|
+
await fs.copyFile(optionalBinaryPath, binaryPath);
|
|
75
|
+
if (process.platform !== "win32") {
|
|
76
|
+
chmodSync(binaryPath, 0o755);
|
|
77
|
+
}
|
|
78
|
+
console.log("✅ Binary copied successfully");
|
|
79
|
+
binaryFound = true;
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
// optionalDependency not available - fall back to downloading
|
|
83
|
+
console.warn(
|
|
84
|
+
`⚠️ ${npmPackage} not found in optionalDependencies (may have been installed with --no-optional flag)`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!binaryFound) {
|
|
89
|
+
// Fallback: Install the platform-specific binary package from npm
|
|
90
|
+
console.log(`📦 Downloading ${npmPackage}@${PACKAGE_VERSION}...`);
|
|
91
|
+
execSync(`npm install --no-save "${npmPackage}@${PACKAGE_VERSION}"`, {
|
|
92
|
+
stdio: "inherit",
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Copy the binary from node_modules to our binaries directory
|
|
96
|
+
const nodeModulesBinaryPath = join(
|
|
97
|
+
__dirname,
|
|
98
|
+
"..",
|
|
99
|
+
"..",
|
|
100
|
+
"..",
|
|
101
|
+
"node_modules",
|
|
102
|
+
npmPackage.replace("@", "").replace("/", "-"),
|
|
103
|
+
binaryName,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (!existsSync(nodeModulesBinaryPath)) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Binary not found at ${nodeModulesBinaryPath} after npm install`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Copy and make executable
|
|
113
|
+
const fs = await import("node:fs/promises");
|
|
114
|
+
await fs.copyFile(nodeModulesBinaryPath, binaryPath);
|
|
115
|
+
|
|
116
|
+
if (process.platform !== "win32") {
|
|
117
|
+
chmodSync(binaryPath, 0o755);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log("✅ Binary installed successfully");
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error("❌ Failed to download binary:", error.message);
|
|
124
|
+
console.error(
|
|
125
|
+
"You can manually download the binary from: https://github.com/dimitropoulos/typeslayer/releases",
|
|
126
|
+
);
|
|
127
|
+
// Don't fail the install, just warn
|
|
128
|
+
process.exit(0);
|
|
129
|
+
}
|
|
130
130
|
})();
|