Skip to content

Commit

Permalink
v3: Prevent legacy-peer-deps=true from breaking deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
ericallam committed May 22, 2024
1 parent a86f36c commit c092c0f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .changeset/warm-planes-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"trigger.dev": patch
---

v3: Prevent legacy-peer-deps=true from breaking deploys

When a global `.npmrc` file includes `legacy-peer-deps=true`, deploys would fail on the `npm ci` step because the package-lock.json wouldn't match the `package.json` file. This is because inside the image build, the `.npmrc` file would not be picked up and so `legacy-peer-deps` would end up being false (which is the default). This change forces the `package-lock.json` file to be created using `legacy-peer-deps=false`
29 changes: 25 additions & 4 deletions packages/cli-v3/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1452,10 +1452,31 @@ async function resolveDependencies(
logger.debug(`No cached package-lock.json found for ${digest}`);

try {
await execa("npm", ["install", "--package-lock-only", "--ignore-scripts", "--no-audit"], {
cwd: projectDir,
stdio: logger.loggerLevel === "debug" ? "inherit" : "pipe",
});
if (logger.loggerLevel === "debug") {
const childProcess = await execa("npm", ["config", "list"], {
cwd: projectDir,
stdio: "inherit",
});

logger.debug("npm config list");
console.log(childProcess.stdout);
}

await execa(
"npm",
[
"install",
"--package-lock-only",
"--ignore-scripts",
"--no-audit",
"--legacy-peer-deps=false",
"--strict-peer-deps=false",
],
{
cwd: projectDir,
stdio: logger.loggerLevel === "debug" ? "inherit" : "pipe",
}
);

const packageLockContents = await readFile(join(projectDir, "package-lock.json"), "utf-8");

Expand Down
13 changes: 6 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion references/v3-catalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dotenv": "^16.4.5",
"execa": "^8.0.1",
"msw": "^2.2.1",
"openai": "^4.28.0",
"openai": "^4.47.0",
"pg": "^8.11.5",
"react": "^18.2.0",
"react-email": "^1.6.1",
Expand Down

0 comments on commit c092c0f

Please sign in to comment.