trigger.dev 3.0.0-beta.7 → 3.0.0-beta.9

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
@@ -794,14 +794,14 @@ import { resolve as importResolve } from "import-meta-resolve";
794
794
  import { createHash } from "node:crypto";
795
795
  import { readFileSync as readFileSync2 } from "node:fs";
796
796
  import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
797
- import { dirname, join as join4, relative as relative3 } from "node:path";
797
+ import { dirname, join as join5, relative as relative3 } from "node:path";
798
798
  import { setTimeout as setTimeout2 } from "node:timers/promises";
799
799
  import terminalLink from "terminal-link";
800
800
  import invariant from "tiny-invariant";
801
801
  import { z as z4 } from "zod";
802
802
 
803
803
  // package.json
804
- var version = "3.0.0-beta.7";
804
+ var version = "3.0.0-beta.9";
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:^3.0.0-beta.6",
820
+ "@trigger.dev/core": "workspace:^3.0.0-beta.7",
821
821
  "@types/degit": "^2.8.3",
822
822
  chalk: "^5.2.0",
823
823
  chokidar: "^3.5.3",
@@ -834,7 +834,6 @@ var dependencies = {
834
834
  "import-meta-resolve": "^4.0.0",
835
835
  ink: "^4.4.1",
836
836
  "jsonc-parser": "^3.2.1",
837
- jsonlines: "^0.1.1",
838
837
  liquidjs: "^10.9.2",
839
838
  "mock-fs": "^5.2.0",
840
839
  nanoid: "^4.0.2",
@@ -900,7 +899,6 @@ var package_default = {
900
899
  "@trigger.dev/core-apps": "workspace:*",
901
900
  "@trigger.dev/tsconfig": "workspace:*",
902
901
  "@types/gradient-string": "^1.1.2",
903
- "@types/jsonlines": "^0.1.5",
904
902
  "@types/mock-fs": "^4.13.1",
905
903
  "@types/node": "18",
906
904
  "@types/object-hash": "^3.0.6",
@@ -2524,6 +2522,29 @@ async function login(options) {
2524
2522
  if (!opts.embedded) {
2525
2523
  intro2("Logging in to Trigger.dev");
2526
2524
  }
2525
+ const accessTokenFromEnv = process.env.TRIGGER_ACCESS_TOKEN;
2526
+ if (accessTokenFromEnv) {
2527
+ const auth = {
2528
+ accessToken: accessTokenFromEnv,
2529
+ apiUrl: process.env.TRIGGER_API_URL ?? "https://api.trigger.dev"
2530
+ };
2531
+ const apiClient3 = new CliApiClient(auth.apiUrl, auth.accessToken);
2532
+ const userData = await apiClient3.whoAmI();
2533
+ if (!userData.success) {
2534
+ throw new Error(userData.error);
2535
+ }
2536
+ return {
2537
+ ok: true,
2538
+ profile: options?.profile ?? "default",
2539
+ userId: userData.data.userId,
2540
+ email: userData.data.email,
2541
+ dashboardUrl: userData.data.dashboardUrl,
2542
+ auth: {
2543
+ accessToken: auth.accessToken,
2544
+ apiUrl: auth.apiUrl
2545
+ }
2546
+ };
2547
+ }
2527
2548
  const authConfig = readAuthConfigProfile(options?.profile);
2528
2549
  if (authConfig && authConfig.accessToken) {
2529
2550
  const whoAmIResult = await whoAmI(
@@ -2939,7 +2960,6 @@ function parseBuildErrorStack(error) {
2939
2960
  return error.message;
2940
2961
  }
2941
2962
  }
2942
- return "Unknown error";
2943
2963
  }
2944
2964
  function logESMRequireError(parsedError, resolvedConfig) {
2945
2965
  logger.log(
@@ -3053,6 +3073,203 @@ function safeJsonParse(json) {
3053
3073
  }
3054
3074
  }
3055
3075
 
3076
+ // src/utilities/javascriptProject.ts
3077
+ import { $ } from "execa";
3078
+ import { join as join4 } from "node:path";
3079
+
3080
+ // src/utilities/getUserPackageManager.ts
3081
+ import { findUp as findUp2 } from "find-up";
3082
+ async function getUserPackageManager(path6) {
3083
+ try {
3084
+ return await detectPackageManagerFromArtifacts(path6);
3085
+ } catch (error) {
3086
+ return detectPackageManagerFromCurrentCommand();
3087
+ }
3088
+ }
3089
+ function detectPackageManagerFromCurrentCommand() {
3090
+ const userAgent = process.env.npm_config_user_agent;
3091
+ if (userAgent) {
3092
+ if (userAgent.startsWith("yarn")) {
3093
+ return "yarn";
3094
+ } else if (userAgent.startsWith("pnpm")) {
3095
+ return "pnpm";
3096
+ } else {
3097
+ return "npm";
3098
+ }
3099
+ } else {
3100
+ return "npm";
3101
+ }
3102
+ }
3103
+ async function detectPackageManagerFromArtifacts(path6) {
3104
+ const packageFiles = [
3105
+ { name: "yarn.lock", pm: "yarn" },
3106
+ { name: "pnpm-lock.yaml", pm: "pnpm" },
3107
+ { name: "package-lock.json", pm: "npm" },
3108
+ { name: "npm-shrinkwrap.json", pm: "npm" }
3109
+ ];
3110
+ for (const { name, pm } of packageFiles) {
3111
+ const foundPath = await findUp2(name, { cwd: path6 });
3112
+ if (typeof foundPath === "string") {
3113
+ return pm;
3114
+ }
3115
+ }
3116
+ throw new Error("Could not detect package manager from artifacts");
3117
+ }
3118
+
3119
+ // src/utilities/javascriptProject.ts
3120
+ var BuiltInModules = /* @__PURE__ */ new Set([
3121
+ "assert",
3122
+ "async_hooks",
3123
+ "buffer",
3124
+ "child_process",
3125
+ "cluster",
3126
+ "console",
3127
+ "constants",
3128
+ "crypto",
3129
+ "dgram",
3130
+ "dns",
3131
+ "domain",
3132
+ "events",
3133
+ "fs",
3134
+ "http",
3135
+ "http2",
3136
+ "https",
3137
+ "inspector",
3138
+ "module",
3139
+ "net",
3140
+ "os",
3141
+ "path",
3142
+ "perf_hooks",
3143
+ "process",
3144
+ "punycode",
3145
+ "querystring",
3146
+ "readline",
3147
+ "repl",
3148
+ "stream",
3149
+ "string_decoder",
3150
+ "timers",
3151
+ "tls",
3152
+ "trace_events",
3153
+ "tty",
3154
+ "url",
3155
+ "util",
3156
+ "v8",
3157
+ "vm",
3158
+ "worker_threads",
3159
+ "zlib"
3160
+ ]);
3161
+ var JavascriptProject = class {
3162
+ constructor(projectPath) {
3163
+ this.projectPath = projectPath;
3164
+ }
3165
+ _packageJson;
3166
+ _packageManager;
3167
+ get packageJson() {
3168
+ if (!this._packageJson) {
3169
+ this._packageJson = readJSONFileSync(join4(this.projectPath, "package.json"));
3170
+ }
3171
+ return this._packageJson;
3172
+ }
3173
+ get scripts() {
3174
+ return {
3175
+ postinstall: this.packageJson.scripts?.postinstall
3176
+ };
3177
+ }
3178
+ async resolve(packageName, options) {
3179
+ if (BuiltInModules.has(packageName)) {
3180
+ return void 0;
3181
+ }
3182
+ if (!this._packageManager) {
3183
+ this._packageManager = await getUserPackageManager(this.projectPath);
3184
+ }
3185
+ const packageManager = this._packageManager;
3186
+ const opts = { allowDev: false, ...options };
3187
+ const packageJsonVersion = this.packageJson.dependencies?.[packageName];
3188
+ if (typeof packageJsonVersion === "string") {
3189
+ return packageJsonVersion;
3190
+ }
3191
+ if (opts.allowDev) {
3192
+ const devPackageJsonVersion = this.packageJson.devDependencies?.[packageName];
3193
+ if (typeof devPackageJsonVersion === "string") {
3194
+ return devPackageJsonVersion;
3195
+ }
3196
+ }
3197
+ const command = packageManager === "npm" ? new NPMCommands() : packageManager === "pnpm" ? new PNPMCommands() : new YarnCommands();
3198
+ try {
3199
+ const version2 = await command.resolveDependencyVersion(packageName, {
3200
+ cwd: this.projectPath
3201
+ });
3202
+ if (version2) {
3203
+ return version2;
3204
+ }
3205
+ } catch (error) {
3206
+ logger.debug(`Failed to resolve dependency version using ${command.name}`, {
3207
+ packageName,
3208
+ error
3209
+ });
3210
+ }
3211
+ }
3212
+ };
3213
+ var PNPMCommands = class {
3214
+ get name() {
3215
+ return "pnpm";
3216
+ }
3217
+ async resolveDependencyVersion(packageName, options) {
3218
+ const cmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
3219
+ const { stdout } = await $({ cwd: options.cwd })`${cmd} list ${packageName} -r --json`;
3220
+ const result = JSON.parse(stdout);
3221
+ logger.debug(`Resolving ${packageName} version using pnpm`, { result });
3222
+ for (const dep of result) {
3223
+ const dependency = dep.dependencies?.[packageName];
3224
+ if (dependency) {
3225
+ return dependency.version;
3226
+ }
3227
+ }
3228
+ }
3229
+ };
3230
+ var NPMCommands = class {
3231
+ get name() {
3232
+ return "npm";
3233
+ }
3234
+ async resolveDependencyVersion(packageName, options) {
3235
+ const cmd = process.platform === "win32" ? "npm.cmd" : "npm";
3236
+ const { stdout } = await $({ cwd: options.cwd })`${cmd} list ${packageName} --json`;
3237
+ const output = JSON.parse(stdout);
3238
+ logger.debug(`Resolving ${packageName} version using npm`, { output });
3239
+ return this.#recursivelySearchDependencies(output.dependencies, packageName);
3240
+ }
3241
+ #recursivelySearchDependencies(dependencies2, packageName) {
3242
+ for (const [name, dependency] of Object.entries(dependencies2)) {
3243
+ if (name === packageName) {
3244
+ return dependency.version;
3245
+ }
3246
+ if (dependency.dependencies) {
3247
+ const result = this.#recursivelySearchDependencies(dependency.dependencies, packageName);
3248
+ if (result) {
3249
+ return result;
3250
+ }
3251
+ }
3252
+ }
3253
+ }
3254
+ };
3255
+ var YarnCommands = class {
3256
+ get name() {
3257
+ return "yarn";
3258
+ }
3259
+ async resolveDependencyVersion(packageName, options) {
3260
+ const cmd = process.platform === "win32" ? "yarn.cmd" : "yarn";
3261
+ const { stdout } = await $({ cwd: options.cwd })`${cmd} info ${packageName} --json`;
3262
+ const lines = stdout.split("\n");
3263
+ logger.debug(`Resolving ${packageName} version using yarn`, { lines });
3264
+ for (const line of lines) {
3265
+ const json = JSON.parse(line);
3266
+ if (json.value === packageName) {
3267
+ return json.children.Version;
3268
+ }
3269
+ }
3270
+ }
3271
+ };
3272
+
3056
3273
  // src/commands/deploy.ts
3057
3274
  var DeployCommandOptions = CommonCommandOptions.extend({
3058
3275
  skipTypecheck: z4.boolean().default(false),
@@ -3251,7 +3468,7 @@ async function _deployCommand(dir, options) {
3251
3468
  if (!image.ok) {
3252
3469
  deploymentSpinner.stop(`Failed to build project.`);
3253
3470
  if (image.logs.trim() !== "") {
3254
- const logPath = join4(await createTempDir(), `build-${deploymentResponse.data.shortCode}.log`);
3471
+ const logPath = join5(await createTempDir(), `build-${deploymentResponse.data.shortCode}.log`);
3255
3472
  await writeFile2(logPath, image.logs);
3256
3473
  logger.log(
3257
3474
  `${chalkError("X Error:")} ${image.error}. Full build logs have been saved to ${logPath})`
@@ -3331,7 +3548,7 @@ async function _deployCommand(dir, options) {
3331
3548
  }
3332
3549
  }
3333
3550
  }
3334
- const parsedError = finishedDeployment.errorData.stack ? parseBuildErrorStack(finishedDeployment.errorData) : finishedDeployment.errorData.message;
3551
+ const parsedError = finishedDeployment.errorData.stack ? parseBuildErrorStack(finishedDeployment.errorData) ?? finishedDeployment.errorData.message : finishedDeployment.errorData.message;
3335
3552
  if (typeof parsedError === "string") {
3336
3553
  deploymentSpinner.stop(`Deployment encountered an error. ${deploymentLink}`);
3337
3554
  logger.log(`${chalkError("X Error:")} ${parsedError}`);
@@ -3740,7 +3957,7 @@ async function compileProject(config, options, configPath) {
3740
3957
  throw new Error("Build failed, aborting deployment");
3741
3958
  }
3742
3959
  if (options.outputMetafile) {
3743
- await writeJSONFile(join4(options.outputMetafile, "worker.json"), result.metafile);
3960
+ await writeJSONFile(join5(options.outputMetafile, "worker.json"), result.metafile);
3744
3961
  }
3745
3962
  const entryPointContents = readFileSync2(
3746
3963
  new URL(importResolve("./workers/prod/entry-point.js", import.meta.url)).href.replace(
@@ -3789,56 +4006,52 @@ async function compileProject(config, options, configPath) {
3789
4006
  }
3790
4007
  if (options.outputMetafile) {
3791
4008
  await writeJSONFile(
3792
- join4(options.outputMetafile, "entry-point.json"),
4009
+ join5(options.outputMetafile, "entry-point.json"),
3793
4010
  entryPointResult.metafile
3794
4011
  );
3795
4012
  }
3796
4013
  const tempDir = await createTempDir();
3797
4014
  logger.debug(`Writing compiled files to ${tempDir}`);
3798
- const metaOutput = result.metafile.outputs[join4("out", "stdin.js")];
4015
+ const metaOutput = result.metafile.outputs[join5("out", "stdin.js")];
3799
4016
  invariant(metaOutput, "Meta output for the result build is missing");
3800
- const entryPointMetaOutput = entryPointResult.metafile.outputs[join4("out", "stdin.js")];
4017
+ const entryPointMetaOutput = entryPointResult.metafile.outputs[join5("out", "stdin.js")];
3801
4018
  invariant(entryPointMetaOutput, "Meta output for the entryPoint build is missing");
3802
4019
  const workerOutputFile = result.outputFiles.find(
3803
- (file) => file.path === join4(config.projectDir, "out", "stdin.js")
4020
+ (file) => file.path === join5(config.projectDir, "out", "stdin.js")
3804
4021
  );
3805
4022
  invariant(workerOutputFile, "Output file for the result build is missing");
3806
4023
  const workerSourcemapFile = result.outputFiles.find(
3807
- (file) => file.path === join4(config.projectDir, "out", "stdin.js.map")
4024
+ (file) => file.path === join5(config.projectDir, "out", "stdin.js.map")
3808
4025
  );
3809
4026
  invariant(workerSourcemapFile, "Sourcemap file for the result build is missing");
3810
4027
  const entryPointOutputFile = entryPointResult.outputFiles.find(
3811
- (file) => file.path === join4(config.projectDir, "out", "stdin.js")
4028
+ (file) => file.path === join5(config.projectDir, "out", "stdin.js")
3812
4029
  );
3813
4030
  invariant(entryPointOutputFile, "Output file for the entryPoint build is missing");
3814
4031
  await writeFile2(
3815
- join4(tempDir, "worker.js"),
4032
+ join5(tempDir, "worker.js"),
3816
4033
  `${workerOutputFile.text}
3817
4034
  //# sourceMappingURL=worker.js.map`
3818
4035
  );
3819
- await writeFile2(join4(tempDir, "worker.js.map"), workerSourcemapFile.text);
3820
- await writeFile2(join4(tempDir, "index.js"), entryPointOutputFile.text);
4036
+ await writeFile2(join5(tempDir, "worker.js.map"), workerSourcemapFile.text);
4037
+ await writeFile2(join5(tempDir, "index.js"), entryPointOutputFile.text);
3821
4038
  logger.debug("Getting the imports for the worker and entryPoint builds", {
3822
4039
  workerImports: metaOutput.imports,
3823
4040
  entryPointImports: entryPointMetaOutput.imports
3824
4041
  });
3825
4042
  const allImports = [...metaOutput.imports, ...entryPointMetaOutput.imports];
3826
- const externalPackageJson = await readJSONFile(join4(config.projectDir, "package.json"));
3827
- const dependencies2 = await gatherRequiredDependencies(
3828
- allImports,
3829
- config,
3830
- externalPackageJson
3831
- );
4043
+ const javascriptProject = new JavascriptProject(config.projectDir);
4044
+ const dependencies2 = await gatherRequiredDependencies(allImports, config, javascriptProject);
3832
4045
  const packageJsonContents = {
3833
4046
  name: "trigger-worker",
3834
4047
  version: "0.0.0",
3835
4048
  description: "",
3836
4049
  dependencies: dependencies2,
3837
4050
  scripts: {
3838
- postinstall: externalPackageJson?.scripts?.postinstall
4051
+ ...javascriptProject.scripts
3839
4052
  }
3840
4053
  };
3841
- await writeJSONFile(join4(tempDir, "package.json"), packageJsonContents);
4054
+ await writeJSONFile(join5(tempDir, "package.json"), packageJsonContents);
3842
4055
  await copyAdditionalFiles(config, tempDir);
3843
4056
  compileSpinner.stop("Project built successfully");
3844
4057
  const resolvingDependenciesResult = await resolveDependencies(
@@ -3853,7 +4066,7 @@ async function compileProject(config, options, configPath) {
3853
4066
  const containerFilePath = new URL(
3854
4067
  importResolve("./Containerfile.prod", import.meta.url)
3855
4068
  ).href.replace("file://", "");
3856
- await copyFile(containerFilePath, join4(tempDir, "Containerfile"));
4069
+ await copyFile(containerFilePath, join5(tempDir, "Containerfile"));
3857
4070
  const contentHasher = createHash("sha256");
3858
4071
  contentHasher.update(Buffer.from(entryPointOutputFile.text));
3859
4072
  contentHasher.update(Buffer.from(workerOutputFile.text));
@@ -3885,8 +4098,8 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
3885
4098
  const hasher = createHash("sha256");
3886
4099
  hasher.update(JSON.stringify(packageJsonContents));
3887
4100
  const digest = hasher.digest("hex").slice(0, 16);
3888
- const cacheDir = join4(config.projectDir, ".trigger", "cache");
3889
- const cachePath = join4(cacheDir, `${digest}.json`);
4101
+ const cacheDir = join5(config.projectDir, ".trigger", "cache");
4102
+ const cachePath = join5(cacheDir, `${digest}.json`);
3890
4103
  span.setAttributes({
3891
4104
  "packageJson.digest": digest,
3892
4105
  "cache.path": cachePath,
@@ -3895,7 +4108,7 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
3895
4108
  try {
3896
4109
  const cachedPackageLock = await readFile2(cachePath, "utf-8");
3897
4110
  logger.debug(`Using cached package-lock.json for ${digest}`);
3898
- await writeFile2(join4(projectDir, "package-lock.json"), cachedPackageLock);
4111
+ await writeFile2(join5(projectDir, "package-lock.json"), cachedPackageLock);
3899
4112
  span.setAttributes({
3900
4113
  "cache.hit": true
3901
4114
  });
@@ -3918,11 +4131,11 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
3918
4131
  cwd: projectDir,
3919
4132
  stdio: logger.loggerLevel === "debug" ? "inherit" : "pipe"
3920
4133
  });
3921
- const packageLockContents = await readFile2(join4(projectDir, "package-lock.json"), "utf-8");
4134
+ const packageLockContents = await readFile2(join5(projectDir, "package-lock.json"), "utf-8");
3922
4135
  logger.debug(`Writing package-lock.json to cache for ${digest}`);
3923
4136
  await mkdir(cacheDir, { recursive: true });
3924
4137
  await writeFile2(cachePath, packageLockContents);
3925
- await writeFile2(join4(projectDir, "package-lock.json"), packageLockContents);
4138
+ await writeFile2(join5(projectDir, "package-lock.json"), packageLockContents);
3926
4139
  span.end();
3927
4140
  resolvingDepsSpinner.stop("Dependencies resolved");
3928
4141
  return true;
@@ -3999,7 +4212,7 @@ async function typecheckProject(config, options) {
3999
4212
  }
4000
4213
  });
4001
4214
  }
4002
- async function gatherRequiredDependencies(imports, config, projectPackageJson) {
4215
+ async function gatherRequiredDependencies(imports, config, project) {
4003
4216
  const dependencies2 = {};
4004
4217
  for (const file of imports) {
4005
4218
  if (file.kind !== "require-call" && file.kind !== "dynamic-import" || !file.external) {
@@ -4009,7 +4222,7 @@ async function gatherRequiredDependencies(imports, config, projectPackageJson) {
4009
4222
  if (dependencies2[packageName]) {
4010
4223
  continue;
4011
4224
  }
4012
- const externalDependencyVersion = (projectPackageJson?.dependencies ?? {})[packageName];
4225
+ const externalDependencyVersion = await project.resolve(packageName);
4013
4226
  if (externalDependencyVersion) {
4014
4227
  dependencies2[packageName] = stripWorkspaceFromVersion(externalDependencyVersion);
4015
4228
  continue;
@@ -4029,10 +4242,9 @@ async function gatherRequiredDependencies(imports, config, projectPackageJson) {
4029
4242
  dependencies2[packageParts.name] = packageParts.version;
4030
4243
  continue;
4031
4244
  } else {
4032
- const externalDependencyVersion = {
4033
- ...projectPackageJson?.devDependencies,
4034
- ...projectPackageJson?.dependencies
4035
- }[packageName];
4245
+ const externalDependencyVersion = await project.resolve(packageParts.name, {
4246
+ allowDev: true
4247
+ });
4036
4248
  if (externalDependencyVersion) {
4037
4249
  dependencies2[packageParts.name] = externalDependencyVersion;
4038
4250
  continue;
@@ -4072,7 +4284,7 @@ async function copyAdditionalFiles(config, tempDir) {
4072
4284
  nodir: true
4073
4285
  });
4074
4286
  for await (const file of glob) {
4075
- const relativeDestinationPath = join4(
4287
+ const relativeDestinationPath = join5(
4076
4288
  tempDir,
4077
4289
  relative3(config.projectDir, file.fullpath())
4078
4290
  );
@@ -4091,7 +4303,7 @@ async function copyAdditionalFiles(config, tempDir) {
4091
4303
  }
4092
4304
  async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
4093
4305
  const tmpDir = await createTempDir();
4094
- const dockerConfigPath = join4(tmpDir, "config.json");
4306
+ const dockerConfigPath = join5(tmpDir, "config.json");
4095
4307
  await writeJSONFile(dockerConfigPath, {
4096
4308
  auths: {
4097
4309
  [registryHost]: {
@@ -4138,7 +4350,7 @@ import { resolve as importResolve2 } from "import-meta-resolve";
4138
4350
  import { render, useInput } from "ink";
4139
4351
  import { createHash as createHash2 } from "node:crypto";
4140
4352
  import fs7, { readFileSync as readFileSync3 } from "node:fs";
4141
- import { basename, dirname as dirname3, join as join5 } from "node:path";
4353
+ import { basename, dirname as dirname3, join as join6 } from "node:path";
4142
4354
  import pDebounce from "p-debounce";
4143
4355
  import { WebSocket } from "partysocket";
4144
4356
  import React, { Suspense, useEffect } from "react";
@@ -4763,7 +4975,7 @@ function runtimeCheck(minimumMajor, minimumMinor) {
4763
4975
  }
4764
4976
 
4765
4977
  // src/commands/dev.tsx
4766
- import { findUp as findUp2, pathExists as pathExists2 } from "find-up";
4978
+ import { findUp as findUp3, pathExists as pathExists2 } from "find-up";
4767
4979
  var apiClient;
4768
4980
  var DevCommandOptions = CommonCommandOptions.extend({
4769
4981
  debugger: z5.boolean().default(false),
@@ -4807,11 +5019,11 @@ async function devCommand(dir, options) {
4807
5019
  process.exitCode = 1;
4808
5020
  return;
4809
5021
  }
4810
- const devInstance = await startDev(dir, options, authorization.auth);
5022
+ const devInstance = await startDev(dir, options, authorization.auth, authorization.dashboardUrl);
4811
5023
  const { waitUntilExit } = devInstance.devReactElement;
4812
5024
  await waitUntilExit();
4813
5025
  }
4814
- async function startDev(dir, options, authorization) {
5026
+ async function startDev(dir, options, authorization, dashboardUrl) {
4815
5027
  let rerender;
4816
5028
  try {
4817
5029
  if (options.logLevel) {
@@ -4849,6 +5061,7 @@ async function startDev(dir, options, authorization) {
4849
5061
  return /* @__PURE__ */ React.createElement(
4850
5062
  DevUI,
4851
5063
  {
5064
+ dashboardUrl,
4852
5065
  config: configParam,
4853
5066
  apiUrl,
4854
5067
  apiKey: devEnv.data.apiKey,
@@ -4880,6 +5093,7 @@ async function startDev(dir, options, authorization) {
4880
5093
  }
4881
5094
  function useDev({
4882
5095
  config,
5096
+ dashboardUrl,
4883
5097
  apiUrl,
4884
5098
  apiKey,
4885
5099
  environmentClient,
@@ -4909,7 +5123,7 @@ function useDev({
4909
5123
  }
4910
5124
  });
4911
5125
  const backgroundWorkerCoordinator = new BackgroundWorkerCoordinator(
4912
- `${apiUrl}/projects/v3/${config.project}`
5126
+ `${dashboardUrl}/projects/v3/${config.project}`
4913
5127
  );
4914
5128
  websocket.addEventListener("open", async (event) => {
4915
5129
  });
@@ -5049,19 +5263,19 @@ function useDev({
5049
5263
  if (!firstBuild) {
5050
5264
  logger.log(chalkGrey("\u25CB Building background worker\u2026"));
5051
5265
  }
5052
- const metaOutputKey = join5("out", `stdin.js`);
5266
+ const metaOutputKey = join6("out", `stdin.js`);
5053
5267
  const metaOutput = result.metafile.outputs[metaOutputKey];
5054
5268
  if (!metaOutput) {
5055
5269
  throw new Error(`Could not find metafile`);
5056
5270
  }
5057
- const outputFileKey = join5(config.projectDir, metaOutputKey);
5271
+ const outputFileKey = join6(config.projectDir, metaOutputKey);
5058
5272
  const outputFile = result.outputFiles.find((file) => file.path === outputFileKey);
5059
5273
  if (!outputFile) {
5060
5274
  throw new Error(
5061
5275
  `Could not find output file for entry point ${metaOutput.entryPoint}`
5062
5276
  );
5063
5277
  }
5064
- const sourceMapFileKey = join5(config.projectDir, `${metaOutputKey}.map`);
5278
+ const sourceMapFileKey = join6(config.projectDir, `${metaOutputKey}.map`);
5065
5279
  const sourceMapFile = result.outputFiles.find(
5066
5280
  (file) => file.path === sourceMapFileKey
5067
5281
  );
@@ -5072,7 +5286,7 @@ function useDev({
5072
5286
  logger.log(chalkGrey("\u25CB No changes detected, skipping build\u2026"));
5073
5287
  return;
5074
5288
  }
5075
- const fullPath = join5(config.projectDir, ".trigger", `${contentHash}.js`);
5289
+ const fullPath = join6(config.projectDir, ".trigger", `${contentHash}.js`);
5076
5290
  const sourceMapPath = `${fullPath}.map`;
5077
5291
  const outputFileWithSourceMap = `${outputFile.text}
5078
5292
  //# sourceMappingURL=${basename(sourceMapPath)}`;
@@ -5158,7 +5372,7 @@ function useDev({
5158
5372
  return;
5159
5373
  } else if (e instanceof UncaughtExceptionError) {
5160
5374
  const parsedBuildError = parseBuildErrorStack(e.originalError);
5161
- if (typeof parsedBuildError !== "string") {
5375
+ if (parsedBuildError && typeof parsedBuildError !== "string") {
5162
5376
  logESMRequireError(
5163
5377
  parsedBuildError,
5164
5378
  configPath ? { status: "file", path: configPath, config } : { status: "in-memory", config }
@@ -5279,7 +5493,7 @@ async function gatherRequiredDependencies2(outputMeta, config) {
5279
5493
  }
5280
5494
  }
5281
5495
  if (config.additionalPackages) {
5282
- const projectPackageJson = await readJSONFile(join5(config.projectDir, "package.json"));
5496
+ const projectPackageJson = await readJSONFile(join6(config.projectDir, "package.json"));
5283
5497
  for (const packageName of config.additionalPackages) {
5284
5498
  if (dependencies2[packageName]) {
5285
5499
  continue;
@@ -5347,9 +5561,9 @@ async function amendNodePathWithPnpmNodeModules(nodePath) {
5347
5561
  return pnpmModulesPath;
5348
5562
  }
5349
5563
  async function findPnpmNodeModulesPath() {
5350
- return await findUp2(
5564
+ return await findUp3(
5351
5565
  async (directory) => {
5352
- const pnpmModules = join5(directory, "node_modules", ".pnpm", "node_modules");
5566
+ const pnpmModules = join6(directory, "node_modules", ".pnpm", "node_modules");
5353
5567
  const hasPnpmNodeModules = await pathExists2(pnpmModules);
5354
5568
  if (hasPnpmNodeModules) {
5355
5569
  return pnpmModules;
@@ -5370,7 +5584,7 @@ import chalk6 from "chalk";
5370
5584
  import { execa as execa3 } from "execa";
5371
5585
  import { applyEdits, modify } from "jsonc-parser";
5372
5586
  import { writeFile as writeFile3 } from "node:fs/promises";
5373
- import { join as join6, relative as relative4, resolve as resolve3 } from "node:path";
5587
+ import { join as join7, relative as relative4, resolve as resolve3 } from "node:path";
5374
5588
  import terminalLink3 from "terminal-link";
5375
5589
  import { z as z6 } from "zod";
5376
5590
 
@@ -5415,45 +5629,6 @@ function replaceAll(input, replacements) {
5415
5629
  return output;
5416
5630
  }
5417
5631
 
5418
- // src/utilities/getUserPackageManager.ts
5419
- import pathModule2 from "path";
5420
- async function getUserPackageManager(path6) {
5421
- try {
5422
- return await detectPackageManagerFromArtifacts(path6);
5423
- } catch (error) {
5424
- return detectPackageManagerFromCurrentCommand();
5425
- }
5426
- }
5427
- function detectPackageManagerFromCurrentCommand() {
5428
- const userAgent = process.env.npm_config_user_agent;
5429
- if (userAgent) {
5430
- if (userAgent.startsWith("yarn")) {
5431
- return "yarn";
5432
- } else if (userAgent.startsWith("pnpm")) {
5433
- return "pnpm";
5434
- } else {
5435
- return "npm";
5436
- }
5437
- } else {
5438
- return "npm";
5439
- }
5440
- }
5441
- async function detectPackageManagerFromArtifacts(path6) {
5442
- const packageFiles = [
5443
- { name: "yarn.lock", pm: "yarn" },
5444
- { name: "pnpm-lock.yaml", pm: "pnpm" },
5445
- { name: "package-lock.json", pm: "npm" },
5446
- { name: "npm-shrinkwrap.json", pm: "npm" }
5447
- ];
5448
- for (const { name, pm } of packageFiles) {
5449
- const exists = await pathExists(pathModule2.join(path6, name));
5450
- if (exists) {
5451
- return pm;
5452
- }
5453
- }
5454
- throw new Error("Could not detect package manager from artifacts");
5455
- }
5456
-
5457
5632
  // src/utilities/resolveInternalFilePath.ts
5458
5633
  import { resolve as importResolve3 } from "import-meta-resolve";
5459
5634
  function resolveInternalFilePath(filePath) {
@@ -5606,13 +5781,13 @@ async function createTriggerDir(dir, options) {
5606
5781
  "cli.example": example
5607
5782
  });
5608
5783
  if (example === "none") {
5609
- await createFile(join6(triggerDir, ".gitkeep"), "");
5784
+ await createFile(join7(triggerDir, ".gitkeep"), "");
5610
5785
  log3.step(`Created directory at ${location}`);
5611
5786
  span.end();
5612
5787
  return { location, isCustomValue: location !== defaultValue };
5613
5788
  }
5614
5789
  const exampleFile = resolveInternalFilePath(`./templates/examples/${example}.ts.template`);
5615
- const outputPath = join6(triggerDir, "example.ts");
5790
+ const outputPath = join7(triggerDir, "example.ts");
5616
5791
  await createFileFromTemplate({
5617
5792
  templatePath: exampleFile,
5618
5793
  outputPath,
@@ -5635,7 +5810,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
5635
5810
  return await tracer.startActiveSpan("gitIgnoreDotTriggerDir", async (span) => {
5636
5811
  try {
5637
5812
  const projectDir = resolve3(process.cwd(), dir);
5638
- const gitIgnorePath = join6(projectDir, ".gitignore");
5813
+ const gitIgnorePath = join7(projectDir, ".gitignore");
5639
5814
  span.setAttributes({
5640
5815
  "cli.projectDir": projectDir,
5641
5816
  "cli.gitIgnorePath": gitIgnorePath
@@ -5669,7 +5844,7 @@ async function addConfigFileToTsConfig(dir, options) {
5669
5844
  return await tracer.startActiveSpan("createTriggerDir", async (span) => {
5670
5845
  try {
5671
5846
  const projectDir = resolve3(process.cwd(), dir);
5672
- const tsconfigPath = join6(projectDir, "tsconfig.json");
5847
+ const tsconfigPath = join7(projectDir, "tsconfig.json");
5673
5848
  span.setAttributes({
5674
5849
  "cli.projectDir": projectDir,
5675
5850
  "cli.tsconfigPath": tsconfigPath
@@ -5756,7 +5931,7 @@ async function writeConfigFile(dir, project, options, triggerDir) {
5756
5931
  spnnr.start("Creating config file");
5757
5932
  const projectDir = resolve3(process.cwd(), dir);
5758
5933
  const templatePath = resolveInternalFilePath("./templates/trigger.config.ts.template");
5759
- const outputPath = join6(projectDir, "trigger.config.ts");
5934
+ const outputPath = join7(projectDir, "trigger.config.ts");
5760
5935
  span.setAttributes({
5761
5936
  "cli.projectDir": projectDir,
5762
5937
  "cli.templatePath": templatePath,