trigger.dev 0.0.0-v3-pnpm-fix-20240409132306 → 0.0.0-v3-schedules-beta-20240417103105
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 +219 -187
- 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/entry-point.js +20 -15
- 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-20240417103105";
|
|
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-20240417103105",
|
|
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,
|
|
@@ -3079,9 +3099,9 @@ import { join as join4 } from "node:path";
|
|
|
3079
3099
|
|
|
3080
3100
|
// src/utilities/getUserPackageManager.ts
|
|
3081
3101
|
import { findUp as findUp2 } from "find-up";
|
|
3082
|
-
async function getUserPackageManager(
|
|
3102
|
+
async function getUserPackageManager(path7) {
|
|
3083
3103
|
try {
|
|
3084
|
-
return await detectPackageManagerFromArtifacts(
|
|
3104
|
+
return await detectPackageManagerFromArtifacts(path7);
|
|
3085
3105
|
} catch (error) {
|
|
3086
3106
|
return detectPackageManagerFromCurrentCommand();
|
|
3087
3107
|
}
|
|
@@ -3100,7 +3120,7 @@ function detectPackageManagerFromCurrentCommand() {
|
|
|
3100
3120
|
return "npm";
|
|
3101
3121
|
}
|
|
3102
3122
|
}
|
|
3103
|
-
async function detectPackageManagerFromArtifacts(
|
|
3123
|
+
async function detectPackageManagerFromArtifacts(path7) {
|
|
3104
3124
|
const packageFiles = [
|
|
3105
3125
|
{ name: "yarn.lock", pm: "yarn" },
|
|
3106
3126
|
{ name: "pnpm-lock.yaml", pm: "pnpm" },
|
|
@@ -3108,7 +3128,7 @@ async function detectPackageManagerFromArtifacts(path6) {
|
|
|
3108
3128
|
{ name: "npm-shrinkwrap.json", pm: "npm" }
|
|
3109
3129
|
];
|
|
3110
3130
|
for (const { name, pm } of packageFiles) {
|
|
3111
|
-
const foundPath = await findUp2(name, { cwd:
|
|
3131
|
+
const foundPath = await findUp2(name, { cwd: path7 });
|
|
3112
3132
|
if (typeof foundPath === "string") {
|
|
3113
3133
|
return pm;
|
|
3114
3134
|
}
|
|
@@ -3270,6 +3290,15 @@ var YarnCommands = class {
|
|
|
3270
3290
|
}
|
|
3271
3291
|
};
|
|
3272
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
|
+
|
|
3273
3302
|
// src/commands/deploy.ts
|
|
3274
3303
|
var DeployCommandOptions = CommonCommandOptions.extend({
|
|
3275
3304
|
skipTypecheck: z4.boolean().default(false),
|
|
@@ -3297,7 +3326,7 @@ function configureDeployCommand(program2) {
|
|
|
3297
3326
|
"Detected missing environment variables won't block deployment"
|
|
3298
3327
|
).option("-c, --config <config file>", "The name of the config file, found at [path]").option(
|
|
3299
3328
|
"-p, --project-ref <project ref>",
|
|
3300
|
-
"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."
|
|
3301
3330
|
)
|
|
3302
3331
|
).addOption(
|
|
3303
3332
|
new CommandOption(
|
|
@@ -3331,10 +3360,10 @@ function configureDeployCommand(program2) {
|
|
|
3331
3360
|
"--output-metafile <path>",
|
|
3332
3361
|
"If provided, will save the esbuild metafile for the build to the specified path"
|
|
3333
3362
|
).hideHelp()
|
|
3334
|
-
).action(async (
|
|
3363
|
+
).action(async (path7, options) => {
|
|
3335
3364
|
await handleTelemetry(async () => {
|
|
3336
3365
|
await printStandloneInitialBanner(true);
|
|
3337
|
-
await deployCommand(
|
|
3366
|
+
await deployCommand(path7, options);
|
|
3338
3367
|
});
|
|
3339
3368
|
});
|
|
3340
3369
|
}
|
|
@@ -3388,7 +3417,7 @@ async function _deployCommand(dir, options) {
|
|
|
3388
3417
|
throw new Error(deploymentEnv.error);
|
|
3389
3418
|
}
|
|
3390
3419
|
const environmentClient = new CliApiClient(authorization.auth.apiUrl, deploymentEnv.data.apiKey);
|
|
3391
|
-
|
|
3420
|
+
log3.step(
|
|
3392
3421
|
`Preparing to deploy "${deploymentEnv.data.name}" (${resolvedConfig.config.project}) to ${options.env}`
|
|
3393
3422
|
);
|
|
3394
3423
|
const compilation = await compileProject(
|
|
@@ -3419,7 +3448,7 @@ async function _deployCommand(dir, options) {
|
|
|
3419
3448
|
);
|
|
3420
3449
|
}
|
|
3421
3450
|
const version2 = deploymentResponse.data.version;
|
|
3422
|
-
const deploymentSpinner =
|
|
3451
|
+
const deploymentSpinner = spinner();
|
|
3423
3452
|
deploymentSpinner.start(`Deploying version ${version2}`);
|
|
3424
3453
|
const selfHostedRegistryHost = deploymentResponse.data.registryHost ?? options.registry;
|
|
3425
3454
|
const registryHost = selfHostedRegistryHost ?? "registry.trigger.dev";
|
|
@@ -3580,7 +3609,7 @@ async function checkEnvVars(envVars, config, options, environmentClient, apiUrl)
|
|
|
3580
3609
|
return await tracer.startActiveSpan("detectEnvVars", async (span) => {
|
|
3581
3610
|
try {
|
|
3582
3611
|
span.setAttribute("envVars.check", envVars);
|
|
3583
|
-
const environmentVariablesSpinner =
|
|
3612
|
+
const environmentVariablesSpinner = spinner();
|
|
3584
3613
|
environmentVariablesSpinner.start("Checking environment variables");
|
|
3585
3614
|
const environmentVariables = await environmentClient.getEnvironmentVariables(config.project);
|
|
3586
3615
|
if (!environmentVariables.success) {
|
|
@@ -3713,7 +3742,8 @@ async function buildAndPushImage(options, updater) {
|
|
|
3713
3742
|
const processCode = await new Promise((res, rej) => {
|
|
3714
3743
|
childProcess2.stderr?.on("data", (data) => {
|
|
3715
3744
|
const text3 = data.toString();
|
|
3716
|
-
|
|
3745
|
+
const lines = text3.split("\n").filter(Boolean);
|
|
3746
|
+
errors.push(...lines);
|
|
3717
3747
|
logger.debug(text3);
|
|
3718
3748
|
});
|
|
3719
3749
|
childProcess2.on("error", (e) => rej(e));
|
|
@@ -3867,13 +3897,12 @@ async function buildAndPushSelfHostedImage(options) {
|
|
|
3867
3897
|
});
|
|
3868
3898
|
}
|
|
3869
3899
|
function extractImageDigest(outputs) {
|
|
3870
|
-
const imageDigestRegex = /sha256:[a-f0-9]{64}/;
|
|
3900
|
+
const imageDigestRegex = /pushing manifest for .+(?<digest>sha256:[a-f0-9]{64})/;
|
|
3871
3901
|
for (const line of outputs) {
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
}
|
|
3902
|
+
const imageDigestMatch = line.match(imageDigestRegex);
|
|
3903
|
+
const digest = imageDigestMatch?.groups?.digest;
|
|
3904
|
+
if (digest) {
|
|
3905
|
+
return digest;
|
|
3877
3906
|
}
|
|
3878
3907
|
}
|
|
3879
3908
|
}
|
|
@@ -3890,25 +3919,25 @@ async function compileProject(config, options, configPath) {
|
|
|
3890
3919
|
throw new Error("Typecheck failed, aborting deployment");
|
|
3891
3920
|
}
|
|
3892
3921
|
}
|
|
3893
|
-
const compileSpinner =
|
|
3922
|
+
const compileSpinner = spinner();
|
|
3894
3923
|
compileSpinner.start(`Building project in ${config.projectDir}`);
|
|
3895
3924
|
const taskFiles = await gatherTaskFiles(config);
|
|
3896
3925
|
const workerFacade = readFileSync2(
|
|
3897
|
-
|
|
3898
|
-
"file://",
|
|
3899
|
-
""
|
|
3900
|
-
),
|
|
3926
|
+
join5(cliRootPath(), "workers", "prod", "worker-facade.js"),
|
|
3901
3927
|
"utf-8"
|
|
3902
3928
|
);
|
|
3903
|
-
const workerSetupPath =
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
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
|
+
);
|
|
3907
3934
|
if (configPath) {
|
|
3908
3935
|
logger.debug("Importing project config from", { configPath });
|
|
3909
3936
|
workerContents = workerContents.replace(
|
|
3910
3937
|
"__IMPORTED_PROJECT_CONFIG__",
|
|
3911
|
-
`import * as importedConfigExports from "${
|
|
3938
|
+
`import * as importedConfigExports from "${escapeImportPath(
|
|
3939
|
+
configPath
|
|
3940
|
+
)}"; const importedConfig = importedConfigExports.config; const handleError = importedConfigExports.handleError;`
|
|
3912
3941
|
);
|
|
3913
3942
|
} else {
|
|
3914
3943
|
workerContents = workerContents.replace(
|
|
@@ -3960,10 +3989,7 @@ async function compileProject(config, options, configPath) {
|
|
|
3960
3989
|
await writeJSONFile(join5(options.outputMetafile, "worker.json"), result.metafile);
|
|
3961
3990
|
}
|
|
3962
3991
|
const entryPointContents = readFileSync2(
|
|
3963
|
-
|
|
3964
|
-
"file://",
|
|
3965
|
-
""
|
|
3966
|
-
),
|
|
3992
|
+
join5(cliRootPath(), "workers", "prod", "entry-point.js"),
|
|
3967
3993
|
"utf-8"
|
|
3968
3994
|
);
|
|
3969
3995
|
const entryPointResult = await build2({
|
|
@@ -4012,9 +4038,9 @@ async function compileProject(config, options, configPath) {
|
|
|
4012
4038
|
}
|
|
4013
4039
|
const tempDir = await createTempDir();
|
|
4014
4040
|
logger.debug(`Writing compiled files to ${tempDir}`);
|
|
4015
|
-
const metaOutput = result.metafile.outputs[
|
|
4041
|
+
const metaOutput = result.metafile.outputs[posix.join("out", "stdin.js")];
|
|
4016
4042
|
invariant(metaOutput, "Meta output for the result build is missing");
|
|
4017
|
-
const entryPointMetaOutput = entryPointResult.metafile.outputs[
|
|
4043
|
+
const entryPointMetaOutput = entryPointResult.metafile.outputs[posix.join("out", "stdin.js")];
|
|
4018
4044
|
invariant(entryPointMetaOutput, "Meta output for the entryPoint build is missing");
|
|
4019
4045
|
const workerOutputFile = result.outputFiles.find(
|
|
4020
4046
|
(file) => file.path === join5(config.projectDir, "out", "stdin.js")
|
|
@@ -4063,9 +4089,7 @@ async function compileProject(config, options, configPath) {
|
|
|
4063
4089
|
if (!resolvingDependenciesResult) {
|
|
4064
4090
|
throw new SkipLoggingError("Failed to resolve dependencies");
|
|
4065
4091
|
}
|
|
4066
|
-
const containerFilePath =
|
|
4067
|
-
importResolve("./Containerfile.prod", import.meta.url)
|
|
4068
|
-
).href.replace("file://", "");
|
|
4092
|
+
const containerFilePath = join5(cliRootPath(), "Containerfile.prod");
|
|
4069
4093
|
await copyFile(containerFilePath, join5(tempDir, "Containerfile"));
|
|
4070
4094
|
const contentHasher = createHash("sha256");
|
|
4071
4095
|
contentHasher.update(Buffer.from(entryPointOutputFile.text));
|
|
@@ -4093,7 +4117,7 @@ async function compileProject(config, options, configPath) {
|
|
|
4093
4117
|
}
|
|
4094
4118
|
async function resolveDependencies(projectDir, packageJsonContents, config, options) {
|
|
4095
4119
|
return await tracer.startActiveSpan("resolveDependencies", async (span) => {
|
|
4096
|
-
const resolvingDepsSpinner =
|
|
4120
|
+
const resolvingDepsSpinner = spinner();
|
|
4097
4121
|
resolvingDepsSpinner.start("Resolving dependencies");
|
|
4098
4122
|
const hasher = createHash("sha256");
|
|
4099
4123
|
hasher.update(JSON.stringify(packageJsonContents));
|
|
@@ -4177,7 +4201,7 @@ ${chalkError("X Error:")} The package ${chalkPurple(
|
|
|
4177
4201
|
async function typecheckProject(config, options) {
|
|
4178
4202
|
return await tracer.startActiveSpan("typecheckProject", async (span) => {
|
|
4179
4203
|
try {
|
|
4180
|
-
const typecheckSpinner =
|
|
4204
|
+
const typecheckSpinner = spinner();
|
|
4181
4205
|
typecheckSpinner.start("Typechecking project");
|
|
4182
4206
|
const tscTypecheck = execa2("npm", ["exec", "tsc", "--", "--noEmit"], {
|
|
4183
4207
|
cwd: config.projectDir
|
|
@@ -4346,11 +4370,10 @@ import {
|
|
|
4346
4370
|
} from "@trigger.dev/core/v3";
|
|
4347
4371
|
import { watch } from "chokidar";
|
|
4348
4372
|
import { context as context2 } from "esbuild";
|
|
4349
|
-
import { resolve as importResolve2 } from "import-meta-resolve";
|
|
4350
4373
|
import { render, useInput } from "ink";
|
|
4351
4374
|
import { createHash as createHash2 } from "node:crypto";
|
|
4352
4375
|
import fs7, { readFileSync as readFileSync3 } from "node:fs";
|
|
4353
|
-
import { basename, dirname as dirname3, join as join6 } from "node:path";
|
|
4376
|
+
import { basename, dirname as dirname3, join as join6, normalize } from "node:path";
|
|
4354
4377
|
import pDebounce from "p-debounce";
|
|
4355
4378
|
import { WebSocket } from "partysocket";
|
|
4356
4379
|
import React, { Suspense, useEffect } from "react";
|
|
@@ -4548,8 +4571,8 @@ var CancelledProcessError = class extends Error {
|
|
|
4548
4571
|
}
|
|
4549
4572
|
};
|
|
4550
4573
|
var BackgroundWorker = class {
|
|
4551
|
-
constructor(
|
|
4552
|
-
this.path =
|
|
4574
|
+
constructor(path7, params) {
|
|
4575
|
+
this.path = path7;
|
|
4553
4576
|
this.params = params;
|
|
4554
4577
|
}
|
|
4555
4578
|
_initialized = false;
|
|
@@ -4637,6 +4660,9 @@ var BackgroundWorker = class {
|
|
|
4637
4660
|
reject(new Error(`Worker exited with code ${code}`));
|
|
4638
4661
|
}
|
|
4639
4662
|
});
|
|
4663
|
+
child.stdout?.on("data", (data) => {
|
|
4664
|
+
logger.log(data.toString());
|
|
4665
|
+
});
|
|
4640
4666
|
});
|
|
4641
4667
|
this._initialized = true;
|
|
4642
4668
|
}
|
|
@@ -4763,9 +4789,9 @@ var BackgroundWorker = class {
|
|
|
4763
4789
|
}
|
|
4764
4790
|
};
|
|
4765
4791
|
var TaskRunProcess = class {
|
|
4766
|
-
constructor(execution,
|
|
4792
|
+
constructor(execution, path7, env, metadata, worker) {
|
|
4767
4793
|
this.execution = execution;
|
|
4768
|
-
this.path =
|
|
4794
|
+
this.path = path7;
|
|
4769
4795
|
this.env = env;
|
|
4770
4796
|
this.metadata = metadata;
|
|
4771
4797
|
this.worker = worker;
|
|
@@ -4930,10 +4956,14 @@ var TaskRunProcess = class {
|
|
|
4930
4956
|
}
|
|
4931
4957
|
#handleLog(data) {
|
|
4932
4958
|
if (!this._currentExecution) {
|
|
4959
|
+
logger.log(`${chalkGrey("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${data.toString()}`);
|
|
4933
4960
|
return;
|
|
4934
4961
|
}
|
|
4962
|
+
const runId = chalkRun(
|
|
4963
|
+
`${this._currentExecution.run.id}.${this._currentExecution.attempt.number}`
|
|
4964
|
+
);
|
|
4935
4965
|
logger.log(
|
|
4936
|
-
|
|
4966
|
+
`${chalkGrey("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${runId} ${data.toString()}`
|
|
4937
4967
|
);
|
|
4938
4968
|
}
|
|
4939
4969
|
#handleStdErr(data) {
|
|
@@ -4941,11 +4971,14 @@ var TaskRunProcess = class {
|
|
|
4941
4971
|
return;
|
|
4942
4972
|
}
|
|
4943
4973
|
if (!this._currentExecution) {
|
|
4944
|
-
logger.
|
|
4974
|
+
logger.log(`${chalkError("\u25CB")} ${chalkGrey(prettyPrintDate(/* @__PURE__ */ new Date()))} ${data.toString()}`);
|
|
4945
4975
|
return;
|
|
4946
4976
|
}
|
|
4947
|
-
|
|
4948
|
-
|
|
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()}`
|
|
4949
4982
|
);
|
|
4950
4983
|
}
|
|
4951
4984
|
#kill() {
|
|
@@ -4989,9 +5022,9 @@ function configureDevCommand(program2) {
|
|
|
4989
5022
|
"-p, --project-ref <project ref>",
|
|
4990
5023
|
"The project ref. Required if there is no config file."
|
|
4991
5024
|
).option("--debugger", "Enable the debugger").option("--debug-otel", "Enable OpenTelemetry debugging")
|
|
4992
|
-
).action(async (
|
|
5025
|
+
).action(async (path7, options) => {
|
|
4993
5026
|
wrapCommandAction("dev", DevCommandOptions, options, async (opts) => {
|
|
4994
|
-
await devCommand(
|
|
5027
|
+
await devCommand(path7, opts);
|
|
4995
5028
|
});
|
|
4996
5029
|
});
|
|
4997
5030
|
}
|
|
@@ -5019,11 +5052,11 @@ async function devCommand(dir, options) {
|
|
|
5019
5052
|
process.exitCode = 1;
|
|
5020
5053
|
return;
|
|
5021
5054
|
}
|
|
5022
|
-
const devInstance = await startDev(dir, options, authorization.auth);
|
|
5055
|
+
const devInstance = await startDev(dir, options, authorization.auth, authorization.dashboardUrl);
|
|
5023
5056
|
const { waitUntilExit } = devInstance.devReactElement;
|
|
5024
5057
|
await waitUntilExit();
|
|
5025
5058
|
}
|
|
5026
|
-
async function startDev(dir, options, authorization) {
|
|
5059
|
+
async function startDev(dir, options, authorization, dashboardUrl) {
|
|
5027
5060
|
let rerender;
|
|
5028
5061
|
try {
|
|
5029
5062
|
if (options.logLevel) {
|
|
@@ -5061,6 +5094,7 @@ async function startDev(dir, options, authorization) {
|
|
|
5061
5094
|
return /* @__PURE__ */ React.createElement(
|
|
5062
5095
|
DevUI,
|
|
5063
5096
|
{
|
|
5097
|
+
dashboardUrl,
|
|
5064
5098
|
config: configParam,
|
|
5065
5099
|
apiUrl,
|
|
5066
5100
|
apiKey: devEnv.data.apiKey,
|
|
@@ -5092,6 +5126,7 @@ async function startDev(dir, options, authorization) {
|
|
|
5092
5126
|
}
|
|
5093
5127
|
function useDev({
|
|
5094
5128
|
config,
|
|
5129
|
+
dashboardUrl,
|
|
5095
5130
|
apiUrl,
|
|
5096
5131
|
apiKey,
|
|
5097
5132
|
environmentClient,
|
|
@@ -5121,7 +5156,7 @@ function useDev({
|
|
|
5121
5156
|
}
|
|
5122
5157
|
});
|
|
5123
5158
|
const backgroundWorkerCoordinator = new BackgroundWorkerCoordinator(
|
|
5124
|
-
`${
|
|
5159
|
+
`${dashboardUrl}/projects/v3/${config.project}`
|
|
5125
5160
|
);
|
|
5126
5161
|
websocket.addEventListener("open", async (event) => {
|
|
5127
5162
|
});
|
|
@@ -5193,22 +5228,21 @@ function useDev({
|
|
|
5193
5228
|
}
|
|
5194
5229
|
let latestWorkerContentHash;
|
|
5195
5230
|
const taskFiles = await gatherTaskFiles(config);
|
|
5196
|
-
const
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
"
|
|
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)}";`
|
|
5202
5237
|
);
|
|
5203
|
-
const workerSetupPath = new URL(
|
|
5204
|
-
importResolve2("./workers/dev/worker-setup.js", import.meta.url)
|
|
5205
|
-
).href.replace("file://", "");
|
|
5206
|
-
let entryPointContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace("__WORKER_SETUP__", `import { tracingSDK, sender } from "${workerSetupPath}";`);
|
|
5207
5238
|
if (configPath) {
|
|
5239
|
+
configPath = normalize(configPath);
|
|
5208
5240
|
logger.debug("Importing project config from", { configPath });
|
|
5209
5241
|
entryPointContents = entryPointContents.replace(
|
|
5210
5242
|
"__IMPORTED_PROJECT_CONFIG__",
|
|
5211
|
-
`import * as importedConfigExports from "${
|
|
5243
|
+
`import * as importedConfigExports from "${escapeImportPath(
|
|
5244
|
+
configPath
|
|
5245
|
+
)}"; const importedConfig = importedConfigExports.config; const handleError = importedConfigExports.handleError;`
|
|
5212
5246
|
);
|
|
5213
5247
|
} else {
|
|
5214
5248
|
entryPointContents = entryPointContents.replace(
|
|
@@ -5261,7 +5295,10 @@ function useDev({
|
|
|
5261
5295
|
if (!firstBuild) {
|
|
5262
5296
|
logger.log(chalkGrey("\u25CB Building background worker\u2026"));
|
|
5263
5297
|
}
|
|
5264
|
-
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
|
+
});
|
|
5265
5302
|
const metaOutput = result.metafile.outputs[metaOutputKey];
|
|
5266
5303
|
if (!metaOutput) {
|
|
5267
5304
|
throw new Error(`Could not find metafile`);
|
|
@@ -5426,12 +5463,12 @@ ${chalkError("X Error:")} The package ${chalkPurple(
|
|
|
5426
5463
|
ignoreInitial: true
|
|
5427
5464
|
}
|
|
5428
5465
|
);
|
|
5429
|
-
taskFileWatcher.on("add", async (
|
|
5466
|
+
taskFileWatcher.on("add", async (path7) => {
|
|
5430
5467
|
throttledRebuild().catch((error) => {
|
|
5431
5468
|
logger.error(error);
|
|
5432
5469
|
});
|
|
5433
5470
|
});
|
|
5434
|
-
taskFileWatcher.on("unlink", async (
|
|
5471
|
+
taskFileWatcher.on("unlink", async (path7) => {
|
|
5435
5472
|
throttledRebuild().catch((error) => {
|
|
5436
5473
|
logger.error(error);
|
|
5437
5474
|
});
|
|
@@ -5572,7 +5609,7 @@ async function findPnpmNodeModulesPath() {
|
|
|
5572
5609
|
}
|
|
5573
5610
|
|
|
5574
5611
|
// src/commands/init.ts
|
|
5575
|
-
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";
|
|
5576
5613
|
import { context as context3, trace as trace3 } from "@opentelemetry/api";
|
|
5577
5614
|
import {
|
|
5578
5615
|
flattenAttributes as flattenAttributes3,
|
|
@@ -5588,7 +5625,7 @@ import { z as z6 } from "zod";
|
|
|
5588
5625
|
|
|
5589
5626
|
// src/utilities/createFileFromTemplate.ts
|
|
5590
5627
|
import fs8 from "fs/promises";
|
|
5591
|
-
import
|
|
5628
|
+
import path6 from "path";
|
|
5592
5629
|
async function createFileFromTemplate(params) {
|
|
5593
5630
|
let template = await readFile(params.templatePath);
|
|
5594
5631
|
if (await pathExists(params.outputPath) && !params.override) {
|
|
@@ -5599,7 +5636,7 @@ async function createFileFromTemplate(params) {
|
|
|
5599
5636
|
}
|
|
5600
5637
|
try {
|
|
5601
5638
|
const output = replaceAll(template, params.replacements);
|
|
5602
|
-
const directoryName =
|
|
5639
|
+
const directoryName = path6.dirname(params.outputPath);
|
|
5603
5640
|
await fs8.mkdir(directoryName, { recursive: true });
|
|
5604
5641
|
await fs8.writeFile(params.outputPath, output);
|
|
5605
5642
|
return {
|
|
@@ -5627,12 +5664,6 @@ function replaceAll(input, replacements) {
|
|
|
5627
5664
|
return output;
|
|
5628
5665
|
}
|
|
5629
5666
|
|
|
5630
|
-
// src/utilities/resolveInternalFilePath.ts
|
|
5631
|
-
import { resolve as importResolve3 } from "import-meta-resolve";
|
|
5632
|
-
function resolveInternalFilePath(filePath) {
|
|
5633
|
-
return new URL(importResolve3(filePath, import.meta.url)).href.replace("file://", "");
|
|
5634
|
-
}
|
|
5635
|
-
|
|
5636
5667
|
// src/commands/init.ts
|
|
5637
5668
|
var InitCommandOptions = CommonCommandOptions.extend({
|
|
5638
5669
|
projectRef: z6.string().optional(),
|
|
@@ -5650,10 +5681,10 @@ function configureInitCommand(program2) {
|
|
|
5650
5681
|
"The version of the @trigger.dev/sdk package to install",
|
|
5651
5682
|
"beta"
|
|
5652
5683
|
).option("--skip-package-install", "Skip installing the @trigger.dev/sdk package").option("--override-config", "Override the existing config file if it exists")
|
|
5653
|
-
).action(async (
|
|
5684
|
+
).action(async (path7, options) => {
|
|
5654
5685
|
await handleTelemetry(async () => {
|
|
5655
5686
|
await printStandloneInitialBanner(true);
|
|
5656
|
-
await initCommand(
|
|
5687
|
+
await initCommand(path7, options);
|
|
5657
5688
|
});
|
|
5658
5689
|
});
|
|
5659
5690
|
}
|
|
@@ -5705,11 +5736,11 @@ async function _initCommand(dir, options) {
|
|
|
5705
5736
|
...flattenAttributes3(selectedProject, "cli.project")
|
|
5706
5737
|
});
|
|
5707
5738
|
logger.debug("Selected project", selectedProject);
|
|
5708
|
-
|
|
5739
|
+
log4.step(`Configuring project "${selectedProject.name}" (${selectedProject.externalRef})`);
|
|
5709
5740
|
if (!options.skipPackageInstall) {
|
|
5710
5741
|
await installPackages2(dir, options);
|
|
5711
5742
|
} else {
|
|
5712
|
-
|
|
5743
|
+
log4.info("Skipping package installation");
|
|
5713
5744
|
}
|
|
5714
5745
|
const triggerDir = await createTriggerDir(dir, options);
|
|
5715
5746
|
await writeConfigFile(dir, selectedProject, options, triggerDir);
|
|
@@ -5719,21 +5750,21 @@ async function _initCommand(dir, options) {
|
|
|
5719
5750
|
"project dashboard",
|
|
5720
5751
|
`${authorization.dashboardUrl}/projects/v3/${selectedProject.externalRef}`
|
|
5721
5752
|
);
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5753
|
+
log4.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
|
|
5754
|
+
log4.info("Next steps:");
|
|
5755
|
+
log4.info(
|
|
5725
5756
|
` 1. To start developing, run ${chalk6.green(
|
|
5726
5757
|
`npx trigger.dev@${options.tag} dev`
|
|
5727
5758
|
)} in your project directory`
|
|
5728
5759
|
);
|
|
5729
|
-
|
|
5730
|
-
|
|
5760
|
+
log4.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
|
|
5761
|
+
log4.info(
|
|
5731
5762
|
` 3. Head over to our ${terminalLink3(
|
|
5732
5763
|
"v3 docs",
|
|
5733
5764
|
"https://trigger.dev/docs/v3"
|
|
5734
5765
|
)} to learn more.`
|
|
5735
5766
|
);
|
|
5736
|
-
|
|
5767
|
+
log4.info(
|
|
5737
5768
|
` 4. Need help? Join our ${terminalLink3(
|
|
5738
5769
|
"Discord community",
|
|
5739
5770
|
"https://trigger.dev/discord"
|
|
@@ -5744,7 +5775,7 @@ async function _initCommand(dir, options) {
|
|
|
5744
5775
|
async function createTriggerDir(dir, options) {
|
|
5745
5776
|
return await tracer.startActiveSpan("createTriggerDir", async (span) => {
|
|
5746
5777
|
try {
|
|
5747
|
-
const defaultValue =
|
|
5778
|
+
const defaultValue = join7(dir, "src", "trigger");
|
|
5748
5779
|
const location = await text({
|
|
5749
5780
|
message: "Where would you like to create the Trigger.dev directory?",
|
|
5750
5781
|
defaultValue,
|
|
@@ -5754,6 +5785,7 @@ async function createTriggerDir(dir, options) {
|
|
|
5754
5785
|
throw new OutroCommandError();
|
|
5755
5786
|
}
|
|
5756
5787
|
const triggerDir = resolve3(process.cwd(), location);
|
|
5788
|
+
logger.debug({ triggerDir });
|
|
5757
5789
|
span.setAttributes({
|
|
5758
5790
|
"cli.triggerDir": triggerDir
|
|
5759
5791
|
});
|
|
@@ -5780,19 +5812,19 @@ async function createTriggerDir(dir, options) {
|
|
|
5780
5812
|
});
|
|
5781
5813
|
if (example === "none") {
|
|
5782
5814
|
await createFile(join7(triggerDir, ".gitkeep"), "");
|
|
5783
|
-
|
|
5815
|
+
log4.step(`Created directory at ${location}`);
|
|
5784
5816
|
span.end();
|
|
5785
5817
|
return { location, isCustomValue: location !== defaultValue };
|
|
5786
5818
|
}
|
|
5787
|
-
const
|
|
5819
|
+
const templatePath = join7(cliRootPath(), "templates", "examples", `${example}.ts.template`);
|
|
5788
5820
|
const outputPath = join7(triggerDir, "example.ts");
|
|
5789
5821
|
await createFileFromTemplate({
|
|
5790
|
-
templatePath
|
|
5822
|
+
templatePath,
|
|
5791
5823
|
outputPath,
|
|
5792
5824
|
replacements: {}
|
|
5793
5825
|
});
|
|
5794
5826
|
const relativeOutputPath = relative4(process.cwd(), outputPath);
|
|
5795
|
-
|
|
5827
|
+
log4.step(`Created example file at ${relativeOutputPath}`);
|
|
5796
5828
|
span.end();
|
|
5797
5829
|
return { location, isCustomValue: location !== defaultValue };
|
|
5798
5830
|
} catch (e) {
|
|
@@ -5815,7 +5847,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
5815
5847
|
});
|
|
5816
5848
|
if (!await pathExists(gitIgnorePath)) {
|
|
5817
5849
|
await createFile(gitIgnorePath, ".trigger");
|
|
5818
|
-
|
|
5850
|
+
log4.step(`Added .trigger to .gitignore`);
|
|
5819
5851
|
span.end();
|
|
5820
5852
|
return;
|
|
5821
5853
|
}
|
|
@@ -5827,7 +5859,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
5827
5859
|
const newGitIgnoreContent = `${gitIgnoreContent}
|
|
5828
5860
|
.trigger`;
|
|
5829
5861
|
await writeFile3(gitIgnorePath, newGitIgnoreContent, "utf-8");
|
|
5830
|
-
|
|
5862
|
+
log4.step(`Added .trigger to .gitignore`);
|
|
5831
5863
|
span.end();
|
|
5832
5864
|
} catch (e) {
|
|
5833
5865
|
if (!(e instanceof SkipCommandError)) {
|
|
@@ -5860,7 +5892,7 @@ async function addConfigFileToTsConfig(dir, options) {
|
|
|
5860
5892
|
const newTsconfigContent = applyEdits(tsconfigContent, edits);
|
|
5861
5893
|
logger.debug("new tsconfig.json content", { newTsconfigContent });
|
|
5862
5894
|
await writeFile3(tsconfigPath, newTsconfigContent, "utf-8");
|
|
5863
|
-
|
|
5895
|
+
log4.step(`Added trigger.config.ts to tsconfig.json`);
|
|
5864
5896
|
span.end();
|
|
5865
5897
|
} catch (e) {
|
|
5866
5898
|
if (!(e instanceof SkipCommandError)) {
|
|
@@ -5873,7 +5905,7 @@ async function addConfigFileToTsConfig(dir, options) {
|
|
|
5873
5905
|
}
|
|
5874
5906
|
async function installPackages2(dir, options) {
|
|
5875
5907
|
return await tracer.startActiveSpan("installPackages", async (span) => {
|
|
5876
|
-
const installSpinner =
|
|
5908
|
+
const installSpinner = spinner();
|
|
5877
5909
|
try {
|
|
5878
5910
|
const projectDir = resolve3(process.cwd(), dir);
|
|
5879
5911
|
const pkgManager = await getUserPackageManager(projectDir);
|
|
@@ -5925,10 +5957,10 @@ async function installPackages2(dir, options) {
|
|
|
5925
5957
|
async function writeConfigFile(dir, project, options, triggerDir) {
|
|
5926
5958
|
return await tracer.startActiveSpan("writeConfigFile", async (span) => {
|
|
5927
5959
|
try {
|
|
5928
|
-
const spnnr =
|
|
5960
|
+
const spnnr = spinner();
|
|
5929
5961
|
spnnr.start("Creating config file");
|
|
5930
5962
|
const projectDir = resolve3(process.cwd(), dir);
|
|
5931
|
-
const templatePath =
|
|
5963
|
+
const templatePath = join7(cliRootPath(), "templates", "trigger.config.ts.template");
|
|
5932
5964
|
const outputPath = join7(projectDir, "trigger.config.ts");
|
|
5933
5965
|
span.setAttributes({
|
|
5934
5966
|
"cli.projectDir": projectDir,
|
|
@@ -5969,7 +6001,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
5969
6001
|
if (projectRef) {
|
|
5970
6002
|
const projectResponse = await apiClient2.getProject(projectRef);
|
|
5971
6003
|
if (!projectResponse.success) {
|
|
5972
|
-
|
|
6004
|
+
log4.error(
|
|
5973
6005
|
`--project-ref ${projectRef} is not a valid project ref. Request to fetch data resulted in: ${projectResponse.error}`
|
|
5974
6006
|
);
|
|
5975
6007
|
throw new SkipCommandError(projectResponse.error);
|
|
@@ -6052,7 +6084,7 @@ async function logout(options) {
|
|
|
6052
6084
|
}
|
|
6053
6085
|
|
|
6054
6086
|
// src/commands/list-profiles.ts
|
|
6055
|
-
import { log as
|
|
6087
|
+
import { log as log5, outro as outro5 } from "@clack/prompts";
|
|
6056
6088
|
var ListProfilesOptions = CommonCommandOptions;
|
|
6057
6089
|
function configureListProfilesCommand(program2) {
|
|
6058
6090
|
return program2.command("list-profiles").description("List all of your CLI profiles").option(
|
|
@@ -6078,10 +6110,10 @@ async function listProfiles(options) {
|
|
|
6078
6110
|
return;
|
|
6079
6111
|
}
|
|
6080
6112
|
const profiles = Object.keys(authConfig);
|
|
6081
|
-
|
|
6113
|
+
log5.message("Profiles:");
|
|
6082
6114
|
for (const profile of profiles) {
|
|
6083
6115
|
const profileConfig = authConfig[profile];
|
|
6084
|
-
|
|
6116
|
+
log5.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
|
|
6085
6117
|
}
|
|
6086
6118
|
outro5("Retrieve account info by running whoami --profile <profile>");
|
|
6087
6119
|
}
|