vize 0.0.1-alpha.20

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 ADDED
@@ -0,0 +1,56 @@
1
+ # Vize
2
+
3
+ High-performance Vue.js toolchain in Rust.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Install from npm
9
+ npm install -g vize
10
+
11
+ # Or install from GitHub
12
+ npm install -g github:vizejs/vize
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ vize [COMMAND] [OPTIONS]
19
+ ```
20
+
21
+ | Command | Description |
22
+ | ------- | -------------------------------------- |
23
+ | `build` | Compile Vue SFC files (default) |
24
+ | `fmt` | Format Vue SFC files |
25
+ | `lint` | Lint Vue SFC files |
26
+ | `check` | Type check Vue SFC files |
27
+ | `musea` | Start component gallery server |
28
+ | `lsp` | Start Language Server Protocol server |
29
+
30
+ ```bash
31
+ vize --help # Show help
32
+ vize <command> --help # Show command-specific help
33
+ ```
34
+
35
+ ## Examples
36
+
37
+ ```bash
38
+ vize # Compile ./**/*.vue to ./dist
39
+ vize build src/**/*.vue -o out # Custom input/output
40
+ vize build --ssr # SSR mode
41
+ vize fmt --check # Check formatting
42
+ vize lint --fix # Auto-fix lint issues
43
+ vize check --strict # Strict type checking
44
+ ```
45
+
46
+ ## Alternative Installation
47
+
48
+ If npm installation fails, you can install via Cargo:
49
+
50
+ ```bash
51
+ cargo install vize
52
+ ```
53
+
54
+ ## License
55
+
56
+ MIT
package/bin/vize ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from "child_process";
4
+ import { dirname, join } from "path";
5
+ import { fileURLToPath } from "url";
6
+ import { existsSync } from "fs";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const binaryName = process.platform === "win32" ? "vize.exe" : "vize";
10
+ const binaryPath = join(__dirname, binaryName);
11
+
12
+ if (!existsSync(binaryPath)) {
13
+ console.error("Vize binary not found. Please reinstall the package.");
14
+ console.error("npm uninstall -g vize && npm install -g vize");
15
+ process.exit(1);
16
+ }
17
+
18
+ const child = spawn(binaryPath, process.argv.slice(2), {
19
+ stdio: "inherit",
20
+ env: process.env,
21
+ });
22
+
23
+ child.on("error", (err) => {
24
+ console.error(`Failed to start Vize: ${err.message}`);
25
+ process.exit(1);
26
+ });
27
+
28
+ child.on("close", (code) => {
29
+ process.exit(code ?? 0);
30
+ });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "vize",
3
+ "version": "0.0.1-alpha.20",
4
+ "description": "Vize - High-performance Vue.js toolchain in Rust",
5
+ "publishConfig": {
6
+ "provenance": true,
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "bin": {
11
+ "vize": "bin/vize"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "scripts"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/vizejs/vize"
20
+ },
21
+ "keywords": [
22
+ "vue",
23
+ "compiler",
24
+ "rust",
25
+ "cli",
26
+ "vize",
27
+ "formatter",
28
+ "linter"
29
+ ],
30
+ "license": "MIT",
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "scripts": {
35
+ "postinstall": "node scripts/postinstall.js"
36
+ }
37
+ }
@@ -0,0 +1,138 @@
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
+ import { createGunzip } from "zlib";
8
+
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const packageJson = await import("../package.json", { with: { type: "json" } });
11
+ const version = packageJson.default.version;
12
+
13
+ const REPO = "vizejs/vize";
14
+
15
+ const PLATFORMS = {
16
+ "darwin-x64": {
17
+ target: "x86_64-apple-darwin",
18
+ filename: "vize-x86_64-apple-darwin.tar.gz",
19
+ },
20
+ "darwin-arm64": {
21
+ target: "aarch64-apple-darwin",
22
+ filename: "vize-aarch64-apple-darwin.tar.gz",
23
+ },
24
+ "linux-x64": {
25
+ target: "x86_64-unknown-linux-gnu",
26
+ filename: "vize-x86_64-unknown-linux-gnu.tar.gz",
27
+ },
28
+ "linux-arm64": {
29
+ target: "aarch64-unknown-linux-gnu",
30
+ filename: "vize-aarch64-unknown-linux-gnu.tar.gz",
31
+ },
32
+ "win32-x64": {
33
+ target: "x86_64-pc-windows-msvc",
34
+ filename: "vize-x86_64-pc-windows-msvc.zip",
35
+ },
36
+ "win32-arm64": {
37
+ target: "aarch64-pc-windows-msvc",
38
+ filename: "vize-aarch64-pc-windows-msvc.zip",
39
+ },
40
+ };
41
+
42
+ async function main() {
43
+ // Skip in CI environment - binary is built separately and not available during pnpm install
44
+ if (process.env.CI) {
45
+ console.log("CI environment detected, skipping binary download.");
46
+ return;
47
+ }
48
+
49
+ const platform = `${process.platform}-${process.arch}`;
50
+ const config = PLATFORMS[platform];
51
+
52
+ if (!config) {
53
+ console.error(`Unsupported platform: ${platform}`);
54
+ console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(", ")}`);
55
+ console.error(
56
+ "\nYou can install the CLI from source using: cargo install vize"
57
+ );
58
+ process.exit(1);
59
+ }
60
+
61
+ const binDir = join(__dirname, "..", "bin");
62
+ const binaryName = process.platform === "win32" ? "vize.exe" : "vize";
63
+ const binaryPath = join(binDir, binaryName);
64
+
65
+ // Skip if binary already exists (for local development)
66
+ if (existsSync(binaryPath)) {
67
+ console.log("Vize binary already exists, skipping download.");
68
+ return;
69
+ }
70
+
71
+ if (!existsSync(binDir)) {
72
+ mkdirSync(binDir, { recursive: true });
73
+ }
74
+
75
+ const tag = `v${version}`;
76
+ const downloadUrl = `https://github.com/${REPO}/releases/download/${tag}/${config.filename}`;
77
+
78
+ console.log(`Downloading Vize ${version} for ${platform}...`);
79
+ console.log(`URL: ${downloadUrl}`);
80
+
81
+ try {
82
+ const response = await fetch(downloadUrl);
83
+
84
+ if (!response.ok) {
85
+ throw new Error(`Failed to download: ${response.status} ${response.statusText}`);
86
+ }
87
+
88
+ const tempFile = join(binDir, config.filename);
89
+
90
+ // Download to temp file
91
+ const fileStream = createWriteStream(tempFile);
92
+ await pipeline(response.body, fileStream);
93
+
94
+ // Extract based on file type
95
+ if (config.filename.endsWith(".tar.gz")) {
96
+ await extractTarGz(tempFile, binDir, binaryName);
97
+ } else if (config.filename.endsWith(".zip")) {
98
+ await extractZip(tempFile, binDir, binaryName);
99
+ }
100
+
101
+ // Clean up temp file
102
+ unlinkSync(tempFile);
103
+
104
+ // Make executable on Unix
105
+ if (process.platform !== "win32") {
106
+ chmodSync(binaryPath, 0o755);
107
+ }
108
+
109
+ console.log(`Vize ${version} installed successfully!`);
110
+ } catch (error) {
111
+ console.error(`Failed to install Vize: ${error.message}`);
112
+ console.error(
113
+ "\nYou can install the CLI from source using: cargo install vize"
114
+ );
115
+ process.exit(1);
116
+ }
117
+ }
118
+
119
+ async function extractTarGz(archivePath, destDir, binaryName) {
120
+ const { execSync } = await import("child_process");
121
+ execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: "inherit" });
122
+
123
+ // The archive contains a 'vize' binary directly
124
+ // If not in place, move it
125
+ const extractedPath = join(destDir, "vize");
126
+ const targetPath = join(destDir, binaryName);
127
+ if (extractedPath !== targetPath && existsSync(extractedPath)) {
128
+ const { renameSync } = await import("fs");
129
+ renameSync(extractedPath, targetPath);
130
+ }
131
+ }
132
+
133
+ async function extractZip(archivePath, destDir, binaryName) {
134
+ const { execSync } = await import("child_process");
135
+ execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { stdio: "inherit" });
136
+ }
137
+
138
+ main();