v3: postInstall config option now replaces the postinstall script found in package.json

This commit is contained in:
Eric Allam
2024-06-28 15:59:37 +01:00
parent 374b6b9c0c
commit 75ec4ac6a6
6 changed files with 9 additions and 22 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
v3: postInstall config option now replaces the postinstall script found in package.json
@@ -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);
}
-2
View File
@@ -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
+1 -9
View File
@@ -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");
+2 -1
View File
@@ -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",
+1
View File
@@ -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");