@gitpagedocs/cli 0.0.1

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 (91) hide show
  1. package/README.md +193 -0
  2. package/ai/application/ai-command.ts +24 -0
  3. package/ai/application/ai-provider-factory.ts +22 -0
  4. package/ai/application/docs-pattern.ts +72 -0
  5. package/ai/application/resolve-chat-credentials.ts +69 -0
  6. package/ai/application/run-ai-cli-command.ts +167 -0
  7. package/ai/config.ts +50 -0
  8. package/ai/core/chat-session.ts +44 -0
  9. package/ai/core/models/ai-cli-config.ts +33 -0
  10. package/ai/core/models/parse-ai-cli-config.ts +76 -0
  11. package/ai/core/ports/illm-provider.ts +32 -0
  12. package/ai/infrastructure/ai-config-file.ts +101 -0
  13. package/ai/infrastructure/file-system-adapter.ts +85 -0
  14. package/ai/infrastructure/llm/tools-llm-provider.ts +54 -0
  15. package/ai/infrastructure/version-docs-writer.ts +143 -0
  16. package/ai/presentation/ai-prompts.ts +239 -0
  17. package/application/config-only/handler.mjs +57 -0
  18. package/application/home/handler.mjs +87 -0
  19. package/application/ports/cli-runtime-ports.ts +93 -0
  20. package/application/report/config-only-reporter.mjs +68 -0
  21. package/application/use-cases/dispatch-mode.ts +18 -0
  22. package/builders/config-orchestrator.mjs +35 -0
  23. package/builders/language-bundles-builder.mjs +24 -0
  24. package/builders/project-links.mjs +50 -0
  25. package/builders/root-config-builder.d.mts +16 -0
  26. package/builders/root-config-builder.mjs +56 -0
  27. package/builders/route-builders.mjs +136 -0
  28. package/builders/theme-template.mjs +76 -0
  29. package/builders/version-config-builder.mjs +186 -0
  30. package/content/docs-en.mjs +556 -0
  31. package/content/docs-es.mjs +469 -0
  32. package/content/docs-pt.mjs +469 -0
  33. package/content/docs.mjs +9 -0
  34. package/contracts/doc-versions.mjs +3 -0
  35. package/contracts/index.mjs +11 -0
  36. package/contracts/langs-paths.mjs +28 -0
  37. package/contracts/languages.mjs +6 -0
  38. package/contracts/layouts-paths.d.mts +17 -0
  39. package/contracts/layouts-paths.mjs +68 -0
  40. package/contracts/path-segments.d.mts +2 -0
  41. package/contracts/path-segments.mjs +15 -0
  42. package/data/default-site-config.mjs +328 -0
  43. package/data/i18n-langmenu.mjs +350 -0
  44. package/data/i18n-translations.mjs +20 -0
  45. package/data/layouts.mjs +437 -0
  46. package/data/path-mappings.mjs +26 -0
  47. package/data/route-metas.mjs +93 -0
  48. package/data/theme-colors.mjs +444 -0
  49. package/data/urls.mjs +12 -0
  50. package/data/version-constants.mjs +3 -0
  51. package/domain/models/cli-options.ts +33 -0
  52. package/domain/services/layouts-migration.d.mts +15 -0
  53. package/domain/services/layouts-migration.mjs +74 -0
  54. package/domain/services/sanitize-segment.mjs +7 -0
  55. package/home/constants.mjs +4 -0
  56. package/home/home-file-writer.mjs +19 -0
  57. package/home/templates.mjs +51 -0
  58. package/index.mjs +38 -0
  59. package/infrastructure/config-only/runtime.mjs +17 -0
  60. package/infrastructure/gitpagedocs-config-file.ts +47 -0
  61. package/infrastructure/home/runtime.mjs +37 -0
  62. package/package.json +60 -0
  63. package/presentation/commands/ai-info.ts +57 -0
  64. package/presentation/commands/chat.ts +259 -0
  65. package/presentation/commands/config-clear.ts +23 -0
  66. package/presentation/commands/config-info.ts +72 -0
  67. package/presentation/commands/diagnostics.ts +174 -0
  68. package/presentation/commands/docs.ts +42 -0
  69. package/presentation/commands/mcp.ts +20 -0
  70. package/presentation/commands/pages.ts +103 -0
  71. package/presentation/commands/password.ts +62 -0
  72. package/presentation/commands/run-command.ts +72 -0
  73. package/presentation/index.ts +125 -0
  74. package/presentation/options/parser.ts +120 -0
  75. package/presentation/options/resolver.ts +46 -0
  76. package/presentation/options/schema.ts +14 -0
  77. package/presentation/ui/banner.ts +13 -0
  78. package/presentation/ui/clack.ts +91 -0
  79. package/presentation/ui/layouts-prompts.ts +124 -0
  80. package/presentation/ui/prompts.ts +147 -0
  81. package/presentation/ui/terminal-stream.ts +97 -0
  82. package/presentation/ui/tty.ts +37 -0
  83. package/runtime/doc-path-resolver.mjs +59 -0
  84. package/runtime/exec.mjs +168 -0
  85. package/runtime/git-ops.mjs +112 -0
  86. package/runtime/layouts-migrator.d.mts +11 -0
  87. package/runtime/layouts-migrator.mjs +117 -0
  88. package/runtime/output.mjs +201 -0
  89. package/runtime/workflow.mjs +131 -0
  90. package/start.mjs +14 -0
  91. package/ui/logger.mjs +9 -0
