CFA: Add option for ESLint

This commit is contained in:
Fuma Nama
2024-11-08 18:32:10 +08:00
parent 0bab8aacdb
commit 46d9208d23
24 changed files with 391 additions and 355 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'create-fumadocs-app': patch
---
Add option for ESLint
+8 -8
View File
@@ -12,7 +12,7 @@
"start": "next start"
},
"dependencies": {
"@oramacloud/client": "^1.3.19",
"@oramacloud/client": "^1.3.20",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-slot": "^1.1.0",
@@ -29,8 +29,8 @@
"geist": "^1.3.1",
"hast-util-to-jsx-runtime": "^2.3.2",
"katex": "^0.16.11",
"lucide-react": "^0.454.0",
"next": "15.0.2",
"lucide-react": "^0.455.0",
"next": "15.0.3",
"phenomenon": "^1.6.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
@@ -48,19 +48,19 @@
},
"devDependencies": {
"@fumadocs/cli": "workspace:*",
"@next/bundle-analyzer": "15.0.2",
"@next/env": "15.0.2",
"@next/eslint-plugin-next": "15.0.2",
"@next/bundle-analyzer": "15.0.3",
"@next/env": "15.0.3",
"@next/eslint-plugin-next": "15.0.3",
"@types/hast": "^3.0.4",
"@types/mdx": "^2.0.13",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"autoprefixer": "^10.4.20",
"eslint-config-custom": "workspace:*",
"fast-glob": "^3.3.1",
"gray-matter": "^4.0.3",
"next-validate-link": "^1.2.0",
"next-validate-link": "^1.4.0",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.14",
"tailwindcss-animate": "^1.0.7",
+2 -2
View File
@@ -11,12 +11,12 @@
"@fumadocs/content-collections": "workspace:*",
"fumadocs-core": "workspace:*",
"fumadocs-ui": "workspace:*",
"next": "^15.0.2",
"next": "^15.0.3",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@content-collections/core": "^0.7.2",
"@content-collections/core": "^0.7.3",
"@content-collections/mdx": "^0.2.0",
"@content-collections/next": "^0.2.3",
"@types/mdx": "^2.0.13",
+1 -1
View File
@@ -13,7 +13,7 @@
"fumadocs-core": "workspace:*",
"fumadocs-mdx": "workspace:*",
"fumadocs-ui": "workspace:*",
"next": "15.0.2",
"next": "15.0.3",
"react": "18.3.1",
"react-dom": "18.3.1"
},
+1 -1
View File
@@ -11,7 +11,7 @@
"fumadocs-core": "workspace:*",
"fumadocs-mdx": "workspace:*",
"fumadocs-ui": "workspace:*",
"next": "15.0.2",
"next": "15.0.3",
"react": "18.3.1",
"react-dom": "18.3.1"
},
+1 -1
View File
@@ -14,7 +14,7 @@
"fumadocs-mdx": "workspace:*",
"fumadocs-openapi": "workspace:*",
"fumadocs-ui": "workspace:*",
"next": "15.0.2",
"next": "15.0.3",
"postcss": "^8.4.47",
"react": "18.3.1",
"react-dom": "18.3.1",
+1 -1
View File
@@ -11,7 +11,7 @@
"@fumadocs/mdx-remote": "workspace:*",
"fumadocs-core": "workspace:*",
"fumadocs-ui": "workspace:*",
"next": "15.0.2",
"next": "15.0.3",
"react": "18.3.1",
"react-dom": "18.3.1"
},
+1 -1
View File
@@ -30,7 +30,7 @@
"tsup": "8.3.5",
"turbo": "2.2.3",
"typescript": "^5.6.3",
"typescript-eslint": "^8.12.2",
"typescript-eslint": "^8.13.0",
"vitest": "^2.1.4"
},
"packageManager": "[email protected]",
+1 -1
View File
@@ -43,7 +43,7 @@
},
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"@types/react": "^18.3.12",
"eslint-config-custom": "workspace:*",
"fast-glob": "^3.3.1",
+2 -2
View File
@@ -35,9 +35,9 @@
"types:check": "tsc --noEmit"
},
"devDependencies": {
"@content-collections/core": "^0.7.2",
"@content-collections/core": "^0.7.3",
"@content-collections/mdx": "^0.2.0",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"eslint-config-custom": "workspace:*",
"fumadocs-core": "workspace:*",
"tsconfig": "workspace:*",
+3 -3
View File
@@ -98,19 +98,19 @@
"devDependencies": {
"@algolia/client-search": "4.24.0",
"@mdx-js/mdx": "^3.1.0",
"@oramacloud/client": "^1.3.19",
"@oramacloud/client": "^1.3.20",
"@types/estree-jsx": "^1.0.5",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/negotiator": "^0.6.3",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"algoliasearch": "4.24.0",
"eslint-config-custom": "workspace:*",
"mdast-util-mdx-jsx": "^3.1.3",
"mdast-util-mdxjs-esm": "^2.0.1",
"next": "^15.0.2",
"next": "^15.0.3",
"remark-mdx": "^3.1.0",
"remark-rehype": "^11.1.1",
"shiki-transformers": "^1.0.0",
+3 -3
View File
@@ -5,15 +5,15 @@
"description": "Used to track dependency versions in create-fumadocs-app",
"license": "MIT",
"dependencies": {
"@content-collections/core": "^0.7.2",
"@content-collections/core": "^0.7.3",
"@content-collections/mdx": "^0.2.0",
"@content-collections/next": "^0.2.3",
"@types/mdx": "^2.0.13",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"autoprefixer": "^10.4.20",
"next": "15.0.2",
"next": "15.0.3",
"postcss": "^8.4.47",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+2 -2
View File
@@ -28,12 +28,12 @@
},
"dependencies": {
"@clack/prompts": "^0.7.0",
"cross-spawn": "^7.0.3",
"cross-spawn": "^7.0.5",
"picocolors": "^1.1.1"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"eslint-config-custom": "workspace:*",
"fast-glob": "^3.3.1",
"tsconfig": "workspace:*"
+36 -20
View File
@@ -17,6 +17,7 @@ export interface Options {
installDeps?: boolean;
initializeGit?: boolean;
eslint?: boolean;
log?: (message: string) => void;
}
@@ -45,6 +46,11 @@ export async function create(options: Options): Promise<void> {
log('Configured Tailwind CSS');
}
if (options.eslint) {
await copy(path.join(sourceDir, `template/+eslint`), dest);
log('Configured ESLint');
}
const packageJson = createPackageJson(projectName, options);
await fs.writeFile(path.join(dest, 'package.json'), packageJson);
@@ -90,10 +96,7 @@ async function copy(
}
}
function createPackageJson(
projectName: string,
{ template, tailwindcss }: Options,
): string {
function createPackageJson(projectName: string, options: Options): string {
const packageJson = {
name: projectName,
version: '0.0.0',
@@ -102,24 +105,25 @@ function createPackageJson(
build: 'next build',
dev: 'next dev',
start: 'next start',
},
} as Record<string, string>,
dependencies: {
next: versionPkg.dependencies.next,
'fumadocs-ui': localVersions['fumadocs-ui'],
'fumadocs-core': localVersions['fumadocs-core'],
react: versionPkg.dependencies.react,
'react-dom': versionPkg.dependencies['react-dom'],
},
} as Record<string, string>,
devDependencies: {
'@types/node': versionPkg.dependencies['@types/node'],
'@types/react': versionPkg.dependencies['@types/react'],
'@types/react-dom': versionPkg.dependencies['@types/react-dom'],
typescript: versionPkg.dependencies.typescript,
},
} as Record<string, string>,
};
if (template === 'content-collections') {
Object.assign(packageJson.dependencies, {
if (options.template === 'content-collections') {
packageJson.dependencies = {
...packageJson.dependencies,
'@fumadocs/content-collections':
localVersions['@fumadocs/content-collections'],
'@content-collections/core':
@@ -128,29 +132,41 @@ function createPackageJson(
versionPkg.dependencies['@content-collections/mdx'],
'@content-collections/next':
versionPkg.dependencies['@content-collections/next'],
});
};
}
if (template === 'fuma-docs-mdx') {
Object.assign(packageJson.scripts, {
if (options.template === 'fuma-docs-mdx') {
packageJson.scripts = {
...packageJson.scripts,
postinstall: 'fumadocs-mdx',
});
};
Object.assign(packageJson.dependencies, {
packageJson.dependencies = {
...packageJson.dependencies,
'fumadocs-mdx': localVersions['fumadocs-mdx'],
});
};
Object.assign(packageJson.devDependencies, {
packageJson.devDependencies = {
...packageJson.devDependencies,
'@types/mdx': versionPkg.dependencies['@types/mdx'],
});
};
}
if (tailwindcss) {
Object.assign(packageJson.devDependencies, {
if (options.tailwindcss) {
packageJson.devDependencies = {
...packageJson.devDependencies,
autoprefixer: versionPkg.dependencies.autoprefixer,
postcss: versionPkg.dependencies.postcss,
tailwindcss: versionPkg.dependencies.tailwindcss,
});
};
}
if (options.eslint) {
packageJson.devDependencies = {
...packageJson.devDependencies,
eslint: '^8',
'eslint-config-next': versionPkg.dependencies.next,
};
}
return JSON.stringify(packageJson, undefined, 2);
+2
View File
@@ -42,6 +42,7 @@ async function main(): Promise<void> {
],
}),
tailwindcss: () => confirm({ message: 'Use Tailwind CSS for styling?' }),
eslint: () => confirm({ message: 'Add default ESLint configuration?' }),
installDeps: () =>
confirm({
message: `Do you want to install packages automatically? (detected as ${manager})`,
@@ -90,6 +91,7 @@ async function main(): Promise<void> {
template: options.template,
outputDir: dest,
installDeps: options.installDeps,
eslint: options.eslint,
log: (message) => {
log.info(message);
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
+1 -1
View File
@@ -40,7 +40,7 @@
"@types/estree": "^1.0.6",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"eslint-config-custom": "workspace:*",
"remark": "^15.0.0",
"tsconfig": "workspace:*",
+2 -2
View File
@@ -72,12 +72,12 @@
"devDependencies": {
"@types/mdx": "^2.0.13",
"@types/micromatch": "^4.0.9",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"@types/react": "^18.3.12",
"@types/ws": "^8.5.13",
"eslint-config-custom": "workspace:*",
"fumadocs-core": "workspace:*",
"next": "15.0.2",
"next": "15.0.3",
"tsconfig": "workspace:*",
"unified": "^11.0.5",
"vfile": "^6.0.3"
+2 -2
View File
@@ -44,7 +44,7 @@
"dependencies": {
"@mdx-js/mdx": "^3.1.0",
"chokidar": "^4.0.1",
"cross-spawn": "^7.0.3",
"cross-spawn": "^7.0.5",
"esbuild": "^0.24.0",
"estree-util-value-to-estree": "^3.2.1",
"fast-glob": "^3.3.1",
@@ -60,7 +60,7 @@
"@types/react": "^18.3.12",
"eslint-config-custom": "workspace:*",
"fumadocs-core": "workspace:*",
"next": "^15.0.2",
"next": "^15.0.3",
"tsconfig": "workspace:*",
"unified": "^11.0.5",
"vfile": "^6.0.3",
+3 -3
View File
@@ -57,13 +57,13 @@
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"@types/openapi-sampler": "^1.0.3",
"@types/react": "^18.3.12",
"bunchee": "^5.6.1",
"eslint-config-custom": "workspace:*",
"lucide-react": "^0.454.0",
"next": "15.0.2",
"lucide-react": "^0.455.0",
"next": "15.0.3",
"openapi-types": "^12.1.3",
"tsconfig": "workspace:*"
},
+1 -1
View File
@@ -46,7 +46,7 @@
"devDependencies": {
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"@types/react": "^18.3.12",
"eslint-config-custom": "workspace:*",
"fumadocs-ui": "workspace:*",
+1 -1
View File
@@ -35,7 +35,7 @@
"types:check": "tsc --noEmit"
},
"dependencies": {
"@types/node": "22.8.7",
"@types/node": "22.9.0",
"fast-glob": "^3.3.1",
"hast-util-to-jsx-runtime": "^2.3.2",
"mdast-util-from-markdown": "^2.0.2",
+4 -4
View File
@@ -74,18 +74,18 @@
"@tailwindcss/typography": "^0.5.15",
"class-variance-authority": "^0.7.0",
"fumadocs-core": "workspace:*",
"lucide-react": "^0.454.0",
"next-themes": "^0.4.1",
"lucide-react": "^0.455.0",
"next-themes": "^0.4.3",
"react-medium-image-zoom": "^5.2.10",
"tailwind-merge": "^2.5.4"
},
"devDependencies": {
"@fumadocs/cli": "workspace:*",
"@next/eslint-plugin-next": "^15.0.2",
"@next/eslint-plugin-next": "^15.0.3",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"eslint-config-custom": "workspace:*",
"next": "15.0.2",
"next": "15.0.3",
"postcss": "^8.4.47",
"postcss-cli": "^11.0.0",
"postcss-lightningcss": "^1.0.1",
+305 -295
View File
File diff suppressed because it is too large Load Diff