create-fumadocs-app 16.0.2 → 16.0.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.
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +215 -0
- package/dist/chunk-BEZTHMLF.js +51 -0
- package/dist/chunk-JCFTHRDR.js +50 -0
- package/dist/chunk-UXPTMGXV.js +130 -0
- package/dist/chunk-ZWEHS3HT.js +191 -0
- package/dist/index.d.ts +63 -1
- package/dist/index.js +5 -283
- package/dist/plugins/biome.base.d.ts +45 -0
- package/dist/plugins/biome.base.js +18 -0
- package/dist/plugins/biome.d.ts +5 -0
- package/dist/plugins/biome.js +43 -0
- package/dist/plugins/biome.next.d.ts +49 -0
- package/dist/plugins/biome.next.js +18 -0
- package/dist/plugins/eslint.d.ts +5 -0
- package/dist/plugins/eslint.js +61 -0
- package/dist/plugins/next-use-src.d.ts +8 -0
- package/dist/plugins/next-use-src.js +39 -0
- package/dist/plugins/orama-cloud.d.ts +5 -0
- package/dist/plugins/orama-cloud.js +359 -0
- package/package.json +19 -8
- package/template/react-router/react-router.config.ts +3 -3
- package/template/react-router-spa/react-router.config.ts +7 -2
- package/dist/chunk-6C2B326N.js +0 -372
- package/dist/create-app.d.ts +0 -61
- package/dist/create-app.js +0 -6
- package/template/+next+biome/biome.json +0 -34
- package/template/+next+eslint/eslint.config.mjs +0 -26
- package/template/+orama-cloud/+next+fuma-docs-mdx/app/layout.tsx +0 -18
- package/template/+orama-cloud/+next+fuma-docs-mdx/app/static.json/route.ts +0 -7
- package/template/+orama-cloud/react-router/app/root.tsx +0 -76
- package/template/+orama-cloud/react-router/app/routes/static.ts +0 -5
- package/template/+orama-cloud/react-router/app/routes.ts +0 -8
- package/template/+orama-cloud/react-router-spa/app/root.tsx +0 -76
- package/template/+orama-cloud/react-router-spa/app/routes/static.ts +0 -5
- package/template/+orama-cloud/react-router-spa/app/routes.ts +0 -8
- package/template/+orama-cloud/tanstack-start/src/routes/__root.tsx +0 -51
- package/template/+orama-cloud/tanstack-start/src/routes/static[.]json.ts +0 -10
- package/template/+orama-cloud/tanstack-start/vite.config.ts +0 -27
- package/template/+orama-cloud/waku/src/components/provider.tsx +0 -8
- package/template/+orama-cloud/waku/src/pages/api/static.json.ts +0 -9
package/dist/index.js
CHANGED
|
@@ -1,285 +1,7 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
managers,
|
|
9
|
-
pick,
|
|
10
|
-
sourceDir,
|
|
11
|
-
templates
|
|
12
|
-
} from "./chunk-6C2B326N.js";
|
|
13
|
-
|
|
14
|
-
// src/index.ts
|
|
15
|
-
import fs2 from "fs/promises";
|
|
16
|
-
import path2 from "path";
|
|
17
|
-
import {
|
|
18
|
-
cancel,
|
|
19
|
-
confirm,
|
|
20
|
-
group,
|
|
21
|
-
intro,
|
|
22
|
-
isCancel,
|
|
23
|
-
outro,
|
|
24
|
-
select,
|
|
25
|
-
spinner,
|
|
26
|
-
text
|
|
27
|
-
} from "@clack/prompts";
|
|
28
|
-
import pc from "picocolors";
|
|
29
|
-
import { program } from "commander";
|
|
30
|
-
|
|
31
|
-
// src/plugins/orama-cloud.ts
|
|
32
|
-
import path from "path";
|
|
33
|
-
import fs from "fs/promises";
|
|
34
|
-
var oramaCloud = {
|
|
35
|
-
packageJson(packageJson) {
|
|
36
|
-
return {
|
|
37
|
-
...packageJson,
|
|
38
|
-
scripts: {
|
|
39
|
-
...packageJson.scripts,
|
|
40
|
-
build: `${packageJson.build} && bun scripts/sync-content.ts`
|
|
41
|
-
},
|
|
42
|
-
dependencies: {
|
|
43
|
-
...packageJson.dependencies,
|
|
44
|
-
...pick(depVersions, ["@orama/core"])
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
readme(content) {
|
|
49
|
-
return `${content}
|
|
50
|
-
|
|
51
|
-
## Orama Cloud
|
|
52
|
-
|
|
53
|
-
This project uses Orama Cloud for 3rd party search solution.
|
|
54
|
-
|
|
55
|
-
See https://fumadocs.dev/docs/headless/search/orama-cloud for integrating Orama Cloud to Fumadocs.`;
|
|
56
|
-
},
|
|
57
|
-
async afterWrite() {
|
|
58
|
-
const { dest, template, options } = this;
|
|
59
|
-
const appDir = path.join(dest, options.useSrcDir ? "src" : ".");
|
|
60
|
-
await copy(path.join(sourceDir, "template/+orama-cloud/@root"), dest);
|
|
61
|
-
await copy(path.join(sourceDir, "template/+orama-cloud/@app"), appDir);
|
|
62
|
-
const filePath = {
|
|
63
|
-
"+next+fuma-docs-mdx": ".next/server/app/static.json.body",
|
|
64
|
-
"tanstack-start": ".output/public/static.json",
|
|
65
|
-
"react-router": "build/client/static.json",
|
|
66
|
-
"react-router-spa": "build/client/static.json",
|
|
67
|
-
waku: "dist/public/static.json"
|
|
68
|
-
}[template.value];
|
|
69
|
-
const SyncContentScript = `import { type OramaDocument, sync } from 'fumadocs-core/search/orama-cloud';
|
|
70
|
-
import * as fs from 'node:fs/promises';
|
|
71
|
-
import { OramaCloud } from '@orama/core';
|
|
72
|
-
|
|
73
|
-
// the path of pre-rendered \`static.json\`
|
|
74
|
-
const filePath = ${JSON.stringify(filePath)};
|
|
75
|
-
|
|
76
|
-
async function main() {
|
|
77
|
-
const orama = new OramaCloud({
|
|
78
|
-
projectId: process.env.NEXT_PUBLIC_ORAMA_PROJECT_ID,
|
|
79
|
-
apiKey: process.env.ORAMA_PRIVATE_API_KEY,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const content = await fs.readFile(filePath);
|
|
83
|
-
const records = JSON.parse(content.toString()) as OramaDocument[];
|
|
84
|
-
|
|
85
|
-
await sync(orama, {
|
|
86
|
-
index: process.env.NEXT_PUBLIC_ORAMA_DATASOURCE_ID,
|
|
87
|
-
documents: records,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
console.log(\`search updated: \${records.length} records\`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
void main();
|
|
94
|
-
`;
|
|
95
|
-
await fs.mkdir(path.join(dest, "scripts"), { recursive: true });
|
|
96
|
-
await fs.writeFile(
|
|
97
|
-
path.join(dest, "scripts/sync-content.ts"),
|
|
98
|
-
SyncContentScript
|
|
99
|
-
);
|
|
100
|
-
await copy(
|
|
101
|
-
path.join(sourceDir, `template/+orama-cloud/${template.value}`),
|
|
102
|
-
appDir
|
|
103
|
-
);
|
|
104
|
-
}
|
|
2
|
+
create
|
|
3
|
+
} from "./chunk-UXPTMGXV.js";
|
|
4
|
+
import "./chunk-ZWEHS3HT.js";
|
|
5
|
+
export {
|
|
6
|
+
create
|
|
105
7
|
};
|
|
106
|
-
var orama_cloud_default = oramaCloud;
|
|
107
|
-
|
|
108
|
-
// src/index.ts
|
|
109
|
-
program.argument("[name]", "the project name");
|
|
110
|
-
program.option("--src", "(Next.js only) enable `src/` directory");
|
|
111
|
-
program.option("--no-src", "(Next.js only) disable `src/` directory");
|
|
112
|
-
program.option("--eslint", "(Next.js only) enable ESLint configuration");
|
|
113
|
-
program.option("--no-eslint", "(Next.js only) disable ESLint configuration");
|
|
114
|
-
program.option("--biome", "(Next.js only) enable Biome configuration");
|
|
115
|
-
program.option("--no-biome", "(Next.js only) disable Biome configuration");
|
|
116
|
-
program.option("--install", "Enable installing packages automatically");
|
|
117
|
-
program.option("--no-install", "Disable installing packages automatically");
|
|
118
|
-
program.option("--no-git", "Disable auto Git repository initialization");
|
|
119
|
-
program.option(
|
|
120
|
-
"--template <name>",
|
|
121
|
-
`template to choose: ${templates.map((v) => v.value).join(", ")}`,
|
|
122
|
-
(value) => {
|
|
123
|
-
if (!templates.some((item) => item.value === value)) {
|
|
124
|
-
throw new Error(`Invalid template: ${value}.`);
|
|
125
|
-
}
|
|
126
|
-
return value;
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
program.option(
|
|
130
|
-
"--pm <name>",
|
|
131
|
-
`package manager to choose: ${managers.join(", ")}`,
|
|
132
|
-
(value) => {
|
|
133
|
-
if (!managers.includes(value)) {
|
|
134
|
-
throw new Error(`Invalid package manager: ${value}.`);
|
|
135
|
-
}
|
|
136
|
-
return value;
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
async function main(config) {
|
|
140
|
-
intro(pc.bgCyan(pc.bold("Create Fumadocs App")));
|
|
141
|
-
const manager = config.pm ?? getPackageManager();
|
|
142
|
-
const options = await group(
|
|
143
|
-
{
|
|
144
|
-
name: () => {
|
|
145
|
-
if (config.name) return Promise.resolve(config.name);
|
|
146
|
-
return text({
|
|
147
|
-
message: "Project name",
|
|
148
|
-
placeholder: "my-app",
|
|
149
|
-
defaultValue: "my-app"
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
template: () => {
|
|
153
|
-
if (config.template) return Promise.resolve(config.template);
|
|
154
|
-
return select({
|
|
155
|
-
message: "Choose a template",
|
|
156
|
-
initialValue: "+next+fuma-docs-mdx",
|
|
157
|
-
options: templates
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
src: async (v) => {
|
|
161
|
-
if (!v.results.template?.startsWith("+next")) return false;
|
|
162
|
-
if (config.src !== void 0) return config.src;
|
|
163
|
-
return confirm({
|
|
164
|
-
message: "Use `/src` directory?",
|
|
165
|
-
initialValue: false
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
lint: async (v) => {
|
|
169
|
-
if (!v.results.template?.startsWith("+next")) return false;
|
|
170
|
-
if (config.eslint !== void 0) {
|
|
171
|
-
return config.eslint ? "eslint" : false;
|
|
172
|
-
}
|
|
173
|
-
if (config.biome !== void 0) {
|
|
174
|
-
return config.biome ? "biome" : false;
|
|
175
|
-
}
|
|
176
|
-
return select({
|
|
177
|
-
message: "Configure linter?",
|
|
178
|
-
initialValue: false,
|
|
179
|
-
options: [
|
|
180
|
-
{
|
|
181
|
-
value: "eslint",
|
|
182
|
-
label: "ESLint"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
value: "biome",
|
|
186
|
-
label: "Biome"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
value: false,
|
|
190
|
-
label: "Disabled"
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
search: () => {
|
|
196
|
-
return select({
|
|
197
|
-
message: "Choose a search solution?",
|
|
198
|
-
options: [
|
|
199
|
-
{
|
|
200
|
-
value: "orama",
|
|
201
|
-
label: "Default",
|
|
202
|
-
hint: "local search powered by Orama, recommended"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
value: "orama-cloud",
|
|
206
|
-
label: "Orama Cloud",
|
|
207
|
-
hint: "3rd party search solution, signup needed"
|
|
208
|
-
}
|
|
209
|
-
]
|
|
210
|
-
});
|
|
211
|
-
},
|
|
212
|
-
installDeps: () => {
|
|
213
|
-
if (config.install !== void 0)
|
|
214
|
-
return Promise.resolve(config.install);
|
|
215
|
-
return confirm({
|
|
216
|
-
message: `Do you want to install packages automatically? (detected as ${manager})`
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
onCancel: () => {
|
|
222
|
-
cancel("Installation Stopped.");
|
|
223
|
-
process.exit(0);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
);
|
|
227
|
-
const projectName = options.name.toLowerCase().replace(/\s/, "-");
|
|
228
|
-
const dest = path2.resolve(cwd, projectName);
|
|
229
|
-
const destDir = await fs2.readdir(dest).catch(() => null);
|
|
230
|
-
if (destDir && destDir.length > 0) {
|
|
231
|
-
const del = await confirm({
|
|
232
|
-
message: `directory ${projectName} already exists, do you want to delete its files?`
|
|
233
|
-
});
|
|
234
|
-
if (isCancel(del)) {
|
|
235
|
-
cancel();
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (del) {
|
|
239
|
-
const info2 = spinner();
|
|
240
|
-
info2.start(`Deleting files in ${projectName}`);
|
|
241
|
-
await Promise.all(
|
|
242
|
-
destDir.map((item) => {
|
|
243
|
-
return fs2.rm(path2.join(dest, item), {
|
|
244
|
-
recursive: true,
|
|
245
|
-
force: true
|
|
246
|
-
});
|
|
247
|
-
})
|
|
248
|
-
);
|
|
249
|
-
info2.stop(`Deleted files in ${projectName}`);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
const info = spinner();
|
|
253
|
-
info.start(`Generating Project`);
|
|
254
|
-
await create({
|
|
255
|
-
packageManager: manager,
|
|
256
|
-
template: options.template,
|
|
257
|
-
outputDir: dest,
|
|
258
|
-
installDeps: options.installDeps,
|
|
259
|
-
lint: options.lint,
|
|
260
|
-
useSrcDir: options.src,
|
|
261
|
-
initializeGit: config.git ?? true,
|
|
262
|
-
plugins: options.search === "orama-cloud" ? [orama_cloud_default] : [],
|
|
263
|
-
log: (message) => {
|
|
264
|
-
info.message(message);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
info.stop("Project Generated");
|
|
268
|
-
outro(pc.bgGreen(pc.bold("Done")));
|
|
269
|
-
console.log(pc.bold("\nOpen the project"));
|
|
270
|
-
console.log(pc.cyan(`cd ${projectName}`));
|
|
271
|
-
console.log(pc.bold("\nRun Development Server"));
|
|
272
|
-
console.log(pc.cyan("npm run dev | pnpm run dev | yarn dev"));
|
|
273
|
-
console.log(
|
|
274
|
-
pc.bold("\nYou can now open the project and start writing documents")
|
|
275
|
-
);
|
|
276
|
-
process.exit(0);
|
|
277
|
-
}
|
|
278
|
-
program.parse();
|
|
279
|
-
main({
|
|
280
|
-
name: program.args[0],
|
|
281
|
-
...program.opts()
|
|
282
|
-
}).catch((e) => {
|
|
283
|
-
console.error(e);
|
|
284
|
-
process.exit(1);
|
|
285
|
-
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var $schema = "https://biomejs.dev/schemas/2.2.0/schema.json";
|
|
2
|
+
var vcs = {
|
|
3
|
+
enabled: true,
|
|
4
|
+
clientKind: "git",
|
|
5
|
+
useIgnoreFile: true
|
|
6
|
+
};
|
|
7
|
+
var files = {
|
|
8
|
+
ignoreUnknown: true,
|
|
9
|
+
includes: [
|
|
10
|
+
"**",
|
|
11
|
+
"!node_modules",
|
|
12
|
+
"!.source"
|
|
13
|
+
]
|
|
14
|
+
};
|
|
15
|
+
var formatter = {
|
|
16
|
+
enabled: true,
|
|
17
|
+
indentStyle: "space",
|
|
18
|
+
indentWidth: 2
|
|
19
|
+
};
|
|
20
|
+
var linter = {
|
|
21
|
+
enabled: true,
|
|
22
|
+
rules: {
|
|
23
|
+
recommended: true
|
|
24
|
+
},
|
|
25
|
+
domains: {
|
|
26
|
+
react: "recommended"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var assist = {
|
|
30
|
+
actions: {
|
|
31
|
+
source: {
|
|
32
|
+
organizeImports: "on"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var biome_base = {
|
|
37
|
+
$schema: $schema,
|
|
38
|
+
vcs: vcs,
|
|
39
|
+
files: files,
|
|
40
|
+
formatter: formatter,
|
|
41
|
+
linter: linter,
|
|
42
|
+
assist: assist
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { $schema, assist, biome_base as default, files, formatter, linter, vcs };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
biome_base_default
|
|
3
|
+
} from "../chunk-JCFTHRDR.js";
|
|
4
|
+
import {
|
|
5
|
+
biome_next_default
|
|
6
|
+
} from "../chunk-BEZTHMLF.js";
|
|
7
|
+
import {
|
|
8
|
+
depVersions,
|
|
9
|
+
pick,
|
|
10
|
+
writeFile
|
|
11
|
+
} from "../chunk-ZWEHS3HT.js";
|
|
12
|
+
|
|
13
|
+
// src/plugins/biome.ts
|
|
14
|
+
import path from "path";
|
|
15
|
+
function biome() {
|
|
16
|
+
return {
|
|
17
|
+
packageJson(packageJson) {
|
|
18
|
+
return {
|
|
19
|
+
...packageJson,
|
|
20
|
+
scripts: {
|
|
21
|
+
...packageJson.scripts,
|
|
22
|
+
lint: "biome check",
|
|
23
|
+
format: "biome format --write"
|
|
24
|
+
},
|
|
25
|
+
devDependencies: {
|
|
26
|
+
...packageJson.devDependencies,
|
|
27
|
+
...pick(depVersions, ["@biomejs/biome"])
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
async afterWrite() {
|
|
32
|
+
const config = this.template.value === "+next+fuma-docs-mdx" ? biome_next_default : biome_base_default;
|
|
33
|
+
await writeFile(
|
|
34
|
+
path.join(this.dest, "biome.json"),
|
|
35
|
+
JSON.stringify(config, null, 2)
|
|
36
|
+
);
|
|
37
|
+
this.log("Configured Biome");
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
biome
|
|
43
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var $schema = "https://biomejs.dev/schemas/2.2.0/schema.json";
|
|
2
|
+
var vcs = {
|
|
3
|
+
enabled: true,
|
|
4
|
+
clientKind: "git",
|
|
5
|
+
useIgnoreFile: true
|
|
6
|
+
};
|
|
7
|
+
var files = {
|
|
8
|
+
ignoreUnknown: true,
|
|
9
|
+
includes: [
|
|
10
|
+
"**",
|
|
11
|
+
"!node_modules",
|
|
12
|
+
"!.next",
|
|
13
|
+
"!dist",
|
|
14
|
+
"!build",
|
|
15
|
+
"!.source"
|
|
16
|
+
]
|
|
17
|
+
};
|
|
18
|
+
var formatter = {
|
|
19
|
+
enabled: true,
|
|
20
|
+
indentStyle: "space",
|
|
21
|
+
indentWidth: 2
|
|
22
|
+
};
|
|
23
|
+
var linter = {
|
|
24
|
+
enabled: true,
|
|
25
|
+
rules: {
|
|
26
|
+
recommended: true
|
|
27
|
+
},
|
|
28
|
+
domains: {
|
|
29
|
+
next: "recommended",
|
|
30
|
+
react: "recommended"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var assist = {
|
|
34
|
+
actions: {
|
|
35
|
+
source: {
|
|
36
|
+
organizeImports: "on"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var biome_next = {
|
|
41
|
+
$schema: $schema,
|
|
42
|
+
vcs: vcs,
|
|
43
|
+
files: files,
|
|
44
|
+
formatter: formatter,
|
|
45
|
+
linter: linter,
|
|
46
|
+
assist: assist
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { $schema, assist, biome_next as default, files, formatter, linter, vcs };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
depVersions,
|
|
3
|
+
writeFile
|
|
4
|
+
} from "../chunk-ZWEHS3HT.js";
|
|
5
|
+
|
|
6
|
+
// src/plugins/eslint.ts
|
|
7
|
+
import path from "path";
|
|
8
|
+
var config = `import { dirname } from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
|
|
15
|
+
const compat = new FlatCompat({
|
|
16
|
+
baseDirectory: __dirname,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const eslintConfig = [
|
|
20
|
+
...compat.extends('next/core-web-vitals', 'next/typescript'),
|
|
21
|
+
{
|
|
22
|
+
ignores: [
|
|
23
|
+
'node_modules/**',
|
|
24
|
+
'.next/**',
|
|
25
|
+
'out/**',
|
|
26
|
+
'build/**',
|
|
27
|
+
'.source/**',
|
|
28
|
+
'next-env.d.ts',
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export default eslintConfig;`;
|
|
34
|
+
function eslint() {
|
|
35
|
+
return {
|
|
36
|
+
packageJson(packageJson) {
|
|
37
|
+
if (this.template.value !== "+next+fuma-docs-mdx") return;
|
|
38
|
+
return {
|
|
39
|
+
...packageJson,
|
|
40
|
+
scripts: {
|
|
41
|
+
...packageJson.scripts,
|
|
42
|
+
lint: "eslint"
|
|
43
|
+
},
|
|
44
|
+
devDependencies: {
|
|
45
|
+
...packageJson.devDependencies,
|
|
46
|
+
eslint: "^9",
|
|
47
|
+
"eslint-config-next": depVersions.next,
|
|
48
|
+
"@eslint/eslintrc": "^3"
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
async afterWrite() {
|
|
53
|
+
if (this.template.value !== "+next+fuma-docs-mdx") return;
|
|
54
|
+
await writeFile(path.join(this.dest, "eslint.config.mjs"), config);
|
|
55
|
+
this.log("Configured ESLint");
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
eslint
|
|
61
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/plugins/next-use-src.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs/promises";
|
|
4
|
+
function nextUseSrc() {
|
|
5
|
+
return {
|
|
6
|
+
template(info) {
|
|
7
|
+
if (info.value !== "+next+fuma-docs-mdx") return;
|
|
8
|
+
return {
|
|
9
|
+
...info,
|
|
10
|
+
appDir: "src",
|
|
11
|
+
rename: (file) => {
|
|
12
|
+
if (path.basename(file) === "mdx-components.tsx" || isRelative(path.join(this.dest, "app"), file) || isRelative(path.join(this.dest, "lib"), file)) {
|
|
13
|
+
return path.join(this.dest, "src", path.relative(this.dest, file));
|
|
14
|
+
}
|
|
15
|
+
return file;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
// update tsconfig.json for src dir
|
|
20
|
+
async afterWrite() {
|
|
21
|
+
if (this.template.value !== "+next+fuma-docs-mdx") return;
|
|
22
|
+
const tsconfigPath = path.join(this.dest, "tsconfig.json");
|
|
23
|
+
const content = (await fs.readFile(tsconfigPath)).toString();
|
|
24
|
+
const config = JSON.parse(content);
|
|
25
|
+
if (config.compilerOptions?.paths) {
|
|
26
|
+
Object.assign(config.compilerOptions.paths, {
|
|
27
|
+
"@/*": ["./src/*"]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
await fs.writeFile(tsconfigPath, JSON.stringify(config, null, 2));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function isRelative(dir, file) {
|
|
35
|
+
return !path.relative(dir, file).startsWith(`..${path.sep}`);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
nextUseSrc
|
|
39
|
+
};
|