@gitpagedocs/cli 1.1.67 → 1.1.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/application/report/config-only-reporter.mjs +8 -1
- package/builders/config-orchestrator.mjs +6 -2
- package/builders/language-bundles-builder.mjs +24 -0
- package/builders/root-config-builder.mjs +1 -6
- package/content/docs-en.mjs +11 -4
- package/content/docs-es.mjs +11 -4
- package/content/docs-pt.mjs +11 -4
- package/contracts/doc-versions.mjs +1 -1
- package/contracts/langs-paths.mjs +25 -0
- package/contracts/languages.mjs +6 -0
- package/data/default-site-config.mjs +2 -2
- package/package.json +3 -3
- package/presentation/commands/config-info.ts +19 -6
- package/runtime/output.mjs +15 -3
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/** Config-only command output messages - SRP: single place for all report messages */
|
|
2
2
|
import { resolveRenderingUrl } from "../../builders/project-links.mjs";
|
|
3
3
|
import { normalizeLayoutsDir } from "../../contracts/layouts-paths.mjs";
|
|
4
|
+
import { languageArtifactPaths } from "../../contracts/langs-paths.mjs";
|
|
5
|
+
import { SUPPORTED_LANGUAGES } from "../../contracts/languages.mjs";
|
|
4
6
|
|
|
5
7
|
export function reportConfigOnlySuccess(options) {
|
|
6
|
-
|
|
8
|
+
const langs = languageArtifactPaths(options.outputDir);
|
|
9
|
+
return [
|
|
10
|
+
`Generated: ${options.outputDir}/ (config-only)`,
|
|
11
|
+
`UI strings: ${langs.manifest} + ${langs.dir}/{${SUPPORTED_LANGUAGES.join(",")}}.json`,
|
|
12
|
+
"No index.html/index.js generated.",
|
|
13
|
+
];
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
export function reportLayoutConfig(options) {
|
|
@@ -5,16 +5,18 @@ import { DOCS } from "../content/docs.mjs";
|
|
|
5
5
|
import { DOC_VERSIONS } from "../data/version-constants.mjs";
|
|
6
6
|
import { buildRootConfig } from "./root-config-builder.mjs";
|
|
7
7
|
import { buildVersionConfig } from "./version-config-builder.mjs";
|
|
8
|
+
import { buildLanguageArtifacts } from "./language-bundles-builder.mjs";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* Build all config artifacts (root, layouts, versions, docs).
|
|
11
|
+
* Build all config artifacts (root, languages, layouts, versions, docs).
|
|
11
12
|
* @param {object} options - { useLocalLayoutConfig, githubOwner, githubRepo, root }
|
|
12
|
-
* @returns {object} { rootConfig, layoutsConfig, fallbackLayoutsConfig, docs, docsHtml, versionConfigs }
|
|
13
|
+
* @returns {object} { rootConfig, languageManifest, languageBundles, layoutsConfig, fallbackLayoutsConfig, docs, docsHtml, versionConfigs }
|
|
13
14
|
*/
|
|
14
15
|
export function buildConfigArtifacts(options = {}) {
|
|
15
16
|
const root = options.root ?? process.cwd();
|
|
16
17
|
|
|
17
18
|
const rootConfig = buildRootConfig(options);
|
|
19
|
+
const { languageManifest, languageBundles } = buildLanguageArtifacts();
|
|
18
20
|
const layoutsConfig = { layouts: LAYOUTS };
|
|
19
21
|
const fallbackLayoutsConfig = { layouts: FALLBACK_LAYOUTS };
|
|
20
22
|
|
|
@@ -25,6 +27,8 @@ export function buildConfigArtifacts(options = {}) {
|
|
|
25
27
|
|
|
26
28
|
return {
|
|
27
29
|
rootConfig,
|
|
30
|
+
languageManifest,
|
|
31
|
+
languageBundles,
|
|
28
32
|
layoutsConfig,
|
|
29
33
|
fallbackLayoutsConfig,
|
|
30
34
|
docs: DOCS,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Build the language manifest + per-language UI string bundles for gitpagedocs */
|
|
2
|
+
import { buildLanguageManifest, splitLanguageBundles } from "@gitpagedocs/tools/i18n";
|
|
3
|
+
import { SUPPORTED_LANGUAGES } from "../contracts/languages.mjs";
|
|
4
|
+
import { defaultLangMenu } from "../data/i18n-langmenu.mjs";
|
|
5
|
+
import { defaultTranslations } from "../data/i18n-translations.mjs";
|
|
6
|
+
|
|
7
|
+
function assertLanguageStrings(languages) {
|
|
8
|
+
const missing = languages.filter((language) => !defaultLangMenu[language]);
|
|
9
|
+
if (missing.length > 0) {
|
|
10
|
+
throw new Error(`No UI strings (i18n-langmenu) for supported language(s): ${missing.join(", ")}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @returns {{ languageManifest: { languages: string[] }, languageBundles: Record<string, object> }}
|
|
16
|
+
*/
|
|
17
|
+
export function buildLanguageArtifacts() {
|
|
18
|
+
const languages = [...SUPPORTED_LANGUAGES];
|
|
19
|
+
assertLanguageStrings(languages);
|
|
20
|
+
return {
|
|
21
|
+
languageManifest: buildLanguageManifest(languages),
|
|
22
|
+
languageBundles: splitLanguageBundles(languages, defaultLangMenu, defaultTranslations),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -6,10 +6,7 @@ import {
|
|
|
6
6
|
resolveSourceViewerPath,
|
|
7
7
|
resolveLayoutsLinks,
|
|
8
8
|
} from "./project-links.mjs";
|
|
9
|
-
import { DOCS } from "../content/docs.mjs";
|
|
10
9
|
import { DOC_VERSIONS } from "../data/version-constants.mjs";
|
|
11
|
-
import { defaultLangMenu } from "../data/i18n-langmenu.mjs";
|
|
12
|
-
import { defaultTranslations } from "../data/i18n-translations.mjs";
|
|
13
10
|
import { getDefaultSiteConfig } from "../data/default-site-config.mjs";
|
|
14
11
|
|
|
15
12
|
export function buildRootConfig(options = {}) {
|
|
@@ -37,7 +34,7 @@ export function buildRootConfig(options = {}) {
|
|
|
37
34
|
"source-viewer-path": sourceViewerPath,
|
|
38
35
|
}));
|
|
39
36
|
|
|
40
|
-
const baseSiteConfig = getDefaultSiteConfig(
|
|
37
|
+
const baseSiteConfig = getDefaultSiteConfig(projectLink);
|
|
41
38
|
|
|
42
39
|
return {
|
|
43
40
|
site: {
|
|
@@ -51,11 +48,9 @@ export function buildRootConfig(options = {}) {
|
|
|
51
48
|
rendering: renderingUrl,
|
|
52
49
|
AiChatEnabled: true,
|
|
53
50
|
docsAccess: { enabled: false, publicKey: "" },
|
|
54
|
-
langmenu: defaultLangMenu,
|
|
55
51
|
},
|
|
56
52
|
VersionControl: {
|
|
57
53
|
versions: versionEntries,
|
|
58
54
|
},
|
|
59
|
-
translations: defaultTranslations,
|
|
60
55
|
};
|
|
61
56
|
}
|
package/content/docs-en.mjs
CHANGED
|
@@ -172,9 +172,10 @@ The version config can render a **Source code** container through \`routes-sourc
|
|
|
172
172
|
|
|
173
173
|
## Config keys (site)
|
|
174
174
|
|
|
175
|
-
- \`name\`, \`defaultLanguage
|
|
175
|
+
- \`name\`, \`defaultLanguage\`
|
|
176
176
|
- \`docsVersion\`, \`rendering\`, \`ThemeDefault\`, \`ThemeModeDefault\`
|
|
177
177
|
- \`ProjectLink\`, \`layoutsConfigPathOficial\`, \`layoutsConfigPath\`
|
|
178
|
+
- Languages and UI strings: \`gitpagedocs/langs.json\` + \`gitpagedocs/langs/<lang>.json\`
|
|
178
179
|
|
|
179
180
|
## Environment variables
|
|
180
181
|
|
|
@@ -316,7 +317,14 @@ Supported adapters:
|
|
|
316
317
|
`,
|
|
317
318
|
configuration: `# Configuration
|
|
318
319
|
|
|
319
|
-
Runtime configuration lives in \`gitpagedocs/config.json\`.
|
|
320
|
+
Runtime configuration lives in \`gitpagedocs/config.json\`. UI text lives next to it, one file per language.
|
|
321
|
+
|
|
322
|
+
## Languages (\`langs.json\` + \`langs/\`)
|
|
323
|
+
|
|
324
|
+
- \`gitpagedocs/langs.json\` lists the shipped languages in menu order: \`{ "languages": ["en", "pt", "es"] }\`.
|
|
325
|
+
- \`gitpagedocs/langs/<lang>.json\` holds that language's strings: \`langmenu\` (header, search, source viewer, audio player, AI chat and docs-access labels) and \`translations\` (\`notFound\`, \`navigation\`, \`footer\`).
|
|
326
|
+
- To add a language, create \`langs/<lang>.json\` and append its code to \`langs.json\`.
|
|
327
|
+
- Older \`config.json\` files that still inline \`site.langmenu\` / \`translations\` keep working; when both exist, the \`langs/\` files win and any missing key is backfilled from the current release.
|
|
320
328
|
|
|
321
329
|
## \`site\` section
|
|
322
330
|
|
|
@@ -324,7 +332,6 @@ Important keys:
|
|
|
324
332
|
|
|
325
333
|
- \`name\`
|
|
326
334
|
- \`defaultLanguage\`
|
|
327
|
-
- \`supportedLanguages\`
|
|
328
335
|
- \`docsVersion\`
|
|
329
336
|
- \`rendering\`
|
|
330
337
|
- \`ThemeDefault\`
|
|
@@ -453,7 +460,7 @@ A pnpm + turborepo monorepo where all business logic lives in one shared core (\
|
|
|
453
460
|
|
|
454
461
|
- **frontend/** — Next.js viewer (Feature-Sliced: \`app / widgets / features / entities / shared\`); static export.
|
|
455
462
|
- **cli/** — the published \`gitpagedocs\` bin (hexagonal: \`presentation / application / domain / infrastructure\`) + \`cli/ai/\` (the AI documentation CLI).
|
|
456
|
-
- **tools/** — \`@gitpagedocs/tools\`: \`ai/ security/ crypto/ cache/ config/ logger/ errors/ filesystem/ documentation/ ports/\`.
|
|
463
|
+
- **tools/** — \`@gitpagedocs/tools\`: \`ai/ security/ crypto/ cache/ config/ logger/ errors/ filesystem/ documentation/ i18n/ ports/\`.
|
|
457
464
|
- **mcp/** — \`@gitpagedocs/mcp\`: MCP tools + resources delegating to \`tools/\`.
|
|
458
465
|
|
|
459
466
|
## Main runtime modules (frontend)
|
package/content/docs-es.mjs
CHANGED
|
@@ -156,9 +156,10 @@ El config de version puede renderizar un contenedor **Codigo fuente** via \`rout
|
|
|
156
156
|
|
|
157
157
|
## Claves de config (site)
|
|
158
158
|
|
|
159
|
-
- \`name\`, \`defaultLanguage
|
|
159
|
+
- \`name\`, \`defaultLanguage\`
|
|
160
160
|
- \`docsVersion\`, \`rendering\`, \`ThemeDefault\`, \`ThemeModeDefault\`
|
|
161
161
|
- \`ProjectLink\`, \`layoutsConfigPathOficial\`, \`layoutsConfigPath\`
|
|
162
|
+
- Idiomas y textos de la UI: \`gitpagedocs/langs.json\` + \`gitpagedocs/langs/<lang>.json\`
|
|
162
163
|
|
|
163
164
|
## Variables de entorno
|
|
164
165
|
|
|
@@ -167,7 +168,14 @@ El config de version puede renderizar un contenedor **Codigo fuente** via \`rout
|
|
|
167
168
|
`,
|
|
168
169
|
configuration: `# Configuracion
|
|
169
170
|
|
|
170
|
-
La configuracion de runtime esta en \`gitpagedocs/config.json\`.
|
|
171
|
+
La configuracion de runtime esta en \`gitpagedocs/config.json\`. Los textos de la UI viven al lado, un archivo por idioma.
|
|
172
|
+
|
|
173
|
+
## Idiomas (\`langs.json\` + \`langs/\`)
|
|
174
|
+
|
|
175
|
+
- \`gitpagedocs/langs.json\` lista los idiomas disponibles en el orden del menu: \`{ "languages": ["en", "pt", "es"] }\`.
|
|
176
|
+
- \`gitpagedocs/langs/<lang>.json\` guarda los textos de ese idioma: \`langmenu\` (cabecera, busqueda, visor de codigo, reproductor de audio, chat de IA y acceso a los docs) y \`translations\` (\`notFound\`, \`navigation\`, \`footer\`).
|
|
177
|
+
- Para agregar un idioma, crea \`langs/<lang>.json\` y agrega su codigo a \`langs.json\`.
|
|
178
|
+
- Los \`config.json\` antiguos que aun traen \`site.langmenu\` / \`translations\` inline siguen funcionando; cuando existen ambos, los archivos de \`langs/\` prevalecen y cualquier clave ausente se completa desde la version actual.
|
|
171
179
|
|
|
172
180
|
## Seccion \`site\`
|
|
173
181
|
|
|
@@ -175,7 +183,6 @@ Claves principales:
|
|
|
175
183
|
|
|
176
184
|
- \`name\`: titulo del proyecto en UI
|
|
177
185
|
- \`defaultLanguage\`: idioma por defecto
|
|
178
|
-
- \`supportedLanguages\`: lista de idiomas disponibles
|
|
179
186
|
- \`HideThemeSelector\`: ocultar/mostrar selector de tema
|
|
180
187
|
- \`ThemeDefault\`: id del tema inicial
|
|
181
188
|
- \`ThemeModeDefault\`: modo inicial (\`light\` o \`dark\`)
|
|
@@ -293,7 +300,7 @@ El proyecto esta organizado por fronteras de feature y responsabilidades de runt
|
|
|
293
300
|
|
|
294
301
|
- **frontend/** — visor Next.js (Feature-Sliced: app / widgets / features / entities / shared); export estatico.
|
|
295
302
|
- **cli/** — el bin publicado \`gitpagedocs\` (hexagonal) + \`cli/ai/\` (CLI de documentacion con IA).
|
|
296
|
-
- **tools/** — \`@gitpagedocs/tools\`: ai/ security/ crypto/ cache/ config/ logger/ errors/ filesystem/ documentation/ ports/.
|
|
303
|
+
- **tools/** — \`@gitpagedocs/tools\`: ai/ security/ crypto/ cache/ config/ logger/ errors/ filesystem/ documentation/ i18n/ ports/.
|
|
297
304
|
- **mcp/** — \`@gitpagedocs/mcp\`: herramientas + recursos MCP que delegan a tools/.
|
|
298
305
|
|
|
299
306
|
## Modulos principales (frontend)
|
package/content/docs-pt.mjs
CHANGED
|
@@ -156,9 +156,10 @@ O config da versao pode renderizar um container **Codigo fonte** via \`routes-so
|
|
|
156
156
|
|
|
157
157
|
## Chaves de config (site)
|
|
158
158
|
|
|
159
|
-
- \`name\`, \`defaultLanguage
|
|
159
|
+
- \`name\`, \`defaultLanguage\`
|
|
160
160
|
- \`docsVersion\`, \`rendering\`, \`ThemeDefault\`, \`ThemeModeDefault\`
|
|
161
161
|
- \`ProjectLink\`, \`layoutsConfigPathOficial\`, \`layoutsConfigPath\`
|
|
162
|
+
- Idiomas e textos da UI: \`gitpagedocs/langs.json\` + \`gitpagedocs/langs/<lang>.json\`
|
|
162
163
|
|
|
163
164
|
## Variaveis de ambiente
|
|
164
165
|
|
|
@@ -167,7 +168,14 @@ O config da versao pode renderizar um container **Codigo fonte** via \`routes-so
|
|
|
167
168
|
`,
|
|
168
169
|
configuration: `# Configuracao
|
|
169
170
|
|
|
170
|
-
A configuracao de runtime fica em \`gitpagedocs/config.json\`.
|
|
171
|
+
A configuracao de runtime fica em \`gitpagedocs/config.json\`. Os textos da UI ficam ao lado, um arquivo por idioma.
|
|
172
|
+
|
|
173
|
+
## Idiomas (\`langs.json\` + \`langs/\`)
|
|
174
|
+
|
|
175
|
+
- \`gitpagedocs/langs.json\` lista os idiomas disponiveis na ordem do menu: \`{ "languages": ["en", "pt", "es"] }\`.
|
|
176
|
+
- \`gitpagedocs/langs/<lang>.json\` guarda os textos daquele idioma: \`langmenu\` (cabecalho, busca, visualizador de codigo, player de audio, chat de IA e acesso aos docs) e \`translations\` (\`notFound\`, \`navigation\`, \`footer\`).
|
|
177
|
+
- Para adicionar um idioma, crie \`langs/<lang>.json\` e inclua o codigo em \`langs.json\`.
|
|
178
|
+
- Arquivos \`config.json\` antigos que ainda trazem \`site.langmenu\` / \`translations\` inline continuam funcionando; quando os dois existem, os arquivos de \`langs/\` prevalecem e qualquer chave ausente e preenchida a partir da versao atual.
|
|
171
179
|
|
|
172
180
|
## Secao \`site\`
|
|
173
181
|
|
|
@@ -175,7 +183,6 @@ Principais chaves:
|
|
|
175
183
|
|
|
176
184
|
- \`name\`: titulo do projeto no UI
|
|
177
185
|
- \`defaultLanguage\`: idioma padrao
|
|
178
|
-
- \`supportedLanguages\`: lista de idiomas disponiveis
|
|
179
186
|
- \`HideThemeSelector\`: esconde/mostra seletor de tema
|
|
180
187
|
- \`ThemeDefault\`: id do tema inicial
|
|
181
188
|
- \`ThemeModeDefault\`: modo inicial (\`light\` ou \`dark\`)
|
|
@@ -293,7 +300,7 @@ O projeto e organizado por fronteiras de feature e responsabilidades do runtime.
|
|
|
293
300
|
|
|
294
301
|
- **frontend/** — visualizador Next.js (Feature-Sliced: app / widgets / features / entities / shared); export estatico.
|
|
295
302
|
- **cli/** — o bin publicado \`gitpagedocs\` (hexagonal) + \`cli/ai/\` (CLI de documentacao com IA).
|
|
296
|
-
- **tools/** — \`@gitpagedocs/tools\`: ai/ security/ crypto/ cache/ config/ logger/ errors/ filesystem/ documentation/ ports/.
|
|
303
|
+
- **tools/** — \`@gitpagedocs/tools\`: ai/ security/ crypto/ cache/ config/ logger/ errors/ filesystem/ documentation/ i18n/ ports/.
|
|
297
304
|
- **mcp/** — \`@gitpagedocs/mcp\`: ferramentas + recursos MCP que delegam ao tools/.
|
|
298
305
|
|
|
299
306
|
## Modulos principais (frontend)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical locations for the language artifacts inside the docs output dir:
|
|
3
|
+
*
|
|
4
|
+
* <outputDir>/langs.json manifest listing the shipped languages
|
|
5
|
+
* <outputDir>/langs/<lang>.json UI strings (langmenu + translations) of one language
|
|
6
|
+
*
|
|
7
|
+
* The file names come from @gitpagedocs/tools so the generator and the viewer
|
|
8
|
+
* never disagree about where the bundles live.
|
|
9
|
+
*/
|
|
10
|
+
import { LANGS_DIRNAME, LANGS_MANIFEST_FILENAME } from "@gitpagedocs/tools/i18n";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Repo-relative POSIX paths of the language artifacts for a docs output dir.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} outputDir Docs output dir (e.g. `gitpagedocs`).
|
|
16
|
+
* @returns {{ manifest: string, dir: string, bundle: (language: string) => string }}
|
|
17
|
+
*/
|
|
18
|
+
export function languageArtifactPaths(outputDir) {
|
|
19
|
+
const dir = `${outputDir}/${LANGS_DIRNAME}`;
|
|
20
|
+
return {
|
|
21
|
+
manifest: `${outputDir}/${LANGS_MANIFEST_FILENAME}`,
|
|
22
|
+
dir,
|
|
23
|
+
bundle: (language) => `${dir}/${language}.json`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Languages the generator ships UI strings and docs for, in menu order. This
|
|
3
|
+
* is the list written to `gitpagedocs/langs.json`; every entry must have a
|
|
4
|
+
* `langs/<lang>.json` bundle and a docs content module.
|
|
5
|
+
*/
|
|
6
|
+
export const SUPPORTED_LANGUAGES = Object.freeze(["en", "pt", "es"]);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/** Site chrome defaults. The language list and UI strings live in langs.json + langs/. */
|
|
2
|
+
export function getDefaultSiteConfig(projectLink) {
|
|
2
3
|
return {
|
|
3
4
|
name: "Git Pages Docs",
|
|
4
5
|
defaultLanguage: "en",
|
|
5
|
-
supportedLanguages: Object.keys(DOCS || { en: 1, pt: 1, es: 1 }),
|
|
6
6
|
HideThemeSelector: false,
|
|
7
7
|
ThemeDefault: "aurora-dark",
|
|
8
8
|
ThemeModeDefault: "dark",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitpagedocs/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.68",
|
|
4
4
|
"description": "CLI that scaffolds and maintains gitpagedocs documentation, generates docs with AI, configures GitHub Pages, and runs the MCP server.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"gitpagedocs": "index.mjs"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@clack/prompts": "^1.5.1",
|
|
32
|
-
"@gitpagedocs/mcp": "^1.1.
|
|
33
|
-
"@gitpagedocs/tools": "^1.1.
|
|
32
|
+
"@gitpagedocs/mcp": "^1.1.68",
|
|
33
|
+
"@gitpagedocs/tools": "^1.1.68",
|
|
34
34
|
"tsx": "^4.21.0"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { DEFAULT_LANGS_MANIFEST_PATH, defaultConfigLoader, isAppError, parseLanguageManifest } from "@gitpagedocs/tools";
|
|
3
4
|
import type { CommandContext } from "./run-command";
|
|
4
5
|
|
|
6
|
+
const UNKNOWN = "—";
|
|
7
|
+
|
|
8
|
+
/** Languages from `gitpagedocs/langs.json`, else the legacy inline `site.supportedLanguages`. */
|
|
9
|
+
async function resolveLanguages(cwd: string, site: Record<string, unknown>): Promise<string[]> {
|
|
10
|
+
try {
|
|
11
|
+
const manifest = parseLanguageManifest(JSON.parse(await readFile(path.join(cwd, DEFAULT_LANGS_MANIFEST_PATH), "utf-8")));
|
|
12
|
+
if (manifest) return manifest.languages;
|
|
13
|
+
} catch {
|
|
14
|
+
// No manifest: fall back to the inline list below.
|
|
15
|
+
}
|
|
16
|
+
return Array.isArray(site.supportedLanguages) ? (site.supportedLanguages as string[]) : [];
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
/** `gitpagedocs config` — resolve and summarize the active gitpagedocs config. */
|
|
6
20
|
export async function runConfig(ctx: CommandContext): Promise<void> {
|
|
7
21
|
try {
|
|
8
22
|
const { config, sourcePath, extension } = await defaultConfigLoader.loadGitPageDocsConfig(ctx.cwd);
|
|
9
23
|
const site = (config as { site?: Record<string, unknown> }).site ?? {};
|
|
24
|
+
const languages = await resolveLanguages(ctx.cwd, site);
|
|
10
25
|
// eslint-disable-next-line no-console
|
|
11
26
|
console.log(
|
|
12
27
|
`\n Config: ${path.relative(ctx.cwd, sourcePath)} (${extension})\n` +
|
|
13
|
-
` site name : ${String(site.name ??
|
|
14
|
-
` default language : ${String(site.defaultLanguage ??
|
|
15
|
-
` languages : ${
|
|
16
|
-
Array.isArray(site.supportedLanguages) ? (site.supportedLanguages as string[]).join(", ") : "—"
|
|
17
|
-
}\n`,
|
|
28
|
+
` site name : ${String(site.name ?? UNKNOWN)}\n` +
|
|
29
|
+
` default language : ${String(site.defaultLanguage ?? UNKNOWN)}\n` +
|
|
30
|
+
` languages : ${languages.length > 0 ? languages.join(", ") : UNKNOWN}\n`,
|
|
18
31
|
);
|
|
19
32
|
} catch (error) {
|
|
20
33
|
const message = isAppError(error) ? error.message : String(error);
|
package/runtime/output.mjs
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
normalizeToOutputPath,
|
|
10
10
|
} from "./doc-path-resolver.mjs";
|
|
11
11
|
import { layoutsArtifactPaths } from "../contracts/layouts-paths.mjs";
|
|
12
|
+
import { languageArtifactPaths } from "../contracts/langs-paths.mjs";
|
|
13
|
+
import { SUPPORTED_LANGUAGES } from "../contracts/languages.mjs";
|
|
12
14
|
|
|
13
15
|
const DEFAULT_ICON_SVG = `<?xml version="1.0" encoding="utf-8"?>
|
|
14
16
|
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -29,7 +31,7 @@ function listExistingVersionIds(root, outputDir) {
|
|
|
29
31
|
function removeLegacySourceViewerFiles(root, outputDir) {
|
|
30
32
|
const versionIds = listExistingVersionIds(root, outputDir);
|
|
31
33
|
for (const versionId of versionIds) {
|
|
32
|
-
for (const language of
|
|
34
|
+
for (const language of SUPPORTED_LANGUAGES) {
|
|
33
35
|
for (const fileName of ["source-viewer", "source-viewer.html"]) {
|
|
34
36
|
const legacyPath = path.join(root, outputDir, "docs", "versions", versionId, language, fileName);
|
|
35
37
|
if (existsSync(legacyPath)) {
|
|
@@ -75,6 +77,15 @@ async function writeLayoutArtifacts(options) {
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
/** Write the language manifest and one UI-strings bundle per shipped language. */
|
|
81
|
+
async function writeLanguageArtifacts(root, outputDir, artifacts) {
|
|
82
|
+
const paths = languageArtifactPaths(outputDir);
|
|
83
|
+
await writeJson(root, paths.manifest, artifacts.languageManifest);
|
|
84
|
+
for (const [language, bundle] of Object.entries(artifacts.languageBundles)) {
|
|
85
|
+
await writeJson(root, paths.bundle(language), bundle);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
export async function writeConfigOnlyOutput(options) {
|
|
79
90
|
const {
|
|
80
91
|
root,
|
|
@@ -88,7 +99,7 @@ export async function writeConfigOnlyOutput(options) {
|
|
|
88
99
|
} = options;
|
|
89
100
|
|
|
90
101
|
// Keep only versioned docs output in docs/, removing legacy root language folders.
|
|
91
|
-
for (const legacyLanguageDir of
|
|
102
|
+
for (const legacyLanguageDir of SUPPORTED_LANGUAGES) {
|
|
92
103
|
const legacyPath = path.join(root, outputDir, "docs", legacyLanguageDir);
|
|
93
104
|
if (existsSync(legacyPath)) {
|
|
94
105
|
rmSync(legacyPath, { recursive: true, force: true });
|
|
@@ -96,6 +107,7 @@ export async function writeConfigOnlyOutput(options) {
|
|
|
96
107
|
}
|
|
97
108
|
|
|
98
109
|
await writeJson(root, `${outputDir}/config.json`, artifacts.rootConfig);
|
|
110
|
+
await writeLanguageArtifacts(root, outputDir, artifacts);
|
|
99
111
|
await writeText(root, `${outputDir}/icon.svg`, DEFAULT_ICON_SVG);
|
|
100
112
|
await writeLayoutArtifacts({
|
|
101
113
|
root,
|
|
@@ -146,7 +158,7 @@ export async function writeConfigOnlyOutput(options) {
|
|
|
146
158
|
}
|
|
147
159
|
|
|
148
160
|
// Ensure version folders always include an index file.
|
|
149
|
-
for (const language of
|
|
161
|
+
for (const language of SUPPORTED_LANGUAGES) {
|
|
150
162
|
const fallbackIndex = artifacts.docs?.[language]?.index;
|
|
151
163
|
if (!fallbackIndex) continue;
|
|
152
164
|
const versionIndexPath = `${outputDir}/docs/versions/${versionId}/${language}/index.md`;
|