Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CLI up-to-date #2007

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
259d7cd
update cli deps
ahkhanjani Oct 31, 2024
23a8ef1
cli: run format
ahkhanjani Oct 31, 2024
82199ea
cli: update deps template + eslint 9 installer
ahkhanjani Oct 31, 2024
d25a610
revert react 19 update
ahkhanjani Nov 1, 2024
97821d2
revert cli's react version
ahkhanjani Nov 1, 2024
1a2368e
dedupe deps
ahkhanjani Nov 1, 2024
810e200
fixes
ahkhanjani Nov 4, 2024
88852eb
update cli deps
ahkhanjani Nov 4, 2024
191477b
Merge branch 'main' into next15
ahkhanjani Nov 4, 2024
2b1dba6
update non-breaking major depenency versions
ahkhanjani Nov 4, 2024
a944834
update and migrate execa
ahkhanjani Nov 4, 2024
d394756
update commander
ahkhanjani Nov 4, 2024
e8a31c9
update other packages
ahkhanjani Nov 4, 2024
6e2718f
dedupe
ahkhanjani Nov 4, 2024
a322825
Merge branch 'main' into next15
ahkhanjani Nov 6, 2024
867d30a
bump template versions
ahkhanjani Nov 6, 2024
318b4bf
update and migrate drizzle
ahkhanjani Nov 6, 2024
9ff88ea
dedupe
ahkhanjani Nov 6, 2024
c18f14b
improve eslint installer code
ahkhanjani Nov 6, 2024
afca173
restore json stringify indent
ahkhanjani Nov 6, 2024
64f9e60
Merge branch 'main' into next15
juliusmarminge Jan 12, 2025
5ea9bf0
Merge branch 'main' into next15
ahkhanjani Feb 15, 2025
190e792
update cli deps
ahkhanjani Feb 15, 2025
8c47a8e
update cli deps
ahkhanjani Feb 22, 2025
5d7f763
fix prettier version mismatch
ahkhanjani Feb 22, 2025
aad6263
fix www prettier version
ahkhanjani Feb 22, 2025
b27e276
"upgrade" app to next15
ahkhanjani Feb 22, 2025
9787bc4
run update
ahkhanjani Feb 22, 2025
b5a50bf
?? update drizzle eslint plugin to have types ??
ahkhanjani Feb 22, 2025
6d6509e
fix format
ahkhanjani Feb 22, 2025
a3e7f92
fix a dep
ahkhanjani Feb 22, 2025
7110bfb
add .js to format script
ahkhanjani Feb 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 41 additions & 42 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,57 +42,56 @@
"start": "node dist/index.js",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
"format": "prettier '**/*.{js,cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
"format:check": "prettier '**/*.{js,cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
"release": "changeset version",
"pub:beta": "pnpm build && npm publish --tag beta",
"pub:next": "pnpm build && npm publish --tag next",
"pub:release": "pnpm build && npm publish"
},
"dependencies": {
"@clack/core": "^0.3.4",
"@clack/prompts": "^0.6.3",
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
"chalk": "5.2.0",
"commander": "^10.0.1",
"execa": "^7.2.0",
"fs-extra": "^11.2.0",
"gradient-string": "^2.0.2",
"ora": "6.3.1",
"sort-package-json": "^2.10.0"
"@clack/core": "^0.3.5",
"@clack/prompts": "^0.7.0",
"chalk": "^5.4.1",
"commander": "^12.1.0",
"execa": "^9.5.2",
"fs-extra": "^11.3.0",
"gradient-string": "^3.0.0",
"ora": "8.1.1",
"sort-package-json": "^2.14.0"
},
"devDependencies": {
"@auth/drizzle-adapter": "^1.1.0",
"@auth/prisma-adapter": "^1.6.0",
"@libsql/client": "^0.9.0",
"@auth/drizzle-adapter": "^1.7.4",
"@auth/prisma-adapter": "^2.7.4",
"@ianvs/prettier-plugin-sort-imports": "^4.4.1",
"@libsql/client": "^0.14.0",
"@planetscale/database": "^1.19.0",
"@prisma/adapter-planetscale": "^5.14.0",
"@prisma/client": "^5.14.0",
"@t3-oss/env-nextjs": "^0.10.1",
"@tanstack/react-query": "^5.49.2",
"@trpc/client": "11.0.0-rc.441",
"@trpc/next": "11.0.0-rc.441",
"@trpc/react-query": "11.0.0-rc.441",
"@trpc/server": "11.0.0-rc.441",
"@prisma/adapter-planetscale": "^5.22.0",
"@prisma/client": "^5.22.0",
"@t3-oss/env-nextjs": "^0.11.1",
"@tanstack/react-query": "^5.66.9",
"@trpc/client": "11.0.0-rc.802",
"@trpc/next": "11.0.0-rc.802",
"@trpc/react-query": "11.0.0-rc.802",
"@trpc/server": "11.0.0-rc.802",
"@types/fs-extra": "^11.0.4",
"@types/gradient-string": "^1.1.6",
"@types/node": "^20.14.10",
"drizzle-kit": "^0.24.0",
"drizzle-orm": "^0.33.0",
"mysql2": "^3.11.0",
"next": "^14.2.4",
"next-auth": "^4.24.7",
"postgres": "^3.4.4",
"prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.5",
"prisma": "^5.14.0",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"superjson": "^2.2.1",
"tailwindcss": "^3.4.3",
"tsup": "^6.7.0",
"type-fest": "^3.13.1",
"typescript": "^5.5.3",
"zod": "^3.23.8"
"@types/node": "^20.17.19",
"drizzle-kit": "^0.28.1",
"drizzle-orm": "^0.36.4",
"mysql2": "^3.12.0",
"next": "^15.1.7",
"next-auth": "5.0.0-beta.25",
"postgres": "^3.4.5",
"prettier": "^3.5.2",
"prettier-plugin-tailwindcss": "^0.6.11",
"prisma": "^5.22.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"superjson": "^2.2.2",
"tailwindcss": "^3.4.17",
"tsup": "^8.3.6",
"type-fest": "^4.35.0",
"typescript": "^5.7.3",
"zod": "^3.24.2"
}
}
2 changes: 1 addition & 1 deletion cli/prettier.config.mjs → cli/prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import baseConfig from "../prettier.config.mjs";
import baseConfig from "../prettier.config.js";

