diff --git a/.changeset/tame-apricots-clap.md b/.changeset/tame-apricots-clap.md new file mode 100644 index 000000000..949229bbb --- /dev/null +++ b/.changeset/tame-apricots-clap.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +v3: postInstall config option now replaces the postinstall script found in package.json diff --git a/packages/cli-v3/e2e/createContainerFile.ts b/packages/cli-v3/e2e/createContainerFile.ts index 548977332..b0e886b24 100644 --- a/packages/cli-v3/e2e/createContainerFile.ts +++ b/packages/cli-v3/e2e/createContainerFile.ts @@ -1,7 +1,6 @@ import { readFileSync } from "node:fs"; import { writeFile } from "node:fs/promises"; import { join, resolve } from "node:path"; -import { cliRootPath } from "../src/utilities/resolveInternalFilePath"; import { ReadConfigResult } from "../src/utilities/configFiles"; type CreateContainerFileOptions = { @@ -25,14 +24,5 @@ export async function createContainerFile(options: CreateContainerFileOptions) { let containerFileContents = readFileSync(containerFilePath, "utf-8"); - if (config.postInstall) { - containerFileContents = containerFileContents.replace( - "__POST_INSTALL__", - `RUN ${config.postInstall}` - ); - } else { - containerFileContents = containerFileContents.replace("__POST_INSTALL__", ""); - } - await writeFile(join(tempDir, "Containerfile"), containerFileContents); } diff --git a/packages/cli-v3/src/Containerfile.prod b/packages/cli-v3/src/Containerfile.prod index 1582a0b52..44c6da2e9 100644 --- a/packages/cli-v3/src/Containerfile.prod +++ b/packages/cli-v3/src/Containerfile.prod @@ -34,8 +34,6 @@ COPY --chown=node:node . . USER node RUN npm ci --no-fund --no-audit && npm cache clean --force -__POST_INSTALL__ - # Development or production stage builds upon the base stage FROM base AS final diff --git a/packages/cli-v3/src/commands/deploy.ts b/packages/cli-v3/src/commands/deploy.ts index 2767e5996..add7f4e68 100644 --- a/packages/cli-v3/src/commands/deploy.ts +++ b/packages/cli-v3/src/commands/deploy.ts @@ -1323,6 +1323,7 @@ async function compileProject( dependencies, scripts: { ...javascriptProject.scripts, + ...(typeof config.postInstall === "string" ? { postinstall: config.postInstall } : {}), }, }; @@ -1364,15 +1365,6 @@ async function compileProject( let containerFileContents = readFileSync(containerFilePath, "utf-8"); - if (config.postInstall) { - containerFileContents = containerFileContents.replace( - "__POST_INSTALL__", - `RUN ${config.postInstall}` - ); - } else { - containerFileContents = containerFileContents.replace("__POST_INSTALL__", ""); - } - await writeFile(join(tempDir, "Containerfile"), containerFileContents); const contentHasher = createHash("sha256"); diff --git a/references/v3-catalog/package.json b/references/v3-catalog/package.json index 14632e9aa..1b0b560ca 100644 --- a/references/v3-catalog/package.json +++ b/references/v3-catalog/package.json @@ -8,7 +8,8 @@ "queues": "ts-node -r tsconfig-paths/register ./src/queues.ts", "build:client": "tsup-node ./src/clientUsage.ts --format esm,cjs", "client": "ts-node -r dotenv/config -r tsconfig-paths/register ./src/clientUsage.ts", - "triggerWithLargePayload": "ts-node -r dotenv/config -r tsconfig-paths/register ./src/triggerWithLargePayload.ts" + "triggerWithLargePayload": "ts-node -r dotenv/config -r tsconfig-paths/register ./src/triggerWithLargePayload.ts", + "postinstall": "echo 'package.json postinstall'" }, "dependencies": { "@ffmpeg-installer/ffmpeg": "^1.1.0", diff --git a/references/v3-catalog/trigger.config.ts b/references/v3-catalog/trigger.config.ts index e460a15e6..cf7a0cb88 100644 --- a/references/v3-catalog/trigger.config.ts +++ b/references/v3-catalog/trigger.config.ts @@ -51,6 +51,7 @@ export const config: TriggerConfig = { dependenciesToBundle: [/@sindresorhus/, "escape-string-regexp", /@t3-oss/], instrumentations: [new OpenAIInstrumentation()], logLevel: "info", + postInstall: "echo '========== config.postInstall'", onStart: async (payload, { ctx }) => { if (ctx.organization.id === "clsylhs0v0002dyx75xx4pod1") { console.log("Initializing the app data source");