trigger.dev 3.0.0-beta.50 → 3.0.0-beta.52

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
@@ -798,7 +798,7 @@ import invariant from "tiny-invariant";
798
798
  import { z as z4 } from "zod";
799
799
 
800
800
  // package.json
801
- var version = "3.0.0-beta.50";
801
+ var version = "3.0.0-beta.52";
802
802
  var dependencies = {
803
803
  "@anatine/esbuild-decorators": "^0.2.19",
804
804
  "@clack/prompts": "^0.7.0",
@@ -815,7 +815,7 @@ var dependencies = {
815
815
  "@opentelemetry/sdk-trace-base": "^1.22.0",
816
816
  "@opentelemetry/sdk-trace-node": "^1.22.0",
817
817
  "@opentelemetry/semantic-conventions": "^1.22.0",
818
- "@trigger.dev/core": "workspace:3.0.0-beta.50",
818
+ "@trigger.dev/core": "workspace:3.0.0-beta.52",
819
819
  "@types/degit": "^2.8.3",
820
820
  chalk: "^5.2.0",
821
821
  chokidar: "^3.5.3",
@@ -2658,6 +2658,30 @@ URL: ${chalkLink(authentication.auth.apiUrl)}
2658
2658
  return userData;
2659
2659
  }
2660
2660
 
2661
+ // src/utilities/linux.ts
2662
+ import { spawn } from "child_process";
2663
+ var isLinuxServer = async () => {
2664
+ if (process.platform !== "linux") {
2665
+ return false;
2666
+ }
2667
+ const xdgAvailable = await new Promise((res) => {
2668
+ const xdg = spawn("xdg-open");
2669
+ xdg.on("error", (error) => {
2670
+ logger.debug("Error while checking for xdg-open", error);
2671
+ res(false);
2672
+ });
2673
+ xdg.on("spawn", () => {
2674
+ res(true);
2675
+ });
2676
+ xdg.on("exit", (code) => {
2677
+ res(code === 0);
2678
+ });
2679
+ xdg.unref();
2680
+ });
2681
+ logger.debug("xdg-open available:", xdgAvailable);
2682
+ return !xdgAvailable;
2683
+ };
2684
+
2661
2685
  // src/commands/login.ts
2662
2686
  var LoginCommandOptions = CommonCommandOptions.extend({
2663
2687
  apiUrl: z3.string()
@@ -2800,9 +2824,10 @@ async function login(options) {
2800
2824
  `Please visit the following URL to login:
2801
2825
  ${chalkLink(authorizationCodeResult.url)}`
2802
2826
  );
2803
- try {
2827
+ if (await isLinuxServer()) {
2828
+ log3.message("Please install `xdg-utils` to automatically open the login URL.");
2829
+ } else {
2804
2830
  await open_default(authorizationCodeResult.url);
2805
- } catch (e) {
2806
2831
  }
2807
2832
  const getPersonalAccessTokenSpinner = spinner();
2808
2833
  getPersonalAccessTokenSpinner.start("Waiting for you to login");
@@ -3016,7 +3041,7 @@ function workerSetupImportConfigPlugin(configPath) {
3016
3041
  }
3017
3042
  };
3018
3043
  }
3019
- function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfigPath) {
3044
+ function bundleDependenciesPlugin(buildIdentifier, dependencies2, dependenciesToBundle, tsconfigPath) {
3020
3045
  const matchPath = tsconfigPath ? createMatchPath(tsconfigPath) : void 0;
3021
3046
  function resolvePath(id) {
3022
3047
  if (!matchPath) {
@@ -3048,6 +3073,9 @@ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfi
3048
3073
  return void 0;
3049
3074
  }
3050
3075
  }
3076
+ if (dependencies2[args.path] && !dependencies2[args.path].external) {
3077
+ return void 0;
3078
+ }
3051
3079
  logger.debug(`[${buildIdentifier}] Externalizing ${args.path}`, {
3052
3080
  ...args
3053
3081
  });
@@ -3447,10 +3475,33 @@ var JavascriptProject = class {
3447
3475
  });
3448
3476
  }
3449
3477
  }
