@gitpagedocs/cli 1.1.62 → 1.1.64

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.
Files changed (59) hide show
  1. package/README.md +193 -193
  2. package/ai/application/ai-command.ts +24 -24
  3. package/ai/application/ai-provider-factory.ts +22 -22
  4. package/ai/application/docs-pattern.ts +68 -68
  5. package/ai/application/run-ai-cli-command.ts +167 -167
  6. package/ai/config.ts +50 -50
  7. package/ai/core/models/ai-cli-config.ts +33 -33
  8. package/ai/core/models/parse-ai-cli-config.ts +78 -78
  9. package/ai/core/ports/illm-provider.ts +32 -32
  10. package/ai/infrastructure/ai-config-file.ts +101 -101
  11. package/ai/infrastructure/file-system-adapter.ts +85 -85
  12. package/ai/infrastructure/llm/tools-llm-provider.ts +54 -54
  13. package/ai/infrastructure/version-docs-writer.ts +143 -143
  14. package/ai/presentation/ai-prompts.ts +239 -239
  15. package/application/ports/cli-runtime-ports.ts +91 -91
  16. package/application/report/config-only-reporter.mjs +64 -64
  17. package/application/use-cases/dispatch-mode.ts +18 -18
  18. package/builders/config-orchestrator.mjs +34 -34
  19. package/builders/project-links.mjs +50 -50
  20. package/builders/root-config-builder.mjs +61 -61
  21. package/builders/route-builders.mjs +136 -136
  22. package/builders/theme-template.mjs +76 -76
  23. package/builders/version-config-builder.mjs +186 -186
  24. package/content/docs-en.mjs +549 -549
  25. package/content/docs-es.mjs +462 -462
  26. package/content/docs-pt.mjs +462 -462
  27. package/contracts/doc-versions.mjs +3 -3
  28. package/data/default-site-config.mjs +321 -321
  29. package/data/i18n-langmenu.mjs +347 -347
  30. package/data/layouts.mjs +436 -436
  31. package/data/path-mappings.mjs +26 -26
  32. package/data/route-metas.mjs +93 -93
  33. package/data/theme-colors.mjs +443 -443
  34. package/data/urls.mjs +12 -12
  35. package/domain/models/cli-options.ts +33 -33
  36. package/home/constants.mjs +4 -4
  37. package/index.mjs +37 -37
  38. package/infrastructure/gitpagedocs-config-file.ts +47 -47
  39. package/infrastructure/home/runtime.mjs +37 -37
  40. package/package.json +3 -3
  41. package/presentation/commands/ai-info.ts +57 -57
  42. package/presentation/commands/config-clear.ts +23 -23
  43. package/presentation/commands/config-info.ts +24 -24
  44. package/presentation/commands/diagnostics.ts +164 -164
  45. package/presentation/commands/docs.ts +37 -37
  46. package/presentation/commands/mcp.ts +20 -20
  47. package/presentation/commands/pages.ts +101 -101
  48. package/presentation/commands/password.ts +62 -62
  49. package/presentation/commands/run-command.ts +70 -70
  50. package/presentation/index.ts +124 -124
  51. package/presentation/options/parser.ts +119 -119
  52. package/presentation/options/resolver.ts +46 -46
  53. package/presentation/ui/clack.ts +91 -91
  54. package/presentation/ui/prompts.ts +146 -146
  55. package/runtime/git-ops.mjs +110 -110
  56. package/runtime/output.mjs +159 -159
  57. package/runtime/workflow.mjs +129 -129
  58. package/start.mjs +12 -12
  59. package/ui/logger.mjs +9 -9
