mirror of
https://github.com/mleem97/gregWiki.git
synced 2026-04-11 03:29:19 +02:00
- Move markdown and wiki-import tree into docs/; keep app shell at repo root - Point docusaurus docs path to docs/; edit links to mleem97/gregWiki - Sync and i18n scripts use gregWiki root and ../.wiki under gregFramework - Sidebars: workspace layout from root docs ids; plugins under mods/extensions - Fix redirects, module catalog URLs, release note paths, and wiki-import category keys - Update repo inventory for split repos; Dockerfile for single-repo context Made-with: Cursor
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
import { join, resolve } from 'node:path';
|
|
|
|
const projectRoot = resolve(process.cwd());
|
|
const gregFrameworkRoot = resolve(projectRoot, '..');
|
|
const wikiDir = join(gregFrameworkRoot, '.wiki');
|
|
const outDir = join(projectRoot, 'docs', 'wiki-import');
|
|
|
|
if (!existsSync(wikiDir)) {
|
|
console.error(
|
|
`Missing ${wikiDir}. Clone or restore the GitHub Wiki working tree there, then re-run this script.\n` +
|
|
'Existing files under docs/wiki-import/ are left unchanged.',
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
mkdirSync(outDir, { recursive: true });
|
|
|
|
function collectMarkdownFiles(rootDir, prefix = '') {
|
|
const entries = readdirSync(join(rootDir, prefix), { withFileTypes: true });
|
|
const results = [];
|
|
|
|
for (const entry of entries) {
|
|
const relativePath = prefix ? join(prefix, entry.name) : entry.name;
|
|
if (entry.isDirectory()) {
|
|
results.push(...collectMarkdownFiles(rootDir, relativePath));
|
|
continue;
|
|
}
|
|
|
|
if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) {
|
|
results.push(relativePath);
|
|
}
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
const files = collectMarkdownFiles(wikiDir);
|
|
|
|
for (const file of files) {
|
|
const source = join(wikiDir, file);
|
|
const sanitizedRelative = file.replace(/\s+/g, '-');
|
|
const target = join(outDir, sanitizedRelative);
|
|
const targetDir = resolve(target, '..');
|
|
mkdirSync(targetDir, { recursive: true });
|
|
const raw = readFileSync(source, 'utf8');
|
|
writeFileSync(target, raw, 'utf8');
|
|
}
|
|
|
|
console.log(`Synced ${files.length} wiki files to ${outDir}`);
|