@gitpagedocs/cli 1.1.61 → 1.1.63

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 (72) hide show
  1. package/README.md +193 -191
  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/config-only/handler.mjs +2 -0
  16. package/application/home/handler.mjs +2 -0
  17. package/application/ports/cli-runtime-ports.ts +91 -87
  18. package/application/report/config-only-reporter.mjs +64 -63
  19. package/application/use-cases/dispatch-mode.ts +18 -18
  20. package/builders/config-orchestrator.mjs +34 -34
  21. package/builders/project-links.mjs +50 -26
  22. package/builders/root-config-builder.d.mts +16 -0
  23. package/builders/root-config-builder.mjs +61 -53
  24. package/builders/route-builders.mjs +136 -136
  25. package/builders/theme-template.mjs +76 -76
  26. package/builders/version-config-builder.mjs +186 -186
  27. package/content/docs-en.mjs +549 -545
  28. package/content/docs-es.mjs +462 -460
  29. package/content/docs-pt.mjs +462 -460
  30. package/contracts/doc-versions.mjs +3 -3
  31. package/contracts/index.mjs +10 -0
  32. package/contracts/layouts-paths.d.mts +17 -0
  33. package/contracts/layouts-paths.mjs +68 -0
  34. package/data/default-site-config.mjs +321 -321
  35. package/data/i18n-langmenu.mjs +347 -347
  36. package/data/layouts.mjs +436 -436
  37. package/data/path-mappings.mjs +26 -26
  38. package/data/route-metas.mjs +93 -93
  39. package/data/theme-colors.mjs +443 -443
  40. package/data/urls.mjs +12 -12
  41. package/domain/models/cli-options.ts +33 -18
  42. package/domain/services/layouts-migration.d.mts +15 -0
  43. package/domain/services/layouts-migration.mjs +60 -0
  44. package/home/constants.mjs +4 -4
  45. package/index.mjs +37 -37
  46. package/infrastructure/gitpagedocs-config-file.ts +47 -47
  47. package/infrastructure/home/runtime.mjs +37 -37
  48. package/package.json +3 -3
  49. package/presentation/commands/ai-info.ts +57 -57
  50. package/presentation/commands/config-clear.ts +23 -23
  51. package/presentation/commands/config-info.ts +24 -24
  52. package/presentation/commands/diagnostics.ts +164 -164
  53. package/presentation/commands/docs.ts +37 -37
  54. package/presentation/commands/mcp.ts +20 -20
  55. package/presentation/commands/pages.ts +101 -101
  56. package/presentation/commands/password.ts +62 -62
  57. package/presentation/commands/run-command.ts +70 -70
  58. package/presentation/index.ts +124 -116
  59. package/presentation/options/parser.ts +119 -104
  60. package/presentation/options/resolver.ts +46 -48
  61. package/presentation/options/schema.ts +4 -0
  62. package/presentation/ui/clack.ts +91 -91
  63. package/presentation/ui/layouts-prompts.ts +124 -0
  64. package/presentation/ui/prompts.ts +146 -138
  65. package/presentation/ui/tty.ts +37 -0
  66. package/runtime/git-ops.mjs +110 -110
  67. package/runtime/layouts-migrator.d.mts +11 -0
  68. package/runtime/layouts-migrator.mjs +103 -0
  69. package/runtime/output.mjs +159 -146
  70. package/runtime/workflow.mjs +129 -129
  71. package/start.mjs +12 -12
  72. package/ui/logger.mjs +9 -9
