Skip to content

Commit

Permalink
Merge branch 'next' into fix-peer-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored Mar 17, 2020
2 parents 0e85469 + 364d0dc commit a8e4f58
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 191 deletions.
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Table of Contents
- [Further Work](#further-work)
- [Contributor License Agreement](#contributor-license-agreement)
- [Documentation](#documentation)
- [Join The Development](#join-the-development)

## Issues

Expand Down
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

At webpack and webpack/webpack-cli repository we follow the [JSFoundation Code of Conduct][1].
Please adhere to the guidelines there and feel free to report any violation of them to the @webpack/core-team,
[**@webpack/cli-team**](https://github.com/orgs/webpack/teams/cli-team), or <conduct@js.foundation>.
**@webpack/cli-team**, or <conduct@js.foundation>.

[1]: https://js.foundation/community/code-of-conduct
[1]: https://github.com/openjs-foundation/code-and-learn/blob/master/CODE_OF_CONDUCT.md
4 changes: 2 additions & 2 deletions packages/generators/src/utils/languageSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function getEntryFolders(self): string[] {
export function getBabelLoader(includeFolders: string[]): Rule {
const include = includeFolders.map((folder: string): string => `path.resolve(__dirname, '${folder}')`);
return {
test: "/.(js|jsx)$/",
test: "/\\.(js|jsx)$/",
include,
loader: "'babel-loader'"
};
Expand All @@ -66,7 +66,7 @@ export function getBabelLoader(includeFolders: string[]): Rule {
export function getTypescriptLoader(includeFolders: string[]): Rule {
const include = includeFolders.map((folder: string): string => `path.resolve(__dirname, '${folder}')`);
return {
test: "/.(ts|tsx)?$/",
test: "/\\.(ts|tsx)$/",
loader: "'ts-loader'",
include,
exclude: ["/node_modules/"]
Expand Down
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.

2 changes: 1 addition & 1 deletion packages/serve/src/args-to-camel-case.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Converts dash-seperated strings to camel case
* Converts dash-separated strings to camel case
*
* @param {String} str - the string to convert
*
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isIdentifierStart, isIdentifierChar, isKeyword } from './validate-ident

function isImportPresent(j: JSCodeshift, ast: Node, path: string): boolean {
if (typeof path !== 'string') {
throw new Error(`path parameter should be string, recieved ${typeof path}`);
throw new Error(`path parameter should be string, received ${typeof path}`);
}
let importExists = false;
ast.find(j.CallExpression).forEach((callExp: Node): void => {
Expand Down Expand Up @@ -599,7 +599,7 @@ function parseMerge(j: JSCodeshift, ast: Node, value: string[], action: string):

function addMergeImports(configIdentifier: string, configPath: string): void {
if (typeof configIdentifier !== 'string' || typeof configPath !== 'string') {
throw new Error(`Both parameters should be strings. recieved ${typeof configIdentifier}, ${typeof configPath}`);
throw new Error(`Both parameters should be strings. received ${typeof configIdentifier}, ${typeof configPath}`);
}
ast.find(j.Program).forEach((p: Node): void => {
if (!isImportPresent(j, ast, 'webpack-merge')) {
Expand Down
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
4 changes: 2 additions & 2 deletions packages/webpack-cli/lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ async function runCLI(cli, commandIsUsed) {
value: process.argv[idx],
pos: idx,
};
// Swap idx of overriden value
// Swap idx of overridden value
if (oldMapValue) {
argsMap[arg].pos = oldMapValue.pos;
keysToDelete.push(idx + 1);
}
});
// Filter out the value for the overriden key
// Filter out the value for the overridden key
const newArgKeys = Object.keys(argsMap).filter(arg => !keysToDelete.includes(argsMap[arg].pos));
// eslint-disable-next-line require-atomic-updates
process.argv = newArgKeys;
Expand Down
4 changes: 0 additions & 4 deletions packages/webpack-cli/lib/groups/StatsGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/env/array/array-env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('env array', () => {
expect(prodScript.stdout).toBe('environment is production');
});

it('is able to compile sucessfully with prod flag', () => {
it('is able to compile successfully with prod flag', () => {
run(__dirname, ['--prod']);

const devScript = spawnSync('node', [devFile]);
Expand Down
2 changes: 1 addition & 1 deletion test/env/object/object-env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('env object', () => {
const bundledScript = spawnSync('node', [executable]);
expect(bundledScript.stdout).toBe('environment is development');
});
it('is able to compile sucessfully with dev flag', () => {
it('is able to compile successfully with dev flag', () => {
run(__dirname, ['--dev']);
const executable = path.join(__dirname, './bin/main.js');
const bundledScript = spawnSync('node', [executable]);
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 a8e4f58

Please sign in to comment.