trigger.dev 0.0.0-v3-pnpm-fix-20240409125541 → 0.0.0-v3-pnpm-fix-20240411185916

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-20240409125541";
804
+ var version = "0.0.0-v3-pnpm-fix-20240411185916";
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-20240409125541",
820
+ "@trigger.dev/core": "workspace:0.0.0-v3-pnpm-fix-20240411185916",
821
821
  "@types/degit": "^2.8.3",
822
822
  chalk: "^5.2.0",
823
823
  chokidar: "^3.5.3",
@@ -2823,6 +2823,10 @@ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfi
2823
2823
  setup(build3) {
2824
2824
  build3.onResolve({ filter: /.*/ }, (args) => {
2825
2825
  const resolvedPath = resolvePath(args.path);
2826
+ logger.debug(`[${buildIdentifier}] Handling ${args.path}`, {
2827
+ ...args,
2828
+ resolvedPath
2829
+ });
2826
2830
  if (!isBareModuleId(resolvedPath)) {
2827
2831
  return void 0;
2828
2832
  }
@@ -2842,9 +2846,6 @@ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfi
2842
2846
  return void 0;
2843
2847
  }
2844
2848
  }
2845
- logger.ignore(`[${buildIdentifier}] Externalizing ${args.path}`, {
2846
- ...args
2847
- });
2848
2849
  return {
2849
2850
  path: args.path,
2850
2851
  external: true
@@ -3076,11 +3077,94 @@ function safeJsonParse(json) {
3076
3077
  // src/utilities/javascriptProject.ts
3077
3078
  import { $ } from "execa";
3078
3079
  import { join as join4 } from "node:path";
3080
+
3081
+ // src/utilities/getUserPackageManager.ts
3082
+ import { findUp as findUp2 } from "find-up";
3083
+ async function getUserPackageManager(path6) {
3084
+ try {
3085
+ return await detectPackageManagerFromArtifacts(path6);
3086
+ } catch (error) {
3087
+ return detectPackageManagerFromCurrentCommand();
3088
+ }
3089
+ }
3090
+ function detectPackageManagerFromCurrentCommand() {
3091
+ const userAgent = process.env.npm_config_user_agent;
3092
+ if (userAgent) {
3093
+ if (userAgent.startsWith("yarn")) {
3094
+ return "yarn";
3095
+ } else if (userAgent.startsWith("pnpm")) {
3096
+ return "pnpm";
3097
+ } else {
3098
+ return "npm";
3099
+ }
3100
+ } else {
3101
+ return "npm";
3102
+ }
3103
+ }
3104
+ async function detectPackageManagerFromArtifacts(path6) {
3105
+ const packageFiles = [
3106
+ { name: "yarn.lock", pm: "yarn" },
3107
+ { name: "pnpm-lock.yaml", pm: "pnpm" },
3108
+ { name: "package-lock.json", pm: "npm" },
3109
+ { name: "npm-shrinkwrap.json", pm: "npm" }
3110
+ ];
3111
+ for (const { name, pm } of packageFiles) {
3112
+ const foundPath = await findUp2(name, { cwd: path6 });
3113
+ if (typeof foundPath === "string") {
3114
+ return pm;
3115
+ }
3116
+ }
3117
+ throw new Error("Could not detect package manager from artifacts");
3118
+ }
3119
+
3120
+ // src/utilities/javascriptProject.ts
3121
+ var BuiltInModules = /* @__PURE__ */ new Set([
3122
+ "assert",
3123
+ "async_hooks",
3124
+ "buffer",
3125
+ "child_process",
3126
+ "cluster",
3127
+ "console",
3128
+ "constants",
3129
+ "crypto",
3130
+ "dgram",
3131
+ "dns",
3132
+ "domain",
3133
+ "events",
3134
+ "fs",
3135
+ "http",
3136
+ "http2",
3137
+ "https",
3138
+ "inspector",
3139
+ "module",
3140
+ "net",
3141
+ "os",
3142
+ "path",
3143
+ "perf_hooks",
3144
+ "process",
3145
+ "punycode",
3146
+ "querystring",
3147
+ "readline",
3148
+ "repl",
3149
+ "stream",
3150
+ "string_decoder",
3151
+ "timers",
3152
+ "tls",
3153
+ "trace_events",
3154
+ "tty",
3155
+ "url",
3156
+ "util",
3157
+ "v8",
3158
+ "vm",
3159
+ "worker_threads",
3160
+ "zlib"
3161
+ ]);
3079
3162
  var JavascriptProject = class {
3080
3163
  constructor(projectPath) {
3081
3164
  this.projectPath = projectPath;
3082
3165
  }
3083
3166
  _packageJson;
3167
+ _packageManager;
3084
3168
  get packageJson() {
3085
3169
  if (!this._packageJson) {
3086
3170
  this._packageJson = readJSONFileSync(join4(this.projectPath, "package.json"));
@@ -3093,6 +3177,13 @@ var JavascriptProject = class {
3093
3177
  };
3094
3178
  }
3095
3179
  async resolve(packageName, options) {
3180
+ if (BuiltInModules.has(packageName)) {
3181
+ return void 0;
3182
+ }
3183
+ if (!this._packageManager) {
3184
+ this._packageManager = await getUserPackageManager(this.projectPath);
3185
+ }
3186
+ const packageManager = this._packageManager;
3096
3187
  const opts = { allowDev: false, ...options };
3097
3188
  const packageJsonVersion = this.packageJson.dependencies?.[packageName];
3098
3189
  if (typeof packageJsonVersion === "string") {
@@ -3104,21 +3195,19 @@ var JavascriptProject = class {
3104
3195
  return devPackageJsonVersion;
3105
3196
  }
3106
3197
  }
3107
- const commands = [new NPMCommands(), new PNPMCommands(), new YarnCommands()];
3108
- for (const command of commands) {
3109
- try {
3110
- const version2 = await command.resolveDependencyVersion(packageName, {
3111
- cwd: this.projectPath
3112
- });
3113
- if (version2) {
3114
- return version2;
3115
- }
3116
- } catch (error) {
3117
- logger.debug(`Failed to resolve dependency version using ${command.name}`, {
3118
- packageName,
3119
- error
3120
- });
3198
+ const command = packageManager === "npm" ? new NPMCommands() : packageManager === "pnpm" ? new PNPMCommands() : new YarnCommands();
3199
+ try {
3200
+ const version2 = await command.resolveDependencyVersion(packageName, {
3201
+ cwd: this.projectPath
3202
+ });
3203
+ if (version2) {
3204
+ return version2;
3121
3205
  }
3206
+ } catch (error) {
3207
+ logger.debug(`Failed to resolve dependency version using ${command.name}`, {
3208
+ packageName,
3209
+ error
3210
+ });
3122
3211
  }
3123
3212
  }
3124
3213
  };
@@ -4887,7 +4976,7 @@ function runtimeCheck(minimumMajor, minimumMinor) {
4887
4976
  }
4888
4977
 
4889
4978
  // src/commands/dev.tsx
4890
- import { findUp as findUp2, pathExists as pathExists2 } from "find-up";
4979
+ import { findUp as findUp3, pathExists as pathExists2 } from "find-up";
4891
4980
  var apiClient;
4892
4981
  var DevCommandOptions = CommonCommandOptions.extend({
4893
4982
  debugger: z5.boolean().default(false),
@@ -4931,11 +5020,11 @@ async function devCommand(dir, options) {
4931
5020
  process.exitCode = 1;
4932
5021
  return;
4933
5022
  }
4934
- const devInstance = await startDev(dir, options, authorization.auth);
5023
+ const devInstance = await startDev(dir, options, authorization.auth, authorization.dashboardUrl);
4935
5024
  const { waitUntilExit } = devInstance.devReactElement;
4936
5025
  await waitUntilExit();
4937
5026
  }
4938
- async function startDev(dir, options, authorization) {
5027
+ async function startDev(dir, options, authorization, dashboardUrl) {
4939
5028
  let rerender;
4940
5029
  try {
4941
5030
  if (options.logLevel) {
@@ -4973,6 +5062,7 @@ async function startDev(dir, options, authorization) {
4973
5062
  return /* @__PURE__ */ React.createElement(
4974
5063
  DevUI,
4975
5064
  {
5065
+ dashboardUrl,
4976
5066
  config: configParam,
4977
5067
  apiUrl,
4978
5068
  apiKey: devEnv.data.apiKey,
@@ -5004,6 +5094,7 @@ async function startDev(dir, options, authorization) {
5004
5094
  }
5005
5095
  function useDev({
5006
5096
  config,
5097
+ dashboardUrl,
5007
5098
  apiUrl,
5008
5099
  apiKey,
5009
5100
  environmentClient,
@@ -5033,7 +5124,7 @@ function useDev({
5033
5124
  }
5034
5125
  });
5035
5126
  const backgroundWorkerCoordinator = new BackgroundWorkerCoordinator(
5036
- `${apiUrl}/projects/v3/${config.project}`
5127
+ `${dashboardUrl}/projects/v3/${config.project}`
5037
5128
  );
5038
5129
  websocket.addEventListener("open", async (event) => {
5039
5130
  });
@@ -5471,7 +5562,7 @@ async function amendNodePathWithPnpmNodeModules(nodePath) {
5471
5562
  return pnpmModulesPath;
5472
5563
  }
5473
5564
  async function findPnpmNodeModulesPath() {
5474
- return await findUp2(
5565
+ return await findUp3(
5475
5566
  async (directory) => {
5476
5567
  const pnpmModules = join6(directory, "node_modules", ".pnpm", "node_modules");
5477
5568
  const hasPnpmNodeModules = await pathExists2(pnpmModules);
@@ -5539,45 +5630,6 @@ function replaceAll(input, replacements) {
5539
5630
  return output;
5540
5631
  }
5541
5632
 
5542
- // src/utilities/getUserPackageManager.ts
5543
- import pathModule2 from "path";
5544
- async function getUserPackageManager(path6) {
5545
- try {
5546
- return await detectPackageManagerFromArtifacts(path6);
5547
- } catch (error) {
5548
- return detectPackageManagerFromCurrentCommand();
5549
- }
5550
- }
5551
- function detectPackageManagerFromCurrentCommand() {
5552
- const userAgent = process.env.npm_config_user_agent;
5553
- if (userAgent) {
5554
- if (userAgent.startsWith("yarn")) {
5555
- return "yarn";
5556
- } else if (userAgent.startsWith("pnpm")) {
5557
- return "pnpm";
5558
- } else {
5559
- return "npm";
5560
- }
5561
- } else {
5562
- return "npm";
5563
- }
5564
- }
5565
- async function detectPackageManagerFromArtifacts(path6) {
5566
- const packageFiles = [
5567
- { name: "yarn.lock", pm: "yarn" },
5568
- { name: "pnpm-lock.yaml", pm: "pnpm" },
5569
- { name: "package-lock.json", pm: "npm" },
5570
- { name: "npm-shrinkwrap.json", pm: "npm" }
5571
- ];
5572
- for (const { name, pm } of packageFiles) {
5573
- const exists = await pathExists(pathModule2.join(path6, name));
5574
- if (exists) {
5575
- return pm;
5576
- }
5577
- }
5578
- throw new Error("Could not detect package manager from artifacts");
5579
- }
5580
-
5581
5633
  // src/utilities/resolveInternalFilePath.ts
5582
5634
  import { resolve as importResolve3 } from "import-meta-resolve";
5583
5635
  function resolveInternalFilePath(filePath) {