trigger.dev 0.0.0-v3-prerelease-20240717092755 → 0.0.0-v3-prerelease-20240730135037

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 = "0.0.0-v3-prerelease-20240717092755";
801
+ var version = "0.0.0-v3-prerelease-20240730135037";
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:0.0.0-v3-prerelease-20240717092755",
818
+ "@trigger.dev/core": "workspace:0.0.0-v3-prerelease-20240730135037",
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,7 +2824,13 @@ async function login(options) {
2800
2824
  `Please visit the following URL to login:
2801
2825
  ${chalkLink(authorizationCodeResult.url)}`
2802
2826
  );
2803
- await open_default(authorizationCodeResult.url);
2827
+ if (await isLinuxServer()) {
2828
+ logger.debug(
2829
+ "Will not open login URL automatically, please install `xdg-utils` to change this behavior."
2830
+ );
2831
+ } else {
2832
+ await open_default(authorizationCodeResult.url);
2833
+ }
2804
2834
  const getPersonalAccessTokenSpinner = spinner();
2805
2835
  getPersonalAccessTokenSpinner.start("Waiting for you to login");
2806
2836
  try {
@@ -3013,7 +3043,7 @@ function workerSetupImportConfigPlugin(configPath) {
3013
3043
  }
3014
3044
  };
3015
3045
  }
3016
- function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfigPath) {
3046
+ function bundleDependenciesPlugin(buildIdentifier, dependencies2, dependenciesToBundle, tsconfigPath) {
3017
3047
  const matchPath = tsconfigPath ? createMatchPath(tsconfigPath) : void 0;
3018
3048
  function resolvePath(id) {
3019
3049
  if (!matchPath) {
@@ -3045,6 +3075,9 @@ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfi
3045
3075
  return void 0;
3046
3076
  }
3047
3077
  }
3078
+ if (dependencies2[args.path] && !dependencies2[args.path].external) {
3079
+ return void 0;
3080
+ }
3048
3081
  logger.debug(`[${buildIdentifier}] Externalizing ${args.path}`, {
3049
3082
  ...args
3050
3083
  });
@@ -3444,10 +3477,33 @@ var JavascriptProject = class {
3444
3477
  });
3445
3478
  }
3446
3479
  }
