trigger.dev 0.0.0-v3-pnpm-fix-20240411185916 → 0.0.0-v3-schedules-beta-20240417141912
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 +217 -188
- package/dist/index.js.map +1 -1
- package/dist/workers/dev/worker-facade.js +26 -45
- package/dist/workers/dev/worker-setup.js +4 -1
- package/dist/workers/prod/worker-facade.js +22 -44
- package/dist/workers/prod/worker-setup.js +4 -1
- package/package.json +5 -8
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ var require_XDGAppPaths = __commonJS({
|
|
|
57
57
|
return typeof t;
|
|
58
58
|
}
|
|
59
59
|
function Adapt(adapter_) {
|
|
60
|
-
var meta = adapter_.meta,
|
|
60
|
+
var meta = adapter_.meta, path7 = adapter_.path, xdg = adapter_.xdg;
|
|
61
61
|
var XDGAppPaths_ = /* @__PURE__ */ function() {
|
|
62
62
|
function XDGAppPaths_2(options_) {
|
|
63
63
|
if (options_ === void 0) {
|
|
@@ -79,7 +79,7 @@ var require_XDGAppPaths = __commonJS({
|
|
|
79
79
|
meta.mainFilename()
|
|
80
80
|
];
|
|
81
81
|
var nameFallback = "$eval";
|
|
82
|
-
var name =
|
|
82
|
+
var name = path7.parse(((_c = namePriorityList.find(function(e) {
|
|
83
83
|
return isString(e);
|
|
84
84
|
})) !== null && _c !== void 0 ? _c : nameFallback) + suffix).name;
|
|
85
85
|
XDGAppPaths.$name = function $name() {
|
|
@@ -98,28 +98,28 @@ var require_XDGAppPaths = __commonJS({
|
|
|
98
98
|
return isIsolated(dirOptions) ? name : "";
|
|
99
99
|
}
|
|
100
100
|
XDGAppPaths.cache = function cache(dirOptions) {
|
|
101
|
-
return
|
|
101
|
+
return path7.join(xdg.cache(), finalPathSegment(dirOptions));
|
|
102
102
|
};
|
|
103
103
|
XDGAppPaths.config = function config(dirOptions) {
|
|
104
|
-
return
|
|
104
|
+
return path7.join(xdg.config(), finalPathSegment(dirOptions));
|
|
105
105
|
};
|
|
106
106
|
XDGAppPaths.data = function data(dirOptions) {
|
|
107
|
-
return
|
|
107
|
+
return path7.join(xdg.data(), finalPathSegment(dirOptions));
|
|
108
108
|
};
|
|
109
109
|
XDGAppPaths.runtime = function runtime(dirOptions) {
|
|
110
|
-
return xdg.runtime() ?
|
|
110
|
+
return xdg.runtime() ? path7.join(xdg.runtime(), finalPathSegment(dirOptions)) : void 0;
|
|
111
111
|
};
|
|
112
112
|
XDGAppPaths.state = function state(dirOptions) {
|
|
113
|
-
return
|
|
113
|
+
return path7.join(xdg.state(), finalPathSegment(dirOptions));
|
|
114
114
|
};
|
|
115
115
|
XDGAppPaths.configDirs = function configDirs(dirOptions) {
|
|
116
116
|
return xdg.configDirs().map(function(s) {
|
|
117
|
-
return
|
|
117
|
+
return path7.join(s, finalPathSegment(dirOptions));
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
120
|
XDGAppPaths.dataDirs = function dataDirs(dirOptions) {
|
|
121
121
|
return xdg.dataDirs().map(function(s) {
|
|
122
|
-
return
|
|
122
|
+
return path7.join(s, finalPathSegment(dirOptions));
|
|
123
123
|
});
|
|
124
124
|
};
|
|
125
125
|
return XDGAppPaths;
|
|
@@ -144,14 +144,14 @@ var require_XDG = __commonJS({
|
|
|
144
144
|
exports.__esModule = true;
|
|
145
145
|
exports.Adapt = void 0;
|
|
146
146
|
function Adapt(adapter_) {
|
|
147
|
-
var env = adapter_.env, osPaths = adapter_.osPaths,
|
|
147
|
+
var env = adapter_.env, osPaths = adapter_.osPaths, path7 = adapter_.path;
|
|
148
148
|
var isMacOS = /^darwin$/i.test(adapter_.process.platform);
|
|
149
149
|
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
150
150
|
function baseDir() {
|
|
151
151
|
return osPaths.home() || osPaths.temp();
|
|
152
152
|
}
|
|
153
153
|
function valOrPath(val, pathSegments) {
|
|
154
|
-
return val ||
|
|
154
|
+
return val || path7.join.apply(path7, pathSegments);
|
|
155
155
|
}
|
|
156
156
|
var linux = function() {
|
|
157
157
|
var cache = function() {
|
|
@@ -226,11 +226,11 @@ var require_XDG = __commonJS({
|
|
|
226
226
|
XDG.state = extension.state;
|
|
227
227
|
XDG.configDirs = function configDirs() {
|
|
228
228
|
var pathList = env.get("XDG_CONFIG_DIRS");
|
|
229
|
-
return __spreadArray([extension.config()], pathList ? pathList.split(
|
|
229
|
+
return __spreadArray([extension.config()], pathList ? pathList.split(path7.delimiter) : []);
|
|
230
230
|
};
|
|
231
231
|
XDG.dataDirs = function dataDirs() {
|
|
232
232
|
var pathList = env.get("XDG_DATA_DIRS");
|
|
233
|
-
return __spreadArray([extension.data()], pathList ? pathList.split(
|
|
233
|
+
return __spreadArray([extension.data()], pathList ? pathList.split(path7.delimiter) : []);
|
|
234
234
|
};
|
|
235
235
|
return XDG;
|
|
236
236
|
}
|
|
@@ -257,13 +257,13 @@ var require_OSPaths = __commonJS({
|
|
|
257
257
|
return !s;
|
|
258
258
|
}
|
|
259
259
|
function Adapt(adapter_) {
|
|
260
|
-
var env = adapter_.env, os2 = adapter_.os,
|
|
260
|
+
var env = adapter_.env, os2 = adapter_.os, path7 = adapter_.path;
|
|
261
261
|
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
262
262
|
function normalizePath(path_) {
|
|
263
263
|
return path_ ? adapter_.path.normalize(adapter_.path.join(path_, ".")) : void 0;
|
|
264
264
|
}
|
|
265
265
|
function home() {
|
|
266
|
-
var
|
|
266
|
+
var posix2 = function() {
|
|
267
267
|
return normalizePath((typeof os2.homedir === "function" ? os2.homedir() : void 0) || env.get("HOME"));
|
|
268
268
|
};
|
|
269
269
|
var windows = function() {
|
|
@@ -271,19 +271,19 @@ var require_OSPaths = __commonJS({
|
|
|
271
271
|
typeof os2.homedir === "function" ? os2.homedir() : void 0,
|
|
272
272
|
env.get("USERPROFILE"),
|
|
273
273
|
env.get("HOME"),
|
|
274
|
-
env.get("HOMEDRIVE") || env.get("HOMEPATH") ?
|
|
274
|
+
env.get("HOMEDRIVE") || env.get("HOMEPATH") ? path7.join(env.get("HOMEDRIVE") || "", env.get("HOMEPATH") || "") : void 0
|
|
275
275
|
];
|
|
276
276
|
return normalizePath(priorityList.find(function(v) {
|
|
277
277
|
return !isEmpty(v);
|
|
278
278
|
}));
|
|
279
279
|
};
|
|
280
|
-
return isWinOS ? windows() :
|
|
280
|
+
return isWinOS ? windows() : posix2();
|
|
281
281
|
}
|
|
282
282
|
function temp() {
|
|
283
283
|
function joinPathToBase(base, segments) {
|
|
284
|
-
return base ?
|
|
284
|
+
return base ? path7.join.apply(path7, __spreadArray([base], segments)) : void 0;
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function posix2() {
|
|
287
287
|
var fallback = "/tmp";
|
|
288
288
|
var priorityList = [
|
|
289
289
|
typeof os2.tmpdir === "function" ? os2.tmpdir() : void 0,
|
|
@@ -331,7 +331,7 @@ var require_OSPaths = __commonJS({
|
|
|
331
331
|
});
|
|
332
332
|
return v && normalizePath(v()) || fallback;
|
|
333
333
|
}
|
|
334
|
-
return isWinOS ? windows() :
|
|
334
|
+
return isWinOS ? windows() : posix2();
|
|
335
335
|
}
|
|
336
336
|
var OSPaths_ = /* @__PURE__ */ function() {
|
|
337
337
|
function OSPaths_2() {
|
|
@@ -385,7 +385,7 @@ var require_node = __commonJS({
|
|
|
385
385
|
exports.__esModule = true;
|
|
386
386
|
exports.adapter = void 0;
|
|
387
387
|
var os2 = __importStar(__require("os"));
|
|
388
|
-
var
|
|
388
|
+
var path7 = __importStar(__require("path"));
|
|
389
389
|
exports.adapter = {
|
|
390
390
|
atImportPermissions: { env: true },
|
|
391
391
|
env: {
|
|
@@ -394,7 +394,7 @@ var require_node = __commonJS({
|
|
|
394
394
|
}
|
|
395
395
|
},
|
|
396
396
|
os: os2,
|
|
397
|
-
path:
|
|
397
|
+
path: path7,
|
|
398
398
|
process
|
|
399
399
|
};
|
|
400
400
|
}
|
|
@@ -447,7 +447,7 @@ var require_node2 = __commonJS({
|
|
|
447
447
|
};
|
|
448
448
|
exports.__esModule = true;
|
|
449
449
|
exports.adapter = void 0;
|
|
450
|
-
var
|
|
450
|
+
var path7 = __importStar(__require("path"));
|
|
451
451
|
var os_paths_1 = __importDefault(require_mod_cjs());
|
|
452
452
|
exports.adapter = {
|
|
453
453
|
atImportPermissions: { env: true },
|
|
@@ -457,7 +457,7 @@ var require_node2 = __commonJS({
|
|
|
457
457
|
}
|
|
458
458
|
},
|
|
459
459
|
osPaths: os_paths_1["default"],
|
|
460
|
-
path:
|
|
460
|
+
path: path7,
|
|
461
461
|
process
|
|
462
462
|
};
|
|
463
463
|
}
|
|
@@ -510,7 +510,7 @@ var require_node3 = __commonJS({
|
|
|
510
510
|
};
|
|
511
511
|
exports.__esModule = true;
|
|
512
512
|
exports.adapter = void 0;
|
|
513
|
-
var
|
|
513
|
+
var path7 = __importStar(__require("path"));
|
|
514
514
|
var xdg_portable_1 = __importDefault(require_mod_cjs2());
|
|
515
515
|
exports.adapter = {
|
|
516
516
|
atImportPermissions: { env: true, read: true },
|
|
@@ -525,7 +525,7 @@ var require_node3 = __commonJS({
|
|
|
525
525
|
return process.pkg ? process.execPath : void 0;
|
|
526
526
|
}
|
|
527
527
|
},
|
|
528
|
-
path:
|
|
528
|
+
path: path7,
|
|
529
529
|
process,
|
|
530
530
|
xdg: xdg_portable_1["default"]
|
|
531
531
|
};
|
|
@@ -777,7 +777,7 @@ var require_retry2 = __commonJS({
|
|
|
777
777
|
import { Command as Command2 } from "commander";
|
|
778
778
|
|
|
779
779
|
// src/commands/deploy.ts
|
|
780
|
-
import { intro as intro3, log as
|
|
780
|
+
import { intro as intro3, log as log3, outro as outro3 } from "@clack/prompts";
|
|
781
781
|
import { depot } from "@depot/cli";
|
|
782
782
|
import { context, trace as trace2 } from "@opentelemetry/api";
|
|
783
783
|
import {
|
|
@@ -790,18 +790,17 @@ import chalk5 from "chalk";
|
|
|
790
790
|
import { Option as CommandOption } from "commander";
|
|
791
791
|
import { build as build2 } from "esbuild";
|
|
792
792
|
import { execa as execa2 } from "execa";
|
|
793
|
-
import { resolve as importResolve } from "import-meta-resolve";
|
|
794
793
|
import { createHash } from "node:crypto";
|
|
795
794
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
796
795
|
import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
797
|
-
import { dirname, join as join5, relative as relative3 } from "node:path";
|
|
796
|
+
import { dirname, join as join5, relative as relative3, posix } from "node:path";
|
|
798
797
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
799
798
|
import terminalLink from "terminal-link";
|
|
800
799
|
import invariant from "tiny-invariant";
|
|
801
800
|
import { z as z4 } from "zod";
|
|
802
801
|
|
|
803
802
|
// package.json
|
|
804
|
-
var version = "0.0.0-v3-
|
|
803
|
+
var version = "0.0.0-v3-schedules-beta-20240417141912";
|
|
805
804
|
var dependencies = {
|
|
806
805
|
"@clack/prompts": "^0.7.0",
|
|
807
806
|
"@depot/cli": "0.0.1-cli.2.55.0",
|
|
@@ -817,7 +816,7 @@ var dependencies = {
|
|
|
817
816
|
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
818
817
|
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
819
818
|
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
820
|
-
"@trigger.dev/core": "workspace:0.0.0-v3-
|
|
819
|
+
"@trigger.dev/core": "workspace:0.0.0-v3-schedules-beta-20240417141912",
|
|
821
820
|
"@types/degit": "^2.8.3",
|
|
822
821
|
chalk: "^5.2.0",
|
|
823
822
|
chokidar: "^3.5.3",
|
|
@@ -906,8 +905,8 @@ var package_default = {
|
|
|
906
905
|
"@types/semver": "^7.3.13",
|
|
907
906
|
"@types/ws": "^8.5.3",
|
|
908
907
|
"cpy-cli": "^5.0.0",
|
|
908
|
+
nodemon: "^3.0.1",
|
|
909
909
|
"npm-run-all": "^4.1.5",
|
|
910
|
-
"npm-watch": "^0.11.0",
|
|
911
910
|
open: "^10.0.3",
|
|
912
911
|
"p-retry": "^6.1.0",
|
|
913
912
|
rimraf: "^3.0.2",
|
|
@@ -917,9 +916,6 @@ var package_default = {
|
|
|
917
916
|
vitest: "^0.34.4",
|
|
918
917
|
"xdg-app-paths": "^8.3.0"
|
|
919
918
|
},
|
|
920
|
-
watch: {
|
|
921
|
-
"build:prod-containerfile": "src/Containerfile.prod"
|
|
922
|
-
},
|
|
923
919
|
scripts: {
|
|
924
920
|
typecheck: "tsc -p tsconfig.check.json",
|
|
925
921
|
build: "npm run clean && run-p build:**",
|
|
@@ -929,7 +925,7 @@ var package_default = {
|
|
|
929
925
|
dev: "npm run clean && run-p dev:**",
|
|
930
926
|
"dev:main": "tsup --watch",
|
|
931
927
|
"dev:workers": "tsup --config tsup.workers.config.ts --watch",
|
|
932
|
-
"dev:
|
|
928
|
+
"dev:test": "nodemon -w src/Containerfile.prod -x npm run build:prod-containerfile",
|
|
933
929
|
clean: "rimraf dist",
|
|
934
930
|
start: "node dist/index.js",
|
|
935
931
|
test: "vitest"
|
|
@@ -1470,31 +1466,31 @@ import fsModule, { writeFile } from "fs/promises";
|
|
|
1470
1466
|
import fs from "node:fs";
|
|
1471
1467
|
import { tmpdir } from "node:os";
|
|
1472
1468
|
import pathModule from "node:path";
|
|
1473
|
-
async function createFile(
|
|
1474
|
-
await fsModule.mkdir(pathModule.dirname(
|
|
1475
|
-
await fsModule.writeFile(
|
|
1476
|
-
return
|
|
1469
|
+
async function createFile(path7, contents) {
|
|
1470
|
+
await fsModule.mkdir(pathModule.dirname(path7), { recursive: true });
|
|
1471
|
+
await fsModule.writeFile(path7, contents);
|
|
1472
|
+
return path7;
|
|
1477
1473
|
}
|
|
1478
|
-
async function pathExists(
|
|
1479
|
-
return fsSync.existsSync(
|
|
1474
|
+
async function pathExists(path7) {
|
|
1475
|
+
return fsSync.existsSync(path7);
|
|
1480
1476
|
}
|
|
1481
|
-
async function readFile(
|
|
1482
|
-
return await fsModule.readFile(
|
|
1477
|
+
async function readFile(path7) {
|
|
1478
|
+
return await fsModule.readFile(path7, "utf8");
|
|
1483
1479
|
}
|
|
1484
|
-
async function readJSONFile(
|
|
1485
|
-
const fileContents = await fsModule.readFile(
|
|
1480
|
+
async function readJSONFile(path7) {
|
|
1481
|
+
const fileContents = await fsModule.readFile(path7, "utf8");
|
|
1486
1482
|
return JSON.parse(fileContents);
|
|
1487
1483
|
}
|
|
1488
|
-
async function writeJSONFile(
|
|
1489
|
-
await writeFile(
|
|
1484
|
+
async function writeJSONFile(path7, json) {
|
|
1485
|
+
await writeFile(path7, JSON.stringify(json), "utf8");
|
|
1490
1486
|
}
|
|
1491
|
-
function readJSONFileSync(
|
|
1492
|
-
const fileContents = fsSync.readFileSync(
|
|
1487
|
+
function readJSONFileSync(path7) {
|
|
1488
|
+
const fileContents = fsSync.readFileSync(path7, "utf8");
|
|
1493
1489
|
return JSON.parse(fileContents);
|
|
1494
1490
|
}
|
|
1495
|
-
function safeDeleteFileSync(
|
|
1491
|
+
function safeDeleteFileSync(path7) {
|
|
1496
1492
|
try {
|
|
1497
|
-
fs.unlinkSync(
|
|
1493
|
+
fs.unlinkSync(path7);
|
|
1498
1494
|
} catch (error) {
|
|
1499
1495
|
}
|
|
1500
1496
|
}
|
|
@@ -1521,12 +1517,13 @@ async function gatherTaskFiles(config) {
|
|
|
1521
1517
|
for (const file of files) {
|
|
1522
1518
|
if (!file.isFile())
|
|
1523
1519
|
continue;
|
|
1524
|
-
if (!file.name.endsWith(".js") && !file.name.endsWith(".ts"))
|
|
1520
|
+
if (!file.name.endsWith(".js") && !file.name.endsWith(".ts") && !file.name.endsWith(".jsx") && !file.name.endsWith(".tsx")) {
|
|
1525
1521
|
continue;
|
|
1522
|
+
}
|
|
1526
1523
|
const fullPath = join(triggerDir, file.name);
|
|
1527
1524
|
const filePath = relative(config.projectDir, fullPath);
|
|
1528
|
-
const
|
|
1529
|
-
const
|
|
1525
|
+
const importName = filePath.replace(/\..+$/, "").replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
1526
|
+
const importPath = filePath.replace(/\\/g, "/");
|
|
1530
1527
|
taskFiles.push({ triggerDir, importPath, importName, filePath });
|
|
1531
1528
|
}
|
|
1532
1529
|
}
|
|
@@ -1656,7 +1653,8 @@ async function readConfig(dir, options) {
|
|
|
1656
1653
|
});
|
|
1657
1654
|
const userConfigModule = await import(builtConfigFileHref);
|
|
1658
1655
|
const rawConfig = await normalizeConfig(
|
|
1659
|
-
userConfigModule
|
|
1656
|
+
userConfigModule?.config,
|
|
1657
|
+
options?.projectRef ? { project: options?.projectRef } : void 0
|
|
1660
1658
|
);
|
|
1661
1659
|
const config = Config.parse(rawConfig);
|
|
1662
1660
|
return {
|
|
@@ -1665,31 +1663,32 @@ async function readConfig(dir, options) {
|
|
|
1665
1663
|
path: configPath
|
|
1666
1664
|
};
|
|
1667
1665
|
}
|
|
1668
|
-
async function resolveConfig(
|
|
1666
|
+
async function resolveConfig(path7, config) {
|
|
1669
1667
|
if (!config.triggerDirectories) {
|
|
1670
|
-
config.triggerDirectories = await findTriggerDirectories(
|
|
1668
|
+
config.triggerDirectories = await findTriggerDirectories(path7);
|
|
1671
1669
|
}
|
|
1672
1670
|
config.triggerDirectories = resolveTriggerDirectories(config.triggerDirectories);
|
|
1673
1671
|
if (!config.triggerUrl) {
|
|
1674
1672
|
config.triggerUrl = CLOUD_API_URL;
|
|
1675
1673
|
}
|
|
1676
1674
|
if (!config.projectDir) {
|
|
1677
|
-
config.projectDir =
|
|
1675
|
+
config.projectDir = path7;
|
|
1678
1676
|
}
|
|
1679
1677
|
if (!config.tsconfigPath) {
|
|
1680
|
-
config.tsconfigPath = await getConfigPath(
|
|
1678
|
+
config.tsconfigPath = await getConfigPath(path7, "tsconfig.json");
|
|
1681
1679
|
}
|
|
1682
1680
|
return config;
|
|
1683
1681
|
}
|
|
1684
|
-
async function normalizeConfig(config) {
|
|
1682
|
+
async function normalizeConfig(config, overrides) {
|
|
1683
|
+
let normalized = config;
|
|
1685
1684
|
if (typeof config === "function") {
|
|
1686
|
-
|
|
1685
|
+
normalized = await config();
|
|
1687
1686
|
}
|
|
1688
|
-
|
|
1687
|
+
normalized = { ...normalized, ...overrides };
|
|
1688
|
+
return normalized;
|
|
1689
1689
|
}
|
|
1690
1690
|
|
|
1691
1691
|
// src/utilities/initialBanner.ts
|
|
1692
|
-
import { spinner } from "@clack/prompts";
|
|
1693
1692
|
import chalk3 from "chalk";
|
|
1694
1693
|
import checkForUpdate from "update-check";
|
|
1695
1694
|
|
|
@@ -1701,6 +1700,25 @@ function getVersion() {
|
|
|
1701
1700
|
return packageJsonContent.version ?? "1.0.0";
|
|
1702
1701
|
}
|
|
1703
1702
|
|
|
1703
|
+
// src/utilities/windows.ts
|
|
1704
|
+
import { log, spinner as clackSpinner } from "@clack/prompts";
|
|
1705
|
+
var isWindows = process.platform === "win32";
|
|
1706
|
+
function escapeImportPath(path7) {
|
|
1707
|
+
return isWindows ? path7.replaceAll("\\", "\\\\") : path7;
|
|
1708
|
+
}
|
|
1709
|
+
var ballmerSpinner = () => ({
|
|
1710
|
+
start: (msg) => {
|
|
1711
|
+
log.step(msg ?? "");
|
|
1712
|
+
},
|
|
1713
|
+
stop: (msg, code) => {
|
|
1714
|
+
log.message(msg ?? "");
|
|
1715
|
+
},
|
|
1716
|
+
message: (msg) => {
|
|
1717
|
+
log.message(msg ?? "");
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
var spinner = () => isWindows ? ballmerSpinner() : clackSpinner();
|
|
1721
|
+
|
|
1704
1722
|
// src/utilities/initialBanner.ts
|
|
1705
1723
|
async function printInitialBanner(performUpdateCheck = true) {
|
|
1706
1724
|
const packageVersion = getVersion();
|
|
@@ -1731,15 +1749,15 @@ After installation, run Trigger.dev with \`npx trigger.dev\`.`
|
|
|
1731
1749
|
}
|
|
1732
1750
|
async function printStandloneInitialBanner(performUpdateCheck = true) {
|
|
1733
1751
|
const packageVersion = getVersion();
|
|
1734
|
-
|
|
1735
|
-
${logo()} ${chalkGrey("(v3 Developer Preview)")}
|
|
1752
|
+
logger.log(`
|
|
1753
|
+
${logo()} ${chalkGrey("(v3 Developer Preview)")}`);
|
|
1736
1754
|
if (performUpdateCheck) {
|
|
1737
1755
|
const maybeNewVersion = await updateCheck();
|
|
1738
1756
|
if (maybeNewVersion !== void 0) {
|
|
1739
|
-
|
|
1757
|
+
logger.log(`Update available ${chalk3.green(maybeNewVersion)}`);
|
|
1740
1758
|
}
|
|
1741
1759
|
}
|
|
1742
|
-
logger.log(
|
|
1760
|
+
logger.log(`${chalkGrey("-".repeat(54))}`);
|
|
1743
1761
|
}
|
|
1744
1762
|
function printDevBanner() {
|
|
1745
1763
|
logger.log(
|
|
@@ -1780,11 +1798,11 @@ async function installPackages(packages, options) {
|
|
|
1780
1798
|
}
|
|
1781
1799
|
);
|
|
1782
1800
|
}
|
|
1783
|
-
function detectPackageNameFromImportPath(
|
|
1784
|
-
if (
|
|
1785
|
-
return
|
|
1801
|
+
function detectPackageNameFromImportPath(path7) {
|
|
1802
|
+
if (path7.startsWith("@")) {
|
|
1803
|
+
return path7.split("/").slice(0, 2).join("/");
|
|
1786
1804
|
} else {
|
|
1787
|
-
return
|
|
1805
|
+
return path7.split("/")[0];
|
|
1788
1806
|
}
|
|
1789
1807
|
}
|
|
1790
1808
|
function stripWorkspaceFromVersion(version2) {
|
|
@@ -1800,16 +1818,16 @@ function parsePackageName(packageSpecifier) {
|
|
|
1800
1818
|
}
|
|
1801
1819
|
return { name: packageSpecifier };
|
|
1802
1820
|
}
|
|
1803
|
-
async function setPackageJsonDeps(
|
|
1821
|
+
async function setPackageJsonDeps(path7, deps) {
|
|
1804
1822
|
try {
|
|
1805
|
-
const existingPackageJson = await readJSONFile(
|
|
1823
|
+
const existingPackageJson = await readJSONFile(path7);
|
|
1806
1824
|
const newPackageJson = {
|
|
1807
1825
|
...existingPackageJson,
|
|
1808
1826
|
dependencies: {
|
|
1809
1827
|
...deps
|
|
1810
1828
|
}
|
|
1811
1829
|
};
|
|
1812
|
-
await writeJSONFile(
|
|
1830
|
+
await writeJSONFile(path7, newPackageJson);
|
|
1813
1831
|
} catch (error) {
|
|
1814
1832
|
const defaultPackageJson = {
|
|
1815
1833
|
name: "temp",
|
|
@@ -1817,12 +1835,12 @@ async function setPackageJsonDeps(path6, deps) {
|
|
|
1817
1835
|
description: "",
|
|
1818
1836
|
dependencies: deps
|
|
1819
1837
|
};
|
|
1820
|
-
await writeJSONFile(
|
|
1838
|
+
await writeJSONFile(path7, defaultPackageJson);
|
|
1821
1839
|
}
|
|
1822
1840
|
}
|
|
1823
1841
|
|
|
1824
1842
|
// src/commands/login.ts
|
|
1825
|
-
import { intro as intro2, log, outro as outro2, select
|
|
1843
|
+
import { intro as intro2, log as log2, outro as outro2, select } from "@clack/prompts";
|
|
1826
1844
|
import { recordSpanException as recordSpanException3 } from "@trigger.dev/core/v3";
|
|
1827
1845
|
|
|
1828
1846
|
// ../../node_modules/.pnpm/open@10.0.3/node_modules/open/index.js
|
|
@@ -2370,7 +2388,7 @@ async function pRetry(input, options) {
|
|
|
2370
2388
|
import { z as z3 } from "zod";
|
|
2371
2389
|
|
|
2372
2390
|
// src/commands/whoami.ts
|
|
2373
|
-
import { intro, note
|
|
2391
|
+
import { intro, note } from "@clack/prompts";
|
|
2374
2392
|
|
|
2375
2393
|
// src/utilities/session.ts
|
|
2376
2394
|
import { recordSpanException as recordSpanException2 } from "@trigger.dev/core/v3";
|
|
@@ -2448,7 +2466,7 @@ async function whoAmI(options, embedded = false) {
|
|
|
2448
2466
|
if (!embedded) {
|
|
2449
2467
|
intro(`Displaying your account details [${options?.profile ?? "default"}]`);
|
|
2450
2468
|
}
|
|
2451
|
-
const loadingSpinner =
|
|
2469
|
+
const loadingSpinner = spinner();
|
|
2452
2470
|
loadingSpinner.start("Checking your account details");
|
|
2453
2471
|
const authentication = await isLoggedIn(options?.profile);
|
|
2454
2472
|
if (!authentication.ok) {
|
|
@@ -2615,16 +2633,16 @@ async function login(options) {
|
|
|
2615
2633
|
}
|
|
2616
2634
|
}
|
|
2617
2635
|
if (opts.embedded) {
|
|
2618
|
-
|
|
2636
|
+
log2.step("You must login to continue.");
|
|
2619
2637
|
}
|
|
2620
2638
|
const apiClient2 = new CliApiClient(authConfig?.apiUrl ?? opts.defaultApiUrl);
|
|
2621
2639
|
const authorizationCodeResult = await createAuthorizationCode(apiClient2);
|
|
2622
|
-
|
|
2640
|
+
log2.step(
|
|
2623
2641
|
`Please visit the following URL to login:
|
|
2624
2642
|
${chalkLink(authorizationCodeResult.url)}`
|
|
2625
2643
|
);
|
|
2626
2644
|
await open_default(authorizationCodeResult.url);
|
|
2627
|
-
const getPersonalAccessTokenSpinner =
|
|
2645
|
+
const getPersonalAccessTokenSpinner = spinner();
|
|
2628
2646
|
getPersonalAccessTokenSpinner.start("Waiting for you to login");
|
|
2629
2647
|
try {
|
|
2630
2648
|
const indexResult = await pRetry(
|
|
@@ -2653,7 +2671,7 @@ ${chalkLink(authorizationCodeResult.url)}`
|
|
|
2653
2671
|
throw new Error(whoAmIResult.error);
|
|
2654
2672
|
}
|
|
2655
2673
|
if (opts.embedded) {
|
|
2656
|
-
|
|
2674
|
+
log2.step("Logged in successfully");
|
|
2657
2675
|
} else {
|
|
2658
2676
|
outro2("Logged in successfully");
|
|
2659
2677
|
}
|
|
@@ -2672,7 +2690,7 @@ ${chalkLink(authorizationCodeResult.url)}`
|
|
|
2672
2690
|
} catch (e) {
|
|
2673
2691
|
getPersonalAccessTokenSpinner.stop(`Failed to get access token`);
|
|
2674
2692
|
if (e instanceof AbortError) {
|
|
2675
|
-
|
|
2693
|
+
log2.error(e.message);
|
|
2676
2694
|
}
|
|
2677
2695
|
recordSpanException3(span, e);
|
|
2678
2696
|
span.end();
|
|
@@ -2721,7 +2739,7 @@ async function getPersonalAccessToken(apiClient2, authorizationCode) {
|
|
|
2721
2739
|
async function createAuthorizationCode(apiClient2) {
|
|
2722
2740
|
return await tracer.startActiveSpan("createAuthorizationCode", async (span) => {
|
|
2723
2741
|
try {
|
|
2724
|
-
const createAuthCodeSpinner =
|
|
2742
|
+
const createAuthCodeSpinner = spinner();
|
|
2725
2743
|
createAuthCodeSpinner.start("Creating authorition code");
|
|
2726
2744
|
const authorizationCodeResult = await apiClient2.createAuthorizationCode();
|
|
2727
2745
|
if (!authorizationCodeResult.success) {
|
|
@@ -2795,7 +2813,9 @@ function workerSetupImportConfigPlugin(configPath) {
|
|
|
2795
2813
|
let workerSetupContents = readFileSync(args.path, "utf-8");
|
|
2796
2814
|
workerSetupContents = workerSetupContents.replace(
|
|
2797
2815
|
"__SETUP_IMPORTED_PROJECT_CONFIG__",
|
|
2798
|
-
`import * as setupImportedConfigExports from "${
|
|
2816
|
+
`import * as setupImportedConfigExports from "${escapeImportPath(
|
|
2817
|
+
configPath
|
|
2818
|
+
)}"; const setupImportedConfig = setupImportedConfigExports.config;`
|
|
2799
2819
|
);
|
|
2800
2820
|
logger.debug("Loading worker setup", {
|
|
2801
2821
|
args,
|
|
@@ -2823,10 +2843,6 @@ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfi
|
|
|
2823
2843
|
setup(build3) {
|
|
2824
2844
|
build3.onResolve({ filter: /.*/ }, (args) => {
|
|
2825
2845
|
const resolvedPath = resolvePath(args.path);
|
|
2826
|
-
logger.debug(`[${buildIdentifier}] Handling ${args.path}`, {
|
|
2827
|
-
...args,
|
|
2828
|
-
resolvedPath
|
|
2829
|
-
});
|
|
2830
2846
|
if (!isBareModuleId(resolvedPath)) {
|
|
2831
2847
|
return void 0;
|
|
2832
2848
|
}
|
|
@@ -2846,6 +2862,9 @@ function bundleDependenciesPlugin(buildIdentifier, dependenciesToBundle, tsconfi
|
|
|
2846
2862
|
return void 0;
|
|
2847
2863
|
}
|
|
2848
2864
|
}
|
|
2865
|
+
logger.ignore(`[${buildIdentifier}] Externalizing ${args.path}`, {
|
|
2866
|
+
...args
|
|
2867
|
+
});
|
|
2849
2868
|
return {
|
|
2850
2869
|
path: args.path,
|
|
2851
2870
|
external: true
|
|
@@ -3080,9 +3099,9 @@ import { join as join4 } from "node:path";
|
|
|
3080
3099
|
|
|
3081
3100
|
// src/utilities/getUserPackageManager.ts
|
|
3082
3101
|
import { findUp as findUp2 } from "find-up";
|
|
3083
|
-
async function getUserPackageManager(
|
|
3102
|
+
async function getUserPackageManager(path7) {
|
|
3084
3103
|
try {
|
|
3085
|
-
return await detectPackageManagerFromArtifacts(
|
|
3104
|
+
return await detectPackageManagerFromArtifacts(path7);
|
|
3086
3105
|
} catch (error) {
|
|
3087
3106
|
return detectPackageManagerFromCurrentCommand();
|
|
3088
3107
|
}
|
|
@@ -3101,7 +3120,7 @@ function detectPackageManagerFromCurrentCommand() {
|
|
|
3101
3120
|
return "npm";
|
|
3102
3121
|
}
|
|
3103
3122
|
}
|
|
3104
|
-
async function detectPackageManagerFromArtifacts(
|
|
3123
|
+
async function detectPackageManagerFromArtifacts(path7) {
|
|
3105
3124
|
const packageFiles = [
|
|
3106
3125
|
{ name: "yarn.lock", pm: "yarn" },
|
|
3107
3126
|
{ name: "pnpm-lock.yaml", pm: "pnpm" },
|
|
@@ -3109,7 +3128,7 @@ async function detectPackageManagerFromArtifacts(path6) {
|
|
|
3109
3128
|
{ name: "npm-shrinkwrap.json", pm: "npm" }
|
|
3110
3129
|
];
|
|
3111
3130
|
for (const { name, pm } of packageFiles) {
|
|
3112
|
-
const foundPath = await findUp2(name, { cwd:
|
|
3131
|
+
const foundPath = await findUp2(name, { cwd: path7 });
|
|
3113
3132
|
if (typeof foundPath === "string") {
|
|
3114
3133
|
return pm;
|
|
3115
3134
|
}
|
|
@@ -3271,6 +3290,15 @@ var YarnCommands = class {
|
|
|
3271
3290
|
}
|
|
3272
3291
|
};
|
|
3273
3292
|
|
|
3293
|
+
// src/utilities/resolveInternalFilePath.ts
|
|
3294
|
+
import path5 from "path";
|
|
3295
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
3296
|
+
function cliRootPath() {
|
|
3297
|
+
const __filename2 = fileURLToPath3(import.meta.url);
|
|
3298
|
+
const __dirname2 = path5.dirname(__filename2);
|
|
3299
|
+
return __dirname2;
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3274
3302
|
// src/commands/deploy.ts
|
|
3275
3303
|
var DeployCommandOptions = CommonCommandOptions.extend({
|
|
3276
3304
|
skipTypecheck: z4.boolean().default(false),
|
|
@@ -3298,7 +3326,7 @@ function configureDeployCommand(program2) {
|
|
|
3298
3326
|
"Detected missing environment variables won't block deployment"
|
|
3299
3327
|
).option("-c, --config <config file>", "The name of the config file, found at [path]").option(
|
|
3300
3328
|
"-p, --project-ref <project ref>",
|
|
3301
|
-
"The project ref. Required if there is no config file."
|
|
3329
|
+
"The project ref. Required if there is no config file. This will override the project specified in the config file."
|
|
3302
3330
|
)
|
|
3303
3331
|
).addOption(
|
|
3304
3332
|
new CommandOption(
|
|
@@ -3332,10 +3360,10 @@ function configureDeployCommand(program2) {
|
|
|
3332
3360
|
"--output-metafile <path>",
|
|
3333
3361
|
"If provided, will save the esbuild metafile for the build to the specified path"
|
|
3334
3362
|
).hideHelp()
|
|
3335
|
-
).action(async (
|
|
3363
|
+
).action(async (path7, options) => {
|
|
3336
3364
|
await handleTelemetry(async () => {
|
|
3337
3365
|
await printStandloneInitialBanner(true);
|
|
3338
|
-
await deployCommand(
|
|
3366
|
+
await deployCommand(path7, options);
|
|
3339
3367
|
});
|
|
3340
3368
|
});
|
|
3341
3369
|
}
|
|
@@ -3389,7 +3417,7 @@ async function _deployCommand(dir, options) {
|
|
|
3389
3417
|
throw new Error(deploymentEnv.error);
|
|
3390
3418
|
}
|
|
3391
3419
|
const environmentClient = new CliApiClient(authorization.auth.apiUrl, deploymentEnv.data.apiKey);
|
|
3392
|
-
|
|
3420
|
+
log3.step(
|
|
3393
3421
|
`Preparing to deploy "${deploymentEnv.data.name}" (${resolvedConfig.config.project}) to ${options.env}`
|
|
3394
3422
|
);
|
|
3395
3423
|
const compilation = await compileProject(
|
|
@@ -3420,7 +3448,7 @@ async function _deployCommand(dir, options) {
|
|
|
3420
3448
|
);
|
|
3421
3449
|
}
|
|
3422
3450
|
const version2 = deploymentResponse.data.version;
|
|
3423
|
-
const deploymentSpinner =
|
|
3451
|
+
const deploymentSpinner = spinner();
|
|
3424
3452
|
deploymentSpinner.start(`Deploying version ${version2}`);
|
|
3425
3453
|
const selfHostedRegistryHost = deploymentResponse.data.registryHost ?? options.registry;
|
|
3426
3454
|
const registryHost = selfHostedRegistryHost ?? "registry.trigger.dev";
|
|
@@ -3581,7 +3609,7 @@ async function checkEnvVars(envVars, config, options, environmentClient, apiUrl)
|
|
|
3581
3609
|
return await tracer.startActiveSpan("detectEnvVars", async (span) => {
|
|
3582
3610
|
try {
|
|
3583
3611
|
span.setAttribute("envVars.check", envVars);
|
|
3584
|
-
const environmentVariablesSpinner =
|
|
3612
|
+
const environmentVariablesSpinner = spinner();
|
|
3585
3613
|
environmentVariablesSpinner.start("Checking environment variables");
|
|
3586
3614
|
const environmentVariables = await environmentClient.getEnvironmentVariables(config.project);
|
|
3587
3615
|
if (!environmentVariables.success) {
|
|
@@ -3714,7 +3742,8 @@ async function buildAndPushImage(options, updater) {
|
|
|
3714
3742
|
const processCode = await new Promise((res, rej) => {
|
|
3715
3743
|
childProcess2.stderr?.on("data", (data) => {
|
|
3716
3744
|
const text3 = data.toString();
|
|
3717
|
-
|
|
3745
|
+
const lines = text3.split("\n").filter(Boolean);
|
|
3746
|
+
errors.push(...lines);
|
|
3718
3747
|
logger.debug(text3);
|
|
3719
3748
|
});
|
|
3720
3749
|
childProcess2.on("error", (e) => rej(e));
|
|
@@ -3868,13 +3897,12 @@ async function buildAndPushSelfHostedImage(options) {
|
|
|
3868
3897
|
});
|
|
3869
3898
|
}
|
|
3870
3899
|
function extractImageDigest(outputs) {
|
|
3871
|
-
const imageDigestRegex = /sha256:[a-f0-9]{64}/;
|
|
3900
|
+
const imageDigestRegex = /pushing manifest for .+(?<digest>sha256:[a-f0-9]{64})/;
|
|
3872
3901
|
for (const line of outputs) {
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
}
|
|
3902
|
+
const imageDigestMatch = line.match(imageDigestRegex);
|
|
3903
|
+
const digest = imageDigestMatch?.groups?.digest;
|
|
3904
|
+
if (digest) {
|
|
3905
|
+
return digest;
|
|
3878
3906
|
}
|
|
3879
3907
|
}
|
|
3880
3908
|
}
|
|
@@ -3891,25 +3919,25 @@ async function compileProject(config, options, configPath) {
|
|
|
3891
3919
|
throw new Error("Typecheck failed, aborting deployment");
|
|
3892
3920
|
}
|
|
3893
3921
|
}
|
|
3894
|
-
const compileSpinner =
|
|
3922
|
+
const compileSpinner = spinner();
|
|
3895
3923
|
compileSpinner.start(`Building project in ${config.projectDir}`);
|
|
3896
3924
|
const taskFiles = await gatherTaskFiles(config);
|
|
3897
3925
|
const workerFacade = readFileSync2(
|
|
3898
|
-
|
|
3899
|
-
"file://",
|
|
3900
|
-
""
|
|
3901
|
-
),
|
|
3926
|
+
join5(cliRootPath(), "workers", "prod", "worker-facade.js"),
|
|
3902
3927
|
"utf-8"
|
|
3903
3928
|
);
|
|
3904
|
-
const workerSetupPath =
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3929
|
+
const workerSetupPath = join5(cliRootPath(), "workers", "dev", "worker-setup.js");
|
|
3930
|
+
let workerContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace(
|
|
3931
|
+
"__WORKER_SETUP__",
|
|
3932
|
+
`import { tracingSDK } from "${escapeImportPath(workerSetupPath)}";`
|
|
3933
|
+
);
|
|
3908
3934
|
if (configPath) {
|
|
3909
3935
|
logger.debug("Importing project config from", { configPath });
|
|
3910
3936
|
workerContents = workerContents.replace(
|
|
3911
3937
|
"__IMPORTED_PROJECT_CONFIG__",
|
|
3912
|
-
`import * as importedConfigExports from "${
|
|
3938
|
+
`import * as importedConfigExports from "${escapeImportPath(
|
|
3939
|
+
configPath
|
|
3940
|
+
)}"; const importedConfig = importedConfigExports.config; const handleError = importedConfigExports.handleError;`
|
|
3913
3941
|
);
|
|
3914
3942
|
} else {
|
|
3915
3943
|
workerContents = workerContents.replace(
|
|
@@ -3961,10 +3989,7 @@ async function compileProject(config, options, configPath) {
|
|
|
3961
3989
|
await writeJSONFile(join5(options.outputMetafile, "worker.json"), result.metafile);
|
|
3962
3990
|
}
|
|
3963
3991
|
const entryPointContents = readFileSync2(
|
|
3964
|
-
|
|
3965
|
-
"file://",
|
|
3966
|
-
""
|
|
3967
|
-
),
|
|
3992
|
+
join5(cliRootPath(), "workers", "prod", "entry-point.js"),
|
|
3968
3993
|
"utf-8"
|
|
3969
3994
|
);
|
|
3970
3995
|
const entryPointResult = await build2({
|
|
@@ -4013,9 +4038,9 @@ async function compileProject(config, options, configPath) {
|
|
|
4013
4038
|
}
|
|
4014
4039
|
const tempDir = await createTempDir();
|
|
4015
4040
|
logger.debug(`Writing compiled files to ${tempDir}`);
|
|
4016
|
-
const metaOutput = result.metafile.outputs[
|
|
4041
|
+
const metaOutput = result.metafile.outputs[posix.join("out", "stdin.js")];
|
|
4017
4042
|
invariant(metaOutput, "Meta output for the result build is missing");
|
|
4018
|
-
const entryPointMetaOutput = entryPointResult.metafile.outputs[
|
|
4043
|
+
const entryPointMetaOutput = entryPointResult.metafile.outputs[posix.join("out", "stdin.js")];
|
|
4019
4044
|
invariant(entryPointMetaOutput, "Meta output for the entryPoint build is missing");
|
|
4020
4045
|
const workerOutputFile = result.outputFiles.find(
|
|
4021
4046
|
(file) => file.path === join5(config.projectDir, "out", "stdin.js")
|
|
@@ -4064,9 +4089,7 @@ async function compileProject(config, options, configPath) {
|
|
|
4064
4089
|
if (!resolvingDependenciesResult) {
|
|
4065
4090
|
throw new SkipLoggingError("Failed to resolve dependencies");
|
|
4066
4091
|
}
|
|
4067
|
-
const containerFilePath =
|
|
4068
|
-
importResolve("./Containerfile.prod", import.meta.url)
|
|
4069
|
-
).href.replace("file://", "");
|
|
4092
|
+
const containerFilePath = join5(cliRootPath(), "Containerfile.prod");
|
|
4070
4093
|
await copyFile(containerFilePath, join5(tempDir, "Containerfile"));
|
|
4071
4094
|
const contentHasher = createHash("sha256");
|
|
4072
4095
|
contentHasher.update(Buffer.from(entryPointOutputFile.text));
|
|
@@ -4094,7 +4117,7 @@ async function compileProject(config, options, configPath) {
|
|
|
4094
4117
|
}
|
|
4095
4118
|
async function resolveDependencies(projectDir, packageJsonContents, config, options) {
|
|
4096
4119
|
return await tracer.startActiveSpan("resolveDependencies", async (span) => {
|
|
4097
|
-
const resolvingDepsSpinner =
|
|
4120
|
+
const resolvingDepsSpinner = spinner();
|
|
4098
4121
|
resolvingDepsSpinner.start("Resolving dependencies");
|
|
4099
4122
|
const hasher = createHash("sha256");
|
|
4100
4123
|
hasher.update(JSON.stringify(packageJsonContents));
|
|
@@ -4178,7 +4201,7 @@ ${chalkError("X Error:")} The package ${chalkPurple(
|
|
|
4178
4201
|
async function typecheckProject(config, options) {
|
|
4179
4202
|
return await tracer.startActiveSpan("typecheckProject", async (span) => {
|
|
4180
4203
|
try {
|
|
4181
|
-
const typecheckSpinner =
|
|
4204
|
+
const typecheckSpinner = spinner();
|
|
4182
4205
|
typecheckSpinner.start("Typechecking project");
|
|
4183
4206
|
const tscTypecheck = execa2("npm", ["exec", "tsc", "--", "--noEmit"], {
|
|
4184
4207
|
cwd: config.projectDir
|
|
@@ -4347,11 +4370,10 @@ import {
|
|
|
4347
4370
|
} from "@trigger.dev/core/v3";
|
|
4348
4371
|
import { watch } from "chokidar";
|
|
4349
4372
|
import { context as context2 } from "esbuild";
|
|
4350
|
-
import { resolve as importResolve2 } from "import-meta-resolve";
|
|
4351
4373
|
import { render, useInput } from "ink";
|
|
4352
4374
|
import { createHash as createHash2 } from "node:crypto";
|
|
4353
4375
|
import fs7, { readFileSync as readFileSync3 } from "node:fs";
|
|
4354
|
-
import { basename, dirname as dirname3, join as join6 } from "node:path";
|
|
4376
|
+
import { basename, dirname as dirname3, join as join6, normalize } from "node:path";
|
|
4355
4377
|
import pDebounce from "p-debounce";
|
|
4356
4378
|
import { WebSocket } from "partysocket";
|
|
4357
4379
|
import React, { Suspense, useEffect } from "react";
|
|
@@ -4549,8 +4571,8 @@ var CancelledProcessError = class extends Error {
|
|
|
4549
4571
|
}
|
|
4550
4572
|
};
|
|
4551
4573
|
var BackgroundWorker = class {
|
|
4552
|
-
constructor(
|
|
4553
|
-
this.path =
|
|
4574
|
+
constructor(path7, params) {
|
|
4575
|
+
this.path = path7;
|
|
4554
4576
|
this.params = params;
|
|
4555
4577
|
}
|
|
4556
4578
|
_initialized = false;
|
|
@@ -4638,6 +4660,9 @@ var BackgroundWorker = class {
|
|
|
4638
4660
|
reject(new Error(`Worker exited with code ${code}`));
|
|
4639
4661
|
}
|
|
4640
4662
|
});
|
|
4663
|
+
child.stdout?.on("data", (data) => {
|
|
4664
|
+
logger.log(data.toString());
|
|
4665
|
+
});
|
|
4641
4666
|
});
|
|
4642
4667
|
this._initialized = true;
|
|
4643
4668
|
}
|
|
@@ -4764,9 +4789,9 @@ var BackgroundWorker = class {
|
|
|
4764
4789
|
}
|
|
4765
4790
|
};
|
|
4766
4791
|
var TaskRunProcess = class {
|
|
4767
|
-
constructor(execution,
|
|
4792
|
+
constructor(execution, path7, env, metadata, worker) {
|
|
4768
4793
|
this.execution = execution;
|
|
4769
|
-
this.path =
|
|
4794
|
+
this.path = path7;
|
|
4770
4795
|
this.env = env;
|
|
4771
4796
|
this.metadata = metadata;
|
|
4772
4797
|
this.worker = worker;
|
|
@@ -4931,10 +4956,14 @@ var TaskRunProcess = class {
|
|
|
4931
4956
|
}
|
|
4932
4957
|
#handleLog(data) {
|
|
4933
4958
|
if (!this._currentExecution) {
|
|
4959
|
+
logger.log(`${chalkGrey("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${data.toString()}`);
|
|
4934
4960
|
return;
|
|
4935
4961
|
}
|
|
4962
|
+
const runId = chalkRun(
|
|
4963
|
+
`${this._currentExecution.run.id}.${this._currentExecution.attempt.number}`
|
|
4964
|
+
);
|
|
4936
4965
|
logger.log(
|
|
4937
|
-
|
|
4966
|
+
`${chalkGrey("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${runId} ${data.toString()}`
|
|
4938
4967
|
);
|
|
4939
4968
|
}
|
|
4940
4969
|
#handleStdErr(data) {
|
|
@@ -4942,11 +4971,14 @@ var TaskRunProcess = class {
|
|
|
4942
4971
|
return;
|
|
4943
4972
|
}
|
|
4944
4973
|
if (!this._currentExecution) {
|
|
4945
|
-
logger.
|
|
4974
|
+
logger.log(`${chalkError("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${data.toString()}`);
|
|
4946
4975
|
return;
|
|
4947
4976
|
}
|
|
4948
|
-
|
|
4949
|
-
|
|
4977
|
+
const runId = chalkRun(
|
|
4978
|
+
`${this._currentExecution.run.id}.${this._currentExecution.attempt.number}`
|
|
4979
|
+
);
|
|
4980
|
+
logger.log(
|
|
4981
|
+
`${chalkError("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${runId} ${data.toString()}`
|
|
4950
4982
|
);
|
|
4951
4983
|
}
|
|
4952
4984
|
#kill() {
|
|
@@ -4990,9 +5022,9 @@ function configureDevCommand(program2) {
|
|
|
4990
5022
|
"-p, --project-ref <project ref>",
|
|
4991
5023
|
"The project ref. Required if there is no config file."
|
|
4992
5024
|
).option("--debugger", "Enable the debugger").option("--debug-otel", "Enable OpenTelemetry debugging")
|
|
4993
|
-
).action(async (
|
|
5025
|
+
).action(async (path7, options) => {
|
|
4994
5026
|
wrapCommandAction("dev", DevCommandOptions, options, async (opts) => {
|
|
4995
|
-
await devCommand(
|
|
5027
|
+
await devCommand(path7, opts);
|
|
4996
5028
|
});
|
|
4997
5029
|
});
|
|
4998
5030
|
}
|
|
@@ -5196,22 +5228,21 @@ function useDev({
|
|
|
5196
5228
|
}
|
|
5197
5229
|
let latestWorkerContentHash;
|
|
5198
5230
|
const taskFiles = await gatherTaskFiles(config);
|
|
5199
|
-
const
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
"
|
|
5231
|
+
const workerFacadePath = join6(cliRootPath(), "workers", "dev", "worker-facade.js");
|
|
5232
|
+
const workerFacade = readFileSync3(workerFacadePath, "utf-8");
|
|
5233
|
+
const workerSetupPath = join6(cliRootPath(), "workers", "dev", "worker-setup.js");
|
|
5234
|
+
let entryPointContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace(
|
|
5235
|
+
"__WORKER_SETUP__",
|
|
5236
|
+
`import { tracingSDK, sender } from "${escapeImportPath(workerSetupPath)}";`
|
|
5205
5237
|
);
|
|
5206
|
-
const workerSetupPath = new URL(
|
|
5207
|
-
importResolve2("./workers/dev/worker-setup.js", import.meta.url)
|
|
5208
|
-
).href.replace("file://", "");
|
|
5209
|
-
let entryPointContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace("__WORKER_SETUP__", `import { tracingSDK, sender } from "${workerSetupPath}";`);
|
|
5210
5238
|
if (configPath) {
|
|
5239
|
+
configPath = normalize(configPath);
|
|
5211
5240
|
logger.debug("Importing project config from", { configPath });
|
|
5212
5241
|
entryPointContents = entryPointContents.replace(
|
|
5213
5242
|
"__IMPORTED_PROJECT_CONFIG__",
|
|
5214
|
-
`import * as importedConfigExports from "${
|
|
5243
|
+
`import * as importedConfigExports from "${escapeImportPath(
|
|
5244
|
+
configPath
|
|
5245
|
+
)}"; const importedConfig = importedConfigExports.config; const handleError = importedConfigExports.handleError;`
|
|
5215
5246
|
);
|
|
5216
5247
|
} else {
|
|
5217
5248
|
entryPointContents = entryPointContents.replace(
|
|
@@ -5264,7 +5295,10 @@ function useDev({
|
|
|
5264
5295
|
if (!firstBuild) {
|
|
5265
5296
|
logger.log(chalkGrey("\u25CB Building background worker\u2026"));
|
|
5266
5297
|
}
|
|
5267
|
-
const metaOutputKey = join6("out", `stdin.js`);
|
|
5298
|
+
const metaOutputKey = join6("out", `stdin.js`).replace(/\\/g, "/");
|
|
5299
|
+
logger.debug("Metafile", {
|
|
5300
|
+
metafileOutputs: JSON.stringify(result.metafile?.outputs)
|
|
5301
|
+
});
|
|
5268
5302
|
const metaOutput = result.metafile.outputs[metaOutputKey];
|
|
5269
5303
|
if (!metaOutput) {
|
|
5270
5304
|
throw new Error(`Could not find metafile`);
|
|
@@ -5429,12 +5463,12 @@ ${chalkError("X Error:")} The package ${chalkPurple(
|
|
|
5429
5463
|
ignoreInitial: true
|
|
5430
5464
|
}
|
|
5431
5465
|
);
|
|
5432
|
-
taskFileWatcher.on("add", async (
|
|
5466
|
+
taskFileWatcher.on("add", async (path7) => {
|
|
5433
5467
|
throttledRebuild().catch((error) => {
|
|
5434
5468
|
logger.error(error);
|
|
5435
5469
|
});
|
|
5436
5470
|
});
|
|
5437
|
-
taskFileWatcher.on("unlink", async (
|
|
5471
|
+
taskFileWatcher.on("unlink", async (path7) => {
|
|
5438
5472
|
throttledRebuild().catch((error) => {
|
|
5439
5473
|
logger.error(error);
|
|
5440
5474
|
});
|
|
@@ -5575,7 +5609,7 @@ async function findPnpmNodeModulesPath() {
|
|
|
5575
5609
|
}
|
|
5576
5610
|
|
|
5577
5611
|
// src/commands/init.ts
|
|
5578
|
-
import { intro as intro4, isCancel, log as
|
|
5612
|
+
import { intro as intro4, isCancel, log as log4, outro as outro4, select as select2, text } from "@clack/prompts";
|
|
5579
5613
|
import { context as context3, trace as trace3 } from "@opentelemetry/api";
|
|
5580
5614
|
import {
|
|
5581
5615
|
flattenAttributes as flattenAttributes3,
|
|
@@ -5591,7 +5625,7 @@ import { z as z6 } from "zod";
|
|
|
5591
5625
|
|
|
5592
5626
|
// src/utilities/createFileFromTemplate.ts
|
|
5593
5627
|
import fs8 from "fs/promises";
|
|
5594
|
-
import
|
|
5628
|
+
import path6 from "path";
|
|
5595
5629
|
async function createFileFromTemplate(params) {
|
|
5596
5630
|
let template = await readFile(params.templatePath);
|
|
5597
5631
|
if (await pathExists(params.outputPath) && !params.override) {
|
|
@@ -5602,7 +5636,7 @@ async function createFileFromTemplate(params) {
|
|
|
5602
5636
|
}
|
|
5603
5637
|
try {
|
|
5604
5638
|
const output = replaceAll(template, params.replacements);
|
|
5605
|
-
const directoryName =
|
|
5639
|
+
const directoryName = path6.dirname(params.outputPath);
|
|
5606
5640
|
await fs8.mkdir(directoryName, { recursive: true });
|
|
5607
5641
|
await fs8.writeFile(params.outputPath, output);
|
|
5608
5642
|
return {
|
|
@@ -5630,12 +5664,6 @@ function replaceAll(input, replacements) {
|
|
|
5630
5664
|
return output;
|
|
5631
5665
|
}
|
|
5632
5666
|
|
|
5633
|
-
// src/utilities/resolveInternalFilePath.ts
|
|
5634
|
-
import { resolve as importResolve3 } from "import-meta-resolve";
|
|
5635
|
-
function resolveInternalFilePath(filePath) {
|
|
5636
|
-
return new URL(importResolve3(filePath, import.meta.url)).href.replace("file://", "");
|
|
5637
|
-
}
|
|
5638
|
-
|
|
5639
5667
|
// src/commands/init.ts
|
|
5640
5668
|
var InitCommandOptions = CommonCommandOptions.extend({
|
|
5641
5669
|
projectRef: z6.string().optional(),
|
|
@@ -5653,10 +5681,10 @@ function configureInitCommand(program2) {
|
|
|
5653
5681
|
"The version of the @trigger.dev/sdk package to install",
|
|
5654
5682
|
"beta"
|
|
5655
5683
|
).option("--skip-package-install", "Skip installing the @trigger.dev/sdk package").option("--override-config", "Override the existing config file if it exists")
|
|
5656
|
-
).action(async (
|
|
5684
|
+
).action(async (path7, options) => {
|
|
5657
5685
|
await handleTelemetry(async () => {
|
|
5658
5686
|
await printStandloneInitialBanner(true);
|
|
5659
|
-
await initCommand(
|
|
5687
|
+
await initCommand(path7, options);
|
|
5660
5688
|
});
|
|
5661
5689
|
});
|
|
5662
5690
|
}
|
|
@@ -5708,11 +5736,11 @@ async function _initCommand(dir, options) {
|
|
|
5708
5736
|
...flattenAttributes3(selectedProject, "cli.project")
|
|
5709
5737
|
});
|
|
5710
5738
|
logger.debug("Selected project", selectedProject);
|
|
5711
|
-
|
|
5739
|
+
log4.step(`Configuring project "${selectedProject.name}" (${selectedProject.externalRef})`);
|
|
5712
5740
|
if (!options.skipPackageInstall) {
|
|
5713
5741
|
await installPackages2(dir, options);
|
|
5714
5742
|
} else {
|
|
5715
|
-
|
|
5743
|
+
log4.info("Skipping package installation");
|
|
5716
5744
|
}
|
|
5717
5745
|
const triggerDir = await createTriggerDir(dir, options);
|
|
5718
5746
|
await writeConfigFile(dir, selectedProject, options, triggerDir);
|
|
@@ -5722,21 +5750,21 @@ async function _initCommand(dir, options) {
|
|
|
5722
5750
|
"project dashboard",
|
|
5723
5751
|
`${authorization.dashboardUrl}/projects/v3/${selectedProject.externalRef}`
|
|
5724
5752
|
);
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5753
|
+
log4.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
|
|
5754
|
+
log4.info("Next steps:");
|
|
5755
|
+
log4.info(
|
|
5728
5756
|
` 1. To start developing, run ${chalk6.green(
|
|
5729
5757
|
`npx trigger.dev@${options.tag} dev`
|
|
5730
5758
|
)} in your project directory`
|
|
5731
5759
|
);
|
|
5732
|
-
|
|
5733
|
-
|
|
5760
|
+
log4.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
|
|
5761
|
+
log4.info(
|
|
5734
5762
|
` 3. Head over to our ${terminalLink3(
|
|
5735
5763
|
"v3 docs",
|
|
5736
5764
|
"https://trigger.dev/docs/v3"
|
|
5737
5765
|
)} to learn more.`
|
|
5738
5766
|
);
|
|
5739
|
-
|
|
5767
|
+
log4.info(
|
|
5740
5768
|
` 4. Need help? Join our ${terminalLink3(
|
|
5741
5769
|
"Discord community",
|
|
5742
5770
|
"https://trigger.dev/discord"
|
|
@@ -5747,7 +5775,7 @@ async function _initCommand(dir, options) {
|
|
|
5747
5775
|
async function createTriggerDir(dir, options) {
|
|
5748
5776
|
return await tracer.startActiveSpan("createTriggerDir", async (span) => {
|
|
5749
5777
|
try {
|
|
5750
|
-
const defaultValue =
|
|
5778
|
+
const defaultValue = join7(dir, "src", "trigger");
|
|
5751
5779
|
const location = await text({
|
|
5752
5780
|
message: "Where would you like to create the Trigger.dev directory?",
|
|
5753
5781
|
defaultValue,
|
|
@@ -5757,6 +5785,7 @@ async function createTriggerDir(dir, options) {
|
|
|
5757
5785
|
throw new OutroCommandError();
|
|
5758
5786
|
}
|
|
5759
5787
|
const triggerDir = resolve3(process.cwd(), location);
|
|
5788
|
+
logger.debug({ triggerDir });
|
|
5760
5789
|
span.setAttributes({
|
|
5761
5790
|
"cli.triggerDir": triggerDir
|
|
5762
5791
|
});
|
|
@@ -5783,19 +5812,19 @@ async function createTriggerDir(dir, options) {
|
|
|
5783
5812
|
});
|
|
5784
5813
|
if (example === "none") {
|
|
5785
5814
|
await createFile(join7(triggerDir, ".gitkeep"), "");
|
|
5786
|
-
|
|
5815
|
+
log4.step(`Created directory at ${location}`);
|
|
5787
5816
|
span.end();
|
|
5788
5817
|
return { location, isCustomValue: location !== defaultValue };
|
|
5789
5818
|
}
|
|
5790
|
-
const
|
|
5819
|
+
const templatePath = join7(cliRootPath(), "templates", "examples", `${example}.ts.template`);
|
|
5791
5820
|
const outputPath = join7(triggerDir, "example.ts");
|
|
5792
5821
|
await createFileFromTemplate({
|
|
5793
|
-
templatePath
|
|
5822
|
+
templatePath,
|
|
5794
5823
|
outputPath,
|
|
5795
5824
|
replacements: {}
|
|
5796
5825
|
});
|
|
5797
5826
|
const relativeOutputPath = relative4(process.cwd(), outputPath);
|
|
5798
|
-
|
|
5827
|
+
log4.step(`Created example file at ${relativeOutputPath}`);
|
|
5799
5828
|
span.end();
|
|
5800
5829
|
return { location, isCustomValue: location !== defaultValue };
|
|
5801
5830
|
} catch (e) {
|
|
@@ -5818,7 +5847,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
5818
5847
|
});
|
|
5819
5848
|
if (!await pathExists(gitIgnorePath)) {
|
|
5820
5849
|
await createFile(gitIgnorePath, ".trigger");
|
|
5821
|
-
|
|
5850
|
+
log4.step(`Added .trigger to .gitignore`);
|
|
5822
5851
|
span.end();
|
|
5823
5852
|
return;
|
|
5824
5853
|
}
|
|
@@ -5830,7 +5859,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
5830
5859
|
const newGitIgnoreContent = `${gitIgnoreContent}
|
|
5831
5860
|
.trigger`;
|
|
5832
5861
|
await writeFile3(gitIgnorePath, newGitIgnoreContent, "utf-8");
|
|
5833
|
-
|
|
5862
|
+
log4.step(`Added .trigger to .gitignore`);
|
|
5834
5863
|
span.end();
|
|
5835
5864
|
} catch (e) {
|
|
5836
5865
|
if (!(e instanceof SkipCommandError)) {
|
|
@@ -5863,7 +5892,7 @@ async function addConfigFileToTsConfig(dir, options) {
|
|
|
5863
5892
|
const newTsconfigContent = applyEdits(tsconfigContent, edits);
|
|
5864
5893
|
logger.debug("new tsconfig.json content", { newTsconfigContent });
|
|
5865
5894
|
await writeFile3(tsconfigPath, newTsconfigContent, "utf-8");
|
|
5866
|
-
|
|
5895
|
+
log4.step(`Added trigger.config.ts to tsconfig.json`);
|
|
5867
5896
|
span.end();
|
|
5868
5897
|
} catch (e) {
|
|
5869
5898
|
if (!(e instanceof SkipCommandError)) {
|
|
@@ -5876,7 +5905,7 @@ async function addConfigFileToTsConfig(dir, options) {
|
|
|
5876
5905
|
}
|
|
5877
5906
|
async function installPackages2(dir, options) {
|
|
5878
5907
|
return await tracer.startActiveSpan("installPackages", async (span) => {
|
|
5879
|
-
const installSpinner =
|
|
5908
|
+
const installSpinner = spinner();
|
|
5880
5909
|
try {
|
|
5881
5910
|
const projectDir = resolve3(process.cwd(), dir);
|
|
5882
5911
|
const pkgManager = await getUserPackageManager(projectDir);
|
|
@@ -5928,10 +5957,10 @@ async function installPackages2(dir, options) {
|
|
|
5928
5957
|
async function writeConfigFile(dir, project, options, triggerDir) {
|
|
5929
5958
|
return await tracer.startActiveSpan("writeConfigFile", async (span) => {
|
|
5930
5959
|
try {
|
|
5931
|
-
const spnnr =
|
|
5960
|
+
const spnnr = spinner();
|
|
5932
5961
|
spnnr.start("Creating config file");
|
|
5933
5962
|
const projectDir = resolve3(process.cwd(), dir);
|
|
5934
|
-
const templatePath =
|
|
5963
|
+
const templatePath = join7(cliRootPath(), "templates", "trigger.config.ts.template");
|
|
5935
5964
|
const outputPath = join7(projectDir, "trigger.config.ts");
|
|
5936
5965
|
span.setAttributes({
|
|
5937
5966
|
"cli.projectDir": projectDir,
|
|
@@ -5972,7 +6001,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
5972
6001
|
if (projectRef) {
|
|
5973
6002
|
const projectResponse = await apiClient2.getProject(projectRef);
|
|
5974
6003
|
if (!projectResponse.success) {
|
|
5975
|
-
|
|
6004
|
+
log4.error(
|
|
5976
6005
|
`--project-ref ${projectRef} is not a valid project ref. Request to fetch data resulted in: ${projectResponse.error}`
|
|
5977
6006
|
);
|
|
5978
6007
|
throw new SkipCommandError(projectResponse.error);
|
|
@@ -6055,7 +6084,7 @@ async function logout(options) {
|
|
|
6055
6084
|
}
|
|
6056
6085
|
|
|
6057
6086
|
// src/commands/list-profiles.ts
|
|
6058
|
-
import { log as
|
|
6087
|
+
import { log as log5, outro as outro5 } from "@clack/prompts";
|
|
6059
6088
|
var ListProfilesOptions = CommonCommandOptions;
|
|
6060
6089
|
function configureListProfilesCommand(program2) {
|
|
6061
6090
|
return program2.command("list-profiles").description("List all of your CLI profiles").option(
|
|
@@ -6081,10 +6110,10 @@ async function listProfiles(options) {
|
|
|
6081
6110
|
return;
|
|
6082
6111
|
}
|
|
6083
6112
|
const profiles = Object.keys(authConfig);
|
|
6084
|
-
|
|
6113
|
+
log5.message("Profiles:");
|
|
6085
6114
|
for (const profile of profiles) {
|
|
6086
6115
|
const profileConfig = authConfig[profile];
|
|
6087
|
-
|
|
6116
|
+
log5.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
|
|
6088
6117
|
}
|
|
6089
6118
|
outro5("Retrieve account info by running whoami --profile <profile>");
|
|
6090
6119
|
}
|