/**
* @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions &
Expand Down
6 changes: 3 additions & 3 deletions cli/src/helpers/installDependencies.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from "chalk";
import { execa, type StdioOption } from "execa";
import { execa, type StdoutStderrOption } from "execa";
import ora, { type Ora } from "ora";

import {
Expand All @@ -13,7 +13,7 @@ const execWithSpinner = async (
pkgManager: PackageManager,
options: {
args?: string[];
stdout?: StdioOption;
stdout?: StdoutStderrOption;
onDataHandle?: (spinner: Ora) => (data: Buffer) => void;
}
) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ const runInstallCommand = async (

if (text.includes("Progress")) {
spinner.text = text.includes("|")
? text.split(" | ")[1] ?? ""
? (text.split(" | ")[1] ?? "")
: text;
}
},
Expand Down
28 changes: 14 additions & 14 deletions cli/src/installers/dependencyVersionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ export const dependencyVersionMap = {
"@prisma/adapter-planetscale": "^5.14.0",

// Drizzle
"drizzle-kit": "^0.24.0",
"drizzle-orm": "^0.33.0",
"eslint-plugin-drizzle": "^0.2.3",
mysql2: "^3.11.0",
"drizzle-kit": "^0.28.1",
"drizzle-orm": "^0.36.4",
"eslint-plugin-drizzle": "0.2.3-a5d12b4", // Should update this to latest when latest gets type declarations
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs attention

mysql2: "^3.12.0",
"@planetscale/database": "^1.19.0",
postgres: "^3.4.4",
"@libsql/client": "^0.9.0",

// TailwindCSS
tailwindcss: "^3.4.3",
postcss: "^8.4.39",
prettier: "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.5",
tailwindcss: "^3.4.17",
postcss: "^8.5.3",
prettier: "^3.5.2",
"prettier-plugin-tailwindcss": "^0.6.11",

// tRPC
"@trpc/client": "^11.0.0-rc.446",
"@trpc/server": "^11.0.0-rc.446",
"@trpc/react-query": "^11.0.0-rc.446",
"@trpc/next": "^11.0.0-rc.446",
"@tanstack/react-query": "^5.50.0",
superjson: "^2.2.1",
"@trpc/client": "^11.0.0-rc.802",
"@trpc/server": "^11.0.0-rc.802",
"@trpc/react-query": "^11.0.0-rc.802",
"@trpc/next": "^11.0.0-rc.802",
"@tanstack/react-query": "^5.66.9",
superjson: "^2.2.2",
"server-only": "^0.0.1",
} as const;
export type AvailableDependencies = keyof typeof dependencyVersionMap;
62 changes: 48 additions & 14 deletions cli/src/installers/eslint.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
import path from "path";
import fs from "fs-extra";
import { format } from "prettier";

import { _initialConfig } from "~/../template/extras/config/_eslint.js";
import { type Installer } from "~/installers/index.js";

export const dynamicEslintInstaller: Installer = ({ projectDir, packages }) => {
const usingDrizzle = !!packages?.drizzle?.inUse;

const eslintConfig = getEslintConfig({ usingDrizzle });
const rawConfig = getRawEslintConfig(usingDrizzle);
const stringConfig = JSON.stringify(rawConfig, null, 2);
const configBody = stringConfig.replace(/"%%|%%"/g, "");

// Convert config from _eslint.config.json to .eslintrc.cjs
const eslintrcFileContents = [
'/** @type {import("eslint").Linter.Config} */',
`const config = ${JSON.stringify(eslintConfig, null, 2)}`,
"module.exports = config;",
const imports = getImports(usingDrizzle);

