Skip to content

Commit de1cc86

Browse files
committed
Fix dev CLI output when not printing update messages
1 parent ff7fa9e commit de1cc86

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

.changeset/polite-rockets-matter.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+
Fix dev CLI output when not printing update messages

packages/cli-v3/src/commands/dev.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,13 @@ async function startDev(
135135

136136
await printStandloneInitialBanner(true);
137137

138+
let displayedUpdateMessage = false;
139+
138140
if (!options.skipUpdateCheck) {
139-
console.log(); // spacing
140-
await updateTriggerPackages(dir, { ...options }, true, true);
141+
displayedUpdateMessage = await updateTriggerPackages(dir, { ...options }, true, true);
141142
}
142143

143-
printDevBanner(!options.skipUpdateCheck);
144+
printDevBanner(displayedUpdateMessage);
144145

145146
logger.debug("Starting dev session", { dir, options, authorization });
146147

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export async function updateTriggerPackages(
5050
options: UpdateCommandOptions,
5151
embedded?: boolean,
5252
requireUpdate?: boolean
53-
) {
53+
): Promise<boolean> {
54+
let hasOutput = false;
55+
5456
if (!embedded) {
5557
intro("Updating packages");
5658
}
@@ -61,7 +63,7 @@ export async function updateTriggerPackages(
6163

6264
if (!packageJson) {
6365
log.error("Failed to load package.json. Try to re-run with `-l debug` to see what's going on.");
64-
return;
66+
return false;
6567
}
6668

6769
const cliVersion = getVersion();
@@ -73,6 +75,8 @@ export async function updateTriggerPackages(
7375
`Current: ${cliVersion}\nLatest: ${newCliVersion}`,
7476
"Run latest: npx trigger.dev@beta"
7577
);
78+
79+
hasOutput = true;
7680
}
7781

7882
const triggerDependencies = getTriggerDependencies(packageJson);
@@ -96,8 +100,9 @@ export async function updateTriggerPackages(
96100
if (versionMismatches.length === 0) {
97101
if (!embedded) {
98102
outro(`Nothing to do${newCliVersion ? " ..but you should really update your CLI!" : ""}`);
103+
return hasOutput;
99104
}
100-
return;
105+
return hasOutput;
101106
}
102107

103108
prettyWarning(
@@ -149,7 +154,7 @@ export async function updateTriggerPackages(
149154
outro("You've been warned!");
150155
}
151156

152-
return;
157+
return hasOutput;
153158
}
154159

155160
const installSpinner = spinner();
@@ -213,6 +218,8 @@ export async function updateTriggerPackages(
213218
`Packages updated${newCliVersion ? " ..but you should really update your CLI too!" : ""}`
214219
);
215220
}
221+
222+
return hasOutput;
216223
}
217224

218225
type Dependency = {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ After installation, run Trigger.dev with \`npx trigger.dev\`.`
4040
export async function printStandloneInitialBanner(performUpdateCheck = true) {
4141
const cliVersion = getVersion();
4242

43-
logger.log(`\n${logo()} ${chalkGrey(`(${cliVersion})`)}\n`);
44-
4543
if (performUpdateCheck) {
4644
const maybeNewVersion = await updateCheck();
4745

4846
// Log a slightly more noticeable message if this is a major bump
4947
if (maybeNewVersion !== undefined) {
50-
logger.log(`Update available ${chalk.green(maybeNewVersion)}`);
48+
logger.log(`\n${logo()} ${chalkGrey(`(${cliVersion} -> ${chalk.green(maybeNewVersion)})`)}`);
49+
} else {
50+
logger.log(`\n${logo()} ${chalkGrey(`(${cliVersion})`)}`);
5151
}
52+
} else {
53+
logger.log(`\n${logo()} ${chalkGrey(`(${cliVersion})`)}`);
5254
}
5355

5456
logger.log(`${chalkGrey("-".repeat(54))}`);

0 commit comments

Comments
 (0)