Download scripts/build-guide.mjs from smlflg/archify-hai: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/smlflg/archify-hai/resolve/main/scripts/build-guide.mjs
- Command line
-
hf download hf://smlflg/archify-hai/scripts/build-guide.mjs
-
curl -L -o build-guide.mjs https://huggingface.co/smlflg/archify-hai/resolve/main/scripts/build-guide.mjs
1.53 kB
| import fs from 'node:fs'; | |
| import path from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| import { publicGuideData } from '../archify/recipes/scenarios.mjs'; | |
| import { copySiteAssets } from './copy-site-assets.mjs'; | |
| import { diagramTypeCopyReplacements } from './site-copy.mjs'; | |
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | |
| const repoRoot = path.resolve(__dirname, '..'); | |
| const templatePath = path.join(__dirname, 'guide-template.html'); | |
| const outputPath = path.resolve(process.argv[2] || path.join(repoRoot, 'docs/guide.html')); | |
| const packageJson = JSON.parse(fs.readFileSync(path.join(repoRoot, 'archify/package.json'), 'utf8')); | |
| const guideJson = JSON.stringify(publicGuideData()) | |
| .replaceAll('&', '\\u0026') | |
| .replaceAll('<', '\\u003c') | |
| .replaceAll('>', '\\u003e'); | |
| const replacements = { | |
| ...diagramTypeCopyReplacements(), | |
| '[[ARCHIFY_VERSION]]': packageJson.version, | |
| '[[RECIPE_COUNT]]': String(publicGuideData().length), | |
| '[[GUIDE_JSON]]': guideJson, | |
| }; | |
| let output = fs.readFileSync(templatePath, 'utf8'); | |
| for (const [placeholder, value] of Object.entries(replacements)) { | |
| output = output.replaceAll(placeholder, value); | |
| } | |
| if (/\[\[[A-Z0-9_]+\]\]/.test(output)) { | |
| throw new Error('Guide template still contains unresolved placeholders.'); | |
| } | |
| fs.mkdirSync(path.dirname(outputPath), { recursive: true }); | |
| copySiteAssets(outputPath); | |
| fs.writeFileSync(outputPath, output); | |
| console.log(`Built ${outputPath} with ${publicGuideData().length} scenario recipes.`); | |