3447
- async resolveAll(packageNames, options) {
3480
+ async extractDirectDependenciesMeta() {
3481
+ return tracer.startActiveSpan(
3482
+ "JavascriptProject.extractDirectDependenciesMeta",
3483
+ async (span) => {
3484
+ const command = await this.#getCommand();
3485
+ span.setAttributes({
3486
+ packageManager: command.name
3487
+ });
3488
+ try {
3489
+ span.end();
3490
+ return await command.extractDirectDependenciesMeta({
3491
+ cwd: this.projectPath
3492
+ });
3493
+ } catch (error) {
3494
+ recordSpanException4(span, error);
3495
+ span.end();
3496
+ logger.debug(`Failed to resolve internal dependencies using ${command.name}`, {
3497
+ error
3498
+ });
3499
+ throw error;
3500
+ }
3501
+ }
3502
+ );
3503
+ }
3504
+ async resolveAll(packageNames) {
3448
3505
  return tracer.startActiveSpan("JavascriptProject.resolveAll", async (span) => {
3449
3506
  const externalPackages = packageNames.filter((packageName) => !isBuiltInModule(packageName));
3450
- const opts = { allowDev: false, ...options };
3451
3507
  const command = await this.#getCommand();
3452
3508
  span.setAttributes({
3453
3509
  externalPackages,
@@ -3475,15 +3531,6 @@ var JavascriptProject = class {
3475
3531
  });
3476
3532
  missingPackageVersions[packageName] = packageJsonVersion;
3477
3533
  }
3478
- if (opts.allowDev) {
3479
- const devPackageJsonVersion = this.packageJson.devDependencies?.[packageName];
3480
- if (typeof devPackageJsonVersion === "string") {
3481
- logger.debug(`Resolved ${packageName} version using devDependencies`, {
3482
- devPackageJsonVersion
3483
- });
3484
- missingPackageVersions[packageName] = devPackageJsonVersion;
3485
- }
3486
- }
3487
3534
  }
3488
3535
  span.setAttributes({
3489
3536
  ...flattenAttributes2(missingPackageVersions, "missingPackageVersions"),
@@ -3593,6 +3640,36 @@ var PNPMCommands = class {
3593
3640
  }
3594
3641
  return results;
3595
3642
  }
3643
+ async extractDirectDependenciesMeta(options) {
3644
+ const result = await this.#listDirectDependencies(options);
3645
+ logger.debug(`Extracting direct dependencies metadata using ${this.name}`);
3646
+ const results = {};
3647
+ for (const projectPkg of result) {
3648
+ results[projectPkg.name] = { version: projectPkg.version, external: false };
3649
+ if (projectPkg.dependencies) {
3650
+ for (const [name, dep] of Object.entries(projectPkg.dependencies)) {
3651
+ const { version: version2 } = dep;
3652
+ results[name] = {
3653
+ version: version2,
3654
+ external: !version2.startsWith("link:")
3655
+ };
3656
+ }
3657
+ }
3658
+ }
3659
+ return results;
3660
+ }
3661
+ async #listDirectDependencies(options) {
3662
+ const childProcess2 = await $({
3663
+ cwd: options.cwd,
3664
+ reject: false
3665
+ })`${this.cmd} list --recursive --json`;
3666
+ if (childProcess2.failed) {
3667
+ logger.debug("Failed to list dependencies, using stdout anyway...", {
3668
+ error: childProcess2
3669
+ });
3670
+ }
3671
+ return JSON.parse(childProcess2.stdout);
3672
+ }
3596
3673
  async #listDependencies(packageNames, options) {
3597
3674
  const childProcess2 = await $({
3598
3675
  cwd: options.cwd,
@@ -3600,7 +3677,7 @@ var PNPMCommands = class {
3600
3677
  })`${this.cmd} list ${packageNames} -r --json`;
3601
3678
  if (childProcess2.failed) {
3602
3679
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3603
- error: childProcess2.stderr
3680
+ error: childProcess2
3604
3681
  });
3605
3682
  }
3606
3683
  return JSON.parse(childProcess2.stdout);
@@ -3635,6 +3712,23 @@ var NPMCommands = class {
3635
3712
  }
3636
3713
  return results;
3637
3714
  }
3715
+ async extractDirectDependenciesMeta(options) {
3716
+ const result = await this.#listDirectDependencies(options);
3717
+ logger.debug(`Extracting direct dependencies metadata using ${this.name}`);
3718
+ return result.dependencies ? this.#flattenDependenciesMeta(result.dependencies) : {};
3719
+ }
3720
+ async #listDirectDependencies(options) {
3721
+ const childProcess2 = await $({
3722
+ cwd: options.cwd,
3723
+ reject: false
3724
+ })`${this.cmd} list --json`;
3725
+ if (childProcess2.failed) {
3726
+ logger.debug("Failed to list dependencies, using stdout anyway...", {
3727
+ error: childProcess2
3728
+ });
3729
+ }
3730
+ return JSON.parse(childProcess2.stdout);
3731
+ }
3638
3732
  async #listDependencies(packageNames, options) {
3639
3733
  const childProcess2 = await $({
3640
3734
  cwd: options.cwd,
@@ -3642,7 +3736,7 @@ var NPMCommands = class {
3642
3736
  })`${this.cmd} list ${packageNames} --json`;
3643
3737
  if (childProcess2.failed) {
3644
3738
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3645
- error: childProcess2.stderr
3739
+ error: childProcess2
3646
3740
  });
3647
3741
  }
3648
3742
  return JSON.parse(childProcess2.stdout);
@@ -3660,6 +3754,17 @@ var NPMCommands = class {
3660
3754
  }
3661
3755
  }
3662
3756
  }
3757
+ #flattenDependenciesMeta(dependencies2) {
3758
+ let results = {};
3759
+ for (const [name, dep] of Object.entries(dependencies2)) {
3760
+ const { version: version2, resolved, dependencies: children } = dep;
3761
+ results[name] = { version: version2, external: !!resolved && !resolved.startsWith("file:") };
3762
+ if (children) {
3763
+ results = { ...results, ...this.#flattenDependenciesMeta(children) };
3764
+ }
3765
+ }
3766
+ return results;
3767
+ }
3663
3768
  };
