trigger.dev 3.0.0-beta.16 → 3.0.0-beta.17

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
@@ -777,7 +777,7 @@ var require_retry2 = __commonJS({
777
777
  import { Command as Command2 } from "commander";
778
778
 
779
779
  // src/commands/deploy.ts
780
- import { intro as intro3, log as log3, outro as outro3 } from "@clack/prompts";
780
+ import { intro as intro4, log as log5, outro as outro4 } from "@clack/prompts";
781
781
  import { depot } from "@depot/cli";
782
782
  import { context, trace as trace2 } from "@opentelemetry/api";
783
783
  import {
@@ -793,14 +793,14 @@ import { execa as execa2 } from "execa";
793
793
  import { createHash } from "node:crypto";
794
794
  import { readFileSync as readFileSync2 } from "node:fs";
795
795
  import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
796
- import { dirname, join as join5, relative as relative3, posix } from "node:path";
796
+ import { dirname, join as join6, relative as relative3, posix } from "node:path";
797
797
  import { setTimeout as setTimeout2 } from "node:timers/promises";
798
798
  import terminalLink2 from "terminal-link";
799
799
  import invariant from "tiny-invariant";
800
800
  import { z as z4 } from "zod";
801
801
 
802
802
  // package.json
803
- var version = "3.0.0-beta.16";
803
+ var version = "3.0.0-beta.17";
804
804
  var dependencies = {
805
805
  "@clack/prompts": "^0.7.0",
806
806
  "@depot/cli": "0.0.1-cli.2.55.0",
@@ -816,7 +816,7 @@ var dependencies = {
816
816
  "@opentelemetry/sdk-trace-base": "^1.22.0",
817
817
  "@opentelemetry/sdk-trace-node": "^1.22.0",
818
818
  "@opentelemetry/semantic-conventions": "^1.22.0",
819
- "@trigger.dev/core": "workspace:^3.0.0-beta.16",
819
+ "@trigger.dev/core": "workspace:^3.0.0-beta.17",
820
820
  "@types/degit": "^2.8.3",
821
821
  chalk: "^5.2.0",
822
822
  chokidar: "^3.5.3",
@@ -837,7 +837,6 @@ var dependencies = {
837
837
  "mock-fs": "^5.2.0",
838
838
  nanoid: "^4.0.2",
839
839
  "node-fetch": "^3.3.0",
840
- "npm-check-updates": "^16.12.2",
841
840
  "object-hash": "^3.0.0",
842
841
  "p-debounce": "^4.0.0",
843
842
  "p-throttle": "^6.1.0",
@@ -1318,6 +1317,7 @@ var logger = new Logger();
1318
1317
  import { outro } from "@clack/prompts";
1319
1318
 
1320
1319
  // src/utilities/cliOutput.ts
1320
+ import { log } from "@clack/prompts";
1321
1321
  import chalk2 from "chalk";
1322
1322
  var green = "#4FFF54";
1323
1323
  var purple = "#735BF3";
@@ -1366,6 +1366,18 @@ function prettyPrintDate(date = /* @__PURE__ */ new Date()) {
1366
1366
  formattedDate += "." + ("00" + date.getMilliseconds()).slice(-3);
1367
1367
  return formattedDate;
1368
1368
  }
1369
+ function prettyWarning(header, body, footer) {
1370
+ const prefix = "Warning: ";
1371
+ const indent = Array(prefix.length).fill(" ").join("");
1372
+ const spacing = "\n\n";
1373
+ const prettyPrefix = chalkWarning(prefix);
1374
+ const withIndents = (text3) => text3?.split("\n").map((line) => `${indent}${line}`).join("\n");
1375
+ const prettyBody = withIndents(body);
1376
+ const prettyFooter = withIndents(footer);
1377
+ log.warn(
1378
+ `${prettyPrefix}${header}${prettyBody ? `${spacing}${prettyBody}` : ""}${prettyFooter ? `${spacing}${prettyFooter}` : ""}`
1379
+ );
1380
+ }
1369
1381
 
1370
1382
  // src/cli/common.ts
1371
1383
  var CommonCommandOptions = z.object({
@@ -1474,6 +1486,9 @@ async function createFile(path7, contents) {
1474
1486
  async function pathExists(path7) {
1475
1487
  return fsSync.existsSync(path7);
1476
1488
  }
1489
+ async function removeFile(path7) {
1490
+ await fsModule.unlink(path7);
1491
+ }
1477
1492
  async function readFile(path7) {
1478
1493
  return await fsModule.readFile(path7, "utf8");
1479
1494
  }
@@ -1481,8 +1496,8 @@ async function readJSONFile(path7) {
1481
1496
  const fileContents = await fsModule.readFile(path7, "utf8");
1482
1497
  return JSON.parse(fileContents);
1483
1498
  }
1484
- async function writeJSONFile(path7, json) {
1485
- await writeFile(path7, JSON.stringify(json), "utf8");
1499
+ async function writeJSONFile(path7, json, pretty = false) {
1500
+ await writeFile(path7, JSON.stringify(json, void 0, pretty ? 2 : void 0), "utf8");
1486
1501
  }
1487
1502
  function readJSONFileSync(path7) {
1488
1503
  const fileContents = fsSync.readFileSync(path7, "utf8");
@@ -1701,29 +1716,29 @@ function getVersion() {
1701
1716
  }
1702
1717
 
1703
1718
  // src/utilities/windows.ts
1704
- import { log, spinner as clackSpinner } from "@clack/prompts";
1719
+ import { log as log2, spinner as clackSpinner } from "@clack/prompts";
1705
1720
  var isWindows = process.platform === "win32";
1706
1721
  function escapeImportPath(path7) {
1707
1722
  return isWindows ? path7.replaceAll("\\", "\\\\") : path7;
1708
1723
  }
1709
1724
  var ballmerSpinner = () => ({
1710
1725
  start: (msg) => {
1711
- log.step(msg ?? "");
1726
+ log2.step(msg ?? "");
1712
1727
  },
1713
1728
  stop: (msg, code) => {
1714
- log.message(msg ?? "");
1729
+ log2.message(msg ?? "");
1715
1730
  },
1716
1731
  message: (msg) => {
1717
- log.message(msg ?? "");
1732
+ log2.message(msg ?? "");
1718
1733
  }
1719
1734
  });
1720
1735
  var spinner = () => isWindows ? ballmerSpinner() : clackSpinner();
1721
1736
 
1722
1737
  // src/utilities/initialBanner.ts
1723
1738
  async function printInitialBanner(performUpdateCheck = true) {
1724
- const packageVersion = getVersion();
1739
+ const cliVersion = getVersion();
1725
1740
  const text3 = `
1726
- ${logo()} ${chalkGrey(`(${packageVersion})`)}
1741
+ ${logo()} ${chalkGrey(`(${cliVersion})`)}
1727
1742
  `;
1728
1743
  logger.info(text3);
1729
1744
  let maybeNewVersion;
@@ -1733,7 +1748,7 @@ ${logo()} ${chalkGrey(`(${packageVersion})`)}
1733
1748
  maybeNewVersion = await updateCheck();
1734
1749
  if (maybeNewVersion !== void 0) {
1735
1750
  loadingSpinner.stop(`Update available ${chalk3.green(maybeNewVersion)}`);
1736
- const currentMajor = parseInt(packageVersion.split(".")[0]);
1751
+ const currentMajor = parseInt(cliVersion.split(".")[0]);
1737
1752
  const newMajor = parseInt(maybeNewVersion.split(".")[0]);
1738
1753
  if (newMajor > currentMajor) {
1739
1754
  logger.warn(
@@ -1748,9 +1763,10 @@ After installation, run Trigger.dev with \`npx trigger.dev\`.`
1748
1763
  }
1749
1764
  }
1750
1765
  async function printStandloneInitialBanner(performUpdateCheck = true) {
1751
- const packageVersion = getVersion();
1766
+ const cliVersion = getVersion();
1752
1767
  logger.log(`
1753
- ${logo()} ${chalkGrey("(v3 Developer Preview)")}`);
1768
+ ${logo()} ${chalkGrey(`(${cliVersion})`)}
1769
+ `);
1754
1770
  if (performUpdateCheck) {
1755
1771
  const maybeNewVersion = await updateCheck();
1756
1772
  if (maybeNewVersion !== void 0) {
@@ -1759,7 +1775,10 @@ ${logo()} ${chalkGrey("(v3 Developer Preview)")}`);
1759
1775
  }
1760
1776
  logger.log(`${chalkGrey("-".repeat(54))}`);
1761
1777
  }
1762
- function printDevBanner() {
1778
+ function printDevBanner(printTopBorder = true) {
1779
+ if (printTopBorder) {
1780
+ logger.log(chalkGrey("-".repeat(54)));
1781
+ }
1763
1782
  logger.log(
1764
1783
  `${chalkGrey("Key:")} ${chalkWorker("Version")} ${chalkGrey("|")} ${chalkTask(
1765
1784
  "Task"
@@ -1771,7 +1790,7 @@ async function doUpdateCheck() {
1771
1790
  let update = null;
1772
1791
  try {
1773
1792
  update = await checkForUpdate(package_default, {
1774
- distTag: package_default.version.startsWith("0.0.0") ? "beta" : "latest"
1793
+ distTag: package_default.version.startsWith("3.0.0-beta") ? "beta" : "latest"
1775
1794
  });
1776
1795
  } catch (err) {
1777
1796
  }
@@ -1840,7 +1859,7 @@ async function setPackageJsonDeps(path7, deps) {
1840
1859
  }
1841
1860
 
1842
1861
  // src/commands/login.ts
1843
- import { intro as intro2, log as log2, outro as outro2, select } from "@clack/prompts";
1862
+ import { intro as intro2, log as log3, outro as outro2, select } from "@clack/prompts";
1844
1863
  import { recordSpanException as recordSpanException3 } from "@trigger.dev/core/v3";
1845
1864
 
1846
1865
  // ../../node_modules/.pnpm/open@10.0.3/node_modules/open/index.js
@@ -2211,14 +2230,14 @@ var baseOpen = async (options) => {
2211
2230
  }
2212
2231
  const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
2213
2232
  if (options.wait) {
2214
- return new Promise((resolve4, reject) => {
2233
+ return new Promise((resolve5, reject) => {
2215
2234
  subprocess.once("error", reject);
2216
2235
  subprocess.once("close", (exitCode) => {
2217
2236
  if (!options.allowNonzeroExitCode && exitCode > 0) {
2218
2237
  reject(new Error(`Exited with code ${exitCode}`));
2219
2238
  return;
2220
2239
  }
2221
- resolve4(subprocess);
2240
+ resolve5(subprocess);
2222
2241
  });
2223
2242
  });
2224
2243
  }
@@ -2335,7 +2354,7 @@ var decorateErrorWithCounts = (error, attemptNumber, options) => {
2335
2354
  return error;
2336
2355
  };
2337
2356
  async function pRetry(input, options) {
2338
- return new Promise((resolve4, reject) => {
2357
+ return new Promise((resolve5, reject) => {
2339
2358
  options = {
2340
2359
  onFailedAttempt() {
2341
2360
  },
@@ -2358,7 +2377,7 @@ async function pRetry(input, options) {
2358
2377
  try {
2359
2378
  const result = await input(attemptNumber);
2360
2379
  cleanUp();
2361
- resolve4(result);
2380
+ resolve5(result);
2362
2381
  } catch (error) {
2363
2382
  try {
2364
2383
  if (!(error instanceof Error)) {
@@ -2633,11 +2652,11 @@ async function login(options) {
2633
2652
  }
2634
2653
  }
2635
2654
  if (opts.embedded) {
2636
- log2.step("You must login to continue.");
2655
+ log3.step("You must login to continue.");
2637
2656
  }
2638
2657
  const apiClient2 = new CliApiClient(authConfig?.apiUrl ?? opts.defaultApiUrl);
2639
2658
  const authorizationCodeResult = await createAuthorizationCode(apiClient2);
2640
- log2.step(
2659
+ log3.step(
2641
2660
  `Please visit the following URL to login:
2642
2661
  ${chalkLink(authorizationCodeResult.url)}`
2643
2662
  );
@@ -2671,7 +2690,7 @@ ${chalkLink(authorizationCodeResult.url)}`
2671
2690
  throw new Error(whoAmIResult.error);
2672
2691
  }
2673
2692
  if (opts.embedded) {
2674
- log2.step("Logged in successfully");
2693
+ log3.step("Logged in successfully");
2675
2694
  } else {
2676
2695
  outro2("Logged in successfully");
2677
2696
  }
@@ -2690,7 +2709,7 @@ ${chalkLink(authorizationCodeResult.url)}`
2690
2709
  } catch (e) {
2691
2710
  getPersonalAccessTokenSpinner.stop(`Failed to get access token`);
2692
2711
  if (e instanceof AbortError) {
2693
- log2.error(e.message);
2712
+ log3.error(e.message);
2694
2713
  }
2695
2714
  recordSpanException3(span, e);
2696
2715
  span.end();
@@ -3117,7 +3136,13 @@ import { join as join4 } from "node:path";
3117
3136
 
3118
3137
  // src/utilities/getUserPackageManager.ts
3119
3138
  import { findUp as findUp2 } from "find-up";
3139
+ import { basename } from "path";
3120
3140
  async function getUserPackageManager(path7) {
3141
+ const packageManager = await detectPackageManager(path7);
3142
+ logger.debug("Detected package manager", { packageManager });
3143
+ return packageManager;
3144
+ }
3145
+ async function detectPackageManager(path7) {
3121
3146
  try {
3122
3147
  return await detectPackageManagerFromArtifacts(path7);
3123
3148
  } catch (error) {
@@ -3139,19 +3164,33 @@ function detectPackageManagerFromCurrentCommand() {
3139
3164
  }
3140
3165
  }
3141
3166
  async function detectPackageManagerFromArtifacts(path7) {
3142
- const packageFiles = [
3143
- { name: "yarn.lock", pm: "yarn" },
3144
- { name: "pnpm-lock.yaml", pm: "pnpm" },
3145
- { name: "package-lock.json", pm: "npm" },
3146
- { name: "npm-shrinkwrap.json", pm: "npm" }
3147
- ];
3148
- for (const { name, pm } of packageFiles) {
3149
- const foundPath = await findUp2(name, { cwd: path7 });
3150
- if (typeof foundPath === "string") {
3151
- return pm;
3152
- }
3167
+ const artifacts = {
3168
+ yarn: "yarn.lock",
3169
+ pnpm: "pnpm-lock.yaml",
3170
+ npm: "package-lock.json",
3171
+ npmShrinkwrap: "npm-shrinkwrap.json"
3172
+ };
3173
+ const foundPath = await findUp2(Object.values(artifacts), { cwd: path7 });
3174
+ if (!foundPath) {
3175
+ throw new Error("Could not detect package manager from artifacts");
3153
3176
  }
3154
- throw new Error("Could not detect package manager from artifacts");
3177
+ logger.debug("Found path from package manager artifacts", { foundPath });
3178
+ switch (basename(foundPath)) {
3179
+ case artifacts.yarn:
3180
+ return "yarn";
3181
+ case artifacts.pnpm:
3182
+ return "pnpm";
3183
+ case artifacts.npm:
3184
+ case artifacts.npmShrinkwrap:
3185
+ return "npm";
3186
+ default:
3187
+ throw new Error(`Unhandled package manager detection path: ${foundPath}`);
3188
+ }
3189
+ }
3190
+
3191
+ // src/utilities/assertExhaustive.ts
3192
+ function assertExhaustive(x) {
3193
+ throw new Error("Unexpected object: " + x);
3155
3194
  }
3156
3195
 
3157
3196
  // src/utilities/javascriptProject.ts
@@ -3210,17 +3249,25 @@ var JavascriptProject = class {
3210
3249
  }
3211
3250
  get scripts() {
3212
3251
  return {
3213
- postinstall: this.packageJson.scripts?.postinstall
3252
+ postinstall: this.packageJson.scripts?.postinstall ?? ""
3214
3253
  };
3215
3254
  }
3255
+ async install() {
3256
+ const command = await this.#getCommand();
3257
+ try {
3258
+ await command.installDependencies({
3259
+ cwd: this.projectPath
3260
+ });
3261
+ } catch (error) {
3262
+ logger.debug(`Failed to install dependencies using ${command.name}`, {
3263
+ error
3264
+ });
3265
+ }
3266
+ }
3216
3267
  async resolve(packageName, options) {
3217
3268
  if (BuiltInModules.has(packageName)) {
3218
3269
  return void 0;
3219
3270
  }
3220
- if (!this._packageManager) {
3221
- this._packageManager = await getUserPackageManager(this.projectPath);
3222
- }
3223
- const packageManager = this._packageManager;
3224
3271
  const opts = { allowDev: false, ...options };
3225
3272
  const packageJsonVersion = this.packageJson.dependencies?.[packageName];
3226
3273
  if (typeof packageJsonVersion === "string") {
@@ -3232,7 +3279,7 @@ var JavascriptProject = class {
3232
3279
  return devPackageJsonVersion;
3233
3280
  }
3234
3281
  }
3235
- const command = packageManager === "npm" ? new NPMCommands() : packageManager === "pnpm" ? new PNPMCommands() : new YarnCommands();
3282
+ const command = await this.#getCommand();
3236
3283
  try {
3237
3284
  const version2 = await command.resolveDependencyVersion(packageName, {
3238
3285
  cwd: this.projectPath
@@ -3247,16 +3294,41 @@ var JavascriptProject = class {
3247
3294
  });
3248
3295
  }
3249
3296
  }
3297
+ async #getCommand() {
3298
+ const packageManager = await this.getPackageManager();
3299
+ switch (packageManager) {
3300
+ case "npm":
3301
+ return new NPMCommands();
3302
+ case "pnpm":
3303
+ return new PNPMCommands();
3304
+ case "yarn":
3305
+ return new YarnCommands();
3306
+ default:
3307
+ assertExhaustive(packageManager);
3308
+ }
3309
+ }
3310
+ async getPackageManager() {
3311
+ if (!this._packageManager) {
3312
+ this._packageManager = await getUserPackageManager(this.projectPath);
3313
+ }
3314
+ return this._packageManager;
3315
+ }
3250
3316
  };
3251
3317
  var PNPMCommands = class {
3252
3318
  get name() {
3253
3319
  return "pnpm";
3254
3320
  }
3321
+ get cmd() {
3322
+ return process.platform === "win32" ? "pnpm.cmd" : "pnpm";
3323
+ }
3324
+ async installDependencies(options) {
3325
+ const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
3326
+ logger.debug(`Installing dependencies using ${this.name}`, { stdout, stderr });
3327
+ }
3255
3328
  async resolveDependencyVersion(packageName, options) {
3256
- const cmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
3257
- const { stdout } = await $({ cwd: options.cwd })`${cmd} list ${packageName} -r --json`;
3329
+ const { stdout } = await $({ cwd: options.cwd })`${this.cmd} list ${packageName} -r --json`;
3258
3330
  const result = JSON.parse(stdout);
3259
- logger.debug(`Resolving ${packageName} version using pnpm`, { result });
3331
+ logger.debug(`Resolving ${packageName} version using ${this.name}`, { result });
3260
3332
  for (const dep of result) {
3261
3333
  const dependency = dep.dependencies?.[packageName];
3262
3334
  if (dependency) {
@@ -3269,11 +3341,17 @@ var NPMCommands = class {
3269
3341
  get name() {
3270
3342
  return "npm";
3271
3343
  }
3344
+ get cmd() {
3345
+ return process.platform === "win32" ? "npm.cmd" : "npm";
3346
+ }
3347
+ async installDependencies(options) {
3348
+ const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
3349
+ logger.debug(`Installing dependencies using ${this.name}`, { stdout, stderr });
3350
+ }
3272
3351
  async resolveDependencyVersion(packageName, options) {
3273
- const cmd = process.platform === "win32" ? "npm.cmd" : "npm";
3274
- const { stdout } = await $({ cwd: options.cwd })`${cmd} list ${packageName} --json`;
3352
+ const { stdout } = await $({ cwd: options.cwd })`${this.cmd} list ${packageName} --json`;
3275
3353
  const output = JSON.parse(stdout);
3276
- logger.debug(`Resolving ${packageName} version using npm`, { output });
3354
+ logger.debug(`Resolving ${packageName} version using ${this.name}`, { output });
3277
3355
  return this.#recursivelySearchDependencies(output.dependencies, packageName);
3278
3356
  }
3279
3357
  #recursivelySearchDependencies(dependencies2, packageName) {
@@ -3294,11 +3372,17 @@ var YarnCommands = class {
3294
3372
  get name() {
3295
3373
  return "yarn";
3296
3374
  }
3375
+ get cmd() {
3376
+ return process.platform === "win32" ? "yarn.cmd" : "yarn";
3377
+ }
3378
+ async installDependencies(options) {
3379
+ const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
3380
+ logger.debug(`Installing dependencies using ${this.name}`, { stdout, stderr });
3381
+ }
3297
3382
  async resolveDependencyVersion(packageName, options) {
3298
- const cmd = process.platform === "win32" ? "yarn.cmd" : "yarn";
3299
- const { stdout } = await $({ cwd: options.cwd })`${cmd} info ${packageName} --json`;
3383
+ const { stdout } = await $({ cwd: options.cwd })`${this.cmd} info ${packageName} --json`;
3300
3384
  const lines = stdout.split("\n");
3301
- logger.debug(`Resolving ${packageName} version using yarn`, { lines });
3385
+ logger.debug(`Resolving ${packageName} version using ${this.name}`, { lines });
3302
3386
  for (const line of lines) {
3303
3387
  const json = JSON.parse(line);
3304
3388
  if (json.value === packageName) {
@@ -3317,6 +3401,204 @@ function cliRootPath() {
3317
3401
  return __dirname2;
3318
3402
  }
3319
3403
 
3404
+ // src/commands/update.ts
3405
+ import { confirm, intro as intro3, isCancel, log as log4, outro as outro3 } from "@clack/prompts";
3406
+ import { join as join5, resolve as resolve2 } from "path";
3407
+ var UpdateCommandOptions = CommonCommandOptions.pick({
3408
+ logLevel: true,
3409
+ skipTelemetry: true
3410
+ });
3411
+ function configureUpdateCommand(program2) {
3412
+ return program2.command("update").description("Updates all @trigger.dev/* packages to match the CLI version").argument("[path]", "The path to the directory that contains the package.json file", ".").option(
3413
+ "-l, --log-level <level>",
3414
+ "The CLI log level to use (debug, info, log, warn, error, none). This does not effect the log level of your trigger.dev tasks.",
3415
+ "log"
3416
+ ).option("--skip-telemetry", "Opt-out of sending telemetry").action(async (path7, options) => {
3417
+ wrapCommandAction("dev", UpdateCommandOptions, options, async (opts) => {
3418
+ await printStandloneInitialBanner(true);
3419
+ await updateCommand(path7, opts);
3420
+ });
3421
+ });
3422
+ }
3423
+ var triggerPackageFilter = /^@trigger\.dev/;
3424
+ async function updateCommand(dir, options) {
3425
+ await updateTriggerPackages(dir, options);
3426
+ }
3427
+ async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
3428
+ if (!embedded) {
3429
+ intro3("Updating packages");
3430
+ }
3431
+ const projectPath = resolve2(process.cwd(), dir);
3432
+ const { packageJson, readonlyPackageJson, packageJsonPath } = await getPackageJson(projectPath);
3433
+ if (!packageJson) {
3434
+ log4.error("Failed to load package.json. Try to re-run with `-l debug` to see what's going on.");
3435
+ return;
3436
+ }
3437
+ const cliVersion = getVersion();
3438
+ const newCliVersion = await updateCheck();
3439
+ if (newCliVersion) {
3440
+ prettyWarning(
3441
+ "You're not running the latest CLI version, please consider updating ASAP",
3442
+ `Current: ${cliVersion}
3443
+ Latest: ${newCliVersion}`,
3444
+ "Run latest: npx trigger.dev@beta"
3445
+ );
3446
+ }
3447
+ const triggerDependencies = getTriggerDependencies(packageJson);
3448
+ function getVersionMismatches(deps, targetVersion) {
3449
+ const mismatches = [];
3450
+ for (const dep of deps) {
3451
+ if (dep.version === targetVersion) {
3452
+ continue;
3453
+ }
3454
+ mismatches.push(dep);
3455
+ }
3456
+ return mismatches;
3457
+ }
3458
+ const versionMismatches = getVersionMismatches(triggerDependencies, cliVersion);
3459
+ if (versionMismatches.length === 0) {
3460
+ if (!embedded) {
3461
+ outro3(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
3462
+ }
3463
+ return;
3464
+ }
3465
+ prettyWarning(
3466
+ "Mismatch between your CLI version and installed packages",
3467
+ "We recommend pinned versions for guaranteed compatibility"
3468
+ );
3469
+ if (!process.stdout.isTTY) {
3470
+ outro3("Deploy failed");
3471
+ console.log(
3472
+ `ERROR: Version mismatch detected while running in CI. This won't end well. Aborting.
3473
+
3474
+ Please run the dev command locally and check that your CLI version matches the one printed below. Additionally, all \`@trigger.dev/*\` packages also need to match this version.
3475
+
3476
+ If your local CLI version doesn't match the one below, you may want to add the \`trigger.dev\` package to your dependencies. You will also have to update your workflow deploy command to \`npx trigger.dev deploy\` to ensure your pinned CLI version is used.
3477
+
3478
+ CLI version: ${cliVersion}
3479
+
3480
+ Current package versions that don't match the CLI:
3481
+ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3482
+ `
3483
+ );
3484
+ process.exit(1);
3485
+ }
3486
+ log4.message("");
3487
+ const userWantsToUpdate = await updateConfirmation(versionMismatches, cliVersion);
3488
+ if (isCancel(userWantsToUpdate)) {
3489
+ throw new OutroCommandError();
3490
+ }
3491
+ if (!userWantsToUpdate) {
3492
+ if (requireUpdate) {
3493
+ outro3("You shall not pass!");
3494
+ logger.log(
3495
+ `${chalkError(
3496
+ "X Error:"
3497
+ )} Update required: Version mismatches are a common source of bugs and errors. Please update or use \`--skip-update-check\` at your own risk.
3498
+ `
3499
+ );
3500
+ process.exit(1);
3501
+ }
3502
+ if (!embedded) {
3503
+ outro3("You've been warned!");
3504
+ }
3505
+ return;
3506
+ }
3507
+ const installSpinner = spinner();
3508
+ installSpinner.start("Writing new package.json file");
3509
+ const packageJsonBackupPath = `${packageJsonPath}.bak`;
3510
+ await writeJSONFile(packageJsonBackupPath, readonlyPackageJson, true);
3511
+ const exitHandler = async (sig) => {
3512
+ log4.warn(
3513
+ `You may have to manually roll back any package.json changes. Backup written to ${packageJsonBackupPath}`
3514
+ );
3515
+ };
3516
+ process.prependOnceListener("exit", exitHandler);
3517
+ mutatePackageJsonWithUpdatedPackages(packageJson, versionMismatches, cliVersion);
3518
+ await writeJSONFile(packageJsonPath, packageJson, true);
3519
+ async function revertPackageJsonChanges() {
3520
+ await writeJSONFile(packageJsonPath, readonlyPackageJson, true);
3521
+ await removeFile(packageJsonBackupPath);
3522
+ }
3523
+ installSpinner.message("Installing new package versions");
3524
+ const jsProject = new JavascriptProject(projectPath);
3525
+ let packageManager;
3526
+ try {
3527
+ packageManager = await jsProject.getPackageManager();
3528
+ installSpinner.message(`Installing new package versions with ${packageManager}`);
3529
+ await jsProject.install();
3530
+ } catch (error) {
3531
+ installSpinner.stop(
3532
+ `Failed to install new package versions${packageManager ? ` with ${packageManager}` : ""}`
3533
+ );
3534
+ process.removeListener("exit", exitHandler);
3535
+ await revertPackageJsonChanges();
3536
+ throw error;
3537
+ }
3538
+ installSpinner.stop("Installed new package versions");
3539
+ process.removeListener("exit", exitHandler);
3540
+ await removeFile(packageJsonBackupPath);
3541
+ if (!embedded) {
3542
+ outro3(
3543
+ `Packages updated${newCliVersion ? " ..but you should really update your CLI too!" : ""}`
3544
+ );
3545
+ }
3546
+ }
3547
+ function getTriggerDependencies(packageJson) {
3548
+ const deps = [];
3549
+ for (const type of ["dependencies", "devDependencies"]) {
3550
+ for (const [name, version2] of Object.entries(packageJson[type] ?? {})) {
3551
+ if (!version2) {
3552
+ continue;
3553
+ }
3554
+ if (version2.startsWith("workspace")) {
3555
+ continue;
3556
+ }
3557
+ if (!triggerPackageFilter.test(name)) {
3558
+ continue;
3559
+ }
3560
+ const ignoredPackages = ["@trigger.dev/companyicons"];
3561
+ if (ignoredPackages.includes(name)) {
3562
+ continue;
3563
+ }
3564
+ deps.push({ type, name, version: version2 });
3565
+ }
3566
+ }
3567
+ return deps;
3568
+ }
3569
+ function mutatePackageJsonWithUpdatedPackages(packageJson, depsToUpdate, targetVersion) {
3570
+ for (const { type, name, version: version2 } of depsToUpdate) {
3571
+ if (!packageJson[type]) {
3572
+ throw new Error(
3573
+ `No ${type} entry found in package.json. Please try to upgrade manually instead.`
3574
+ );
3575
+ }
3576
+ packageJson[type][name] = targetVersion;
3577
+ }
3578
+ }
3579
+ function printUpdateTable(depsToUpdate, targetVersion) {
3580
+ log4.message("Suggested updates");
3581
+ const tableData = depsToUpdate.map((dep) => ({
3582
+ package: dep.name,
3583
+ old: dep.version,
3584
+ new: targetVersion
3585
+ }));
3586
+ logger.table(tableData);
3587
+ }
3588
+ async function updateConfirmation(depsToUpdate, targetVersion) {
3589
+ printUpdateTable(depsToUpdate, targetVersion);
3590
+ let confirmMessage = "Would you like to apply those updates?";
3591
+ return await confirm({
3592
+ message: confirmMessage
3593
+ });
3594
+ }
3595
+ async function getPackageJson(absoluteProjectPath) {
3596
+ const packageJsonPath = join5(absoluteProjectPath, "package.json");
3597
+ const readonlyPackageJson = Object.freeze(await readJSONFile(packageJsonPath));
3598
+ const packageJson = structuredClone(readonlyPackageJson);
3599
+ return { packageJson, readonlyPackageJson, packageJsonPath };
3600
+ }
3601
+
3320
3602
  // src/commands/deploy.ts
3321
3603
  var DeployCommandOptions = CommonCommandOptions.extend({
3322
3604
  skipTypecheck: z4.boolean().default(false),
@@ -3332,7 +3614,8 @@ var DeployCommandOptions = CommonCommandOptions.extend({
3332
3614
  projectRef: z4.string().optional(),
3333
3615
  outputMetafile: z4.string().optional(),
3334
3616
  apiUrl: z4.string().optional(),
3335
- saveLogs: z4.boolean().default(false)
3617
+ saveLogs: z4.boolean().default(false),
3618
+ skipUpdateCheck: z4.boolean().default(false)
3336
3619
  });
3337
3620
  function configureDeployCommand(program2) {
3338
3621
  return commonOptions(
@@ -3340,7 +3623,7 @@ function configureDeployCommand(program2) {
3340
3623
  "-e, --env <env>",
3341
3624
  "Deploy to a specific environment (currently only prod and staging are supported)",
3342
3625
  "prod"
3343
- ).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option(
3626
+ ).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option("--skip-update-check", "Skip checking for @trigger.dev package updates").option(
3344
3627
  "--ignore-env-var-check",
3345
3628
  "Detected missing environment variables won't block deployment"
3346
3629
  ).option("-c, --config <config file>", "The name of the config file, found at [path]").option(
@@ -3398,7 +3681,10 @@ async function deployCommand(dir, options) {
3398
3681
  }
3399
3682
  async function _deployCommand(dir, options) {
3400
3683
  const span = trace2.getSpan(context.active());
3401
- intro3("Deploying project");
3684
+ intro4("Deploying project");
3685
+ if (!options.skipUpdateCheck) {
3686
+ await updateTriggerPackages(dir, { ...options }, true, true);
3687
+ }
3402
3688
  const authorization = await login({
3403
3689
  embedded: true,
3404
3690
  defaultApiUrl: options.apiUrl,
@@ -3441,7 +3727,7 @@ async function _deployCommand(dir, options) {
3441
3727
  throw new Error(deploymentEnv.error);
3442
3728
  }
3443
3729
  const environmentClient = new CliApiClient(authorization.auth.apiUrl, deploymentEnv.data.apiKey);
3444
- log3.step(
3730
+ log5.step(
3445
3731
  `Preparing to deploy "${deploymentEnv.data.name}" (${resolvedConfig.config.project}) to ${options.env}`
3446
3732
  );
3447
3733
  const compilation = await compileProject(
@@ -3544,7 +3830,7 @@ async function _deployCommand(dir, options) {
3544
3830
  printWarnings(warnings.warnings);
3545
3831
  if (options.saveLogs) {
3546
3832
  const logPath = await saveLogs(deploymentResponse.data.shortCode, image.logs);
3547
- log3.info(`Build logs have been saved to ${logPath}`);
3833
+ log5.info(`Build logs have been saved to ${logPath}`);
3548
3834
  }
3549
3835
  };
3550
3836
  const imageReference = options.selfHosted ? `${selfHostedRegistryHost ? `${selfHostedRegistryHost}/` : ""}${image.image}${image.digest ? `@${image.digest}` : ""}` : `${registryHost}/${image.image}${image.digest ? `@${image.digest}` : ""}`;
@@ -3601,11 +3887,11 @@ async function _deployCommand(dir, options) {
3601
3887
  await preExitTasks();
3602
3888
  const taskCount = finishedDeployment.worker?.tasks.length ?? 0;
3603
3889
  if (taskCount === 0) {
3604
- outro3(
3890
+ outro4(
3605
3891
  `Version ${version2} deployed with no detected tasks. Please make sure you are exporting tasks in your project. ${deploymentLink}`
3606
3892
  );
3607
3893
  } else {
3608
- outro3(
3894
+ outro4(
3609
3895
  `Version ${version2} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${deploymentLink}`
3610
3896
  );
3611
3897
  }
@@ -3661,12 +3947,12 @@ async function _deployCommand(dir, options) {
3661
3947
  }
3662
3948
  function printErrors(errors) {
3663
3949
  for (const error of errors ?? []) {
3664
- log3.error(`${chalkError("Error:")} ${error}`);
3950
+ log5.error(`${chalkError("Error:")} ${error}`);
3665
3951
  }
3666
3952
  }
3667
3953
  function printWarnings(warnings) {
3668
3954
  for (const warning of warnings ?? []) {
3669
- log3.warn(`${chalkWarning("Warning:")} ${warning}`);
3955
+ log5.warn(`${chalkWarning("Warning:")} ${warning}`);
3670
3956
  }
3671
3957
  }
3672
3958
  function checkLogsForWarnings(logs) {
@@ -3740,7 +4026,7 @@ If it's a binary: Please ${terminalLink2(
3740
4026
  continue;
3741
4027
  }
3742
4028
  const message = getMessageFromTemplate(error.message, matches.groups);
3743
- log3.error(`${chalkError("Error:")} ${message}`);
4029
+ log5.error(`${chalkError("Error:")} ${message}`);
3744
4030
  break;
3745
4031
  }
3746
4032
  }
@@ -3754,7 +4040,7 @@ function getMessageFromTemplate(template, replacer) {
3754
4040
  return message;
3755
4041
  }
3756
4042
  async function saveLogs(shortCode, logs) {
3757
- const logPath = join5(await createTempDir(), `build-${shortCode}.log`);
4043
+ const logPath = join6(await createTempDir(), `build-${shortCode}.log`);
3758
4044
  await writeFile2(logPath, logs);
3759
4045
  return logPath;
3760
4046
  }
@@ -3765,9 +4051,9 @@ async function failDeploy(shortCode, errorSummary, logs, deploymentSpinner, warn
3765
4051
  printWarnings(warnings);
3766
4052
  printErrors(errors);
3767
4053
  checkLogsForErrors(logs);
3768
- outro3(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
4054
+ outro4(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
3769
4055
  } else {
3770
- outro3(`${chalkError("Error:")} ${errorSummary}.`);
4056
+ outro4(`${chalkError("Error:")} ${errorSummary}.`);
3771
4057
  }
3772
4058
  }
3773
4059
  async function checkEnvVars(envVars, config, options, environmentClient, apiUrl) {
@@ -4088,10 +4374,10 @@ async function compileProject(config, options, configPath) {
4088
4374
  compileSpinner.start(`Building project in ${config.projectDir}`);
4089
4375
  const taskFiles = await gatherTaskFiles(config);
4090
4376
  const workerFacade = readFileSync2(
4091
- join5(cliRootPath(), "workers", "prod", "worker-facade.js"),
4377
+ join6(cliRootPath(), "workers", "prod", "worker-facade.js"),
4092
4378
  "utf-8"
4093
4379
  );
4094
- const workerSetupPath = join5(cliRootPath(), "workers", "prod", "worker-setup.js");
4380
+ const workerSetupPath = join6(cliRootPath(), "workers", "prod", "worker-setup.js");
4095
4381
  let workerContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace(
4096
4382
  "__WORKER_SETUP__",
4097
4383
  `import { tracingSDK } from "${escapeImportPath(workerSetupPath)}";`
@@ -4151,10 +4437,10 @@ async function compileProject(config, options, configPath) {
4151
4437
  throw new Error("Build failed, aborting deployment");
4152
4438
  }
4153
4439
  if (options.outputMetafile) {
4154
- await writeJSONFile(join5(options.outputMetafile, "worker.json"), result.metafile);
4440
+ await writeJSONFile(join6(options.outputMetafile, "worker.json"), result.metafile);
4155
4441
  }
4156
4442
  const entryPointContents = readFileSync2(
4157
- join5(cliRootPath(), "workers", "prod", "entry-point.js"),
4443
+ join6(cliRootPath(), "workers", "prod", "entry-point.js"),
4158
4444
  "utf-8"
4159
4445
  );
4160
4446
  const entryPointResult = await build2({
@@ -4197,7 +4483,7 @@ async function compileProject(config, options, configPath) {
4197
4483
  }
4198
4484
  if (options.outputMetafile) {
4199
4485
  await writeJSONFile(
4200
- join5(options.outputMetafile, "entry-point.json"),
4486
+ join6(options.outputMetafile, "entry-point.json"),
4201
4487
  entryPointResult.metafile
4202
4488
  );
4203
4489
  }
@@ -4208,24 +4494,24 @@ async function compileProject(config, options, configPath) {
4208
4494
  const entryPointMetaOutput = entryPointResult.metafile.outputs[posix.join("out", "stdin.js")];
4209
4495
  invariant(entryPointMetaOutput, "Meta output for the entryPoint build is missing");
4210
4496
  const workerOutputFile = result.outputFiles.find(
4211
- (file) => file.path === join5(config.projectDir, "out", "stdin.js")
4497
+ (file) => file.path === join6(config.projectDir, "out", "stdin.js")
4212
4498
  );
4213
4499
  invariant(workerOutputFile, "Output file for the result build is missing");
4214
4500
  const workerSourcemapFile = result.outputFiles.find(
4215
- (file) => file.path === join5(config.projectDir, "out", "stdin.js.map")
4501
+ (file) => file.path === join6(config.projectDir, "out", "stdin.js.map")
4216
4502
  );
4217
4503
  invariant(workerSourcemapFile, "Sourcemap file for the result build is missing");
4218
4504
  const entryPointOutputFile = entryPointResult.outputFiles.find(
4219
- (file) => file.path === join5(config.projectDir, "out", "stdin.js")
4505
+ (file) => file.path === join6(config.projectDir, "out", "stdin.js")
4220
4506
  );
4221
4507
  invariant(entryPointOutputFile, "Output file for the entryPoint build is missing");
4222
4508
  await writeFile2(
4223
- join5(tempDir, "worker.js"),
4509
+ join6(tempDir, "worker.js"),
4224
4510
  `${workerOutputFile.text}
4225
4511
  //# sourceMappingURL=worker.js.map`
4226
4512
  );
4227
- await writeFile2(join5(tempDir, "worker.js.map"), workerSourcemapFile.text);
4228
- await writeFile2(join5(tempDir, "index.js"), entryPointOutputFile.text);
4513
+ await writeFile2(join6(tempDir, "worker.js.map"), workerSourcemapFile.text);
4514
+ await writeFile2(join6(tempDir, "index.js"), entryPointOutputFile.text);
4229
4515
  logger.debug("Getting the imports for the worker and entryPoint builds", {
4230
4516
  workerImports: metaOutput.imports,
4231
4517
  entryPointImports: entryPointMetaOutput.imports
@@ -4242,11 +4528,11 @@ async function compileProject(config, options, configPath) {
4242
4528
  ...javascriptProject.scripts
4243
4529
  }
4244
4530
  };
4245
- await writeJSONFile(join5(tempDir, "package.json"), packageJsonContents);
4531
+ await writeJSONFile(join6(tempDir, "package.json"), packageJsonContents);
4246
4532
  const copyResult = await copyAdditionalFiles(config, tempDir);
4247
4533
  if (!copyResult.ok) {
4248
4534
  compileSpinner.stop("Project built with warnings");
4249
- log3.warn(
4535
+ log5.warn(
4250
4536
  `No additionalFiles matches for:
4251
4537
 
4252
4538
  ${copyResult.noMatches.map((glob) => `- "${glob}"`).join("\n")}
@@ -4268,8 +4554,8 @@ If this is unexpected you should check your ${terminalLink2(
4268
4554
  if (!resolvingDependenciesResult) {
4269
4555
  throw new SkipLoggingError("Failed to resolve dependencies");
4270
4556
  }
4271
- const containerFilePath = join5(cliRootPath(), "Containerfile.prod");
4272
- await copyFile(containerFilePath, join5(tempDir, "Containerfile"));
4557
+ const containerFilePath = join6(cliRootPath(), "Containerfile.prod");
4558
+ await copyFile(containerFilePath, join6(tempDir, "Containerfile"));
4273
4559
  const contentHasher = createHash("sha256");
4274
4560
  contentHasher.update(Buffer.from(entryPointOutputFile.text));
4275
4561
  contentHasher.update(Buffer.from(workerOutputFile.text));
@@ -4301,8 +4587,8 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
4301
4587
  const hasher = createHash("sha256");
4302
4588
  hasher.update(JSON.stringify(packageJsonContents));
4303
4589
  const digest = hasher.digest("hex").slice(0, 16);
4304
- const cacheDir = join5(config.projectDir, ".trigger", "cache");
4305
- const cachePath = join5(cacheDir, `${digest}.json`);
4590
+ const cacheDir = join6(config.projectDir, ".trigger", "cache");
4591
+ const cachePath = join6(cacheDir, `${digest}.json`);
4306
4592
  span.setAttributes({
4307
4593
  "packageJson.digest": digest,
4308
4594
  "cache.path": cachePath,
@@ -4311,7 +4597,7 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
4311
4597
  try {
4312
4598
  const cachedPackageLock = await readFile2(cachePath, "utf-8");
4313
4599
  logger.debug(`Using cached package-lock.json for ${digest}`);
4314
- await writeFile2(join5(projectDir, "package-lock.json"), cachedPackageLock);
4600
+ await writeFile2(join6(projectDir, "package-lock.json"), cachedPackageLock);
4315
4601
  span.setAttributes({
4316
4602
  "cache.hit": true
4317
4603
  });
@@ -4334,11 +4620,11 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
4334
4620
  cwd: projectDir,
4335
4621
  stdio: logger.loggerLevel === "debug" ? "inherit" : "pipe"
4336
4622
  });
4337
- const packageLockContents = await readFile2(join5(projectDir, "package-lock.json"), "utf-8");
4623
+ const packageLockContents = await readFile2(join6(projectDir, "package-lock.json"), "utf-8");
4338
4624
  logger.debug(`Writing package-lock.json to cache for ${digest}`);
4339
4625
  await mkdir(cacheDir, { recursive: true });
4340
4626
  await writeFile2(cachePath, packageLockContents);
4341
- await writeFile2(join5(projectDir, "package-lock.json"), packageLockContents);
4627
+ await writeFile2(join6(projectDir, "package-lock.json"), packageLockContents);
4342
4628
  span.end();
4343
4629
  resolvingDepsSpinner.stop("Dependencies resolved");
4344
4630
  return true;
@@ -4390,8 +4676,8 @@ async function typecheckProject(config, options) {
4390
4676
  tscTypecheck.stdout?.on("data", (chunk) => stdouts.push(chunk.toString()));
4391
4677
  tscTypecheck.stderr?.on("data", (chunk) => stderrs.push(chunk.toString()));
4392
4678
  try {
4393
- await new Promise((resolve4, reject) => {
4394
- tscTypecheck.addListener("exit", (code) => code === 0 ? resolve4(code) : reject(code));
4679
+ await new Promise((resolve5, reject) => {
4680
+ tscTypecheck.addListener("exit", (code) => code === 0 ? resolve5(code) : reject(code));
4395
4681
  });
4396
4682
  } catch (error) {
4397
4683
  typecheckSpinner.stop(
@@ -4509,7 +4795,7 @@ async function copyAdditionalFiles(config, tempDir) {
4509
4795
  for await (const file of glob) {
4510
4796
  matches++;
4511
4797
  const pathInsideTempDir = relative3(config.projectDir, file.fullpath()).split(posix.sep).filter((p) => p !== "..").join(posix.sep);
4512
- const relativeDestinationPath = join5(tempDir, pathInsideTempDir);
4798
+ const relativeDestinationPath = join6(tempDir, pathInsideTempDir);
4513
4799
  logger.debug(`Copying file ${file.fullpath()} to ${relativeDestinationPath}`);
4514
4800
  await mkdir(dirname(relativeDestinationPath), { recursive: true });
4515
4801
  await copyFile(file.fullpath(), relativeDestinationPath);
@@ -4540,7 +4826,7 @@ async function copyAdditionalFiles(config, tempDir) {
4540
4826
  }
4541
4827
  async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
4542
4828
  const tmpDir = await createTempDir();
4543
- const dockerConfigPath = join5(tmpDir, "config.json");
4829
+ const dockerConfigPath = join6(tmpDir, "config.json");
4544
4830
  await writeJSONFile(dockerConfigPath, {
4545
4831
  auths: {
4546
4832
  [registryHost]: {
@@ -4586,7 +4872,7 @@ import { context as context2 } from "esbuild";
4586
4872
  import { render, useInput } from "ink";
4587
4873
  import { createHash as createHash2 } from "node:crypto";
4588
4874
  import fs7, { readFileSync as readFileSync3 } from "node:fs";
4589
- import { basename, dirname as dirname3, join as join6, normalize } from "node:path";
4875
+ import { basename as basename2, dirname as dirname3, join as join7, normalize } from "node:path";
4590
4876
  import pDebounce from "p-debounce";
4591
4877
  import { WebSocket } from "partysocket";
4592
4878
  import React, { Suspense, useEffect } from "react";
@@ -4625,7 +4911,7 @@ import {
4625
4911
  import dotenv from "dotenv";
4626
4912
  import { Evt } from "evt";
4627
4913
  import { fork } from "node:child_process";
4628
- import { dirname as dirname2, resolve as resolve2 } from "node:path";
4914
+ import { dirname as dirname2, resolve as resolve3 } from "node:path";
4629
4915
  import terminalLink3 from "terminal-link";
4630
4916
  var BackgroundWorkerCoordinator = class {
4631
4917
  constructor(baseURL) {
@@ -4825,7 +5111,7 @@ var BackgroundWorker = class {
4825
5111
  ...this.#readEnvVars()
4826
5112
  };
4827
5113
  logger.debug("Initializing worker", { path: this.path, cwd, fullEnv });
4828
- this.tasks = await new Promise((resolve4, reject) => {
5114
+ this.tasks = await new Promise((resolve5, reject) => {
4829
5115
  const child = fork(this.path, {
4830
5116
  stdio: [
4831
5117
  /*stdin*/
@@ -4852,7 +5138,7 @@ var BackgroundWorker = class {
4852
5138
  if (message.type === "TASKS_READY" && !resolved) {
4853
5139
  clearTimeout(timeout);
4854
5140
  resolved = true;
4855
- resolve4(message.payload.tasks);
5141
+ resolve5(message.payload.tasks);
4856
5142
  child.kill();
4857
5143
  } else if (message.type === "UNCAUGHT_EXCEPTION") {
4858
5144
  clearTimeout(timeout);
@@ -4987,7 +5273,7 @@ var BackgroundWorker = class {
4987
5273
  const result = {};
4988
5274
  dotenv.config({
4989
5275
  processEnv: result,
4990
- path: [".env", ".env.local", ".env.development.local"].map((p) => resolve2(process.cwd(), p))
5276
+ path: [".env", ".env.local", ".env.development.local"].map((p) => resolve3(process.cwd(), p))
4991
5277
  });
4992
5278
  process.env.TRIGGER_API_URL && (result.TRIGGER_API_URL = process.env.TRIGGER_API_URL);
4993
5279
  delete result.TRIGGER_API_URL;
@@ -5088,8 +5374,8 @@ var TaskRunProcess = class {
5088
5374
  async executeTaskRun(payload) {
5089
5375
  let resolver;
5090
5376
  let rejecter;
5091
- const promise = new Promise((resolve4, reject) => {
5092
- resolver = resolve4;
5377
+ const promise = new Promise((resolve5, reject) => {
5378
+ resolver = resolve5;
5093
5379
  rejecter = reject;
5094
5380
  });
5095
5381
  this._attemptStatuses.set(payload.execution.attempt.id, "PENDING");
@@ -5235,14 +5521,15 @@ var DevCommandOptions = CommonCommandOptions.extend({
5235
5521
  debugger: z5.boolean().default(false),
5236
5522
  debugOtel: z5.boolean().default(false),
5237
5523
  config: z5.string().optional(),
5238
- projectRef: z5.string().optional()
5524
+ projectRef: z5.string().optional(),
5525
+ skipUpdateCheck: z5.boolean().default(false)
5239
5526
  });
5240
5527
  function configureDevCommand(program2) {
5241
5528
  return commonOptions(
5242
5529
  program2.command("dev").description("Run your Trigger.dev tasks locally").argument("[path]", "The path to the project", ".").option("-c, --config <config file>", "The name of the config file, found at [path].").option(
5243
5530
  "-p, --project-ref <project ref>",
5244
5531
  "The project ref. Required if there is no config file."
5245
- ).option("--debugger", "Enable the debugger").option("--debug-otel", "Enable OpenTelemetry debugging")
5532
+ ).option("--debugger", "Enable the debugger").option("--debug-otel", "Enable OpenTelemetry debugging").option("--skip-update-check", "Skip checking for @trigger.dev package updates")
5246
5533
  ).action(async (path7, options) => {
5247
5534
  wrapCommandAction("dev", DevCommandOptions, options, async (opts) => {
5248
5535
  await devCommand(path7, opts);
@@ -5284,7 +5571,11 @@ async function startDev(dir, options, authorization, dashboardUrl) {
5284
5571
  logger.loggerLevel = options.logLevel;
5285
5572
  }
5286
5573
  await printStandloneInitialBanner(true);
5287
- printDevBanner();
5574
+ if (!options.skipUpdateCheck) {
5575
+ console.log();
5576
+ await updateTriggerPackages(dir, { ...options }, false, true);
5577
+ }
5578
+ printDevBanner(!options.skipUpdateCheck);
5288
5579
  logger.debug("Starting dev session", { dir, options, authorization });
5289
5580
  let config = await readConfig(dir, {
5290
5581
  projectRef: options.projectRef,
@@ -5449,9 +5740,9 @@ function useDev({
5449
5740
  }
5450
5741
  let latestWorkerContentHash;
5451
5742
  const taskFiles = await gatherTaskFiles(config);
5452
- const workerFacadePath = join6(cliRootPath(), "workers", "dev", "worker-facade.js");
5743
+ const workerFacadePath = join7(cliRootPath(), "workers", "dev", "worker-facade.js");
5453
5744
  const workerFacade = readFileSync3(workerFacadePath, "utf-8");
5454
- const workerSetupPath = join6(cliRootPath(), "workers", "dev", "worker-setup.js");
5745
+ const workerSetupPath = join7(cliRootPath(), "workers", "dev", "worker-setup.js");
5455
5746
  let entryPointContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace(
5456
5747
  "__WORKER_SETUP__",
5457
5748
  `import { tracingSDK, sender } from "${escapeImportPath(workerSetupPath)}";`
@@ -5516,7 +5807,7 @@ function useDev({
5516
5807
  if (!firstBuild) {
5517
5808
  logger.log(chalkGrey("\u25CB Building background worker\u2026"));
5518
5809
  }
5519
- const metaOutputKey = join6("out", `stdin.js`).replace(/\\/g, "/");
5810
+ const metaOutputKey = join7("out", `stdin.js`).replace(/\\/g, "/");
5520
5811
  logger.debug("Metafile", {
5521
5812
  metafileOutputs: JSON.stringify(result.metafile?.outputs)
5522
5813
  });
@@ -5524,14 +5815,14 @@ function useDev({
5524
5815
  if (!metaOutput) {
5525
5816
  throw new Error(`Could not find metafile`);
5526
5817
  }
5527
- const outputFileKey = join6(config.projectDir, metaOutputKey);
5818
+ const outputFileKey = join7(config.projectDir, metaOutputKey);
5528
5819
  const outputFile = result.outputFiles.find((file) => file.path === outputFileKey);
5529
5820
  if (!outputFile) {
5530
5821
  throw new Error(
5531
5822
  `Could not find output file for entry point ${metaOutput.entryPoint}`
5532
5823
  );
5533
5824
  }
5534
- const sourceMapFileKey = join6(config.projectDir, `${metaOutputKey}.map`);
5825
+ const sourceMapFileKey = join7(config.projectDir, `${metaOutputKey}.map`);
5535
5826
  const sourceMapFile = result.outputFiles.find(
5536
5827
  (file) => file.path === sourceMapFileKey
5537
5828
  );
@@ -5542,10 +5833,10 @@ function useDev({
5542
5833
  logger.log(chalkGrey("\u25CB No changes detected, skipping build\u2026"));
5543
5834
  return;
5544
5835
  }
5545
- const fullPath = join6(config.projectDir, ".trigger", `${contentHash}.js`);
5836
+ const fullPath = join7(config.projectDir, ".trigger", `${contentHash}.js`);
5546
5837
  const sourceMapPath = `${fullPath}.map`;
5547
5838
  const outputFileWithSourceMap = `${outputFile.text}
5548
- //# sourceMappingURL=${basename(sourceMapPath)}`;
5839
+ //# sourceMappingURL=${basename2(sourceMapPath)}`;
5549
5840
  await fs7.promises.mkdir(dirname3(fullPath), { recursive: true });
5550
5841
  await fs7.promises.writeFile(fullPath, outputFileWithSourceMap);
5551
5842
  logger.debug(`Wrote background worker to ${fullPath}`);
@@ -5749,7 +6040,7 @@ async function gatherRequiredDependencies2(outputMeta, config) {
5749
6040
  }
5750
6041
  }
5751
6042
  if (config.additionalPackages) {
5752
- const projectPackageJson = await readJSONFile(join6(config.projectDir, "package.json"));
6043
+ const projectPackageJson = await readJSONFile(join7(config.projectDir, "package.json"));
5753
6044
  for (const packageName of config.additionalPackages) {
5754
6045
  if (dependencies2[packageName]) {
5755
6046
  continue;
@@ -5819,7 +6110,7 @@ async function amendNodePathWithPnpmNodeModules(nodePath) {
5819
6110
  async function findPnpmNodeModulesPath() {
5820
6111
  return await findUp3(
5821
6112
  async (directory) => {
5822
- const pnpmModules = join6(directory, "node_modules", ".pnpm", "node_modules");
6113
+ const pnpmModules = join7(directory, "node_modules", ".pnpm", "node_modules");
5823
6114
  const hasPnpmNodeModules = await pathExists2(pnpmModules);
5824
6115
  if (hasPnpmNodeModules) {
5825
6116
  return pnpmModules;
@@ -5830,7 +6121,7 @@ async function findPnpmNodeModulesPath() {
5830
6121
  }
5831
6122
 
5832
6123
  // src/commands/init.ts
5833
- import { intro as intro4, isCancel, log as log4, outro as outro4, select as select2, text } from "@clack/prompts";
6124
+ import { intro as intro5, isCancel as isCancel2, log as log6, outro as outro5, select as select2, text } from "@clack/prompts";
5834
6125
  import { context as context3, trace as trace3 } from "@opentelemetry/api";
5835
6126
  import {
5836
6127
  flattenAttributes as flattenAttributes3,
@@ -5840,7 +6131,7 @@ import chalk6 from "chalk";
5840
6131
  import { execa as execa3 } from "execa";
5841
6132
  import { applyEdits, modify } from "jsonc-parser";
5842
6133
  import { writeFile as writeFile3 } from "node:fs/promises";
5843
- import { join as join7, relative as relative4, resolve as resolve3 } from "node:path";
6134
+ import { join as join8, relative as relative4, resolve as resolve4 } from "node:path";
5844
6135
  import terminalLink4 from "terminal-link";
5845
6136
  import { z as z6 } from "zod";
5846
6137
 
@@ -5916,7 +6207,7 @@ async function initCommand(dir, options) {
5916
6207
  }
5917
6208
  async function _initCommand(dir, options) {
5918
6209
  const span = trace3.getSpan(context3.active());
5919
- intro4("Initializing project");
6210
+ intro5("Initializing project");
5920
6211
  const authorization = await login({
5921
6212
  embedded: true,
5922
6213
  defaultApiUrl: options.apiUrl,
@@ -5940,7 +6231,7 @@ async function _initCommand(dir, options) {
5940
6231
  if (!options.overrideConfig) {
5941
6232
  try {
5942
6233
  const result = await readConfig(dir);
5943
- outro4(
6234
+ outro5(
5944
6235
  result.status === "file" ? `Project already initialized: Found config file at ${result.path}. Pass --override-config to override` : "Project already initialized"
5945
6236
  );
5946
6237
  return;
@@ -5957,11 +6248,11 @@ async function _initCommand(dir, options) {
5957
6248
  ...flattenAttributes3(selectedProject, "cli.project")
5958
6249
  });
5959
6250
  logger.debug("Selected project", selectedProject);
5960
- log4.step(`Configuring project "${selectedProject.name}" (${selectedProject.externalRef})`);
6251
+ log6.step(`Configuring project "${selectedProject.name}" (${selectedProject.externalRef})`);
5961
6252
  if (!options.skipPackageInstall) {
5962
6253
  await installPackages2(dir, options);
5963
6254
  } else {
5964
- log4.info("Skipping package installation");
6255
+ log6.info("Skipping package installation");
5965
6256
  }
5966
6257
  const triggerDir = await createTriggerDir(dir, options);
5967
6258
  await writeConfigFile(dir, selectedProject, options, triggerDir);
@@ -5971,41 +6262,41 @@ async function _initCommand(dir, options) {
5971
6262
  "project dashboard",
5972
6263
  `${authorization.dashboardUrl}/projects/v3/${selectedProject.externalRef}`
5973
6264
  );
5974
- log4.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
5975
- log4.info("Next steps:");
5976
- log4.info(
6265
+ log6.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
6266
+ log6.info("Next steps:");
6267
+ log6.info(
5977
6268
  ` 1. To start developing, run ${chalk6.green(
5978
6269
  `npx trigger.dev@${options.tag} dev`
5979
6270
  )} in your project directory`
5980
6271
  );
5981
- log4.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
5982
- log4.info(
6272
+ log6.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
6273
+ log6.info(
5983
6274
  ` 3. Head over to our ${terminalLink4(
5984
6275
  "v3 docs",
5985
6276
  "https://trigger.dev/docs/v3"
5986
6277
  )} to learn more.`
5987
6278
  );
5988
- log4.info(
6279
+ log6.info(
5989
6280
  ` 4. Need help? Join our ${terminalLink4(
5990
6281
  "Discord community",
5991
6282
  "https://trigger.dev/discord"
5992
6283
  )} or email us at ${chalk6.cyan("help@trigger.dev")}`
5993
6284
  );
5994
- outro4(`Project initialized successfully. Happy coding!`);
6285
+ outro5(`Project initialized successfully. Happy coding!`);
5995
6286
  }
5996
6287
  async function createTriggerDir(dir, options) {
5997
6288
  return await tracer.startActiveSpan("createTriggerDir", async (span) => {
5998
6289
  try {
5999
- const defaultValue = join7(dir, "src", "trigger");
6290
+ const defaultValue = join8(dir, "src", "trigger");
6000
6291
  const location = await text({
6001
6292
  message: "Where would you like to create the Trigger.dev directory?",
6002
6293
  defaultValue,
6003
6294
  placeholder: defaultValue
6004
6295
  });
6005
- if (isCancel(location)) {
6296
+ if (isCancel2(location)) {
6006
6297
  throw new OutroCommandError();
6007
6298
  }
6008
- const triggerDir = resolve3(process.cwd(), location);
6299
+ const triggerDir = resolve4(process.cwd(), location);
6009
6300
  logger.debug({ triggerDir });
6010
6301
  span.setAttributes({
6011
6302
  "cli.triggerDir": triggerDir
@@ -6024,7 +6315,7 @@ async function createTriggerDir(dir, options) {
6024
6315
  }
6025
6316
  ]
6026
6317
  });
6027
- if (isCancel(exampleSelection)) {
6318
+ if (isCancel2(exampleSelection)) {
6028
6319
  throw new OutroCommandError();
6029
6320
  }
6030
6321
  const example = exampleSelection;
@@ -6032,20 +6323,20 @@ async function createTriggerDir(dir, options) {
6032
6323
  "cli.example": example
6033
6324
  });
6034
6325
  if (example === "none") {
6035
- await createFile(join7(triggerDir, ".gitkeep"), "");
6036
- log4.step(`Created directory at ${location}`);
6326
+ await createFile(join8(triggerDir, ".gitkeep"), "");
6327
+ log6.step(`Created directory at ${location}`);
6037
6328
  span.end();
6038
6329
  return { location, isCustomValue: location !== defaultValue };
6039
6330
  }
6040
- const templatePath = join7(cliRootPath(), "templates", "examples", `${example}.ts.template`);
6041
- const outputPath = join7(triggerDir, "example.ts");
6331
+ const templatePath = join8(cliRootPath(), "templates", "examples", `${example}.ts.template`);
6332
+ const outputPath = join8(triggerDir, "example.ts");
6042
6333
  await createFileFromTemplate({
6043
6334
  templatePath,
6044
6335
  outputPath,
6045
6336
  replacements: {}
6046
6337
  });
6047
6338
  const relativeOutputPath = relative4(process.cwd(), outputPath);
6048
- log4.step(`Created example file at ${relativeOutputPath}`);
6339
+ log6.step(`Created example file at ${relativeOutputPath}`);
6049
6340
  span.end();
6050
6341
  return { location, isCustomValue: location !== defaultValue };
6051
6342
  } catch (e) {
@@ -6060,15 +6351,15 @@ async function createTriggerDir(dir, options) {
6060
6351
  async function gitIgnoreDotTriggerDir(dir, options) {
6061
6352
  return await tracer.startActiveSpan("gitIgnoreDotTriggerDir", async (span) => {
6062
6353
  try {
6063
- const projectDir = resolve3(process.cwd(), dir);
6064
- const gitIgnorePath = join7(projectDir, ".gitignore");
6354
+ const projectDir = resolve4(process.cwd(), dir);
6355
+ const gitIgnorePath = join8(projectDir, ".gitignore");
6065
6356
  span.setAttributes({
6066
6357
  "cli.projectDir": projectDir,
6067
6358
  "cli.gitIgnorePath": gitIgnorePath
6068
6359
  });
6069
6360
  if (!await pathExists(gitIgnorePath)) {
6070
6361
  await createFile(gitIgnorePath, ".trigger");
6071
- log4.step(`Added .trigger to .gitignore`);
6362
+ log6.step(`Added .trigger to .gitignore`);
6072
6363
  span.end();
6073
6364
  return;
6074
6365
  }
@@ -6080,7 +6371,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
6080
6371
  const newGitIgnoreContent = `${gitIgnoreContent}
6081
6372
  .trigger`;
6082
6373
  await writeFile3(gitIgnorePath, newGitIgnoreContent, "utf-8");
6083
- log4.step(`Added .trigger to .gitignore`);
6374
+ log6.step(`Added .trigger to .gitignore`);
6084
6375
  span.end();
6085
6376
  } catch (e) {
6086
6377
  if (!(e instanceof SkipCommandError)) {
@@ -6094,8 +6385,8 @@ async function gitIgnoreDotTriggerDir(dir, options) {
6094
6385
  async function addConfigFileToTsConfig(dir, options) {
6095
6386
  return await tracer.startActiveSpan("createTriggerDir", async (span) => {
6096
6387
  try {
6097
- const projectDir = resolve3(process.cwd(), dir);
6098
- const tsconfigPath = join7(projectDir, "tsconfig.json");
6388
+ const projectDir = resolve4(process.cwd(), dir);
6389
+ const tsconfigPath = join8(projectDir, "tsconfig.json");
6099
6390
  span.setAttributes({
6100
6391
  "cli.projectDir": projectDir,
6101
6392
  "cli.tsconfigPath": tsconfigPath
@@ -6113,7 +6404,7 @@ async function addConfigFileToTsConfig(dir, options) {
6113
6404
  const newTsconfigContent = applyEdits(tsconfigContent, edits);
6114
6405
  logger.debug("new tsconfig.json content", { newTsconfigContent });
6115
6406
  await writeFile3(tsconfigPath, newTsconfigContent, "utf-8");
6116
- log4.step(`Added trigger.config.ts to tsconfig.json`);
6407
+ log6.step(`Added trigger.config.ts to tsconfig.json`);
6117
6408
  span.end();
6118
6409
  } catch (e) {
6119
6410
  if (!(e instanceof SkipCommandError)) {
@@ -6128,7 +6419,7 @@ async function installPackages2(dir, options) {
6128
6419
  return await tracer.startActiveSpan("installPackages", async (span) => {
6129
6420
  const installSpinner = spinner();
6130
6421
  try {
6131
- const projectDir = resolve3(process.cwd(), dir);
6422
+ const projectDir = resolve4(process.cwd(), dir);
6132
6423
  const pkgManager = await getUserPackageManager(projectDir);
6133
6424
  span.setAttributes({
6134
6425
  "cli.projectDir": projectDir,
@@ -6180,9 +6471,9 @@ async function writeConfigFile(dir, project, options, triggerDir) {
6180
6471
  try {
6181
6472
  const spnnr = spinner();
6182
6473
  spnnr.start("Creating config file");
6183
- const projectDir = resolve3(process.cwd(), dir);
6184
- const templatePath = join7(cliRootPath(), "templates", "trigger.config.ts.template");
6185
- const outputPath = join7(projectDir, "trigger.config.ts");
6474
+ const projectDir = resolve4(process.cwd(), dir);
6475
+ const templatePath = join8(cliRootPath(), "templates", "trigger.config.ts.template");
6476
+ const outputPath = join8(projectDir, "trigger.config.ts");
6186
6477
  span.setAttributes({
6187
6478
  "cli.projectDir": projectDir,
6188
6479
  "cli.templatePath": templatePath,
@@ -6222,7 +6513,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
6222
6513
  if (projectRef) {
6223
6514
  const projectResponse = await apiClient2.getProject(projectRef);
6224
6515
  if (!projectResponse.success) {
6225
- log4.error(
6516
+ log6.error(
6226
6517
  `--project-ref ${projectRef} is not a valid project ref. Request to fetch data resulted in: ${projectResponse.error}`
6227
6518
  );
6228
6519
  throw new SkipCommandError(projectResponse.error);
@@ -6242,7 +6533,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
6242
6533
  "Create new project",
6243
6534
  `${dashboardUrl}/projects/new?version=v3`
6244
6535
  );
6245
- outro4(`You don't have any projects yet. ${newProjectLink}`);
6536
+ outro5(`You don't have any projects yet. ${newProjectLink}`);
6246
6537
  throw new SkipCommandError();
6247
6538
  }
6248
6539
  const selectedProject = await select2({
@@ -6253,7 +6544,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
6253
6544
  hint: project.organization.title
6254
6545
  }))
6255
6546
  });
6256
- if (isCancel(selectedProject)) {
6547
+ if (isCancel2(selectedProject)) {
6257
6548
  throw new OutroCommandError();
6258
6549
  }
6259
6550
  const projectData = projectsResponse.data.find(
@@ -6305,7 +6596,7 @@ async function logout(options) {
6305
6596
  }
6306
6597
 
6307
6598
  // src/commands/list-profiles.ts
6308
- import { log as log5, outro as outro5 } from "@clack/prompts";
6599
+ import { log as log7, outro as outro6 } from "@clack/prompts";
6309
6600
  var ListProfilesOptions = CommonCommandOptions;
6310
6601
  function configureListProfilesCommand(program2) {
6311
6602
  return program2.command("list-profiles").description("List all of your CLI profiles").option(
@@ -6331,12 +6622,12 @@ async function listProfiles(options) {
6331
6622
  return;
6332
6623
  }
6333
6624
  const profiles = Object.keys(authConfig);
6334
- log5.message("Profiles:");
6625
+ log7.message("Profiles:");
6335
6626
  for (const profile of profiles) {
6336
6627
  const profileConfig = authConfig[profile];
6337
- log5.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
6628
+ log7.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
6338
6629
  }
6339
- outro5("Retrieve account info by running whoami --profile <profile>");
6630
+ outro6("Retrieve account info by running whoami --profile <profile>");
6340
6631
  }
6341
6632
 
6342
6633
  // src/cli/index.ts
@@ -6349,6 +6640,7 @@ configureDeployCommand(program);
6349
6640
  configureWhoamiCommand(program);
6350
6641
  configureLogoutCommand(program);
6351
6642
  configureListProfilesCommand(program);
6643
+ configureUpdateCommand(program);
6352
6644
 
6353
6645
  // src/index.ts
6354
6646
  var main = async () => {