trigger.dev 0.0.0-v3-prerelease-20240424094958 → 0.0.0-v3-decorators-20240424152300

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
@@ -792,15 +792,16 @@ import { execa as execa2 } from "execa";
792
792
  import { createHash } from "node:crypto";
793
793
  import { readFileSync as readFileSync2 } from "node:fs";
794
794
  import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
795
- import { dirname, join as join6, relative as relative3, posix } from "node:path";
795
+ import { dirname, join as join6, posix, relative as relative3 } from "node:path";
796
796
  import { setTimeout as setTimeout2 } from "node:timers/promises";
797
797
  import terminalLink2 from "terminal-link";
798
798
  import invariant from "tiny-invariant";
799
799
  import { z as z4 } from "zod";
800
800
 
801
801
  // package.json
802
- var version = "0.0.0-v3-prerelease-20240424094958";
802
+ var version = "0.0.0-v3-decorators-20240424152300";
803
803
  var dependencies = {
804
+ "@anatine/esbuild-decorators": "^0.2.19",
804
805
  "@clack/prompts": "^0.7.0",
805
806
  "@depot/cli": "0.0.1-cli.2.55.0",
806
807
  "@opentelemetry/api": "^1.8.0",
@@ -815,7 +816,7 @@ var dependencies = {
815
816
  "@opentelemetry/sdk-trace-base": "^1.22.0",
816
817
  "@opentelemetry/sdk-trace-node": "^1.22.0",
817
818
  "@opentelemetry/semantic-conventions": "^1.22.0",
818
- "@trigger.dev/core": "workspace:0.0.0-v3-prerelease-20240424094958",
819
+ "@trigger.dev/core": "workspace:0.0.0-v3-decorators-20240424152300",
819
820
  "@types/degit": "^2.8.3",
820
821
  chalk: "^5.2.0",
821
822
  chokidar: "^3.5.3",
@@ -1596,6 +1597,7 @@ async function getTriggerDirectories(dirPath) {
1596
1597
 
1597
1598
  // src/utilities/configFiles.ts
1598
1599
  import { build } from "esbuild";
1600
+ import { esbuildDecorators } from "@anatine/esbuild-decorators";
1599
1601
  function getGlobalConfigFolderPath() {
1600
1602
  const configDir = mod_esm_default("trigger").config();
1601
1603
  return configDir;
@@ -1701,7 +1703,14 @@ async function readConfig(dir, options) {
1701
1703
  platform: "node",
1702
1704
  target: ["es2018", "node18"],
1703
1705
  outfile: builtConfigFilePath,
1704
- logLevel: "silent"
1706
+ logLevel: "silent",
1707
+ plugins: [
1708
+ esbuildDecorators({
1709
+ cwd: absoluteDir,
1710
+ tsx: false,
1711
+ force: false
1712
+ })
1713
+ ]
1705
1714
  });
1706
1715
  const userConfigModule = await import(builtConfigFileHref);
1707
1716
  const rawConfig = await normalizeConfig(
@@ -1802,14 +1811,18 @@ After installation, run Trigger.dev with \`npx trigger.dev\`.`
1802
1811
  }
1803
1812
  async function printStandloneInitialBanner(performUpdateCheck = true) {
1804
1813
  const cliVersion = getVersion();
1805
- logger.log(`
1806
- ${logo()} ${chalkGrey(`(${cliVersion})`)}
1807
- `);
1808
1814
  if (performUpdateCheck) {
1809
1815
  const maybeNewVersion = await updateCheck();
1810
1816
  if (maybeNewVersion !== void 0) {
1811
- logger.log(`Update available ${chalk3.green(maybeNewVersion)}`);
1817
+ logger.log(`
1818
+ ${logo()} ${chalkGrey(`(${cliVersion} -> ${chalk3.green(maybeNewVersion)})`)}`);
1819
+ } else {
1820
+ logger.log(`
1821
+ ${logo()} ${chalkGrey(`(${cliVersion})`)}`);
1812
1822
  }
1823
+ } else {
1824
+ logger.log(`
1825
+ ${logo()} ${chalkGrey(`(${cliVersion})`)}`);
1813
1826
  }
1814
1827
  logger.log(`${chalkGrey("-".repeat(54))}`);
1815
1828
  }
@@ -2638,11 +2651,15 @@ async function login(options) {
2638
2651
  true
2639
2652
  );
2640
2653
  if (!whoAmIResult.success) {
2641
- prettyError("Whoami failed", whoAmIResult.error);
2654
+ prettyError("Unable to validate existing personal access token", whoAmIResult.error);
2642
2655
  if (!opts.embedded) {
2643
- outro3("Login failed");
2656
+ outro3(
2657
+ `Login failed using stored token. To fix, first logout using \`trigger.dev logout${options?.profile ? ` --profile ${options.profile}` : ""}\` and then try again.`
2658
+ );
2659
+ throw new SkipLoggingError(whoAmIResult.error);
2660
+ } else {
2661
+ throw new Error(whoAmIResult.error);
2644
2662
  }
2645
- throw new Error(whoAmIResult.error);
2646
2663
  } else {
2647
2664
  if (!opts.embedded) {
2648
2665
  const continueOption = await select({
@@ -2832,6 +2849,7 @@ ${authorizationCodeResult.error}`
2832
2849
  }
2833
2850
 
2834
2851
  // src/commands/deploy.ts
2852
+ import { esbuildDecorators as esbuildDecorators2 } from "@anatine/esbuild-decorators";
2835
2853
  import { Glob } from "glob";
2836
2854
 
2837
2855
  // src/utilities/build.ts
@@ -3164,18 +3182,6 @@ ${chalkError("X Error:")} Failed to start. The following ${zodIssues.length ===
3164
3182
  }
3165
3183
  }
3166
3184
 
3167
- // src/utilities/safeJsonParse.ts
3168
- function safeJsonParse(json) {
3169
- if (!json) {
3170
- return void 0;
3171
- }
3172
- try {
3173
- return JSON.parse(json);
3174
- } catch {
3175
- return void 0;
3176
- }
3177
- }
3178
-
3179
3185
  // src/utilities/javascriptProject.ts
3180
3186
  import { $ } from "execa";
3181
3187
  import { join as join4 } from "node:path";
@@ -3447,6 +3453,18 @@ function cliRootPath() {
3447
3453
  return __dirname2;
3448
3454
  }
3449
3455
 
3456
+ // src/utilities/safeJsonParse.ts
3457
+ function safeJsonParse(json) {
3458
+ if (!json) {
3459
+ return void 0;
3460
+ }
3461
+ try {
3462
+ return JSON.parse(json);
3463
+ } catch {
3464
+ return void 0;
3465
+ }
3466
+ }
3467
+
3450
3468
  // src/commands/update.ts
3451
3469
  import { confirm, intro as intro3, isCancel, log as log4, outro as outro4 } from "@clack/prompts";
3452
3470
  import { join as join5, resolve as resolve2 } from "path";
@@ -3471,6 +3489,7 @@ async function updateCommand(dir, options) {
3471
3489
  await updateTriggerPackages(dir, options);
3472
3490
  }
3473
3491
  async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
3492
+ let hasOutput = false;
3474
3493
  if (!embedded) {
3475
3494
  intro3("Updating packages");
3476
3495
  }
@@ -3478,7 +3497,7 @@ async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
3478
3497
  const { packageJson, readonlyPackageJson, packageJsonPath } = await getPackageJson(projectPath);
3479
3498
  if (!packageJson) {
3480
3499
  log4.error("Failed to load package.json. Try to re-run with `-l debug` to see what's going on.");
3481
- return;
3500
+ return false;
3482
3501
  }
3483
3502
  const cliVersion = getVersion();
3484
3503
  const newCliVersion = await updateCheck();
@@ -3489,6 +3508,7 @@ async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
3489
3508
  Latest: ${newCliVersion}`,
3490
3509
  "Run latest: npx trigger.dev@beta"
3491
3510
  );
3511
+ hasOutput = true;
3492
3512
  }
3493
3513
  const triggerDependencies = getTriggerDependencies(packageJson);
3494
3514
  function getVersionMismatches(deps, targetVersion) {
@@ -3505,8 +3525,9 @@ Latest: ${newCliVersion}`,
3505
3525
  if (versionMismatches.length === 0) {
3506
3526
  if (!embedded) {
3507
3527
  outro4(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
3528
+ return hasOutput;
3508
3529
  }
3509
- return;
3530
+ return hasOutput;
3510
3531
  }
3511
3532
  prettyWarning(
3512
3533
  "Mismatch between your CLI version and installed packages",
@@ -3516,15 +3537,15 @@ Latest: ${newCliVersion}`,
3516
3537
  outro4("Deploy failed");
3517
3538
  console.log(
3518
3539
  `ERROR: Version mismatch detected while running in CI. This won't end well. Aborting.
3519
-
3520
- 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.
3521
-
3522
- 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.
3523
-
3524
- CLI version: ${cliVersion}
3525
-
3526
- Current package versions that don't match the CLI:
3527
- ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3540
+
3541
+ 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.
3542
+
3543
+ If your local CLI version doesn't match the one below, you may want to pin the CLI version in this CI step. To do that, just replace \`trigger.dev@beta\` with \`trigger.dev@<FULL_VERSION>\`, for example: \`npx trigger.dev@3.0.0-beta.17 deploy\`
3544
+
3545
+ CLI version: ${cliVersion}
3546
+
3547
+ Current package versions that don't match the CLI:
3548
+ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3528
3549
  `
3529
3550
  );
3530
3551
  process.exit(1);
@@ -3548,7 +3569,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3548
3569
  if (!embedded) {
3549
3570
  outro4("You've been warned!");
3550
3571
  }
3551
- return;
3572
+ return hasOutput;
3552
3573
  }
3553
3574
  const installSpinner = spinner();
3554
3575
  installSpinner.start("Writing new package.json file");
@@ -3589,6 +3610,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
3589
3610
  `Packages updated${newCliVersion ? " ..but you should really update your CLI too!" : ""}`
3590
3611
  );
3591
3612
  }
3613
+ return hasOutput;
3592
3614
  }
3593
3615
  function getTriggerDependencies(packageJson) {
3594
3616
  const deps = [];
@@ -4418,7 +4440,12 @@ async function compileProject(config, options, configPath) {
4418
4440
  config.dependenciesToBundle,
4419
4441
  config.tsconfigPath
4420
4442
  ),
4421
- workerSetupImportConfigPlugin(configPath)
4443
+ workerSetupImportConfigPlugin(configPath),
4444
+ esbuildDecorators2({
4445
+ tsconfig: config.tsconfigPath,
4446
+ tsx: true,
4447
+ force: false
4448
+ })
4422
4449
  ]
4423
4450
  });