@@ -1,87 +1,91 @@
1
- import type { CliOptions } from "../../domain/models/cli-options";
2
-
3
- export interface BuildArtifactsInput {
4
- useLocalLayoutConfig: boolean;
5
- githubOwner: string;
6
- githubRepo: string;
7
- root: string;
8
- }
9
-
10
- export interface LayoutDefinition {
11
- file: string;
12
- [key: string]: unknown;
13
- }
14
-
15
- export interface BuiltConfigArtifacts {
16
- rootConfig: unknown;
17
- layoutsConfig: unknown;
18
- fallbackLayoutsConfig: unknown;
19
- docs?: Record<string, Record<string, string>>;
20
- docsHtml?: Record<string, Record<string, string>>;
21
- versionConfigs: Record<string, Record<string, unknown>>;
22
- }
23
-
24
- export interface CliRuntimeParams {
25
- root: string;
26
- pkgRoot: string;
27
- prebuiltDir: string;
28
- buildConfigArtifacts: (input: BuildArtifactsInput) => BuiltConfigArtifacts;
29
- createThemeTemplate: (layout: LayoutDefinition) => unknown;
30
- layouts: LayoutDefinition[];
31
- }
32
-
33
- export interface CliCommandContext extends CliRuntimeParams {
34
- options: CliOptions;
35
- }
36
-
37
- export interface CliCommandRunner {
38
- runConfigOnly: (params: CliCommandContext) => Promise<void>;
39
- runHome: (params: CliCommandContext) => Promise<void>;
40
- runAi: (params: CliCommandContext) => Promise<void>;
41
- }
42
-
43
- export interface ConfigOnlyOutputInput {
44
- root: string;
45
- pkgRoot: string;
46
- outputDir: string;
47
- artifacts: BuiltConfigArtifacts;
48
- useLocalLayoutConfig: boolean;
49
- layouts: LayoutDefinition[];
50
- createThemeTemplate: (layout: LayoutDefinition) => unknown;
51
- }
52
-
53
- export interface ConfigOnlyRuntimePort {
54
- hasPath: (absolutePath: string) => boolean;
55
- writeConfigOnlyOutput: (input: ConfigOnlyOutputInput) => Promise<void>;
56
- writeText: (root: string, relativePath: string, data: string) => Promise<void>;
57
- ensureGitHubPagesWorkflow: (
58
- getCurrentGitBranch: () => string,
59
- writeText: (relativePath: string, content: string) => Promise<void>,
60
- docsPath?: string,
61
- ) => Promise<void>;
62
- getCurrentGitBranch: (root: string) => string;
63
- runGitPushForGeneratedArtifacts: (
64
- options: CliOptions,
65
- root: string,
66
- sanitizeSegment: (value: string | undefined | null) => string,
67
- ) => void;
68
- logInfo: (message: string) => void;
69
- }
70
-
71
- export interface HomeRuntimePort {
72
- joinPath: (...parts: string[]) => string;
73
- ensureDirEmpty: (root: string, relativeDir: string) => void;
74
- copyRecursive: (src: string, dest: string) => void;
75
- readDirNames: (absolutePath: string) => string[];
76
- existsPath: (absolutePath: string) => boolean;
77
- runNextBuild: (root: string, env: NodeJS.ProcessEnv) => void;
78
- writeConfigOnlyOutput: (input: ConfigOnlyOutputInput) => Promise<void>;
79
- writeHomeFiles: (
80
- root: string,
81
- outputDir: string,
82
- options: { repositorySearch?: boolean; basePath?: string },
83
- ) => Promise<void>;
84
- writeText: (root: string, relativePath: string, data: string) => Promise<void>;
85
- logSuccess: (message: string) => void;
86
- logInfo: (message: string) => void;
87
- }
1
+ import type { CliOptions } from "../../domain/models/cli-options";
2
+
3
+ export interface BuildArtifactsInput {
4
+ useLocalLayoutConfig: boolean;
5
+ /** Repo-relative layouts home the generated config should reference. */
6
+ layoutsDir: string;
7
+ githubOwner: string;
8
+ githubRepo: string;
9
+ root: string;
10
+ }
11
+
12
+ export interface LayoutDefinition {
13
+ file: string;
14
+ [key: string]: unknown;
15
+ }
16
+
17
+ export interface BuiltConfigArtifacts {
18
+ rootConfig: unknown;
19
+ layoutsConfig: unknown;
20
+ fallbackLayoutsConfig: unknown;
21
+ docs?: Record<string, Record<string, string>>;
22
+ docsHtml?: Record<string, Record<string, string>>;
23
+ versionConfigs: Record<string, Record<string, unknown>>;
24
+ }
25
+
26
+ export interface CliRuntimeParams {
27
+ root: string;
28
+ pkgRoot: string;
29
+ prebuiltDir: string;
30
+ buildConfigArtifacts: (input: BuildArtifactsInput) => BuiltConfigArtifacts;
31
+ createThemeTemplate: (layout: LayoutDefinition) => unknown;
32
+ layouts: LayoutDefinition[];
33
+ }
34
+
35
+ export interface CliCommandContext extends CliRuntimeParams {
36
+ options: CliOptions;
37
+ }
38
+
39
+ export interface CliCommandRunner {
40
+ runConfigOnly: (params: CliCommandContext) => Promise<void>;
41
+ runHome: (params: CliCommandContext) => Promise<void>;
42
+ runAi: (params: CliCommandContext) => Promise<void>;
43
+ }
44
+
45
+ export interface ConfigOnlyOutputInput {
46
+ root: string;
47
+ pkgRoot: string;
48
+ outputDir: string;
49
+ /** Repo-relative layouts home local layouts are written to. */
50
+ layoutsDir: string;
51
+ artifacts: BuiltConfigArtifacts;
52
+ useLocalLayoutConfig: boolean;
53
+ layouts: LayoutDefinition[];
54
+ createThemeTemplate: (layout: LayoutDefinition) => unknown;
55
+ }
56
+
57
+ export interface ConfigOnlyRuntimePort {
58
+ hasPath: (absolutePath: string) => boolean;
59
+ writeConfigOnlyOutput: (input: ConfigOnlyOutputInput) => Promise<void>;
60
+ writeText: (root: string, relativePath: string, data: string) => Promise<void>;
61
+ ensureGitHubPagesWorkflow: (
62
+ getCurrentGitBranch: () => string,
63
+ writeText: (relativePath: string, content: string) => Promise<void>,
64
+ docsPath?: string,
65
+ ) => Promise<void>;
66
+ getCurrentGitBranch: (root: string) => string;
67
+ runGitPushForGeneratedArtifacts: (
68
+ options: CliOptions,
69
+ root: string,
70
+ sanitizeSegment: (value: string | undefined | null) => string,
71
+ ) => void;
72
+ logInfo: (message: string) => void;
73
+ }
74
+
75
+ export interface HomeRuntimePort {
76
+ joinPath: (...parts: string[]) => string;
77
+ ensureDirEmpty: (root: string, relativeDir: string) => void;
78
+ copyRecursive: (src: string, dest: string) => void;
79
+ readDirNames: (absolutePath: string) => string[];
80
+ existsPath: (absolutePath: string) => boolean;
81
+ runNextBuild: (root: string, env: NodeJS.ProcessEnv) => void;
82
+ writeConfigOnlyOutput: (input: ConfigOnlyOutputInput) => Promise<void>;
83
+ writeHomeFiles: (
84
+ root: string,
85
+ outputDir: string,
86
+ options: { repositorySearch?: boolean; basePath?: string },
87
+ ) => Promise<void>;
88
+ writeText: (root: string, relativePath: string, data: string) => Promise<void>;
89
+ logSuccess: (message: string) => void;
90
+ logInfo: (message: string) => void;
91
+ }
@@ -1,63 +1,64 @@
1
- /** Config-only command output messages - SRP: single place for all report messages */
2
- import { resolveRenderingUrl } from "../../builders/project-links.mjs";
3
-
4
- export function reportConfigOnlySuccess(options) {
5
- return [`Generated: ${options.outputDir}/ (config-only)`, "No index.html/index.js generated."];
6
- }
7
-
8
- export function reportLayoutConfig(options) {
9
- if (options.useLocalLayoutConfig) {
10
- return ["Local layouts generated in gitpagedocs/layouts/ (--layoutconfig)."];
11
- } else {
12
- return ["Using official remote layouts config by default (no local gitpagedocs/layouts generated)."];
13
- }
14
- }
15
-
16
- export function reportRenderingUrl(options) {
17
- if (options.githubOwner && options.githubRepo) {
18
- return [
19
- `Configured rendering URL: ${resolveRenderingUrl(options.githubOwner, options.githubRepo)}`,
20
- `Official viewer remains available: https://vidigal-code.github.io/git-page-docs/${options.githubOwner}/${options.githubRepo}?modetheme=light&lang=pt`,
21
- ];
22
- }
23
- return [];
24
- }
25
-
26
- export function reportPushMode() {
27
- return [
28
- "Generated: .github/workflows/gitpagedocs-pages.yml",
29
- "Push mode enabled: committed and pushed gitpagedocs/ + workflow to origin.",
30
- ];
31
- }
32
-
33
- export function reportBuildFlag() {
34
- return ["`--build` keeps compatibility flag but output remains gitpagedocs/."];
35
- }
36
-
37
- export function reportFullOrServeSkipped() {
38
- return ["External commands were skipped (no prebuilt copy and no local serve spawn)."];
39
- }
40
-
41
- export function reportPrebuiltDetected() {
42
- return ["`prebuilt/` detected, but ignored by config-only generator."];
43
- }
44
-
45
- export function reportAll(options, prebuiltDetected) {
46
- const lines = [];
47
- lines.push(...reportConfigOnlySuccess(options));
48
- lines.push(...reportLayoutConfig(options));
49
- lines.push(...reportRenderingUrl(options));
50
- if (options.shouldPush) {
51
- lines.push(...reportPushMode());
52
- }
53
- if (options.isBuild) {
54
- lines.push(...reportBuildFlag());
55
- }
56
- if (options.mode === "full" || options.isServe) {
57
- lines.push(...reportFullOrServeSkipped());
58
- }
59
- if (prebuiltDetected) {
60
- lines.push(...reportPrebuiltDetected());
61
- }
62
- return lines;
63
- }
1
+ /** Config-only command output messages - SRP: single place for all report messages */
2
+ import { resolveRenderingUrl } from "../../builders/project-links.mjs";
3
+ import { normalizeLayoutsDir } from "../../contracts/layouts-paths.mjs";
4
+
5
+ export function reportConfigOnlySuccess(options) {
6
+ return [`Generated: ${options.outputDir}/ (config-only)`, "No index.html/index.js generated."];
7
+ }
8
+
9
+ export function reportLayoutConfig(options) {
10
+ const layoutsDir = normalizeLayoutsDir(options.layoutsDir);
11
+ if (options.useLocalLayoutConfig) {
12
+ return [`Local layouts generated in ${layoutsDir}/ (--layoutconfig).`];
13
+ }
14
+ return [`Using official remote layouts config by default (no local ${layoutsDir}/ generated).`];
15
+ }
16
+
17
+ export function reportRenderingUrl(options) {
18
+ if (options.githubOwner && options.githubRepo) {
19
+ return [
20
+ `Configured rendering URL: ${resolveRenderingUrl(options.githubOwner, options.githubRepo)}`,
21
+ `Official viewer remains available: https://vidigal-code.github.io/git-page-docs/${options.githubOwner}/${options.githubRepo}?modetheme=light&lang=pt`,
22
+ ];
23
+ }
24
+ return [];
25
+ }
26
+
27
+ export function reportPushMode() {
28
+ return [
29
+ "Generated: .github/workflows/gitpagedocs-pages.yml",
30
+ "Push mode enabled: committed and pushed gitpagedocs/ + workflow to origin.",
31
+ ];
32
+ }
33
+
34
+ export function reportBuildFlag() {
35
+ return ["`--build` keeps compatibility flag but output remains gitpagedocs/."];
36
+ }
37
+
38
+ export function reportFullOrServeSkipped() {
39
+ return ["External commands were skipped (no prebuilt copy and no local serve spawn)."];
40
+ }
41
+
42
+ export function reportPrebuiltDetected() {
43
+ return ["`prebuilt/` detected, but ignored by config-only generator."];
44
+ }
45
+
46
+ export function reportAll(options, prebuiltDetected) {
47
+ const lines = [];
48
+ lines.push(...reportConfigOnlySuccess(options));
49
+ lines.push(...reportLayoutConfig(options));
50
+ lines.push(...reportRenderingUrl(options));
51
+ if (options.shouldPush) {
52
+ lines.push(...reportPushMode());
53
+ }
54
+ if (options.isBuild) {
55
+ lines.push(...reportBuildFlag());
56
+ }
57
+ if (options.mode === "full" || options.isServe) {
58
+ lines.push(...reportFullOrServeSkipped());
59
+ }
60
+ if (prebuiltDetected) {
61
+ lines.push(...reportPrebuiltDetected());
62
+ }
63
+ return lines;
64
+ }
@@ -1,18 +1,18 @@
1
- import type { CliOptions } from "../../domain/models/cli-options";
2
- import type { CliCommandRunner, CliRuntimeParams } from "../ports/cli-runtime-ports";
3
-
4
- export async function dispatchMode(
5
- options: CliOptions,
6
- params: CliRuntimeParams,
7
- runner: CliCommandRunner,
8
- ): Promise<void> {
9
- if (options.mode === "ai") {
10
- await runner.runAi({ ...params, options });
11
- return;
12
- }
13
- if (options.mode === "home") {
14
- await runner.runHome({ ...params, options });
15
- return;
16
- }
17
- await runner.runConfigOnly({ ...params, options });
18
- }
1
+ import type { CliOptions } from "../../domain/models/cli-options";
2
+ import type { CliCommandRunner, CliRuntimeParams } from "../ports/cli-runtime-ports";
3
+
4
+ export async function dispatchMode(
5
+ options: CliOptions,
6
+ params: CliRuntimeParams,
7
+ runner: CliCommandRunner,
8
+ ): Promise<void> {
9
+ if (options.mode === "ai") {
10
+ await runner.runAi({ ...params, options });
11
+ return;
12
+ }
13
+ if (options.mode === "home") {
14
+ await runner.runHome({ ...params, options });
15
+ return;
16
+ }
17
+ await runner.runConfigOnly({ ...params, options });
18
+ }
@@ -1,34 +1,34 @@
1
- /** Orchestrate build of config artifacts for gitpagedocs */
2
-
3
- import { LAYOUTS, FALLBACK_LAYOUTS } from "../data/layouts.mjs";
4
- import { DOCS } from "../content/docs.mjs";
5
- import { DOC_VERSIONS } from "../data/version-constants.mjs";
6
- import { buildRootConfig } from "./root-config-builder.mjs";
7
- import { buildVersionConfig } from "./version-config-builder.mjs";
8
-
9
- /**
10
- * Build all config artifacts (root, layouts, versions, docs).
11
- * @param {object} options - { useLocalLayoutConfig, githubOwner, githubRepo, root }
12
- * @returns {object} { rootConfig, layoutsConfig, fallbackLayoutsConfig, docs, docsHtml, versionConfigs }
13
- */
14
- export function buildConfigArtifacts(options = {}) {
15
- const root = options.root ?? process.cwd();
16
-
17
- const rootConfig = buildRootConfig(options);
18
- const layoutsConfig = { layouts: LAYOUTS };
19
- const fallbackLayoutsConfig = { layouts: FALLBACK_LAYOUTS };
20
-
21
- const versionConfigs = {};
22
- for (const versionId of DOC_VERSIONS) {
23
- versionConfigs[versionId] = buildVersionConfig(versionId, options);
24
- }
25
-
26
- return {
27
- rootConfig,
28
- layoutsConfig,
29
- fallbackLayoutsConfig,
30
- docs: DOCS,
31
- docsHtml: {},
32
- versionConfigs,
33
- };
34
- }
1
+ /** Orchestrate build of config artifacts for gitpagedocs */
2
+
3
+ import { LAYOUTS, FALLBACK_LAYOUTS } from "../data/layouts.mjs";
4
+ import { DOCS } from "../content/docs.mjs";
5
+ import { DOC_VERSIONS } from "../data/version-constants.mjs";
6
+ import { buildRootConfig } from "./root-config-builder.mjs";
7
+ import { buildVersionConfig } from "./version-config-builder.mjs";
8
+
9
+ /**
10
+ * Build all config artifacts (root, layouts, versions, docs).
11
+ * @param {object} options - { useLocalLayoutConfig, githubOwner, githubRepo, root }
12
+ * @returns {object} { rootConfig, layoutsConfig, fallbackLayoutsConfig, docs, docsHtml, versionConfigs }
13
+ */
14
+ export function buildConfigArtifacts(options = {}) {
15
+ const root = options.root ?? process.cwd();
16
+
17
+ const rootConfig = buildRootConfig(options);
18
+ const layoutsConfig = { layouts: LAYOUTS };
19
+ const fallbackLayoutsConfig = { layouts: FALLBACK_LAYOUTS };
20
+
21
+ const versionConfigs = {};
22
+ for (const versionId of DOC_VERSIONS) {
23
+ versionConfigs[versionId] = buildVersionConfig(versionId, options);
24
+ }
25
+
26
+ return {
27
+ rootConfig,
28
+ layoutsConfig,
29
+ fallbackLayoutsConfig,
30
+ docs: DOCS,
31
+ docsHtml: {},
32
+ versionConfigs,
33
+ };
34
+ }
@@ -1,26 +1,50 @@
1
- /** Shared derivation of project URLs from CLI options (single source of truth
2
- * for root and version config builders). */
3
-
4
- export const DEFAULT_PROJECT_LINK = "https://github.com/Vidigal-code/git-page-docs";
5
- export const DEFAULT_RENDERING_URL = "https://vidigal-code.github.io/git-page-docs/";
6
-
7
- export function resolveProjectLink(githubOwner, githubRepo) {
8
- return githubOwner && githubRepo
9
- ? `https://github.com/${githubOwner}/${githubRepo}`
10
- : DEFAULT_PROJECT_LINK;
11
- }
12
-
13
- export function resolveRenderingUrl(githubOwner, githubRepo) {
14
- return githubOwner && githubRepo
15
- ? `https://${githubOwner}.github.io/${githubRepo}/`
16
- : DEFAULT_RENDERING_URL;
17
- }
18
-
19
- export function resolveSourceViewerPath(githubOwner, githubRepo) {
20
- // User repositories use the symbolic HEAD ref so any default branch works
21
- // (github.com, the trees API and raw.githubusercontent all accept it);
22
- // the official repository keeps its stable main link.
23
- return githubOwner && githubRepo
24
- ? `${resolveProjectLink(githubOwner, githubRepo)}/tree/HEAD`
25
- : `${DEFAULT_PROJECT_LINK}/tree/main`;
26
- }
1
+ /** Shared derivation of project URLs from CLI options (single source of truth
2
+ * for root and version config builders). */
3
+
4
+ import { layoutsArtifactPaths } from "../contracts/layouts-paths.mjs";
5
+
6
+ export const DEFAULT_PROJECT_LINK = "https://github.com/Vidigal-code/git-page-docs";
7
+ export const DEFAULT_RENDERING_URL = "https://vidigal-code.github.io/git-page-docs/";
8
+
9
+ export function resolveProjectLink(githubOwner, githubRepo) {
10
+ return githubOwner && githubRepo
11
+ ? `https://github.com/${githubOwner}/${githubRepo}`
12
+ : DEFAULT_PROJECT_LINK;
13
+ }
14
+
15
+ export function resolveRenderingUrl(githubOwner, githubRepo) {
16
+ return githubOwner && githubRepo
17
+ ? `https://${githubOwner}.github.io/${githubRepo}/`
18
+ : DEFAULT_RENDERING_URL;
19
+ }
20
+
21
+ /**
22
+ * Where the viewer should look for locally generated layouts.
23
+ *
24
+ * Mirrors resolveSourceViewerPath: user repositories use the symbolic HEAD ref
25
+ * so any default branch resolves. Without an owner/repo pair there is no URL to
26
+ * build, so the repo-relative path is returned - the viewer reads it directly in
27
+ * local mode and still discovers it by probing the repository otherwise.
28
+ *
29
+ * @param {string} githubOwner
30
+ * @param {string} githubRepo
31
+ * @param {string} layoutsDir Repo-relative layouts home.
32
+ * @returns {{ config: string, templates: string }}
33
+ */
34
+ export function resolveLayoutsLinks(githubOwner, githubRepo, layoutsDir) {
35
+ const paths = layoutsArtifactPaths(layoutsDir);
36
+ if (!githubOwner || !githubRepo) {
37
+ return { config: paths.config, templates: paths.templates };
38
+ }
39
+ const base = `${resolveProjectLink(githubOwner, githubRepo)}/blob/HEAD`;
40
+ return { config: `${base}/${paths.config}`, templates: `${base}/${paths.templates}` };
41
+ }
42
+
43
+ export function resolveSourceViewerPath(githubOwner, githubRepo) {
44
+ // User repositories use the symbolic HEAD ref so any default branch works
45
+ // (github.com, the trees API and raw.githubusercontent all accept it);
46
+ // the official repository keeps its stable main link.
47
+ return githubOwner && githubRepo
48
+ ? `${resolveProjectLink(githubOwner, githubRepo)}/tree/HEAD`
49
+ : `${DEFAULT_PROJECT_LINK}/tree/main`;
50
+ }
@@ -0,0 +1,16 @@
1
+ /** Options that shape the generated root config. */
2
+ export interface RootConfigOptions {
3
+ useLocalLayoutConfig?: boolean;
4
+ githubOwner?: string;
5
+ githubRepo?: string;
6
+ /** Repo-relative layouts home referenced by the generated config. */
7
+ layoutsDir?: string;
8
+ }
9
+
10
+ export interface RootConfig {
11
+ site: Record<string, unknown>;
12
+ VersionControl: { versions: Array<Record<string, unknown>> };
13
+ translations: Record<string, unknown>;
14
+ }
15
+
16
+ export declare function buildRootConfig(options?: RootConfigOptions): RootConfig;
@@ -1,53 +1,61 @@
1
- /** Build root config for gitpagedocs */
2
- import { OFFICIAL_LAYOUTS_CONFIG_URL, OFFICIAL_LAYOUTS_TEMPLATES_URL } from "../data/urls.mjs";
3
- import { resolveProjectLink, resolveRenderingUrl, resolveSourceViewerPath } from "./project-links.mjs";
4
- import { DOCS } from "../content/docs.mjs";
5
- import { DOC_VERSIONS } from "../data/version-constants.mjs";
6
- import { defaultLangMenu } from "../data/i18n-langmenu.mjs";
7
- import { defaultTranslations } from "../data/i18n-translations.mjs";
8
- import { getDefaultSiteConfig } from "../data/default-site-config.mjs";
9
-
10
- export function buildRootConfig(options = {}) {
11
- const useLocalLayoutConfig = Boolean(options.useLocalLayoutConfig);
12
- const useOfficialLayouts = !useLocalLayoutConfig;
13
- const githubOwner = options.githubOwner;
14
- const githubRepo = options.githubRepo;
15
- const repositorySearchHome = true;
16
- const renderingUrl = resolveRenderingUrl(githubOwner, githubRepo);
17
- const projectLink = resolveProjectLink(githubOwner, githubRepo);
18
- const sourceViewerPath = resolveSourceViewerPath(githubOwner, githubRepo);
19
-
20
- const versionEntries = DOC_VERSIONS.map((id) => ({
21
- id,
22
- path: `gitpagedocs/docs/versions/${id}/config.json`,
23
- ProjectLink: projectLink,
24
- PathConfig: `gitpagedocs/docs/versions/${id}/config.json`,
25
- PreviewProject: "",
26
- UpdateDate: "",
27
- branch: "",
28
- release: "",
29
- commit: "",
30
- "source-viewer": true,
31
- "source-viewer-path": sourceViewerPath,
32
- }));
33
-
34
- const baseSiteConfig = getDefaultSiteConfig(DOCS, projectLink);
35
-
36
- return {
37
- site: {
38
- ...baseSiteConfig,
39
- layoutsConfigPathOficial: useOfficialLayouts,
40
- layoutsConfigPathTemplatesOficial: useOfficialLayouts ? OFFICIAL_LAYOUTS_TEMPLATES_URL : "",
41
- layoutsConfigPathOficialUrl: useOfficialLayouts ? OFFICIAL_LAYOUTS_CONFIG_URL : "",
42
- repositorySearchHome,
43
- rendering: renderingUrl,
44
- AiChatEnabled: true,
45
- docsAccess: { enabled: false, publicKey: "" },
46
- langmenu: defaultLangMenu,
47
- },
48
- VersionControl: {
49
- versions: versionEntries,
50
- },
51
- translations: defaultTranslations,
52
- };
53
- }
1
+ /** Build root config for gitpagedocs */
2
+ import { OFFICIAL_LAYOUTS_CONFIG_URL, OFFICIAL_LAYOUTS_TEMPLATES_URL } from "../data/urls.mjs";
3
+ import {
4
+ resolveProjectLink,
5
+ resolveRenderingUrl,
6
+ resolveSourceViewerPath,
7
+ resolveLayoutsLinks,
8
+ } from "./project-links.mjs";
9
+ import { DOCS } from "../content/docs.mjs";
10
+ 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
+ import { getDefaultSiteConfig } from "../data/default-site-config.mjs";
14
+
15
+ export function buildRootConfig(options = {}) {
16
+ const useLocalLayoutConfig = Boolean(options.useLocalLayoutConfig);
17
+ const useOfficialLayouts = !useLocalLayoutConfig;
18
+ const githubOwner = options.githubOwner;
19
+ const githubRepo = options.githubRepo;
20
+ const repositorySearchHome = true;
21
+ const renderingUrl = resolveRenderingUrl(githubOwner, githubRepo);
22
+ const projectLink = resolveProjectLink(githubOwner, githubRepo);
23
+ const sourceViewerPath = resolveSourceViewerPath(githubOwner, githubRepo);
24
+ const layoutsLinks = resolveLayoutsLinks(githubOwner, githubRepo, options.layoutsDir);
25
+
26
+ const versionEntries = DOC_VERSIONS.map((id) => ({
27
+ id,
28
+ path: `gitpagedocs/docs/versions/${id}/config.json`,
29
+ ProjectLink: projectLink,
30
+ PathConfig: `gitpagedocs/docs/versions/${id}/config.json`,
31
+ PreviewProject: "",
32
+ UpdateDate: "",
33
+ branch: "",
34
+ release: "",
35
+ commit: "",
36
+ "source-viewer": true,
37
+ "source-viewer-path": sourceViewerPath,
38
+ }));
39
+
40
+ const baseSiteConfig = getDefaultSiteConfig(DOCS, projectLink);
41
+
42
+ return {
43
+ site: {
44
+ ...baseSiteConfig,
45
+ layoutsConfigPathOficial: useOfficialLayouts,
46
+ layoutsConfigPathTemplatesOficial: useOfficialLayouts ? OFFICIAL_LAYOUTS_TEMPLATES_URL : "",
47
+ layoutsConfigPathOficialUrl: useOfficialLayouts ? OFFICIAL_LAYOUTS_CONFIG_URL : "",
48
+ layoutsConfigPath: useLocalLayoutConfig ? layoutsLinks.config : "",
49
+ layoutsConfigPathTemplates: useLocalLayoutConfig ? layoutsLinks.templates : "",
50
+ repositorySearchHome,
51
+ rendering: renderingUrl,
52
+ AiChatEnabled: true,
53
+ docsAccess: { enabled: false, publicKey: "" },
54
+ langmenu: defaultLangMenu,
55
+ },
56
+ VersionControl: {
57
+ versions: versionEntries,
58
+ },
59
+ translations: defaultTranslations,
60
+ };
61
+ }