3450
- async resolveAll(packageNames, options) {
3478
+ async extractDirectDependenciesMeta() {
3479
+ return tracer.startActiveSpan(
3480
+ "JavascriptProject.extractDirectDependenciesMeta",
3481
+ async (span) => {
3482
+ const command = await this.#getCommand();
3483
+ span.setAttributes({
3484
+ packageManager: command.name
3485
+ });
3486
+ try {
3487
+ span.end();
3488
+ return await command.extractDirectDependenciesMeta({
3489
+ cwd: this.projectPath
3490
+ });
3491
+ } catch (error) {
3492
+ recordSpanException4(span, error);
3493
+ span.end();
3494
+ logger.debug(`Failed to resolve internal dependencies using ${command.name}`, {
3495
+ error
3496
+ });
3497
+ throw error;
3498
+ }
3499
+ }
3500
+ );
3501
+ }
3502
+ async resolveAll(packageNames) {
3451
3503
  return tracer.startActiveSpan("JavascriptProject.resolveAll", async (span) => {
3452
3504
  const externalPackages = packageNames.filter((packageName) => !isBuiltInModule(packageName));
3453
- const opts = { allowDev: false, ...options };
3454
3505
  const command = await this.#getCommand();
3455
3506
  span.setAttributes({
3456
3507
  externalPackages,
@@ -3478,15 +3529,6 @@ var JavascriptProject = class {
3478
3529
  });
3479
3530
  missingPackageVersions[packageName] = packageJsonVersion;
3480
3531
  }
3481
- if (opts.allowDev) {
3482
- const devPackageJsonVersion = this.packageJson.devDependencies?.[packageName];
3483
- if (typeof devPackageJsonVersion === "string") {
3484
- logger.debug(`Resolved ${packageName} version using devDependencies`, {
3485
- devPackageJsonVersion
3486
- });
3487
- missingPackageVersions[packageName] = devPackageJsonVersion;
3488
- }
3489
- }
3490
3532
  }
3491
3533
  span.setAttributes({
3492
3534
  ...flattenAttributes2(missingPackageVersions, "missingPackageVersions"),
@@ -3596,6 +3638,36 @@ var PNPMCommands = class {
3596
3638
  }
3597
3639
  return results;
3598
3640
  }
3641
+ async extractDirectDependenciesMeta(options) {
3642
+ const result = await this.#listDirectDependencies(options);
3643
+ logger.debug(`Extracting direct dependencies metadata using ${this.name}`);
3644
+ const results = {};
3645
+ for (const projectPkg of result) {
3646
+ results[projectPkg.name] = { version: projectPkg.version, external: false };
3647
+ if (projectPkg.dependencies) {
3648
+ for (const [name, dep] of Object.entries(projectPkg.dependencies)) {
3649
+ const { version: version2 } = dep;
3650
+ results[name] = {
3651
+ version: version2,
3652
+ external: !version2.startsWith("link:")
3653
+ };
3654
+ }
3655
+ }
3656
+ }
3657
+ return results;
3658
+ }
3659
+ async #listDirectDependencies(options) {
3660
+ const childProcess2 = await $({
3661
+ cwd: options.cwd,
3662
+ reject: false
3663
+ })`${this.cmd} list --recursive --json`;
3664
+ if (childProcess2.failed) {
3665
+ logger.debug("Failed to list dependencies, using stdout anyway...", {
3666
+ error: childProcess2
3667
+ });
3668
+ }
3669
+ return JSON.parse(childProcess2.stdout);
3670
+ }
3599
3671
  async #listDependencies(packageNames, options) {
3600
3672
  const childProcess2 = await $({
3601
3673
  cwd: options.cwd,
@@ -3603,7 +3675,7 @@ var PNPMCommands = class {
3603
3675
  })`${this.cmd} list ${packageNames} -r --json`;
3604
3676
  if (childProcess2.failed) {
3605
3677
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3606
- error: childProcess2.stderr
3678
+ error: childProcess2
3607
3679
  });
3608
3680
  }
3609
3681
  return JSON.parse(childProcess2.stdout);
@@ -3638,6 +3710,23 @@ var NPMCommands = class {
3638
3710
  }
3639
3711
  return results;
3640
3712
  }
3713
+ async extractDirectDependenciesMeta(options) {
3714
+ const result = await this.#listDirectDependencies(options);
3715
+ logger.debug(`Extracting direct dependencies metadata using ${this.name}`);
3716
+ return result.dependencies ? this.#flattenDependenciesMeta(result.dependencies) : {};
3717
+ }
3718
+ async #listDirectDependencies(options) {
3719
+ const childProcess2 = await $({
3720
+ cwd: options.cwd,
3721
+ reject: false
3722
+ })`${this.cmd} list --json`;
3723
+ if (childProcess2.failed) {
3724
+ logger.debug("Failed to list dependencies, using stdout anyway...", {
3725
+ error: childProcess2
3726
+ });
3727
+ }
3728
+ return JSON.parse(childProcess2.stdout);
3729
+ }
3641
3730
  async #listDependencies(packageNames, options) {
3642
3731
  const childProcess2 = await $({
3643
3732
  cwd: options.cwd,
@@ -3645,7 +3734,7 @@ var NPMCommands = class {
3645
3734
  })`${this.cmd} list ${packageNames} --json`;
3646
3735
  if (childProcess2.failed) {
3647
3736
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3648
- error: childProcess2.stderr
3737
+ error: childProcess2
3649
3738
  });
3650
3739
  }
3651
3740
  return JSON.parse(childProcess2.stdout);
