vize 0.0.1-alpha.100
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 +56 -0
- package/bin/vize +30 -0
- package/package.json +63 -0
- package/scripts/postinstall.js +137 -0
- package/src/config.ts +192 -0
- package/src/index.ts +33 -0
- package/src/types.ts +515 -0
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,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vize",
|
|
3
|
+
"version": "0.0.1-alpha.100",
|
|
4
|
+
"description": "Vize - High-performance Vue.js toolchain in Rust",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./config": {
|
|
17
|
+
"import": "./dist/config.js",
|
|
18
|
+
"types": "./dist/config.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"vize": "bin/vize"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin",
|
|
26
|
+
"scripts",
|
|
27
|
+
"dist",
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/ubugeeei/vize"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"vue",
|
|
36
|
+
"compiler",
|
|
37
|
+
"rust",
|
|
38
|
+
"cli",
|
|
39
|
+
"vize",
|
|
40
|
+
"formatter",
|
|
41
|
+
"linter"
|
|
42
|
+
],
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"oxc-transform": "^0.56.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.0.0",
|
|
52
|
+
"tsdown": "^0.9.0",
|
|
53
|
+
"typescript": "~5.6.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsdown",
|
|
57
|
+
"postinstall": "node scripts/postinstall.js",
|
|
58
|
+
"lint": "oxlint --deny-warnings --type-aware --tsconfig tsconfig.json",
|
|
59
|
+
"lint:fix": "oxlint --type-aware --tsconfig tsconfig.json --fix",
|
|
60
|
+
"fmt": "oxfmt --write src",
|
|
61
|
+
"fmt:check": "oxfmt src"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
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 = "vizejs/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.exe" : "vize";
|
|
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
|
+
|
|
137
|
+
void main();
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { transform } from "oxc-transform";
|
|
5
|
+
import type {
|
|
6
|
+
VizeConfig,
|
|
7
|
+
LoadConfigOptions,
|
|
8
|
+
UserConfigExport,
|
|
9
|
+
ConfigEnv,
|
|
10
|
+
GlobalTypesConfig,
|
|
11
|
+
GlobalTypeDeclaration,
|
|
12
|
+
} from "./types.js";
|
|
13
|
+
|
|
14
|
+
const CONFIG_FILE_NAMES = [
|
|
15
|
+
"vize.config.ts",
|
|
16
|
+
"vize.config.js",
|
|
17
|
+
"vize.config.mjs",
|
|
18
|
+
"vize.config.json",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const DEFAULT_CONFIG_ENV: ConfigEnv = {
|
|
22
|
+
mode: "development",
|
|
23
|
+
command: "serve",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Define a Vize configuration with type checking.
|
|
28
|
+
* Accepts a plain object or a function that receives ConfigEnv.
|
|
29
|
+
*/
|
|
30
|
+
export function defineConfig(config: UserConfigExport): UserConfigExport {
|
|
31
|
+
return config;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Load vize.config file from the specified directory
|
|
36
|
+
*/
|
|
37
|
+
export async function loadConfig(
|
|
38
|
+
root: string,
|
|
39
|
+
options: LoadConfigOptions = {},
|
|
40
|
+
): Promise<VizeConfig | null> {
|
|
41
|
+
const { mode = "root", configFile, env } = options;
|
|
42
|
+
|
|
43
|
+
if (mode === "none") {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Custom config file path
|
|
48
|
+
if (configFile) {
|
|
49
|
+
const absolutePath = path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile);
|
|
50
|
+
if (fs.existsSync(absolutePath)) {
|
|
51
|
+
return loadConfigFile(absolutePath, env);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Search for config file
|
|
57
|
+
if (mode === "auto") {
|
|
58
|
+
const configPath = findConfigFileAuto(root);
|
|
59
|
+
if (!configPath) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return loadConfigFile(configPath, env);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// mode === "root"
|
|
66
|
+
const configPath = findConfigFileInDir(root);
|
|
67
|
+
if (!configPath) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return loadConfigFile(configPath, env);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Find config file in a specific directory
|
|
75
|
+
*/
|
|
76
|
+
function findConfigFileInDir(dir: string): string | null {
|
|
77
|
+
for (const name of CONFIG_FILE_NAMES) {
|
|
78
|
+
const filePath = path.join(dir, name);
|
|
79
|
+
if (fs.existsSync(filePath)) {
|
|
80
|
+
return filePath;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Find config file by searching from cwd upward
|
|
88
|
+
*/
|
|
89
|
+
function findConfigFileAuto(startDir: string): string | null {
|
|
90
|
+
let currentDir = path.resolve(startDir);
|
|
91
|
+
const root = path.parse(currentDir).root;
|
|
92
|
+
|
|
93
|
+
while (currentDir !== root) {
|
|
94
|
+
const configPath = findConfigFileInDir(currentDir);
|
|
95
|
+
if (configPath) {
|
|
96
|
+
return configPath;
|
|
97
|
+
}
|
|
98
|
+
currentDir = path.dirname(currentDir);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Load and evaluate a config file
|
|
106
|
+
*/
|
|
107
|
+
async function loadConfigFile(filePath: string, env?: ConfigEnv): Promise<VizeConfig | null> {
|
|
108
|
+
if (!fs.existsSync(filePath)) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const ext = path.extname(filePath);
|
|
113
|
+
|
|
114
|
+
if (ext === ".json") {
|
|
115
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
116
|
+
return JSON.parse(content);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (ext === ".ts") {
|
|
120
|
+
return loadTypeScriptConfig(filePath, env);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// .js, .mjs - ESM
|
|
124
|
+
return loadESMConfig(filePath, env);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resolve a UserConfigExport to a VizeConfig
|
|
129
|
+
*/
|
|
130
|
+
async function resolveConfigExport(
|
|
131
|
+
exported: UserConfigExport,
|
|
132
|
+
env?: ConfigEnv,
|
|
133
|
+
): Promise<VizeConfig> {
|
|
134
|
+
if (typeof exported === "function") {
|
|
135
|
+
return exported(env ?? DEFAULT_CONFIG_ENV);
|
|
136
|
+
}
|
|
137
|
+
return exported;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Load TypeScript config file using oxc-transform
|
|
142
|
+
*/
|
|
143
|
+
async function loadTypeScriptConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {
|
|
144
|
+
const source = fs.readFileSync(filePath, "utf-8");
|
|
145
|
+
const result = transform(filePath, source, {
|
|
146
|
+
typescript: {
|
|
147
|
+
onlyRemoveTypeImports: true,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const code = result.code;
|
|
152
|
+
|
|
153
|
+
// Write to temp file and import (use Date.now() to avoid race conditions)
|
|
154
|
+
const tempFile = filePath.replace(/\.ts$/, `.temp.${Date.now()}.mjs`);
|
|
155
|
+
fs.writeFileSync(tempFile, code);
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
const fileUrl = pathToFileURL(tempFile).href;
|
|
159
|
+
const module = await import(fileUrl);
|
|
160
|
+
const exported: UserConfigExport = module.default || module;
|
|
161
|
+
return resolveConfigExport(exported, env);
|
|
162
|
+
} finally {
|
|
163
|
+
fs.unlinkSync(tempFile);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Load ESM config file
|
|
169
|
+
*/
|
|
170
|
+
async function loadESMConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {
|
|
171
|
+
const fileUrl = pathToFileURL(filePath).href;
|
|
172
|
+
const module = await import(fileUrl);
|
|
173
|
+
const exported: UserConfigExport = module.default || module;
|
|
174
|
+
return resolveConfigExport(exported, env);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects
|
|
179
|
+
*/
|
|
180
|
+
export function normalizeGlobalTypes(
|
|
181
|
+
config: GlobalTypesConfig,
|
|
182
|
+
): Record<string, GlobalTypeDeclaration> {
|
|
183
|
+
const result: Record<string, GlobalTypeDeclaration> = {};
|
|
184
|
+
for (const [key, value] of Object.entries(config)) {
|
|
185
|
+
if (typeof value === "string") {
|
|
186
|
+
result[key] = { type: value };
|
|
187
|
+
} else {
|
|
188
|
+
result[key] = value;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vize - High-performance Vue.js toolchain in Rust
|
|
3
|
+
*
|
|
4
|
+
* This package provides:
|
|
5
|
+
* - CLI binary for compilation, linting, and formatting
|
|
6
|
+
* - Configuration utilities for programmatic use
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Types
|
|
10
|
+
export type {
|
|
11
|
+
VizeConfig,
|
|
12
|
+
CompilerConfig,
|
|
13
|
+
VitePluginConfig,
|
|
14
|
+
LinterConfig,
|
|
15
|
+
TypeCheckerConfig,
|
|
16
|
+
FormatterConfig,
|
|
17
|
+
LspConfig,
|
|
18
|
+
MuseaConfig,
|
|
19
|
+
MuseaVrtConfig,
|
|
20
|
+
MuseaA11yConfig,
|
|
21
|
+
MuseaAutogenConfig,
|
|
22
|
+
GlobalTypesConfig,
|
|
23
|
+
GlobalTypeDeclaration,
|
|
24
|
+
LoadConfigOptions,
|
|
25
|
+
ConfigEnv,
|
|
26
|
+
UserConfigExport,
|
|
27
|
+
MaybePromise,
|
|
28
|
+
RuleSeverity,
|
|
29
|
+
RuleCategory,
|
|
30
|
+
} from "./types.js";
|
|
31
|
+
|
|
32
|
+
// Config utilities
|
|
33
|
+
export { defineConfig, loadConfig, normalizeGlobalTypes } from "./config.js";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Dynamic config support
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
6
|
+
|
|
7
|
+
export interface ConfigEnv {
|
|
8
|
+
mode: string;
|
|
9
|
+
command: "serve" | "build" | "check" | "lint" | "fmt";
|
|
10
|
+
isSsrBuild?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type UserConfigExport = VizeConfig | ((env: ConfigEnv) => MaybePromise<VizeConfig>);
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Rule severity
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
export type RuleSeverity = "off" | "warn" | "error";
|
|
20
|
+
|
|
21
|
+
export type RuleCategory = "correctness" | "suspicious" | "style" | "perf" | "a11y" | "security";
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// VizeConfig
|
|
25
|
+
// ============================================================================
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Vize configuration options
|
|
29
|
+
*/
|
|
30
|
+
export interface VizeConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Vue compiler options
|
|
33
|
+
*/
|
|
34
|
+
compiler?: CompilerConfig;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Vite plugin options
|
|
38
|
+
*/
|
|
39
|
+
vite?: VitePluginConfig;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Linter options
|
|
43
|
+
*/
|
|
44
|
+
linter?: LinterConfig;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Type checker options
|
|
48
|
+
*/
|
|
49
|
+
typeChecker?: TypeCheckerConfig;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Formatter options
|
|
53
|
+
*/
|
|
54
|
+
formatter?: FormatterConfig;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* LSP options
|
|
58
|
+
*/
|
|
59
|
+
lsp?: LspConfig;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Musea component gallery options
|
|
63
|
+
*/
|
|
64
|
+
musea?: MuseaConfig;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Global type declarations
|
|
68
|
+
*/
|
|
69
|
+
globalTypes?: GlobalTypesConfig;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// CompilerConfig
|
|
74
|
+
// ============================================================================
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Compiler configuration
|
|
78
|
+
*/
|
|
79
|
+
export interface CompilerConfig {
|
|
80
|
+
/**
|
|
81
|
+
* Compilation mode
|
|
82
|
+
* @default 'module'
|
|
83
|
+
*/
|
|
84
|
+
mode?: "module" | "function";
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Enable Vapor mode compilation
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
vapor?: boolean;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Enable SSR mode
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
ssr?: boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Enable source map generation
|
|
100
|
+
* @default true in development, false in production
|
|
101
|
+
*/
|
|
102
|
+
sourceMap?: boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Prefix template identifiers with _ctx
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
prefixIdentifiers?: boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Hoist static nodes
|
|
112
|
+
* @default true
|
|
113
|
+
*/
|
|
114
|
+
hoistStatic?: boolean;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Cache v-on handlers
|
|
118
|
+
* @default true
|
|
119
|
+
*/
|
|
120
|
+
cacheHandlers?: boolean;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Enable TypeScript parsing in <script> blocks
|
|
124
|
+
* @default true
|
|
125
|
+
*/
|
|
126
|
+
isTs?: boolean;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Script file extension for generated output
|
|
130
|
+
* @default 'ts'
|
|
131
|
+
*/
|
|
132
|
+
scriptExt?: "ts" | "js";
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Module name for runtime imports
|
|
136
|
+
* @default 'vue'
|
|
137
|
+
*/
|
|
138
|
+
runtimeModuleName?: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Global variable name for runtime (IIFE builds)
|
|
142
|
+
* @default 'Vue'
|
|
143
|
+
*/
|
|
144
|
+
runtimeGlobalName?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ============================================================================
|
|
148
|
+
// VitePluginConfig
|
|
149
|
+
// ============================================================================
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Vite plugin configuration
|
|
153
|
+
*/
|
|
154
|
+
export interface VitePluginConfig {
|
|
155
|
+
/**
|
|
156
|
+
* Files to include in compilation
|
|
157
|
+
* @default /\.vue$/
|
|
158
|
+
*/
|
|
159
|
+
include?: string | RegExp | (string | RegExp)[];
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Files to exclude from compilation
|
|
163
|
+
* @default /node_modules/
|
|
164
|
+
*/
|
|
165
|
+
exclude?: string | RegExp | (string | RegExp)[];
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Glob patterns to scan for .vue files during pre-compilation
|
|
169
|
+
* @default ['**\/*.vue']
|
|
170
|
+
*/
|
|
171
|
+
scanPatterns?: string[];
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Glob patterns to ignore during pre-compilation
|
|
175
|
+
* @default ['node_modules/**', 'dist/**', '.git/**']
|
|
176
|
+
*/
|
|
177
|
+
ignorePatterns?: string[];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ============================================================================
|
|
181
|
+
// LinterConfig
|
|
182
|
+
// ============================================================================
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Linter configuration
|
|
186
|
+
*/
|
|
187
|
+
export interface LinterConfig {
|
|
188
|
+
/**
|
|
189
|
+
* Enable linting
|
|
190
|
+
*/
|
|
191
|
+
enabled?: boolean;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Rules to enable/disable
|
|
195
|
+
*/
|
|
196
|
+
rules?: Record<string, RuleSeverity>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Category-level severity overrides
|
|
200
|
+
*/
|
|
201
|
+
categories?: Partial<Record<RuleCategory, RuleSeverity>>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// ============================================================================
|
|
205
|
+
// TypeCheckerConfig
|
|
206
|
+
// ============================================================================
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Type checker configuration
|
|
210
|
+
*/
|
|
211
|
+
export interface TypeCheckerConfig {
|
|
212
|
+
/**
|
|
213
|
+
* Enable type checking
|
|
214
|
+
* @default false
|
|
215
|
+
*/
|
|
216
|
+
enabled?: boolean;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Enable strict mode
|
|
220
|
+
* @default false
|
|
221
|
+
*/
|
|
222
|
+
strict?: boolean;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Check component props
|
|
226
|
+
* @default true
|
|
227
|
+
*/
|
|
228
|
+
checkProps?: boolean;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Check component emits
|
|
232
|
+
* @default true
|
|
233
|
+
*/
|
|
234
|
+
checkEmits?: boolean;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Check template bindings
|
|
238
|
+
* @default true
|
|
239
|
+
*/
|
|
240
|
+
checkTemplateBindings?: boolean;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Path to tsconfig.json
|
|
244
|
+
* @default auto-detected
|
|
245
|
+
*/
|
|
246
|
+
tsconfig?: string;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Path to tsgo binary
|
|
250
|
+
*/
|
|
251
|
+
tsgoPath?: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ============================================================================
|
|
255
|
+
// FormatterConfig
|
|
256
|
+
// ============================================================================
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Formatter configuration
|
|
260
|
+
*/
|
|
261
|
+
export interface FormatterConfig {
|
|
262
|
+
/**
|
|
263
|
+
* Max line width
|
|
264
|
+
* @default 80
|
|
265
|
+
*/
|
|
266
|
+
printWidth?: number;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Indentation width
|
|
270
|
+
* @default 2
|
|
271
|
+
*/
|
|
272
|
+
tabWidth?: number;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Use tabs for indentation
|
|
276
|
+
* @default false
|
|
277
|
+
*/
|
|
278
|
+
useTabs?: boolean;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Print semicolons
|
|
282
|
+
* @default true
|
|
283
|
+
*/
|
|
284
|
+
semi?: boolean;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Use single quotes
|
|
288
|
+
* @default false
|
|
289
|
+
*/
|
|
290
|
+
singleQuote?: boolean;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Trailing commas
|
|
294
|
+
* @default 'all'
|
|
295
|
+
*/
|
|
296
|
+
trailingComma?: "all" | "none" | "es5";
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ============================================================================
|
|
300
|
+
// LspConfig
|
|
301
|
+
// ============================================================================
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* LSP configuration
|
|
305
|
+
*/
|
|
306
|
+
export interface LspConfig {
|
|
307
|
+
/**
|
|
308
|
+
* Enable LSP
|
|
309
|
+
* @default true
|
|
310
|
+
*/
|
|
311
|
+
enabled?: boolean;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Enable diagnostics
|
|
315
|
+
* @default true
|
|
316
|
+
*/
|
|
317
|
+
diagnostics?: boolean;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Enable completions
|
|
321
|
+
* @default true
|
|
322
|
+
*/
|
|
323
|
+
completion?: boolean;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Enable hover information
|
|
327
|
+
* @default true
|
|
328
|
+
*/
|
|
329
|
+
hover?: boolean;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Enable go-to-definition
|
|
333
|
+
* @default true
|
|
334
|
+
*/
|
|
335
|
+
definition?: boolean;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Enable formatting via LSP
|
|
339
|
+
* @default true
|
|
340
|
+
*/
|
|
341
|
+
formatting?: boolean;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Enable code actions
|
|
345
|
+
* @default true
|
|
346
|
+
*/
|
|
347
|
+
codeActions?: boolean;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Use tsgo for type checking in LSP
|
|
351
|
+
* @default false
|
|
352
|
+
*/
|
|
353
|
+
tsgo?: boolean;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ============================================================================
|
|
357
|
+
// MuseaConfig
|
|
358
|
+
// ============================================================================
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* VRT (Visual Regression Testing) configuration for Musea
|
|
362
|
+
*/
|
|
363
|
+
export interface MuseaVrtConfig {
|
|
364
|
+
/**
|
|
365
|
+
* Threshold for pixel comparison (0-1)
|
|
366
|
+
* @default 0.1
|
|
367
|
+
*/
|
|
368
|
+
threshold?: number;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Output directory for screenshots
|
|
372
|
+
* @default '__musea_snapshots__'
|
|
373
|
+
*/
|
|
374
|
+
outDir?: string;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Viewport sizes
|
|
378
|
+
*/
|
|
379
|
+
viewports?: Array<{ width: number; height: number; name?: string }>;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* A11y configuration for Musea
|
|
384
|
+
*/
|
|
385
|
+
export interface MuseaA11yConfig {
|
|
386
|
+
/**
|
|
387
|
+
* Enable a11y checking
|
|
388
|
+
* @default false
|
|
389
|
+
*/
|
|
390
|
+
enabled?: boolean;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Axe-core rules to enable/disable
|
|
394
|
+
*/
|
|
395
|
+
rules?: Record<string, boolean>;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Autogen configuration for Musea
|
|
400
|
+
*/
|
|
401
|
+
export interface MuseaAutogenConfig {
|
|
402
|
+
/**
|
|
403
|
+
* Enable auto-generation of variants
|
|
404
|
+
* @default false
|
|
405
|
+
*/
|
|
406
|
+
enabled?: boolean;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Max variants to generate per component
|
|
410
|
+
* @default 10
|
|
411
|
+
*/
|
|
412
|
+
maxVariants?: number;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Musea component gallery configuration
|
|
417
|
+
*/
|
|
418
|
+
export interface MuseaConfig {
|
|
419
|
+
/**
|
|
420
|
+
* Glob patterns for art files
|
|
421
|
+
* @default ['**\/*.art.vue']
|
|
422
|
+
*/
|
|
423
|
+
include?: string[];
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Glob patterns to exclude
|
|
427
|
+
* @default ['node_modules/**', 'dist/**']
|
|
428
|
+
*/
|
|
429
|
+
exclude?: string[];
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Base path for gallery
|
|
433
|
+
* @default '/__musea__'
|
|
434
|
+
*/
|
|
435
|
+
basePath?: string;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Enable Storybook compatibility
|
|
439
|
+
* @default false
|
|
440
|
+
*/
|
|
441
|
+
storybookCompat?: boolean;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Enable inline art detection in .vue files
|
|
445
|
+
* @default false
|
|
446
|
+
*/
|
|
447
|
+
inlineArt?: boolean;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* VRT configuration
|
|
451
|
+
*/
|
|
452
|
+
vrt?: MuseaVrtConfig;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* A11y configuration
|
|
456
|
+
*/
|
|
457
|
+
a11y?: MuseaA11yConfig;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Autogen configuration
|
|
461
|
+
*/
|
|
462
|
+
autogen?: MuseaAutogenConfig;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// ============================================================================
|
|
466
|
+
// GlobalTypesConfig
|
|
467
|
+
// ============================================================================
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Global type declaration
|
|
471
|
+
*/
|
|
472
|
+
export interface GlobalTypeDeclaration {
|
|
473
|
+
/**
|
|
474
|
+
* TypeScript type string
|
|
475
|
+
*/
|
|
476
|
+
type: string;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Default value
|
|
480
|
+
*/
|
|
481
|
+
defaultValue?: string;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Global types configuration
|
|
486
|
+
*/
|
|
487
|
+
export type GlobalTypesConfig = Record<string, GlobalTypeDeclaration | string>;
|
|
488
|
+
|
|
489
|
+
// ============================================================================
|
|
490
|
+
// LoadConfigOptions
|
|
491
|
+
// ============================================================================
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Options for loading vize.config file
|
|
495
|
+
*/
|
|
496
|
+
export interface LoadConfigOptions {
|
|
497
|
+
/**
|
|
498
|
+
* Config file search mode
|
|
499
|
+
* - 'root': Search only in the specified root directory
|
|
500
|
+
* - 'auto': Search from cwd upward until finding a config file
|
|
501
|
+
* - 'none': Don't load config file
|
|
502
|
+
* @default 'root'
|
|
503
|
+
*/
|
|
504
|
+
mode?: "root" | "auto" | "none";
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Custom config file path (overrides automatic search)
|
|
508
|
+
*/
|
|
509
|
+
configFile?: string;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Config environment for dynamic config resolution
|
|
513
|
+
*/
|
|
514
|
+
env?: ConfigEnv;
|
|
515
|
+
}
|