vite-plus 0.1.8 → 0.1.9

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.
@@ -1,9 +1,9 @@
1
- import { type AgentConfig } from '../utils/agent.js';
1
+ import { hasExistingAgentInstructions, type AgentConfig } from '../utils/agent.js';
2
2
  export interface AgentSetupSelection {
3
3
  instructionFilePath: 'CLAUDE.md' | 'AGENTS.md';
4
4
  agents: AgentConfig[];
5
5
  }
6
6
  export declare function resolveAgentSetup(root: string, interactive: boolean): Promise<AgentSetupSelection>;
7
- export declare function hasExistingAgentInstructions(root: string): boolean;
7
+ export { hasExistingAgentInstructions };
8
8
  export declare function injectAgentBlock(root: string, filePath: string): void;
9
9
  export declare function setupMcpConfig(root: string, selectedAgents: AgentConfig[]): void;
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import * as prompts from '@voidzero-dev/vite-plus-prompts';
4
- import { detectAgents, getAgentById, } from '../utils/agent.js';
4
+ import { detectAgents, getAgentById, hasExistingAgentInstructions, replaceMarkedAgentInstructionsSection, } from '../utils/agent.js';
5
5
  import { writeJsonFile, readJsonFile } from '../utils/json.js';
6
6
  import { pkgRoot } from '../utils/path.js';
7
7
  function detectInstructionFilePath(root, agentConfigs) {
@@ -56,69 +56,36 @@ export async function resolveAgentSetup(root, interactive) {
56
56
  }
57
57
  return pickAgentWhenUndetected();
58
58
  }
59
- // --- Version and template reading ---
60
- function getOwnVersion() {
61
- const pkg = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf-8'));
62
- if (typeof pkg.version !== 'string') {
63
- throw new Error('vite-plus package.json is missing a "version" field');
64
- }
65
- return pkg.version;
66
- }
59
+ // --- Template reading ---
67
60
  function readAgentPrompt() {
68
61
  return readFileSync(join(pkgRoot, 'AGENTS.md'), 'utf-8');
69
62
  }
