trigger.dev 0.0.0-v3-pnpm-fix-20240404110601 → 0.0.0-v3-pnpm-fix-20240404122439

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -801,7 +801,7 @@ import invariant from "tiny-invariant";
801
801
  import { z as z4 } from "zod";
802
802
 
803
803
  // package.json
804
- var version = "0.0.0-v3-pnpm-fix-20240404110601";
804
+ var version = "0.0.0-v3-pnpm-fix-20240404122439";
805
805
  var dependencies = {
806
806
  "@clack/prompts": "^0.7.0",
807
807
  "@depot/cli": "0.0.1-cli.2.55.0",
@@ -817,7 +817,7 @@ var dependencies = {
817
817
  "@opentelemetry/sdk-trace-base": "^1.22.0",
818
818
  "@opentelemetry/sdk-trace-node": "^1.22.0",
819
819
  "@opentelemetry/semantic-conventions": "^1.22.0",
820
- "@trigger.dev/core": "workspace:0.0.0-v3-pnpm-fix-20240404110601",
820
+ "@trigger.dev/core": "workspace:0.0.0-v3-pnpm-fix-20240404122439",
821
821
  "@types/degit": "^2.8.3",
822
822
  chalk: "^5.2.0",
823
823
  chokidar: "^3.5.3",
@@ -4360,7 +4360,11 @@ var BackgroundWorker = class {
4360
4360
  }
4361
4361
  let resolved = false;
4362
4362
  const cwd = dirname2(this.path);
4363
- logger.debug("Initializing worker", { path: this.path, cwd });
4363
+ const fullEnv = {
4364
+ ...this.params.env,
4365
+ ...this.#readEnvVars()
4366
+ };
4367
+ logger.debug("Initializing worker", { path: this.path, cwd, fullEnv });
4364
4368
  this.tasks = await new Promise((resolve4, reject) => {
4365
4369
  const child = fork(this.path, {
4366
4370
  stdio: [
@@ -4373,10 +4377,7 @@ var BackgroundWorker = class {
4373
4377
  "ipc"
4374
4378
  ],
4375
4379
  cwd,
4376
- env: {
4377
- ...this.params.env,
4378
- ...this.#readEnvVars()
4379
- }
4380
+ env: fullEnv
4380
4381
  });
4381
4382
  const timeout = setTimeout(() => {
4382
4383
  if (resolved) {
@@ -4750,6 +4751,7 @@ function runtimeCheck(minimumMajor, minimumMinor) {
4750
4751
  }
4751
4752
 
4752
4753
  // src/commands/dev.tsx
4754
+ import { findUp as findUp2, pathExists as pathExists2 } from "find-up";
4753
4755
  var apiClient;
4754
4756
  var DevCommandOptions = CommonCommandOptions.extend({
4755
4757
  debugger: z5.boolean().default(false),
@@ -5071,7 +5073,7 @@ function useDev({
5071
5073
  await fs7.promises.writeFile(sourceMapPath2, sourceMapFile.text);
5072
5074
  }
5073
5075
  const environmentVariablesResponse = await environmentClient.getEnvironmentVariables(config.project);
5074
- const processEnv = gatherProcessEnv();
5076
+ const processEnv = await gatherProcessEnv();
5075
5077
  const backgroundWorker = new BackgroundWorker(fullPath, {
5076
5078
  projectConfig: config,
5077
5079
  dependencies: dependencies2,
@@ -5302,7 +5304,7 @@ ${task.filePath} -> ${task.exportName}`).join("")}`;
5302
5304
  }).join("");
5303
5305
  return `Duplicate ${chalkTask("task id")} detected:${duplicateTable}`;
5304
5306
  }
5305
- function gatherProcessEnv() {
5307
+ async function gatherProcessEnv() {
5306
5308
  const env = {
5307
5309
  NODE_ENV: process.env.NODE_ENV ?? "development",
5308
5310
  PATH: process.env.PATH,
@@ -5313,12 +5315,37 @@ function gatherProcessEnv() {
5313
5315
  NVM_BIN: process.env.NVM_BIN,
5314
5316
  LANG: process.env.LANG,
5315
5317
  TERM: process.env.TERM,
5316
- NODE_PATH: process.env.NODE_PATH,
5318
+ NODE_PATH: await amendNodePathWithPnpmNodeModules(process.env.NODE_PATH),
5317
5319
  HOME: process.env.HOME,
5318
5320
  BUN_INSTALL: process.env.BUN_INSTALL
5319
5321
  };
5320
5322
  return Object.fromEntries(Object.entries(env).filter(([key, value]) => value !== void 0));
5321
5323
  }
5324
+ async function amendNodePathWithPnpmNodeModules(nodePath) {
5325
+ const pnpmModulesPath = await findPnpmNodeModulesPath();
5326
+ if (!pnpmModulesPath) {
5327
+ return nodePath;
5328
+ }
5329
+ if (nodePath) {
5330
+ if (nodePath.includes(pnpmModulesPath)) {
5331
+ return nodePath;
5332
+ }
5333
+ return `${nodePath}:${pnpmModulesPath}`;
5334
+ }
5335
+ return pnpmModulesPath;
5336
+ }
5337
+ async function findPnpmNodeModulesPath() {
5338
+ return await findUp2(
5339
+ async (directory) => {
5340
+ const pnpmModules = join5(directory, "node_modules", ".pnpm", "node_modules");
5341
+ const hasPnpmNodeModules = await pathExists2(pnpmModules);
5342
+ if (hasPnpmNodeModules) {
5343
+ return pnpmModules;
5344
+ }
5345
+ },
5346
+ { type: "directory" }
5347
+ );
5348
+ }
5322
5349
 
5323
5350
  // src/commands/init.ts
5324
5351
  import { intro as intro4, isCancel, log as log3, outro as outro4, select as select2, spinner as spinner5, text } from "@clack/prompts";