| 8 | const API_DIR = join(__dirname, '..', 'docs', 'api') |
| 9 | |
| 10 | async function main() { |
| 11 | try { |
| 12 | console.log('Getting milkdown...') |
| 13 | execSync('git submodule update --remote', { stdio: 'inherit' }) |
| 14 | |
| 15 | // Change to milkdown directory |
| 16 | process.chdir(MILKDOWN_DIR) |
| 17 | |
| 18 | // Run pnpm install |
| 19 | console.log('Installing dependencies...') |
| 20 | execSync('pnpm install', { stdio: 'inherit' }) |
| 21 | |
| 22 | // Build TypeScript files |
| 23 | console.log('Building TypeScript files...') |
| 24 | execSync('pnpm --filter=@milkdown/dev exec tsc', { stdio: 'inherit' }) |
| 25 | execSync('pnpm --filter=@milkdown/docs build', { stdio: 'inherit' }) |
| 26 | |
| 27 | // Ensure api directory exists |
| 28 | if (!existsSync(API_DIR)) { |
| 29 | mkdirSync(API_DIR, { recursive: true }) |
| 30 | } |
| 31 | |
| 32 | // Copy files from milkdown/docs/lib to api directory |
| 33 | const sourceDir = join(MILKDOWN_DIR, 'docs', 'lib') |
| 34 | console.log('Copying files...') |
| 35 | |
| 36 | // Copy all markdown files |
| 37 | execSync(`cp ${join(sourceDir, '*.md')} ${API_DIR}`, { stdio: 'inherit' }) |
| 38 | |
| 39 | console.log('Done!') |
| 40 | } catch (error) { |
| 41 | console.error('Error:', error) |
| 42 | process.exit(1) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | main() |