70
- // --- Versioned injection ---
71
- const MARKER_OPEN_RE = /<!--injected-by-vite-plus-v([\w.+-]+)-->/;
72
- const MARKER_CLOSE = '<!--/injected-by-vite-plus-->';
73
- const MARKER_BLOCK_RE = /<!--injected-by-vite-plus-v[\w.+-]+-->\n[\s\S]*?<!--\/injected-by-vite-plus-->/;
74
- export function hasExistingAgentInstructions(root) {
75
- for (const file of ['AGENTS.md', 'CLAUDE.md']) {
76
- const fullPath = join(root, file);
77
- if (existsSync(fullPath)) {
78
- const content = readFileSync(fullPath, 'utf-8');
79
- if (MARKER_OPEN_RE.test(content)) {
80
- return true;
81
- }
82
- }
83
- }
84
- return false;
85
- }
63
+ // --- Agent instructions injection ---
64
+ export { hasExistingAgentInstructions };
86
65
  export function injectAgentBlock(root, filePath) {
87
66
  const fullPath = join(root, filePath);
88
- const version = getOwnVersion();
89
- const promptContent = readAgentPrompt();
90
- const openMarker = `<!--injected-by-vite-plus-v${version}-->`;
91
- const block = `${openMarker}\n${promptContent}\n${MARKER_CLOSE}`;
67
+ const template = readAgentPrompt();
92
68
  if (existsSync(fullPath)) {
93
69
  const existing = readFileSync(fullPath, 'utf-8');
94
- const match = existing.match(MARKER_OPEN_RE);
95
- if (match) {
96
- if (match[1] === version) {
97
- prompts.log.info(`${filePath} already has Vite+ instructions (v${version})`);
98
- return;
99
- }
100
- // Replace existing block with updated version
101
- const updated = existing.replace(MARKER_BLOCK_RE, block);
102
- if (updated === existing) {
103
- // Closing marker is missing or malformed — append fresh block
104
- const separator = existing.endsWith('\n') ? '\n' : '\n\n';
105
- writeFileSync(fullPath, existing + separator + block + '\n');
106
- prompts.log.warn(`Existing Vite+ block in ${filePath} was malformed; appended fresh block`);
70
+ const updated = replaceMarkedAgentInstructionsSection(existing, template);
71
+ if (updated !== undefined) {
72
+ if (updated !== existing) {
73
+ writeFileSync(fullPath, updated);
74
+ prompts.log.success(`Updated Vite+ instructions in ${filePath}`);
107
75
  }
108
76
  else {
109
- writeFileSync(fullPath, updated);
110
- prompts.log.success(`Updated Vite+ instructions in ${filePath} (v${match[1]} → v${version})`);
77
+ prompts.log.info(`${filePath} already has up-to-date Vite+ instructions`);
111
78
  }
112
79
  }
113
80
  else {
114
- // Append block to end of file
81
+ // No markers found append template
115
82
  const separator = existing.endsWith('\n') ? '\n' : '\n\n';
116
- writeFileSync(fullPath, existing + separator + block + '\n');
83
+ writeFileSync(fullPath, existing + separator + template);
117
84
  prompts.log.success(`Added Vite+ instructions to ${filePath}`);
118
85
  }
119
86
  }
120
87
  else {
121
- writeFileSync(fullPath, block + '\n');
88
+ writeFileSync(fullPath, template);
122
89
  prompts.log.success(`Created ${filePath} with Vite+ instructions`);
123
90
  }
124
91
  }
@@ -1986,6 +1986,12 @@ function detectExistingAgentTargetPaths(projectRoot) {
1986
1986
  }
1987
1987
  return detectedPaths.length > 0 ? detectedPaths : void 0;
1988
1988
  }
1989
+ function hasExistingAgentInstructions(projectRoot) {
1990
+ const targetPaths = detectExistingAgentTargetPaths(projectRoot);
1991
+ if (!targetPaths) return false;
1992
+ for (const targetPath of targetPaths) if (fs.readFileSync(path.join(projectRoot, targetPath), "utf-8").includes(AGENT_INSTRUCTIONS_START_MARKER)) return true;
1993
+ return false;
1994
+ }
1989
1995
  function resolveAgentTargetPaths(agent) {
1990
1996
  const agentNames = parseAgentNames(agent);
1991
1997
  const resolvedAgentNames = agentNames.length > 0 ? agentNames : ["other"];
@@ -2165,4 +2171,4 @@ function getMarkedRange(content, startMarker, endMarker) {
2165
2171
  };
2166
2172
  }
2167
2173
  //#endregion
2168
- export { select as A, cancel as C, multiselect as D, log as E, text as M, Ct as N, note as O, PackageManager as S, intro as T, pkgRoot as _, selectAgentTargetPaths as a, runCommandSilently as b, defaultInteractive as c, promptGitHooks as d, runViteFmt as f, displayRelative as g, upgradeYarn as h, getAgentById as i, spinner as j, outro as k, downloadPackageManager$1 as l, selectPackageManager as m, detectAgents as n, writeAgentInstructions as o, runViteInstall as p, detectExistingAgentTargetPaths as r, cancelAndExit as s, detectAgentConflicts as t, getSpinner as u, rulesDir as v, confirm as w, DependencyType as x, templatesDir as y };
2174
+ export { note as A, DependencyType as C, intro as D, confirm as E, Ct as F, select as M, spinner as N, log as O, text as P, runCommandSilently as S, cancel as T, upgradeYarn as _, hasExistingAgentInstructions as a, rulesDir as b, writeAgentInstructions as c, downloadPackageManager$1 as d, getSpinner as f, selectPackageManager as g, runViteInstall as h, getAgentById as i, outro as j, multiselect as k, cancelAndExit as l, runViteFmt as m, detectAgents as n, replaceMarkedAgentInstructionsSection as o, promptGitHooks as p, detectExistingAgentTargetPaths as r, selectAgentTargetPaths as s, detectAgentConflicts as t, defaultInteractive as u, displayRelative as v, PackageManager as w, templatesDir as x, pkgRoot as y };
@@ -1,4 +1,4 @@
1
- import { A as select, C as cancel, E as log, N as Ct, O as note, _ as pkgRoot, c as defaultInteractive, d as promptGitHooks, i as getAgentById, n as detectAgents } from "./agent-CA64n2mH.js";
1
+ import { A as note, F as Ct, M as select, O as log, T as cancel, a as hasExistingAgentInstructions, i as getAgentById, n as detectAgents, o as replaceMarkedAgentInstructionsSection, p as promptGitHooks, u as defaultInteractive, y as pkgRoot } from "./agent-D0WD4q4_.js";
2
2
  import { t as lib_default } from "./lib-DxappLRQ.js";
3
3
  import { i as writeJsonFile, r as readJsonFile, s as VITE_PLUS_NAME } from "./json-BRdVJ52a.js";
4
4
  import { i as log$1, t as renderCliDoc } from "./help-CbTzUdXc.js";
@@ -151,54 +151,25 @@ async function resolveAgentSetup(root, interactive) {
151
151
  };
152
152
  return pickAgentWhenUndetected();
153
153
  }
