Skip to content

Commit

Permalink
chore(webpack-cli): remove pretty output functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Mar 11, 2020
1 parent d2a47ef commit ca35fe3
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 181 deletions.
1 change: 0 additions & 1 deletion packages/info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"dependencies": {
"@types/yargs": "13.0.0",
"chalk": "3.0.0",
"cli-table3": "0.5.1",
"envinfo": "7.3.1",
"prettyjson": "1.2.1",
"yargs": "13.2.2"
Expand Down
4 changes: 0 additions & 4 deletions packages/info/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { argv } from './options';

import { AVAILABLE_COMMANDS, AVAILABLE_FORMATS, IGNORE_FLAGS } from './commands';
import { configReader, fetchConfig, resolveFilePath, getNameFromPath } from './configParser';
import { renderTable } from './renderTable';

interface Information {
Binaries?: string[];
Expand Down Expand Up @@ -56,9 +55,6 @@ export default async function info(customArgv: object): Promise<string[]> {
const config = fetchConfig(fullConfigPath);
const parsedConfig = configReader(config);

const stringifiedTable = renderTable(parsedConfig, fileName);
if (args.config) return parsedConfig;
else process.stdout.write(stringifiedTable + '\n');
} else {
Object.keys(args).forEach((flag: string) => {
if (IGNORE_FLAGS.includes(flag)) {
Expand Down
15 changes: 0 additions & 15 deletions packages/info/src/renderTable.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/webpack-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Options
-h, --hot Enables Hot Module Replacement
-s, --sourcemap string Determine source maps to use
--prefetch string Prefetch this request
--pretty Prints a fancy output
-j, --json Prints result as JSON
--standard Prints standard output
-d, --dev Run development build
Expand Down
6 changes: 1 addition & 5 deletions packages/webpack-cli/lib/groups/StatsGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class StatsGroup extends GroupHelper {

resolveOptions() {
if (this.args.verbose && this.args.stats) {
logger.warn('Conflict between "verbose" and "stats" options. Using verbose.');
logger.warn('Conflict between "verbqose" and "stats" options. Using verbose.');
this.opts.option.stats = {
verbose: true,
};
Expand All @@ -27,10 +27,6 @@ class StatsGroup extends GroupHelper {
this.opts.options.stats = this.args.stats;
}
}

if (this.args.pretty) {
this.opts.outputOptions.pretty = true;
}
}

run() {
Expand Down
15 changes: 2 additions & 13 deletions packages/webpack-cli/lib/utils/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,8 @@ class Compiler {
return process.stdout.isTTY && process.platform === 'darwin';
}

generateOutput(outputOptions, stats, statsErrors, processingMessageBuffer) {
if (outputOptions.pretty) {
const statsObj = stats.toJson(outputOptions);
if (statsObj.children && Array.isArray(statsObj.children) && this.compilerOptions && Array.isArray(this.compilerOptions)) {
statsObj.children.forEach(child => {
this.output.generateFancyOutput(child, statsErrors, processingMessageBuffer);
});
return;
}
this.output.generateFancyOutput(statsObj, statsErrors, processingMessageBuffer);
} else {
this.output.generateRawOutput(stats, this.compilerOptions);
}
generateOutput(outputOptions, stats) {
this.output.generateRawOutput(stats, this.compilerOptions);
process.stdout.write('\n');
if (outputOptions.watch) {
logger.info('watching files for updates...');
Expand Down
111 changes: 0 additions & 111 deletions packages/webpack-cli/lib/utils/CompilerOutput.js
Original file line number Diff line number Diff line change
@@ -1,115 +1,4 @@
const chalk = require('chalk');
const Table = require('cli-table3');
const webpack = require('webpack');
const logger = require('./logger');

class CompilerOutput {
generateFancyOutput(statsObj, statsErrors, processingMessageBuffer) {
const { assets, entrypoints, time, builtAt, warnings, outputPath, hash, chunks } = statsObj;

const visibleEmojies = this._showEmojiConditionally() ? ['✅', '🌏', '⚒️ ', '⏱ ', '📂', '#️⃣'] : new Array(6).fill('');

process.stdout.write('\n');
process.stdout.write(`${visibleEmojies[0]} ${chalk.underline.bold('Compilation Results')}\n`);
process.stdout.write('\n');
process.stdout.write(`${visibleEmojies[1]} Version: ${webpack.version}\n`);
process.stdout.write(`${visibleEmojies[2]} Built: ${new Date(builtAt).toString()}\n`);
process.stdout.write(`${visibleEmojies[3]} Compile Time: ${time}ms\n`);
process.stdout.write(`${visibleEmojies[4]} Output Directory: ${outputPath}\n`);
process.stdout.write(`${visibleEmojies[5]} Hash: ${hash}\n`);
process.stdout.write('\n');

const assetsTble = new Table({
head: ['Entrypoint', 'Bundle'],
style: { compact: true, 'padding-left': 1, head: [] },
});

let compilationTableEmpty = true;

Object.keys(entrypoints).forEach(entry => {
const entrypoint = entrypoints[entry];
entrypoint.assets.forEach(assetName => {
const asset = assets.find(asset => {
return asset.name === assetName;
});
if (asset) {
const entrypointChunks = entrypoint.chunks.map(id => {
return chunks.find(chunk => chunk.id === id);
});

const chunksOutput = this._createChunksOutput(entrypointChunks);
const kbSize = `${(asset.size / 1000).toFixed(2)} kb`;
const hasBeenCompiled = asset.comparedForEmit;
const bundleTbl = new Table({
chars: {
top: '',
'top-mid': '',
'top-left': '',
'top-right': '',
bottom: '',
'bottom-mid': '',
'bottom-left': '',
'bottom-right': '',
left: '',
'left-mid': '',
mid: '',
'mid-mid': '',
right: '',
'right-mid': '',
},
style: { compact: true },
});
bundleTbl.push({ 'Bundle Name': asset.name });
bundleTbl.push({ 'Compared For Emit': hasBeenCompiled });
bundleTbl.push({ 'Bundle size': kbSize });
const bundleOutput = bundleTbl.toString() + `\n\nModules:\n${chunksOutput}`;
assetsTble.push([entrypoint.name, bundleOutput]);
compilationTableEmpty = false;
}
});
});

if (!compilationTableEmpty) {
process.stdout.write(assetsTble.toString());
}

if (processingMessageBuffer.length > 0) {
processingMessageBuffer.forEach(buff => {
if (buff.lvl === 'warn') {
warnings.push(buff.msg);
} else {
statsErrors.push(buff.msg);
}
});
}

if (warnings) {
warnings.forEach(warning => {
process.stdout.write('\n\n');

if (warning.message) {
logger.warn(warning.message);
process.stdout.write('\n');
logger.debug(warning.stack);
return;
}
logger.warn(warning);
});
process.stdout.write('\n');
}

if (statsErrors) {
statsErrors.forEach(err => {
if (err.loc) logger.warn(err.loc);
if (err.name) {
process.stdout.write('\n');
logger.error(err.name);
}
});
}
return statsObj;
}

generateRawOutput(stats, options) {
process.stdout.write(stats.toString(options.stats));
}
Expand Down
7 changes: 0 additions & 7 deletions packages/webpack-cli/lib/utils/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,6 @@ module.exports = {
description: 'Prints result as JSON',
group: DISPLAY_GROUP,
},
{
name: 'pretty',
usage: 'webpack --pretty',
type: Boolean,
description: 'Prints a fancy output',
group: DISPLAY_GROUP,
},
{
name: 'dev',
usage: '--dev',
Expand Down
1 change: 0 additions & 1 deletion packages/webpack-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@webpack-cli/package-utils": "^1.0.1-alpha.4",
"ansi-escapes": "^4.2.1",
"chalk": "^3.0.0",
"cli-table3": "^0.5.1",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
"enquirer": "^2.3.4",
Expand Down
12 changes: 0 additions & 12 deletions test/output/pretty/pretty.test.js

This file was deleted.

1 change: 0 additions & 1 deletion test/output/pretty/src/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3877,16 +3877,6 @@ cli-cursor@^3.1.0:
dependencies:
restore-cursor "^3.1.0"

cli-table3@0.5.1, cli-table3@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.5.1.tgz#0252372d94dfc40dbd8df06005f48f31f656f202"
integrity sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==
dependencies:
object-assign "^4.1.0"
string-width "^2.1.1"
optionalDependencies:
colors "^1.1.2"

cli-table@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23"
Expand Down

0 comments on commit ca35fe3

Please sign in to comment.