vize 0.114.0 → 0.116.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/README.md +1 -0
- package/dist/{config-tvugwdpH.d.mts → config-CczvMtD4.d.mts} +14 -6
- package/dist/config-CczvMtD4.d.mts.map +1 -0
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +3 -2
- package/dist/config.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/package.json +2 -2
- package/pkl/TypeCheckerConfig.pkl +5 -2
- package/pkl/jsonschema/generate.pkl +11 -3
- package/pkl/vize.pkl +3 -2
- package/schemas/vize.config.schema.json +11 -3
- package/src/config.ts +3 -2
- package/src/types/generated.ts +18 -4
- package/src/types/rules.ts +2 -0
- package/dist/config-tvugwdpH.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ Override config discovery with `--config`, or disable it with `--no-config`.
|
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
94
|
vp exec vize lint --preset essential --max-warnings 0 src
|
|
95
|
+
vp exec vize lint --preset ecosystem src
|
|
95
96
|
vp exec vize lint --preset opinionated --help-level short src
|
|
96
97
|
vp exec vize lint --format json src
|
|
97
98
|
vp exec vize lint --format plain src
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
5
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
6
|
*/
|
|
7
|
-
type LintPreset = "happy-path" | "opinionated" | "essential" | "incremental" | "nuxt";
|
|
7
|
+
type LintPreset = "happy-path" | "opinionated" | "essential" | "incremental" | "ecosystem" | "nuxt";
|
|
8
8
|
type RuleSeverity = "off" | "warn" | "error";
|
|
9
9
|
type RuleCategory = "correctness" | "suspicious" | "style" | "perf" | "a11y" | "security";
|
|
10
10
|
/**
|
|
@@ -102,7 +102,7 @@ interface LinterConfig {
|
|
|
102
102
|
/**
|
|
103
103
|
* Built-in lint preset
|
|
104
104
|
*/
|
|
105
|
-
preset?: "happy-path" | "opinionated" | "essential" | "incremental" | "nuxt";
|
|
105
|
+
preset?: "happy-path" | "opinionated" | "essential" | "incremental" | "ecosystem" | "nuxt";
|
|
106
106
|
/**
|
|
107
107
|
* Rules to enable/disable
|
|
108
108
|
*/
|
|
@@ -166,7 +166,11 @@ interface TypeCheckerConfig {
|
|
|
166
166
|
*/
|
|
167
167
|
tsconfig?: string;
|
|
168
168
|
/**
|
|
169
|
-
* Path to
|
|
169
|
+
* Path to the Corsa executable. This is the canonical runtime key; tsgoPath is kept as a compatibility alias.
|
|
170
|
+
*/
|
|
171
|
+
corsaPath?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Deprecated alias for typeChecker.corsaPath
|
|
170
174
|
*/
|
|
171
175
|
tsgoPath?: string;
|
|
172
176
|
/**
|
|
@@ -174,7 +178,7 @@ interface TypeCheckerConfig {
|
|
|
174
178
|
*/
|
|
175
179
|
globalsFile?: string;
|
|
176
180
|
/**
|
|
177
|
-
*
|
|
181
|
+
* Reserved Corsa server count. The direct project-session runner currently supports only 1.
|
|
178
182
|
*/
|
|
179
183
|
servers?: number;
|
|
180
184
|
}
|
|
@@ -291,6 +295,10 @@ interface LanguageServerConfig {
|
|
|
291
295
|
* Enable editor-oriented IDE features
|
|
292
296
|
*/
|
|
293
297
|
editor?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Enable Vue ecosystem lint and editor helpers
|
|
300
|
+
*/
|
|
301
|
+
ecosystem?: boolean;
|
|
294
302
|
/**
|
|
295
303
|
* Enable completions
|
|
296
304
|
*/
|
|
@@ -468,7 +476,7 @@ interface GlobalTypeDeclaration {
|
|
|
468
476
|
}
|
|
469
477
|
//#endregion
|
|
470
478
|
//#region src/types/rules.d.ts
|
|
471
|
-
declare const LINT_RULE_NAMES: readonly ["a11y/alt-text", "a11y/anchor-has-content", "a11y/anchor-is-valid", "a11y/aria-props", "a11y/aria-role", "a11y/aria-unsupported-elements", "a11y/click-events-have-key-events", "a11y/form-control-has-label", "a11y/heading-has-content", "a11y/heading-levels", "a11y/iframe-has-title", "a11y/img-alt", "a11y/interactive-supports-focus", "a11y/label-has-for", "a11y/landmark-roles", "a11y/media-has-caption", "a11y/mouse-events-have-key-events", "a11y/no-access-key", "a11y/no-aria-hidden-on-focusable", "a11y/no-autofocus", "a11y/no-distracting-elements", "a11y/no-i-for-icon", "a11y/no-redundant-roles", "a11y/no-refer-to-non-existent-id", "a11y/no-role-presentation-on-focusable", "a11y/no-static-element-interactions", "a11y/placeholder-label-option", "a11y/role-has-required-aria-props", "a11y/tabindex-no-positive", "a11y/use-list", "ecosystem/nuxt-prefer-nuxt-link", "ecosystem/pinia-prefer-store-to-refs", "ecosystem/router-link-require-to", "ecosystem/vue-i18n-no-missing-key", "ecosystem/vue-router-prefer-named-link", "ecosystem/vue-router-prefer-named-push", "ecosystem/vue-test-utils-no-html-snapshot", "html/deprecated-attr", "html/deprecated-element", "html/id-duplication", "html/no-consecutive-br", "html/no-duplicate-dt", "html/no-empty-palpable-content", "html/require-datetime", "script/no-get-current-instance", "script/no-next-tick", "script/no-options-api", "ssr/no-browser-globals-in-ssr", "ssr/no-hydration-mismatch", "type/no-floating-promises", "type/no-reactivity-loss", "type/no-unsafe-template-binding", "type/require-typed-emits", "type/require-typed-props", "vapor/no-inline-template", "vapor/no-vue-lifecycle-events", "vapor/prefer-static-class", "vapor/require-vapor-attribute", "vue/attribute-hyphenation", "vue/attribute-order", "vue/component-definition-name-casing", "vue/component-name-in-template-casing", "vue/html-quotes", "vue/html-self-closing", "vue/multi-word-component-names", "vue/mustache-interpolation-spacing", "vue/no-boolean-attr-value", "vue/no-child-content", "vue/no-dupe-v-else-if", "vue/no-duplicate-attributes", "vue/no-inline-style", "vue/no-lone-template", "vue/no-multi-spaces", "vue/no-mutating-props", "vue/no-preprocessor-lang", "vue/no-reserved-component-names", "vue/no-script-non-standard-lang", "vue/no-src-attribute", "vue/no-template-key", "vue/no-template-lang", "vue/no-template-shadow", "vue/no-textarea-mustache", "vue/no-unsafe-url", "vue/no-unused-components", "vue/no-unused-properties", "vue/no-unused-vars", "vue/no-use-v-if-with-v-for", "vue/no-useless-template-attributes", "vue/no-v-html", "vue/no-v-text-v-html-on-component", "vue/permitted-contents", "vue/prefer-props-shorthand", "vue/prop-name-casing", "vue/require-component-is", "vue/require-component-registration", "vue/require-scoped-style", "vue/require-v-for-key", "vue/scoped-event-names", "vue/sfc-element-order", "vue/single-style-block", "vue/use-unique-element-ids", "vue/use-v-on-exact", "vue/v-bind-style", "vue/v-on-style", "vue/v-slot-style", "vue/valid-attribute-name", "vue/valid-v-bind", "vue/valid-v-else", "vue/valid-v-for", "vue/valid-v-if", "vue/valid-v-memo", "vue/valid-v-model", "vue/valid-v-on", "vue/valid-v-show", "vue/valid-v-slot", "vue/warn-custom-block", "vue/warn-custom-directive"];
|
|
479
|
+
declare const LINT_RULE_NAMES: readonly ["a11y/alt-text", "a11y/anchor-has-content", "a11y/anchor-is-valid", "a11y/aria-props", "a11y/aria-role", "a11y/aria-unsupported-elements", "a11y/click-events-have-key-events", "a11y/form-control-has-label", "a11y/heading-has-content", "a11y/heading-levels", "a11y/iframe-has-title", "a11y/img-alt", "a11y/interactive-supports-focus", "a11y/label-has-for", "a11y/landmark-roles", "a11y/media-has-caption", "a11y/mouse-events-have-key-events", "a11y/no-access-key", "a11y/no-aria-hidden-on-focusable", "a11y/no-autofocus", "a11y/no-distracting-elements", "a11y/no-i-for-icon", "a11y/no-redundant-roles", "a11y/no-refer-to-non-existent-id", "a11y/no-role-presentation-on-focusable", "a11y/no-static-element-interactions", "a11y/placeholder-label-option", "a11y/role-has-required-aria-props", "a11y/tabindex-no-positive", "a11y/use-list", "ecosystem/nuxt-prefer-nuxt-link", "ecosystem/pinia-prefer-store-to-refs", "ecosystem/router-link-require-to", "ecosystem/void-link-require-href", "ecosystem/void-link-valid-method", "ecosystem/vue-i18n-no-missing-key", "ecosystem/vue-router-prefer-named-link", "ecosystem/vue-router-prefer-named-push", "ecosystem/vue-test-utils-no-html-snapshot", "html/deprecated-attr", "html/deprecated-element", "html/id-duplication", "html/no-consecutive-br", "html/no-duplicate-dt", "html/no-empty-palpable-content", "html/require-datetime", "script/no-get-current-instance", "script/no-next-tick", "script/no-options-api", "ssr/no-browser-globals-in-ssr", "ssr/no-hydration-mismatch", "type/no-floating-promises", "type/no-reactivity-loss", "type/no-unsafe-template-binding", "type/require-typed-emits", "type/require-typed-props", "vapor/no-inline-template", "vapor/no-vue-lifecycle-events", "vapor/prefer-static-class", "vapor/require-vapor-attribute", "vue/attribute-hyphenation", "vue/attribute-order", "vue/component-definition-name-casing", "vue/component-name-in-template-casing", "vue/html-quotes", "vue/html-self-closing", "vue/multi-word-component-names", "vue/mustache-interpolation-spacing", "vue/no-boolean-attr-value", "vue/no-child-content", "vue/no-dupe-v-else-if", "vue/no-duplicate-attributes", "vue/no-inline-style", "vue/no-lone-template", "vue/no-multi-spaces", "vue/no-mutating-props", "vue/no-preprocessor-lang", "vue/no-reserved-component-names", "vue/no-script-non-standard-lang", "vue/no-src-attribute", "vue/no-template-key", "vue/no-template-lang", "vue/no-template-shadow", "vue/no-textarea-mustache", "vue/no-unsafe-url", "vue/no-unused-components", "vue/no-unused-properties", "vue/no-unused-vars", "vue/no-use-v-if-with-v-for", "vue/no-useless-template-attributes", "vue/no-v-html", "vue/no-v-text-v-html-on-component", "vue/permitted-contents", "vue/prefer-props-shorthand", "vue/prop-name-casing", "vue/require-component-is", "vue/require-component-registration", "vue/require-scoped-style", "vue/require-v-for-key", "vue/scoped-event-names", "vue/sfc-element-order", "vue/single-style-block", "vue/use-unique-element-ids", "vue/use-v-on-exact", "vue/v-bind-style", "vue/v-on-style", "vue/v-slot-style", "vue/valid-attribute-name", "vue/valid-v-bind", "vue/valid-v-else", "vue/valid-v-for", "vue/valid-v-if", "vue/valid-v-memo", "vue/valid-v-model", "vue/valid-v-on", "vue/valid-v-show", "vue/valid-v-slot", "vue/warn-custom-block", "vue/warn-custom-directive"];
|
|
472
480
|
type LintRuleName = (typeof LINT_RULE_NAMES)[number];
|
|
473
481
|
type LintRulesConfig = Partial<Record<LintRuleName, RuleSeverity>>;
|
|
474
482
|
//#endregion
|
|
@@ -531,4 +539,4 @@ declare function loadConfig(root: string, options?: LoadConfigOptions): Promise<
|
|
|
531
539
|
declare function normalizeGlobalTypes(config: GlobalTypesConfig): Record<string, GlobalTypeDeclaration>;
|
|
532
540
|
//#endregion
|
|
533
541
|
export { MuseaConfig as C, TypeCheckerConfig as D, RuleSeverity as E, VitePluginConfig as O, MuseaAutogenConfig as S, RuleCategory as T, GlobalTypesConfig as _, loadConfig as a, LinterConfig as b, ConfigEnv as c, UserConfigExport as d, LintRuleName as f, GlobalTypeDeclaration as g, FormatterConfig as h, defineConfig as i, VizeConfig as k, LoadConfigOptions as l, CompilerConfig as m, VIZE_CONFIG_JSON_SCHEMA_PATH as n, normalizeGlobalTypes as o, LintRulesConfig as p, VIZE_CONFIG_PKL_SCHEMA_PATH as r, LspConfig as s, CONFIG_FILE_NAMES as t, MaybePromise as u, LanguageServerConfig as v, MuseaVrtConfig as w, MuseaA11yConfig as x, LintPreset as y };
|
|
534
|
-
//# sourceMappingURL=config-
|
|
542
|
+
//# sourceMappingURL=config-CczvMtD4.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CczvMtD4.d.mts","names":[],"sources":["../src/types/generated.ts","../src/types/rules.ts","../src/types/runtime.ts","../src/types/index.ts","../src/config.ts"],"mappings":";;AAOA;;;;KAAY,UAAA;AAAA,KAQA,YAAA;AAAA,KAEA,YAAA;;;;UAKK,UAAA;EACf,QAAA,GAAW,cAAA;EACX,IAAA,GAAO,gBAAA;EACP,MAAA,GAAS,YAAA;EACT,WAAA,GAAc,iBAAA;EACd,SAAA,GAAY,eAAA;EACZ,cAAA,GAAiB,oBAAA;EACjB,GAAA,GAAM,oBAAA;EACN,KAAA,GAAQ,WAAA;EACR,WAAA,GAAc,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ATH, t as CONFIG_FILE_NAMES } from "./config-
|
|
1
|
+
import { a as loadConfig, i as defineConfig, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, r as VIZE_CONFIG_PKL_SCHEMA_PATH, t as CONFIG_FILE_NAMES } from "./config-CczvMtD4.mjs";
|
|
2
2
|
export { CONFIG_FILE_NAMES, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, defineConfig, loadConfig, normalizeGlobalTypes };
|
package/dist/config.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
6
|
import { transform } from "oxc-transform";
|
|
6
7
|
//#region src/config.ts
|
|
@@ -137,7 +138,7 @@ function createPklConfigWithBundledSchemaImports(filePath) {
|
|
|
137
138
|
return `${prefix}${quote}${pathToFileURL(bundledSchemaPath).href}${quote}`;
|
|
138
139
|
});
|
|
139
140
|
if (!patched) return null;
|
|
140
|
-
const tempFile = path.join(configDir, `.vize-config-${process.pid}-${Date.now()}-${
|
|
141
|
+
const tempFile = path.join(configDir, `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.pkl`);
|
|
141
142
|
fs.writeFileSync(tempFile, content, {
|
|
142
143
|
flag: "wx",
|
|
143
144
|
mode: 384
|
|
@@ -150,7 +151,7 @@ async function resolveConfigExport(exported, env) {
|
|
|
150
151
|
}
|
|
151
152
|
async function loadTypeScriptConfig(filePath, env) {
|
|
152
153
|
const result = await transform(filePath, fs.readFileSync(filePath, "utf-8"), { typescript: { onlyRemoveTypeImports: true } });
|
|
153
|
-
const tempFile = path.join(path.dirname(filePath), `.vize-config-${process.pid}-${Date.now()}.mjs`);
|
|
154
|
+
const tempFile = path.join(path.dirname(filePath), `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.mjs`);
|
|
154
155
|
fs.writeFileSync(tempFile, result.code, {
|
|
155
156
|
flag: "wx",
|
|
156
157
|
mode: 384
|
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { execFileSync } from \"node:child_process\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { transform } from \"oxc-transform\";\nimport type {\n LanguageServerConfig,\n VizeConfig,\n LoadConfigOptions,\n UserConfigExport,\n ConfigEnv,\n GlobalTypesConfig,\n GlobalTypeDeclaration,\n} from \"./types/index.js\";\n\nexport const CONFIG_FILE_NAMES = [\n \"vize.config.pkl\",\n \"vize.config.ts\",\n \"vize.config.js\",\n \"vize.config.mjs\",\n \"vize.config.json\",\n] as const;\n\nconst DEFAULT_CONFIG_ENV: ConfigEnv = {\n mode: \"development\",\n command: \"serve\",\n};\n\nconst PACKAGE_ROOT = path.resolve(fileURLToPath(new URL(\".\", import.meta.url)), \"..\");\n\nexport const VIZE_CONFIG_JSON_SCHEMA_PATH = path.join(\n PACKAGE_ROOT,\n \"schemas\",\n \"vize.config.schema.json\",\n);\n\nexport const VIZE_CONFIG_PKL_SCHEMA_PATH = path.join(PACKAGE_ROOT, \"pkl\", \"vize.pkl\");\n\nconst DOCUMENTED_PKL_SCHEMA_IMPORT_RE =\n /^(\\s*(?:amends|import)\\s+)([\"'])node_modules\\/vize\\/pkl\\/(VizeConfig\\.pkl|vize\\.pkl)\\2/gm;\n\ntype CompatVizeConfig = VizeConfig & {\n lsp?: LanguageServerConfig;\n};\n\n/**\n * Define a Vize configuration with type checking.\n * Accepts a plain object or a function that receives ConfigEnv.\n */\nexport function defineConfig(config: UserConfigExport): UserConfigExport {\n return config;\n}\n\n/**\n * Load `vize.config.*` from the specified directory.\n */\nexport async function loadConfig(\n root: string,\n options: LoadConfigOptions = {},\n): Promise<VizeConfig | null> {\n const { mode = \"root\", configFile, env } = options;\n\n if (mode === \"none\") {\n return null;\n }\n\n if (configFile) {\n const absolutePath = path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile);\n if (fs.existsSync(absolutePath)) {\n return loadConfigFile(absolutePath, env);\n }\n return null;\n }\n\n if (mode === \"auto\") {\n return loadConfigFromDirAuto(root, env);\n }\n\n return loadConfigFromDir(root, env);\n}\n\nasync function loadConfigFromDir(dir: string, env?: ConfigEnv): Promise<VizeConfig | null> {\n for (const name of CONFIG_FILE_NAMES) {\n const filePath = path.join(dir, name);\n if (!fs.existsSync(filePath)) {\n continue;\n }\n\n const config = await loadConfigFile(filePath, env);\n if (config !== null) {\n return config;\n }\n }\n return null;\n}\n\nasync function loadConfigFromDirAuto(\n startDir: string,\n env?: ConfigEnv,\n): Promise<VizeConfig | null> {\n let currentDir = path.resolve(startDir);\n\n while (true) {\n const config = await loadConfigFromDir(currentDir, env);\n if (config !== null) {\n return config;\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return null;\n }\n\n currentDir = parentDir;\n }\n}\n\nasync function loadConfigFile(filePath: string, env?: ConfigEnv): Promise<VizeConfig | null> {\n const absolutePath = path.resolve(filePath);\n if (!fs.existsSync(absolutePath)) {\n return null;\n }\n\n const ext = path.extname(absolutePath);\n\n if (ext === \".pkl\") {\n return loadPklConfig(absolutePath);\n }\n\n if (ext === \".json\") {\n const content = fs.readFileSync(absolutePath, \"utf-8\");\n return parseJsonConfig(content, absolutePath);\n }\n\n if (ext === \".ts\") {\n return loadTypeScriptConfig(absolutePath, env);\n }\n\n return loadESMConfig(absolutePath, env);\n}\n\nfunction findPklBinary(): string | null {\n try {\n const pklPkgPath = import.meta.resolve?.(\"@pkl-community/pkl\");\n if (pklPkgPath) {\n const pklLibDir = path.dirname(fileURLToPath(pklPkgPath));\n const pklPackageDir = path.dirname(pklLibDir);\n const candidates = [\n path.join(pklLibDir, \"main.js\"),\n path.join(pklPackageDir, \"pkl\"),\n path.join(pklPackageDir, \"pkl.exe\"),\n ];\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n try {\n execFileSync(candidate, [\"--version\"], { stdio: \"ignore\" });\n return candidate;\n } catch {\n // Keep looking: the bundled shim can exist even when its runtime is unavailable.\n }\n }\n }\n }\n } catch {\n // Fall back to PATH below.\n }\n\n try {\n execFileSync(\"pkl\", [\"--version\"], { stdio: \"ignore\" });\n return \"pkl\";\n } catch {\n return null;\n }\n}\n\nfunction loadPklConfig(filePath: string): VizeConfig | null {\n const pklBin = findPklBinary();\n if (!pklBin) {\n console.warn(\n \"[vize] pkl CLI not found. Install @pkl-community/pkl or add pkl to PATH. \" +\n \"Falling back to the next config format.\",\n );\n return null;\n }\n\n let output: string;\n const patchedFilePath = createPklConfigWithBundledSchemaImports(filePath);\n const evalFilePath = patchedFilePath ?? filePath;\n try {\n output = execFileSync(pklBin, [\"eval\", \"-f\", \"json\", evalFilePath], {\n cwd: path.dirname(filePath),\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n timeout: 30_000,\n });\n } catch (error) {\n throw new Error(`Failed to evaluate vize PKL config at ${filePath}: ${getErrorMessage(error)}`);\n } finally {\n if (patchedFilePath) {\n fs.rmSync(patchedFilePath, { force: true });\n }\n }\n return parseJsonConfig(output, filePath);\n}\n\nfunction createPklConfigWithBundledSchemaImports(filePath: string): string | null {\n const configDir = path.dirname(filePath);\n const source = fs.readFileSync(filePath, \"utf-8\");\n let patched = false;\n\n const content = source.replace(\n DOCUMENTED_PKL_SCHEMA_IMPORT_RE,\n (match, prefix, quote, schemaFile) => {\n const projectSchemaPath = path.join(configDir, \"node_modules\", \"vize\", \"pkl\", schemaFile);\n if (fs.existsSync(projectSchemaPath)) {\n return match;\n }\n\n const bundledSchemaPath = path.join(PACKAGE_ROOT, \"pkl\", schemaFile);\n if (!fs.existsSync(bundledSchemaPath)) {\n return match;\n }\n\n patched = true;\n return `${prefix}${quote}${pathToFileURL(bundledSchemaPath).href}${quote}`;\n },\n );\n\n if (!patched) {\n return null;\n }\n\n const tempFile = path.join(\n configDir,\n `.vize-config-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}.pkl`,\n );\n fs.writeFileSync(tempFile, content, { flag: \"wx\", mode: 0o600 });\n return tempFile;\n}\n\nasync function resolveConfigExport(\n exported: UserConfigExport,\n env?: ConfigEnv,\n): Promise<VizeConfig> {\n if (typeof exported === \"function\") {\n return normalizeLoadedConfig(await exported(env ?? DEFAULT_CONFIG_ENV));\n }\n\n return normalizeLoadedConfig(exported);\n}\n\nasync function loadTypeScriptConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const source = fs.readFileSync(filePath, \"utf-8\");\n const result = await transform(filePath, source, {\n typescript: {\n onlyRemoveTypeImports: true,\n },\n });\n\n const tempFile = path.join(\n path.dirname(filePath),\n `.vize-config-${process.pid}-${Date.now()}.mjs`,\n );\n fs.writeFileSync(tempFile, result.code, { flag: \"wx\", mode: 0o600 });\n\n try {\n const module = await importFresh(tempFile);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n } finally {\n fs.rmSync(tempFile, { force: true });\n }\n}\n\nasync function loadESMConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const module = await importFresh(filePath);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n}\n\nasync function importFresh(filePath: string): Promise<Record<string, unknown>> {\n const fileUrl = pathToFileURL(filePath);\n fileUrl.searchParams.set(\"t\", String(fs.statSync(filePath).mtimeMs));\n return import(fileUrl.href);\n}\n\nfunction parseJsonConfig(content: string, filePath: string): VizeConfig {\n try {\n return normalizeLoadedConfig(JSON.parse(content));\n } catch (error) {\n throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);\n }\n}\n\nfunction normalizeLoadedConfig(config: unknown): VizeConfig {\n const normalized = stripNullish(config);\n return normalizeConfigAliases((normalized ?? {}) as CompatVizeConfig);\n}\n\nfunction stripNullish(value: unknown): unknown {\n if (value === null) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => stripNullish(entry)).filter((entry) => entry !== undefined);\n }\n\n if (typeof value === \"object\" && value !== null) {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const normalizedEntry = stripNullish(entry);\n if (normalizedEntry !== undefined) {\n result[key] = normalizedEntry;\n }\n }\n return result;\n }\n\n return value;\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects\n */\nexport function normalizeGlobalTypes(\n config: GlobalTypesConfig,\n): Record<string, GlobalTypeDeclaration> {\n const resolvedConfig =\n \"types\" in config &&\n typeof config.types === \"object\" &&\n config.types !== null &&\n !Array.isArray(config.types)\n ? config.types\n : config;\n\n const result: Record<string, GlobalTypeDeclaration> = {};\n for (const [key, value] of Object.entries(resolvedConfig)) {\n if (typeof value === \"string\") {\n result[key] = { type: value };\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\nfunction normalizeConfigAliases(config: CompatVizeConfig): VizeConfig {\n if (config.lsp === undefined) {\n return config;\n }\n\n const { lsp, ...rest } = config;\n if (config.languageServer !== undefined) {\n return rest;\n }\n\n return {\n ...rest,\n languageServer: lsp,\n };\n}\n"],"mappings":";;;;;;AAeA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAgC;CACpC,MAAM;CACN,SAAS;CACV;AAED,MAAM,eAAe,KAAK,QAAQ,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC,EAAE,KAAK;AAErF,MAAa,+BAA+B,KAAK,KAC/C,cACA,WACA,0BACD;AAED,MAAa,8BAA8B,KAAK,KAAK,cAAc,OAAO,WAAW;AAErF,MAAM,kCACJ;;;;;AAUF,SAAgB,aAAa,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Ae,EACvD,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,EAAE,MAAM,OAAO;MAE7B,OAAO,OAAO;CAGlB,OAAO;;AAGT,SAAS,uBAAuB,QAAsC;CACpE,IAAI,OAAO,QAAQ,KAAA,GACjB,OAAO;CAGT,MAAM,EAAE,KAAK,GAAG,SAAS;CACzB,IAAI,OAAO,mBAAmB,KAAA,GAC5B,OAAO;CAGT,OAAO;EACL,GAAG;EACH,gBAAgB;EACjB"}
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { execFileSync } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { transform } from \"oxc-transform\";\nimport type {\n LanguageServerConfig,\n VizeConfig,\n LoadConfigOptions,\n UserConfigExport,\n ConfigEnv,\n GlobalTypesConfig,\n GlobalTypeDeclaration,\n} from \"./types/index.js\";\n\nexport const CONFIG_FILE_NAMES = [\n \"vize.config.pkl\",\n \"vize.config.ts\",\n \"vize.config.js\",\n \"vize.config.mjs\",\n \"vize.config.json\",\n] as const;\n\nconst DEFAULT_CONFIG_ENV: ConfigEnv = {\n mode: \"development\",\n command: \"serve\",\n};\n\nconst PACKAGE_ROOT = path.resolve(fileURLToPath(new URL(\".\", import.meta.url)), \"..\");\n\nexport const VIZE_CONFIG_JSON_SCHEMA_PATH = path.join(\n PACKAGE_ROOT,\n \"schemas\",\n \"vize.config.schema.json\",\n);\n\nexport const VIZE_CONFIG_PKL_SCHEMA_PATH = path.join(PACKAGE_ROOT, \"pkl\", \"vize.pkl\");\n\nconst DOCUMENTED_PKL_SCHEMA_IMPORT_RE =\n /^(\\s*(?:amends|import)\\s+)([\"'])node_modules\\/vize\\/pkl\\/(VizeConfig\\.pkl|vize\\.pkl)\\2/gm;\n\ntype CompatVizeConfig = VizeConfig & {\n lsp?: LanguageServerConfig;\n};\n\n/**\n * Define a Vize configuration with type checking.\n * Accepts a plain object or a function that receives ConfigEnv.\n */\nexport function defineConfig(config: UserConfigExport): UserConfigExport {\n return config;\n}\n\n/**\n * Load `vize.config.*` from the specified directory.\n */\nexport async function loadConfig(\n root: string,\n options: LoadConfigOptions = {},\n): Promise<VizeConfig | null> {\n const { mode = \"root\", configFile, env } = options;\n\n if (mode === \"none\") {\n return null;\n }\n\n if (configFile) {\n const absolutePath = path.isAbsolute(configFile) ? configFile : path.resolve(root, configFile);\n if (fs.existsSync(absolutePath)) {\n return loadConfigFile(absolutePath, env);\n }\n return null;\n }\n\n if (mode === \"auto\") {\n return loadConfigFromDirAuto(root, env);\n }\n\n return loadConfigFromDir(root, env);\n}\n\nasync function loadConfigFromDir(dir: string, env?: ConfigEnv): Promise<VizeConfig | null> {\n for (const name of CONFIG_FILE_NAMES) {\n const filePath = path.join(dir, name);\n if (!fs.existsSync(filePath)) {\n continue;\n }\n\n const config = await loadConfigFile(filePath, env);\n if (config !== null) {\n return config;\n }\n }\n return null;\n}\n\nasync function loadConfigFromDirAuto(\n startDir: string,\n env?: ConfigEnv,\n): Promise<VizeConfig | null> {\n let currentDir = path.resolve(startDir);\n\n while (true) {\n const config = await loadConfigFromDir(currentDir, env);\n if (config !== null) {\n return config;\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n return null;\n }\n\n currentDir = parentDir;\n }\n}\n\nasync function loadConfigFile(filePath: string, env?: ConfigEnv): Promise<VizeConfig | null> {\n const absolutePath = path.resolve(filePath);\n if (!fs.existsSync(absolutePath)) {\n return null;\n }\n\n const ext = path.extname(absolutePath);\n\n if (ext === \".pkl\") {\n return loadPklConfig(absolutePath);\n }\n\n if (ext === \".json\") {\n const content = fs.readFileSync(absolutePath, \"utf-8\");\n return parseJsonConfig(content, absolutePath);\n }\n\n if (ext === \".ts\") {\n return loadTypeScriptConfig(absolutePath, env);\n }\n\n return loadESMConfig(absolutePath, env);\n}\n\nfunction findPklBinary(): string | null {\n try {\n const pklPkgPath = import.meta.resolve?.(\"@pkl-community/pkl\");\n if (pklPkgPath) {\n const pklLibDir = path.dirname(fileURLToPath(pklPkgPath));\n const pklPackageDir = path.dirname(pklLibDir);\n const candidates = [\n path.join(pklLibDir, \"main.js\"),\n path.join(pklPackageDir, \"pkl\"),\n path.join(pklPackageDir, \"pkl.exe\"),\n ];\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n try {\n execFileSync(candidate, [\"--version\"], { stdio: \"ignore\" });\n return candidate;\n } catch {\n // Keep looking: the bundled shim can exist even when its runtime is unavailable.\n }\n }\n }\n }\n } catch {\n // Fall back to PATH below.\n }\n\n try {\n execFileSync(\"pkl\", [\"--version\"], { stdio: \"ignore\" });\n return \"pkl\";\n } catch {\n return null;\n }\n}\n\nfunction loadPklConfig(filePath: string): VizeConfig | null {\n const pklBin = findPklBinary();\n if (!pklBin) {\n console.warn(\n \"[vize] pkl CLI not found. Install @pkl-community/pkl or add pkl to PATH. \" +\n \"Falling back to the next config format.\",\n );\n return null;\n }\n\n let output: string;\n const patchedFilePath = createPklConfigWithBundledSchemaImports(filePath);\n const evalFilePath = patchedFilePath ?? filePath;\n try {\n output = execFileSync(pklBin, [\"eval\", \"-f\", \"json\", evalFilePath], {\n cwd: path.dirname(filePath),\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n timeout: 30_000,\n });\n } catch (error) {\n throw new Error(`Failed to evaluate vize PKL config at ${filePath}: ${getErrorMessage(error)}`);\n } finally {\n if (patchedFilePath) {\n fs.rmSync(patchedFilePath, { force: true });\n }\n }\n return parseJsonConfig(output, filePath);\n}\n\nfunction createPklConfigWithBundledSchemaImports(filePath: string): string | null {\n const configDir = path.dirname(filePath);\n const source = fs.readFileSync(filePath, \"utf-8\");\n let patched = false;\n\n const content = source.replace(\n DOCUMENTED_PKL_SCHEMA_IMPORT_RE,\n (match, prefix, quote, schemaFile) => {\n const projectSchemaPath = path.join(configDir, \"node_modules\", \"vize\", \"pkl\", schemaFile);\n if (fs.existsSync(projectSchemaPath)) {\n return match;\n }\n\n const bundledSchemaPath = path.join(PACKAGE_ROOT, \"pkl\", schemaFile);\n if (!fs.existsSync(bundledSchemaPath)) {\n return match;\n }\n\n patched = true;\n return `${prefix}${quote}${pathToFileURL(bundledSchemaPath).href}${quote}`;\n },\n );\n\n if (!patched) {\n return null;\n }\n\n const tempFile = path.join(\n configDir,\n `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.pkl`,\n );\n fs.writeFileSync(tempFile, content, { flag: \"wx\", mode: 0o600 });\n return tempFile;\n}\n\nasync function resolveConfigExport(\n exported: UserConfigExport,\n env?: ConfigEnv,\n): Promise<VizeConfig> {\n if (typeof exported === \"function\") {\n return normalizeLoadedConfig(await exported(env ?? DEFAULT_CONFIG_ENV));\n }\n\n return normalizeLoadedConfig(exported);\n}\n\nasync function loadTypeScriptConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const source = fs.readFileSync(filePath, \"utf-8\");\n const result = await transform(filePath, source, {\n typescript: {\n onlyRemoveTypeImports: true,\n },\n });\n\n const tempFile = path.join(\n path.dirname(filePath),\n `.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.mjs`,\n );\n fs.writeFileSync(tempFile, result.code, { flag: \"wx\", mode: 0o600 });\n\n try {\n const module = await importFresh(tempFile);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n } finally {\n fs.rmSync(tempFile, { force: true });\n }\n}\n\nasync function loadESMConfig(filePath: string, env?: ConfigEnv): Promise<VizeConfig> {\n const module = await importFresh(filePath);\n const exported: UserConfigExport = module.default || module;\n return resolveConfigExport(exported, env);\n}\n\nasync function importFresh(filePath: string): Promise<Record<string, unknown>> {\n const fileUrl = pathToFileURL(filePath);\n fileUrl.searchParams.set(\"t\", String(fs.statSync(filePath).mtimeMs));\n return import(fileUrl.href);\n}\n\nfunction parseJsonConfig(content: string, filePath: string): VizeConfig {\n try {\n return normalizeLoadedConfig(JSON.parse(content));\n } catch (error) {\n throw new Error(`Failed to parse vize config JSON at ${filePath}: ${getErrorMessage(error)}`);\n }\n}\n\nfunction normalizeLoadedConfig(config: unknown): VizeConfig {\n const normalized = stripNullish(config);\n return normalizeConfigAliases((normalized ?? {}) as CompatVizeConfig);\n}\n\nfunction stripNullish(value: unknown): unknown {\n if (value === null) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => stripNullish(entry)).filter((entry) => entry !== undefined);\n }\n\n if (typeof value === \"object\" && value !== null) {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const normalizedEntry = stripNullish(entry);\n if (normalizedEntry !== undefined) {\n result[key] = normalizedEntry;\n }\n }\n return result;\n }\n\n return value;\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Normalize GlobalTypesConfig shorthand strings to GlobalTypeDeclaration objects\n */\nexport function normalizeGlobalTypes(\n config: GlobalTypesConfig,\n): Record<string, GlobalTypeDeclaration> {\n const resolvedConfig =\n \"types\" in config &&\n typeof config.types === \"object\" &&\n config.types !== null &&\n !Array.isArray(config.types)\n ? config.types\n : config;\n\n const result: Record<string, GlobalTypeDeclaration> = {};\n for (const [key, value] of Object.entries(resolvedConfig)) {\n if (typeof value === \"string\") {\n result[key] = { type: value };\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\nfunction normalizeConfigAliases(config: CompatVizeConfig): VizeConfig {\n if (config.lsp === undefined) {\n return config;\n }\n\n const { lsp, ...rest } = config;\n if (config.languageServer !== undefined) {\n return rest;\n }\n\n return {\n ...rest,\n languageServer: lsp,\n };\n}\n"],"mappings":";;;;;;;AAgBA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAgC;CACpC,MAAM;CACN,SAAS;CACV;AAED,MAAM,eAAe,KAAK,QAAQ,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,I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AO,UAAU,QACjB,CAAC,MAAM,QAAQ,OAAO,MAAM,GACxB,OAAO,QACP;CAEN,MAAM,SAAgD,EAAE;CACxD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,eAAe,EACvD,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,EAAE,MAAM,OAAO;MAE7B,OAAO,OAAO;CAGlB,OAAO;;AAGT,SAAS,uBAAuB,QAAsC;CACpE,IAAI,OAAO,QAAQ,KAAA,GACjB,OAAO;CAGT,MAAM,EAAE,KAAK,GAAG,SAAS;CACzB,IAAI,OAAO,mBAAmB,KAAA,GAC5B,OAAO;CAGT,OAAO;EACL,GAAG;EACH,gBAAgB;EACjB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as MuseaConfig, D as TypeCheckerConfig, E as RuleSeverity, O as VitePluginConfig, S as MuseaAutogenConfig, T as RuleCategory, _ as GlobalTypesConfig, a as loadConfig, b as LinterConfig, c as ConfigEnv, d as UserConfigExport, f as LintRuleName, g as GlobalTypeDeclaration, h as FormatterConfig, i as defineConfig, k as VizeConfig, l as LoadConfigOptions, m as CompilerConfig, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, p as LintRulesConfig, r as VIZE_CONFIG_PKL_SCHEMA_PATH, s as LspConfig, t as CONFIG_FILE_NAMES, u as MaybePromise, v as LanguageServerConfig, w as MuseaVrtConfig, x as MuseaA11yConfig, y as LintPreset } from "./config-
|
|
1
|
+
import { C as MuseaConfig, D as TypeCheckerConfig, E as RuleSeverity, O as VitePluginConfig, S as MuseaAutogenConfig, T as RuleCategory, _ as GlobalTypesConfig, a as loadConfig, b as LinterConfig, c as ConfigEnv, d as UserConfigExport, f as LintRuleName, g as GlobalTypeDeclaration, h as FormatterConfig, i as defineConfig, k as VizeConfig, l as LoadConfigOptions, m as CompilerConfig, n as VIZE_CONFIG_JSON_SCHEMA_PATH, o as normalizeGlobalTypes, p as LintRulesConfig, r as VIZE_CONFIG_PKL_SCHEMA_PATH, s as LspConfig, t as CONFIG_FILE_NAMES, u as MaybePromise, v as LanguageServerConfig, w as MuseaVrtConfig, x as MuseaA11yConfig, y as LintPreset } from "./config-CczvMtD4.mjs";
|
|
2
2
|
export { CONFIG_FILE_NAMES, type CompilerConfig, type ConfigEnv, type FormatterConfig, type GlobalTypeDeclaration, type GlobalTypesConfig, type LanguageServerConfig, type LintPreset, type LintRuleName, type LintRulesConfig, type LinterConfig, type LoadConfigOptions, type LspConfig, type MaybePromise, type MuseaA11yConfig, type MuseaAutogenConfig, type MuseaConfig, type MuseaVrtConfig, type RuleCategory, type RuleSeverity, type TypeCheckerConfig, type UserConfigExport, VIZE_CONFIG_JSON_SCHEMA_PATH, VIZE_CONFIG_PKL_SCHEMA_PATH, type VitePluginConfig, type VizeConfig, defineConfig, loadConfig, normalizeGlobalTypes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vize",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.116.0",
|
|
4
4
|
"description": "Vize - High-performance Vue.js toolchain in Rust",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@vizejs/native": "0.
|
|
52
|
+
"@vizejs/native": "0.116.0",
|
|
53
53
|
"oxc-transform": "0.130.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
@@ -32,12 +32,15 @@ class TypeCheckerConfig {
|
|
|
32
32
|
/// Path to tsconfig.json.
|
|
33
33
|
tsconfig: String? = null
|
|
34
34
|
|
|
35
|
-
/// Path to
|
|
35
|
+
/// Path to the Corsa executable.
|
|
36
|
+
corsaPath: String? = null
|
|
37
|
+
|
|
38
|
+
/// Deprecated alias for `corsaPath`.
|
|
36
39
|
tsgoPath: String? = null
|
|
37
40
|
|
|
38
41
|
/// Path to a .d.ts file that declares template globals.
|
|
39
42
|
globalsFile: String? = null
|
|
40
43
|
|
|
41
|
-
///
|
|
44
|
+
/// Reserved Corsa server count. The direct project-session runner currently supports only 1.
|
|
42
45
|
servers: Int? = null
|
|
43
46
|
}
|
|
@@ -12,7 +12,7 @@ local ruleSeverityEnum: JsonSchema = new JsonSchema {
|
|
|
12
12
|
|
|
13
13
|
local lintPresetEnum: JsonSchema = new JsonSchema {
|
|
14
14
|
type = "string"
|
|
15
|
-
enum = new Listing { "happy-path"; "opinionated"; "essential"; "incremental"; "nuxt" }
|
|
15
|
+
enum = new Listing { "happy-path"; "opinionated"; "essential"; "incremental"; "ecosystem"; "nuxt" }
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
local compilerConfigDef: JsonSchema = new JsonSchema {
|
|
@@ -206,9 +206,13 @@ local typeCheckerConfigDef: JsonSchema = new JsonSchema {
|
|
|
206
206
|
type = "string"
|
|
207
207
|
description = "Path to tsconfig.json"
|
|
208
208
|
}
|
|
209
|
+
["corsaPath"] = new JsonSchema {
|
|
210
|
+
type = "string"
|
|
211
|
+
description = "Path to the Corsa executable. This is the canonical runtime key; tsgoPath is kept as a compatibility alias."
|
|
212
|
+
}
|
|
209
213
|
["tsgoPath"] = new JsonSchema {
|
|
210
214
|
type = "string"
|
|
211
|
-
description = "
|
|
215
|
+
description = "Deprecated alias for typeChecker.corsaPath"
|
|
212
216
|
}
|
|
213
217
|
["globalsFile"] = new JsonSchema {
|
|
214
218
|
type = "string"
|
|
@@ -216,7 +220,7 @@ local typeCheckerConfigDef: JsonSchema = new JsonSchema {
|
|
|
216
220
|
}
|
|
217
221
|
["servers"] = new JsonSchema {
|
|
218
222
|
type = "integer"
|
|
219
|
-
description = "
|
|
223
|
+
description = "Reserved Corsa server count. The direct project-session runner currently supports only 1."
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
additionalProperties = false
|
|
@@ -366,6 +370,10 @@ local languageServerConfigDef: JsonSchema = new JsonSchema {
|
|
|
366
370
|
type = "boolean"
|
|
367
371
|
description = "Enable editor-oriented IDE features"
|
|
368
372
|
}
|
|
373
|
+
["ecosystem"] = new JsonSchema {
|
|
374
|
+
type = "boolean"
|
|
375
|
+
description = "Enable Vue ecosystem lint and editor helpers"
|
|
376
|
+
}
|
|
369
377
|
["completion"] = new JsonSchema {
|
|
370
378
|
type = "boolean"
|
|
371
379
|
description = "Enable completions"
|
package/pkl/vize.pkl
CHANGED
|
@@ -11,7 +11,7 @@ module vize.Config
|
|
|
11
11
|
typealias CompilerMode = "module" | "function"
|
|
12
12
|
typealias ScriptExt = "ts" | "js"
|
|
13
13
|
typealias RuleSeverity = "off" | "warn" | "error"
|
|
14
|
-
typealias LintPreset = "happy-path" | "opinionated" | "essential" | "incremental" | "nuxt"
|
|
14
|
+
typealias LintPreset = "happy-path" | "opinionated" | "essential" | "incremental" | "ecosystem" | "nuxt"
|
|
15
15
|
typealias TrailingComma = "all" | "none" | "es5"
|
|
16
16
|
typealias FilterPattern = String | Listing<String>
|
|
17
17
|
typealias GlobalTypeValue = String | GlobalTypeDeclaration
|
|
@@ -57,8 +57,8 @@ class TypeCheckerConfig {
|
|
|
57
57
|
checkInvalidExports: Boolean? = null
|
|
58
58
|
checkFallthroughAttrs: Boolean? = null
|
|
59
59
|
tsconfig: String? = null
|
|
60
|
-
tsgoPath: String? = null
|
|
61
60
|
corsaPath: String? = null
|
|
61
|
+
tsgoPath: String? = null
|
|
62
62
|
globalsFile: String? = null
|
|
63
63
|
servers: Int? = null
|
|
64
64
|
}
|
|
@@ -79,6 +79,7 @@ class LspConfig {
|
|
|
79
79
|
diagnostics: Boolean? = null
|
|
80
80
|
typecheck: Boolean? = null
|
|
81
81
|
editor: Boolean? = null
|
|
82
|
+
ecosystem: Boolean? = null
|
|
82
83
|
completion: Boolean? = null
|
|
83
84
|
hover: Boolean? = null
|
|
84
85
|
definition: Boolean? = null
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"description": "Built-in lint preset",
|
|
126
126
|
"default": "happy-path",
|
|
127
127
|
"type": "string",
|
|
128
|
-
"enum": ["happy-path", "opinionated", "essential", "incremental", "nuxt"]
|
|
128
|
+
"enum": ["happy-path", "opinionated", "essential", "incremental", "ecosystem", "nuxt"]
|
|
129
129
|
},
|
|
130
130
|
"rules": {
|
|
131
131
|
"description": "Rules to enable/disable",
|
|
@@ -222,8 +222,12 @@
|
|
|
222
222
|
"description": "Path to tsconfig.json",
|
|
223
223
|
"type": "string"
|
|
224
224
|
},
|
|
225
|
+
"corsaPath": {
|
|
226
|
+
"description": "Path to the Corsa executable. This is the canonical runtime key; tsgoPath is kept as a compatibility alias.",
|
|
227
|
+
"type": "string"
|
|
228
|
+
},
|
|
225
229
|
"tsgoPath": {
|
|
226
|
-
"description": "
|
|
230
|
+
"description": "Deprecated alias for typeChecker.corsaPath",
|
|
227
231
|
"type": "string"
|
|
228
232
|
},
|
|
229
233
|
"globalsFile": {
|
|
@@ -231,7 +235,7 @@
|
|
|
231
235
|
"type": "string"
|
|
232
236
|
},
|
|
233
237
|
"servers": {
|
|
234
|
-
"description": "
|
|
238
|
+
"description": "Reserved Corsa server count. The direct project-session runner currently supports only 1.",
|
|
235
239
|
"type": "integer"
|
|
236
240
|
}
|
|
237
241
|
},
|
|
@@ -382,6 +386,10 @@
|
|
|
382
386
|
"description": "Enable editor-oriented IDE features",
|
|
383
387
|
"type": "boolean"
|
|
384
388
|
},
|
|
389
|
+
"ecosystem": {
|
|
390
|
+
"description": "Enable Vue ecosystem lint and editor helpers",
|
|
391
|
+
"type": "boolean"
|
|
392
|
+
},
|
|
385
393
|
"completion": {
|
|
386
394
|
"description": "Enable completions",
|
|
387
395
|
"type": "boolean"
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
6
|
import { transform } from "oxc-transform";
|
|
6
7
|
import type {
|
|
@@ -233,7 +234,7 @@ function createPklConfigWithBundledSchemaImports(filePath: string): string | nul
|
|
|
233
234
|
|
|
234
235
|
const tempFile = path.join(
|
|
235
236
|
configDir,
|
|
236
|
-
`.vize-config-${process.pid}-${Date.now()}-${
|
|
237
|
+
`.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.pkl`,
|
|
237
238
|
);
|
|
238
239
|
fs.writeFileSync(tempFile, content, { flag: "wx", mode: 0o600 });
|
|
239
240
|
return tempFile;
|
|
@@ -260,7 +261,7 @@ async function loadTypeScriptConfig(filePath: string, env?: ConfigEnv): Promise<
|
|
|
260
261
|
|
|
261
262
|
const tempFile = path.join(
|
|
262
263
|
path.dirname(filePath),
|
|
263
|
-
`.vize-config-${process.pid}-${Date.now()}.mjs`,
|
|
264
|
+
`.vize-config-${process.pid}-${Date.now()}-${randomUUID()}.mjs`,
|
|
264
265
|
);
|
|
265
266
|
fs.writeFileSync(tempFile, result.code, { flag: "wx", mode: 0o600 });
|
|
266
267
|
|
package/src/types/generated.ts
CHANGED
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export type LintPreset =
|
|
8
|
+
export type LintPreset =
|
|
9
|
+
| "happy-path"
|
|
10
|
+
| "opinionated"
|
|
11
|
+
| "essential"
|
|
12
|
+
| "incremental"
|
|
13
|
+
| "ecosystem"
|
|
14
|
+
| "nuxt";
|
|
9
15
|
|
|
10
16
|
export type RuleSeverity = "off" | "warn" | "error";
|
|
11
17
|
|
|
@@ -106,7 +112,7 @@ export interface LinterConfig {
|
|
|
106
112
|
/**
|
|
107
113
|
* Built-in lint preset
|
|
108
114
|
*/
|
|
109
|
-
preset?: "happy-path" | "opinionated" | "essential" | "incremental" | "nuxt";
|
|
115
|
+
preset?: "happy-path" | "opinionated" | "essential" | "incremental" | "ecosystem" | "nuxt";
|
|
110
116
|
/**
|
|
111
117
|
* Rules to enable/disable
|
|
112
118
|
*/
|
|
@@ -170,7 +176,11 @@ export interface TypeCheckerConfig {
|
|
|
170
176
|
*/
|
|
171
177
|
tsconfig?: string;
|
|
172
178
|
/**
|
|
173
|
-
* Path to
|
|
179
|
+
* Path to the Corsa executable. This is the canonical runtime key; tsgoPath is kept as a compatibility alias.
|
|
180
|
+
*/
|
|
181
|
+
corsaPath?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Deprecated alias for typeChecker.corsaPath
|
|
174
184
|
*/
|
|
175
185
|
tsgoPath?: string;
|
|
176
186
|
/**
|
|
@@ -178,7 +188,7 @@ export interface TypeCheckerConfig {
|
|
|
178
188
|
*/
|
|
179
189
|
globalsFile?: string;
|
|
180
190
|
/**
|
|
181
|
-
*
|
|
191
|
+
* Reserved Corsa server count. The direct project-session runner currently supports only 1.
|
|
182
192
|
*/
|
|
183
193
|
servers?: number;
|
|
184
194
|
}
|
|
@@ -295,6 +305,10 @@ export interface LanguageServerConfig {
|
|
|
295
305
|
* Enable editor-oriented IDE features
|
|
296
306
|
*/
|
|
297
307
|
editor?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Enable Vue ecosystem lint and editor helpers
|
|
310
|
+
*/
|
|
311
|
+
ecosystem?: boolean;
|
|
298
312
|
/**
|
|
299
313
|
* Enable completions
|
|
300
314
|
*/
|
package/src/types/rules.ts
CHANGED
|
@@ -37,6 +37,8 @@ export const LINT_RULE_NAMES = [
|
|
|
37
37
|
"ecosystem/nuxt-prefer-nuxt-link",
|
|
38
38
|
"ecosystem/pinia-prefer-store-to-refs",
|
|
39
39
|
"ecosystem/router-link-require-to",
|
|
40
|
+
"ecosystem/void-link-require-href",
|
|
41
|
+
"ecosystem/void-link-valid-method",
|
|
40
42
|
"ecosystem/vue-i18n-no-missing-key",
|
|
41
43
|
"ecosystem/vue-router-prefer-named-link",
|
|
42
44
|
"ecosystem/vue-router-prefer-named-push",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-tvugwdpH.d.mts","names":[],"sources":["../src/types/generated.ts","../src/types/rules.ts","../src/types/runtime.ts","../src/types/index.ts","../src/config.ts"],"mappings":";;AAOA;;;;KAAY,UAAA;AAAA,KAEA,YAAA;AAAA,KAEA,YAAA;;;;UAKK,UAAA;EACf,QAAA,GAAW,cAAA;EACX,IAAA,GAAO,gBAAA;EACP,MAAA,GAAS,YAAA;EACT,WAAA,GAAc,iBAAA;EACd,SAAA,GAAY,eAAA;EACZ,cAAA,GAAiB,oBAAA;EACjB,GAAA,GAAM,oBAAA;EACN,KAAA,GAAQ,WAAA;EACR,WAAA,GAAc,iBAAA;AAAA;;;;UAKC,cAAA;EANP;;;EAUR,IAAA;EAjBA;;;EAqBA,KAAA;EAnBA;;;EAuBA,GAAA;EArBA;;;EAyBA,SAAA;EAvBA;;;EA2BA,iBAAA;EAzBA;;;EA6BA,WAAA;EAxBe;;;EA4Bf,aAAA;EAxBA;;;EA4BA,IAAA;EAZA;;;EAgBA,SAAA;EAAA;;;EAIA,iBAAA;EAIiB;AAKnB;;EALE,iBAAA;AAAA;;;;UAKe,gBAAA;EAQ6B;;;EAJ5C,OAAA,YAAmB,MAAA,aAAmB,MAAA;EAItC;;;EAAA,OAAA,YAAmB,MAAA,aAAmB,MAAA;EAQtC;;;EAJA,YAAA;EAS2B;;;EAL3B,cAAA;AAAA;;;;UAKe,YAAA;EAoBb;;;EAhBF,OAAA;EAoBE;;;EAhBF,MAAA;EAsBgC;;;EAlBhC,KAAA;IAAA,CACG,CAAA;EAAA;EAiCH;;;EA5BA,UAAA;IACE,WAAA;IACA,UAAA;IACA,KAAA;IACA,IAAA;IACA,IAAA;IACA,QAAA;EAAA;AAAA;AA+DJ;;;AAAA,UAzDiB,iBAAA;EA6Df;;;EAzDA,OAAA;EAyEA;;;EArEA,MAAA;EAqFA;;;EAjFA,UAAA;EAiGA;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