feat: add heroku version field

This commit is contained in:
Mauricio Siu 2024-12-07 13:27:54 -06:00
parent 1056810170
commit 4c45be1447
9 changed files with 8041 additions and 4 deletions

View File

@ -41,6 +41,7 @@ const mySchema = z.discriminatedUnion("buildType", [
}),
z.object({
buildType: z.literal("heroku_buildpacks"),
herokuVersion: z.string().nullable().default(""),
}),
z.object({
buildType: z.literal("paketo_buildpacks"),
@ -90,6 +91,13 @@ export const ShowBuildChooseForm = ({ applicationId }: Props) => {
dockerBuildStage: data.dockerBuildStage || "",
}),
});
} else if (data.buildType === "heroku_buildpacks") {
form.reset({
buildType: data.buildType,
...(data.buildType && {
herokuVersion: data.herokuVersion || "",
}),
});
} else {
form.reset({
buildType: data.buildType,
@ -110,6 +118,8 @@ export const ShowBuildChooseForm = ({ applicationId }: Props) => {
data.buildType === "dockerfile" ? data.dockerContextPath : null,
dockerBuildStage:
data.buildType === "dockerfile" ? data.dockerBuildStage : null,
herokuVersion:
data.buildType === "heroku_buildpacks" ? data.herokuVersion : null,
})
.then(async () => {
toast.success("Build type saved");
@ -200,6 +210,28 @@ export const ShowBuildChooseForm = ({ applicationId }: Props) => {
);
}}
/>
{buildType === "heroku_buildpacks" && (
<FormField
control={form.control}
name="herokuVersion"
render={({ field }) => {
return (
<FormItem>
<FormLabel>Heroku Version (Optional)</FormLabel>
<FormControl>
<Input
placeholder={"Heroku Version (Default: 24)"}
{...field}
value={field.value ?? ""}
/>
</FormControl>
<FormMessage />
</FormItem>
);
}}
/>
)}
{buildType === "dockerfile" && (
<>
<FormField

View File

@ -0,0 +1 @@
ALTER TABLE "application" ADD COLUMN "herokuVersion" text;

View File

@ -0,0 +1 @@
ALTER TABLE "application" ALTER COLUMN "herokuVersion" SET DEFAULT '24';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -330,6 +330,20 @@
"when": 1732851191048,
"tag": "0046_purple_sleeper",
"breakpoints": true
},
{
"idx": 47,
"version": "6",
"when": 1733599090582,
"tag": "0047_tidy_revanche",
"breakpoints": true
},
{
"idx": 48,
"version": "6",
"when": 1733599163710,
"tag": "0048_flat_expediter",
"breakpoints": true
}
]
}

View File

@ -296,6 +296,7 @@ export const applicationRouter = createTRPCRouter({
publishDirectory: input.publishDirectory,
dockerContextPath: input.dockerContextPath,
dockerBuildStage: input.dockerBuildStage,
herokuVersion: input.herokuVersion,
});
return true;

View File

@ -178,6 +178,7 @@ export const applications = pgTable("application", {
.notNull()
.default("idle"),
buildType: buildType("buildType").notNull().default("nixpacks"),
herokuVersion: text("herokuVersion").default("24"),
publishDirectory: text("publishDirectory"),
createdAt: text("createdAt")
.notNull()
@ -368,6 +369,7 @@ const createSchema = createInsertSchema(applications, {
"nixpacks",
"static",
]),
herokuVersion: z.string().optional(),
publishDirectory: z.string().optional(),
owner: z.string(),
healthCheckSwarm: HealthCheckSwarmSchema.nullable(),
@ -408,6 +410,7 @@ export const apiSaveBuildType = createSchema
dockerfile: true,
dockerContextPath: true,
dockerBuildStage: true,
herokuVersion: true,
})
.required()
.merge(createSchema.pick({ publishDirectory: true }));

View File

@ -16,14 +16,13 @@ export const buildHeroku = async (
application.project.env,
);
try {
const builderVersion = env.HEROKU_STACK_VERSION || '24';
const args = [
"build",
appName,
"--path",
buildAppDirectory,
"--builder",
`heroku/builder:${builderVersion}`,
`heroku/builder:${application.herokuVersion || "24"}`,
];
for (const env of envVariables) {
@ -53,14 +52,13 @@ export const getHerokuCommand = (
application.project.env,
);
const builderVersion = env.HEROKU_STACK_VERSION || '24';
const args = [
"build",
appName,
"--path",
buildAppDirectory,
"--builder",
`heroku/builder:${builderVersion}`,
`heroku/builder:${application.herokuVersion || "24"}`,
];
for (const env of envVariables) {