trigger.dev 3.0.0-beta.36 → 3.0.0-beta.38
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 +91 -68
- package/dist/index.js.map +1 -1
- package/dist/workers/dev/worker-facade.js +19 -3
- package/dist/workers/dev/worker-setup.js +1 -1
- package/dist/workers/prod/entry-point.js +94 -101
- package/dist/workers/prod/worker-facade.js +43 -11
- package/dist/workers/prod/worker-setup.js +1 -1
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -799,7 +799,7 @@ import invariant from "tiny-invariant";
|
|
|
799
799
|
import { z as z4 } from "zod";
|
|
800
800
|
|
|
801
801
|
// package.json
|
|
802
|
-
var version = "3.0.0-beta.
|
|
802
|
+
var version = "3.0.0-beta.38";
|
|
803
803
|
var dependencies = {
|
|
804
804
|
"@anatine/esbuild-decorators": "^0.2.19",
|
|
805
805
|
"@clack/prompts": "^0.7.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:3.0.0-beta.
|
|
819
|
+
"@trigger.dev/core": "workspace:3.0.0-beta.38",
|
|
820
820
|
"@types/degit": "^2.8.3",
|
|
821
821
|
chalk: "^5.2.0",
|
|
822
822
|
chokidar: "^3.5.3",
|
|
@@ -913,7 +913,7 @@ var package_default = {
|
|
|
913
913
|
tsup: "^8.0.1",
|
|
914
914
|
"type-fest": "^3.6.0",
|
|
915
915
|
typescript: "^5.3.3",
|
|
916
|
-
vitest: "^
|
|
916
|
+
vitest: "^1.6.0",
|
|
917
917
|
"xdg-app-paths": "^8.3.0"
|
|
918
918
|
},
|
|
919
919
|
scripts: {
|
|
@@ -928,7 +928,8 @@ var package_default = {
|
|
|
928
928
|
"dev:test": "nodemon -w src/Containerfile.prod -x npm run build:prod-containerfile",
|
|
929
929
|
clean: "rimraf dist",
|
|
930
930
|
start: "node dist/index.js",
|
|
931
|
-
test: "vitest"
|
|
931
|
+
test: "vitest",
|
|
932
|
+
"test:e2e": "vitest --run -c e2e/vite.config.js"
|
|
932
933
|
},
|
|
933
934
|
dependencies,
|
|
934
935
|
engines: {
|
|
@@ -1185,55 +1186,6 @@ import {
|
|
|
1185
1186
|
SEMRESATTRS_SERVICE_NAME,
|
|
1186
1187
|
SEMRESATTRS_SERVICE_VERSION
|
|
1187
1188
|
} from "@opentelemetry/semantic-conventions";
|
|
1188
|
-
function initializeTracing() {
|
|
1189
|
-
if (process.argv.includes("--skip-telemetry") || process.env.TRIGGER_DEV_SKIP_TELEMETRY) {
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
if (process.env.OTEL_INTERNAL_DIAG_DEBUG) {
|
|
1193
|
-
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
|
1194
|
-
}
|
|
1195
|
-
const resource = detectResourcesSync({
|
|
1196
|
-
detectors: [processDetectorSync]
|
|
1197
|
-
}).merge(
|
|
1198
|
-
new Resource({
|
|
1199
|
-
[SEMRESATTRS_SERVICE_NAME]: "trigger.dev cli v3",
|
|
1200
|
-
[SEMRESATTRS_SERVICE_VERSION]: version
|
|
1201
|
-
})
|
|
1202
|
-
);
|
|
1203
|
-
const traceProvider = new NodeTracerProvider({
|
|
1204
|
-
forceFlushTimeoutMillis: 500,
|
|
1205
|
-
resource,
|
|
1206
|
-
spanLimits: {
|
|
1207
|
-
attributeCountLimit: 1e3,
|
|
1208
|
-
attributeValueLengthLimit: 1e3,
|
|
1209
|
-
eventCountLimit: 100,
|
|
1210
|
-
attributePerEventCountLimit: 100,
|
|
1211
|
-
linkCountLimit: 10,
|
|
1212
|
-
attributePerLinkCountLimit: 100
|
|
1213
|
-
}
|
|
1214
|
-
});
|
|
1215
|
-
const spanExporter = new OTLPTraceExporter({
|
|
1216
|
-
url: "https://otel.baselime.io/v1",
|
|
1217
|
-
timeoutMillis: 5e3,
|
|
1218
|
-
headers: {
|
|
1219
|
-
"x-api-key": "b6e0fbbaf8dc2524773d2152ae2e9eb5c7fbaa52"
|
|
1220
|
-
}
|
|
1221
|
-
});
|
|
1222
|
-
const spanProcessor = new SimpleSpanProcessor(spanExporter);
|
|
1223
|
-
traceProvider.addSpanProcessor(spanProcessor);
|
|
1224
|
-
traceProvider.register();
|
|
1225
|
-
registerInstrumentations({
|
|
1226
|
-
instrumentations: [new FetchInstrumentation()]
|
|
1227
|
-
});
|
|
1228
|
-
return traceProvider;
|
|
1229
|
-
}
|
|
1230
|
-
var provider = initializeTracing();
|
|
1231
|
-
function getTracer() {
|
|
1232
|
-
return trace.getTracer("trigger.dev cli v3", version);
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
// src/cli/common.ts
|
|
1236
|
-
import { fromZodError } from "zod-validation-error";
|
|
1237
1189
|
|
|
1238
1190
|
// src/utilities/logger.ts
|
|
1239
1191
|
import { format } from "node:util";
|
|
@@ -1348,7 +1300,58 @@ var Logger = class {
|
|
|
1348
1300
|
};
|
|
1349
1301
|
var logger = new Logger();
|
|
1350
1302
|
|
|
1303
|
+
// src/telemetry/tracing.ts
|
|
1304
|
+
function initializeTracing() {
|
|
1305
|
+
if (process.argv.includes("--skip-telemetry") || process.env.TRIGGER_DEV_SKIP_TELEMETRY || // only for backwards compat
|
|
1306
|
+
process.env.TRIGGER_TELEMETRY_DISABLED) {
|
|
1307
|
+
logger.debug("\u{1F4C9} Telemetry disabled");
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
if (process.env.OTEL_INTERNAL_DIAG_DEBUG) {
|
|
1311
|
+
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
|
1312
|
+
}
|
|
1313
|
+
const resource = detectResourcesSync({
|
|
1314
|
+
detectors: [processDetectorSync]
|
|
1315
|
+
}).merge(
|
|
1316
|
+
new Resource({
|
|
1317
|
+
[SEMRESATTRS_SERVICE_NAME]: "trigger.dev cli v3",
|
|
1318
|
+
[SEMRESATTRS_SERVICE_VERSION]: version
|
|
1319
|
+
})
|
|
1320
|
+
);
|
|
1321
|
+
const traceProvider = new NodeTracerProvider({
|
|
1322
|
+
forceFlushTimeoutMillis: 3e4,
|
|
1323
|
+
resource,
|
|
1324
|
+
spanLimits: {
|
|
1325
|
+
attributeCountLimit: 1e3,
|
|
1326
|
+
attributeValueLengthLimit: 1e3,
|
|
1327
|
+
eventCountLimit: 100,
|
|
1328
|
+
attributePerEventCountLimit: 100,
|
|
1329
|
+
linkCountLimit: 10,
|
|
1330
|
+
attributePerLinkCountLimit: 100
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
const spanExporter = new OTLPTraceExporter({
|
|
1334
|
+
url: "https://otel.baselime.io/v1",
|
|
1335
|
+
timeoutMillis: 5e3,
|
|
1336
|
+
headers: {
|
|
1337
|
+
"x-api-key": "b6e0fbbaf8dc2524773d2152ae2e9eb5c7fbaa52"
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
const spanProcessor = new SimpleSpanProcessor(spanExporter);
|
|
1341
|
+
traceProvider.addSpanProcessor(spanProcessor);
|
|
1342
|
+
traceProvider.register();
|
|
1343
|
+
registerInstrumentations({
|
|
1344
|
+
instrumentations: [new FetchInstrumentation()]
|
|
1345
|
+
});
|
|
1346
|
+
return traceProvider;
|
|
1347
|
+
}
|
|
1348
|
+
var provider = initializeTracing();
|
|
1349
|
+
function getTracer() {
|
|
1350
|
+
return trace.getTracer("trigger.dev cli v3", version);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1351
1353
|
// src/cli/common.ts
|
|
1354
|
+
import { fromZodError } from "zod-validation-error";
|
|
1352
1355
|
import { outro } from "@clack/prompts";
|
|
1353
1356
|
|
|
1354
1357
|
// src/utilities/cliOutput.ts
|
|
@@ -1600,8 +1603,8 @@ async function gatherTaskFilesFromDir(dirPath, triggerDir, config) {
|
|
|
1600
1603
|
}
|
|
1601
1604
|
return taskFiles;
|
|
1602
1605
|
}
|
|
1603
|
-
function resolveTriggerDirectories(dirs) {
|
|
1604
|
-
return dirs.map((dir) => resolve(dir));
|
|
1606
|
+
function resolveTriggerDirectories(projectDir, dirs) {
|
|
1607
|
+
return dirs.map((dir) => resolve(projectDir, dir));
|
|
1605
1608
|
}
|
|
1606
1609
|
var IGNORED_DIRS = ["node_modules", ".git", "dist", "build"];
|
|
1607
1610
|
async function findTriggerDirectories(dirPath) {
|
|
@@ -1701,7 +1704,7 @@ async function findFilePath(dir, fileName) {
|
|
|
1701
1704
|
return result;
|
|
1702
1705
|
}
|
|
1703
1706
|
async function readConfig(dir, options) {
|
|
1704
|
-
const absoluteDir = path2.resolve(process.cwd(), dir);
|
|
1707
|
+
const absoluteDir = path2.resolve(options?.cwd || process.cwd(), dir);
|
|
1705
1708
|
const configPath = await getConfigPath(dir, options?.configFile);
|
|
1706
1709
|
if (!configPath) {
|
|
1707
1710
|
if (options?.projectRef) {
|
|
@@ -1774,7 +1777,7 @@ async function resolveConfig(path7, config) {
|
|
|
1774
1777
|
if (!config.triggerDirectories) {
|
|
1775
1778
|
config.triggerDirectories = await findTriggerDirectories(path7);
|
|
1776
1779
|
}
|
|
1777
|
-
config.triggerDirectories = resolveTriggerDirectories(config.triggerDirectories);
|
|
1780
|
+
config.triggerDirectories = resolveTriggerDirectories(path7, config.triggerDirectories);
|
|
1778
1781
|
logger.debug("Resolved trigger directories", { triggerDirectories: config.triggerDirectories });
|
|
1779
1782
|
if (!config.triggerUrl) {
|
|
1780
1783
|
config.triggerUrl = CLOUD_API_URL;
|
|
@@ -2680,7 +2683,7 @@ async function login(options) {
|
|
|
2680
2683
|
if (accessTokenFromEnv) {
|
|
2681
2684
|
const auth = {
|
|
2682
2685
|
accessToken: accessTokenFromEnv,
|
|
2683
|
-
apiUrl: process.env.TRIGGER_API_URL ?? "https://api.trigger.dev"
|
|
2686
|
+
apiUrl: process.env.TRIGGER_API_URL ?? opts.defaultApiUrl ?? "https://api.trigger.dev"
|
|
2684
2687
|
};
|
|
2685
2688
|
const apiClient3 = new CliApiClient(auth.apiUrl, auth.accessToken);
|
|
2686
2689
|
const userData = await apiClient3.whoAmI();
|
|
@@ -3941,7 +3944,7 @@ function configureDeployCommand(program2) {
|
|
|
3941
3944
|
).addOption(
|
|
3942
3945
|
new CommandOption(
|
|
3943
3946
|
"--self-hosted",
|
|
3944
|
-
"Build and load the image using your local Docker. Use the --registry option to specify the registry to push the image to when using --self-hosted, or just use --push
|
|
3947
|
+
"Build and load the image using your local Docker. Use the --registry option to specify the registry to push the image to when using --self-hosted, or just use --push to push to the default registry."
|
|
3945
3948
|
).hideHelp()
|
|
3946
3949
|
).addOption(
|
|
3947
3950
|
new CommandOption(
|
|
@@ -4244,6 +4247,10 @@ ${authorization.error}`
|
|
|
4244
4247
|
logESMRequireError(parsedError, resolvedConfig);
|
|
4245
4248
|
}
|
|
4246
4249
|
await preExitTasks();
|
|
4250
|
+
if (finishedDeployment.errorData.stderr) {
|
|
4251
|
+
log5.error(`Error logs:
|
|
4252
|
+
${finishedDeployment.errorData.stderr}`);
|
|
4253
|
+
}
|
|
4247
4254
|
throw new SkipLoggingError(
|
|
4248
4255
|
`Deployment encountered an error: ${finishedDeployment.errorData.name}`
|
|
4249
4256
|
);
|
|
@@ -4647,7 +4654,7 @@ async function compileProject(config, options, configPath) {
|
|
|
4647
4654
|
return await tracer.startActiveSpan("compileProject", async (span) => {
|
|
4648
4655
|
try {
|
|
4649
4656
|
if (!options.skipTypecheck) {
|
|
4650
|
-
const typecheck = await typecheckProject(config
|
|
4657
|
+
const typecheck = await typecheckProject(config);
|
|
4651
4658
|
if (!typecheck) {
|
|
4652
4659
|
throw new Error("Typecheck failed, aborting deployment");
|
|
4653
4660
|
}
|
|
@@ -4845,8 +4852,7 @@ If this is unexpected you should check your ${terminalLink2(
|
|
|
4845
4852
|
const resolvingDependenciesResult = await resolveDependencies(
|
|
4846
4853
|
tempDir,
|
|
4847
4854
|
packageJsonContents,
|
|
4848
|
-
config
|
|
4849
|
-
options
|
|
4855
|
+
config
|
|
4850
4856
|
);
|
|
4851
4857
|
if (!resolvingDependenciesResult) {
|
|
4852
4858
|
throw new SkipLoggingError("Failed to resolve dependencies");
|
|
@@ -4925,14 +4931,17 @@ async function resolveEnvironmentVariables(config, apiClient2, options) {
|
|
|
4925
4931
|
});
|
|
4926
4932
|
if (uploadResult.success) {
|
|
4927
4933
|
$spinner.stop(`${total} environment variable${total > 1 ? "s" : ""} synced`);
|
|
4934
|
+
return;
|
|
4928
4935
|
} else {
|
|
4929
4936
|
$spinner.stop("Failed to sync environment variables");
|
|
4930
4937
|
throw new Error(uploadResult.error);
|
|
4931
4938
|
}
|
|
4932
4939
|
} else {
|
|
4933
4940
|
$spinner.stop("No environment variables to sync");
|
|
4941
|
+
return;
|
|
4934
4942
|
}
|
|
4935
4943
|
}
|
|
4944
|
+
$spinner.stop("Environment variables resolved");
|
|
4936
4945
|
} catch (e) {
|
|
4937
4946
|
recordSpanException5(span, e);
|
|
4938
4947
|
throw e;
|
|
@@ -4941,7 +4950,7 @@ async function resolveEnvironmentVariables(config, apiClient2, options) {
|
|
|
4941
4950
|
}
|
|
4942
4951
|
});
|
|
4943
4952
|
}
|
|
4944
|
-
async function resolveDependencies(projectDir, packageJsonContents, config
|
|
4953
|
+
async function resolveDependencies(projectDir, packageJsonContents, config) {
|
|
4945
4954
|
return await tracer.startActiveSpan("resolveDependencies", async (span) => {
|
|
4946
4955
|
const resolvingDepsSpinner = spinner();
|
|
4947
4956
|
resolvingDepsSpinner.start("Resolving dependencies");
|
|
@@ -5043,7 +5052,7 @@ ${chalkError("X Error:")} The package ${chalkPurple(
|
|
|
5043
5052
|
}
|
|
5044
5053
|
});
|
|
5045
5054
|
}
|
|
5046
|
-
async function typecheckProject(config
|
|
5055
|
+
async function typecheckProject(config) {
|
|
5047
5056
|
return await tracer.startActiveSpan("typecheckProject", async (span) => {
|
|
5048
5057
|
try {
|
|
5049
5058
|
const typecheckSpinner = spinner();
|
|
@@ -5497,6 +5506,7 @@ var BackgroundWorker = class {
|
|
|
5497
5506
|
_onClose = new Evt();
|
|
5498
5507
|
tasks = [];
|
|
5499
5508
|
metadata;
|
|
5509
|
+
stderr = [];
|
|
5500
5510
|
_taskRunProcesses = /* @__PURE__ */ new Map();
|
|
5501
5511
|
_taskRunProcessesBeingKilled = /* @__PURE__ */ new Set();
|
|
5502
5512
|
_closed = false;
|
|
@@ -5595,6 +5605,9 @@ var BackgroundWorker = class {
|
|
|
5595
5605
|
child.stdout?.on("data", (data) => {
|
|
5596
5606
|
logger.log(data.toString());
|
|
5597
5607
|
});
|
|
5608
|
+
child.stderr?.on("data", (data) => {
|
|
5609
|
+
this.stderr.push(data.toString());
|
|
5610
|
+
});
|
|
5598
5611
|
});
|
|
5599
5612
|
this._initialized = true;
|
|
5600
5613
|
}
|
|
@@ -5981,6 +5994,9 @@ var TaskRunProcess = class {
|
|
|
5981
5994
|
switch (message.type) {
|
|
5982
5995
|
case "TASK_RUN_COMPLETED": {
|
|
5983
5996
|
const { result, execution } = message.payload;
|
|
5997
|
+
logger.debug(`[${this.runId}] task run completed`, {
|
|
5998
|
+
result
|
|
5999
|
+
});
|
|
5984
6000
|
const promiseStatus = this._attemptStatuses.get(execution.attempt.id);
|
|
5985
6001
|
if (promiseStatus !== "PENDING") {
|
|
5986
6002
|
return;
|
|
@@ -6614,7 +6630,8 @@ function useDev({
|
|
|
6614
6630
|
}
|
|
6615
6631
|
const parsedError = parseNpmInstallError(e);
|
|
6616
6632
|
if (typeof parsedError === "string") {
|
|
6617
|
-
logger.log(
|
|
6633
|
+
logger.log(`
|
|
6634
|
+
${chalkError("X Error:")} ${parsedError}`);
|
|
6618
6635
|
} else {
|
|
6619
6636
|
switch (parsedError.type) {
|
|
6620
6637
|
case "package-not-found-error": {
|
|
@@ -6637,6 +6654,12 @@ ${chalkError("X Error:")} The package ${chalkPurple(
|
|
|
6637
6654
|
}
|
|
6638
6655
|
}
|
|
6639
6656
|
}
|
|
6657
|
+
const stderr = backgroundWorker.stderr.map((line) => line.trim()).filter((line) => line.length > 0).join("\n");
|
|
6658
|
+
if (stderr) {
|
|
6659
|
+
logger.log(`
|
|
6660
|
+
${chalkError("X Error logs:")}
|
|
6661
|
+
${stderr}`);
|
|
6662
|
+
}
|
|
6640
6663
|
}
|
|
6641
6664
|
});
|
|
6642
6665
|
}
|
|
@@ -6877,7 +6900,7 @@ function configureInitCommand(program2) {
|
|
|
6877
6900
|
).option(
|
|
6878
6901
|
"-t, --tag <package tag>",
|
|
6879
6902
|
"The version of the @trigger.dev/sdk package to install",
|
|
6880
|
-
|
|
6903
|
+
version
|
|
6881
6904
|
).option("--skip-package-install", "Skip installing the @trigger.dev/sdk package").option("--override-config", "Override the existing config file if it exists")
|
|
6882
6905
|
).action(async (path7, options) => {
|
|
6883
6906
|
await handleTelemetry(async () => {
|
|
@@ -6952,7 +6975,7 @@ async function _initCommand(dir, options) {
|
|
|
6952
6975
|
log6.info("Next steps:");
|
|
6953
6976
|
log6.info(
|
|
6954
6977
|
` 1. To start developing, run ${chalk5.green(
|
|
6955
|
-
`npx trigger.dev@${options.tag} dev`
|
|
6978
|
+
`npx trigger.dev@${options.tag} dev${options.apiUrl === CLOUD_API_URL ? "" : ` -a ${options.apiUrl}`}`
|
|
6956
6979
|
)} in your project directory`
|
|
6957
6980
|
);
|
|
6958
6981
|
log6.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
|
|
@@ -7131,7 +7154,7 @@ async function installPackages2(dir, options) {
|
|
|
7131
7154
|
switch (pkgManager) {
|
|
7132
7155
|
case "npm": {
|
|
7133
7156
|
installSpinner.start(`Running npm install @trigger.dev/sdk@${options.tag}`);
|
|
7134
|
-
await execa3("npm", ["install", `@trigger.dev/sdk@${options.tag}`], {
|
|
7157
|
+
await execa3("npm", ["install", "--save-exact", `@trigger.dev/sdk@${options.tag}`], {
|
|
7135
7158
|
cwd: projectDir,
|
|
7136
7159
|
stdio: options.logLevel === "debug" ? "inherit" : "ignore"
|
|
7137
7160
|
});
|