create-thally-docs 0.7.0 → 0.7.2
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/LICENSE +1 -1
- package/dist/chunk-KN6QUPKR.js +785 -0
- package/dist/{chunk-BVI7FKFR.js → chunk-QGRDDS5V.js} +1 -1
- package/dist/index.js +27 -7
- package/dist/migrate/index.js +2 -2
- package/dist/scaffold.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-EPL2DCB2.js +0 -435
package/LICENSE
CHANGED
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/scaffold.ts
|
|
4
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync as readdirSync2 } from "fs";
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
|
|
7
|
+
// src/download.ts
|
|
8
|
+
import { Readable, pipeline } from "stream";
|
|
9
|
+
import { promisify } from "util";
|
|
10
|
+
import tar from "tar";
|
|
11
|
+
var pipelineAsync = promisify(pipeline);
|
|
12
|
+
var TEMPLATE_REPOSITORY = "thallylabs/docs";
|
|
13
|
+
var TARBALL_URL = `https://codeload.github.com/${TEMPLATE_REPOSITORY}/tar.gz/main`;
|
|
14
|
+
var EXCLUDE_PATHS = [
|
|
15
|
+
// Match both the directory entry itself and every nested file. Tar invokes
|
|
16
|
+
// the filter for `.../node_modules` before descendants, without a trailing `/`.
|
|
17
|
+
"/node_modules",
|
|
18
|
+
// The canonical docs repository may temporarily retain package sources while
|
|
19
|
+
// runtime work is being upstreamed. A scaffold consumes the published
|
|
20
|
+
// packages declared in package.json; it must never inherit those sources.
|
|
21
|
+
"/packages",
|
|
22
|
+
"/.git/",
|
|
23
|
+
"/.next/",
|
|
24
|
+
"/.data/",
|
|
25
|
+
"/.thally/",
|
|
26
|
+
"/thally-agent.yml",
|
|
27
|
+
"/thally-track.yml",
|
|
28
|
+
"/CODEOWNERS",
|
|
29
|
+
"/CLAUDE.md",
|
|
30
|
+
"/notes/",
|
|
31
|
+
"/public/images/",
|
|
32
|
+
"/src/public/",
|
|
33
|
+
"/snippets/",
|
|
34
|
+
"/.github/ISSUE_TEMPLATE/",
|
|
35
|
+
"/.github/PULL_REQUEST_TEMPLATE.md",
|
|
36
|
+
"/README.md"
|
|
37
|
+
];
|
|
38
|
+
function shouldInclude(path) {
|
|
39
|
+
for (const excluded of EXCLUDE_PATHS) {
|
|
40
|
+
if (path.includes(excluded)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
async function downloadTemplate(targetDir, siteName) {
|
|
47
|
+
console.log("");
|
|
48
|
+
console.log(` \u23F3 Creating ${siteName?.trim() || "your docs site"}...`);
|
|
49
|
+
const response = await fetch(TARBALL_URL);
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`Failed to download template: ${response.status} ${response.statusText}`);
|
|
52
|
+
}
|
|
53
|
+
if (!response.body) {
|
|
54
|
+
throw new Error("Response body is empty");
|
|
55
|
+
}
|
|
56
|
+
const nodeStream = Readable.fromWeb(response.body);
|
|
57
|
+
await pipelineAsync(
|
|
58
|
+
nodeStream,
|
|
59
|
+
tar.extract({ cwd: targetDir, strip: 1, filter: shouldInclude })
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/docs-json.ts
|
|
64
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
65
|
+
import { join } from "path";
|
|
66
|
+
function readDocsJson(projectDir) {
|
|
67
|
+
const docsPath = join(projectDir, "docs.json");
|
|
68
|
+
const raw = readFileSync(docsPath, "utf8");
|
|
69
|
+
return JSON.parse(raw);
|
|
70
|
+
}
|
|
71
|
+
function writeDocsJson(projectDir, config) {
|
|
72
|
+
const docsPath = join(projectDir, "docs.json");
|
|
73
|
+
writeFileSync(docsPath, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
74
|
+
}
|
|
75
|
+
function resetTrackingConfig(projectDir) {
|
|
76
|
+
const config = readDocsJson(projectDir);
|
|
77
|
+
if (config.tracking) {
|
|
78
|
+
delete config.tracking;
|
|
79
|
+
writeDocsJson(projectDir, config);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function writeTrackingConfig(projectDir, repos) {
|
|
83
|
+
if (repos.length === 0) return;
|
|
84
|
+
const config = readDocsJson(projectDir);
|
|
85
|
+
config.tracking = { repos: repos.map((r) => ({ owner: r.owner, repo: r.repo, branch: "main" })) };
|
|
86
|
+
writeDocsJson(projectDir, config);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/customize.ts
|
|
90
|
+
import { existsSync, mkdirSync, writeFileSync as writeFileSync2, readFileSync as readFileSync2, readdirSync, cpSync, rmSync } from "fs";
|
|
91
|
+
import { join as join2 } from "path";
|
|
92
|
+
var STARTER_PAGES = {
|
|
93
|
+
"introduction.mdx": `---
|
|
94
|
+
title: Introduction
|
|
95
|
+
description: Welcome to {NAME}.
|
|
96
|
+
mode: home
|
|
97
|
+
keywords:
|
|
98
|
+
- {NAME}
|
|
99
|
+
- documentation
|
|
100
|
+
- overview
|
|
101
|
+
- getting started
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
<Hero
|
|
105
|
+
title="Welcome to {NAME}"
|
|
106
|
+
subtitle="Use this starter to introduce your product, guide readers to their first successful outcome, and publish a clear API reference."
|
|
107
|
+
primaryLabel="Start the quickstart"
|
|
108
|
+
primaryHref="/quickstart"
|
|
109
|
+
secondaryLabel="See components"
|
|
110
|
+
secondaryHref="/components"
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
<CardGroup cols={3}>
|
|
114
|
+
<Card title="Quickstart" icon="party-horn" href="/quickstart">
|
|
115
|
+
Show readers the fastest path to a useful first result.
|
|
116
|
+
</Card>
|
|
117
|
+
<Card title="Components" icon="grid-round" href="/components">
|
|
118
|
+
Structure guides with steps, tabs, cards, callouts, accordions, and more.
|
|
119
|
+
</Card>
|
|
120
|
+
<Card title="API reference" icon="code-simple" href="/api">
|
|
121
|
+
Replace \`openapi.yaml\` with your specification to publish interactive endpoints.
|
|
122
|
+
</Card>
|
|
123
|
+
<Card title="Customize" icon="wrench" href="/customization">
|
|
124
|
+
Make the navigation, brand, typography, and links your own.
|
|
125
|
+
</Card>
|
|
126
|
+
<Card title="Multi-language" icon="message" href="/es">
|
|
127
|
+
Switch to the included Spanish example from the language menu.
|
|
128
|
+
</Card>
|
|
129
|
+
<Card title="Agent-ready docs" icon="link-simple" href="/llms.txt">
|
|
130
|
+
Give coding agents a clean, structured version of your documentation.
|
|
131
|
+
</Card>
|
|
132
|
+
</CardGroup>
|
|
133
|
+
|
|
134
|
+
<Note type="info" title="Make it yours">
|
|
135
|
+
Start by editing \`src/content/introduction.mdx\`. Then update \`docs.json\` to
|
|
136
|
+
organize navigation and \`src/data/site.ts\` to set your product name and links.
|
|
137
|
+
</Note>
|
|
138
|
+
`,
|
|
139
|
+
"quickstart.mdx": `---
|
|
140
|
+
title: Quickstart
|
|
141
|
+
description: Give readers the fastest path to a successful first result with {NAME}.
|
|
142
|
+
keywords:
|
|
143
|
+
- {NAME}
|
|
144
|
+
- quickstart
|
|
145
|
+
- installation
|
|
146
|
+
- getting started
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
Describe the prerequisites and the shortest useful workflow. A good quickstart
|
|
150
|
+
takes someone from zero to a visible result without explaining every option.
|
|
151
|
+
|
|
152
|
+
## Prerequisites
|
|
153
|
+
|
|
154
|
+
- Requirement one, such as an account, API key, or supported runtime
|
|
155
|
+
- Requirement two, such as a compatible device, browser, or operating system
|
|
156
|
+
|
|
157
|
+
<Steps>
|
|
158
|
+
<Step title="Install">
|
|
159
|
+
Explain how to install {NAME} or create an account.
|
|
160
|
+
|
|
161
|
+
\`\`\`bash
|
|
162
|
+
npm install your-package
|
|
163
|
+
\`\`\`
|
|
164
|
+
</Step>
|
|
165
|
+
<Step title="Configure">
|
|
166
|
+
Show only the configuration required for the first successful run.
|
|
167
|
+
|
|
168
|
+
\`\`\`bash
|
|
169
|
+
your-cli init
|
|
170
|
+
\`\`\`
|
|
171
|
+
</Step>
|
|
172
|
+
<Step title="Run it">
|
|
173
|
+
Give readers a command or action with an observable result.
|
|
174
|
+
|
|
175
|
+
\`\`\`bash
|
|
176
|
+
your-cli start
|
|
177
|
+
\`\`\`
|
|
178
|
+
</Step>
|
|
179
|
+
</Steps>
|
|
180
|
+
|
|
181
|
+
<Tip>
|
|
182
|
+
Tell readers where to get help, then link to the next guide they should read.
|
|
183
|
+
</Tip>
|
|
184
|
+
`,
|
|
185
|
+
"components.mdx": `---
|
|
186
|
+
title: Components
|
|
187
|
+
description: A compact tour of the rich MDX components available in {NAME}.
|
|
188
|
+
keywords:
|
|
189
|
+
- {NAME}
|
|
190
|
+
- components
|
|
191
|
+
- MDX
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
Use components to keep complex instructions clear without turning every page
|
|
195
|
+
into a wall of text.
|
|
196
|
+
|
|
197
|
+
## Show equivalent paths
|
|
198
|
+
|
|
199
|
+
<Tabs>
|
|
200
|
+
<Tab title="npm">
|
|
201
|
+
\`\`\`bash
|
|
202
|
+
npm install your-package
|
|
203
|
+
\`\`\`
|
|
204
|
+
</Tab>
|
|
205
|
+
<Tab title="pnpm">
|
|
206
|
+
\`\`\`bash
|
|
207
|
+
pnpm add your-package
|
|
208
|
+
\`\`\`
|
|
209
|
+
</Tab>
|
|
210
|
+
<Tab title="yarn">
|
|
211
|
+
\`\`\`bash
|
|
212
|
+
yarn add your-package
|
|
213
|
+
\`\`\`
|
|
214
|
+
</Tab>
|
|
215
|
+
</Tabs>
|
|
216
|
+
|
|
217
|
+
## Reveal detail when it matters
|
|
218
|
+
|
|
219
|
+
<Accordion title="Where should advanced configuration live?">
|
|
220
|
+
Keep the default path visible and move optional detail into an accordion. This
|
|
221
|
+
lets new readers move quickly without hiding information from experts.
|
|
222
|
+
</Accordion>
|
|
223
|
+
|
|
224
|
+
## Communicate status
|
|
225
|
+
|
|
226
|
+
<Badge variant="success">Stable</Badge>{" "}
|
|
227
|
+
<Badge variant="warning">Beta</Badge>{" "}
|
|
228
|
+
<Badge variant="info">New</Badge>
|
|
229
|
+
|
|
230
|
+
<Tip>
|
|
231
|
+
Browse the complete component library at [docs.thally.io](https://docs.thally.io/components/card).
|
|
232
|
+
</Tip>
|
|
233
|
+
`,
|
|
234
|
+
"customization.mdx": `---
|
|
235
|
+
title: Customization
|
|
236
|
+
description: Make {NAME} feel unmistakably like your product.
|
|
237
|
+
keywords:
|
|
238
|
+
- {NAME}
|
|
239
|
+
- branding
|
|
240
|
+
- navigation
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
Your documentation should feel like part of the product\u2014not a separate website.
|
|
244
|
+
|
|
245
|
+
<CardGroup cols={2}>
|
|
246
|
+
<Card title="Brand and theme" icon="party-horn" href="https://docs.thally.io/guides/branding-and-theming">
|
|
247
|
+
Configure colors, logos, favicons, typography, and light or dark presentation.
|
|
248
|
+
</Card>
|
|
249
|
+
<Card title="Navigation" icon="book-open" href="https://docs.thally.io/guides/configuring-navigation">
|
|
250
|
+
Organize tabs, icon-labelled groups, pages, and external destinations in \`docs.json\`.
|
|
251
|
+
</Card>
|
|
252
|
+
<Card title="Domains" icon="link-simple" href="https://app.thally.io">
|
|
253
|
+
Connect a custom domain from your site settings in Thally Cloud.
|
|
254
|
+
</Card>
|
|
255
|
+
<Card title="Analytics and feedback" icon="message" href="https://app.thally.io">
|
|
256
|
+
Learn what readers need and collect feedback without third-party widgets.
|
|
257
|
+
</Card>
|
|
258
|
+
</CardGroup>
|
|
259
|
+
|
|
260
|
+
<Note type="info" title="Start with docs.json">
|
|
261
|
+
Navigation and portable presentation settings live in \`docs.json\`. Site
|
|
262
|
+
identity and fallback brand values live in \`src/data/site.ts\`.
|
|
263
|
+
</Note>
|
|
264
|
+
`,
|
|
265
|
+
"changelog.mdx": `---
|
|
266
|
+
title: Changelog
|
|
267
|
+
description: Notable changes, releases, and improvements to {NAME}.
|
|
268
|
+
keywords:
|
|
269
|
+
- {NAME}
|
|
270
|
+
- changelog
|
|
271
|
+
- releases
|
|
272
|
+
- updates
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## v0.1.0
|
|
276
|
+
|
|
277
|
+
The first release of your **{NAME}** documentation.
|
|
278
|
+
|
|
279
|
+
- Initial docs site scaffolded with [Thally](https://github.com/thallylabs/thally)
|
|
280
|
+
- Agent-ready endpoints live: \`/llms.txt\`, \`/ai.txt\`, \`/api/docs-index\`, and \`/api/agent-readiness\`
|
|
281
|
+
- Starter guides in the Overview tab and an interactive API reference
|
|
282
|
+
|
|
283
|
+
Edit this page at \`src/content/changelog.mdx\` to announce your own releases as you ship.
|
|
284
|
+
`
|
|
285
|
+
};
|
|
286
|
+
var STARTER_SPANISH_PAGES = {
|
|
287
|
+
"introduction.mdx": `---
|
|
288
|
+
title: Introducci\xF3n
|
|
289
|
+
description: Te damos la bienvenida a {NAME}.
|
|
290
|
+
mode: home
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
<Hero
|
|
294
|
+
title="Te damos la bienvenida a {NAME}"
|
|
295
|
+
subtitle="Usa este sitio inicial para presentar tu producto, guiar a tus lectores hasta su primer resultado y publicar una referencia de API clara."
|
|
296
|
+
primaryLabel="Abrir inicio r\xE1pido"
|
|
297
|
+
primaryHref="/es/quickstart"
|
|
298
|
+
secondaryLabel="Ver componentes"
|
|
299
|
+
secondaryHref="/es/components"
|
|
300
|
+
/>
|
|
301
|
+
|
|
302
|
+
<CardGroup cols={3}>
|
|
303
|
+
<Card title="Inicio r\xE1pido" icon="party-horn" href="/es/quickstart">
|
|
304
|
+
Ayuda a tus lectores a lograr su primer resultado en minutos.
|
|
305
|
+
</Card>
|
|
306
|
+
<Card title="Componentes" icon="grid-round" href="/es/components">
|
|
307
|
+
Usa pesta\xF1as, pasos, tarjetas, avisos y acordeones.
|
|
308
|
+
</Card>
|
|
309
|
+
<Card title="Referencia de API" icon="code-simple" href="/es/api">
|
|
310
|
+
Convierte \`openapi.yaml\` en documentaci\xF3n interactiva.
|
|
311
|
+
</Card>
|
|
312
|
+
<Card title="Personalizaci\xF3n" icon="wrench" href="/es/customization">
|
|
313
|
+
Adapta la navegaci\xF3n, marca, tipograf\xEDa y enlaces.
|
|
314
|
+
</Card>
|
|
315
|
+
<Card title="Varios idiomas" icon="message" href="/">
|
|
316
|
+
Cambia entre ingl\xE9s y espa\xF1ol desde el selector de idioma.
|
|
317
|
+
</Card>
|
|
318
|
+
<Card title="Preparado para IA" icon="link-simple" href="/llms.txt">
|
|
319
|
+
Publica contenido legible por agentes desde el primer d\xEDa.
|
|
320
|
+
</Card>
|
|
321
|
+
</CardGroup>
|
|
322
|
+
`,
|
|
323
|
+
"quickstart.mdx": `---
|
|
324
|
+
title: Inicio r\xE1pido
|
|
325
|
+
description: Gu\xEDa a tus lectores hasta su primer resultado con {NAME}.
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
Un buen inicio r\xE1pido lleva al lector de cero a un resultado visible sin explicar
|
|
329
|
+
todas las opciones.
|
|
330
|
+
|
|
331
|
+
<Steps>
|
|
332
|
+
<Step title="Instala">
|
|
333
|
+
Explica c\xF3mo instalar {NAME} o crear una cuenta.
|
|
334
|
+
|
|
335
|
+
\`\`\`bash
|
|
336
|
+
npm install your-package
|
|
337
|
+
\`\`\`
|
|
338
|
+
</Step>
|
|
339
|
+
<Step title="Configura">
|
|
340
|
+
Muestra \xFAnicamente la configuraci\xF3n necesaria para comenzar.
|
|
341
|
+
</Step>
|
|
342
|
+
<Step title="Ejecuta">
|
|
343
|
+
Termina con una acci\xF3n y un resultado que el lector pueda comprobar.
|
|
344
|
+
</Step>
|
|
345
|
+
</Steps>
|
|
346
|
+
|
|
347
|
+
<Tip>Enlaza la siguiente gu\xEDa que deber\xEDa leer una vez completado este flujo.</Tip>
|
|
348
|
+
`,
|
|
349
|
+
"components.mdx": `---
|
|
350
|
+
title: Componentes
|
|
351
|
+
description: Una muestra de los componentes MDX disponibles en {NAME}.
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
<Tabs>
|
|
355
|
+
<Tab title="npm">\`npm install your-package\`</Tab>
|
|
356
|
+
<Tab title="pnpm">\`pnpm add your-package\`</Tab>
|
|
357
|
+
<Tab title="yarn">\`yarn add your-package\`</Tab>
|
|
358
|
+
</Tabs>
|
|
359
|
+
|
|
360
|
+
<Accordion title="\xBFD\xF3nde debe ir la configuraci\xF3n avanzada?">
|
|
361
|
+
Mant\xE9n visible el camino principal y coloca los detalles opcionales aqu\xED.
|
|
362
|
+
</Accordion>
|
|
363
|
+
|
|
364
|
+
<Badge variant="success">Estable</Badge>{" "}
|
|
365
|
+
<Badge variant="warning">Beta</Badge>{" "}
|
|
366
|
+
<Badge variant="info">Nuevo</Badge>
|
|
367
|
+
`,
|
|
368
|
+
"customization.mdx": `---
|
|
369
|
+
title: Personalizaci\xF3n
|
|
370
|
+
description: Haz que {NAME} se sienta como una parte natural de tu producto.
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
<CardGroup cols={2}>
|
|
374
|
+
<Card title="Marca y tema" icon="party-horn">Configura colores, logotipos, tipograf\xEDa y apariencia.</Card>
|
|
375
|
+
<Card title="Navegaci\xF3n" icon="book-open">Organiza pesta\xF1as, grupos con iconos y p\xE1ginas en \`docs.json\`.</Card>
|
|
376
|
+
<Card title="Dominios" icon="link-simple">Conecta un dominio personalizado desde Thally Cloud.</Card>
|
|
377
|
+
<Card title="Anal\xEDtica y feedback" icon="message">Comprende qu\xE9 necesitan tus lectores.</Card>
|
|
378
|
+
</CardGroup>
|
|
379
|
+
`,
|
|
380
|
+
"changelog.mdx": `---
|
|
381
|
+
title: Novedades
|
|
382
|
+
description: Cambios, versiones y mejoras destacadas de {NAME}.
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## v0.1.0
|
|
386
|
+
|
|
387
|
+
La primera versi\xF3n de la documentaci\xF3n de **{NAME}**.
|
|
388
|
+
|
|
389
|
+
- Sitio creado con [Thally](https://github.com/thallylabs/thally)
|
|
390
|
+
- Referencia de API y contenido preparado para agentes
|
|
391
|
+
- Ejemplo biling\xFCe en ingl\xE9s y espa\xF1ol
|
|
392
|
+
`
|
|
393
|
+
};
|
|
394
|
+
function buildStarterDocsJson({
|
|
395
|
+
enableAiChat,
|
|
396
|
+
repoUrl,
|
|
397
|
+
i18nLocales
|
|
398
|
+
}) {
|
|
399
|
+
const config = {};
|
|
400
|
+
config.theme = "default";
|
|
401
|
+
if (enableAiChat) {
|
|
402
|
+
config.ai = { chat: true };
|
|
403
|
+
}
|
|
404
|
+
if (repoUrl) {
|
|
405
|
+
config.navbar = {
|
|
406
|
+
links: [{ label: "GitHub", href: repoUrl, type: "github" }],
|
|
407
|
+
primary: { label: "Get started", href: "/quickstart" }
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
const locales = [
|
|
411
|
+
{ code: "en", label: "English" },
|
|
412
|
+
{ code: "es", label: "Espa\xF1ol" },
|
|
413
|
+
...(i18nLocales ?? []).filter(({ code }) => code !== "en" && code !== "es")
|
|
414
|
+
];
|
|
415
|
+
config.i18n = { defaultLocale: "en", locales };
|
|
416
|
+
config.tabs = [
|
|
417
|
+
{
|
|
418
|
+
tab: "Overview",
|
|
419
|
+
groups: [
|
|
420
|
+
{ group: "Getting Started", icon: "book-open", pages: ["introduction", "quickstart"] },
|
|
421
|
+
{ group: "Explore", icon: "grid-round", pages: ["components"] },
|
|
422
|
+
{ group: "Project", icon: "wrench", pages: ["customization"] }
|
|
423
|
+
]
|
|
424
|
+
},
|
|
425
|
+
{ tab: "API Reference", api: { source: "openapi.yaml" } },
|
|
426
|
+
{ tab: "Changelog", href: "/changelog" }
|
|
427
|
+
];
|
|
428
|
+
return JSON.stringify(config, null, 2) + "\n";
|
|
429
|
+
}
|
|
430
|
+
function writeStarterContent(targetDir, projectName, enableAiChat = true, repoUrl = "", i18nLocales) {
|
|
431
|
+
const contentDir = join2(targetDir, "src", "content");
|
|
432
|
+
if (existsSync(contentDir)) {
|
|
433
|
+
const entries = readdirSync(contentDir);
|
|
434
|
+
for (const entry of entries) {
|
|
435
|
+
const fullPath = join2(contentDir, entry);
|
|
436
|
+
rmSync(fullPath, { recursive: true, force: true });
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
mkdirSync(contentDir, { recursive: true });
|
|
440
|
+
}
|
|
441
|
+
for (const [filename, template] of Object.entries(STARTER_PAGES)) {
|
|
442
|
+
const content = template.replace(/\{NAME\}/g, projectName);
|
|
443
|
+
writeFileSync2(join2(contentDir, filename), content, "utf8");
|
|
444
|
+
}
|
|
445
|
+
const spanishDir = join2(contentDir, "es");
|
|
446
|
+
mkdirSync(spanishDir, { recursive: true });
|
|
447
|
+
for (const [filename, template] of Object.entries(STARTER_SPANISH_PAGES)) {
|
|
448
|
+
const content = template.replace(/\{NAME\}/g, projectName);
|
|
449
|
+
writeFileSync2(join2(spanishDir, filename), content, "utf8");
|
|
450
|
+
}
|
|
451
|
+
writeFileSync2(
|
|
452
|
+
join2(targetDir, "docs.json"),
|
|
453
|
+
buildStarterDocsJson({ enableAiChat, repoUrl: repoUrl || void 0, i18nLocales }),
|
|
454
|
+
"utf8"
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
function writeStarterAgentGuide(targetDir, projectName) {
|
|
458
|
+
const guide = `# ${projectName} documentation instructions
|
|
459
|
+
|
|
460
|
+
## About this project
|
|
461
|
+
|
|
462
|
+
- This is a documentation site built with [Thally](https://github.com/thallylabs/thally).
|
|
463
|
+
- Pages are MDX files with YAML frontmatter in \`src/content/\`.
|
|
464
|
+
- Navigation and product features are configured in \`docs.json\`.
|
|
465
|
+
- Site identity and fallback brand values live in \`src/data/site.ts\`.
|
|
466
|
+
- Use \`/llms.txt\`, \`/llms-full.txt\`, and \`/skill.md\` on the deployed site for agent-readable context.
|
|
467
|
+
|
|
468
|
+
## Terminology
|
|
469
|
+
|
|
470
|
+
<!-- Add product-specific terms and preferred usage. -->
|
|
471
|
+
|
|
472
|
+
## Writing style
|
|
473
|
+
|
|
474
|
+
- Use active voice and address the reader as \u201Cyou.\u201D
|
|
475
|
+
- Keep sentences concise and headings in sentence case.
|
|
476
|
+
- Bold interface labels and format commands, files, and code with backticks.
|
|
477
|
+
- Lead with the outcome, then explain prerequisites and steps.
|
|
478
|
+
|
|
479
|
+
## Content boundaries
|
|
480
|
+
|
|
481
|
+
<!-- Define what belongs in public docs and what must remain internal. -->
|
|
482
|
+
`;
|
|
483
|
+
writeFileSync2(join2(targetDir, "AGENTS.md"), guide, "utf8");
|
|
484
|
+
}
|
|
485
|
+
function writeStarterReadme(targetDir, projectName) {
|
|
486
|
+
const readme = `# ${projectName}
|
|
487
|
+
|
|
488
|
+
Documentation powered by [Thally](https://github.com/thallylabs/thally).
|
|
489
|
+
|
|
490
|
+
## Local development
|
|
491
|
+
|
|
492
|
+
\`\`\`bash
|
|
493
|
+
npm install
|
|
494
|
+
npm run dev
|
|
495
|
+
\`\`\`
|
|
496
|
+
|
|
497
|
+
Open [http://localhost:3040](http://localhost:3040).
|
|
498
|
+
|
|
499
|
+
## Write your docs
|
|
500
|
+
|
|
501
|
+
- Add MDX pages in \`src/content/\`.
|
|
502
|
+
- Organize navigation and product features in \`docs.json\`.
|
|
503
|
+
- Update the site name, links, and brand defaults in \`src/data/site.ts\`.
|
|
504
|
+
- Copy \`.env.example\` to \`.env.local\` for local secrets.
|
|
505
|
+
|
|
506
|
+
The starter includes a home hero, icon-grouped navigation, English and Spanish
|
|
507
|
+
examples, a guided quickstart, component showcase, changelog, OpenAPI reference,
|
|
508
|
+
and \`AGENTS.md\` writing instructions for coding agents.
|
|
509
|
+
|
|
510
|
+
## Publishing changes
|
|
511
|
+
|
|
512
|
+
Push changes to the default branch to trigger your connected deployment. If the
|
|
513
|
+
site is not connected yet, add the repository in
|
|
514
|
+
[Thally Cloud](https://app.thally.io) or deploy it to any Next.js host.
|
|
515
|
+
|
|
516
|
+
Run \`npx create-thally-docs check --ci .\` before publishing. Deploy the site
|
|
517
|
+
anywhere Next.js is supported, or connect the repository to
|
|
518
|
+
[Thally Cloud](https://app.thally.io) for managed hosting and services.
|
|
519
|
+
`;
|
|
520
|
+
writeFileSync2(join2(targetDir, "README.md"), readme, "utf8");
|
|
521
|
+
}
|
|
522
|
+
function updateSiteConfig(targetDir, projectName, description, brandPreset, repoUrl) {
|
|
523
|
+
const siteFile = join2(targetDir, "src", "data", "site.ts");
|
|
524
|
+
if (!existsSync(siteFile)) {
|
|
525
|
+
console.log(" \u26A0\uFE0F Could not find src/data/site.ts \u2014 skipping config update.");
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
let source = readFileSync2(siteFile, "utf8");
|
|
529
|
+
source = source.replace(
|
|
530
|
+
/name:\s*'[^']*'/,
|
|
531
|
+
`name: '${projectName.replace(/'/g, "\\'")}'`
|
|
532
|
+
);
|
|
533
|
+
source = source.replace(
|
|
534
|
+
/description:\s*\n\s*'[^']*'/,
|
|
535
|
+
`description:
|
|
536
|
+
'${description.replace(/'/g, "\\'")}'`
|
|
537
|
+
);
|
|
538
|
+
source = source.replace(
|
|
539
|
+
/const brandPreset:\s*BrandPresetKey\s*=\s*'[^']*'/,
|
|
540
|
+
`const brandPreset: BrandPresetKey = '${brandPreset}'`
|
|
541
|
+
);
|
|
542
|
+
source = source.replace(/repoUrl:\s*'[^']*'/, `repoUrl: '${repoUrl}'`);
|
|
543
|
+
source = source.replace(
|
|
544
|
+
/\{\s*label:\s*'GitHub',\s*href:\s*'[^']*'\s*\}/,
|
|
545
|
+
`{ label: 'GitHub', href: '${repoUrl}' }`
|
|
546
|
+
);
|
|
547
|
+
source = source.replace(
|
|
548
|
+
/\{\s*label:\s*'Support',\s*href:\s*'[^']*'\s*\}/,
|
|
549
|
+
`{ label: 'Support', href: '${repoUrl ? `${repoUrl}/issues/new` : ""}' }`
|
|
550
|
+
);
|
|
551
|
+
if (!repoUrl) {
|
|
552
|
+
source = source.replace(
|
|
553
|
+
/\n\s*\{\s*label:\s*'(?:GitHub|Support)',\s*href:\s*''\s*\},?/g,
|
|
554
|
+
""
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
writeFileSync2(siteFile, source, "utf8");
|
|
558
|
+
}
|
|
559
|
+
function patchApiReferenceGuard(targetDir) {
|
|
560
|
+
const filePath = join2(targetDir, "src", "data", "api-reference.ts");
|
|
561
|
+
if (!existsSync(filePath)) return;
|
|
562
|
+
let source = readFileSync2(filePath, "utf8");
|
|
563
|
+
source = source.replace(
|
|
564
|
+
/export async function buildApiNavigation\([^)]*\)[^{]*\{\n/,
|
|
565
|
+
(match) => `${match} if (apiReferenceConfig.specs.length === 0) return []
|
|
566
|
+
`
|
|
567
|
+
);
|
|
568
|
+
writeFileSync2(filePath, source, "utf8");
|
|
569
|
+
}
|
|
570
|
+
function patchTopBarNavigation(targetDir) {
|
|
571
|
+
const filePath = join2(targetDir, "src", "components", "layout", "top-bar.tsx");
|
|
572
|
+
if (!existsSync(filePath)) return;
|
|
573
|
+
const source = readFileSync2(filePath, "utf8");
|
|
574
|
+
if (!source.includes("target={isExternal ? '_blank' : undefined}")) return;
|
|
575
|
+
const patched = source.replace(
|
|
576
|
+
/if \(collection\.href\) \{\n const isExternal[^\n]+\n return \(\n <a[\s\S]*?<\/a>\n \)\n \}/,
|
|
577
|
+
`if (collection.href) {
|
|
578
|
+
const isExternal = /^https?:\\/\\//.test(collection.href)
|
|
579
|
+
if (isExternal) {
|
|
580
|
+
return (
|
|
581
|
+
<a
|
|
582
|
+
key={collection.id}
|
|
583
|
+
href={collection.href}
|
|
584
|
+
target="_blank"
|
|
585
|
+
rel="noreferrer"
|
|
586
|
+
className={baseClasses}
|
|
587
|
+
>
|
|
588
|
+
{collection.label}
|
|
589
|
+
</a>
|
|
590
|
+
)
|
|
591
|
+
}
|
|
592
|
+
return (
|
|
593
|
+
<Link
|
|
594
|
+
key={collection.id}
|
|
595
|
+
href={collection.href}
|
|
596
|
+
className={baseClasses}
|
|
597
|
+
>
|
|
598
|
+
{collection.label}
|
|
599
|
+
</Link>
|
|
600
|
+
)
|
|
601
|
+
}`
|
|
602
|
+
);
|
|
603
|
+
writeFileSync2(filePath, patched, "utf8");
|
|
604
|
+
}
|
|
605
|
+
function patchOpenApiFetch(targetDir) {
|
|
606
|
+
const filePath = join2(targetDir, "src", "lib", "openapi", "fetch.ts");
|
|
607
|
+
if (!existsSync(filePath)) return;
|
|
608
|
+
let source = readFileSync2(filePath, "utf8");
|
|
609
|
+
source = source.replace(
|
|
610
|
+
/const absolutePath = path\.isAbsolute\(filePath\) \? filePath : path\.resolve\(process\.cwd\(\), filePath\)/,
|
|
611
|
+
`const absolutePath = filePath.startsWith('/')
|
|
612
|
+
? path.resolve(process.cwd(), 'public', filePath.slice(1))
|
|
613
|
+
: path.resolve(process.cwd(), filePath)`
|
|
614
|
+
);
|
|
615
|
+
writeFileSync2(filePath, source, "utf8");
|
|
616
|
+
}
|
|
617
|
+
function updateEnvExample(targetDir) {
|
|
618
|
+
const envFile = join2(targetDir, ".env.example");
|
|
619
|
+
if (existsSync(envFile)) {
|
|
620
|
+
const envLocal = join2(targetDir, ".env.local");
|
|
621
|
+
if (!existsSync(envLocal)) {
|
|
622
|
+
cpSync(envFile, envLocal);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function patchPackageJson(targetDir, slug) {
|
|
627
|
+
const pkgPath = join2(targetDir, "package.json");
|
|
628
|
+
if (!existsSync(pkgPath)) return;
|
|
629
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
630
|
+
const hadWorkspaces = Array.isArray(pkg.workspaces) && pkg.workspaces.length > 0;
|
|
631
|
+
pkg.name = slug;
|
|
632
|
+
delete pkg.workspaces;
|
|
633
|
+
if (pkg.scripts) {
|
|
634
|
+
if (pkg.scripts["prebuild"]) pkg.scripts["prebuild"] = "npm run embeddings:build";
|
|
635
|
+
delete pkg.scripts["pretest"];
|
|
636
|
+
delete pkg.scripts["packages:build"];
|
|
637
|
+
}
|
|
638
|
+
if (pkg.dependencies?.["@thallylabs/mcp"] === "*") {
|
|
639
|
+
pkg.dependencies["@thallylabs/mcp"] = "0.7.0";
|
|
640
|
+
}
|
|
641
|
+
writeFileSync2(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
642
|
+
`, "utf8");
|
|
643
|
+
const lockPath = join2(targetDir, "package-lock.json");
|
|
644
|
+
if (!existsSync(lockPath)) return;
|
|
645
|
+
const lock = JSON.parse(readFileSync2(lockPath, "utf8"));
|
|
646
|
+
const hasWorkspaceEntries = Object.keys(lock.packages ?? {}).some(
|
|
647
|
+
(key) => key === "packages" || key.startsWith("packages/")
|
|
648
|
+
);
|
|
649
|
+
if (hadWorkspaces || hasWorkspaceEntries) {
|
|
650
|
+
rmSync(lockPath);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
lock.name = slug;
|
|
654
|
+
if (lock.packages?.[""]) lock.packages[""].name = slug;
|
|
655
|
+
writeFileSync2(lockPath, `${JSON.stringify(lock, null, 2)}
|
|
656
|
+
`, "utf8");
|
|
657
|
+
}
|
|
658
|
+
function patchGitignore(targetDir) {
|
|
659
|
+
const gitignorePath = join2(targetDir, ".gitignore");
|
|
660
|
+
const existing = existsSync(gitignorePath) ? readFileSync2(gitignorePath, "utf8") : "";
|
|
661
|
+
const lines = existing.split(/\r?\n/);
|
|
662
|
+
if (lines.includes("node_modules/")) return;
|
|
663
|
+
const separator = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
664
|
+
writeFileSync2(gitignorePath, `${existing}${separator}node_modules/
|
|
665
|
+
`, "utf8");
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// src/utils.ts
|
|
669
|
+
import { execSync } from "child_process";
|
|
670
|
+
import { basename } from "path";
|
|
671
|
+
function slugify(name) {
|
|
672
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
673
|
+
}
|
|
674
|
+
function run(cmd, cwd) {
|
|
675
|
+
execSync(cmd, { cwd, stdio: "inherit" });
|
|
676
|
+
}
|
|
677
|
+
function initGit(targetDir) {
|
|
678
|
+
try {
|
|
679
|
+
run("git init", targetDir);
|
|
680
|
+
run("git add -A", targetDir);
|
|
681
|
+
run('git commit -m "Initial commit from create-thally-docs"', targetDir);
|
|
682
|
+
} catch {
|
|
683
|
+
console.log(" \u26A0\uFE0F Could not initialize git (you can do this manually).");
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function installDeps(targetDir) {
|
|
687
|
+
console.log("");
|
|
688
|
+
console.log(" \u{1F4E6} Installing dependencies...");
|
|
689
|
+
console.log("");
|
|
690
|
+
run("npm install", targetDir);
|
|
691
|
+
}
|
|
692
|
+
function logo() {
|
|
693
|
+
console.log("");
|
|
694
|
+
console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
|
|
695
|
+
console.log(" \u2551 \u2551");
|
|
696
|
+
console.log(" \u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2551");
|
|
697
|
+
console.log(" \u2551 \u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D \u2551");
|
|
698
|
+
console.log(" \u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2551");
|
|
699
|
+
console.log(" \u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2554\u255D \u2551");
|
|
700
|
+
console.log(" \u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2551");
|
|
701
|
+
console.log(" \u2551 \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u2551");
|
|
702
|
+
console.log(" \u2551 \u2551");
|
|
703
|
+
console.log(" \u2551 Beautiful docs, zero lock-in. \u2551");
|
|
704
|
+
console.log(" \u2551 \u2551");
|
|
705
|
+
console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
|
|
706
|
+
console.log("");
|
|
707
|
+
}
|
|
708
|
+
function success(projectDir, projectName) {
|
|
709
|
+
console.log("");
|
|
710
|
+
console.log(" \u2705 Your Thally project is ready!");
|
|
711
|
+
console.log("");
|
|
712
|
+
console.log(` \u{1F4C2} ${projectDir}`);
|
|
713
|
+
console.log("");
|
|
714
|
+
console.log(" Next steps:");
|
|
715
|
+
console.log("");
|
|
716
|
+
console.log(` cd ${basename(projectDir)}`);
|
|
717
|
+
console.log(" npm run dev");
|
|
718
|
+
console.log("");
|
|
719
|
+
console.log(` Then open http://localhost:3040 to see your ${projectName} docs.`);
|
|
720
|
+
console.log("");
|
|
721
|
+
console.log(" \u{1F4DD} Key files to edit:");
|
|
722
|
+
console.log(" \u2022 src/data/site.ts \u2014 name, links, branding");
|
|
723
|
+
console.log(" \u2022 docs.json \u2014 navigation structure");
|
|
724
|
+
console.log(" \u2022 src/content/*.mdx \u2014 your documentation");
|
|
725
|
+
console.log(" \u2022 openapi.yaml \u2014 API spec (optional)");
|
|
726
|
+
console.log("");
|
|
727
|
+
console.log(" Happy documenting! \u{1F680}");
|
|
728
|
+
console.log("");
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// src/scaffold.ts
|
|
732
|
+
async function scaffold(options) {
|
|
733
|
+
const {
|
|
734
|
+
projectDir,
|
|
735
|
+
projectName,
|
|
736
|
+
description,
|
|
737
|
+
brandPreset,
|
|
738
|
+
repoUrl,
|
|
739
|
+
doInstall,
|
|
740
|
+
enableAiChat = true,
|
|
741
|
+
i18nLocales,
|
|
742
|
+
trackRepos
|
|
743
|
+
} = options;
|
|
744
|
+
const targetDir = resolve(projectDir);
|
|
745
|
+
if (existsSync2(targetDir) && readdirSync2(targetDir).length > 0) {
|
|
746
|
+
throw new Error(`Directory "${targetDir}" already exists and is not empty.`);
|
|
747
|
+
}
|
|
748
|
+
mkdirSync2(targetDir, { recursive: true });
|
|
749
|
+
const slug = slugify(projectName);
|
|
750
|
+
await downloadTemplate(targetDir, projectName);
|
|
751
|
+
resetTrackingConfig(targetDir);
|
|
752
|
+
if (trackRepos?.length) {
|
|
753
|
+
writeTrackingConfig(targetDir, trackRepos);
|
|
754
|
+
const list = trackRepos.map((r) => `${r.owner}/${r.repo}`).join(", ");
|
|
755
|
+
console.log(` \u2713 Thally Track enabled \u2014 watching ${list} (branch main, all files; refine in docs.json).`);
|
|
756
|
+
console.log(" To finish wiring it: `thally track setup` (pick a trigger) + `thally agent init`,");
|
|
757
|
+
console.log(" then add your ANTHROPIC_API_KEY. See /guides/thally-track.");
|
|
758
|
+
}
|
|
759
|
+
writeStarterContent(targetDir, projectName, enableAiChat, repoUrl, i18nLocales);
|
|
760
|
+
writeStarterReadme(targetDir, projectName);
|
|
761
|
+
writeStarterAgentGuide(targetDir, projectName);
|
|
762
|
+
updateSiteConfig(targetDir, projectName, description, brandPreset, repoUrl);
|
|
763
|
+
patchApiReferenceGuard(targetDir);
|
|
764
|
+
patchTopBarNavigation(targetDir);
|
|
765
|
+
patchOpenApiFetch(targetDir);
|
|
766
|
+
patchPackageJson(targetDir, slug);
|
|
767
|
+
patchGitignore(targetDir);
|
|
768
|
+
updateEnvExample(targetDir);
|
|
769
|
+
if (doInstall) {
|
|
770
|
+
installDeps(targetDir);
|
|
771
|
+
}
|
|
772
|
+
initGit(targetDir);
|
|
773
|
+
return { projectDir: targetDir };
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
export {
|
|
777
|
+
slugify,
|
|
778
|
+
initGit,
|
|
779
|
+
installDeps,
|
|
780
|
+
logo,
|
|
781
|
+
success,
|
|
782
|
+
readDocsJson,
|
|
783
|
+
writeDocsJson,
|
|
784
|
+
scaffold
|
|
785
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
initGit,
|
|
4
4
|
installDeps,
|
|
5
5
|
scaffold
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KN6QUPKR.js";
|
|
7
7
|
|
|
8
8
|
// src/migrate/index.ts
|
|
9
9
|
import { mkdirSync as mkdirSync2, copyFileSync as copyFileSync2, readFileSync as readFileSync3, writeFileSync, existsSync as existsSync3, mkdtempSync, rmSync } from "fs";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
migrateDocs,
|
|
4
4
|
parseGitHubUrl
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QGRDDS5V.js";
|
|
6
6
|
import {
|
|
7
7
|
logo,
|
|
8
8
|
readDocsJson,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
slugify,
|
|
11
11
|
success,
|
|
12
12
|
writeDocsJson
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KN6QUPKR.js";
|
|
14
14
|
|
|
15
15
|
// src/index.ts
|
|
16
16
|
import { existsSync as existsSync3, readdirSync as readdirSync2 } from "fs";
|
|
@@ -240,8 +240,17 @@ function extractLinks(content) {
|
|
|
240
240
|
}
|
|
241
241
|
return links;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
243
|
+
function localizedPage(pageId, secondaryLocales) {
|
|
244
|
+
const [first, ...rest] = pageId.split("/");
|
|
245
|
+
if (secondaryLocales.has(first) && rest.length > 0) {
|
|
246
|
+
return { navPageId: rest.join("/"), locale: first };
|
|
247
|
+
}
|
|
248
|
+
return { navPageId: pageId };
|
|
249
|
+
}
|
|
250
|
+
function pageIdToPath(pageId, secondaryLocales) {
|
|
251
|
+
const { navPageId, locale } = localizedPage(pageId, secondaryLocales);
|
|
252
|
+
const basePath = navPageId === "introduction" ? "/" : `/${navPageId}`;
|
|
253
|
+
return locale ? `/${locale}${basePath === "/" ? "" : basePath}` : basePath;
|
|
245
254
|
}
|
|
246
255
|
function validateOpenApi(projectDir, source, issues) {
|
|
247
256
|
const specPath = join(projectDir, source);
|
|
@@ -292,6 +301,13 @@ async function runCheck(projectDir, options) {
|
|
|
292
301
|
const contentDir = join(projectDir, "src", "content");
|
|
293
302
|
const issues = [];
|
|
294
303
|
const config = readDocsJson(projectDir);
|
|
304
|
+
const secondaryLocales = new Set(
|
|
305
|
+
(config.i18n?.locales ?? []).map((locale) => locale.code).filter((code) => code !== config.i18n?.defaultLocale)
|
|
306
|
+
);
|
|
307
|
+
const generatedApiPaths = /* @__PURE__ */ new Set([
|
|
308
|
+
"/api",
|
|
309
|
+
...Array.from(secondaryLocales, (locale) => `/${locale}/api`)
|
|
310
|
+
]);
|
|
295
311
|
const navPageIds = /* @__PURE__ */ new Set();
|
|
296
312
|
const duplicates = /* @__PURE__ */ new Set();
|
|
297
313
|
for (const tab of config.tabs) {
|
|
@@ -324,7 +340,8 @@ async function runCheck(projectDir, options) {
|
|
|
324
340
|
for (const filePath of allFiles) {
|
|
325
341
|
const rel = filePath.slice(contentDir.length + 1).replace(/\.mdx$/, "").replace(/\\/g, "/");
|
|
326
342
|
const pageId = rel.endsWith("/index") ? rel.slice(0, -6) : rel;
|
|
327
|
-
|
|
343
|
+
const { navPageId } = localizedPage(pageId, secondaryLocales);
|
|
344
|
+
if (!navPageIds.has(navPageId)) {
|
|
328
345
|
if (fix) {
|
|
329
346
|
addOrphanToNav(projectDir, pageId);
|
|
330
347
|
fixedOrphans.push(pageId);
|
|
@@ -350,7 +367,7 @@ async function runCheck(projectDir, options) {
|
|
|
350
367
|
if (!data.description) issues.push({ severity: "warning", message: `Missing "description" in frontmatter`, file: rel2 });
|
|
351
368
|
if (content.trim().length < 50) issues.push({ severity: "warning", message: `Very short body (${content.trim().length} chars) \u2014 page may be empty`, file: rel2 });
|
|
352
369
|
if (options.drift) checkDrift(projectDir, rel2, data, issues);
|
|
353
|
-
const path = pageIdToPath(pageId);
|
|
370
|
+
const path = pageIdToPath(pageId, secondaryLocales);
|
|
354
371
|
const anchors = extractHeadingAnchors(content);
|
|
355
372
|
validPaths.add(path);
|
|
356
373
|
anchorsByPath.set(path, anchors);
|
|
@@ -371,7 +388,10 @@ async function runCheck(projectDir, options) {
|
|
|
371
388
|
const [beforeHash, anchor] = target.split("#");
|
|
372
389
|
let path = beforeHash.split("?")[0];
|
|
373
390
|
if (path.length > 1) path = path.replace(/\/$/, "");
|
|
374
|
-
|
|
391
|
+
const isGeneratedApiPath = Array.from(generatedApiPaths).some(
|
|
392
|
+
(prefix) => path === prefix || path.startsWith(`${prefix}/`)
|
|
393
|
+
);
|
|
394
|
+
if (isGeneratedApiPath || path.startsWith("/_next") || /\.[a-z0-9]+$/i.test(path)) continue;
|
|
375
395
|
if (!validPaths.has(path)) {
|
|
376
396
|
issues.push({ severity: "error", message: `Broken link: "${target}" \u2014 no page at "${path}"`, file, line });
|
|
377
397
|
} else if (anchor && !anchorsByPath.get(path)?.has(anchor)) {
|
package/dist/migrate/index.js
CHANGED
package/dist/scaffold.js
CHANGED
package/package.json
CHANGED
package/dist/chunk-EPL2DCB2.js
DELETED
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/scaffold.ts
|
|
4
|
-
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync as readdirSync2 } from "fs";
|
|
5
|
-
import { resolve } from "path";
|
|
6
|
-
|
|
7
|
-
// src/download.ts
|
|
8
|
-
import { Readable, pipeline } from "stream";
|
|
9
|
-
import { promisify } from "util";
|
|
10
|
-
import tar from "tar";
|
|
11
|
-
var pipelineAsync = promisify(pipeline);
|
|
12
|
-
var TARBALL_URL = "https://codeload.github.com/thallylabs/thally/tar.gz/main";
|
|
13
|
-
var EXCLUDE_PATHS = [
|
|
14
|
-
"/cli/",
|
|
15
|
-
"/packages/",
|
|
16
|
-
"/node_modules/",
|
|
17
|
-
"/.git/",
|
|
18
|
-
"/thally-agent.yml",
|
|
19
|
-
"/thally-track.yml",
|
|
20
|
-
"/CODEOWNERS"
|
|
21
|
-
];
|
|
22
|
-
function shouldInclude(path) {
|
|
23
|
-
for (const excluded of EXCLUDE_PATHS) {
|
|
24
|
-
if (path.includes(excluded)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
async function downloadTemplate(targetDir, siteName) {
|
|
31
|
-
console.log("");
|
|
32
|
-
console.log(` \u23F3 Creating ${siteName?.trim() || "your docs site"}...`);
|
|
33
|
-
const response = await fetch(TARBALL_URL);
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error(`Failed to download template: ${response.status} ${response.statusText}`);
|
|
36
|
-
}
|
|
37
|
-
if (!response.body) {
|
|
38
|
-
throw new Error("Response body is empty");
|
|
39
|
-
}
|
|
40
|
-
const nodeStream = Readable.fromWeb(response.body);
|
|
41
|
-
await pipelineAsync(
|
|
42
|
-
nodeStream,
|
|
43
|
-
tar.extract({ cwd: targetDir, strip: 1, filter: shouldInclude })
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/docs-json.ts
|
|
48
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
49
|
-
import { join } from "path";
|
|
50
|
-
function readDocsJson(projectDir) {
|
|
51
|
-
const docsPath = join(projectDir, "docs.json");
|
|
52
|
-
const raw = readFileSync(docsPath, "utf8");
|
|
53
|
-
return JSON.parse(raw);
|
|
54
|
-
}
|
|
55
|
-
function writeDocsJson(projectDir, config) {
|
|
56
|
-
const docsPath = join(projectDir, "docs.json");
|
|
57
|
-
writeFileSync(docsPath, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
58
|
-
}
|
|
59
|
-
function resetTrackingConfig(projectDir) {
|
|
60
|
-
const config = readDocsJson(projectDir);
|
|
61
|
-
if (config.tracking) {
|
|
62
|
-
delete config.tracking;
|
|
63
|
-
writeDocsJson(projectDir, config);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function writeTrackingConfig(projectDir, repos) {
|
|
67
|
-
if (repos.length === 0) return;
|
|
68
|
-
const config = readDocsJson(projectDir);
|
|
69
|
-
config.tracking = { repos: repos.map((r) => ({ owner: r.owner, repo: r.repo, branch: "main" })) };
|
|
70
|
-
writeDocsJson(projectDir, config);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// src/customize.ts
|
|
74
|
-
import { existsSync, mkdirSync, writeFileSync as writeFileSync2, readFileSync as readFileSync2, readdirSync, cpSync } from "fs";
|
|
75
|
-
import { join as join2 } from "path";
|
|
76
|
-
import { execSync } from "child_process";
|
|
77
|
-
var STARTER_PAGES = {
|
|
78
|
-
"introduction.mdx": `---
|
|
79
|
-
title: Introduction
|
|
80
|
-
description: Welcome to {NAME} \u2014 learn what it does, how the docs are organized, and where to start.
|
|
81
|
-
keywords:
|
|
82
|
-
- {NAME}
|
|
83
|
-
- documentation
|
|
84
|
-
- overview
|
|
85
|
-
- getting started
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## Welcome
|
|
89
|
-
|
|
90
|
-
Welcome to the **{NAME}** documentation. This is your home base for guides, API
|
|
91
|
-
references, and everything you need to build with {NAME}. The site is powered by
|
|
92
|
-
[Thally](https://github.com/thallylabs/thally), an agent-native docs platform \u2014 every page
|
|
93
|
-
is served to humans as polished HTML and to AI agents as structured JSON, JSON-LD,
|
|
94
|
-
and Markdown from the same URL, so assistants can read your docs accurately.
|
|
95
|
-
|
|
96
|
-
## What you'll find here
|
|
97
|
-
|
|
98
|
-
- **Guides** \u2014 step-by-step walkthroughs of common tasks and workflows.
|
|
99
|
-
- **API reference** \u2014 generated from your OpenAPI spec, with a live "Try It" console.
|
|
100
|
-
- **Quickstart** \u2014 install {NAME} and make your first call in a few minutes.
|
|
101
|
-
|
|
102
|
-
## Next steps
|
|
103
|
-
|
|
104
|
-
Start with the [Quickstart](/quickstart) to get {NAME} running, then make this site
|
|
105
|
-
your own by editing \`src/content/introduction.mdx\` and updating the navigation in
|
|
106
|
-
\`docs.json\`. Every change you save is instantly reflected for both readers and agents.
|
|
107
|
-
`,
|
|
108
|
-
"quickstart.mdx": `---
|
|
109
|
-
title: Quickstart
|
|
110
|
-
description: Install {NAME}, configure your API key, and make your first call in under five minutes.
|
|
111
|
-
keywords:
|
|
112
|
-
- {NAME}
|
|
113
|
-
- quickstart
|
|
114
|
-
- installation
|
|
115
|
-
- getting started
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## Installation
|
|
119
|
-
|
|
120
|
-
Install {NAME} with your package manager of choice. We recommend pinning the
|
|
121
|
-
version in your project so builds stay reproducible across machines and CI:
|
|
122
|
-
|
|
123
|
-
\`\`\`bash
|
|
124
|
-
npm install {SLUG}
|
|
125
|
-
\`\`\`
|
|
126
|
-
|
|
127
|
-
## Basic usage
|
|
128
|
-
|
|
129
|
-
Import the client and initialize it with your API key. Keep the key in an
|
|
130
|
-
environment variable rather than committing it to source control, so it never
|
|
131
|
-
leaks into your repository or build logs:
|
|
132
|
-
|
|
133
|
-
\`\`\`ts
|
|
134
|
-
import { create } from '{SLUG}'
|
|
135
|
-
|
|
136
|
-
const client = create({ apiKey: process.env.API_KEY })
|
|
137
|
-
\`\`\`
|
|
138
|
-
|
|
139
|
-
## What's next
|
|
140
|
-
|
|
141
|
-
That's the basics \u2014 you're ready to build. Explore the guides for common workflows,
|
|
142
|
-
open the API reference to try endpoints against a live "Try It" console, or edit this
|
|
143
|
-
page at \`src/content/quickstart.mdx\` to document your own onboarding flow.
|
|
144
|
-
`,
|
|
145
|
-
"changelog.mdx": `---
|
|
146
|
-
title: Changelog
|
|
147
|
-
description: Notable changes, releases, and improvements to {NAME}.
|
|
148
|
-
keywords:
|
|
149
|
-
- {NAME}
|
|
150
|
-
- changelog
|
|
151
|
-
- releases
|
|
152
|
-
- updates
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## v0.1.0
|
|
156
|
-
|
|
157
|
-
The first release of your **{NAME}** documentation.
|
|
158
|
-
|
|
159
|
-
- Initial docs site scaffolded with [Thally](https://github.com/thallylabs/thally)
|
|
160
|
-
- Agent-ready endpoints live: \`/llms.txt\`, \`/ai.txt\`, \`/api/docs-index\`, and \`/api/agent-readiness\`
|
|
161
|
-
- Starter guides in the Overview tab and an interactive API reference
|
|
162
|
-
|
|
163
|
-
Edit this page at \`src/content/changelog.mdx\` to announce your own releases as you ship.
|
|
164
|
-
`
|
|
165
|
-
};
|
|
166
|
-
function buildStarterDocsJson({
|
|
167
|
-
enableAiChat,
|
|
168
|
-
repoUrl,
|
|
169
|
-
i18nLocales
|
|
170
|
-
}) {
|
|
171
|
-
const config = {};
|
|
172
|
-
config.theme = "sharp";
|
|
173
|
-
config.fonts = {
|
|
174
|
-
body: { family: "Plus Jakarta Sans", weight: ["400", "500", "600", "700"] },
|
|
175
|
-
heading: { family: "Outfit", weight: ["600", "700"] }
|
|
176
|
-
};
|
|
177
|
-
if (enableAiChat) {
|
|
178
|
-
config.ai = { chat: true };
|
|
179
|
-
}
|
|
180
|
-
if (repoUrl) {
|
|
181
|
-
config.navbar = {
|
|
182
|
-
links: [{ label: "GitHub", href: repoUrl, type: "github" }],
|
|
183
|
-
primary: { label: "Get started", href: "/quickstart" }
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
if (i18nLocales && i18nLocales.length > 0) {
|
|
187
|
-
config.i18n = {
|
|
188
|
-
defaultLocale: "en",
|
|
189
|
-
locales: [{ code: "en", label: "English" }, ...i18nLocales]
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
config.tabs = [
|
|
193
|
-
{
|
|
194
|
-
tab: "Overview",
|
|
195
|
-
groups: [{ group: "Getting Started", pages: ["introduction", "quickstart"] }]
|
|
196
|
-
},
|
|
197
|
-
{ tab: "API Reference", api: { source: "openapi.yaml" } },
|
|
198
|
-
{ tab: "Changelog", href: "/changelog" }
|
|
199
|
-
];
|
|
200
|
-
return JSON.stringify(config, null, 2) + "\n";
|
|
201
|
-
}
|
|
202
|
-
function writeStarterContent(targetDir, projectName, slug, enableAiChat = true, repoUrl = "", i18nLocales) {
|
|
203
|
-
const contentDir = join2(targetDir, "src", "content");
|
|
204
|
-
if (existsSync(contentDir)) {
|
|
205
|
-
const entries = readdirSync(contentDir);
|
|
206
|
-
for (const entry of entries) {
|
|
207
|
-
const fullPath = join2(contentDir, entry);
|
|
208
|
-
execSync(`rm -rf "${fullPath}"`);
|
|
209
|
-
}
|
|
210
|
-
} else {
|
|
211
|
-
mkdirSync(contentDir, { recursive: true });
|
|
212
|
-
}
|
|
213
|
-
for (const [filename, template] of Object.entries(STARTER_PAGES)) {
|
|
214
|
-
const content = template.replace(/\{NAME\}/g, projectName).replace(/\{SLUG\}/g, slug);
|
|
215
|
-
writeFileSync2(join2(contentDir, filename), content, "utf8");
|
|
216
|
-
}
|
|
217
|
-
writeFileSync2(
|
|
218
|
-
join2(targetDir, "docs.json"),
|
|
219
|
-
buildStarterDocsJson({ enableAiChat, repoUrl: repoUrl || void 0, i18nLocales }),
|
|
220
|
-
"utf8"
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
function updateSiteConfig(targetDir, projectName, description, brandPreset, repoUrl) {
|
|
224
|
-
const siteFile = join2(targetDir, "src", "data", "site.ts");
|
|
225
|
-
if (!existsSync(siteFile)) {
|
|
226
|
-
console.log(" \u26A0\uFE0F Could not find src/data/site.ts \u2014 skipping config update.");
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
let source = readFileSync2(siteFile, "utf8");
|
|
230
|
-
source = source.replace(
|
|
231
|
-
/name:\s*'[^']*'/,
|
|
232
|
-
`name: '${projectName.replace(/'/g, "\\'")}'`
|
|
233
|
-
);
|
|
234
|
-
source = source.replace(
|
|
235
|
-
/description:\s*\n\s*'[^']*'/,
|
|
236
|
-
`description:
|
|
237
|
-
'${description.replace(/'/g, "\\'")}'`
|
|
238
|
-
);
|
|
239
|
-
source = source.replace(
|
|
240
|
-
/const brandPreset:\s*BrandPresetKey\s*=\s*'[^']*'/,
|
|
241
|
-
`const brandPreset: BrandPresetKey = '${brandPreset}'`
|
|
242
|
-
);
|
|
243
|
-
source = source.replace(/repoUrl:\s*'[^']*'/, `repoUrl: '${repoUrl}'`);
|
|
244
|
-
source = source.replace(
|
|
245
|
-
/\{\s*label:\s*'GitHub',\s*href:\s*'[^']*'\s*\}/,
|
|
246
|
-
`{ label: 'GitHub', href: '${repoUrl}' }`
|
|
247
|
-
);
|
|
248
|
-
source = source.replace(
|
|
249
|
-
/\{\s*label:\s*'Support',\s*href:\s*'[^']*'\s*\}/,
|
|
250
|
-
`{ label: 'Support', href: '${repoUrl ? `${repoUrl}/issues/new` : ""}' }`
|
|
251
|
-
);
|
|
252
|
-
writeFileSync2(siteFile, source, "utf8");
|
|
253
|
-
}
|
|
254
|
-
function patchApiReferenceGuard(targetDir) {
|
|
255
|
-
const filePath = join2(targetDir, "src", "data", "api-reference.ts");
|
|
256
|
-
if (!existsSync(filePath)) return;
|
|
257
|
-
let source = readFileSync2(filePath, "utf8");
|
|
258
|
-
source = source.replace(
|
|
259
|
-
/export async function buildApiNavigation\([^)]*\)[^{]*\{\n/,
|
|
260
|
-
(match) => `${match} if (apiReferenceConfig.specs.length === 0) return []
|
|
261
|
-
`
|
|
262
|
-
);
|
|
263
|
-
writeFileSync2(filePath, source, "utf8");
|
|
264
|
-
}
|
|
265
|
-
function patchTopBarNavigation(targetDir) {
|
|
266
|
-
const filePath = join2(targetDir, "src", "components", "layout", "top-bar.tsx");
|
|
267
|
-
if (!existsSync(filePath)) return;
|
|
268
|
-
const source = readFileSync2(filePath, "utf8");
|
|
269
|
-
if (!source.includes("target={isExternal ? '_blank' : undefined}")) return;
|
|
270
|
-
const patched = source.replace(
|
|
271
|
-
/if \(collection\.href\) \{\n const isExternal[^\n]+\n return \(\n <a[\s\S]*?<\/a>\n \)\n \}/,
|
|
272
|
-
`if (collection.href) {
|
|
273
|
-
const isExternal = /^https?:\\/\\//.test(collection.href)
|
|
274
|
-
if (isExternal) {
|
|
275
|
-
return (
|
|
276
|
-
<a
|
|
277
|
-
key={collection.id}
|
|
278
|
-
href={collection.href}
|
|
279
|
-
target="_blank"
|
|
280
|
-
rel="noreferrer"
|
|
281
|
-
className={baseClasses}
|
|
282
|
-
>
|
|
283
|
-
{collection.label}
|
|
284
|
-
</a>
|
|
285
|
-
)
|
|
286
|
-
}
|
|
287
|
-
return (
|
|
288
|
-
<Link
|
|
289
|
-
key={collection.id}
|
|
290
|
-
href={collection.href}
|
|
291
|
-
className={baseClasses}
|
|
292
|
-
>
|
|
293
|
-
{collection.label}
|
|
294
|
-
</Link>
|
|
295
|
-
)
|
|
296
|
-
}`
|
|
297
|
-
);
|
|
298
|
-
writeFileSync2(filePath, patched, "utf8");
|
|
299
|
-
}
|
|
300
|
-
function patchOpenApiFetch(targetDir) {
|
|
301
|
-
const filePath = join2(targetDir, "src", "lib", "openapi", "fetch.ts");
|
|
302
|
-
if (!existsSync(filePath)) return;
|
|
303
|
-
let source = readFileSync2(filePath, "utf8");
|
|
304
|
-
source = source.replace(
|
|
305
|
-
/const absolutePath = path\.isAbsolute\(filePath\) \? filePath : path\.resolve\(process\.cwd\(\), filePath\)/,
|
|
306
|
-
`const absolutePath = filePath.startsWith('/')
|
|
307
|
-
? path.resolve(process.cwd(), 'public', filePath.slice(1))
|
|
308
|
-
: path.resolve(process.cwd(), filePath)`
|
|
309
|
-
);
|
|
310
|
-
writeFileSync2(filePath, source, "utf8");
|
|
311
|
-
}
|
|
312
|
-
function updateEnvExample(targetDir) {
|
|
313
|
-
const envFile = join2(targetDir, ".env.example");
|
|
314
|
-
if (existsSync(envFile)) {
|
|
315
|
-
const envLocal = join2(targetDir, ".env.local");
|
|
316
|
-
if (!existsSync(envLocal)) {
|
|
317
|
-
cpSync(envFile, envLocal);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// src/utils.ts
|
|
323
|
-
import { execSync as execSync2 } from "child_process";
|
|
324
|
-
import { basename } from "path";
|
|
325
|
-
function slugify(name) {
|
|
326
|
-
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
|
327
|
-
}
|
|
328
|
-
function run(cmd, cwd) {
|
|
329
|
-
execSync2(cmd, { cwd, stdio: "inherit" });
|
|
330
|
-
}
|
|
331
|
-
function initGit(targetDir) {
|
|
332
|
-
try {
|
|
333
|
-
run("git init", targetDir);
|
|
334
|
-
run("git add -A", targetDir);
|
|
335
|
-
run('git commit -m "Initial commit from create-thally-docs"', targetDir);
|
|
336
|
-
} catch {
|
|
337
|
-
console.log(" \u26A0\uFE0F Could not initialize git (you can do this manually).");
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function installDeps(targetDir) {
|
|
341
|
-
console.log("");
|
|
342
|
-
console.log(" \u{1F4E6} Installing dependencies...");
|
|
343
|
-
console.log("");
|
|
344
|
-
run("npm install", targetDir);
|
|
345
|
-
}
|
|
346
|
-
function logo() {
|
|
347
|
-
console.log("");
|
|
348
|
-
console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
|
|
349
|
-
console.log(" \u2551 \u2551");
|
|
350
|
-
console.log(" \u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2551");
|
|
351
|
-
console.log(" \u2551 \u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D \u2551");
|
|
352
|
-
console.log(" \u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2551");
|
|
353
|
-
console.log(" \u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2554\u255D \u2551");
|
|
354
|
-
console.log(" \u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2551");
|
|
355
|
-
console.log(" \u2551 \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u2551");
|
|
356
|
-
console.log(" \u2551 \u2551");
|
|
357
|
-
console.log(" \u2551 Beautiful docs, zero lock-in. \u2551");
|
|
358
|
-
console.log(" \u2551 \u2551");
|
|
359
|
-
console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
|
|
360
|
-
console.log("");
|
|
361
|
-
}
|
|
362
|
-
function success(projectDir, projectName) {
|
|
363
|
-
console.log("");
|
|
364
|
-
console.log(" \u2705 Your Thally project is ready!");
|
|
365
|
-
console.log("");
|
|
366
|
-
console.log(` \u{1F4C2} ${projectDir}`);
|
|
367
|
-
console.log("");
|
|
368
|
-
console.log(" Next steps:");
|
|
369
|
-
console.log("");
|
|
370
|
-
console.log(` cd ${basename(projectDir)}`);
|
|
371
|
-
console.log(" npm run dev");
|
|
372
|
-
console.log("");
|
|
373
|
-
console.log(` Then open http://localhost:3040 to see your ${projectName} docs.`);
|
|
374
|
-
console.log("");
|
|
375
|
-
console.log(" \u{1F4DD} Key files to edit:");
|
|
376
|
-
console.log(" \u2022 src/data/site.ts \u2014 name, links, branding");
|
|
377
|
-
console.log(" \u2022 docs.json \u2014 navigation structure");
|
|
378
|
-
console.log(" \u2022 src/content/*.mdx \u2014 your documentation");
|
|
379
|
-
console.log(" \u2022 openapi.yaml \u2014 API spec (optional)");
|
|
380
|
-
console.log("");
|
|
381
|
-
console.log(" Happy documenting! \u{1F680}");
|
|
382
|
-
console.log("");
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// src/scaffold.ts
|
|
386
|
-
async function scaffold(options) {
|
|
387
|
-
const {
|
|
388
|
-
projectDir,
|
|
389
|
-
projectName,
|
|
390
|
-
description,
|
|
391
|
-
brandPreset,
|
|
392
|
-
repoUrl,
|
|
393
|
-
doInstall,
|
|
394
|
-
enableAiChat = true,
|
|
395
|
-
i18nLocales,
|
|
396
|
-
trackRepos
|
|
397
|
-
} = options;
|
|
398
|
-
const targetDir = resolve(projectDir);
|
|
399
|
-
if (existsSync2(targetDir) && readdirSync2(targetDir).length > 0) {
|
|
400
|
-
throw new Error(`Directory "${targetDir}" already exists and is not empty.`);
|
|
401
|
-
}
|
|
402
|
-
mkdirSync2(targetDir, { recursive: true });
|
|
403
|
-
const slug = slugify(projectName);
|
|
404
|
-
await downloadTemplate(targetDir, projectName);
|
|
405
|
-
resetTrackingConfig(targetDir);
|
|
406
|
-
if (trackRepos?.length) {
|
|
407
|
-
writeTrackingConfig(targetDir, trackRepos);
|
|
408
|
-
const list = trackRepos.map((r) => `${r.owner}/${r.repo}`).join(", ");
|
|
409
|
-
console.log(` \u2713 Thally Track enabled \u2014 watching ${list} (branch main, all files; refine in docs.json).`);
|
|
410
|
-
console.log(" To finish wiring it: `thally track setup` (pick a trigger) + `thally agent init`,");
|
|
411
|
-
console.log(" then add your ANTHROPIC_API_KEY. See /guides/thally-track.");
|
|
412
|
-
}
|
|
413
|
-
writeStarterContent(targetDir, projectName, slug, enableAiChat, repoUrl, i18nLocales);
|
|
414
|
-
updateSiteConfig(targetDir, projectName, description, brandPreset, repoUrl);
|
|
415
|
-
patchApiReferenceGuard(targetDir);
|
|
416
|
-
patchTopBarNavigation(targetDir);
|
|
417
|
-
patchOpenApiFetch(targetDir);
|
|
418
|
-
updateEnvExample(targetDir);
|
|
419
|
-
if (doInstall) {
|
|
420
|
-
installDeps(targetDir);
|
|
421
|
-
}
|
|
422
|
-
initGit(targetDir);
|
|
423
|
-
return { projectDir: targetDir };
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export {
|
|
427
|
-
slugify,
|
|
428
|
-
initGit,
|
|
429
|
-
installDeps,
|
|
430
|
-
logo,
|
|
431
|
-
success,
|
|
432
|
-
readDocsJson,
|
|
433
|
-
writeDocsJson,
|
|
434
|
-
scaffold
|
|
435
|
-
};
|