154
- function getOwnVersion() {
155
- const pkg = JSON.parse(readFileSync(join(pkgRoot, "package.json"), "utf-8"));
156
- if (typeof pkg.version !== "string") throw new Error("vite-plus package.json is missing a \"version\" field");
157
- return pkg.version;
158
- }
159
154
  function readAgentPrompt() {
160
155
  return readFileSync(join(pkgRoot, "AGENTS.md"), "utf-8");
161
156
  }
162
- const MARKER_OPEN_RE = /<!--injected-by-vite-plus-v([\w.+-]+)-->/;
163
- const MARKER_CLOSE = "<!--/injected-by-vite-plus-->";
164
- const MARKER_BLOCK_RE = /<!--injected-by-vite-plus-v[\w.+-]+-->\n[\s\S]*?<!--\/injected-by-vite-plus-->/;
165
- function hasExistingAgentInstructions(root) {
166
- for (const file of ["AGENTS.md", "CLAUDE.md"]) {
167
- const fullPath = join(root, file);
168
- if (existsSync(fullPath)) {
169
- const content = readFileSync(fullPath, "utf-8");
170
- if (MARKER_OPEN_RE.test(content)) return true;
171
- }
172
- }
173
- return false;
174
- }
175
157
  function injectAgentBlock(root, filePath) {
176
158
  const fullPath = join(root, filePath);
177
- const version = getOwnVersion();
178
- const promptContent = readAgentPrompt();
179
- const block = `${`<!--injected-by-vite-plus-v${version}-->`}\n${promptContent}\n${MARKER_CLOSE}`;
159
+ const template = readAgentPrompt();
180
160
  if (existsSync(fullPath)) {
181
161
  const existing = readFileSync(fullPath, "utf-8");
182
- const match = existing.match(MARKER_OPEN_RE);
183
- if (match) {
184
- if (match[1] === version) {
185
- log.info(`${filePath} already has Vite+ instructions (v${version})`);
186
- return;
187
- }
188
- const updated = existing.replace(MARKER_BLOCK_RE, block);
189
- if (updated === existing) {
190
- writeFileSync(fullPath, existing + (existing.endsWith("\n") ? "\n" : "\n\n") + block + "\n");
191
- log.warn(`Existing Vite+ block in ${filePath} was malformed; appended fresh block`);
192
- } else {
193
- writeFileSync(fullPath, updated);
194
- log.success(`Updated Vite+ instructions in ${filePath} (v${match[1]} → v${version})`);
195
- }
196
- } else {
197
- writeFileSync(fullPath, existing + (existing.endsWith("\n") ? "\n" : "\n\n") + block + "\n");
162
+ const updated = replaceMarkedAgentInstructionsSection(existing, template);
163
+ if (updated !== void 0) if (updated !== existing) {
164
+ writeFileSync(fullPath, updated);
165
+ log.success(`Updated Vite+ instructions in ${filePath}`);
166
+ } else log.info(`${filePath} already has up-to-date Vite+ instructions`);
167
+ else {
168
+ writeFileSync(fullPath, existing + (existing.endsWith("\n") ? "\n" : "\n\n") + template);
198
169
  log.success(`Added Vite+ instructions to ${filePath}`);
199
170
  }
200
171
  } else {
201
- writeFileSync(fullPath, block + "\n");
172
+ writeFileSync(fullPath, template);
202
173
  log.success(`Created ${filePath} with Vite+ instructions`);
203
174
  }
204
175
  }
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, t as __commonJSMin } from "./chunk-CgnkrU7a.js";
2
- import { A as select, C as cancel, D as multiselect, E as log, M as text, N as Ct, S as PackageManager, T as intro, a as selectAgentTargetPaths, c as defaultInteractive, d as promptGitHooks, f as runViteFmt, g as displayRelative, j as spinner, l as downloadPackageManager$1, m as selectPackageManager, o as writeAgentInstructions, p as runViteInstall, r as detectExistingAgentTargetPaths, w as confirm, x as DependencyType, y as templatesDir } from "./agent-CA64n2mH.js";
2
+ import { C as DependencyType, D as intro, E as confirm, F as Ct, M as select, N as spinner, O as log, P as text, T as cancel, c as writeAgentInstructions, d as downloadPackageManager$1, g as selectPackageManager, h as runViteInstall, k as multiselect, m as runViteFmt, p as promptGitHooks, r as detectExistingAgentTargetPaths, s as selectAgentTargetPaths, u as defaultInteractive, v as displayRelative, w as PackageManager, x as templatesDir } from "./agent-D0WD4q4_.js";
3
3
  import { t as lib_default } from "./lib-DxappLRQ.js";
