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

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-20240801102736";
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-20240801102736",
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,11 @@ 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
+ log3.message("Please install `xdg-utils` to automatically open the login URL.");
2829
+ } else {
2830
+ await open_default(authorizationCodeResult.url);
2831
+ }
2804
2832
  const getPersonalAccessTokenSpinner = spinner();
2805
2833
  getPersonalAccessTokenSpinner.start("Waiting for you to login");
2806
2834
  try {
@@ -3013,7 +3041,7 @@ function workerSetupImportConfigPlugin(configPath) {
3013
3041
  }
3014
3042
  };
3015
3043
  }
3016
- function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfigPath) {
3044
+ function bundleDependenciesPlugin(buildIdentifier, dependencies2, dependenciesToBundle, tsconfigPath) {
3017
3045
  const matchPath = tsconfigPath ? createMatchPath(tsconfigPath) : void 0;
3018
3046
  function resolvePath(id) {
3019
3047
  if (!matchPath) {
@@ -3045,6 +3073,9 @@ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfi
3045
3073
  return void 0;
3046
3074
  }
3047
3075
  }
3076
+ if (dependencies2[args.path] && !dependencies2[args.path].external) {
3077
+ return void 0;
3078
+ }
3048
3079
  logger.debug(`[${buildIdentifier}] Externalizing ${args.path}`, {
3049
3080
  ...args
3050
3081
  });
@@ -3444,10 +3475,33 @@ var JavascriptProject = class {
3444
3475
  });
3445
3476
  }
3446
3477
  }
3447
- 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) {
3448
3503
  return tracer.startActiveSpan("JavascriptProject.resolveAll", async (span) => {
3449
3504
  const externalPackages = packageNames.filter((packageName) => !isBuiltInModule(packageName));
3450
- const opts = { allowDev: false, ...options };
3451
3505
  const command = await this.#getCommand();
3452
3506
  span.setAttributes({
3453
3507
  externalPackages,
@@ -3475,15 +3529,6 @@ var JavascriptProject = class {
3475
3529
  });
3476
3530
  missingPackageVersions[packageName] = packageJsonVersion;
3477
3531
  }
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
3532
  }
3488
3533
  span.setAttributes({
3489
3534
  ...flattenAttributes2(missingPackageVersions, "missingPackageVersions"),
@@ -3593,6 +3638,36 @@ var PNPMCommands = class {
3593
3638
  }
3594
3639
  return results;
3595
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
+ }
3596
3671
  async #listDependencies(packageNames, options) {
3597
3672
  const childProcess2 = await $({
3598
3673
  cwd: options.cwd,
@@ -3600,7 +3675,7 @@ var PNPMCommands = class {
3600
3675
  })`${this.cmd} list ${packageNames} -r --json`;
3601
3676
  if (childProcess2.failed) {
3602
3677
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3603
- error: childProcess2.stderr
3678
+ error: childProcess2
3604
3679
  });
3605
3680
  }
3606
3681
  return JSON.parse(childProcess2.stdout);
@@ -3635,6 +3710,23 @@ var NPMCommands = class {
3635
3710
  }
3636
3711
  return results;
3637
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
+ }
3638
3730
  async #listDependencies(packageNames, options) {
3639
3731
  const childProcess2 = await $({
3640
3732
  cwd: options.cwd,
@@ -3642,7 +3734,7 @@ var NPMCommands = class {
3642
3734
  })`${this.cmd} list ${packageNames} --json`;
3643
3735
  if (childProcess2.failed) {
3644
3736
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3645
- error: childProcess2.stderr
3737
+ error: childProcess2
3646
3738
  });
3647
3739
  }
3648
3740
  return JSON.parse(childProcess2.stdout);
@@ -3660,6 +3752,17 @@ var NPMCommands = class {
3660
3752
  }
3661
3753
  }
3662
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
+ }
3663
3766
  };
3664
3767
  var YarnCommands = class {
3665
3768
  get name() {
@@ -3697,6 +3800,30 @@ var YarnCommands = class {
3697
3800
  }
3698
3801
  return results;
3699
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
+ }
3700
3827
  async #listDependencies(packageNames, options) {
3701
3828
  const childProcess2 = await $({
3702
3829
  cwd: options.cwd,
@@ -3704,7 +3831,7 @@ var YarnCommands = class {
3704
3831
  })`${this.cmd} info ${packageNames} --json`;
3705
3832
  if (childProcess2.failed) {
3706
3833
  logger.debug("Failed to list dependencies, using stdout anyway...", {
3707
- error: childProcess2.stderr
3834
+ error: childProcess2
3708
3835
  });
3709
3836
  }
3710
3837
  return childProcess2.stdout;
@@ -3720,6 +3847,26 @@ var YarnCommands = class {
3720
3847
  }
3721
3848
  return parts[0];
3722
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
+ }
3723
3870
  };
3724
3871
  function isBuiltInModule(module) {
3725
3872
  if (module.startsWith("node:")) {
@@ -4843,6 +4990,7 @@ async function compileProject(config, options, configPath) {
4843
4990
  mockServerOnlyPlugin(),
4844
4991
  bundleDependenciesPlugin(
4845
4992
  "workerFacade",
4993
+ {},
4846
4994
  config.dependenciesToBundle,
4847
4995
  config.tsconfigPath
4848
4996
  ),
@@ -4894,6 +5042,7 @@ async function compileProject(config, options, configPath) {
4894
5042
  plugins: [
4895
5043
  bundleDependenciesPlugin(
4896
5044
  "entryPoint.ts",
5045
+ {},
4897
5046
  config.dependenciesToBundle,
4898
5047
  config.tsconfigPath
4899
5048
  )
@@ -6657,6 +6806,7 @@ function useDev({
6657
6806
  bundleTriggerDevCore("workerFacade", config.tsconfigPath),
6658
6807
  bundleDependenciesPlugin(
6659
6808
  "workerFacade",
6809
+ {},
6660
6810
  (config.dependenciesToBundle ?? []).concat([/^@trigger.dev/]),
6661
6811
  config.tsconfigPath
6662
6812
  ),