vite-plus 0.2.8 → 0.3.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/AGENTS.md +7 -0
- package/README.md +13 -6
- package/binding/index.cjs +57 -54
- package/binding/index.d.cts +100 -3
- package/dist/{agent-CI79DuSy.js → agent-Wqx0MPk0.js} +4 -188
- package/dist/bin.js +298 -278
- package/dist/command-CLJK5jGW.js +2 -0
- package/dist/command-CguLh2KL.js +471 -0
- package/dist/config/bin.js +29 -15
- package/dist/{constants-BppDcRc1.js → constants-Bn-U8o4v.js} +13 -3
- package/dist/create/bin.js +197 -247
- package/dist/{define-config-DPnHe1Mx.js → define-config-GXUdVT-0.js} +3 -3
- package/dist/{define-config-CEm_MtvJ.cjs → define-config-WiVlryJ2.cjs} +2 -2
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.js +1 -1
- package/dist/{dist-CSQWHI6y.js → dist-BDYZP12R.js} +193 -149
- package/dist/dist-Dqv1-Clg.js +3 -0
- package/dist/{editor-CGWdbLgD.js → editor-CC4DqODz.js} +736 -153
- package/dist/{terminal-CrqqK8WT.js → help-BmKpeOP9.js} +27 -34
- package/dist/hooks/bin.d.ts +1 -0
- package/dist/hooks/bin.js +131 -0
- package/dist/hooks-DFqViZqZ.js +573 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-BU88uu6o.js → json-cULBl7Pi.js} +145 -139
- package/dist/migration/bin.js +67 -21
- package/dist/migration/compat/worker.js +1 -1
- package/dist/{oxlint-plugin-config-BHOzlwMw.js → oxlint-plugin-config-DX5ezKbB.js} +1 -1
- package/dist/oxlint-plugin.js +1 -1
- package/dist/pack-bin.js +5 -4
- package/dist/{package-hV-77cBb.js → package-CBe9EWPY.js} +2 -2
- package/dist/{prompts-DYap08te.js → prompts-DF3yU-eU.js} +136 -512
- package/dist/{report-BS7ULx7A.js → report-ZNR1Mk6h.js} +1 -0
- package/dist/{resolve-vite-config-EWXclqvV.js → resolve-vite-config-ipGb39Jo.js} +2 -9
- package/dist/staged/bin.js +299 -251
- package/dist/terminal-MKGAuy-p.js +39 -0
- package/dist/test/browser/providers/playwright/context.d.ts +1 -1
- package/dist/test/browser/providers/playwright.d.ts +6 -6
- package/dist/test/browser/providers/preview/context.d.ts +1 -1
- package/dist/test/browser/providers/preview.d.ts +4 -4
- package/dist/test/browser/providers/webdriverio/context.d.ts +1 -1
- package/dist/test/browser/providers/webdriverio.d.ts +6 -6
- package/dist/test/browser-playwright/context.d.ts +1 -1
- package/dist/test/browser-playwright.d.ts +6 -6
- package/dist/test/browser-preview/context.d.ts +1 -1
- package/dist/test/browser-preview.d.ts +4 -4
- package/dist/test/browser-webdriverio/context.d.ts +1 -1
- package/dist/test/browser-webdriverio.d.ts +6 -6
- package/dist/test/context.d.ts +3 -3
- package/dist/test/locators.d.ts +1 -1
- package/dist/toolchain.d.ts +25 -0
- package/dist/toolchain.js +194 -0
- package/dist/toolchain.json +193 -0
- package/dist/tsconfig-BVHG3DpR.js +2 -0
- package/dist/{tsconfig-CVUKLfL8.js → tsconfig-LD2QhQ0O.js} +5 -4
- package/dist/tsgolint-path.js +1 -1
- package/dist/version.js +5 -4
- package/dist/versions.d.ts +3 -3
- package/dist/versions.js +6 -6
- package/docs/guide/ci.md +37 -4
- package/docs/guide/commit-hooks.md +87 -14
- package/docs/guide/create.md +7 -4
- package/docs/guide/env.md +20 -6
- package/docs/guide/fmt.md +2 -2
- package/docs/guide/github-actions-cache.md +5 -1
- package/docs/guide/ide-integration.md +61 -2
- package/docs/guide/index.md +3 -1
- package/docs/guide/install.md +27 -1
- package/docs/guide/installer-env-vars.md +53 -6
- package/docs/guide/lint.md +3 -1
- package/docs/guide/migrate-rules.md +9 -0
- package/docs/guide/migrate.md +41 -4
- package/docs/guide/monorepo.md +4 -4
- package/docs/guide/test.md +8 -0
- package/docs/guide/troubleshooting.md +12 -4
- package/docs/guide/upgrade.md +75 -5
- package/package.json +36 -33
- package/rules/vite-tools.yml +0 -7
- package/dist/dist-DT25H9pj.js +0 -3
- package/docs/_data/team.ts +0 -131
- package/docs/package.json +0 -30
- package/docs/pnpm-lock.yaml +0 -4003
- package/docs/pnpm-workspace.yaml +0 -6
- package/docs/public/checkmark.svg +0 -1
- package/docs/public/cta-background.jpg +0 -0
- package/docs/public/favicon.svg +0 -1
- package/docs/public/icon.svg +0 -1
- package/docs/public/logo.svg +0 -1
- package/docs/public/og.jpg +0 -0
- package/docs/vite.config.ts +0 -17
- package/dist/{log-update-CoW8Z4Dl.js → log-update-DHZRyJ2m.js} +1 -1
- package/dist/{tsgolint-path-eMZT-oea.js → tsgolint-path-CbDReEOx.js} +1 -1
package/binding/index.d.cts
CHANGED
|
@@ -174,6 +174,38 @@ export interface MangleOptionsKeepNames {
|
|
|
174
174
|
class: boolean;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
export interface ManglePropertiesOptions {
|
|
178
|
+
/**
|
|
179
|
+
* JavaScript `RegExp` selecting property names to mangle. The source and flags are compiled
|
|
180
|
+
* with Rust's regex engine. Flags `i`, `m`, `s`, and `u` are supported.
|
|
181
|
+
*/
|
|
182
|
+
include: RegExp;
|
|
183
|
+
/** JavaScript `RegExp` excluding property names selected by `include`. */
|
|
184
|
+
exclude?: RegExp;
|
|
185
|
+
/** Exact names that are neither mangled nor emitted as automatic output names. */
|
|
186
|
+
reserved?: Array<string>;
|
|
187
|
+
/**
|
|
188
|
+
* Mangle quoted property occurrences in addition to unquoted occurrences.
|
|
189
|
+
*
|
|
190
|
+
* @default false
|
|
191
|
+
*/
|
|
192
|
+
quoted?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Generate readable `_$name$_`-style output names.
|
|
195
|
+
*
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
debug?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Stable mappings from original names to output names. `false` reserves an original name.
|
|
201
|
+
* Entries that do not match `include`, or that match `exclude`, remain inert but are
|
|
202
|
+
* preserved in the returned `mangleCache`. String targets must be `IdentifierName` values
|
|
203
|
+
* other than `__proto__`, `constructor`, or `prototype`. The original name `__proto__` is
|
|
204
|
+
* always reserved and cannot be used as a cache key.
|
|
205
|
+
*/
|
|
206
|
+
cache?: Record<string, string | false>;
|
|
207
|
+
}
|
|
208
|
+
|
|
177
209
|
/**
|
|
178
210
|
* Minify asynchronously.
|
|
179
211
|
*
|
|
@@ -190,6 +222,12 @@ export interface MinifyOptions {
|
|
|
190
222
|
module?: boolean;
|
|
191
223
|
compress?: boolean | CompressOptions;
|
|
192
224
|
mangle?: boolean | MangleOptions;
|
|
225
|
+
/**
|
|
226
|
+
* Mangle matching property names independently of identifier mangling. Properties owned by
|
|
227
|
+
* unminified code, imported module namespaces, globals, or host APIs must be excluded or
|
|
228
|
+
* reserved.
|
|
229
|
+
*/
|
|
230
|
+
mangleProps?: ManglePropertiesOptions;
|
|
193
231
|
codegen?: boolean | CodegenOptions;
|
|
194
232
|
sourcemap?: boolean;
|
|
195
233
|
}
|
|
@@ -203,6 +241,11 @@ export interface MinifyResult {
|
|
|
203
241
|
* Only populated when `codegen.legalComments` is `"linked"` or `"external"`.
|
|
204
242
|
*/
|
|
205
243
|
legalComments: Array<string>;
|
|
244
|
+
/**
|
|
245
|
+
* Updated property-name cache sorted by original name. Present when `mangleProps` ran on a
|
|
246
|
+
* parse without errors.
|
|
247
|
+
*/
|
|
248
|
+
mangleCache?: Record<string, string | false>;
|
|
206
249
|
}
|
|
207
250
|
|
|
208
251
|
/** Minify synchronously. */
|
|
@@ -2063,6 +2106,7 @@ export interface BindingChecksOptions {
|
|
|
2063
2106
|
ineffectiveDynamicImport?: boolean;
|
|
2064
2107
|
largeBarrelModules?: boolean;
|
|
2065
2108
|
sourcemapBroken?: boolean;
|
|
2109
|
+
namespaceConflict?: boolean;
|
|
2066
2110
|
}
|
|
2067
2111
|
|
|
2068
2112
|
export interface BindingChunkImportMap {
|
|
@@ -2682,6 +2726,22 @@ export interface BindingModuleSideEffectsRule {
|
|
|
2682
2726
|
external?: boolean;
|
|
2683
2727
|
}
|
|
2684
2728
|
|
|
2729
|
+
/**
|
|
2730
|
+
* Counters of the Rust-side tracking allocator. V8 never allocates through
|
|
2731
|
+
* the Rust global allocator, so these numbers exclude the JS heap and GC
|
|
2732
|
+
* noise completely, unlike `process.memoryUsage()`.
|
|
2733
|
+
*/
|
|
2734
|
+
export interface BindingNativeMemoryStats {
|
|
2735
|
+
/** Bytes currently allocated and not yet freed, since process start. */
|
|
2736
|
+
liveBytes: number;
|
|
2737
|
+
/** Highest `live_bytes` seen since process start or the last reset. */
|
|
2738
|
+
peakBytes: number;
|
|
2739
|
+
/** Successful `alloc` calls since the last reset. */
|
|
2740
|
+
allocCount: number;
|
|
2741
|
+
/** Successful `realloc` calls since the last reset. */
|
|
2742
|
+
reallocCount: number;
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2685
2745
|
export interface BindingOptimization {
|
|
2686
2746
|
inlineConst?: boolean | BindingInlineConstConfig;
|
|
2687
2747
|
pifeForModuleWrappers?: boolean;
|
|
@@ -3268,6 +3328,13 @@ export declare const enum FilterTokenKind {
|
|
|
3268
3328
|
QueryValue = 'QueryValue',
|
|
3269
3329
|
}
|
|
3270
3330
|
|
|
3331
|
+
/**
|
|
3332
|
+
* Returns the Rust-side allocator counters, or `None` when this binding was
|
|
3333
|
+
* built without the `tracking_allocator` cargo feature (the default —
|
|
3334
|
+
* tracking costs a few atomic operations per allocation).
|
|
3335
|
+
*/
|
|
3336
|
+
export declare function getNativeMemoryStats(): BindingNativeMemoryStats | null;
|
|
3337
|
+
|
|
3271
3338
|
export declare function initTraceSubscriber(): TraceSubscriberGuard | null;
|
|
3272
3339
|
|
|
3273
3340
|
export interface JsChangedOutputs {
|
|
@@ -3330,6 +3397,13 @@ export interface PreRenderedChunk {
|
|
|
3330
3397
|
|
|
3331
3398
|
export declare function registerPlugins(id: number, plugins: Array<BindingPluginWithIndex>): void;
|
|
3332
3399
|
|
|
3400
|
+
/**
|
|
3401
|
+
* Starts a new measuring window: the peak restarts from the current live
|
|
3402
|
+
* bytes and the counts restart from zero. No-op when the binding was built
|
|
3403
|
+
* without the `tracking_allocator` cargo feature.
|
|
3404
|
+
*/
|
|
3405
|
+
export declare function resetNativeMemoryStats(): void;
|
|
3406
|
+
|
|
3333
3407
|
export declare function resolveTsconfig(
|
|
3334
3408
|
filename: string,
|
|
3335
3409
|
cache: TsconfigCache | undefined | null,
|
|
@@ -3377,8 +3451,14 @@ export interface CliOptions {
|
|
|
3377
3451
|
pack: (err: Error | null) => Promise<JsCommandResolvedResult>;
|
|
3378
3452
|
doc: (err: Error | null) => Promise<JsCommandResolvedResult>;
|
|
3379
3453
|
cwd?: string;
|
|
3454
|
+
/** Whether the user supplied the global `-C` option. */
|
|
3455
|
+
explicitChdir?: boolean;
|
|
3380
3456
|
/** CLI arguments (should be process.argv.slice(2) from JavaScript) */
|
|
3381
3457
|
args?: Array<string>;
|
|
3458
|
+
/** Generated toolchain manifest shipped with this vite-plus package. */
|
|
3459
|
+
toolchainManifestPath: string;
|
|
3460
|
+
/** Root directory of this vite-plus package. */
|
|
3461
|
+
vitePlusPackagePath: string;
|
|
3382
3462
|
/** Read the vite.config.ts in the Node.js side and return the `lint` and `fmt` config JSON string back to the Rust side */
|
|
3383
3463
|
resolveUniversalViteConfig: (err: Error | null, arg: string) => Promise<string>;
|
|
3384
3464
|
}
|
|
@@ -3471,6 +3551,14 @@ export interface DownloadPackageManagerResult {
|
|
|
3471
3551
|
/** Re-enable blocking stdio after Node.js has initialized its lazy standard streams. */
|
|
3472
3552
|
export declare function ensureBlockingStdio(): void;
|
|
3473
3553
|
|
|
3554
|
+
/**
|
|
3555
|
+
* Resolved on-disk category roots from [`vp_shared::EnvConfig`].
|
|
3556
|
+
*
|
|
3557
|
+
* JavaScript must not read `VP_HOME` / `VP_*_DIR` / `XDG_*` itself;
|
|
3558
|
+
* this is the JS surface of the same `EnvConfig::get().dirs` Rust uses.
|
|
3559
|
+
*/
|
|
3560
|
+
export declare function getVpDirs(): VpDirsJs;
|
|
3561
|
+
|
|
3474
3562
|
/**
|
|
3475
3563
|
* Whether `config_key` is already declared as a top-level property in the
|
|
3476
3564
|
* vite config's `defineConfig({...})` (or equivalent) object literal.
|
|
@@ -3664,7 +3752,7 @@ export declare function rewriteScripts(scriptsJson: string, rulesYaml: string):
|
|
|
3664
3752
|
* Main entry point for the CLI, called from JavaScript.
|
|
3665
3753
|
*
|
|
3666
3754
|
* This is an async function that spawns a new thread for the non-Send async code
|
|
3667
|
-
* from
|
|
3755
|
+
* from vt, while allowing the NAPI async context to continue running
|
|
3668
3756
|
* and process JavaScript callbacks (via ThreadsafeFunction).
|
|
3669
3757
|
*/
|
|
3670
3758
|
export declare function run(options: CliOptions): Promise<number>;
|
|
@@ -3672,7 +3760,7 @@ export declare function run(options: CliOptions): Promise<number>;
|
|
|
3672
3760
|
/**
|
|
3673
3761
|
* Run a command with fspy tracking, callable from JavaScript.
|
|
3674
3762
|
*
|
|
3675
|
-
* This function wraps `
|
|
3763
|
+
* This function wraps `vp_command::run_command_with_fspy` to provide
|
|
3676
3764
|
* a JavaScript-friendly interface for executing commands and tracking
|
|
3677
3765
|
* their file system accesses.
|
|
3678
3766
|
*
|
|
@@ -3742,7 +3830,7 @@ export interface RunCommandResult {
|
|
|
3742
3830
|
/**
|
|
3743
3831
|
* Whether the Vite+ banner should be emitted in the current environment.
|
|
3744
3832
|
*
|
|
3745
|
-
* Mirrors `
|
|
3833
|
+
* Mirrors `vp_shared::header::should_print_header` so both CLIs apply
|
|
3746
3834
|
* the same TTY + git-hook gating without duplicating the rules in JS.
|
|
3747
3835
|
*/
|
|
3748
3836
|
export declare function shouldPrintVitePlusHeader(): boolean;
|
|
@@ -3789,6 +3877,15 @@ export declare function upsertJsonConfig(
|
|
|
3789
3877
|
/** Render the Vite+ header using the Rust implementation. */
|
|
3790
3878
|
export declare function vitePlusHeader(): string;
|
|
3791
3879
|
|
|
3880
|
+
/** Resolved on-disk category roots from [`vp_shared::EnvConfig`]. */
|
|
3881
|
+
export interface VpDirsJs {
|
|
3882
|
+
bin: string;
|
|
3883
|
+
data: string;
|
|
3884
|
+
cache: string;
|
|
3885
|
+
config: string;
|
|
3886
|
+
state: string;
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3792
3889
|
/**
|
|
3793
3890
|
* Wrap safe inline `plugins: [...]` arrays in recognized Vite config objects
|
|
3794
3891
|
* with `lazyPlugins(() => [...])` and add a `lazyPlugins` import from
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { A as isCancel, C as log, E as select, w as multiselect } from "./prompts-
|
|
2
|
-
import path
|
|
1
|
+
import { A as isCancel, C as log, E as select, w as multiselect } from "./prompts-DF3yU-eU.js";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
|
-
import fs
|
|
4
|
+
import fs from "node:fs";
|
|
5
5
|
import fsPromises from "node:fs/promises";
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
7
6
|
//#region src/utils/path.ts
|
|
8
7
|
function findPkgRoot() {
|
|
9
8
|
let dir = import.meta.dirname;
|
|
@@ -20,189 +19,6 @@ function displayRelative(to, from = process.cwd()) {
|
|
|
20
19
|
return path.relative(from, to).replaceAll("\\", "/");
|
|
21
20
|
}
|
|
22
21
|
//#endregion
|
|
23
|
-
//#region src/config/hooks.ts
|
|
24
|
-
const SUPPORTED_GIT_HOOK_NAMES = [
|
|
25
|
-
"pre-commit",
|
|
26
|
-
"pre-merge-commit",
|
|
27
|
-
"prepare-commit-msg",
|
|
28
|
-
"commit-msg",
|
|
29
|
-
"post-commit",
|
|
30
|
-
"applypatch-msg",
|
|
31
|
-
"pre-applypatch",
|
|
32
|
-
"post-applypatch",
|
|
33
|
-
"pre-rebase",
|
|
34
|
-
"post-rewrite",
|
|
35
|
-
"post-checkout",
|
|
36
|
-
"post-merge",
|
|
37
|
-
"pre-push",
|
|
38
|
-
"pre-auto-gc"
|
|
39
|
-
];
|
|
40
|
-
function nestedDirname(depth) {
|
|
41
|
-
let expr = "\"$0\"";
|
|
42
|
-
for (let i = 0; i < depth; i++) expr = `"$(dirname ${expr})"`;
|
|
43
|
-
return expr;
|
|
44
|
-
}
|
|
45
|
-
function hookScript(dir) {
|
|
46
|
-
const separators = process.platform === "win32" ? /[\\/]/ : /\//;
|
|
47
|
-
return `#!/usr/bin/env sh
|
|
48
|
-
{ [ "$HUSKY" = "2" ] || [ "$VP_GIT_HOOKS" = "2" ] || [ "$VITE_GIT_HOOKS" = "2" ]; } && set -x
|
|
49
|
-
n=$(basename "$0")
|
|
50
|
-
s=$(dirname "$(dirname "$0")")/$n
|
|
51
|
-
|
|
52
|
-
[ ! -f "$s" ] && exit 0
|
|
53
|
-
|
|
54
|
-
i="\${XDG_CONFIG_HOME:-$HOME/.config}/vite-plus/hooks-init.sh"
|
|
55
|
-
[ ! -f "$i" ] && i="\${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh"
|
|
56
|
-
[ -f "$i" ] && . "$i"
|
|
57
|
-
|
|
58
|
-
{ [ "\${HUSKY-}" = "0" ] || [ "\${VP_GIT_HOOKS-}" = "0" ] || [ "\${VITE_GIT_HOOKS-}" = "0" ]; } && exit 0
|
|
59
|
-
|
|
60
|
-
d=${nestedDirname(dir.split(separators).filter((s) => s !== "" && s !== ".").length + 2)}
|
|
61
|
-
__vp_shell=/bin/sh
|
|
62
|
-
[ -x "$__vp_shell" ] || __vp_shell=$(command -v sh)
|
|
63
|
-
|
|
64
|
-
if [ -n "\${VP_HOME-}" ]; then
|
|
65
|
-
__vp_bin="$VP_HOME/bin"
|
|
66
|
-
elif [ -n "\${HOME-}" ]; then
|
|
67
|
-
__vp_bin="$HOME/.vite-plus/bin"
|
|
68
|
-
else
|
|
69
|
-
__vp_bin=""
|
|
70
|
-
fi
|
|
71
|
-
[ -n "$__vp_bin" ] && [ -d "$__vp_bin" ] && export PATH="$PATH:$__vp_bin"
|
|
72
|
-
|
|
73
|
-
export PATH="$d/node_modules/.bin:$PATH"
|
|
74
|
-
"$__vp_shell" -e "$s" "$@"
|
|
75
|
-
c=$?
|
|
76
|
-
|
|
77
|
-
[ $c != 0 ] && echo "VITE+ - $n script failed (code $c)"
|
|
78
|
-
[ $c = 127 ] && echo "VITE+ - command not found in PATH=$PATH"
|
|
79
|
-
exit $c`;
|
|
80
|
-
}
|
|
81
|
-
function normalizeHooksPath(hooksPath) {
|
|
82
|
-
let normalized = normalize(hooksPath);
|
|
83
|
-
while (normalized.endsWith(sep)) normalized = normalized.slice(0, -1);
|
|
84
|
-
return normalized;
|
|
85
|
-
}
|
|
86
|
-
function findUnsafeHookInstallPath(root, dir) {
|
|
87
|
-
const projectRoot = resolve(root);
|
|
88
|
-
const internalPath = resolve(projectRoot, dir, "_");
|
|
89
|
-
const relativeInternalPath = relative(projectRoot, internalPath);
|
|
90
|
-
let currentPath = projectRoot;
|
|
91
|
-
for (const component of relativeInternalPath.split(sep).filter(Boolean)) {
|
|
92
|
-
currentPath = join(currentPath, component);
|
|
93
|
-
const stats = lstatSync(currentPath, { throwIfNoEntry: false });
|
|
94
|
-
if (!stats) return null;
|
|
95
|
-
if (stats.isSymbolicLink()) return {
|
|
96
|
-
kind: "symbolic",
|
|
97
|
-
relativePath: relative(projectRoot, currentPath)
|
|
98
|
-
};
|
|
99
|
-
if (!stats.isDirectory()) return {
|
|
100
|
-
kind: "not-directory",
|
|
101
|
-
relativePath: relative(projectRoot, currentPath)
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
for (const filename of [
|
|
105
|
-
"husky.sh",
|
|
106
|
-
".gitignore",
|
|
107
|
-
"h",
|
|
108
|
-
...SUPPORTED_GIT_HOOK_NAMES
|
|
109
|
-
]) {
|
|
110
|
-
const filePath = join(internalPath, filename);
|
|
111
|
-
const stats = lstatSync(filePath, { throwIfNoEntry: false });
|
|
112
|
-
if (!stats) continue;
|
|
113
|
-
if (stats.isSymbolicLink()) return {
|
|
114
|
-
kind: "symbolic",
|
|
115
|
-
relativePath: relative(projectRoot, filePath)
|
|
116
|
-
};
|
|
117
|
-
if (!stats.isFile()) return {
|
|
118
|
-
kind: "not-file",
|
|
119
|
-
relativePath: relative(projectRoot, filePath)
|
|
120
|
-
};
|
|
121
|
-
if (stats.nlink > 1) return {
|
|
122
|
-
kind: "linked",
|
|
123
|
-
relativePath: relative(projectRoot, filePath)
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
function describeUnsafeHookInstallPath(unsafePath) {
|
|
129
|
-
if (unsafePath.kind === "symbolic") return `symbolic hook path "${unsafePath.relativePath}" not allowed`;
|
|
130
|
-
if (unsafePath.kind === "linked") return `multiply linked hook path "${unsafePath.relativePath}" not allowed`;
|
|
131
|
-
if (unsafePath.kind === "not-directory") return `hook path "${unsafePath.relativePath}" is not a directory`;
|
|
132
|
-
return `hook path "${unsafePath.relativePath}" is not a file`;
|
|
133
|
-
}
|
|
134
|
-
function install(dir = ".vite-hooks") {
|
|
135
|
-
if (process.env.HUSKY === "0" || process.env.VP_GIT_HOOKS === "0" || process.env.VITE_GIT_HOOKS === "0") return {
|
|
136
|
-
message: "skip install (git hooks disabled)",
|
|
137
|
-
isError: false
|
|
138
|
-
};
|
|
139
|
-
if (dir.includes("..")) return {
|
|
140
|
-
message: ".. not allowed",
|
|
141
|
-
isError: false
|
|
142
|
-
};
|
|
143
|
-
if (isAbsolute(dir)) return {
|
|
144
|
-
message: "absolute hooks directory not allowed",
|
|
145
|
-
isError: false
|
|
146
|
-
};
|
|
147
|
-
if (relative(process.cwd(), resolve(process.cwd(), dir)) === "") return {
|
|
148
|
-
message: "hooks directory must be a project subdirectory",
|
|
149
|
-
isError: false
|
|
150
|
-
};
|
|
151
|
-
const unsafeInstallPath = findUnsafeHookInstallPath(process.cwd(), dir);
|
|
152
|
-
if (unsafeInstallPath) return {
|
|
153
|
-
message: describeUnsafeHookInstallPath(unsafeInstallPath),
|
|
154
|
-
isError: false
|
|
155
|
-
};
|
|
156
|
-
const prefixResult = spawnSync("git", ["rev-parse", "--show-prefix"]);
|
|
157
|
-
if (prefixResult.status == null) return {
|
|
158
|
-
message: "git command not found",
|
|
159
|
-
isError: true
|
|
160
|
-
};
|
|
161
|
-
if (prefixResult.status !== 0) return {
|
|
162
|
-
message: ".git can't be found",
|
|
163
|
-
isError: false
|
|
164
|
-
};
|
|
165
|
-
const internal = (x = "") => join(dir, "_", x);
|
|
166
|
-
const rel = prefixResult.stdout.toString().trim().replace(/\/$/, "");
|
|
167
|
-
const target = rel ? `${rel}/${dir}/_` : `${dir}/_`;
|
|
168
|
-
const checkResult = spawnSync("git", [
|
|
169
|
-
"config",
|
|
170
|
-
"--get",
|
|
171
|
-
"core.hooksPath"
|
|
172
|
-
]);
|
|
173
|
-
const existingHooksPath = checkResult.status === 0 ? checkResult.stdout?.toString().trim() : "";
|
|
174
|
-
if (existingHooksPath && normalizeHooksPath(existingHooksPath) !== normalizeHooksPath(target)) return {
|
|
175
|
-
message: `core.hooksPath is already set to "${existingHooksPath}", skipping`,
|
|
176
|
-
isError: false
|
|
177
|
-
};
|
|
178
|
-
rmSync(internal("husky.sh"), { force: true });
|
|
179
|
-
mkdirSync(internal(), { recursive: true });
|
|
180
|
-
writeFileSync(internal(".gitignore"), "*");
|
|
181
|
-
writeFileSync(internal("h"), hookScript(dir), { mode: 493 });
|
|
182
|
-
chmodSync(internal("h"), 493);
|
|
183
|
-
for (const hook of SUPPORTED_GIT_HOOK_NAMES) {
|
|
184
|
-
writeFileSync(internal(hook), `#!/usr/bin/env sh\n. "$(dirname "$0")/h"`, { mode: 493 });
|
|
185
|
-
chmodSync(internal(hook), 493);
|
|
186
|
-
}
|
|
187
|
-
const { status, stderr } = spawnSync("git", [
|
|
188
|
-
"config",
|
|
189
|
-
"core.hooksPath",
|
|
190
|
-
target
|
|
191
|
-
]);
|
|
192
|
-
if (status == null) return {
|
|
193
|
-
message: "git command not found",
|
|
194
|
-
isError: true
|
|
195
|
-
};
|
|
196
|
-
if (status) return {
|
|
197
|
-
message: "" + stderr,
|
|
198
|
-
isError: true
|
|
199
|
-
};
|
|
200
|
-
return {
|
|
201
|
-
message: "",
|
|
202
|
-
isError: false
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
//#endregion
|
|
206
22
|
//#region src/utils/agent.ts
|
|
207
23
|
const AGENTS = [
|
|
208
24
|
{
|
|
@@ -597,4 +413,4 @@ function getMarkedRange(content, startMarker, endMarker) {
|
|
|
597
413
|
};
|
|
598
414
|
}
|
|
599
415
|
//#endregion
|
|
600
|
-
export { selectAgentTargets as a, writeCopilotSetupWorkflow as c,
|
|
416
|
+
export { selectAgentTargets as a, writeCopilotSetupWorkflow as c, templatesDir as d, selectAgentTargetPaths as i, displayRelative as l, detectAgentConflicts as n, updateExistingAgentInstructions as o, detectExistingAgentTargetPaths as r, writeAgentInstructions as s, COPILOT_AGENT_ID as t, rulesDir as u };
|