trigger.dev 0.0.0-v3-prelease-20240419151535 → 0.0.0-v3-trigger-dirs-20240422172150
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/Containerfile.prod
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:21-bookworm-slim@sha256:fb82287cf66ca32d854c05f54251fca8b572149163f154248df7e800003c90b5 AS base
|
|
2
2
|
|
|
3
3
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
4
4
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
package/dist/index.js
CHANGED
|
@@ -795,12 +795,12 @@ import { readFileSync as readFileSync2 } from "node:fs";
|
|
|
795
795
|
import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
796
796
|
import { dirname, join as join5, relative as relative3, posix } from "node:path";
|
|
797
797
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
798
|
-
import
|
|
798
|
+
import terminalLink2 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-
|
|
803
|
+
var version = "0.0.0-v3-trigger-dirs-20240422172150";
|
|
804
804
|
var dependencies = {
|
|
805
805
|
"@clack/prompts": "^0.7.0",
|
|
806
806
|
"@depot/cli": "0.0.1-cli.2.55.0",
|
|
@@ -816,7 +816,7 @@ var dependencies = {
|
|
|
816
816
|
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
817
817
|
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
818
818
|
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
819
|
-
"@trigger.dev/core": "workspace:0.0.0-v3-
|
|
819
|
+
"@trigger.dev/core": "workspace:0.0.0-v3-trigger-dirs-20240422172150",
|
|
820
820
|
"@types/degit": "^2.8.3",
|
|
821
821
|
chalk: "^5.2.0",
|
|
822
822
|
chokidar: "^3.5.3",
|
|
@@ -1540,9 +1540,12 @@ async function getTriggerDirectories(dirPath) {
|
|
|
1540
1540
|
const entries = await fs2.promises.readdir(dirPath, { withFileTypes: true });
|
|
1541
1541
|
const triggerDirectories = [];
|
|
1542
1542
|
for (const entry of entries) {
|
|
1543
|
-
if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name))
|
|
1543
|
+
if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name) || entry.name.startsWith("."))
|
|
1544
1544
|
continue;
|
|
1545
1545
|
const fullPath = join(dirPath, entry.name);
|
|
1546
|
+
if (fullPath.endsWith("app/api/trigger")) {
|
|
1547
|
+
continue;
|
|
1548
|
+
}
|
|
1546
1549
|
if (entry.name === "trigger") {
|
|
1547
1550
|
triggerDirectories.push(fullPath);
|
|
1548
1551
|
}
|
|
@@ -1616,6 +1619,15 @@ async function getConfigPath(dir, fileName) {
|
|
|
1616
1619
|
});
|
|
1617
1620
|
return await findUp(fileName ? [fileName] : CONFIG_FILES, { cwd: dir });
|
|
1618
1621
|
}
|
|
1622
|
+
async function findFilePath(dir, fileName) {
|
|
1623
|
+
const result = await findUp([fileName], { cwd: dir });
|
|
1624
|
+
logger.debug("Searched for the file", {
|
|
1625
|
+
dir,
|
|
1626
|
+
fileName,
|
|
1627
|
+
result
|
|
1628
|
+
});
|
|
1629
|
+
return result;
|
|
1630
|
+
}
|
|
1619
1631
|
async function readConfig(dir, options) {
|
|
1620
1632
|
const absoluteDir = path2.resolve(process.cwd(), dir);
|
|
1621
1633
|
const configPath = await getConfigPath(dir, options?.configFile);
|
|
@@ -1668,6 +1680,7 @@ async function resolveConfig(path7, config) {
|
|
|
1668
1680
|
config.triggerDirectories = await findTriggerDirectories(path7);
|
|
1669
1681
|
}
|
|
1670
1682
|
config.triggerDirectories = resolveTriggerDirectories(config.triggerDirectories);
|
|
1683
|
+
logger.debug("Resolved trigger directories", { triggerDirectories: config.triggerDirectories });
|
|
1671
1684
|
if (!config.triggerUrl) {
|
|
1672
1685
|
config.triggerUrl = CLOUD_API_URL;
|
|
1673
1686
|
}
|
|
@@ -1675,7 +1688,7 @@ async function resolveConfig(path7, config) {
|
|
|
1675
1688
|
config.projectDir = path7;
|
|
1676
1689
|
}
|
|
1677
1690
|
if (!config.tsconfigPath) {
|
|
1678
|
-
config.tsconfigPath = await
|
|
1691
|
+
config.tsconfigPath = await findFilePath(path7, "tsconfig.json");
|
|
1679
1692
|
}
|
|
1680
1693
|
return config;
|
|
1681
1694
|
}
|
|
@@ -2954,6 +2967,20 @@ function getLoaderForFile(file) {
|
|
|
2954
2967
|
import chalk4 from "chalk";
|
|
2955
2968
|
import { relative as relative2 } from "node:path";
|
|
2956
2969
|
import { groupTaskMetadataIssuesByTask } from "@trigger.dev/core/v3";
|
|
2970
|
+
import terminalLink from "terminal-link";
|
|
2971
|
+
|
|
2972
|
+
// src/utilities/links.ts
|
|
2973
|
+
var docs = {
|
|
2974
|
+
config: {
|
|
2975
|
+
home: "https://trigger.dev/docs/v3/trigger-config",
|
|
2976
|
+
esm: "https://trigger.dev/docs/v3/trigger-config#esm-only-packages",
|
|
2977
|
+
prisma: "https://trigger.dev/docs/v3/trigger-config#prisma-and-other-generators",
|
|
2978
|
+
additionalPackages: "https://trigger.dev/docs/v3/trigger-config#prisma-and-other-generators"
|
|
2979
|
+
}
|
|
2980
|
+
};
|
|
2981
|
+
var getInTouch = "https://trigger.dev/contact";
|
|
2982
|
+
|
|
2983
|
+
// src/utilities/deployErrors.ts
|
|
2957
2984
|
function errorIsErrorLike(error) {
|
|
2958
2985
|
return error instanceof Error || typeof error === "object" && error !== null && "message" in error;
|
|
2959
2986
|
}
|
|
@@ -3019,6 +3046,10 @@ ${chalkGrey("\u25CB")} Dynamically import the module in your code: ${chalkGrey(
|
|
|
3019
3046
|
`
|
|
3020
3047
|
);
|
|
3021
3048
|
}
|
|
3049
|
+
logger.log(
|
|
3050
|
+
`${chalkGrey("\u25CB")} For more info see the ${terminalLink("relevant docs", docs.config.esm)}.
|
|
3051
|
+
`
|
|
3052
|
+
);
|
|
3022
3053
|
}
|
|
3023
3054
|
function parseNpmInstallError(error) {
|
|
3024
3055
|
if (typeof error === "string") {
|
|
@@ -3313,7 +3344,8 @@ var DeployCommandOptions = CommonCommandOptions.extend({
|
|
|
3313
3344
|
config: z4.string().optional(),
|
|
3314
3345
|
projectRef: z4.string().optional(),
|
|
3315
3346
|
outputMetafile: z4.string().optional(),
|
|
3316
|
-
apiUrl: z4.string().optional()
|
|
3347
|
+
apiUrl: z4.string().optional(),
|
|
3348
|
+
saveLogs: z4.boolean().default(false)
|
|
3317
3349
|
});
|
|
3318
3350
|
function configureDeployCommand(program2) {
|
|
3319
3351
|
return commonOptions(
|
|
@@ -3360,6 +3392,11 @@ function configureDeployCommand(program2) {
|
|
|
3360
3392
|
"--output-metafile <path>",
|
|
3361
3393
|
"If provided, will save the esbuild metafile for the build to the specified path"
|
|
3362
3394
|
).hideHelp()
|
|
3395
|
+
).addOption(
|
|
3396
|
+
new CommandOption(
|
|
3397
|
+
"--save-logs",
|
|
3398
|
+
"If provided, will save logs even for successful builds"
|
|
3399
|
+
).hideHelp()
|
|
3363
3400
|
).action(async (path7, options) => {
|
|
3364
3401
|
await handleTelemetry(async () => {
|
|
3365
3402
|
await printStandloneInitialBanner(true);
|
|
@@ -3494,19 +3531,35 @@ async function _deployCommand(dir, options) {
|
|
|
3494
3531
|
);
|
|
3495
3532
|
};
|
|
3496
3533
|
const image = await buildImage();
|
|
3534
|
+
const warnings = checkLogsForWarnings(image.logs);
|
|
3535
|
+
if (!warnings.ok) {
|
|
3536
|
+
await failDeploy(
|
|
3537
|
+
deploymentResponse.data.shortCode,
|
|
3538
|
+
warnings.summary,
|
|
3539
|
+
image.logs,
|
|
3540
|
+
deploymentSpinner,
|
|
3541
|
+
warnings.warnings,
|
|
3542
|
+
warnings.errors
|
|
3543
|
+
);
|
|
3544
|
+
throw new SkipLoggingError(`Failed to build project image: ${warnings.summary}`);
|
|
3545
|
+
}
|
|
3497
3546
|
if (!image.ok) {
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
} else {
|
|
3506
|
-
logger.log(`${chalkError("X Error:")} ${image.error}.`);
|
|
3507
|
-
}
|
|
3547
|
+
await failDeploy(
|
|
3548
|
+
deploymentResponse.data.shortCode,
|
|
3549
|
+
image.error,
|
|
3550
|
+
image.logs,
|
|
3551
|
+
deploymentSpinner,
|
|
3552
|
+
warnings.warnings
|
|
3553
|
+
);
|
|
3508
3554
|
throw new SkipLoggingError(`Failed to build project image: ${image.error}`);
|
|
3509
3555
|
}
|
|
3556
|
+
const preExitTasks = async () => {
|
|
3557
|
+
printWarnings(warnings.warnings);
|
|
3558
|
+
if (options.saveLogs) {
|
|
3559
|
+
const logPath = await saveLogs(deploymentResponse.data.shortCode, image.logs);
|
|
3560
|
+
log3.info(`Build logs have been saved to ${logPath}`);
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3510
3563
|
const imageReference = options.selfHosted ? `${selfHostedRegistryHost ? `${selfHostedRegistryHost}/` : ""}${image.image}${image.digest ? `@${image.digest}` : ""}` : `${registryHost}/${image.image}${image.digest ? `@${image.digest}` : ""}`;
|
|
3511
3564
|
span?.setAttributes({
|
|
3512
3565
|
"image.reference": imageReference
|
|
@@ -3515,6 +3568,7 @@ async function _deployCommand(dir, options) {
|
|
|
3515
3568
|
deploymentSpinner.stop(
|
|
3516
3569
|
`Project image built: ${imageReference}. Skipping deployment as requested`
|
|
3517
3570
|
);
|
|
3571
|
+
await preExitTasks();
|
|
3518
3572
|
throw new SkipCommandError("Skipping deployment as requested");
|
|
3519
3573
|
}
|
|
3520
3574
|
deploymentSpinner.message(
|
|
@@ -3529,6 +3583,7 @@ async function _deployCommand(dir, options) {
|
|
|
3529
3583
|
);
|
|
3530
3584
|
if (!startIndexingResponse.success) {
|
|
3531
3585
|
deploymentSpinner.stop(`Failed to start indexing: ${startIndexingResponse.error}`);
|
|
3586
|
+
await preExitTasks();
|
|
3532
3587
|
throw new SkipLoggingError(`Failed to start indexing: ${startIndexingResponse.error}`);
|
|
3533
3588
|
}
|
|
3534
3589
|
const finishedDeployment = await waitForDeploymentToFinish(
|
|
@@ -3537,19 +3592,26 @@ async function _deployCommand(dir, options) {
|
|
|
3537
3592
|
);
|
|
3538
3593
|
if (!finishedDeployment) {
|
|
3539
3594
|
deploymentSpinner.stop(`Deployment failed to complete`);
|
|
3595
|
+
await preExitTasks();
|
|
3540
3596
|
throw new SkipLoggingError("Deployment failed to complete: unknown issue");
|
|
3541
3597
|
}
|
|
3542
3598
|
if (typeof finishedDeployment === "string") {
|
|
3543
3599
|
deploymentSpinner.stop(`Deployment failed to complete: ${finishedDeployment}`);
|
|
3600
|
+
await preExitTasks();
|
|
3544
3601
|
throw new SkipLoggingError(`Deployment failed to complete: ${finishedDeployment}`);
|
|
3545
3602
|
}
|
|
3546
|
-
const deploymentLink =
|
|
3603
|
+
const deploymentLink = terminalLink2(
|
|
3547
3604
|
"View deployment",
|
|
3548
3605
|
`${authorization.dashboardUrl}/projects/v3/${resolvedConfig.config.project}/deployments/${finishedDeployment.shortCode}`
|
|
3549
3606
|
);
|
|
3550
3607
|
switch (finishedDeployment.status) {
|
|
3551
3608
|
case "DEPLOYED": {
|
|
3552
|
-
|
|
3609
|
+
if (warnings.warnings.length > 0) {
|
|
3610
|
+
deploymentSpinner.stop("Deployment completed with warnings");
|
|
3611
|
+
} else {
|
|
3612
|
+
deploymentSpinner.stop("Deployment completed");
|
|
3613
|
+
}
|
|
3614
|
+
await preExitTasks();
|
|
3553
3615
|
const taskCount = finishedDeployment.worker?.tasks.length ?? 0;
|
|
3554
3616
|
if (taskCount === 0) {
|
|
3555
3617
|
outro3(
|
|
@@ -3571,6 +3633,7 @@ async function _deployCommand(dir, options) {
|
|
|
3571
3633
|
if (parsedError2.success) {
|
|
3572
3634
|
deploymentSpinner.stop(`Deployment encountered an error. ${deploymentLink}`);
|
|
3573
3635
|
logTaskMetadataParseError(parsedError2.data.zodIssues, parsedError2.data.tasks);
|
|
3636
|
+
await preExitTasks();
|
|
3574
3637
|
throw new SkipLoggingError(
|
|
3575
3638
|
`Deployment encountered an error: ${finishedDeployment.errorData.name}`
|
|
3576
3639
|
);
|
|
@@ -3585,6 +3648,7 @@ async function _deployCommand(dir, options) {
|
|
|
3585
3648
|
deploymentSpinner.stop(`Deployment encountered an error. ${deploymentLink}`);
|
|
3586
3649
|
logESMRequireError(parsedError, resolvedConfig);
|
|
3587
3650
|
}
|
|
3651
|
+
await preExitTasks();
|
|
3588
3652
|
throw new SkipLoggingError(
|
|
3589
3653
|
`Deployment encountered an error: ${finishedDeployment.errorData.name}`
|
|
3590
3654
|
);
|
|
@@ -3592,19 +3656,133 @@ async function _deployCommand(dir, options) {
|
|
|
3592
3656
|
deploymentSpinner.stop(
|
|
3593
3657
|
`Deployment failed with an unknown error. Please contact eric@trigger.dev for help. ${deploymentLink}`
|
|
3594
3658
|
);
|
|
3659
|
+
await preExitTasks();
|
|
3595
3660
|
throw new SkipLoggingError("Deployment failed with an unknown error");
|
|
3596
3661
|
}
|
|
3597
3662
|
}
|
|
3598
3663
|
case "CANCELED": {
|
|
3599
3664
|
deploymentSpinner.stop(`Deployment was canceled. ${deploymentLink}`);
|
|
3665
|
+
await preExitTasks();
|
|
3600
3666
|
throw new SkipLoggingError("Deployment was canceled");
|
|
3601
3667
|
}
|
|
3602
3668
|
case "TIMED_OUT": {
|
|
3603
3669
|
deploymentSpinner.stop(`Deployment timed out. ${deploymentLink}`);
|
|
3670
|
+
await preExitTasks();
|
|
3604
3671
|
throw new SkipLoggingError("Deployment timed out");
|
|
3605
3672
|
}
|
|
3606
3673
|
}
|
|
3607
3674
|
}
|
|
3675
|
+
function printErrors(errors) {
|
|
3676
|
+
for (const error of errors ?? []) {
|
|
3677
|
+
log3.error(`${chalkError("Error:")} ${error}`);
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
function printWarnings(warnings) {
|
|
3681
|
+
for (const warning of warnings ?? []) {
|
|
3682
|
+
log3.warn(`${chalkWarning("Warning:")} ${warning}`);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
function checkLogsForWarnings(logs) {
|
|
3686
|
+
const warnings = [
|
|
3687
|
+
{
|
|
3688
|
+
regex: /prisma:warn We could not find your Prisma schema/,
|
|
3689
|
+
message: `Prisma generate failed to find the default schema. Did you include it in config.additionalFiles? ${terminalLink2(
|
|
3690
|
+
"Config docs",
|
|
3691
|
+
docs.config.prisma
|
|
3692
|
+
)}
|
|
3693
|
+
Custom schema paths require a postinstall script like this: \`prisma generate --schema=./custom/path/to/schema.prisma\``,
|
|
3694
|
+
shouldFail: true
|
|
3695
|
+
}
|
|
3696
|
+
];
|
|
3697
|
+
const errorMessages2 = [];
|
|
3698
|
+
const warningMessages = [];
|
|
3699
|
+
let shouldFail = false;
|
|
3700
|
+
for (const warning of warnings) {
|
|
3701
|
+
const matches = logs.match(warning.regex);
|
|
3702
|
+
if (!matches) {
|
|
3703
|
+
continue;
|
|
3704
|
+
}
|
|
3705
|
+
const message = getMessageFromTemplate(warning.message, matches.groups);
|
|
3706
|
+
if (warning.shouldFail) {
|
|
3707
|
+
shouldFail = true;
|
|
3708
|
+
errorMessages2.push(message);
|
|
3709
|
+
} else {
|
|
3710
|
+
warningMessages.push(message);
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
if (shouldFail) {
|
|
3714
|
+
return {
|
|
3715
|
+
ok: false,
|
|
3716
|
+
summary: "Build succeeded with critical warnings. Will not proceed",
|
|
3717
|
+
warnings: warningMessages,
|
|
3718
|
+
errors: errorMessages2
|
|
3719
|
+
};
|
|
3720
|
+
}
|
|
3721
|
+
return {
|
|
3722
|
+
ok: true,
|
|
3723
|
+
warnings: warningMessages
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
function checkLogsForErrors(logs) {
|
|
3727
|
+
const errors = [
|
|
3728
|
+
{
|
|
3729
|
+
regex: /Error: Provided --schema at (?<schema>.*) doesn't exist/,
|
|
3730
|
+
message: `Prisma generate failed to find the specified schema at "$schema".
|
|
3731
|
+
Did you include it in config.additionalFiles? ${terminalLink2(
|
|
3732
|
+
"Config docs",
|
|
3733
|
+
docs.config.prisma
|
|
3734
|
+
)}`
|
|
3735
|
+
},
|
|
3736
|
+
{
|
|
3737
|
+
regex: /sh: 1: (?<packageOrBinary>.*): not found/,
|
|
3738
|
+
message: `$packageOrBinary not found
|
|
3739
|
+
|
|
3740
|
+
If it's a package: Include it in ${terminalLink2(
|
|
3741
|
+
"config.additionalPackages",
|
|
3742
|
+
docs.config.prisma
|
|
3743
|
+
)}
|
|
3744
|
+
If it's a binary: Please ${terminalLink2(
|
|
3745
|
+
"get in touch",
|
|
3746
|
+
getInTouch
|
|
3747
|
+
)} and we'll see what we can do!`
|
|
3748
|
+
}
|
|
3749
|
+
];
|
|
3750
|
+
for (const error of errors) {
|
|
3751
|
+
const matches = logs.match(error.regex);
|
|
3752
|
+
if (!matches) {
|
|
3753
|
+
continue;
|
|
3754
|
+
}
|
|
3755
|
+
const message = getMessageFromTemplate(error.message, matches.groups);
|
|
3756
|
+
log3.error(`${chalkError("Error:")} ${message}`);
|
|
3757
|
+
break;
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
function getMessageFromTemplate(template, replacer) {
|
|
3761
|
+
let message = template;
|
|
3762
|
+
if (replacer) {
|
|
3763
|
+
for (const [key, value] of Object.entries(replacer)) {
|
|
3764
|
+
message = message.replaceAll(`$${key}`, value);
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
return message;
|
|
3768
|
+
}
|
|
3769
|
+
async function saveLogs(shortCode, logs) {
|
|
3770
|
+
const logPath = join5(await createTempDir(), `build-${shortCode}.log`);
|
|
3771
|
+
await writeFile2(logPath, logs);
|
|
3772
|
+
return logPath;
|
|
3773
|
+
}
|
|
3774
|
+
async function failDeploy(shortCode, errorSummary, logs, deploymentSpinner, warnings, errors) {
|
|
3775
|
+
deploymentSpinner.stop(`Failed to deploy project`);
|
|
3776
|
+
if (logs.trim() !== "") {
|
|
3777
|
+
const logPath = await saveLogs(shortCode, logs);
|
|
3778
|
+
printWarnings(warnings);
|
|
3779
|
+
printErrors(errors);
|
|
3780
|
+
checkLogsForErrors(logs);
|
|
3781
|
+
outro3(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
|
|
3782
|
+
} else {
|
|
3783
|
+
outro3(`${chalkError("Error:")} ${errorSummary}.`);
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3608
3786
|
async function checkEnvVars(envVars, config, options, environmentClient, apiUrl) {
|
|
3609
3787
|
return await tracer.startActiveSpan("detectEnvVars", async (span) => {
|
|
3610
3788
|
try {
|
|
@@ -3623,7 +3801,7 @@ async function checkEnvVars(envVars, config, options, environmentClient, apiUrl)
|
|
|
3623
3801
|
`Found missing env vars in ${options.env}: ${arrayToSentence(
|
|
3624
3802
|
missingEnvironmentVariables
|
|
3625
3803
|
)}. ${options.ignoreEnvVarCheck ? "Continuing deployment because of --ignore-env-var-check. " : "Aborting deployment. "}${chalk5.bgBlueBright(
|
|
3626
|
-
|
|
3804
|
+
terminalLink2(
|
|
3627
3805
|
"Manage env vars",
|
|
3628
3806
|
`${apiUrl}/projects/v3/${config.project}/environment-variables`
|
|
3629
3807
|
)
|
|
@@ -3926,7 +4104,7 @@ async function compileProject(config, options, configPath) {
|
|
|
3926
4104
|
join5(cliRootPath(), "workers", "prod", "worker-facade.js"),
|
|
3927
4105
|
"utf-8"
|
|
3928
4106
|
);
|
|
3929
|
-
const workerSetupPath = join5(cliRootPath(), "workers", "
|
|
4107
|
+
const workerSetupPath = join5(cliRootPath(), "workers", "prod", "worker-setup.js");
|
|
3930
4108
|
let workerContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace(
|
|
3931
4109
|
"__WORKER_SETUP__",
|
|
3932
4110
|
`import { tracingSDK } from "${escapeImportPath(workerSetupPath)}";`
|
|
@@ -4078,8 +4256,22 @@ async function compileProject(config, options, configPath) {
|
|
|
4078
4256
|
}
|
|
4079
4257
|
};
|
|
4080
4258
|
await writeJSONFile(join5(tempDir, "package.json"), packageJsonContents);
|
|
4081
|
-
await copyAdditionalFiles(config, tempDir);
|
|
4082
|
-
|
|
4259
|
+
const copyResult = await copyAdditionalFiles(config, tempDir);
|
|
4260
|
+
if (!copyResult.ok) {
|
|
4261
|
+
compileSpinner.stop("Project built with warnings");
|
|
4262
|
+
log3.warn(
|
|
4263
|
+
`No additionalFiles matches for:
|
|
4264
|
+
|
|
4265
|
+
${copyResult.noMatches.map((glob) => `- "${glob}"`).join("\n")}
|
|
4266
|
+
|
|
4267
|
+
If this is unexpected you should check your ${terminalLink2(
|
|
4268
|
+
"glob patterns",
|
|
4269
|
+
"https://github.com/isaacs/node-glob?tab=readme-ov-file#glob-primer"
|
|
4270
|
+
)} are valid.`
|
|
4271
|
+
);
|
|
4272
|
+
} else {
|
|
4273
|
+
compileSpinner.stop("Project built successfully");
|
|
4274
|
+
}
|
|
4083
4275
|
const resolvingDependenciesResult = await resolveDependencies(
|
|
4084
4276
|
tempDir,
|
|
4085
4277
|
packageJsonContents,
|
|
@@ -4286,8 +4478,9 @@ async function gatherRequiredDependencies(imports, config, project) {
|
|
|
4286
4478
|
}
|
|
4287
4479
|
async function copyAdditionalFiles(config, tempDir) {
|
|
4288
4480
|
const additionalFiles = config.additionalFiles ?? [];
|
|
4481
|
+
const noMatches = [];
|
|
4289
4482
|
if (additionalFiles.length === 0) {
|
|
4290
|
-
return;
|
|
4483
|
+
return { ok: true };
|
|
4291
4484
|
}
|
|
4292
4485
|
return await tracer.startActiveSpan(
|
|
4293
4486
|
"copyAdditionalFiles",
|
|
@@ -4301,22 +4494,55 @@ async function copyAdditionalFiles(config, tempDir) {
|
|
|
4301
4494
|
logger.debug(`Copying files to ${tempDir}`, {
|
|
4302
4495
|
additionalFiles
|
|
4303
4496
|
});
|
|
4304
|
-
const
|
|
4497
|
+
const globOptions = {
|
|
4305
4498
|
withFileTypes: true,
|
|
4306
4499
|
ignore: ["node_modules"],
|
|
4307
4500
|
cwd: config.projectDir,
|
|
4308
4501
|
nodir: true
|
|
4309
|
-
}
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
)
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4502
|
+
};
|
|
4503
|
+
const globs = [];
|
|
4504
|
+
let i = 0;
|
|
4505
|
+
for (const additionalFile of additionalFiles) {
|
|
4506
|
+
let glob;
|
|
4507
|
+
if (i === 0) {
|
|
4508
|
+
glob = new Glob(additionalFile, globOptions);
|
|
4509
|
+
} else {
|
|
4510
|
+
const previousGlob = globs[i - 1];
|
|
4511
|
+
if (!previousGlob) {
|
|
4512
|
+
logger.error("No previous glob, this shouldn't happen", { i, additionalFiles });
|
|
4513
|
+
continue;
|
|
4514
|
+
}
|
|
4515
|
+
glob = new Glob(additionalFile, previousGlob);
|
|
4516
|
+
}
|
|
4517
|
+
if (!(Symbol.asyncIterator in glob)) {
|
|
4518
|
+
logger.error("Glob should be an async iterator", { glob });
|
|
4519
|
+
throw new Error("Unrecoverable error while copying additional files");
|
|
4520
|
+
}
|
|
4521
|
+
let matches = 0;
|
|
4522
|
+
for await (const file of glob) {
|
|
4523
|
+
matches++;
|
|
4524
|
+
const pathInsideTempDir = relative3(config.projectDir, file.fullpath()).split(posix.sep).filter((p) => p !== "..").join(posix.sep);
|
|
4525
|
+
const relativeDestinationPath = join5(tempDir, pathInsideTempDir);
|
|
4526
|
+
logger.debug(`Copying file ${file.fullpath()} to ${relativeDestinationPath}`);
|
|
4527
|
+
await mkdir(dirname(relativeDestinationPath), { recursive: true });
|
|
4528
|
+
await copyFile(file.fullpath(), relativeDestinationPath);
|
|
4529
|
+
}
|
|
4530
|
+
if (matches === 0) {
|
|
4531
|
+
noMatches.push(additionalFile);
|
|
4532
|
+
}
|
|
4533
|
+
globs[i] = glob;
|
|
4534
|
+
i++;
|
|
4318
4535
|
}
|
|
4319
4536
|
span.end();
|
|
4537
|
+
if (noMatches.length > 0) {
|
|
4538
|
+
return {
|
|
4539
|
+
ok: false,
|
|
4540
|
+
noMatches
|
|
4541
|
+
};
|
|
4542
|
+
}
|
|
4543
|
+
return {
|
|
4544
|
+
ok: true
|
|
4545
|
+
};
|
|
4320
4546
|
} catch (error) {
|
|
4321
4547
|
recordSpanException4(span, error);
|
|
4322
4548
|
span.end();
|
|
@@ -4413,7 +4639,7 @@ import dotenv from "dotenv";
|
|
|
4413
4639
|
import { Evt } from "evt";
|
|
4414
4640
|
import { fork } from "node:child_process";
|
|
4415
4641
|
import { dirname as dirname2, resolve as resolve2 } from "node:path";
|
|
4416
|
-
import
|
|
4642
|
+
import terminalLink3 from "terminal-link";
|
|
4417
4643
|
var BackgroundWorkerCoordinator = class {
|
|
4418
4644
|
constructor(baseURL) {
|
|
4419
4645
|
this.baseURL = baseURL;
|
|
@@ -4498,7 +4724,7 @@ var BackgroundWorkerCoordinator = class {
|
|
|
4498
4724
|
const logsUrl = `${this.baseURL}/runs/${execution.run.id}`;
|
|
4499
4725
|
const pipe = chalkGrey("|");
|
|
4500
4726
|
const bullet = chalkGrey("\u25CB");
|
|
4501
|
-
const link = chalkLink(
|
|
4727
|
+
const link = chalkLink(terminalLink3("View logs", logsUrl));
|
|
4502
4728
|
let timestampPrefix = chalkGrey(prettyPrintDate(payload.execution.attempt.startedAt));
|
|
4503
4729
|
const workerPrefix = chalkWorker(record.version);
|
|
4504
4730
|
const taskPrefix = chalkTask(execution.task.id);
|
|
@@ -5628,7 +5854,7 @@ import { execa as execa3 } from "execa";
|
|
|
5628
5854
|
import { applyEdits, modify } from "jsonc-parser";
|
|
5629
5855
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
5630
5856
|
import { join as join7, relative as relative4, resolve as resolve3 } from "node:path";
|
|
5631
|
-
import
|
|
5857
|
+
import terminalLink4 from "terminal-link";
|
|
5632
5858
|
import { z as z6 } from "zod";
|
|
5633
5859
|
|
|
5634
5860
|
// src/utilities/createFileFromTemplate.ts
|
|
@@ -5754,7 +5980,7 @@ async function _initCommand(dir, options) {
|
|
|
5754
5980
|
await writeConfigFile(dir, selectedProject, options, triggerDir);
|
|
5755
5981
|
await addConfigFileToTsConfig(dir, options);
|
|
5756
5982
|
await gitIgnoreDotTriggerDir(dir, options);
|
|
5757
|
-
const projectDashboard =
|
|
5983
|
+
const projectDashboard = terminalLink4(
|
|
5758
5984
|
"project dashboard",
|
|
5759
5985
|
`${authorization.dashboardUrl}/projects/v3/${selectedProject.externalRef}`
|
|
5760
5986
|
);
|
|
@@ -5767,13 +5993,13 @@ async function _initCommand(dir, options) {
|
|
|
5767
5993
|
);
|
|
5768
5994
|
log4.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
|
|
5769
5995
|
log4.info(
|
|
5770
|
-
` 3. Head over to our ${
|
|
5996
|
+
` 3. Head over to our ${terminalLink4(
|
|
5771
5997
|
"v3 docs",
|
|
5772
5998
|
"https://trigger.dev/docs/v3"
|
|
5773
5999
|
)} to learn more.`
|
|
5774
6000
|
);
|
|
5775
6001
|
log4.info(
|
|
5776
|
-
` 4. Need help? Join our ${
|
|
6002
|
+
` 4. Need help? Join our ${terminalLink4(
|
|
5777
6003
|
"Discord community",
|
|
5778
6004
|
"https://trigger.dev/discord"
|
|
5779
6005
|
)} or email us at ${chalk6.cyan("help@trigger.dev")}`
|
|
@@ -6025,7 +6251,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
6025
6251
|
throw new Error(`Failed to get projects: ${projectsResponse.error}`);
|
|
6026
6252
|
}
|
|
6027
6253
|
if (projectsResponse.data.length === 0) {
|
|
6028
|
-
const newProjectLink =
|
|
6254
|
+
const newProjectLink = terminalLink4(
|
|
6029
6255
|
"Create new project",
|
|
6030
6256
|
`${dashboardUrl}/projects/new?version=v3`
|
|
6031
6257
|
);
|