From 9c221658fdae7f9e551765ecd80333721ccde4d9 Mon Sep 17 00:00:00 2001 From: Dipak Halkude Date: Sat, 11 Oct 2025 03:33:11 +0530 Subject: [PATCH 1/2] feat: add option to ignore build errors #2139 --- cli/src/cli/index.ts | 18 +++++++++++++++++- cli/src/helpers/createProject.ts | 32 +++++++++++++++++++++++++++++++- cli/src/index.ts | 5 +++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 013c4c36ea..5468ed2f98 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -41,6 +41,8 @@ interface CliFlags { eslint: boolean; /** @internal Used in CI */ biome: boolean; + /** @internal Used in CI */ + ignoreBuildErrors: boolean; } interface CliResults { @@ -68,6 +70,7 @@ const defaultOptions: CliResults = { dbProvider: "sqlite", eslint: false, biome: false, + ignoreBuildErrors: false, }, databaseProvider: "sqlite", }; @@ -161,6 +164,11 @@ export const runCli = async (): Promise => { "Experimental: Boolean value if we should install biome. Must be used in conjunction with `--CI`.", (value) => !!value && value !== "false" ) + .option( + "--ignoreBuildErrors [boolean]", + "Experimental: Boolean value if we should ignore TypeScript and ESLint build errors. Must be used in conjunction with `--CI`.", + (value) => !!value && value !== "false" + ) /** END CI-FLAGS */ .version(getVersion(), "-v, --version", "Display the version number") .addHelpText( @@ -201,6 +209,7 @@ export const runCli = async (): Promise => { if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth"); if (cliResults.flags.eslint) cliResults.packages.push("eslint"); if (cliResults.flags.biome) cliResults.packages.push("biome"); + cliResults.flags.ignoreBuildErrors = cliResults.flags.ignoreBuildErrors ?? false; if (cliResults.flags.prisma && cliResults.flags.drizzle) { // We test a matrix of all possible combination of packages in CI. Checking for impossible // combinations here and exiting gracefully is easier than changing the CI matrix to exclude @@ -333,6 +342,12 @@ export const runCli = async (): Promise => { initialValue: "eslint", }); }, + ignoreBuildErrors: () => { + return p.confirm({ + message: "Would you like to ignore TypeScript and ESLint build errors?", + initialValue: false, + }); + }, ...(!cliResults.flags.noGit && { git: () => { return p.confirm({ @@ -388,6 +403,7 @@ export const runCli = async (): Promise => { noGit: !project.git || cliResults.flags.noGit, noInstall: !project.install || cliResults.flags.noInstall, importAlias: project.importAlias ?? cliResults.flags.importAlias, + ignoreBuildErrors: project.ignoreBuildErrors ?? cliResults.flags.ignoreBuildErrors, }, }; } catch (err) { @@ -414,4 +430,4 @@ export const runCli = async (): Promise => { } return cliResults; -}; +}; \ No newline at end of file diff --git a/cli/src/helpers/createProject.ts b/cli/src/helpers/createProject.ts index 81b385485f..28ac3fde64 100644 --- a/cli/src/helpers/createProject.ts +++ b/cli/src/helpers/createProject.ts @@ -24,8 +24,32 @@ interface CreateProjectOptions { importAlias: string; appRouter: boolean; databaseProvider: DatabaseProvider; + ignoreBuildErrors: boolean; } +const updateNextConfigWithIgnoreOptions = (projectDir: string) => { + const nextConfigPath = path.join(projectDir, "next.config.js"); + + if (!fs.existsSync(nextConfigPath)) { + return; + } + + let configContent = fs.readFileSync(nextConfigPath, "utf-8"); + + // Find the config object and add the ignore options + const configWithIgnores = configContent.replace( + /const config = {([^}]*)};/, + `const config = {$1 typescript: { + ignoreBuildErrors: true, + }, + eslint: { + ignoreDuringBuilds: true, + },};` + ); + + fs.writeFileSync(nextConfigPath, configWithIgnores); +}; + export const createProject = async ({ projectName, scopedAppName, @@ -33,6 +57,7 @@ export const createProject = async ({ noInstall, appRouter, databaseProvider, + ignoreBuildErrors, }: CreateProjectOptions) => { const pkgManager = getUserPkgManager(); const projectDir = path.resolve(process.cwd(), projectName); @@ -75,6 +100,11 @@ export const createProject = async ({ selectIndexFile({ projectDir, packages }); } + // Add ignore build errors configuration if selected + if (ignoreBuildErrors) { + updateNextConfigWithIgnoreOptions(projectDir); + } + // If no tailwind, select use css modules if (!packages.tailwind.inUse) { const indexModuleCss = path.join( @@ -91,4 +121,4 @@ export const createProject = async ({ } return projectDir; -}; +}; \ No newline at end of file diff --git a/cli/src/index.ts b/cli/src/index.ts index 1cd6a85413..95014ef222 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -39,7 +39,7 @@ const main = async () => { const { appName, packages, - flags: { noGit, noInstall, importAlias, appRouter }, + flags: { noGit, noInstall, importAlias, appRouter, ignoreBuildErrors }, databaseProvider, } = await runCli(); @@ -56,6 +56,7 @@ const main = async () => { importAlias, noInstall, appRouter, + ignoreBuildErrors, }); // Write name to package.json @@ -120,4 +121,4 @@ main().catch((err) => { console.log(err); } process.exit(1); -}); +}); \ No newline at end of file From 1ad644c05a29ee71f14cfae984922b9266ce9d82 Mon Sep 17 00:00:00 2001 From: Dipak Halkude Date: Sat, 11 Oct 2025 04:08:47 +0530 Subject: [PATCH 2/2] feat: add option to ignore build errors - Add interactive prompt for ignoring TypeScript/ESLint build errors - Add --ignoreBuildErrors CLI flag for CI usage - Conditionally update next.config.js with ignore options - Works for both App Router and Pages Router - Add changeset for minor version bump --- .changeset/277351.md | 5 +++++ cli/src/cli/index.ts | 11 +++++++---- cli/src/helpers/createProject.ts | 8 ++++---- cli/src/index.ts | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 .changeset/277351.md diff --git a/.changeset/277351.md b/.changeset/277351.md new file mode 100644 index 0000000000..ca6777a146 --- /dev/null +++ b/.changeset/277351.md @@ -0,0 +1,5 @@ +--- +'create-t3-app': minor +--- + +feat: add option to ignore build errors diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 5468ed2f98..754ae3ac63 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -209,7 +209,8 @@ export const runCli = async (): Promise => { if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth"); if (cliResults.flags.eslint) cliResults.packages.push("eslint"); if (cliResults.flags.biome) cliResults.packages.push("biome"); - cliResults.flags.ignoreBuildErrors = cliResults.flags.ignoreBuildErrors ?? false; + cliResults.flags.ignoreBuildErrors = + cliResults.flags.ignoreBuildErrors ?? false; if (cliResults.flags.prisma && cliResults.flags.drizzle) { // We test a matrix of all possible combination of packages in CI. Checking for impossible // combinations here and exiting gracefully is easier than changing the CI matrix to exclude @@ -344,7 +345,8 @@ export const runCli = async (): Promise => { }, ignoreBuildErrors: () => { return p.confirm({ - message: "Would you like to ignore TypeScript and ESLint build errors?", + message: + "Would you like to ignore TypeScript and ESLint build errors?", initialValue: false, }); }, @@ -403,7 +405,8 @@ export const runCli = async (): Promise => { noGit: !project.git || cliResults.flags.noGit, noInstall: !project.install || cliResults.flags.noInstall, importAlias: project.importAlias ?? cliResults.flags.importAlias, - ignoreBuildErrors: project.ignoreBuildErrors ?? cliResults.flags.ignoreBuildErrors, + ignoreBuildErrors: + project.ignoreBuildErrors ?? cliResults.flags.ignoreBuildErrors, }, }; } catch (err) { @@ -430,4 +433,4 @@ export const runCli = async (): Promise => { } return cliResults; -}; \ No newline at end of file +}; diff --git a/cli/src/helpers/createProject.ts b/cli/src/helpers/createProject.ts index 28ac3fde64..a92f1e91e2 100644 --- a/cli/src/helpers/createProject.ts +++ b/cli/src/helpers/createProject.ts @@ -29,13 +29,13 @@ interface CreateProjectOptions { const updateNextConfigWithIgnoreOptions = (projectDir: string) => { const nextConfigPath = path.join(projectDir, "next.config.js"); - + if (!fs.existsSync(nextConfigPath)) { return; } - let configContent = fs.readFileSync(nextConfigPath, "utf-8"); - + const configContent = fs.readFileSync(nextConfigPath, "utf-8"); + // Find the config object and add the ignore options const configWithIgnores = configContent.replace( /const config = {([^}]*)};/, @@ -121,4 +121,4 @@ export const createProject = async ({ } return projectDir; -}; \ No newline at end of file +}; diff --git a/cli/src/index.ts b/cli/src/index.ts index 95014ef222..868ac82072 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -121,4 +121,4 @@ main().catch((err) => { console.log(err); } process.exit(1); -}); \ No newline at end of file +});