create-fumadocs-app 16.0.1 → 16.0.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/dist/{chunk-YVEWA65C.js → chunk-6C2B326N.js} +198 -196
- package/dist/create-app.d.ts +35 -8
- package/dist/create-app.js +3 -5
- package/dist/index.js +110 -32
- package/package.json +3 -2
- package/template/+next+fuma-docs-mdx/app/(home)/page.tsx +16 -0
- package/template/{+next+tailwindcss → +next+fuma-docs-mdx}/app/layout.tsx +1 -1
- package/template/{+next → +next+fuma-docs-mdx}/example.gitignore +0 -2
- package/template/+next+fuma-docs-mdx/lib/layout.shared.tsx +9 -0
- package/template/+next+fuma-docs-mdx/lib/source.ts +1 -1
- package/template/{+next → +next+fuma-docs-mdx}/mdx-components.tsx +0 -1
- package/template/+next+fuma-docs-mdx/package.json +29 -0
- package/template/+next+fuma-docs-mdx/source.config.ts +1 -0
- package/template/+next+fuma-docs-mdx/tsconfig.json +2 -2
- package/template/{+next → +orama-cloud/+next+fuma-docs-mdx}/app/layout.tsx +4 -9
- package/template/+orama-cloud/+next+fuma-docs-mdx/app/static.json/route.ts +7 -0
- package/template/+orama-cloud/@app/components/search.tsx +59 -0
- package/template/+orama-cloud/@app/lib/export-static-indexes.ts +14 -0
- package/template/+orama-cloud/@root/.env.example +6 -0
- package/template/+orama-cloud/react-router/app/root.tsx +76 -0
- package/template/+orama-cloud/react-router/app/routes/static.ts +5 -0
- package/template/+orama-cloud/react-router/app/routes.ts +8 -0
- package/template/+orama-cloud/react-router-spa/app/root.tsx +76 -0
- package/template/+orama-cloud/react-router-spa/app/routes/static.ts +5 -0
- package/template/+orama-cloud/react-router-spa/app/routes.ts +8 -0
- package/template/+orama-cloud/tanstack-start/src/routes/__root.tsx +51 -0
- package/template/+orama-cloud/tanstack-start/src/routes/static[.]json.ts +10 -0
- package/template/+orama-cloud/tanstack-start/vite.config.ts +27 -0
- package/template/+orama-cloud/waku/src/components/provider.tsx +8 -0
- package/template/+orama-cloud/waku/src/pages/api/static.json.ts +9 -0
- package/template/react-router/app/docs/page.tsx +4 -4
- package/template/react-router/example.gitignore +0 -1
- package/template/react-router-spa/README.md +12 -0
- package/template/react-router-spa/app/app.css +3 -0
- package/template/react-router-spa/app/components/search.tsx +50 -0
- package/template/react-router-spa/app/docs/page.tsx +53 -0
- package/template/react-router-spa/app/docs/search.ts +10 -0
- package/template/react-router-spa/app/lib/layout.shared.tsx +9 -0
- package/template/react-router-spa/app/lib/source.ts +7 -0
- package/template/react-router-spa/app/root.tsx +76 -0
- package/template/react-router-spa/app/routes/home.tsx +30 -0
- package/template/react-router-spa/app/routes.ts +7 -0
- package/template/react-router-spa/content/docs/index.mdx +32 -0
- package/template/react-router-spa/content/docs/test.mdx +24 -0
- package/template/react-router-spa/example.gitignore +7 -0
- package/template/react-router-spa/package.json +36 -0
- package/template/react-router-spa/public/favicon.ico +0 -0
- package/template/react-router-spa/react-router.config.ts +18 -0
- package/template/react-router-spa/serve.json +3 -0
- package/template/react-router-spa/source.config.ts +7 -0
- package/template/react-router-spa/tsconfig.json +28 -0
- package/template/react-router-spa/vite.config.ts +10 -0
- package/template/tanstack-start/example.gitignore +9 -1
- package/template/tanstack-start/package.json +6 -6
- package/template/waku/example.gitignore +3 -1
- package/template/waku/package.json +3 -3
- package/template/+next/README.md +0 -37
- package/template/+next/app/(home)/page.tsx +0 -42
- package/template/+next/lib/layout.shared.tsx +0 -30
- package/template/+next+content-collections/app/docs/[[...slug]]/page.tsx +0 -51
- package/template/+next+content-collections/content-collections.ts +0 -26
- package/template/+next+content-collections/lib/source.ts +0 -8
- package/template/+next+content-collections/next.config.mjs +0 -8
- package/template/+next+content-collections/tsconfig.json +0 -35
- package/template/+next+tailwindcss/app/(home)/page.tsx +0 -19
- package/template/{+next → +next+fuma-docs-mdx}/app/(home)/layout.tsx +0 -0
- package/template/{+next → +next+fuma-docs-mdx}/app/api/search/route.ts +0 -0
- package/template/{+next → +next+fuma-docs-mdx}/app/docs/layout.tsx +1 -1
- /package/template/{+next+tailwindcss → +next+fuma-docs-mdx}/app/global.css +0 -0
- /package/template/{+next → +next+fuma-docs-mdx}/content/docs/index.mdx +0 -0
- /package/template/{+next → +next+fuma-docs-mdx}/content/docs/test.mdx +0 -0
- /package/template/{+next+tailwindcss → +next+fuma-docs-mdx}/postcss.config.mjs +0 -0
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
// src/create-app.ts
|
|
2
|
-
import
|
|
2
|
+
import path2 from "path";
|
|
3
3
|
import fs2 from "fs/promises";
|
|
4
4
|
|
|
5
|
-
// src/
|
|
6
|
-
import
|
|
7
|
-
import { join } from "path";
|
|
5
|
+
// src/utils.ts
|
|
6
|
+
import fs from "fs/promises";
|
|
7
|
+
import path, { join } from "path";
|
|
8
8
|
import { x } from "tinyexec";
|
|
9
|
+
async function copy(from, to, options = {}) {
|
|
10
|
+
const {
|
|
11
|
+
rename = (s) => s,
|
|
12
|
+
filterDir = () => true,
|
|
13
|
+
filter = () => true
|
|
14
|
+
} = options;
|
|
15
|
+
const stats = await fs.stat(from);
|
|
16
|
+
if (stats.isDirectory() && filterDir(from)) {
|
|
17
|
+
const files = await fs.readdir(from);
|
|
18
|
+
await Promise.all(
|
|
19
|
+
files.map(
|
|
20
|
+
(file) => copy(path.join(from, file), path.join(to, file), options)
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (stats.isFile() && filter(from)) {
|
|
25
|
+
to = rename(to);
|
|
26
|
+
await fs.mkdir(path.dirname(to), { recursive: true });
|
|
27
|
+
await fs.copyFile(from, to);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
9
30
|
async function isInGitRepository(cwd2) {
|
|
10
31
|
const { exitCode } = await x("git", ["rev-parse", "--is-inside-work-tree"], {
|
|
11
32
|
nodeOptions: { cwd: cwd2 }
|
|
@@ -57,9 +78,51 @@ async function tryGitInit(cwd2) {
|
|
|
57
78
|
return false;
|
|
58
79
|
}
|
|
59
80
|
}
|
|
81
|
+
function pick(obj, keys) {
|
|
82
|
+
const result = {};
|
|
83
|
+
for (const key of keys) {
|
|
84
|
+
if (key in obj) {
|
|
85
|
+
result[key] = obj[key];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/auto-install.ts
|
|
92
|
+
import { x as x2 } from "tinyexec";
|
|
93
|
+
var managers = ["npm", "yarn", "bun", "pnpm"];
|
|
94
|
+
function getPackageManager() {
|
|
95
|
+
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
96
|
+
if (userAgent.startsWith("yarn")) {
|
|
97
|
+
return "yarn";
|
|
98
|
+
}
|
|
99
|
+
if (userAgent.startsWith("pnpm")) {
|
|
100
|
+
return "pnpm";
|
|
101
|
+
}
|
|
102
|
+
if (userAgent.startsWith("bun")) {
|
|
103
|
+
return "bun";
|
|
104
|
+
}
|
|
105
|
+
return "npm";
|
|
106
|
+
}
|
|
107
|
+
async function autoInstall(manager, dest) {
|
|
108
|
+
await x2(manager, ["install"], {
|
|
109
|
+
throwOnError: true,
|
|
110
|
+
nodeOptions: {
|
|
111
|
+
env: {
|
|
112
|
+
...process.env,
|
|
113
|
+
NODE_ENV: "development",
|
|
114
|
+
DISABLE_OPENCOLLECTIVE: "1"
|
|
115
|
+
},
|
|
116
|
+
cwd: dest
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/constants.ts
|
|
122
|
+
import { fileURLToPath } from "url";
|
|
60
123
|
|
|
61
124
|
// src/versions.js
|
|
62
|
-
var versions = { "fumadocs-core": "16.0.
|
|
125
|
+
var versions = { "fumadocs-core": "16.0.2", "fumadocs-ui": "16.0.2", "fumadocs-mdx": "13.0.0", "@fumadocs/mdx-remote": "1.4.3", "@fumadocs/content-collections": "1.2.4" };
|
|
63
126
|
|
|
64
127
|
// ../create-app-versions/package.json
|
|
65
128
|
var package_default = {
|
|
@@ -72,6 +135,7 @@ var package_default = {
|
|
|
72
135
|
"@content-collections/core": "^0.11.1",
|
|
73
136
|
"@content-collections/mdx": "^0.2.2",
|
|
74
137
|
"@content-collections/next": "^0.2.8",
|
|
138
|
+
"@orama/core": "^1.2.13",
|
|
75
139
|
"@react-router/dev": "^7.9.4",
|
|
76
140
|
"@react-router/node": "^7.9.4",
|
|
77
141
|
"@react-router/serve": "^7.9.4",
|
|
@@ -103,60 +167,58 @@ var package_default = {
|
|
|
103
167
|
}
|
|
104
168
|
};
|
|
105
169
|
|
|
106
|
-
// src/auto-install.ts
|
|
107
|
-
import { x as x2 } from "tinyexec";
|
|
108
|
-
var managers = ["npm", "yarn", "bun", "pnpm"];
|
|
109
|
-
function getPackageManager() {
|
|
110
|
-
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
111
|
-
if (userAgent.startsWith("yarn")) {
|
|
112
|
-
return "yarn";
|
|
113
|
-
}
|
|
114
|
-
if (userAgent.startsWith("pnpm")) {
|
|
115
|
-
return "pnpm";
|
|
116
|
-
}
|
|
117
|
-
if (userAgent.startsWith("bun")) {
|
|
118
|
-
return "bun";
|
|
119
|
-
}
|
|
120
|
-
return "npm";
|
|
121
|
-
}
|
|
122
|
-
async function autoInstall(manager, dest) {
|
|
123
|
-
await x2(manager, ["install"], {
|
|
124
|
-
throwOnError: true,
|
|
125
|
-
nodeOptions: {
|
|
126
|
-
env: {
|
|
127
|
-
...process.env,
|
|
128
|
-
NODE_ENV: "development",
|
|
129
|
-
DISABLE_OPENCOLLECTIVE: "1"
|
|
130
|
-
},
|
|
131
|
-
cwd: dest
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
170
|
// src/constants.ts
|
|
137
|
-
import { fileURLToPath } from "url";
|
|
138
171
|
var sourceDir = fileURLToPath(new URL(`../`, import.meta.url).href);
|
|
139
172
|
var cwd = process.cwd();
|
|
140
|
-
|
|
141
|
-
// src/create-app.ts
|
|
142
173
|
var templates = [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
174
|
+
{
|
|
175
|
+
value: "+next+fuma-docs-mdx",
|
|
176
|
+
label: "Next.js: Fumadocs MDX",
|
|
177
|
+
hint: "recommended",
|
|
178
|
+
componentsDir: "components"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
value: "waku",
|
|
182
|
+
label: "Waku: Fumadocs MDX",
|
|
183
|
+
componentsDir: "src/components"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
value: "react-router",
|
|
187
|
+
label: "React Router: Fumadocs MDX (not RSC)",
|
|
188
|
+
componentsDir: "app/components"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
value: "react-router-spa",
|
|
192
|
+
label: "React Router SPA: Fumadocs MDX (not RSC)",
|
|
193
|
+
hint: "SPA mode allows you to host the site statically, compatible with a CDN.",
|
|
194
|
+
componentsDir: "app/components"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
value: "tanstack-start",
|
|
198
|
+
label: "Tanstack Start: Fumadocs MDX (not RSC)",
|
|
199
|
+
componentsDir: "src/components"
|
|
200
|
+
}
|
|
148
201
|
];
|
|
202
|
+
var depVersions = {
|
|
203
|
+
...versions,
|
|
204
|
+
...package_default.dependencies
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/create-app.ts
|
|
149
208
|
function defaults(options) {
|
|
150
209
|
return {
|
|
151
210
|
...options,
|
|
152
|
-
|
|
153
|
-
|
|
211
|
+
plugins: options.plugins ?? [],
|
|
212
|
+
useSrcDir: options.template.startsWith("+next") && options.useSrcDir === true,
|
|
154
213
|
lint: options.lint ?? false,
|
|
155
214
|
initializeGit: options.initializeGit ?? false,
|
|
156
215
|
installDeps: options.installDeps ?? false,
|
|
157
216
|
log: console.log
|
|
158
217
|
};
|
|
159
218
|
}
|
|
219
|
+
function isRelative(dir, file) {
|
|
220
|
+
return !path2.relative(dir, file).startsWith(`..${path2.sep}`);
|
|
221
|
+
}
|
|
160
222
|
async function create(createOptions) {
|
|
161
223
|
const options = defaults(createOptions);
|
|
162
224
|
const {
|
|
@@ -168,72 +230,57 @@ async function create(createOptions) {
|
|
|
168
230
|
lint,
|
|
169
231
|
initializeGit,
|
|
170
232
|
packageManager,
|
|
171
|
-
|
|
233
|
+
plugins
|
|
172
234
|
} = options;
|
|
173
|
-
const projectName =
|
|
174
|
-
const dest =
|
|
235
|
+
const projectName = path2.basename(outputDir);
|
|
236
|
+
const dest = path2.resolve(cwd, outputDir);
|
|
175
237
|
const isNext = options.template.startsWith("+next");
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
238
|
+
const pluginContext = {
|
|
239
|
+
template: templates.find((item) => item.value === template),
|
|
240
|
+
dest,
|
|
241
|
+
options
|
|
242
|
+
};
|
|
243
|
+
await copy(path2.join(sourceDir, `template/${template}`), dest, {
|
|
244
|
+
rename(file) {
|
|
245
|
+
file = file.replace("example.gitignore", ".gitignore");
|
|
246
|
+
if (useSrcDir && (path2.basename(file) === "mdx-components.tsx" || isRelative(path2.join(dest, "app"), file) || isRelative(path2.join(dest, "lib"), file))) {
|
|
247
|
+
return path2.join(dest, "src", path2.relative(dest, file));
|
|
248
|
+
}
|
|
182
249
|
return file;
|
|
183
250
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
251
|
+
});
|
|
252
|
+
if (isNext && lint) {
|
|
253
|
+
await copy(path2.join(sourceDir, `template/+next+${lint}`), dest);
|
|
254
|
+
log("Configured Linter");
|
|
188
255
|
}
|
|
189
|
-
if (isNext) {
|
|
190
|
-
|
|
191
|
-
await
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
await copy(
|
|
198
|
-
path.join(sourceDir, `template/+next+tailwindcss`),
|
|
199
|
-
dest,
|
|
200
|
-
defaultRename
|
|
201
|
-
);
|
|
202
|
-
log("Configured Tailwind CSS");
|
|
203
|
-
}
|
|
204
|
-
if (lint) {
|
|
205
|
-
await copy(
|
|
206
|
-
path.join(sourceDir, `template/+next+${lint}`),
|
|
207
|
-
dest,
|
|
208
|
-
defaultRename
|
|
209
|
-
);
|
|
210
|
-
log("Configured Linter");
|
|
211
|
-
}
|
|
212
|
-
if (useSrcDir) {
|
|
213
|
-
const tsconfigPath = path.join(dest, "tsconfig.json");
|
|
214
|
-
const content = (await fs2.readFile(tsconfigPath)).toString();
|
|
215
|
-
const config = JSON.parse(content);
|
|
216
|
-
if (config.compilerOptions?.paths) {
|
|
217
|
-
Object.assign(config.compilerOptions.paths, {
|
|
218
|
-
"@/*": ["./src/*"]
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
await fs2.writeFile(tsconfigPath, JSON.stringify(config, null, 2));
|
|
256
|
+
if (isNext && useSrcDir) {
|
|
257
|
+
const tsconfigPath = path2.join(dest, "tsconfig.json");
|
|
258
|
+
const content = (await fs2.readFile(tsconfigPath)).toString();
|
|
259
|
+
const config = JSON.parse(content);
|
|
260
|
+
if (config.compilerOptions?.paths) {
|
|
261
|
+
Object.assign(config.compilerOptions.paths, {
|
|
262
|
+
"@/*": ["./src/*"]
|
|
263
|
+
});
|
|
222
264
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
);
|
|
265
|
+
await fs2.writeFile(tsconfigPath, JSON.stringify(config, null, 2));
|
|
266
|
+
}
|
|
267
|
+
let packageJson = await createPackageJson(projectName, dest, options);
|
|
268
|
+
for (const plugin of plugins) {
|
|
269
|
+
const result = await plugin.packageJson?.call(pluginContext, packageJson);
|
|
270
|
+
if (result) packageJson = result;
|
|
229
271
|
}
|
|
230
|
-
const packageJson = isNext ? await createNextPackageJson(projectName, options) : await createPackageJson(projectName, dest);
|
|
231
272
|
await fs2.writeFile(
|
|
232
|
-
|
|
273
|
+
path2.join(dest, "package.json"),
|
|
233
274
|
JSON.stringify(packageJson, null, 2)
|
|
234
275
|
);
|
|
235
|
-
|
|
236
|
-
|
|
276
|
+
let readme = await getReadme(dest, projectName);
|
|
277
|
+
for (const plugin of plugins) {
|
|
278
|
+
readme = await plugin.readme?.call(pluginContext, readme) ?? readme;
|
|
279
|
+
}
|
|
280
|
+
await fs2.writeFile(path2.join(dest, "README.md"), readme);
|
|
281
|
+
for (const plugin of plugins) {
|
|
282
|
+
await plugin.afterWrite?.call(pluginContext);
|
|
283
|
+
}
|
|
237
284
|
if (installDeps) {
|
|
238
285
|
try {
|
|
239
286
|
await autoInstall(packageManager, dest);
|
|
@@ -247,124 +294,79 @@ async function create(createOptions) {
|
|
|
247
294
|
}
|
|
248
295
|
}
|
|
249
296
|
async function getReadme(dest, projectName) {
|
|
250
|
-
const template = await fs2.readFile(
|
|
297
|
+
const template = await fs2.readFile(path2.join(dest, "README.md")).then((res) => res.toString());
|
|
251
298
|
return `# ${projectName}
|
|
252
299
|
|
|
253
300
|
${template}`;
|
|
254
301
|
}
|
|
255
|
-
async function
|
|
256
|
-
const
|
|
257
|
-
if (stats.isDirectory()) {
|
|
258
|
-
const files = await fs2.readdir(from);
|
|
259
|
-
await Promise.all(
|
|
260
|
-
files.map(
|
|
261
|
-
(file) => copy(path.join(from, file), rename(path.join(to, file)))
|
|
262
|
-
)
|
|
263
|
-
);
|
|
264
|
-
} else {
|
|
265
|
-
await fs2.mkdir(path.dirname(to), { recursive: true });
|
|
266
|
-
await fs2.copyFile(from, to);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
async function createNextPackageJson(projectName, { template, lint, tailwindcss }) {
|
|
270
|
-
return {
|
|
271
|
-
name: projectName,
|
|
272
|
-
version: "0.0.0",
|
|
273
|
-
private: true,
|
|
274
|
-
scripts: {
|
|
275
|
-
build: "next build",
|
|
276
|
-
dev: "next dev --turbo",
|
|
277
|
-
start: "next start",
|
|
278
|
-
...template === "+next+fuma-docs-mdx" && {
|
|
279
|
-
postinstall: "fumadocs-mdx"
|
|
280
|
-
},
|
|
281
|
-
...lint && {
|
|
282
|
-
eslint: {
|
|
283
|
-
lint: "eslint"
|
|
284
|
-
},
|
|
285
|
-
biome: { lint: "biome check", format: "biome format --write" }
|
|
286
|
-
}[lint]
|
|
287
|
-
},
|
|
288
|
-
dependencies: {
|
|
289
|
-
...pick(package_default.dependencies, [
|
|
290
|
-
"next",
|
|
291
|
-
"react",
|
|
292
|
-
"react-dom",
|
|
293
|
-
"lucide-react"
|
|
294
|
-
]),
|
|
295
|
-
...pick(versions, ["fumadocs-ui", "fumadocs-core"]),
|
|
296
|
-
...{
|
|
297
|
-
"+next+content-collections": {
|
|
298
|
-
...pick(package_default.dependencies, [
|
|
299
|
-
"@content-collections/mdx",
|
|
300
|
-
"@content-collections/core",
|
|
301
|
-
"@content-collections/next"
|
|
302
|
-
]),
|
|
303
|
-
...pick(versions, ["@fumadocs/content-collections"])
|
|
304
|
-
},
|
|
305
|
-
"+next+fuma-docs-mdx": pick(versions, ["fumadocs-mdx"]),
|
|
306
|
-
waku: null,
|
|
307
|
-
"tanstack-start": null,
|
|
308
|
-
"react-router": null
|
|
309
|
-
}[template]
|
|
310
|
-
},
|
|
311
|
-
devDependencies: {
|
|
312
|
-
...pick(package_default.dependencies, [
|
|
313
|
-
"@types/node",
|
|
314
|
-
"@types/react",
|
|
315
|
-
"@types/react-dom",
|
|
316
|
-
"typescript",
|
|
317
|
-
"@types/mdx"
|
|
318
|
-
]),
|
|
319
|
-
...tailwindcss && pick(package_default.dependencies, [
|
|
320
|
-
"@tailwindcss/postcss",
|
|
321
|
-
"tailwindcss",
|
|
322
|
-
"postcss"
|
|
323
|
-
]),
|
|
324
|
-
...lint && {
|
|
325
|
-
eslint: {
|
|
326
|
-
eslint: "^9",
|
|
327
|
-
"eslint-config-next": package_default.dependencies.next,
|
|
328
|
-
"@eslint/eslintrc": "^3"
|
|
329
|
-
},
|
|
330
|
-
biome: pick(package_default.dependencies, ["@biomejs/biome"])
|
|
331
|
-
}[lint]
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
async function createPackageJson(projectName, dir) {
|
|
302
|
+
async function createPackageJson(projectName, dir, { template, lint }) {
|
|
303
|
+
const isNext = template.startsWith("+next");
|
|
336
304
|
function replaceWorkspaceDeps(deps) {
|
|
337
305
|
for (const k in deps) {
|
|
338
|
-
if (deps[k].startsWith("workspace:") && k in
|
|
339
|
-
deps[k] =
|
|
306
|
+
if (deps[k].startsWith("workspace:") && k in depVersions) {
|
|
307
|
+
deps[k] = depVersions[k];
|
|
340
308
|
}
|
|
341
309
|
}
|
|
342
310
|
return deps;
|
|
343
311
|
}
|
|
344
|
-
|
|
345
|
-
await fs2.readFile(
|
|
312
|
+
let packageJson = JSON.parse(
|
|
313
|
+
await fs2.readFile(path2.join(dir, "package.json")).then((res) => res.toString())
|
|
346
314
|
);
|
|
347
|
-
|
|
315
|
+
packageJson = {
|
|
348
316
|
name: projectName,
|
|
349
317
|
...packageJson,
|
|
350
318
|
dependencies: replaceWorkspaceDeps(packageJson.dependencies),
|
|
351
319
|
devDependencies: replaceWorkspaceDeps(packageJson.devDependencies)
|
|
352
320
|
};
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
321
|
+
if (isNext) {
|
|
322
|
+
packageJson = {
|
|
323
|
+
...packageJson,
|
|
324
|
+
scripts: {
|
|
325
|
+
...packageJson.scripts,
|
|
326
|
+
postinstall: "fumadocs-mdx"
|
|
327
|
+
}
|
|
328
|
+
};
|
|
360
329
|
}
|
|
361
|
-
|
|
330
|
+
if (isNext && lint === "biome") {
|
|
331
|
+
packageJson = {
|
|
332
|
+
...packageJson,
|
|
333
|
+
scripts: {
|
|
334
|
+
...packageJson.scripts,
|
|
335
|
+
lint: "biome check",
|
|
336
|
+
format: "biome format --write"
|
|
337
|
+
},
|
|
338
|
+
devDependencies: {
|
|
339
|
+
...packageJson.devDependencies,
|
|
340
|
+
...pick(depVersions, ["@biomejs/biome"])
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (isNext && lint === "eslint") {
|
|
345
|
+
packageJson = {
|
|
346
|
+
...packageJson,
|
|
347
|
+
scripts: {
|
|
348
|
+
...packageJson.scripts,
|
|
349
|
+
lint: "eslint"
|
|
350
|
+
},
|
|
351
|
+
devDependencies: {
|
|
352
|
+
...packageJson.devDependencies,
|
|
353
|
+
eslint: "^9",
|
|
354
|
+
"eslint-config-next": depVersions.next,
|
|
355
|
+
"@eslint/eslintrc": "^3"
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
return packageJson;
|
|
362
360
|
}
|
|
363
361
|
|
|
364
362
|
export {
|
|
363
|
+
copy,
|
|
364
|
+
pick,
|
|
365
365
|
managers,
|
|
366
366
|
getPackageManager,
|
|
367
|
+
sourceDir,
|
|
367
368
|
cwd,
|
|
368
369
|
templates,
|
|
370
|
+
depVersions,
|
|
369
371
|
create
|
|
370
372
|
};
|
package/dist/create-app.d.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
type PackageManager = (typeof managers)[number];
|
|
2
2
|
declare const managers: readonly ["npm", "yarn", "bun", "pnpm"];
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
interface TemplateInfo {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
hint?: string;
|
|
8
|
+
componentsDir: string;
|
|
9
|
+
}
|
|
10
|
+
declare const templates: ({
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
hint: string;
|
|
14
|
+
componentsDir: string;
|
|
15
|
+
} | {
|
|
16
|
+
value: string;
|
|
17
|
+
label: string;
|
|
18
|
+
componentsDir: string;
|
|
19
|
+
hint?: undefined;
|
|
20
|
+
})[];
|
|
21
|
+
|
|
22
|
+
type Template = (typeof templates)[number]['value'];
|
|
6
23
|
interface Options {
|
|
7
24
|
outputDir: string;
|
|
8
25
|
template: Template;
|
|
@@ -15,11 +32,6 @@ interface Options {
|
|
|
15
32
|
* @defaultValue false
|
|
16
33
|
*/
|
|
17
34
|
useSrcDir?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* (Next.js only) Configure Tailwind CSS
|
|
20
|
-
* @defaultValue true
|
|
21
|
-
*/
|
|
22
|
-
tailwindcss?: boolean;
|
|
23
35
|
/**
|
|
24
36
|
* (Next.js Only) Configure Lint
|
|
25
37
|
* @defaultValue false
|
|
@@ -28,7 +40,22 @@ interface Options {
|
|
|
28
40
|
installDeps?: boolean;
|
|
29
41
|
initializeGit?: boolean;
|
|
30
42
|
log?: (message: string) => void;
|
|
43
|
+
plugins?: TemplatePlugin[];
|
|
44
|
+
}
|
|
45
|
+
interface TemplatePluginContext {
|
|
46
|
+
template: TemplateInfo;
|
|
47
|
+
options: Required<Options>;
|
|
48
|
+
/**
|
|
49
|
+
* output directory
|
|
50
|
+
*/
|
|
51
|
+
dest: string;
|
|
52
|
+
}
|
|
53
|
+
type Awaitable<T> = T | Promise<T>;
|
|
54
|
+
interface TemplatePlugin {
|
|
55
|
+
packageJson?: (this: TemplatePluginContext, packageJson: any) => Awaitable<void | any>;
|
|
56
|
+
afterWrite?: (this: TemplatePluginContext) => Awaitable<void>;
|
|
57
|
+
readme?: (this: TemplatePluginContext, content: string) => Awaitable<void | string>;
|
|
31
58
|
}
|
|
32
59
|
declare function create(createOptions: Options): Promise<void>;
|
|
33
60
|
|
|
34
|
-
export { type Options, type Template,
|
|
61
|
+
export { type Options, type Template, type TemplatePlugin, type TemplatePluginContext, create };
|