trigger.dev 3.0.0-beta.8 → 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.8";
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",
@@ -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",
@@ -2962,7 +2960,6 @@ function parseBuildErrorStack(error) {
2962
2960
  return error.message;
2963
2961
  }
2964
2962
  }
2965
- return "Unknown error";
2966
2963
  }
2967
2964
  function logESMRequireError(parsedError, resolvedConfig) {
2968
2965
  logger.log(
@@ -3076,6 +3073,203 @@ function safeJsonParse(json) {
3076
3073
  }
3077
3074
  }
3078
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
+
3079
3273
  // src/commands/deploy.ts
3080
3274
  var DeployCommandOptions = CommonCommandOptions.extend({
3081
3275
  skipTypecheck: z4.boolean().default(false),
@@ -3274,7 +3468,7 @@ async function _deployCommand(dir, options) {
3274
3468
  if (!image.ok) {
3275
3469
  deploymentSpinner.stop(`Failed to build project.`);
3276
3470
  if (image.logs.trim() !== "") {
3277
- const logPath = join4(await createTempDir(), `build-${deploymentResponse.data.shortCode}.log`);
3471
+ const logPath = join5(await createTempDir(), `build-${deploymentResponse.data.shortCode}.log`);
3278
3472
  await writeFile2(logPath, image.logs);
3279
3473
  logger.log(
3280
3474
  `${chalkError("X Error:")} ${image.error}. Full build logs have been saved to ${logPath})`
@@ -3354,7 +3548,7 @@ async function _deployCommand(dir, options) {
3354
3548
  }
3355
3549
  }
3356
3550
  }
3357
- 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;
3358
3552
  if (typeof parsedError === "string") {
3359
3553
  deploymentSpinner.stop(`Deployment encountered an error. ${deploymentLink}`);
3360
3554
  logger.log(`${chalkError("X Error:")} ${parsedError}`);
@@ -3763,7 +3957,7 @@ async function compileProject(config, options, configPath) {
3763
3957
  throw new Error("Build failed, aborting deployment");
3764
3958
  }
3765
3959
  if (options.outputMetafile) {
3766
- await writeJSONFile(join4(options.outputMetafile, "worker.json"), result.metafile);
3960
+ await writeJSONFile(join5(options.outputMetafile, "worker.json"), result.metafile);
3767
3961
  }
3768
3962
  const entryPointContents = readFileSync2(
3769
3963
  new URL(importResolve("./workers/prod/entry-point.js", import.meta.url)).href.replace(
@@ -3812,56 +4006,52 @@ async function compileProject(config, options, configPath) {
3812
4006
  }
3813
4007
  if (options.outputMetafile) {
3814
4008
  await writeJSONFile(
3815
- join4(options.outputMetafile, "entry-point.json"),
4009
+ join5(options.outputMetafile, "entry-point.json"),
3816
4010
  entryPointResult.metafile
3817
4011
  );
3818
4012
  }
3819
4013
  const tempDir = await createTempDir();
3820
4014
  logger.debug(`Writing compiled files to ${tempDir}`);
3821
- const metaOutput = result.metafile.outputs[join4("out", "stdin.js")];
4015
+ const metaOutput = result.metafile.outputs[join5("out", "stdin.js")];
3822
4016
  invariant(metaOutput, "Meta output for the result build is missing");
3823
- const entryPointMetaOutput = entryPointResult.metafile.outputs[join4("out", "stdin.js")];
4017
+ const entryPointMetaOutput = entryPointResult.metafile.outputs[join5("out", "stdin.js")];
3824
4018
  invariant(entryPointMetaOutput, "Meta output for the entryPoint build is missing");
3825
4019
  const workerOutputFile = result.outputFiles.find(
3826
- (file) => file.path === join4(config.projectDir, "out", "stdin.js")
4020
+ (file) => file.path === join5(config.projectDir, "out", "stdin.js")
3827
4021
  );
3828
4022
  invariant(workerOutputFile, "Output file for the result build is missing");
3829
4023
  const workerSourcemapFile = result.outputFiles.find(
3830
- (file) => file.path === join4(config.projectDir, "out", "stdin.js.map")
4024
+ (file) => file.path === join5(config.projectDir, "out", "stdin.js.map")
3831
4025
  );
3832
4026
  invariant(workerSourcemapFile, "Sourcemap file for the result build is missing");
3833
4027
  const entryPointOutputFile = entryPointResult.outputFiles.find(
3834
- (file) => file.path === join4(config.projectDir, "out", "stdin.js")
4028
+ (file) => file.path === join5(config.projectDir, "out", "stdin.js")
3835
4029
  );
3836
4030
  invariant(entryPointOutputFile, "Output file for the entryPoint build is missing");
3837
4031
  await writeFile2(
3838
- join4(tempDir, "worker.js"),
4032
+ join5(tempDir, "worker.js"),
3839
4033
  `${workerOutputFile.text}
3840
4034
  //# sourceMappingURL=worker.js.map`
3841
4035
  );
3842
- await writeFile2(join4(tempDir, "worker.js.map"), workerSourcemapFile.text);
3843
- 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);
3844
4038
  logger.debug("Getting the imports for the worker and entryPoint builds", {
3845
4039
  workerImports: metaOutput.imports,
3846
4040
  entryPointImports: entryPointMetaOutput.imports
3847
4041
  });
3848
4042
  const allImports = [...metaOutput.imports, ...entryPointMetaOutput.imports];
3849
- const externalPackageJson = await readJSONFile(join4(config.projectDir, "package.json"));
3850
- const dependencies2 = await gatherRequiredDependencies(
3851
- allImports,
3852
- config,
3853
- externalPackageJson
3854
- );
4043
+ const javascriptProject = new JavascriptProject(config.projectDir);
4044
+ const dependencies2 = await gatherRequiredDependencies(allImports, config, javascriptProject);
3855
4045
  const packageJsonContents = {
3856
4046
  name: "trigger-worker",
3857
4047
  version: "0.0.0",
3858
4048
  description: "",
3859
4049
  dependencies: dependencies2,
3860
4050
  scripts: {
3861
- postinstall: externalPackageJson?.scripts?.postinstall
4051
+ ...javascriptProject.scripts
3862
4052
  }
3863
4053
  };
3864
- await writeJSONFile(join4(tempDir, "package.json"), packageJsonContents);
4054
+ await writeJSONFile(join5(tempDir, "package.json"), packageJsonContents);
3865
4055
  await copyAdditionalFiles(config, tempDir);
3866
4056
  compileSpinner.stop("Project built successfully");
3867
4057
  const resolvingDependenciesResult = await resolveDependencies(
@@ -3876,7 +4066,7 @@ async function compileProject(config, options, configPath) {
3876
4066
  const containerFilePath = new URL(
3877
4067
  importResolve("./Containerfile.prod", import.meta.url)
3878
4068
  ).href.replace("file://", "");
3879
- await copyFile(containerFilePath, join4(tempDir, "Containerfile"));
4069
+ await copyFile(containerFilePath, join5(tempDir, "Containerfile"));
3880
4070
  const contentHasher = createHash("sha256");
3881
4071
  contentHasher.update(Buffer.from(entryPointOutputFile.text));
3882
4072
  contentHasher.update(Buffer.from(workerOutputFile.text));
@@ -3908,8 +4098,8 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
3908
4098
  const hasher = createHash("sha256");
3909
4099
  hasher.update(JSON.stringify(packageJsonContents));
3910
4100
  const digest = hasher.digest("hex").slice(0, 16);
3911
- const cacheDir = join4(config.projectDir, ".trigger", "cache");
3912
- const cachePath = join4(cacheDir, `${digest}.json`);
4101
+ const cacheDir = join5(config.projectDir, ".trigger", "cache");
4102
+ const cachePath = join5(cacheDir, `${digest}.json`);
3913
4103
  span.setAttributes({
3914
4104
  "packageJson.digest": digest,
3915
4105
  "cache.path": cachePath,
@@ -3918,7 +4108,7 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
3918
4108
  try {
3919
4109
  const cachedPackageLock = await readFile2(cachePath, "utf-8");
3920
4110
  logger.debug(`Using cached package-lock.json for ${digest}`);
3921
- await writeFile2(join4(projectDir, "package-lock.json"), cachedPackageLock);
4111
+ await writeFile2(join5(projectDir, "package-lock.json"), cachedPackageLock);
3922
4112
  span.setAttributes({
3923
4113
  "cache.hit": true
3924
4114
  });
@@ -3941,11 +4131,11 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
3941
4131
  cwd: projectDir,
3942
4132
  stdio: logger.loggerLevel === "debug" ? "inherit" : "pipe"
3943
4133
  });
3944
- const packageLockContents = await readFile2(join4(projectDir, "package-lock.json"), "utf-8");
4134
+ const packageLockContents = await readFile2(join5(projectDir, "package-lock.json"), "utf-8");
3945
4135
  logger.debug(`Writing package-lock.json to cache for ${digest}`);
3946
4136
  await mkdir(cacheDir, { recursive: true });
3947
4137
  await writeFile2(cachePath, packageLockContents);
3948
- await writeFile2(join4(projectDir, "package-lock.json"), packageLockContents);
4138
+ await writeFile2(join5(projectDir, "package-lock.json"), packageLockContents);
3949
4139
  span.end();
3950
4140
  resolvingDepsSpinner.stop("Dependencies resolved");
3951
4141
  return true;
@@ -4022,7 +4212,7 @@ async function typecheckProject(config, options) {
4022
4212
  }
4023
4213
  });
4024
4214
  }
4025
- async function gatherRequiredDependencies(imports, config, projectPackageJson) {
4215
+ async function gatherRequiredDependencies(imports, config, project) {
4026
4216
  const dependencies2 = {};
4027
4217
  for (const file of imports) {
4028
4218
  if (file.kind !== "require-call" && file.kind !== "dynamic-import" || !file.external) {
@@ -4032,7 +4222,7 @@ async function gatherRequiredDependencies(imports, config, projectPackageJson) {
4032
4222
  if (dependencies2[packageName]) {
4033
4223
  continue;
4034
4224
  }
4035
- const externalDependencyVersion = (projectPackageJson?.dependencies ?? {})[packageName];
4225
+ const externalDependencyVersion = await project.resolve(packageName);
4036
4226
  if (externalDependencyVersion) {
4037
4227
  dependencies2[packageName] = stripWorkspaceFromVersion(externalDependencyVersion);
4038
4228
  continue;
@@ -4052,10 +4242,9 @@ async function gatherRequiredDependencies(imports, config, projectPackageJson) {
4052
4242
  dependencies2[packageParts.name] = packageParts.version;
4053
4243
  continue;
4054
4244
  } else {
4055
- const externalDependencyVersion = {
4056
- ...projectPackageJson?.devDependencies,
4057
- ...projectPackageJson?.dependencies
4058
- }[packageName];
4245
+ const externalDependencyVersion = await project.resolve(packageParts.name, {
4246
+ allowDev: true
4247
+ });
4059
4248
  if (externalDependencyVersion) {
4060
4249
  dependencies2[packageParts.name] = externalDependencyVersion;
4061
4250
  continue;
@@ -4095,7 +4284,7 @@ async function copyAdditionalFiles(config, tempDir) {
4095
4284
  nodir: true
4096
4285
  });
4097
4286
  for await (const file of glob) {
4098
- const relativeDestinationPath = join4(
4287
+ const relativeDestinationPath = join5(
4099
4288
  tempDir,
4100
4289
  relative3(config.projectDir, file.fullpath())
4101
4290
  );
@@ -4114,7 +4303,7 @@ async function copyAdditionalFiles(config, tempDir) {
4114
4303
  }
4115
4304
  async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
4116
4305
  const tmpDir = await createTempDir();
4117
- const dockerConfigPath = join4(tmpDir, "config.json");
4306
+ const dockerConfigPath = join5(tmpDir, "config.json");
4118
4307
  await writeJSONFile(dockerConfigPath, {
4119
4308
  auths: {
4120
4309
  [registryHost]: {
@@ -4161,7 +4350,7 @@ import { resolve as importResolve2 } from "import-meta-resolve";
4161
4350
  import { render, useInput } from "ink";
4162
4351
  import { createHash as createHash2 } from "node:crypto";
4163
4352
  import fs7, { readFileSync as readFileSync3 } from "node:fs";
4164
- import { basename, dirname as dirname3, join as join5 } from "node:path";
4353
+ import { basename, dirname as dirname3, join as join6 } from "node:path";
4165
4354
  import pDebounce from "p-debounce";
4166
4355
  import { WebSocket } from "partysocket";
4167
4356
  import React, { Suspense, useEffect } from "react";
@@ -4786,7 +4975,7 @@ function runtimeCheck(minimumMajor, minimumMinor) {
4786
4975
  }
4787
4976
 
4788
4977
  // src/commands/dev.tsx
4789
- import { findUp as findUp2, pathExists as pathExists2 } from "find-up";
4978
+ import { findUp as findUp3, pathExists as pathExists2 } from "find-up";
4790
4979
  var apiClient;
4791
4980
  var DevCommandOptions = CommonCommandOptions.extend({
4792
4981
  debugger: z5.boolean().default(false),
@@ -4830,11 +5019,11 @@ async function devCommand(dir, options) {
4830
5019
  process.exitCode = 1;
4831
5020
  return;
4832
5021
  }
4833
- const devInstance = await startDev(dir, options, authorization.auth);
5022
+ const devInstance = await startDev(dir, options, authorization.auth, authorization.dashboardUrl);
4834
5023
  const { waitUntilExit } = devInstance.devReactElement;
4835
5024
  await waitUntilExit();
4836
5025
  }
4837
- async function startDev(dir, options, authorization) {
5026
+ async function startDev(dir, options, authorization, dashboardUrl) {
4838
5027
  let rerender;
4839
5028
  try {
4840
5029
  if (options.logLevel) {
@@ -4872,6 +5061,7 @@ async function startDev(dir, options, authorization) {
4872
5061
  return /* @__PURE__ */ React.createElement(
4873
5062
  DevUI,
4874
5063
  {
5064
+ dashboardUrl,
4875
5065
  config: configParam,
4876
5066
  apiUrl,
4877
5067
  apiKey: devEnv.data.apiKey,
@@ -4903,6 +5093,7 @@ async function startDev(dir, options, authorization) {
4903
5093
  }
4904
5094
  function useDev({
4905
5095
  config,
5096
+ dashboardUrl,
4906
5097
  apiUrl,
4907
5098
  apiKey,
4908
5099
  environmentClient,
@@ -4932,7 +5123,7 @@ function useDev({
4932
5123
  }
4933
5124
  });
4934
5125
  const backgroundWorkerCoordinator = new BackgroundWorkerCoordinator(
4935
- `${apiUrl}/projects/v3/${config.project}`
5126
+ `${dashboardUrl}/projects/v3/${config.project}`
4936
5127
  );
4937
5128
  websocket.addEventListener("open", async (event) => {
4938
5129
  });
@@ -5072,19 +5263,19 @@ function useDev({
5072
5263
  if (!firstBuild) {
5073
5264
  logger.log(chalkGrey("\u25CB Building background worker\u2026"));
5074
5265
  }
5075
- const metaOutputKey = join5("out", `stdin.js`);
5266
+ const metaOutputKey = join6("out", `stdin.js`);
5076
5267
  const metaOutput = result.metafile.outputs[metaOutputKey];
5077
5268
  if (!metaOutput) {
5078
5269
  throw new Error(`Could not find metafile`);
5079
5270
  }
5080
- const outputFileKey = join5(config.projectDir, metaOutputKey);
5271
+ const outputFileKey = join6(config.projectDir, metaOutputKey);
5081
5272
  const outputFile = result.outputFiles.find((file) => file.path === outputFileKey);
5082
5273
  if (!outputFile) {
5083
5274
  throw new Error(
5084
5275
  `Could not find output file for entry point ${metaOutput.entryPoint}`
5085
5276
  );
5086
5277
  }
5087
- const sourceMapFileKey = join5(config.projectDir, `${metaOutputKey}.map`);
5278
+ const sourceMapFileKey = join6(config.projectDir, `${metaOutputKey}.map`);
5088
5279
  const sourceMapFile = result.outputFiles.find(
5089
5280
  (file) => file.path === sourceMapFileKey
5090
5281
  );
@@ -5095,7 +5286,7 @@ function useDev({
5095
5286
  logger.log(chalkGrey("\u25CB No changes detected, skipping build\u2026"));
5096
5287
  return;
5097
5288
  }
5098
- const fullPath = join5(config.projectDir, ".trigger", `${contentHash}.js`);
5289
+ const fullPath = join6(config.projectDir, ".trigger", `${contentHash}.js`);
5099
5290
  const sourceMapPath = `${fullPath}.map`;
5100
5291
  const outputFileWithSourceMap = `${outputFile.text}
5101
5292
  //# sourceMappingURL=${basename(sourceMapPath)}`;
@@ -5181,7 +5372,7 @@ function useDev({
5181
5372
  return;
5182
5373
  } else if (e instanceof UncaughtExceptionError) {
5183
5374
  const parsedBuildError = parseBuildErrorStack(e.originalError);
5184
- if (typeof parsedBuildError !== "string") {
5375
+ if (parsedBuildError && typeof parsedBuildError !== "string") {
5185
5376
  logESMRequireError(
5186
5377
  parsedBuildError,
5187
5378
  configPath ? { status: "file", path: configPath, config } : { status: "in-memory", config }
@@ -5302,7 +5493,7 @@ async function gatherRequiredDependencies2(outputMeta, config) {
5302
5493
  }
5303
5494
  }
5304
5495
  if (config.additionalPackages) {
5305
- const projectPackageJson = await readJSONFile(join5(config.projectDir, "package.json"));
5496
+ const projectPackageJson = await readJSONFile(join6(config.projectDir, "package.json"));
5306
5497
  for (const packageName of config.additionalPackages) {
5307
5498
  if (dependencies2[packageName]) {
5308
5499
  continue;
@@ -5370,9 +5561,9 @@ async function amendNodePathWithPnpmNodeModules(nodePath) {
5370
5561
  return pnpmModulesPath;
5371
5562
  }
5372
5563
  async function findPnpmNodeModulesPath() {
5373
- return await findUp2(
5564
+ return await findUp3(
5374
5565
  async (directory) => {
5375
- const pnpmModules = join5(directory, "node_modules", ".pnpm", "node_modules");
5566
+ const pnpmModules = join6(directory, "node_modules", ".pnpm", "node_modules");
5376
5567
  const hasPnpmNodeModules = await pathExists2(pnpmModules);
5377
5568
  if (hasPnpmNodeModules) {
5378
5569
  return pnpmModules;
@@ -5393,7 +5584,7 @@ import chalk6 from "chalk";
5393
5584
  import { execa as execa3 } from "execa";
5394
5585
  import { applyEdits, modify } from "jsonc-parser";
5395
5586
  import { writeFile as writeFile3 } from "node:fs/promises";
5396
- 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";
5397
5588
  import terminalLink3 from "terminal-link";
5398
5589
  import { z as z6 } from "zod";
5399
5590
 
@@ -5438,45 +5629,6 @@ function replaceAll(input, replacements) {
5438
5629
  return output;
5439
5630
  }
5440
5631
 
5441
- // src/utilities/getUserPackageManager.ts
5442
- import pathModule2 from "path";
5443
- async function getUserPackageManager(path6) {
5444
- try {
5445
- return await detectPackageManagerFromArtifacts(path6);
5446
- } catch (error) {
5447
- return detectPackageManagerFromCurrentCommand();
5448
- }
5449
- }
5450
- function detectPackageManagerFromCurrentCommand() {
5451
- const userAgent = process.env.npm_config_user_agent;
5452
- if (userAgent) {
5453
- if (userAgent.startsWith("yarn")) {
5454
- return "yarn";
5455
- } else if (userAgent.startsWith("pnpm")) {
5456
- return "pnpm";
5457
- } else {
5458
- return "npm";
5459
- }
5460
- } else {
5461
- return "npm";
5462
- }
5463
- }
5464
- async function detectPackageManagerFromArtifacts(path6) {
5465
- const packageFiles = [
5466
- { name: "yarn.lock", pm: "yarn" },
5467
- { name: "pnpm-lock.yaml", pm: "pnpm" },
5468
- { name: "package-lock.json", pm: "npm" },
5469
- { name: "npm-shrinkwrap.json", pm: "npm" }
5470
- ];
5471
- for (const { name, pm } of packageFiles) {
5472
- const exists = await pathExists(pathModule2.join(path6, name));
5473
- if (exists) {
5474
- return pm;
5475
- }
5476
- }
5477
- throw new Error("Could not detect package manager from artifacts");
5478
- }
5479
-
5480
5632
  // src/utilities/resolveInternalFilePath.ts
5481
5633
  import { resolve as importResolve3 } from "import-meta-resolve";
5482
5634
  function resolveInternalFilePath(filePath) {
@@ -5629,13 +5781,13 @@ async function createTriggerDir(dir, options) {
5629
5781
  "cli.example": example
5630
5782
  });
5631
5783
  if (example === "none") {
5632
- await createFile(join6(triggerDir, ".gitkeep"), "");
5784
+ await createFile(join7(triggerDir, ".gitkeep"), "");
5633
5785
  log3.step(`Created directory at ${location}`);
5634
5786
  span.end();
5635
5787
  return { location, isCustomValue: location !== defaultValue };
5636
5788
  }
5637
5789
  const exampleFile = resolveInternalFilePath(`./templates/examples/${example}.ts.template`);
5638
- const outputPath = join6(triggerDir, "example.ts");
5790
+ const outputPath = join7(triggerDir, "example.ts");
5639
5791
  await createFileFromTemplate({
5640
5792
  templatePath: exampleFile,
5641
5793
  outputPath,
@@ -5658,7 +5810,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
5658
5810
  return await tracer.startActiveSpan("gitIgnoreDotTriggerDir", async (span) => {
5659
5811
  try {
5660
5812
  const projectDir = resolve3(process.cwd(), dir);
5661
- const gitIgnorePath = join6(projectDir, ".gitignore");
5813
+ const gitIgnorePath = join7(projectDir, ".gitignore");
5662
5814
  span.setAttributes({
5663
5815
  "cli.projectDir": projectDir,
5664
5816
  "cli.gitIgnorePath": gitIgnorePath
@@ -5692,7 +5844,7 @@ async function addConfigFileToTsConfig(dir, options) {
5692
5844
  return await tracer.startActiveSpan("createTriggerDir", async (span) => {
5693
5845
  try {
5694
5846
  const projectDir = resolve3(process.cwd(), dir);
5695
- const tsconfigPath = join6(projectDir, "tsconfig.json");
5847
+ const tsconfigPath = join7(projectDir, "tsconfig.json");
5696
5848
  span.setAttributes({
5697
5849
  "cli.projectDir": projectDir,
5698
5850
  "cli.tsconfigPath": tsconfigPath
@@ -5779,7 +5931,7 @@ async function writeConfigFile(dir, project, options, triggerDir) {
5779
5931
  spnnr.start("Creating config file");
5780
5932
  const projectDir = resolve3(process.cwd(), dir);
5781
5933
  const templatePath = resolveInternalFilePath("./templates/trigger.config.ts.template");
5782
- const outputPath = join6(projectDir, "trigger.config.ts");
5934
+ const outputPath = join7(projectDir, "trigger.config.ts");
5783
5935
  span.setAttributes({
5784
5936
  "cli.projectDir": projectDir,
5785
5937
  "cli.templatePath": templatePath,