create-fumadocs-app 15.6.3 → 15.6.4

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.
@@ -1,380 +0,0 @@
1
- // src/create-app.ts
2
- import path from "path";
3
- import fs from "fs/promises";
4
-
5
- // src/git.ts
6
- import { execSync } from "child_process";
7
- import { rmSync } from "fs";
8
- import { join } from "path";
9
- function isInGitRepository(cwd2) {
10
- try {
11
- execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore", cwd: cwd2 });
12
- return true;
13
- } catch {
14
- return false;
15
- }
16
- }
17
- function isInMercurialRepository(cwd2) {
18
- try {
19
- execSync("hg --cwd . root", { stdio: "ignore", cwd: cwd2 });
20
- return true;
21
- } catch {
22
- return false;
23
- }
24
- }
25
- function isDefaultBranchSet(cwd2) {
26
- try {
27
- execSync("git config init.defaultBranch", { stdio: "ignore", cwd: cwd2 });
28
- return true;
29
- } catch {
30
- return false;
31
- }
32
- }
33
- function tryGitInit(root) {
34
- let didInit = false;
35
- try {
36
- execSync("git --version", { stdio: "ignore" });
37
- if (isInGitRepository(root) || isInMercurialRepository(root)) {
38
- return false;
39
- }
40
- execSync("git init", { stdio: "ignore", cwd: root });
41
- didInit = true;
42
- if (!isDefaultBranchSet(root)) {
43
- execSync("git checkout -b main", { stdio: "ignore", cwd: root });
44
- }
45
- execSync("git add -A", { stdio: "ignore", cwd: root });
46
- execSync('git commit -m "Initial commit from Create Fumadocs App"', {
47
- stdio: "ignore",
48
- cwd: root
49
- });
50
- return true;
51
- } catch {
52
- if (didInit) {
53
- try {
54
- rmSync(join(root, ".git"), { recursive: true, force: true });
55
- } catch {
56
- }
57
- }
58
- return false;
59
- }
60
- }
61
-
62
- // src/versions.js
63
- var versions = { "fumadocs-core": "15.6.3", "fumadocs-ui": "15.6.3", "fumadocs-mdx": "11.6.10", "@fumadocs/mdx-remote": "1.3.4", "@fumadocs/content-collections": "1.2.1" };
64
-
65
- // ../create-app-versions/package.json
66
- var package_default = {
67
- name: "example-versions",
68
- version: "0.0.0",
69
- private: true,
70
- description: "Used to track dependency versions in create-fumadocs-app",
71
- license: "MIT",
72
- dependencies: {
73
- "@content-collections/core": "^0.9.1",
74
- "@content-collections/mdx": "^0.2.2",
75
- "@content-collections/next": "^0.2.6",
76
- "@react-router/dev": "^7.6.3",
77
- "@react-router/node": "^7.6.3",
78
- "@react-router/serve": "^7.6.3",
79
- "@tailwindcss/postcss": "^4.1.11",
80
- "@tailwindcss/vite": "^4.1.11",
81
- "@tanstack/react-router": "^1.123.0",
82
- "@tanstack/react-start": "^1.123.0",
83
- "@types/mdx": "^2.0.13",
84
- "@types/node": "24.0.7",
85
- "@types/react": "^19.1.8",
86
- "@types/react-dom": "^19.1.6",
87
- "@vitejs/plugin-react": "^4.6.0",
88
- "gray-matter": "^4.0.3",
89
- isbot: "^5.1.28",
90
- next: "15.3.4",
91
- postcss: "^8.5.6",
92
- react: "^19.1.0",
93
- "react-dom": "^19.1.0",
94
- "react-router": "^7.6.3",
95
- "react-router-devtools": "^5.0.6",
96
- shiki: "^3.7.0",
97
- tailwindcss: "^4.1.11",
98
- tinyglobby: "^0.2.14",
99
- typescript: "^5.8.3",
100
- vinxi: "^0.5.8",
101
- vite: "^7.0.0",
102
- "vite-tsconfig-paths": "^5.1.4"
103
- }
104
- };
105
-
106
- // src/auto-install.ts
107
- import { spawn } from "cross-spawn";
108
- function getPackageManager() {
109
- const userAgent = process.env.npm_config_user_agent ?? "";
110
- if (userAgent.startsWith("yarn")) {
111
- return "yarn";
112
- }
113
- if (userAgent.startsWith("pnpm")) {
114
- return "pnpm";
115
- }
116
- if (userAgent.startsWith("bun")) {
117
- return "bun";
118
- }
119
- return "npm";
120
- }
121
- function autoInstall(manager, dest) {
122
- return new Promise((res, reject) => {
123
- const installProcess = spawn(manager, ["install"], {
124
- stdio: "ignore",
125
- env: {
126
- ...process.env,
127
- NODE_ENV: "development",
128
- DISABLE_OPENCOLLECTIVE: "1"
129
- },
130
- cwd: dest
131
- });
132
- installProcess.on("close", (code) => {
133
- if (code !== 0) {
134
- reject(new Error("Install failed"));
135
- } else {
136
- res();
137
- }
138
- });
139
- });
140
- }
141
-
142
- // src/constants.ts
143
- import { fileURLToPath } from "url";
144
- var sourceDir = fileURLToPath(new URL(`../`, import.meta.url).href);
145
- var cwd = process.cwd();
146
-
147
- // src/create-app.ts
148
- async function create(options) {
149
- const {
150
- installDeps = true,
151
- initializeGit = true,
152
- log = console.log
153
- } = options;
154
- const projectName = path.basename(options.outputDir);
155
- const dest = path.resolve(cwd, options.outputDir);
156
- const isNext = options.template.startsWith("+next");
157
- function isRelative(dir, file) {
158
- return !path.relative(path.join(dest, dir), file).startsWith(`..${path.sep}`);
159
- }
160
- function defaultRename(file) {
161
- file = file.replace("example.gitignore", ".gitignore");
162
- if (!options.useSrcDir || !isNext) {
163
- return file;
164
- }
165
- if (path.basename(file) === "mdx-components.tsx" || isRelative("app", file) || isRelative("lib", file)) {
166
- return path.join(dest, "src", path.relative(dest, file));
167
- }
168
- return file;
169
- }
170
- if (isNext) {
171
- await copy(path.join(sourceDir, `template/+next`), dest, defaultRename);
172
- }
173
- await copy(
174
- path.join(sourceDir, `template/${options.template}`),
175
- dest,
176
- defaultRename
177
- );
178
- if (isNext && options.tailwindcss) {
179
- await copy(
180
- path.join(sourceDir, `template/+next+tailwindcss`),
181
- dest,
182
- defaultRename
183
- );
184
- log("Configured Tailwind CSS");
185
- }
186
- if (isNext && options.eslint) {
187
- await copy(
188
- path.join(sourceDir, `template/+next+eslint`),
189
- dest,
190
- defaultRename
191
- );
192
- log("Configured ESLint");
193
- }
194
- if (isNext && options.useSrcDir) {
195
- const tsconfigPath = path.join(dest, "tsconfig.json");
196
- const content = (await fs.readFile(tsconfigPath)).toString();
197
- const config = JSON.parse(content);
198
- if (config.compilerOptions?.paths) {
199
- Object.assign(config.compilerOptions.paths, {
200
- "@/*": ["./src/*"]
201
- });
202
- }
203
- await fs.writeFile(tsconfigPath, JSON.stringify(config, null, 2));
204
- }
205
- const packageJson = createPackageJson(projectName, options);
206
- await fs.writeFile(
207
- path.join(dest, "package.json"),
208
- JSON.stringify(packageJson, null, 2)
209
- );
210
- const readMe = await getReadme(dest, projectName);
211
- await fs.writeFile(path.join(dest, "README.md"), readMe);
212
- if (installDeps) {
213
- await autoInstall(options.packageManager, dest);
214
- log("Installed dependencies");
215
- }
216
- if (initializeGit && tryGitInit(dest)) {
217
- log("Initialized Git repository");
218
- }
219
- }
220
- async function getReadme(dest, projectName) {
221
- const template = await fs.readFile(path.join(dest, "README.md")).then((res) => res.toString());
222
- return `# ${projectName}
223
-
224
- ${template}`;
225
- }
226
- async function copy(from, to, rename = (s) => s) {
227
- const stats = await fs.stat(from);
228
- if (stats.isDirectory()) {
229
- const files = await fs.readdir(from);
230
- await Promise.all(
231
- files.map(
232
- (file) => copy(path.join(from, file), rename(path.join(to, file)))
233
- )
234
- );
235
- } else {
236
- await fs.mkdir(path.dirname(to), { recursive: true });
237
- await fs.copyFile(from, to);
238
- }
239
- }
240
- function createPackageJson(projectName, options) {
241
- if (options.template === "react-router") {
242
- return {
243
- name: projectName,
244
- private: true,
245
- type: "module",
246
- scripts: {
247
- build: "react-router build",
248
- dev: "react-router dev",
249
- start: "react-router-serve ./build/server/index.js",
250
- typecheck: "react-router typegen && tsc"
251
- },
252
- dependencies: {
253
- ...pick(versions, [
254
- "@fumadocs/mdx-remote",
255
- "fumadocs-core",
256
- "fumadocs-ui"
257
- ]),
258
- ...pick(package_default.dependencies, [
259
- "@react-router/node",
260
- "@react-router/serve",
261
- "gray-matter",
262
- "isbot",
263
- "react",
264
- "react-dom",
265
- "react-router",
266
- "shiki"
267
- ])
268
- },
269
- devDependencies: pick(package_default.dependencies, [
270
- "@react-router/dev",
271
- "@tailwindcss/vite",
272
- "@types/node",
273
- "@types/react",
274
- "@types/react-dom",
275
- "react-router-devtools",
276
- "tailwindcss",
277
- "typescript",
278
- "vite",
279
- "vite-tsconfig-paths"
280
- ])
281
- };
282
- }
283
- if (options.template === "tanstack-start") {
284
- return {
285
- name: projectName,
286
- type: "module",
287
- scripts: {
288
- dev: "vinxi dev",
289
- build: "NODE_ENV=production vinxi build",
290
- start: "vinxi start"
291
- },
292
- private: true,
293
- dependencies: {
294
- ...pick(versions, [
295
- "@fumadocs/mdx-remote",
296
- "fumadocs-ui",
297
- "fumadocs-core"
298
- ]),
299
- ...pick(package_default.dependencies, [
300
- "@tanstack/react-router",
301
- "@tanstack/react-start",
302
- "tinyglobby",
303
- "gray-matter",
304
- "react",
305
- "react-dom",
306
- "vinxi"
307
- ])
308
- },
309
- devDependencies: pick(package_default.dependencies, [
310
- "@tailwindcss/vite",
311
- "@types/react",
312
- "@types/react-dom",
313
- "@vitejs/plugin-react",
314
- "tailwindcss",
315
- "typescript",
316
- "vite",
317
- "vite-tsconfig-paths"
318
- ])
319
- };
320
- }
321
- return {
322
- name: projectName,
323
- version: "0.0.0",
324
- private: true,
325
- scripts: {
326
- build: "next build",
327
- dev: "next dev --turbo",
328
- start: "next start",
329
- ...options.template === "+next+fuma-docs-mdx" ? {
330
- postinstall: "fumadocs-mdx"
331
- } : null
332
- },
333
- dependencies: {
334
- ...pick(package_default.dependencies, ["next", "react", "react-dom"]),
335
- ...pick(versions, ["fumadocs-ui", "fumadocs-core"]),
336
- ...options.template === "+next+content-collections" ? {
337
- ...pick(package_default.dependencies, [
338
- "@content-collections/mdx",
339
- "@content-collections/core",
340
- "@content-collections/next"
341
- ]),
342
- ...pick(versions, ["@fumadocs/content-collections"])
343
- } : null,
344
- ...options.template === "+next+fuma-docs-mdx" ? pick(versions, ["fumadocs-mdx"]) : null
345
- },
346
- devDependencies: {
347
- ...pick(package_default.dependencies, [
348
- "@types/node",
349
- "@types/react",
350
- "@types/react-dom",
351
- "typescript",
352
- "@types/mdx"
353
- ]),
354
- ...options.tailwindcss ? pick(package_default.dependencies, [
355
- "@tailwindcss/postcss",
356
- "tailwindcss",
357
- "postcss"
358
- ]) : null,
359
- ...options.eslint ? {
360
- eslint: "^8",
361
- "eslint-config-next": package_default.dependencies.next
362
- } : null
363
- }
364
- };
365
- }
366
- function pick(obj, keys) {
367
- const result = {};
368
- for (const key of keys) {
369
- if (key in obj) {
370
- result[key] = obj[key];
371
- }
372
- }
373
- return result;
374
- }
375
-
376
- export {
377
- getPackageManager,
378
- cwd,
379
- create
380
- };
@@ -1,6 +0,0 @@
1
- import {
2
- createStartAPIHandler,
3
- defaultAPIFileRouteHandler,
4
- } from '@tanstack/react-start/api';
5
-
6
- export default createStartAPIHandler(defaultAPIFileRouteHandler);
@@ -1,7 +0,0 @@
1
- import { hydrateRoot } from 'react-dom/client';
2
- import { StartClient } from '@tanstack/react-start';
3
- import { createRouter } from './router';
4
-
5
- const router = createRouter();
6
-
7
- hydrateRoot(document, <StartClient router={router} />);
@@ -1,13 +0,0 @@
1
- // app/ssr.tsx
2
- import {
3
- createStartHandler,
4
- defaultStreamHandler,
5
- } from '@tanstack/react-start/server';
6
- import { getRouterManifest } from '@tanstack/react-start/router-manifest';
7
-
8
- import { createRouter } from './router';
9
-
10
- export default createStartHandler({
11
- createRouter,
12
- getRouterManifest,
13
- })(defaultStreamHandler);
@@ -1,43 +0,0 @@
1
- import { defineConfig } from '@tanstack/react-start/config';
2
- import tsConfigPaths from 'vite-tsconfig-paths';
3
- import tailwindcss from '@tailwindcss/vite';
4
-
5
- export default defineConfig({
6
- server: {
7
- hooks: {
8
- 'prerender:routes': async (routes) => {
9
- const { source } = await import('./lib/source');
10
- const pages = source.getPages();
11
-
12
- for (const page of pages) {
13
- routes.add(page.url);
14
- }
15
- },
16
- },
17
- prerender: {
18
- routes: ['/'],
19
- crawlLinks: true,
20
- },
21
- },
22
- vite: {
23
- build: {
24
- rollupOptions: {
25
- // Shiki results in a huge bundle because Rollup tries to bundle every language/theme
26
- external: ['shiki'],
27
- // most React.js libraries now include 'use client'
28
- onwarn(warning, warn) {
29
- if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
30
- return;
31
- }
32
- warn(warning);
33
- },
34
- },
35
- },
36
- plugins: [
37
- tsConfigPaths({
38
- projects: ['./tsconfig.json'],
39
- }),
40
- tailwindcss(),
41
- ],
42
- },
43
- });