Files
2026-05-12 18:48:04 +00:00

38 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Copy `docs/changelog.md` → `ordinis-admin-ui/src/changelog-public.md`.
*
* Why: public CHANGELOG лежит в `docs/` (single source of truth, читается
* mkdocs/Diplodoc для /docs/changelog.html). admin-ui WhatsNewButton тоже
* импортирует его через Vite `?raw`, но Docker build context = admin-ui/,
* `docs/` снаружи. Скрипт вызывается через `predev` / `prebuild` npm
* hooks — копирует файл в admin-ui/src/ перед start'ом vite.
*
* В CI копию делает `.gitlab-ci.yml` `docker-admin-ui:before_script:` —
* перед docker build файл уже в context'е, Dockerfile `COPY . .` подхватит.
*
* **Critical name choice:** `changelog-public.md`, не `changelog.md`. macOS
* по умолчанию case-insensitive filesystem (APFS / HFS+) — `changelog.md` ≡
* `CHANGELOG.md` ≡ existing internal CHANGELOG.md → overwrite. Suffix
* `-public` устраняет конфликт + явно показывает purpose. Plus файл живёт
* в `src/` (не root) чтобы Vite `?raw` ресолвил по relative path без `..`.
*
* `src/changelog-public.md` — generated, gitignored.
*/
import { copyFileSync, existsSync, mkdirSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const SRC = resolve(__dirname, '..', '..', 'docs', 'changelog.md')
const DST = resolve(__dirname, '..', 'src', 'changelog-public.md')
if (!existsSync(SRC)) {
console.error(`copy-changelog: source missing ${SRC}`)
process.exit(0)
}
mkdirSync(dirname(DST), { recursive: true })
copyFileSync(SRC, DST)
console.log(`copy-changelog: ${SRC}${DST}`)