trigger.dev 0.0.0-v3-update-command-20240423125505 → 0.0.0-v3-prerelease-20240424094958

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,16 +777,15 @@ var require_retry2 = __commonJS({
777
777
  import { Command as Command2 } from "commander";
778
778
 
779
779
  // src/commands/deploy.ts
780
- import { intro as intro4, log as log5, outro as outro4 } from "@clack/prompts";
780
+ import { intro as intro4, log as log5, outro as outro5 } from "@clack/prompts";
781
781
  import { depot } from "@depot/cli";
782
782
  import { context, trace as trace2 } from "@opentelemetry/api";
783
783
  import {
784
784
  TaskMetadataFailedToParseData,
785
785
  detectDependencyVersion,
786
- flattenAttributes as flattenAttributes2,
787
- recordSpanException as recordSpanException4
786
+ flattenAttributes as flattenAttributes2
788
787
  } from "@trigger.dev/core/v3";
789
- import chalk5 from "chalk";
788
+ import { recordSpanException as recordSpanException4 } from "@trigger.dev/core/v3/workers";
790
789
  import { Option as CommandOption } from "commander";
791
790
  import { build as build2 } from "esbuild";
792
791
  import { execa as execa2 } from "execa";
@@ -797,10 +796,10 @@ import { dirname, join as join6, relative as relative3, posix } from "node:path"
797
796
  import { setTimeout as setTimeout2 } from "node:timers/promises";
798
797
  import terminalLink2 from "terminal-link";
799
798
  import invariant from "tiny-invariant";
800
- import { z as z5 } from "zod";
799
+ import { z as z4 } from "zod";
801
800
 
802
801
  // package.json
803
- var version = "0.0.0-v3-update-command-20240423125505";
802
+ var version = "0.0.0-v3-prerelease-20240424094958";
804
803
  var dependencies = {
805
804
  "@clack/prompts": "^0.7.0",
806
805
  "@depot/cli": "0.0.1-cli.2.55.0",
@@ -816,7 +815,7 @@ var dependencies = {
816
815
  "@opentelemetry/sdk-trace-base": "^1.22.0",
817
816
  "@opentelemetry/sdk-trace-node": "^1.22.0",
818
817
  "@opentelemetry/semantic-conventions": "^1.22.0",
819
- "@trigger.dev/core": "workspace:0.0.0-v3-update-command-20240423125505",
818
+ "@trigger.dev/core": "workspace:0.0.0-v3-prerelease-20240424094958",
820
819
  "@types/degit": "^2.8.3",
821
820
  chalk: "^5.2.0",
822
821
  chokidar: "^3.5.3",
@@ -837,7 +836,6 @@ var dependencies = {
837
836
  "mock-fs": "^5.2.0",
838
837
  nanoid: "^4.0.2",
839
838
  "node-fetch": "^3.3.0",
840
- "npm-check-updates": "^16.12.2",
841
839
  "object-hash": "^3.0.0",
842
840
  "p-debounce": "^4.0.0",
843
841
  "p-throttle": "^6.1.0",
@@ -1141,7 +1139,8 @@ async function zodfetch(schema, url, requestInit) {
1141
1139
  }
1142
1140
 
1143
1141
  // src/cli/common.ts
1144
- import { flattenAttributes, recordSpanException } from "@trigger.dev/core/v3";
1142
+ import { flattenAttributes } from "@trigger.dev/core/v3";
1143
+ import { recordSpanException } from "@trigger.dev/core/v3/workers";
1145
1144
  import { z } from "zod";
1146
1145
 
1147
1146
  // src/telemetry/tracing.ts
@@ -1151,6 +1150,10 @@ import { Resource, detectResourcesSync, processDetectorSync } from "@opentelemet
1151
1150
  import { NodeTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
1152
1151
  import { FetchInstrumentation } from "@opentelemetry/instrumentation-fetch";
1153
1152
  import { DiagConsoleLogger, DiagLogLevel, diag, trace } from "@opentelemetry/api";
1153
+ import {
1154
+ SEMRESATTRS_SERVICE_NAME,
1155
+ SEMRESATTRS_SERVICE_VERSION
1156
+ } from "@opentelemetry/semantic-conventions";
1154
1157
  function initializeTracing() {
1155
1158
  if (process.argv.includes("--skip-telemetry") || process.env.TRIGGER_DEV_SKIP_TELEMETRY) {
1156
1159
  return;
@@ -1162,7 +1165,8 @@ function initializeTracing() {
1162
1165
  detectors: [processDetectorSync]
1163
1166
  }).merge(
1164
1167
  new Resource({
1165
- service: "trigger.dev cli v3"
1168
+ [SEMRESATTRS_SERVICE_NAME]: "trigger.dev cli v3",
1169
+ [SEMRESATTRS_SERVICE_VERSION]: version
1166
1170
  })
1167
1171
  );
1168
1172
  const traceProvider = new NodeTracerProvider({
@@ -1179,10 +1183,9 @@ function initializeTracing() {
1179
1183
  });
1180
1184
  const spanExporter = new OTLPTraceExporter({
1181
1185
  url: "https://otel.baselime.io/v1",
1182
- timeoutMillis: 500,
1186
+ timeoutMillis: 5e3,
1183
1187
  headers: {
1184
- "x-api-key": "e9f963244f8b092850d42e34a5339b2d5e68070b".split("").reverse().join("")
1185
- // this is a joke
1188
+ "x-api-key": "b6e0fbbaf8dc2524773d2152ae2e9eb5c7fbaa52"
1186
1189
  }
1187
1190
  });
1188
1191
  const spanProcessor = new SimpleSpanProcessor(spanExporter);
@@ -1195,7 +1198,7 @@ function initializeTracing() {
1195
1198
  }
1196
1199
  var provider = initializeTracing();
1197
1200
  function getTracer() {
1198
- return trace.getTracer("trigger.dev cli", version);
1201
+ return trace.getTracer("trigger.dev cli v3", version);
1199
1202
  }
1200
1203
 
1201
1204
  // src/cli/common.ts
@@ -1367,6 +1370,18 @@ function prettyPrintDate(date = /* @__PURE__ */ new Date()) {
1367
1370
  formattedDate += "." + ("00" + date.getMilliseconds()).slice(-3);
1368
1371
  return formattedDate;
1369
1372
  }
1373
+ function prettyError(header, body, footer) {
1374
+ const prefix = "Error: ";
1375
+ const indent = Array(prefix.length).fill(" ").join("");
1376
+ const spacing = "\n\n";
1377
+ const prettyPrefix = chalkError(prefix);
1378
+ const withIndents = (text3) => text3?.split("\n").map((line) => `${indent}${line}`).join("\n");
1379
+ const prettyBody = withIndents(body);
1380
+ const prettyFooter = withIndents(footer);
1381
+ log.error(
1382
+ `${prettyPrefix}${header}${prettyBody ? `${spacing}${prettyBody}` : ""}${prettyFooter ? `${spacing}${prettyFooter}` : ""}`
1383
+ );
1384
+ }
1370
1385
  function prettyWarning(header, body, footer) {
1371
1386
  const prefix = "Warning: ";
1372
1387
  const indent = Array(prefix.length).fill(" ").join("");
@@ -1529,14 +1544,23 @@ function createTaskFileImports(taskFiles) {
1529
1544
  async function gatherTaskFiles(config) {
1530
1545
  const taskFiles = [];
1531
1546
  for (const triggerDir of config.triggerDirectories) {
1532
- const files = await fs2.promises.readdir(triggerDir, { withFileTypes: true });
1533
- for (const file of files) {
1534
- if (!file.isFile())
1535
- continue;
1547
+ const files = await gatherTaskFilesFromDir(triggerDir, triggerDir, config);
1548
+ taskFiles.push(...files);
1549
+ }
1550
+ return taskFiles;
1551
+ }
1552
+ async function gatherTaskFilesFromDir(dirPath, triggerDir, config) {
1553
+ const taskFiles = [];
1554
+ const files = await fs2.promises.readdir(dirPath, { withFileTypes: true });
1555
+ for (const file of files) {
1556
+ if (!file.isFile()) {
1557
+ const fullPath = join(dirPath, file.name);
1558
+ taskFiles.push(...await gatherTaskFilesFromDir(fullPath, triggerDir, config));
1559
+ } else {
1536
1560
  if (!file.name.endsWith(".js") && !file.name.endsWith(".ts") && !file.name.endsWith(".jsx") && !file.name.endsWith(".tsx")) {
1537
1561
  continue;
1538
1562
  }
1539
- const fullPath = join(triggerDir, file.name);
1563
+ const fullPath = join(dirPath, file.name);
1540
1564
  const filePath = relative(config.projectDir, fullPath);
1541
1565
  const importName = filePath.replace(/\..+$/, "").replace(/[^a-zA-Z0-9_$]/g, "_");
1542
1566
  const importPath = filePath.replace(/\\/g, "/");
@@ -1556,9 +1580,12 @@ async function getTriggerDirectories(dirPath) {
1556
1580
  const entries = await fs2.promises.readdir(dirPath, { withFileTypes: true });
1557
1581
  const triggerDirectories = [];
1558
1582
  for (const entry of entries) {
1559
- if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name))
1583
+ if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name) || entry.name.startsWith("."))
1560
1584
  continue;
1561
1585
  const fullPath = join(dirPath, entry.name);
1586
+ if (fullPath.endsWith("app/api/trigger")) {
1587
+ continue;
1588
+ }
1562
1589
  if (entry.name === "trigger") {
1563
1590
  triggerDirectories.push(fullPath);
1564
1591
  }
@@ -1632,6 +1659,15 @@ async function getConfigPath(dir, fileName) {
1632
1659
  });
1633
1660
  return await findUp(fileName ? [fileName] : CONFIG_FILES, { cwd: dir });
1634
1661
  }
1662
+ async function findFilePath(dir, fileName) {
1663
+ const result = await findUp([fileName], { cwd: dir });
1664
+ logger.debug("Searched for the file", {
1665
+ dir,
1666
+ fileName,
1667
+ result
1668
+ });
1669
+ return result;
1670
+ }
1635
1671
  async function readConfig(dir, options) {
1636
1672
  const absoluteDir = path2.resolve(process.cwd(), dir);
1637
1673
  const configPath = await getConfigPath(dir, options?.configFile);
@@ -1684,6 +1720,7 @@ async function resolveConfig(path7, config) {
1684
1720
  config.triggerDirectories = await findTriggerDirectories(path7);
1685
1721
  }
1686
1722
  config.triggerDirectories = resolveTriggerDirectories(config.triggerDirectories);
1723
+ logger.debug("Resolved trigger directories", { triggerDirectories: config.triggerDirectories });
1687
1724
  if (!config.triggerUrl) {
1688
1725
  config.triggerUrl = CLOUD_API_URL;
1689
1726
  }
@@ -1691,7 +1728,7 @@ async function resolveConfig(path7, config) {
1691
1728
  config.projectDir = path7;
1692
1729
  }
1693
1730
  if (!config.tsconfigPath) {
1694
- config.tsconfigPath = await getConfigPath(path7, "tsconfig.json");
1731
+ config.tsconfigPath = await findFilePath(path7, "tsconfig.json");
1695
1732
  }
1696
1733
  return config;
1697
1734
  }
@@ -1860,8 +1897,8 @@ async function setPackageJsonDeps(path7, deps) {
1860
1897
  }
1861
1898
 
1862
1899
  // src/commands/login.ts
1863
- import { intro as intro2, log as log3, outro as outro2, select } from "@clack/prompts";
1864
- import { recordSpanException as recordSpanException3 } from "@trigger.dev/core/v3";
1900
+ import { intro as intro2, log as log3, outro as outro3, select } from "@clack/prompts";
1901
+ import { recordSpanException as recordSpanException3 } from "@trigger.dev/core/v3/workers";
1865
1902
 
1866
1903
  // ../../node_modules/.pnpm/open@10.0.3/node_modules/open/index.js
1867
1904
  import process6 from "node:process";
@@ -2408,10 +2445,10 @@ async function pRetry(input, options) {
2408
2445
  import { z as z3 } from "zod";
2409
2446
 
2410
2447
  // src/commands/whoami.ts
2411
- import { intro, note } from "@clack/prompts";
2448
+ import { intro, note, outro as outro2 } from "@clack/prompts";
2412
2449
 
2413
2450
  // src/utilities/session.ts
2414
- import { recordSpanException as recordSpanException2 } from "@trigger.dev/core/v3";
2451
+ import { recordSpanException as recordSpanException2 } from "@trigger.dev/core/v3/workers";
2415
2452
  var tracer2 = getTracer();
2416
2453
  async function isLoggedIn(profile = "default") {
2417
2454
  return await tracer2.startActiveSpan("isLoggedIn", async (span) => {
@@ -2493,9 +2530,16 @@ async function whoAmI(options, embedded = false) {
2493
2530
  if (authentication.error === "fetch failed") {
2494
2531
  loadingSpinner.stop("Fetch failed. Platform down?");
2495
2532
  } else {
2496
- loadingSpinner.stop(
2497
- `You must login first. Use \`trigger.dev login --profile ${options?.profile ?? "default"}\` to login.`
2498
- );
2533
+ if (embedded) {
2534
+ loadingSpinner.stop(
2535
+ `Failed to check account details. You may want to run \`trigger.dev logout --profile ${options?.profile ?? "default"}\` and try again.`
2536
+ );
2537
+ } else {
2538
+ loadingSpinner.stop(
2539
+ `You must login first. Use \`trigger.dev login --profile ${options?.profile ?? "default"}\` to login.`
2540
+ );
2541
+ outro2("Whoami failed");
2542
+ }
2499
2543
  }
2500
2544
  return {
2501
2545
  success: false,
@@ -2591,9 +2635,13 @@ async function login(options) {
2591
2635
  skipTelemetry: !span.isRecording(),
2592
2636
  logLevel: logger.loggerLevel
2593
2637
  },
2594
- opts.embedded
2638
+ true
2595
2639
  );
2596
2640
  if (!whoAmIResult.success) {
2641
+ prettyError("Whoami failed", whoAmIResult.error);
2642
+ if (!opts.embedded) {
2643
+ outro3("Login failed");
2644
+ }
2597
2645
  throw new Error(whoAmIResult.error);
2598
2646
  } else {
2599
2647
  if (!opts.embedded) {
@@ -2612,7 +2660,7 @@ async function login(options) {
2612
2660
  initialValue: false
2613
2661
  });
2614
2662
  if (continueOption !== true) {
2615
- outro2("Already logged in");
2663
+ outro3("Already logged in");
2616
2664
  span.setAttributes({
2617
2665
  "cli.userId": whoAmIResult.data.userId,
2618
2666
  "cli.email": whoAmIResult.data.email,
@@ -2693,7 +2741,7 @@ ${chalkLink(authorizationCodeResult.url)}`
2693
2741
  if (opts.embedded) {
2694
2742
  log3.step("Logged in successfully");
2695
2743
  } else {
2696
- outro2("Logged in successfully");
2744
+ outro3("Logged in successfully");
2697
2745
  }
2698
2746
  span.end();
2699
2747
  return {
@@ -2795,7 +2843,7 @@ function bundleTriggerDevCore(buildIdentifier, tsconfigPath) {
2795
2843
  name: "trigger-bundle-core",
2796
2844
  setup(build3) {
2797
2845
  build3.onResolve({ filter: /.*/ }, (args) => {
2798
- if (args.path !== "@trigger.dev/core/v3") {
2846
+ if (!args.path.startsWith("@trigger.dev/core/v3")) {
2799
2847
  return void 0;
2800
2848
  }
2801
2849
  const triggerSdkPath = __require.resolve("@trigger.dev/sdk/v3", { paths: [process.cwd()] });
@@ -2803,17 +2851,14 @@ function bundleTriggerDevCore(buildIdentifier, tsconfigPath) {
2803
2851
  ...args,
2804
2852
  triggerSdkPath
2805
2853
  });
2806
- const resolvedPath = __require.resolve("@trigger.dev/core/v3", {
2854
+ const resolvedPath = __require.resolve(args.path, {
2807
2855
  paths: [triggerSdkPath]
2808
2856
  });
2809
- logger.debug(
2810
- `[${buildIdentifier}][trigger-bundle-core] Externalizing @trigger.dev/core/v3`,
2811
- {
2812
- ...args,
2813
- triggerSdkPath,
2814
- resolvedPath
2815
- }
2816
- );
2857
+ logger.debug(`[${buildIdentifier}][trigger-bundle-core] Externalizing ${args.path}`, {
2858
+ ...args,
2859
+ triggerSdkPath,
2860
+ resolvedPath
2861
+ });
2817
2862
  return {
2818
2863
  path: resolvedPath,
2819
2864
  external: false
@@ -3329,7 +3374,7 @@ var PNPMCommands = class {
3329
3374
  async resolveDependencyVersion(packageName, options) {
3330
3375
  const { stdout } = await $({ cwd: options.cwd })`${this.cmd} list ${packageName} -r --json`;
3331
3376
  const result = JSON.parse(stdout);
3332
- logger.debug(`Resolving ${packageName} version using pnpm`, { result });
3377
+ logger.debug(`Resolving ${packageName} version using ${this.name}`, { result });
3333
3378
  for (const dep of result) {
3334
3379
  const dependency = dep.dependencies?.[packageName];
3335
3380
  if (dependency) {
@@ -3343,7 +3388,7 @@ var NPMCommands = class {
3343
3388
  return "npm";
3344
3389
  }
3345
3390
  get cmd() {
3346
- return process.platform === "win32" ? "pnpm.cmd" : "pnpm";
3391
+ return process.platform === "win32" ? "npm.cmd" : "npm";
3347
3392
  }
3348
3393
  async installDependencies(options) {
3349
3394
  const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
@@ -3352,7 +3397,7 @@ var NPMCommands = class {
3352
3397
  async resolveDependencyVersion(packageName, options) {
3353
3398
  const { stdout } = await $({ cwd: options.cwd })`${this.cmd} list ${packageName} --json`;
3354
3399
  const output = JSON.parse(stdout);
3355
- logger.debug(`Resolving ${packageName} version using npm`, { output });
3400
+ logger.debug(`Resolving ${packageName} version using ${this.name}`, { output });
3356
3401
  return this.#recursivelySearchDependencies(output.dependencies, packageName);
3357
3402
  }
3358
3403
  #recursivelySearchDependencies(dependencies2, packageName) {
@@ -3374,7 +3419,7 @@ var YarnCommands = class {
3374
3419
  return "yarn";
3375
3420
  }
3376
3421
  get cmd() {
3377
- return process.platform === "win32" ? "pnpm.cmd" : "pnpm";
3422
+ return process.platform === "win32" ? "yarn.cmd" : "yarn";
3378
3423
  }
3379
3424
  async installDependencies(options) {
3380
3425
  const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
@@ -3383,7 +3428,7 @@ var YarnCommands = class {
3383
3428
  async resolveDependencyVersion(packageName, options) {
3384
3429
  const { stdout } = await $({ cwd: options.cwd })`${this.cmd} info ${packageName} --json`;
3385
3430
  const lines = stdout.split("\n");
3386
- logger.debug(`Resolving ${packageName} version using yarn`, { lines });
3431
+ logger.debug(`Resolving ${packageName} version using ${this.name}`, { lines });
3387
3432
  for (const line of lines) {
3388
3433
  const json = JSON.parse(line);
3389
3434
  if (json.value === packageName) {
@@ -3403,9 +3448,7 @@ function cliRootPath() {
3403
3448
  }
3404
3449
 
3405
3450
  // src/commands/update.ts
3406
- import { confirm, intro as intro3, isCancel, log as log4, outro as outro3 } from "@clack/prompts";
3407
- import { run as ncuRun } from "npm-check-updates";
3408
- import { z as z4 } from "zod";
3451
+ import { confirm, intro as intro3, isCancel, log as log4, outro as outro4 } from "@clack/prompts";
3409
3452
  import { join as join5, resolve as resolve2 } from "path";
3410
3453
  var UpdateCommandOptions = CommonCommandOptions.pick({
3411
3454
  logLevel: true,
@@ -3423,7 +3466,6 @@ function configureUpdateCommand(program2) {
3423
3466
  });
3424
3467
  });
3425
3468
  }
3426
- var NcuRunResult = z4.record(z4.string());
3427
3469
  var triggerPackageFilter = /^@trigger\.dev/;
3428
3470
  async function updateCommand(dir, options) {
3429
3471
  await updateTriggerPackages(dir, options);
@@ -3443,8 +3485,9 @@ async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
3443
3485
  if (newCliVersion) {
3444
3486
  prettyWarning(
3445
3487
  "You're not running the latest CLI version, please consider updating ASAP",
3446
- "To update, run: `(p)npm i trigger.dev@beta`\nOr run with: `(p)npx trigger.dev@beta`",
3447
- "Yarn works too!"
3488
+ `Current: ${cliVersion}
3489
+ Latest: ${newCliVersion}`,
3490
+ "Run latest: npx trigger.dev@beta"
3448
3491
  );
3449
3492
  }
3450
3493
  const triggerDependencies = getTriggerDependencies(packageJson);
@@ -3461,7 +3504,7 @@ async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
3461
3504
  const versionMismatches = getVersionMismatches(triggerDependencies, cliVersion);
3462
3505
  if (versionMismatches.length === 0) {
3463
3506
  if (!embedded) {
3464
- outro3(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
3507
+ outro4(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
3465
3508
  }
3466
3509
  return;
3467
3510
  }
@@ -3470,7 +3513,7 @@ async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
3470
3513
  "We recommend pinned versions for guaranteed compatibility"
3471
3514
  );
3472
3515
  if (!process.stdout.isTTY) {
3473
- outro3("Deploy failed");
3516
+ outro4("Deploy failed");
3474
3517
  console.log(
3475
3518
  `ERROR: Version mismatch detected while running in CI. This won't end well. Aborting.
3476
3519
 
@@ -3493,17 +3536,17 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3493
3536
  }
3494
3537
  if (!userWantsToUpdate) {
3495
3538
  if (requireUpdate) {
3496
- outro3("You shall not pass!");
3539
+ outro4("You shall not pass!");
3497
3540
  logger.log(
3498
3541
  `${chalkError(
3499
3542
  "X Error:"
3500
- )} Update required: Version mismatches will cause errors and headaches. Don't use \`--skip-update-check\`, just update, please.
3543
+ )} Update required: Version mismatches are a common source of bugs and errors. Please update or use \`--skip-update-check\` at your own risk.
3501
3544
  `
3502
3545
  );
3503
3546
  process.exit(1);
3504
3547
  }
3505
3548
  if (!embedded) {
3506
- outro3("You've been warned!");
3549
+ outro4("You've been warned!");
3507
3550
  }
3508
3551
  return;
3509
3552
  }
@@ -3542,7 +3585,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3542
3585
  process.removeListener("exit", exitHandler);
3543
3586
  await removeFile(packageJsonBackupPath);
3544
3587
  if (!embedded) {
3545
- outro3(
3588
+ outro4(
3546
3589
  `Packages updated${newCliVersion ? " ..but you should really update your CLI too!" : ""}`
3547
3590
  );
3548
3591
  }
@@ -3560,6 +3603,10 @@ function getTriggerDependencies(packageJson) {
3560
3603
  if (!triggerPackageFilter.test(name)) {
3561
3604
  continue;
3562
3605
  }
3606
+ const ignoredPackages = ["@trigger.dev/companyicons"];
3607
+ if (ignoredPackages.includes(name)) {
3608
+ continue;
3609
+ }
3563
3610
  deps.push({ type, name, version: version2 });
3564
3611
  }
3565
3612
  }
@@ -3600,21 +3647,20 @@ async function getPackageJson(absoluteProjectPath) {
3600
3647
 
3601
3648
  // src/commands/deploy.ts
3602
3649
  var DeployCommandOptions = CommonCommandOptions.extend({
3603
- skipTypecheck: z5.boolean().default(false),
3604
- skipDeploy: z5.boolean().default(false),
3605
- ignoreEnvVarCheck: z5.boolean().default(false),
3606
- env: z5.enum(["prod", "staging"]),
3607
- loadImage: z5.boolean().default(false),
3608
- buildPlatform: z5.enum(["linux/amd64", "linux/arm64"]).default("linux/amd64"),
3609
- selfHosted: z5.boolean().default(false),
3610
- registry: z5.string().optional(),
3611
- push: z5.boolean().default(false),
3612
- config: z5.string().optional(),
3613
- projectRef: z5.string().optional(),
3614
- outputMetafile: z5.string().optional(),
3615
- apiUrl: z5.string().optional(),
3616
- saveLogs: z5.boolean().default(false),
3617
- skipUpdateCheck: z5.boolean().default(false)
3650
+ skipTypecheck: z4.boolean().default(false),
3651
+ skipDeploy: z4.boolean().default(false),
3652
+ env: z4.enum(["prod", "staging"]),
3653
+ loadImage: z4.boolean().default(false),
3654
+ buildPlatform: z4.enum(["linux/amd64", "linux/arm64"]).default("linux/amd64"),
3655
+ selfHosted: z4.boolean().default(false),
3656
+ registry: z4.string().optional(),
3657
+ push: z4.boolean().default(false),
3658
+ config: z4.string().optional(),
3659
+ projectRef: z4.string().optional(),
3660
+ outputMetafile: z4.string().optional(),
3661
+ apiUrl: z4.string().optional(),
3662
+ saveLogs: z4.boolean().default(false),
3663
+ skipUpdateCheck: z4.boolean().default(false)
3618
3664
  });
3619
3665
  function configureDeployCommand(program2) {
3620
3666
  return commonOptions(
@@ -3622,10 +3668,7 @@ function configureDeployCommand(program2) {
3622
3668
  "-e, --env <env>",
3623
3669
  "Deploy to a specific environment (currently only prod and staging are supported)",
3624
3670
  "prod"
3625
- ).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option("--skip-update-check", "Skip checking for @trigger.dev package updates").option(
3626
- "--ignore-env-var-check",
3627
- "Detected missing environment variables won't block deployment"
3628
- ).option("-c, --config <config file>", "The name of the config file, found at [path]").option(
3671
+ ).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option("--skip-update-check", "Skip checking for @trigger.dev package updates").option("-c, --config <config file>", "The name of the config file, found at [path]").option(
3629
3672
  "-p, --project-ref <project ref>",
3630
3673
  "The project ref. Required if there is no config file. This will override the project specified in the config file."
3631
3674
  )
@@ -3649,6 +3692,11 @@ function configureDeployCommand(program2) {
3649
3692
  "--tag <tag>",
3650
3693
  "(Coming soon) Specify the tag to use when pushing the image to the registry"
3651
3694
  ).hideHelp()
3695
+ ).addOption(
3696
+ new CommandOption(
3697
+ "--ignore-env-var-check",
3698
+ "(deprecated) Detected missing environment variables won't block deployment"
3699
+ ).hideHelp()
3652
3700
  ).addOption(new CommandOption("-D, --skip-deploy", "Skip deploying the image").hideHelp()).addOption(
3653
3701
  new CommandOption("--load-image", "Load the built image into your local docker").hideHelp()
3654
3702
  ).addOption(
@@ -3735,15 +3783,6 @@ async function _deployCommand(dir, options) {
3735
3783
  resolvedConfig.status === "file" ? resolvedConfig.path : void 0
3736
3784
  );
3737
3785
  logger.debug("Compilation result", { compilation });
3738
- if (compilation.envVars.length > 0) {
3739
- await checkEnvVars(
3740
- compilation.envVars ?? [],
3741
- resolvedConfig.config,
3742
- options,
3743
- environmentClient,
3744
- authorization.dashboardUrl
3745
- );
3746
- }
3747
3786
  const deploymentResponse = await environmentClient.initializeDeployment({
3748
3787
  contentHash: compilation.contentHash,
3749
3788
  userId: authorization.userId
@@ -3886,11 +3925,11 @@ async function _deployCommand(dir, options) {
3886
3925
  await preExitTasks();
3887
3926
  const taskCount = finishedDeployment.worker?.tasks.length ?? 0;
3888
3927
  if (taskCount === 0) {
3889
- outro4(
3928
+ outro5(
3890
3929
  `Version ${version2} deployed with no detected tasks. Please make sure you are exporting tasks in your project. ${deploymentLink}`
3891
3930
  );
3892
3931
  } else {
3893
- outro4(
3932
+ outro5(
3894
3933
  `Version ${version2} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${deploymentLink}`
3895
3934
  );
3896
3935
  }
@@ -4050,55 +4089,11 @@ async function failDeploy(shortCode, errorSummary, logs, deploymentSpinner, warn
4050
4089
  printWarnings(warnings);
4051
4090
  printErrors(errors);
4052
4091
  checkLogsForErrors(logs);
4053
- outro4(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
4092
+ outro5(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
4054
4093
  } else {
4055
- outro4(`${chalkError("Error:")} ${errorSummary}.`);
4094
+ outro5(`${chalkError("Error:")} ${errorSummary}.`);
4056
4095
  }
4057
4096
  }
4058
- async function checkEnvVars(envVars, config, options, environmentClient, apiUrl) {
4059
- return await tracer.startActiveSpan("detectEnvVars", async (span) => {
4060
- try {
4061
- span.setAttribute("envVars.check", envVars);
4062
- const environmentVariablesSpinner = spinner();
4063
- environmentVariablesSpinner.start("Checking environment variables");
4064
- const environmentVariables = await environmentClient.getEnvironmentVariables(config.project);
4065
- if (!environmentVariables.success) {
4066
- environmentVariablesSpinner.stop(`Failed to fetch environment variables, skipping check`);
4067
- } else {
4068
- const missingEnvironmentVariables = envVars.filter(
4069
- (envVar) => environmentVariables.data.variables[envVar] === void 0
4070
- );
4071
- if (missingEnvironmentVariables.length > 0) {
4072
- environmentVariablesSpinner.stop(
4073
- `Found missing env vars in ${options.env}: ${arrayToSentence(
4074
- missingEnvironmentVariables
4075
- )}. ${options.ignoreEnvVarCheck ? "Continuing deployment because of --ignore-env-var-check. " : "Aborting deployment. "}${chalk5.bgBlueBright(
4076
- terminalLink2(
4077
- "Manage env vars",
4078
- `${apiUrl}/projects/v3/${config.project}/environment-variables`
4079
- )
4080
- )}`
4081
- );
4082
- span.setAttributes({
4083
- "envVars.missing": missingEnvironmentVariables
4084
- });
4085
- if (!options.ignoreEnvVarCheck) {
4086
- throw new SkipLoggingError("Found missing environment variables");
4087
- } else {
4088
- span.end();
4089
- return;
4090
- }
4091
- }
4092
- environmentVariablesSpinner.stop(`Environment variable check passed`);
4093
- }
4094
- span.end();
4095
- } catch (e) {
4096
- recordSpanException4(span, e);
4097
- span.end();
4098
- throw e;
4099
- }
4100
- });
4101
- }
4102
4097
  async function waitForDeploymentToFinish(deploymentId, client, timeoutInSeconds = 60) {
4103
4098
  return tracer.startActiveSpan("waitForDeploymentToFinish", async (span) => {
4104
4099
  try {
@@ -4560,18 +4555,11 @@ If this is unexpected you should check your ${terminalLink2(
4560
4555
  contentHasher.update(Buffer.from(workerOutputFile.text));
4561
4556
  contentHasher.update(Buffer.from(JSON.stringify(dependencies2)));
4562
4557
  const contentHash = contentHasher.digest("hex");
4563
- const workerSetupEnvVars = await findAllEnvironmentVariableReferencesInFile(workerSetupPath);
4564
- const workerFacadeEnvVars = findAllEnvironmentVariableReferences(workerContents);
4565
- const envVars = findAllEnvironmentVariableReferences(workerOutputFile.text);
4566
- const finalEnvVars = envVars.filter(
4567
- (envVar) => !workerFacadeEnvVars.includes(envVar) && !workerSetupEnvVars.includes(envVar)
4568
- );
4569
4558
  span.setAttributes({
4570
- contentHash,
4571
- envVars: finalEnvVars
4559
+ contentHash
4572
4560
  });
4573
4561
  span.end();
4574
- return { path: tempDir, contentHash, envVars: finalEnvVars };
4562
+ return { path: tempDir, contentHash };
4575
4563
  } catch (e) {
4576
4564
  recordSpanException4(span, e);
4577
4565
  span.end();
@@ -4836,36 +4824,14 @@ async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
4836
4824
  logger.debug(`Writing docker config to ${dockerConfigPath}`);
4837
4825
  return tmpDir;
4838
4826
  }
4839
- async function findAllEnvironmentVariableReferencesInFile(filePath) {
4840
- const fileContents = await readFile2(filePath, "utf-8");
4841
- return findAllEnvironmentVariableReferences(fileContents);
4842
- }
4843
- var IGNORED_ENV_VARS = ["NODE_ENV", "SHELL", "HOME", "PWD", "LOGNAME", "USER", "PATH", "DEBUG"];
4844
- function findAllEnvironmentVariableReferences(code) {
4845
- const regex = /\bprocess\.env\.([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
4846
- const matches = code.matchAll(regex);
4847
- const matchesArray = Array.from(matches, (match) => match[1]).filter(Boolean);
4848
- const filteredMatches = matchesArray.filter((match) => !IGNORED_ENV_VARS.includes(match));
4849
- return Array.from(new Set(filteredMatches));
4850
- }
4851
- function arrayToSentence(items) {
4852
- if (items.length === 1 && typeof items[0] === "string") {
4853
- return items[0];
4854
- }
4855
- if (items.length === 2) {
4856
- return `${items[0]} and ${items[1]}`;
4857
- }
4858
- return `${items.slice(0, -1).join(", ")}, and ${items[items.length - 1]}`;
4859
- }
4860
4827
 
4861
4828
  // src/commands/dev.tsx
4862
4829
  import {
4863
- ZodMessageHandler as ZodMessageHandler2,
4864
- ZodMessageSender as ZodMessageSender2,
4865
4830
  clientWebsocketMessages,
4866
4831
  detectDependencyVersion as detectDependencyVersion2,
4867
4832
  serverWebsocketMessages
4868
4833
  } from "@trigger.dev/core/v3";
4834
+ import { ZodMessageHandler as ZodMessageHandler2, ZodMessageSender as ZodMessageSender2 } from "@trigger.dev/core/v3/zodMessageHandler";
4869
4835
  import { watch } from "chokidar";
4870
4836
  import { context as context2 } from "esbuild";
4871
4837
  import { render, useInput } from "ink";
@@ -4876,7 +4842,7 @@ import pDebounce from "p-debounce";
4876
4842
  import { WebSocket } from "partysocket";
4877
4843
  import React, { Suspense, useEffect } from "react";
4878
4844
  import { WebSocket as wsWebSocket } from "ws";
4879
- import { z as z6 } from "zod";
4845
+ import { z as z5 } from "zod";
4880
4846
 
4881
4847
  // src/workers/common/errors.ts
4882
4848
  var UncaughtExceptionError = class extends Error {
@@ -4900,13 +4866,12 @@ var TaskMetadataParseError = class extends Error {
4900
4866
  import {
4901
4867
  SemanticInternalAttributes,
4902
4868
  TaskRunErrorCodes,
4903
- ZodMessageHandler,
4904
- ZodMessageSender,
4905
4869
  childToWorkerMessages,
4906
4870
  correctErrorStackTrace,
4907
4871
  formatDurationMilliseconds,
4908
4872
  workerToChildMessages
4909
4873
  } from "@trigger.dev/core/v3";
4874
+ import { ZodMessageHandler, ZodMessageSender } from "@trigger.dev/core/v3/zodMessageHandler";
4910
4875
  import dotenv from "dotenv";
4911
4876
  import { Evt } from "evt";
4912
4877
  import { fork } from "node:child_process";
@@ -5517,11 +5482,11 @@ function runtimeCheck(minimumMajor, minimumMinor) {
5517
5482
  import { findUp as findUp3, pathExists as pathExists2 } from "find-up";
5518
5483
  var apiClient;
5519
5484
  var DevCommandOptions = CommonCommandOptions.extend({
5520
- debugger: z6.boolean().default(false),
5521
- debugOtel: z6.boolean().default(false),
5522
- config: z6.string().optional(),
5523
- projectRef: z6.string().optional(),
5524
- skipUpdateCheck: z6.boolean().default(false)
5485
+ debugger: z5.boolean().default(false),
5486
+ debugOtel: z5.boolean().default(false),
5487
+ config: z5.string().optional(),
5488
+ projectRef: z5.string().optional(),
5489
+ skipUpdateCheck: z5.boolean().default(false)
5525
5490
  });
5526
5491
  function configureDevCommand(program2) {
5527
5492
  return commonOptions(
@@ -5807,9 +5772,6 @@ function useDev({
5807
5772
  logger.log(chalkGrey("\u25CB Building background worker\u2026"));
5808
5773
  }
5809
5774
  const metaOutputKey = join7("out", `stdin.js`).replace(/\\/g, "/");
5810
- logger.debug("Metafile", {
5811
- metafileOutputs: JSON.stringify(result.metafile?.outputs)
5812
- });
5813
5775
  const metaOutput = result.metafile.outputs[metaOutputKey];
5814
5776
  if (!metaOutput) {
5815
5777
  throw new Error(`Could not find metafile`);
@@ -5863,8 +5825,15 @@ function useDev({
5863
5825
  latestWorkerContentHash = contentHash;
5864
5826
  let packageVersion;
5865
5827
  const taskResources = [];
5866
- if (!backgroundWorker.tasks) {
5867
- throw new Error(`Background Worker started without tasks`);
5828
+ if (!backgroundWorker.tasks || backgroundWorker.tasks.length === 0) {
5829
+ logger.log(
5830
+ `${chalkError(
5831
+ "X Error:"
5832
+ )} Worker failed to build: no tasks found. Searched in ${config.triggerDirectories.join(
5833
+ ", "
5834
+ )}`
5835
+ );
5836
+ return;
5868
5837
  }
5869
5838
  for (const task of backgroundWorker.tasks) {
5870
5839
  taskResources.push(task);
@@ -5883,6 +5852,9 @@ function useDev({
5883
5852
  );
5884
5853
  return;
5885
5854
  }
5855
+ logger.debug("Creating background worker with tasks", {
5856
+ tasks: taskResources
5857
+ });
5886
5858
  const backgroundWorkerBody = {
5887
5859
  localOnly: true,
5888
5860
  metadata: {
@@ -5969,7 +5941,7 @@ ${chalkError("X Error:")} The package ${chalkPurple(
5969
5941
  }
5970
5942
  const throttledRebuild = pDebounce(runBuild, 250, { before: true });
5971
5943
  const taskFileWatcher = watch(
5972
- config.triggerDirectories.map((triggerDir) => `${triggerDir}/*.ts`),
5944
+ config.triggerDirectories.map((triggerDir) => `${triggerDir}/**/*.ts`),
5973
5945
  {
5974
5946
  ignoreInitial: true
5975
5947
  }
@@ -6120,19 +6092,17 @@ async function findPnpmNodeModulesPath() {
6120
6092
  }
6121
6093
 
6122
6094
  // src/commands/init.ts
6123
- import { intro as intro5, isCancel as isCancel2, log as log6, outro as outro5, select as select2, text } from "@clack/prompts";
6095
+ import { intro as intro5, isCancel as isCancel2, log as log6, outro as outro6, select as select2, text } from "@clack/prompts";
6124
6096
  import { context as context3, trace as trace3 } from "@opentelemetry/api";
6125
- import {
6126
- flattenAttributes as flattenAttributes3,
6127
- recordSpanException as recordSpanException5
6128
- } from "@trigger.dev/core/v3";
6129
- import chalk6 from "chalk";
6097
+ import { flattenAttributes as flattenAttributes3 } from "@trigger.dev/core/v3";
6098
+ import { recordSpanException as recordSpanException5 } from "@trigger.dev/core/v3/workers";
6099
+ import chalk5 from "chalk";
6130
6100
  import { execa as execa3 } from "execa";
6131
6101
  import { applyEdits, modify } from "jsonc-parser";
6132
6102
  import { writeFile as writeFile3 } from "node:fs/promises";
6133
6103
  import { join as join8, relative as relative4, resolve as resolve4 } from "node:path";
6134
6104
  import terminalLink4 from "terminal-link";
6135
- import { z as z7 } from "zod";
6105
+ import { z as z6 } from "zod";
6136
6106
 
6137
6107
  // src/utilities/createFileFromTemplate.ts
6138
6108
  import fs8 from "fs/promises";
@@ -6177,10 +6147,10 @@ function replaceAll(input, replacements) {
6177
6147
 
6178
6148
  // src/commands/init.ts
6179
6149
  var InitCommandOptions = CommonCommandOptions.extend({
6180
- projectRef: z7.string().optional(),
6181
- overrideConfig: z7.boolean().default(false),
6182
- tag: z7.string().default("beta"),
6183
- skipPackageInstall: z7.boolean().default(false)
6150
+ projectRef: z6.string().optional(),
6151
+ overrideConfig: z6.boolean().default(false),
6152
+ tag: z6.string().default("beta"),
6153
+ skipPackageInstall: z6.boolean().default(false)
6184
6154
  });
6185
6155
  function configureInitCommand(program2) {
6186
6156
  return commonOptions(
@@ -6230,7 +6200,7 @@ async function _initCommand(dir, options) {
6230
6200
  if (!options.overrideConfig) {
6231
6201
  try {
6232
6202
  const result = await readConfig(dir);
6233
- outro5(
6203
+ outro6(
6234
6204
  result.status === "file" ? `Project already initialized: Found config file at ${result.path}. Pass --override-config to override` : "Project already initialized"
6235
6205
  );
6236
6206
  return;
@@ -6264,7 +6234,7 @@ async function _initCommand(dir, options) {
6264
6234
  log6.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
6265
6235
  log6.info("Next steps:");
6266
6236
  log6.info(
6267
- ` 1. To start developing, run ${chalk6.green(
6237
+ ` 1. To start developing, run ${chalk5.green(
6268
6238
  `npx trigger.dev@${options.tag} dev`
6269
6239
  )} in your project directory`
6270
6240
  );
@@ -6279,9 +6249,9 @@ async function _initCommand(dir, options) {
6279
6249
  ` 4. Need help? Join our ${terminalLink4(
6280
6250
  "Discord community",
6281
6251
  "https://trigger.dev/discord"
6282
- )} or email us at ${chalk6.cyan("help@trigger.dev")}`
6252
+ )} or email us at ${chalk5.cyan("help@trigger.dev")}`
6283
6253
  );
6284
- outro5(`Project initialized successfully. Happy coding!`);
6254
+ outro6(`Project initialized successfully. Happy coding!`);
6285
6255
  }
6286
6256
  async function createTriggerDir(dir, options) {
6287
6257
  return await tracer.startActiveSpan("createTriggerDir", async (span) => {
@@ -6532,7 +6502,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
6532
6502
  "Create new project",
6533
6503
  `${dashboardUrl}/projects/new?version=v3`
6534
6504
  );
6535
- outro5(`You don't have any projects yet. ${newProjectLink}`);
6505
+ outro6(`You don't have any projects yet. ${newProjectLink}`);
6536
6506
  throw new SkipCommandError();
6537
6507
  }
6538
6508
  const selectedProject = await select2({
@@ -6595,7 +6565,7 @@ async function logout(options) {
6595
6565
  }
6596
6566
 
6597
6567
  // src/commands/list-profiles.ts
6598
- import { log as log7, outro as outro6 } from "@clack/prompts";
6568
+ import { log as log7, outro as outro7 } from "@clack/prompts";
6599
6569
  var ListProfilesOptions = CommonCommandOptions;
6600
6570
  function configureListProfilesCommand(program2) {
6601
6571
  return program2.command("list-profiles").description("List all of your CLI profiles").option(
@@ -6626,7 +6596,7 @@ async function listProfiles(options) {
6626
6596
  const profileConfig = authConfig[profile];
6627
6597
  log7.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
6628
6598
  }
6629
- outro6("Retrieve account info by running whoami --profile <profile>");
6599
+ outro7("Retrieve account info by running whoami --profile <profile>");
6630
6600
  }
6631
6601
 
6632
6602
  // src/cli/index.ts