trigger.dev 0.0.0-v3-prerelease-20240624162135 → 0.0.0-v3-prerelease-20240628191401
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
|
@@ -794,12 +794,11 @@ import { readFileSync as readFileSync2 } from "node:fs";
|
|
|
794
794
|
import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
795
795
|
import { dirname, join as join6, posix, relative as relative3 } from "node:path";
|
|
796
796
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
797
|
-
import terminalLink2 from "terminal-link";
|
|
798
797
|
import invariant from "tiny-invariant";
|
|
799
798
|
import { z as z4 } from "zod";
|
|
800
799
|
|
|
801
800
|
// package.json
|
|
802
|
-
var version = "0.0.0-v3-prerelease-
|
|
801
|
+
var version = "0.0.0-v3-prerelease-20240628191401";
|
|
803
802
|
var dependencies = {
|
|
804
803
|
"@anatine/esbuild-decorators": "^0.2.19",
|
|
805
804
|
"@clack/prompts": "^0.7.0",
|
|
@@ -816,7 +815,7 @@ var dependencies = {
|
|
|
816
815
|
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
817
816
|
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
818
817
|
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
819
|
-
"@trigger.dev/core": "workspace:0.0.0-v3-prerelease-
|
|
818
|
+
"@trigger.dev/core": "workspace:0.0.0-v3-prerelease-20240628191401",
|
|
820
819
|
"@types/degit": "^2.8.3",
|
|
821
820
|
chalk: "^5.2.0",
|
|
822
821
|
chokidar: "^3.5.3",
|
|
@@ -851,12 +850,12 @@ var dependencies = {
|
|
|
851
850
|
"terminal-link": "^3.0.0",
|
|
852
851
|
"tiny-invariant": "^1.2.0",
|
|
853
852
|
"tsconfig-paths": "^4.2.0",
|
|
853
|
+
typescript: "^5.4.0",
|
|
854
854
|
"update-check": "^1.5.4",
|
|
855
855
|
url: "^0.11.1",
|
|
856
856
|
ws: "^8.12.0",
|
|
857
857
|
zod: "3.22.3",
|
|
858
|
-
"zod-validation-error": "^1.5.0"
|
|
859
|
-
typescript: "^5.4.0"
|
|
858
|
+
"zod-validation-error": "^1.5.0"
|
|
860
859
|
};
|
|
861
860
|
var package_default = {
|
|
862
861
|
name: "trigger.dev",
|
|
@@ -909,7 +908,7 @@ var package_default = {
|
|
|
909
908
|
"npm-run-all": "^4.1.5",
|
|
910
909
|
open: "^10.0.3",
|
|
911
910
|
"p-retry": "^6.1.0",
|
|
912
|
-
rimraf: "^
|
|
911
|
+
rimraf: "^5.0.7",
|
|
913
912
|
tsup: "^8.0.1",
|
|
914
913
|
"type-fest": "^3.6.0",
|
|
915
914
|
typescript: "^5.3.3",
|
|
@@ -1357,6 +1356,7 @@ import { outro } from "@clack/prompts";
|
|
|
1357
1356
|
// src/utilities/cliOutput.ts
|
|
1358
1357
|
import { log } from "@clack/prompts";
|
|
1359
1358
|
import chalk2 from "chalk";
|
|
1359
|
+
import terminalLink from "terminal-link";
|
|
1360
1360
|
var green = "#4FFF54";
|
|
1361
1361
|
var purple = "#735BF3";
|
|
1362
1362
|
function chalkGreen(text3) {
|
|
@@ -1428,6 +1428,12 @@ function prettyWarning(header, body, footer) {
|
|
|
1428
1428
|
`${prettyPrefix}${header}${prettyBody ? `${spacing}${prettyBody}` : ""}${prettyFooter ? `${spacing}${prettyFooter}` : ""}`
|
|
1429
1429
|
);
|
|
1430
1430
|
}
|
|
1431
|
+
function cliLink(text3, url, options) {
|
|
1432
|
+
return terminalLink(text3, url, {
|
|
1433
|
+
fallback: (text4, url2) => `${text4} ${url2}`,
|
|
1434
|
+
...options
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1431
1437
|
|
|
1432
1438
|
// src/cli/common.ts
|
|
1433
1439
|
var CommonCommandOptions = z.object({
|
|
@@ -3125,7 +3131,6 @@ function getLoaderForFile(file) {
|
|
|
3125
3131
|
import chalk4 from "chalk";
|
|
3126
3132
|
import { relative as relative2 } from "node:path";
|
|
3127
3133
|
import { groupTaskMetadataIssuesByTask } from "@trigger.dev/core/v3";
|
|
3128
|
-
import terminalLink from "terminal-link";
|
|
3129
3134
|
|
|
3130
3135
|
// src/utilities/links.ts
|
|
3131
3136
|
var docs = {
|
|
@@ -3148,13 +3153,9 @@ function parseBuildErrorStack(error) {
|
|
|
3148
3153
|
}
|
|
3149
3154
|
if (errorIsErrorLike(error)) {
|
|
3150
3155
|
if (typeof error.stack === "string") {
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
const moduleRegex = /node_modules\/(@[^\/]+\/[^\/]+|[^\/]+)\/[^\/]+\s/;
|
|
3155
|
-
const match = moduleRegex.exec(error.stack);
|
|
3156
|
-
if (match) {
|
|
3157
|
-
moduleName = match[1];
|
|
3156
|
+
if (error.stack.includes("ERR_REQUIRE_ESM")) {
|
|
3157
|
+
const moduleName = getPackageNameFromEsmRequireError(error.stack);
|
|
3158
|
+
if (moduleName) {
|
|
3158
3159
|
return {
|
|
3159
3160
|
type: "esm-require-error",
|
|
3160
3161
|
moduleName
|
|
@@ -3166,6 +3167,27 @@ function parseBuildErrorStack(error) {
|
|
|
3166
3167
|
}
|
|
3167
3168
|
}
|
|
3168
3169
|
}
|
|
3170
|
+
function getPackageNameFromEsmRequireError(stack) {
|
|
3171
|
+
const pathRegex = /require\(\) of ES Module (.*) from/;
|
|
3172
|
+
const pathMatch = pathRegex.exec(stack);
|
|
3173
|
+
if (!pathMatch) {
|
|
3174
|
+
return;
|
|
3175
|
+
}
|
|
3176
|
+
const filePath = pathMatch[1];
|
|
3177
|
+
if (!filePath) {
|
|
3178
|
+
return;
|
|
3179
|
+
}
|
|
3180
|
+
const lastPart = filePath.split("node_modules/").pop();
|
|
3181
|
+
if (!lastPart) {
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
const moduleRegex = /(@[^\/]+\/[^\/]+|[^\/]+)/;
|
|
3185
|
+
const match = moduleRegex.exec(lastPart);
|
|
3186
|
+
if (!match) {
|
|
3187
|
+
return;
|
|
3188
|
+
}
|
|
3189
|
+
return match[1];
|
|
3190
|
+
}
|
|
3169
3191
|
function logESMRequireError(parsedError, resolvedConfig) {
|
|
3170
3192
|
logger.log(
|
|
3171
3193
|
`
|
|
@@ -3205,7 +3227,7 @@ ${chalkGrey("\u25CB")} Dynamically import the module in your code: ${chalkGrey(
|
|
|
3205
3227
|
);
|
|
3206
3228
|
}
|
|
3207
3229
|
logger.log(
|
|
3208
|
-
`${chalkGrey("\u25CB")} For more info see the ${
|
|
3230
|
+
`${chalkGrey("\u25CB")} For more info see the ${cliLink("relevant docs", docs.config.esm)}.
|
|
3209
3231
|
`
|
|
3210
3232
|
);
|
|
3211
3233
|
}
|
|
@@ -3277,6 +3299,13 @@ import { join as join4 } from "node:path";
|
|
|
3277
3299
|
// src/utilities/getUserPackageManager.ts
|
|
3278
3300
|
import { findUp as findUp2 } from "find-up";
|
|
3279
3301
|
import { basename } from "path";
|
|
3302
|
+
var LOCKFILES = {
|
|
3303
|
+
npm: "package-lock.json",
|
|
3304
|
+
npmShrinkwrap: "npm-shrinkwrap.json",
|
|
3305
|
+
pnpm: "pnpm-lock.yaml",
|
|
3306
|
+
yarn: "yarn.lock",
|
|
3307
|
+
bun: "bun.lockb"
|
|
3308
|
+
};
|
|
3280
3309
|
async function getUserPackageManager(path7) {
|
|
3281
3310
|
const packageManager = await detectPackageManager(path7);
|
|
3282
3311
|
logger.debug("Detected package manager", { packageManager });
|
|
@@ -3304,24 +3333,23 @@ function detectPackageManagerFromCurrentCommand() {
|
|
|
3304
3333
|
}
|
|
3305
3334
|
}
|
|
3306
3335
|
async function detectPackageManagerFromArtifacts(path7) {
|
|
3307
|
-
const
|
|
3308
|
-
yarn: "yarn.lock",
|
|
3309
|
-
pnpm: "pnpm-lock.yaml",
|
|
3310
|
-
npm: "package-lock.json",
|
|
3311
|
-
npmShrinkwrap: "npm-shrinkwrap.json"
|
|
3312
|
-
};
|
|
3313
|
-
const foundPath = await findUp2(Object.values(artifacts), { cwd: path7 });
|
|
3336
|
+
const foundPath = await findUp2(Object.values(LOCKFILES), { cwd: path7 });
|
|
3314
3337
|
if (!foundPath) {
|
|
3315
3338
|
throw new Error("Could not detect package manager from artifacts");
|
|
3316
3339
|
}
|
|
3317
3340
|
logger.debug("Found path from package manager artifacts", { foundPath });
|
|
3318
3341
|
switch (basename(foundPath)) {
|
|
3319
|
-
case
|
|
3342
|
+
case LOCKFILES.yarn:
|
|
3343
|
+
logger.debug("Found yarn artifact", { foundPath });
|
|
3320
3344
|
return "yarn";
|
|
3321
|
-
case
|
|
3345
|
+
case LOCKFILES.pnpm:
|
|
3346
|
+
logger.debug("Found pnpm artifact", { foundPath });
|
|
3322
3347
|
return "pnpm";
|
|
3323
|
-
case
|
|
3324
|
-
case
|
|
3348
|
+
case LOCKFILES.npm:
|
|
3349
|
+
case LOCKFILES.npmShrinkwrap:
|
|
3350
|
+
logger.debug("Found npm artifact", { foundPath });
|
|
3351
|
+
case LOCKFILES.bun:
|
|
3352
|
+
logger.debug("Found bun artifact", { foundPath });
|
|
3325
3353
|
return "npm";
|
|
3326
3354
|
default:
|
|
3327
3355
|
throw new Error(`Unhandled package manager detection path: ${foundPath}`);
|
|
@@ -3349,10 +3377,53 @@ var JavascriptProject = class {
|
|
|
3349
3377
|
}
|
|
3350
3378
|
return this._packageJson;
|
|
3351
3379
|
}
|
|
3380
|
+
get allowedPackageJson() {
|
|
3381
|
+
const disallowedKeys = [
|
|
3382
|
+
"scripts",
|
|
3383
|
+
"devDependencies",
|
|
3384
|
+
"dependencies",
|
|
3385
|
+
"peerDependencies",
|
|
3386
|
+
"author",
|
|
3387
|
+
"contributors",
|
|
3388
|
+
"funding",
|
|
3389
|
+
"bugs",
|
|
3390
|
+
"files",
|
|
3391
|
+
"keywords",
|
|
3392
|
+
"main",
|
|
3393
|
+
"module",
|
|
3394
|
+
"type",
|
|
3395
|
+
"bin",
|
|
3396
|
+
"browser",
|
|
3397
|
+
"man",
|
|
3398
|
+
"directories",
|
|
3399
|
+
"repository",
|
|
3400
|
+
"peerDependenciesMeta",
|
|
3401
|
+
"optionalDependencies",
|
|
3402
|
+
"engines",
|
|
3403
|
+
"os",
|
|
3404
|
+
"cpu",
|
|
3405
|
+
"private",
|
|
3406
|
+
"publishConfig",
|
|
3407
|
+
"workspaces"
|
|
3408
|
+
];
|
|
3409
|
+
return Object.keys(this.packageJson).reduce(
|
|
3410
|
+
(acc, key) => {
|
|
3411
|
+
if (!disallowedKeys.includes(key)) {
|
|
3412
|
+
acc[key] = this.packageJson[key];
|
|
3413
|
+
}
|
|
3414
|
+
return acc;
|
|
3415
|
+
},
|
|
3416
|
+
{}
|
|
3417
|
+
);
|
|
3418
|
+
}
|
|
3352
3419
|
get scripts() {
|
|
3353
|
-
return
|
|
3354
|
-
|
|
3355
|
-
|
|
3420
|
+
return this.#filterScripts();
|
|
3421
|
+
}
|
|
3422
|
+
#filterScripts() {
|
|
3423
|
+
if (!this.packageJson.scripts || typeof this.packageJson.scripts !== "object") {
|
|
3424
|
+
return {};
|
|
3425
|
+
}
|
|
3426
|
+
return this.packageJson.scripts;
|
|
3356
3427
|
}
|
|
3357
3428
|
async install() {
|
|
3358
3429
|
const command = await this.#getCommand();
|
|
@@ -3718,27 +3789,49 @@ Latest: ${newCliVersion}`,
|
|
|
3718
3789
|
}
|
|
3719
3790
|
const triggerDependencies = getTriggerDependencies(packageJson);
|
|
3720
3791
|
function getVersionMismatches(deps, targetVersion) {
|
|
3721
|
-
const
|
|
3792
|
+
const mismatches2 = [];
|
|
3722
3793
|
for (const dep of deps) {
|
|
3723
3794
|
if (dep.version === targetVersion) {
|
|
3724
3795
|
continue;
|
|
3725
3796
|
}
|
|
3726
|
-
|
|
3797
|
+
mismatches2.push(dep);
|
|
3798
|
+
}
|
|
3799
|
+
const extractRelease = (version2) => {
|
|
3800
|
+
const release = Number(version2.split("3.0.0-beta.")[1]);
|
|
3801
|
+
return release || void 0;
|
|
3802
|
+
};
|
|
3803
|
+
let isDowngrade2 = false;
|
|
3804
|
+
const targetRelease = extractRelease(targetVersion);
|
|
3805
|
+
if (targetRelease) {
|
|
3806
|
+
isDowngrade2 = mismatches2.some((dep) => {
|
|
3807
|
+
const depRelease = extractRelease(dep.version);
|
|
3808
|
+
if (!depRelease) {
|
|
3809
|
+
return false;
|
|
3810
|
+
}
|
|
3811
|
+
return depRelease > targetRelease;
|
|
3812
|
+
});
|
|
3727
3813
|
}
|
|
3728
|
-
return
|
|
3814
|
+
return {
|
|
3815
|
+
mismatches: mismatches2,
|
|
3816
|
+
isDowngrade: isDowngrade2
|
|
3817
|
+
};
|
|
3729
3818
|
}
|
|
3730
|
-
const
|
|
3731
|
-
if (
|
|
3819
|
+
const { mismatches, isDowngrade } = getVersionMismatches(triggerDependencies, cliVersion);
|
|
3820
|
+
if (mismatches.length === 0) {
|
|
3732
3821
|
if (!embedded) {
|
|
3733
3822
|
outro4(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
|
|
3734
3823
|
return hasOutput;
|
|
3735
3824
|
}
|
|
3736
3825
|
return hasOutput;
|
|
3737
3826
|
}
|
|
3738
|
-
|
|
3739
|
-
"
|
|
3740
|
-
|
|
3741
|
-
|
|
3827
|
+
if (isDowngrade) {
|
|
3828
|
+
prettyError("Some of the installed @trigger.dev packages are newer than your CLI version");
|
|
3829
|
+
} else {
|
|
3830
|
+
prettyWarning(
|
|
3831
|
+
"Mismatch between your CLI version and installed packages",
|
|
3832
|
+
"We recommend pinned versions for guaranteed compatibility"
|
|
3833
|
+
);
|
|
3834
|
+
}
|
|
3742
3835
|
if (!process.stdout.isTTY) {
|
|
3743
3836
|
outro4("Deploy failed");
|
|
3744
3837
|
console.log(
|
|
@@ -3751,13 +3844,24 @@ Latest: ${newCliVersion}`,
|
|
|
3751
3844
|
CLI version: ${cliVersion}
|
|
3752
3845
|
|
|
3753
3846
|
Current package versions that don't match the CLI:
|
|
3754
|
-
${
|
|
3847
|
+
${mismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
|
|
3848
|
+
`
|
|
3849
|
+
);
|
|
3850
|
+
process.exit(1);
|
|
3851
|
+
}
|
|
3852
|
+
if (isDowngrade) {
|
|
3853
|
+
printUpdateTable("Versions", mismatches, cliVersion, "installed", "CLI");
|
|
3854
|
+
outro4("CLI update required!");
|
|
3855
|
+
logger.log(
|
|
3856
|
+
`${chalkError(
|
|
3857
|
+
"X Error:"
|
|
3858
|
+
)} Please update your CLI. Alternatively, use \`--skip-update-check\` at your own risk.
|
|
3755
3859
|
`
|
|
3756
3860
|
);
|
|
3757
3861
|
process.exit(1);
|
|
3758
3862
|
}
|
|
3759
3863
|
log4.message("");
|
|
3760
|
-
const userWantsToUpdate = await updateConfirmation(
|
|
3864
|
+
const userWantsToUpdate = await updateConfirmation(mismatches, cliVersion);
|
|
3761
3865
|
if (isCancel(userWantsToUpdate)) {
|
|
3762
3866
|
throw new OutroCommandError();
|
|
3763
3867
|
}
|
|
@@ -3787,7 +3891,7 @@ Latest: ${newCliVersion}`,
|
|
|
3787
3891
|
);
|
|
3788
3892
|
};
|
|
3789
3893
|
process.prependOnceListener("exit", exitHandler);
|
|
3790
|
-
mutatePackageJsonWithUpdatedPackages(packageJson,
|
|
3894
|
+
mutatePackageJsonWithUpdatedPackages(packageJson, mismatches, cliVersion);
|
|
3791
3895
|
await writeJSONFile(packageJsonPath, packageJson, true);
|
|
3792
3896
|
async function revertPackageJsonChanges() {
|
|
3793
3897
|
await writeJSONFile(packageJsonPath, readonlyPackageJson, true);
|
|
@@ -3850,17 +3954,17 @@ function mutatePackageJsonWithUpdatedPackages(packageJson, depsToUpdate, targetV
|
|
|
3850
3954
|
packageJson[type][name] = targetVersion;
|
|
3851
3955
|
}
|
|
3852
3956
|
}
|
|
3853
|
-
function printUpdateTable(depsToUpdate, targetVersion) {
|
|
3854
|
-
log4.message(
|
|
3957
|
+
function printUpdateTable(heading, depsToUpdate, targetVersion, oldColumn = "old", newColumn = "new") {
|
|
3958
|
+
log4.message(heading);
|
|
3855
3959
|
const tableData = depsToUpdate.map((dep) => ({
|
|
3856
3960
|
package: dep.name,
|
|
3857
|
-
|
|
3858
|
-
|
|
3961
|
+
[oldColumn]: dep.version,
|
|
3962
|
+
[newColumn]: targetVersion
|
|
3859
3963
|
}));
|
|
3860
3964
|
logger.table(tableData);
|
|
3861
3965
|
}
|
|
3862
3966
|
async function updateConfirmation(depsToUpdate, targetVersion) {
|
|
3863
|
-
printUpdateTable(depsToUpdate, targetVersion);
|
|
3967
|
+
printUpdateTable("Suggested updates", depsToUpdate, targetVersion);
|
|
3864
3968
|
let confirmMessage = "Would you like to apply those updates?";
|
|
3865
3969
|
return await confirm({
|
|
3866
3970
|
message: confirmMessage
|
|
@@ -4198,7 +4302,7 @@ ${authorization.error}`
|
|
|
4198
4302
|
await preExitTasks();
|
|
4199
4303
|
throw new SkipLoggingError(`Deployment failed to complete: ${finishedDeployment}`);
|
|
4200
4304
|
}
|
|
4201
|
-
const deploymentLink =
|
|
4305
|
+
const deploymentLink = cliLink(
|
|
4202
4306
|
"View deployment",
|
|
4203
4307
|
`${authorization.dashboardUrl}/projects/v3/${resolvedConfig.config.project}/deployments/${finishedDeployment.shortCode}`
|
|
4204
4308
|
);
|
|
@@ -4288,7 +4392,7 @@ function checkLogsForWarnings(logs) {
|
|
|
4288
4392
|
const warnings = [
|
|
4289
4393
|
{
|
|
4290
4394
|
regex: /prisma:warn We could not find your Prisma schema/,
|
|
4291
|
-
message: `Prisma generate failed to find the default schema. Did you include it in config.additionalFiles? ${
|
|
4395
|
+
message: `Prisma generate failed to find the default schema. Did you include it in config.additionalFiles? ${cliLink(
|
|
4292
4396
|
"Config docs",
|
|
4293
4397
|
docs.config.prisma
|
|
4294
4398
|
)}
|
|
@@ -4330,7 +4434,7 @@ function checkLogsForErrors(logs) {
|
|
|
4330
4434
|
{
|
|
4331
4435
|
regex: /Error: Provided --schema at (?<schema>.*) doesn't exist/,
|
|
4332
4436
|
message: `Prisma generate failed to find the specified schema at "$schema".
|
|
4333
|
-
Did you include it in config.additionalFiles? ${
|
|
4437
|
+
Did you include it in config.additionalFiles? ${cliLink(
|
|
4334
4438
|
"Config docs",
|
|
4335
4439
|
docs.config.prisma
|
|
4336
4440
|
)}`
|
|
@@ -4339,11 +4443,11 @@ Did you include it in config.additionalFiles? ${terminalLink2(
|
|
|
4339
4443
|
regex: /sh: 1: (?<packageOrBinary>.*): not found/,
|
|
4340
4444
|
message: `$packageOrBinary not found
|
|
4341
4445
|
|
|
4342
|
-
If it's a package: Include it in ${
|
|
4446
|
+
If it's a package: Include it in ${cliLink(
|
|
4343
4447
|
"config.additionalPackages",
|
|
4344
4448
|
docs.config.prisma
|
|
4345
4449
|
)}
|
|
4346
|
-
If it's a binary: Please ${
|
|
4450
|
+
If it's a binary: Please ${cliLink(
|
|
4347
4451
|
"get in touch",
|
|
4348
4452
|
getInTouch
|
|
4349
4453
|
)} and we'll see what we can do!`
|
|
@@ -4821,12 +4925,11 @@ async function compileProject(config, options, configPath) {
|
|
|
4821
4925
|
const dependencies2 = await resolveRequiredDependencies(allImports, config, javascriptProject);
|
|
4822
4926
|
logger.debug("gatherRequiredDependencies()", { dependencies: dependencies2 });
|
|
4823
4927
|
const packageJsonContents = {
|
|
4824
|
-
|
|
4825
|
-
version: "0.0.0",
|
|
4826
|
-
description: "",
|
|
4928
|
+
...javascriptProject.allowedPackageJson,
|
|
4827
4929
|
dependencies: dependencies2,
|
|
4828
4930
|
scripts: {
|
|
4829
|
-
...javascriptProject.scripts
|
|
4931
|
+
...javascriptProject.scripts,
|
|
4932
|
+
...typeof config.postInstall === "string" ? { postinstall: config.postInstall } : {}
|
|
4830
4933
|
}
|
|
4831
4934
|
};
|
|
4832
4935
|
span.setAttributes({
|
|
@@ -4841,7 +4944,7 @@ async function compileProject(config, options, configPath) {
|
|
|
4841
4944
|
|
|
4842
4945
|
${copyResult.noMatches.map((glob) => `- "${glob}"`).join("\n")}
|
|
4843
4946
|
|
|
4844
|
-
If this is unexpected you should check your ${
|
|
4947
|
+
If this is unexpected you should check your ${cliLink(
|
|
4845
4948
|
"glob patterns",
|
|
4846
4949
|
"https://github.com/isaacs/node-glob?tab=readme-ov-file#glob-primer"
|
|
4847
4950
|
)} are valid.`
|
|
@@ -4859,14 +4962,6 @@ If this is unexpected you should check your ${terminalLink2(
|
|
|
4859
4962
|
}
|
|
4860
4963
|
const containerFilePath = join6(cliRootPath(), "Containerfile.prod");
|
|
4861
4964
|
let containerFileContents = readFileSync2(containerFilePath, "utf-8");
|
|
4862
|
-
if (config.postInstall) {
|
|
4863
|
-
containerFileContents = containerFileContents.replace(
|
|
4864
|
-
"__POST_INSTALL__",
|
|
4865
|
-
`RUN ${config.postInstall}`
|
|
4866
|
-
);
|
|
4867
|
-
} else {
|
|
4868
|
-
containerFileContents = containerFileContents.replace("__POST_INSTALL__", "");
|
|
4869
|
-
}
|
|
4870
4965
|
await writeFile2(join6(tempDir, "Containerfile"), containerFileContents);
|
|
4871
4966
|
const contentHasher = createHash("sha256");
|
|
4872
4967
|
contentHasher.update(Buffer.from(entryPointOutputFile.text));
|
|
@@ -5299,9 +5394,11 @@ var TaskMetadataParseError = class extends Error {
|
|
|
5299
5394
|
}
|
|
5300
5395
|
};
|
|
5301
5396
|
var UnexpectedExitError = class extends Error {
|
|
5302
|
-
constructor(code) {
|
|
5397
|
+
constructor(code, signal, stderr) {
|
|
5303
5398
|
super(`Unexpected exit with code ${code}`);
|
|
5304
5399
|
this.code = code;
|
|
5400
|
+
this.signal = signal;
|
|
5401
|
+
this.stderr = stderr;
|
|
5305
5402
|
this.name = "UnexpectedExitError";
|
|
5306
5403
|
}
|
|
5307
5404
|
};
|
|
@@ -5323,6 +5420,21 @@ var SigKillTimeoutProcessError = class extends Error {
|
|
|
5323
5420
|
this.name = "SigKillTimeoutProcessError";
|
|
5324
5421
|
}
|
|
5325
5422
|
};
|
|
5423
|
+
function getFriendlyErrorMessage(code, signal, stderr) {
|
|
5424
|
+
const message = (text3) => {
|
|
5425
|
+
if (signal) {
|
|
5426
|
+
return `[${signal}] ${text3}`;
|
|
5427
|
+
} else {
|
|
5428
|
+
return text3;
|
|
5429
|
+
}
|
|
5430
|
+
};
|
|
5431
|
+
if (code === 137 || stderr?.includes("OOMErrorHandler")) {
|
|
5432
|
+
return message(
|
|
5433
|
+
"Process ran out of memory! Try choosing a machine preset with more memory for this task."
|
|
5434
|
+
);
|
|
5435
|
+
}
|
|
5436
|
+
return message(`Process exited with code ${code}.`);
|
|
5437
|
+
}
|
|
5326
5438
|
|
|
5327
5439
|
// src/workers/dev/backgroundWorker.ts
|
|
5328
5440
|
import {
|
|
@@ -5338,7 +5450,6 @@ import dotenv from "dotenv";
|
|
|
5338
5450
|
import { Evt } from "evt";
|
|
5339
5451
|
import { fork } from "node:child_process";
|
|
5340
5452
|
import { dirname as dirname2, resolve as resolve4 } from "node:path";
|
|
5341
|
-
import terminalLink3 from "terminal-link";
|
|
5342
5453
|
var BackgroundWorkerCoordinator = class {
|
|
5343
5454
|
constructor(baseURL) {
|
|
5344
5455
|
this.baseURL = baseURL;
|
|
@@ -5575,7 +5686,7 @@ var BackgroundWorker = class {
|
|
|
5575
5686
|
resolved = true;
|
|
5576
5687
|
child.kill();
|
|
5577
5688
|
reject(new Error("Worker timed out"));
|
|
5578
|
-
},
|
|
5689
|
+
}, 2e4);
|
|
5579
5690
|
child.on("message", async (msg) => {
|
|
5580
5691
|
const message = this._handler.parseMessage(msg);
|
|
5581
5692
|
if (message.type === "TASKS_READY" && !resolved) {
|
|
@@ -5745,7 +5856,7 @@ var BackgroundWorker = class {
|
|
|
5745
5856
|
const logsUrl = `${baseURL}/runs/${execution.run.id}`;
|
|
5746
5857
|
const pipe = chalkGrey("|");
|
|
5747
5858
|
const bullet = chalkGrey("\u25CB");
|
|
5748
|
-
const link = chalkLink(
|
|
5859
|
+
const link = chalkLink(cliLink("View logs", logsUrl));
|
|
5749
5860
|
let timestampPrefix = chalkGrey(prettyPrintDate(payload.execution.attempt.startedAt));
|
|
5750
5861
|
const workerPrefix = chalkWorker(this.metadata.version);
|
|
5751
5862
|
const taskPrefix = chalkTask(execution.task.id);
|
|
@@ -5822,7 +5933,9 @@ var BackgroundWorker = class {
|
|
|
5822
5933
|
retry: void 0,
|
|
5823
5934
|
error: {
|
|
5824
5935
|
type: "INTERNAL_ERROR",
|
|
5825
|
-
code: TaskRunErrorCodes.TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE
|
|
5936
|
+
code: TaskRunErrorCodes.TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE,
|
|
5937
|
+
message: getFriendlyErrorMessage(e.code, e.signal, e.stderr),
|
|
5938
|
+
stackTrace: e.stderr
|
|
5826
5939
|
}
|
|
5827
5940
|
};
|
|
5828
5941
|
}
|
|
@@ -5884,6 +5997,7 @@ var TaskRunProcess = class {
|
|
|
5884
5997
|
_currentExecution;
|
|
5885
5998
|
_isBeingKilled = false;
|
|
5886
5999
|
_isBeingCancelled = false;
|
|
6000
|
+
_stderr = [];
|
|
5887
6001
|
/**
|
|
5888
6002
|
* @deprecated use onTaskRunHeartbeat instead
|
|
5889
6003
|
*/
|
|
@@ -6043,7 +6157,13 @@ var TaskRunProcess = class {
|
|
|
6043
6157
|
} else if (this._isBeingKilled) {
|
|
6044
6158
|
rejecter(new CleanupProcessError());
|
|
6045
6159
|
} else {
|
|
6046
|
-
rejecter(
|
|
6160
|
+
rejecter(
|
|
6161
|
+
new UnexpectedExitError(
|
|
6162
|
+
code ?? -1,
|
|
6163
|
+
signal,
|
|
6164
|
+
this._stderr.length ? this._stderr.join("\n") : void 0
|
|
6165
|
+
)
|
|
6166
|
+
);
|
|
6047
6167
|
}
|
|
6048
6168
|
}
|
|
6049
6169
|
}
|
|
@@ -6072,9 +6192,14 @@ var TaskRunProcess = class {
|
|
|
6072
6192
|
const runId = chalkRun(
|
|
6073
6193
|
`${this._currentExecution.run.id}.${this._currentExecution.attempt.number}`
|
|
6074
6194
|
);
|
|
6195
|
+
const errorLine = data.toString();
|
|
6075
6196
|
logger.log(
|
|
6076
|
-
`${chalkError("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${runId} ${
|
|
6197
|
+
`${chalkError("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${runId} ${errorLine}`
|
|
6077
6198
|
);
|
|
6199
|
+
if (this._stderr.length > 100) {
|
|
6200
|
+
this._stderr.shift();
|
|
6201
|
+
}
|
|
6202
|
+
this._stderr.push(errorLine);
|
|
6078
6203
|
}
|
|
6079
6204
|
#kill() {
|
|
6080
6205
|
logger.debug(`[${this.runId}] #kill()`, { pid: this.pid });
|
|
@@ -6594,12 +6719,18 @@ function useDev({
|
|
|
6594
6719
|
throw new Error(backgroundWorkerRecord.error);
|
|
6595
6720
|
}
|
|
6596
6721
|
backgroundWorker.metadata = backgroundWorkerRecord.data;
|
|
6722
|
+
backgroundWorker;
|
|
6723
|
+
const testUrl = `${dashboardUrl}/projects/v3/${config.project}/test?environment=dev`;
|
|
6724
|
+
const runsUrl = `${dashboardUrl}/projects/v3/${config.project}/runs?envSlug=dev`;
|
|
6725
|
+
const pipe = chalkGrey("|");
|
|
6726
|
+
const bullet = chalkGrey("\u25CB");
|
|
6727
|
+
const arrow = chalkGrey("->");
|
|
6728
|
+
const testLink = chalkLink(cliLink("Test tasks", testUrl));
|
|
6729
|
+
const runsLink = chalkLink(cliLink("View runs", runsUrl));
|
|
6730
|
+
const workerStarted = chalkGrey("Background worker started");
|
|
6731
|
+
const workerVersion = chalkWorker(backgroundWorkerRecord.data.version);
|
|
6597
6732
|
logger.log(
|
|
6598
|
-
`${
|
|
6599
|
-
`\u25CB Background worker started -> ${chalkWorker(
|
|
6600
|
-
backgroundWorkerRecord.data.version
|
|
6601
|
-
)}`
|
|
6602
|
-
)}`
|
|
6733
|
+
`${bullet} ${workerStarted} ${arrow} ${workerVersion} ${pipe} ${testLink} ${pipe} ${runsLink}`
|
|
6603
6734
|
);
|
|
6604
6735
|
firstBuild = false;
|
|
6605
6736
|
await backgroundWorkerCoordinator.registerWorker(
|
|
@@ -6607,6 +6738,9 @@ function useDev({
|
|
|
6607
6738
|
backgroundWorker
|
|
6608
6739
|
);
|
|
6609
6740
|
} catch (e) {
|
|
6741
|
+
logger.debug("Error starting background worker", {
|
|
6742
|
+
error: e
|
|
6743
|
+
});
|
|
6610
6744
|
if (e instanceof TaskMetadataParseError) {
|
|
6611
6745
|
logTaskMetadataParseError(e.zodIssues, e.tasks);
|
|
6612
6746
|
return;
|
|
@@ -6837,11 +6971,10 @@ import { context as context3, trace as trace3 } from "@opentelemetry/api";
|
|
|
6837
6971
|
import { flattenAttributes as flattenAttributes4 } from "@trigger.dev/core/v3";
|
|
6838
6972
|
import { recordSpanException as recordSpanException6 } from "@trigger.dev/core/v3/workers";
|
|
6839
6973
|
import chalk5 from "chalk";
|
|
6840
|
-
import { execa as execa3 } from "execa";
|
|
6841
|
-
import
|
|
6974
|
+
import { ExecaError as ExecaError2, execa as execa3 } from "execa";
|
|
6975
|
+
import { applyEdits, modify, findNodeAtLocation, parseTree, getNodeValue } from "jsonc-parser";
|
|
6842
6976
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
6843
6977
|
import { join as join8, relative as relative4, resolve as resolve5 } from "node:path";
|
|
6844
|
-
import terminalLink4 from "terminal-link";
|
|
6845
6978
|
import { z as z6 } from "zod";
|
|
6846
6979
|
|
|
6847
6980
|
// src/utilities/createFileFromTemplate.ts
|
|
@@ -6886,12 +7019,12 @@ function replaceAll(input, replacements) {
|
|
|
6886
7019
|
}
|
|
6887
7020
|
|
|
6888
7021
|
// src/commands/init.ts
|
|
6889
|
-
var { applyEdits, modify, findNodeAtLocation, parseTree, getNodeValue } = jsoncParser;
|
|
6890
7022
|
var InitCommandOptions = CommonCommandOptions.extend({
|
|
6891
7023
|
projectRef: z6.string().optional(),
|
|
6892
7024
|
overrideConfig: z6.boolean().default(false),
|
|
6893
7025
|
tag: z6.string().default("beta"),
|
|
6894
|
-
skipPackageInstall: z6.boolean().default(false)
|
|
7026
|
+
skipPackageInstall: z6.boolean().default(false),
|
|
7027
|
+
pkgArgs: z6.string().optional()
|
|
6895
7028
|
});
|
|
6896
7029
|
function configureInitCommand(program2) {
|
|
6897
7030
|
return commonOptions(
|
|
@@ -6902,7 +7035,10 @@ function configureInitCommand(program2) {
|
|
|
6902
7035
|
"-t, --tag <package tag>",
|
|
6903
7036
|
"The version of the @trigger.dev/sdk package to install",
|
|
6904
7037
|
version
|
|
6905
|
-
).option("--skip-package-install", "Skip installing the @trigger.dev/sdk package").option("--override-config", "Override the existing config file if it exists")
|
|
7038
|
+
).option("--skip-package-install", "Skip installing the @trigger.dev/sdk package").option("--override-config", "Override the existing config file if it exists").option(
|
|
7039
|
+
"--pkg-args <args>",
|
|
7040
|
+
"Additional arguments to pass to the package manager, accepts CSV for multiple args"
|
|
7041
|
+
)
|
|
6906
7042
|
).action(async (path7, options) => {
|
|
6907
7043
|
await handleTelemetry(async () => {
|
|
6908
7044
|
await printStandloneInitialBanner(true);
|
|
@@ -6918,6 +7054,7 @@ async function initCommand(dir, options) {
|
|
|
6918
7054
|
async function _initCommand(dir, options) {
|
|
6919
7055
|
const span = trace3.getSpan(context3.active());
|
|
6920
7056
|
intro5("Initializing project");
|
|
7057
|
+
await detectTsConfig(dir, options);
|
|
6921
7058
|
const authorization = await login({
|
|
6922
7059
|
embedded: true,
|
|
6923
7060
|
defaultApiUrl: options.apiUrl,
|
|
@@ -6968,7 +7105,7 @@ async function _initCommand(dir, options) {
|
|
|
6968
7105
|
await writeConfigFile(dir, selectedProject, options, triggerDir);
|
|
6969
7106
|
await addConfigFileToTsConfig(dir, options);
|
|
6970
7107
|
await gitIgnoreDotTriggerDir(dir, options);
|
|
6971
|
-
const projectDashboard =
|
|
7108
|
+
const projectDashboard = cliLink(
|
|
6972
7109
|
"project dashboard",
|
|
6973
7110
|
`${authorization.dashboardUrl}/projects/v3/${selectedProject.externalRef}`
|
|
6974
7111
|
);
|
|
@@ -6981,13 +7118,10 @@ async function _initCommand(dir, options) {
|
|
|
6981
7118
|
);
|
|
6982
7119
|
log6.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
|
|
6983
7120
|
log6.info(
|
|
6984
|
-
` 3. Head over to our ${
|
|
6985
|
-
"v3 docs",
|
|
6986
|
-
"https://trigger.dev/docs/v3"
|
|
6987
|
-
)} to learn more.`
|
|
7121
|
+
` 3. Head over to our ${cliLink("v3 docs", "https://trigger.dev/docs/v3")} to learn more.`
|
|
6988
7122
|
);
|
|
6989
7123
|
log6.info(
|
|
6990
|
-
` 4. Need help? Join our ${
|
|
7124
|
+
` 4. Need help? Join our ${cliLink(
|
|
6991
7125
|
"Discord community",
|
|
6992
7126
|
"https://trigger.dev/discord"
|
|
6993
7127
|
)} or email us at ${chalk5.cyan("help@trigger.dev")}`
|
|
@@ -7092,8 +7226,39 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
7092
7226
|
}
|
|
7093
7227
|
});
|
|
7094
7228
|
}
|
|
7229
|
+
async function detectTsConfig(dir, options) {
|
|
7230
|
+
return await tracer.startActiveSpan("detectTsConfig", async (span) => {
|
|
7231
|
+
try {
|
|
7232
|
+
const projectDir = resolve5(process.cwd(), dir);
|
|
7233
|
+
const tsconfigPath = join8(projectDir, "tsconfig.json");
|
|
7234
|
+
span.setAttributes({
|
|
7235
|
+
"cli.projectDir": projectDir,
|
|
7236
|
+
"cli.tsconfigPath": tsconfigPath
|
|
7237
|
+
});
|
|
7238
|
+
const tsconfigExists = await pathExists(tsconfigPath);
|
|
7239
|
+
if (!tsconfigExists) {
|
|
7240
|
+
prettyError(
|
|
7241
|
+
"No tsconfig.json found",
|
|
7242
|
+
`The init command needs to be run in a TypeScript project. You can create one like this:`,
|
|
7243
|
+
`npm install typescript --save-dev
|
|
7244
|
+
npx tsc --init
|
|
7245
|
+
`
|
|
7246
|
+
);
|
|
7247
|
+
throw new Error("TypeScript required");
|
|
7248
|
+
}
|
|
7249
|
+
logger.debug("tsconfig.json exists", { tsconfigPath });
|
|
7250
|
+
span.end();
|
|
7251
|
+
} catch (e) {
|
|
7252
|
+
if (!(e instanceof SkipCommandError)) {
|
|
7253
|
+
recordSpanException6(span, e);
|
|
7254
|
+
}
|
|
7255
|
+
span.end();
|
|
7256
|
+
throw e;
|
|
7257
|
+
}
|
|
7258
|
+
});
|
|
7259
|
+
}
|
|
7095
7260
|
async function addConfigFileToTsConfig(dir, options) {
|
|
7096
|
-
return await tracer.startActiveSpan("
|
|
7261
|
+
return await tracer.startActiveSpan("addConfigFileToTsConfig", async (span) => {
|
|
7097
7262
|
try {
|
|
7098
7263
|
const projectDir = resolve5(process.cwd(), dir);
|
|
7099
7264
|
const tsconfigPath = join8(projectDir, "tsconfig.json");
|
|
@@ -7144,49 +7309,58 @@ async function addConfigFileToTsConfig(dir, options) {
|
|
|
7144
7309
|
async function installPackages2(dir, options) {
|
|
7145
7310
|
return await tracer.startActiveSpan("installPackages", async (span) => {
|
|
7146
7311
|
const installSpinner = spinner();
|
|
7312
|
+
let pkgManager;
|
|
7147
7313
|
try {
|
|
7148
7314
|
const projectDir = resolve5(process.cwd(), dir);
|
|
7149
|
-
|
|
7315
|
+
pkgManager = await getUserPackageManager(projectDir);
|
|
7150
7316
|
span.setAttributes({
|
|
7151
7317
|
"cli.projectDir": projectDir,
|
|
7152
7318
|
"cli.packageManager": pkgManager,
|
|
7153
7319
|
"cli.tag": options.tag
|
|
7154
7320
|
});
|
|
7321
|
+
const userArgs = options.pkgArgs?.split(",") ?? [];
|
|
7322
|
+
const execaOptions = { cwd: projectDir };
|
|
7323
|
+
let installProcess;
|
|
7324
|
+
let args;
|
|
7155
7325
|
switch (pkgManager) {
|
|
7156
7326
|
case "npm": {
|
|
7157
|
-
|
|
7158
|
-
await execa3("npm", ["install", "--save-exact", `@trigger.dev/sdk@${options.tag}`], {
|
|
7159
|
-
cwd: projectDir,
|
|
7160
|
-
stdio: options.logLevel === "debug" ? "inherit" : "ignore"
|
|
7161
|
-
});
|
|
7162
|
-
break;
|
|
7163
|
-
}
|
|
7164
|
-
case "pnpm": {
|
|
7165
|
-
installSpinner.start(`Running pnpm add @trigger.dev/sdk@${options.tag}`);
|
|
7166
|
-
await execa3("pnpm", ["add", `@trigger.dev/sdk@${options.tag}`], {
|
|
7167
|
-
cwd: projectDir,
|
|
7168
|
-
stdio: options.logLevel === "debug" ? "inherit" : "ignore"
|
|
7169
|
-
});
|
|
7327
|
+
args = ["install", "--save-exact", ...userArgs, `@trigger.dev/sdk@${options.tag}`];
|
|
7170
7328
|
break;
|
|
7171
7329
|
}
|
|
7330
|
+
case "pnpm":
|
|
7172
7331
|
case "yarn": {
|
|
7173
|
-
|
|
7174
|
-
await execa3("yarn", ["add", `@trigger.dev/sdk@${options.tag}`], {
|
|
7175
|
-
cwd: projectDir,
|
|
7176
|
-
stdio: options.logLevel === "debug" ? "inherit" : "ignore"
|
|
7177
|
-
});
|
|
7332
|
+
args = ["add", ...userArgs, `@trigger.dev/sdk@${options.tag}`];
|
|
7178
7333
|
break;
|
|
7179
7334
|
}
|
|
7180
7335
|
}
|
|
7336
|
+
installSpinner.start(`Running ${pkgManager} ${args.join(" ")}`);
|
|
7337
|
+
installProcess = execa3(pkgManager, args, execaOptions);
|
|
7338
|
+
const handleProcessOutput = (data) => {
|
|
7339
|
+
logger.debug(data.toString());
|
|
7340
|
+
};
|
|
7341
|
+
installProcess.stderr?.on("data", handleProcessOutput);
|
|
7342
|
+
installProcess.stdout?.on("data", handleProcessOutput);
|
|
7343
|
+
await installProcess;
|
|
7181
7344
|
installSpinner.stop(`@trigger.dev/sdk@${options.tag} installed`);
|
|
7182
7345
|
span.end();
|
|
7183
7346
|
} catch (e) {
|
|
7184
|
-
|
|
7185
|
-
`Failed to install @trigger.dev/sdk@${options.tag}
|
|
7186
|
-
|
|
7347
|
+
if (options.logLevel === "debug") {
|
|
7348
|
+
installSpinner.stop(`Failed to install @trigger.dev/sdk@${options.tag}.`);
|
|
7349
|
+
} else {
|
|
7350
|
+
installSpinner.stop(
|
|
7351
|
+
`Failed to install @trigger.dev/sdk@${options.tag}. Rerun command with --log-level debug for more details.`
|
|
7352
|
+
);
|
|
7353
|
+
}
|
|
7187
7354
|
if (!(e instanceof SkipCommandError)) {
|
|
7188
7355
|
recordSpanException6(span, e);
|
|
7189
7356
|
}
|
|
7357
|
+
if (e instanceof ExecaError2) {
|
|
7358
|
+
if (pkgManager) {
|
|
7359
|
+
e.message += `
|
|
7360
|
+
|
|
7361
|
+
Note: You can pass additional args to ${pkgManager} by using --pkg-args. For example: trigger.dev init --pkg-args="--workspace-root"`;
|
|
7362
|
+
}
|
|
7363
|
+
}
|
|
7190
7364
|
span.end();
|
|
7191
7365
|
throw e;
|
|
7192
7366
|
}
|
|
@@ -7255,7 +7429,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
7255
7429
|
throw new Error(`Failed to get projects: ${projectsResponse.error}`);
|
|
7256
7430
|
}
|
|
7257
7431
|
if (projectsResponse.data.length === 0) {
|
|
7258
|
-
const newProjectLink =
|
|
7432
|
+
const newProjectLink = cliLink(
|
|
7259
7433
|
"Create new project",
|
|
7260
7434
|
`${dashboardUrl}/projects/new?version=v3`
|
|
7261
7435
|
);
|