From 210de3596f7b1f5bcd072852c7b16f839dbfaace Mon Sep 17 00:00:00 2001 From: myftija Date: Wed, 8 Oct 2025 16:13:49 +0200 Subject: [PATCH 1/2] feat(build-server): add option to specify pre-build command Adds an option to specify a pre-build command in the build settings. Can be useful for projects that need a step before the build, e.g., to generate a prisma client. Also, remove the install directory in favor of simplicity. Both pre-build and install commands are run from the root of the repo. Users that need to run the commands in a different dir can just prepend to the command, e.g., `cd apps/web && pnpm run primsa:migrate` --- .../route.tsx | 50 +++++++++++-------- apps/webapp/app/v3/buildSettings.ts | 2 +- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx index 1ba5f26407..e7ddbd5af4 100644 --- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx +++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx @@ -156,23 +156,25 @@ const UpdateBuildSettingsFormSchema = z.object({ .refine((val) => !val || val.length <= 255, { message: "Config file path must not exceed 255 characters", }), - installDirectory: z + installCommand: z .string() .trim() .optional() - .transform((val) => (val ? val.replace(/^\/+/, "") : val)) - .refine((val) => !val || val.length <= 255, { - message: "Install directory must not exceed 255 characters", + .refine((val) => !val || !val.includes("\n"), { + message: "Install command must be a single line", + }) + .refine((val) => !val || val.length <= 500, { + message: "Install command must not exceed 500 characters", }), - installCommand: z + preBuildCommand: z .string() .trim() .optional() .refine((val) => !val || !val.includes("\n"), { - message: "Install command must be a single line", + message: "Pre-build command must be a single line", }) .refine((val) => !val || val.length <= 500, { - message: "Install command must not exceed 500 characters", + message: "Pre-build command must not exceed 500 characters", }), }); @@ -401,11 +403,11 @@ export const action: ActionFunction = async ({ request, params }) => { }); } case "update-build-settings": { - const { installDirectory, installCommand, triggerConfigFilePath } = submission.value; + const { installCommand, preBuildCommand, triggerConfigFilePath } = submission.value; const resultOrFail = await projectSettingsService.updateBuildSettings(projectId, { - installDirectory: installDirectory || undefined, installCommand: installCommand || undefined, + preBuildCommand: preBuildCommand || undefined, triggerConfigFilePath: triggerConfigFilePath || undefined, }); @@ -1100,14 +1102,14 @@ function BuildSettingsForm({ buildSettings }: { buildSettings: BuildSettings }) const [hasBuildSettingsChanges, setHasBuildSettingsChanges] = useState(false); const [buildSettingsValues, setBuildSettingsValues] = useState({ - installDirectory: buildSettings?.installDirectory || "", + preBuildCommand: buildSettings?.preBuildCommand || "", installCommand: buildSettings?.installCommand || "", triggerConfigFilePath: buildSettings?.triggerConfigFilePath || "", }); useEffect(() => { const hasChanges = - buildSettingsValues.installDirectory !== (buildSettings?.installDirectory || "") || + buildSettingsValues.preBuildCommand !== (buildSettings?.preBuildCommand || "") || buildSettingsValues.installCommand !== (buildSettings?.installCommand || "") || buildSettingsValues.triggerConfigFilePath !== (buildSettings?.triggerConfigFilePath || ""); setHasBuildSettingsChanges(hasChanges); @@ -1157,7 +1159,7 @@ function BuildSettingsForm({ buildSettings }: { buildSettings: BuildSettings }) { setBuildSettingsValues((prev) => ({ ...prev, @@ -1165,26 +1167,30 @@ function BuildSettingsForm({ buildSettings }: { buildSettings: BuildSettings }) })); }} /> - Command to install your project dependencies. Auto-detected by default. + + Command to install your project dependencies. This will be run from the root directory + of your repo. Auto-detected by default. + {fields.installCommand.error} - + { setBuildSettingsValues((prev) => ({ ...prev, - installDirectory: e.target.value, + preBuildCommand: e.target.value, })); }} /> - The directory where the install command is run in. Auto-detected by default. - - {fields.installDirectory.error} - + + Any commands that needs to run before we build and deploy your project. This will be run + from the root directory of your repo. + + {fields.preBuildCommand.error} {buildSettingsForm.error} ; From c9298799725e380253fdd1474810d7139e3d737e Mon Sep 17 00:00:00 2001 From: myftija Date: Wed, 8 Oct 2025 16:58:48 +0200 Subject: [PATCH 2/2] Fix spelling --- .../route.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx index e7ddbd5af4..bb75af34fe 100644 --- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx +++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings/route.tsx @@ -1187,7 +1187,7 @@ function BuildSettingsForm({ buildSettings }: { buildSettings: BuildSettings }) }} /> - Any commands that needs to run before we build and deploy your project. This will be run + Any command that needs to run before we build and deploy your project. This will be run from the root directory of your repo. {fields.preBuildCommand.error}