@gitpagedocs/cli 1.1.53 → 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/index.mjs CHANGED
@@ -1,38 +1,38 @@
1
- #!/usr/bin/env node
2
-
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { spawnSync } from "node:child_process";
6
-
7
- const scriptPath = fileURLToPath(import.meta.url);
8
- const scriptDir = path.dirname(scriptPath);
9
- const tsEntry = path.join(scriptDir, "presentation", "index.ts");
10
-
11
- // Resolve tsx from THIS package's location, not the user's cwd. `node --import
12
- // tsx` would otherwise resolve the bare "tsx" specifier relative to the current
13
- // working directory, which fails when the CLI is installed globally and run
14
- // from a project that doesn't depend on tsx (ERR_MODULE_NOT_FOUND 'tsx').
15
- let tsxLoader = "tsx";
16
- try {
17
- tsxLoader = import.meta.resolve("tsx");
18
- } catch {
19
- // Older Node without a stable import.meta.resolve — fall back to the bare
20
- // specifier (works when tsx is resolvable from the cwd or globally).
21
- }
22
-
23
- const result = spawnSync(
24
- process.execPath,
25
- ["--import", tsxLoader, tsEntry, ...process.argv.slice(2)],
26
- {
27
- stdio: "inherit",
28
- cwd: process.cwd(),
29
- env: process.env,
30
- },
31
- );
32
-
33
- if (result.error) {
34
- console.error("[gitpagedocs] Failed to run TypeScript CLI runtime.", result.error);
35
- process.exitCode = 1;
36
- } else if (typeof result.status === "number" && result.status !== 0) {
37
- process.exitCode = result.status;
38
- }
1
+ #!/usr/bin/env node
2
+
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { spawnSync } from "node:child_process";
6
+
7
+ const scriptPath = fileURLToPath(import.meta.url);
8
+ const scriptDir = path.dirname(scriptPath);
9
+ const tsEntry = path.join(scriptDir, "presentation", "index.ts");
10
+
11
+ // Resolve tsx from THIS package's location, not the user's cwd. `node --import
12
+ // tsx` would otherwise resolve the bare "tsx" specifier relative to the current
13
+ // working directory, which fails when the CLI is installed globally and run
14
+ // from a project that doesn't depend on tsx (ERR_MODULE_NOT_FOUND 'tsx').
15
+ let tsxLoader = "tsx";
16
+ try {
17
+ tsxLoader = import.meta.resolve("tsx");
18
+ } catch {
19
+ // Older Node without a stable import.meta.resolve — fall back to the bare
20
+ // specifier (works when tsx is resolvable from the cwd or globally).
21
+ }
22
+
23
+ const result = spawnSync(
24
+ process.execPath,
25
+ ["--import", tsxLoader, tsEntry, ...process.argv.slice(2)],
26
+ {
27
+ stdio: "inherit",
28
+ cwd: process.cwd(),
29
+ env: process.env,
30
+ },
31
+ );
32
+
33
+ if (result.error) {
34
+ console.error("[gitpagedocs] Failed to run TypeScript CLI runtime.", result.error);
35
+ process.exitCode = 1;
36
+ } else if (typeof result.status === "number" && result.status !== 0) {
37
+ process.exitCode = result.status;
38
+ }
@@ -1,47 +1,47 @@
1
- import fs from "node:fs/promises";
2
- import { defaultConfigLoader } from "@gitpagedocs/tools";
3
-
4
- export interface DocsAccessConfig {
5
- enabled: boolean;
6
- publicKey: string;
7
- }
8
-
9
- /**
10
- * Reads and patches the generated gitpagedocs/config.json IN PLACE, preserving
11
- * every existing key (raw-JSON round-trip — it never reserializes through a typed
12
- * model that could drop unknown fields). Used by interactive commands that need
13
- * to persist a single value (e.g. the documentation password public key).
14
- */
15
- export class GitPageDocsConfigRepository {
16
- constructor(private readonly cwd: string = process.cwd()) {}
17
-
18
- /** Absolute path to the JSON config, or throws a friendly, actionable error. */
19
- async resolvePath(): Promise<string> {
20
- const resolved = await defaultConfigLoader.resolveConfigPath(this.cwd);
21
- if (!resolved) {
22
- throw new Error("gitpagedocs config.json not found. Run `gitpagedocs` first to generate it.");
23
- }
24
- if (!resolved.endsWith(".json")) {
25
- throw new Error(`Expected a JSON config to patch, found "${resolved}". Use a gitpagedocs/config.json.`);
26
- }
27
- return resolved;
28
- }
29
-
30
- /**
31
- * Set `site.docsAccess = { enabled, publicKey }`, leaving all other config keys
32
- * untouched. Returns the path that was written.
33
- */
34
- async patchDocsAccess(publicKey: string, enabled = true): Promise<string> {
35
- const configPath = await this.resolvePath();
36
- const raw = await fs.readFile(configPath, "utf-8");
37
- const config = JSON.parse(raw) as Record<string, unknown>;
38
- const site =
39
- config.site && typeof config.site === "object"
40
- ? (config.site as Record<string, unknown>)
41
- : {};
42
- site.docsAccess = { enabled, publicKey } satisfies DocsAccessConfig;
43
- config.site = site;
44
- await fs.writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
45
- return configPath;
46
- }
47
- }
1
+ import fs from "node:fs/promises";
2
+ import { defaultConfigLoader } from "@gitpagedocs/tools";
3
+
4
+ export interface DocsAccessConfig {
5
+ enabled: boolean;
6
+ publicKey: string;
7
+ }
8
+
9
+ /**
10
+ * Reads and patches the generated gitpagedocs/config.json IN PLACE, preserving
11
+ * every existing key (raw-JSON round-trip — it never reserializes through a typed
12
+ * model that could drop unknown fields). Used by interactive commands that need
13
+ * to persist a single value (e.g. the documentation password public key).
14
+ */
15
+ export class GitPageDocsConfigRepository {
16
+ constructor(private readonly cwd: string = process.cwd()) {}
17
+
18
+ /** Absolute path to the JSON config, or throws a friendly, actionable error. */
19
+ async resolvePath(): Promise<string> {
20
+ const resolved = await defaultConfigLoader.resolveConfigPath(this.cwd);
21
+ if (!resolved) {
22
+ throw new Error("gitpagedocs config.json not found. Run `gitpagedocs` first to generate it.");
23
+ }
24
+ if (!resolved.endsWith(".json")) {
25
+ throw new Error(`Expected a JSON config to patch, found "${resolved}". Use a gitpagedocs/config.json.`);
26
+ }
27
+ return resolved;
28
+ }
29
+
30
+ /**
31
+ * Set `site.docsAccess = { enabled, publicKey }`, leaving all other config keys
32
+ * untouched. Returns the path that was written.
33
+ */
34
+ async patchDocsAccess(publicKey: string, enabled = true): Promise<string> {
35
+ const configPath = await this.resolvePath();
36
+ const raw = await fs.readFile(configPath, "utf-8");
37
+ const config = JSON.parse(raw) as Record<string, unknown>;
38
+ const site =
39
+ config.site && typeof config.site === "object"
40
+ ? (config.site as Record<string, unknown>)
41
+ : {};
42
+ site.docsAccess = { enabled, publicKey } satisfies DocsAccessConfig;
43
+ config.site = site;
44
+ await fs.writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
45
+ return configPath;
46
+ }
47
+ }
package/package.json CHANGED
@@ -1,60 +1,60 @@
1
- {
2
- "name": "@gitpagedocs/cli",
3
- "version": "1.1.53",
4
- "description": "CLI that scaffolds and maintains gitpagedocs documentation, generates docs with AI, configures GitHub Pages, and runs the MCP server.",
5
- "bin": {
6
- "gitpagedocs": "index.mjs"
7
- },
8
- "main": "index.mjs",
9
- "files": [
10
- "index.mjs",
11
- "start.mjs",
12
- "ai",
13
- "application",
14
- "builders",
15
- "content",
16
- "contracts",
17
- "data",
18
- "domain",
19
- "home",
20
- "infrastructure",
21
- "presentation",
22
- "runtime",
23
- "ui",
24
- "prebuilt",
25
- "README.md"
26
- ],
27
- "engines": {
28
- "node": ">=20"
29
- },
30
- "dependencies": {
31
- "@clack/prompts": "^1.5.1",
32
- "@gitpagedocs/mcp": "^1.1.53",
33
- "@gitpagedocs/tools": "^1.1.53",
34
- "tsx": "^4.21.0"
35
- },
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/Vidigal-code/git-page-docs.git",
39
- "directory": "cli"
40
- },
41
- "keywords": [
42
- "gitpagedocs",
43
- "documentation",
44
- "markdown",
45
- "spa",
46
- "cli",
47
- "github-pages",
48
- "create-gitpagedocs"
49
- ],
50
- "author": "Vidigal-code",
51
- "license": "ISC",
52
- "bugs": {
53
- "url": "https://github.com/Vidigal-code/git-page-docs/issues"
54
- },
55
- "homepage": "https://vidigal-code.github.io/git-page-docs/",
56
- "publishConfig": {
57
- "registry": "https://registry.npmjs.org/",
58
- "access": "public"
59
- }
60
- }
1
+ {
2
+ "name": "@gitpagedocs/cli",
3
+ "version": "1.1.55",
4
+ "description": "CLI that scaffolds and maintains gitpagedocs documentation, generates docs with AI, configures GitHub Pages, and runs the MCP server.",
5
+ "bin": {
6
+ "gitpagedocs": "index.mjs"
7
+ },
8
+ "main": "index.mjs",
9
+ "files": [
10
+ "index.mjs",
11
+ "start.mjs",
12
+ "ai",
13
+ "application",
14
+ "builders",
15
+ "content",
16
+ "contracts",
17
+ "data",
18
+ "domain",
19
+ "home",
20
+ "infrastructure",
21
+ "presentation",
22
+ "runtime",
23
+ "ui",
24
+ "prebuilt",
25
+ "README.md"
26
+ ],
27
+ "engines": {
28
+ "node": ">=20"
29
+ },
30
+ "dependencies": {
31
+ "@clack/prompts": "^1.5.1",
32
+ "@gitpagedocs/mcp": "^1.1.54",
33
+ "@gitpagedocs/tools": "^1.1.54",
34
+ "tsx": "^4.21.0"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/Vidigal-code/git-page-docs.git",
39
+ "directory": "cli"
40
+ },
41
+ "keywords": [
42
+ "gitpagedocs",
43
+ "documentation",
44
+ "markdown",
45
+ "spa",
46
+ "cli",
47
+ "github-pages",
48
+ "create-gitpagedocs"
49
+ ],
50
+ "author": "Vidigal-code",
51
+ "license": "ISC",
52
+ "bugs": {
53
+ "url": "https://github.com/Vidigal-code/git-page-docs/issues"
54
+ },
55
+ "homepage": "https://vidigal-code.github.io/git-page-docs/",
56
+ "publishConfig": {
57
+ "registry": "https://registry.npmjs.org/",
58
+ "access": "public"
59
+ }
60
+ }
@@ -1,62 +1,62 @@
1
- import { NodeCryptoService, deriveDocAccessKeys } from "@gitpagedocs/tools";
2
- import type { CommandContext } from "./run-command";
3
- import { askPassword, note, outro } from "../ui/clack";
4
- import { interactivePromptsAvailable } from "../ui/prompts";
5
- import { GitPageDocsConfigRepository } from "../../infrastructure/gitpagedocs-config-file";
6
-
7
- const MIN_PASSWORD_LENGTH = 4;
8
-
9
- /**
10
- * `gitpagedocs password` — interactively set a documentation access password.
11
- *
12
- * Type + confirm a password, derive the double-hash key pair, write the PUBLIC
13
- * key into gitpagedocs/config.json (which makes the frontend gate the docs), and
14
- * print the PRIVATE key for the user to copy. The password itself is never stored.
15
- */
16
- export async function runPassword(ctx: CommandContext): Promise<void> {
17
- if (!interactivePromptsAvailable()) {
18
- // eslint-disable-next-line no-console
19
- console.log("\n `gitpagedocs password` is interactive — run it in a terminal (TTY).\n");
20
- return;
21
- }
22
-
23
- const password = await askPassword({
24
- message: "Documentation password:",
25
- validate: (v) =>
26
- v && v.trim().length >= MIN_PASSWORD_LENGTH
27
- ? undefined
28
- : `Use at least ${MIN_PASSWORD_LENGTH} characters.`,
29
- });
30
- const confirmation = await askPassword({
31
- message: "Confirm password:",
32
- validate: (v) => (v ? undefined : "Required."),
33
- });
34
-
35
- if (password !== confirmation) {
36
- note("Passwords do not match. Nothing was changed.", "Aborted");
37
- return;
38
- }
39
-
40
- const { privateKey, publicKey } = await deriveDocAccessKeys(password, new NodeCryptoService());
41
-
42
- let configPath: string;
43
- try {
44
- configPath = await new GitPageDocsConfigRepository(ctx.cwd).patchDocsAccess(publicKey);
45
- } catch (error) {
46
- note(error instanceof Error ? error.message : String(error), "Could not save");
47
- return;
48
- }
49
-
50
- note(
51
- `Public key saved to ${configPath}\nThe documentation is now password-protected.`,
52
- "Saved",
53
- );
54
- // eslint-disable-next-line no-console
55
- console.log(
56
- "\n PRIVATE KEY (copy & keep it safe — it also unlocks the docs):\n\n" +
57
- ` ${privateKey}\n\n` +
58
- " Readers can unlock with the password OR this private key.\n" +
59
- " To remove protection, set site.docsAccess.enabled to false in config.json.\n",
60
- );
61
- outro("Done.");
62
- }
1
+ import { NodeCryptoService, deriveDocAccessKeys } from "@gitpagedocs/tools";
2
+ import type { CommandContext } from "./run-command";
3
+ import { askPassword, note, outro } from "../ui/clack";
4
+ import { interactivePromptsAvailable } from "../ui/prompts";
5
+ import { GitPageDocsConfigRepository } from "../../infrastructure/gitpagedocs-config-file";
6
+
7
+ const MIN_PASSWORD_LENGTH = 4;
8
+
9
+ /**
10
+ * `gitpagedocs password` — interactively set a documentation access password.
11
+ *
12
+ * Type + confirm a password, derive the double-hash key pair, write the PUBLIC
13
+ * key into gitpagedocs/config.json (which makes the frontend gate the docs), and
14
+ * print the PRIVATE key for the user to copy. The password itself is never stored.
15
+ */
16
+ export async function runPassword(ctx: CommandContext): Promise<void> {
17
+ if (!interactivePromptsAvailable()) {
18
+ // eslint-disable-next-line no-console
19
+ console.log("\n `gitpagedocs password` is interactive — run it in a terminal (TTY).\n");
20
+ return;
21
+ }
22
+
23
+ const password = await askPassword({
24
+ message: "Documentation password:",
25
+ validate: (v) =>
26
+ v && v.trim().length >= MIN_PASSWORD_LENGTH
27
+ ? undefined
28
+ : `Use at least ${MIN_PASSWORD_LENGTH} characters.`,
29
+ });
30
+ const confirmation = await askPassword({
31
+ message: "Confirm password:",
32
+ validate: (v) => (v ? undefined : "Required."),
33
+ });
34
+
35
+ if (password !== confirmation) {
36
+ note("Passwords do not match. Nothing was changed.", "Aborted");
37
+ return;
38
+ }
39
+
40
+ const { privateKey, publicKey } = await deriveDocAccessKeys(password, new NodeCryptoService());
41
+
42
+ let configPath: string;
43
+ try {
44
+ configPath = await new GitPageDocsConfigRepository(ctx.cwd).patchDocsAccess(publicKey);
45
+ } catch (error) {
46
+ note(error instanceof Error ? error.message : String(error), "Could not save");
47
+ return;
48
+ }
49
+
50
+ note(
51
+ `Public key saved to ${configPath}\nThe documentation is now password-protected.`,
52
+ "Saved",
53
+ );
54
+ // eslint-disable-next-line no-console
55
+ console.log(
56
+ "\n PRIVATE KEY (copy & keep it safe — it also unlocks the docs):\n\n" +
57
+ ` ${privateKey}\n\n` +
58
+ " Readers can unlock with the password OR this private key.\n" +
59
+ " To remove protection, set site.docsAccess.enabled to false in config.json.\n",
60
+ );
61
+ outro("Done.");
62
+ }
@@ -1,48 +1,48 @@
1
- import type { CliOptions } from "../../domain/models/cli-options";
2
- import { parseCliOptions } from "./parser";
3
- import {
4
- shouldRunInteractive,
5
- promptConfigOnlyOptions,
6
- promptHomeOptions,
7
- promptDeployOptions,
8
- ensureGitRepoInteractive,
9
- interactivePromptsAvailable,
10
- } from "../ui/prompts";
11
- import { DEFAULTS } from "./schema";
12
- // @ts-expect-error .mjs runtime module is type-less in this package.
13
- import { detectRepoFromGit } from "../../runtime/git-ops.mjs";
14
-
15
- export async function resolveOptions(argv: string[], env: NodeJS.ProcessEnv): Promise<CliOptions> {
16
- const parsed = parseCliOptions(argv, env);
17
-
18
- if (parsed.mode === "home") {
19
- parsed.repositorySearch = parsed.repositorySearch ?? DEFAULTS.home.repositorySearch;
20
- parsed.basePath = parsed.basePath ?? parsed.docsPath ?? DEFAULTS.home.basePath;
21
- }
22
-
23
- // `deploy` / `--push` need owner + repo AND a git repo. If anything is
24
- // missing, prompt interactively (owner/repo pre-filled from the git origin
25
- // remote; offer to `git init`) instead of throwing. In CI/non-TTY we fall
26
- // through so the explicit guards in the push flow still fire clearly.
27
- if (parsed.shouldPush && interactivePromptsAvailable()) {
28
- let resolved = parsed;
29
- if (!parsed.githubOwner || !parsed.githubRepo) {
30
- const detected = detectRepoFromGit(process.cwd()) as { owner: string; repo: string } | null;
31
- resolved = await promptDeployOptions(parsed, detected);
32
- }
33
- await ensureGitRepoInteractive(process.cwd());
34
- return resolved;
35
- }
36
-
37
- const runHomeInteractive = parsed.isInteractive || (shouldRunInteractive(argv) && parsed.mode === "home");
38
- if (runHomeInteractive && parsed.mode === "home") {
39
- return promptHomeOptions(parsed);
40
- }
41
-
42
- const runConfigInteractive = parsed.isInteractive || (shouldRunInteractive(argv) && parsed.mode === "config-only");
43
- if (runConfigInteractive && parsed.mode === "config-only") {
44
- return promptConfigOnlyOptions(parsed);
45
- }
46
-
47
- return parsed;
48
- }
1
+ import type { CliOptions } from "../../domain/models/cli-options";
2
+ import { parseCliOptions } from "./parser";
3
+ import {
4
+ shouldRunInteractive,
5
+ promptConfigOnlyOptions,
6
+ promptHomeOptions,
7
+ promptDeployOptions,
8
+ ensureGitRepoInteractive,
9
+ interactivePromptsAvailable,
10
+ } from "../ui/prompts";
11
+ import { DEFAULTS } from "./schema";
12
+ // @ts-expect-error .mjs runtime module is type-less in this package.
13
+ import { detectRepoFromGit } from "../../runtime/git-ops.mjs";
14
+
15
+ export async function resolveOptions(argv: string[], env: NodeJS.ProcessEnv): Promise<CliOptions> {
16
+ const parsed = parseCliOptions(argv, env);
17
+
18
+ if (parsed.mode === "home") {
19
+ parsed.repositorySearch = parsed.repositorySearch ?? DEFAULTS.home.repositorySearch;
20
+ parsed.basePath = parsed.basePath ?? parsed.docsPath ?? DEFAULTS.home.basePath;
21
+ }
22
+
23
+ // `deploy` / `--push` need owner + repo AND a git repo. If anything is
24
+ // missing, prompt interactively (owner/repo pre-filled from the git origin
25
+ // remote; offer to `git init`) instead of throwing. In CI/non-TTY we fall
26
+ // through so the explicit guards in the push flow still fire clearly.
27
+ if (parsed.shouldPush && interactivePromptsAvailable()) {
28
+ let resolved = parsed;
29
+ if (!parsed.githubOwner || !parsed.githubRepo) {
30
+ const detected = detectRepoFromGit(process.cwd()) as { owner: string; repo: string } | null;
31
+ resolved = await promptDeployOptions(parsed, detected);
32
+ }
33
+ await ensureGitRepoInteractive(process.cwd());
34
+ return resolved;
35
+ }
36
+
37
+ const runHomeInteractive = parsed.isInteractive || (shouldRunInteractive(argv) && parsed.mode === "home");
38
+ if (runHomeInteractive && parsed.mode === "home") {
39
+ return promptHomeOptions(parsed);
40
+ }
41
+
42
+ const runConfigInteractive = parsed.isInteractive || (shouldRunInteractive(argv) && parsed.mode === "config-only");
43
+ if (runConfigInteractive && parsed.mode === "config-only") {
44
+ return promptConfigOnlyOptions(parsed);
45
+ }
46
+
47
+ return parsed;
48
+ }
@@ -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
- async function writeJson(root, relativePath, data) {
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
- for (const [versionId, versionConfig] of Object.entries(artifacts.versionConfigs)) {
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 ?? {})) {