4
- import { _ as rewriteMonorepo, a as detectExistingEditor, f as installGitHooks, n as updatePackageJsonWithDeps, o as selectEditor, r as updateWorkspaceConfig, s as writeEditorConfigs, t as detectWorkspace$1, v as rewriteMonorepoProject, y as rewriteStandaloneProject } from "./workspace-CpFQmwjZ.js";
4
+ import { _ as rewriteMonorepo, a as detectExistingEditor, f as installGitHooks, n as updatePackageJsonWithDeps, o as selectEditor, r as updateWorkspaceConfig, s as writeEditorConfigs, t as detectWorkspace$1, v as rewriteMonorepoProject, y as rewriteStandaloneProject } from "./workspace-ktWMiLVj.js";
5
5
  import "./browser-CBapUTD0.js";
6
6
  import { r as readJsonFile, t as editJsonFile } from "./json-BRdVJ52a.js";
7
7
  import "./package-YAMvX5PJ.js";
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM } from "./chunk-CgnkrU7a.js";
2
- import { A as select, E as log, N as Ct, S as PackageManager, a as selectAgentTargetPaths, c as defaultInteractive, d as promptGitHooks, g as displayRelative, h as upgradeYarn, j as spinner, k as outro, l as downloadPackageManager$1, m as selectPackageManager, o as writeAgentInstructions, p as runViteInstall, s as cancelAndExit, t as detectAgentConflicts, w as confirm } from "./agent-CA64n2mH.js";
2
+ import { E as confirm, F as Ct, M as select, N as spinner, O as log, _ as upgradeYarn, c as writeAgentInstructions, d as downloadPackageManager$1, g as selectPackageManager, h as runViteInstall, j as outro, l as cancelAndExit, p as promptGitHooks, s as selectAgentTargetPaths, t as detectAgentConflicts, u as defaultInteractive, v as displayRelative, w as PackageManager } from "./agent-D0WD4q4_.js";
3
3
  import { t as lib_default } from "./lib-DxappLRQ.js";
