vize 0.0.1-alpha.108 → 0.0.1-alpha.112
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/vize +27 -8
- package/package.json +9 -3
- package/scripts/postinstall.js +0 -145
package/bin/vize
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
|
+
import { createRequire } from "module";
|
|
4
5
|
import { dirname, join } from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
import { existsSync } from "fs";
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
const binaryName = process.platform === "win32" ? "vize-cli.exe" : "vize-cli";
|
|
10
|
-
const binaryPath = join(__dirname, binaryName);
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const PLATFORMS = {
|
|
10
|
+
"darwin-x64": { pkg: "@vizejs/cli-darwin-x64", bin: "vize" },
|
|
11
|
+
"darwin-arm64": { pkg: "@vizejs/cli-darwin-arm64", bin: "vize" },
|
|
12
|
+
"linux-x64": { pkg: "@vizejs/cli-linux-x64", bin: "vize" },
|
|
13
|
+
"linux-arm64": { pkg: "@vizejs/cli-linux-arm64", bin: "vize" },
|
|
14
|
+
"win32-x64": { pkg: "@vizejs/cli-win32-x64", bin: "vize.exe" },
|
|
15
|
+
"win32-arm64": { pkg: "@vizejs/cli-win32-arm64", bin: "vize.exe" },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
19
|
+
const config = PLATFORMS[platform];
|
|
20
|
+
|
|
21
|
+
if (!config) {
|
|
22
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
23
|
+
console.error("You can install from source: cargo install vize");
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let binaryPath;
|
|
28
|
+
try {
|
|
29
|
+
const pkgDir = dirname(require.resolve(`${config.pkg}/package.json`));
|
|
30
|
+
binaryPath = join(pkgDir, config.bin);
|
|
31
|
+
} catch {
|
|
32
|
+
console.error(`Vize binary package not found: ${config.pkg}`);
|
|
33
|
+
console.error("Try reinstalling: npm install vize");
|
|
15
34
|
process.exit(1);
|
|
16
35
|
}
|
|
17
36
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vize",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.112",
|
|
4
4
|
"description": "Vize - High-performance Vue.js toolchain in Rust",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"bin",
|
|
26
|
-
"scripts",
|
|
27
26
|
"dist",
|
|
28
27
|
"src"
|
|
29
28
|
],
|
|
@@ -44,6 +43,14 @@
|
|
|
44
43
|
"engines": {
|
|
45
44
|
"node": ">=18"
|
|
46
45
|
},
|
|
46
|
+
"optionalDependencies": {
|
|
47
|
+
"@vizejs/cli-darwin-x64": "0.0.1-alpha.112",
|
|
48
|
+
"@vizejs/cli-darwin-arm64": "0.0.1-alpha.112",
|
|
49
|
+
"@vizejs/cli-linux-x64": "0.0.1-alpha.112",
|
|
50
|
+
"@vizejs/cli-linux-arm64": "0.0.1-alpha.112",
|
|
51
|
+
"@vizejs/cli-win32-x64": "0.0.1-alpha.112",
|
|
52
|
+
"@vizejs/cli-win32-arm64": "0.0.1-alpha.112"
|
|
53
|
+
},
|
|
47
54
|
"dependencies": {
|
|
48
55
|
"oxc-transform": "^0.56.0"
|
|
49
56
|
},
|
|
@@ -54,7 +61,6 @@
|
|
|
54
61
|
},
|
|
55
62
|
"scripts": {
|
|
56
63
|
"build": "tsdown",
|
|
57
|
-
"postinstall": "node scripts/postinstall.js",
|
|
58
64
|
"lint": "oxlint --deny-warnings --type-aware --tsconfig tsconfig.json",
|
|
59
65
|
"lint:fix": "oxlint --type-aware --tsconfig tsconfig.json --fix",
|
|
60
66
|
"fmt": "oxfmt --write src",
|
package/scripts/postinstall.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { createWriteStream, chmodSync, existsSync, mkdirSync, unlinkSync } from "fs";
|
|
4
|
-
import { dirname, join } from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
import { pipeline } from "stream/promises";
|
|
7
|
-
|
|
8
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const packageJson = await import("../package.json", { with: { type: "json" } });
|
|
10
|
-
const version = packageJson.default.version;
|
|
11
|
-
|
|
12
|
-
const REPO = "ubugeeei/vize";
|
|
13
|
-
|
|
14
|
-
const PLATFORMS = {
|
|
15
|
-
"darwin-x64": {
|
|
16
|
-
target: "x86_64-apple-darwin",
|
|
17
|
-
filename: "vize-x86_64-apple-darwin.tar.gz",
|
|
18
|
-
},
|
|
19
|
-
"darwin-arm64": {
|
|
20
|
-
target: "aarch64-apple-darwin",
|
|
21
|
-
filename: "vize-aarch64-apple-darwin.tar.gz",
|
|
22
|
-
},
|
|
23
|
-
"linux-x64": {
|
|
24
|
-
target: "x86_64-unknown-linux-gnu",
|
|
25
|
-
filename: "vize-x86_64-unknown-linux-gnu.tar.gz",
|
|
26
|
-
},
|
|
27
|
-
"linux-arm64": {
|
|
28
|
-
target: "aarch64-unknown-linux-gnu",
|
|
29
|
-
filename: "vize-aarch64-unknown-linux-gnu.tar.gz",
|
|
30
|
-
},
|
|
31
|
-
"win32-x64": {
|
|
32
|
-
target: "x86_64-pc-windows-msvc",
|
|
33
|
-
filename: "vize-x86_64-pc-windows-msvc.zip",
|
|
34
|
-
},
|
|
35
|
-
"win32-arm64": {
|
|
36
|
-
target: "aarch64-pc-windows-msvc",
|
|
37
|
-
filename: "vize-aarch64-pc-windows-msvc.zip",
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
async function main() {
|
|
42
|
-
// Skip in CI environment - binary is built separately and not available during pnpm install
|
|
43
|
-
if (process.env.CI) {
|
|
44
|
-
console.log("CI environment detected, skipping binary download.");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const platform = `${process.platform}-${process.arch}`;
|
|
49
|
-
const config = PLATFORMS[platform];
|
|
50
|
-
|
|
51
|
-
if (!config) {
|
|
52
|
-
console.error(`Unsupported platform: ${platform}`);
|
|
53
|
-
console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(", ")}`);
|
|
54
|
-
console.error(
|
|
55
|
-
"\nYou can install the CLI from source using: cargo install vize"
|
|
56
|
-
);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const binDir = join(__dirname, "..", "bin");
|
|
61
|
-
const binaryName = process.platform === "win32" ? "vize-cli.exe" : "vize-cli";
|
|
62
|
-
const binaryPath = join(binDir, binaryName);
|
|
63
|
-
|
|
64
|
-
// Skip if binary already exists (for local development)
|
|
65
|
-
if (existsSync(binaryPath)) {
|
|
66
|
-
console.log("Vize binary already exists, skipping download.");
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!existsSync(binDir)) {
|
|
71
|
-
mkdirSync(binDir, { recursive: true });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const tag = `v${version}`;
|
|
75
|
-
const downloadUrl = `https://github.com/${REPO}/releases/download/${tag}/${config.filename}`;
|
|
76
|
-
|
|
77
|
-
console.log(`Downloading Vize ${version} for ${platform}...`);
|
|
78
|
-
console.log(`URL: ${downloadUrl}`);
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
const response = await fetch(downloadUrl);
|
|
82
|
-
|
|
83
|
-
if (!response.ok) {
|
|
84
|
-
throw new Error(`Failed to download: ${response.status} ${response.statusText}`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const tempFile = join(binDir, config.filename);
|
|
88
|
-
|
|
89
|
-
// Download to temp file
|
|
90
|
-
const fileStream = createWriteStream(tempFile);
|
|
91
|
-
await pipeline(response.body, fileStream);
|
|
92
|
-
|
|
93
|
-
// Extract based on file type
|
|
94
|
-
if (config.filename.endsWith(".tar.gz")) {
|
|
95
|
-
await extractTarGz(tempFile, binDir, binaryName);
|
|
96
|
-
} else if (config.filename.endsWith(".zip")) {
|
|
97
|
-
await extractZip(tempFile, binDir, binaryName);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Clean up temp file
|
|
101
|
-
unlinkSync(tempFile);
|
|
102
|
-
|
|
103
|
-
// Make executable on Unix
|
|
104
|
-
if (process.platform !== "win32") {
|
|
105
|
-
chmodSync(binaryPath, 0o755);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
console.log(`Vize ${version} installed successfully!`);
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.error(`Failed to install Vize: ${error.message}`);
|
|
111
|
-
console.error(
|
|
112
|
-
"\nYou can install the CLI from source using: cargo install vize"
|
|
113
|
-
);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function extractTarGz(archivePath, destDir, binaryName) {
|
|
119
|
-
const { execSync } = await import("child_process");
|
|
120
|
-
execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: "inherit" });
|
|
121
|
-
|
|
122
|
-
// The archive contains a 'vize' binary directly
|
|
123
|
-
// If not in place, move it
|
|
124
|
-
const extractedPath = join(destDir, "vize");
|
|
125
|
-
const targetPath = join(destDir, binaryName);
|
|
126
|
-
if (extractedPath !== targetPath && existsSync(extractedPath)) {
|
|
127
|
-
const { renameSync } = await import("fs");
|
|
128
|
-
renameSync(extractedPath, targetPath);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async function extractZip(archivePath, destDir, binaryName) {
|
|
133
|
-
const { execSync } = await import("child_process");
|
|
134
|
-
execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { stdio: "inherit" });
|
|
135
|
-
|
|
136
|
-
// Rename extracted binary to match expected name
|
|
137
|
-
const extractedPath = join(destDir, "vize.exe");
|
|
138
|
-
const targetPath = join(destDir, binaryName);
|
|
139
|
-
if (extractedPath !== targetPath && existsSync(extractedPath)) {
|
|
140
|
-
const { renameSync } = await import("fs");
|
|
141
|
-
renameSync(extractedPath, targetPath);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
void main();
|