Skip to content

Commit 416f2e4

Browse files
committed
feat: Ship docs directly at vite-plus/docs.
1 parent fc96932 commit 416f2e4

10 files changed

Lines changed: 60 additions & 900 deletions

File tree

packages/cli/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/npm
22
/artifacts
33
/LICENSE
4-
/skills/vite-plus/docs
4+
/docs

packages/cli/AGENTS.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44

55
This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, and it invokes Vite through `vp dev` and `vp build`. Run `vp help` to print a list of commands and `vp <command> --help` for information about a specific command.
66

7-
## Common Pitfalls
8-
9-
- **Running scripts:** Vite+ built-in commands (`vp lint`, `vp dev`, `vp build`, `vp test`, etc.) always run the Vite+ built-in tool. Use `vp run <script>` to run `package.json` scripts or tasks defined in `vite.config.ts`
10-
- **Do not install Vitest, Oxlint, Oxfmt, or tsdown directly:** Vite+ wraps these tools. Do not install or upgrade them, use Vite+ directly.
11-
- **Import JavaScript modules from `vite-plus`:** Import modules from the `vite-plus` dependency, not from `vite` or `vitest`. For example, `import { defineConfig } from 'vite-plus';` or `import { expect, test, vi } from 'vite-plus/test';`. You must not install `vitest` to import test utilities.
7+
Docs are local at `node_modules/vite-plus/docs` or online at https://viteplus.dev/guide/.
128

139
## Review Checklist
1410

1511
- [ ] Run `vp install` after pulling remote changes and before getting started.
1612
- [ ] Run `vp check` and `vp test` to format, lint, type check and test changes.
17-
- [ ] Check if there are tasks or `package.json` scripts necessary for validation, run via `vp run <script>`.
13+
- [ ] Check if there are `vite.config.ts` tasks or `package.json` scripts necessary for validation, run via `vp run <script>`.
1814

19-
* Docs: https://viteplus.dev/guide/
2015
<!--VITE PLUS END-->

packages/cli/build.ts

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* 3. syncCorePackageExports() - Creates shim files to re-export from @voidzero-dev/vite-plus-core
88
* 4. syncTestPackageExports() - Creates shim files to re-export from @voidzero-dev/vite-plus-test
99
* 5. syncVersionsExport() - Generates ./versions module with bundled tool versions
10-
* 6. copySkillDocs() - Copies docs into skills/vite-plus/docs for runtime MCP access
10+
* 6. copyBundledDocs() - Copies docs into docs/ for bundled package access
1111
* 7. syncReadmeFromRoot() - Keeps package README in sync
1212
*
1313
* The sync functions allow this package to be a drop-in replacement for 'vite' by
@@ -19,7 +19,7 @@
1919
*/
2020