@@ -0,0 +1,131 @@
1
+ import { trimSlashes } from "../contracts/path-segments.mjs";
2
+
3
+ function sanitizeDocsPath(docsPath) {
4
+ if (!docsPath || typeof docsPath !== "string") return "";
5
+ const segment = trimSlashes(docsPath).trim();
6
+ return /^[A-Za-z0-9._-]+$/.test(segment) ? segment : "";
7
+ }
8
+
9
+ export async function ensureGitHubPagesWorkflow(getCurrentGitBranch, writeText, docsPath = "") {
10
+ const pathSegment = sanitizeDocsPath(docsPath);
11
+ const buildStepsBlock =
12
+ pathSegment
13
+ ? ` - name: Build static site with target repository path
14
+ run: pnpm exec next build frontend && mv frontend/out out
15
+ working-directory: .gitpagedocs-runtime
16
+ env:
17
+ GITPAGEDOCS_PATH: "${pathSegment}"
18
+
19
+ - name: Relocate output to custom docs path
20
+ run: |
21
+ mkdir -p .gitpagedocs-runtime/out_new/${pathSegment}
22
+ mv .gitpagedocs-runtime/out/* .gitpagedocs-runtime/out_new/${pathSegment}/
23
+ rm -rf .gitpagedocs-runtime/out
24
+ mv .gitpagedocs-runtime/out_new .gitpagedocs-runtime/out
25
+
26
+ - name: Redirect site root to custom docs path
27
+ 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`
28
+ : ` - name: Build static site with target repository path
29
+ run: pnpm exec next build frontend && mv frontend/out out
30
+ working-directory: .gitpagedocs-runtime`;
31
+ const currentBranch = getCurrentGitBranch();
32
+ const workflowPath = ".github/workflows/gitpagedocs-pages.yml";
33
+ const workflowContent = `name: Deploy GitPageDocs
34
+
35
+ on:
36
+ push:
37
+ branches: ["${currentBranch}"]
38
+ workflow_dispatch:
39
+
40
+ permissions:
41
+ contents: read
42
+ pages: write
43
+ id-token: write
44
+
45
+ concurrency:
46
+ group: "pages"
47
+ cancel-in-progress: false
48
+
49
+ jobs:
50
+ build:
51
+ runs-on: ubuntu-latest
52
+ permissions:
53
+ contents: read
54
+ pages: write
55
+ id-token: write
56
+ env:
57
+ GITHUB_ACTIONS: "true"
58
+ GITHUB_REPOSITORY: \${{ github.repository }}
59
+ GITPAGEDOCS_REPOSITORY_SEARCH: "true"
60
+ steps:
61
+ - name: Checkout target repository
62
+ uses: actions/checkout@v4
63
+
64
+ - name: Setup pnpm
65
+ uses: pnpm/action-setup@v4
66
+
67
+ - name: Setup Node
68
+ uses: actions/setup-node@v4
69
+ with:
70
+ node-version: "24"
71
+
72
+ - name: Setup Pages
73
+ uses: actions/configure-pages@v5
74
+ with:
75
+ enablement: true
76
+
77
+ - name: Prepare runtime source
78
+ run: |
79
+ git clone --depth 1 https://github.com/Vidigal-code/git-page-docs.git .gitpagedocs-runtime
80
+ cp .gitpagedocs-runtime/gitpagedocs/icon.svg /tmp/default-icon.svg 2>/dev/null || true
81
+ if [ -d gitpagelayouts ]; then
82
+ rm -rf .gitpagedocs-runtime/gitpagelayouts
83
+ cp -R gitpagelayouts .gitpagedocs-runtime/gitpagelayouts
84
+ fi
85
+ if [ -d gitpagedocs ]; then
86
+ rm -rf .gitpagedocs-runtime/gitpagedocs
87
+ cp -R gitpagedocs .gitpagedocs-runtime/gitpagedocs
88
+ fi
89
+ mkdir -p .gitpagedocs-runtime/public
90
+ if [ -f icon.svg ]; then
91
+ cp icon.svg .gitpagedocs-runtime/public/icon.svg
92
+ elif [ -f gitpagedocs/icon.svg ]; then
93
+ cp gitpagedocs/icon.svg .gitpagedocs-runtime/public/icon.svg
94
+ elif [ -f /tmp/default-icon.svg ]; then
95
+ cp /tmp/default-icon.svg .gitpagedocs-runtime/public/icon.svg
96
+ fi
97
+
98
+ - name: Install runtime dependencies
99
+ run: pnpm install --frozen-lockfile
100
+ working-directory: .gitpagedocs-runtime
101
+
102
+ ${buildStepsBlock}
103
+
104
+ - name: Add .nojekyll
105
+ run: touch .gitpagedocs-runtime/out/.nojekyll 2>/dev/null || mkdir -p .gitpagedocs-runtime/out && touch .gitpagedocs-runtime/out/.nojekyll
106
+
107
+ - name: Upload artifact
108
+ uses: actions/upload-pages-artifact@v3
109
+ with:
110
+ path: ./.gitpagedocs-runtime/out
111
+
112
+ deploy:
113
+ environment:
114
+ name: github-pages
115
+ url: \${{ steps.deployment.outputs.page_url }}
116
+ runs-on: ubuntu-latest
117
+ needs: build
118
+ permissions:
119
+ pages: write
120
+ id-token: write
121
+ steps:
122
+ - name: Deploy to GitHub Pages
123
+ id: deployment
124
+ uses: actions/deploy-pages@v4
125
+ with:
126
+ timeout: 900000
127
+ error_count: 30
128
+ reporting_interval: 10000
129
+ `;
130
+ await writeText(workflowPath, workflowContent);
131
+ }
package/start.mjs ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { spawnExecutable } from "./runtime/exec.mjs";
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
+ let child;
8
+ try {
9
+ child = spawnExecutable("npx", ["next", "start", "frontend"], { stdio: "inherit", env });
10
+ } catch (error) {
11
+ console.error(`[gitpagedocs] ${error instanceof Error ? error.message : String(error)}`);
12
+ process.exit(1);
13
+ }
14
+ child.on("exit", (code) => process.exit(code ?? 0));
package/ui/logger.mjs ADDED
@@ -0,0 +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
+ }