Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/orange-jobs-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"wrangler": patch
---

fix: print wrangler banner at the start of every d1 command

This PR adds a wrangler banner to the start of every D1 command (except when invoked in JSON-mode)

For example:

```
⛅️ wrangler 3.27.0
-------------------
...
```
2 changes: 2 additions & 0 deletions packages/wrangler/src/d1/create.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Text } from "ink";
import React from "react";
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { withConfig } from "../config";
import { UserError } from "../errors";
Expand Down Expand Up @@ -32,6 +33,7 @@ export function Options(yargs: CommonYargsArgv) {
type HandlerOptions = StrictYargsOptionsToInterface<typeof Options>;
export const Handler = withConfig<HandlerOptions>(
async ({ name, config, location }): Promise<void> => {
await printWranglerBanner();
const accountId = await requireAuth(config);

if (location) {
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/d1/delete.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { withConfig } from "../config";
import { confirm } from "../dialogs";
Expand All @@ -24,6 +25,7 @@ export function Options(d1ListYargs: CommonYargsArgv) {
type HandlerOptions = StrictYargsOptionsToInterface<typeof Options>;
export const Handler = withConfig<HandlerOptions>(
async ({ name, skipConfirmation, config }): Promise<void> => {
await printWranglerBanner();
const accountId = await requireAuth(config);

const db: Database = await getDatabaseByNameOrBinding(
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/d1/execute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Static, Text } from "ink";
import Table from "ink-table";
import { Miniflare } from "miniflare";
import React from "react";
import { printWranglerBanner } from "../";
import { fetchResult } from "../cfetch";
import { readConfig } from "../config";
import { getLocalPersistencePath } from "../dev/get-local-persistence-path";
Expand Down Expand Up @@ -98,6 +99,7 @@ export const Handler = async (args: HandlerOptions): Promise<void> => {
// set loggerLevel to error to avoid readConfig warnings appearing in JSON output
logger.loggerLevel = "error";
}
await printWranglerBanner();
const config = readConfig(args.config, args);

if (file && command)
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/src/d1/info.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Table from "ink-table";
import prettyBytes from "pretty-bytes";
import React from "react";
import { printWranglerBanner } from "..";
import { fetchGraphqlResult } from "../cfetch";
import { withConfig } from "../config";
import { logger } from "../logger";
Expand Down Expand Up @@ -118,7 +119,6 @@ export const Handler = withConfig<HandlerOptions>(
logger.log(JSON.stringify(output, null, 2));
} else {
// Snip off the "uuid" property from the response and use those as the header

const entries = Object.entries(output).filter(([k, _v]) => k !== "uuid");
const data = entries.map(([k, v]) => {
let value;
Expand All @@ -140,6 +140,7 @@ export const Handler = withConfig<HandlerOptions>(
};
});

await printWranglerBanner();
logger.log(renderToString(<Table data={data} />));
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/d1/list.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Table from "ink-table";
import React from "react";
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { withConfig } from "../config";
import { logger } from "../logger";
Expand Down Expand Up @@ -31,6 +32,7 @@ export const Handler = withConfig<HandlerOptions>(
if (json) {
logger.log(JSON.stringify(dbs, null, 2));
} else {
await printWranglerBanner();
logger.log(renderToString(<Table data={dbs}></Table>));
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/d1/migrations/apply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from "path";
import { Box, Text } from "ink";
import Table from "ink-table";
import React from "react";
import { printWranglerBanner } from "../..";
import { withConfig } from "../../config";
import { confirm } from "../../dialogs";
import { UserError } from "../../errors";
Expand Down Expand Up @@ -51,6 +52,7 @@ export const ApplyHandler = withConfig<ApplyHandlerOptions>(
preview,
batchSize,
}): Promise<void> => {
await printWranglerBanner();
const databaseInfo = getDatabaseInfoFromConfig(config, database);
if (!databaseInfo && !local) {
throw new UserError(
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/d1/migrations/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from "node:fs";
import path from "path";
import { Box, Text } from "ink";
import React from "react";
import { printWranglerBanner } from "../..";
import { withConfig } from "../../config";
import { UserError } from "../../errors";
import { logger } from "../../logger";
Expand All @@ -27,6 +28,7 @@ type CreateHandlerOptions = StrictYargsOptionsToInterface<typeof CreateOptions>;

export const CreateHandler = withConfig<CreateHandlerOptions>(
async ({ config, database, message }): Promise<void> => {
await printWranglerBanner();
const databaseInfo = getDatabaseInfoFromConfig(config, database);
if (!databaseInfo) {
throw new UserError(
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/src/d1/migrations/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from "path";
import { Box, Text } from "ink";
import Table from "ink-table";
import React from "react";
import { printWranglerBanner } from "../..";
import { withConfig } from "../../config";
import { UserError } from "../../errors";
import { logger } from "../../logger";
Expand All @@ -28,6 +29,7 @@ type ListHandlerOptions = StrictYargsOptionsToInterface<typeof ListOptions>;

export const ListHandler = withConfig<ListHandlerOptions>(
async ({ config, database, local, persistTo, preview }): Promise<void> => {
await printWranglerBanner();
if (!local) {
await requireAuth({});
}
Expand Down