2121
import { execSync } from 'node:child_process';
22-
import { existsSync, globSync, readdirSync, statSync } from 'node:fs';
22+
import { existsSync, readdirSync, statSync } from 'node:fs';
2323
import { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
2424
import { dirname, join } from 'node:path';
2525
import { fileURLToPath } from 'node:url';
@@ -74,7 +74,7 @@ if (!skipTs) {
7474
await syncTestPackageExports();
7575
await syncVersionsExport();
7676
}
77-
await copySkillDocs();
77+
await copyBundledDocs();
7878
await syncReadmeFromRoot();
7979

8080
async function buildNapiBinding() {
@@ -387,42 +387,27 @@ async function syncVersionsExport() {
387387
}
388388

389389
/**
390-
* Copy markdown doc files from the monorepo docs/ directory into skills/vite-plus/docs/,
391-
* preserving the relative directory structure. This keeps stable file paths for
392-
* skills routing and MCP page slugs.
390+
* Copy the docs source tree into docs/, preserving relative paths.
391+
* Generated VitePress output and installed dependencies are excluded so the package
392+
* only ships authoring sources and referenced assets.
393393
*/
394-
async function copySkillDocs() {
395-
console.log('\nCopying skill docs...');
394+
async function copyBundledDocs() {
395+
console.log('\nCopying bundled docs...');
396396

397397
const docsSourceDir = join(projectDir, '..', '..', 'docs');
398-
const docsTargetDir = join(projectDir, 'skills', 'vite-plus', 'docs');
398+
const docsTargetDir = join(projectDir, 'docs');
399399

400400
if (!existsSync(docsSourceDir)) {
401-
console.log(' Docs source directory not found, skipping skill docs copy');
401+
console.log(' Docs source directory not found, skipping docs copy');
402402
return;
403403
}
404404

405405
// Clean and recreate target directory
406406
await rm(docsTargetDir, { recursive: true, force: true });
407407
await mkdir(docsTargetDir, { recursive: true });
408408

409-
// Find all markdown files recursively and copy them with their relative paths.
410-
const mdFiles = globSync('**/*.md', { cwd: docsSourceDir }).filter(
411-
(f) => !f.includes('node_modules') && f !== 'index.md',
412-
);
413-
// eslint-disable-next-line unicorn/no-array-sort -- sorted traversal keeps output deterministic
414-
mdFiles.sort();
415-
416-
let copied = 0;
417-
for (const relPath of mdFiles) {
418-
const sourcePath = join(docsSourceDir, relPath);
419-
const targetPath = join(docsTargetDir, relPath);
420-
await mkdir(dirname(targetPath), { recursive: true });
421-
await copyFile(sourcePath, targetPath);
422-
copied++;
423-
}
424-
425-
console.log(` Copied ${copied} doc files to skills/vite-plus/docs/ (with paths preserved)`);
409+
const copied = await copyDocsTree(docsSourceDir, docsTargetDir);
410+
console.log(` Copied ${copied} docs files to docs/ (with paths preserved)`);
426411
}
427412

428413
async function syncReadmeFromRoot() {
@@ -460,6 +445,49 @@ function splitReadme(content: string, label: string) {
460445
};
461446
}
462447

448+
async function copyDocsTree(
449+
docsSourceDir: string,
450+
docsTargetDir: string,
451+
relativePath = '',
452+
): Promise<number> {
453+
let copied = 0;
454+
const currentDir = join(docsSourceDir, relativePath);
455+
456+
for (const entry of readdirSync(currentDir, { withFileTypes: true })) {
457+
const entryRelPath = relativePath ? join(relativePath, entry.name) : entry.name;
458+
const normalizedPath = entryRelPath.replaceAll('\\', '/');
459+
460+
if (shouldSkipDocsPath(normalizedPath)) {
461+
continue;
462+
}
463+
464+
const sourcePath = join(docsSourceDir, entryRelPath);
465+
const targetPath = join(docsTargetDir, entryRelPath);
466+
467+
if (entry.isDirectory()) {
468+
await mkdir(targetPath, { recursive: true });
469+
copied += await copyDocsTree(docsSourceDir, docsTargetDir, entryRelPath);
470+
continue;
471+
}
472+
473+
if (!entry.isFile()) {
474+
continue;
475+
}
476+
477+
await mkdir(dirname(targetPath), { recursive: true });
478+
await copyFile(sourcePath, targetPath);
479+
copied++;
480+
}
481+
482+
return copied;
483+
}
484+
485+
function shouldSkipDocsPath(relativePath: string) {
486+
return ['node_modules', '.vitepress/cache', '.vitepress/dist'].some(
487+
(prefix) => relativePath === prefix || relativePath.startsWith(`${prefix}/`),
488+
);
489+
}
490+
463491
type ExportValue =
464492
| string
465493
| {

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"binding/index.d.ts",
2929
"binding/index.js",
3030
"dist/test",
31+
"docs",
3132
"rules",
32-
"skills",
3333
"templates"
3434
],
3535
"type": "module",

packages/cli/skills/vite-plus/SKILL.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

packages/cli/src/bin.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Unified entry point for both the local CLI (via bin/vp) and the global CLI (via Rust vp binary).
33
*
4-
* Global commands (create, migrate, config, mcp, staged, --version) are handled by tsdown-bundled modules.
4+
* Global commands (create, migrate, config, staged, --version) are handled by tsdown-bundled modules.
55
* All other commands are delegated to the Rust core through NAPI bindings, which
66
* uses JavaScript tool resolver functions to locate tool binaries.
77
*
@@ -54,8 +54,6 @@ if (command === 'create') {
5454
await import('./migration/bin.js');
5555
} else if (command === 'config') {
5656
await import('./config/bin.js');
57-
} else if (command === 'mcp') {
58-
await import('./mcp/bin.js');
5957
} else if (command === '--version' || command === '-V') {
6058
await import('./version.js');
6159
} else if (command === 'staged') {

0 commit comments

Comments
 (0)