trigger.dev 0.0.0-v3-canary-20240321171119 → 0.0.0-v3-canary-20240322092243
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
|
|
796
|
+
import { join as join4 } 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-
|
|
803
|
+
var version = "0.0.0-v3-canary-20240322092243";
|
|
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-
|
|
824
|
+
"@trigger.dev/core": "workspace:0.0.0-v3-canary-20240322092243",
|
|
825
825
|
"@types/degit": "^2.8.3",
|
|
826
826
|
chalk: "^5.2.0",
|
|
827
827
|
chokidar: "^3.5.3",
|
|
@@ -856,6 +856,7 @@ var dependencies = {
|
|
|
856
856
|
"supports-color": "^9.4.0",
|
|
857
857
|
"terminal-link": "^3.0.0",
|
|
858
858
|
"tiny-invariant": "^1.2.0",
|
|
859
|
+
"tsconfig-paths": "^4.2.0",
|
|
859
860
|
"update-check": "^1.5.4",
|
|
860
861
|
url: "^0.11.1",
|
|
861
862
|
ws: "^8.12.0",
|
|
@@ -1588,6 +1589,9 @@ async function resolveConfig(path6, config) {
|
|
|
1588
1589
|
if (!config.projectDir) {
|
|
1589
1590
|
config.projectDir = path6;
|
|
1590
1591
|
}
|
|
1592
|
+
if (!config.tsconfigPath) {
|
|
1593
|
+
config.tsconfigPath = await getConfigPath(path6, "tsconfig.json");
|
|
1594
|
+
}
|
|
1591
1595
|
return config;
|
|
1592
1596
|
}
|
|
1593
1597
|
async function normalizeConfig(config) {
|
|
@@ -2626,55 +2630,139 @@ ${authorizationCodeResult.error}`
|
|
|
2626
2630
|
}
|
|
2627
2631
|
|
|
2628
2632
|
// src/utilities/build.ts
|
|
2629
|
-
import {
|
|
2630
|
-
import
|
|
2633
|
+
import { extname, isAbsolute } from "node:path";
|
|
2634
|
+
import tsConfigPaths from "tsconfig-paths";
|
|
2631
2635
|
function bundleDependenciesPlugin(config) {
|
|
2636
|
+
const matchPath = config.tsconfigPath ? createMatchPath(config.tsconfigPath) : void 0;
|
|
2637
|
+
function resolvePath(id) {
|
|
2638
|
+
if (!matchPath) {
|
|
2639
|
+
return id;
|
|
2640
|
+
}
|
|
2641
|
+
return matchPath(id, void 0, void 0, [".ts", ".tsx", ".js", ".jsx"]) || id;
|
|
2642
|
+
}
|
|
2632
2643
|
return {
|
|
2633
2644
|
name: "bundle-dependencies",
|
|
2634
2645
|
setup(build3) {
|
|
2635
2646
|
build3.onResolve({ filter: /.*/ }, (args) => {
|
|
2636
|
-
|
|
2647
|
+
const resolvedPath = resolvePath(args.path);
|
|
2648
|
+
logger.debug(`Checking if ${args.path} should be bundled or external`, {
|
|
2649
|
+
...args,
|
|
2650
|
+
resolvedPath
|
|
2651
|
+
});
|
|
2652
|
+
if (!isBareModuleId(resolvedPath)) {
|
|
2653
|
+
logger.debug(`Bundling ${args.path} because its not a bareModuleId`, {
|
|
2654
|
+
...args
|
|
2655
|
+
});
|
|
2656
|
+
return void 0;
|
|
2657
|
+
}
|
|
2658
|
+
if (args.path.startsWith("@trigger.dev/")) {
|
|
2659
|
+
logger.debug(`Bundling ${args.path} because its a trigger.dev package`, {
|
|
2660
|
+
...args
|
|
2661
|
+
});
|
|
2662
|
+
return void 0;
|
|
2663
|
+
}
|
|
2664
|
+
let loader;
|
|
2665
|
+
try {
|
|
2666
|
+
loader = getLoaderForFile(args.path);
|
|
2667
|
+
} catch (e) {
|
|
2668
|
+
if (!(e instanceof Error && e.message.startsWith("Cannot get loader for file"))) {
|
|
2669
|
+
throw e;
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
if (loader === "file") {
|
|
2637
2673
|
return void 0;
|
|
2638
2674
|
}
|
|
2639
2675
|
for (let pattern of config.dependenciesToBundle ?? []) {
|
|
2640
2676
|
if (typeof pattern === "string" ? args.path === pattern : pattern.test(args.path)) {
|
|
2641
|
-
|
|
2642
|
-
const resolvedPath = resolvePath(args.path, config);
|
|
2643
|
-
logger.debug(`Bundling ${args.path} as ${resolvedPath}`);
|
|
2644
|
-
return {
|
|
2645
|
-
path: resolvedPath,
|
|
2646
|
-
external: false
|
|
2647
|
-
};
|
|
2648
|
-
} catch (error) {
|
|
2649
|
-
logger.error(`Failed to resolve path ${args.path}`, error);
|
|
2650
|
-
return void 0;
|
|
2651
|
-
}
|
|
2677
|
+
return void 0;
|
|
2652
2678
|
}
|
|
2653
2679
|
}
|
|
2654
|
-
|
|
2680
|
+
logger.debug(`Externalizing ${args.path}`, {
|
|
2681
|
+
...args
|
|
2682
|
+
});
|
|
2683
|
+
return {
|
|
2684
|
+
path: args.path,
|
|
2685
|
+
external: true
|
|
2686
|
+
};
|
|
2655
2687
|
});
|
|
2656
2688
|
}
|
|
2657
2689
|
};
|
|
2658
2690
|
}
|
|
2659
|
-
function
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
requireUrl
|
|
2666
|
-
});
|
|
2667
|
-
return tmpRequire.resolve(path6);
|
|
2668
|
-
} catch (e) {
|
|
2669
|
-
logger.debug(
|
|
2670
|
-
"[bundle-dependencies] Attempting to resolve path using ESM import.meta.url resolver",
|
|
2671
|
-
{
|
|
2672
|
-
path: path6,
|
|
2673
|
-
importMetaUrl: import.meta.url
|
|
2674
|
-
}
|
|
2675
|
-
);
|
|
2676
|
-
return __require.resolve(path6);
|
|
2691
|
+
function isBareModuleId(id) {
|
|
2692
|
+
return !id.startsWith("node:") && !id.startsWith(".") && !isAbsolute(id);
|
|
2693
|
+
}
|
|
2694
|
+
function createMatchPath(tsconfigPath) {
|
|
2695
|
+
if (!tsconfigPath) {
|
|
2696
|
+
return void 0;
|
|
2677
2697
|
}
|
|
2698
|
+
let configLoaderResult = tsConfigPaths.loadConfig(tsconfigPath);
|
|
2699
|
+
if (configLoaderResult.resultType === "failed") {
|
|
2700
|
+
if (configLoaderResult.message === "Missing baseUrl in compilerOptions") {
|
|
2701
|
+
throw new Error(
|
|
2702
|
+
`\u{1F6A8} Oops! No baseUrl found, please set compilerOptions.baseUrl in your tsconfig or jsconfig`
|
|
2703
|
+
);
|
|
2704
|
+
}
|
|
2705
|
+
return void 0;
|
|
2706
|
+
}
|
|
2707
|
+
return tsConfigPaths.createMatchPath(
|
|
2708
|
+
configLoaderResult.absoluteBaseUrl,
|
|
2709
|
+
configLoaderResult.paths,
|
|
2710
|
+
configLoaderResult.mainFields,
|
|
2711
|
+
configLoaderResult.addMatchAll
|
|
2712
|
+
);
|
|
2713
|
+
}
|
|
2714
|
+
var loaders = {
|
|
2715
|
+
".aac": "file",
|
|
2716
|
+
".avif": "file",
|
|
2717
|
+
".css": "file",
|
|
2718
|
+
".csv": "file",
|
|
2719
|
+
".eot": "file",
|
|
2720
|
+
".fbx": "file",
|
|
2721
|
+
".flac": "file",
|
|
2722
|
+
".gif": "file",
|
|
2723
|
+
".glb": "file",
|
|
2724
|
+
".gltf": "file",
|
|
2725
|
+
".gql": "text",
|
|
2726
|
+
".graphql": "text",
|
|
2727
|
+
".hdr": "file",
|
|
2728
|
+
".ico": "file",
|
|
2729
|
+
".jpeg": "file",
|
|
2730
|
+
".jpg": "file",
|
|
2731
|
+
".js": "jsx",
|
|
2732
|
+
".jsx": "jsx",
|
|
2733
|
+
".json": "json",
|
|
2734
|
+
// We preprocess md and mdx files using @mdx-js/mdx and send through
|
|
2735
|
+
// the JSX for esbuild to handle
|
|
2736
|
+
".md": "jsx",
|
|
2737
|
+
".mdx": "jsx",
|
|
2738
|
+
".mov": "file",
|
|
2739
|
+
".mp3": "file",
|
|
2740
|
+
".mp4": "file",
|
|
2741
|
+
".node": "copy",
|
|
2742
|
+
".ogg": "file",
|
|
2743
|
+
".otf": "file",
|
|
2744
|
+
".png": "file",
|
|
2745
|
+
".psd": "file",
|
|
2746
|
+
".sql": "text",
|
|
2747
|
+
".svg": "file",
|
|
2748
|
+
".ts": "ts",
|
|
2749
|
+
".tsx": "tsx",
|
|
2750
|
+
".ttf": "file",
|
|
2751
|
+
".wasm": "file",
|
|
2752
|
+
".wav": "file",
|
|
2753
|
+
".webm": "file",
|
|
2754
|
+
".webmanifest": "file",
|
|
2755
|
+
".webp": "file",
|
|
2756
|
+
".woff": "file",
|
|
2757
|
+
".woff2": "file",
|
|
2758
|
+
".zip": "file"
|
|
2759
|
+
};
|
|
2760
|
+
function getLoaderForFile(file) {
|
|
2761
|
+
const ext = extname(file);
|
|
2762
|
+
const loader = loaders[ext];
|
|
2763
|
+
if (loader)
|
|
2764
|
+
return loader;
|
|
2765
|
+
throw new Error(`Cannot get loader for file ${file}`);
|
|
2678
2766
|
}
|
|
2679
2767
|
|
|
2680
2768
|
// src/commands/deploy.ts
|
|
@@ -3230,8 +3318,6 @@ async function compileProject(config, options, configPath) {
|
|
|
3230
3318
|
minify: false,
|
|
3231
3319
|
sourcemap: "external",
|
|
3232
3320
|
// does not set the //# sourceMappingURL= comment in the file, we handle it ourselves
|
|
3233
|
-
packages: "external",
|
|
3234
|
-
// https://esbuild.github.io/api/#packages
|
|
3235
3321
|
logLevel: "error",
|
|
3236
3322
|
platform: "node",
|
|
3237
3323
|
format: "cjs",
|
|
@@ -3254,7 +3340,7 @@ async function compileProject(config, options, configPath) {
|
|
|
3254
3340
|
throw new Error("Build failed, aborting deployment");
|
|
3255
3341
|
}
|
|
3256
3342
|
if (options.outputMetafile) {
|
|
3257
|
-
await writeJSONFile(
|
|
3343
|
+
await writeJSONFile(join4(options.outputMetafile, "worker.json"), result.metafile);
|
|
3258
3344
|
}
|
|
3259
3345
|
const entryPointContents = readFileSync(
|
|
3260
3346
|
new URL(importResolve("./workers/prod/entry-point.js", import.meta.url)).href.replace(
|
|
@@ -3297,35 +3383,35 @@ async function compileProject(config, options, configPath) {
|
|
|
3297
3383
|
}
|
|
3298
3384
|
if (options.outputMetafile) {
|
|
3299
3385
|
await writeJSONFile(
|
|
3300
|
-
|
|
3386
|
+
join4(options.outputMetafile, "entry-point.json"),
|
|
3301
3387
|
entryPointResult.metafile
|
|
3302
3388
|
);
|
|
3303
3389
|
}
|
|
3304
3390
|
const tempDir = await createTempDir();
|
|
3305
3391
|
logger.debug(`Writing compiled files to ${tempDir}`);
|
|
3306
|
-
const metaOutput = result.metafile.outputs[
|
|
3392
|
+
const metaOutput = result.metafile.outputs[join4("out", "stdin.js")];
|
|
3307
3393
|
invariant(metaOutput, "Meta output for the result build is missing");
|
|
3308
|
-
const entryPointMetaOutput = entryPointResult.metafile.outputs[
|
|
3394
|
+
const entryPointMetaOutput = entryPointResult.metafile.outputs[join4("out", "stdin.js")];
|
|
3309
3395
|
invariant(entryPointMetaOutput, "Meta output for the entryPoint build is missing");
|
|
3310
3396
|
const workerOutputFile = result.outputFiles.find(
|
|
3311
|
-
(file) => file.path ===
|
|
3397
|
+
(file) => file.path === join4(config.projectDir, "out", "stdin.js")
|
|
3312
3398
|
);
|
|
3313
3399
|
invariant(workerOutputFile, "Output file for the result build is missing");
|
|
3314
3400
|
const workerSourcemapFile = result.outputFiles.find(
|
|
3315
|
-
(file) => file.path ===
|
|
3401
|
+
(file) => file.path === join4(config.projectDir, "out", "stdin.js.map")
|
|
3316
3402
|
);
|
|
3317
3403
|
invariant(workerSourcemapFile, "Sourcemap file for the result build is missing");
|
|
3318
3404
|
const entryPointOutputFile = entryPointResult.outputFiles.find(
|
|
3319
|
-
(file) => file.path ===
|
|
3405
|
+
(file) => file.path === join4(config.projectDir, "out", "stdin.js")
|
|
3320
3406
|
);
|
|
3321
3407
|
invariant(entryPointOutputFile, "Output file for the entryPoint build is missing");
|
|
3322
3408
|
await writeFile2(
|
|
3323
|
-
|
|
3409
|
+
join4(tempDir, "worker.js"),
|
|
3324
3410
|
`${workerOutputFile.text}
|
|
3325
3411
|
//# sourceMappingURL=worker.js.map`
|
|
3326
3412
|
);
|
|
3327
|
-
await writeFile2(
|
|
3328
|
-
await writeFile2(
|
|
3413
|
+
await writeFile2(join4(tempDir, "worker.js.map"), workerSourcemapFile.text);
|
|
3414
|
+
await writeFile2(join4(tempDir, "index.js"), entryPointOutputFile.text);
|
|
3329
3415
|
const allImports = [...metaOutput.imports, ...entryPointMetaOutput.imports];
|
|
3330
3416
|
const dependencies2 = await gatherRequiredDependencies(allImports, config);
|
|
3331
3417
|
const packageJsonContents = {
|
|
@@ -3334,7 +3420,7 @@ async function compileProject(config, options, configPath) {
|
|
|
3334
3420
|
description: "",
|
|
3335
3421
|
dependencies: dependencies2
|
|
3336
3422
|
};
|
|
3337
|
-
await writeJSONFile(
|
|
3423
|
+
await writeJSONFile(join4(tempDir, "package.json"), packageJsonContents);
|
|
3338
3424
|
compileSpinner.stop("Project built successfully");
|
|
3339
3425
|
const resolvingDependenciesResult = await resolveDependencies(
|
|
3340
3426
|
tempDir,
|
|
@@ -3348,7 +3434,7 @@ async function compileProject(config, options, configPath) {
|
|
|
3348
3434
|
const containerFilePath = new URL(
|
|
3349
3435
|
importResolve("./Containerfile.prod", import.meta.url)
|
|
3350
3436
|
).href.replace("file://", "");
|
|
3351
|
-
await copyFile(containerFilePath,
|
|
3437
|
+
await copyFile(containerFilePath, join4(tempDir, "Containerfile"));
|
|
3352
3438
|
const contentHasher = createHash("sha256");
|
|
3353
3439
|
contentHasher.update(Buffer.from(entryPointOutputFile.text));
|
|
3354
3440
|
contentHasher.update(Buffer.from(workerOutputFile.text));
|
|
@@ -3380,8 +3466,8 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
|
|
|
3380
3466
|
const hasher = createHash("sha256");
|
|
3381
3467
|
hasher.update(JSON.stringify(packageJsonContents));
|
|
3382
3468
|
const digest = hasher.digest("hex").slice(0, 16);
|
|
3383
|
-
const cacheDir =
|
|
3384
|
-
const cachePath =
|
|
3469
|
+
const cacheDir = join4(config.projectDir, ".trigger", "cache");
|
|
3470
|
+
const cachePath = join4(cacheDir, `${digest}.json`);
|
|
3385
3471
|
span.setAttributes({
|
|
3386
3472
|
"packageJson.digest": digest,
|
|
3387
3473
|
"cache.path": cachePath,
|
|
@@ -3390,7 +3476,7 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
|
|
|
3390
3476
|
try {
|
|
3391
3477
|
const cachedPackageLock = await readFile2(cachePath, "utf-8");
|
|
3392
3478
|
logger.debug(`Using cached package-lock.json for ${digest}`);
|
|
3393
|
-
await writeFile2(
|
|
3479
|
+
await writeFile2(join4(projectDir, "package-lock.json"), cachedPackageLock);
|
|
3394
3480
|
span.setAttributes({
|
|
3395
3481
|
"cache.hit": true
|
|
3396
3482
|
});
|
|
@@ -3413,11 +3499,11 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
|
|
|
3413
3499
|
cwd: projectDir,
|
|
3414
3500
|
stdio: logger.loggerLevel === "debug" ? "inherit" : "pipe"
|
|
3415
3501
|
});
|
|
3416
|
-
const packageLockContents = await readFile2(
|
|
3502
|
+
const packageLockContents = await readFile2(join4(projectDir, "package-lock.json"), "utf-8");
|
|
3417
3503
|
logger.debug(`Writing package-lock.json to cache for ${digest}`);
|
|
3418
3504
|
await mkdir(cacheDir, { recursive: true });
|
|
3419
3505
|
await writeFile2(cachePath, packageLockContents);
|
|
3420
|
-
await writeFile2(
|
|
3506
|
+
await writeFile2(join4(projectDir, "package-lock.json"), packageLockContents);
|
|
3421
3507
|
span.end();
|
|
3422
3508
|
resolvingDepsSpinner.stop("Dependencies resolved");
|
|
3423
3509
|
return true;
|
|
@@ -3472,7 +3558,7 @@ async function typecheckProject(config, options) {
|
|
|
3472
3558
|
});
|
|
3473
3559
|
}
|
|
3474
3560
|
async function gatherRequiredDependencies(imports, config) {
|
|
3475
|
-
const externalPackageJson = await readJSONFile(
|
|
3561
|
+
const externalPackageJson = await readJSONFile(join4(config.projectDir, "package.json"));
|
|
3476
3562
|
const dependencies2 = {};
|
|
3477
3563
|
for (const file of imports) {
|
|
3478
3564
|
if (file.kind !== "require-call" || !file.external) {
|
|
@@ -3521,7 +3607,7 @@ async function gatherRequiredDependencies(imports, config) {
|
|
|
3521
3607
|
}
|
|
3522
3608
|
async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
|
|
3523
3609
|
const tmpDir = await createTempDir();
|
|
3524
|
-
const dockerConfigPath =
|
|
3610
|
+
const dockerConfigPath = join4(tmpDir, "config.json");
|
|
3525
3611
|
await writeJSONFile(dockerConfigPath, {
|
|
3526
3612
|
auths: {
|
|
3527
3613
|
[registryHost]: {
|
|
@@ -3567,7 +3653,7 @@ import { resolve as importResolve2 } from "import-meta-resolve";
|
|
|
3567
3653
|
import { Box, Text, render, useApp, useInput } from "ink";
|
|
3568
3654
|
import { createHash as createHash2 } from "node:crypto";
|
|
3569
3655
|
import fs7, { readFileSync as readFileSync2 } from "node:fs";
|
|
3570
|
-
import { basename, dirname as dirname2, join as
|
|
3656
|
+
import { basename, dirname as dirname2, join as join5 } from "node:path";
|
|
3571
3657
|
import pThrottle from "p-throttle";
|
|
3572
3658
|
import { WebSocket } from "partysocket";
|
|
3573
3659
|
import React, { Suspense, useEffect } from "react";
|
|
@@ -3844,6 +3930,7 @@ var BackgroundWorker = class {
|
|
|
3844
3930
|
}
|
|
3845
3931
|
if (!this._taskRunProcesses.has(payload.execution.run.id)) {
|
|
3846
3932
|
const taskRunProcess = new TaskRunProcess(
|
|
3933
|
+
payload.execution.run.id,
|
|
3847
3934
|
this.path,
|
|
3848
3935
|
{
|
|
3849
3936
|
...this.params.env,
|
|
@@ -3953,7 +4040,8 @@ var BackgroundWorker = class {
|
|
|
3953
4040
|
}
|
|
3954
4041
|
};
|
|
3955
4042
|
var TaskRunProcess = class {
|
|
3956
|
-
constructor(path6, env, metadata, worker) {
|
|
4043
|
+
constructor(runId, path6, env, metadata, worker) {
|
|
4044
|
+
this.runId = runId;
|
|
3957
4045
|
this.path = path6;
|
|
3958
4046
|
this.env = env;
|
|
3959
4047
|
this.metadata = metadata;
|
|
@@ -3984,7 +4072,7 @@ var TaskRunProcess = class {
|
|
|
3984
4072
|
await this.cleanup(true);
|
|
3985
4073
|
}
|
|
3986
4074
|
async initialize() {
|
|
3987
|
-
logger.debug(
|
|
4075
|
+
logger.debug(`[${this.runId}] initializing task run process`, {
|
|
3988
4076
|
env: this.env,
|
|
3989
4077
|
path: this.path,
|
|
3990
4078
|
processEnv: process.env
|
|
@@ -4019,6 +4107,7 @@ var TaskRunProcess = class {
|
|
|
4019
4107
|
if (kill && this._isBeingKilled) {
|
|
4020
4108
|
return;
|
|
4021
4109
|
}
|
|
4110
|
+
logger.debug(`[${this.runId}] cleaning up task run process`, { kill });
|
|
4022
4111
|
await this._sender.send("CLEANUP", {
|
|
4023
4112
|
flush: true,
|
|
4024
4113
|
kill
|
|
@@ -4046,6 +4135,7 @@ var TaskRunProcess = class {
|
|
|
4046
4135
|
return result;
|
|
4047
4136
|
}
|
|
4048
4137
|
taskRunCompletedNotification(completion, execution) {
|
|
4138
|
+
logger.debug(`[${this.runId}] task run completed notification`, { completion, execution });
|
|
4049
4139
|
if (!completion.ok && typeof completion.retry !== "undefined") {
|
|
4050
4140
|
return;
|
|
4051
4141
|
}
|
|
@@ -4086,6 +4176,7 @@ var TaskRunProcess = class {
|
|
|
4086
4176
|
}
|
|
4087
4177
|
}
|
|
4088
4178
|
async #handleExit(code) {
|
|
4179
|
+
logger.debug(`[${this.runId}] task run process exiting`, { code });
|
|
4089
4180
|
for (const [id, status] of this._attemptStatuses.entries()) {
|
|
4090
4181
|
if (status === "PENDING") {
|
|
4091
4182
|
this._attemptStatuses.set(id, "REJECTED");
|
|
@@ -4365,8 +4456,6 @@ function useDev({
|
|
|
4365
4456
|
minify: false,
|
|
4366
4457
|
sourcemap: "external",
|
|
4367
4458
|
// does not set the //# sourceMappingURL= comment in the file, we handle it ourselves
|
|
4368
|
-
packages: "external",
|
|
4369
|
-
// https://esbuild.github.io/api/#packages
|
|
4370
4459
|
logLevel: "error",
|
|
4371
4460
|
platform: "node",
|
|
4372
4461
|
format: "cjs",
|
|
@@ -4392,19 +4481,19 @@ function useDev({
|
|
|
4392
4481
|
if (!firstBuild) {
|
|
4393
4482
|
logger.log(chalk6.dim("\u2394 Rebuilding background worker..."));
|
|
4394
4483
|
}
|
|
4395
|
-
const metaOutputKey =
|
|
4484
|
+
const metaOutputKey = join5("out", `stdin.js`);
|
|
4396
4485
|
const metaOutput = result.metafile.outputs[metaOutputKey];
|
|
4397
4486
|
if (!metaOutput) {
|
|
4398
4487
|
throw new Error(`Could not find metafile`);
|
|
4399
4488
|
}
|
|
4400
|
-
const outputFileKey =
|
|
4489
|
+
const outputFileKey = join5(config.projectDir, metaOutputKey);
|
|
4401
4490
|
const outputFile = result.outputFiles.find((file) => file.path === outputFileKey);
|
|
4402
4491
|
if (!outputFile) {
|
|
4403
4492
|
throw new Error(
|
|
4404
4493
|
`Could not find output file for entry point ${metaOutput.entryPoint}`
|
|
4405
4494
|
);
|
|
4406
4495
|
}
|
|
4407
|
-
const sourceMapFileKey =
|
|
4496
|
+
const sourceMapFileKey = join5(config.projectDir, `${metaOutputKey}.map`);
|
|
4408
4497
|
const sourceMapFile = result.outputFiles.find(
|
|
4409
4498
|
(file) => file.path === sourceMapFileKey
|
|
4410
4499
|
);
|
|
@@ -4416,7 +4505,7 @@ function useDev({
|
|
|
4416
4505
|
logger.debug(`No changes detected, skipping build`);
|
|
4417
4506
|
return;
|
|
4418
4507
|
}
|
|
4419
|
-
const fullPath =
|
|
4508
|
+
const fullPath = join5(config.projectDir, ".trigger", `${contentHash}.js`);
|
|
4420
4509
|
const sourceMapPath = `${fullPath}.map`;
|
|
4421
4510
|
const outputFileWithSourceMap = `${outputFile.text}
|
|
4422
4511
|
//# sourceMappingURL=${basename(sourceMapPath)}`;
|
|
@@ -4605,7 +4694,7 @@ async function gatherRequiredDependencies2(outputMeta, config) {
|
|
|
4605
4694
|
}
|
|
4606
4695
|
}
|
|
4607
4696
|
if (config.additionalPackages) {
|
|
4608
|
-
const projectPackageJson = await readJSONFile(
|
|
4697
|
+
const projectPackageJson = await readJSONFile(join5(config.projectDir, "package.json"));
|
|
4609
4698
|
for (const packageName of config.additionalPackages) {
|
|
4610
4699
|
if (dependencies2[packageName]) {
|
|
4611
4700
|
continue;
|
|
@@ -4661,7 +4750,7 @@ import chalk7 from "chalk";
|
|
|
4661
4750
|
import { execa as execa3 } from "execa";
|
|
4662
4751
|
import { applyEdits, modify } from "jsonc-parser";
|
|
4663
4752
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
4664
|
-
import { join as
|
|
4753
|
+
import { join as join6, relative as relative2, resolve as resolve3 } from "node:path";
|
|
4665
4754
|
import terminalLink3 from "terminal-link";
|
|
4666
4755
|
import { z as z6 } from "zod";
|
|
4667
4756
|
|
|
@@ -4899,13 +4988,13 @@ async function createTriggerDir(dir, options) {
|
|
|
4899
4988
|
"cli.example": example
|
|
4900
4989
|
});
|
|
4901
4990
|
if (example === "none") {
|
|
4902
|
-
await createFile(
|
|
4991
|
+
await createFile(join6(triggerDir, ".gitkeep"), "");
|
|
4903
4992
|
log3.step(`Created directory at ${location}`);
|
|
4904
4993
|
span.end();
|
|
4905
4994
|
return;
|
|
4906
4995
|
}
|
|
4907
4996
|
const exampleFile = resolveInternalFilePath(`./templates/examples/${example}.ts.template`);
|
|
4908
|
-
const outputPath =
|
|
4997
|
+
const outputPath = join6(triggerDir, "example.ts");
|
|
4909
4998
|
await createFileFromTemplate({
|
|
4910
4999
|
templatePath: exampleFile,
|
|
4911
5000
|
outputPath,
|
|
@@ -4927,7 +5016,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
4927
5016
|
return await tracer.startActiveSpan("gitIgnoreDotTriggerDir", async (span) => {
|
|
4928
5017
|
try {
|
|
4929
5018
|
const projectDir = resolve3(process.cwd(), dir);
|
|
4930
|
-
const gitIgnorePath =
|
|
5019
|
+
const gitIgnorePath = join6(projectDir, ".gitignore");
|
|
4931
5020
|
span.setAttributes({
|
|
4932
5021
|
"cli.projectDir": projectDir,
|
|
4933
5022
|
"cli.gitIgnorePath": gitIgnorePath
|
|
@@ -4961,7 +5050,7 @@ async function addConfigFileToTsConfig(dir, options) {
|
|
|
4961
5050
|
return await tracer.startActiveSpan("createTriggerDir", async (span) => {
|
|
4962
5051
|
try {
|
|
4963
5052
|
const projectDir = resolve3(process.cwd(), dir);
|
|
4964
|
-
const tsconfigPath =
|
|
5053
|
+
const tsconfigPath = join6(projectDir, "tsconfig.json");
|
|
4965
5054
|
span.setAttributes({
|
|
4966
5055
|
"cli.projectDir": projectDir,
|
|
4967
5056
|
"cli.tsconfigPath": tsconfigPath
|
|
@@ -5048,7 +5137,7 @@ async function writeConfigFile(dir, project, options) {
|
|
|
5048
5137
|
spnnr.start("Creating config file");
|
|
5049
5138
|
const projectDir = resolve3(process.cwd(), dir);
|
|
5050
5139
|
const templatePath = resolveInternalFilePath("./templates/trigger.config.ts.template");
|
|
5051
|
-
const outputPath =
|
|
5140
|
+
const outputPath = join6(projectDir, "trigger.config.ts");
|
|
5052
5141
|
span.setAttributes({
|
|
5053
5142
|
"cli.projectDir": projectDir,
|
|
5054
5143
|
"cli.templatePath": templatePath,
|