@@ -3663,6 +3752,17 @@ var NPMCommands = class {
3663
3752
  }
3664
3753
  }
3665
3754
  }
3755
+ #flattenDependenciesMeta(dependencies2) {
3756
+ let results = {};
3757
+ for (const [name, dep] of Object.entries(dependencies2)) {
3758
+ const { version: version2, resolved, dependencies: children } = dep;
3759
+ results[name] = { version: version2, external: !!resolved && !resolved.startsWith("file:") };
3760
+ if (children) {
3761
+ results = { ...results, ...this.#flattenDependenciesMeta(children) };
3762
+ }
3763
+ }
3764
+ return results;
3765
+ }
3666
3766
  };
3667
3767
  var YarnCommands = class {
3668
3768
  get name() {
@@ -3700,6 +3800,30 @@ var YarnCommands = class {
3700
3800
  }
3701
3801
  return results;
3702
3802
  }
3803
+ async extractDirectDependenciesMeta(options) {
3804
+ const result = await this.#listDirectDependencies(options);
3805
+ const rawPackagesData = result.split("\n");
3806
+ logger.debug(`Extracting direct dependencies metadata using ${this.name}`);
3807
+ const results = {};
3808
+ for (const rawPackageData of rawPackagesData) {
3809
+ const packageData = JSON.parse(rawPackageData);
3810
+ const [name, dependencyMeta] = this.#parseYarnValueIntoDependencyMeta(packageData.value);
3811
+ results[name] = dependencyMeta;
3812
+ }
3813
+ return results;
3814
+ }
3815
+ async #listDirectDependencies(options) {
3816
+ const childProcess2 = await $({
3817
+ cwd: options.cwd,
3818
+ reject: false
3819
+ })`${this.cmd} info --all --json`;
3820
+ if (childProcess2.failed) {
3821
+ logger.debug("Failed to list dependencies, using stdout anyway...", {
3822
+ error: childProcess2
3823
+ });
3824
+ }
3825
+ return childProcess2.stdout;
3826
+ }
3703
3827
  async #listDependencies(packageNames, options) {
3704
3828
  const childProcess2 = await $({
3705
3829
  cwd: options.cwd,
@@ -3707,7 +3831,7 @@ var YarnCommands = class {
3707
3831
  })`${this.cmd} info ${packageNames} --json`;
3708
3832
  if (childProcess2.failed) {
3709
3833
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3710
- error: childProcess2.stderr
3834
+ error: childProcess2
3711
3835
  });
3712
3836
  }
3713
3837
  return childProcess2.stdout;
@@ -3723,6 +3847,26 @@ var YarnCommands = class {
3723
3847
  }
3724
3848
  return parts[0];
3725
3849
  }
3850
+ #parseYarnValueIntoDependencyMeta(value) {
3851
+ const parts = value.split("@");
3852
+ let name, protocol, version2;
3853
+ if (parts.length === 3) {
3854
+ name = `@${parts[1]}`;
3855
+ [protocol = "", version2 = ""] = parts[2].split(":");
3856
+ } else if (parts.length === 2) {
3857
+ name = parts[0].toString();
3858
+ [protocol = "", version2 = ""] = parts[1].split(":");
3859
+ } else {
3860
+ throw new Error("Failed parsing ${value} into dependency meta");
3861
+ }
3862
+ return [
3863
+ name,
3864
+ {
3865
+ version: version2,
3866
+ external: protocol !== "workspace" && protocol !== "file"
3867
+ }
3868
+ ];
3869
+ }
3726
3870
  };
3727
3871
  function isBuiltInModule(module) {
3728
3872
  if (module.startsWith("node:")) {
@@ -4846,6 +4990,7 @@ async function compileProject(config, options, configPath) {
4846
4990
  mockServerOnlyPlugin(),
4847
4991
  bundleDependenciesPlugin(
4848
4992
  "workerFacade",
4993
+ {},
4849
4994
  config.dependenciesToBundle,
4850
4995
  config.tsconfigPath
4851
4996
  ),
@@ -4897,6 +5042,7 @@ async function compileProject(config, options, configPath) {
4897
5042
  plugins: [
4898
5043
  bundleDependenciesPlugin(
4899
5044
  "entryPoint.ts",
5045
+ {},
4900
5046
  config.dependenciesToBundle,
4901
5047
  config.tsconfigPath
4902
5048
  )
@@ -6660,6 +6806,7 @@ function useDev({
6660
6806
  bundleTriggerDevCore("workerFacade", config.tsconfigPath),
6661
6807
  bundleDependenciesPlugin(
6662
6808
  "workerFacade",
6809
+ {},
6663
6810
  (config.dependenciesToBundle ?? []).concat([/^@trigger.dev/]),
6664
6811
  config.tsconfigPath
6665
6812
  ),