mirror of
https://github.com/nocobase/nocobase.git
synced 2026-12-06 22:23:41 +08:00
* chore(docs): remove capability screenshots no page uses approval-joint-rules.svg, default-login-en.png, northstar-login-en.png, northstar-transport-print-en.png and workflow-subscription-flow.svg are referenced by no page, overview or home page in either language, and the site never published them. * feat(docs): build the documentation site with Astro Replace the Rspress site with a plain Astro site. The Markdown stays in docs/docs/<lang>/ and is read through a content collection, so the structural checks keep working on the same tree. - One build writes both languages: English to dist/, Simplified Chinese to dist/zh-CN/, every page as <path>/index.html for the CDN rules. - URLs keep their published shape: x/index.md is /x/, x.md is /x. - BaseLayout carries a shared SEO head (title, description, keywords, robots, canonical, en-US/zh-CN/x-default alternates, Open Graph), header and footer; DocLayout adds the _meta.json sidebar with per-module roots, table of contents, previous/next, Copy Markdown and TechArticle/BreadcrumbList JSON-LD. - The home page, the 2 vs 3 comparison and the capability overviews keep their static markup and run their scripts without React. - :::tip/:::info callouts, links to .md/.mdx files rewritten to page URLs, external links in a new tab, heading anchors, table wrapper. - The build fails on a broken internal link or heading fragment. - sitemap.xml lists canonical, indexable pages of both languages with their alternates; robots.txt points at it; DOCS_SITE_ORIGIN sets the origin, defaulting to https://docs.nocobase.com. - llms.txt, llms-full.txt and per-page .md copies keep their URLs. - A Pagefind index is written for both languages; no page loads it yet. - The /cn/* redirect pages are no longer generated. The search plugins, the hidden documentation assistant, the plugin-page components, the copied Rspress navigation and the React dependencies go with Rspress. The root keeps vite on the catalog version so that vitest's peer stays on vite 6 while Astro brings vite 8. * ci(docs): build both languages in one Astro build The site now writes every language and the <path>/index.html layout the CDN rules expect in a single build, so the per-language builds and the normalize step go. Pull requests that change only docs/ skip the Quality checks, so the workflow also runs the package's lint, typecheck and tests. Triggers, dispatch inputs and the publish steps are unchanged. * docs(docs): describe the Astro documentation site Rewrite the documentation-site rules for the Astro build: URL rules, how to add a Markdown or hand-written page, the SEO and llms outputs, search, toolchain and deployment. Update the package README, AGENTS.md and the scripts README, which still listed ten languages and the Rspress dead-link check. * fix(docs): match the previous footer and code block metrics Inset the divider above the previous and next links and draw chevrons, and set code blocks to the 14px type and 16px padding the Rspress theme used, so Markdown pages keep their former layout. * fix(docs): publish only the overview screenshots a page uses The capability overviews imported every screenshot in the assets directory as a URL, which published each one a second time next to the copy the Markdown pages use. Resolve the referenced ones through getImage instead, so both share one output file. The built site is now 221 MB, against 279 MB for the Rspress build. * fix(docs): generate Astro types before linting The type-aware lint rules read the content collection types Astro writes to .astro/, which a fresh checkout does not have, so CI saw every collection entry as any. Run astro sync first. * fix(docs): type the content collection without generated types The pull request checks lint changed files with the root ESLint before anything runs astro sync, and ESLint resolves this package's configuration, whose type-aware rules then see every collection entry as any. Read the collection through a small module whose shape is declared next to it, so the code is typed whether or not .astro/ exists.
66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
import { spawnSync } from 'node:child_process';
|
|
|
|
const supportedExtension =
|
|
/\.(?:[cm]?[jt]sx?|json5?|jsonc|mdx?|ya?ml|css|scss|less|html|astro)$/u;
|
|
const mode = process.argv[2];
|
|
|
|
if (mode !== '--check' && mode !== '--write') {
|
|
console.error('Usage: node scripts/format-changed.mjs --check|--write');
|
|
process.exitCode = 2;
|
|
} else {
|
|
const tracked = readGitPaths([
|
|
'diff',
|
|
'--name-only',
|
|
'--diff-filter=ACMR',
|
|
'-z',
|
|
'HEAD',
|
|
]);
|
|
const untracked = readGitPaths([
|
|
'ls-files',
|
|
'--others',
|
|
'--exclude-standard',
|
|
'-z',
|
|
]);
|
|
const files = [...new Set([...tracked, ...untracked])].filter((file) =>
|
|
supportedExtension.test(file),
|
|
);
|
|
|
|
if (files.length === 0) {
|
|
console.log('No changed files require formatting.');
|
|
} else {
|
|
const prettierMode = mode === '--check' ? '--check' : '--write';
|
|
const pnpmCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
|
|
const result = spawnSync(
|
|
pnpmCommand,
|
|
[
|
|
'exec',
|
|
'prettier',
|
|
prettierMode,
|
|
'--ignore-path',
|
|
'.prettierignore',
|
|
'--',
|
|
...files,
|
|
],
|
|
{ stdio: 'inherit' },
|
|
);
|
|
|
|
if (result.error) {
|
|
throw result.error;
|
|
}
|
|
process.exitCode = result.status ?? 1;
|
|
}
|
|
}
|
|
|
|
function readGitPaths(args) {
|
|
const result = spawnSync('git', args, { encoding: 'buffer' });
|
|
if (result.error) {
|
|
throw result.error;
|
|
}
|
|
if (result.status !== 0) {
|
|
process.stderr.write(result.stderr);
|
|
process.exit(result.status ?? 1);
|
|
}
|
|
|
|
return result.stdout.toString('utf8').split('\0').filter(Boolean);
|
|
}
|