// Convert config from _eslint.js to eslint.config.js
const configFileContents = [
...imports,
"",
"export default tseslint.config(",
configBody,
");",
].join("\n");

const eslintConfigDest = path.join(projectDir, ".eslintrc.cjs");
fs.writeFileSync(eslintConfigDest, eslintrcFileContents, "utf-8");
const configDest = path.join(projectDir, "eslint.config.js");
format(configFileContents, { parser: "typescript" })
.then((formattedConfigFileContents) => {
fs.writeFileSync(configDest, formattedConfigFileContents, "utf-8");
})
.catch((e) => {
console.error("Unable to format ESLint config file.", e);
// Write to fs anyway.
fs.writeFileSync(configDest, configFileContents, "utf-8");
});
};

const getEslintConfig = ({ usingDrizzle }: { usingDrizzle: boolean }) => {
function getRawEslintConfig(usingDrizzle: boolean) {
const eslintConfig = _initialConfig;

if (usingDrizzle) {
eslintConfig.plugins = [...(eslintConfig.plugins ?? []), "drizzle"];
Object.assign(eslintConfig.plugins, {
drizzle: "%%drizzlePlugin%%",
});

eslintConfig.rules = {
...eslintConfig.rules,
Object.assign(eslintConfig.rules, {
"drizzle/enforce-delete-with-where": [
"error",
{ drizzleObjectName: ["db", "ctx.db"] },
Expand All @@ -36,7 +52,25 @@ const getEslintConfig = ({ usingDrizzle }: { usingDrizzle: boolean }) => {
"error",
{ drizzleObjectName: ["db", "ctx.db"] },
],
};
});
}

return eslintConfig;
};
}

function getImports(usingDrizzle: boolean): string[] {
const imports = [
createImport("nextPlugin", "@next/eslint-plugin-next"),
createImport("tseslint", "typescript-eslint"),
];

if (usingDrizzle) {
imports.unshift(createImport("drizzlePlugin", "eslint-plugin-drizzle"));
}

return imports;
}

function createImport(defaultImportName: string, packageName: string): string {
return `import ${defaultImportName} from "${packageName}";`;
}
1 change: 0 additions & 1 deletion cli/template/base/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const config = {
locales: ["en"],
defaultLocale: "en",
},
transpilePackages: ["geist"],
};

export default config;
26 changes: 12 additions & 14 deletions cli/template/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"private": true,
"scripts": {
"dev": "next dev --turbo",
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint",
Expand All @@ -14,22 +14,20 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@t3-oss/env-nextjs": "^0.10.1",
"geist": "^1.3.0",
"next": "^15.0.1",
"@t3-oss/env-nextjs": "^0.11.1",
"geist": "^1.3.1",
"next": "^15.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"zod": "^3.23.3"
"zod": "^3.23.8"
},
"devDependencies": {
"@types/eslint": "^8.56.10",
"@types/node": "^20.14.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"eslint": "^8.57.0",
"eslint-config-next": "^15.0.1",
"typescript": "^5.5.3"
"@next/eslint-plugin-next": "^15.0.2",
"@types/node": "^20.17.6",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"eslint": "^9.14.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.13.0"
}
}
1 change: 0 additions & 1 deletion cli/template/base/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
}
},
"include": [
".eslintrc.cjs",
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/** @type {import("eslint").Linter.Config} */
export const _initialConfig = {
parser: "@typescript-eslint/parser",
parserOptions: { project: true },
plugins: ["@typescript-eslint"],
plugins: {
"@next/next": "%%nextPlugin%%",
"@typescript-eslint": "%%tseslint.plugin%%",
},
extends: [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"%%...nextPlugin.configs['core-web-vitals'].rules%%",
"%%...tseslint.configs.recommendedTypeChecked%%",
"%%...tseslint.configs.stylisticTypeChecked%%",
],
languageOptions: {
parser: "%%tseslint.parser%%",
parserOptions: { project: true },
},
rules: {
"@typescript-eslint/array-type": "off",
"@typescript-eslint/consistent-type-definitions": "off",
Expand Down
1 change: 1 addition & 0 deletions cli/template/extras/config/drizzle-config-mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
dbCredentials: {
url: env.DATABASE_URL,
},
casing: "snake_case",
tablesFilter: ["project1_*"],
} satisfies Config;
1 change: 1 addition & 0 deletions cli/template/extras/config/drizzle-config-postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
dbCredentials: {
url: env.DATABASE_URL,
},
casing: "snake_case",
tablesFilter: ["project1_*"],
} satisfies Config;
1 change: 1 addition & 0 deletions cli/template/extras/config/drizzle-config-sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
dbCredentials: {
url: env.DATABASE_URL,
},
casing: "snake_case",
tablesFilter: ["project1_*"],
} satisfies Config;
Loading
Loading