Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/277351.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-t3-app': minor
---

feat: add option to ignore build errors
19 changes: 19 additions & 0 deletions cli/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ interface CliFlags {
eslint: boolean;
/** @internal Used in CI */
biome: boolean;
/** @internal Used in CI */
ignoreBuildErrors: boolean;
}

interface CliResults {
Expand Down Expand Up @@ -68,6 +70,7 @@ const defaultOptions: CliResults = {
dbProvider: "sqlite",
eslint: false,
biome: false,
ignoreBuildErrors: false,
},
databaseProvider: "sqlite",
};
Expand Down Expand Up @@ -161,6 +164,11 @@ export const runCli = async (): Promise<CliResults> => {
"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(
Expand Down Expand Up @@ -201,6 +209,8 @@ export const runCli = async (): Promise<CliResults> => {
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
Expand Down Expand Up @@ -333,6 +343,13 @@ export const runCli = async (): Promise<CliResults> => {
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({
Expand Down Expand Up @@ -388,6 +405,8 @@ export const runCli = async (): Promise<CliResults> => {
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) {
Expand Down
30 changes: 30 additions & 0 deletions cli/src/helpers/createProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,40 @@ 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;
}

const 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,
packages,
noInstall,
appRouter,
databaseProvider,
ignoreBuildErrors,
}: CreateProjectOptions) => {
const pkgManager = getUserPkgManager();
const projectDir = path.resolve(process.cwd(), projectName);
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const main = async () => {
const {
appName,
packages,
flags: { noGit, noInstall, importAlias, appRouter },
flags: { noGit, noInstall, importAlias, appRouter, ignoreBuildErrors },
databaseProvider,
} = await runCli();

Expand All @@ -56,6 +56,7 @@ const main = async () => {
importAlias,
noInstall,
appRouter,
ignoreBuildErrors,
});

// Write name to package.json
Expand Down