4
- import { _ as rewriteMonorepo, b as createMigrationReport, c as checkViteVersion, d as detectPrettierProject, f as installGitHooks, g as preflightGitHooksSetup, h as migratePrettierToOxfmt, i as detectEditorConflicts, l as checkVitestVersion, m as migrateEslintToOxlint, o as selectEditor, p as mergeViteConfigFiles, s as writeEditorConfigs, t as detectWorkspace$1, u as detectEslintProject, x as require_semver, y as rewriteStandaloneProject } from "./workspace-CpFQmwjZ.js";
4
+ import { _ as rewriteMonorepo, b as createMigrationReport, c as checkViteVersion, d as detectPrettierProject, f as installGitHooks, g as preflightGitHooksSetup, h as migratePrettierToOxfmt, i as detectEditorConflicts, l as checkVitestVersion, m as migrateEslintToOxlint, o as selectEditor, p as mergeViteConfigFiles, s as writeEditorConfigs, t as detectWorkspace$1, u as detectEslintProject, x as require_semver, y as rewriteStandaloneProject } from "./workspace-ktWMiLVj.js";
5
5
  import "./browser-CBapUTD0.js";
6
6
  import "./json-BRdVJ52a.js";
7
7
  import { i as readNearestPackageJson, r as hasVitePlusDependency } from "./package-YAMvX5PJ.js";
@@ -1,5 +1,5 @@
1
1
  import { i as __toESM, t as __commonJSMin } from "./chunk-CgnkrU7a.js";
2
- import { A as select, E as log, N as Ct, S as PackageManager, b as runCommandSilently, g as displayRelative, u as getSpinner, v as rulesDir } from "./agent-CA64n2mH.js";
2
+ import { F as Ct, M as select, O as log, S as runCommandSilently, b as rulesDir, f as getSpinner, v as displayRelative, w as PackageManager } from "./agent-D0WD4q4_.js";
3
3
  import { _ as YAMLMap, g as YAMLSeq, i as parseDocument, n as parse, y as Scalar } from "./browser-CBapUTD0.js";
4
4
  import { a as BASEURL_TSCONFIG_WARNING, c as VITE_PLUS_OVERRIDE_PACKAGES, i as writeJsonFile, l as VITE_PLUS_VERSION, n as isJsonFile, r as readJsonFile, s as VITE_PLUS_NAME, t as editJsonFile } from "./json-BRdVJ52a.js";
5
5
  import { n as getScopeFromPackageName, t as detectPackageMetadata } from "./package-YAMvX5PJ.js";
package/dist/pack-bin.js CHANGED
@@ -57,6 +57,7 @@ cli
57
57
  .option('--public-dir <dir>', 'Alias for --copy, deprecated')
58
58
  .option('--tsconfig <tsconfig>', 'Set tsconfig path')
59
59
  .option('--unbundle', 'Unbundle mode')
60
+ .option('--root <dir>', 'Root directory of input files')
60
61
  .option('--exe', 'Bundle as executable')
61
62
  .option('-W, --workspace [dir]', 'Enable workspace mode')
62
63
  .option('-F, --filter <pattern>', 'Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name')
@@ -82,4 +82,15 @@ export type RunConfig = {
82
82
  tasks?: {
83
83
  [key in string]?: Task;
84
84
  };
85
+ /**
86
+ * Whether to automatically run `preX`/`postX` package.json scripts as
87
+ * lifecycle hooks when script `X` is executed.
88
+ *
89
+ * When `true` (the default), running script `test` will automatically
90
+ * run `pretest` before and `posttest` after, if they exist.
91
+ *
92
+ * This option can only be set in the workspace root's config file.
93
+ * Setting it in a package's config will result in an error.
94
+ */
95
+ enablePrePostScripts?: boolean;
85
96
  };
@@ -63,6 +63,7 @@ export declare function selectAgentTargetPath({ interactive, agent, onCancel, }:
63
63
  }): Promise<string | undefined>;
64
64
  export declare function detectExistingAgentTargetPaths(projectRoot: string): string[] | undefined;
65
65
  export declare function detectExistingAgentTargetPath(projectRoot: string): string | undefined;
66
+ export declare function hasExistingAgentInstructions(projectRoot: string): boolean;
66
67
  export declare function resolveAgentTargetPaths(agent?: string | string[]): string[];
67
68
  export declare function resolveAgentTargetPath(agent?: string): string;
