Skip to content

Commit 90f4672

Browse files
committed
print currently active profile on commands
1 parent b0a0093 commit 90f4672

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

packages/wrangler/src/__tests__/banner.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ describe("wrangler banner", () => {
1616
expect(std.out).toMatchInlineSnapshot(`
1717
"
1818
⛅️ wrangler x.x.x
19-
──────────────────"
19+
──────────────────
20+
Using profile: testing"
2021
`);
2122
});
2223

@@ -38,7 +39,8 @@ describe("wrangler banner", () => {
3839
expect(std.out).toMatchInlineSnapshot(`
3940
"
4041
⛅️ wrangler x.x.x
41-
──────────────────"
42+
──────────────────
43+
Using profile: testing"
4244
`);
4345
});
4446
});

packages/wrangler/src/core/register-yargs-command.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from "../metrics/sanitization";
2222
import { writeOutput } from "../output";
2323
import { addBreadcrumb } from "../sentry";
24+
import { getActiveProfileName } from "../user/profiles";
2425
import { dedent } from "../utils/dedent";
2526
import { isLocal, printResourceLocation } from "../utils/is-local";
2627
import { printWranglerBanner } from "../wrangler-banner";
@@ -146,6 +147,13 @@ function createHandler(def: InternalCommandDefinition, argv: string[]) {
146147
typeof shouldPrintBanner !== "function" || bannerEnabled;
147148

148149
if (!getWranglerHideBanner()) {
150+
if ((def.behaviour?.printActiveProfile ?? true) && shouldPrintBanner) {
151+
const activeProfile = getActiveProfileName();
152+
if (activeProfile !== "default") {
153+
logger.log(`Using profile: ${chalk.blue(activeProfile)}`);
154+
}
155+
}
156+
149157
if (def.metadata.deprecated) {
150158
logger.warn(def.metadata.deprecatedMessage);
151159
}

packages/wrangler/src/core/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ export type CommandDefinition<
158158
*/
159159
printMetricsBanner?: boolean;
160160

161+
/**
162+
* Whether to print the active authentication profile after the banner.
163+
* Only shown when a non-default profile is active.
164+
*
165+
* @default true
166+
*/
167+
printActiveProfile?: boolean;
168+
161169
/**
162170
* By default, wrangler will print warnings about the Wrangler configuration file.
163171
* Set this value to `false` to skip printing these warnings.

0 commit comments

Comments
 (0)