trigger.dev 4.1.2 → 4.3.0
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/esm/apiClient.d.ts +15 -2
- package/dist/esm/apiClient.js +11 -1
- package/dist/esm/apiClient.js.map +1 -1
- package/dist/esm/build/buildWorker.d.ts +2 -0
- package/dist/esm/build/buildWorker.js +20 -6
- package/dist/esm/build/buildWorker.js.map +1 -1
- package/dist/esm/build/bundle.d.ts +7 -2
- package/dist/esm/build/bundle.js +19 -6
- package/dist/esm/build/bundle.js.map +1 -1
- package/dist/esm/build/extensions.d.ts +4 -2
- package/dist/esm/build/extensions.js +15 -13
- package/dist/esm/build/extensions.js.map +1 -1
- package/dist/esm/build/manifests.d.ts +1 -1
- package/dist/esm/build/manifests.js +74 -5
- package/dist/esm/build/manifests.js.map +1 -1
- package/dist/esm/cli/common.d.ts +2 -2
- package/dist/esm/cli/common.js +1 -0
- package/dist/esm/cli/common.js.map +1 -1
- package/dist/esm/commands/analyze.d.ts +2 -2
- package/dist/esm/commands/deploy.js +382 -29
- package/dist/esm/commands/deploy.js.map +1 -1
- package/dist/esm/commands/dev.d.ts +2 -2
- package/dist/esm/commands/dev.js +1 -1
- package/dist/esm/commands/dev.js.map +1 -1
- package/dist/esm/commands/env.js +3 -3
- package/dist/esm/commands/env.js.map +1 -1
- package/dist/esm/commands/init.js +1 -1
- package/dist/esm/commands/init.js.map +1 -1
- package/dist/esm/commands/install-mcp.d.ts +2 -2
- package/dist/esm/commands/list-profiles.d.ts +2 -2
- package/dist/esm/commands/login.d.ts +2 -2
- package/dist/esm/commands/login.js +1 -1
- package/dist/esm/commands/login.js.map +1 -1
- package/dist/esm/commands/logout.d.ts +2 -2
- package/dist/esm/commands/logout.js +1 -1
- package/dist/esm/commands/logout.js.map +1 -1
- package/dist/esm/commands/mcp.d.ts +2 -2
- package/dist/esm/commands/mcp.js +1 -1
- package/dist/esm/commands/mcp.js.map +1 -1
- package/dist/esm/commands/preview.js +1 -1
- package/dist/esm/commands/preview.js.map +1 -1
- package/dist/esm/commands/promote.js +1 -1
- package/dist/esm/commands/promote.js.map +1 -1
- package/dist/esm/commands/switch.d.ts +2 -2
- package/dist/esm/commands/trigger.d.ts +2 -2
- package/dist/esm/commands/trigger.js +1 -1
- package/dist/esm/commands/trigger.js.map +1 -1
- package/dist/esm/commands/update.d.ts +2 -2
- package/dist/esm/commands/whoami.d.ts +2 -2
- package/dist/esm/commands/whoami.js +1 -1
- package/dist/esm/commands/whoami.js.map +1 -1
- package/dist/esm/commands/workers/build.js +2 -1
- package/dist/esm/commands/workers/build.js.map +1 -1
- package/dist/esm/commands/workers/create.js +1 -1
- package/dist/esm/commands/workers/create.js.map +1 -1
- package/dist/esm/commands/workers/list.js +1 -1
- package/dist/esm/commands/workers/list.js.map +1 -1
- package/dist/esm/commands/workers/run.js +1 -1
- package/dist/esm/commands/workers/run.js.map +1 -1
- package/dist/esm/deploy/archiveContext.d.ts +2 -0
- package/dist/esm/deploy/archiveContext.js +130 -0
- package/dist/esm/deploy/archiveContext.js.map +1 -0
- package/dist/esm/deploy/buildImage.d.ts +7 -0
- package/dist/esm/deploy/buildImage.js +62 -22
- package/dist/esm/deploy/buildImage.js.map +1 -1
- package/dist/esm/dev/devSession.js +6 -2
- package/dist/esm/dev/devSession.js.map +1 -1
- package/dist/esm/dev/devSupervisor.js +8 -4
- package/dist/esm/dev/devSupervisor.js.map +1 -1
- package/dist/esm/entryPoints/dev-run-controller.d.ts +0 -1
- package/dist/esm/entryPoints/dev-run-controller.js +0 -6
- package/dist/esm/entryPoints/dev-run-controller.js.map +1 -1
- package/dist/esm/entryPoints/dev-run-worker.js +1 -0
- package/dist/esm/entryPoints/dev-run-worker.js.map +1 -1
- package/dist/esm/entryPoints/managed/env.d.ts +2 -2
- package/dist/esm/entryPoints/managed/env.js +2 -2
- package/dist/esm/entryPoints/managed/env.js.map +1 -1
- package/dist/esm/entryPoints/managed-index-controller.js +4 -2
- package/dist/esm/entryPoints/managed-index-controller.js.map +1 -1
- package/dist/esm/entryPoints/managed-run-worker.js +1 -0
- package/dist/esm/entryPoints/managed-run-worker.js.map +1 -1
- package/dist/esm/executions/taskRunProcess.js +4 -0
- package/dist/esm/executions/taskRunProcess.js.map +1 -1
- package/dist/esm/mcp/tools/deploys.d.ts +84 -30
- package/dist/esm/mcp/tools/docs.d.ts +42 -15
- package/dist/esm/mcp/tools/orgs.d.ts +84 -30
- package/dist/esm/mcp/tools/previewBranches.d.ts +42 -15
- package/dist/esm/mcp/tools/runs.d.ts +168 -60
- package/dist/esm/mcp/tools/tasks.d.ts +84 -30
- package/dist/esm/mcp/utils.d.ts +42 -15
- package/dist/esm/utilities/buildManifest.js +3 -1
- package/dist/esm/utilities/buildManifest.js.map +1 -1
- package/dist/esm/utilities/dotEnv.js +11 -1
- package/dist/esm/utilities/dotEnv.js.map +1 -1
- package/dist/esm/utilities/fileSystem.d.ts +17 -0
- package/dist/esm/utilities/fileSystem.js +65 -1
- package/dist/esm/utilities/fileSystem.js.map +1 -1
- package/dist/esm/utilities/gitMeta.d.ts +1 -0
- package/dist/esm/utilities/gitMeta.js +1 -1
- package/dist/esm/utilities/gitMeta.js.map +1 -1
- package/dist/esm/utilities/initialBanner.d.ts +2 -2
- package/dist/esm/utilities/initialBanner.js +6 -6
- package/dist/esm/utilities/initialBanner.js.map +1 -1
- package/dist/esm/utilities/logger.d.ts +1 -1
- package/dist/esm/utilities/tempDirectories.d.ts +7 -0
- package/dist/esm/utilities/tempDirectories.js +23 -0
- package/dist/esm/utilities/tempDirectories.js.map +1 -1
- package/dist/esm/utilities/windows.d.ts +3 -1
- package/dist/esm/utilities/windows.js +14 -1
- package/dist/esm/utilities/windows.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +9 -5
package/dist/esm/cli/common.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ export declare const CommonCommandOptions: z.ZodObject<{
|
|
|
6
6
|
skipTelemetry: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
profile: z.ZodDefault<z.ZodString>;
|
|
8
8
|
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
logLevel: "error" | "
|
|
9
|
+
logLevel: "error" | "log" | "debug" | "info" | "warn" | "none";
|
|
10
10
|
skipTelemetry: boolean;
|
|
11
11
|
profile: string;
|
|
12
12
|
apiUrl?: string | undefined;
|
|
13
13
|
}, {
|
|
14
|
-
logLevel?: "error" | "
|
|
14
|
+
logLevel?: "error" | "log" | "debug" | "info" | "warn" | "none" | undefined;
|
|
15
15
|
apiUrl?: string | undefined;
|
|
16
16
|
skipTelemetry?: boolean | undefined;
|
|
17
17
|
profile?: string | undefined;
|
package/dist/esm/cli/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/cli/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EA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CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -8,11 +8,11 @@ declare const AnalyzeOptions: z.ZodObject<Pick<{
|
|
|
8
8
|
}, "logLevel" | "skipTelemetry"> & {
|
|
9
9
|
verbose: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
logLevel: "error" | "
|
|
11
|
+
logLevel: "error" | "log" | "debug" | "info" | "warn" | "none";
|
|
12
12
|
verbose: boolean;
|
|
13
13
|
skipTelemetry: boolean;
|
|
14
14
|
}, {
|
|
15
|
-
logLevel?: "error" | "
|
|
15
|
+
logLevel?: "error" | "log" | "debug" | "info" | "warn" | "none" | undefined;
|
|
16
16
|
verbose?: boolean | undefined;
|
|
17
17
|
skipTelemetry?: boolean | undefined;
|
|
18
18
|
}>;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { intro, log, outro } from "@clack/prompts";
|
|
2
2
|
import { getBranch, prepareDeploymentError, tryCatch } from "@trigger.dev/core/v3";
|
|
3
|
+
import { DeploymentEventFromString, } from "@trigger.dev/core/v3/schemas";
|
|
3
4
|
import { Option as CommandOption } from "commander";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
+
import { join, relative, resolve } from "node:path";
|
|
5
6
|
import { isCI } from "std-env";
|
|
6
7
|
import { x } from "tinyexec";
|
|
7
8
|
import { z } from "zod";
|
|
9
|
+
import chalk from "chalk";
|
|
8
10
|
import { buildWorker } from "../build/buildWorker.js";
|
|
9
11
|
import { resolveAlwaysExternal } from "../build/externals.js";
|
|
10
|
-
import {
|
|
12
|
+
import { createContextArchive, getArchiveSize } from "../deploy/archiveContext.js";
|
|
13
|
+
import { S2 } from "@s2-dev/streamstore";
|
|
14
|
+
import { mkdir, readFile, unlink } from "node:fs/promises";
|
|
15
|
+
import { CommonCommandOptions, commonOptions, handleTelemetry, OutroCommandError, SkipLoggingError, wrapCommandAction, } from "../cli/common.js";
|
|
11
16
|
import { loadConfig } from "../config.js";
|
|
12
17
|
import { buildImage } from "../deploy/buildImage.js";
|
|
13
18
|
import { checkLogsForErrors, checkLogsForWarnings, printErrors, printWarnings, saveLogs, } from "../deploy/logs.js";
|
|
14
|
-
import { chalkError, cliLink, isLinksSupported, prettyError, prettyWarning, } from "../utilities/cliOutput.js";
|
|
19
|
+
import { chalkError, chalkGrey, chalkWarning, cliLink, isLinksSupported, prettyError, prettyWarning, } from "../utilities/cliOutput.js";
|
|
15
20
|
import { loadDotEnvVars } from "../utilities/dotEnv.js";
|
|
16
21
|
import { isDirectory } from "../utilities/fileSystem.js";
|
|
17
22
|
import { setGithubActionsOutputAndEnvVars } from "../utilities/githubActions.js";
|
|
18
|
-
import { createGitMeta } from "../utilities/gitMeta.js";
|
|
23
|
+
import { createGitMeta, isGitHubActions } from "../utilities/gitMeta.js";
|
|
19
24
|
import { printStandloneInitialBanner } from "../utilities/initialBanner.js";
|
|
20
25
|
import { resolveLocalEnvVars } from "../utilities/localEnvVars.js";
|
|
21
26
|
import { logger } from "../utilities/logger.js";
|
|
@@ -36,14 +41,22 @@ const DeployCommandOptions = CommonCommandOptions.extend({
|
|
|
36
41
|
saveLogs: z.boolean().default(false),
|
|
37
42
|
skipUpdateCheck: z.boolean().default(false),
|
|
38
43
|
skipPromotion: z.boolean().default(false),
|
|
39
|
-
|
|
44
|
+
cache: z.boolean().default(true),
|
|
40
45
|
envFile: z.string().optional(),
|
|
41
46
|
// Local build options
|
|
42
47
|
forceLocalBuild: z.boolean().optional(),
|
|
48
|
+
localBuild: z.boolean().optional(),
|
|
43
49
|
useRegistryCache: z.boolean().default(false),
|
|
44
50
|
network: z.enum(["default", "none", "host"]).optional(),
|
|
45
51
|
push: z.boolean().optional(),
|
|
46
52
|
builder: z.string().default("trigger"),
|
|
53
|
+
nativeBuildServer: z.boolean().default(false),
|
|
54
|
+
detach: z.boolean().default(false),
|
|
55
|
+
plain: z.boolean().default(false),
|
|
56
|
+
compression: z.enum(["zstd", "gzip"]).default("zstd"),
|
|
57
|
+
cacheCompression: z.enum(["zstd", "gzip"]).default("zstd"),
|
|
58
|
+
compressionLevel: z.number().optional(),
|
|
59
|
+
forceCompression: z.boolean().default(true),
|
|
47
60
|
});
|
|
48
61
|
export function configureDeployCommand(program) {
|
|
49
62
|
return (commonOptions(program
|
|
@@ -66,15 +79,30 @@ export function configureDeployCommand(program) {
|
|
|
66
79
|
.addOption(new CommandOption("--load", "Load the built image into your local docker").hideHelp())
|
|
67
80
|
.addOption(new CommandOption("--no-load", "Do not load the built image into your local docker").hideHelp())
|
|
68
81
|
.addOption(new CommandOption("--save-logs", "If provided, will save logs even for successful builds").hideHelp())
|
|
82
|
+
.addOption(new CommandOption("--compression <algorithm>", "Compression algorithm for image layers: zstd or gzip (default: zstd)")
|
|
83
|
+
.choices(["zstd", "gzip"])
|
|
84
|
+
.hideHelp())
|
|
85
|
+
.addOption(new CommandOption("--cache-compression <algorithm>", "Compression algorithm for build cache: zstd or gzip (default: zstd)")
|
|
86
|
+
.choices(["zstd", "gzip"])
|
|
87
|
+
.hideHelp())
|
|
88
|
+
.addOption(new CommandOption("--compression-level <level>", "The compression level to use when building the image.").hideHelp())
|
|
89
|
+
.addOption(new CommandOption("--force-compression", "Force recompression of all layers. Enabled by default when using zstd.").hideHelp())
|
|
90
|
+
.addOption(new CommandOption("--no-force-compression", "Disable forced recompression of layers.").hideHelp())
|
|
69
91
|
// Local build options
|
|
70
|
-
.addOption(new CommandOption("--force-local-build", "
|
|
92
|
+
.addOption(new CommandOption("--force-local-build", "Deprecated alias for --local-build").implies({
|
|
93
|
+
localBuild: true,
|
|
94
|
+
}))
|
|
95
|
+
.addOption(new CommandOption("--local-build", "Build the deployment image locally"))
|
|
71
96
|
.addOption(new CommandOption("--push", "Push the image after local builds").hideHelp())
|
|
72
97
|
.addOption(new CommandOption("--no-push", "Do not push the image after local builds").hideHelp())
|
|
73
98
|
.addOption(new CommandOption("--network <mode>", "The networking mode for RUN instructions when building locally").hideHelp())
|
|
74
99
|
.addOption(new CommandOption("--builder <builder>", "The builder to use when building locally").hideHelp())
|
|
100
|
+
.addOption(new CommandOption("--native-build-server", "Use the native build server for building the image"))
|
|
101
|
+
.addOption(new CommandOption("--detach", "Return immediately after the deployment is queued, do not wait for the build to complete. Implies using the native build server.").implies({ nativeBuildServer: true }))
|
|
102
|
+
.addOption(new CommandOption("--plain", "Plain output").hideHelp())
|
|
75
103
|
.action(async (path, options) => {
|
|
76
104
|
await handleTelemetry(async () => {
|
|
77
|
-
await printStandloneInitialBanner(true);
|
|
105
|
+
await printStandloneInitialBanner(true, options.profile);
|
|
78
106
|
await deployCommand(path, options);
|
|
79
107
|
});
|
|
80
108
|
}));
|
|
@@ -85,7 +113,9 @@ export async function deployCommand(dir, options) {
|
|
|
85
113
|
});
|
|
86
114
|
}
|
|
87
115
|
async function _deployCommand(dir, options) {
|
|
88
|
-
|
|
116
|
+
if (!options.plain) {
|
|
117
|
+
intro(`Deploying project${options.skipPromotion ? " (without promotion)" : ""}`);
|
|
118
|
+
}
|
|
89
119
|
if (!options.skipUpdateCheck) {
|
|
90
120
|
await updateTriggerPackages(dir, { ...options }, true, true);
|
|
91
121
|
}
|
|
@@ -96,6 +126,7 @@ async function _deployCommand(dir, options) {
|
|
|
96
126
|
embedded: true,
|
|
97
127
|
defaultApiUrl: options.apiUrl,
|
|
98
128
|
profile: options.profile,
|
|
129
|
+
silent: options.plain,
|
|
99
130
|
});
|
|
100
131
|
if (!authorization.ok) {
|
|
101
132
|
if (authorization.error === "fetch failed") {
|
|
@@ -160,10 +191,21 @@ async function _deployCommand(dir, options) {
|
|
|
160
191
|
if (!projectClient) {
|
|
161
192
|
throw new Error("Failed to get project client");
|
|
162
193
|
}
|
|
194
|
+
if (options.nativeBuildServer) {
|
|
195
|
+
await handleNativeBuildServerDeploy({
|
|
196
|
+
apiClient: projectClient.client,
|
|
197
|
+
config: resolvedConfig,
|
|
198
|
+
dashboardUrl: authorization.dashboardUrl,
|
|
199
|
+
options,
|
|
200
|
+
userId: authorization.auth.tokenType === "personal" ? authorization.userId : undefined,
|
|
201
|
+
gitMeta,
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
163
205
|
const serverEnvVars = await projectClient.client.getEnvironmentVariables(resolvedConfig.project);
|
|
164
206
|
loadDotEnvVars(resolvedConfig.workingDir, options.envFile);
|
|
165
207
|
const destination = getTmpDir(resolvedConfig.workingDir, "build", options.dryRun);
|
|
166
|
-
const $buildSpinner = spinner();
|
|
208
|
+
const $buildSpinner = spinner({ plain: options.plain });
|
|
167
209
|
const forcedExternals = await resolveAlwaysExternal(projectClient.client);
|
|
168
210
|
const { features } = resolvedConfig;
|
|
169
211
|
const [error, buildManifest] = await tryCatch(buildWorker({
|
|
@@ -175,6 +217,7 @@ async function _deployCommand(dir, options) {
|
|
|
175
217
|
rewritePaths: true,
|
|
176
218
|
envVars: serverEnvVars.success ? serverEnvVars.data.variables : {},
|
|
177
219
|
forcedExternals,
|
|
220
|
+
plain: options.plain,
|
|
178
221
|
listener: {
|
|
179
222
|
onBundleStart() {
|
|
180
223
|
$buildSpinner.start("Building trigger code");
|
|
@@ -200,10 +243,12 @@ async function _deployCommand(dir, options) {
|
|
|
200
243
|
gitMeta,
|
|
201
244
|
type: features.run_engine_v2 ? "MANAGED" : "V1",
|
|
202
245
|
runtime: buildManifest.runtime,
|
|
246
|
+
isNativeBuild: false,
|
|
247
|
+
triggeredVia: getTriggeredVia(),
|
|
203
248
|
}, envVars.TRIGGER_EXISTING_DEPLOYMENT_ID);
|
|
204
|
-
const isLocalBuild = options.
|
|
249
|
+
const isLocalBuild = options.localBuild || !deployment.externalBuildData;
|
|
205
250
|
// Would be best to actually store this separately in the deployment object. This is an okay proxy for now.
|
|
206
|
-
const remoteBuildExplicitlySkipped = options.
|
|
251
|
+
const remoteBuildExplicitlySkipped = options.localBuild && !!deployment.externalBuildData;
|
|
207
252
|
// Fail fast if we know local builds will fail
|
|
208
253
|
if (isLocalBuild) {
|
|
209
254
|
const result = await x("docker", ["buildx", "version"]);
|
|
@@ -221,7 +266,7 @@ async function _deployCommand(dir, options) {
|
|
|
221
266
|
const numberOfEnvVars = Object.keys(childVars).length + Object.keys(parentVars).length;
|
|
222
267
|
const vars = numberOfEnvVars === 1 ? "var" : "vars";
|
|
223
268
|
if (!options.skipSyncEnvVars) {
|
|
224
|
-
const $spinner = spinner();
|
|
269
|
+
const $spinner = spinner({ plain: options.plain });
|
|
225
270
|
$spinner.start(`Syncing ${numberOfEnvVars} env ${vars} with the server`);
|
|
226
271
|
const uploadResult = await syncEnvVarsWithServer(projectClient.client, resolvedConfig.project, options.env, childVars, parentVars);
|
|
227
272
|
if (!uploadResult.success) {
|
|
@@ -243,10 +288,13 @@ async function _deployCommand(dir, options) {
|
|
|
243
288
|
const rawTestLink = `${authorization.dashboardUrl}/projects/v3/${resolvedConfig.project}/test?environment=${options.env === "prod" ? "prod" : "stg"}`;
|
|
244
289
|
const deploymentLink = cliLink("View deployment", rawDeploymentLink);
|
|
245
290
|
const testLink = cliLink("Test tasks", rawTestLink);
|
|
246
|
-
const $spinner = spinner();
|
|
247
|
-
const buildSuffix = isLocalBuild &&
|
|
248
|
-
const deploySuffix = isLocalBuild &&
|
|
249
|
-
if (
|
|
291
|
+
const $spinner = spinner({ plain: options.plain });
|
|
292
|
+
const buildSuffix = isLocalBuild && process.env.TRIGGER_LOCAL_BUILD_LABEL_DISABLED !== "1" ? " (local)" : "";
|
|
293
|
+
const deploySuffix = isLocalBuild && process.env.TRIGGER_LOCAL_BUILD_LABEL_DISABLED !== "1" ? " (local build)" : "";
|
|
294
|
+
if (options.plain) {
|
|
295
|
+
$spinner.start(`Building version ${version}${buildSuffix}`);
|
|
296
|
+
}
|
|
297
|
+
else if (isCI) {
|
|
250
298
|
log.step(`Building version ${version}\n`);
|
|
251
299
|
}
|
|
252
300
|
else {
|
|
@@ -260,7 +308,7 @@ async function _deployCommand(dir, options) {
|
|
|
260
308
|
const buildResult = await buildImage({
|
|
261
309
|
isLocalBuild,
|
|
262
310
|
useRegistryCache: options.useRegistryCache,
|
|
263
|
-
noCache: options.
|
|
311
|
+
noCache: !options.cache,
|
|
264
312
|
deploymentId: deployment.id,
|
|
265
313
|
deploymentVersion: deployment.version,
|
|
266
314
|
imageTag: deployment.imageTag,
|
|
@@ -279,8 +327,12 @@ async function _deployCommand(dir, options) {
|
|
|
279
327
|
authAccessToken: authorization.auth.accessToken,
|
|
280
328
|
compilationPath: destination.path,
|
|
281
329
|
buildEnvVars: buildManifest.build.env,
|
|
330
|
+
compression: options.compression,
|
|
331
|
+
cacheCompression: options.cacheCompression,
|
|
332
|
+
compressionLevel: options.compressionLevel,
|
|
333
|
+
forceCompression: options.forceCompression,
|
|
282
334
|
onLog: (logMessage) => {
|
|
283
|
-
if (isCI) {
|
|
335
|
+
if (options.plain || isCI) {
|
|
284
336
|
console.log(logMessage);
|
|
285
337
|
return;
|
|
286
338
|
}
|
|
@@ -299,7 +351,7 @@ async function _deployCommand(dir, options) {
|
|
|
299
351
|
});
|
|
300
352
|
logger.debug("Build result", buildResult);
|
|
301
353
|
const warnings = checkLogsForWarnings(buildResult.logs);
|
|
302
|
-
const canShowLocalBuildHint = !isLocalBuild &&
|
|
354
|
+
const canShowLocalBuildHint = !isLocalBuild && process.env.TRIGGER_LOCAL_BUILD_HINT_DISABLED !== "1";
|
|
303
355
|
const buildFailed = !warnings.ok || !buildResult.ok;
|
|
304
356
|
if (buildFailed && canShowLocalBuildHint) {
|
|
305
357
|
const providerStatus = await projectClient.client.getRemoteBuildProviderStatus();
|
|
@@ -331,7 +383,10 @@ async function _deployCommand(dir, options) {
|
|
|
331
383
|
}, buildResult.logs, $spinner);
|
|
332
384
|
throw new SkipLoggingError(errorData?.message ?? "Failed to get deployment with worker");
|
|
333
385
|
}
|
|
334
|
-
if (
|
|
386
|
+
if (options.plain) {
|
|
387
|
+
$spinner.message(`Deploying version ${version}${deploySuffix}`);
|
|
388
|
+
}
|
|
389
|
+
else if (isCI) {
|
|
335
390
|
log.step(`Deploying version ${version}${deploySuffix}\n`);
|
|
336
391
|
}
|
|
337
392
|
else {
|
|
@@ -347,7 +402,7 @@ async function _deployCommand(dir, options) {
|
|
|
347
402
|
skipPromotion: options.skipPromotion,
|
|
348
403
|
skipPushToRegistry: remoteBuildExplicitlySkipped,
|
|
349
404
|
}, (logMessage) => {
|
|
350
|
-
if (isCI) {
|
|
405
|
+
if (options.plain || isCI) {
|
|
351
406
|
console.log(logMessage);
|
|
352
407
|
return;
|
|
353
408
|
}
|
|
@@ -362,20 +417,32 @@ async function _deployCommand(dir, options) {
|
|
|
362
417
|
await failDeploy(projectClient.client, deployment, { name: "FinalizeError", message: finalizeResponse.error }, buildResult.logs, $spinner);
|
|
363
418
|
throw new SkipLoggingError("Failed to finalize deployment");
|
|
364
419
|
}
|
|
365
|
-
if (
|
|
420
|
+
if (options.plain) {
|
|
421
|
+
console.log(`Successfully deployed version ${version}${deploySuffix}`);
|
|
422
|
+
}
|
|
423
|
+
else if (isCI) {
|
|
366
424
|
log.step(`Successfully deployed version ${version}${deploySuffix}`);
|
|
367
425
|
}
|
|
368
426
|
else {
|
|
369
427
|
$spinner.stop(`Successfully deployed version ${version}${deploySuffix}`);
|
|
370
428
|
}
|
|
371
429
|
const taskCount = deploymentWithWorker.worker?.tasks.length ?? 0;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
430
|
+
if (options.plain) {
|
|
431
|
+
console.log(`Version ${version} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"}`);
|
|
432
|
+
if (process.env.TRIGGER_DEPLOYMENT_LINK_OUTPUT_DISABLED !== "1") {
|
|
433
|
+
console.log(`Deployment: ${rawDeploymentLink}`);
|
|
434
|
+
console.log(`Test: ${rawTestLink}`);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
outro(`Version ${version} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${isLinksSupported ? `| ${deploymentLink} | ${testLink}` : ""}`);
|
|
439
|
+
if (!isLinksSupported) {
|
|
440
|
+
console.log("View deployment");
|
|
441
|
+
console.log(rawDeploymentLink);
|
|
442
|
+
console.log(); // new line
|
|
443
|
+
console.log("Test tasks");
|
|
444
|
+
console.log(rawTestLink);
|
|
445
|
+
}
|
|
379
446
|
}
|
|
380
447
|
if (options.saveLogs) {
|
|
381
448
|
const logPath = await saveLogs(deployment.shortCode, buildResult.logs);
|
|
@@ -528,6 +595,292 @@ async function initializeOrAttachDeployment(apiClient, data, existingDeploymentI
|
|
|
528
595
|
}
|
|
529
596
|
return newDeploymentOrError.data;
|
|
530
597
|
}
|
|
598
|
+
function getTriggeredVia() {
|
|
599
|
+
// Check specific CI providers first (most specific to least specific)
|
|
600
|
+
if (isGitHubActions()) {
|
|
601
|
+
return "cli:github_actions";
|
|
602
|
+
}
|
|
603
|
+
if (process.env.GITLAB_CI === "true") {
|
|
604
|
+
return "cli:gitlab_ci";
|
|
605
|
+
}
|
|
606
|
+
if (process.env.CIRCLECI === "true") {
|
|
607
|
+
return "cli:circleci";
|
|
608
|
+
}
|
|
609
|
+
if (process.env.JENKINS_URL) {
|
|
610
|
+
return "cli:jenkins";
|
|
611
|
+
}
|
|
612
|
+
if (process.env.TF_BUILD === "True") {
|
|
613
|
+
return "cli:azure_pipelines";
|
|
614
|
+
}
|
|
615
|
+
if (process.env.BITBUCKET_BUILD_NUMBER) {
|
|
616
|
+
return "cli:bitbucket_pipelines";
|
|
617
|
+
}
|
|
618
|
+
if (process.env.TRAVIS === "true") {
|
|
619
|
+
return "cli:travis_ci";
|
|
620
|
+
}
|
|
621
|
+
if (process.env.BUILDKITE === "true") {
|
|
622
|
+
return "cli:buildkite";
|
|
623
|
+
}
|
|
624
|
+
// Fallback for other/unknown CI environments
|
|
625
|
+
if (isCI) {
|
|
626
|
+
return "cli:ci_other";
|
|
627
|
+
}
|
|
628
|
+
return "cli:manual";
|
|
629
|
+
}
|
|
630
|
+
async function handleNativeBuildServerDeploy({ apiClient, options, config, dashboardUrl, userId, gitMeta, }) {
|
|
631
|
+
const tmpDir = join(config.workingDir, ".trigger", "tmp");
|
|
632
|
+
await mkdir(tmpDir, { recursive: true });
|
|
633
|
+
const archivePath = join(tmpDir, `deploy-${Date.now()}.tar.gz`);
|
|
634
|
+
const $deploymentSpinner = spinner();
|
|
635
|
+
$deploymentSpinner.start("Preparing deployment files");
|
|
636
|
+
await createContextArchive(config.workspaceDir, archivePath);
|
|
637
|
+
const archiveSize = await getArchiveSize(archivePath);
|
|
638
|
+
const sizeMB = (archiveSize / 1024 / 1024).toFixed(2);
|
|
639
|
+
$deploymentSpinner.message(`Deployment files ready (${sizeMB} MB)`);
|
|
640
|
+
const artifactResult = await apiClient.createArtifact({
|
|
641
|
+
type: "deployment_context",
|
|
642
|
+
contentType: "application/gzip",
|
|
643
|
+
contentLength: archiveSize,
|
|
644
|
+
});
|
|
645
|
+
if (!artifactResult.success) {
|
|
646
|
+
$deploymentSpinner.stop("Failed creating deployment artifact");
|
|
647
|
+
log.error(chalk.bold(chalkError(artifactResult.error)));
|
|
648
|
+
throw new OutroCommandError(`Deployment failed`);
|
|
649
|
+
}
|
|
650
|
+
const { artifactKey, uploadUrl, uploadFields } = artifactResult.data;
|
|
651
|
+
logger.debug("Artifact created", { artifactKey });
|
|
652
|
+
$deploymentSpinner.message("Uploading deployment files");
|
|
653
|
+
const [readError, fileBuffer] = await tryCatch(readFile(archivePath));
|
|
654
|
+
if (readError) {
|
|
655
|
+
$deploymentSpinner.stop("Failed reading deployment archive");
|
|
656
|
+
log.error(chalk.bold(chalkError(readError.message)));
|
|
657
|
+
throw new OutroCommandError(`Deployment failed`);
|
|
658
|
+
}
|
|
659
|
+
const formData = new FormData();
|
|
660
|
+
for (const [key, value] of Object.entries(uploadFields)) {
|
|
661
|
+
formData.append(key, value);
|
|
662
|
+
}
|
|
663
|
+
const blob = new Blob([new Uint8Array(fileBuffer)], { type: "application/gzip" });
|
|
664
|
+
formData.append("file", blob, "deployment.tar.gz");
|
|
665
|
+
const [uploadError, uploadResponse] = await tryCatch(fetch(uploadUrl, {
|
|
666
|
+
method: "POST",
|
|
667
|
+
body: formData,
|
|
668
|
+
}));
|
|
669
|
+
if (uploadError || !uploadResponse?.ok) {
|
|
670
|
+
$deploymentSpinner.stop("Failed to upload deployment files");
|
|
671
|
+
log.error(chalk.bold(chalkError(`${uploadError?.message} (${uploadResponse?.statusText} ${uploadResponse?.status})`)));
|
|
672
|
+
throw new OutroCommandError(`Deployment failed`);
|
|
673
|
+
}
|
|
674
|
+
const [unlinkError] = await tryCatch(unlink(archivePath));
|
|
675
|
+
if (unlinkError) {
|
|
676
|
+
logger.debug("Failed to delete deployment artifact file", { archivePath, error: unlinkError });
|
|
677
|
+
}
|
|
678
|
+
$deploymentSpinner.message("Deployment files uploaded");
|
|
679
|
+
const configFilePath = config.configFile !== undefined
|
|
680
|
+
? relative(config.workspaceDir, config.configFile).replace(/\\/g, "/")
|
|
681
|
+
: undefined;
|
|
682
|
+
const initializeDeploymentResult = await apiClient.initializeDeployment({
|
|
683
|
+
contentHash: "-",
|
|
684
|
+
userId,
|
|
685
|
+
gitMeta,
|
|
686
|
+
type: config.features.run_engine_v2 ? "MANAGED" : "V1",
|
|
687
|
+
runtime: config.runtime,
|
|
688
|
+
isNativeBuild: true,
|
|
689
|
+
artifactKey,
|
|
690
|
+
skipPromotion: options.skipPromotion,
|
|
691
|
+
configFilePath,
|
|
692
|
+
triggeredVia: getTriggeredVia(),
|
|
693
|
+
});
|
|
694
|
+
if (!initializeDeploymentResult.success) {
|
|
695
|
+
$deploymentSpinner.stop("Failed to initialize deployment");
|
|
696
|
+
log.error(chalk.bold(chalkError(initializeDeploymentResult.error)));
|
|
697
|
+
throw new OutroCommandError(`Deployment failed`);
|
|
698
|
+
}
|
|
699
|
+
const deployment = initializeDeploymentResult.data;
|
|
700
|
+
const rawDeploymentLink = `${dashboardUrl}/projects/v3/${config.project}/deployments/${deployment.shortCode}`;
|
|
701
|
+
const rawTestLink = `${dashboardUrl}/projects/v3/${config.project}/test?environment=${options.env === "prod" ? "prod" : "stg"}`;
|
|
702
|
+
const exposedDeploymentLink = isLinksSupported
|
|
703
|
+
? cliLink(chalk.bold(rawDeploymentLink), rawDeploymentLink)
|
|
704
|
+
: chalk.bold(rawDeploymentLink);
|
|
705
|
+
$deploymentSpinner.stop("Deployment initialized");
|
|
706
|
+
log.info(`View deployment: ${exposedDeploymentLink}`);
|
|
707
|
+
setGithubActionsOutputAndEnvVars({
|
|
708
|
+
envVars: {
|
|
709
|
+
TRIGGER_DEPLOYMENT_VERSION: deployment.version,
|
|
710
|
+
TRIGGER_VERSION: deployment.version,
|
|
711
|
+
TRIGGER_DEPLOYMENT_SHORT_CODE: deployment.shortCode,
|
|
712
|
+
TRIGGER_DEPLOYMENT_URL: rawDeploymentLink,
|
|
713
|
+
TRIGGER_TEST_URL: rawTestLink,
|
|
714
|
+
},
|
|
715
|
+
outputs: {
|
|
716
|
+
deploymentVersion: deployment.version,
|
|
717
|
+
workerVersion: deployment.version,
|
|
718
|
+
deploymentShortCode: deployment.shortCode,
|
|
719
|
+
deploymentUrl: rawDeploymentLink,
|
|
720
|
+
testUrl: rawTestLink,
|
|
721
|
+
needsPromotion: options.skipPromotion ? "true" : "false",
|
|
722
|
+
},
|
|
723
|
+
});
|
|
724
|
+
if (options.detach) {
|
|
725
|
+
outro(`Version ${deployment.version} is being deployed`);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const { eventStream } = deployment;
|
|
729
|
+
if (!eventStream) {
|
|
730
|
+
log.warn(`Failed streaming build logs, open the deployment in the dashboard to view the logs`);
|
|
731
|
+
outro(`Version ${deployment.version} is being deployed`);
|
|
732
|
+
return process.exit(0);
|
|
733
|
+
}
|
|
734
|
+
const $queuedSpinner = spinner();
|
|
735
|
+
$queuedSpinner.start("Build queued");
|
|
736
|
+
const abortController = new AbortController();
|
|
737
|
+
const s2 = new S2({ accessToken: eventStream.s2.accessToken });
|
|
738
|
+
const basin = s2.basin(eventStream.s2.basin);
|
|
739
|
+
const stream = basin.stream(eventStream.s2.stream);
|
|
740
|
+
const [readSessionError, readSession] = await tryCatch(stream.readSession({
|
|
741
|
+
seq_num: 0,
|
|
742
|
+
wait: 60 * 20, // 20 minutes
|
|
743
|
+
as: "bytes",
|
|
744
|
+
}, { signal: abortController.signal }));
|
|
745
|
+
if (readSessionError) {
|
|
746
|
+
$queuedSpinner.stop("Failed to query build progress");
|
|
747
|
+
log.warn(`Failed streaming build logs, open the deployment in the dashboard to view the logs`);
|
|
748
|
+
outro(`Version ${deployment.version} is being deployed ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""}`);
|
|
749
|
+
return process.exit(0);
|
|
750
|
+
}
|
|
751
|
+
const decoder = new TextDecoder();
|
|
752
|
+
let finalDeploymentEvent;
|
|
753
|
+
let queuedSpinnerStopped = false;
|
|
754
|
+
for await (const record of readSession) {
|
|
755
|
+
const decoded = decoder.decode(record.body);
|
|
756
|
+
const result = DeploymentEventFromString.safeParse(decoded);
|
|
757
|
+
if (!result.success) {
|
|
758
|
+
logger.debug("Failed to parse deployment event, skipping", {
|
|
759
|
+
error: result.error,
|
|
760
|
+
record: decoded,
|
|
761
|
+
});
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
const event = result.data;
|
|
765
|
+
switch (event.type) {
|
|
766
|
+
case "log": {
|
|
767
|
+
if (record.seq_num === 0) {
|
|
768
|
+
$queuedSpinner.stop("Build started");
|
|
769
|
+
console.log("│");
|
|
770
|
+
queuedSpinnerStopped = true;
|
|
771
|
+
}
|
|
772
|
+
const formattedTimestamp = chalkGrey(new Date(record.timestamp).toLocaleTimeString("en-US", {
|
|
773
|
+
hour12: false,
|
|
774
|
+
hour: "2-digit",
|
|
775
|
+
minute: "2-digit",
|
|
776
|
+
second: "2-digit",
|
|
777
|
+
fractionalSecondDigits: 3,
|
|
778
|
+
}));
|
|
779
|
+
const { level, message } = event.data;
|
|
780
|
+
const formattedMessage = level === "error"
|
|
781
|
+
? chalk.bold(chalkError(message))
|
|
782
|
+
: level === "warn"
|
|
783
|
+
? chalkWarning(message)
|
|
784
|
+
: level === "debug"
|
|
785
|
+
? chalkGrey(message)
|
|
786
|
+
: message;
|
|
787
|
+
// We use console.log here instead of clack's logger as the current version does not support changing the line spacing.
|
|
788
|
+
// And the logs look verbose with the default spacing.
|
|
789
|
+
// We cannot upgrade because the newer versions introduced some weird issues with the spinner.
|
|
790
|
+
// Ideally, we'd use clack's `taskLog` to only show the recent n lines of logs as they are streamed, but that also seems brittle
|
|
791
|
+
// and has some issues with cursor movements/clearing lines that it shouldn't clear.
|
|
792
|
+
// We can revisit this on future versions of `@clack/prompts`.
|
|
793
|
+
console.log(`│ ${formattedTimestamp} ${formattedMessage}`);
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
case "finalized": {
|
|
797
|
+
finalDeploymentEvent = event.data;
|
|
798
|
+
abortController.abort(); // stop the stream
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
default: {
|
|
802
|
+
event;
|
|
803
|
+
logger.debug("Unknown deployment event, skipping", { event });
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (!queuedSpinnerStopped && !finalDeploymentEvent) {
|
|
809
|
+
// unlikely that it happens in practice, only in rare corner cases
|
|
810
|
+
// the timeout would kick in earlier if the build server fails to dequeue the build
|
|
811
|
+
$queuedSpinner.stop("Log stream stopped");
|
|
812
|
+
log.error("Failed dequeueing build, please try again shortly");
|
|
813
|
+
throw new OutroCommandError(`Version ${deployment.version} ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""}`);
|
|
814
|
+
}
|
|
815
|
+
if (!finalDeploymentEvent) {
|
|
816
|
+
log.error("Stopped receiving updates from the build server, please check the deployment status in the dashboard");
|
|
817
|
+
if (!isLinksSupported) {
|
|
818
|
+
log.info(`View deployment: ${rawDeploymentLink}`);
|
|
819
|
+
}
|
|
820
|
+
throw new OutroCommandError(`Version ${deployment.version} ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""}`);
|
|
821
|
+
}
|
|
822
|
+
switch (finalDeploymentEvent.result) {
|
|
823
|
+
case "succeeded": {
|
|
824
|
+
queuedSpinnerStopped
|
|
825
|
+
? log.success("Deployment completed successfully")
|
|
826
|
+
: $queuedSpinner.stop("Deployment completed successfully");
|
|
827
|
+
if (finalDeploymentEvent.message) {
|
|
828
|
+
log.success(finalDeploymentEvent.message);
|
|
829
|
+
}
|
|
830
|
+
if (options.skipPromotion) {
|
|
831
|
+
log.info(`This deployment was not automatically promoted. You can promote in the dashboard or via the promote command, e.g, \`npx trigger.dev promote ${deployment.version}\`.`);
|
|
832
|
+
}
|
|
833
|
+
if (!isLinksSupported) {
|
|
834
|
+
log.info(`Test tasks: ${rawTestLink}`);
|
|
835
|
+
}
|
|
836
|
+
outro(`Version ${deployment.version} was deployed ${isLinksSupported
|
|
837
|
+
? `| ${cliLink("Test tasks", rawTestLink)} | ${cliLink("View deployment", rawDeploymentLink)}`
|
|
838
|
+
: ""}`);
|
|
839
|
+
return process.exit(0);
|
|
840
|
+
}
|
|
841
|
+
case "failed": {
|
|
842
|
+
if (!queuedSpinnerStopped) {
|
|
843
|
+
$queuedSpinner.stop("Deployment failed");
|
|
844
|
+
}
|
|
845
|
+
log.error(chalk.bold(chalkError("Deployment failed" +
|
|
846
|
+
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : ""))));
|
|
847
|
+
throw new OutroCommandError(`Version ${deployment.version} deployment failed ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""}`);
|
|
848
|
+
}
|
|
849
|
+
case "timed_out": {
|
|
850
|
+
if (!queuedSpinnerStopped) {
|
|
851
|
+
$queuedSpinner.stop("Deployment timed out");
|
|
852
|
+
}
|
|
853
|
+
log.error(chalk.bold(chalkError("Deployment timed out" +
|
|
854
|
+
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : ""))));
|
|
855
|
+
throw new OutroCommandError(`Version ${deployment.version} deployment timed out ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""}`);
|
|
856
|
+
}
|
|
857
|
+
case "canceled": {
|
|
858
|
+
if (!queuedSpinnerStopped) {
|
|
859
|
+
$queuedSpinner.stop("Deployment was canceled");
|
|
860
|
+
}
|
|
861
|
+
log.error(chalk.bold(chalkError("Deployment was canceled" +
|
|
862
|
+
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : ""))));
|
|
863
|
+
throw new OutroCommandError(`Version ${deployment.version} deployment canceled ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""}`);
|
|
864
|
+
}
|
|
865
|
+
default: {
|
|
866
|
+
// This case is only relevant in case we extend the enum in the future.
|
|
867
|
+
// New enum values will not be treated as errors in older cli versions.
|
|
868
|
+
queuedSpinnerStopped
|
|
869
|
+
? log.success("Log stream finished")
|
|
870
|
+
: $queuedSpinner.stop("Log stream finished");
|
|
871
|
+
if (finalDeploymentEvent.message) {
|
|
872
|
+
log.message(finalDeploymentEvent.message);
|
|
873
|
+
}
|
|
874
|
+
if (!isLinksSupported) {
|
|
875
|
+
log.info(`Test tasks: ${rawTestLink}`);
|
|
876
|
+
}
|
|
877
|
+
outro(`Version ${deployment.version} ${isLinksSupported
|
|
878
|
+
? `| ${cliLink("Test tasks", rawTestLink)} | ${cliLink("View deployment", rawDeploymentLink)}`
|
|
879
|
+
: ""}`);
|
|
880
|
+
return process.exit(0);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
531
884
|
export function verifyDirectory(dir, projectPath) {
|
|
532
885
|
if (dir !== "." && !isDirectory(projectPath)) {
|
|
533
886
|
if (dir === "staging" || dir === "prod" || dir === "preview") {
|