68
69
  export interface AgentConflictInfo {
@@ -203,6 +203,19 @@ export function detectExistingAgentTargetPaths(projectRoot) {
203
203
  export function detectExistingAgentTargetPath(projectRoot) {
204
204
  return detectExistingAgentTargetPaths(projectRoot)?.[0];
205
205
  }
206
+ export function hasExistingAgentInstructions(projectRoot) {
207
+ const targetPaths = detectExistingAgentTargetPaths(projectRoot);
208
+ if (!targetPaths) {
209
+ return false;
210
+ }
211
+ for (const targetPath of targetPaths) {
212
+ const content = fs.readFileSync(path.join(projectRoot, targetPath), 'utf-8');
213
+ if (content.includes(AGENT_INSTRUCTIONS_START_MARKER)) {
214
+ return true;
215
+ }
216
+ }
217
+ return false;
218
+ }
206
219
  export function resolveAgentTargetPaths(agent) {
207
220
  const agentNames = parseAgentNames(agent);
208
221
  const resolvedAgentNames = agentNames.length > 0 ? agentNames : ['other'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plus",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "oxfmt": "./bin/oxfmt",
@@ -297,12 +297,12 @@
297
297
  "@oxc-project/types": "=0.115.0",
298
298
  "cac": "^6.7.14",
299
299
  "cross-spawn": "^7.0.5",
300
- "oxfmt": "=0.39.0",
301
- "oxlint": "=1.54.0",
300
+ "oxfmt": "=0.40.0",
301
+ "oxlint": "=1.55.0",
302
302
  "oxlint-tsgolint": "=0.16.0",
303
303
  "picocolors": "^1.1.1",
304
- "@voidzero-dev/vite-plus-core": "0.1.8",
305
- "@voidzero-dev/vite-plus-test": "0.1.8"
304
+ "@voidzero-dev/vite-plus-core": "0.1.9",
305
+ "@voidzero-dev/vite-plus-test": "0.1.9"
306
306
  },
307
307
  "devDependencies": {
308
308
  "@napi-rs/cli": "^3.4.1",
@@ -323,9 +323,9 @@
323
323
  "tsdown": "^0.21.2",
324
324
  "validate-npm-package-name": "^7.0.2",
325
325
  "yaml": "^2.8.1",
326
- "@voidzero-dev/vite-plus-prompts": "0.0.0",
327
326
  "rolldown": "1.0.0-rc.9",
328
- "vite": "npm:@voidzero-dev/vite-plus-core@0.1.8"
327
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.1.9",
328
+ "@voidzero-dev/vite-plus-prompts": "0.0.0"
329
329
  },
330
330
  "napi": {
331
331
  "binaryName": "vite-plus",
@@ -343,12 +343,12 @@
343
343
  "node": "^20.19.0 || >=22.12.0"
344
344
  },
345
345
  "optionalDependencies": {
346
- "@voidzero-dev/vite-plus-darwin-arm64": "0.1.8",
347
- "@voidzero-dev/vite-plus-darwin-x64": "0.1.8",
348
- "@voidzero-dev/vite-plus-linux-arm64-gnu": "0.1.8",
349
- "@voidzero-dev/vite-plus-linux-x64-gnu": "0.1.8",
350
- "@voidzero-dev/vite-plus-win32-x64-msvc": "0.1.8",
351
- "@voidzero-dev/vite-plus-win32-arm64-msvc": "0.1.8"
346
+ "@voidzero-dev/vite-plus-darwin-arm64": "0.1.9",
347
+ "@voidzero-dev/vite-plus-darwin-x64": "0.1.9",
348
+ "@voidzero-dev/vite-plus-linux-arm64-gnu": "0.1.9",
349
+ "@voidzero-dev/vite-plus-linux-x64-gnu": "0.1.9",
350
+ "@voidzero-dev/vite-plus-win32-x64-msvc": "0.1.9",
351
+ "@voidzero-dev/vite-plus-win32-arm64-msvc": "0.1.9"
352
352
  },
353
353
  "scripts": {
354
354
  "build": "oxnode -C dev ./build.ts",