Skip to content

Commit 63a643b

Browse files
nicktrnericallam
andauthored
v3: fix digest extraction (#1024)
* fix image digest extraction * fix project ref cli arg override * Create late-steaks-behave.md --------- Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent efd970a commit 63a643b

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

.changeset/late-steaks-behave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
v3: fix digest extraction

packages/cli-v3/src/commands/deploy.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function configureDeployCommand(program: Command) {
9494
.option("-c, --config <config file>", "The name of the config file, found at [path]")
9595
.option(
9696
"-p, --project-ref <project ref>",
97-
"The project ref. Required if there is no config file."
97+
"The project ref. Required if there is no config file. This will override the project specified in the config file."
9898
)
9999
)
100100
.addOption(
@@ -688,7 +688,10 @@ async function buildAndPushImage(
688688
childProcess.stderr?.on("data", (data: Buffer) => {
689689
const text = data.toString();
690690

691-
errors.push(text);
691+
// Emitted data chunks can contain multiple lines. Remove empty lines.
692+
const lines = text.split("\n").filter(Boolean);
693+
694+
errors.push(...lines);
692695
logger.debug(text);
693696
});
694697

@@ -896,14 +899,15 @@ async function buildAndPushSelfHostedImage(
896899
}
897900

898901
function extractImageDigest(outputs: string[]) {
899-
const imageDigestRegex = /sha256:[a-f0-9]{64}/;
902+
const imageDigestRegex = /pushing manifest for .+(?<digest>sha256:[a-f0-9]{64})/;
900903

901904
for (const line of outputs) {
902-
if (line.includes("pushing manifest")) {
903-
const imageDigestMatch = line.match(imageDigestRegex);
904-
if (imageDigestMatch) {
905-
return imageDigestMatch[0];
906-
}
905+
const imageDigestMatch = line.match(imageDigestRegex);
906+
907+
const digest = imageDigestMatch?.groups?.digest;
908+
909+
if (digest) {
910+
return digest;
907911
}
908912
}
909913
}

packages/cli-v3/src/utilities/configFiles.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,13 @@ export async function readConfig(
164164

165165
// import the config file
166166
const userConfigModule = await import(builtConfigFileHref);
167+
168+
// The --project-ref CLI arg will always override the project specified in the config file
167169
const rawConfig = await normalizeConfig(
168-
userConfigModule ? userConfigModule.config : { project: options?.projectRef }
170+
userConfigModule?.config,
171+
options?.projectRef ? { project: options?.projectRef } : undefined
169172
);
173+
170174
const config = Config.parse(rawConfig);
171175

172176
return {
@@ -198,10 +202,14 @@ export async function resolveConfig(path: string, config: Config): Promise<Resol
198202
return config as ResolvedConfig;
199203
}
200204

201-
export async function normalizeConfig(config: any): Promise<any> {
205+
export async function normalizeConfig(config: any, overrides?: Record<string, any>): Promise<any> {
206+
let normalized = config;
207+
202208
if (typeof config === "function") {
203-
config = config();
209+
normalized = await config();
204210
}
205211

206-
return await config;
212+
normalized = { ...normalized, ...overrides };
213+
214+
return normalized;
207215
}

0 commit comments

Comments
 (0)