Skip to content

Commit

Permalink
CFA: Add option for ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed Nov 8, 2024
1 parent 0bab8aa commit 46d9208
Show file tree
Hide file tree
Showing 24 changed files with 391 additions and 355 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-years-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-fumadocs-app': patch
---

Add option for ESLint
16 changes: 8 additions & 8 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions examples/content-collections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/next-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/remote-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/content-collections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/create-app-versions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
Expand Down
56 changes: 36 additions & 20 deletions packages/create-app/src/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Options {

installDeps?: boolean;
initializeGit?: boolean;
eslint?: boolean;
log?: (message: string) => void;
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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',
Expand All @@ -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':
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions packages/create-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})`,
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions packages/create-app/template/+eslint/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
2 changes: 1 addition & 1 deletion packages/doc-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/mdx-remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions packages/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/twoslash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
Loading

0 comments on commit 46d9208

Please sign in to comment.