trigger.dev 0.0.0-v3-update-command-20240423145551 → 0.0.0-v3-prerelease-20240424101411

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.
@@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
5
5
  busybox \
6
6
  ca-certificates \
7
7
  dumb-init \
8
+ git \
8
9
  openssl \
9
10
  && rm -rf /var/lib/apt/lists/*
10
11
 
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";
@@ -800,7 +799,7 @@ import invariant from "tiny-invariant";
800
799
  import { z as z4 } from "zod";
801
800
 
802
801
  // package.json
803
- var version = "0.0.0-v3-update-command-20240423145551";
802
+ var version = "0.0.0-v3-prerelease-20240424101411";
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-20240423145551",
818
+ "@trigger.dev/core": "workspace:0.0.0-v3-prerelease-20240424101411",
820
819
  "@types/degit": "^2.8.3",
821
820
  chalk: "^5.2.0",
822
821
  chokidar: "^3.5.3",
@@ -1140,7 +1139,8 @@ async function zodfetch(schema, url, requestInit) {
1140
1139
  }
1141
1140
 
1142
1141
  // src/cli/common.ts
1143
- 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";
1144
1144
  import { z } from "zod";
1145
1145
 
1146
1146
  // src/telemetry/tracing.ts
@@ -1150,6 +1150,10 @@ import { Resource, detectResourcesSync, processDetectorSync } from "@opentelemet
1150
1150
  import { NodeTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
1151
1151
  import { FetchInstrumentation } from "@opentelemetry/instrumentation-fetch";
1152
1152
  import { DiagConsoleLogger, DiagLogLevel, diag, trace } from "@opentelemetry/api";
1153
+ import {
1154
+ SEMRESATTRS_SERVICE_NAME,
1155
+ SEMRESATTRS_SERVICE_VERSION
1156
+ } from "@opentelemetry/semantic-conventions";
1153
1157
  function initializeTracing() {
1154
1158
  if (process.argv.includes("--skip-telemetry") || process.env.TRIGGER_DEV_SKIP_TELEMETRY) {
1155
1159
  return;
@@ -1161,7 +1165,8 @@ function initializeTracing() {
1161
1165
  detectors: [processDetectorSync]
1162
1166
  }).merge(
1163
1167
  new Resource({
1164
- service: "trigger.dev cli v3"
1168
+ [SEMRESATTRS_SERVICE_NAME]: "trigger.dev cli v3",
1169
+ [SEMRESATTRS_SERVICE_VERSION]: version
1165
1170
  })
1166
1171
  );
1167
1172
  const traceProvider = new NodeTracerProvider({
@@ -1178,10 +1183,9 @@ function initializeTracing() {
1178
1183
  });
1179
1184
  const spanExporter = new OTLPTraceExporter({
1180
1185
  url: "https://otel.baselime.io/v1",
1181
- timeoutMillis: 500,
1186
+ timeoutMillis: 5e3,
1182
1187
  headers: {
1183
- "x-api-key": "e9f963244f8b092850d42e34a5339b2d5e68070b".split("").reverse().join("")
1184
- // this is a joke
1188
+ "x-api-key": "b6e0fbbaf8dc2524773d2152ae2e9eb5c7fbaa52"
1185
1189
  }
1186
1190
  });
1187
1191
  const spanProcessor = new SimpleSpanProcessor(spanExporter);
@@ -1194,7 +1198,7 @@ function initializeTracing() {
1194
1198
  }
1195
1199
  var provider = initializeTracing();
1196
1200
  function getTracer() {
1197
- return trace.getTracer("trigger.dev cli", version);
1201
+ return trace.getTracer("trigger.dev cli v3", version);
1198
1202
  }
1199
1203
 
1200
1204
  // src/cli/common.ts
@@ -1366,6 +1370,18 @@ function prettyPrintDate(date = /* @__PURE__ */ new Date()) {
1366
1370
  formattedDate += "." + ("00" + date.getMilliseconds()).slice(-3);
1367
1371
  return formattedDate;
1368
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
+ }
1369
1385
  function prettyWarning(header, body, footer) {
1370
1386
  const prefix = "Warning: ";
1371
1387
  const indent = Array(prefix.length).fill(" ").join("");
@@ -1528,14 +1544,23 @@ function createTaskFileImports(taskFiles) {
1528
1544
  async function gatherTaskFiles(config) {
1529
1545
  const taskFiles = [];
1530
1546
  for (const triggerDir of config.triggerDirectories) {
1531
- const files = await fs2.promises.readdir(triggerDir, { withFileTypes: true });
1532
- for (const file of files) {
1533
- if (!file.isFile())
1534
- 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 {
1535
1560
  if (!file.name.endsWith(".js") && !file.name.endsWith(".ts") && !file.name.endsWith(".jsx") && !file.name.endsWith(".tsx")) {
1536
1561
  continue;
1537
1562
  }
1538
- const fullPath = join(triggerDir, file.name);
1563
+ const fullPath = join(dirPath, file.name);
1539
1564
  const filePath = relative(config.projectDir, fullPath);
1540
1565
  const importName = filePath.replace(/\..+$/, "").replace(/[^a-zA-Z0-9_$]/g, "_");
1541
1566
  const importPath = filePath.replace(/\\/g, "/");
@@ -1555,9 +1580,12 @@ async function getTriggerDirectories(dirPath) {
1555
1580
  const entries = await fs2.promises.readdir(dirPath, { withFileTypes: true });
1556
1581
  const triggerDirectories = [];
1557
1582
  for (const entry of entries) {
1558
- if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name))
1583
+ if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name) || entry.name.startsWith("."))
1559
1584
  continue;
1560
1585
  const fullPath = join(dirPath, entry.name);
1586
+ if (fullPath.endsWith("app/api/trigger")) {
1587
+ continue;
1588
+ }
1561
1589
  if (entry.name === "trigger") {
1562
1590
  triggerDirectories.push(fullPath);
1563
1591
  }
@@ -1631,6 +1659,15 @@ async function getConfigPath(dir, fileName) {
1631
1659
  });
1632
1660
  return await findUp(fileName ? [fileName] : CONFIG_FILES, { cwd: dir });
1633
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
+ }
1634
1671
  async function readConfig(dir, options) {
1635
1672
  const absoluteDir = path2.resolve(process.cwd(), dir);
1636
1673
  const configPath = await getConfigPath(dir, options?.configFile);
@@ -1683,6 +1720,7 @@ async function resolveConfig(path7, config) {
1683
1720
  config.triggerDirectories = await findTriggerDirectories(path7);
1684
1721
  }
1685
1722
  config.triggerDirectories = resolveTriggerDirectories(config.triggerDirectories);
1723
+ logger.debug("Resolved trigger directories", { triggerDirectories: config.triggerDirectories });
1686
1724
  if (!config.triggerUrl) {
1687
1725
  config.triggerUrl = CLOUD_API_URL;
1688
1726
  }
@@ -1690,7 +1728,7 @@ async function resolveConfig(path7, config) {
1690
1728
  config.projectDir = path7;
1691
1729
  }
1692
1730
  if (!config.tsconfigPath) {
1693
- config.tsconfigPath = await getConfigPath(path7, "tsconfig.json");
1731
+ config.tsconfigPath = await findFilePath(path7, "tsconfig.json");
1694
1732
  }
1695
1733
  return config;
1696
1734
  }
@@ -1859,8 +1897,8 @@ async function setPackageJsonDeps(path7, deps) {
1859
1897
  }
1860
1898
 
1861
1899
  // src/commands/login.ts
1862
- import { intro as intro2, log as log3, outro as outro2, select } from "@clack/prompts";
1863
- 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";
1864
1902
 
1865
1903
  // ../../node_modules/.pnpm/open@10.0.3/node_modules/open/index.js
1866
1904
  import process6 from "node:process";
@@ -2407,10 +2445,10 @@ async function pRetry(input, options) {
2407
2445
  import { z as z3 } from "zod";
2408
2446
 
2409
2447
  // src/commands/whoami.ts
2410
- import { intro, note } from "@clack/prompts";
2448
+ import { intro, note, outro as outro2 } from "@clack/prompts";
2411
2449
 
2412
2450
  // src/utilities/session.ts
2413
- import { recordSpanException as recordSpanException2 } from "@trigger.dev/core/v3";
2451
+ import { recordSpanException as recordSpanException2 } from "@trigger.dev/core/v3/workers";
2414
2452
  var tracer2 = getTracer();
2415
2453
  async function isLoggedIn(profile = "default") {
2416
2454
  return await tracer2.startActiveSpan("isLoggedIn", async (span) => {
@@ -2492,9 +2530,16 @@ async function whoAmI(options, embedded = false) {
2492
2530
  if (authentication.error === "fetch failed") {
2493
2531
  loadingSpinner.stop("Fetch failed. Platform down?");
2494
2532
  } else {
2495
- loadingSpinner.stop(
2496
- `You must login first. Use \`trigger.dev login --profile ${options?.profile ?? "default"}\` to login.`
2497
- );
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
+ }
2498
2543
  }
2499
2544
  return {
2500
2545
  success: false,
@@ -2590,10 +2635,18 @@ async function login(options) {
2590
2635
  skipTelemetry: !span.isRecording(),
2591
2636
  logLevel: logger.loggerLevel
2592
2637
  },
2593
- opts.embedded
2638
+ true
2594
2639
  );
2595
2640
  if (!whoAmIResult.success) {
2596
- throw new Error(whoAmIResult.error);
2641
+ prettyError("Unable to validate existing personal access token", whoAmIResult.error);
2642
+ if (!opts.embedded) {
2643
+ outro3(
2644
+ `Login failed using stored token. To fix, first logout using \`trigger.dev logout${options?.profile ? ` --profile ${options.profile}` : ""}\` and then try again.`
2645
+ );
2646
+ throw new SkipLoggingError(whoAmIResult.error);
2647
+ } else {
2648
+ throw new Error(whoAmIResult.error);
2649
+ }
2597
2650
  } else {
2598
2651
  if (!opts.embedded) {
2599
2652
  const continueOption = await select({
@@ -2611,7 +2664,7 @@ async function login(options) {
2611
2664
  initialValue: false
2612
2665
  });
2613
2666
  if (continueOption !== true) {
2614
- outro2("Already logged in");
2667
+ outro3("Already logged in");
2615
2668
  span.setAttributes({
2616
2669
  "cli.userId": whoAmIResult.data.userId,
2617
2670
  "cli.email": whoAmIResult.data.email,
@@ -2692,7 +2745,7 @@ ${chalkLink(authorizationCodeResult.url)}`
2692
2745
  if (opts.embedded) {
2693
2746
  log3.step("Logged in successfully");
2694
2747
  } else {
2695
- outro2("Logged in successfully");
2748
+ outro3("Logged in successfully");
2696
2749
  }
2697
2750
  span.end();
2698
2751
  return {
@@ -2794,7 +2847,7 @@ function bundleTriggerDevCore(buildIdentifier, tsconfigPath) {
2794
2847
  name: "trigger-bundle-core",
2795
2848
  setup(build3) {
2796
2849
  build3.onResolve({ filter: /.*/ }, (args) => {
2797
- if (args.path !== "@trigger.dev/core/v3") {
2850
+ if (!args.path.startsWith("@trigger.dev/core/v3")) {
2798
2851
  return void 0;
2799
2852
  }
2800
2853
  const triggerSdkPath = __require.resolve("@trigger.dev/sdk/v3", { paths: [process.cwd()] });
@@ -2802,17 +2855,14 @@ function bundleTriggerDevCore(buildIdentifier, tsconfigPath) {
2802
2855
  ...args,
2803
2856
  triggerSdkPath
2804
2857
  });
2805
- const resolvedPath = __require.resolve("@trigger.dev/core/v3", {
2858
+ const resolvedPath = __require.resolve(args.path, {
2806
2859
  paths: [triggerSdkPath]
2807
2860
  });
2808
- logger.debug(
2809
- `[${buildIdentifier}][trigger-bundle-core] Externalizing @trigger.dev/core/v3`,
2810
- {
2811
- ...args,
2812
- triggerSdkPath,
2813
- resolvedPath
2814
- }
2815
- );
2861
+ logger.debug(`[${buildIdentifier}][trigger-bundle-core] Externalizing ${args.path}`, {
2862
+ ...args,
2863
+ triggerSdkPath,
2864
+ resolvedPath
2865
+ });
2816
2866
  return {
2817
2867
  path: resolvedPath,
2818
2868
  external: false
@@ -3402,7 +3452,7 @@ function cliRootPath() {
3402
3452
  }
3403
3453
 
3404
3454
  // src/commands/update.ts
3405
- import { confirm, intro as intro3, isCancel, log as log4, outro as outro3 } from "@clack/prompts";
3455
+ import { confirm, intro as intro3, isCancel, log as log4, outro as outro4 } from "@clack/prompts";
3406
3456
  import { join as join5, resolve as resolve2 } from "path";
3407
3457
  var UpdateCommandOptions = CommonCommandOptions.pick({
3408
3458
  logLevel: true,
@@ -3458,7 +3508,7 @@ Latest: ${newCliVersion}`,
3458
3508
  const versionMismatches = getVersionMismatches(triggerDependencies, cliVersion);
3459
3509
  if (versionMismatches.length === 0) {
3460
3510
  if (!embedded) {
3461
- outro3(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
3511
+ outro4(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
3462
3512
  }
3463
3513
  return;
3464
3514
  }
@@ -3467,7 +3517,7 @@ Latest: ${newCliVersion}`,
3467
3517
  "We recommend pinned versions for guaranteed compatibility"
3468
3518
  );
3469
3519
  if (!process.stdout.isTTY) {
3470
- outro3("Deploy failed");
3520
+ outro4("Deploy failed");
3471
3521
  console.log(
3472
3522
  `ERROR: Version mismatch detected while running in CI. This won't end well. Aborting.
3473
3523
 
@@ -3490,7 +3540,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3490
3540
  }
3491
3541
  if (!userWantsToUpdate) {
3492
3542
  if (requireUpdate) {
3493
- outro3("You shall not pass!");
3543
+ outro4("You shall not pass!");
3494
3544
  logger.log(
3495
3545
  `${chalkError(
3496
3546
  "X Error:"
@@ -3500,7 +3550,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3500
3550
  process.exit(1);
3501
3551
  }
3502
3552
  if (!embedded) {
3503
- outro3("You've been warned!");
3553
+ outro4("You've been warned!");
3504
3554
  }
3505
3555
  return;
3506
3556
  }
@@ -3539,7 +3589,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3539
3589
  process.removeListener("exit", exitHandler);
3540
3590
  await removeFile(packageJsonBackupPath);
3541
3591
  if (!embedded) {
3542
- outro3(
3592
+ outro4(
3543
3593
  `Packages updated${newCliVersion ? " ..but you should really update your CLI too!" : ""}`
3544
3594
  );
3545
3595
  }
@@ -3603,7 +3653,6 @@ async function getPackageJson(absoluteProjectPath) {
3603
3653
  var DeployCommandOptions = CommonCommandOptions.extend({
3604
3654
  skipTypecheck: z4.boolean().default(false),
3605
3655
  skipDeploy: z4.boolean().default(false),
3606
- ignoreEnvVarCheck: z4.boolean().default(false),
3607
3656
  env: z4.enum(["prod", "staging"]),
3608
3657
  loadImage: z4.boolean().default(false),
3609
3658
  buildPlatform: z4.enum(["linux/amd64", "linux/arm64"]).default("linux/amd64"),
@@ -3623,10 +3672,7 @@ function configureDeployCommand(program2) {
3623
3672
  "-e, --env <env>",
3624
3673
  "Deploy to a specific environment (currently only prod and staging are supported)",
3625
3674
  "prod"
3626
- ).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option("--skip-update-check", "Skip checking for @trigger.dev package updates").option(
3627
- "--ignore-env-var-check",
3628
- "Detected missing environment variables won't block deployment"
3629
- ).option("-c, --config <config file>", "The name of the config file, found at [path]").option(
3675
+ ).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(
3630
3676
  "-p, --project-ref <project ref>",
3631
3677
  "The project ref. Required if there is no config file. This will override the project specified in the config file."
3632
3678
  )
@@ -3650,6 +3696,11 @@ function configureDeployCommand(program2) {
3650
3696
  "--tag <tag>",
3651
3697
  "(Coming soon) Specify the tag to use when pushing the image to the registry"
3652
3698
  ).hideHelp()
3699
+ ).addOption(
3700
+ new CommandOption(
3701
+ "--ignore-env-var-check",
3702
+ "(deprecated) Detected missing environment variables won't block deployment"
3703
+ ).hideHelp()
3653
3704
  ).addOption(new CommandOption("-D, --skip-deploy", "Skip deploying the image").hideHelp()).addOption(
3654
3705
  new CommandOption("--load-image", "Load the built image into your local docker").hideHelp()
3655
3706
  ).addOption(
@@ -3736,15 +3787,6 @@ async function _deployCommand(dir, options) {
3736
3787
  resolvedConfig.status === "file" ? resolvedConfig.path : void 0
3737
3788
  );
3738
3789
  logger.debug("Compilation result", { compilation });
3739
- if (compilation.envVars.length > 0) {
3740
- await checkEnvVars(
3741
- compilation.envVars ?? [],
3742
- resolvedConfig.config,
3743
- options,
3744
- environmentClient,
3745
- authorization.dashboardUrl
3746
- );
3747
- }
3748
3790
  const deploymentResponse = await environmentClient.initializeDeployment({
3749
3791
  contentHash: compilation.contentHash,
3750
3792
  userId: authorization.userId
@@ -3887,11 +3929,11 @@ async function _deployCommand(dir, options) {
3887
3929
  await preExitTasks();
3888
3930
  const taskCount = finishedDeployment.worker?.tasks.length ?? 0;
3889
3931
  if (taskCount === 0) {
3890
- outro4(
3932
+ outro5(
3891
3933
  `Version ${version2} deployed with no detected tasks. Please make sure you are exporting tasks in your project. ${deploymentLink}`
3892
3934
  );
3893
3935
  } else {
3894
- outro4(
3936
+ outro5(
3895
3937
  `Version ${version2} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${deploymentLink}`
3896
3938
  );
3897
3939
  }
@@ -4051,55 +4093,11 @@ async function failDeploy(shortCode, errorSummary, logs, deploymentSpinner, warn
4051
4093
  printWarnings(warnings);
4052
4094
  printErrors(errors);
4053
4095
  checkLogsForErrors(logs);
4054
- outro4(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
4096
+ outro5(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
4055
4097
  } else {
4056
- outro4(`${chalkError("Error:")} ${errorSummary}.`);
4098
+ outro5(`${chalkError("Error:")} ${errorSummary}.`);
4057
4099
  }
4058
4100
  }
4059
- async function checkEnvVars(envVars, config, options, environmentClient, apiUrl) {
4060
- return await tracer.startActiveSpan("detectEnvVars", async (span) => {
4061
- try {
4062
- span.setAttribute("envVars.check", envVars);
4063
- const environmentVariablesSpinner = spinner();
4064
- environmentVariablesSpinner.start("Checking environment variables");
4065
- const environmentVariables = await environmentClient.getEnvironmentVariables(config.project);
4066
- if (!environmentVariables.success) {
4067
- environmentVariablesSpinner.stop(`Failed to fetch environment variables, skipping check`);
4068
- } else {
4069
- const missingEnvironmentVariables = envVars.filter(
4070
- (envVar) => environmentVariables.data.variables[envVar] === void 0
4071
- );
4072
- if (missingEnvironmentVariables.length > 0) {
4073
- environmentVariablesSpinner.stop(
4074
- `Found missing env vars in ${options.env}: ${arrayToSentence(
4075
- missingEnvironmentVariables
4076
- )}. ${options.ignoreEnvVarCheck ? "Continuing deployment because of --ignore-env-var-check. " : "Aborting deployment. "}${chalk5.bgBlueBright(
4077
- terminalLink2(
4078
- "Manage env vars",
4079
- `${apiUrl}/projects/v3/${config.project}/environment-variables`
4080
- )
4081
- )}`
4082
- );
4083
- span.setAttributes({
4084
- "envVars.missing": missingEnvironmentVariables
4085
- });
4086
- if (!options.ignoreEnvVarCheck) {
4087
- throw new SkipLoggingError("Found missing environment variables");
4088
- } else {
4089
- span.end();
4090
- return;
4091
- }
4092
- }
4093
- environmentVariablesSpinner.stop(`Environment variable check passed`);
4094
- }
4095
- span.end();
4096
- } catch (e) {
4097
- recordSpanException4(span, e);
4098
- span.end();
4099
- throw e;
4100
- }
4101
- });
4102
- }
4103
4101
  async function waitForDeploymentToFinish(deploymentId, client, timeoutInSeconds = 60) {
4104
4102
  return tracer.startActiveSpan("waitForDeploymentToFinish", async (span) => {
4105
4103
  try {
@@ -4561,18 +4559,11 @@ If this is unexpected you should check your ${terminalLink2(
4561
4559
  contentHasher.update(Buffer.from(workerOutputFile.text));
4562
4560
  contentHasher.update(Buffer.from(JSON.stringify(dependencies2)));
4563
4561
  const contentHash = contentHasher.digest("hex");
4564
- const workerSetupEnvVars = await findAllEnvironmentVariableReferencesInFile(workerSetupPath);
4565
- const workerFacadeEnvVars = findAllEnvironmentVariableReferences(workerContents);
4566
- const envVars = findAllEnvironmentVariableReferences(workerOutputFile.text);
4567
- const finalEnvVars = envVars.filter(
4568
- (envVar) => !workerFacadeEnvVars.includes(envVar) && !workerSetupEnvVars.includes(envVar)
4569
- );
4570
4562
  span.setAttributes({
4571
- contentHash,
4572
- envVars: finalEnvVars
4563
+ contentHash
4573
4564
  });
4574
4565
  span.end();
4575
- return { path: tempDir, contentHash, envVars: finalEnvVars };
4566
+ return { path: tempDir, contentHash };
4576
4567
  } catch (e) {
4577
4568
  recordSpanException4(span, e);
4578
4569
  span.end();
@@ -4837,36 +4828,14 @@ async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
4837
4828
  logger.debug(`Writing docker config to ${dockerConfigPath}`);
4838
4829
  return tmpDir;
4839
4830
  }
4840
- async function findAllEnvironmentVariableReferencesInFile(filePath) {
4841
- const fileContents = await readFile2(filePath, "utf-8");
4842
- return findAllEnvironmentVariableReferences(fileContents);
4843
- }
4844
- var IGNORED_ENV_VARS = ["NODE_ENV", "SHELL", "HOME", "PWD", "LOGNAME", "USER", "PATH", "DEBUG"];
4845
- function findAllEnvironmentVariableReferences(code) {
4846
- const regex = /\bprocess\.env\.([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
4847
- const matches = code.matchAll(regex);
4848
- const matchesArray = Array.from(matches, (match) => match[1]).filter(Boolean);
4849
- const filteredMatches = matchesArray.filter((match) => !IGNORED_ENV_VARS.includes(match));
4850
- return Array.from(new Set(filteredMatches));
4851
- }
4852
- function arrayToSentence(items) {
4853
- if (items.length === 1 && typeof items[0] === "string") {
4854
- return items[0];
4855
- }
4856
- if (items.length === 2) {
4857
- return `${items[0]} and ${items[1]}`;
4858
- }
4859
- return `${items.slice(0, -1).join(", ")}, and ${items[items.length - 1]}`;
4860
- }
4861
4831
 
4862
4832
  // src/commands/dev.tsx
4863
4833
  import {
4864
- ZodMessageHandler as ZodMessageHandler2,
4865
- ZodMessageSender as ZodMessageSender2,
4866
4834
  clientWebsocketMessages,
4867
4835
  detectDependencyVersion as detectDependencyVersion2,
4868
4836
  serverWebsocketMessages
4869
4837
  } from "@trigger.dev/core/v3";
4838
+ import { ZodMessageHandler as ZodMessageHandler2, ZodMessageSender as ZodMessageSender2 } from "@trigger.dev/core/v3/zodMessageHandler";
4870
4839
  import { watch } from "chokidar";
4871
4840
  import { context as context2 } from "esbuild";
4872
4841
  import { render, useInput } from "ink";
@@ -4901,13 +4870,12 @@ var TaskMetadataParseError = class extends Error {
4901
4870
  import {
4902
4871
  SemanticInternalAttributes,
4903
4872
  TaskRunErrorCodes,
4904
- ZodMessageHandler,
4905
- ZodMessageSender,
4906
4873
  childToWorkerMessages,
4907
4874
  correctErrorStackTrace,
4908
4875
  formatDurationMilliseconds,
4909
4876
  workerToChildMessages
4910
4877
  } from "@trigger.dev/core/v3";
4878
+ import { ZodMessageHandler, ZodMessageSender } from "@trigger.dev/core/v3/zodMessageHandler";
4911
4879
  import dotenv from "dotenv";
4912
4880
  import { Evt } from "evt";
4913
4881
  import { fork } from "node:child_process";
@@ -5808,9 +5776,6 @@ function useDev({
5808
5776
  logger.log(chalkGrey("\u25CB Building background worker\u2026"));
5809
5777
  }
5810
5778
  const metaOutputKey = join7("out", `stdin.js`).replace(/\\/g, "/");
5811
- logger.debug("Metafile", {
5812
- metafileOutputs: JSON.stringify(result.metafile?.outputs)
5813
- });
5814
5779
  const metaOutput = result.metafile.outputs[metaOutputKey];
5815
5780
  if (!metaOutput) {
5816
5781
  throw new Error(`Could not find metafile`);
@@ -5864,8 +5829,15 @@ function useDev({
5864
5829
  latestWorkerContentHash = contentHash;
5865
5830
  let packageVersion;
5866
5831
  const taskResources = [];
5867
- if (!backgroundWorker.tasks) {
5868
- throw new Error(`Background Worker started without tasks`);
5832
+ if (!backgroundWorker.tasks || backgroundWorker.tasks.length === 0) {
5833
+ logger.log(
5834
+ `${chalkError(
5835
+ "X Error:"
5836
+ )} Worker failed to build: no tasks found. Searched in ${config.triggerDirectories.join(
5837
+ ", "
5838
+ )}`
5839
+ );
5840
+ return;
5869
5841
  }
5870
5842
  for (const task of backgroundWorker.tasks) {
5871
5843
  taskResources.push(task);
@@ -5884,6 +5856,9 @@ function useDev({
5884
5856
  );
5885
5857
  return;
5886
5858
  }
5859
+ logger.debug("Creating background worker with tasks", {
5860
+ tasks: taskResources
5861
+ });
5887
5862
  const backgroundWorkerBody = {
5888
5863
  localOnly: true,
5889
5864
  metadata: {
@@ -5970,7 +5945,7 @@ ${chalkError("X Error:")} The package ${chalkPurple(
5970
5945
  }
5971
5946
  const throttledRebuild = pDebounce(runBuild, 250, { before: true });
5972
5947
  const taskFileWatcher = watch(
5973
- config.triggerDirectories.map((triggerDir) => `${triggerDir}/*.ts`),
5948
+ config.triggerDirectories.map((triggerDir) => `${triggerDir}/**/*.ts`),
5974
5949
  {
5975
5950
  ignoreInitial: true
5976
5951
  }
@@ -6121,13 +6096,11 @@ async function findPnpmNodeModulesPath() {
6121
6096
  }
6122
6097
 
6123
6098
  // src/commands/init.ts
6124
- import { intro as intro5, isCancel as isCancel2, log as log6, outro as outro5, select as select2, text } from "@clack/prompts";
6099
+ import { intro as intro5, isCancel as isCancel2, log as log6, outro as outro6, select as select2, text } from "@clack/prompts";
6125
6100
  import { context as context3, trace as trace3 } from "@opentelemetry/api";
6126
- import {
6127
- flattenAttributes as flattenAttributes3,
6128
- recordSpanException as recordSpanException5
6129
- } from "@trigger.dev/core/v3";
6130
- import chalk6 from "chalk";
6101
+ import { flattenAttributes as flattenAttributes3 } from "@trigger.dev/core/v3";
6102
+ import { recordSpanException as recordSpanException5 } from "@trigger.dev/core/v3/workers";
6103
+ import chalk5 from "chalk";
6131
6104
  import { execa as execa3 } from "execa";
6132
6105
  import { applyEdits, modify } from "jsonc-parser";
6133
6106
  import { writeFile as writeFile3 } from "node:fs/promises";
@@ -6231,7 +6204,7 @@ async function _initCommand(dir, options) {
6231
6204
  if (!options.overrideConfig) {
6232
6205
  try {
6233
6206
  const result = await readConfig(dir);
6234
- outro5(
6207
+ outro6(
6235
6208
  result.status === "file" ? `Project already initialized: Found config file at ${result.path}. Pass --override-config to override` : "Project already initialized"
6236
6209
  );
6237
6210
  return;
@@ -6265,7 +6238,7 @@ async function _initCommand(dir, options) {
6265
6238
  log6.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
6266
6239
  log6.info("Next steps:");
6267
6240
  log6.info(
6268
- ` 1. To start developing, run ${chalk6.green(
6241
+ ` 1. To start developing, run ${chalk5.green(
6269
6242
  `npx trigger.dev@${options.tag} dev`
6270
6243
  )} in your project directory`
6271
6244
  );
@@ -6280,9 +6253,9 @@ async function _initCommand(dir, options) {
6280
6253
  ` 4. Need help? Join our ${terminalLink4(
6281
6254
  "Discord community",
6282
6255
  "https://trigger.dev/discord"
6283
- )} or email us at ${chalk6.cyan("help@trigger.dev")}`
6256
+ )} or email us at ${chalk5.cyan("help@trigger.dev")}`
6284
6257
  );
6285
- outro5(`Project initialized successfully. Happy coding!`);
6258
+ outro6(`Project initialized successfully. Happy coding!`);
6286
6259
  }
6287
6260
  async function createTriggerDir(dir, options) {
6288
6261
  return await tracer.startActiveSpan("createTriggerDir", async (span) => {
@@ -6533,7 +6506,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
6533
6506
  "Create new project",
6534
6507
  `${dashboardUrl}/projects/new?version=v3`
6535
6508
  );
6536
- outro5(`You don't have any projects yet. ${newProjectLink}`);
6509
+ outro6(`You don't have any projects yet. ${newProjectLink}`);
6537
6510
  throw new SkipCommandError();
6538
6511
  }
6539
6512
  const selectedProject = await select2({
@@ -6596,7 +6569,7 @@ async function logout(options) {
6596
6569
  }
6597
6570
 
6598
6571
  // src/commands/list-profiles.ts
6599
- import { log as log7, outro as outro6 } from "@clack/prompts";
6572
+ import { log as log7, outro as outro7 } from "@clack/prompts";
6600
6573
  var ListProfilesOptions = CommonCommandOptions;
6601
6574
  function configureListProfilesCommand(program2) {
6602
6575
  return program2.command("list-profiles").description("List all of your CLI profiles").option(
@@ -6627,7 +6600,7 @@ async function listProfiles(options) {
6627
6600
  const profileConfig = authConfig[profile];
6628
6601
  log7.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
6629
6602
  }
6630
- outro6("Retrieve account info by running whoami --profile <profile>");
6603
+ outro7("Retrieve account info by running whoami --profile <profile>");
6631
6604
  }
6632
6605
 
6633
6606
  // src/cli/index.ts