trigger.dev 0.0.0-v3-update-command-20240423145551 → 0.0.0-v3-prerelease-20240424094958
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 +1 -0
- package/dist/index.js +129 -160
- package/dist/index.js.map +1 -1
- package/dist/workers/dev/worker-facade.js +19 -13
- package/dist/workers/dev/worker-setup.js +5 -3
- package/dist/workers/prod/entry-point.js +6 -6
- package/dist/workers/prod/worker-facade.js +19 -15
- package/dist/workers/prod/worker-setup.js +3 -4
- package/package.json +4 -4
package/dist/Containerfile.prod
CHANGED
package/dist/index.js
CHANGED
|
@@ -777,16 +777,15 @@ var require_retry2 = __commonJS({
|
|
|
777
777
|
import { Command as Command2 } from "commander";
|
|
778
778
|
|
|
779
779
|
// src/commands/deploy.ts
|
|
780
|
-
import { intro as intro4, log as log5, outro as
|
|
780
|
+
import { intro as intro4, log as log5, outro as outro5 } from "@clack/prompts";
|
|
781
781
|
import { depot } from "@depot/cli";
|
|
782
782
|
import { context, trace as trace2 } from "@opentelemetry/api";
|
|
783
783
|
import {
|
|
784
784
|
TaskMetadataFailedToParseData,
|
|
785
785
|
detectDependencyVersion,
|
|
786
|
-
flattenAttributes as flattenAttributes2
|
|
787
|
-
recordSpanException as recordSpanException4
|
|
786
|
+
flattenAttributes as flattenAttributes2
|
|
788
787
|
} from "@trigger.dev/core/v3";
|
|
789
|
-
import
|
|
788
|
+
import { recordSpanException as recordSpanException4 } from "@trigger.dev/core/v3/workers";
|
|
790
789
|
import { Option as CommandOption } from "commander";
|
|
791
790
|
import { build as build2 } from "esbuild";
|
|
792
791
|
import { execa as execa2 } from "execa";
|
|
@@ -800,7 +799,7 @@ import invariant from "tiny-invariant";
|
|
|
800
799
|
import { z as z4 } from "zod";
|
|
801
800
|
|
|
802
801
|
// package.json
|
|
803
|
-
var version = "0.0.0-v3-
|
|
802
|
+
var version = "0.0.0-v3-prerelease-20240424094958";
|
|
804
803
|
var dependencies = {
|
|
805
804
|
"@clack/prompts": "^0.7.0",
|
|
806
805
|
"@depot/cli": "0.0.1-cli.2.55.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-
|
|
818
|
+
"@trigger.dev/core": "workspace:0.0.0-v3-prerelease-20240424094958",
|
|
820
819
|
"@types/degit": "^2.8.3",
|
|
821
820
|
chalk: "^5.2.0",
|
|
822
821
|
chokidar: "^3.5.3",
|
|
@@ -1140,7 +1139,8 @@ async function zodfetch(schema, url, requestInit) {
|
|
|
1140
1139
|
}
|
|
1141
1140
|
|
|
1142
1141
|
// src/cli/common.ts
|
|
1143
|
-
import { flattenAttributes
|
|
1142
|
+
import { flattenAttributes } from "@trigger.dev/core/v3";
|
|
1143
|
+
import { recordSpanException } from "@trigger.dev/core/v3/workers";
|
|
1144
1144
|
import { z } from "zod";
|
|
1145
1145
|
|
|
1146
1146
|
// src/telemetry/tracing.ts
|
|
@@ -1150,6 +1150,10 @@ import { Resource, detectResourcesSync, processDetectorSync } from "@opentelemet
|
|
|
1150
1150
|
import { NodeTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
|
|
1151
1151
|
import { FetchInstrumentation } from "@opentelemetry/instrumentation-fetch";
|
|
1152
1152
|
import { DiagConsoleLogger, DiagLogLevel, diag, trace } from "@opentelemetry/api";
|
|
1153
|
+
import {
|
|
1154
|
+
SEMRESATTRS_SERVICE_NAME,
|
|
1155
|
+
SEMRESATTRS_SERVICE_VERSION
|
|
1156
|
+
} from "@opentelemetry/semantic-conventions";
|
|
1153
1157
|
function initializeTracing() {
|
|
1154
1158
|
if (process.argv.includes("--skip-telemetry") || process.env.TRIGGER_DEV_SKIP_TELEMETRY) {
|
|
1155
1159
|
return;
|
|
@@ -1161,7 +1165,8 @@ function initializeTracing() {
|
|
|
1161
1165
|
detectors: [processDetectorSync]
|
|
1162
1166
|
}).merge(
|
|
1163
1167
|
new Resource({
|
|
1164
|
-
|
|
1168
|
+
[SEMRESATTRS_SERVICE_NAME]: "trigger.dev cli v3",
|
|
1169
|
+
[SEMRESATTRS_SERVICE_VERSION]: version
|
|
1165
1170
|
})
|
|
1166
1171
|
);
|
|
1167
1172
|
const traceProvider = new NodeTracerProvider({
|
|
@@ -1178,10 +1183,9 @@ function initializeTracing() {
|
|
|
1178
1183
|
});
|
|
1179
1184
|
const spanExporter = new OTLPTraceExporter({
|
|
1180
1185
|
url: "https://otel.baselime.io/v1",
|
|
1181
|
-
timeoutMillis:
|
|
1186
|
+
timeoutMillis: 5e3,
|
|
1182
1187
|
headers: {
|
|
1183
|
-
"x-api-key": "
|
|
1184
|
-
// this is a joke
|
|
1188
|
+
"x-api-key": "b6e0fbbaf8dc2524773d2152ae2e9eb5c7fbaa52"
|
|
1185
1189
|
}
|
|
1186
1190
|
});
|
|
1187
1191
|
const spanProcessor = new SimpleSpanProcessor(spanExporter);
|
|
@@ -1194,7 +1198,7 @@ function initializeTracing() {
|
|
|
1194
1198
|
}
|
|
1195
1199
|
var provider = initializeTracing();
|
|
1196
1200
|
function getTracer() {
|
|
1197
|
-
return trace.getTracer("trigger.dev cli", version);
|
|
1201
|
+
return trace.getTracer("trigger.dev cli v3", version);
|
|
1198
1202
|
}
|
|
1199
1203
|
|
|
1200
1204
|
// src/cli/common.ts
|
|
@@ -1366,6 +1370,18 @@ function prettyPrintDate(date = /* @__PURE__ */ new Date()) {
|
|
|
1366
1370
|
formattedDate += "." + ("00" + date.getMilliseconds()).slice(-3);
|
|
1367
1371
|
return formattedDate;
|
|
1368
1372
|
}
|
|
1373
|
+
function prettyError(header, body, footer) {
|
|
1374
|
+
const prefix = "Error: ";
|
|
1375
|
+
const indent = Array(prefix.length).fill(" ").join("");
|
|
1376
|
+
const spacing = "\n\n";
|
|
1377
|
+
const prettyPrefix = chalkError(prefix);
|
|
1378
|
+
const withIndents = (text3) => text3?.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
1379
|
+
const prettyBody = withIndents(body);
|
|
1380
|
+
const prettyFooter = withIndents(footer);
|
|
1381
|
+
log.error(
|
|
1382
|
+
`${prettyPrefix}${header}${prettyBody ? `${spacing}${prettyBody}` : ""}${prettyFooter ? `${spacing}${prettyFooter}` : ""}`
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1369
1385
|
function prettyWarning(header, body, footer) {
|
|
1370
1386
|
const prefix = "Warning: ";
|
|
1371
1387
|
const indent = Array(prefix.length).fill(" ").join("");
|
|
@@ -1528,14 +1544,23 @@ function createTaskFileImports(taskFiles) {
|
|
|
1528
1544
|
async function gatherTaskFiles(config) {
|
|
1529
1545
|
const taskFiles = [];
|
|
1530
1546
|
for (const triggerDir of config.triggerDirectories) {
|
|
1531
|
-
const files = await
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1547
|
+
const files = await gatherTaskFilesFromDir(triggerDir, triggerDir, config);
|
|
1548
|
+
taskFiles.push(...files);
|
|
1549
|
+
}
|
|
1550
|
+
return taskFiles;
|
|
1551
|
+
}
|
|
1552
|
+
async function gatherTaskFilesFromDir(dirPath, triggerDir, config) {
|
|
1553
|
+
const taskFiles = [];
|
|
1554
|
+
const files = await fs2.promises.readdir(dirPath, { withFileTypes: true });
|
|
1555
|
+
for (const file of files) {
|
|
1556
|
+
if (!file.isFile()) {
|
|
1557
|
+
const fullPath = join(dirPath, file.name);
|
|
1558
|
+
taskFiles.push(...await gatherTaskFilesFromDir(fullPath, triggerDir, config));
|
|
1559
|
+
} else {
|
|
1535
1560
|
if (!file.name.endsWith(".js") && !file.name.endsWith(".ts") && !file.name.endsWith(".jsx") && !file.name.endsWith(".tsx")) {
|
|
1536
1561
|
continue;
|
|
1537
1562
|
}
|
|
1538
|
-
const fullPath = join(
|
|
1563
|
+
const fullPath = join(dirPath, file.name);
|
|
1539
1564
|
const filePath = relative(config.projectDir, fullPath);
|
|
1540
1565
|
const importName = filePath.replace(/\..+$/, "").replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
1541
1566
|
const importPath = filePath.replace(/\\/g, "/");
|
|
@@ -1555,9 +1580,12 @@ async function getTriggerDirectories(dirPath) {
|
|
|
1555
1580
|
const entries = await fs2.promises.readdir(dirPath, { withFileTypes: true });
|
|
1556
1581
|
const triggerDirectories = [];
|
|
1557
1582
|
for (const entry of entries) {
|
|
1558
|
-
if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name))
|
|
1583
|
+
if (!entry.isDirectory() || IGNORED_DIRS.includes(entry.name) || entry.name.startsWith("."))
|
|
1559
1584
|
continue;
|
|
1560
1585
|
const fullPath = join(dirPath, entry.name);
|
|
1586
|
+
if (fullPath.endsWith("app/api/trigger")) {
|
|
1587
|
+
continue;
|
|
1588
|
+
}
|
|
1561
1589
|
if (entry.name === "trigger") {
|
|
1562
1590
|
triggerDirectories.push(fullPath);
|
|
1563
1591
|
}
|
|
@@ -1631,6 +1659,15 @@ async function getConfigPath(dir, fileName) {
|
|
|
1631
1659
|
});
|
|
1632
1660
|
return await findUp(fileName ? [fileName] : CONFIG_FILES, { cwd: dir });
|
|
1633
1661
|
}
|
|
1662
|
+
async function findFilePath(dir, fileName) {
|
|
1663
|
+
const result = await findUp([fileName], { cwd: dir });
|
|
1664
|
+
logger.debug("Searched for the file", {
|
|
1665
|
+
dir,
|
|
1666
|
+
fileName,
|
|
1667
|
+
result
|
|
1668
|
+
});
|
|
1669
|
+
return result;
|
|
1670
|
+
}
|
|
1634
1671
|
async function readConfig(dir, options) {
|
|
1635
1672
|
const absoluteDir = path2.resolve(process.cwd(), dir);
|
|
1636
1673
|
const configPath = await getConfigPath(dir, options?.configFile);
|
|
@@ -1683,6 +1720,7 @@ async function resolveConfig(path7, config) {
|
|
|
1683
1720
|
config.triggerDirectories = await findTriggerDirectories(path7);
|
|
1684
1721
|
}
|
|
1685
1722
|
config.triggerDirectories = resolveTriggerDirectories(config.triggerDirectories);
|
|
1723
|
+
logger.debug("Resolved trigger directories", { triggerDirectories: config.triggerDirectories });
|
|
1686
1724
|
if (!config.triggerUrl) {
|
|
1687
1725
|
config.triggerUrl = CLOUD_API_URL;
|
|
1688
1726
|
}
|
|
@@ -1690,7 +1728,7 @@ async function resolveConfig(path7, config) {
|
|
|
1690
1728
|
config.projectDir = path7;
|
|
1691
1729
|
}
|
|
1692
1730
|
if (!config.tsconfigPath) {
|
|
1693
|
-
config.tsconfigPath = await
|
|
1731
|
+
config.tsconfigPath = await findFilePath(path7, "tsconfig.json");
|
|
1694
1732
|
}
|
|
1695
1733
|
return config;
|
|
1696
1734
|
}
|
|
@@ -1859,8 +1897,8 @@ async function setPackageJsonDeps(path7, deps) {
|
|
|
1859
1897
|
}
|
|
1860
1898
|
|
|
1861
1899
|
// src/commands/login.ts
|
|
1862
|
-
import { intro as intro2, log as log3, outro as
|
|
1863
|
-
import { recordSpanException as recordSpanException3 } from "@trigger.dev/core/v3";
|
|
1900
|
+
import { intro as intro2, log as log3, outro as outro3, select } from "@clack/prompts";
|
|
1901
|
+
import { recordSpanException as recordSpanException3 } from "@trigger.dev/core/v3/workers";
|
|
1864
1902
|
|
|
1865
1903
|
// ../../node_modules/.pnpm/open@10.0.3/node_modules/open/index.js
|
|
1866
1904
|
import process6 from "node:process";
|
|
@@ -2407,10 +2445,10 @@ async function pRetry(input, options) {
|
|
|
2407
2445
|
import { z as z3 } from "zod";
|
|
2408
2446
|
|
|
2409
2447
|
// src/commands/whoami.ts
|
|
2410
|
-
import { intro, note } from "@clack/prompts";
|
|
2448
|
+
import { intro, note, outro as outro2 } from "@clack/prompts";
|
|
2411
2449
|
|
|
2412
2450
|
// src/utilities/session.ts
|
|
2413
|
-
import { recordSpanException as recordSpanException2 } from "@trigger.dev/core/v3";
|
|
2451
|
+
import { recordSpanException as recordSpanException2 } from "@trigger.dev/core/v3/workers";
|
|
2414
2452
|
var tracer2 = getTracer();
|
|
2415
2453
|
async function isLoggedIn(profile = "default") {
|
|
2416
2454
|
return await tracer2.startActiveSpan("isLoggedIn", async (span) => {
|
|
@@ -2492,9 +2530,16 @@ async function whoAmI(options, embedded = false) {
|
|
|
2492
2530
|
if (authentication.error === "fetch failed") {
|
|
2493
2531
|
loadingSpinner.stop("Fetch failed. Platform down?");
|
|
2494
2532
|
} else {
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2533
|
+
if (embedded) {
|
|
2534
|
+
loadingSpinner.stop(
|
|
2535
|
+
`Failed to check account details. You may want to run \`trigger.dev logout --profile ${options?.profile ?? "default"}\` and try again.`
|
|
2536
|
+
);
|
|
2537
|
+
} else {
|
|
2538
|
+
loadingSpinner.stop(
|
|
2539
|
+
`You must login first. Use \`trigger.dev login --profile ${options?.profile ?? "default"}\` to login.`
|
|
2540
|
+
);
|
|
2541
|
+
outro2("Whoami failed");
|
|
2542
|
+
}
|
|
2498
2543
|
}
|
|
2499
2544
|
return {
|
|
2500
2545
|
success: false,
|
|
@@ -2590,9 +2635,13 @@ async function login(options) {
|
|
|
2590
2635
|
skipTelemetry: !span.isRecording(),
|
|
2591
2636
|
logLevel: logger.loggerLevel
|
|
2592
2637
|
},
|
|
2593
|
-
|
|
2638
|
+
true
|
|
2594
2639
|
);
|
|
2595
2640
|
if (!whoAmIResult.success) {
|
|
2641
|
+
prettyError("Whoami failed", whoAmIResult.error);
|
|
2642
|
+
if (!opts.embedded) {
|
|
2643
|
+
outro3("Login failed");
|
|
2644
|
+
}
|
|
2596
2645
|
throw new Error(whoAmIResult.error);
|
|
2597
2646
|
} else {
|
|
2598
2647
|
if (!opts.embedded) {
|
|
@@ -2611,7 +2660,7 @@ async function login(options) {
|
|
|
2611
2660
|
initialValue: false
|
|
2612
2661
|
});
|
|
2613
2662
|
if (continueOption !== true) {
|
|
2614
|
-
|
|
2663
|
+
outro3("Already logged in");
|
|
2615
2664
|
span.setAttributes({
|
|
2616
2665
|
"cli.userId": whoAmIResult.data.userId,
|
|
2617
2666
|
"cli.email": whoAmIResult.data.email,
|
|
@@ -2692,7 +2741,7 @@ ${chalkLink(authorizationCodeResult.url)}`
|
|
|
2692
2741
|
if (opts.embedded) {
|
|
2693
2742
|
log3.step("Logged in successfully");
|
|
2694
2743
|
} else {
|
|
2695
|
-
|
|
2744
|
+
outro3("Logged in successfully");
|
|
2696
2745
|
}
|
|
2697
2746
|
span.end();
|
|
2698
2747
|
return {
|
|
@@ -2794,7 +2843,7 @@ function bundleTriggerDevCore(buildIdentifier, tsconfigPath) {
|
|
|
2794
2843
|
name: "trigger-bundle-core",
|
|
2795
2844
|
setup(build3) {
|
|
2796
2845
|
build3.onResolve({ filter: /.*/ }, (args) => {
|
|
2797
|
-
if (args.path
|
|
2846
|
+
if (!args.path.startsWith("@trigger.dev/core/v3")) {
|
|
2798
2847
|
return void 0;
|
|
2799
2848
|
}
|
|
2800
2849
|
const triggerSdkPath = __require.resolve("@trigger.dev/sdk/v3", { paths: [process.cwd()] });
|
|
@@ -2802,17 +2851,14 @@ function bundleTriggerDevCore(buildIdentifier, tsconfigPath) {
|
|
|
2802
2851
|
...args,
|
|
2803
2852
|
triggerSdkPath
|
|
2804
2853
|
});
|
|
2805
|
-
const resolvedPath = __require.resolve(
|
|
2854
|
+
const resolvedPath = __require.resolve(args.path, {
|
|
2806
2855
|
paths: [triggerSdkPath]
|
|
2807
2856
|
});
|
|
2808
|
-
logger.debug(
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
resolvedPath
|
|
2814
|
-
}
|
|
2815
|
-
);
|
|
2857
|
+
logger.debug(`[${buildIdentifier}][trigger-bundle-core] Externalizing ${args.path}`, {
|
|
2858
|
+
...args,
|
|
2859
|
+
triggerSdkPath,
|
|
2860
|
+
resolvedPath
|
|
2861
|
+
});
|
|
2816
2862
|
return {
|
|
2817
2863
|
path: resolvedPath,
|
|
2818
2864
|
external: false
|
|
@@ -3402,7 +3448,7 @@ function cliRootPath() {
|
|
|
3402
3448
|
}
|
|
3403
3449
|
|
|
3404
3450
|
// src/commands/update.ts
|
|
3405
|
-
import { confirm, intro as intro3, isCancel, log as log4, outro as
|
|
3451
|
+
import { confirm, intro as intro3, isCancel, log as log4, outro as outro4 } from "@clack/prompts";
|
|
3406
3452
|
import { join as join5, resolve as resolve2 } from "path";
|
|
3407
3453
|
var UpdateCommandOptions = CommonCommandOptions.pick({
|
|
3408
3454
|
logLevel: true,
|
|
@@ -3458,7 +3504,7 @@ Latest: ${newCliVersion}`,
|
|
|
3458
3504
|
const versionMismatches = getVersionMismatches(triggerDependencies, cliVersion);
|
|
3459
3505
|
if (versionMismatches.length === 0) {
|
|
3460
3506
|
if (!embedded) {
|
|
3461
|
-
|
|
3507
|
+
outro4(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
|
|
3462
3508
|
}
|
|
3463
3509
|
return;
|
|
3464
3510
|
}
|
|
@@ -3467,7 +3513,7 @@ Latest: ${newCliVersion}`,
|
|
|
3467
3513
|
"We recommend pinned versions for guaranteed compatibility"
|
|
3468
3514
|
);
|
|
3469
3515
|
if (!process.stdout.isTTY) {
|
|
3470
|
-
|
|
3516
|
+
outro4("Deploy failed");
|
|
3471
3517
|
console.log(
|
|
3472
3518
|
`ERROR: Version mismatch detected while running in CI. This won't end well. Aborting.
|
|
3473
3519
|
|
|
@@ -3490,7 +3536,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
|
|
|
3490
3536
|
}
|
|
3491
3537
|
if (!userWantsToUpdate) {
|
|
3492
3538
|
if (requireUpdate) {
|
|
3493
|
-
|
|
3539
|
+
outro4("You shall not pass!");
|
|
3494
3540
|
logger.log(
|
|
3495
3541
|
`${chalkError(
|
|
3496
3542
|
"X Error:"
|
|
@@ -3500,7 +3546,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
|
|
|
3500
3546
|
process.exit(1);
|
|
3501
3547
|
}
|
|
3502
3548
|
if (!embedded) {
|
|
3503
|
-
|
|
3549
|
+
outro4("You've been warned!");
|
|
3504
3550
|
}
|
|
3505
3551
|
return;
|
|
3506
3552
|
}
|
|
@@ -3539,7 +3585,7 @@ ${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
|
|
|
3539
3585
|
process.removeListener("exit", exitHandler);
|
|
3540
3586
|
await removeFile(packageJsonBackupPath);
|
|
3541
3587
|
if (!embedded) {
|
|
3542
|
-
|
|
3588
|
+
outro4(
|
|
3543
3589
|
`Packages updated${newCliVersion ? " ..but you should really update your CLI too!" : ""}`
|
|
3544
3590
|
);
|
|
3545
3591
|
}
|
|
@@ -3603,7 +3649,6 @@ async function getPackageJson(absoluteProjectPath) {
|
|
|
3603
3649
|
var DeployCommandOptions = CommonCommandOptions.extend({
|
|
3604
3650
|
skipTypecheck: z4.boolean().default(false),
|
|
3605
3651
|
skipDeploy: z4.boolean().default(false),
|
|
3606
|
-
ignoreEnvVarCheck: z4.boolean().default(false),
|
|
3607
3652
|
env: z4.enum(["prod", "staging"]),
|
|
3608
3653
|
loadImage: z4.boolean().default(false),
|
|
3609
3654
|
buildPlatform: z4.enum(["linux/amd64", "linux/arm64"]).default("linux/amd64"),
|
|
@@ -3623,10 +3668,7 @@ function configureDeployCommand(program2) {
|
|
|
3623
3668
|
"-e, --env <env>",
|
|
3624
3669
|
"Deploy to a specific environment (currently only prod and staging are supported)",
|
|
3625
3670
|
"prod"
|
|
3626
|
-
).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option("--skip-update-check", "Skip checking for @trigger.dev package updates").option(
|
|
3627
|
-
"--ignore-env-var-check",
|
|
3628
|
-
"Detected missing environment variables won't block deployment"
|
|
3629
|
-
).option("-c, --config <config file>", "The name of the config file, found at [path]").option(
|
|
3671
|
+
).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option("--skip-update-check", "Skip checking for @trigger.dev package updates").option("-c, --config <config file>", "The name of the config file, found at [path]").option(
|
|
3630
3672
|
"-p, --project-ref <project ref>",
|
|
3631
3673
|
"The project ref. Required if there is no config file. This will override the project specified in the config file."
|
|
3632
3674
|
)
|
|
@@ -3650,6 +3692,11 @@ function configureDeployCommand(program2) {
|
|
|
3650
3692
|
"--tag <tag>",
|
|
3651
3693
|
"(Coming soon) Specify the tag to use when pushing the image to the registry"
|
|
3652
3694
|
).hideHelp()
|
|
3695
|
+
).addOption(
|
|
3696
|
+
new CommandOption(
|
|
3697
|
+
"--ignore-env-var-check",
|
|
3698
|
+
"(deprecated) Detected missing environment variables won't block deployment"
|
|
3699
|
+
).hideHelp()
|
|
3653
3700
|
).addOption(new CommandOption("-D, --skip-deploy", "Skip deploying the image").hideHelp()).addOption(
|
|
3654
3701
|
new CommandOption("--load-image", "Load the built image into your local docker").hideHelp()
|
|
3655
3702
|
).addOption(
|
|
@@ -3736,15 +3783,6 @@ async function _deployCommand(dir, options) {
|
|
|
3736
3783
|
resolvedConfig.status === "file" ? resolvedConfig.path : void 0
|
|
3737
3784
|
);
|
|
3738
3785
|
logger.debug("Compilation result", { compilation });
|
|
3739
|
-
if (compilation.envVars.length > 0) {
|
|
3740
|
-
await checkEnvVars(
|
|
3741
|
-
compilation.envVars ?? [],
|
|
3742
|
-
resolvedConfig.config,
|
|
3743
|
-
options,
|
|
3744
|
-
environmentClient,
|
|
3745
|
-
authorization.dashboardUrl
|
|
3746
|
-
);
|
|
3747
|
-
}
|
|
3748
3786
|
const deploymentResponse = await environmentClient.initializeDeployment({
|
|
3749
3787
|
contentHash: compilation.contentHash,
|
|
3750
3788
|
userId: authorization.userId
|
|
@@ -3887,11 +3925,11 @@ async function _deployCommand(dir, options) {
|
|
|
3887
3925
|
await preExitTasks();
|
|
3888
3926
|
const taskCount = finishedDeployment.worker?.tasks.length ?? 0;
|
|
3889
3927
|
if (taskCount === 0) {
|
|
3890
|
-
|
|
3928
|
+
outro5(
|
|
3891
3929
|
`Version ${version2} deployed with no detected tasks. Please make sure you are exporting tasks in your project. ${deploymentLink}`
|
|
3892
3930
|
);
|
|
3893
3931
|
} else {
|
|
3894
|
-
|
|
3932
|
+
outro5(
|
|
3895
3933
|
`Version ${version2} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${deploymentLink}`
|
|
3896
3934
|
);
|
|
3897
3935
|
}
|
|
@@ -4051,55 +4089,11 @@ async function failDeploy(shortCode, errorSummary, logs, deploymentSpinner, warn
|
|
|
4051
4089
|
printWarnings(warnings);
|
|
4052
4090
|
printErrors(errors);
|
|
4053
4091
|
checkLogsForErrors(logs);
|
|
4054
|
-
|
|
4092
|
+
outro5(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
|
|
4055
4093
|
} else {
|
|
4056
|
-
|
|
4094
|
+
outro5(`${chalkError("Error:")} ${errorSummary}.`);
|
|
4057
4095
|
}
|
|
4058
4096
|
}
|
|
4059
|
-
async function checkEnvVars(envVars, config, options, environmentClient, apiUrl) {
|
|
4060
|
-
return await tracer.startActiveSpan("detectEnvVars", async (span) => {
|
|
4061
|
-
try {
|
|
4062
|
-
span.setAttribute("envVars.check", envVars);
|
|
4063
|
-
const environmentVariablesSpinner = spinner();
|
|
4064
|
-
environmentVariablesSpinner.start("Checking environment variables");
|
|
4065
|
-
const environmentVariables = await environmentClient.getEnvironmentVariables(config.project);
|
|
4066
|
-
if (!environmentVariables.success) {
|
|
4067
|
-
environmentVariablesSpinner.stop(`Failed to fetch environment variables, skipping check`);
|
|
4068
|
-
} else {
|
|
4069
|
-
const missingEnvironmentVariables = envVars.filter(
|
|
4070
|
-
(envVar) => environmentVariables.data.variables[envVar] === void 0
|
|
4071
|
-
);
|
|
4072
|
-
if (missingEnvironmentVariables.length > 0) {
|
|
4073
|
-
environmentVariablesSpinner.stop(
|
|
4074
|
-
`Found missing env vars in ${options.env}: ${arrayToSentence(
|
|
4075
|
-
missingEnvironmentVariables
|
|
4076
|
-
)}. ${options.ignoreEnvVarCheck ? "Continuing deployment because of --ignore-env-var-check. " : "Aborting deployment. "}${chalk5.bgBlueBright(
|
|
4077
|
-
terminalLink2(
|
|
4078
|
-
"Manage env vars",
|
|
4079
|
-
`${apiUrl}/projects/v3/${config.project}/environment-variables`
|
|
4080
|
-
)
|
|
4081
|
-
)}`
|
|
4082
|
-
);
|
|
4083
|
-
span.setAttributes({
|
|
4084
|
-
"envVars.missing": missingEnvironmentVariables
|
|
4085
|
-
});
|
|
4086
|
-
if (!options.ignoreEnvVarCheck) {
|
|
4087
|
-
throw new SkipLoggingError("Found missing environment variables");
|
|
4088
|
-
} else {
|
|
4089
|
-
span.end();
|
|
4090
|
-
return;
|
|
4091
|
-
}
|
|
4092
|
-
}
|
|
4093
|
-
environmentVariablesSpinner.stop(`Environment variable check passed`);
|
|
4094
|
-
}
|
|
4095
|
-
span.end();
|
|
4096
|
-
} catch (e) {
|
|
4097
|
-
recordSpanException4(span, e);
|
|
4098
|
-
span.end();
|
|
4099
|
-
throw e;
|
|
4100
|
-
}
|
|
4101
|
-
});
|
|
4102
|
-
}
|
|
4103
4097
|
async function waitForDeploymentToFinish(deploymentId, client, timeoutInSeconds = 60) {
|
|
4104
4098
|
return tracer.startActiveSpan("waitForDeploymentToFinish", async (span) => {
|
|
4105
4099
|
try {
|
|
@@ -4561,18 +4555,11 @@ If this is unexpected you should check your ${terminalLink2(
|
|
|
4561
4555
|
contentHasher.update(Buffer.from(workerOutputFile.text));
|
|
4562
4556
|
contentHasher.update(Buffer.from(JSON.stringify(dependencies2)));
|
|
4563
4557
|
const contentHash = contentHasher.digest("hex");
|
|
4564
|
-
const workerSetupEnvVars = await findAllEnvironmentVariableReferencesInFile(workerSetupPath);
|
|
4565
|
-
const workerFacadeEnvVars = findAllEnvironmentVariableReferences(workerContents);
|
|
4566
|
-
const envVars = findAllEnvironmentVariableReferences(workerOutputFile.text);
|
|
4567
|
-
const finalEnvVars = envVars.filter(
|
|
4568
|
-
(envVar) => !workerFacadeEnvVars.includes(envVar) && !workerSetupEnvVars.includes(envVar)
|
|
4569
|
-
);
|
|
4570
4558
|
span.setAttributes({
|
|
4571
|
-
contentHash
|
|
4572
|
-
envVars: finalEnvVars
|
|
4559
|
+
contentHash
|
|
4573
4560
|
});
|
|
4574
4561
|
span.end();
|
|
4575
|
-
return { path: tempDir, contentHash
|
|
4562
|
+
return { path: tempDir, contentHash };
|
|
4576
4563
|
} catch (e) {
|
|
4577
4564
|
recordSpanException4(span, e);
|
|
4578
4565
|
span.end();
|
|
@@ -4837,36 +4824,14 @@ async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
|
|
|
4837
4824
|
logger.debug(`Writing docker config to ${dockerConfigPath}`);
|
|
4838
4825
|
return tmpDir;
|
|
4839
4826
|
}
|
|
4840
|
-
async function findAllEnvironmentVariableReferencesInFile(filePath) {
|
|
4841
|
-
const fileContents = await readFile2(filePath, "utf-8");
|
|
4842
|
-
return findAllEnvironmentVariableReferences(fileContents);
|
|
4843
|
-
}
|
|
4844
|
-
var IGNORED_ENV_VARS = ["NODE_ENV", "SHELL", "HOME", "PWD", "LOGNAME", "USER", "PATH", "DEBUG"];
|
|
4845
|
-
function findAllEnvironmentVariableReferences(code) {
|
|
4846
|
-
const regex = /\bprocess\.env\.([a-zA-Z_][a-zA-Z0-9_]*)\b/g;
|
|
4847
|
-
const matches = code.matchAll(regex);
|
|
4848
|
-
const matchesArray = Array.from(matches, (match) => match[1]).filter(Boolean);
|
|
4849
|
-
const filteredMatches = matchesArray.filter((match) => !IGNORED_ENV_VARS.includes(match));
|
|
4850
|
-
return Array.from(new Set(filteredMatches));
|
|
4851
|
-
}
|
|
4852
|
-
function arrayToSentence(items) {
|
|
4853
|
-
if (items.length === 1 && typeof items[0] === "string") {
|
|
4854
|
-
return items[0];
|
|
4855
|
-
}
|
|
4856
|
-
if (items.length === 2) {
|
|
4857
|
-
return `${items[0]} and ${items[1]}`;
|
|
4858
|
-
}
|
|
4859
|
-
return `${items.slice(0, -1).join(", ")}, and ${items[items.length - 1]}`;
|
|
4860
|
-
}
|
|
4861
4827
|
|
|
4862
4828
|
// src/commands/dev.tsx
|
|
4863
4829
|
import {
|
|
4864
|
-
ZodMessageHandler as ZodMessageHandler2,
|
|
4865
|
-
ZodMessageSender as ZodMessageSender2,
|
|
4866
4830
|
clientWebsocketMessages,
|
|
4867
4831
|
detectDependencyVersion as detectDependencyVersion2,
|
|
4868
4832
|
serverWebsocketMessages
|
|
4869
4833
|
} from "@trigger.dev/core/v3";
|
|
4834
|
+
import { ZodMessageHandler as ZodMessageHandler2, ZodMessageSender as ZodMessageSender2 } from "@trigger.dev/core/v3/zodMessageHandler";
|
|
4870
4835
|
import { watch } from "chokidar";
|
|
4871
4836
|
import { context as context2 } from "esbuild";
|
|
4872
4837
|
import { render, useInput } from "ink";
|
|
@@ -4901,13 +4866,12 @@ var TaskMetadataParseError = class extends Error {
|
|
|
4901
4866
|
import {
|
|
4902
4867
|
SemanticInternalAttributes,
|
|
4903
4868
|
TaskRunErrorCodes,
|
|
4904
|
-
ZodMessageHandler,
|
|
4905
|
-
ZodMessageSender,
|
|
4906
4869
|
childToWorkerMessages,
|
|
4907
4870
|
correctErrorStackTrace,
|
|
4908
4871
|
formatDurationMilliseconds,
|
|
4909
4872
|
workerToChildMessages
|
|
4910
4873
|
} from "@trigger.dev/core/v3";
|
|
4874
|
+
import { ZodMessageHandler, ZodMessageSender } from "@trigger.dev/core/v3/zodMessageHandler";
|
|
4911
4875
|
import dotenv from "dotenv";
|
|
4912
4876
|
import { Evt } from "evt";
|
|
4913
4877
|
import { fork } from "node:child_process";
|
|
@@ -5808,9 +5772,6 @@ function useDev({
|
|
|
5808
5772
|
logger.log(chalkGrey("\u25CB Building background worker\u2026"));
|
|
5809
5773
|
}
|
|
5810
5774
|
const metaOutputKey = join7("out", `stdin.js`).replace(/\\/g, "/");
|
|
5811
|
-
logger.debug("Metafile", {
|
|
5812
|
-
metafileOutputs: JSON.stringify(result.metafile?.outputs)
|
|
5813
|
-
});
|
|
5814
5775
|
const metaOutput = result.metafile.outputs[metaOutputKey];
|
|
5815
5776
|
if (!metaOutput) {
|
|
5816
5777
|
throw new Error(`Could not find metafile`);
|
|
@@ -5864,8 +5825,15 @@ function useDev({
|
|
|
5864
5825
|
latestWorkerContentHash = contentHash;
|
|
5865
5826
|
let packageVersion;
|
|
5866
5827
|
const taskResources = [];
|
|
5867
|
-
if (!backgroundWorker.tasks) {
|
|
5868
|
-
|
|
5828
|
+
if (!backgroundWorker.tasks || backgroundWorker.tasks.length === 0) {
|
|
5829
|
+
logger.log(
|
|
5830
|
+
`${chalkError(
|
|
5831
|
+
"X Error:"
|
|
5832
|
+
)} Worker failed to build: no tasks found. Searched in ${config.triggerDirectories.join(
|
|
5833
|
+
", "
|
|
5834
|
+
)}`
|
|
5835
|
+
);
|
|
5836
|
+
return;
|
|
5869
5837
|
}
|
|
5870
5838
|
for (const task of backgroundWorker.tasks) {
|
|
5871
5839
|
taskResources.push(task);
|
|
@@ -5884,6 +5852,9 @@ function useDev({
|
|
|
5884
5852
|
);
|
|
5885
5853
|
return;
|
|
5886
5854
|
}
|
|
5855
|
+
logger.debug("Creating background worker with tasks", {
|
|
5856
|
+
tasks: taskResources
|
|
5857
|
+
});
|
|
5887
5858
|
const backgroundWorkerBody = {
|
|
5888
5859
|
localOnly: true,
|
|
5889
5860
|
metadata: {
|
|
@@ -5970,7 +5941,7 @@ ${chalkError("X Error:")} The package ${chalkPurple(
|
|
|
5970
5941
|
}
|
|
5971
5942
|
const throttledRebuild = pDebounce(runBuild, 250, { before: true });
|
|
5972
5943
|
const taskFileWatcher = watch(
|
|
5973
|
-
config.triggerDirectories.map((triggerDir) => `${triggerDir}
|
|
5944
|
+
config.triggerDirectories.map((triggerDir) => `${triggerDir}/**/*.ts`),
|
|
5974
5945
|
{
|
|
5975
5946
|
ignoreInitial: true
|
|
5976
5947
|
}
|
|
@@ -6121,13 +6092,11 @@ async function findPnpmNodeModulesPath() {
|
|
|
6121
6092
|
}
|
|
6122
6093
|
|
|
6123
6094
|
// src/commands/init.ts
|
|
6124
|
-
import { intro as intro5, isCancel as isCancel2, log as log6, outro as
|
|
6095
|
+
import { intro as intro5, isCancel as isCancel2, log as log6, outro as outro6, select as select2, text } from "@clack/prompts";
|
|
6125
6096
|
import { context as context3, trace as trace3 } from "@opentelemetry/api";
|
|
6126
|
-
import {
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
} from "@trigger.dev/core/v3";
|
|
6130
|
-
import chalk6 from "chalk";
|
|
6097
|
+
import { flattenAttributes as flattenAttributes3 } from "@trigger.dev/core/v3";
|
|
6098
|
+
import { recordSpanException as recordSpanException5 } from "@trigger.dev/core/v3/workers";
|
|
6099
|
+
import chalk5 from "chalk";
|
|
6131
6100
|
import { execa as execa3 } from "execa";
|
|
6132
6101
|
import { applyEdits, modify } from "jsonc-parser";
|
|
6133
6102
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
@@ -6231,7 +6200,7 @@ async function _initCommand(dir, options) {
|
|
|
6231
6200
|
if (!options.overrideConfig) {
|
|
6232
6201
|
try {
|
|
6233
6202
|
const result = await readConfig(dir);
|
|
6234
|
-
|
|
6203
|
+
outro6(
|
|
6235
6204
|
result.status === "file" ? `Project already initialized: Found config file at ${result.path}. Pass --override-config to override` : "Project already initialized"
|
|
6236
6205
|
);
|
|
6237
6206
|
return;
|
|
@@ -6265,7 +6234,7 @@ async function _initCommand(dir, options) {
|
|
|
6265
6234
|
log6.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
|
|
6266
6235
|
log6.info("Next steps:");
|
|
6267
6236
|
log6.info(
|
|
6268
|
-
` 1. To start developing, run ${
|
|
6237
|
+
` 1. To start developing, run ${chalk5.green(
|
|
6269
6238
|
`npx trigger.dev@${options.tag} dev`
|
|
6270
6239
|
)} in your project directory`
|
|
6271
6240
|
);
|
|
@@ -6280,9 +6249,9 @@ async function _initCommand(dir, options) {
|
|
|
6280
6249
|
` 4. Need help? Join our ${terminalLink4(
|
|
6281
6250
|
"Discord community",
|
|
6282
6251
|
"https://trigger.dev/discord"
|
|
6283
|
-
)} or email us at ${
|
|
6252
|
+
)} or email us at ${chalk5.cyan("help@trigger.dev")}`
|
|
6284
6253
|
);
|
|
6285
|
-
|
|
6254
|
+
outro6(`Project initialized successfully. Happy coding!`);
|
|
6286
6255
|
}
|
|
6287
6256
|
async function createTriggerDir(dir, options) {
|
|
6288
6257
|
return await tracer.startActiveSpan("createTriggerDir", async (span) => {
|
|
@@ -6533,7 +6502,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
6533
6502
|
"Create new project",
|
|
6534
6503
|
`${dashboardUrl}/projects/new?version=v3`
|
|
6535
6504
|
);
|
|
6536
|
-
|
|
6505
|
+
outro6(`You don't have any projects yet. ${newProjectLink}`);
|
|
6537
6506
|
throw new SkipCommandError();
|
|
6538
6507
|
}
|
|
6539
6508
|
const selectedProject = await select2({
|
|
@@ -6596,7 +6565,7 @@ async function logout(options) {
|
|
|
6596
6565
|
}
|
|
6597
6566
|
|
|
6598
6567
|
// src/commands/list-profiles.ts
|
|
6599
|
-
import { log as log7, outro as
|
|
6568
|
+
import { log as log7, outro as outro7 } from "@clack/prompts";
|
|
6600
6569
|
var ListProfilesOptions = CommonCommandOptions;
|
|
6601
6570
|
function configureListProfilesCommand(program2) {
|
|
6602
6571
|
return program2.command("list-profiles").description("List all of your CLI profiles").option(
|
|
@@ -6627,7 +6596,7 @@ async function listProfiles(options) {
|
|
|
6627
6596
|
const profileConfig = authConfig[profile];
|
|
6628
6597
|
log7.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
|
|
6629
6598
|
}
|
|
6630
|
-
|
|
6599
|
+
outro7("Retrieve account info by running whoami --profile <profile>");
|
|
6631
6600
|
}
|
|
6632
6601
|
|
|
6633
6602
|
// src/cli/index.ts
|