create-fumadocs-app 16.0.3 → 16.0.5
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/README.md +1 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +215 -0
- package/dist/chunk-BEZTHMLF.js +51 -0
- package/dist/chunk-F7NHHEKG.js +130 -0
- package/dist/chunk-JCFTHRDR.js +50 -0
- package/dist/{chunk-HLHY7KAF.js → chunk-XPRRZX4H.js} +37 -59
- package/dist/index.d.ts +63 -1
- package/dist/index.js +6 -208
- 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 +18 -8
- package/dist/chunk-3VWJJEHU.js +0 -204
- package/dist/create-app.d.ts +0 -49
- package/dist/create-app.js +0 -7
- package/dist/orama-cloud-VQUOOEZ2.js +0 -313
- package/template/+next+biome/biome.json +0 -34
- package/template/+next+eslint/eslint.config.mjs +0 -26
package/dist/index.js
CHANGED
|
@@ -1,209 +1,7 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import {
|
|
3
|
-
create
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
templates
|
|
10
|
-
} from "./chunk-HLHY7KAF.js";
|
|
11
|
-
|
|
12
|
-
// src/index.ts
|
|
13
|
-
import fs from "fs/promises";
|
|
14
|
-
import path from "path";
|
|
15
|
-
import {
|
|
16
|
-
cancel,
|
|
17
|
-
confirm,
|
|
18
|
-
group,
|
|
19
|
-
intro,
|
|
20
|
-
isCancel,
|
|
21
|
-
outro,
|
|
22
|
-
select,
|
|
23
|
-
spinner,
|
|
24
|
-
text
|
|
25
|
-
} from "@clack/prompts";
|
|
26
|
-
import pc from "picocolors";
|
|
27
|
-
import { program } from "commander";
|
|
28
|
-
program.argument("[name]", "the project name");
|
|
29
|
-
program.option("--src", "(Next.js only) enable `src/` directory");
|
|
30
|
-
program.option("--no-src", "(Next.js only) disable `src/` directory");
|
|
31
|
-
program.option("--eslint", "(Next.js only) enable ESLint configuration");
|
|
32
|
-
program.option("--no-eslint", "(Next.js only) disable ESLint configuration");
|
|
33
|
-
program.option("--biome", "(Next.js only) enable Biome configuration");
|
|
34
|
-
program.option("--no-biome", "(Next.js only) disable Biome configuration");
|
|
35
|
-
program.option("--install", "Enable installing packages automatically");
|
|
36
|
-
program.option("--no-install", "Disable installing packages automatically");
|
|
37
|
-
program.option("--no-git", "Disable auto Git repository initialization");
|
|
38
|
-
program.option(
|
|
39
|
-
"--template <name>",
|
|
40
|
-
`template to choose: ${templates.map((v) => v.value).join(", ")}`,
|
|
41
|
-
(value) => {
|
|
42
|
-
if (!templates.some((item) => item.value === value)) {
|
|
43
|
-
throw new Error(`Invalid template: ${value}.`);
|
|
44
|
-
}
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
program.option(
|
|
49
|
-
"--pm <name>",
|
|
50
|
-
`package manager to choose: ${managers.join(", ")}`,
|
|
51
|
-
(value) => {
|
|
52
|
-
if (!managers.includes(value)) {
|
|
53
|
-
throw new Error(`Invalid package manager: ${value}.`);
|
|
54
|
-
}
|
|
55
|
-
return value;
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
async function main(config) {
|
|
59
|
-
intro(pc.bgCyan(pc.bold("Create Fumadocs App")));
|
|
60
|
-
const manager = config.pm ?? getPackageManager();
|
|
61
|
-
const options = await group(
|
|
62
|
-
{
|
|
63
|
-
name: () => {
|
|
64
|
-
if (config.name) return Promise.resolve(config.name);
|
|
65
|
-
return text({
|
|
66
|
-
message: "Project name",
|
|
67
|
-
placeholder: "my-app",
|
|
68
|
-
defaultValue: "my-app"
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
template: () => {
|
|
72
|
-
if (config.template) return Promise.resolve(config.template);
|
|
73
|
-
return select({
|
|
74
|
-
message: "Choose a template",
|
|
75
|
-
initialValue: "+next+fuma-docs-mdx",
|
|
76
|
-
options: templates
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
src: async (v) => {
|
|
80
|
-
if (!v.results.template?.startsWith("+next")) return false;
|
|
81
|
-
if (config.src !== void 0) return config.src;
|
|
82
|
-
return confirm({
|
|
83
|
-
message: "Use `/src` directory?",
|
|
84
|
-
initialValue: false
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
lint: async (v) => {
|
|
88
|
-
if (!v.results.template?.startsWith("+next")) return false;
|
|
89
|
-
if (config.eslint !== void 0) {
|
|
90
|
-
return config.eslint ? "eslint" : false;
|
|
91
|
-
}
|
|
92
|
-
if (config.biome !== void 0) {
|
|
93
|
-
return config.biome ? "biome" : false;
|
|
94
|
-
}
|
|
95
|
-
return select({
|
|
96
|
-
message: "Configure linter?",
|
|
97
|
-
initialValue: false,
|
|
98
|
-
options: [
|
|
99
|
-
{
|
|
100
|
-
value: false,
|
|
101
|
-
label: "Disabled"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
value: "eslint",
|
|
105
|
-
label: "ESLint"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
value: "biome",
|
|
109
|
-
label: "Biome"
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
search: () => {
|
|
115
|
-
return select({
|
|
116
|
-
message: "Choose a search solution?",
|
|
117
|
-
options: [
|
|
118
|
-
{
|
|
119
|
-
value: "orama",
|
|
120
|
-
label: "Default",
|
|
121
|
-
hint: "local search powered by Orama, recommended"
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
value: "orama-cloud",
|
|
125
|
-
label: "Orama Cloud",
|
|
126
|
-
hint: "3rd party search solution, signup needed"
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
installDeps: () => {
|
|
132
|
-
if (config.install !== void 0)
|
|
133
|
-
return Promise.resolve(config.install);
|
|
134
|
-
return confirm({
|
|
135
|
-
message: `Do you want to install packages automatically? (detected as ${manager})`
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
onCancel: () => {
|
|
141
|
-
cancel("Installation Stopped.");
|
|
142
|
-
process.exit(0);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
const projectName = options.name.toLowerCase().replace(/\s/, "-");
|
|
147
|
-
const dest = path.resolve(cwd, projectName);
|
|
148
|
-
const destDir = await fs.readdir(dest).catch(() => null);
|
|
149
|
-
if (destDir && destDir.length > 0) {
|
|
150
|
-
const del = await confirm({
|
|
151
|
-
message: `directory ${projectName} already exists, do you want to delete its files?`
|
|
152
|
-
});
|
|
153
|
-
if (isCancel(del)) {
|
|
154
|
-
cancel();
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (del) {
|
|
158
|
-
const info2 = spinner();
|
|
159
|
-
info2.start(`Deleting files in ${projectName}`);
|
|
160
|
-
await Promise.all(
|
|
161
|
-
destDir.map((item) => {
|
|
162
|
-
return fs.rm(path.join(dest, item), {
|
|
163
|
-
recursive: true,
|
|
164
|
-
force: true
|
|
165
|
-
});
|
|
166
|
-
})
|
|
167
|
-
);
|
|
168
|
-
info2.stop(`Deleted files in ${projectName}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const info = spinner();
|
|
172
|
-
info.start(`Generating Project`);
|
|
173
|
-
const plugins = [];
|
|
174
|
-
if (options.search === "orama-cloud") {
|
|
175
|
-
const { oramaCloud } = await import("./orama-cloud-VQUOOEZ2.js");
|
|
176
|
-
plugins.push(oramaCloud());
|
|
177
|
-
}
|
|
178
|
-
await create({
|
|
179
|
-
packageManager: manager,
|
|
180
|
-
template: options.template,
|
|
181
|
-
outputDir: dest,
|
|
182
|
-
installDeps: options.installDeps,
|
|
183
|
-
lint: options.lint,
|
|
184
|
-
useSrcDir: options.src,
|
|
185
|
-
initializeGit: config.git ?? true,
|
|
186
|
-
plugins,
|
|
187
|
-
log: (message) => {
|
|
188
|
-
info.message(message);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
info.stop("Project Generated");
|
|
192
|
-
outro(pc.bgGreen(pc.bold("Done")));
|
|
193
|
-
console.log(pc.bold("\nOpen the project"));
|
|
194
|
-
console.log(pc.cyan(`cd ${projectName}`));
|
|
195
|
-
console.log(pc.bold("\nRun Development Server"));
|
|
196
|
-
console.log(pc.cyan("npm run dev | pnpm run dev | yarn dev"));
|
|
197
|
-
console.log(
|
|
198
|
-
pc.bold("\nYou can now open the project and start writing documents")
|
|
199
|
-
);
|
|
200
|
-
process.exit(0);
|
|
201
|
-
}
|
|
202
|
-
program.parse();
|
|
203
|
-
main({
|
|
204
|
-
name: program.args[0],
|
|
205
|
-
...program.opts()
|
|
206
|
-
}).catch((e) => {
|
|
207
|
-
console.error(e);
|
|
208
|
-
process.exit(1);
|
|
209
|
-
});
|
|
2
|
+
create
|
|
3
|
+
} from "./chunk-F7NHHEKG.js";
|
|
4
|
+
import "./chunk-XPRRZX4H.js";
|
|
5
|
+
export {
|
|
6
|
+
create
|
|
7
|
+
};
|
|
@@ -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-XPRRZX4H.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
|
+
pick,
|
|
4
|
+
writeFile
|
|
5
|
+
} from "../chunk-XPRRZX4H.js";
|
|
6
|
+
|
|
7
|
+
// src/plugins/eslint.ts
|
|
8
|
+
import path from "path";
|
|
9
|
+
var config = `import { dirname } from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
|
|
16
|
+
const compat = new FlatCompat({
|
|
17
|
+
baseDirectory: __dirname,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const eslintConfig = [
|
|
21
|
+
...compat.extends('next/core-web-vitals', 'next/typescript'),
|
|
22
|
+
{
|
|
23
|
+
ignores: [
|
|
24
|
+
'node_modules/**',
|
|
25
|
+
'.next/**',
|
|
26
|
+
'out/**',
|
|
27
|
+
'build/**',
|
|
28
|
+
'.source/**',
|
|
29
|
+
'next-env.d.ts',
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export default eslintConfig;`;
|
|
35
|
+
function eslint() {
|
|
36
|
+
return {
|
|
37
|
+
packageJson(packageJson) {
|
|
38
|
+
if (this.template.value !== "+next+fuma-docs-mdx") return;
|
|
39
|
+
return {
|
|
40
|
+
...packageJson,
|
|
41
|
+
scripts: {
|
|
42
|
+
...packageJson.scripts,
|
|
43
|
+
lint: "eslint"
|
|
44
|
+
},
|
|
45
|
+
devDependencies: {
|
|
46
|
+
...packageJson.devDependencies,
|
|
47
|
+
"eslint-config-next": packageJson.dependencies.next,
|
|
48
|
+
...pick(depVersions, ["eslint", "@eslint/eslintrc"])
|
|
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
|
+
};
|