diff --git a/.changeset/orange-jobs-exist.md b/.changeset/orange-jobs-exist.md new file mode 100644 index 000000000000..78e89805fd4c --- /dev/null +++ b/.changeset/orange-jobs-exist.md @@ -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 +------------------- +... +``` diff --git a/packages/wrangler/src/d1/create.tsx b/packages/wrangler/src/d1/create.tsx index 04b3d0128695..42cce40b28e2 100644 --- a/packages/wrangler/src/d1/create.tsx +++ b/packages/wrangler/src/d1/create.tsx @@ -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"; @@ -32,6 +33,7 @@ export function Options(yargs: CommonYargsArgv) { type HandlerOptions = StrictYargsOptionsToInterface; export const Handler = withConfig( async ({ name, config, location }): Promise => { + await printWranglerBanner(); const accountId = await requireAuth(config); if (location) { diff --git a/packages/wrangler/src/d1/delete.ts b/packages/wrangler/src/d1/delete.ts index d7434d551cf2..9fe936e63e40 100644 --- a/packages/wrangler/src/d1/delete.ts +++ b/packages/wrangler/src/d1/delete.ts @@ -1,3 +1,4 @@ +import { printWranglerBanner } from ".."; import { fetchResult } from "../cfetch"; import { withConfig } from "../config"; import { confirm } from "../dialogs"; @@ -24,6 +25,7 @@ export function Options(d1ListYargs: CommonYargsArgv) { type HandlerOptions = StrictYargsOptionsToInterface; export const Handler = withConfig( async ({ name, skipConfirmation, config }): Promise => { + await printWranglerBanner(); const accountId = await requireAuth(config); const db: Database = await getDatabaseByNameOrBinding( diff --git a/packages/wrangler/src/d1/execute.tsx b/packages/wrangler/src/d1/execute.tsx index f31b6dc5d6fd..b304ecc6cde9 100644 --- a/packages/wrangler/src/d1/execute.tsx +++ b/packages/wrangler/src/d1/execute.tsx @@ -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"; @@ -98,6 +99,7 @@ export const Handler = async (args: HandlerOptions): Promise => { // 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) diff --git a/packages/wrangler/src/d1/info.tsx b/packages/wrangler/src/d1/info.tsx index f5dce3f74b23..cdaf76db6cbd 100644 --- a/packages/wrangler/src/d1/info.tsx +++ b/packages/wrangler/src/d1/info.tsx @@ -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"; @@ -118,7 +119,6 @@ export const Handler = withConfig( 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; @@ -140,6 +140,7 @@ export const Handler = withConfig( }; }); + await printWranglerBanner(); logger.log(renderToString()); } } diff --git a/packages/wrangler/src/d1/list.tsx b/packages/wrangler/src/d1/list.tsx index f82fb26c17fa..f08db1fe53e0 100644 --- a/packages/wrangler/src/d1/list.tsx +++ b/packages/wrangler/src/d1/list.tsx @@ -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"; @@ -31,6 +32,7 @@ export const Handler = withConfig( if (json) { logger.log(JSON.stringify(dbs, null, 2)); } else { + await printWranglerBanner(); logger.log(renderToString(
)); } } diff --git a/packages/wrangler/src/d1/migrations/apply.tsx b/packages/wrangler/src/d1/migrations/apply.tsx index 3e0f60148cfd..f91ba6eec47d 100644 --- a/packages/wrangler/src/d1/migrations/apply.tsx +++ b/packages/wrangler/src/d1/migrations/apply.tsx @@ -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"; @@ -51,6 +52,7 @@ export const ApplyHandler = withConfig( preview, batchSize, }): Promise => { + await printWranglerBanner(); const databaseInfo = getDatabaseInfoFromConfig(config, database); if (!databaseInfo && !local) { throw new UserError( diff --git a/packages/wrangler/src/d1/migrations/create.tsx b/packages/wrangler/src/d1/migrations/create.tsx index 5553e327fc11..1cb9f3ee190b 100644 --- a/packages/wrangler/src/d1/migrations/create.tsx +++ b/packages/wrangler/src/d1/migrations/create.tsx @@ -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"; @@ -27,6 +28,7 @@ type CreateHandlerOptions = StrictYargsOptionsToInterface; export const CreateHandler = withConfig( async ({ config, database, message }): Promise => { + await printWranglerBanner(); const databaseInfo = getDatabaseInfoFromConfig(config, database); if (!databaseInfo) { throw new UserError( diff --git a/packages/wrangler/src/d1/migrations/list.tsx b/packages/wrangler/src/d1/migrations/list.tsx index bfa3de41dee5..ea88d528c2d0 100644 --- a/packages/wrangler/src/d1/migrations/list.tsx +++ b/packages/wrangler/src/d1/migrations/list.tsx @@ -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"; @@ -28,6 +29,7 @@ type ListHandlerOptions = StrictYargsOptionsToInterface; export const ListHandler = withConfig( async ({ config, database, local, persistTo, preview }): Promise => { + await printWranglerBanner(); if (!local) { await requireAuth({}); }