Skip to content

Commit c8bf2fd

Browse files
refactor(ui): remove dead code
1 parent a89ebef commit c8bf2fd

File tree

3 files changed

+0
-153
lines changed

3 files changed

+0
-153
lines changed

packages/webpack-cli/src/ui-renderer.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ export interface CommandHelpData {
5959
globalOptions: HelpOption[];
6060
}
6161

62-
/** Passed to `renderCommandHeader` to describe the running command. */
63-
export interface CommandMeta {
64-
name: string;
65-
description: string;
66-
}
67-
6862
/** One section emitted by `renderInfoOutput`, e.g. "System" or "Binaries". */
6963
export interface InfoSection {
7064
title: string;
@@ -139,29 +133,6 @@ export function renderRows(
139133
}
140134
}
141135

142-
export function renderCommandHeader(meta: CommandMeta, opts: RenderOptions): void {
143-
const { colors, log } = opts;
144-
const termWidth = Math.min(opts.columns || MAX_WIDTH, MAX_WIDTH);
145-
146-
log("");
147-
log(`${indent(INDENT)}${colors.bold(colors.cyan("⬡"))} ${colors.bold(`webpack ${meta.name}`)}`);
148-
log(divider(termWidth, colors));
149-
150-
if (meta.description) {
151-
const descWidth = termWidth - INDENT * 2;
152-
for (const line of wrapValue(meta.description, descWidth)) {
153-
log(`${indent(INDENT)}${line}`);
154-
}
155-
log("");
156-
}
157-
}
158-
159-
export function renderCommandFooter(opts: RenderOptions): void {
160-
const termWidth = Math.min(opts.columns, MAX_WIDTH);
161-
opts.log(divider(termWidth, opts.colors));
162-
opts.log("");
163-
}
164-
165136
function _renderHelpOptions(
166137
options: HelpOption[],
167138
colors: Colors,
@@ -286,11 +257,6 @@ export function renderWarning(message: string, opts: RenderOptions): void {
286257
log(`${indent(INDENT)}${colors.yellow("⚠")} ${message}`);
287258
}
288259

289-
export function renderInfo(message: string, opts: RenderOptions): void {
290-
const { colors, log } = opts;
291-
log(`${indent(INDENT)}${colors.cyan("ℹ")} ${message}`);
292-
}
293-
294260
export function parseEnvinfoSections(raw: string): InfoSection[] {
295261
const sections: InfoSection[] = [];
296262
let current: InfoSection | null = null;

test/api/__snapshots__/ui-renderer.test.js.snap.webpack5

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,6 @@ exports[`renderAliasHelp should match snapshot 1`] = `
7474
]
7575
`;
7676

77-
exports[`renderCommandFooter should match snapshot 1`] = `
78-
[
79-
" ──────────────────────────────────────────────────────────────────────────",
80-
"",
81-
]
82-
`;
83-
84-
exports[`renderCommandHeader should match snapshot 1`] = `
85-
[
86-
"",
87-
" ⬡ webpack build",
88-
" ──────────────────────────────────────────────────────────────────────────",
89-
" Compiling.",
90-
"",
91-
]
92-
`;
93-
9477
exports[`renderCommandHelp should match full output snapshot for build command 1`] = `
9578
[
9679
"",
@@ -182,12 +165,6 @@ exports[`renderFooter should match snapshot (verbose) 1`] = `
182165
]
183166
`;
184167

185-
exports[`renderInfo should match snapshot 1`] = `
186-
[
187-
" ℹ just so you know",
188-
]
189-
`;
190-
191168
exports[`renderInfoOutput should match full output snapshot 1`] = `
192169
[
193170
"",

test/api/ui-renderer.test.js

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ const {
33
MAX_WIDTH,
44
parseEnvinfoSections,
55
renderAliasHelp,
6-
renderCommandFooter,
7-
renderCommandHeader,
86
renderCommandHelp,
97
renderError,
108
renderFooter,
11-
renderInfo,
129
renderInfoOutput,
1310
renderOptionHelp,
1411
renderSuccess,
@@ -292,84 +289,6 @@ describe("renderCommandHelp", () => {
292289
});
293290
});
294291

295-
describe("renderCommandHeader", () => {
296-
it("should render 'webpack <name>' in the header", () => {
297-
const { captured, opts } = makeOpts();
298-
renderCommandHeader({ name: "build", description: "Compiling." }, opts);
299-
expect(getOutput(captured)).toContain("webpack build");
300-
});
301-
302-
it("should render the description", () => {
303-
const { captured, opts } = makeOpts();
304-
renderCommandHeader({ name: "build", description: "Compiling." }, opts);
305-
expect(getOutput(captured)).toContain("Compiling.");
306-
});
307-
308-
it("should render a divider", () => {
309-
const { captured, opts } = makeOpts();
310-
renderCommandHeader({ name: "build", description: "Compiling." }, opts);
311-
expect(captured.some((l) => /{10,}/.test(l))).toBe(true);
312-
});
313-
314-
it("should include the ⬡ icon", () => {
315-
const { captured, opts } = makeOpts();
316-
renderCommandHeader({ name: "build", description: "Compiling." }, opts);
317-
expect(getOutput(captured)).toContain("⬡");
318-
});
319-
320-
it("should omit description block when empty", () => {
321-
const { captured, opts } = makeOpts();
322-
renderCommandHeader({ name: "build", description: "" }, opts);
323-
const nonEmpty = captured.filter((l) => l.trim().length > 0);
324-
expect(nonEmpty).toHaveLength(2); // icon+title + divider
325-
});
326-
327-
it("should cap divider at MAX_WIDTH on wide terminals", () => {
328-
const { captured, opts } = makeOpts(300);
329-
renderCommandHeader({ name: "build", description: "Building." }, opts);
330-
const div = captured.find((l) => /{10,}/.test(l));
331-
expect(stripAnsi(div).length).toBeLessThanOrEqual(INDENT + MAX_WIDTH);
332-
});
333-
334-
it("should match snapshot", () => {
335-
const { captured, opts } = makeOpts();
336-
renderCommandHeader({ name: "build", description: "Compiling." }, opts);
337-
expect(captured).toMatchSnapshot();
338-
});
339-
});
340-
341-
describe("renderCommandFooter", () => {
342-
it("should render a divider", () => {
343-
const { captured, opts } = makeOpts();
344-
renderCommandFooter(opts);
345-
expect(captured.some((l) => /{10,}/.test(l))).toBe(true);
346-
});
347-
348-
it("should end with a blank line", () => {
349-
const { captured, opts } = makeOpts();
350-
renderCommandFooter(opts);
351-
expect(captured[captured.length - 1]).toBe("");
352-
});
353-
354-
it("header and footer dividers should be the same length", () => {
355-
const hCapture = makeOpts(80);
356-
renderCommandHeader({ name: "build", description: "" }, hCapture.opts);
357-
const hDiv = hCapture.captured.find((l) => /{10,}/.test(l));
358-
359-
const fCapture = makeOpts(80);
360-
renderCommandFooter(fCapture.opts);
361-
const fDiv = fCapture.captured.find((l) => /{10,}/.test(l));
362-
363-
expect(stripAnsi(hDiv)).toHaveLength(stripAnsi(fDiv).length);
364-
});
365-
366-
it("should match snapshot", () => {
367-
const { captured, opts } = makeOpts();
368-
renderCommandFooter(opts);
369-
expect(captured).toMatchSnapshot();
370-
});
371-
});
372-
373292
describe("renderOptionHelp", () => {
374293
it("should render option name in header", () => {
375294
const { captured, opts } = makeOpts();
@@ -573,21 +492,6 @@ describe("renderWarning", () => {
573492
});
574493
});
575494

576-
describe("renderInfo", () => {
577-
it("outputs message with ℹ", () => {
578-
const { captured, opts } = makeOpts();
579-
renderInfo("just so you know", opts);
580-
expect(getOutput(captured)).toContain("ℹ");
581-
expect(getOutput(captured)).toContain("just so you know");
582-
});
583-
584-
it("should match snapshot", () => {
585-
const { captured, opts } = makeOpts();
586-
renderInfo("just so you know", opts);
587-
expect(captured).toMatchSnapshot();
588-
});
589-
});
590-
591495
describe("parseEnvinfoSections", () => {
592496
it("returns one section per heading", () => {
593497
const sections = parseEnvinfoSections(ENVINFO_FIXTURE);

0 commit comments

Comments
 (0)