trigger.dev 0.0.0-v3-canary-20240322112439 → 0.0.0-v3-canary-20240322145829

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
@@ -793,14 +793,14 @@ import { resolve as importResolve } from "import-meta-resolve";
793
793
  import { createHash } from "node:crypto";
794
794
  import { readFileSync } from "node:fs";
795
795
  import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
796
- import { join as join4 } from "node:path";
796
+ import { dirname, join as join4, relative as relative2 } from "node:path";
797
797
  import { setTimeout as setTimeout2 } from "node:timers/promises";
798
798
  import terminalLink from "terminal-link";
799
799
  import invariant from "tiny-invariant";
800
800
  import { z as z4 } from "zod";
801
801
 
802
802
  // package.json
803
- var version = "0.0.0-v3-canary-20240322112439";
803
+ var version = "0.0.0-v3-canary-20240322145829";
804
804
  var dependencies = {
805
805
  "@baselime/node-opentelemetry": "^0.4.6",
806
806
  "@clack/prompts": "^0.7.0",
@@ -821,7 +821,7 @@ var dependencies = {
821
821
  "@opentelemetry/sdk-trace-node": "^1.21.0",
822
822
  "@opentelemetry/semantic-conventions": "^1.21.0",
823
823
  "@traceloop/instrumentation-openai": "^0.3.9",
824
- "@trigger.dev/core": "workspace:0.0.0-v3-canary-20240322112439",
824
+ "@trigger.dev/core": "workspace:0.0.0-v3-canary-20240322145829",
825
825
  "@types/degit": "^2.8.3",
826
826
  chalk: "^5.2.0",
827
827
  chokidar: "^3.5.3",
@@ -833,6 +833,7 @@ var dependencies = {
833
833
  evt: "^2.4.13",
834
834
  execa: "^8.0.0",
835
835
  "find-up": "^7.0.0",
836
+ glob: "^10.3.10",
836
837
  "gradient-string": "^2.0.2",
837
838
  "import-meta-resolve": "^4.0.0",
838
839
  ink: "^4.4.1",
@@ -2766,6 +2767,7 @@ function getLoaderForFile(file) {
2766
2767
  }
2767
2768
 
2768
2769
  // src/commands/deploy.ts
2770
+ import { Glob } from "glob";
2769
2771
  var DeployCommandOptions = CommonCommandOptions.extend({
2770
2772
  skipTypecheck: z4.boolean().default(false),
2771
2773
  skipDeploy: z4.boolean().default(false),
@@ -3413,14 +3415,23 @@ async function compileProject(config, options, configPath) {
3413
3415
  await writeFile2(join4(tempDir, "worker.js.map"), workerSourcemapFile.text);
3414
3416
  await writeFile2(join4(tempDir, "index.js"), entryPointOutputFile.text);
3415
3417
  const allImports = [...metaOutput.imports, ...entryPointMetaOutput.imports];
3416
- const dependencies2 = await gatherRequiredDependencies(allImports, config);
3418
+ const externalPackageJson = await readJSONFile(join4(config.projectDir, "package.json"));
3419
+ const dependencies2 = await gatherRequiredDependencies(
3420
+ allImports,
3421
+ config,
3422
+ externalPackageJson
3423
+ );
3417
3424
  const packageJsonContents = {
3418
3425
  name: "trigger-worker",
3419
3426
  version: "0.0.0",
3420
3427
  description: "",
3421
- dependencies: dependencies2
3428
+ dependencies: dependencies2,
3429
+ scripts: {
3430
+ postinstall: externalPackageJson?.scripts?.postinstall
3431
+ }
3422
3432
  };
3423
3433
  await writeJSONFile(join4(tempDir, "package.json"), packageJsonContents);
3434
+ await copyAdditionalFiles(config, tempDir);
3424
3435
  compileSpinner.stop("Project built successfully");
3425
3436
  const resolvingDependenciesResult = await resolveDependencies(
3426
3437
  tempDir,
@@ -3557,8 +3568,7 @@ async function typecheckProject(config, options) {
3557
3568
  }
3558
3569
  });
3559
3570
  }
3560
- async function gatherRequiredDependencies(imports, config) {
3561
- const externalPackageJson = await readJSONFile(join4(config.projectDir, "package.json"));
3571
+ async function gatherRequiredDependencies(imports, config, projectPackageJson) {
3562
3572
  const dependencies2 = {};
3563
3573
  for (const file of imports) {
3564
3574
  if (file.kind !== "require-call" || !file.external) {
@@ -3568,7 +3578,7 @@ async function gatherRequiredDependencies(imports, config) {
3568
3578
  if (dependencies2[packageName]) {
3569
3579
  continue;
3570
3580
  }
3571
- const externalDependencyVersion = (externalPackageJson?.dependencies ?? {})[packageName];
3581
+ const externalDependencyVersion = (projectPackageJson?.dependencies ?? {})[packageName];
3572
3582
  if (externalDependencyVersion) {
3573
3583
  dependencies2[packageName] = stripWorkspaceFromVersion(externalDependencyVersion);
3574
3584
  continue;
@@ -3589,8 +3599,8 @@ async function gatherRequiredDependencies(imports, config) {
3589
3599
  continue;
3590
3600
  } else {
3591
3601
  const externalDependencyVersion = {
3592
- ...externalPackageJson?.devDependencies,
3593
- ...externalPackageJson?.dependencies
3602
+ ...projectPackageJson?.devDependencies,
3603
+ ...projectPackageJson?.dependencies
3594
3604
  }[packageName];
3595
3605
  if (externalDependencyVersion) {
3596
3606
  dependencies2[packageParts.name] = externalDependencyVersion;
@@ -3605,6 +3615,47 @@ async function gatherRequiredDependencies(imports, config) {
3605
3615
  }
3606
3616
  return Object.fromEntries(Object.entries(dependencies2).sort(([a], [b]) => a.localeCompare(b)));
3607
3617
  }
3618
+ async function copyAdditionalFiles(config, tempDir) {
3619
+ const additionalFiles = config.additionalFiles ?? [];
3620
+ if (additionalFiles.length === 0) {
3621
+ return;
3622
+ }
3623
+ return await tracer.startActiveSpan(
3624
+ "copyAdditionalFiles",
3625
+ {
3626
+ attributes: {
3627
+ "config.additionalFiles": additionalFiles
3628
+ }
3629
+ },
3630
+ async (span) => {
3631
+ try {
3632
+ logger.debug(`Copying files to ${tempDir}`, {
3633
+ additionalFiles
3634
+ });
3635
+ const glob = new Glob(additionalFiles, {
3636
+ withFileTypes: true,
3637
+ ignore: ["node_modules"],
3638
+ cwd: config.projectDir,
3639
+ nodir: true
3640
+ });
3641
+ for await (const file of glob) {
3642
+ const relativeDestinationPath = join4(
3643
+ tempDir,
3644
+ relative2(config.projectDir, file.fullpath())
3645
+ );
3646
+ logger.debug(`Copying file ${file.fullpath()} to ${relativeDestinationPath}`);
3647
+ await mkdir(dirname(relativeDestinationPath), { recursive: true });
3648
+ await copyFile(file.fullpath(), relativeDestinationPath);
3649
+ }
3650
+ span.end();
3651
+ } catch (error) {
3652
+ recordSpanException4(span, error);
3653
+ span.end();
3654
+ throw error;
3655
+ }
3656
+ }
3657
+ );
3658
+ }
3608
3659
  async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
3609
3660
  const tmpDir = await createTempDir();
3610
3661
  const dockerConfigPath = join4(tmpDir, "config.json");
@@ -3653,7 +3704,7 @@ import { resolve as importResolve2 } from "import-meta-resolve";
3653
3704
  import { Box, Text, render, useApp, useInput } from "ink";
3654
3705
  import { createHash as createHash2 } from "node:crypto";
3655
3706
  import fs7, { readFileSync as readFileSync2 } from "node:fs";
3656
- import { basename, dirname as dirname2, join as join5 } from "node:path";
3707
+ import { basename, dirname as dirname3, join as join5 } from "node:path";
3657
3708
  import pThrottle from "p-throttle";
3658
3709
  import { WebSocket } from "partysocket";
3659
3710
  import React, { Suspense, useEffect } from "react";
@@ -3684,7 +3735,7 @@ import chalk5 from "chalk";
3684
3735
  import dotenv from "dotenv";
3685
3736
  import { Evt } from "evt";
3686
3737
  import { fork } from "node:child_process";
3687
- import { dirname, resolve as resolve2 } from "node:path";
3738
+ import { dirname as dirname2, resolve as resolve2 } from "node:path";
3688
3739
  import terminalLink2 from "terminal-link";
3689
3740
  var BackgroundWorkerCoordinator = class {
3690
3741
  constructor(baseURL) {
@@ -3866,7 +3917,7 @@ var BackgroundWorker = class {
3866
3917
  throw new Error("Worker already initialized");
3867
3918
  }
3868
3919
  if (this.params.dependencies) {
3869
- await installPackages(this.params.dependencies, { cwd: dirname(this.path) });
3920
+ await installPackages(this.params.dependencies, { cwd: dirname2(this.path) });
3870
3921
  }
3871
3922
  let resolved = false;
3872
3923
  this.tasks = await new Promise((resolve4, reject) => {
@@ -4050,7 +4101,6 @@ var TaskRunProcess = class {
4050
4101
  schema: workerToChildMessages,
4051
4102
  sender: async (message) => {
4052
4103
  if (this._child?.connected && !this._isBeingKilled && !this._child.killed) {
4053
- logger.debug(`[${this.runId}] sending message to task run process`, { message });
4054
4104
  this._child.send(message);
4055
4105
  }
4056
4106
  }
@@ -4087,7 +4137,7 @@ var TaskRunProcess = class {
4087
4137
  "pipe",
4088
4138
  "ipc"
4089
4139
  ],
4090
- cwd: dirname(this.path),
4140
+ cwd: dirname2(this.path),
4091
4141
  env: {
4092
4142
  ...this.env,
4093
4143
  OTEL_RESOURCE_ATTRIBUTES: JSON.stringify({
@@ -4512,7 +4562,7 @@ function useDev({
4512
4562
  const sourceMapPath = `${fullPath}.map`;
4513
4563
  const outputFileWithSourceMap = `${outputFile.text}
4514
4564
  //# sourceMappingURL=${basename(sourceMapPath)}`;
4515
- await fs7.promises.mkdir(dirname2(fullPath), { recursive: true });
4565
+ await fs7.promises.mkdir(dirname3(fullPath), { recursive: true });
4516
4566
  await fs7.promises.writeFile(fullPath, outputFileWithSourceMap);
4517
4567
  logger.debug(`Wrote background worker to ${fullPath}`);
4518
4568
  const dependencies2 = await gatherRequiredDependencies2(metaOutput, config);
@@ -4753,7 +4803,7 @@ import chalk7 from "chalk";
4753
4803
  import { execa as execa3 } from "execa";
4754
4804
  import { applyEdits, modify } from "jsonc-parser";
4755
4805
  import { writeFile as writeFile3 } from "node:fs/promises";
4756
- import { join as join6, relative as relative2, resolve as resolve3 } from "node:path";
4806
+ import { join as join6, relative as relative3, resolve as resolve3 } from "node:path";
4757
4807
  import terminalLink3 from "terminal-link";
4758
4808
  import { z as z6 } from "zod";
4759
4809
 
@@ -5003,7 +5053,7 @@ async function createTriggerDir(dir, options) {
5003
5053
  outputPath,
5004
5054
  replacements: {}
5005
5055
  });
5006
- const relativeOutputPath = relative2(process.cwd(), outputPath);
5056
+ const relativeOutputPath = relative3(process.cwd(), outputPath);
5007
5057
  log3.step(`Created example file at ${relativeOutputPath}`);
5008
5058
  span.end();
5009
5059
  } catch (e) {
@@ -5154,7 +5204,7 @@ async function writeConfigFile(dir, project, options) {
5154
5204
  outputPath,
5155
5205
  override: options.overrideConfig
5156
5206
  });
5157
- const relativePathToOutput = relative2(process.cwd(), outputPath);
5207
+ const relativePathToOutput = relative3(process.cwd(), outputPath);
5158
5208
  spnnr.stop(
5159
5209
  result.success ? `Config file created at ${relativePathToOutput}` : `Failed to create config file: ${result.error}`
5160
5210
  );