mirror of
https://github.com/zoriya/v10.git
synced 2026-08-05 13:48:14 +00:00
feat(cli): add @videojs/cli docs command for LLM-friendly installation (#1214)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
9681515446
commit
24b8b77c8a
@@ -0,0 +1,43 @@
|
||||
import { cpSync, existsSync, mkdirSync, rmSync, statSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
function findWorkspaceRoot(start) {
|
||||
let dir = start;
|
||||
while (dir !== dirname(dir)) {
|
||||
if (existsSync(join(dir, 'pnpm-workspace.yaml'))) return dir;
|
||||
dir = dirname(dir);
|
||||
}
|
||||
throw new Error('Could not find pnpm-workspace.yaml — is this script running inside the monorepo?');
|
||||
}
|
||||
|
||||
const WORKSPACE_ROOT = findWorkspaceRoot(__dirname);
|
||||
const SITE_DIST = join(WORKSPACE_ROOT, 'site', 'dist');
|
||||
const CLI_DOCS = join(__dirname, '..', 'docs');
|
||||
|
||||
if (!existsSync(SITE_DIST)) {
|
||||
console.warn('⚠ site/dist not found — skipping docs copy. Build the site first.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Clean and recreate docs dir
|
||||
rmSync(CLI_DOCS, { recursive: true, force: true });
|
||||
mkdirSync(CLI_DOCS, { recursive: true });
|
||||
|
||||
for (const framework of ['html', 'react']) {
|
||||
const src = join(SITE_DIST, 'docs', 'framework', framework);
|
||||
if (!existsSync(src)) continue;
|
||||
|
||||
const dest = join(CLI_DOCS, framework);
|
||||
cpSync(src, dest, {
|
||||
recursive: true,
|
||||
filter: (path) => {
|
||||
if (statSync(path).isDirectory()) return true;
|
||||
return path.endsWith('.md') || path.endsWith('.txt');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log('✓ Docs copied to packages/cli/docs/');
|
||||
Reference in New Issue
Block a user