4424
4451
  if (result.errors.length > 0) {
@@ -5480,6 +5507,7 @@ function runtimeCheck(minimumMajor, minimumMinor) {
5480
5507
 
5481
5508
  // src/commands/dev.tsx
5482
5509
  import { findUp as findUp3, pathExists as pathExists2 } from "find-up";
5510
+ import { esbuildDecorators as esbuildDecorators3 } from "@anatine/esbuild-decorators";
5483
5511
  var apiClient;
5484
5512
  var DevCommandOptions = CommonCommandOptions.extend({
5485
5513
  debugger: z5.boolean().default(false),
@@ -5535,11 +5563,11 @@ async function startDev(dir, options, authorization, dashboardUrl) {
5535
5563
  logger.loggerLevel = options.logLevel;
5536
5564
  }
5537
5565
  await printStandloneInitialBanner(true);
5566
+ let displayedUpdateMessage = false;
5538
5567
  if (!options.skipUpdateCheck) {
5539
- console.log();
5540
- await updateTriggerPackages(dir, { ...options }, false, true);
5568
+ displayedUpdateMessage = await updateTriggerPackages(dir, { ...options }, true, true);
5541
5569
  }
5542
- printDevBanner(!options.skipUpdateCheck);
5570
+ printDevBanner(displayedUpdateMessage);
5543
5571
  logger.debug("Starting dev session", { dir, options, authorization });
5544
5572
  let config = await readConfig(dir, {
5545
5573
  projectRef: options.projectRef,
@@ -5758,6 +5786,11 @@ function useDev({
5758
5786
  config.tsconfigPath
5759
5787
  ),
5760
5788
  workerSetupImportConfigPlugin(configPath),
5789
+ esbuildDecorators3({
5790
+ tsconfig: config.tsconfigPath,
5791
+ tsx: true,
5792
+ force: false
5793
+ }),
5761
5794
  {
5762
5795
  name: "trigger.dev v3",
5763
5796
  setup(build3) {