trigger.dev 3.0.0-beta.15 → 3.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +680 -175
- package/dist/index.js.map +1 -1
- package/dist/workers/dev/worker-facade.js +1 -1
- package/dist/workers/prod/worker-facade.js +1 -1
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -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
|
|
780
|
+
import { intro as intro4, log as log5, outro as outro4 } from "@clack/prompts";
|
|
781
781
|
import { depot } from "@depot/cli";
|
|
782
782
|
import { context, trace as trace2 } from "@opentelemetry/api";
|
|
783
783
|
import {
|
|
@@ -793,14 +793,14 @@ import { execa as execa2 } from "execa";
|
|
|
793
793
|
import { createHash } from "node:crypto";
|
|
794
794
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
795
795
|
import { copyFile, mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
796
|
-
import { dirname, join as
|
|
796
|
+
import { dirname, join as join6, relative as relative3, posix } from "node:path";
|
|
797
797
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
798
|
-
import
|
|
798
|
+
import terminalLink2 from "terminal-link";
|
|
799
799
|
import invariant from "tiny-invariant";
|
|
800
800
|
import { z as z4 } from "zod";
|
|
801
801
|
|
|
802
802
|
// package.json
|
|
803
|
-
var version = "3.0.0-beta.
|
|
803
|
+
var version = "3.0.0-beta.17";
|
|
804
804
|
var dependencies = {
|
|
805
805
|
"@clack/prompts": "^0.7.0",
|
|
806
806
|
"@depot/cli": "0.0.1-cli.2.55.0",
|
|
@@ -816,7 +816,7 @@ var dependencies = {
|
|
|
816
816
|
"@opentelemetry/sdk-trace-base": "^1.22.0",
|
|
817
817
|
"@opentelemetry/sdk-trace-node": "^1.22.0",
|
|
818
818
|
"@opentelemetry/semantic-conventions": "^1.22.0",
|
|
819
|
-
"@trigger.dev/core": "workspace:^3.0.0-beta.
|
|
819
|
+
"@trigger.dev/core": "workspace:^3.0.0-beta.17",
|
|
820
820
|
"@types/degit": "^2.8.3",
|
|
821
821
|
chalk: "^5.2.0",
|
|
822
822
|
chokidar: "^3.5.3",
|
|
@@ -837,7 +837,6 @@ var dependencies = {
|
|
|
837
837
|
"mock-fs": "^5.2.0",
|
|
838
838
|
nanoid: "^4.0.2",
|
|
839
839
|
"node-fetch": "^3.3.0",
|
|
840
|
-
"npm-check-updates": "^16.12.2",
|
|
841
840
|
"object-hash": "^3.0.0",
|
|
842
841
|
"p-debounce": "^4.0.0",
|
|
843
842
|
"p-throttle": "^6.1.0",
|
|
@@ -1318,6 +1317,7 @@ var logger = new Logger();
|
|
|
1318
1317
|
import { outro } from "@clack/prompts";
|
|
1319
1318
|
|
|
1320
1319
|
// src/utilities/cliOutput.ts
|
|
1320
|
+
import { log } from "@clack/prompts";
|
|
1321
1321
|
import chalk2 from "chalk";
|
|
1322
1322
|
var green = "#4FFF54";
|
|
1323
1323
|
var purple = "#735BF3";
|
|
@@ -1366,6 +1366,18 @@ function prettyPrintDate(date = /* @__PURE__ */ new Date()) {
|
|
|
1366
1366
|
formattedDate += "." + ("00" + date.getMilliseconds()).slice(-3);
|
|
1367
1367
|
return formattedDate;
|
|
1368
1368
|
}
|
|
1369
|
+
function prettyWarning(header, body, footer) {
|
|
1370
|
+
const prefix = "Warning: ";
|
|
1371
|
+
const indent = Array(prefix.length).fill(" ").join("");
|
|
1372
|
+
const spacing = "\n\n";
|
|
1373
|
+
const prettyPrefix = chalkWarning(prefix);
|
|
1374
|
+
const withIndents = (text3) => text3?.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
1375
|
+
const prettyBody = withIndents(body);
|
|
1376
|
+
const prettyFooter = withIndents(footer);
|
|
1377
|
+
log.warn(
|
|
1378
|
+
`${prettyPrefix}${header}${prettyBody ? `${spacing}${prettyBody}` : ""}${prettyFooter ? `${spacing}${prettyFooter}` : ""}`
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1369
1381
|
|
|
1370
1382
|
// src/cli/common.ts
|
|
1371
1383
|
var CommonCommandOptions = z.object({
|
|
@@ -1474,6 +1486,9 @@ async function createFile(path7, contents) {
|
|
|
1474
1486
|
async function pathExists(path7) {
|
|
1475
1487
|
return fsSync.existsSync(path7);
|
|
1476
1488
|
}
|
|
1489
|
+
async function removeFile(path7) {
|
|
1490
|
+
await fsModule.unlink(path7);
|
|
1491
|
+
}
|
|
1477
1492
|
async function readFile(path7) {
|
|
1478
1493
|
return await fsModule.readFile(path7, "utf8");
|
|
1479
1494
|
}
|
|
@@ -1481,8 +1496,8 @@ async function readJSONFile(path7) {
|
|
|
1481
1496
|
const fileContents = await fsModule.readFile(path7, "utf8");
|
|
1482
1497
|
return JSON.parse(fileContents);
|
|
1483
1498
|
}
|
|
1484
|
-
async function writeJSONFile(path7, json) {
|
|
1485
|
-
await writeFile(path7, JSON.stringify(json), "utf8");
|
|
1499
|
+
async function writeJSONFile(path7, json, pretty = false) {
|
|
1500
|
+
await writeFile(path7, JSON.stringify(json, void 0, pretty ? 2 : void 0), "utf8");
|
|
1486
1501
|
}
|
|
1487
1502
|
function readJSONFileSync(path7) {
|
|
1488
1503
|
const fileContents = fsSync.readFileSync(path7, "utf8");
|
|
@@ -1701,29 +1716,29 @@ function getVersion() {
|
|
|
1701
1716
|
}
|
|
1702
1717
|
|
|
1703
1718
|
// src/utilities/windows.ts
|
|
1704
|
-
import { log, spinner as clackSpinner } from "@clack/prompts";
|
|
1719
|
+
import { log as log2, spinner as clackSpinner } from "@clack/prompts";
|
|
1705
1720
|
var isWindows = process.platform === "win32";
|
|
1706
1721
|
function escapeImportPath(path7) {
|
|
1707
1722
|
return isWindows ? path7.replaceAll("\\", "\\\\") : path7;
|
|
1708
1723
|
}
|
|
1709
1724
|
var ballmerSpinner = () => ({
|
|
1710
1725
|
start: (msg) => {
|
|
1711
|
-
|
|
1726
|
+
log2.step(msg ?? "");
|
|
1712
1727
|
},
|
|
1713
1728
|
stop: (msg, code) => {
|
|
1714
|
-
|
|
1729
|
+
log2.message(msg ?? "");
|
|
1715
1730
|
},
|
|
1716
1731
|
message: (msg) => {
|
|
1717
|
-
|
|
1732
|
+
log2.message(msg ?? "");
|
|
1718
1733
|
}
|
|
1719
1734
|
});
|
|
1720
1735
|
var spinner = () => isWindows ? ballmerSpinner() : clackSpinner();
|
|
1721
1736
|
|
|
1722
1737
|
// src/utilities/initialBanner.ts
|
|
1723
1738
|
async function printInitialBanner(performUpdateCheck = true) {
|
|
1724
|
-
const
|
|
1739
|
+
const cliVersion = getVersion();
|
|
1725
1740
|
const text3 = `
|
|
1726
|
-
${logo()} ${chalkGrey(`(${
|
|
1741
|
+
${logo()} ${chalkGrey(`(${cliVersion})`)}
|
|
1727
1742
|
`;
|
|
1728
1743
|
logger.info(text3);
|
|
1729
1744
|
let maybeNewVersion;
|
|
@@ -1733,7 +1748,7 @@ ${logo()} ${chalkGrey(`(${packageVersion})`)}
|
|
|
1733
1748
|
maybeNewVersion = await updateCheck();
|
|
1734
1749
|
if (maybeNewVersion !== void 0) {
|
|
1735
1750
|
loadingSpinner.stop(`Update available ${chalk3.green(maybeNewVersion)}`);
|
|
1736
|
-
const currentMajor = parseInt(
|
|
1751
|
+
const currentMajor = parseInt(cliVersion.split(".")[0]);
|
|
1737
1752
|
const newMajor = parseInt(maybeNewVersion.split(".")[0]);
|
|
1738
1753
|
if (newMajor > currentMajor) {
|
|
1739
1754
|
logger.warn(
|
|
@@ -1748,9 +1763,10 @@ After installation, run Trigger.dev with \`npx trigger.dev\`.`
|
|
|
1748
1763
|
}
|
|
1749
1764
|
}
|
|
1750
1765
|
async function printStandloneInitialBanner(performUpdateCheck = true) {
|
|
1751
|
-
const
|
|
1766
|
+
const cliVersion = getVersion();
|
|
1752
1767
|
logger.log(`
|
|
1753
|
-
${logo()} ${chalkGrey(
|
|
1768
|
+
${logo()} ${chalkGrey(`(${cliVersion})`)}
|
|
1769
|
+
`);
|
|
1754
1770
|
if (performUpdateCheck) {
|
|
1755
1771
|
const maybeNewVersion = await updateCheck();
|
|
1756
1772
|
if (maybeNewVersion !== void 0) {
|
|
@@ -1759,7 +1775,10 @@ ${logo()} ${chalkGrey("(v3 Developer Preview)")}`);
|
|
|
1759
1775
|
}
|
|
1760
1776
|
logger.log(`${chalkGrey("-".repeat(54))}`);
|
|
1761
1777
|
}
|
|
1762
|
-
function printDevBanner() {
|
|
1778
|
+
function printDevBanner(printTopBorder = true) {
|
|
1779
|
+
if (printTopBorder) {
|
|
1780
|
+
logger.log(chalkGrey("-".repeat(54)));
|
|
1781
|
+
}
|
|
1763
1782
|
logger.log(
|
|
1764
1783
|
`${chalkGrey("Key:")} ${chalkWorker("Version")} ${chalkGrey("|")} ${chalkTask(
|
|
1765
1784
|
"Task"
|
|
@@ -1771,7 +1790,7 @@ async function doUpdateCheck() {
|
|
|
1771
1790
|
let update = null;
|
|
1772
1791
|
try {
|
|
1773
1792
|
update = await checkForUpdate(package_default, {
|
|
1774
|
-
distTag: package_default.version.startsWith("
|
|
1793
|
+
distTag: package_default.version.startsWith("3.0.0-beta") ? "beta" : "latest"
|
|
1775
1794
|
});
|
|
1776
1795
|
} catch (err) {
|
|
1777
1796
|
}
|
|
@@ -1840,7 +1859,7 @@ async function setPackageJsonDeps(path7, deps) {
|
|
|
1840
1859
|
}
|
|
1841
1860
|
|
|
1842
1861
|
// src/commands/login.ts
|
|
1843
|
-
import { intro as intro2, log as
|
|
1862
|
+
import { intro as intro2, log as log3, outro as outro2, select } from "@clack/prompts";
|
|
1844
1863
|
import { recordSpanException as recordSpanException3 } from "@trigger.dev/core/v3";
|
|
1845
1864
|
|
|
1846
1865
|
// ../../node_modules/.pnpm/open@10.0.3/node_modules/open/index.js
|
|
@@ -2211,14 +2230,14 @@ var baseOpen = async (options) => {
|
|
|
2211
2230
|
}
|
|
2212
2231
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
2213
2232
|
if (options.wait) {
|
|
2214
|
-
return new Promise((
|
|
2233
|
+
return new Promise((resolve5, reject) => {
|
|
2215
2234
|
subprocess.once("error", reject);
|
|
2216
2235
|
subprocess.once("close", (exitCode) => {
|
|
2217
2236
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
2218
2237
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
2219
2238
|
return;
|
|
2220
2239
|
}
|
|
2221
|
-
|
|
2240
|
+
resolve5(subprocess);
|
|
2222
2241
|
});
|
|
2223
2242
|
});
|
|
2224
2243
|
}
|
|
@@ -2335,7 +2354,7 @@ var decorateErrorWithCounts = (error, attemptNumber, options) => {
|
|
|
2335
2354
|
return error;
|
|
2336
2355
|
};
|
|
2337
2356
|
async function pRetry(input, options) {
|
|
2338
|
-
return new Promise((
|
|
2357
|
+
return new Promise((resolve5, reject) => {
|
|
2339
2358
|
options = {
|
|
2340
2359
|
onFailedAttempt() {
|
|
2341
2360
|
},
|
|
@@ -2358,7 +2377,7 @@ async function pRetry(input, options) {
|
|
|
2358
2377
|
try {
|
|
2359
2378
|
const result = await input(attemptNumber);
|
|
2360
2379
|
cleanUp();
|
|
2361
|
-
|
|
2380
|
+
resolve5(result);
|
|
2362
2381
|
} catch (error) {
|
|
2363
2382
|
try {
|
|
2364
2383
|
if (!(error instanceof Error)) {
|
|
@@ -2633,11 +2652,11 @@ async function login(options) {
|
|
|
2633
2652
|
}
|
|
2634
2653
|
}
|
|
2635
2654
|
if (opts.embedded) {
|
|
2636
|
-
|
|
2655
|
+
log3.step("You must login to continue.");
|
|
2637
2656
|
}
|
|
2638
2657
|
const apiClient2 = new CliApiClient(authConfig?.apiUrl ?? opts.defaultApiUrl);
|
|
2639
2658
|
const authorizationCodeResult = await createAuthorizationCode(apiClient2);
|
|
2640
|
-
|
|
2659
|
+
log3.step(
|
|
2641
2660
|
`Please visit the following URL to login:
|
|
2642
2661
|
${chalkLink(authorizationCodeResult.url)}`
|
|
2643
2662
|
);
|
|
@@ -2671,7 +2690,7 @@ ${chalkLink(authorizationCodeResult.url)}`
|
|
|
2671
2690
|
throw new Error(whoAmIResult.error);
|
|
2672
2691
|
}
|
|
2673
2692
|
if (opts.embedded) {
|
|
2674
|
-
|
|
2693
|
+
log3.step("Logged in successfully");
|
|
2675
2694
|
} else {
|
|
2676
2695
|
outro2("Logged in successfully");
|
|
2677
2696
|
}
|
|
@@ -2690,7 +2709,7 @@ ${chalkLink(authorizationCodeResult.url)}`
|
|
|
2690
2709
|
} catch (e) {
|
|
2691
2710
|
getPersonalAccessTokenSpinner.stop(`Failed to get access token`);
|
|
2692
2711
|
if (e instanceof AbortError) {
|
|
2693
|
-
|
|
2712
|
+
log3.error(e.message);
|
|
2694
2713
|
}
|
|
2695
2714
|
recordSpanException3(span, e);
|
|
2696
2715
|
span.end();
|
|
@@ -2954,6 +2973,20 @@ function getLoaderForFile(file) {
|
|
|
2954
2973
|
import chalk4 from "chalk";
|
|
2955
2974
|
import { relative as relative2 } from "node:path";
|
|
2956
2975
|
import { groupTaskMetadataIssuesByTask } from "@trigger.dev/core/v3";
|
|
2976
|
+
import terminalLink from "terminal-link";
|
|
2977
|
+
|
|
2978
|
+
// src/utilities/links.ts
|
|
2979
|
+
var docs = {
|
|
2980
|
+
config: {
|
|
2981
|
+
home: "https://trigger.dev/docs/v3/trigger-config",
|
|
2982
|
+
esm: "https://trigger.dev/docs/v3/trigger-config#esm-only-packages",
|
|
2983
|
+
prisma: "https://trigger.dev/docs/v3/trigger-config#prisma-and-other-generators",
|
|
2984
|
+
additionalPackages: "https://trigger.dev/docs/v3/trigger-config#prisma-and-other-generators"
|
|
2985
|
+
}
|
|
2986
|
+
};
|
|
2987
|
+
var getInTouch = "https://trigger.dev/contact";
|
|
2988
|
+
|
|
2989
|
+
// src/utilities/deployErrors.ts
|
|
2957
2990
|
function errorIsErrorLike(error) {
|
|
2958
2991
|
return error instanceof Error || typeof error === "object" && error !== null && "message" in error;
|
|
2959
2992
|
}
|
|
@@ -3019,6 +3052,10 @@ ${chalkGrey("\u25CB")} Dynamically import the module in your code: ${chalkGrey(
|
|
|
3019
3052
|
`
|
|
3020
3053
|
);
|
|
3021
3054
|
}
|
|
3055
|
+
logger.log(
|
|
3056
|
+
`${chalkGrey("\u25CB")} For more info see the ${terminalLink("relevant docs", docs.config.esm)}.
|
|
3057
|
+
`
|
|
3058
|
+
);
|
|
3022
3059
|
}
|
|
3023
3060
|
function parseNpmInstallError(error) {
|
|
3024
3061
|
if (typeof error === "string") {
|
|
@@ -3099,7 +3136,13 @@ import { join as join4 } from "node:path";
|
|
|
3099
3136
|
|
|
3100
3137
|
// src/utilities/getUserPackageManager.ts
|
|
3101
3138
|
import { findUp as findUp2 } from "find-up";
|
|
3139
|
+
import { basename } from "path";
|
|
3102
3140
|
async function getUserPackageManager(path7) {
|
|
3141
|
+
const packageManager = await detectPackageManager(path7);
|
|
3142
|
+
logger.debug("Detected package manager", { packageManager });
|
|
3143
|
+
return packageManager;
|
|
3144
|
+
}
|
|
3145
|
+
async function detectPackageManager(path7) {
|
|
3103
3146
|
try {
|
|
3104
3147
|
return await detectPackageManagerFromArtifacts(path7);
|
|
3105
3148
|
} catch (error) {
|
|
@@ -3121,19 +3164,33 @@ function detectPackageManagerFromCurrentCommand() {
|
|
|
3121
3164
|
}
|
|
3122
3165
|
}
|
|
3123
3166
|
async function detectPackageManagerFromArtifacts(path7) {
|
|
3124
|
-
const
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
return pm;
|
|
3134
|
-
}
|
|
3167
|
+
const artifacts = {
|
|
3168
|
+
yarn: "yarn.lock",
|
|
3169
|
+
pnpm: "pnpm-lock.yaml",
|
|
3170
|
+
npm: "package-lock.json",
|
|
3171
|
+
npmShrinkwrap: "npm-shrinkwrap.json"
|
|
3172
|
+
};
|
|
3173
|
+
const foundPath = await findUp2(Object.values(artifacts), { cwd: path7 });
|
|
3174
|
+
if (!foundPath) {
|
|
3175
|
+
throw new Error("Could not detect package manager from artifacts");
|
|
3135
3176
|
}
|
|
3136
|
-
|
|
3177
|
+
logger.debug("Found path from package manager artifacts", { foundPath });
|
|
3178
|
+
switch (basename(foundPath)) {
|
|
3179
|
+
case artifacts.yarn:
|
|
3180
|
+
return "yarn";
|
|
3181
|
+
case artifacts.pnpm:
|
|
3182
|
+
return "pnpm";
|
|
3183
|
+
case artifacts.npm:
|
|
3184
|
+
case artifacts.npmShrinkwrap:
|
|
3185
|
+
return "npm";
|
|
3186
|
+
default:
|
|
3187
|
+
throw new Error(`Unhandled package manager detection path: ${foundPath}`);
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
// src/utilities/assertExhaustive.ts
|
|
3192
|
+
function assertExhaustive(x) {
|
|
3193
|
+
throw new Error("Unexpected object: " + x);
|
|
3137
3194
|
}
|
|
3138
3195
|
|
|
3139
3196
|
// src/utilities/javascriptProject.ts
|
|
@@ -3192,17 +3249,25 @@ var JavascriptProject = class {
|
|
|
3192
3249
|
}
|
|
3193
3250
|
get scripts() {
|
|
3194
3251
|
return {
|
|
3195
|
-
postinstall: this.packageJson.scripts?.postinstall
|
|
3252
|
+
postinstall: this.packageJson.scripts?.postinstall ?? ""
|
|
3196
3253
|
};
|
|
3197
3254
|
}
|
|
3255
|
+
async install() {
|
|
3256
|
+
const command = await this.#getCommand();
|
|
3257
|
+
try {
|
|
3258
|
+
await command.installDependencies({
|
|
3259
|
+
cwd: this.projectPath
|
|
3260
|
+
});
|
|
3261
|
+
} catch (error) {
|
|
3262
|
+
logger.debug(`Failed to install dependencies using ${command.name}`, {
|
|
3263
|
+
error
|
|
3264
|
+
});
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3198
3267
|
async resolve(packageName, options) {
|
|
3199
3268
|
if (BuiltInModules.has(packageName)) {
|
|
3200
3269
|
return void 0;
|
|
3201
3270
|
}
|
|
3202
|
-
if (!this._packageManager) {
|
|
3203
|
-
this._packageManager = await getUserPackageManager(this.projectPath);
|
|
3204
|
-
}
|
|
3205
|
-
const packageManager = this._packageManager;
|
|
3206
3271
|
const opts = { allowDev: false, ...options };
|
|
3207
3272
|
const packageJsonVersion = this.packageJson.dependencies?.[packageName];
|
|
3208
3273
|
if (typeof packageJsonVersion === "string") {
|
|
@@ -3214,7 +3279,7 @@ var JavascriptProject = class {
|
|
|
3214
3279
|
return devPackageJsonVersion;
|
|
3215
3280
|
}
|
|
3216
3281
|
}
|
|
3217
|
-
const command =
|
|
3282
|
+
const command = await this.#getCommand();
|
|
3218
3283
|
try {
|
|
3219
3284
|
const version2 = await command.resolveDependencyVersion(packageName, {
|
|
3220
3285
|
cwd: this.projectPath
|
|
@@ -3229,16 +3294,41 @@ var JavascriptProject = class {
|
|
|
3229
3294
|
});
|
|
3230
3295
|
}
|
|
3231
3296
|
}
|
|
3297
|
+
async #getCommand() {
|
|
3298
|
+
const packageManager = await this.getPackageManager();
|
|
3299
|
+
switch (packageManager) {
|
|
3300
|
+
case "npm":
|
|
3301
|
+
return new NPMCommands();
|
|
3302
|
+
case "pnpm":
|
|
3303
|
+
return new PNPMCommands();
|
|
3304
|
+
case "yarn":
|
|
3305
|
+
return new YarnCommands();
|
|
3306
|
+
default:
|
|
3307
|
+
assertExhaustive(packageManager);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
async getPackageManager() {
|
|
3311
|
+
if (!this._packageManager) {
|
|
3312
|
+
this._packageManager = await getUserPackageManager(this.projectPath);
|
|
3313
|
+
}
|
|
3314
|
+
return this._packageManager;
|
|
3315
|
+
}
|
|
3232
3316
|
};
|
|
3233
3317
|
var PNPMCommands = class {
|
|
3234
3318
|
get name() {
|
|
3235
3319
|
return "pnpm";
|
|
3236
3320
|
}
|
|
3321
|
+
get cmd() {
|
|
3322
|
+
return process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
|
3323
|
+
}
|
|
3324
|
+
async installDependencies(options) {
|
|
3325
|
+
const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
|
|
3326
|
+
logger.debug(`Installing dependencies using ${this.name}`, { stdout, stderr });
|
|
3327
|
+
}
|
|
3237
3328
|
async resolveDependencyVersion(packageName, options) {
|
|
3238
|
-
const
|
|
3239
|
-
const { stdout } = await $({ cwd: options.cwd })`${cmd} list ${packageName} -r --json`;
|
|
3329
|
+
const { stdout } = await $({ cwd: options.cwd })`${this.cmd} list ${packageName} -r --json`;
|
|
3240
3330
|
const result = JSON.parse(stdout);
|
|
3241
|
-
logger.debug(`Resolving ${packageName} version using
|
|
3331
|
+
logger.debug(`Resolving ${packageName} version using ${this.name}`, { result });
|
|
3242
3332
|
for (const dep of result) {
|
|
3243
3333
|
const dependency = dep.dependencies?.[packageName];
|
|
3244
3334
|
if (dependency) {
|
|
@@ -3251,11 +3341,17 @@ var NPMCommands = class {
|
|
|
3251
3341
|
get name() {
|
|
3252
3342
|
return "npm";
|
|
3253
3343
|
}
|
|
3344
|
+
get cmd() {
|
|
3345
|
+
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
3346
|
+
}
|
|
3347
|
+
async installDependencies(options) {
|
|
3348
|
+
const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
|
|
3349
|
+
logger.debug(`Installing dependencies using ${this.name}`, { stdout, stderr });
|
|
3350
|
+
}
|
|
3254
3351
|
async resolveDependencyVersion(packageName, options) {
|
|
3255
|
-
const
|
|
3256
|
-
const { stdout } = await $({ cwd: options.cwd })`${cmd} list ${packageName} --json`;
|
|
3352
|
+
const { stdout } = await $({ cwd: options.cwd })`${this.cmd} list ${packageName} --json`;
|
|
3257
3353
|
const output = JSON.parse(stdout);
|
|
3258
|
-
logger.debug(`Resolving ${packageName} version using
|
|
3354
|
+
logger.debug(`Resolving ${packageName} version using ${this.name}`, { output });
|
|
3259
3355
|
return this.#recursivelySearchDependencies(output.dependencies, packageName);
|
|
3260
3356
|
}
|
|
3261
3357
|
#recursivelySearchDependencies(dependencies2, packageName) {
|
|
@@ -3276,11 +3372,17 @@ var YarnCommands = class {
|
|
|
3276
3372
|
get name() {
|
|
3277
3373
|
return "yarn";
|
|
3278
3374
|
}
|
|
3375
|
+
get cmd() {
|
|
3376
|
+
return process.platform === "win32" ? "yarn.cmd" : "yarn";
|
|
3377
|
+
}
|
|
3378
|
+
async installDependencies(options) {
|
|
3379
|
+
const { stdout, stderr } = await $({ cwd: options.cwd })`${this.cmd} install`;
|
|
3380
|
+
logger.debug(`Installing dependencies using ${this.name}`, { stdout, stderr });
|
|
3381
|
+
}
|
|
3279
3382
|
async resolveDependencyVersion(packageName, options) {
|
|
3280
|
-
const
|
|
3281
|
-
const { stdout } = await $({ cwd: options.cwd })`${cmd} info ${packageName} --json`;
|
|
3383
|
+
const { stdout } = await $({ cwd: options.cwd })`${this.cmd} info ${packageName} --json`;
|
|
3282
3384
|
const lines = stdout.split("\n");
|
|
3283
|
-
logger.debug(`Resolving ${packageName} version using
|
|
3385
|
+
logger.debug(`Resolving ${packageName} version using ${this.name}`, { lines });
|
|
3284
3386
|
for (const line of lines) {
|
|
3285
3387
|
const json = JSON.parse(line);
|
|
3286
3388
|
if (json.value === packageName) {
|
|
@@ -3299,6 +3401,204 @@ function cliRootPath() {
|
|
|
3299
3401
|
return __dirname2;
|
|
3300
3402
|
}
|
|
3301
3403
|
|
|
3404
|
+
// src/commands/update.ts
|
|
3405
|
+
import { confirm, intro as intro3, isCancel, log as log4, outro as outro3 } from "@clack/prompts";
|
|
3406
|
+
import { join as join5, resolve as resolve2 } from "path";
|
|
3407
|
+
var UpdateCommandOptions = CommonCommandOptions.pick({
|
|
3408
|
+
logLevel: true,
|
|
3409
|
+
skipTelemetry: true
|
|
3410
|
+
});
|
|
3411
|
+
function configureUpdateCommand(program2) {
|
|
3412
|
+
return program2.command("update").description("Updates all @trigger.dev/* packages to match the CLI version").argument("[path]", "The path to the directory that contains the package.json file", ".").option(
|
|
3413
|
+
"-l, --log-level <level>",
|
|
3414
|
+
"The CLI log level to use (debug, info, log, warn, error, none). This does not effect the log level of your trigger.dev tasks.",
|
|
3415
|
+
"log"
|
|
3416
|
+
).option("--skip-telemetry", "Opt-out of sending telemetry").action(async (path7, options) => {
|
|
3417
|
+
wrapCommandAction("dev", UpdateCommandOptions, options, async (opts) => {
|
|
3418
|
+
await printStandloneInitialBanner(true);
|
|
3419
|
+
await updateCommand(path7, opts);
|
|
3420
|
+
});
|
|
3421
|
+
});
|
|
3422
|
+
}
|
|
3423
|
+
var triggerPackageFilter = /^@trigger\.dev/;
|
|
3424
|
+
async function updateCommand(dir, options) {
|
|
3425
|
+
await updateTriggerPackages(dir, options);
|
|
3426
|
+
}
|
|
3427
|
+
async function updateTriggerPackages(dir, options, embedded, requireUpdate) {
|
|
3428
|
+
if (!embedded) {
|
|
3429
|
+
intro3("Updating packages");
|
|
3430
|
+
}
|
|
3431
|
+
const projectPath = resolve2(process.cwd(), dir);
|
|
3432
|
+
const { packageJson, readonlyPackageJson, packageJsonPath } = await getPackageJson(projectPath);
|
|
3433
|
+
if (!packageJson) {
|
|
3434
|
+
log4.error("Failed to load package.json. Try to re-run with `-l debug` to see what's going on.");
|
|
3435
|
+
return;
|
|
3436
|
+
}
|
|
3437
|
+
const cliVersion = getVersion();
|
|
3438
|
+
const newCliVersion = await updateCheck();
|
|
3439
|
+
if (newCliVersion) {
|
|
3440
|
+
prettyWarning(
|
|
3441
|
+
"You're not running the latest CLI version, please consider updating ASAP",
|
|
3442
|
+
`Current: ${cliVersion}
|
|
3443
|
+
Latest: ${newCliVersion}`,
|
|
3444
|
+
"Run latest: npx trigger.dev@beta"
|
|
3445
|
+
);
|
|
3446
|
+
}
|
|
3447
|
+
const triggerDependencies = getTriggerDependencies(packageJson);
|
|
3448
|
+
function getVersionMismatches(deps, targetVersion) {
|
|
3449
|
+
const mismatches = [];
|
|
3450
|
+
for (const dep of deps) {
|
|
3451
|
+
if (dep.version === targetVersion) {
|
|
3452
|
+
continue;
|
|
3453
|
+
}
|
|
3454
|
+
mismatches.push(dep);
|
|
3455
|
+
}
|
|
3456
|
+
return mismatches;
|
|
3457
|
+
}
|
|
3458
|
+
const versionMismatches = getVersionMismatches(triggerDependencies, cliVersion);
|
|
3459
|
+
if (versionMismatches.length === 0) {
|
|
3460
|
+
if (!embedded) {
|
|
3461
|
+
outro3(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
|
|
3462
|
+
}
|
|
3463
|
+
return;
|
|
3464
|
+
}
|
|
3465
|
+
prettyWarning(
|
|
3466
|
+
"Mismatch between your CLI version and installed packages",
|
|
3467
|
+
"We recommend pinned versions for guaranteed compatibility"
|
|
3468
|
+
);
|
|
3469
|
+
if (!process.stdout.isTTY) {
|
|
3470
|
+
outro3("Deploy failed");
|
|
3471
|
+
console.log(
|
|
3472
|
+
`ERROR: Version mismatch detected while running in CI. This won't end well. Aborting.
|
|
3473
|
+
|
|
3474
|
+
Please run the dev command locally and check that your CLI version matches the one printed below. Additionally, all \`@trigger.dev/*\` packages also need to match this version.
|
|
3475
|
+
|
|
3476
|
+
If your local CLI version doesn't match the one below, you may want to add the \`trigger.dev\` package to your dependencies. You will also have to update your workflow deploy command to \`npx trigger.dev deploy\` to ensure your pinned CLI version is used.
|
|
3477
|
+
|
|
3478
|
+
CLI version: ${cliVersion}
|
|
3479
|
+
|
|
3480
|
+
Current package versions that don't match the CLI:
|
|
3481
|
+
${versionMismatches.map((dep) => `- ${dep.name}@${dep.version}`).join("\n")}
|
|
3482
|
+
`
|
|
3483
|
+
);
|
|
3484
|
+
process.exit(1);
|
|
3485
|
+
}
|
|
3486
|
+
log4.message("");
|
|
3487
|
+
const userWantsToUpdate = await updateConfirmation(versionMismatches, cliVersion);
|
|
3488
|
+
if (isCancel(userWantsToUpdate)) {
|
|
3489
|
+
throw new OutroCommandError();
|
|
3490
|
+
}
|
|
3491
|
+
if (!userWantsToUpdate) {
|
|
3492
|
+
if (requireUpdate) {
|
|
3493
|
+
outro3("You shall not pass!");
|
|
3494
|
+
logger.log(
|
|
3495
|
+
`${chalkError(
|
|
3496
|
+
"X Error:"
|
|
3497
|
+
)} Update required: Version mismatches are a common source of bugs and errors. Please update or use \`--skip-update-check\` at your own risk.
|
|
3498
|
+
`
|
|
3499
|
+
);
|
|
3500
|
+
process.exit(1);
|
|
3501
|
+
}
|
|
3502
|
+
if (!embedded) {
|
|
3503
|
+
outro3("You've been warned!");
|
|
3504
|
+
}
|
|
3505
|
+
return;
|
|
3506
|
+
}
|
|
3507
|
+
const installSpinner = spinner();
|
|
3508
|
+
installSpinner.start("Writing new package.json file");
|
|
3509
|
+
const packageJsonBackupPath = `${packageJsonPath}.bak`;
|
|
3510
|
+
await writeJSONFile(packageJsonBackupPath, readonlyPackageJson, true);
|
|
3511
|
+
const exitHandler = async (sig) => {
|
|
3512
|
+
log4.warn(
|
|
3513
|
+
`You may have to manually roll back any package.json changes. Backup written to ${packageJsonBackupPath}`
|
|
3514
|
+
);
|
|
3515
|
+
};
|
|
3516
|
+
process.prependOnceListener("exit", exitHandler);
|
|
3517
|
+
mutatePackageJsonWithUpdatedPackages(packageJson, versionMismatches, cliVersion);
|
|
3518
|
+
await writeJSONFile(packageJsonPath, packageJson, true);
|
|
3519
|
+
async function revertPackageJsonChanges() {
|
|
3520
|
+
await writeJSONFile(packageJsonPath, readonlyPackageJson, true);
|
|
3521
|
+
await removeFile(packageJsonBackupPath);
|
|
3522
|
+
}
|
|
3523
|
+
installSpinner.message("Installing new package versions");
|
|
3524
|
+
const jsProject = new JavascriptProject(projectPath);
|
|
3525
|
+
let packageManager;
|
|
3526
|
+
try {
|
|
3527
|
+
packageManager = await jsProject.getPackageManager();
|
|
3528
|
+
installSpinner.message(`Installing new package versions with ${packageManager}`);
|
|
3529
|
+
await jsProject.install();
|
|
3530
|
+
} catch (error) {
|
|
3531
|
+
installSpinner.stop(
|
|
3532
|
+
`Failed to install new package versions${packageManager ? ` with ${packageManager}` : ""}`
|
|
3533
|
+
);
|
|
3534
|
+
process.removeListener("exit", exitHandler);
|
|
3535
|
+
await revertPackageJsonChanges();
|
|
3536
|
+
throw error;
|
|
3537
|
+
}
|
|
3538
|
+
installSpinner.stop("Installed new package versions");
|
|
3539
|
+
process.removeListener("exit", exitHandler);
|
|
3540
|
+
await removeFile(packageJsonBackupPath);
|
|
3541
|
+
if (!embedded) {
|
|
3542
|
+
outro3(
|
|
3543
|
+
`Packages updated${newCliVersion ? " ..but you should really update your CLI too!" : ""}`
|
|
3544
|
+
);
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
function getTriggerDependencies(packageJson) {
|
|
3548
|
+
const deps = [];
|
|
3549
|
+
for (const type of ["dependencies", "devDependencies"]) {
|
|
3550
|
+
for (const [name, version2] of Object.entries(packageJson[type] ?? {})) {
|
|
3551
|
+
if (!version2) {
|
|
3552
|
+
continue;
|
|
3553
|
+
}
|
|
3554
|
+
if (version2.startsWith("workspace")) {
|
|
3555
|
+
continue;
|
|
3556
|
+
}
|
|
3557
|
+
if (!triggerPackageFilter.test(name)) {
|
|
3558
|
+
continue;
|
|
3559
|
+
}
|
|
3560
|
+
const ignoredPackages = ["@trigger.dev/companyicons"];
|
|
3561
|
+
if (ignoredPackages.includes(name)) {
|
|
3562
|
+
continue;
|
|
3563
|
+
}
|
|
3564
|
+
deps.push({ type, name, version: version2 });
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
return deps;
|
|
3568
|
+
}
|
|
3569
|
+
function mutatePackageJsonWithUpdatedPackages(packageJson, depsToUpdate, targetVersion) {
|
|
3570
|
+
for (const { type, name, version: version2 } of depsToUpdate) {
|
|
3571
|
+
if (!packageJson[type]) {
|
|
3572
|
+
throw new Error(
|
|
3573
|
+
`No ${type} entry found in package.json. Please try to upgrade manually instead.`
|
|
3574
|
+
);
|
|
3575
|
+
}
|
|
3576
|
+
packageJson[type][name] = targetVersion;
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
function printUpdateTable(depsToUpdate, targetVersion) {
|
|
3580
|
+
log4.message("Suggested updates");
|
|
3581
|
+
const tableData = depsToUpdate.map((dep) => ({
|
|
3582
|
+
package: dep.name,
|
|
3583
|
+
old: dep.version,
|
|
3584
|
+
new: targetVersion
|
|
3585
|
+
}));
|
|
3586
|
+
logger.table(tableData);
|
|
3587
|
+
}
|
|
3588
|
+
async function updateConfirmation(depsToUpdate, targetVersion) {
|
|
3589
|
+
printUpdateTable(depsToUpdate, targetVersion);
|
|
3590
|
+
let confirmMessage = "Would you like to apply those updates?";
|
|
3591
|
+
return await confirm({
|
|
3592
|
+
message: confirmMessage
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3595
|
+
async function getPackageJson(absoluteProjectPath) {
|
|
3596
|
+
const packageJsonPath = join5(absoluteProjectPath, "package.json");
|
|
3597
|
+
const readonlyPackageJson = Object.freeze(await readJSONFile(packageJsonPath));
|
|
3598
|
+
const packageJson = structuredClone(readonlyPackageJson);
|
|
3599
|
+
return { packageJson, readonlyPackageJson, packageJsonPath };
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3302
3602
|
// src/commands/deploy.ts
|
|
3303
3603
|
var DeployCommandOptions = CommonCommandOptions.extend({
|
|
3304
3604
|
skipTypecheck: z4.boolean().default(false),
|
|
@@ -3313,7 +3613,9 @@ var DeployCommandOptions = CommonCommandOptions.extend({
|
|
|
3313
3613
|
config: z4.string().optional(),
|
|
3314
3614
|
projectRef: z4.string().optional(),
|
|
3315
3615
|
outputMetafile: z4.string().optional(),
|
|
3316
|
-
apiUrl: z4.string().optional()
|
|
3616
|
+
apiUrl: z4.string().optional(),
|
|
3617
|
+
saveLogs: z4.boolean().default(false),
|
|
3618
|
+
skipUpdateCheck: z4.boolean().default(false)
|
|
3317
3619
|
});
|
|
3318
3620
|
function configureDeployCommand(program2) {
|
|
3319
3621
|
return commonOptions(
|
|
@@ -3321,7 +3623,7 @@ function configureDeployCommand(program2) {
|
|
|
3321
3623
|
"-e, --env <env>",
|
|
3322
3624
|
"Deploy to a specific environment (currently only prod and staging are supported)",
|
|
3323
3625
|
"prod"
|
|
3324
|
-
).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option(
|
|
3626
|
+
).option("--skip-typecheck", "Whether to skip the pre-build typecheck").option("--skip-update-check", "Skip checking for @trigger.dev package updates").option(
|
|
3325
3627
|
"--ignore-env-var-check",
|
|
3326
3628
|
"Detected missing environment variables won't block deployment"
|
|
3327
3629
|
).option("-c, --config <config file>", "The name of the config file, found at [path]").option(
|
|
@@ -3360,6 +3662,11 @@ function configureDeployCommand(program2) {
|
|
|
3360
3662
|
"--output-metafile <path>",
|
|
3361
3663
|
"If provided, will save the esbuild metafile for the build to the specified path"
|
|
3362
3664
|
).hideHelp()
|
|
3665
|
+
).addOption(
|
|
3666
|
+
new CommandOption(
|
|
3667
|
+
"--save-logs",
|
|
3668
|
+
"If provided, will save logs even for successful builds"
|
|
3669
|
+
).hideHelp()
|
|
3363
3670
|
).action(async (path7, options) => {
|
|
3364
3671
|
await handleTelemetry(async () => {
|
|
3365
3672
|
await printStandloneInitialBanner(true);
|
|
@@ -3374,7 +3681,10 @@ async function deployCommand(dir, options) {
|
|
|
3374
3681
|
}
|
|
3375
3682
|
async function _deployCommand(dir, options) {
|
|
3376
3683
|
const span = trace2.getSpan(context.active());
|
|
3377
|
-
|
|
3684
|
+
intro4("Deploying project");
|
|
3685
|
+
if (!options.skipUpdateCheck) {
|
|
3686
|
+
await updateTriggerPackages(dir, { ...options }, true, true);
|
|
3687
|
+
}
|
|
3378
3688
|
const authorization = await login({
|
|
3379
3689
|
embedded: true,
|
|
3380
3690
|
defaultApiUrl: options.apiUrl,
|
|
@@ -3417,7 +3727,7 @@ async function _deployCommand(dir, options) {
|
|
|
3417
3727
|
throw new Error(deploymentEnv.error);
|
|
3418
3728
|
}
|
|
3419
3729
|
const environmentClient = new CliApiClient(authorization.auth.apiUrl, deploymentEnv.data.apiKey);
|
|
3420
|
-
|
|
3730
|
+
log5.step(
|
|
3421
3731
|
`Preparing to deploy "${deploymentEnv.data.name}" (${resolvedConfig.config.project}) to ${options.env}`
|
|
3422
3732
|
);
|
|
3423
3733
|
const compilation = await compileProject(
|
|
@@ -3494,19 +3804,35 @@ async function _deployCommand(dir, options) {
|
|
|
3494
3804
|
);
|
|
3495
3805
|
};
|
|
3496
3806
|
const image = await buildImage();
|
|
3807
|
+
const warnings = checkLogsForWarnings(image.logs);
|
|
3808
|
+
if (!warnings.ok) {
|
|
3809
|
+
await failDeploy(
|
|
3810
|
+
deploymentResponse.data.shortCode,
|
|
3811
|
+
warnings.summary,
|
|
3812
|
+
image.logs,
|
|
3813
|
+
deploymentSpinner,
|
|
3814
|
+
warnings.warnings,
|
|
3815
|
+
warnings.errors
|
|
3816
|
+
);
|
|
3817
|
+
throw new SkipLoggingError(`Failed to build project image: ${warnings.summary}`);
|
|
3818
|
+
}
|
|
3497
3819
|
if (!image.ok) {
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
} else {
|
|
3506
|
-
logger.log(`${chalkError("X Error:")} ${image.error}.`);
|
|
3507
|
-
}
|
|
3820
|
+
await failDeploy(
|
|
3821
|
+
deploymentResponse.data.shortCode,
|
|
3822
|
+
image.error,
|
|
3823
|
+
image.logs,
|
|
3824
|
+
deploymentSpinner,
|
|
3825
|
+
warnings.warnings
|
|
3826
|
+
);
|
|
3508
3827
|
throw new SkipLoggingError(`Failed to build project image: ${image.error}`);
|
|
3509
3828
|
}
|
|
3829
|
+
const preExitTasks = async () => {
|
|
3830
|
+
printWarnings(warnings.warnings);
|
|
3831
|
+
if (options.saveLogs) {
|
|
3832
|
+
const logPath = await saveLogs(deploymentResponse.data.shortCode, image.logs);
|
|
3833
|
+
log5.info(`Build logs have been saved to ${logPath}`);
|
|
3834
|
+
}
|
|
3835
|
+
};
|
|
3510
3836
|
const imageReference = options.selfHosted ? `${selfHostedRegistryHost ? `${selfHostedRegistryHost}/` : ""}${image.image}${image.digest ? `@${image.digest}` : ""}` : `${registryHost}/${image.image}${image.digest ? `@${image.digest}` : ""}`;
|
|
3511
3837
|
span?.setAttributes({
|
|
3512
3838
|
"image.reference": imageReference
|
|
@@ -3515,6 +3841,7 @@ async function _deployCommand(dir, options) {
|
|
|
3515
3841
|
deploymentSpinner.stop(
|
|
3516
3842
|
`Project image built: ${imageReference}. Skipping deployment as requested`
|
|
3517
3843
|
);
|
|
3844
|
+
await preExitTasks();
|
|
3518
3845
|
throw new SkipCommandError("Skipping deployment as requested");
|
|
3519
3846
|
}
|
|
3520
3847
|
deploymentSpinner.message(
|
|
@@ -3529,6 +3856,7 @@ async function _deployCommand(dir, options) {
|
|
|
3529
3856
|
);
|
|
3530
3857
|
if (!startIndexingResponse.success) {
|
|
3531
3858
|
deploymentSpinner.stop(`Failed to start indexing: ${startIndexingResponse.error}`);
|
|
3859
|
+
await preExitTasks();
|
|
3532
3860
|
throw new SkipLoggingError(`Failed to start indexing: ${startIndexingResponse.error}`);
|
|
3533
3861
|
}
|
|
3534
3862
|
const finishedDeployment = await waitForDeploymentToFinish(
|
|
@@ -3537,26 +3865,33 @@ async function _deployCommand(dir, options) {
|
|
|
3537
3865
|
);
|
|
3538
3866
|
if (!finishedDeployment) {
|
|
3539
3867
|
deploymentSpinner.stop(`Deployment failed to complete`);
|
|
3868
|
+
await preExitTasks();
|
|
3540
3869
|
throw new SkipLoggingError("Deployment failed to complete: unknown issue");
|
|
3541
3870
|
}
|
|
3542
3871
|
if (typeof finishedDeployment === "string") {
|
|
3543
3872
|
deploymentSpinner.stop(`Deployment failed to complete: ${finishedDeployment}`);
|
|
3873
|
+
await preExitTasks();
|
|
3544
3874
|
throw new SkipLoggingError(`Deployment failed to complete: ${finishedDeployment}`);
|
|
3545
3875
|
}
|
|
3546
|
-
const deploymentLink =
|
|
3876
|
+
const deploymentLink = terminalLink2(
|
|
3547
3877
|
"View deployment",
|
|
3548
3878
|
`${authorization.dashboardUrl}/projects/v3/${resolvedConfig.config.project}/deployments/${finishedDeployment.shortCode}`
|
|
3549
3879
|
);
|
|
3550
3880
|
switch (finishedDeployment.status) {
|
|
3551
3881
|
case "DEPLOYED": {
|
|
3552
|
-
|
|
3882
|
+
if (warnings.warnings.length > 0) {
|
|
3883
|
+
deploymentSpinner.stop("Deployment completed with warnings");
|
|
3884
|
+
} else {
|
|
3885
|
+
deploymentSpinner.stop("Deployment completed");
|
|
3886
|
+
}
|
|
3887
|
+
await preExitTasks();
|
|
3553
3888
|
const taskCount = finishedDeployment.worker?.tasks.length ?? 0;
|
|
3554
3889
|
if (taskCount === 0) {
|
|
3555
|
-
|
|
3890
|
+
outro4(
|
|
3556
3891
|
`Version ${version2} deployed with no detected tasks. Please make sure you are exporting tasks in your project. ${deploymentLink}`
|
|
3557
3892
|
);
|
|
3558
3893
|
} else {
|
|
3559
|
-
|
|
3894
|
+
outro4(
|
|
3560
3895
|
`Version ${version2} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${deploymentLink}`
|
|
3561
3896
|
);
|
|
3562
3897
|
}
|
|
@@ -3571,6 +3906,7 @@ async function _deployCommand(dir, options) {
|
|
|
3571
3906
|
if (parsedError2.success) {
|
|
3572
3907
|
deploymentSpinner.stop(`Deployment encountered an error. ${deploymentLink}`);
|
|
3573
3908
|
logTaskMetadataParseError(parsedError2.data.zodIssues, parsedError2.data.tasks);
|
|
3909
|
+
await preExitTasks();
|
|
3574
3910
|
throw new SkipLoggingError(
|
|
3575
3911
|
`Deployment encountered an error: ${finishedDeployment.errorData.name}`
|
|
3576
3912
|
);
|
|
@@ -3585,6 +3921,7 @@ async function _deployCommand(dir, options) {
|
|
|
3585
3921
|
deploymentSpinner.stop(`Deployment encountered an error. ${deploymentLink}`);
|
|
3586
3922
|
logESMRequireError(parsedError, resolvedConfig);
|
|
3587
3923
|
}
|
|
3924
|
+
await preExitTasks();
|
|
3588
3925
|
throw new SkipLoggingError(
|
|
3589
3926
|
`Deployment encountered an error: ${finishedDeployment.errorData.name}`
|
|
3590
3927
|
);
|
|
@@ -3592,19 +3929,133 @@ async function _deployCommand(dir, options) {
|
|
|
3592
3929
|
deploymentSpinner.stop(
|
|
3593
3930
|
`Deployment failed with an unknown error. Please contact eric@trigger.dev for help. ${deploymentLink}`
|
|
3594
3931
|
);
|
|
3932
|
+
await preExitTasks();
|
|
3595
3933
|
throw new SkipLoggingError("Deployment failed with an unknown error");
|
|
3596
3934
|
}
|
|
3597
3935
|
}
|
|
3598
3936
|
case "CANCELED": {
|
|
3599
3937
|
deploymentSpinner.stop(`Deployment was canceled. ${deploymentLink}`);
|
|
3938
|
+
await preExitTasks();
|
|
3600
3939
|
throw new SkipLoggingError("Deployment was canceled");
|
|
3601
3940
|
}
|
|
3602
3941
|
case "TIMED_OUT": {
|
|
3603
3942
|
deploymentSpinner.stop(`Deployment timed out. ${deploymentLink}`);
|
|
3943
|
+
await preExitTasks();
|
|
3604
3944
|
throw new SkipLoggingError("Deployment timed out");
|
|
3605
3945
|
}
|
|
3606
3946
|
}
|
|
3607
3947
|
}
|
|
3948
|
+
function printErrors(errors) {
|
|
3949
|
+
for (const error of errors ?? []) {
|
|
3950
|
+
log5.error(`${chalkError("Error:")} ${error}`);
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
function printWarnings(warnings) {
|
|
3954
|
+
for (const warning of warnings ?? []) {
|
|
3955
|
+
log5.warn(`${chalkWarning("Warning:")} ${warning}`);
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
function checkLogsForWarnings(logs) {
|
|
3959
|
+
const warnings = [
|
|
3960
|
+
{
|
|
3961
|
+
regex: /prisma:warn We could not find your Prisma schema/,
|
|
3962
|
+
message: `Prisma generate failed to find the default schema. Did you include it in config.additionalFiles? ${terminalLink2(
|
|
3963
|
+
"Config docs",
|
|
3964
|
+
docs.config.prisma
|
|
3965
|
+
)}
|
|
3966
|
+
Custom schema paths require a postinstall script like this: \`prisma generate --schema=./custom/path/to/schema.prisma\``,
|
|
3967
|
+
shouldFail: true
|
|
3968
|
+
}
|
|
3969
|
+
];
|
|
3970
|
+
const errorMessages2 = [];
|
|
3971
|
+
const warningMessages = [];
|
|
3972
|
+
let shouldFail = false;
|
|
3973
|
+
for (const warning of warnings) {
|
|
3974
|
+
const matches = logs.match(warning.regex);
|
|
3975
|
+
if (!matches) {
|
|
3976
|
+
continue;
|
|
3977
|
+
}
|
|
3978
|
+
const message = getMessageFromTemplate(warning.message, matches.groups);
|
|
3979
|
+
if (warning.shouldFail) {
|
|
3980
|
+
shouldFail = true;
|
|
3981
|
+
errorMessages2.push(message);
|
|
3982
|
+
} else {
|
|
3983
|
+
warningMessages.push(message);
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
if (shouldFail) {
|
|
3987
|
+
return {
|
|
3988
|
+
ok: false,
|
|
3989
|
+
summary: "Build succeeded with critical warnings. Will not proceed",
|
|
3990
|
+
warnings: warningMessages,
|
|
3991
|
+
errors: errorMessages2
|
|
3992
|
+
};
|
|
3993
|
+
}
|
|
3994
|
+
return {
|
|
3995
|
+
ok: true,
|
|
3996
|
+
warnings: warningMessages
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
function checkLogsForErrors(logs) {
|
|
4000
|
+
const errors = [
|
|
4001
|
+
{
|
|
4002
|
+
regex: /Error: Provided --schema at (?<schema>.*) doesn't exist/,
|
|
4003
|
+
message: `Prisma generate failed to find the specified schema at "$schema".
|
|
4004
|
+
Did you include it in config.additionalFiles? ${terminalLink2(
|
|
4005
|
+
"Config docs",
|
|
4006
|
+
docs.config.prisma
|
|
4007
|
+
)}`
|
|
4008
|
+
},
|
|
4009
|
+
{
|
|
4010
|
+
regex: /sh: 1: (?<packageOrBinary>.*): not found/,
|
|
4011
|
+
message: `$packageOrBinary not found
|
|
4012
|
+
|
|
4013
|
+
If it's a package: Include it in ${terminalLink2(
|
|
4014
|
+
"config.additionalPackages",
|
|
4015
|
+
docs.config.prisma
|
|
4016
|
+
)}
|
|
4017
|
+
If it's a binary: Please ${terminalLink2(
|
|
4018
|
+
"get in touch",
|
|
4019
|
+
getInTouch
|
|
4020
|
+
)} and we'll see what we can do!`
|
|
4021
|
+
}
|
|
4022
|
+
];
|
|
4023
|
+
for (const error of errors) {
|
|
4024
|
+
const matches = logs.match(error.regex);
|
|
4025
|
+
if (!matches) {
|
|
4026
|
+
continue;
|
|
4027
|
+
}
|
|
4028
|
+
const message = getMessageFromTemplate(error.message, matches.groups);
|
|
4029
|
+
log5.error(`${chalkError("Error:")} ${message}`);
|
|
4030
|
+
break;
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
function getMessageFromTemplate(template, replacer) {
|
|
4034
|
+
let message = template;
|
|
4035
|
+
if (replacer) {
|
|
4036
|
+
for (const [key, value] of Object.entries(replacer)) {
|
|
4037
|
+
message = message.replaceAll(`$${key}`, value);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
return message;
|
|
4041
|
+
}
|
|
4042
|
+
async function saveLogs(shortCode, logs) {
|
|
4043
|
+
const logPath = join6(await createTempDir(), `build-${shortCode}.log`);
|
|
4044
|
+
await writeFile2(logPath, logs);
|
|
4045
|
+
return logPath;
|
|
4046
|
+
}
|
|
4047
|
+
async function failDeploy(shortCode, errorSummary, logs, deploymentSpinner, warnings, errors) {
|
|
4048
|
+
deploymentSpinner.stop(`Failed to deploy project`);
|
|
4049
|
+
if (logs.trim() !== "") {
|
|
4050
|
+
const logPath = await saveLogs(shortCode, logs);
|
|
4051
|
+
printWarnings(warnings);
|
|
4052
|
+
printErrors(errors);
|
|
4053
|
+
checkLogsForErrors(logs);
|
|
4054
|
+
outro4(`${chalkError("Error:")} ${errorSummary}. Full build logs have been saved to ${logPath}`);
|
|
4055
|
+
} else {
|
|
4056
|
+
outro4(`${chalkError("Error:")} ${errorSummary}.`);
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
3608
4059
|
async function checkEnvVars(envVars, config, options, environmentClient, apiUrl) {
|
|
3609
4060
|
return await tracer.startActiveSpan("detectEnvVars", async (span) => {
|
|
3610
4061
|
try {
|
|
@@ -3623,7 +4074,7 @@ async function checkEnvVars(envVars, config, options, environmentClient, apiUrl)
|
|
|
3623
4074
|
`Found missing env vars in ${options.env}: ${arrayToSentence(
|
|
3624
4075
|
missingEnvironmentVariables
|
|
3625
4076
|
)}. ${options.ignoreEnvVarCheck ? "Continuing deployment because of --ignore-env-var-check. " : "Aborting deployment. "}${chalk5.bgBlueBright(
|
|
3626
|
-
|
|
4077
|
+
terminalLink2(
|
|
3627
4078
|
"Manage env vars",
|
|
3628
4079
|
`${apiUrl}/projects/v3/${config.project}/environment-variables`
|
|
3629
4080
|
)
|
|
@@ -3923,10 +4374,10 @@ async function compileProject(config, options, configPath) {
|
|
|
3923
4374
|
compileSpinner.start(`Building project in ${config.projectDir}`);
|
|
3924
4375
|
const taskFiles = await gatherTaskFiles(config);
|
|
3925
4376
|
const workerFacade = readFileSync2(
|
|
3926
|
-
|
|
4377
|
+
join6(cliRootPath(), "workers", "prod", "worker-facade.js"),
|
|
3927
4378
|
"utf-8"
|
|
3928
4379
|
);
|
|
3929
|
-
const workerSetupPath =
|
|
4380
|
+
const workerSetupPath = join6(cliRootPath(), "workers", "prod", "worker-setup.js");
|
|
3930
4381
|
let workerContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace(
|
|
3931
4382
|
"__WORKER_SETUP__",
|
|
3932
4383
|
`import { tracingSDK } from "${escapeImportPath(workerSetupPath)}";`
|
|
@@ -3986,10 +4437,10 @@ async function compileProject(config, options, configPath) {
|
|
|
3986
4437
|
throw new Error("Build failed, aborting deployment");
|
|
3987
4438
|
}
|
|
3988
4439
|
if (options.outputMetafile) {
|
|
3989
|
-
await writeJSONFile(
|
|
4440
|
+
await writeJSONFile(join6(options.outputMetafile, "worker.json"), result.metafile);
|
|
3990
4441
|
}
|
|
3991
4442
|
const entryPointContents = readFileSync2(
|
|
3992
|
-
|
|
4443
|
+
join6(cliRootPath(), "workers", "prod", "entry-point.js"),
|
|
3993
4444
|
"utf-8"
|
|
3994
4445
|
);
|
|
3995
4446
|
const entryPointResult = await build2({
|
|
@@ -4032,7 +4483,7 @@ async function compileProject(config, options, configPath) {
|
|
|
4032
4483
|
}
|
|
4033
4484
|
if (options.outputMetafile) {
|
|
4034
4485
|
await writeJSONFile(
|
|
4035
|
-
|
|
4486
|
+
join6(options.outputMetafile, "entry-point.json"),
|
|
4036
4487
|
entryPointResult.metafile
|
|
4037
4488
|
);
|
|
4038
4489
|
}
|
|
@@ -4043,24 +4494,24 @@ async function compileProject(config, options, configPath) {
|
|
|
4043
4494
|
const entryPointMetaOutput = entryPointResult.metafile.outputs[posix.join("out", "stdin.js")];
|
|
4044
4495
|
invariant(entryPointMetaOutput, "Meta output for the entryPoint build is missing");
|
|
4045
4496
|
const workerOutputFile = result.outputFiles.find(
|
|
4046
|
-
(file) => file.path ===
|
|
4497
|
+
(file) => file.path === join6(config.projectDir, "out", "stdin.js")
|
|
4047
4498
|
);
|
|
4048
4499
|
invariant(workerOutputFile, "Output file for the result build is missing");
|
|
4049
4500
|
const workerSourcemapFile = result.outputFiles.find(
|
|
4050
|
-
(file) => file.path ===
|
|
4501
|
+
(file) => file.path === join6(config.projectDir, "out", "stdin.js.map")
|
|
4051
4502
|
);
|
|
4052
4503
|
invariant(workerSourcemapFile, "Sourcemap file for the result build is missing");
|
|
4053
4504
|
const entryPointOutputFile = entryPointResult.outputFiles.find(
|
|
4054
|
-
(file) => file.path ===
|
|
4505
|
+
(file) => file.path === join6(config.projectDir, "out", "stdin.js")
|
|
4055
4506
|
);
|
|
4056
4507
|
invariant(entryPointOutputFile, "Output file for the entryPoint build is missing");
|
|
4057
4508
|
await writeFile2(
|
|
4058
|
-
|
|
4509
|
+
join6(tempDir, "worker.js"),
|
|
4059
4510
|
`${workerOutputFile.text}
|
|
4060
4511
|
//# sourceMappingURL=worker.js.map`
|
|
4061
4512
|
);
|
|
4062
|
-
await writeFile2(
|
|
4063
|
-
await writeFile2(
|
|
4513
|
+
await writeFile2(join6(tempDir, "worker.js.map"), workerSourcemapFile.text);
|
|
4514
|
+
await writeFile2(join6(tempDir, "index.js"), entryPointOutputFile.text);
|
|
4064
4515
|
logger.debug("Getting the imports for the worker and entryPoint builds", {
|
|
4065
4516
|
workerImports: metaOutput.imports,
|
|
4066
4517
|
entryPointImports: entryPointMetaOutput.imports
|
|
@@ -4077,9 +4528,23 @@ async function compileProject(config, options, configPath) {
|
|
|
4077
4528
|
...javascriptProject.scripts
|
|
4078
4529
|
}
|
|
4079
4530
|
};
|
|
4080
|
-
await writeJSONFile(
|
|
4081
|
-
await copyAdditionalFiles(config, tempDir);
|
|
4082
|
-
|
|
4531
|
+
await writeJSONFile(join6(tempDir, "package.json"), packageJsonContents);
|
|
4532
|
+
const copyResult = await copyAdditionalFiles(config, tempDir);
|
|
4533
|
+
if (!copyResult.ok) {
|
|
4534
|
+
compileSpinner.stop("Project built with warnings");
|
|
4535
|
+
log5.warn(
|
|
4536
|
+
`No additionalFiles matches for:
|
|
4537
|
+
|
|
4538
|
+
${copyResult.noMatches.map((glob) => `- "${glob}"`).join("\n")}
|
|
4539
|
+
|
|
4540
|
+
If this is unexpected you should check your ${terminalLink2(
|
|
4541
|
+
"glob patterns",
|
|
4542
|
+
"https://github.com/isaacs/node-glob?tab=readme-ov-file#glob-primer"
|
|
4543
|
+
)} are valid.`
|
|
4544
|
+
);
|
|
4545
|
+
} else {
|
|
4546
|
+
compileSpinner.stop("Project built successfully");
|
|
4547
|
+
}
|
|
4083
4548
|
const resolvingDependenciesResult = await resolveDependencies(
|
|
4084
4549
|
tempDir,
|
|
4085
4550
|
packageJsonContents,
|
|
@@ -4089,8 +4554,8 @@ async function compileProject(config, options, configPath) {
|
|
|
4089
4554
|
if (!resolvingDependenciesResult) {
|
|
4090
4555
|
throw new SkipLoggingError("Failed to resolve dependencies");
|
|
4091
4556
|
}
|
|
4092
|
-
const containerFilePath =
|
|
4093
|
-
await copyFile(containerFilePath,
|
|
4557
|
+
const containerFilePath = join6(cliRootPath(), "Containerfile.prod");
|
|
4558
|
+
await copyFile(containerFilePath, join6(tempDir, "Containerfile"));
|
|
4094
4559
|
const contentHasher = createHash("sha256");
|
|
4095
4560
|
contentHasher.update(Buffer.from(entryPointOutputFile.text));
|
|
4096
4561
|
contentHasher.update(Buffer.from(workerOutputFile.text));
|
|
@@ -4122,8 +4587,8 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
|
|
|
4122
4587
|
const hasher = createHash("sha256");
|
|
4123
4588
|
hasher.update(JSON.stringify(packageJsonContents));
|
|
4124
4589
|
const digest = hasher.digest("hex").slice(0, 16);
|
|
4125
|
-
const cacheDir =
|
|
4126
|
-
const cachePath =
|
|
4590
|
+
const cacheDir = join6(config.projectDir, ".trigger", "cache");
|
|
4591
|
+
const cachePath = join6(cacheDir, `${digest}.json`);
|
|
4127
4592
|
span.setAttributes({
|
|
4128
4593
|
"packageJson.digest": digest,
|
|
4129
4594
|
"cache.path": cachePath,
|
|
@@ -4132,7 +4597,7 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
|
|
|
4132
4597
|
try {
|
|
4133
4598
|
const cachedPackageLock = await readFile2(cachePath, "utf-8");
|
|
4134
4599
|
logger.debug(`Using cached package-lock.json for ${digest}`);
|
|
4135
|
-
await writeFile2(
|
|
4600
|
+
await writeFile2(join6(projectDir, "package-lock.json"), cachedPackageLock);
|
|
4136
4601
|
span.setAttributes({
|
|
4137
4602
|
"cache.hit": true
|
|
4138
4603
|
});
|
|
@@ -4155,11 +4620,11 @@ async function resolveDependencies(projectDir, packageJsonContents, config, opti
|
|
|
4155
4620
|
cwd: projectDir,
|
|
4156
4621
|
stdio: logger.loggerLevel === "debug" ? "inherit" : "pipe"
|
|
4157
4622
|
});
|
|
4158
|
-
const packageLockContents = await readFile2(
|
|
4623
|
+
const packageLockContents = await readFile2(join6(projectDir, "package-lock.json"), "utf-8");
|
|
4159
4624
|
logger.debug(`Writing package-lock.json to cache for ${digest}`);
|
|
4160
4625
|
await mkdir(cacheDir, { recursive: true });
|
|
4161
4626
|
await writeFile2(cachePath, packageLockContents);
|
|
4162
|
-
await writeFile2(
|
|
4627
|
+
await writeFile2(join6(projectDir, "package-lock.json"), packageLockContents);
|
|
4163
4628
|
span.end();
|
|
4164
4629
|
resolvingDepsSpinner.stop("Dependencies resolved");
|
|
4165
4630
|
return true;
|
|
@@ -4211,8 +4676,8 @@ async function typecheckProject(config, options) {
|
|
|
4211
4676
|
tscTypecheck.stdout?.on("data", (chunk) => stdouts.push(chunk.toString()));
|
|
4212
4677
|
tscTypecheck.stderr?.on("data", (chunk) => stderrs.push(chunk.toString()));
|
|
4213
4678
|
try {
|
|
4214
|
-
await new Promise((
|
|
4215
|
-
tscTypecheck.addListener("exit", (code) => code === 0 ?
|
|
4679
|
+
await new Promise((resolve5, reject) => {
|
|
4680
|
+
tscTypecheck.addListener("exit", (code) => code === 0 ? resolve5(code) : reject(code));
|
|
4216
4681
|
});
|
|
4217
4682
|
} catch (error) {
|
|
4218
4683
|
typecheckSpinner.stop(
|
|
@@ -4286,8 +4751,9 @@ async function gatherRequiredDependencies(imports, config, project) {
|
|
|
4286
4751
|
}
|
|
4287
4752
|
async function copyAdditionalFiles(config, tempDir) {
|
|
4288
4753
|
const additionalFiles = config.additionalFiles ?? [];
|
|
4754
|
+
const noMatches = [];
|
|
4289
4755
|
if (additionalFiles.length === 0) {
|
|
4290
|
-
return;
|
|
4756
|
+
return { ok: true };
|
|
4291
4757
|
}
|
|
4292
4758
|
return await tracer.startActiveSpan(
|
|
4293
4759
|
"copyAdditionalFiles",
|
|
@@ -4301,22 +4767,55 @@ async function copyAdditionalFiles(config, tempDir) {
|
|
|
4301
4767
|
logger.debug(`Copying files to ${tempDir}`, {
|
|
4302
4768
|
additionalFiles
|
|
4303
4769
|
});
|
|
4304
|
-
const
|
|
4770
|
+
const globOptions = {
|
|
4305
4771
|
withFileTypes: true,
|
|
4306
4772
|
ignore: ["node_modules"],
|
|
4307
4773
|
cwd: config.projectDir,
|
|
4308
4774
|
nodir: true
|
|
4309
|
-
}
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
)
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4775
|
+
};
|
|
4776
|
+
const globs = [];
|
|
4777
|
+
let i = 0;
|
|
4778
|
+
for (const additionalFile of additionalFiles) {
|
|
4779
|
+
let glob;
|
|
4780
|
+
if (i === 0) {
|
|
4781
|
+
glob = new Glob(additionalFile, globOptions);
|
|
4782
|
+
} else {
|
|
4783
|
+
const previousGlob = globs[i - 1];
|
|
4784
|
+
if (!previousGlob) {
|
|
4785
|
+
logger.error("No previous glob, this shouldn't happen", { i, additionalFiles });
|
|
4786
|
+
continue;
|
|
4787
|
+
}
|
|
4788
|
+
glob = new Glob(additionalFile, previousGlob);
|
|
4789
|
+
}
|
|
4790
|
+
if (!(Symbol.asyncIterator in glob)) {
|
|
4791
|
+
logger.error("Glob should be an async iterator", { glob });
|
|
4792
|
+
throw new Error("Unrecoverable error while copying additional files");
|
|
4793
|
+
}
|
|
4794
|
+
let matches = 0;
|
|
4795
|
+
for await (const file of glob) {
|
|
4796
|
+
matches++;
|
|
4797
|
+
const pathInsideTempDir = relative3(config.projectDir, file.fullpath()).split(posix.sep).filter((p) => p !== "..").join(posix.sep);
|
|
4798
|
+
const relativeDestinationPath = join6(tempDir, pathInsideTempDir);
|
|
4799
|
+
logger.debug(`Copying file ${file.fullpath()} to ${relativeDestinationPath}`);
|
|
4800
|
+
await mkdir(dirname(relativeDestinationPath), { recursive: true });
|
|
4801
|
+
await copyFile(file.fullpath(), relativeDestinationPath);
|
|
4802
|
+
}
|
|
4803
|
+
if (matches === 0) {
|
|
4804
|
+
noMatches.push(additionalFile);
|
|
4805
|
+
}
|
|
4806
|
+
globs[i] = glob;
|
|
4807
|
+
i++;
|
|
4318
4808
|
}
|
|
4319
4809
|
span.end();
|
|
4810
|
+
if (noMatches.length > 0) {
|
|
4811
|
+
return {
|
|
4812
|
+
ok: false,
|
|
4813
|
+
noMatches
|
|
4814
|
+
};
|
|
4815
|
+
}
|
|
4816
|
+
return {
|
|
4817
|
+
ok: true
|
|
4818
|
+
};
|
|
4320
4819
|
} catch (error) {
|
|
4321
4820
|
recordSpanException4(span, error);
|
|
4322
4821
|
span.end();
|
|
@@ -4327,7 +4826,7 @@ async function copyAdditionalFiles(config, tempDir) {
|
|
|
4327
4826
|
}
|
|
4328
4827
|
async function ensureLoggedIntoDockerRegistry(registryHost, auth) {
|
|
4329
4828
|
const tmpDir = await createTempDir();
|
|
4330
|
-
const dockerConfigPath =
|
|
4829
|
+
const dockerConfigPath = join6(tmpDir, "config.json");
|
|
4331
4830
|
await writeJSONFile(dockerConfigPath, {
|
|
4332
4831
|
auths: {
|
|
4333
4832
|
[registryHost]: {
|
|
@@ -4373,7 +4872,7 @@ import { context as context2 } from "esbuild";
|
|
|
4373
4872
|
import { render, useInput } from "ink";
|
|
4374
4873
|
import { createHash as createHash2 } from "node:crypto";
|
|
4375
4874
|
import fs7, { readFileSync as readFileSync3 } from "node:fs";
|
|
4376
|
-
import { basename, dirname as dirname3, join as
|
|
4875
|
+
import { basename as basename2, dirname as dirname3, join as join7, normalize } from "node:path";
|
|
4377
4876
|
import pDebounce from "p-debounce";
|
|
4378
4877
|
import { WebSocket } from "partysocket";
|
|
4379
4878
|
import React, { Suspense, useEffect } from "react";
|
|
@@ -4412,8 +4911,8 @@ import {
|
|
|
4412
4911
|
import dotenv from "dotenv";
|
|
4413
4912
|
import { Evt } from "evt";
|
|
4414
4913
|
import { fork } from "node:child_process";
|
|
4415
|
-
import { dirname as dirname2, resolve as
|
|
4416
|
-
import
|
|
4914
|
+
import { dirname as dirname2, resolve as resolve3 } from "node:path";
|
|
4915
|
+
import terminalLink3 from "terminal-link";
|
|
4417
4916
|
var BackgroundWorkerCoordinator = class {
|
|
4418
4917
|
constructor(baseURL) {
|
|
4419
4918
|
this.baseURL = baseURL;
|
|
@@ -4498,7 +4997,7 @@ var BackgroundWorkerCoordinator = class {
|
|
|
4498
4997
|
const logsUrl = `${this.baseURL}/runs/${execution.run.id}`;
|
|
4499
4998
|
const pipe = chalkGrey("|");
|
|
4500
4999
|
const bullet = chalkGrey("\u25CB");
|
|
4501
|
-
const link = chalkLink(
|
|
5000
|
+
const link = chalkLink(terminalLink3("View logs", logsUrl));
|
|
4502
5001
|
let timestampPrefix = chalkGrey(prettyPrintDate(payload.execution.attempt.startedAt));
|
|
4503
5002
|
const workerPrefix = chalkWorker(record.version);
|
|
4504
5003
|
const taskPrefix = chalkTask(execution.task.id);
|
|
@@ -4612,7 +5111,7 @@ var BackgroundWorker = class {
|
|
|
4612
5111
|
...this.#readEnvVars()
|
|
4613
5112
|
};
|
|
4614
5113
|
logger.debug("Initializing worker", { path: this.path, cwd, fullEnv });
|
|
4615
|
-
this.tasks = await new Promise((
|
|
5114
|
+
this.tasks = await new Promise((resolve5, reject) => {
|
|
4616
5115
|
const child = fork(this.path, {
|
|
4617
5116
|
stdio: [
|
|
4618
5117
|
/*stdin*/
|
|
@@ -4639,7 +5138,7 @@ var BackgroundWorker = class {
|
|
|
4639
5138
|
if (message.type === "TASKS_READY" && !resolved) {
|
|
4640
5139
|
clearTimeout(timeout);
|
|
4641
5140
|
resolved = true;
|
|
4642
|
-
|
|
5141
|
+
resolve5(message.payload.tasks);
|
|
4643
5142
|
child.kill();
|
|
4644
5143
|
} else if (message.type === "UNCAUGHT_EXCEPTION") {
|
|
4645
5144
|
clearTimeout(timeout);
|
|
@@ -4774,7 +5273,7 @@ var BackgroundWorker = class {
|
|
|
4774
5273
|
const result = {};
|
|
4775
5274
|
dotenv.config({
|
|
4776
5275
|
processEnv: result,
|
|
4777
|
-
path: [".env", ".env.local", ".env.development.local"].map((p) =>
|
|
5276
|
+
path: [".env", ".env.local", ".env.development.local"].map((p) => resolve3(process.cwd(), p))
|
|
4778
5277
|
});
|
|
4779
5278
|
process.env.TRIGGER_API_URL && (result.TRIGGER_API_URL = process.env.TRIGGER_API_URL);
|
|
4780
5279
|
delete result.TRIGGER_API_URL;
|
|
@@ -4875,8 +5374,8 @@ var TaskRunProcess = class {
|
|
|
4875
5374
|
async executeTaskRun(payload) {
|
|
4876
5375
|
let resolver;
|
|
4877
5376
|
let rejecter;
|
|
4878
|
-
const promise = new Promise((
|
|
4879
|
-
resolver =
|
|
5377
|
+
const promise = new Promise((resolve5, reject) => {
|
|
5378
|
+
resolver = resolve5;
|
|
4880
5379
|
rejecter = reject;
|
|
4881
5380
|
});
|
|
4882
5381
|
this._attemptStatuses.set(payload.execution.attempt.id, "PENDING");
|
|
@@ -5022,14 +5521,15 @@ var DevCommandOptions = CommonCommandOptions.extend({
|
|
|
5022
5521
|
debugger: z5.boolean().default(false),
|
|
5023
5522
|
debugOtel: z5.boolean().default(false),
|
|
5024
5523
|
config: z5.string().optional(),
|
|
5025
|
-
projectRef: z5.string().optional()
|
|
5524
|
+
projectRef: z5.string().optional(),
|
|
5525
|
+
skipUpdateCheck: z5.boolean().default(false)
|
|
5026
5526
|
});
|
|
5027
5527
|
function configureDevCommand(program2) {
|
|
5028
5528
|
return commonOptions(
|
|
5029
5529
|
program2.command("dev").description("Run your Trigger.dev tasks locally").argument("[path]", "The path to the project", ".").option("-c, --config <config file>", "The name of the config file, found at [path].").option(
|
|
5030
5530
|
"-p, --project-ref <project ref>",
|
|
5031
5531
|
"The project ref. Required if there is no config file."
|
|
5032
|
-
).option("--debugger", "Enable the debugger").option("--debug-otel", "Enable OpenTelemetry debugging")
|
|
5532
|
+
).option("--debugger", "Enable the debugger").option("--debug-otel", "Enable OpenTelemetry debugging").option("--skip-update-check", "Skip checking for @trigger.dev package updates")
|
|
5033
5533
|
).action(async (path7, options) => {
|
|
5034
5534
|
wrapCommandAction("dev", DevCommandOptions, options, async (opts) => {
|
|
5035
5535
|
await devCommand(path7, opts);
|
|
@@ -5071,7 +5571,11 @@ async function startDev(dir, options, authorization, dashboardUrl) {
|
|
|
5071
5571
|
logger.loggerLevel = options.logLevel;
|
|
5072
5572
|
}
|
|
5073
5573
|
await printStandloneInitialBanner(true);
|
|
5074
|
-
|
|
5574
|
+
if (!options.skipUpdateCheck) {
|
|
5575
|
+
console.log();
|
|
5576
|
+
await updateTriggerPackages(dir, { ...options }, false, true);
|
|
5577
|
+
}
|
|
5578
|
+
printDevBanner(!options.skipUpdateCheck);
|
|
5075
5579
|
logger.debug("Starting dev session", { dir, options, authorization });
|
|
5076
5580
|
let config = await readConfig(dir, {
|
|
5077
5581
|
projectRef: options.projectRef,
|
|
@@ -5236,9 +5740,9 @@ function useDev({
|
|
|
5236
5740
|
}
|
|
5237
5741
|
let latestWorkerContentHash;
|
|
5238
5742
|
const taskFiles = await gatherTaskFiles(config);
|
|
5239
|
-
const workerFacadePath =
|
|
5743
|
+
const workerFacadePath = join7(cliRootPath(), "workers", "dev", "worker-facade.js");
|
|
5240
5744
|
const workerFacade = readFileSync3(workerFacadePath, "utf-8");
|
|
5241
|
-
const workerSetupPath =
|
|
5745
|
+
const workerSetupPath = join7(cliRootPath(), "workers", "dev", "worker-setup.js");
|
|
5242
5746
|
let entryPointContents = workerFacade.replace("__TASKS__", createTaskFileImports(taskFiles)).replace(
|
|
5243
5747
|
"__WORKER_SETUP__",
|
|
5244
5748
|
`import { tracingSDK, sender } from "${escapeImportPath(workerSetupPath)}";`
|
|
@@ -5303,7 +5807,7 @@ function useDev({
|
|
|
5303
5807
|
if (!firstBuild) {
|
|
5304
5808
|
logger.log(chalkGrey("\u25CB Building background worker\u2026"));
|
|
5305
5809
|
}
|
|
5306
|
-
const metaOutputKey =
|
|
5810
|
+
const metaOutputKey = join7("out", `stdin.js`).replace(/\\/g, "/");
|
|
5307
5811
|
logger.debug("Metafile", {
|
|
5308
5812
|
metafileOutputs: JSON.stringify(result.metafile?.outputs)
|
|
5309
5813
|
});
|
|
@@ -5311,14 +5815,14 @@ function useDev({
|
|
|
5311
5815
|
if (!metaOutput) {
|
|
5312
5816
|
throw new Error(`Could not find metafile`);
|
|
5313
5817
|
}
|
|
5314
|
-
const outputFileKey =
|
|
5818
|
+
const outputFileKey = join7(config.projectDir, metaOutputKey);
|
|
5315
5819
|
const outputFile = result.outputFiles.find((file) => file.path === outputFileKey);
|
|
5316
5820
|
if (!outputFile) {
|
|
5317
5821
|
throw new Error(
|
|
5318
5822
|
`Could not find output file for entry point ${metaOutput.entryPoint}`
|
|
5319
5823
|
);
|
|
5320
5824
|
}
|
|
5321
|
-
const sourceMapFileKey =
|
|
5825
|
+
const sourceMapFileKey = join7(config.projectDir, `${metaOutputKey}.map`);
|
|
5322
5826
|
const sourceMapFile = result.outputFiles.find(
|
|
5323
5827
|
(file) => file.path === sourceMapFileKey
|
|
5324
5828
|
);
|
|
@@ -5329,10 +5833,10 @@ function useDev({
|
|
|
5329
5833
|
logger.log(chalkGrey("\u25CB No changes detected, skipping build\u2026"));
|
|
5330
5834
|
return;
|
|
5331
5835
|
}
|
|
5332
|
-
const fullPath =
|
|
5836
|
+
const fullPath = join7(config.projectDir, ".trigger", `${contentHash}.js`);
|
|
5333
5837
|
const sourceMapPath = `${fullPath}.map`;
|
|
5334
5838
|
const outputFileWithSourceMap = `${outputFile.text}
|
|
5335
|
-
//# sourceMappingURL=${
|
|
5839
|
+
//# sourceMappingURL=${basename2(sourceMapPath)}`;
|
|
5336
5840
|
await fs7.promises.mkdir(dirname3(fullPath), { recursive: true });
|
|
5337
5841
|
await fs7.promises.writeFile(fullPath, outputFileWithSourceMap);
|
|
5338
5842
|
logger.debug(`Wrote background worker to ${fullPath}`);
|
|
@@ -5536,7 +6040,7 @@ async function gatherRequiredDependencies2(outputMeta, config) {
|
|
|
5536
6040
|
}
|
|
5537
6041
|
}
|
|
5538
6042
|
if (config.additionalPackages) {
|
|
5539
|
-
const projectPackageJson = await readJSONFile(
|
|
6043
|
+
const projectPackageJson = await readJSONFile(join7(config.projectDir, "package.json"));
|
|
5540
6044
|
for (const packageName of config.additionalPackages) {
|
|
5541
6045
|
if (dependencies2[packageName]) {
|
|
5542
6046
|
continue;
|
|
@@ -5606,7 +6110,7 @@ async function amendNodePathWithPnpmNodeModules(nodePath) {
|
|
|
5606
6110
|
async function findPnpmNodeModulesPath() {
|
|
5607
6111
|
return await findUp3(
|
|
5608
6112
|
async (directory) => {
|
|
5609
|
-
const pnpmModules =
|
|
6113
|
+
const pnpmModules = join7(directory, "node_modules", ".pnpm", "node_modules");
|
|
5610
6114
|
const hasPnpmNodeModules = await pathExists2(pnpmModules);
|
|
5611
6115
|
if (hasPnpmNodeModules) {
|
|
5612
6116
|
return pnpmModules;
|
|
@@ -5617,7 +6121,7 @@ async function findPnpmNodeModulesPath() {
|
|
|
5617
6121
|
}
|
|
5618
6122
|
|
|
5619
6123
|
// src/commands/init.ts
|
|
5620
|
-
import { intro as
|
|
6124
|
+
import { intro as intro5, isCancel as isCancel2, log as log6, outro as outro5, select as select2, text } from "@clack/prompts";
|
|
5621
6125
|
import { context as context3, trace as trace3 } from "@opentelemetry/api";
|
|
5622
6126
|
import {
|
|
5623
6127
|
flattenAttributes as flattenAttributes3,
|
|
@@ -5627,8 +6131,8 @@ import chalk6 from "chalk";
|
|
|
5627
6131
|
import { execa as execa3 } from "execa";
|
|
5628
6132
|
import { applyEdits, modify } from "jsonc-parser";
|
|
5629
6133
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
5630
|
-
import { join as
|
|
5631
|
-
import
|
|
6134
|
+
import { join as join8, relative as relative4, resolve as resolve4 } from "node:path";
|
|
6135
|
+
import terminalLink4 from "terminal-link";
|
|
5632
6136
|
import { z as z6 } from "zod";
|
|
5633
6137
|
|
|
5634
6138
|
// src/utilities/createFileFromTemplate.ts
|
|
@@ -5703,7 +6207,7 @@ async function initCommand(dir, options) {
|
|
|
5703
6207
|
}
|
|
5704
6208
|
async function _initCommand(dir, options) {
|
|
5705
6209
|
const span = trace3.getSpan(context3.active());
|
|
5706
|
-
|
|
6210
|
+
intro5("Initializing project");
|
|
5707
6211
|
const authorization = await login({
|
|
5708
6212
|
embedded: true,
|
|
5709
6213
|
defaultApiUrl: options.apiUrl,
|
|
@@ -5727,7 +6231,7 @@ async function _initCommand(dir, options) {
|
|
|
5727
6231
|
if (!options.overrideConfig) {
|
|
5728
6232
|
try {
|
|
5729
6233
|
const result = await readConfig(dir);
|
|
5730
|
-
|
|
6234
|
+
outro5(
|
|
5731
6235
|
result.status === "file" ? `Project already initialized: Found config file at ${result.path}. Pass --override-config to override` : "Project already initialized"
|
|
5732
6236
|
);
|
|
5733
6237
|
return;
|
|
@@ -5744,55 +6248,55 @@ async function _initCommand(dir, options) {
|
|
|
5744
6248
|
...flattenAttributes3(selectedProject, "cli.project")
|
|
5745
6249
|
});
|
|
5746
6250
|
logger.debug("Selected project", selectedProject);
|
|
5747
|
-
|
|
6251
|
+
log6.step(`Configuring project "${selectedProject.name}" (${selectedProject.externalRef})`);
|
|
5748
6252
|
if (!options.skipPackageInstall) {
|
|
5749
6253
|
await installPackages2(dir, options);
|
|
5750
6254
|
} else {
|
|
5751
|
-
|
|
6255
|
+
log6.info("Skipping package installation");
|
|
5752
6256
|
}
|
|
5753
6257
|
const triggerDir = await createTriggerDir(dir, options);
|
|
5754
6258
|
await writeConfigFile(dir, selectedProject, options, triggerDir);
|
|
5755
6259
|
await addConfigFileToTsConfig(dir, options);
|
|
5756
6260
|
await gitIgnoreDotTriggerDir(dir, options);
|
|
5757
|
-
const projectDashboard =
|
|
6261
|
+
const projectDashboard = terminalLink4(
|
|
5758
6262
|
"project dashboard",
|
|
5759
6263
|
`${authorization.dashboardUrl}/projects/v3/${selectedProject.externalRef}`
|
|
5760
6264
|
);
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
6265
|
+
log6.success("Successfully initialized project for Trigger.dev v3 \u{1FAE1}");
|
|
6266
|
+
log6.info("Next steps:");
|
|
6267
|
+
log6.info(
|
|
5764
6268
|
` 1. To start developing, run ${chalk6.green(
|
|
5765
6269
|
`npx trigger.dev@${options.tag} dev`
|
|
5766
6270
|
)} in your project directory`
|
|
5767
6271
|
);
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
` 3. Head over to our ${
|
|
6272
|
+
log6.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
|
|
6273
|
+
log6.info(
|
|
6274
|
+
` 3. Head over to our ${terminalLink4(
|
|
5771
6275
|
"v3 docs",
|
|
5772
6276
|
"https://trigger.dev/docs/v3"
|
|
5773
6277
|
)} to learn more.`
|
|
5774
6278
|
);
|
|
5775
|
-
|
|
5776
|
-
` 4. Need help? Join our ${
|
|
6279
|
+
log6.info(
|
|
6280
|
+
` 4. Need help? Join our ${terminalLink4(
|
|
5777
6281
|
"Discord community",
|
|
5778
6282
|
"https://trigger.dev/discord"
|
|
5779
6283
|
)} or email us at ${chalk6.cyan("help@trigger.dev")}`
|
|
5780
6284
|
);
|
|
5781
|
-
|
|
6285
|
+
outro5(`Project initialized successfully. Happy coding!`);
|
|
5782
6286
|
}
|
|
5783
6287
|
async function createTriggerDir(dir, options) {
|
|
5784
6288
|
return await tracer.startActiveSpan("createTriggerDir", async (span) => {
|
|
5785
6289
|
try {
|
|
5786
|
-
const defaultValue =
|
|
6290
|
+
const defaultValue = join8(dir, "src", "trigger");
|
|
5787
6291
|
const location = await text({
|
|
5788
6292
|
message: "Where would you like to create the Trigger.dev directory?",
|
|
5789
6293
|
defaultValue,
|
|
5790
6294
|
placeholder: defaultValue
|
|
5791
6295
|
});
|
|
5792
|
-
if (
|
|
6296
|
+
if (isCancel2(location)) {
|
|
5793
6297
|
throw new OutroCommandError();
|
|
5794
6298
|
}
|
|
5795
|
-
const triggerDir =
|
|
6299
|
+
const triggerDir = resolve4(process.cwd(), location);
|
|
5796
6300
|
logger.debug({ triggerDir });
|
|
5797
6301
|
span.setAttributes({
|
|
5798
6302
|
"cli.triggerDir": triggerDir
|
|
@@ -5811,7 +6315,7 @@ async function createTriggerDir(dir, options) {
|
|
|
5811
6315
|
}
|
|
5812
6316
|
]
|
|
5813
6317
|
});
|
|
5814
|
-
if (
|
|
6318
|
+
if (isCancel2(exampleSelection)) {
|
|
5815
6319
|
throw new OutroCommandError();
|
|
5816
6320
|
}
|
|
5817
6321
|
const example = exampleSelection;
|
|
@@ -5819,20 +6323,20 @@ async function createTriggerDir(dir, options) {
|
|
|
5819
6323
|
"cli.example": example
|
|
5820
6324
|
});
|
|
5821
6325
|
if (example === "none") {
|
|
5822
|
-
await createFile(
|
|
5823
|
-
|
|
6326
|
+
await createFile(join8(triggerDir, ".gitkeep"), "");
|
|
6327
|
+
log6.step(`Created directory at ${location}`);
|
|
5824
6328
|
span.end();
|
|
5825
6329
|
return { location, isCustomValue: location !== defaultValue };
|
|
5826
6330
|
}
|
|
5827
|
-
const templatePath =
|
|
5828
|
-
const outputPath =
|
|
6331
|
+
const templatePath = join8(cliRootPath(), "templates", "examples", `${example}.ts.template`);
|
|
6332
|
+
const outputPath = join8(triggerDir, "example.ts");
|
|
5829
6333
|
await createFileFromTemplate({
|
|
5830
6334
|
templatePath,
|
|
5831
6335
|
outputPath,
|
|
5832
6336
|
replacements: {}
|
|
5833
6337
|
});
|
|
5834
6338
|
const relativeOutputPath = relative4(process.cwd(), outputPath);
|
|
5835
|
-
|
|
6339
|
+
log6.step(`Created example file at ${relativeOutputPath}`);
|
|
5836
6340
|
span.end();
|
|
5837
6341
|
return { location, isCustomValue: location !== defaultValue };
|
|
5838
6342
|
} catch (e) {
|
|
@@ -5847,15 +6351,15 @@ async function createTriggerDir(dir, options) {
|
|
|
5847
6351
|
async function gitIgnoreDotTriggerDir(dir, options) {
|
|
5848
6352
|
return await tracer.startActiveSpan("gitIgnoreDotTriggerDir", async (span) => {
|
|
5849
6353
|
try {
|
|
5850
|
-
const projectDir =
|
|
5851
|
-
const gitIgnorePath =
|
|
6354
|
+
const projectDir = resolve4(process.cwd(), dir);
|
|
6355
|
+
const gitIgnorePath = join8(projectDir, ".gitignore");
|
|
5852
6356
|
span.setAttributes({
|
|
5853
6357
|
"cli.projectDir": projectDir,
|
|
5854
6358
|
"cli.gitIgnorePath": gitIgnorePath
|
|
5855
6359
|
});
|
|
5856
6360
|
if (!await pathExists(gitIgnorePath)) {
|
|
5857
6361
|
await createFile(gitIgnorePath, ".trigger");
|
|
5858
|
-
|
|
6362
|
+
log6.step(`Added .trigger to .gitignore`);
|
|
5859
6363
|
span.end();
|
|
5860
6364
|
return;
|
|
5861
6365
|
}
|
|
@@ -5867,7 +6371,7 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
5867
6371
|
const newGitIgnoreContent = `${gitIgnoreContent}
|
|
5868
6372
|
.trigger`;
|
|
5869
6373
|
await writeFile3(gitIgnorePath, newGitIgnoreContent, "utf-8");
|
|
5870
|
-
|
|
6374
|
+
log6.step(`Added .trigger to .gitignore`);
|
|
5871
6375
|
span.end();
|
|
5872
6376
|
} catch (e) {
|
|
5873
6377
|
if (!(e instanceof SkipCommandError)) {
|
|
@@ -5881,8 +6385,8 @@ async function gitIgnoreDotTriggerDir(dir, options) {
|
|
|
5881
6385
|
async function addConfigFileToTsConfig(dir, options) {
|
|
5882
6386
|
return await tracer.startActiveSpan("createTriggerDir", async (span) => {
|
|
5883
6387
|
try {
|
|
5884
|
-
const projectDir =
|
|
5885
|
-
const tsconfigPath =
|
|
6388
|
+
const projectDir = resolve4(process.cwd(), dir);
|
|
6389
|
+
const tsconfigPath = join8(projectDir, "tsconfig.json");
|
|
5886
6390
|
span.setAttributes({
|
|
5887
6391
|
"cli.projectDir": projectDir,
|
|
5888
6392
|
"cli.tsconfigPath": tsconfigPath
|
|
@@ -5900,7 +6404,7 @@ async function addConfigFileToTsConfig(dir, options) {
|
|
|
5900
6404
|
const newTsconfigContent = applyEdits(tsconfigContent, edits);
|
|
5901
6405
|
logger.debug("new tsconfig.json content", { newTsconfigContent });
|
|
5902
6406
|
await writeFile3(tsconfigPath, newTsconfigContent, "utf-8");
|
|
5903
|
-
|
|
6407
|
+
log6.step(`Added trigger.config.ts to tsconfig.json`);
|
|
5904
6408
|
span.end();
|
|
5905
6409
|
} catch (e) {
|
|
5906
6410
|
if (!(e instanceof SkipCommandError)) {
|
|
@@ -5915,7 +6419,7 @@ async function installPackages2(dir, options) {
|
|
|
5915
6419
|
return await tracer.startActiveSpan("installPackages", async (span) => {
|
|
5916
6420
|
const installSpinner = spinner();
|
|
5917
6421
|
try {
|
|
5918
|
-
const projectDir =
|
|
6422
|
+
const projectDir = resolve4(process.cwd(), dir);
|
|
5919
6423
|
const pkgManager = await getUserPackageManager(projectDir);
|
|
5920
6424
|
span.setAttributes({
|
|
5921
6425
|
"cli.projectDir": projectDir,
|
|
@@ -5967,9 +6471,9 @@ async function writeConfigFile(dir, project, options, triggerDir) {
|
|
|
5967
6471
|
try {
|
|
5968
6472
|
const spnnr = spinner();
|
|
5969
6473
|
spnnr.start("Creating config file");
|
|
5970
|
-
const projectDir =
|
|
5971
|
-
const templatePath =
|
|
5972
|
-
const outputPath =
|
|
6474
|
+
const projectDir = resolve4(process.cwd(), dir);
|
|
6475
|
+
const templatePath = join8(cliRootPath(), "templates", "trigger.config.ts.template");
|
|
6476
|
+
const outputPath = join8(projectDir, "trigger.config.ts");
|
|
5973
6477
|
span.setAttributes({
|
|
5974
6478
|
"cli.projectDir": projectDir,
|
|
5975
6479
|
"cli.templatePath": templatePath,
|
|
@@ -6009,7 +6513,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
6009
6513
|
if (projectRef) {
|
|
6010
6514
|
const projectResponse = await apiClient2.getProject(projectRef);
|
|
6011
6515
|
if (!projectResponse.success) {
|
|
6012
|
-
|
|
6516
|
+
log6.error(
|
|
6013
6517
|
`--project-ref ${projectRef} is not a valid project ref. Request to fetch data resulted in: ${projectResponse.error}`
|
|
6014
6518
|
);
|
|
6015
6519
|
throw new SkipCommandError(projectResponse.error);
|
|
@@ -6025,11 +6529,11 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
6025
6529
|
throw new Error(`Failed to get projects: ${projectsResponse.error}`);
|
|
6026
6530
|
}
|
|
6027
6531
|
if (projectsResponse.data.length === 0) {
|
|
6028
|
-
const newProjectLink =
|
|
6532
|
+
const newProjectLink = terminalLink4(
|
|
6029
6533
|
"Create new project",
|
|
6030
6534
|
`${dashboardUrl}/projects/new?version=v3`
|
|
6031
6535
|
);
|
|
6032
|
-
|
|
6536
|
+
outro5(`You don't have any projects yet. ${newProjectLink}`);
|
|
6033
6537
|
throw new SkipCommandError();
|
|
6034
6538
|
}
|
|
6035
6539
|
const selectedProject = await select2({
|
|
@@ -6040,7 +6544,7 @@ async function selectProject(apiClient2, dashboardUrl, projectRef) {
|
|
|
6040
6544
|
hint: project.organization.title
|
|
6041
6545
|
}))
|
|
6042
6546
|
});
|
|
6043
|
-
if (
|
|
6547
|
+
if (isCancel2(selectedProject)) {
|
|
6044
6548
|
throw new OutroCommandError();
|
|
6045
6549
|
}
|
|
6046
6550
|
const projectData = projectsResponse.data.find(
|
|
@@ -6092,7 +6596,7 @@ async function logout(options) {
|
|
|
6092
6596
|
}
|
|
6093
6597
|
|
|
6094
6598
|
// src/commands/list-profiles.ts
|
|
6095
|
-
import { log as
|
|
6599
|
+
import { log as log7, outro as outro6 } from "@clack/prompts";
|
|
6096
6600
|
var ListProfilesOptions = CommonCommandOptions;
|
|
6097
6601
|
function configureListProfilesCommand(program2) {
|
|
6098
6602
|
return program2.command("list-profiles").description("List all of your CLI profiles").option(
|
|
@@ -6118,12 +6622,12 @@ async function listProfiles(options) {
|
|
|
6118
6622
|
return;
|
|
6119
6623
|
}
|
|
6120
6624
|
const profiles = Object.keys(authConfig);
|
|
6121
|
-
|
|
6625
|
+
log7.message("Profiles:");
|
|
6122
6626
|
for (const profile of profiles) {
|
|
6123
6627
|
const profileConfig = authConfig[profile];
|
|
6124
|
-
|
|
6628
|
+
log7.info(`${profile}${profileConfig?.apiUrl ? ` - ${chalkGrey(profileConfig.apiUrl)}` : ""}`);
|
|
6125
6629
|
}
|
|
6126
|
-
|
|
6630
|
+
outro6("Retrieve account info by running whoami --profile <profile>");
|
|
6127
6631
|
}
|
|
6128
6632
|
|
|
6129
6633
|
// src/cli/index.ts
|
|
@@ -6136,6 +6640,7 @@ configureDeployCommand(program);
|
|
|
6136
6640
|
configureWhoamiCommand(program);
|
|
6137
6641
|
configureLogoutCommand(program);
|
|
6138
6642
|
configureListProfilesCommand(program);
|
|
6643
|
+
configureUpdateCommand(program);
|
|
6139
6644
|
|
|
6140
6645
|
// src/index.ts
|
|
6141
6646
|
var main = async () => {
|