3664
3769
  var YarnCommands = class {
3665
3770
  get name() {
@@ -3697,6 +3802,30 @@ var YarnCommands = class {
3697
3802
  }
3698
3803
  return results;
3699
3804
  }
3805
+ async extractDirectDependenciesMeta(options) {
3806
+ const result = await this.#listDirectDependencies(options);
3807
+ const rawPackagesData = result.split("\n");
3808
+ logger.debug(`Extracting direct dependencies metadata using ${this.name}`);
3809
+ const results = {};
3810
+ for (const rawPackageData of rawPackagesData) {
3811
+ const packageData = JSON.parse(rawPackageData);
3812
+ const [name, dependencyMeta] = this.#parseYarnValueIntoDependencyMeta(packageData.value);
3813
+ results[name] = dependencyMeta;
3814
+ }
3815
+ return results;
3816
+ }
3817
+ async #listDirectDependencies(options) {
3818
+ const childProcess2 = await $({
3819
+ cwd: options.cwd,
3820
+ reject: false
3821
+ })`${this.cmd} info --all --json`;
3822
+ if (childProcess2.failed) {
3823
+ logger.debug("Failed to list dependencies, using stdout anyway...", {
3824
+ error: childProcess2
3825
+ });
3826
+ }
3827
+ return childProcess2.stdout;
3828
+ }
3700
3829
  async #listDependencies(packageNames, options) {
3701
3830
  const childProcess2 = await $({
3702
3831
  cwd: options.cwd,
@@ -3704,7 +3833,7 @@ var YarnCommands = class {
3704
3833
  })`${this.cmd} info ${packageNames} --json`;
3705
3834
  if (childProcess2.failed) {
3706
3835
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3707
- error: childProcess2.stderr
3836
+ error: childProcess2
3708
3837
  });
3709
3838
  }
3710
3839
  return childProcess2.stdout;
@@ -3720,6 +3849,26 @@ var YarnCommands = class {
3720
3849
  }
3721
3850
  return parts[0];
3722
3851
  }
3852
+ #parseYarnValueIntoDependencyMeta(value) {
3853
+ const parts = value.split("@");
3854
+ let name, protocol, version2;
3855
+ if (parts.length === 3) {
3856
+ name = `@${parts[1]}`;
3857
+ [protocol = "", version2 = ""] = parts[2].split(":");
3858
+ } else if (parts.length === 2) {
3859
+ name = parts[0].toString();
3860
+ [protocol = "", version2 = ""] = parts[1].split(":");
3861
+ } else {
3862
+ throw new Error("Failed parsing ${value} into dependency meta");
3863
+ }
3864
+ return [
3865
+ name,
3866
+ {
3867
+ version: version2,
3868
+ external: protocol !== "workspace" && protocol !== "file"
3869
+ }
3870
+ ];
3871
+ }
3723
3872
  };
3724
3873
  function isBuiltInModule(module) {
3725
3874
  if (module.startsWith("node:")) {
@@ -4843,6 +4992,7 @@ async function compileProject(config, options, configPath) {
4843
4992
  mockServerOnlyPlugin(),
4844
4993
  bundleDependenciesPlugin(
4845
4994
  "workerFacade",
4995
+ {},
4846
4996
  config.dependenciesToBundle,
4847
4997
  config.tsconfigPath
4848
4998
  ),
@@ -4894,6 +5044,7 @@ async function compileProject(config, options, configPath) {
4894
5044
  plugins: [
4895
5045
  bundleDependenciesPlugin(
4896
5046
  "entryPoint.ts",
5047
+ {},
4897
5048
  config.dependenciesToBundle,
4898
5049
  config.tsconfigPath
4899
5050
  )
@@ -6657,6 +6808,7 @@ function useDev({
6657
6808
  bundleTriggerDevCore("workerFacade", config.tsconfigPath),
6658
6809
  bundleDependenciesPlugin(
6659
6810
  "workerFacade",
6811
+ {},
6660
6812
  (config.dependenciesToBundle ?? []).concat([/^@trigger.dev/]),
6661
6813
  config.tsconfigPath
6662
6814
  ),