|
7 | 7 | * 3. syncCorePackageExports() - Creates shim files to re-export from @voidzero-dev/vite-plus-core |
8 | 8 | * 4. syncTestPackageExports() - Creates shim files to re-export from @voidzero-dev/vite-plus-test |
9 | 9 | * 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 |
11 | 11 | * 7. syncReadmeFromRoot() - Keeps package README in sync |
12 | 12 | * |
13 | 13 | * The sync functions allow this package to be a drop-in replacement for 'vite' by |
|
19 | 19 | */ |
20 | 20 |
|
21 | 21 | import { execSync } from 'node:child_process'; |
22 | | -import { existsSync, globSync, readdirSync, statSync } from 'node:fs'; |
23 | | -import { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises'; |
24 | | -import { dirname, join } from 'node:path'; |
| 22 | +import { existsSync, readdirSync, statSync } from 'node:fs'; |
| 23 | +import { copyFile, cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises'; |
| 24 | +import { dirname, join, relative } from 'node:path'; |
25 | 25 | import { fileURLToPath } from 'node:url'; |
26 | 26 | import { parseArgs } from 'node:util'; |
27 | 27 |
|
@@ -74,7 +74,7 @@ if (!skipTs) { |
74 | 74 | await syncTestPackageExports(); |
75 | 75 | await syncVersionsExport(); |
76 | 76 | } |
77 | | -await copySkillDocs(); |
| 77 | +await copyBundledDocs(); |
78 | 78 | await syncReadmeFromRoot(); |
79 | 79 |
|
80 | 80 | async function buildNapiBinding() { |
@@ -387,42 +387,32 @@ async function syncVersionsExport() { |
387 | 387 | } |
388 | 388 |
|
389 | 389 | /** |
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. |
393 | 393 | */ |
394 | | -async function copySkillDocs() { |
395 | | - console.log('\nCopying skill docs...'); |
| 394 | +async function copyBundledDocs() { |
| 395 | + console.log('\nCopying bundled docs...'); |
396 | 396 |
|
397 | 397 | const docsSourceDir = join(projectDir, '..', '..', 'docs'); |
398 | | - const docsTargetDir = join(projectDir, 'skills', 'vite-plus', 'docs'); |
| 398 | + const docsTargetDir = join(projectDir, 'docs'); |
399 | 399 |
|
400 | 400 | 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'); |
402 | 402 | return; |
403 | 403 | } |
404 | 404 |
|
405 | | - // Clean and recreate target directory |
| 405 | + const skipPrefixes = ['node_modules', '.vitepress/cache', '.vitepress/dist']; |
406 | 406 | await rm(docsTargetDir, { recursive: true, force: true }); |
407 | | - await mkdir(docsTargetDir, { recursive: true }); |
408 | | - |
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 | | - } |
| 407 | + await cp(docsSourceDir, docsTargetDir, { |
| 408 | + recursive: true, |
| 409 | + filter: (src) => { |
| 410 | + const rel = relative(docsSourceDir, src).replaceAll('\\', '/'); |
| 411 | + return !skipPrefixes.some((prefix) => rel === prefix || rel.startsWith(`${prefix}/`)); |
| 412 | + }, |
| 413 | + }); |
424 | 414 |
|
425 | | - console.log(` Copied ${copied} doc files to skills/vite-plus/docs/ (with paths preserved)`); |
| 415 | + console.log(' Copied docs to docs/ (with paths preserved)'); |
426 | 416 | } |
427 | 417 |
|
428 | 418 | async function syncReadmeFromRoot() { |
|
0 commit comments