@@ -1,159 +1,159 @@
1
- import { existsSync, readdirSync, rmSync } from "node:fs";
2
- import { mkdir, writeFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import {
5
- parseDocFileToKey,
6
- parseHtmlFileToKey,
7
- extractLanguageFromPath,
8
- withVersionBadge,
9
- normalizeToOutputPath,
10
- } from "./doc-path-resolver.mjs";
11
- import { layoutsArtifactPaths } from "../contracts/layouts-paths.mjs";
12
-
13
- const DEFAULT_ICON_SVG = `<?xml version="1.0" encoding="utf-8"?>
14
- <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
15
- <path opacity="0.1" fill-rule="evenodd" clip-rule="evenodd" d="M12 3C4.5885 3 3 4.5885 3 12C3 19.4115 4.5885 21 12 21C19.4115 21 21 19.4115 21 12C21 4.5885 19.4115 3 12 3ZM14.2695 9.03471C15.1872 8.34452 15.7204 8.25293 15.9299 8.25017C16.1326 8.86788 16.1588 9.54654 16.0042 10.1835C15.9945 10.2234 15.9842 10.263 15.9731 10.3025C15.941 10.4168 15.9647 10.5393 16.0366 10.6333L16.0377 10.6347C16.0521 10.6537 16.0664 10.6728 16.0805 10.6922C16.5194 11.2949 16.7603 12.0687 16.7497 12.8714L16.7496 12.8747C16.7496 14.5738 16.3076 15.5644 15.6994 16.1583C15.0859 16.7572 14.2627 16.9938 13.4137 17.0968L13.3898 17.0997L13.3777 17.1014C12.443 17.2601 11.5456 17.2688 10.6078 17.1286L10.604 17.1281L10.5687 17.1233C9.72415 17.0085 8.90483 16.7616 8.29455 16.1566C7.68912 15.5564 7.25036 14.5643 7.25038 12.8747L7.25034 12.8714C7.23972 12.0687 7.48056 11.2949 7.91949 10.6922C7.93482 10.6711 7.9504 10.6503 7.96621 10.6297C8.03648 10.538 8.05962 10.4184 8.02812 10.3068L8.02599 10.2993C8.01523 10.2608 8.00513 10.2222 7.99569 10.1834C7.84087 9.54684 7.86561 8.86863 8.0659 8.25016C8.27679 8.2528 8.81228 8.34432 9.73045 9.03473C9.76619 9.0616 9.80249 9.08937 9.83937 9.11807C9.93139 9.19 10.0529 9.21205 10.1644 9.17703L10.1657 9.17661C10.2268 9.15768 10.2882 9.13972 10.3496 9.12272C11.4349 8.82255 12.5651 8.82255 13.6504 9.12272C13.7088 9.13888 13.7671 9.15592 13.8253 9.17382L13.8277 9.17457C13.9431 9.21015 14.0704 9.18836 14.1678 9.11252C14.2022 9.08578 14.2361 9.05985 14.2695 9.03471Z" fill="#323232"/>
16
- <path d="M13.717 8.88177C12.5881 8.56954 11.4119 8.56954 10.283 8.88177C10.2637 8.8871 10.2444 8.89254 10.2252 8.89808C10.1067 8.93218 9.97923 8.909 9.8807 8.83491V8.83491C8.69311 7.94193 8.07278 7.98181 7.91927 8.01161V8.01161C7.8946 8.0164 7.87585 8.03481 7.86732 8.05844C7.86516 8.06441 7.86303 8.07038 7.8609 8.07636C7.61639 8.76505 7.57904 9.52813 7.75277 10.2425C7.76289 10.2841 7.77371 10.3255 7.78525 10.3667C7.78601 10.3694 7.78677 10.3721 7.78753 10.3748C7.79754 10.4102 7.7902 10.4483 7.7678 10.4776V10.4776C7.75074 10.4998 7.73394 10.5223 7.71741 10.545C7.24479 11.1939 6.98907 12.0213 7.00036 12.8747C7.00036 16.3399 8.80396 17.1358 10.535 17.3711L10.5708 17.3758C11.5347 17.5199 12.4587 17.511 13.4195 17.3479L13.4438 17.345C15.1832 17.1339 16.9996 16.3587 16.9996 12.8747C17.0109 12.0213 16.7552 11.1939 16.2826 10.545C16.2674 10.5242 16.252 10.5035 16.2364 10.483C16.236 10.4825 16.2356 10.482 16.2352 10.4815C16.211 10.4498 16.203 10.4085 16.2138 10.3701V10.3701C16.2257 10.3277 16.2368 10.2852 16.2471 10.2425C16.421 9.52611 16.3815 8.76076 16.1329 8.07176C16.1313 8.06753 16.1298 8.06331 16.1283 8.05909C16.1195 8.03503 16.1004 8.01628 16.0752 8.01142V8.01142C15.921 7.98164 15.3041 7.94381 14.1193 8.83491V8.83491C14.0208 8.90896 13.8933 8.93197 13.7748 8.89804C13.7556 8.89252 13.7363 8.8871 13.717 8.88177Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
17
- <path d="M3 12C3 4.5885 4.5885 3 12 3C19.4115 3 21 4.5885 21 12C21 19.4115 19.4115 21 12 21C4.5885 21 3 19.4115 3 12Z" stroke="#323232" stroke-width="2"/>
18
- </svg>
19
- `;
20
-
21
- function listExistingVersionIds(root, outputDir) {
22
- const versionsRoot = path.join(root, outputDir, "docs", "versions");
23
- if (!existsSync(versionsRoot)) return [];
24
- return readdirSync(versionsRoot, { withFileTypes: true })
25
- .filter((entry) => entry.isDirectory())
26
- .map((entry) => entry.name);
27
- }
28
-
29
- function removeLegacySourceViewerFiles(root, outputDir) {
30
- const versionIds = listExistingVersionIds(root, outputDir);
31
- for (const versionId of versionIds) {
32
- for (const language of ["pt", "en", "es"]) {
33
- for (const fileName of ["source-viewer", "source-viewer.html"]) {
34
- const legacyPath = path.join(root, outputDir, "docs", "versions", versionId, language, fileName);
35
- if (existsSync(legacyPath)) {
36
- rmSync(legacyPath, { force: true });
37
- }
38
- }
39
- }
40
- }
41
- }
42
-
43
- async function writeJson(root, relativePath, data) {
44
- const absolutePath = path.join(root, relativePath);
45
- await mkdir(path.dirname(absolutePath), { recursive: true });
46
- await writeFile(absolutePath, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
47
- }
48
-
49
- export async function writeText(root, relativePath, data) {
50
- const absolutePath = path.join(root, relativePath);
51
- await mkdir(path.dirname(absolutePath), { recursive: true });
52
- await writeFile(absolutePath, data, "utf-8");
53
- }
54
-
55
- /**
56
- * Write the local layout artifacts into the standalone layouts home.
57
- *
58
- * No layouts folder is ever deleted here. The legacy `<outputDir>/layouts/`
59
- * folder can hold hand-edited templates and the viewer still reads it, so
60
- * relocating it is an explicit, confirmed migration rather than a side effect of
61
- * generating. Switching back to official layouts likewise leaves an existing
62
- * layouts home in place: `layoutsConfigPathOficial` already decides which source
63
- * the viewer uses, so the files are inert rather than harmful.
64
- */
65
- async function writeLayoutArtifacts(options) {
66
- const { root, layoutsDir, useLocalLayoutConfig, layouts, artifacts, createThemeTemplate } = options;
67
-
68
- if (!useLocalLayoutConfig) return;
69
-
70
- const paths = layoutsArtifactPaths(layoutsDir);
71
- await writeJson(root, paths.config, artifacts.layoutsConfig);
72
- await writeJson(root, paths.fallbackConfig, artifacts.fallbackLayoutsConfig);
73
- for (const layout of layouts) {
74
- await writeJson(root, `${paths.root}/${layout.file}`, createThemeTemplate(layout));
75
- }
76
- }
77
-
78
- export async function writeConfigOnlyOutput(options) {
79
- const {
80
- root,
81
- pkgRoot,
82
- outputDir,
83
- artifacts,
84
- useLocalLayoutConfig,
85
- layoutsDir,
86
- layouts,
87
- createThemeTemplate,
88
- } = options;
89
-
90
- // Keep only versioned docs output in docs/, removing legacy root language folders.
91
- for (const legacyLanguageDir of ["en", "pt", "es"]) {
92
- const legacyPath = path.join(root, outputDir, "docs", legacyLanguageDir);
93
- if (existsSync(legacyPath)) {
94
- rmSync(legacyPath, { recursive: true, force: true });
95
- }
96
- }
97
-
98
- await writeJson(root, `${outputDir}/config.json`, artifacts.rootConfig);
99
- await writeText(root, `${outputDir}/icon.svg`, DEFAULT_ICON_SVG);
100
- await writeLayoutArtifacts({
101
- root,
102
- layoutsDir,
103
- useLocalLayoutConfig,
104
- layouts,
105
- artifacts,
106
- createThemeTemplate,
107
- });
108
-
109
- for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
110
- await writeJson(root, `${outputDir}/docs/versions/${versionId}/config.json`, versionConfig);
111
- }
112
-
113
- removeLegacySourceViewerFiles(root, outputDir);
114
-
115
- for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
116
- const versionRoutesMd = versionConfig["routes-md"] ?? versionConfig.routes ?? [];
117
- for (const route of versionRoutesMd) {
118
- for (const docPath of Object.values(route.path ?? {})) {
119
- const fileName = path.basename(docPath);
120
- const key = parseDocFileToKey(fileName);
121
- const language = extractLanguageFromPath(docPath);
122
- const content = key && language ? artifacts.docs?.[language]?.[key] : undefined;
123
- if (!content) continue;
124
- const versionedContent = withVersionBadge(content, versionId, language);
125
- await writeText(root, normalizeToOutputPath(outputDir, docPath), versionedContent);
126
- }
127
- }
128
-
129
- const versionRoutesHtml = versionConfig["routes-html"] ?? [];
130
- const docsHtml = artifacts.docsHtml ?? {};
131
- for (const route of versionRoutesHtml) {
132
- if (route.url) continue;
133
- for (const docPath of Object.values(route.path ?? {})) {
134
- const fileName = path.basename(docPath);
135
- const key = parseHtmlFileToKey(fileName);
136
- const language = extractLanguageFromPath(docPath);
137
- const content = key && language ? docsHtml[key]?.[language] : undefined;
138
- if (!content) continue;
139
- const normalizedHtmlPath = normalizeToOutputPath(outputDir, docPath);
140
- await writeText(root, normalizedHtmlPath, content);
141
- // Backward-compatible alias for tools or users that still expect ".html".
142
- if (!path.extname(docPath)) {
143
- await writeText(root, `${normalizedHtmlPath}.html`, content);
144
- }
145
- }
146
- }
147
-
148
- // Ensure version folders always include an index file.
149
- for (const language of ["pt", "en", "es"]) {
150
- const fallbackIndex = artifacts.docs?.[language]?.index;
151
- if (!fallbackIndex) continue;
152
- const versionIndexPath = `${outputDir}/docs/versions/${versionId}/${language}/index.md`;
153
- if (!existsSync(path.join(root, versionIndexPath))) {
154
- const versionedFallbackIndex = withVersionBadge(fallbackIndex, versionId, language);
155
- await writeText(root, versionIndexPath, versionedFallbackIndex);
156
- }
157
- }
158
- }
159
- }
1
+ import { existsSync, readdirSync, rmSync } from "node:fs";
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import {
5
+ parseDocFileToKey,
6
+ parseHtmlFileToKey,
7
+ extractLanguageFromPath,
8
+ withVersionBadge,
9
+ normalizeToOutputPath,
10
+ } from "./doc-path-resolver.mjs";
11
+ import { layoutsArtifactPaths } from "../contracts/layouts-paths.mjs";
12
+
13
+ const DEFAULT_ICON_SVG = `<?xml version="1.0" encoding="utf-8"?>
14
+ <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
15
+ <path opacity="0.1" fill-rule="evenodd" clip-rule="evenodd" d="M12 3C4.5885 3 3 4.5885 3 12C3 19.4115 4.5885 21 12 21C19.4115 21 21 19.4115 21 12C21 4.5885 19.4115 3 12 3ZM14.2695 9.03471C15.1872 8.34452 15.7204 8.25293 15.9299 8.25017C16.1326 8.86788 16.1588 9.54654 16.0042 10.1835C15.9945 10.2234 15.9842 10.263 15.9731 10.3025C15.941 10.4168 15.9647 10.5393 16.0366 10.6333L16.0377 10.6347C16.0521 10.6537 16.0664 10.6728 16.0805 10.6922C16.5194 11.2949 16.7603 12.0687 16.7497 12.8714L16.7496 12.8747C16.7496 14.5738 16.3076 15.5644 15.6994 16.1583C15.0859 16.7572 14.2627 16.9938 13.4137 17.0968L13.3898 17.0997L13.3777 17.1014C12.443 17.2601 11.5456 17.2688 10.6078 17.1286L10.604 17.1281L10.5687 17.1233C9.72415 17.0085 8.90483 16.7616 8.29455 16.1566C7.68912 15.5564 7.25036 14.5643 7.25038 12.8747L7.25034 12.8714C7.23972 12.0687 7.48056 11.2949 7.91949 10.6922C7.93482 10.6711 7.9504 10.6503 7.96621 10.6297C8.03648 10.538 8.05962 10.4184 8.02812 10.3068L8.02599 10.2993C8.01523 10.2608 8.00513 10.2222 7.99569 10.1834C7.84087 9.54684 7.86561 8.86863 8.0659 8.25016C8.27679 8.2528 8.81228 8.34432 9.73045 9.03473C9.76619 9.0616 9.80249 9.08937 9.83937 9.11807C9.93139 9.19 10.0529 9.21205 10.1644 9.17703L10.1657 9.17661C10.2268 9.15768 10.2882 9.13972 10.3496 9.12272C11.4349 8.82255 12.5651 8.82255 13.6504 9.12272C13.7088 9.13888 13.7671 9.15592 13.8253 9.17382L13.8277 9.17457C13.9431 9.21015 14.0704 9.18836 14.1678 9.11252C14.2022 9.08578 14.2361 9.05985 14.2695 9.03471Z" fill="#323232"/>
16
+ <path d="M13.717 8.88177C12.5881 8.56954 11.4119 8.56954 10.283 8.88177C10.2637 8.8871 10.2444 8.89254 10.2252 8.89808C10.1067 8.93218 9.97923 8.909 9.8807 8.83491V8.83491C8.69311 7.94193 8.07278 7.98181 7.91927 8.01161V8.01161C7.8946 8.0164 7.87585 8.03481 7.86732 8.05844C7.86516 8.06441 7.86303 8.07038 7.8609 8.07636C7.61639 8.76505 7.57904 9.52813 7.75277 10.2425C7.76289 10.2841 7.77371 10.3255 7.78525 10.3667C7.78601 10.3694 7.78677 10.3721 7.78753 10.3748C7.79754 10.4102 7.7902 10.4483 7.7678 10.4776V10.4776C7.75074 10.4998 7.73394 10.5223 7.71741 10.545C7.24479 11.1939 6.98907 12.0213 7.00036 12.8747C7.00036 16.3399 8.80396 17.1358 10.535 17.3711L10.5708 17.3758C11.5347 17.5199 12.4587 17.511 13.4195 17.3479L13.4438 17.345C15.1832 17.1339 16.9996 16.3587 16.9996 12.8747C17.0109 12.0213 16.7552 11.1939 16.2826 10.545C16.2674 10.5242 16.252 10.5035 16.2364 10.483C16.236 10.4825 16.2356 10.482 16.2352 10.4815C16.211 10.4498 16.203 10.4085 16.2138 10.3701V10.3701C16.2257 10.3277 16.2368 10.2852 16.2471 10.2425C16.421 9.52611 16.3815 8.76076 16.1329 8.07176C16.1313 8.06753 16.1298 8.06331 16.1283 8.05909C16.1195 8.03503 16.1004 8.01628 16.0752 8.01142V8.01142C15.921 7.98164 15.3041 7.94381 14.1193 8.83491V8.83491C14.0208 8.90896 13.8933 8.93197 13.7748 8.89804C13.7556 8.89252 13.7363 8.8871 13.717 8.88177Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
17
+ <path d="M3 12C3 4.5885 4.5885 3 12 3C19.4115 3 21 4.5885 21 12C21 19.4115 19.4115 21 12 21C4.5885 21 3 19.4115 3 12Z" stroke="#323232" stroke-width="2"/>
18
+ </svg>
19
+ `;
20
+
21
+ function listExistingVersionIds(root, outputDir) {
22
+ const versionsRoot = path.join(root, outputDir, "docs", "versions");
23
+ if (!existsSync(versionsRoot)) return [];
24
+ return readdirSync(versionsRoot, { withFileTypes: true })
25
+ .filter((entry) => entry.isDirectory())
26
+ .map((entry) => entry.name);
27
+ }
28
+
29
+ function removeLegacySourceViewerFiles(root, outputDir) {
30
+ const versionIds = listExistingVersionIds(root, outputDir);
31
+ for (const versionId of versionIds) {
32
+ for (const language of ["pt", "en", "es"]) {
33
+ for (const fileName of ["source-viewer", "source-viewer.html"]) {
34
+ const legacyPath = path.join(root, outputDir, "docs", "versions", versionId, language, fileName);
35
+ if (existsSync(legacyPath)) {
36
+ rmSync(legacyPath, { force: true });
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ async function writeJson(root, relativePath, data) {
44
+ const absolutePath = path.join(root, relativePath);
45
+ await mkdir(path.dirname(absolutePath), { recursive: true });
46
+ await writeFile(absolutePath, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
47
+ }
48
+
49
+ export async function writeText(root, relativePath, data) {
50
+ const absolutePath = path.join(root, relativePath);
51
+ await mkdir(path.dirname(absolutePath), { recursive: true });
52
+ await writeFile(absolutePath, data, "utf-8");
53
+ }
54
+
55
+ /**
56
+ * Write the local layout artifacts into the standalone layouts home.
57
+ *
58
+ * No layouts folder is ever deleted here. The legacy `<outputDir>/layouts/`
59
+ * folder can hold hand-edited templates and the viewer still reads it, so
60
+ * relocating it is an explicit, confirmed migration rather than a side effect of
61
+ * generating. Switching back to official layouts likewise leaves an existing
62
+ * layouts home in place: `layoutsConfigPathOficial` already decides which source
63
+ * the viewer uses, so the files are inert rather than harmful.
64
+ */
65
+ async function writeLayoutArtifacts(options) {
66
+ const { root, layoutsDir, useLocalLayoutConfig, layouts, artifacts, createThemeTemplate } = options;
67
+
68
+ if (!useLocalLayoutConfig) return;
69
+
70
+ const paths = layoutsArtifactPaths(layoutsDir);
71
+ await writeJson(root, paths.config, artifacts.layoutsConfig);
72
+ await writeJson(root, paths.fallbackConfig, artifacts.fallbackLayoutsConfig);
73
+ for (const layout of layouts) {
74
+ await writeJson(root, `${paths.root}/${layout.file}`, createThemeTemplate(layout));
75
+ }
76
+ }
77
+
78
+ export async function writeConfigOnlyOutput(options) {
79
+ const {
80
+ root,
81
+ pkgRoot,
82
+ outputDir,
83
+ artifacts,
84
+ useLocalLayoutConfig,
85
+ layoutsDir,
86
+ layouts,
87
+ createThemeTemplate,
88
+ } = options;
89
+
90
+ // Keep only versioned docs output in docs/, removing legacy root language folders.
91
+ for (const legacyLanguageDir of ["en", "pt", "es"]) {
92
+ const legacyPath = path.join(root, outputDir, "docs", legacyLanguageDir);
93
+ if (existsSync(legacyPath)) {
94
+ rmSync(legacyPath, { recursive: true, force: true });
95
+ }
96
+ }
97
+
98
+ await writeJson(root, `${outputDir}/config.json`, artifacts.rootConfig);
99
+ await writeText(root, `${outputDir}/icon.svg`, DEFAULT_ICON_SVG);
100
+ await writeLayoutArtifacts({
101
+ root,
102
+ layoutsDir,
103
+ useLocalLayoutConfig,
104
+ layouts,
105
+ artifacts,
106
+ createThemeTemplate,
107
+ });
108
+
109
+ for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
110
+ await writeJson(root, `${outputDir}/docs/versions/${versionId}/config.json`, versionConfig);
111
+ }
112
+
113
+ removeLegacySourceViewerFiles(root, outputDir);
114
+
115
+ for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
116
+ const versionRoutesMd = versionConfig["routes-md"] ?? versionConfig.routes ?? [];
117
+ for (const route of versionRoutesMd) {
118
+ for (const docPath of Object.values(route.path ?? {})) {
119
+ const fileName = path.basename(docPath);
120
+ const key = parseDocFileToKey(fileName);
121
+ const language = extractLanguageFromPath(docPath);
122
+ const content = key && language ? artifacts.docs?.[language]?.[key] : undefined;
123
+ if (!content) continue;
124
+ const versionedContent = withVersionBadge(content, versionId, language);
125
+ await writeText(root, normalizeToOutputPath(outputDir, docPath), versionedContent);
126
+ }
127
+ }
128
+
129
+ const versionRoutesHtml = versionConfig["routes-html"] ?? [];
130
+ const docsHtml = artifacts.docsHtml ?? {};
131
+ for (const route of versionRoutesHtml) {
132
+ if (route.url) continue;
133
+ for (const docPath of Object.values(route.path ?? {})) {
134
+ const fileName = path.basename(docPath);
135
+ const key = parseHtmlFileToKey(fileName);
136
+ const language = extractLanguageFromPath(docPath);
137
+ const content = key && language ? docsHtml[key]?.[language] : undefined;
138
+ if (!content) continue;
139
+ const normalizedHtmlPath = normalizeToOutputPath(outputDir, docPath);
140
+ await writeText(root, normalizedHtmlPath, content);
141
+ // Backward-compatible alias for tools or users that still expect ".html".
142
+ if (!path.extname(docPath)) {
143
+ await writeText(root, `${normalizedHtmlPath}.html`, content);
144
+ }
145
+ }
146
+ }
147
+
148
+ // Ensure version folders always include an index file.
149
+ for (const language of ["pt", "en", "es"]) {
150
+ const fallbackIndex = artifacts.docs?.[language]?.index;
151
+ if (!fallbackIndex) continue;
152
+ const versionIndexPath = `${outputDir}/docs/versions/${versionId}/${language}/index.md`;
153
+ if (!existsSync(path.join(root, versionIndexPath))) {
154
+ const versionedFallbackIndex = withVersionBadge(fallbackIndex, versionId, language);
155
+ await writeText(root, versionIndexPath, versionedFallbackIndex);
156
+ }
157
+ }
158
+ }
159
+ }
@@ -1,129 +1,129 @@
1
- function sanitizeDocsPath(docsPath) {
2
- if (!docsPath || typeof docsPath !== "string") return "";
3
- const segment = docsPath.replace(/^\/+|\/+$/g, "").trim();
4
- return /^[A-Za-z0-9._-]+$/.test(segment) ? segment : "";
5
- }
6
-
7
- export async function ensureGitHubPagesWorkflow(getCurrentGitBranch, writeText, docsPath = "") {
8
- const pathSegment = sanitizeDocsPath(docsPath);
9
- const buildStepsBlock =
10
- pathSegment
11
- ? ` - name: Build static site with target repository path
12
- run: pnpm exec next build frontend && mv frontend/out out
13
- working-directory: .gitpagedocs-runtime
14
- env:
15
- GITPAGEDOCS_PATH: "${pathSegment}"
16
-
17
- - name: Relocate output to custom docs path
18
- run: |
19
- mkdir -p .gitpagedocs-runtime/out_new/${pathSegment}
20
- mv .gitpagedocs-runtime/out/* .gitpagedocs-runtime/out_new/${pathSegment}/
21
- rm -rf .gitpagedocs-runtime/out
22
- mv .gitpagedocs-runtime/out_new .gitpagedocs-runtime/out
23
-
24
- - name: Redirect site root to custom docs path
25
- run: printf '%s' '<!doctype html><meta http-equiv="refresh" content="0; url=./${pathSegment}/"><title>Redirecting</title><a href="./${pathSegment}/">Documentation</a>' > .gitpagedocs-runtime/out/index.html`
26
- : ` - name: Build static site with target repository path
27
- run: pnpm exec next build frontend && mv frontend/out out
28
- working-directory: .gitpagedocs-runtime`;
29
- const currentBranch = getCurrentGitBranch();
30
- const workflowPath = ".github/workflows/gitpagedocs-pages.yml";
31
- const workflowContent = `name: Deploy GitPageDocs
32
-
33
- on:
34
- push:
35
- branches: ["${currentBranch}"]
36
- workflow_dispatch:
37
-
38
- permissions:
39
- contents: read
40
- pages: write
41
- id-token: write
42
-
43
- concurrency:
44
- group: "pages"
45
- cancel-in-progress: false
46
-
47
- jobs:
48
- build:
49
- runs-on: ubuntu-latest
50
- permissions:
51
- contents: read
52
- pages: write
53
- id-token: write
54
- env:
55
- GITHUB_ACTIONS: "true"
56
- GITHUB_REPOSITORY: \${{ github.repository }}
57
- GITPAGEDOCS_REPOSITORY_SEARCH: "true"
58
- steps:
59
- - name: Checkout target repository
60
- uses: actions/checkout@v4
61
-
62
- - name: Setup pnpm
63
- uses: pnpm/action-setup@v4
64
-
65
- - name: Setup Node
66
- uses: actions/setup-node@v4
67
- with:
68
- node-version: "24"
69
-
70
- - name: Setup Pages
71
- uses: actions/configure-pages@v5
72
- with:
73
- enablement: true
74
-
75
- - name: Prepare runtime source
76
- run: |
77
- git clone --depth 1 https://github.com/Vidigal-code/git-page-docs.git .gitpagedocs-runtime
78
- cp .gitpagedocs-runtime/gitpagedocs/icon.svg /tmp/default-icon.svg 2>/dev/null || true
79
- if [ -d gitpagelayouts ]; then
80
- rm -rf .gitpagedocs-runtime/gitpagelayouts
81
- cp -R gitpagelayouts .gitpagedocs-runtime/gitpagelayouts
82
- fi
83
- if [ -d gitpagedocs ]; then
84
- rm -rf .gitpagedocs-runtime/gitpagedocs
85
- cp -R gitpagedocs .gitpagedocs-runtime/gitpagedocs
86
- fi
87
- mkdir -p .gitpagedocs-runtime/public
88
- if [ -f icon.svg ]; then
89
- cp icon.svg .gitpagedocs-runtime/public/icon.svg
90
- elif [ -f gitpagedocs/icon.svg ]; then
91
- cp gitpagedocs/icon.svg .gitpagedocs-runtime/public/icon.svg
92
- elif [ -f /tmp/default-icon.svg ]; then
93
- cp /tmp/default-icon.svg .gitpagedocs-runtime/public/icon.svg
94
- fi
95
-
96
- - name: Install runtime dependencies
97
- run: pnpm install --frozen-lockfile
98
- working-directory: .gitpagedocs-runtime
99
-
100
- ${buildStepsBlock}
101
-
102
- - name: Add .nojekyll
103
- run: touch .gitpagedocs-runtime/out/.nojekyll 2>/dev/null || mkdir -p .gitpagedocs-runtime/out && touch .gitpagedocs-runtime/out/.nojekyll
104
-
105
- - name: Upload artifact
106
- uses: actions/upload-pages-artifact@v3
107
- with:
108
- path: ./.gitpagedocs-runtime/out
109
-
110
- deploy:
111
- environment:
112
- name: github-pages
113
- url: \${{ steps.deployment.outputs.page_url }}
114
- runs-on: ubuntu-latest
115
- needs: build
116
- permissions:
117
- pages: write
118
- id-token: write
119
- steps:
120
- - name: Deploy to GitHub Pages
121
- id: deployment
122
- uses: actions/deploy-pages@v4
123
- with:
124
- timeout: 900000
125
- error_count: 30
126
- reporting_interval: 10000
127
- `;
128
- await writeText(workflowPath, workflowContent);
129
- }
1
+ function sanitizeDocsPath(docsPath) {
2
+ if (!docsPath || typeof docsPath !== "string") return "";
3
+ const segment = docsPath.replace(/^\/+|\/+$/g, "").trim();
4
+ return /^[A-Za-z0-9._-]+$/.test(segment) ? segment : "";
5
+ }
6
+
7
+ export async function ensureGitHubPagesWorkflow(getCurrentGitBranch, writeText, docsPath = "") {
8
+ const pathSegment = sanitizeDocsPath(docsPath);
9
+ const buildStepsBlock =
10
+ pathSegment
11
+ ? ` - name: Build static site with target repository path
12
+ run: pnpm exec next build frontend && mv frontend/out out
13
+ working-directory: .gitpagedocs-runtime
14
+ env:
15
+ GITPAGEDOCS_PATH: "${pathSegment}"
16
+
17
+ - name: Relocate output to custom docs path
18
+ run: |
19
+ mkdir -p .gitpagedocs-runtime/out_new/${pathSegment}
20
+ mv .gitpagedocs-runtime/out/* .gitpagedocs-runtime/out_new/${pathSegment}/
21
+ rm -rf .gitpagedocs-runtime/out
22
+ mv .gitpagedocs-runtime/out_new .gitpagedocs-runtime/out
23
+
24
+ - name: Redirect site root to custom docs path
25
+ run: printf '%s' '<!doctype html><meta http-equiv="refresh" content="0; url=./${pathSegment}/"><title>Redirecting</title><a href="./${pathSegment}/">Documentation</a>' > .gitpagedocs-runtime/out/index.html`
26
+ : ` - name: Build static site with target repository path
27
+ run: pnpm exec next build frontend && mv frontend/out out
28
+ working-directory: .gitpagedocs-runtime`;
29
+ const currentBranch = getCurrentGitBranch();
30
+ const workflowPath = ".github/workflows/gitpagedocs-pages.yml";
31
+ const workflowContent = `name: Deploy GitPageDocs
32
+
33
+ on:
34
+ push:
35
+ branches: ["${currentBranch}"]
36
+ workflow_dispatch:
37
+
38
+ permissions:
39
+ contents: read
40
+ pages: write
41
+ id-token: write
42
+
43
+ concurrency:
44
+ group: "pages"
45
+ cancel-in-progress: false
46
+
47
+ jobs:
48
+ build:
49
+ runs-on: ubuntu-latest
50
+ permissions:
51
+ contents: read
52
+ pages: write
53
+ id-token: write
54
+ env:
55
+ GITHUB_ACTIONS: "true"
56
+ GITHUB_REPOSITORY: \${{ github.repository }}
57
+ GITPAGEDOCS_REPOSITORY_SEARCH: "true"
58
+ steps:
59
+ - name: Checkout target repository
60
+ uses: actions/checkout@v4
61
+
62
+ - name: Setup pnpm
63
+ uses: pnpm/action-setup@v4
64
+
65
+ - name: Setup Node
66
+ uses: actions/setup-node@v4
67
+ with:
68
+ node-version: "24"
69
+
70
+ - name: Setup Pages
71
+ uses: actions/configure-pages@v5
72
+ with:
73
+ enablement: true
74
+
75
+ - name: Prepare runtime source
76
+ run: |
77
+ git clone --depth 1 https://github.com/Vidigal-code/git-page-docs.git .gitpagedocs-runtime
78
+ cp .gitpagedocs-runtime/gitpagedocs/icon.svg /tmp/default-icon.svg 2>/dev/null || true
79
+ if [ -d gitpagelayouts ]; then
80
+ rm -rf .gitpagedocs-runtime/gitpagelayouts
81
+ cp -R gitpagelayouts .gitpagedocs-runtime/gitpagelayouts
82
+ fi
83
+ if [ -d gitpagedocs ]; then
84
+ rm -rf .gitpagedocs-runtime/gitpagedocs
85
+ cp -R gitpagedocs .gitpagedocs-runtime/gitpagedocs
86
+ fi
87
+ mkdir -p .gitpagedocs-runtime/public
88
+ if [ -f icon.svg ]; then
89
+ cp icon.svg .gitpagedocs-runtime/public/icon.svg
90
+ elif [ -f gitpagedocs/icon.svg ]; then
91
+ cp gitpagedocs/icon.svg .gitpagedocs-runtime/public/icon.svg
92
+ elif [ -f /tmp/default-icon.svg ]; then
93
+ cp /tmp/default-icon.svg .gitpagedocs-runtime/public/icon.svg
94
+ fi
95
+
96
+ - name: Install runtime dependencies
97
+ run: pnpm install --frozen-lockfile
98
+ working-directory: .gitpagedocs-runtime
99
+
100
+ ${buildStepsBlock}
101
+
102
+ - name: Add .nojekyll
103
+ run: touch .gitpagedocs-runtime/out/.nojekyll 2>/dev/null || mkdir -p .gitpagedocs-runtime/out && touch .gitpagedocs-runtime/out/.nojekyll
104
+
105
+ - name: Upload artifact
106
+ uses: actions/upload-pages-artifact@v3
107
+ with:
108
+ path: ./.gitpagedocs-runtime/out
109
+
110
+ deploy:
111
+ environment:
112
+ name: github-pages
113
+ url: \${{ steps.deployment.outputs.page_url }}
114
+ runs-on: ubuntu-latest
115
+ needs: build
116
+ permissions:
117
+ pages: write
118
+ id-token: write
119
+ steps:
120
+ - name: Deploy to GitHub Pages
121
+ id: deployment
122
+ uses: actions/deploy-pages@v4
123
+ with:
124
+ timeout: 900000
125
+ error_count: 30
126
+ reporting_interval: 10000
127
+ `;
128
+ await writeText(workflowPath, workflowContent);
129
+ }
package/start.mjs CHANGED
@@ -1,12 +1,12 @@
1
- #!/usr/bin/env node
2
- import { spawn } from "child_process";
3
-
4
- const env = { ...process.env, GITPAGEDOCS_REPOSITORY_SEARCH: "true" };
5
- // The Next app lives in frontend/, so `next build` emits to frontend/.next —
6
- // point `next start` at the same directory (matches `next build frontend`).
7
- const child = spawn("npx", ["next", "start", "frontend"], {
8
- stdio: "inherit",
9
- env,
10
- shell: true,
11
- });
12
- child.on("exit", (code) => process.exit(code ?? 0));
1
+ #!/usr/bin/env node
2
+ import { spawn } from "child_process";
3
+
4
+ const env = { ...process.env, GITPAGEDOCS_REPOSITORY_SEARCH: "true" };
5
+ // The Next app lives in frontend/, so `next build` emits to frontend/.next —
6
+ // point `next start` at the same directory (matches `next build frontend`).
7
+ const child = spawn("npx", ["next", "start", "frontend"], {
8
+ stdio: "inherit",
9
+ env,
10
+ shell: true,
11
+ });
12
+ child.on("exit", (code) => process.exit(code ?? 0));
package/ui/logger.mjs CHANGED
@@ -1,9 +1,9 @@
1
- /** Consistent log formatting */
2
-
3
- export function logSuccess(msg) {
4
- console.log(` [ok] ${msg}`);
5
- }
6
-
7
- export function logInfo(msg) {
8
- console.log(` ${msg}`);
9
- }
1
+ /** Consistent log formatting */
2
+
3
+ export function logSuccess(msg) {
4
+ console.log(` [ok] ${msg}`);
5
+ }
6
+
7
+ export function logInfo(msg) {
8
+ console.log(` ${msg}`);
9
+ }