@gitpagedocs/cli 1.1.54 → 1.1.55
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/README.md +30 -30
- package/builders/config-orchestrator.mjs +1 -7
- package/builders/root-config-builder.mjs +12 -9
- package/builders/route-builders.mjs +25 -0
- package/builders/theme-template.mjs +1 -1
- package/builders/version-config-builder.mjs +62 -56
- package/content/docs-en.mjs +23 -22
- package/content/docs-es.mjs +20 -19
- package/content/docs-pt.mjs +20 -19
- package/contracts/doc-versions.mjs +3 -1
- package/data/i18n-langmenu.mjs +47 -11
- package/data/path-mappings.mjs +2 -10
- package/data/route-metas.mjs +21 -1
- package/package.json +3 -3
- package/runtime/output.mjs +35 -11
- package/runtime/workflow.mjs +24 -61
- package/start.mjs +1 -1
- package/builders/source-viewer.mjs +0 -330
package/data/i18n-langmenu.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const defaultLangMenu = {
|
|
1
|
+
export const defaultLangMenu = {
|
|
2
2
|
pt: {
|
|
3
3
|
pt: "Portugues",
|
|
4
4
|
en: "Ingles",
|
|
@@ -15,11 +15,23 @@ export const defaultLangMenu = {
|
|
|
15
15
|
typeToNavigate: "Digite para navegar...",
|
|
16
16
|
noNavigationResults: "Nenhum resultado de navegacao.",
|
|
17
17
|
focusMode: "Modo foco",
|
|
18
|
-
versionLinksLabel: "Links do repositorio",
|
|
19
|
-
titleHeaderMenuMd: "Markdown",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
versionLinksLabel: "Links do repositorio",
|
|
19
|
+
titleHeaderMenuMd: "Markdown",
|
|
20
|
+
titleHeaderMenuSourceViewer: "Codigo fonte",
|
|
21
|
+
titleHeaderMenuVideo: "Vídeo",
|
|
22
|
+
titleHeaderMenuAudio: "Áudio",
|
|
23
|
+
titleHeaderMenuHtml: "Páginas",
|
|
24
|
+
sourceViewerBranchLabel: "Branch",
|
|
25
|
+
sourceViewerFilterLabel: "Filtrar arquivos",
|
|
26
|
+
sourceViewerClearLabel: "Limpar",
|
|
27
|
+
sourceViewerLoadingTree: "Carregando arvore do repositorio...",
|
|
28
|
+
sourceViewerLoadingFile: "Carregando arquivo...",
|
|
29
|
+
sourceViewerNotFound: "Repositorio, branch ou arvore de codigo nao encontrado.",
|
|
30
|
+
sourceViewerFileError: "Nao foi possivel carregar o arquivo.",
|
|
31
|
+
sourceViewerEmpty: "Nenhuma entrada encontrada.",
|
|
32
|
+
sourceViewerSelectFile: "Selecione um arquivo",
|
|
33
|
+
sourceViewerPreview: "Preview",
|
|
34
|
+
sourceViewerCode: "Codigo",
|
|
23
35
|
lastUpdateVersionLabel: "Ultima versao de atualizacao",
|
|
24
36
|
darkMode: "Modo escuro",
|
|
25
37
|
lightMode: "Modo claro",
|
|
@@ -118,9 +130,21 @@ export const defaultLangMenu = {
|
|
|
118
130
|
focusMode: "Focus mode",
|
|
119
131
|
versionLinksLabel: "Repository links",
|
|
120
132
|
titleHeaderMenuMd: "Markdown",
|
|
133
|
+
titleHeaderMenuSourceViewer: "Source code",
|
|
121
134
|
titleHeaderMenuVideo: "Video",
|
|
122
135
|
titleHeaderMenuAudio: "Audio",
|
|
123
136
|
titleHeaderMenuHtml: "Pages",
|
|
137
|
+
sourceViewerBranchLabel: "Branch",
|
|
138
|
+
sourceViewerFilterLabel: "Filter files",
|
|
139
|
+
sourceViewerClearLabel: "Clear",
|
|
140
|
+
sourceViewerLoadingTree: "Loading source tree...",
|
|
141
|
+
sourceViewerLoadingFile: "Loading file...",
|
|
142
|
+
sourceViewerNotFound: "Repository, branch, or source tree was not found.",
|
|
143
|
+
sourceViewerFileError: "File could not be loaded.",
|
|
144
|
+
sourceViewerEmpty: "No entries found.",
|
|
145
|
+
sourceViewerSelectFile: "Select a file",
|
|
146
|
+
sourceViewerPreview: "Preview",
|
|
147
|
+
sourceViewerCode: "Code",
|
|
124
148
|
lastUpdateVersionLabel: "Last update version",
|
|
125
149
|
darkMode: "Dark mode",
|
|
126
150
|
lightMode: "Light mode",
|
|
@@ -217,11 +241,23 @@ export const defaultLangMenu = {
|
|
|
217
241
|
typeToNavigate: "Escribe para navegar...",
|
|
218
242
|
noNavigationResults: "Sin resultados de navegacion.",
|
|
219
243
|
focusMode: "Modo foco",
|
|
220
|
-
versionLinksLabel: "Enlaces del repositorio",
|
|
221
|
-
titleHeaderMenuMd: "Markdown",
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
244
|
+
versionLinksLabel: "Enlaces del repositorio",
|
|
245
|
+
titleHeaderMenuMd: "Markdown",
|
|
246
|
+
titleHeaderMenuSourceViewer: "Codigo fuente",
|
|
247
|
+
titleHeaderMenuVideo: "Vídeo",
|
|
248
|
+
titleHeaderMenuAudio: "Áudio",
|
|
249
|
+
titleHeaderMenuHtml: "Páginas",
|
|
250
|
+
sourceViewerBranchLabel: "Branch",
|
|
251
|
+
sourceViewerFilterLabel: "Filtrar archivos",
|
|
252
|
+
sourceViewerClearLabel: "Limpiar",
|
|
253
|
+
sourceViewerLoadingTree: "Cargando arbol del repositorio...",
|
|
254
|
+
sourceViewerLoadingFile: "Cargando archivo...",
|
|
255
|
+
sourceViewerNotFound: "Repositorio, branch o arbol de codigo no encontrado.",
|
|
256
|
+
sourceViewerFileError: "No se pudo cargar el archivo.",
|
|
257
|
+
sourceViewerEmpty: "No se encontraron entradas.",
|
|
258
|
+
sourceViewerSelectFile: "Selecciona un archivo",
|
|
259
|
+
sourceViewerPreview: "Preview",
|
|
260
|
+
sourceViewerCode: "Codigo",
|
|
225
261
|
lastUpdateVersionLabel: "Ultima version de actualizacion",
|
|
226
262
|
darkMode: "Modo oscuro",
|
|
227
263
|
lightMode: "Modo claro",
|
package/data/path-mappings.mjs
CHANGED
|
@@ -10,6 +10,7 @@ export const ROUTE_PATHS = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const VIDEO_IDS = ["bdIJkGr2NV0", "c67GaAkf1BE", "N3my6W_Rdwg", "r8jQ9hVA2qs"];
|
|
13
|
+
export const AUDIO_IDS = ["0w80F8FffQ4"];
|
|
13
14
|
|
|
14
15
|
export const PAGE2_AUDIO = {
|
|
15
16
|
enabled: true,
|
|
@@ -19,16 +20,7 @@ export const PAGE2_AUDIO = {
|
|
|
19
20
|
{
|
|
20
21
|
url: "https://www.youtube.com/watch?v=0w80F8FffQ4",
|
|
21
22
|
type: "youtube",
|
|
22
|
-
title: { pt: "
|
|
23
|
+
title: { pt: "Musica pagina 2", en: "Page 2 music", es: "Musica pagina 2" },
|
|
23
24
|
},
|
|
24
25
|
],
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
-
export const SOURCE_VIEWER_META = {
|
|
28
|
-
titles: { pt: "Código fonte", en: "Source code", es: "Código fuente" },
|
|
29
|
-
descriptions: {
|
|
30
|
-
pt: "Visualizar código-fonte do projeto",
|
|
31
|
-
en: "View project source code",
|
|
32
|
-
es: "Ver código fuente del proyecto",
|
|
33
|
-
},
|
|
34
|
-
};
|
package/data/route-metas.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Route and video metadata for doc versions */
|
|
2
2
|
|
|
3
|
-
export const DEFAULT_HIERARCHY = { md: 0,
|
|
3
|
+
export const DEFAULT_HIERARCHY = { md: 0, "source-viewer": 1, html: 2, video: 3, audio: 4 };
|
|
4
4
|
|
|
5
5
|
export const ROUTE_META_ID1 = {
|
|
6
6
|
titles: { pt: "Primeiros passos", en: "Getting Started", es: "Primeros pasos" },
|
|
@@ -36,6 +36,26 @@ export const ROUTE_META_ID6 = {
|
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export const SOURCE_VIEWER_META = {
|
|
40
|
+
id: 7,
|
|
41
|
+
titles: { pt: "Codigo fonte", en: "Source code", es: "Codigo fuente" },
|
|
42
|
+
descriptions: {
|
|
43
|
+
pt: "Explore a arvore do repositorio, navegue por pastas e visualize arquivos diretamente na documentacao.",
|
|
44
|
+
en: "Explore the repository tree, browse folders, and preview files directly inside the documentation.",
|
|
45
|
+
es: "Explora el arbol del repositorio, navega por carpetas y previsualiza archivos directamente en la documentacion.",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const AUDIO_META_ID12 = {
|
|
50
|
+
id: 12,
|
|
51
|
+
title: { pt: "Trilha de audio", en: "Audio track", es: "Pista de audio" },
|
|
52
|
+
description: {
|
|
53
|
+
pt: "Ouça uma faixa de exemplo diretamente na documentacao.",
|
|
54
|
+
en: "Listen to a sample track directly inside the documentation.",
|
|
55
|
+
es: "Escucha una pista de ejemplo directamente en la documentacion.",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
39
59
|
export const VIDEO_META_ID1 = {
|
|
40
60
|
title: { pt: "Interactive vs non-interactive modes | Copilot CLI for beginners", en: "Interactive vs non-interactive modes | Copilot CLI for beginners", es: "Interactive vs non-interactive modes | Copilot CLI for beginners" },
|
|
41
61
|
description: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitpagedocs/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.55",
|
|
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.54",
|
|
33
|
+
"@gitpagedocs/tools": "^1.1.54",
|
|
34
34
|
"tsx": "^4.21.0"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
package/runtime/output.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, rmSync } from "node:fs";
|
|
1
|
+
import { existsSync, readdirSync, rmSync } from "node:fs";
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import {
|
|
@@ -15,15 +15,37 @@ function isWithin(parent, child) {
|
|
|
15
15
|
return !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const DEFAULT_ICON_SVG = `<?xml version="1.0" encoding="utf-8"?>
|
|
18
|
+
const DEFAULT_ICON_SVG = `<?xml version="1.0" encoding="utf-8"?>
|
|
19
19
|
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
20
20
|
<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"/>
|
|
21
21
|
<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"/>
|
|
22
22
|
<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"/>
|
|
23
|
-
</svg>
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
</svg>
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
function listExistingVersionIds(root, outputDir) {
|
|
27
|
+
const versionsRoot = path.join(root, outputDir, "docs", "versions");
|
|
28
|
+
if (!existsSync(versionsRoot)) return [];
|
|
29
|
+
return readdirSync(versionsRoot, { withFileTypes: true })
|
|
30
|
+
.filter((entry) => entry.isDirectory())
|
|
31
|
+
.map((entry) => entry.name);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function removeLegacySourceViewerFiles(root, outputDir) {
|
|
35
|
+
const versionIds = listExistingVersionIds(root, outputDir);
|
|
36
|
+
for (const versionId of versionIds) {
|
|
37
|
+
for (const language of ["pt", "en", "es"]) {
|
|
38
|
+
for (const fileName of ["source-viewer", "source-viewer.html"]) {
|
|
39
|
+
const legacyPath = path.join(root, outputDir, "docs", "versions", versionId, language, fileName);
|
|
40
|
+
if (existsSync(legacyPath)) {
|
|
41
|
+
rmSync(legacyPath, { force: true });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function writeJson(root, relativePath, data) {
|
|
27
49
|
const absolutePath = path.join(root, relativePath);
|
|
28
50
|
await mkdir(path.dirname(absolutePath), { recursive: true });
|
|
29
51
|
await writeFile(absolutePath, `${JSON.stringify(data, null, 2)}\n`, "utf-8");
|
|
@@ -71,11 +93,13 @@ export async function writeConfigOnlyOutput(options) {
|
|
|
71
93
|
rmSync(layoutsPath, { recursive: true, force: true });
|
|
72
94
|
}
|
|
73
95
|
|
|
74
|
-
for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
|
|
75
|
-
await writeJson(root, `${outputDir}/docs/versions/${versionId}/config.json`, versionConfig);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
|
|
97
|
+
await writeJson(root, `${outputDir}/docs/versions/${versionId}/config.json`, versionConfig);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
removeLegacySourceViewerFiles(root, outputDir);
|
|
101
|
+
|
|
102
|
+
for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
|
|
79
103
|
const versionRoutesMd = versionConfig["routes-md"] ?? versionConfig.routes ?? [];
|
|
80
104
|
for (const route of versionRoutesMd) {
|
|
81
105
|
for (const docPath of Object.values(route.path ?? {})) {
|
package/runtime/workflow.mjs
CHANGED
|
@@ -6,30 +6,23 @@ function sanitizeDocsPath(docsPath) {
|
|
|
6
6
|
|
|
7
7
|
export async function ensureGitHubPagesWorkflow(getCurrentGitBranch, writeText, docsPath = "") {
|
|
8
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- name: Relocate output to custom docs path
|
|
21
|
-
run: |
|
|
22
|
-
mkdir -p .gitpagedocs-runtime/out_new/${pathSegment}
|
|
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}
|
|
23
20
|
mv .gitpagedocs-runtime/out/* .gitpagedocs-runtime/out_new/${pathSegment}/
|
|
24
21
|
rm -rf .gitpagedocs-runtime/out
|
|
25
22
|
mv .gitpagedocs-runtime/out_new .gitpagedocs-runtime/out`
|
|
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
|
-
env:
|
|
30
|
-
GITHUB_ACTIONS: "true"
|
|
31
|
-
GITHUB_REPOSITORY: \${{ github.repository }}
|
|
32
|
-
GITPAGEDOCS_REPOSITORY_SEARCH: "true"`;
|
|
23
|
+
: ` - name: Build static site with target repository path
|
|
24
|
+
run: pnpm exec next build frontend && mv frontend/out out
|
|
25
|
+
working-directory: .gitpagedocs-runtime`;
|
|
33
26
|
const currentBranch = getCurrentGitBranch();
|
|
34
27
|
const workflowPath = ".github/workflows/gitpagedocs-pages.yml";
|
|
35
28
|
const workflowContent = `name: Deploy GitPageDocs
|
|
@@ -49,9 +42,13 @@ concurrency:
|
|
|
49
42
|
cancel-in-progress: true
|
|
50
43
|
|
|
51
44
|
jobs:
|
|
52
|
-
build:
|
|
53
|
-
runs-on: ubuntu-latest
|
|
54
|
-
|
|
45
|
+
build:
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
env:
|
|
48
|
+
GITHUB_ACTIONS: "true"
|
|
49
|
+
GITHUB_REPOSITORY: \${{ github.repository }}
|
|
50
|
+
GITPAGEDOCS_REPOSITORY_SEARCH: "true"
|
|
51
|
+
steps:
|
|
55
52
|
- name: Checkout target repository
|
|
56
53
|
uses: actions/checkout@v4
|
|
57
54
|
|
|
@@ -87,43 +84,9 @@ jobs:
|
|
|
87
84
|
run: pnpm install --frozen-lockfile
|
|
88
85
|
working-directory: .gitpagedocs-runtime
|
|
89
86
|
|
|
90
|
-
${buildStepsBlock}
|
|
91
|
-
|
|
92
|
-
- name:
|
|
93
|
-
env:
|
|
94
|
-
GITHUB_REPOSITORY: \${{ github.repository }}
|
|
95
|
-
run: |
|
|
96
|
-
node <<'NODE'
|
|
97
|
-
const fs = require('fs');
|
|
98
|
-
const path = require('path');
|
|
99
|
-
const pathSegment = ${JSON.stringify(pathSegment)};
|
|
100
|
-
const repoName = (process.env.GITHUB_REPOSITORY || '').split('/')[1] || '';
|
|
101
|
-
const isUserPage = repoName.toLowerCase().endsWith('.github.io');
|
|
102
|
-
const rootRedirectBase = pathSegment;
|
|
103
|
-
const cfgPath = path.join('.gitpagedocs-runtime', 'gitpagedocs', 'config.json');
|
|
104
|
-
if (!fs.existsSync(cfgPath)) process.exit(0);
|
|
105
|
-
const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'));
|
|
106
|
-
const defaultVersion = cfg?.site?.docsVersion || cfg?.VersionControl?.versions?.[0]?.id || '1.1.0';
|
|
107
|
-
const defaultLang = cfg?.site?.defaultLanguage || 'en';
|
|
108
|
-
const redirectTargetRoot = rootRedirectBase
|
|
109
|
-
? './' + rootRedirectBase + '/v/' + defaultVersion + '/?lang=' + defaultLang
|
|
110
|
-
: './v/' + defaultVersion + '/?lang=' + defaultLang;
|
|
111
|
-
const redirectTargetProject = './v/' + defaultVersion + '/?lang=' + defaultLang;
|
|
112
|
-
const rootHtml = '<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=' + redirectTargetRoot + '"/><script>window.location.replace("' + redirectTargetRoot + '" + (window.location.search || ""));</script></head><body>Redirecting...</body></html>';
|
|
113
|
-
fs.writeFileSync(path.join('.gitpagedocs-runtime', 'out', 'index.html'), rootHtml);
|
|
114
|
-
const projectPathSegments = [];
|
|
115
|
-
if (repoName && !isUserPage) projectPathSegments.push(repoName);
|
|
116
|
-
if (pathSegment) projectPathSegments.push(pathSegment);
|
|
117
|
-
if (projectPathSegments.length > 0) {
|
|
118
|
-
const projectIndexPath = path.join('.gitpagedocs-runtime', 'out', ...projectPathSegments, 'index.html');
|
|
119
|
-
if (fs.existsSync(path.dirname(projectIndexPath))) {
|
|
120
|
-
const projectHtml = '<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=' + redirectTargetProject + '"/><script>window.location.replace("' + redirectTargetProject + '" + (window.location.search || ""));</script></head><body>Redirecting...</body></html>';
|
|
121
|
-
fs.writeFileSync(projectIndexPath, projectHtml);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
NODE
|
|
125
|
-
|
|
126
|
-
- name: Add .nojekyll
|
|
87
|
+
${buildStepsBlock}
|
|
88
|
+
|
|
89
|
+
- name: Add .nojekyll
|
|
127
90
|
run: touch .gitpagedocs-runtime/out/.nojekyll 2>/dev/null || mkdir -p .gitpagedocs-runtime/out && touch .gitpagedocs-runtime/out/.nojekyll
|
|
128
91
|
|
|
129
92
|
- name: Upload artifact
|
package/start.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from "child_process";
|
|
3
3
|
|
|
4
|
-
const env = { ...process.env, GITPAGEDOCS_REPOSITORY_SEARCH: "
|
|
4
|
+
const env = { ...process.env, GITPAGEDOCS_REPOSITORY_SEARCH: "true" };
|
|
5
5
|
// The Next app lives in frontend/, so `next build` emits to frontend/.next —
|
|
6
6
|
// point `next start` at the same directory (matches `next build frontend`).
|
|
7
7
|
const child = spawn("npx", ["next", "start", "frontend"], {
|