From 1cc1fa07c59b102364f9c57d379b89e42201dab8 Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Tue, 20 Oct 2020 17:15:33 +0300 Subject: [PATCH 001/581] refactor: code (#1971) --- .../__tests__/cli-executer.test.js | 65 ----------- packages/webpack-cli/lib/bootstrap.js | 106 ++++++------------ packages/webpack-cli/lib/utils/arg-parser.js | 17 ++- .../webpack-cli/lib/utils/cli-executer.js | 64 ----------- packages/webpack-cli/lib/utils/process-log.js | 18 --- test/watch/watch-flag.test.js | 7 +- 6 files changed, 52 insertions(+), 225 deletions(-) delete mode 100644 packages/webpack-cli/__tests__/cli-executer.test.js delete mode 100644 packages/webpack-cli/lib/utils/cli-executer.js delete mode 100644 packages/webpack-cli/lib/utils/process-log.js diff --git a/packages/webpack-cli/__tests__/cli-executer.test.js b/packages/webpack-cli/__tests__/cli-executer.test.js deleted file mode 100644 index f64847f5084..00000000000 --- a/packages/webpack-cli/__tests__/cli-executer.test.js +++ /dev/null @@ -1,65 +0,0 @@ -jest.mock('enquirer'); - -describe('CLI Executer', () => { - let cliExecuter = null; - let multiCalls = 0; - let multiChoices = null; - let multiMapper = null; - - let inputCalls = 0; - const inputConstructorObjs = []; - - beforeAll(() => { - let inputRunCount = 0; - - const enquirer = require('enquirer'); - enquirer.MultiSelect = class MultiSelect { - constructor(obj) { - multiCalls++; - multiChoices = obj.choices; - multiMapper = obj.result; - } - - run() { - return ['--config', '--entry', '--progress']; - } - }; - enquirer.Input = class Input { - constructor(obj) { - this.mapper = obj.result; - inputCalls++; - inputConstructorObjs.push(obj); - } - - run() { - inputRunCount++; - return this.mapper(`test${inputRunCount}`); - } - }; - - cliExecuter = require('../lib/utils/cli-executer'); - }); - - it('runs enquirer options then runs webpack', async () => { - const args = await cliExecuter(); - expect(args.length).toBe(5); - - // check that webpack options are actually being displayed that - // the user can select from - expect(multiCalls).toEqual(1); - expect(multiChoices instanceof Array).toBeTruthy(); - expect(multiChoices.length > 0).toBeTruthy(); - expect(multiChoices[0]).toMatch(/--entry/); - - // ensure flag names are parsed out correctly - expect(typeof multiMapper).toEqual('function'); - expect(multiMapper(['--test1: test flag', '--test2: test flag 2'])).toEqual(['--test1', '--test2']); - - // check that the user is then prompted to set values to - // some flags - expect(inputCalls).toEqual(2); - expect(inputConstructorObjs.length).toEqual(2); - expect(inputConstructorObjs[0].message).toEqual('Enter value of the --config flag'); - expect(inputConstructorObjs[1].message).toEqual('Enter value of the --entry flag'); - }); -}); diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index 20e60ab7617..31ae522773e 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -1,35 +1,24 @@ -const { options } = require('colorette'); const WebpackCLI = require('./webpack-cli'); const { core } = require('./utils/cli-flags'); const versionRunner = require('./groups/runVersion'); const helpRunner = require('./groups/runHelp'); const logger = require('./utils/logger'); const { isCommandUsed } = require('./utils/arg-utils'); -const cliExecuter = require('./utils/cli-executer'); const argParser = require('./utils/arg-parser'); -require('./utils/process-log'); - process.title = 'webpack-cli'; -// Create a new instance of the CLI object -const cli = new WebpackCLI(); - -const parseArgs = (args) => argParser(core, args, true, process.title); - const runCLI = async (cliArgs) => { - let args; + const parsedArgs = argParser(core, cliArgs, true, process.title); - const commandIsUsed = isCommandUsed(cliArgs); - const parsedArgs = parseArgs(cliArgs); if (parsedArgs.unknownArgs.includes('help') || parsedArgs.opts.help) { - options.enabled = !cliArgs.includes('--no-color'); helpRunner(cliArgs); process.exit(0); } + const commandIsUsed = isCommandUsed(cliArgs); + if (parsedArgs.unknownArgs.includes('version') || parsedArgs.opts.version) { - options.enabled = !cliArgs.includes('--no-color'); versionRunner(cliArgs, commandIsUsed); process.exit(0); } @@ -39,74 +28,45 @@ const runCLI = async (cliArgs) => { } try { - // handle the default webpack entry CLI argument, where instead - // of doing 'webpack-cli --entry ./index.js' you can simply do - // 'webpack-cli ./index.js' - // if the unknown arg starts with a '-', it will be considered - // an unknown flag rather than an entry + // Create a new instance of the CLI object + const cli = new WebpackCLI(); + + // Handle the default webpack entry CLI argument, where instead of doing 'webpack-cli --entry ./index.js' you can simply do 'webpack-cli ./index.js' + // If the unknown arg starts with a '-', it will be considered an unknown flag rather than an entry let entry; - if (parsedArgs.unknownArgs.length > 0 && !parsedArgs.unknownArgs[0].startsWith('-')) { - if (parsedArgs.unknownArgs.length === 1) { - entry = parsedArgs.unknownArgs[0]; - } else { - entry = []; - parsedArgs.unknownArgs.forEach((unknown) => { - if (!unknown.startsWith('-')) { - entry.push(unknown); - } - }); - } - } else if (parsedArgs.unknownArgs.length > 0) { - parsedArgs.unknownArgs.forEach((unknown) => { - logger.warn(`Unknown argument: ${unknown}`); + + if (parsedArgs.unknownArgs.length > 0) { + entry = []; + + parsedArgs.unknownArgs = parsedArgs.unknownArgs.filter((item) => { + if (item.startsWith('-')) { + return true; + } + + entry.push(item); + + return false; }); - const args = await cliExecuter(); - const { opts } = parseArgs(args); - await cli.run(opts, core); - return; } + + if (parsedArgs.unknownArgs.length > 0) { + parsedArgs.unknownArgs.forEach(async (unknown) => { + logger.error(`Unknown argument: ${unknown}`); + }); + + process.exit(2); + } + const parsedArgsOpts = parsedArgs.opts; - // Enable/Disable color on console - options.enabled = parsedArgsOpts.color ? true : false; if (entry) { parsedArgsOpts.entry = entry; } - const result = await cli.run(parsedArgsOpts, core); - if (!result) { - return; - } - } catch (err) { - if (err.name === 'UNKNOWN_VALUE') { - logger.error(`Parse Error (unknown argument): ${err.value}`); - return; - } else if (err.name === 'ALREADY_SET') { - const argsMap = {}; - const keysToDelete = []; - cliArgs.forEach((arg, idx) => { - const oldMapValue = argsMap[arg]; - argsMap[arg] = { - value: cliArgs[idx], - pos: idx, - }; - // Swap idx of overridden value - if (oldMapValue) { - argsMap[arg].pos = oldMapValue.pos; - keysToDelete.push(idx + 1); - } - }); - // Filter out the value for the overridden key - const newArgKeys = Object.keys(argsMap).filter((arg) => !keysToDelete.includes(argsMap[arg].pos)); - - cliArgs = newArgKeys; - args = argParser('', core, cliArgs); - await cli.run(args.opts, core); - logger.warn('\nDuplicate flags found, defaulting to last set value'); - } else { - logger.error(err); - return; - } + await cli.run(parsedArgsOpts, core); + } catch (error) { + logger.error(error); + process.exit(2); } }; diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index e60e1833b02..5d3aec0a9eb 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -15,6 +15,7 @@ const { defaultCommands } = require('./commands'); */ const argParser = (options, args, argsOnly = false, name = '') => { const parser = new commander.Command(); + // Set parser name parser.name(name); parser.storeOptionsAsProperties(false); @@ -51,6 +52,7 @@ const argParser = (options, args, argsOnly = false, name = '') => { options.reduce((parserInstance, option) => { let optionType = option.type; let isStringOrBool = false; + if (Array.isArray(optionType)) { // filter out duplicate types optionType = optionType.filter((type, index) => { @@ -77,7 +79,9 @@ const argParser = (options, args, argsOnly = false, name = '') => { } const flags = option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`; + let flagsWithType = flags; + if (isStringOrBool) { // commander recognizes [value] as an optional placeholder, // making this flag work either as a string or a boolean @@ -100,17 +104,25 @@ const argParser = (options, args, argsOnly = false, name = '') => { // this ensures we're only splitting by the first `=` const [allKeys, val] = value.split(/=(.+)/, 2); const splitKeys = allKeys.split(/\.(?!$)/); + let prevRef = previous; + splitKeys.forEach((someKey, index) => { - if (!prevRef[someKey]) prevRef[someKey] = {}; + if (!prevRef[someKey]) { + prevRef[someKey] = {}; + } + if ('string' === typeof prevRef[someKey]) { prevRef[someKey] = {}; } + if (index === splitKeys.length - 1) { prevRef[someKey] = val || true; } + prevRef = prevRef[someKey]; }); + return previous; }; parserInstance.option(flagsWithType, option.description, multiArg, option.defaultValue).action(() => {}); @@ -144,8 +156,8 @@ const argParser = (options, args, argsOnly = false, name = '') => { const result = parser.parse(args, parseOptions); const opts = result.opts(); - const unknownArgs = result.args; + args.forEach((arg) => { const flagName = arg.slice(5); const option = options.find((opt) => opt.name === flagName); @@ -153,6 +165,7 @@ const argParser = (options, args, argsOnly = false, name = '') => { const flagUsed = args.includes(flag) && !unknownArgs.includes(flag); let alias = ''; let aliasUsed = false; + if (option && option.alias) { alias = `-${option.alias}`; aliasUsed = args.includes(alias) && !unknownArgs.includes(alias); diff --git a/packages/webpack-cli/lib/utils/cli-executer.js b/packages/webpack-cli/lib/utils/cli-executer.js deleted file mode 100644 index 276981f1285..00000000000 --- a/packages/webpack-cli/lib/utils/cli-executer.js +++ /dev/null @@ -1,64 +0,0 @@ -const { MultiSelect, Input } = require('enquirer'); -const { cyan } = require('colorette'); -const logger = require('./logger'); -const cliArgs = require('./cli-flags').core; - -const prompter = async () => { - const args = []; - - const typePrompt = new MultiSelect({ - name: 'type', - message: 'Which flags do you want to use?', - choices: cliArgs.reduce((prev, curr) => { - return [...prev, `--${curr.name}: ${curr.description}`]; - }, []), - result: (value) => { - return value.map((flag) => flag.split(':')[0]); - }, - }); - - const selections = await typePrompt.run(); - - const boolArgs = []; - const questions = []; - selections.forEach((selection) => { - const options = cliArgs.find((flag) => { - return flag.name === selection.slice(2); - }); - - if (options.type === Boolean) { - boolArgs.push(selection); - return; - } - - const valuePrompt = new Input({ - name: 'value', - message: `Enter value of the ${selection} flag`, - initial: options.defaultValue, - result: (value) => [selection, value], - validate: (value) => Boolean(value), - }); - questions.push(valuePrompt); - }); - - // Create promise chain to force synchronous prompt of question - for await (const question of questions) { - const flagArgs = await question.run(); - args.push(...flagArgs); - } - - return [...args, ...boolArgs]; -}; - -const run = async () => { - try { - const args = await prompter(); - logger.info('\nExecuting CLI\n'); - return args; - } catch (err) { - logger.error(`Action Interrupted, use ${cyan('webpack-cli help')} to see possible options.`); - process.exit(2); - } -}; - -module.exports = run; diff --git a/packages/webpack-cli/lib/utils/process-log.js b/packages/webpack-cli/lib/utils/process-log.js deleted file mode 100644 index 45933841849..00000000000 --- a/packages/webpack-cli/lib/utils/process-log.js +++ /dev/null @@ -1,18 +0,0 @@ -const logger = require('./logger'); - -function logErrorAndExit(error) { - if (error && error.stack) logger.error(error.stack); - process.exit(error.exitCode); -} - -process.on('uncaughtException', (error) => { - logger.error(`Uncaught exception: ${error}`); - logErrorAndExit(error); -}); - -process.on('unhandledRejection', (error) => { - logger.error(`Promise rejection: ${error}`); - logErrorAndExit(error); -}); - -//TODO: implement logger for debug diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index 362c01c3615..e326fed48d8 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -1,18 +1,19 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); const { runAndGetWatchProc, isWebpack5 } = require('../utils/test-utils'); const { writeFileSync } = require('fs'); const { resolve } = require('path'); const wordsInStatsv4 = ['Hash', 'Version', 'Time', 'Built at:', 'main.js']; -const wordsInStatsv5 = ['asset', 'index.js', `compiled \u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m`]; +const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; describe('--watch flag', () => { it('should recompile upon file change', (done) => { const proc = runAndGetWatchProc(__dirname, ['--watch'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { - const data = chunk.toString(); + const data = stripAnsi(chunk.toString()); if (semaphore === 0 && data.includes('watching files for updates')) { process.nextTick(() => { @@ -47,7 +48,7 @@ describe('--watch flag', () => { const proc = runAndGetWatchProc(__dirname, ['--watch'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { - const data = chunk.toString(); + const data = stripAnsi(chunk.toString()); if (semaphore === 0 && data.includes('Compilation starting')) { semaphore++; From e8010b3aac695971e542ad4d3584ce534da39b8f Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 21 Oct 2020 16:43:40 +0530 Subject: [PATCH 002/581] fix: help and version functionality (#1972) * fix: invoke runHelp function if --help is passed * tests: for --help * fix: help & version * tests: updates * fix: conflict * tests: update --- packages/webpack-cli/lib/bootstrap.js | 13 ------------- packages/webpack-cli/lib/utils/arg-parser.js | 13 ++++++++++--- test/help/help-commands.test.js | 7 ++++--- test/help/help-flags.test.js | 8 ++++++++ 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index 31ae522773e..56996ec64c7 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -1,7 +1,5 @@ const WebpackCLI = require('./webpack-cli'); const { core } = require('./utils/cli-flags'); -const versionRunner = require('./groups/runVersion'); -const helpRunner = require('./groups/runHelp'); const logger = require('./utils/logger'); const { isCommandUsed } = require('./utils/arg-utils'); const argParser = require('./utils/arg-parser'); @@ -11,18 +9,7 @@ process.title = 'webpack-cli'; const runCLI = async (cliArgs) => { const parsedArgs = argParser(core, cliArgs, true, process.title); - if (parsedArgs.unknownArgs.includes('help') || parsedArgs.opts.help) { - helpRunner(cliArgs); - process.exit(0); - } - const commandIsUsed = isCommandUsed(cliArgs); - - if (parsedArgs.unknownArgs.includes('version') || parsedArgs.opts.version) { - versionRunner(cliArgs, commandIsUsed); - process.exit(0); - } - if (commandIsUsed) { return; } diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index 5d3aec0a9eb..896362c2503 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -2,6 +2,7 @@ const commander = require('commander'); const logger = require('./logger'); const { commands } = require('./cli-flags'); const runHelp = require('../groups/runHelp'); +const runVersion = require('../groups/runVersion'); const { defaultCommands } = require('./commands'); /** @@ -39,11 +40,17 @@ const argParser = (options, args, argsOnly = false, name = '') => { // Prevent default behavior parser.on('command:*', () => {}); - // Use customized help output if available - parser.on('option:help', () => { + // Use customized help output + if (args.includes('--help') || args.includes('help')) { runHelp(args); process.exit(0); - }); + } + + // Use Customized version + if (args.includes('--version') || args.includes('version') || args.includes('-v')) { + runVersion(args); + process.exit(0); + } // Allow execution if unknown arguments are present parser.allowUnknownOption(true); diff --git a/test/help/help-commands.test.js b/test/help/help-commands.test.js index 63f2e94fdf4..aa2f8dad0e1 100644 --- a/test/help/help-commands.test.js +++ b/test/help/help-commands.test.js @@ -4,9 +4,10 @@ const { run } = require('../utils/test-utils'); const helpHeader = 'The build tool for modern web applications'; describe('commands help', () => { - it('throws error if supplied as an argument for subcommands', () => { - const { stderr } = run(__dirname, ['serve', 'help'], false); - expect(stderr).toContain('Unknown argument: help'); + it('shows help for subcommands', () => { + const { stderr, stdout } = run(__dirname, ['serve', 'help'], false); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack s | serve'); }); it('shows help information with subcommands as an arg', () => { diff --git a/test/help/help-flags.test.js b/test/help/help-flags.test.js index 544824ce3c4..0829d58a9be 100644 --- a/test/help/help-flags.test.js +++ b/test/help/help-flags.test.js @@ -21,6 +21,14 @@ describe('commands help', () => { expect(stderr).toHaveLength(0); }); + it('should show help for --mode', () => { + const { stdout, stderr } = run(__dirname, ['--mode', '--help'], false); + expect(stdout).not.toContain(helpHeader); + expect(stdout).toContain('webpack --mode '); + expect(stdout).toContain('Defines the mode to pass to webpack'); + expect(stderr).toHaveLength(0); + }); + it('gives precedence to earlier flag in case of multiple flags', () => { const { stdout, stderr } = run(__dirname, ['--help', '--entry', '--merge'], false); expect(stdout).not.toContain(helpHeader); From 1e50e9852cd79455f6ee468700f9225fc0428516 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 23 Oct 2020 16:11:20 +0300 Subject: [PATCH 003/581] chore(deps-dev): bump webpack from 5.1.3 to 5.2.0 (#1981) Bumps [webpack](https://github.com/webpack/webpack) from 5.1.3 to 5.2.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.1.3...v5.2.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7568463a40f..e48c320bc45 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2825,7 +2825,7 @@ acorn@^7.1.0, acorn@^7.1.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.0.3: +acorn@^8.0.4: version "8.0.4" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.0.4.tgz#7a3ae4191466a6984eee0fe3407a4f3aa9db8354" integrity sha512-XNP0PqF1XD19ZlLKvB7cMmnZswW4C/03pRHgirB30uSJTaS3A3V1/P4sS3HPvFmjoriPCJQs+JDSbm4bL1TxGQ== @@ -3394,7 +3394,7 @@ browser-resolve@^1.11.3: dependencies: resolve "1.1.7" -browserslist@^4.12.0, browserslist@^4.14.3, browserslist@^4.8.5: +browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4.8.5: version "4.14.5" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.5.tgz#1c751461a102ddc60e40993639b709be7f2c4015" integrity sha512-Z+vsCZIvCBvqLoYkBFTwEYH3v5MCQbsAjp50ERycpOjnPmolg1Gjy4+KaWWpm8QOJt9GHkhdqAl14NpCX73CWA== @@ -4718,10 +4718,10 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" -enhanced-resolve@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.2.0.tgz#3db3307a608f236f33aeea79303d32915792cbab" - integrity sha512-NZlGLl8DxmZoq0uqPPtJfsCAir68uR047+Udsh1FH4+5ydGQdMurn/A430A1BtxASVmMEuS7/XiJ5OxJ9apAzQ== +enhanced-resolve@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.3.0.tgz#14be504e14ad58e9821a311ea6a9037c716786d9" + integrity sha512-EENz3E701+77g0wfbOITeI8WLPNso2kQNMBIBEi/TH/BEa9YXtS01X7sIEk5XXsfFq1jNkhIpu08hBPH1TRLIQ== dependencies: graceful-fs "^4.2.4" tapable "^2.0.0" @@ -4891,7 +4891,7 @@ eslint-plugin-prettier@^3.1.4: dependencies: prettier-linter-helpers "^1.0.0" -eslint-scope@^5.0.0, eslint-scope@^5.1.0: +eslint-scope@^5.0.0, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== @@ -11554,9 +11554,9 @@ webpack-sources@^2.0.1: source-map "^0.6.1" webpack@^5.1.0: - version "5.1.3" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.1.3.tgz#a6e4fd250ef2513f94844ae5d8f7570215a2ac49" - integrity sha512-bNBF5EOpt5a6NeCBFu0+8KJtG61cVmOb2b/a5tPNRLz3OWgDpHMbmnDkaSm3nf/UQ6ufw4PWYGVsVOAi8UfL2A== + version "5.2.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.2.0.tgz#02f22466b79751a80a50f20f027a716e296b3ef5" + integrity sha512-evtOjOJQq3zaHJIWsJjM4TGtNHtSrNVAIyQ+tdPW/fRd+4PLGbUG6S3xt+N4+QwDBOaCVd0xCWiHd4R6lWO5DQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" @@ -11564,11 +11564,11 @@ webpack@^5.1.0: "@webassemblyjs/helper-module-context" "1.9.0" "@webassemblyjs/wasm-edit" "1.9.0" "@webassemblyjs/wasm-parser" "1.9.0" - acorn "^8.0.3" - browserslist "^4.14.3" + acorn "^8.0.4" + browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.2.0" - eslint-scope "^5.1.0" + enhanced-resolve "^5.3.0" + eslint-scope "^5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" graceful-fs "^4.2.4" From dd39959631aecbc3d7a594d8e5cdc6de4e5ae229 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 24 Oct 2020 21:25:48 +0530 Subject: [PATCH 004/581] tests: for exit-code in case of error in config (#1979) --- .eslintignore | 1 + .prettierignore | 1 + test/config/error/config-error.test.js | 20 ++++++++++++++++++++ test/config/error/src/index.js | 1 + test/config/error/syntax-error.js | 5 +++++ test/config/error/webpack.config.js | 5 +++++ 6 files changed, 33 insertions(+) create mode 100644 test/config/error/config-error.test.js create mode 100644 test/config/error/src/index.js create mode 100644 test/config/error/syntax-error.js create mode 100644 test/config/error/webpack.config.js diff --git a/.eslintignore b/.eslintignore index aafbffa5401..d1514bd87ba 100644 --- a/.eslintignore +++ b/.eslintignore @@ -15,6 +15,7 @@ test/**/bin/ test/**/binary/ test/**/index.js test/typescript/webpack.config.ts +test/config/error/syntax-error.js test/plugin/test-plugin/test/test-utils.js test/plugin/test-plugin/test/functional.test.js test/plugin/test-plugin/examples/simple/src/static-esm-module.js diff --git a/.prettierignore b/.prettierignore index a039fd52884..d037f141282 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,3 +4,4 @@ test/**/dist/ test/**/bin/ test/**/binary/ test/**/index.js +test/config/error/syntax-error.js diff --git a/test/config/error/config-error.test.js b/test/config/error/config-error.test.js new file mode 100644 index 00000000000..d11e29e29a7 --- /dev/null +++ b/test/config/error/config-error.test.js @@ -0,0 +1,20 @@ +'use strict'; +const { resolve } = require('path'); +const { run } = require('../../utils/test-utils'); + +describe('config error', () => { + it('should throw error with invalid configuration', () => { + const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + + expect(stderr).toContain('Invalid configuration object'); + expect(stderr).toContain(`"development" | "production" | "none"`); + expect(exitCode).toBe(2); + }); + + it('should throw syntax error and exit with non-zero exit code', () => { + const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.js')]); + + expect(stderr).toContain('SyntaxError: Unexpected token'); + expect(exitCode).toBe(2); + }); +}); diff --git a/test/config/error/src/index.js b/test/config/error/src/index.js new file mode 100644 index 00000000000..97bfc742a9b --- /dev/null +++ b/test/config/error/src/index.js @@ -0,0 +1 @@ +console.log('config error test'); diff --git a/test/config/error/syntax-error.js b/test/config/error/syntax-error.js new file mode 100644 index 00000000000..96fc2e63b73 --- /dev/null +++ b/test/config/error/syntax-error.js @@ -0,0 +1,5 @@ +module.exports = { + name: 'config-error', + mode: 'development', + target: 'node'; //SyntaxError: Unexpected token ';' +}; diff --git a/test/config/error/webpack.config.js b/test/config/error/webpack.config.js new file mode 100644 index 00000000000..a967a05223c --- /dev/null +++ b/test/config/error/webpack.config.js @@ -0,0 +1,5 @@ +module.exports = { + name: 'config-error', + mode: 'unknown', //error + target: 'node', +}; From 8b8c007b9e1452cad3f8bab1e23f14a929d1b9bc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 26 Oct 2020 14:11:45 +0300 Subject: [PATCH 005/581] chore(deps): bump commander from 6.1.0 to 6.2.0 (#1984) Bumps [commander](https://github.com/tj/commander.js) from 6.1.0 to 6.2.0. - [Release notes](https://github.com/tj/commander.js/releases) - [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/tj/commander.js/compare/v6.1.0...v6.2.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index e48c320bc45..a116a6307c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3916,9 +3916,9 @@ commander@^2.18.0, commander@^2.20.0: integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== commander@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-6.1.0.tgz#f8d722b78103141006b66f4c7ba1e97315ba75bc" - integrity sha512-wl7PNrYWd2y5mp1OK/LhTlv8Ff4kQJQRXXAvF+uU/TPNiVJUxZLRYGj/B0y/lPGAVcSbJqH2Za/cvHmrPMC8mA== + version "6.2.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" + integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q== commitlint-config-cz@^0.13.2: version "0.13.2" From 2cb0c0e383670949ce31231edbfda514f47c3dfc Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Mon, 26 Oct 2020 12:21:51 +0100 Subject: [PATCH 006/581] fix: callback deprecation (#1977) --- .../lib/plugins/WebpackCLIPlugin.js | 53 +++++++ packages/webpack-cli/lib/webpack-cli.js | 132 ++++++------------ test/core-flags/cache-flags.test.js | 8 ++ test/utils/cli-plugin-test/plugin.test.js | 2 +- 4 files changed, 107 insertions(+), 88 deletions(-) create mode 100644 packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js diff --git a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js new file mode 100644 index 00000000000..c79c8654a95 --- /dev/null +++ b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js @@ -0,0 +1,53 @@ +const { packageExists } = require('../utils/package-exists'); +const webpack = packageExists('webpack') ? require('webpack') : undefined; +const logger = require('../utils/logger'); + +const PluginName = 'webpack-cli'; + +class WebpackCLIPlugin { + constructor(options) { + this.options = options; + } + async apply(compiler) { + const compilers = compiler.compilers || [compiler]; + + for (const compiler of compilers) { + if (this.options.progress) { + const { ProgressPlugin } = compiler.webpack || webpack; + + let progressPluginExists; + + if (compiler.options.plugins) { + progressPluginExists = Boolean(compiler.options.plugins.find((e) => e instanceof ProgressPlugin)); + } + + if (!progressPluginExists) { + new ProgressPlugin().apply(compiler); + } + } + } + + const compilationName = (compilation) => (compilation.name ? ` ${compilation.name}` : ''); + + compiler.hooks.watchRun.tap(PluginName, (compilation) => { + const { bail, watch } = compilation.options; + if (bail && watch) { + logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); + } + + logger.success(`Compilation${compilationName(compilation)} starting...`); + }); + + compiler.hooks.done.tap(PluginName, (compilation) => { + logger.success(`Compilation${compilationName(compilation)} finished`); + + process.nextTick(() => { + if (compiler.watchMode) { + logger.success('watching files for updates...'); + } + }); + }); + } +} + +module.exports = WebpackCLIPlugin; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 07bdf950c40..9ae5c1ae010 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -10,6 +10,7 @@ const { toKebabCase } = require('./utils/helpers'); const assignFlagDefaults = require('./utils/flag-defaults'); const { writeFileSync } = require('fs'); const { options: coloretteOptions } = require('colorette'); +const WebpackCLIPlugin = require('./plugins/WebpackCLIPlugin'); // CLI arg resolvers const handleConfigResolution = require('./groups/ConfigGroup'); @@ -212,24 +213,27 @@ class WebpackCLI extends GroupHelper { return this.runOptionGroups(args); } - createCompiler(options) { + handleError(error) { + // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 + // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 + const ValidationError = webpack.ValidationError || webpack.WebpackOptionsValidationError; + + // In case of schema errors print and exit process + // For webpack@4 and webpack@5 + if (error instanceof ValidationError) { + logger.error(error.message); + } else { + logger.error(error); + } + } + + createCompiler(options, callback) { let compiler; try { - compiler = webpack(options); + compiler = webpack(options, callback); } catch (error) { - // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 - // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 - const ValidationError = webpack.ValidationError ? webpack.ValidationError : webpack.WebpackOptionsValidationError; - - // In case of schema errors print and exit process - // For webpack@4 and webpack@5 - if (error instanceof ValidationError) { - logger.error(error.message); - } else { - logger.error(error); - } - + this.handleError(error); process.exit(2); } @@ -245,54 +249,35 @@ class WebpackCLI extends GroupHelper { async run(args, cliOptions) { await this.processArgs(args, cliOptions); - const compiler = this.createCompiler(this.compilerConfiguration); - - const options = this.compilerConfiguration; - const outputOptions = this.outputConfiguration; - - if (outputOptions.interactive) { - const interactive = require('./utils/interactive'); + let compiler; - return interactive(compiler, options, outputOptions); - } + let options = this.compilerConfiguration; + let outputOptions = this.outputConfiguration; - const compilers = compiler.compilers ? compiler.compilers : [compiler]; - const isWatchMode = Boolean(compilers.find((compiler) => compiler.options.watch)); const isRawOutput = typeof outputOptions.json === 'undefined'; if (isRawOutput) { - for (const compiler of compilers) { - if (outputOptions.progress) { - const { ProgressPlugin } = webpack; - - let progressPluginExists; - - if (compiler.options.plugins) { - progressPluginExists = Boolean(compiler.options.plugins.find((e) => e instanceof ProgressPlugin)); - } + const webpackCLIPlugin = new WebpackCLIPlugin({ + progress: outputOptions.progress, + }); - if (!progressPluginExists) { - new ProgressPlugin().apply(compiler); - } + const addPlugin = (options) => { + if (!options.plugins) { + options.plugins = []; } + options.plugins.unshift(webpackCLIPlugin); + }; + if (Array.isArray(options)) { + options.forEach(addPlugin); + } else { + addPlugin(options); } - - compiler.hooks.watchRun.tap('watchInfo', (compilation) => { - if (compilation.options.bail && isWatchMode) { - logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); - } - - logger.success(`Compilation${compilation.name ? `${compilation.name}` : ''} starting...`); - }); - compiler.hooks.done.tap('watchInfo', (compilation) => { - logger.success(`Compilation${compilation.name ? `${compilation.name}` : ''} finished`); - }); } const callback = (error, stats) => { if (error) { - logger.error(error); - process.exit(1); + this.handleError(error); + process.exit(2); } if (stats.hasErrors()) { @@ -314,9 +299,11 @@ class WebpackCLI extends GroupHelper { return stats; }; + const getStatsOptionsFromCompiler = (compiler) => getStatsOptions(compiler.options ? compiler.options.stats : undefined); + const foundStats = compiler.compilers - ? { children: compiler.compilers.map((compiler) => getStatsOptions(compiler.options.stats)) } - : getStatsOptions(compiler.options.stats); + ? { children: compiler.compilers.map(getStatsOptionsFromCompiler) } + : getStatsOptionsFromCompiler(compiler); if (outputOptions.json === true) { process.stdout.write(JSON.stringify(stats.toJson(foundStats), null, 2) + '\n'); @@ -335,46 +322,17 @@ class WebpackCLI extends GroupHelper { } else { logger.raw(`${stats.toString(foundStats)}`); } - - if (isWatchMode) { - logger.success('watching files for updates...'); - } }; - if (isWatchMode) { - const watchOptions = (compiler.options && compiler.options.watchOptions) || {}; + compiler = this.createCompiler(options, callback); - if (watchOptions.stdin) { - process.stdin.on('end', function () { - process.exit(); - }); - process.stdin.resume(); - } - - return new Promise((resolve) => { - compiler.watch(watchOptions, (error, stats) => { - callback(error, stats); + if (compiler && outputOptions.interactive) { + const interactive = require('./utils/interactive'); - resolve(); - }); - }); - } else { - return new Promise((resolve) => { - compiler.run((error, stats) => { - if (compiler.close) { - compiler.close(() => { - callback(error, stats); - - resolve(); - }); - } else { - callback(error, stats); - - resolve(); - } - }); - }); + interactive(compiler, options, outputOptions); } + + return Promise.resolve(); } } diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index 8a2cb8ccbb8..57a1f0338ac 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -1,10 +1,18 @@ 'use strict'; +const path = require('path'); +const rimraf = require('rimraf'); const { run, isWindows } = require('../utils/test-utils'); const { existsSync, writeFileSync, unlinkSync } = require('fs'); const { resolve } = require('path'); describe('cache related flags from core', () => { + beforeEach((done) => { + rimraf(path.join(__dirname, '../../node_modules/.cache/webpack/*'), () => { + done(); + }); + }); + it('should be successful with --cache ', () => { const { stderr, stdout } = run(__dirname, ['--cache']); expect(stderr).toBeFalsy(); diff --git a/test/utils/cli-plugin-test/plugin.test.js b/test/utils/cli-plugin-test/plugin.test.js index 96a5ff20c27..14e4810a3fa 100644 --- a/test/utils/cli-plugin-test/plugin.test.js +++ b/test/utils/cli-plugin-test/plugin.test.js @@ -10,6 +10,6 @@ describe('webpack-cli-test-plugin Test', () => { if (typeof cli !== 'undefined') { expect(stdout).toContain(`alias: { alias: [ 'alias1', 'alias2' ] }`); } - expect(stdout).toContain('plugins: [ WebpackCLITestPlugin { opts: [Array], showAll: true } ]'); + expect(stdout).toContain(` WebpackCLITestPlugin { opts: [Array], showAll: true }`); }); }); From 8186ca289584f05a6d1e0c484fd7fa19c2d99420 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 26 Oct 2020 14:22:24 +0300 Subject: [PATCH 007/581] chore(deps-dev): bump eslint-config-prettier from 6.12.0 to 6.14.0 (#1975) Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 6.12.0 to 6.14.0. - [Release notes](https://github.com/prettier/eslint-config-prettier/releases) - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v6.12.0...v6.14.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index a116a6307c9..2140c26d7a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4858,9 +4858,9 @@ escodegen@^1.11.1: source-map "~0.6.1" eslint-config-prettier@^6.11.0: - version "6.12.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.12.0.tgz#9eb2bccff727db1c52104f0b49e87ea46605a0d2" - integrity sha512-9jWPlFlgNwRUYVoujvWTQ1aMO8o6648r+K7qU7K5Jmkbyqav1fuEZC0COYpGBxyiAJb65Ra9hrmFx19xRGwXWw== + version "6.14.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.14.0.tgz#390e7863a8ae99970981933826476169285b3a27" + integrity sha512-DbVwh0qZhAC7CNDWcq8cBdK6FcVHiMTKmCypOPWeZkp9hJ8xYwTaWSa6bb6cjfi8KOeJy0e9a8Izxyx+O4+gCQ== dependencies: get-stdin "^6.0.0" From 53f7d4ab122939f44179872ae094f96be48a2180 Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Thu, 29 Oct 2020 14:02:52 +0300 Subject: [PATCH 008/581] chore(deps): update (#1994) --- package.json | 41 +- .../generators/__tests__/utils/entry.test.ts | 1 - .../__tests__/utils/languageSupport.test.ts | 2 - .../__tests__/utils/plugins.test.ts | 1 - .../__tests__/utils/styleSupport.test.ts | 2 - .../__tests__/global-packages-path.test.ts | 2 +- test/core-flags/module-flags.test.js | 2 +- test/core-flags/optimization-flags.test.js | 2 + test/core-flags/output-flags.test.js | 11 - yarn.lock | 1707 +++++++++-------- 10 files changed, 880 insertions(+), 891 deletions(-) diff --git a/package.json b/package.json index 248cb7f4e3a..537f6218b4f 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ "fix": "yarn lint:eslint --fix && yarn lint:prettier --write", "prepsuite": "node scripts/prepareSuite.js", "pretest": "yarn build && yarn lint && yarn prepsuite", - "test": "jest --reporters=default --reporters=jest-junit", - "test:cli": "jest test --reporters=default --reporters=jest-junit --forceExit", - "test:packages": "jest packages/ --reporters=default --reporters=jest-junit --forceExit", + "test": "jest --reporters=default", + "test:cli": "jest test --reporters=default --forceExit", + "test:packages": "jest packages/ --reporters=default --forceExit", "test:ci": "yarn test:cli && yarn test:packages", "test:watch": "jest test/ packages/ --watch", "test:smoke": "smoketests/smoketests.sh", @@ -54,13 +54,13 @@ "webpack": "4.x.x || 5.x.x" }, "devDependencies": { - "@babel/core": "^7.11.1", - "@babel/preset-env": "^7.11.0", + "@babel/core": "^7.12.3", + "@babel/preset-env": "^7.12.1", "@commitlint/cli": "^11.0.0", "@commitlint/config-lerna-scopes": "^11.0.0", - "@types/cross-spawn": "^6.0.1", - "@types/jest": "^25.1.4", - "@types/node": "13.9.8", + "@types/cross-spawn": "^6.0.2", + "@types/jest": "^26.0.15", + "@types/node": "^14.14.5", "@typescript-eslint/eslint-plugin": "^2.34.0", "@typescript-eslint/parser": "^2.34.0", "colorette": "^1.2.1", @@ -69,29 +69,28 @@ "concat-stream": "^2.0.0", "cz-customizable": "^6.3.0", "del-cli": "^3.0.1", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.11.0", + "eslint": "^7.12.1", + "eslint-config-prettier": "^6.15.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.1.4", - "execa": "^4.0.3", + "execa": "^4.1.0", "get-port": "^5.1.1", - "git-cz": "^4.7.0", - "husky": "^4.2.5", - "jest": "^25.2.3", - "jest-junit": "^11.1.0", + "git-cz": "^4.7.1", + "husky": "^4.3.0", + "jest": "^26.6.1", "jest-serializer-ansi": "^1.0.3", - "jest-watch-typeahead": "^0.5.0", + "jest-watch-typeahead": "^0.6.1", "lerna": "^3.22.1", - "lint-staged": "^10.2.11", - "prettier": "^2.0.5", + "lint-staged": "^10.5.0", + "prettier": "^2.1.2", "readable-stream": "^3.6.0", "rimraf": "^3.0.2", "strip-ansi": "^6.0.0", - "ts-jest": "^25.5.1", + "ts-jest": "^26.4.3", "typescript": "^3.9.7", - "webpack": "^5.1.0", + "webpack": "^5.3.0", "webpack-bundle-analyzer": "^3.9.0", - "webpack-dev-server": "3.10.3", + "webpack-dev-server": "^3.11.0", "yeoman-test": "^2.7.0" } } diff --git a/packages/generators/__tests__/utils/entry.test.ts b/packages/generators/__tests__/utils/entry.test.ts index 78ba29200f2..688382d4781 100644 --- a/packages/generators/__tests__/utils/entry.test.ts +++ b/packages/generators/__tests__/utils/entry.test.ts @@ -4,7 +4,6 @@ jest.setMock('@webpack-cli/webpack-scaffold', { }); import { Input, InputValidate } from '@webpack-cli/webpack-scaffold'; -// eslint-disable-next-line node/no-missing-import import entry from '../../lib/utils/entry'; describe('entry', () => { diff --git a/packages/generators/__tests__/utils/languageSupport.test.ts b/packages/generators/__tests__/utils/languageSupport.test.ts index 9d9161cc224..858eef018cf 100644 --- a/packages/generators/__tests__/utils/languageSupport.test.ts +++ b/packages/generators/__tests__/utils/languageSupport.test.ts @@ -1,6 +1,4 @@ -// eslint-disable-next-line node/no-missing-import import language, { LangType, getBabelLoader, getTypescriptLoader } from '../../lib/utils/languageSupport'; -// eslint-disable-next-line node/no-missing-import import { CustomGenerator } from '../../lib/types'; // TODO: enable after jest release diff --git a/packages/generators/__tests__/utils/plugins.test.ts b/packages/generators/__tests__/utils/plugins.test.ts index 8c87df4530e..35c7fe8ecc2 100644 --- a/packages/generators/__tests__/utils/plugins.test.ts +++ b/packages/generators/__tests__/utils/plugins.test.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line node/no-missing-import import { replaceAt, generatePluginName } from '../../lib/utils/plugins'; describe('generate plugin name', () => { diff --git a/packages/generators/__tests__/utils/styleSupport.test.ts b/packages/generators/__tests__/utils/styleSupport.test.ts index 3eb4a0ce4a9..550b95a9ebb 100644 --- a/packages/generators/__tests__/utils/styleSupport.test.ts +++ b/packages/generators/__tests__/utils/styleSupport.test.ts @@ -1,6 +1,4 @@ -// eslint-disable-next-line node/no-missing-import import style, { StylingType } from '../../lib/utils/styleSupport'; -// eslint-disable-next-line node/no-missing-import import { CustomGenerator } from '../../lib/types'; // TODO: enable after jest release diff --git a/packages/utils/__tests__/global-packages-path.test.ts b/packages/utils/__tests__/global-packages-path.test.ts index a36c469bfdb..467057d4657 100644 --- a/packages/utils/__tests__/global-packages-path.test.ts +++ b/packages/utils/__tests__/global-packages-path.test.ts @@ -2,7 +2,7 @@ jest.setMock('webpack-cli/lib/utils/get-package-manager', { getPackageManager: jest.fn(), }); -// eslint-disable-next-line node/no-missing-import + import { getPathToGlobalPackages } from '../lib/global-packages-path'; import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; jest.mock('execa'); diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index 2d7a79a2c68..51083e646a1 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -22,7 +22,7 @@ describe('module config related flag', () => { const option = propName.split('Reset')[0]; expect(stdout).toContain(`${option}: []`); } else if (flag.name.includes('rules-')) { - expect(stdout).toContain('sideEffects: true'); + expect(stdout).toContain("sideEffects: 'flag'"); } else { expect(stdout).toContain(`${propName}: true`); } diff --git a/test/core-flags/optimization-flags.test.js b/test/core-flags/optimization-flags.test.js index 9dcbaa364ef..32b3de29f0d 100644 --- a/test/core-flags/optimization-flags.test.js +++ b/test/core-flags/optimization-flags.test.js @@ -62,6 +62,8 @@ describe('optimization config related flag', () => { expect(stdout).toContain(`usedExports: 'global'`); } else if (flag.name === 'optimization-split-chunks-default-size-types') { expect(stdout).toContain(`defaultSizeTypes: [Array]`); + } else if (flag.name === 'optimization-side-effects') { + expect(stdout).toContain(`${propName}: 'flag'`); } else { expect(stdout).toContain(`${propName}: 'named'`); } diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index 15e8f0163a6..c11e2206587 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -64,10 +64,6 @@ describe('output config related flag', () => { stdout = run(__dirname, [`--${flag.name}`, 'commonjs']).stdout; expect(stdout).toContain(`${propName}: 'commonjs'`); - } else if (flag.name === 'output-enabled-library-types') { - stdout = run(__dirname, [`--${flag.name}`, 'global']).stdout; - - expect(stdout).toContain(`${propName}: [ 'global' ]`); } else if (flag.name === 'output-chunk-loading') { stdout = run(__dirname, [`--${flag.name}`, 'jsonp']).stdout; @@ -95,19 +91,12 @@ describe('output config related flag', () => { } else if (flag.name === 'output-enabled-library-types') { stdout = run(__dirname, [`--${flag.name}`, 'var']).stdout; - expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: [ 'var' ]`); } else if (flag.name === 'output-path') { expect(stdout).toContain('test'); } else if (flag.name === 'output-worker-chunk-loading') { stdout = run(__dirname, [`--${flag.name}`, 'async-node']).stdout; expect(stdout).toContain(`${propName}: 'async-node'`); - } else if (flag.name === 'output-worker-chunk-loading') { - stdout = run(__dirname, [`--${flag.name}`, 'async-node']).stdout; - expect(stdout).toContain(`${propName}: 'async-node'`); - } else if (flag.name === 'output-chunk-format') { - stdout = run(__dirname, [`--${flag.name}`, 'commonjs']).stdout; - expect(stdout).toContain(`${propName}: 'commonjs'`); } else if (flag.name.includes('wasm')) { stdout = run(__dirname, [`--${flag.name}`, 'async-node']).stdout; expect(stdout).toContain(`${propName}: 'async-node'`); diff --git a/yarn.lock b/yarn.lock index 2140c26d7a9..0f7675a01a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14,7 +14,7 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.1.tgz#d7386a689aa0ddf06255005b4b991988021101a0" integrity sha512-725AQupWJZ8ba0jbKceeFblZTY90McUBWMwHhkFQ9q1zKPJ95GUktljFcgcsIVwRnTnRKlcYzfiNImg5G9m6ZQ== -"@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.11.1", "@babel/core@^7.7.5": +"@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.12.3", "@babel/core@^7.7.5": version "7.12.3" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.3.tgz#1b436884e1e3bff6fb1328dc02b208759de92ad8" integrity sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g== @@ -775,7 +775,7 @@ "@babel/helper-create-regexp-features-plugin" "^7.12.1" "@babel/helper-plugin-utils" "^7.10.4" -"@babel/preset-env@^7.1.6", "@babel/preset-env@^7.11.0": +"@babel/preset-env@^7.1.6", "@babel/preset-env@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.1.tgz#9c7e5ca82a19efc865384bb4989148d2ee5d7ac2" integrity sha512-H8kxXmtPaAGT7TyBvSSkoSTUK6RHh61So05SyEbpmr0MCZrsNYn7mGMzzeYoOUCdHzww61k8XBft2TaES+xPLg== @@ -1076,6 +1076,22 @@ resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-11.0.0.tgz#719cf05fcc1abb6533610a2e0f5dd1e61eac14fe" integrity sha512-VoNqai1vR5anRF5Tuh/+SWDFk7xi7oMwHrHrbm1BprYXjB2RJsWLhUrStMssDxEl5lW/z3EUdg8RvH/IUBccSQ== +"@eslint/eslintrc@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" + integrity sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA== + dependencies: + ajv "^6.12.4" + debug "^4.1.1" + espree "^7.3.0" + globals "^12.1.0" + ignore "^4.0.6" + import-fresh "^3.2.1" + js-yaml "^3.13.1" + lodash "^4.17.19" + minimatch "^3.0.4" + strip-json-comments "^3.1.1" + "@evocateur/libnpmaccess@^3.1.2": version "3.1.2" resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845" @@ -1166,173 +1182,181 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd" integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw== -"@jest/console@^25.5.0": - version "25.5.0" - resolved "https://registry.yarnpkg.com/@jest/console/-/console-25.5.0.tgz#770800799d510f37329c508a9edd0b7b447d9abb" - integrity sha512-T48kZa6MK1Y6k4b89sexwmSF4YLeZS/Udqg3Jj3jG/cHH+N/sLFCEoXEDMOKugJQ9FxPN1osxIknvKkxt6MKyw== +"@jest/console@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-26.6.1.tgz#6a19eaac4aa8687b4db9130495817c65aec3d34e" + integrity sha512-cjqcXepwC5M+VeIhwT6Xpi/tT4AiNzlIx8SMJ9IihduHnsSrnWNvTBfKIpmqOOCNOPqtbBx6w2JqfoLOJguo8g== dependencies: - "@jest/types" "^25.5.0" - chalk "^3.0.0" - jest-message-util "^25.5.0" - jest-util "^25.5.0" + "@jest/types" "^26.6.1" + "@types/node" "*" + chalk "^4.0.0" + jest-message-util "^26.6.1" + jest-util "^26.6.1" slash "^3.0.0" -"@jest/core@^25.5.4": - version "25.5.4" - resolved "https://registry.yarnpkg.com/@jest/core/-/core-25.5.4.tgz#3ef7412f7339210f003cdf36646bbca786efe7b4" - integrity sha512-3uSo7laYxF00Dg/DMgbn4xMJKmDdWvZnf89n8Xj/5/AeQ2dOQmn6b6Hkj/MleyzZWXpwv+WSdYWl4cLsy2JsoA== +"@jest/core@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-26.6.1.tgz#77426822f667a2cda82bf917cee11cc8ba71f9ac" + integrity sha512-p4F0pgK3rKnoS9olXXXOkbus1Bsu6fd8pcvLMPsUy4CVXZ8WSeiwQ1lK5hwkCIqJ+amZOYPd778sbPha/S8Srw== dependencies: - "@jest/console" "^25.5.0" - "@jest/reporters" "^25.5.1" - "@jest/test-result" "^25.5.0" - "@jest/transform" "^25.5.1" - "@jest/types" "^25.5.0" + "@jest/console" "^26.6.1" + "@jest/reporters" "^26.6.1" + "@jest/test-result" "^26.6.1" + "@jest/transform" "^26.6.1" + "@jest/types" "^26.6.1" + "@types/node" "*" ansi-escapes "^4.2.1" - chalk "^3.0.0" + chalk "^4.0.0" exit "^0.1.2" graceful-fs "^4.2.4" - jest-changed-files "^25.5.0" - jest-config "^25.5.4" - jest-haste-map "^25.5.1" - jest-message-util "^25.5.0" - jest-regex-util "^25.2.6" - jest-resolve "^25.5.1" - jest-resolve-dependencies "^25.5.4" - jest-runner "^25.5.4" - jest-runtime "^25.5.4" - jest-snapshot "^25.5.1" - jest-util "^25.5.0" - jest-validate "^25.5.0" - jest-watcher "^25.5.0" + jest-changed-files "^26.6.1" + jest-config "^26.6.1" + jest-haste-map "^26.6.1" + jest-message-util "^26.6.1" + jest-regex-util "^26.0.0" + jest-resolve "^26.6.1" + jest-resolve-dependencies "^26.6.1" + jest-runner "^26.6.1" + jest-runtime "^26.6.1" + jest-snapshot "^26.6.1" + jest-util "^26.6.1" + jest-validate "^26.6.1" + jest-watcher "^26.6.1" micromatch "^4.0.2" p-each-series "^2.1.0" - realpath-native "^2.0.0" rimraf "^3.0.0" slash "^3.0.0" strip-ansi "^6.0.0" -"@jest/environment@^25.5.0": - version "25.5.0" - resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-25.5.0.tgz#aa33b0c21a716c65686638e7ef816c0e3a0c7b37" - integrity sha512-U2VXPEqL07E/V7pSZMSQCvV5Ea4lqOlT+0ZFijl/i316cRMHvZ4qC+jBdryd+lmRetjQo0YIQr6cVPNxxK87mA== +"@jest/create-cache-key-function@^26.5.0": + version "26.5.0" + resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-26.5.0.tgz#1d07947adc51ea17766d9f0ccf5a8d6ea94c47dc" + integrity sha512-DJ+pEBUIqarrbv1W/C39f9YH0rJ4wsXZ/VC6JafJPlHW2HOucKceeaqTOQj9MEDQZjySxMLkOq5mfXZXNZcmWw== + +"@jest/environment@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-26.6.1.tgz#38a56f1cc66f96bf53befcc5ebeaf1c2dce90e9a" + integrity sha512-GNvHwkOFJtNgSwdzH9flUPzF9AYAZhUg124CBoQcwcZCM9s5TLz8Y3fMtiaWt4ffbigoetjGk5PU2Dd8nLrSEw== dependencies: - "@jest/fake-timers" "^25.5.0" - "@jest/types" "^25.5.0" - jest-mock "^25.5.0" + "@jest/fake-timers" "^26.6.1" + "@jest/types" "^26.6.1" + "@types/node" "*" + jest-mock "^26.6.1" -"@jest/fake-timers@^25.5.0": - version "25.5.0" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-25.5.0.tgz#46352e00533c024c90c2bc2ad9f2959f7f114185" - integrity sha512-9y2+uGnESw/oyOI3eww9yaxdZyHq7XvprfP/eeoCsjqKYts2yRlsHS/SgjPDV8FyMfn2nbMy8YzUk6nyvdLOpQ== +"@jest/fake-timers@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-26.6.1.tgz#5aafba1822075b7142e702b906094bea15f51acf" + integrity sha512-T/SkMLgOquenw/nIisBRD6XAYpFir0kNuclYLkse5BpzeDUukyBr+K31xgAo9M0hgjU9ORlekAYPSzc0DKfmKg== dependencies: - "@jest/types" "^25.5.0" - jest-message-util "^25.5.0" - jest-mock "^25.5.0" - jest-util "^25.5.0" - lolex "^5.0.0" + "@jest/types" "^26.6.1" + "@sinonjs/fake-timers" "^6.0.1" + "@types/node" "*" + jest-message-util "^26.6.1" + jest-mock "^26.6.1" + jest-util "^26.6.1" -"@jest/globals@^25.5.2": - version "25.5.2" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-25.5.2.tgz#5e45e9de8d228716af3257eeb3991cc2e162ca88" - integrity sha512-AgAS/Ny7Q2RCIj5kZ+0MuKM1wbF0WMLxbCVl/GOMoCNbODRdJ541IxJ98xnZdVSZXivKpJlNPIWa3QmY0l4CXA== +"@jest/globals@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-26.6.1.tgz#b232c7611d8a2de62b4bf9eb9a007138322916f4" + integrity sha512-acxXsSguuLV/CeMYmBseefw6apO7NuXqpE+v5r3yD9ye2PY7h1nS20vY7Obk2w6S7eJO4OIAJeDnoGcLC/McEQ== dependencies: - "@jest/environment" "^25.5.0" - "@jest/types" "^25.5.0" - expect "^25.5.0" + "@jest/environment" "^26.6.1" + "@jest/types" "^26.6.1" + expect "^26.6.1" -"@jest/reporters@^25.5.1": - version "25.5.1" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-25.5.1.tgz#cb686bcc680f664c2dbaf7ed873e93aa6811538b" - integrity sha512-3jbd8pPDTuhYJ7vqiHXbSwTJQNavczPs+f1kRprRDxETeE3u6srJ+f0NPuwvOmk+lmunZzPkYWIFZDLHQPkviw== +"@jest/reporters@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-26.6.1.tgz#582ede05278cf5eeffe58bc519f4a35f54fbcb0d" + integrity sha512-J6OlXVFY3q1SXWJhjme5i7qT/BAZSikdOK2t8Ht5OS32BDo6KfG5CzIzzIFnAVd82/WWbc9Hb7SJ/jwSvVH9YA== dependencies: "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "^25.5.0" - "@jest/test-result" "^25.5.0" - "@jest/transform" "^25.5.1" - "@jest/types" "^25.5.0" - chalk "^3.0.0" + "@jest/console" "^26.6.1" + "@jest/test-result" "^26.6.1" + "@jest/transform" "^26.6.1" + "@jest/types" "^26.6.1" + chalk "^4.0.0" collect-v8-coverage "^1.0.0" exit "^0.1.2" glob "^7.1.2" graceful-fs "^4.2.4" istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^4.0.0" + istanbul-lib-instrument "^4.0.3" istanbul-lib-report "^3.0.0" istanbul-lib-source-maps "^4.0.0" istanbul-reports "^3.0.2" - jest-haste-map "^25.5.1" - jest-resolve "^25.5.1" - jest-util "^25.5.0" - jest-worker "^25.5.0" + jest-haste-map "^26.6.1" + jest-resolve "^26.6.1" + jest-util "^26.6.1" + jest-worker "^26.6.1" slash "^3.0.0" source-map "^0.6.0" - string-length "^3.1.0" + string-length "^4.0.1" terminal-link "^2.0.0" - v8-to-istanbul "^4.1.3" + v8-to-istanbul "^6.0.1" optionalDependencies: - node-notifier "^6.0.0" + node-notifier "^8.0.0" -"@jest/source-map@^25.5.0": - version "25.5.0" - resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-25.5.0.tgz#df5c20d6050aa292c2c6d3f0d2c7606af315bd1b" - integrity sha512-eIGx0xN12yVpMcPaVpjXPnn3N30QGJCJQSkEDUt9x1fI1Gdvb07Ml6K5iN2hG7NmMP6FDmtPEssE3z6doOYUwQ== +"@jest/source-map@^26.5.0": + version "26.5.0" + resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-26.5.0.tgz#98792457c85bdd902365cd2847b58fff05d96367" + integrity sha512-jWAw9ZwYHJMe9eZq/WrsHlwF8E3hM9gynlcDpOyCb9bR8wEd9ZNBZCi7/jZyzHxC7t3thZ10gO2IDhu0bPKS5g== dependencies: callsites "^3.0.0" graceful-fs "^4.2.4" source-map "^0.6.0" -"@jest/test-result@^25.5.0": - version "25.5.0" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-25.5.0.tgz#139a043230cdeffe9ba2d8341b27f2efc77ce87c" - integrity sha512-oV+hPJgXN7IQf/fHWkcS99y0smKLU2czLBJ9WA0jHITLst58HpQMtzSYxzaBvYc6U5U6jfoMthqsUlUlbRXs0A== +"@jest/test-result@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-26.6.1.tgz#d75698d8a06aa663e8936663778c831512330cc1" + integrity sha512-wqAgIerIN2gSdT2A8WeA5+AFh9XQBqYGf8etK143yng3qYd0mF0ie2W5PVmgnjw4VDU6ammI9NdXrKgNhreawg== dependencies: - "@jest/console" "^25.5.0" - "@jest/types" "^25.5.0" + "@jest/console" "^26.6.1" + "@jest/types" "^26.6.1" "@types/istanbul-lib-coverage" "^2.0.0" collect-v8-coverage "^1.0.0" -"@jest/test-sequencer@^25.5.4": - version "25.5.4" - resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-25.5.4.tgz#9b4e685b36954c38d0f052e596d28161bdc8b737" - integrity sha512-pTJGEkSeg1EkCO2YWq6hbFvKNXk8ejqlxiOg1jBNLnWrgXOkdY6UmqZpwGFXNnRt9B8nO1uWMzLLZ4eCmhkPNA== +"@jest/test-sequencer@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-26.6.1.tgz#34216ac2c194b0eeebde30d25424d1134703fd2e" + integrity sha512-0csqA/XApZiNeTIPYh6koIDCACSoR6hi29T61tKJMtCZdEC+tF3PoNt7MS0oK/zKC6daBgCbqXxia5ztr/NyCQ== dependencies: - "@jest/test-result" "^25.5.0" + "@jest/test-result" "^26.6.1" graceful-fs "^4.2.4" - jest-haste-map "^25.5.1" - jest-runner "^25.5.4" - jest-runtime "^25.5.4" + jest-haste-map "^26.6.1" + jest-runner "^26.6.1" + jest-runtime "^26.6.1" -"@jest/transform@^25.5.1": - version "25.5.1" - resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-25.5.1.tgz#0469ddc17699dd2bf985db55fa0fb9309f5c2db3" - integrity sha512-Y8CEoVwXb4QwA6Y/9uDkn0Xfz0finGkieuV0xkdF9UtZGJeLukD5nLkaVrVsODB1ojRWlaoD0AJZpVHCSnJEvg== +"@jest/transform@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-26.6.1.tgz#f70786f96e0f765947b4fb4f54ffcfb7bd783711" + integrity sha512-oNFAqVtqRxZRx6vXL3I4bPKUK0BIlEeaalkwxyQGGI8oXDQBtYQBpiMe5F7qPs4QdvvFYB42gPGIMMcxXaBBxQ== dependencies: "@babel/core" "^7.1.0" - "@jest/types" "^25.5.0" + "@jest/types" "^26.6.1" babel-plugin-istanbul "^6.0.0" - chalk "^3.0.0" + chalk "^4.0.0" convert-source-map "^1.4.0" fast-json-stable-stringify "^2.0.0" graceful-fs "^4.2.4" - jest-haste-map "^25.5.1" - jest-regex-util "^25.2.6" - jest-util "^25.5.0" + jest-haste-map "^26.6.1" + jest-regex-util "^26.0.0" + jest-util "^26.6.1" micromatch "^4.0.2" pirates "^4.0.1" - realpath-native "^2.0.0" slash "^3.0.0" source-map "^0.6.1" write-file-atomic "^3.0.0" -"@jest/types@^25.5.0": - version "25.5.0" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-25.5.0.tgz#4d6a4793f7b9599fc3680877b856a97dbccf2a9d" - integrity sha512-OXD0RgQ86Tu3MazKo8bnrkDRaDXXMGUqd+kTtLtK1Zb7CRzQcaSRPPPV37SvYTdevXEBVxe0HXylEjs8ibkmCw== +"@jest/types@^26.6.1": + version "26.6.1" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.1.tgz#2638890e8031c0bc8b4681e0357ed986e2f866c5" + integrity sha512-ywHavIKNpAVrStiRY5wiyehvcktpijpItvGiK72RAn5ctqmzvPk8OvKnvHeBqa1XdQr959CTWAJMqxI8BTibyg== dependencies: "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^1.1.1" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" "@types/yargs" "^15.0.0" - chalk "^3.0.0" + chalk "^4.0.0" "@lerna/add@3.21.0": version "3.21.0" @@ -2217,7 +2241,7 @@ dependencies: defer-to-connect "^2.0.0" -"@types/babel__core@^7.1.7": +"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7": version "7.1.10" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.10.tgz#ca58fc195dd9734e77e57c6f2df565623636ab40" integrity sha512-x8OM8XzITIMyiwl5Vmo2B1cR1S1Ipkyv4mdlbJjMa1lmuKvKY9FrBbEANIaMlnWn5Rf7uO+rC/VgYabNkE17Hw== @@ -2243,7 +2267,7 @@ "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" -"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": +"@types/babel__traverse@*", "@types/babel__traverse@^7.0.4", "@types/babel__traverse@^7.0.6": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.0.15.tgz#db9e4238931eb69ef8aab0ad6523d4d4caa39d03" integrity sha512-Pzh9O3sTK8V6I1olsXpCfj2k/ygO2q1X0vhhnDrEQyYLHZesWz+zMZMVcwXLCYf0U36EtmyYaFGPfXlTtDHe3A== @@ -2260,7 +2284,7 @@ "@types/node" "*" "@types/responselike" "*" -"@types/cross-spawn@^6.0.1", "@types/cross-spawn@^6.0.2": +"@types/cross-spawn@^6.0.2": version "6.0.2" resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.2.tgz#168309de311cd30a2b8ae720de6475c2fbf33ac7" integrity sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw== @@ -2370,21 +2394,20 @@ dependencies: "@types/istanbul-lib-coverage" "*" -"@types/istanbul-reports@^1.1.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz#e875cc689e47bce549ec81f3df5e6f6f11cfaeb2" - integrity sha512-P/W9yOX/3oPZSpaYOCQzGqgCQRXn0FFO/V8bWrCQs+wLmvVVxk6CRBXALEvNs9OHIatlnlFokfhuDo2ug01ciw== +"@types/istanbul-reports@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.0.tgz#508b13aa344fa4976234e75dddcc34925737d821" + integrity sha512-nwKNbvnwJ2/mndE9ItP/zc2TCzw6uuodnF4EHYWD+gCQDVBuRQL5UzbZD0/ezy1iKsFU2ZQiDqg4M9dN4+wZgA== dependencies: - "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" -"@types/jest@^25.1.4": - version "25.2.3" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-25.2.3.tgz#33d27e4c4716caae4eced355097a47ad363fdcaf" - integrity sha512-JXc1nK/tXHiDhV55dvfzqtmP4S3sy3T3ouV2tkViZgxY/zeUkcpQcQPGRlgF4KmWzWW5oiWYSZwtCB+2RsE4Fw== +"@types/jest@26.x", "@types/jest@^26.0.15": + version "26.0.15" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe" + integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog== dependencies: - jest-diff "^25.2.1" - pretty-format "^25.2.1" + jest-diff "^26.0.0" + pretty-format "^26.0.0" "@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.6": version "7.0.6" @@ -2448,10 +2471,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.8.tgz#fe2012f2355e4ce08bca44aeb3abbb21cf88d33f" integrity sha512-KPcKqKm5UKDkaYPTuXSx8wEP7vE9GnuaXIZKijwRYcePpZFDVuy2a57LarFKiORbHOuTOOwYzxVxcUzsh2P2Pw== -"@types/node@13.9.8": - version "13.9.8" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.8.tgz#09976420fc80a7a00bf40680c63815ed8c7616f4" - integrity sha512-1WgO8hsyHynlx7nhP1kr0OFzsgKz5XDQL+Lfc3b1Q3qIln/n8cKD4m09NJ0+P1Rq7Zgnc7N0+SsMnoD1rEb0kA== +"@types/node@^14.14.5": + version "14.14.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.5.tgz#e92d3b8f76583efa26c1a63a21c9d3c1143daa29" + integrity sha512-H5Wn24s/ZOukBmDn03nnGTp18A60ny9AmCwnEcgJiTgSGsCO7k+NWP7zjCCbhlcnVCoI+co52dUAt9GMhOSULw== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -2468,10 +2491,10 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.0.tgz#a2502fb7ce9b6626fdbfc2e2a496f472de1bdd05" integrity sha512-gDE8JJEygpay7IjA/u3JiIURvwZW08f0cZSZLAzFoX/ZmeqvS0Sqv+97aKuHpNsalAMMhwPe+iAS6fQbfmbt7A== -"@types/prettier@^1.19.0": - version "1.19.1" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.1.tgz#33509849f8e679e4add158959fdb086440e9553f" - integrity sha512-5qOlnZscTn4xxM5MeGXAMOsIOIKIbh9e85zJWfBRVPlRMEVawzoPhINYbRGkBZCI8LxvBe7tJCdWiarA99OZfQ== +"@types/prettier@^2.0.0": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.5.tgz#b6ab3bba29e16b821d84e09ecfaded462b816b00" + integrity sha512-UEyp8LwZ4Dg30kVU2Q3amHHyTn1jEdhCIE59ANed76GaT1Vp76DD3ZWSAxgCrw6wJ0TqeoBpqmfUHiUDPs//HQ== "@types/responselike@*": version "1.0.0" @@ -2480,10 +2503,10 @@ dependencies: "@types/node" "*" -"@types/stack-utils@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" - integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== +"@types/stack-utils@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff" + integrity sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw== "@types/text-table@*": version "0.2.1" @@ -2774,7 +2797,7 @@ JSONStream@^1.0.4, JSONStream@^1.2.1, JSONStream@^1.3.4, JSONStream@^1.3.5: jsonparse "^1.2.0" through ">=2.2.7 <3" -abab@^2.0.0: +abab@^2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a" integrity sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q== @@ -2792,35 +2815,25 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7: mime-types "~2.1.24" negotiator "0.6.2" -acorn-globals@^4.3.2: - version "4.3.4" - resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.3.4.tgz#9fa1926addc11c97308c4e66d7add0d40c3272e7" - integrity sha512-clfQEh21R+D0leSbUdWf3OcfqyaCSAQ8Ryq00bofSekfr9W8u1jyYZo6ir0xu9Gtcf7BjcHJpnbZH7JOCpP60A== +acorn-globals@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-6.0.0.tgz#46cdd39f0f8ff08a876619b55f5ac8a6dc770b45" + integrity sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg== dependencies: - acorn "^6.0.1" - acorn-walk "^6.0.1" + acorn "^7.1.1" + acorn-walk "^7.1.1" acorn-jsx@^5.2.0: version "5.3.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b" integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng== -acorn-walk@^6.0.1: - version "6.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.2.0.tgz#123cb8f3b84c2171f1f7fb252615b1c78a6b1a8c" - integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA== - acorn-walk@^7.1.1: version "7.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== -acorn@^6.0.1: - version "6.4.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6" - integrity sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ== - -acorn@^7.1.0, acorn@^7.1.1: +acorn@^7.1.1, acorn@^7.4.0: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== @@ -2869,7 +2882,7 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.5: +ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -3031,11 +3044,6 @@ array-differ@^3.0.0: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== -array-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" - integrity sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM= - array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" @@ -3190,17 +3198,17 @@ babel-core@^7.0.0-bridge.0: resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg== -babel-jest@^25.5.1: - version "25.5.1" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-25.5.1.tgz#bc2e6101f849d6f6aec09720ffc7bc5332e62853" - integrity sha512-9dA9+GmMjIzgPnYtkhBg73gOo/RHqPmLruP3BaGL4KEX3Dwz6pI8auSN8G8+iuEG90+GSswyKvslN+JYSaacaQ== +babel-jest@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.6.1.tgz#07bd7bec14de47fe0f2c9a139741329f1f41788b" + integrity sha512-duMWEOKrSBYRVTTNpL2SipNIWnZOjP77auOBMPQ3zXAdnDbyZQWU8r/RxNWpUf9N6cgPFecQYelYLytTVXVDtA== dependencies: - "@jest/transform" "^25.5.1" - "@jest/types" "^25.5.0" + "@jest/transform" "^26.6.1" + "@jest/types" "^26.6.1" "@types/babel__core" "^7.1.7" babel-plugin-istanbul "^6.0.0" - babel-preset-jest "^25.5.0" - chalk "^3.0.0" + babel-preset-jest "^26.5.0" + chalk "^4.0.0" graceful-fs "^4.2.4" slash "^3.0.0" @@ -3222,16 +3230,17 @@ babel-plugin-istanbul@^6.0.0: istanbul-lib-instrument "^4.0.0" test-exclude "^6.0.0" -babel-plugin-jest-hoist@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-25.5.0.tgz#129c80ba5c7fc75baf3a45b93e2e372d57ca2677" - integrity sha512-u+/W+WAjMlvoocYGTwthAiQSxDcJAyHpQ6oWlHdFZaaN+Rlk8Q7iiwDPg2lN/FyJtAYnKjFxbn7xus4HCFkg5g== +babel-plugin-jest-hoist@^26.5.0: + version "26.5.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-26.5.0.tgz#3916b3a28129c29528de91e5784a44680db46385" + integrity sha512-ck17uZFD3CDfuwCLATWZxkkuGGFhMij8quP8CNhwj8ek1mqFgbFzRJ30xwC04LLscj/aKsVFfRST+b5PT7rSuw== dependencies: "@babel/template" "^7.3.3" "@babel/types" "^7.3.3" + "@types/babel__core" "^7.0.0" "@types/babel__traverse" "^7.0.6" -babel-preset-current-node-syntax@^0.1.2: +babel-preset-current-node-syntax@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.4.tgz#826f1f8e7245ad534714ba001f84f7e906c3b615" integrity sha512-5/INNCYhUGqw7VbVjT/hb3ucjgkVHKXY7lX3ZjlN4gm565VyFmJUrJ/h+h16ECVB38R/9SF6aACydpKMLZ/c9w== @@ -3248,13 +3257,13 @@ babel-preset-current-node-syntax@^0.1.2: "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" "@babel/plugin-syntax-optional-chaining" "^7.8.3" -babel-preset-jest@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-25.5.0.tgz#c1d7f191829487a907764c65307faa0e66590b49" - integrity sha512-8ZczygctQkBU+63DtSOKGh7tFL0CeCuz+1ieud9lJ1WPQ9O6A1a/r+LGn6Y705PA6whHQ3T1XuB/PmpfNYf8Fw== +babel-preset-jest@^26.5.0: + version "26.5.0" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-26.5.0.tgz#f1b166045cd21437d1188d29f7fba470d5bdb0e7" + integrity sha512-F2vTluljhqkiGSJGBg/jOruA8vIIIL11YrxRcO7nviNTMbbofPSHwnm8mgP7d/wS7wRSexRoI6X1A6T74d4LQA== dependencies: - babel-plugin-jest-hoist "^25.5.0" - babel-preset-current-node-syntax "^0.1.2" + babel-plugin-jest-hoist "^26.5.0" + babel-preset-current-node-syntax "^0.1.3" balanced-match@^1.0.0: version "1.0.0" @@ -3387,13 +3396,6 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browser-resolve@^1.11.3: - version "1.11.3" - resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.3.tgz#9b7cbb3d0f510e4cb86bdbd796124d28b5890af6" - integrity sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ== - dependencies: - resolve "1.1.7" - browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4.8.5: version "4.14.5" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.5.tgz#1c751461a102ddc60e40993639b709be7f2c4015" @@ -3585,6 +3587,11 @@ camelcase@^5.0.0, camelcase@^5.3.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== +camelcase@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.1.0.tgz#27dc176173725fb0adf8a48b647f4d7871944d78" + integrity sha512-WCMml9ivU60+8rEJgELlFp1gxFcEGxwYleE3bziHEDeqsqAWGHdimB7beBFGjLzVNgPGyDsfgXLQEYMpmIFnVQ== + caniuse-lite@^1.0.30001135: version "1.0.30001148" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001148.tgz#dc97c7ed918ab33bf8706ddd5e387287e015d637" @@ -3626,7 +3633,7 @@ chalk@^1.0.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.1, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.1, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3635,13 +3642,10 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.1, chalk@^2.4.1, chalk@^2.4 escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" +char-regex@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" + integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== chardet@^0.7.0: version "0.7.0" @@ -3689,6 +3693,11 @@ ci-info@^2.0.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== +cjs-module-lexer@^0.4.2: + version "0.4.3" + resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.4.3.tgz#9e31f7fe701f5fcee5793f77ab4e58fa8dcde8bc" + integrity sha512-5RLK0Qfs0PNDpEyBXIr3bIT1Muw3ojSlvpw6dAmkUcO0+uTrsBn7GuEIgx40u+OzbCBLDta7nvmud85P4EmTsQ== + class-utils@^0.3.5: version "0.3.6" resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" @@ -3751,15 +3760,6 @@ cli-width@^3.0.0: resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw== -cliui@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" - integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ== - dependencies: - string-width "^2.1.1" - strip-ansi "^4.0.0" - wrap-ansi "^2.0.0" - cliui@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" @@ -4207,7 +4207,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -4216,7 +4216,7 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -cssom@^0.4.1: +cssom@^0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10" integrity sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw== @@ -4226,7 +4226,7 @@ cssom@~0.3.6: resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a" integrity sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg== -cssstyle@^2.0.0: +cssstyle@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-2.3.0.tgz#ff665a0ddbdc31864b09647f34163443d90b0852" integrity sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A== @@ -4281,14 +4281,14 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -data-urls@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-1.1.0.tgz#15ee0582baa5e22bb59c77140da8f9c76963bbfe" - integrity sha512-YTWYI9se1P55u58gL5GkQHW4P6VJBJ5iBT+B5a7i2Tjadhv52paJG0qHX4A0OR6/t52odI64KP2YvFpkDOi3eQ== +data-urls@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-2.0.0.tgz#156485a72963a970f5d5821aaf642bef2bf2db9b" + integrity sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ== dependencies: - abab "^2.0.0" - whatwg-mimetype "^2.2.0" - whatwg-url "^7.0.0" + abab "^2.0.3" + whatwg-mimetype "^2.3.0" + whatwg-url "^8.0.0" date-fns@^1.27.2: version "1.30.1" @@ -4346,6 +4346,11 @@ decamelize@^1.1.0, decamelize@^1.1.2, decamelize@^1.2.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= +decimal.js@^10.2.0: + version "10.2.1" + resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.2.1.tgz#238ae7b0f0c793d3e3cea410108b35a2c01426a3" + integrity sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw== + decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" @@ -4380,7 +4385,7 @@ deep-extend@^0.6.0, deep-extend@~0.6.0: resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== -deep-is@~0.1.3: +deep-is@^0.1.3, deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= @@ -4527,10 +4532,10 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" -diff-sequences@^25.2.6: - version "25.2.6" - resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-25.2.6.tgz#5f467c00edd35352b7bca46d7927d60e687a76dd" - integrity sha512-Hq8o7+6GaZeoFjtpgvRBUknSXNeJiCx7V9Fr94ZMljNiCr9n9L8H8aJqgWOQiDDGdyn29fRNcDdRVJ5fdyihfg== +diff-sequences@^26.5.0: + version "26.5.0" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.5.0.tgz#ef766cf09d43ed40406611f11c6d8d9dd8b2fefd" + integrity sha512-ZXx86srb/iYy6jG71k++wBN9P9J05UNQ5hQHQd9MtMPvcqXPx/vKU69jfHV637D00Q2gSgPk2D+jSx3l1lDW/Q== diff@^3.5.0: version "3.5.0" @@ -4591,12 +4596,12 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -domexception@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90" - integrity sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug== +domexception@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/domexception/-/domexception-2.0.1.tgz#fb44aefba793e1574b0af6aed2801d057529f304" + integrity sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg== dependencies: - webidl-conversions "^4.0.2" + webidl-conversions "^5.0.0" dot-prop@^4.2.0: version "4.2.1" @@ -4689,6 +4694,11 @@ elegant-spinner@^1.0.1: resolved "https://registry.yarnpkg.com/elegant-spinner/-/elegant-spinner-1.0.1.tgz#db043521c95d7e303fd8f345bedc3349cfb0729e" integrity sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4= +emittery@^0.7.1: + version "0.7.2" + resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.7.2.tgz#25595908e13af0f5674ab419396e2fb394cdfa82" + integrity sha512-A8OG5SR/ij3SsJdWDJdkkSYUjQdCUx6APQXem0SaEePBSRg4eymGYwBkKo1Y6DU+af/Jn2dBQqDBvjnr9Vi8nQ== + emoji-regex@^7.0.1: version "7.0.3" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" @@ -4718,15 +4728,15 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" -enhanced-resolve@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.3.0.tgz#14be504e14ad58e9821a311ea6a9037c716786d9" - integrity sha512-EENz3E701+77g0wfbOITeI8WLPNso2kQNMBIBEi/TH/BEa9YXtS01X7sIEk5XXsfFq1jNkhIpu08hBPH1TRLIQ== +enhanced-resolve@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.3.1.tgz#3f988d0d7775bdc2d96ede321dc81f8249492f57" + integrity sha512-G1XD3MRGrGfNcf6Hg0LVZG7GIKcYkbfHa5QMxt1HDUTdYoXH0JR1xXyg+MaKLF73E9A27uWNVxvFivNRYeUB6w== dependencies: graceful-fs "^4.2.4" tapable "^2.0.0" -enquirer@^2.3.4, enquirer@^2.3.6: +enquirer@^2.3.4, enquirer@^2.3.5, enquirer@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== @@ -4845,7 +4855,12 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -escodegen@^1.11.1: +escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== + +escodegen@^1.14.1: version "1.14.3" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503" integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw== @@ -4857,10 +4872,10 @@ escodegen@^1.11.1: optionalDependencies: source-map "~0.6.1" -eslint-config-prettier@^6.11.0: - version "6.14.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.14.0.tgz#390e7863a8ae99970981933826476169285b3a27" - integrity sha512-DbVwh0qZhAC7CNDWcq8cBdK6FcVHiMTKmCypOPWeZkp9hJ8xYwTaWSa6bb6cjfi8KOeJy0e9a8Izxyx+O4+gCQ== +eslint-config-prettier@^6.15.0: + version "6.15.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.15.0.tgz#7f93f6cb7d45a92f1537a70ecc06366e1ac6fed9" + integrity sha512-a1+kOYLR8wMGustcgAjdydMsQ2A/2ipRPwRKUmfYaSxc9ZPcrku080Ctl6zrZzZNs/U82MjSv+qKREkoq3bJaw== dependencies: get-stdin "^6.0.0" @@ -4899,41 +4914,41 @@ eslint-scope@^5.0.0, eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-utils@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" - integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== - dependencies: - eslint-visitor-keys "^1.1.0" - -eslint-utils@^2.0.0: +eslint-utils@^2.0.0, eslint-utils@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== dependencies: eslint-visitor-keys "^1.1.0" -eslint-visitor-keys@^1.1.0: +eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== -eslint@^6.8.0: - version "6.8.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb" - integrity sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig== +eslint-visitor-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" + integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== + +eslint@^7.12.1: + version "7.12.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.12.1.tgz#bd9a81fa67a6cfd51656cdb88812ce49ccec5801" + integrity sha512-HlMTEdr/LicJfN08LB3nM1rRYliDXOmfoO4vj39xN6BLpFzF00hbwBoqHk8UcJ2M/3nlARZWy/mslvGEuZFvsg== dependencies: "@babel/code-frame" "^7.0.0" + "@eslint/eslintrc" "^0.2.1" ajv "^6.10.0" - chalk "^2.1.0" - cross-spawn "^6.0.5" + chalk "^4.0.0" + cross-spawn "^7.0.2" debug "^4.0.1" doctrine "^3.0.0" - eslint-scope "^5.0.0" - eslint-utils "^1.4.3" - eslint-visitor-keys "^1.1.0" - espree "^6.1.2" - esquery "^1.0.1" + enquirer "^2.3.5" + eslint-scope "^5.1.1" + eslint-utils "^2.1.0" + eslint-visitor-keys "^2.0.0" + espree "^7.3.0" + esquery "^1.2.0" esutils "^2.0.2" file-entry-cache "^5.0.1" functional-red-black-tree "^1.0.1" @@ -4942,40 +4957,38 @@ eslint@^6.8.0: ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^7.0.0" is-glob "^4.0.0" js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.3.0" - lodash "^4.17.14" + levn "^0.4.1" + lodash "^4.17.19" minimatch "^3.0.4" - mkdirp "^0.5.1" natural-compare "^1.4.0" - optionator "^0.8.3" + optionator "^0.9.1" progress "^2.0.0" - regexpp "^2.0.1" - semver "^6.1.2" - strip-ansi "^5.2.0" - strip-json-comments "^3.0.1" + regexpp "^3.1.0" + semver "^7.2.1" + strip-ansi "^6.0.0" + strip-json-comments "^3.1.0" table "^5.2.3" text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^6.1.2: - version "6.2.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a" - integrity sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw== +espree@^7.3.0: + version "7.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" + integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw== dependencies: - acorn "^7.1.1" + acorn "^7.4.0" acorn-jsx "^5.2.0" - eslint-visitor-keys "^1.1.0" + eslint-visitor-keys "^1.3.0" esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.0.1: +esquery@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== @@ -5049,10 +5062,10 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execa@^3.2.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-3.4.0.tgz#c08ed4550ef65d858fac269ffc8572446f37eb89" - integrity sha512-r9vdGQk4bmCuK1yKQu1KTwcT2zwfWdbdaXfCtAh+5nU/4fSX+JAb7vZGvI5naJrQlvONrEB20jeruESI69530g== +execa@^4.0.0, execa@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/execa/-/execa-4.0.3.tgz#0a34dabbad6d66100bd6f2c576c8669403f317f2" + integrity sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A== dependencies: cross-spawn "^7.0.0" get-stream "^5.0.0" @@ -5061,14 +5074,13 @@ execa@^3.2.0: merge-stream "^2.0.0" npm-run-path "^4.0.0" onetime "^5.1.0" - p-finally "^2.0.0" signal-exit "^3.0.2" strip-final-newline "^2.0.0" -execa@^4.0.0, execa@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/execa/-/execa-4.0.3.tgz#0a34dabbad6d66100bd6f2c576c8669403f317f2" - integrity sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A== +execa@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" + integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== dependencies: cross-spawn "^7.0.0" get-stream "^5.0.0" @@ -5105,17 +5117,17 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -expect@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/expect/-/expect-25.5.0.tgz#f07f848712a2813bb59167da3fb828ca21f58bba" - integrity sha512-w7KAXo0+6qqZZhovCaBVPSIqQp7/UTcx4M9uKt2m6pd2VB1voyC8JizLRqeEqud3AAVP02g+hbErDu5gu64tlA== +expect@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/expect/-/expect-26.6.1.tgz#e1e053cdc43b21a452b36fc7cc9401e4603949c1" + integrity sha512-BRfxIBHagghMmr1D2MRY0Qv5d3Nc8HCqgbDwNXw/9izmM5eBb42a2YjLKSbsqle76ozGkAEPELQX4IdNHAKRNA== dependencies: - "@jest/types" "^25.5.0" + "@jest/types" "^26.6.1" ansi-styles "^4.0.0" - jest-get-type "^25.2.6" - jest-matcher-utils "^25.5.0" - jest-message-util "^25.5.0" - jest-regex-util "^25.2.6" + jest-get-type "^26.3.0" + jest-matcher-utils "^26.6.1" + jest-message-util "^26.6.1" + jest-regex-util "^26.0.0" express@^4.16.3, express@^4.17.1: version "4.17.1" @@ -5245,7 +5257,7 @@ fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -fast-levenshtein@~2.0.6: +fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= @@ -5617,11 +5629,6 @@ gensync@^1.0.0-beta.1: resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269" integrity sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg== -get-caller-file@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" - integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== - get-caller-file@^2.0.1: version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" @@ -5712,7 +5719,7 @@ gh-got@^5.0.0: got "^6.2.0" is-plain-obj "^1.1.0" -git-cz@^4.7.0: +git-cz@^4.7.1: version "4.7.1" resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.1.tgz#90edaa8dba1ec8be689b22fbf8d006c44b21b31f" integrity sha512-Emb/Xz/LcL3SGxA/PD6RUrhUT6m2v0O9nWTjwCBAoE2UXxj9HkJcfphL3RkePtiTNFkVZMk0q5EUfHnO7HAfiw== @@ -6125,14 +6132,14 @@ hpack.js@^2.1.6: readable-stream "^2.0.1" wbuf "^1.1.0" -html-encoding-sniffer@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz#e70d84b94da53aa375e11fe3a351be6642ca46f8" - integrity sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw== +html-encoding-sniffer@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz#42a6dc4fd33f00281176e8b23759ca4e4fa185f3" + integrity sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ== dependencies: - whatwg-encoding "^1.0.1" + whatwg-encoding "^1.0.5" -html-entities@^1.2.1: +html-entities@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.3.1.tgz#fb9a1a4b5b14c5daba82d3e34c6ae4fe701a0e44" integrity sha512-rhE/4Z3hIhzHAUKbW8jVcCyuT5oJCXXqhN/6mXXVCpzTmvJnoH2HL/bt3EZ6p55jbFJBeAe1ZNpL5BugLujxNA== @@ -6250,7 +6257,7 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" -husky@^4.2.5: +husky@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.0.tgz#0b2ec1d66424e9219d359e26a51c58ec5278f0de" integrity sha512-tTMeLCLqSBqnflBZnlVDhpaIMucSGaYyX6855jM4AguGeWCeSzNdb1mfyWduTZ3pe3SJVvVWGL0jO1iKZVPfTA== @@ -6429,7 +6436,7 @@ inquirer@^6.2.0, inquirer@^6.3.1: strip-ansi "^5.1.0" through "^2.3.6" -inquirer@^7.0.0, inquirer@^7.1.0: +inquirer@^7.1.0: version "7.3.3" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003" integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA== @@ -6466,11 +6473,6 @@ interpret@^2.0.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== -invert-kv@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" - integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== - ip-regex@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9" @@ -6544,6 +6546,13 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" +is-core-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.0.0.tgz#58531b70aed1db7c0e8d4eb1a0a2d1ddd64bd12d" + integrity sha512-jq1AH6C8MuteOoBPwkxHafmByhL9j5q4OaPGdbuD+ZtQJVzH+i6E3BJDQcBA09k57i2Hh2yQbEG8yObZ0jdlWw== + dependencies: + has "^1.0.3" + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -6724,6 +6733,11 @@ is-plain-object@^5.0.0: resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== +is-potential-custom-element-name@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz#0c52e54bcca391bb2c494b21e8626d7336c6e397" + integrity sha1-DFLlS8yjkbssSUsh6GJtczbG45c= + is-promise@^2.1.0: version "2.2.2" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.2.2.tgz#39ab959ccbf9a774cf079f7b40c7a26f763135f1" @@ -6809,7 +6823,7 @@ is-wsl@^1.1.0: resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= -is-wsl@^2.1.1: +is-wsl@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== @@ -6858,7 +6872,7 @@ istanbul-lib-coverage@^3.0.0: resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz#f5944a37c70b550b02a78a5c3b2055b280cec8ec" integrity sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg== -istanbul-lib-instrument@^4.0.0: +istanbul-lib-instrument@^4.0.0, istanbul-lib-instrument@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz#873c6fff897450118222774696a3f28902d77c1d" integrity sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ== @@ -6913,299 +6927,292 @@ jake@^10.6.1: filelist "^1.0.1" minimatch "^3.0.4" -jest-changed-files@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-25.5.0.tgz#141cc23567ceb3f534526f8614ba39421383634c" - integrity sha512-EOw9QEqapsDT7mKF162m8HFzRPbmP8qJQny6ldVOdOVBz3ACgPm/1nAn5fPQ/NDaYhX/AHkrGwwkCncpAVSXcw== +jest-changed-files@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-26.6.1.tgz#2fac3dc51297977ee883347948d8e3d37c417fba" + integrity sha512-NhSdZ5F6b/rIN5V46x1l31vrmukD/bJUXgYAY8VtP1SknYdJwjYDRxuLt7Z8QryIdqCjMIn2C0Cd98EZ4umo8Q== dependencies: - "@jest/types" "^25.5.0" - execa "^3.2.0" + "@jest/types" "^26.6.1" + execa "^4.0.0" throat "^5.0.0" -jest-cli@^25.5.4: - version "25.5.4" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-25.5.4.tgz#b9f1a84d1301a92c5c217684cb79840831db9f0d" - integrity sha512-rG8uJkIiOUpnREh1768/N3n27Cm+xPFkSNFO91tgg+8o2rXeVLStz+vkXkGr4UtzH6t1SNbjwoiswd7p4AhHTw== +jest-cli@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-26.6.1.tgz#8952242fa812c05bd129abf7c022424045b7fd67" + integrity sha512-aPLoEjlwFrCWhiPpW5NUxQA1X1kWsAnQcQ0SO/fHsCvczL3W75iVAcH9kP6NN+BNqZcHNEvkhxT5cDmBfEAh+w== dependencies: - "@jest/core" "^25.5.4" - "@jest/test-result" "^25.5.0" - "@jest/types" "^25.5.0" - chalk "^3.0.0" + "@jest/core" "^26.6.1" + "@jest/test-result" "^26.6.1" + "@jest/types" "^26.6.1" + chalk "^4.0.0" exit "^0.1.2" graceful-fs "^4.2.4" import-local "^3.0.2" is-ci "^2.0.0" - jest-config "^25.5.4" - jest-util "^25.5.0" - jest-validate "^25.5.0" + jest-config "^26.6.1" + jest-util "^26.6.1" + jest-validate "^26.6.1" prompts "^2.0.1" - realpath-native "^2.0.0" - yargs "^15.3.1" + yargs "^15.4.1" -jest-config@^25.5.4: - version "25.5.4" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-25.5.4.tgz#38e2057b3f976ef7309b2b2c8dcd2a708a67f02c" - integrity sha512-SZwR91SwcdK6bz7Gco8qL7YY2sx8tFJYzvg216DLihTWf+LKY/DoJXpM9nTzYakSyfblbqeU48p/p7Jzy05Atg== +jest-config@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-26.6.1.tgz#8c343fbdd9c24ad003e261f73583c3c020f32b42" + integrity sha512-mtJzIynIwW1d1nMlKCNCQiSgWaqFn8cH/fOSNY97xG7Y9tBCZbCSuW2GTX0RPmceSJGO7l27JgwC18LEg0Vg+g== dependencies: "@babel/core" "^7.1.0" - "@jest/test-sequencer" "^25.5.4" - "@jest/types" "^25.5.0" - babel-jest "^25.5.1" - chalk "^3.0.0" + "@jest/test-sequencer" "^26.6.1" + "@jest/types" "^26.6.1" + babel-jest "^26.6.1" + chalk "^4.0.0" deepmerge "^4.2.2" glob "^7.1.1" graceful-fs "^4.2.4" - jest-environment-jsdom "^25.5.0" - jest-environment-node "^25.5.0" - jest-get-type "^25.2.6" - jest-jasmine2 "^25.5.4" - jest-regex-util "^25.2.6" - jest-resolve "^25.5.1" - jest-util "^25.5.0" - jest-validate "^25.5.0" + jest-environment-jsdom "^26.6.1" + jest-environment-node "^26.6.1" + jest-get-type "^26.3.0" + jest-jasmine2 "^26.6.1" + jest-regex-util "^26.0.0" + jest-resolve "^26.6.1" + jest-util "^26.6.1" + jest-validate "^26.6.1" micromatch "^4.0.2" - pretty-format "^25.5.0" - realpath-native "^2.0.0" + pretty-format "^26.6.1" -jest-diff@^25.2.1, jest-diff@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-25.5.0.tgz#1dd26ed64f96667c068cef026b677dfa01afcfa9" - integrity sha512-z1kygetuPiREYdNIumRpAHY6RXiGmp70YHptjdaxTWGmA085W3iCnXNx0DhflK3vwrKmrRWyY1wUpkPMVxMK7A== +jest-diff@^26.0.0, jest-diff@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.1.tgz#38aa194979f454619bb39bdee299fb64ede5300c" + integrity sha512-BBNy/zin2m4kG5In126O8chOBxLLS/XMTuuM2+YhgyHk87ewPzKTuTJcqj3lOWOi03NNgrl+DkMeV/exdvG9gg== dependencies: - chalk "^3.0.0" - diff-sequences "^25.2.6" - jest-get-type "^25.2.6" - pretty-format "^25.5.0" + chalk "^4.0.0" + diff-sequences "^26.5.0" + jest-get-type "^26.3.0" + pretty-format "^26.6.1" -jest-docblock@^25.3.0: - version "25.3.0" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-25.3.0.tgz#8b777a27e3477cd77a168c05290c471a575623ef" - integrity sha512-aktF0kCar8+zxRHxQZwxMy70stc9R1mOmrLsT5VO3pIT0uzGRSDAXxSlz4NqQWpuLjPpuMhPRl7H+5FRsvIQAg== +jest-docblock@^26.0.0: + version "26.0.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-26.0.0.tgz#3e2fa20899fc928cb13bd0ff68bd3711a36889b5" + integrity sha512-RDZ4Iz3QbtRWycd8bUEPxQsTlYazfYn/h5R65Fc6gOfwozFhoImx+affzky/FFBuqISPTqjXomoIGJVKBWoo0w== dependencies: detect-newline "^3.0.0" -jest-each@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-25.5.0.tgz#0c3c2797e8225cb7bec7e4d249dcd96b934be516" - integrity sha512-QBogUxna3D8vtiItvn54xXde7+vuzqRrEeaw8r1s+1TG9eZLVJE5ZkKoSUlqFwRjnlaA4hyKGiu9OlkFIuKnjA== - dependencies: - "@jest/types" "^25.5.0" - chalk "^3.0.0" - jest-get-type "^25.2.6" - jest-util "^25.5.0" - pretty-format "^25.5.0" - -jest-environment-jsdom@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-25.5.0.tgz#dcbe4da2ea997707997040ecf6e2560aec4e9834" - integrity sha512-7Jr02ydaq4jaWMZLY+Skn8wL5nVIYpWvmeatOHL3tOcV3Zw8sjnPpx+ZdeBfc457p8jCR9J6YCc+Lga0oIy62A== - dependencies: - "@jest/environment" "^25.5.0" - "@jest/fake-timers" "^25.5.0" - "@jest/types" "^25.5.0" - jest-mock "^25.5.0" - jest-util "^25.5.0" - jsdom "^15.2.1" - -jest-environment-node@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-25.5.0.tgz#0f55270d94804902988e64adca37c6ce0f7d07a1" - integrity sha512-iuxK6rQR2En9EID+2k+IBs5fCFd919gVVK5BeND82fYeLWPqvRcFNPKu9+gxTwfB5XwBGBvZ0HFQa+cHtIoslA== - dependencies: - "@jest/environment" "^25.5.0" - "@jest/fake-timers" "^25.5.0" - "@jest/types" "^25.5.0" - jest-mock "^25.5.0" - jest-util "^25.5.0" - semver "^6.3.0" +jest-each@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-26.6.1.tgz#e968e88309a3e2ae9648634af8f89d8ee5acfddd" + integrity sha512-gSn8eB3buchuq45SU7pLB7qmCGax1ZSxfaWuEFblCyNMtyokYaKFh9dRhYPujK6xYL57dLIPhLKatjmB5XWzGA== + dependencies: + "@jest/types" "^26.6.1" + chalk "^4.0.0" + jest-get-type "^26.3.0" + jest-util "^26.6.1" + pretty-format "^26.6.1" + +jest-environment-jsdom@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-26.6.1.tgz#63093bf89daee6139616568a43633b84cf7aac21" + integrity sha512-A17RiXuHYNVlkM+3QNcQ6n5EZyAc6eld8ra9TW26luounGWpku4tj03uqRgHJCI1d4uHr5rJiuCH5JFRtdmrcA== + dependencies: + "@jest/environment" "^26.6.1" + "@jest/fake-timers" "^26.6.1" + "@jest/types" "^26.6.1" + "@types/node" "*" + jest-mock "^26.6.1" + jest-util "^26.6.1" + jsdom "^16.4.0" + +jest-environment-node@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-26.6.1.tgz#4d73d8b33c26989a92a0ed3ad0bfd6f7a196d9bd" + integrity sha512-YffaCp6h0j1kbcf1NVZ7umC6CPgD67YS+G1BeornfuSkx5s3xdhuwG0DCxSiHPXyT81FfJzA1L7nXvhq50OWIg== + dependencies: + "@jest/environment" "^26.6.1" + "@jest/fake-timers" "^26.6.1" + "@jest/types" "^26.6.1" + "@types/node" "*" + jest-mock "^26.6.1" + jest-util "^26.6.1" -jest-get-type@^25.2.6: - version "25.2.6" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-25.2.6.tgz#0b0a32fab8908b44d508be81681487dbabb8d877" - integrity sha512-DxjtyzOHjObRM+sM1knti6or+eOgcGU4xVSb2HNP1TqO4ahsT+rqZg+nyqHWJSvWgKC5cG3QjGFBqxLghiF/Ig== +jest-get-type@^26.3.0: + version "26.3.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0" + integrity sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig== -jest-haste-map@^25.5.1: - version "25.5.1" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-25.5.1.tgz#1df10f716c1d94e60a1ebf7798c9fb3da2620943" - integrity sha512-dddgh9UZjV7SCDQUrQ+5t9yy8iEgKc1AKqZR9YDww8xsVOtzPQSMVLDChc21+g29oTRexb9/B0bIlZL+sWmvAQ== +jest-haste-map@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.6.1.tgz#97e96f5fd7576d980307fbe6160b10c016b543d4" + integrity sha512-9kPafkv0nX6ta1PrshnkiyhhoQoFWncrU/uUBt3/AP1r78WSCU5iLceYRTwDvJl67H3RrXqSlSVDDa/AsUB7OQ== dependencies: - "@jest/types" "^25.5.0" + "@jest/types" "^26.6.1" "@types/graceful-fs" "^4.1.2" + "@types/node" "*" anymatch "^3.0.3" fb-watchman "^2.0.0" graceful-fs "^4.2.4" - jest-serializer "^25.5.0" - jest-util "^25.5.0" - jest-worker "^25.5.0" + jest-regex-util "^26.0.0" + jest-serializer "^26.5.0" + jest-util "^26.6.1" + jest-worker "^26.6.1" micromatch "^4.0.2" sane "^4.0.3" walker "^1.0.7" - which "^2.0.2" optionalDependencies: fsevents "^2.1.2" -jest-jasmine2@^25.5.4: - version "25.5.4" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-25.5.4.tgz#66ca8b328fb1a3c5364816f8958f6970a8526968" - integrity sha512-9acbWEfbmS8UpdcfqnDO+uBUgKa/9hcRh983IHdM+pKmJPL77G0sWAAK0V0kr5LK3a8cSBfkFSoncXwQlRZfkQ== +jest-jasmine2@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-26.6.1.tgz#11c92603d1fa97e3c33404359e69d6cec7e57017" + integrity sha512-2uYdT32o/ZzSxYAPduAgokO8OlAL1YdG/9oxcEY138EDNpIK5XRRJDaGzTZdIBWSxk0aR8XxN44FvfXtHB+Fiw== dependencies: "@babel/traverse" "^7.1.0" - "@jest/environment" "^25.5.0" - "@jest/source-map" "^25.5.0" - "@jest/test-result" "^25.5.0" - "@jest/types" "^25.5.0" - chalk "^3.0.0" + "@jest/environment" "^26.6.1" + "@jest/source-map" "^26.5.0" + "@jest/test-result" "^26.6.1" + "@jest/types" "^26.6.1" + "@types/node" "*" + chalk "^4.0.0" co "^4.6.0" - expect "^25.5.0" + expect "^26.6.1" is-generator-fn "^2.0.0" - jest-each "^25.5.0" - jest-matcher-utils "^25.5.0" - jest-message-util "^25.5.0" - jest-runtime "^25.5.4" - jest-snapshot "^25.5.1" - jest-util "^25.5.0" - pretty-format "^25.5.0" + jest-each "^26.6.1" + jest-matcher-utils "^26.6.1" + jest-message-util "^26.6.1" + jest-runtime "^26.6.1" + jest-snapshot "^26.6.1" + jest-util "^26.6.1" + pretty-format "^26.6.1" throat "^5.0.0" -jest-junit@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-11.1.0.tgz#79cd53948e44d62b2b30fa23ea0d7a899d2c8d7a" - integrity sha512-c2LFOyKY7+ZxL5zSu+WHmHfsJ2wqbOpeYJ4Uu26yMhFxny2J2NQj6AVS7M+Eaxji9Q/oIDDK5tQy0DGzDp9xOw== +jest-leak-detector@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-26.6.1.tgz#f63e46dc4e3aa30d29b40ae49966a15730d25bbe" + integrity sha512-j9ZOtJSJKlHjrs4aIxWjiQUjyrffPdiAQn2Iw0916w7qZE5Lk0T2KhIH6E9vfhzP6sw0Q0jtnLLb4vQ71o1HlA== dependencies: - mkdirp "^1.0.4" - strip-ansi "^5.2.0" - uuid "^3.3.3" - xml "^1.0.1" + jest-get-type "^26.3.0" + pretty-format "^26.6.1" -jest-leak-detector@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-25.5.0.tgz#2291c6294b0ce404241bb56fe60e2d0c3e34f0bb" - integrity sha512-rV7JdLsanS8OkdDpZtgBf61L5xZ4NnYLBq72r6ldxahJWWczZjXawRsoHyXzibM5ed7C2QRjpp6ypgwGdKyoVA== +jest-matcher-utils@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-26.6.1.tgz#bc90822d352c91c2ec1814731327691d06598400" + integrity sha512-9iu3zrsYlUnl8pByhREF9rr5eYoiEb1F7ymNKg6lJr/0qD37LWS5FSW/JcoDl8UdMX2+zAzabDs7sTO+QFKjCg== dependencies: - jest-get-type "^25.2.6" - pretty-format "^25.5.0" - -jest-matcher-utils@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-25.5.0.tgz#fbc98a12d730e5d2453d7f1ed4a4d948e34b7867" - integrity sha512-VWI269+9JS5cpndnpCwm7dy7JtGQT30UHfrnM3mXl22gHGt/b7NkjBqXfbhZ8V4B7ANUsjK18PlSBmG0YH7gjw== - dependencies: - chalk "^3.0.0" - jest-diff "^25.5.0" - jest-get-type "^25.2.6" - pretty-format "^25.5.0" + chalk "^4.0.0" + jest-diff "^26.6.1" + jest-get-type "^26.3.0" + pretty-format "^26.6.1" -jest-message-util@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-25.5.0.tgz#ea11d93204cc7ae97456e1d8716251185b8880ea" - integrity sha512-ezddz3YCT/LT0SKAmylVyWWIGYoKHOFOFXx3/nA4m794lfVUskMcwhip6vTgdVrOtYdjeQeis2ypzes9mZb4EA== +jest-message-util@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-26.6.1.tgz#d62c20c0fe7be10bfd6020b675abb9b5fa933ff3" + integrity sha512-cqM4HnqncIebBNdTKrBoWR/4ufHTll0pK/FWwX0YasK+TlBQEMqw3IEdynuuOTjDPFO3ONlFn37280X48beByw== dependencies: "@babel/code-frame" "^7.0.0" - "@jest/types" "^25.5.0" - "@types/stack-utils" "^1.0.1" - chalk "^3.0.0" + "@jest/types" "^26.6.1" + "@types/stack-utils" "^2.0.0" + chalk "^4.0.0" graceful-fs "^4.2.4" micromatch "^4.0.2" slash "^3.0.0" - stack-utils "^1.0.1" + stack-utils "^2.0.2" -jest-mock@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-25.5.0.tgz#a91a54dabd14e37ecd61665d6b6e06360a55387a" - integrity sha512-eXWuTV8mKzp/ovHc5+3USJMYsTBhyQ+5A1Mak35dey/RG8GlM4YWVylZuGgVXinaW6tpvk/RSecmF37FKUlpXA== +jest-mock@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-26.6.1.tgz#6c12a92a82fc833f81a5b6de6b67d78386e276a3" + integrity sha512-my0lPTBu1awY8iVG62sB2sx9qf8zxNDVX+5aFgoB8Vbqjb6LqIOsfyFA8P1z6H2IsqMbvOX9oCJnK67Y3yUIMA== dependencies: - "@jest/types" "^25.5.0" + "@jest/types" "^26.6.1" + "@types/node" "*" -jest-pnp-resolver@^1.2.1: +jest-pnp-resolver@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz#b704ac0ae028a89108a4d040b3f919dfddc8e33c" integrity sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w== -jest-regex-util@^25.2.1, jest-regex-util@^25.2.6: - version "25.2.6" - resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-25.2.6.tgz#d847d38ba15d2118d3b06390056028d0f2fd3964" - integrity sha512-KQqf7a0NrtCkYmZZzodPftn7fL1cq3GQAFVMn5Hg8uKx/fIenLEobNanUxb7abQ1sjADHBseG/2FGpsv/wr+Qw== +jest-regex-util@^26.0.0: + version "26.0.0" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-26.0.0.tgz#d25e7184b36e39fd466c3bc41be0971e821fee28" + integrity sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A== -jest-resolve-dependencies@^25.5.4: - version "25.5.4" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-25.5.4.tgz#85501f53957c8e3be446e863a74777b5a17397a7" - integrity sha512-yFmbPd+DAQjJQg88HveObcGBA32nqNZ02fjYmtL16t1xw9bAttSn5UGRRhzMHIQbsep7znWvAvnD4kDqOFM0Uw== +jest-resolve-dependencies@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-26.6.1.tgz#e9d091a159ad198c029279737a8b4c507791d75c" + integrity sha512-MN6lufbZJ3RBfTnJesZtHu3hUCBqPdHRe2+FhIt0yiqJ3fMgzWRqMRQyN/d/QwOE7KXwAG2ekZutbPhuD7s51A== dependencies: - "@jest/types" "^25.5.0" - jest-regex-util "^25.2.6" - jest-snapshot "^25.5.1" + "@jest/types" "^26.6.1" + jest-regex-util "^26.0.0" + jest-snapshot "^26.6.1" -jest-resolve@^25.5.1: - version "25.5.1" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-25.5.1.tgz#0e6fbcfa7c26d2a5fe8f456088dc332a79266829" - integrity sha512-Hc09hYch5aWdtejsUZhA+vSzcotf7fajSlPA6EZPE1RmPBAD39XtJhvHWFStid58iit4IPDLI/Da4cwdDmAHiQ== +jest-resolve@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-26.6.1.tgz#e9a9130cc069620d5aeeb87043dd9e130b68c6a1" + integrity sha512-hiHfQH6rrcpAmw9xCQ0vD66SDuU+7ZulOuKwc4jpbmFFsz0bQG/Ib92K+9/489u5rVw0btr/ZhiHqBpmkbCvuQ== dependencies: - "@jest/types" "^25.5.0" - browser-resolve "^1.11.3" - chalk "^3.0.0" + "@jest/types" "^26.6.1" + chalk "^4.0.0" graceful-fs "^4.2.4" - jest-pnp-resolver "^1.2.1" + jest-pnp-resolver "^1.2.2" + jest-util "^26.6.1" read-pkg-up "^7.0.1" - realpath-native "^2.0.0" - resolve "^1.17.0" + resolve "^1.18.1" slash "^3.0.0" -jest-runner@^25.5.4: - version "25.5.4" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-25.5.4.tgz#ffec5df3875da5f5c878ae6d0a17b8e4ecd7c71d" - integrity sha512-V/2R7fKZo6blP8E9BL9vJ8aTU4TH2beuqGNxHbxi6t14XzTb+x90B3FRgdvuHm41GY8ch4xxvf0ATH4hdpjTqg== +jest-runner@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-26.6.1.tgz#a945971b5a23740c1fe20e372a38de668b7c76bf" + integrity sha512-DmpNGdgsbl5s0FGkmsInmqnmqCtliCSnjWA2TFAJS1m1mL5atwfPsf+uoZ8uYQ2X0uDj4NM+nPcDnUpbNTRMBA== dependencies: - "@jest/console" "^25.5.0" - "@jest/environment" "^25.5.0" - "@jest/test-result" "^25.5.0" - "@jest/types" "^25.5.0" - chalk "^3.0.0" + "@jest/console" "^26.6.1" + "@jest/environment" "^26.6.1" + "@jest/test-result" "^26.6.1" + "@jest/types" "^26.6.1" + "@types/node" "*" + chalk "^4.0.0" + emittery "^0.7.1" exit "^0.1.2" graceful-fs "^4.2.4" - jest-config "^25.5.4" - jest-docblock "^25.3.0" - jest-haste-map "^25.5.1" - jest-jasmine2 "^25.5.4" - jest-leak-detector "^25.5.0" - jest-message-util "^25.5.0" - jest-resolve "^25.5.1" - jest-runtime "^25.5.4" - jest-util "^25.5.0" - jest-worker "^25.5.0" + jest-config "^26.6.1" + jest-docblock "^26.0.0" + jest-haste-map "^26.6.1" + jest-leak-detector "^26.6.1" + jest-message-util "^26.6.1" + jest-resolve "^26.6.1" + jest-runtime "^26.6.1" + jest-util "^26.6.1" + jest-worker "^26.6.1" source-map-support "^0.5.6" throat "^5.0.0" -jest-runtime@^25.5.4: - version "25.5.4" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-25.5.4.tgz#dc981fe2cb2137abcd319e74ccae7f7eeffbfaab" - integrity sha512-RWTt8LeWh3GvjYtASH2eezkc8AehVoWKK20udV6n3/gC87wlTbE1kIA+opCvNWyyPeBs6ptYsc6nyHUb1GlUVQ== - dependencies: - "@jest/console" "^25.5.0" - "@jest/environment" "^25.5.0" - "@jest/globals" "^25.5.2" - "@jest/source-map" "^25.5.0" - "@jest/test-result" "^25.5.0" - "@jest/transform" "^25.5.1" - "@jest/types" "^25.5.0" +jest-runtime@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-26.6.1.tgz#9a131e7b4f0bc6beefd62e7443f757c1d5fa9dec" + integrity sha512-7uOCNeezXDWgjEyzYbRN2ViY7xNZzusNVGAMmU0UHRUNXuY4j4GBHKGMqPo/cBPZA9bSYp+lwK2DRRBU5Dv6YQ== + dependencies: + "@jest/console" "^26.6.1" + "@jest/environment" "^26.6.1" + "@jest/fake-timers" "^26.6.1" + "@jest/globals" "^26.6.1" + "@jest/source-map" "^26.5.0" + "@jest/test-result" "^26.6.1" + "@jest/transform" "^26.6.1" + "@jest/types" "^26.6.1" "@types/yargs" "^15.0.0" - chalk "^3.0.0" + chalk "^4.0.0" + cjs-module-lexer "^0.4.2" collect-v8-coverage "^1.0.0" exit "^0.1.2" glob "^7.1.3" graceful-fs "^4.2.4" - jest-config "^25.5.4" - jest-haste-map "^25.5.1" - jest-message-util "^25.5.0" - jest-mock "^25.5.0" - jest-regex-util "^25.2.6" - jest-resolve "^25.5.1" - jest-snapshot "^25.5.1" - jest-util "^25.5.0" - jest-validate "^25.5.0" - realpath-native "^2.0.0" + jest-config "^26.6.1" + jest-haste-map "^26.6.1" + jest-message-util "^26.6.1" + jest-mock "^26.6.1" + jest-regex-util "^26.0.0" + jest-resolve "^26.6.1" + jest-snapshot "^26.6.1" + jest-util "^26.6.1" + jest-validate "^26.6.1" slash "^3.0.0" strip-bom "^4.0.0" - yargs "^15.3.1" + yargs "^15.4.1" jest-serializer-ansi@^1.0.3: version "1.0.3" @@ -7216,89 +7223,85 @@ jest-serializer-ansi@^1.0.3: lodash "^4.17.4" strip-ansi "^4.0.0" -jest-serializer@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-25.5.0.tgz#a993f484e769b4ed54e70e0efdb74007f503072b" - integrity sha512-LxD8fY1lByomEPflwur9o4e2a5twSQ7TaVNLlFUuToIdoJuBt8tzHfCsZ42Ok6LkKXWzFWf3AGmheuLAA7LcCA== +jest-serializer@^26.5.0: + version "26.5.0" + resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-26.5.0.tgz#f5425cc4c5f6b4b355f854b5f0f23ec6b962bc13" + integrity sha512-+h3Gf5CDRlSLdgTv7y0vPIAoLgX/SI7T4v6hy+TEXMgYbv+ztzbg5PSN6mUXAT/hXYHvZRWm+MaObVfqkhCGxA== dependencies: + "@types/node" "*" graceful-fs "^4.2.4" -jest-snapshot@^25.5.1: - version "25.5.1" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-25.5.1.tgz#1a2a576491f9961eb8d00c2e5fd479bc28e5ff7f" - integrity sha512-C02JE1TUe64p2v1auUJ2ze5vcuv32tkv9PyhEb318e8XOKF7MOyXdJ7kdjbvrp3ChPLU2usI7Rjxs97Dj5P0uQ== +jest-snapshot@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-26.6.1.tgz#469e9d0b749496aea7dad0d7e5e5c88b91cdb4cc" + integrity sha512-JA7bZp7HRTIJYAi85pJ/OZ2eur2dqmwIToA5/6d7Mn90isGEfeF9FvuhDLLEczgKP1ihreBzrJ6Vr7zteP5JNA== dependencies: "@babel/types" "^7.0.0" - "@jest/types" "^25.5.0" - "@types/prettier" "^1.19.0" - chalk "^3.0.0" - expect "^25.5.0" + "@jest/types" "^26.6.1" + "@types/babel__traverse" "^7.0.4" + "@types/prettier" "^2.0.0" + chalk "^4.0.0" + expect "^26.6.1" graceful-fs "^4.2.4" - jest-diff "^25.5.0" - jest-get-type "^25.2.6" - jest-matcher-utils "^25.5.0" - jest-message-util "^25.5.0" - jest-resolve "^25.5.1" - make-dir "^3.0.0" + jest-diff "^26.6.1" + jest-get-type "^26.3.0" + jest-haste-map "^26.6.1" + jest-matcher-utils "^26.6.1" + jest-message-util "^26.6.1" + jest-resolve "^26.6.1" natural-compare "^1.4.0" - pretty-format "^25.5.0" - semver "^6.3.0" + pretty-format "^26.6.1" + semver "^7.3.2" -jest-util@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-25.5.0.tgz#31c63b5d6e901274d264a4fec849230aa3fa35b0" - integrity sha512-KVlX+WWg1zUTB9ktvhsg2PXZVdkI1NBevOJSkTKYAyXyH4QSvh+Lay/e/v+bmaFfrkfx43xD8QTfgobzlEXdIA== +jest-util@^26.1.0, jest-util@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.1.tgz#4cc0d09ec57f28d12d053887eec5dc976a352e9b" + integrity sha512-xCLZUqVoqhquyPLuDXmH7ogceGctbW8SMyQVjD9o+1+NPWI7t0vO08udcFLVPLgKWcvc+zotaUv/RuaR6l8HIA== dependencies: - "@jest/types" "^25.5.0" - chalk "^3.0.0" + "@jest/types" "^26.6.1" + "@types/node" "*" + chalk "^4.0.0" graceful-fs "^4.2.4" is-ci "^2.0.0" - make-dir "^3.0.0" + micromatch "^4.0.2" -jest-validate@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-25.5.0.tgz#fb4c93f332c2e4cf70151a628e58a35e459a413a" - integrity sha512-okUFKqhZIpo3jDdtUXUZ2LxGUZJIlfdYBvZb1aczzxrlyMlqdnnws9MOxezoLGhSaFc2XYaHNReNQfj5zPIWyQ== +jest-validate@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-26.6.1.tgz#28730eb8570d60968d9d06f1a8c94d922167bd2a" + integrity sha512-BEFpGbylKocnNPZULcnk+TGaz1oFZQH/wcaXlaXABbu0zBwkOGczuWgdLucUouuQqn7VadHZZeTvo8VSFDLMOA== dependencies: - "@jest/types" "^25.5.0" - camelcase "^5.3.1" - chalk "^3.0.0" - jest-get-type "^25.2.6" + "@jest/types" "^26.6.1" + camelcase "^6.0.0" + chalk "^4.0.0" + jest-get-type "^26.3.0" leven "^3.1.0" - pretty-format "^25.5.0" + pretty-format "^26.6.1" -jest-watch-typeahead@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jest-watch-typeahead/-/jest-watch-typeahead-0.5.0.tgz#903dba6112f22daae7e90b0a271853f7ff182008" - integrity sha512-4r36w9vU8+rdg48hj0Z7TvcSqVP6Ao8dk04grlHQNgduyCB0SqrI0xWIl85ZhXrzYvxQ0N5H+rRLAejkQzEHeQ== +jest-watch-typeahead@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/jest-watch-typeahead/-/jest-watch-typeahead-0.6.1.tgz#45221b86bb6710b7e97baaa1640ae24a07785e63" + integrity sha512-ITVnHhj3Jd/QkqQcTqZfRgjfyRhDFM/auzgVo2RKvSwi18YMvh0WvXDJFoFED6c7jd/5jxtu4kSOb9PTu2cPVg== dependencies: - ansi-escapes "^4.2.1" - chalk "^3.0.0" - jest-regex-util "^25.2.1" - jest-watcher "^25.2.4" + ansi-escapes "^4.3.1" + chalk "^4.0.0" + jest-regex-util "^26.0.0" + jest-watcher "^26.3.0" slash "^3.0.0" - string-length "^3.1.0" + string-length "^4.0.1" strip-ansi "^6.0.0" -jest-watcher@^25.2.4, jest-watcher@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-25.5.0.tgz#d6110d101df98badebe435003956fd4a465e8456" - integrity sha512-XrSfJnVASEl+5+bb51V0Q7WQx65dTSk7NL4yDdVjPnRNpM0hG+ncFmDYJo9O8jaSRcAitVbuVawyXCRoxGrT5Q== +jest-watcher@^26.3.0, jest-watcher@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-26.6.1.tgz#debfa34e9c5c3e735593403794fe53d2955bfabc" + integrity sha512-0LBIPPncNi9CaLKK15bnxyd2E8OMl4kJg0PTiNOI+MXztXw1zVdtX/x9Pr6pXaQYps+eS/ts43O4+HByZ7yJSw== dependencies: - "@jest/test-result" "^25.5.0" - "@jest/types" "^25.5.0" + "@jest/test-result" "^26.6.1" + "@jest/types" "^26.6.1" + "@types/node" "*" ansi-escapes "^4.2.1" - chalk "^3.0.0" - jest-util "^25.5.0" - string-length "^3.1.0" - -jest-worker@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-25.5.0.tgz#2611d071b79cea0f43ee57a3d118593ac1547db1" - integrity sha512-/dsSmUkIy5EBGfv/IjjqmFxrNAUpBERfGs1oHROyD7yxjG/w+t0GOJDX8O1k32ySmd7+a5IhnJU2qQFcJ4n1vw== - dependencies: - merge-stream "^2.0.0" - supports-color "^7.0.0" + chalk "^4.0.0" + jest-util "^26.6.1" + string-length "^4.0.1" jest-worker@^26.5.0: version "26.5.0" @@ -7309,14 +7312,23 @@ jest-worker@^26.5.0: merge-stream "^2.0.0" supports-color "^7.0.0" -jest@^25.2.3: - version "25.5.4" - resolved "https://registry.yarnpkg.com/jest/-/jest-25.5.4.tgz#f21107b6489cfe32b076ce2adcadee3587acb9db" - integrity sha512-hHFJROBTqZahnO+X+PMtT6G2/ztqAZJveGqz//FnWWHurizkD05PQGzRZOhF3XP6z7SJmL+5tCfW8qV06JypwQ== +jest-worker@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.1.tgz#c2ae8cde6802cc14056043f997469ec170d9c32a" + integrity sha512-R5IE3qSGz+QynJx8y+ICEkdI2OJ3RJjRQVEyCcFAd3yVhQSEtquziPO29Mlzgn07LOVE8u8jhJ1FqcwegiXWOw== dependencies: - "@jest/core" "^25.5.4" + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^7.0.0" + +jest@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/jest/-/jest-26.6.1.tgz#821e8280d2bdeeed40ac7bc43941dceff0f1b650" + integrity sha512-f+ahfqw3Ffy+9vA7sWFGpTmhtKEMsNAZiWBVXDkrpIO73zIz22iimjirnV78kh/eWlylmvLh/0WxHN6fZraZdA== + dependencies: + "@jest/core" "^26.6.1" import-local "^3.0.2" - jest-cli "^25.5.4" + jest-cli "^26.6.1" js-tokens@^4.0.0: version "4.0.0" @@ -7360,36 +7372,36 @@ jscodeshift@^0.7.0: temp "^0.8.1" write-file-atomic "^2.3.0" -jsdom@^15.2.1: - version "15.2.1" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-15.2.1.tgz#d2feb1aef7183f86be521b8c6833ff5296d07ec5" - integrity sha512-fAl1W0/7T2G5vURSyxBzrJ1LSdQn6Tr5UX/xD4PXDx/PDgwygedfW6El/KIj3xJ7FU61TTYnc/l/B7P49Eqt6g== - dependencies: - abab "^2.0.0" - acorn "^7.1.0" - acorn-globals "^4.3.2" - array-equal "^1.0.0" - cssom "^0.4.1" - cssstyle "^2.0.0" - data-urls "^1.1.0" - domexception "^1.0.1" - escodegen "^1.11.1" - html-encoding-sniffer "^1.0.2" +jsdom@^16.4.0: + version "16.4.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.4.0.tgz#36005bde2d136f73eee1a830c6d45e55408edddb" + integrity sha512-lYMm3wYdgPhrl7pDcRmvzPhhrGVBeVhPIqeHjzeiHN3DFmD1RBpbExbi8vU7BJdH8VAZYovR8DMt0PNNDM7k8w== + dependencies: + abab "^2.0.3" + acorn "^7.1.1" + acorn-globals "^6.0.0" + cssom "^0.4.4" + cssstyle "^2.2.0" + data-urls "^2.0.0" + decimal.js "^10.2.0" + domexception "^2.0.1" + escodegen "^1.14.1" + html-encoding-sniffer "^2.0.1" + is-potential-custom-element-name "^1.0.0" nwsapi "^2.2.0" - parse5 "5.1.0" - pn "^1.1.0" - request "^2.88.0" - request-promise-native "^1.0.7" - saxes "^3.1.9" - symbol-tree "^3.2.2" + parse5 "5.1.1" + request "^2.88.2" + request-promise-native "^1.0.8" + saxes "^5.0.0" + symbol-tree "^3.2.4" tough-cookie "^3.0.1" - w3c-hr-time "^1.0.1" - w3c-xmlserializer "^1.1.2" - webidl-conversions "^4.0.2" + w3c-hr-time "^1.0.2" + w3c-xmlserializer "^2.0.0" + webidl-conversions "^6.1.0" whatwg-encoding "^1.0.5" whatwg-mimetype "^2.3.0" - whatwg-url "^7.0.0" - ws "^7.0.0" + whatwg-url "^8.0.0" + ws "^7.2.3" xml-name-validator "^3.0.0" jsesc@^2.5.1: @@ -7533,13 +7545,6 @@ lazy-cache@^2.0.1: dependencies: set-getter "^0.1.0" -lcid@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" - integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA== - dependencies: - invert-kv "^2.0.0" - lerna@^3.22.1: version "3.22.1" resolved "https://registry.yarnpkg.com/lerna/-/lerna-3.22.1.tgz#82027ac3da9c627fd8bf02ccfeff806a98e65b62" @@ -7569,7 +7574,15 @@ leven@^3.1.0: resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== -levn@^0.3.0, levn@~0.3.0: +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" + +levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= @@ -7582,10 +7595,10 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= -lint-staged@^10.2.11: - version "10.4.2" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.4.2.tgz#9fee4635c4b5ddb845746f237c6d43494ccd21c1" - integrity sha512-OLCA9K1hS+Sl179SO6kX0JtnsaKj/MZalEhUj5yAgXsb63qPI/Gfn6Ua1KuZdbfkZNEu3/n5C/obYCu70IMt9g== +lint-staged@^10.5.0: + version "10.5.0" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.0.tgz#c923c2447a84c595874f3de696778736227e7a7a" + integrity sha512-gjC9+HGkBubOF+Yyoj9pd52Qfm/kYB+dRX1UOgWjHKvSDYl+VHkZXlBMlqSZa2cH3Kp5/uNL480sV6e2dTgXSg== dependencies: chalk "^4.1.0" cli-truncate "^2.1.0" @@ -7828,18 +7841,11 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" -loglevel@^1.6.6: +loglevel@^1.6.8: version "1.7.0" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.0.tgz#728166855a740d59d38db01cf46f042caa041bb0" integrity sha512-i2sY04nal5jDcagM3FMfG++T69GEEM8CYuOfeOIvmXzOIcwE9a/CJPR0MFM97pYMj/u10lzz7/zd7+qwhrBTqQ== -lolex@^5.0.0: - version "5.1.2" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-5.1.2.tgz#953694d098ce7c07bc5ed6d0e42bc6c0c6d5a367" - integrity sha512-h4hmjAvHTmd+25JSwrtTIuwbKdwg5NzZVRMLn9saij4SZaepCrTCxPr35H/3bjwfMJtN+t3CX8672UIkglz28A== - dependencies: - "@sinonjs/commons" "^1.7.0" - loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" @@ -7921,13 +7927,6 @@ makeerror@1.0.x: dependencies: tmpl "1.0.x" -map-age-cleaner@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" - integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== - dependencies: - p-defer "^1.0.0" - map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -8003,15 +8002,6 @@ mem-fs@^1.1.0, mem-fs@^1.2.0: vinyl "^2.0.1" vinyl-file "^3.0.0" -mem@^4.0.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178" - integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w== - dependencies: - map-age-cleaner "^0.1.1" - mimic-fn "^2.0.0" - p-is-promise "^2.0.0" - memory-fs@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" @@ -8105,14 +8095,6 @@ methods@~1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= -micromatch@4.x, micromatch@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" - integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q== - dependencies: - braces "^3.0.1" - picomatch "^2.0.5" - micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" @@ -8132,6 +8114,14 @@ micromatch@^3.1.10, micromatch@^3.1.4: snapdragon "^0.8.1" to-regex "^3.0.2" +micromatch@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" + integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q== + dependencies: + braces "^3.0.1" + picomatch "^2.0.5" + mime-db@1.44.0: version "1.44.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" @@ -8164,7 +8154,7 @@ mimic-fn@^1.0.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== -mimic-fn@^2.0.0, mimic-fn@^2.1.0: +mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== @@ -8264,12 +8254,12 @@ mkdirp-promise@^5.0.1: dependencies: mkdirp "*" -mkdirp@*, mkdirp@^1.0.0, mkdirp@^1.0.3, mkdirp@^1.0.4: +mkdirp@*, mkdirp@1.x, mkdirp@^1.0.0, mkdirp@^1.0.3, mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== -mkdirp@0.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.5: +mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.5: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== @@ -8472,16 +8462,17 @@ node-modules-regexp@^1.0.0: resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= -node-notifier@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-6.0.0.tgz#cea319e06baa16deec8ce5cd7f133c4a46b68e12" - integrity sha512-SVfQ/wMw+DesunOm5cKqr6yDcvUTDl/yc97ybGHMrteNEY6oekXpNpS3lZwgLlwz0FLgHoiW28ZpmBHUDg37cw== +node-notifier@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-8.0.0.tgz#a7eee2d51da6d0f7ff5094bc7108c911240c1620" + integrity sha512-46z7DUmcjoYdaWyXouuFNNfUo6eFa94t23c53c+lG/9Cvauk4a98rAUp9672X5dxGdQmLpPzTxzu8f/OeEPaFA== dependencies: growly "^1.3.0" - is-wsl "^2.1.1" - semver "^6.3.0" + is-wsl "^2.2.0" + semver "^7.3.2" shellwords "^0.1.1" - which "^1.3.1" + uuid "^8.3.0" + which "^2.0.2" node-releases@^1.1.61: version "1.1.61" @@ -8757,7 +8748,7 @@ opn@^5.5.0: dependencies: is-wsl "^1.1.0" -optionator@^0.8.1, optionator@^0.8.3: +optionator@^0.8.1: version "0.8.3" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== @@ -8769,6 +8760,18 @@ optionator@^0.8.1, optionator@^0.8.3: type-check "~0.3.2" word-wrap "~1.2.3" +optionator@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" + integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== + dependencies: + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.3" + original@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/original/-/original-1.0.2.tgz#e442a61cffe1c5fd20a65f3261c26663b303f25f" @@ -8781,15 +8784,6 @@ os-homedir@^1.0.0: resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= -os-locale@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" - integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q== - dependencies: - execa "^1.0.0" - lcid "^2.0.0" - mem "^4.0.0" - os-name@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/os-name/-/os-name-3.1.0.tgz#dec19d966296e1cd62d701a5a66ee1ddeae70801" @@ -8816,11 +8810,6 @@ p-cancelable@^2.0.0: resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.0.0.tgz#4a3740f5bdaf5ed5d7c3e34882c6fb5d6b266a6e" integrity sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg== -p-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" - integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= - p-each-series@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.1.0.tgz#961c8dd3f195ea96c747e636b262b800a6b1af48" @@ -8838,16 +8827,6 @@ p-finally@^1.0.0: resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= -p-finally@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-2.0.1.tgz#bd6fcaa9c559a096b680806f4d657b3f0f240561" - integrity sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw== - -p-is-promise@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e" - integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg== - p-lazy@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/p-lazy/-/p-lazy-3.0.0.tgz#3d8b2aceea3e49f8e5883947838e9370f15c9e28" @@ -9052,10 +9031,10 @@ parse-url@^5.0.0: parse-path "^4.0.0" protocols "^1.4.0" -parse5@5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.0.tgz#c59341c9723f414c452975564c7c00a68d58acd2" - integrity sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ== +parse5@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.1.tgz#f68e4e5ba1852ac2cadc00f4555fff6c2abb6178" + integrity sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug== parseurl@~1.3.2, parseurl@~1.3.3: version "1.3.3" @@ -9212,12 +9191,7 @@ please-upgrade-node@^3.2.0: dependencies: semver-compare "^1.0.0" -pn@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" - integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA== - -portfinder@^1.0.25: +portfinder@^1.0.26: version "1.0.28" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778" integrity sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA== @@ -9231,6 +9205,11 @@ posix-character-classes@^0.1.0: resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -9248,7 +9227,7 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.0.5: +prettier@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg== @@ -9258,15 +9237,15 @@ pretty-bytes@^5.2.0: resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.4.1.tgz#cd89f79bbcef21e3d21eb0da68ffe93f803e884b" integrity sha512-s1Iam6Gwz3JI5Hweaz4GoCD1WUNUIyzePFy5+Js2hjwGVt2Z79wNN+ZKOZ2vB6C+Xs6njyB84Z1IthQg8d9LxA== -pretty-format@^25.2.1, pretty-format@^25.5.0: - version "25.5.0" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a" - integrity sha512-kbo/kq2LQ/A/is0PQwsEHM7Ca6//bGPPvU6UnsdDRSKTWxT/ru/xb88v4BJf6a69H+uTytOEsTusT9ksd/1iWQ== +pretty-format@^26.0.0, pretty-format@^26.6.1: + version "26.6.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.1.tgz#af9a2f63493a856acddeeb11ba6bcf61989660a8" + integrity sha512-MeqqsP5PYcRBbGMvwzsyBdmAJ4EFX7pWFyl7x4+dMVg5pE0ZDdBIvEH2ergvIO+Gvwv1wh64YuOY9y5LuyY/GA== dependencies: - "@jest/types" "^25.5.0" + "@jest/types" "^26.6.1" ansi-regex "^5.0.0" ansi-styles "^4.0.0" - react-is "^16.12.0" + react-is "^17.0.1" private@^0.1.8: version "0.1.8" @@ -9438,10 +9417,10 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -react-is@^16.12.0: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" - integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== +react-is@^17.0.1: + version "17.0.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.1.tgz#5b3531bd76a645a4c9fb6e693ed36419e3301339" + integrity sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA== read-chunk@^3.2.0: version "3.2.0" @@ -9586,11 +9565,6 @@ readdirp@^2.2.1: micromatch "^3.1.10" readable-stream "^2.0.2" -realpath-native@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-2.0.0.tgz#7377ac429b6e1fd599dc38d08ed942d0d7beb866" - integrity sha512-v1SEYUOXXdbBZK8ZuNgO4TBjamPsiSgcFr0aP+tEKpQZK8vooEUqV6nm6Cv502mX4NF2EfsnVqtNAHG+/6Ur1Q== - recast@^0.18.1: version "0.18.10" resolved "https://registry.yarnpkg.com/recast/-/recast-0.18.10.tgz#605ebbe621511eb89b6356a7e224bff66ed91478" @@ -9684,12 +9658,7 @@ regexp.prototype.flags@^1.2.0: define-properties "^1.1.3" es-abstract "^1.17.0-next.1" -regexpp@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" - integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== - -regexpp@^3.0.0: +regexpp@^3.0.0, regexpp@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== @@ -9752,7 +9721,7 @@ request-promise-core@1.1.4: dependencies: lodash "^4.17.19" -request-promise-native@^1.0.7: +request-promise-native@^1.0.8: version "1.0.9" resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.9.tgz#e407120526a5efdc9a39b28a5679bf47b9d9dc28" integrity sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g== @@ -9761,7 +9730,7 @@ request-promise-native@^1.0.7: stealthy-require "^1.1.1" tough-cookie "^2.3.3" -request@^2.88.0: +request@^2.88.0, request@^2.88.2: version "2.88.2" resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== @@ -9792,11 +9761,6 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= -require-main-filename@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" - integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= - require-main-filename@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" @@ -9863,18 +9827,21 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" - integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= - -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.17.0, resolve@^1.3.2, resolve@^1.9.0: +resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.3.2, resolve@^1.9.0: version "1.17.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== dependencies: path-parse "^1.0.6" +resolve@^1.18.1: + version "1.18.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.18.1.tgz#018fcb2c5b207d2a6424aee361c5a266da8f4130" + integrity sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA== + dependencies: + is-core-module "^2.0.0" + path-parse "^1.0.6" + responselike@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/responselike/-/responselike-2.0.0.tgz#26391bcc3174f750f9a79eacc40a12a5c42d7723" @@ -10005,12 +9972,12 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saxes@^3.1.9: - version "3.1.11" - resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" - integrity sha512-Ydydq3zC+WYDJK1+gRxRapLIED9PWeSuuS41wqyoRmzvhhh9nc+QQrVMKJYzJFULazeGhzSV0QleN2wD3boh2g== +saxes@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/saxes/-/saxes-5.0.1.tgz#eebab953fa3b7608dbe94e5dadb15c888fa6696d" + integrity sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw== dependencies: - xmlchars "^2.1.1" + xmlchars "^2.2.0" schema-utils@^1.0.0: version "1.0.0" @@ -10062,21 +10029,21 @@ semver-regex@^2.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@6.x, semver@^6.0.0, semver@^6.1.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - semver@7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== -semver@7.3.2, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2: +semver@7.3.2, semver@7.x, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== +semver@^6.0.0, semver@^6.1.0, semver@^6.2.0, semver@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + send@0.17.1: version "0.17.1" resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" @@ -10325,13 +10292,14 @@ sockjs-client@1.4.0: json3 "^3.3.2" url-parse "^1.4.3" -sockjs@0.3.19: - version "0.3.19" - resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.19.tgz#d976bbe800af7bd20ae08598d582393508993c0d" - integrity sha512-V48klKZl8T6MzatbLlzzRNhMepEys9Y4oGFpypBFFn1gLI/QQ9HtLLyWJNbPlwGLelOVOEijUbTTJeLLI59jLw== +sockjs@0.3.20: + version "0.3.20" + resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.20.tgz#b26a283ec562ef8b2687b44033a4eeceac75d855" + integrity sha512-SpmVOVpdq0DJc0qArhF3E5xsxvaiqGNb73XfgBpK1y3UD5gs8DSo8aCTsuT5pX8rssdc2NDIzANwP9eCAiSdTA== dependencies: faye-websocket "^0.10.0" - uuid "^3.0.1" + uuid "^3.4.0" + websocket-driver "0.6.5" socks-proxy-agent@^4.0.0: version "4.0.2" @@ -10438,7 +10406,7 @@ spdy-transport@^3.0.0: readable-stream "^3.0.6" wbuf "^1.7.3" -spdy@^4.0.1: +spdy@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/spdy/-/spdy-4.0.2.tgz#b74f466203a3eda452c02492b91fb9e84a27677b" integrity sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA== @@ -10497,10 +10465,12 @@ ssri@^6.0.0, ssri@^6.0.1: dependencies: figgy-pudding "^3.5.1" -stack-utils@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.2.tgz#33eba3897788558bebfc2db059dc158ec36cebb8" - integrity sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA== +stack-utils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.2.tgz#5cf48b4557becb4638d0bc4f21d23f5d19586593" + integrity sha512-0H7QK2ECz3fyZMzQ8rH0j2ykpfbnd20BFtfg/SqVC2+sCTtcw0aDTGB7dk+de4U4uUeuz6nOtJcrkFFLG1B0Rg== + dependencies: + escape-string-regexp "^2.0.0" static-extend@^0.1.1: version "0.1.2" @@ -10538,13 +10508,13 @@ string-argv@0.3.1: resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== -string-length@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-length/-/string-length-3.1.0.tgz#107ef8c23456e187a8abd4a61162ff4ac6e25837" - integrity sha512-Ttp5YvkGm5v9Ijagtaz1BnN+k9ObpvS0eIBblPMp2YWL8FBmi9qblQ9fexc2k/CXFgrTIteU3jAw3payCnwSTA== +string-length@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.1.tgz#4a973bf31ef77c4edbceadd6af2611996985f8a1" + integrity sha512-PKyXUd0LK0ePjSOnWn34V2uD6acUWev9uy0Ft05k0E8xRW+SKcA0F7eMr7h5xlzfn+4O3N+55rduYyet3Jk+jw== dependencies: - astral-regex "^1.0.0" - strip-ansi "^5.2.0" + char-regex "^1.0.2" + strip-ansi "^6.0.0" string-template@~0.2.1: version "0.2.1" @@ -10560,7 +10530,7 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: +"string-width@^1.0.2 || 2", string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -10714,7 +10684,7 @@ strip-indent@^3.0.0: dependencies: min-indent "^1.0.0" -strip-json-comments@^3.0.1: +strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -10767,7 +10737,7 @@ symbol-observable@^1.1.0: resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== -symbol-tree@^3.2.2: +symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== @@ -11027,6 +10997,13 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" +tr46@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.0.2.tgz#03273586def1595ae08fedb38d7733cee91d2479" + integrity sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg== + dependencies: + punycode "^2.1.1" + trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" @@ -11052,21 +11029,23 @@ tryer@^1.0.1: resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== -ts-jest@^25.5.1: - version "25.5.1" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-25.5.1.tgz#2913afd08f28385d54f2f4e828be4d261f4337c7" - integrity sha512-kHEUlZMK8fn8vkxDjwbHlxXRB9dHYpyzqKIGDNxbzs+Rz+ssNDSDNusEK8Fk/sDd4xE6iKoQLfFkFVaskmTJyw== +ts-jest@^26.4.3: + version "26.4.3" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.3.tgz#d153a616033e7ec8544b97ddbe2638cbe38d53db" + integrity sha512-pFDkOKFGY+nL9v5pkhm+BIFpoAuno96ff7GMnIYr/3L6slFOS365SI0fGEVYx2RKGji5M2elxhWjDMPVcOCdSw== dependencies: + "@jest/create-cache-key-function" "^26.5.0" + "@types/jest" "26.x" bs-logger "0.x" buffer-from "1.x" fast-json-stable-stringify "2.x" + jest-util "^26.1.0" json5 "2.x" lodash.memoize "4.x" make-error "1.x" - micromatch "4.x" - mkdirp "0.x" - semver "6.x" - yargs-parser "18.x" + mkdirp "1.x" + semver "7.x" + yargs-parser "20.x" tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" @@ -11092,6 +11071,13 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== + dependencies: + prelude-ls "^1.2.1" + type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -11340,20 +11326,25 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= -uuid@^3.0.1, uuid@^3.3.2, uuid@^3.3.3: +uuid@^3.0.1, uuid@^3.3.2, uuid@^3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +uuid@^8.3.0: + version "8.3.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31" + integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg== + v8-compile-cache@^2.0.3, v8-compile-cache@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745" integrity sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ== -v8-to-istanbul@^4.1.3: - version "4.1.4" - resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-4.1.4.tgz#b97936f21c0e2d9996d4985e5c5156e9d4e49cd6" - integrity sha512-Rw6vJHj1mbdK8edjR7+zuJrpDtKIgNdAvTSAcpYfgMIw+u2dPDntD3dgN4XQFLU2/fvFQdzj+EeSGfd/jnY5fQ== +v8-to-istanbul@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-6.0.1.tgz#7ef0e32faa10f841fe4c1b0f8de96ed067c0be1e" + integrity sha512-PzM1WlqquhBvsV+Gco6WSFeg1AGdD53ccMRkFeyHRE/KRZaVacPOmQYP3EeVgDBtKD2BJ8kgynBQ5OtKiHCH+w== dependencies: "@types/istanbul-lib-coverage" "^2.0.1" convert-source-map "^1.6.0" @@ -11411,20 +11402,18 @@ vinyl@^2.0.1, vinyl@^2.2.0: remove-trailing-separator "^1.0.1" replace-ext "^1.0.0" -w3c-hr-time@^1.0.1: +w3c-hr-time@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" integrity sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ== dependencies: browser-process-hrtime "^1.0.0" -w3c-xmlserializer@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-1.1.2.tgz#30485ca7d70a6fd052420a3d12fd90e6339ce794" - integrity sha512-p10l/ayESzrBMYWRID6xbuCKh2Fp77+sA0doRuGn4tTIMrrZVeqfpKjXHY+oDh3K4nLdPgNwMTVP6Vp4pvqbNg== +w3c-xmlserializer@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz#3e7104a05b75146cc60f564380b7f683acf1020a" + integrity sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA== dependencies: - domexception "^1.0.1" - webidl-conversions "^4.0.2" xml-name-validator "^3.0.0" walker@^1.0.7, walker@~1.0.5: @@ -11461,6 +11450,16 @@ webidl-conversions@^4.0.2: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== +webidl-conversions@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" + integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== + +webidl-conversions@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514" + integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w== + webpack-bundle-analyzer@^3.9.0: version "3.9.0" resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.9.0.tgz#f6f94db108fb574e415ad313de41a2707d33ef3c" @@ -11491,10 +11490,10 @@ webpack-dev-middleware@^3.7.2: range-parser "^1.2.1" webpack-log "^2.0.0" -webpack-dev-server@3.10.3: - version "3.10.3" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.10.3.tgz#f35945036813e57ef582c2420ef7b470e14d3af0" - integrity sha512-e4nWev8YzEVNdOMcNzNeCN947sWJNd43E5XvsJzbAL08kGc2frm1tQ32hTJslRS+H65LCb/AaUCYU7fjHCpDeQ== +webpack-dev-server@^3.11.0: + version "3.11.0" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.11.0.tgz#8f154a3bce1bcfd1cc618ef4e703278855e7ff8c" + integrity sha512-PUxZ+oSTxogFQgkTtFndEtJIPNmml7ExwufBZ9L2/Xyyd5PnOL5UreWe5ZT7IU25DSdykL9p1MLQzmLh2ljSeg== dependencies: ansi-html "0.0.7" bonjour "^3.5.0" @@ -11504,31 +11503,31 @@ webpack-dev-server@3.10.3: debug "^4.1.1" del "^4.1.1" express "^4.17.1" - html-entities "^1.2.1" + html-entities "^1.3.1" http-proxy-middleware "0.19.1" import-local "^2.0.0" internal-ip "^4.3.0" ip "^1.1.5" is-absolute-url "^3.0.3" killable "^1.0.1" - loglevel "^1.6.6" + loglevel "^1.6.8" opn "^5.5.0" p-retry "^3.0.1" - portfinder "^1.0.25" + portfinder "^1.0.26" schema-utils "^1.0.0" selfsigned "^1.10.7" semver "^6.3.0" serve-index "^1.9.1" - sockjs "0.3.19" + sockjs "0.3.20" sockjs-client "1.4.0" - spdy "^4.0.1" + spdy "^4.0.2" strip-ansi "^3.0.1" supports-color "^6.1.0" url "^0.11.0" webpack-dev-middleware "^3.7.2" webpack-log "^2.0.0" ws "^6.2.1" - yargs "12.0.5" + yargs "^13.3.2" webpack-log@^2.0.0: version "2.0.0" @@ -11545,18 +11544,18 @@ webpack-merge@^4.2.2: dependencies: lodash "^4.17.15" -webpack-sources@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.0.1.tgz#1467f6e692ddce91e88b8044c44347b1087bbd4f" - integrity sha512-A9oYz7ANQBK5EN19rUXbvNgfdfZf5U2gP0769OXsj9CvYkCR6OHOsd6OKyEy4H38GGxpsQPKIL83NC64QY6Xmw== +webpack-sources@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.1.1.tgz#6922dc1bf7f7f95aab56675535b6e20f87b9147f" + integrity sha512-hraq9n99K564zuZUsE61iATO3jvzxOmGo20UlOe3zgdHOBp8inTJgv7EY4RgvCv7Ywx0/vpQTyYSjnFpv4gNtQ== dependencies: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.2.0.tgz#02f22466b79751a80a50f20f027a716e296b3ef5" - integrity sha512-evtOjOJQq3zaHJIWsJjM4TGtNHtSrNVAIyQ+tdPW/fRd+4PLGbUG6S3xt+N4+QwDBOaCVd0xCWiHd4R6lWO5DQ== +webpack@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.3.0.tgz#cfa5d9d235fff41e71de0c7c1cd1fc58c7a6ff28" + integrity sha512-0LumZ36pDaWsh+PO3i6FpNQYVqNu5Rs/Jn5AoYQyHpUxIlzn5H7omwApiEzaIUeWDccExOpkNZGO6agCVSqXPg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" @@ -11567,7 +11566,7 @@ webpack@^5.1.0: acorn "^8.0.4" browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.3.0" + enhanced-resolve "^5.3.1" eslint-scope "^5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" @@ -11581,7 +11580,14 @@ webpack@^5.1.0: tapable "^2.0.0" terser-webpack-plugin "^5.0.0" watchpack "^2.0.0" - webpack-sources "^2.0.1" + webpack-sources "^2.1.0" + +websocket-driver@0.6.5: + version "0.6.5" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.6.5.tgz#5cb2556ceb85f4373c6d8238aa691c8454e13a36" + integrity sha1-XLJVbOuF9Dc8bYI4qmkchFThOjY= + dependencies: + websocket-extensions ">=0.1.1" websocket-driver@>=0.5.1: version "0.7.4" @@ -11597,14 +11603,14 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== -whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.5: +whatwg-encoding@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz#5abacf777c32166a51d085d6b4f3e7d27113ddb0" integrity sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw== dependencies: iconv-lite "0.4.24" -whatwg-mimetype@^2.2.0, whatwg-mimetype@^2.3.0: +whatwg-mimetype@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== @@ -11618,6 +11624,15 @@ whatwg-url@^7.0.0: tr46 "^1.0.1" webidl-conversions "^4.0.2" +whatwg-url@^8.0.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.4.0.tgz#50fb9615b05469591d2b2bd6dfaed2942ed72837" + integrity sha512-vwTUFf6V4zhcPkWp/4CQPr1TW9Ml6SF4lVyaIMBdJw5i6qUUJ1QWM4Z6YYVkfka0OUIzVo/0aNtGVGk256IKWw== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^2.0.2" + webidl-conversions "^6.1.0" + which-module@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" @@ -11683,14 +11698,6 @@ wordwrapjs@^4.0.0: reduce-flatten "^2.0.0" typical "^5.0.0" -wrap-ansi@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" - integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= - dependencies: - string-width "^1.0.1" - strip-ansi "^3.0.1" - wrap-ansi@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-3.0.1.tgz#288a04d87eda5c286e060dfe8f135ce8d007f8ba" @@ -11787,7 +11794,7 @@ ws@^6.0.0, ws@^6.2.1: dependencies: async-limiter "~1.0.0" -ws@^7.0.0: +ws@^7.2.3: version "7.3.1" resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== @@ -11797,12 +11804,7 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== -xml@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" - integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= - -xmlchars@^2.1.1: +xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== @@ -11812,7 +11814,7 @@ xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== -"y18n@^3.2.1 || ^4.0.0", y18n@^4.0.0: +y18n@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== @@ -11827,18 +11829,15 @@ yaml@^1.10.0: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== -yargs-parser@18.x, yargs-parser@^18.1.2, yargs-parser@^18.1.3: - version "18.1.3" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" - integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" +yargs-parser@20.x: + version "20.2.3" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.3.tgz#92419ba867b858c868acf8bae9bf74af0dd0ce26" + integrity sha512-emOFRT9WVHw03QSvN5qor9QQT9+sw5vwxfYweivSMHTcAXPefwVae2FjO7JJjj8hCE4CzPOPeFM83VwT29HCww== -yargs-parser@^11.1.1: - version "11.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" - integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ== +yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== dependencies: camelcase "^5.0.0" decamelize "^1.2.0" @@ -11851,23 +11850,29 @@ yargs-parser@^15.0.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs@12.0.5: - version "12.0.5" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" - integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw== +yargs-parser@^18.1.2, yargs-parser@^18.1.3: + version "18.1.3" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" + integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== dependencies: - cliui "^4.0.0" + camelcase "^5.0.0" decamelize "^1.2.0" + +yargs@^13.3.2: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" find-up "^3.0.0" - get-caller-file "^1.0.1" - os-locale "^3.0.0" + get-caller-file "^2.0.1" require-directory "^2.1.1" - require-main-filename "^1.0.1" + require-main-filename "^2.0.0" set-blocking "^2.0.0" - string-width "^2.0.0" + string-width "^3.0.0" which-module "^2.0.0" - y18n "^3.2.1 || ^4.0.0" - yargs-parser "^11.1.1" + y18n "^4.0.0" + yargs-parser "^13.1.2" yargs@^14.2.2: version "14.2.3" @@ -11886,7 +11891,7 @@ yargs@^14.2.2: y18n "^4.0.0" yargs-parser "^15.0.1" -yargs@^15.1.0, yargs@^15.3.1: +yargs@^15.1.0, yargs@^15.4.1: version "15.4.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== From afe90873bf3bc5081412405478200167244cebe4 Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Thu, 29 Oct 2020 16:55:27 +0300 Subject: [PATCH 009/581] chore(deps): update (#1999) --- package.json | 2 +- .../__tests__/addon-generator.test.ts | 3 +- packages/generators/package.json | 6 +- packages/generators/src/addon-generator.ts | 4 +- packages/migrate/package.json | 6 +- packages/utils/package.json | 16 +- packages/webpack-cli/package.json | 10 +- packages/webpack-scaffold/package.json | 6 +- yarn.lock | 556 ++++++++---------- 9 files changed, 256 insertions(+), 353 deletions(-) diff --git a/package.json b/package.json index 537f6218b4f..08d5ab483e9 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@commitlint/config-lerna-scopes": "^11.0.0", "@types/cross-spawn": "^6.0.2", "@types/jest": "^26.0.15", - "@types/node": "^14.14.5", + "@types/node": "^14.14.6", "@typescript-eslint/eslint-plugin": "^2.34.0", "@typescript-eslint/parser": "^2.34.0", "colorette": "^1.2.1", diff --git a/packages/generators/__tests__/addon-generator.test.ts b/packages/generators/__tests__/addon-generator.test.ts index d0958cd59f9..d8690c29f25 100644 --- a/packages/generators/__tests__/addon-generator.test.ts +++ b/packages/generators/__tests__/addon-generator.test.ts @@ -4,7 +4,6 @@ jest.setMock('@webpack-cli/utils', { import fs from 'fs'; import path from 'path'; -import mkdirp from 'mkdirp'; import rimraf from 'rimraf'; import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; import addonGenerator from '../src/addon-generator'; @@ -22,7 +21,7 @@ describe.skip('addon generator', () => { beforeAll(() => { rimraf.sync(testAssetsPath); - mkdirp.sync(genPath); + fs.mkdirSync(genPath, { recursive: true }); // set the working directory to here so that the addon directory is // generated in ./test-assets/test-addon process.chdir(genPath); diff --git a/packages/generators/package.json b/packages/generators/package.json index 1fb24fe7d30..347039741ed 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -18,7 +18,6 @@ "@webpack-cli/webpack-scaffold": "^1.0.2", "colorette": "^1.2.1", "log-symbols": "^4.0.0", - "mkdirp": "^1.0.4", "yeoman-generator": "^4.12.0" }, "peerDependencies": { @@ -26,10 +25,9 @@ "webpack-cli": "4.x.x" }, "devDependencies": { - "@types/mkdirp": "^1.0.0", "@types/yeoman-assert": "^3.1.1", - "@types/yeoman-generator": "^4.11.2", - "@types/yeoman-test": "^2.0.3", + "@types/yeoman-generator": "^4.11.3", + "@types/yeoman-test": "^2.0.5", "rimraf": "^3.0.2", "yeoman-assert": "^3.1.1", "yeoman-test": "^2.3.0" diff --git a/packages/generators/src/addon-generator.ts b/packages/generators/src/addon-generator.ts index 10fb9936512..538c837df20 100644 --- a/packages/generators/src/addon-generator.ts +++ b/packages/generators/src/addon-generator.ts @@ -1,5 +1,5 @@ import logger from 'webpack-cli/lib/utils/logger'; -import mkdirp from 'mkdirp'; +import fs from 'fs'; import path from 'path'; import Generator from 'yeoman-generator'; import { generatorCopy, generatorCopyTpl } from '@webpack-cli/utils'; @@ -53,7 +53,7 @@ const addonGenerator = ( `); const pathToProjectDir: string = this.destinationPath(this.props.name); try { - mkdirp.sync(pathToProjectDir); + fs.mkdirSync(pathToProjectDir, { recursive: true }); } catch (error) { logger.error('Failed to create directory'); logger.error(error); diff --git a/packages/migrate/package.json b/packages/migrate/package.json index 705eacf544d..c06ff92d938 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -15,8 +15,8 @@ "@webpack-cli/utils": "^1.0.2", "colorette": "^1.2.1", "diff": "^4.0.2", - "inquirer": "^7.1.0", - "jscodeshift": "^0.7.0", + "inquirer": "^7.3.3", + "jscodeshift": "^0.11.0", "listr": "^0.14.3", "p-each-series": "^2.1.0", "p-lazy": "^3.0.0" @@ -27,7 +27,7 @@ }, "devDependencies": { "@types/diff": "^4.0.2", - "@types/inquirer": "^6.5.0", + "@types/inquirer": "^7.3.1", "@types/listr": "^0.14.2" }, "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" diff --git a/packages/utils/package.json b/packages/utils/package.json index 26ad2dc1b04..87c1ef7fbc7 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -14,14 +14,14 @@ "dependencies": { "colorette": "^1.2.1", "cross-spawn": "^7.0.3", - "execa": "^4.0.0", + "execa": "^4.1.0", "findup-sync": "^4.0.0", "global-modules": "^2.0.0", - "got": "^10.7.0", - "jscodeshift": "^0.7.0", + "got": "^11.8.0", + "jscodeshift": "^0.11.0", "p-each-series": "^2.1.0", - "yeoman-environment": "^2.8.1", - "yeoman-generator": "^4.7.2" + "yeoman-environment": "^2.10.3", + "yeoman-generator": "^4.12.0" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", @@ -29,9 +29,9 @@ }, "devDependencies": { "@types/cross-spawn": "^6.0.2", - "@types/got": "9.6.9", - "@types/prettier": "1.19.0", - "@types/yeoman-generator": "^4.11.2" + "@types/got": "^9.6.11", + "@types/prettier": "^2.1.5", + "@types/yeoman-generator": "^4.11.3" }, "peerDependenciesMeta": { "prettier": { diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index d6024055b6a..c6e0534cd41 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -32,13 +32,13 @@ "ansi-escapes": "^4.3.1", "colorette": "^1.2.1", "command-line-usage": "^6.1.0", - "commander": "^6.0.0", - "enquirer": "^2.3.4", - "execa": "^4.0.0", + "commander": "^6.2.0", + "enquirer": "^2.3.6", + "execa": "^4.1.0", "import-local": "^3.0.2", - "interpret": "^2.0.0", + "interpret": "^2.2.0", "rechoir": "^0.7.0", - "v8-compile-cache": "^2.1.0", + "v8-compile-cache": "^2.2.0", "webpack-merge": "^4.2.2" }, "peerDependencies": { diff --git a/packages/webpack-scaffold/package.json b/packages/webpack-scaffold/package.json index 76dee7085f2..41e238c8e1a 100644 --- a/packages/webpack-scaffold/package.json +++ b/packages/webpack-scaffold/package.json @@ -12,11 +12,11 @@ "lib" ], "dependencies": { - "jscodeshift": "^0.7.0", - "yeoman-generator": "^4.7.2" + "jscodeshift": "^0.11.0", + "yeoman-generator": "^4.12.0" }, "devDependencies": { - "@types/yeoman-generator": "^4.11.2" + "@types/yeoman-generator": "^4.11.3" }, "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" } diff --git a/yarn.lock b/yarn.lock index 0f7675a01a6..2135c198799 100644 --- a/yarn.lock +++ b/yarn.lock @@ -70,18 +70,6 @@ browserslist "^4.12.0" semver "^5.5.0" -"@babel/helper-create-class-features-plugin@^7.12.0": - version "7.12.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.0.tgz#f3f2fc77bacc89e59ce6764daeabc1fb23e79a05" - integrity sha512-9tD1r9RK928vxvxcoNK8/7uwT7Q2DJZP1dnJmyMAJPwOF0yr8PPwqdpyw33lUpCfrJ765bOs5XNa4KSfUDWFSw== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-member-expression-to-functions" "^7.12.0" - "@babel/helper-optimise-call-expression" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-replace-supers" "^7.12.0" - "@babel/helper-split-export-declaration" "^7.10.4" - "@babel/helper-create-class-features-plugin@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.1.tgz#3c45998f431edd4a9214c5f1d3ad1448a6137f6e" @@ -112,11 +100,11 @@ lodash "^4.17.19" "@babel/helper-explode-assignable-expression@^7.10.4": - version "7.11.4" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.11.4.tgz#2d8e3470252cc17aba917ede7803d4a7a276a41b" - integrity sha512-ux9hm3zR4WV1Y3xXxXkdG/0gxF9nvI0YVmKVhvK9AfMoaQkemL3sJpXw+Xbz65azo8qJiEz2XVDUpK3KYhH3ZQ== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.12.1.tgz#8006a466695c4ad86a2a5f2fb15b5f2c31ad5633" + integrity sha512-dmUwH8XmlrUpVqgtZ737tK88v07l840z9j3OEhCLwKTkjlvKpfqXVIZ0wpK3aeOxspwGrf/5AP5qLx4rO3w5rA== dependencies: - "@babel/types" "^7.10.4" + "@babel/types" "^7.12.1" "@babel/helper-function-name@^7.10.4": version "7.10.4" @@ -141,13 +129,6 @@ dependencies: "@babel/types" "^7.10.4" -"@babel/helper-member-expression-to-functions@^7.12.0": - version "7.12.0" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.0.tgz#48f605fa801764f3e5b2e301e49d35fe1820c4f3" - integrity sha512-I0d/bgzgzgLsJMk7UZ0TN2KV3OGjC/t/9Saz8PKb9jrcEAXhgjGysOgp4PDKydIKjUv/gj2St4ae+ov8l+T9Xg== - dependencies: - "@babel/types" "^7.12.0" - "@babel/helper-member-expression-to-functions@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.1.tgz#fba0f2fcff3fba00e6ecb664bb5e6e26e2d6165c" @@ -205,16 +186,6 @@ "@babel/helper-wrap-function" "^7.10.4" "@babel/types" "^7.12.1" -"@babel/helper-replace-supers@^7.12.0": - version "7.12.0" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.12.0.tgz#98d3f3eb779752e59c7422ab387c9b444323be60" - integrity sha512-9kycFdq2c9e7PXZOr2z/ZqTFF9OzFu287iFwYS+CiDVPuoTCfY8hoTsIqNQNetQjlqoRsRyJFrMG1uhGAR4EEw== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.12.0" - "@babel/helper-optimise-call-expression" "^7.10.4" - "@babel/traverse" "^7.12.0" - "@babel/types" "^7.12.0" - "@babel/helper-replace-supers@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.12.1.tgz#f15c9cc897439281891e11d5ce12562ac0cf3fa9" @@ -257,9 +228,9 @@ integrity sha512-YpJabsXlJVWP0USHjnC/AQDTLlZERbON577YUVO/wLpqyj6HAtVYnWaQaN0iUN+1/tWn3c+uKKXjRut5115Y2A== "@babel/helper-wrap-function@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.10.4.tgz#8a6f701eab0ff39f765b5a1cfef409990e624b87" - integrity sha512-6py45WvEF0MhiLrdxtRjKjufwLL1/ob2qDJgg5JgNdojBAZSAKnAjkyOCNug6n+OBl4VW76XjvgSFTdaMcW0Ug== + version "7.12.3" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.12.3.tgz#3332339fc4d1fbbf1c27d7958c27d34708e990d9" + integrity sha512-Cvb8IuJDln3rs6tzjW3Y8UeelAOdnpB8xtQ4sme2MSZ9wOxrbThporC0y/EtE16VAtoyEfLM404Xr1e0OOp+ow== dependencies: "@babel/helper-function-name" "^7.10.4" "@babel/template" "^7.10.4" @@ -338,7 +309,7 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" -"@babel/plugin-proposal-nullish-coalescing-operator@^7.12.1": +"@babel/plugin-proposal-nullish-coalescing-operator@^7.1.0", "@babel/plugin-proposal-nullish-coalescing-operator@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.12.1.tgz#3ed4fff31c015e7f3f1467f190dbe545cd7b046c" integrity sha512-nZY0ESiaQDI1y96+jk6VxMOaL4LPo/QDHBqL+SF3/vl6dHkTwHlOI8L4ZwuRBHgakRBw5zsVylel7QPbbGuYgg== @@ -354,7 +325,7 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-numeric-separator" "^7.10.4" -"@babel/plugin-proposal-object-rest-spread@^7.0.0", "@babel/plugin-proposal-object-rest-spread@^7.12.1": +"@babel/plugin-proposal-object-rest-spread@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.12.1.tgz#def9bd03cea0f9b72283dac0ec22d289c7691069" integrity sha512-s6SowJIjzlhx8o7lsFx5zmY4At6CTtDvgNQDdPzkBQucle58A6b/TTeEBYtyDgmcXjUTM+vE8YOGHZzzbc/ioA== @@ -371,7 +342,7 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-optional-catch-binding" "^7.8.0" -"@babel/plugin-proposal-optional-chaining@^7.12.1": +"@babel/plugin-proposal-optional-chaining@^7.1.0", "@babel/plugin-proposal-optional-chaining@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.12.1.tgz#cce122203fc8a32794296fc377c6dedaf4363797" integrity sha512-c2uRpY6WzaVDzynVY9liyykS+kVU+WRZPMPYpkelXH8KBt1oXoI89kPbZKKG/jDT5UK92FTW2fZkZaJhdiBabw== @@ -431,10 +402,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" -"@babel/plugin-syntax-flow@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.10.4.tgz#53351dd7ae01995e567d04ce42af1a6e0ba846a6" - integrity sha512-yxQsX1dJixF4qEEdzVbst3SZQ58Nrooz8NV9Z9GL4byTE25BvJgl5lf0RECUf0fh28rZBb/RYTWn/eeKwCMrZQ== +"@babel/plugin-syntax-flow@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.12.1.tgz#a77670d9abe6d63e8acadf4c31bb1eb5a506bbdd" + integrity sha512-1lBLLmtxrwpm4VKmtVFselI/P3pX+G63fAtUUt6b2Nzgao77KNDwyuRt90Mj2/9pKobtt68FdvjfqohZjg/FCA== dependencies: "@babel/helper-plugin-utils" "^7.10.4" @@ -501,10 +472,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-syntax-typescript@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.10.4.tgz#2f55e770d3501e83af217d782cb7517d7bb34d25" - integrity sha512-oSAEz1YkBCAKr5Yiq8/BNtvSAPwkp/IyUnwZogd8p+F0RuYQQrLeRUzIQhueQTTBy/F+a40uS7OFKxnkRvmvFQ== +"@babel/plugin-syntax-typescript@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.12.1.tgz#460ba9d77077653803c3dd2e673f76d66b4029e5" + integrity sha512-UZNEcCY+4Dp9yYRCAHrHDU+9ZXLYaY9MgBXSRLkB9WjYFRR6quJBumfVrEkUxrePPBwFcpWfNKXqVRQQtm7mMA== dependencies: "@babel/helper-plugin-utils" "^7.10.4" @@ -589,13 +560,13 @@ "@babel/helper-builder-binary-assignment-operator-visitor" "^7.10.4" "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-flow-strip-types@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.10.4.tgz#c497957f09e86e3df7296271e9eb642876bf7788" - integrity sha512-XTadyuqNst88UWBTdLjM+wEY7BFnY2sYtPyAidfC7M/QaZnSuIZpMvLxqGT7phAcnGyWh/XQFLKcGf04CnvxSQ== +"@babel/plugin-transform-flow-strip-types@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.12.1.tgz#8430decfa7eb2aea5414ed4a3fa6e1652b7d77c4" + integrity sha512-8hAtkmsQb36yMmEtk2JZ9JnVyDSnDOdlB+0nEGzIDLuK4yR3JcEjfuFPYkdEPSh8Id+rAMeBEn+X0iVEyho6Hg== dependencies: "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-flow" "^7.10.4" + "@babel/plugin-syntax-flow" "^7.12.1" "@babel/plugin-transform-for-of@^7.12.1": version "7.12.1" @@ -635,7 +606,7 @@ "@babel/helper-plugin-utils" "^7.10.4" babel-plugin-dynamic-import-node "^2.3.3" -"@babel/plugin-transform-modules-commonjs@^7.12.1": +"@babel/plugin-transform-modules-commonjs@^7.1.0", "@babel/plugin-transform-modules-commonjs@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.12.1.tgz#fa403124542636c786cf9b460a0ffbb48a86e648" integrity sha512-dY789wq6l0uLY8py9c1B48V8mVL5gZh/+PQ5ZPrylPYsnAvnEMjqsUXkuoDVPeVK+0VyGar+D08107LzDQ6pag== @@ -751,14 +722,14 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-typescript@^7.12.0": - version "7.12.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.0.tgz#bd6422833a56e4268d8d599238f0b3c5e170078a" - integrity sha512-gahRNAWgE76hjI3TZPVEfV7vGjOCJi5ACd4eSoAItk/ErC114i2UHnk+1ScS2dOour0p6J6kB99hNFX2vzL2Ww== +"@babel/plugin-transform-typescript@^7.12.1": + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.1.tgz#d92cc0af504d510e26a754a7dbc2e5c8cd9c7ab4" + integrity sha512-VrsBByqAIntM+EYMqSm59SiMEf7qkmI9dqMt6RbD/wlwueWmYcI0FFK5Fj47pP6DRZm+3teXjosKlwcZJ5lIMw== dependencies: - "@babel/helper-create-class-features-plugin" "^7.12.0" + "@babel/helper-create-class-features-plugin" "^7.12.1" "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-typescript" "^7.10.4" + "@babel/plugin-syntax-typescript" "^7.12.1" "@babel/plugin-transform-unicode-escapes@^7.12.1": version "7.12.1" @@ -775,7 +746,7 @@ "@babel/helper-create-regexp-features-plugin" "^7.12.1" "@babel/helper-plugin-utils" "^7.10.4" -"@babel/preset-env@^7.1.6", "@babel/preset-env@^7.12.1": +"@babel/preset-env@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.1.tgz#9c7e5ca82a19efc865384bb4989148d2ee5d7ac2" integrity sha512-H8kxXmtPaAGT7TyBvSSkoSTUK6RHh61So05SyEbpmr0MCZrsNYn7mGMzzeYoOUCdHzww61k8XBft2TaES+xPLg== @@ -848,12 +819,12 @@ semver "^5.5.0" "@babel/preset-flow@^7.0.0": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.10.4.tgz#e0d9c72f8cb02d1633f6a5b7b16763aa2edf659f" - integrity sha512-XI6l1CptQCOBv+ZKYwynyswhtOKwpZZp5n0LG1QKCo8erRhqjoQV6nvx61Eg30JHpysWQSBwA2AWRU3pBbSY5g== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.12.1.tgz#1a81d376c5a9549e75352a3888f8c273455ae940" + integrity sha512-UAoyMdioAhM6H99qPoKvpHMzxmNVXno8GYU/7vZmGaHk6/KqfDYL1W0NxszVbJ2EP271b7e6Ox+Vk2A9QsB3Sw== dependencies: "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-transform-flow-strip-types" "^7.10.4" + "@babel/plugin-transform-flow-strip-types" "^7.12.1" "@babel/preset-modules@^0.1.3": version "0.1.4" @@ -867,17 +838,17 @@ esutils "^2.0.2" "@babel/preset-typescript@^7.1.0": - version "7.12.0" - resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.12.0.tgz#3fe6b4958ca6fb0e086dc5574a27d0ced99185e8" - integrity sha512-2XVy4sy/zkP4gqmXW0TzSh/QwOniN2Cy3srhsD0TRBlMTOmjaYnWCWA6aWopwpcwfYkEKD6jKLLjYMq15zDNWg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.12.1.tgz#86480b483bb97f75036e8864fe404cc782cc311b" + integrity sha512-hNK/DhmoJPsksdHuI/RVrcEws7GN5eamhi28JkO52MqIxU8Z0QpmiSOQxZHWOHV7I3P4UjHV97ay4TcamMA6Kw== dependencies: "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-transform-typescript" "^7.12.0" + "@babel/plugin-transform-typescript" "^7.12.1" "@babel/register@^7.0.0": - version "7.12.0" - resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.12.0.tgz#fa5fa900bd79380ff508ae963a5766172d3a9e56" - integrity sha512-2F2v0qYSAwrGyK9mZ8lIoUluHRzLTgkJ2oRXlLV9GVe/ze/sTFBiOocLRMSJYDB2lLiABlVC+pZHlZ8qihO1Xg== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.12.1.tgz#cdb087bdfc4f7241c03231f22e15d211acf21438" + integrity sha512-XWcmseMIncOjoydKZnWvWi0/5CUCD+ZYKhRwgYlWOrA8fGZ/FjuLRpqtIhLOVD/fvR1b9DQHtZPn68VvhpYf+Q== dependencies: find-cache-dir "^2.0.0" lodash "^4.17.19" @@ -886,9 +857,9 @@ source-map-support "^0.5.16" "@babel/runtime@^7.11.2", "@babel/runtime@^7.8.4": - version "7.12.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.0.tgz#98bd7666186969c04be893d747cf4a6c6c8fa6b0" - integrity sha512-lS4QLXQ2Vbw2ubfQjeQcn+BZgZ5+ROHW9f+DWjEp5Y+NHYmkRGKqHSJ1tuhbUauKu2nhZNTBIvsIQ8dXfY5Gjw== + version "7.12.1" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.1.tgz#b4116a6b6711d010b2dad3b7b6e43bf1b9954740" + integrity sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA== dependencies: regenerator-runtime "^0.13.4" @@ -901,7 +872,7 @@ "@babel/parser" "^7.10.4" "@babel/types" "^7.10.4" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.0", "@babel/traverse@^7.12.1": +"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.1.tgz#941395e0c5cc86d5d3e75caa095d3924526f0c1e" integrity sha512-MA3WPoRt1ZHo2ZmoGKNqi20YnPt0B1S0GTZEPhhd+hw2KGUzBlHuVunj6K4sNuK+reEvyiPwtp0cpaqLzJDmAw== @@ -916,7 +887,7 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.0", "@babel/types@^7.12.1", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": +"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.1.tgz#e109d9ab99a8de735be287ee3d6a9947a190c4ae" integrity sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA== @@ -2106,9 +2077,9 @@ "@octokit/types" "^2.0.1" "@octokit/plugin-request-log@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" - integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== + version "1.0.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.2.tgz#394d59ec734cd2f122431fbaf05099861ece3c44" + integrity sha512-oTJSNAmBqyDR41uSMunLQKMX0jmEXbwD1fpz8FG27lScV3RhtGfBa1/BBLym+PxcC16IBlF7KH9vP1BUYxA+Eg== "@octokit/plugin-rest-endpoint-methods@2.4.0": version "2.4.0" @@ -2193,10 +2164,10 @@ dependencies: any-observable "^0.3.0" -"@sindresorhus/is@^2.0.0": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-2.1.1.tgz#ceff6a28a5b4867c2dd4a1ba513de278ccbe8bb1" - integrity sha512-/aPsuoj/1Dw/kzhkgz+ES6TxG0zfTMGLwuK2ZG00k/iJzYHTLCE8mVU8EPqEOp/lmxPoq1C1C9RYToRKb2KEfg== +"@sindresorhus/is@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.0.0.tgz#2ff674e9611b45b528896d820d3d7a812de2f0e4" + integrity sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ== "@sinonjs/commons@^1", "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.1": version "1.8.1" @@ -2234,7 +2205,7 @@ resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5" integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ== -"@szmarczak/http-timer@^4.0.0": +"@szmarczak/http-timer@^4.0.5": version "4.0.5" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.5.tgz#bfbd50211e9dfa51ba07da58a14cdfd333205152" integrity sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ== @@ -2302,9 +2273,9 @@ integrity sha512-mIenTfsIe586/yzsyfql69KRnA75S8SVXQbTLpDejRrjH0QSJcpu3AUOi/Vjnt9IOsXKxPhJfGpQUNMueIU1fQ== "@types/ejs@*": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@types/ejs/-/ejs-3.0.4.tgz#8851fcdedb96e410fbb24f83b8be6763ef9afa77" - integrity sha512-ZxnwyBGO4KX/82AsFHTX82eMw0PsoBcIngEat+zx0y+3yxoNDJucAihg9nAcrc+g4Cwiv/4WcWsX4oiy0ySrRQ== + version "3.0.5" + resolved "https://registry.yarnpkg.com/@types/ejs/-/ejs-3.0.5.tgz#95a3a1c3d9603eba80fe67ff56da1ba275ef2eda" + integrity sha512-k4ef69sS4sIqAPW9GoBnN+URAON2LeL1H0duQvL4RgdEBna19/WattYSA1qYqvbVEDRTSWzOw56tCLhC/m/IOw== "@types/eslint-scope@^3.7.0": version "3.7.0" @@ -2345,19 +2316,19 @@ "@types/minimatch" "*" "@types/node" "*" -"@types/got@9.6.9": - version "9.6.9" - resolved "https://registry.yarnpkg.com/@types/got/-/got-9.6.9.tgz#b3192188b96c871b9c67dc80d1b0336441432a38" - integrity sha512-w+ZE+Ovp6fM+1sHwJB7RN3f3pTJHZkyABuULqbtknqezQyWadFEp5BzOXaZzRqAw2md6/d3ybxQJt+BNgpvzOg== +"@types/got@^9.6.11": + version "9.6.11" + resolved "https://registry.yarnpkg.com/@types/got/-/got-9.6.11.tgz#482b402cc5ee459481aeeadb08142ebb1a9afb26" + integrity sha512-dr3IiDNg5TDesGyuwTrN77E1Cd7DCdmCFtEfSGqr83jMMtcwhf/SGPbN2goY4JUWQfvxwY56+e5tjfi+oXeSdA== dependencies: "@types/node" "*" "@types/tough-cookie" "*" form-data "^2.5.0" "@types/graceful-fs@^4.1.2": - version "4.1.3" - resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.3.tgz#039af35fe26bec35003e8d86d2ee9c586354348f" - integrity sha512-AiHRaEB50LQg0pZmm659vNBb9f4SJ0qrAnteuzhSeAUcJKxoYgEnprg/83kppCnc2zvtCKbdZry1a5pVY3lOTQ== + version "4.1.4" + resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.4.tgz#4ff9f641a7c6d1a3508ff88bc3141b152772e753" + integrity sha512-mWA/4zFQhfvOA8zWkXobwJvBD7vzcxgrOQ0J5CH1votGqdq9m7+FwtGaqyCZqC3NyyBkc9z4m+iry4LlqcMWJg== dependencies: "@types/node" "*" @@ -2366,7 +2337,7 @@ resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a" integrity sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A== -"@types/inquirer@*": +"@types/inquirer@*", "@types/inquirer@^7.3.1": version "7.3.1" resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-7.3.1.tgz#1f231224e7df11ccfaf4cf9acbcc3b935fea292d" integrity sha512-osD38QVIfcdgsPCT0V3lD7eH0OFurX71Jft18bZrsVQWVRt6TuxRzlr0GJLrxoHZR2V5ph7/qP8se/dcnI7o0g== @@ -2374,14 +2345,6 @@ "@types/through" "*" rxjs "^6.4.0" -"@types/inquirer@^6.5.0": - version "6.5.0" - resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-6.5.0.tgz#b83b0bf30b88b8be7246d40e51d32fe9d10e09be" - integrity sha512-rjaYQ9b9y/VFGOpqBEXRavc3jh0a+e6evAbI31tMda8VlPaSy0AZJfXsvmIe3wklc7W6C3zCSfleuMXR7NOyXw== - dependencies: - "@types/through" "*" - rxjs "^6.4.0" - "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": version "2.0.3" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz#4ba8ddb720221f432e443bd5f9117fd22cfd4762" @@ -2414,7 +2377,7 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== -"@types/keyv@*", "@types/keyv@^3.1.1": +"@types/keyv@*": version "3.1.1" resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.1.tgz#e45a45324fca9dab716ab1230ee249c9fb52cfa7" integrity sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw== @@ -2459,22 +2422,10 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= -"@types/mkdirp@^1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-1.0.1.tgz#0930b948914a78587de35458b86c907b6e98bbf6" - integrity sha512-HkGSK7CGAXncr8Qn/0VqNtExEE+PHMWb+qlR1faHMao7ng6P3tAaoWWBMdva0gL5h4zprjIO89GJOLXsMcDm1Q== - dependencies: - "@types/node" "*" - -"@types/node@*", "@types/node@>= 8": - version "14.11.8" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.8.tgz#fe2012f2355e4ce08bca44aeb3abbb21cf88d33f" - integrity sha512-KPcKqKm5UKDkaYPTuXSx8wEP7vE9GnuaXIZKijwRYcePpZFDVuy2a57LarFKiORbHOuTOOwYzxVxcUzsh2P2Pw== - -"@types/node@^14.14.5": - version "14.14.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.5.tgz#e92d3b8f76583efa26c1a63a21c9d3c1143daa29" - integrity sha512-H5Wn24s/ZOukBmDn03nnGTp18A60ny9AmCwnEcgJiTgSGsCO7k+NWP7zjCCbhlcnVCoI+co52dUAt9GMhOSULw== +"@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": + version "14.14.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.6.tgz#146d3da57b3c636cc0d1769396ce1cfa8991147f" + integrity sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -2486,17 +2437,12 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== -"@types/prettier@1.19.0": - version "1.19.0" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.0.tgz#a2502fb7ce9b6626fdbfc2e2a496f472de1bdd05" - integrity sha512-gDE8JJEygpay7IjA/u3JiIURvwZW08f0cZSZLAzFoX/ZmeqvS0Sqv+97aKuHpNsalAMMhwPe+iAS6fQbfmbt7A== - -"@types/prettier@^2.0.0": +"@types/prettier@^2.0.0", "@types/prettier@^2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.5.tgz#b6ab3bba29e16b821d84e09ecfaded462b816b00" integrity sha512-UEyp8LwZ4Dg30kVU2Q3amHHyTn1jEdhCIE59ANed76GaT1Vp76DD3ZWSAxgCrw6wJ0TqeoBpqmfUHiUDPs//HQ== -"@types/responselike@*": +"@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== @@ -2539,9 +2485,9 @@ integrity sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw== "@types/yargs@^15.0.0": - version "15.0.8" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.8.tgz#7644904cad7427eb704331ea9bf1ee5499b82e23" - integrity sha512-b0BYzFUzBpOhPjpl1wtAHU994jBeKF4TKVlT7ssFv44T617XNcPdRoG4AzHLVshLzlrF7i3lTelH7UbuNYV58Q== + version "15.0.9" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.9.tgz#524cd7998fe810cdb02f26101b699cccd156ff19" + integrity sha512-HmU8SeIRhZCWcnRskCs36Q1Q00KBV6Cqh/ora8WN1+22dY07AZdn6Gel8QZ3t26XYPImtcL8WV/eqjhVmMEw4g== dependencies: "@types/yargs-parser" "*" @@ -2551,9 +2497,9 @@ integrity sha512-ACDlMVhoLIA3VQPFKtJWlr3evUE3DaEbVxi1ukivBRNB1havMW+vo2J0+hNURF19yiqs7iu+yUHLG25bCi2xcw== "@types/yeoman-environment@*": - version "2.10.1" - resolved "https://registry.yarnpkg.com/@types/yeoman-environment/-/yeoman-environment-2.10.1.tgz#fc979808dfec9cc712b3553ceeb147747688bcc2" - integrity sha512-kQsGzveMwoP/MnipjggDT77ozoq592bDLastlGX8FT/8mwpJ1I6C9y4duk8KxxaO0JNTOGy9rC/ghd7BWG6YmQ== + version "2.10.2" + resolved "https://registry.yarnpkg.com/@types/yeoman-environment/-/yeoman-environment-2.10.2.tgz#008b4f7a350ff8fb2be7ad7dda2580ead048ee76" + integrity sha512-Vz0qYnsUkTdH15nYo1OKax6wODQvPk6OKnbr3ATWRFizMTn6FhtoInuOIxVELK9swdqhAOF1goSdWhid0HmJkg== dependencies: "@types/diff" "*" "@types/inquirer" "*" @@ -2563,7 +2509,7 @@ chalk "^4.1.0" rxjs ">=6.4.0" -"@types/yeoman-generator@*", "@types/yeoman-generator@^4.11.2": +"@types/yeoman-generator@*", "@types/yeoman-generator@^4.11.3": version "4.11.3" resolved "https://registry.yarnpkg.com/@types/yeoman-generator/-/yeoman-generator-4.11.3.tgz#3b4c0040cf0c28237dd9f535a15c620d3f68c5f4" integrity sha512-bZRBRahUEs10YhPC4zTKwX5h1mfoFT4Qvav+z0WyT37SgKK9IgIozn8/k6IF9h9PNkxpAhFcER5llwdzCyFZnw== @@ -2575,7 +2521,7 @@ "@types/yeoman-environment" "*" rxjs ">=6.4.0" -"@types/yeoman-test@^2.0.3": +"@types/yeoman-test@^2.0.5": version "2.0.5" resolved "https://registry.yarnpkg.com/@types/yeoman-test/-/yeoman-test-2.0.5.tgz#91131a779237b599e477de555b607a2e850b4c71" integrity sha512-BYJFfJ8o341YnOOkzm0Qw3v3C8t/3WSMXTYUepSa7IIBG+PFU14/v+X90llzaNBYjpvDCjhj16H7GY2R874IiQ== @@ -3118,10 +3064,12 @@ assign-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= -ast-types@0.13.3: - version "0.13.3" - resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.3.tgz#50da3f28d17bdbc7969a3a2d83a0e4a72ae755a7" - integrity sha512-XTZ7xGML849LkQP86sWdQzfhwbt3YwIO6MqbX9mUNYY98VKaaVZP7YNNm70IpwecbkkxmfC5IYAzOQ/2p29zRA== +ast-types@0.14.2: + version "0.14.2" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.14.2.tgz#600b882df8583e3cd4f2df5fa20fa83759d4bdfd" + integrity sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA== + dependencies: + tslib "^2.0.1" astral-regex@^1.0.0: version "1.0.0" @@ -3496,13 +3444,10 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" -cacheable-lookup@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-2.0.1.tgz#87be64a18b925234875e10a9bb1ebca4adce6b38" - integrity sha512-EMMbsiOTcdngM/K6gV/OxF2x0t07+vMOWxZNSCRQMjO2MY2nhZQ6OYhOOpyQrbhqsgtvKGI7hcq6xjnA92USjg== - dependencies: - "@types/keyv" "^3.1.1" - keyv "^4.0.0" +cacheable-lookup@^5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.3.tgz#049fdc59dffdd4fc285e8f4f82936591bd59fec3" + integrity sha512-W+JBqF9SWe18A72XFzN/V/CULFzPm7sBXzzR6ekkE+3tLG72wFZrBiBZhrZuDoYexop4PHJVdFAKb/Nj9+tm9w== cacheable-request@^7.0.1: version "7.0.1" @@ -3588,14 +3533,14 @@ camelcase@^5.0.0, camelcase@^5.3.1: integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== camelcase@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.1.0.tgz#27dc176173725fb0adf8a48b647f4d7871944d78" - integrity sha512-WCMml9ivU60+8rEJgELlFp1gxFcEGxwYleE3bziHEDeqsqAWGHdimB7beBFGjLzVNgPGyDsfgXLQEYMpmIFnVQ== + version "6.2.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" + integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== caniuse-lite@^1.0.30001135: - version "1.0.30001148" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001148.tgz#dc97c7ed918ab33bf8706ddd5e387287e015d637" - integrity sha512-E66qcd0KMKZHNJQt9hiLZGE3J4zuTqE1OnU53miEVtylFbwOEmeA5OsRu90noZful+XGSQOni1aT2tiqu/9yYw== + version "1.0.30001153" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001153.tgz#9a0942fe777cd7178fb084693b79415ff747ecd9" + integrity sha512-qv14w7kWwm2IW7DBvAKWlCqGTmV2XxNtSejJBVplwRjhkohHuhRUpeSlPjtu9erru0+A12zCDUiSmvx/AcqVRA== capture-exit@^2.0.0: version "2.0.0" @@ -3915,7 +3860,7 @@ commander@^2.18.0, commander@^2.20.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^6.0.0: +commander@^6.0.0, commander@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q== @@ -4356,12 +4301,12 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -decompress-response@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-5.0.0.tgz#7849396e80e3d1eba8cb2f75ef4930f76461cb0f" - integrity sha512-TLZWWybuxWgoW7Lykv+gq9xvzOsUjQ9tF09Tj6NSTYGMTCHNXzrPnD6Hi+TgZq19PyTAGH4Ll/NIM/eTGglnMw== +decompress-response@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" + integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== dependencies: - mimic-response "^2.0.0" + mimic-response "^3.1.0" dedent@^0.7.0: version "0.7.0" @@ -4685,9 +4630,9 @@ ejs@^3.0.1: jake "^10.6.1" electron-to-chromium@^1.3.571: - version "1.3.579" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.579.tgz#58bf17499de6edf697e1442017d8569bce0d301a" - integrity sha512-9HaGm4UDxCtcmIqWWdv79pGgpRZWTqr+zg6kxp0MelSHfe1PNjrI8HXy1HgTSy4p0iQETGt8/ElqKFLW008BSA== + version "1.3.584" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.584.tgz#506cf7ba5895aafa8241876ab028654b61fd9ceb" + integrity sha512-NB3DzrTzJFhWkUp+nl2KtUtoFzrfGXTir2S+BU4tXGyXH9vlluPuFpE3pTKeH7+PY460tHLjKzh6K2+TWwW+Ww== elegant-spinner@^1.0.1: version "1.0.1" @@ -4736,7 +4681,7 @@ enhanced-resolve@^5.3.1: graceful-fs "^4.2.4" tapable "^2.0.0" -enquirer@^2.3.4, enquirer@^2.3.5, enquirer@^2.3.6: +enquirer@^2.3.5, enquirer@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== @@ -4784,7 +4729,7 @@ error@^7.0.2: dependencies: string-template "~0.2.1" -es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: +es-abstract@^1.17.0-next.1: version "1.17.7" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.7.tgz#a4de61b2f66989fc7421676c1cb9787573ace54c" integrity sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g== @@ -5062,22 +5007,7 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execa@^4.0.0, execa@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/execa/-/execa-4.0.3.tgz#0a34dabbad6d66100bd6f2c576c8669403f317f2" - integrity sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A== - dependencies: - cross-spawn "^7.0.0" - get-stream "^5.0.0" - human-signals "^1.1.1" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.0" - onetime "^5.1.0" - signal-exit "^3.0.2" - strip-final-newline "^2.0.0" - -execa@^4.1.0: +execa@^4.0.0, execa@^4.0.3, execa@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== @@ -5263,9 +5193,9 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= fastq@^1.6.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.8.0.tgz#550e1f9f59bbc65fe185cb6a9b4d95357107f481" - integrity sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q== + version "1.9.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.9.0.tgz#e16a72f338eaca48e91b5c23593bcc2ef66b7947" + integrity sha512-i7FVWL8HhVY+CTkwFxkN2mk3h+787ixS5S63eb78diVRc1MCssarHq3W5cj0av7YDSwmaV928RNag+U1etRQ7w== dependencies: reusify "^1.0.4" @@ -5464,9 +5394,9 @@ flatted@^2.0.0: integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== flow-parser@0.*: - version "0.135.0" - resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.135.0.tgz#6fa98be0cd4d3b214cc9f121c86a070e312649ce" - integrity sha512-ev8SvmG+XU9D6WgHVezP4kY3Myr1tJvTUTEi7mbhhj+rn889K7YXdakte6oqXNLIJYJ2f5Fuw18zXTVa1NO8Kw== + version "0.137.0" + resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.137.0.tgz#8c05612ff9344648d8bcdeaa4c58d131e875d842" + integrity sha512-i3KXJZ8lhlQI0n+BoZzIeH/rv+fNvAiu1i9/s64MklBV+HuhFbycUML7367J2eng0gapLnwvYPFNaPZys8POsA== flush-write-stream@^1.0.0: version "1.1.1" @@ -5625,9 +5555,9 @@ genfun@^5.0.0: integrity sha512-KGDOARWVga7+rnB3z9Sd2Letx515owfk0hSxHGuqjANb1M+x2bGZGqHLiozPsYMdM2OubeMni/Hpwmjq6qIUhA== gensync@^1.0.0-beta.1: - version "1.0.0-beta.1" - resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269" - integrity sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg== + version "1.0.0-beta.2" + resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" + integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== get-caller-file@^2.0.1: version "2.0.5" @@ -5771,9 +5701,9 @@ git-up@^4.0.0: parse-url "^5.0.0" git-url-parse@^11.1.2: - version "11.3.0" - resolved "https://registry.yarnpkg.com/git-url-parse/-/git-url-parse-11.3.0.tgz#1515b4574c4eb2efda7d25cc50b29ce8beaefaae" - integrity sha512-i3XNa8IKmqnUqWBcdWBjOcnyZYfN3C1WRvnKI6ouFWwsXCZEnlgbwbm55ZpJ3OJMhfEP/ryFhqW8bBhej3C5Ug== + version "11.4.0" + resolved "https://registry.yarnpkg.com/git-url-parse/-/git-url-parse-11.4.0.tgz#f2bb1f2b00f05552540e95a62e31399a639a6aa6" + integrity sha512-KlIa5jvMYLjXMQXkqpFzobsyD/V2K5DRHl5OAf+6oDFPlPLxrGDVQlIdI63c4/Kt6kai4kALENSALlzTGST3GQ== dependencies: git-up "^4.0.0" @@ -5935,26 +5865,22 @@ globby@^9.2.0: pify "^4.0.1" slash "^2.0.0" -got@^10.7.0: - version "10.7.0" - resolved "https://registry.yarnpkg.com/got/-/got-10.7.0.tgz#62889dbcd6cca32cd6a154cc2d0c6895121d091f" - integrity sha512-aWTDeNw9g+XqEZNcTjMMZSy7B7yE9toWOFYip7ofFTLleJhvZwUxxTxkTpKvF+p1SAA4VHmuEy7PiHTHyq8tJg== +got@^11.8.0: + version "11.8.0" + resolved "https://registry.yarnpkg.com/got/-/got-11.8.0.tgz#be0920c3586b07fd94add3b5b27cb28f49e6545f" + integrity sha512-k9noyoIIY9EejuhaBNLyZ31D5328LeqnyPNXJQb2XlJZcKakLqN5m6O/ikhq/0lw56kUYS54fVm+D1x57YC9oQ== dependencies: - "@sindresorhus/is" "^2.0.0" - "@szmarczak/http-timer" "^4.0.0" + "@sindresorhus/is" "^4.0.0" + "@szmarczak/http-timer" "^4.0.5" "@types/cacheable-request" "^6.0.1" - cacheable-lookup "^2.0.0" + "@types/responselike" "^1.0.0" + cacheable-lookup "^5.0.3" cacheable-request "^7.0.1" - decompress-response "^5.0.0" - duplexer3 "^0.1.4" - get-stream "^5.0.0" + decompress-response "^6.0.0" + http2-wrapper "^1.0.0-beta.5.2" lowercase-keys "^2.0.0" - mimic-response "^2.1.0" p-cancelable "^2.0.0" - p-event "^4.0.0" responselike "^2.0.0" - to-readable-stream "^2.0.0" - type-fest "^0.10.0" got@^6.2.0: version "6.7.1" @@ -6237,6 +6163,14 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" +http2-wrapper@^1.0.0-beta.5.2: + version "1.0.0-beta.5.2" + resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz#8b923deb90144aea65cf834b016a340fc98556f3" + integrity sha512-xYz9goEyBnC8XwXDTuC/MZ6t+MrKVQZOk4s7+PaDkwIsQd8IwqvM+0M6bA/2lvG8GHXcPdf+MejTUeO2LCPCeQ== + dependencies: + quick-lru "^5.1.1" + resolve-alpn "^1.0.0" + https-proxy-agent@^2.2.3: version "2.2.4" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" @@ -6436,7 +6370,7 @@ inquirer@^6.2.0, inquirer@^6.3.1: strip-ansi "^5.1.0" through "^2.3.6" -inquirer@^7.1.0: +inquirer@^7.1.0, inquirer@^7.3.3: version "7.3.3" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003" integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA== @@ -6468,7 +6402,7 @@ interpret@^1.0.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA== -interpret@^2.0.0: +interpret@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== @@ -7303,15 +7237,6 @@ jest-watcher@^26.3.0, jest-watcher@^26.6.1: jest-util "^26.6.1" string-length "^4.0.1" -jest-worker@^26.5.0: - version "26.5.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.5.0.tgz#87deee86dbbc5f98d9919e0dadf2c40e3152fa30" - integrity sha512-kTw66Dn4ZX7WpjZ7T/SUDgRhapFRKWmisVAF0Rv4Fu8SLFD7eLbqpLvbxVqYhSgaWa7I+bW7pHnbyfNsH6stug== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^7.0.0" - jest-worker@^26.6.1: version "26.6.1" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.1.tgz#c2ae8cde6802cc14056043f997469ec170d9c32a" @@ -7348,27 +7273,28 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= -jscodeshift@^0.7.0: - version "0.7.1" - resolved "https://registry.yarnpkg.com/jscodeshift/-/jscodeshift-0.7.1.tgz#0236ad475d6f0770ca998a0160925d62b57d2507" - integrity sha512-YMkZSyoc8zg5woZL23cmWlnFLPH/mHilonGA7Qbzs7H6M4v4PH0Qsn4jeDyw+CHhVoAnm9UxQyB0Yw1OT+mktA== +jscodeshift@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/jscodeshift/-/jscodeshift-0.11.0.tgz#4f95039408f3f06b0e39bb4d53bc3139f5330e2f" + integrity sha512-SdRK2C7jjs4k/kT2mwtO07KJN9RnjxtKn03d9JVj6c3j9WwaLcFYsICYDnLAzY0hp+wG2nxl+Cm2jWLiNVYb8g== dependencies: "@babel/core" "^7.1.6" "@babel/parser" "^7.1.6" "@babel/plugin-proposal-class-properties" "^7.1.0" - "@babel/plugin-proposal-object-rest-spread" "^7.0.0" - "@babel/preset-env" "^7.1.6" + "@babel/plugin-proposal-nullish-coalescing-operator" "^7.1.0" + "@babel/plugin-proposal-optional-chaining" "^7.1.0" + "@babel/plugin-transform-modules-commonjs" "^7.1.0" "@babel/preset-flow" "^7.0.0" "@babel/preset-typescript" "^7.1.0" "@babel/register" "^7.0.0" babel-core "^7.0.0-bridge.0" colors "^1.1.2" flow-parser "0.*" - graceful-fs "^4.1.11" + graceful-fs "^4.2.4" micromatch "^3.1.10" neo-async "^2.5.0" node-dir "^0.1.17" - recast "^0.18.1" + recast "^0.20.3" temp "^0.8.1" write-file-atomic "^2.3.0" @@ -8164,10 +8090,10 @@ mimic-response@^1.0.0: resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== -mimic-response@^2.0.0, mimic-response@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-2.1.0.tgz#d13763d35f613d09ec37ebb30bac0469c0ee8f43" - integrity sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA== +mimic-response@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" + integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== min-indent@^1.0.0: version "1.0.1" @@ -8254,7 +8180,7 @@ mkdirp-promise@^5.0.1: dependencies: mkdirp "*" -mkdirp@*, mkdirp@1.x, mkdirp@^1.0.0, mkdirp@^1.0.3, mkdirp@^1.0.4: +mkdirp@*, mkdirp@1.x, mkdirp@^1.0.0, mkdirp@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== @@ -8475,9 +8401,9 @@ node-notifier@^8.0.0: which "^2.0.2" node-releases@^1.1.61: - version "1.1.61" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.61.tgz#707b0fca9ce4e11783612ba4a2fcba09047af16e" - integrity sha512-DD5vebQLg8jLCOzwupn954fbIiZht05DAZs0k2u8NStSe6h9XdsuIQL8hSRKYiU8WUQRznmSDrKGbv3ObOmC7g== + version "1.1.64" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.64.tgz#71b4ae988e9b1dd7c1ffce58dd9e561752dfebc5" + integrity sha512-Iec8O9166/x2HRMJyLLLWkd0sFFLrFNy+Xf+JQfSQsdBJzPcHpNl3JQ9gD4j+aJxmCa25jNsIbM4bmACtSbkSg== nopt@^4.0.1: version "4.0.3" @@ -8815,13 +8741,6 @@ p-each-series@^2.1.0: resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.1.0.tgz#961c8dd3f195ea96c747e636b262b800a6b1af48" integrity sha512-ZuRs1miPT4HrjFa+9fRfOFXxGJfORgelKV9f9nNOWw2gl6gVsRaVDOQP0+MI0G0wGKns1Yacsu0GjOFbTK0JFQ== -p-event@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/p-event/-/p-event-4.2.0.tgz#af4b049c8acd91ae81083ebd1e6f5cae2044c1b5" - integrity sha512-KXatOjCRXXkSePPb1Nbi0p0m+gQAwdlbhi4wQKJPI1HsMQS9g+Sqp2o+QHziPr7eYJyOZet836KoHEVM1mwOrQ== - dependencies: - p-timeout "^3.1.0" - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -8931,13 +8850,6 @@ p-retry@^3.0.1: dependencies: retry "^0.12.0" -p-timeout@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-3.2.0.tgz#c7e17abc971d2a7962ef83626b35d635acf23dfe" - integrity sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg== - dependencies: - p-finally "^1.0.0" - p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" @@ -9247,11 +9159,6 @@ pretty-format@^26.0.0, pretty-format@^26.6.1: ansi-styles "^4.0.0" react-is "^17.0.1" -private@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" - integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== - process-nextick-args@^2.0.0, process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" @@ -9276,12 +9183,12 @@ promise-retry@^1.1.1: retry "^0.10.0" prompts@^2.0.1: - version "2.3.2" - resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.3.2.tgz#480572d89ecf39566d2bd3fe2c9fccb7c4c0b068" - integrity sha512-Q06uKs2CkNYVID0VqwfAl9mipo99zkBv/n2JtWY89Yxa3ZabWSrs0e2KTudKVa3peLUvYXMefDqIleLPVUBZMA== + version "2.4.0" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.0.tgz#4aa5de0723a231d1ee9121c40fdf663df73f61d7" + integrity sha512-awZAKrk3vN6CroQukBL+R9051a4R3zCZBlJm/HBfrSZ8iTpYix3VX1vU4mveiLpiwmOJT4wokTF9m6HUk4KqWQ== dependencies: kleur "^3.0.3" - sisteransi "^1.0.4" + sisteransi "^1.0.5" promzard@^0.3.0: version "0.3.0" @@ -9395,6 +9302,11 @@ quick-lru@^4.0.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== +quick-lru@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" + integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== + randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" @@ -9565,15 +9477,15 @@ readdirp@^2.2.1: micromatch "^3.1.10" readable-stream "^2.0.2" -recast@^0.18.1: - version "0.18.10" - resolved "https://registry.yarnpkg.com/recast/-/recast-0.18.10.tgz#605ebbe621511eb89b6356a7e224bff66ed91478" - integrity sha512-XNvYvkfdAN9QewbrxeTOjgINkdY/odTgTS56ZNEWL9Ml0weT4T3sFtvnTuF+Gxyu46ANcRm1ntrF6F5LAJPAaQ== +recast@^0.20.3: + version "0.20.4" + resolved "https://registry.yarnpkg.com/recast/-/recast-0.20.4.tgz#db55983eac70c46b3fff96c8e467d65ffb4a7abc" + integrity sha512-6qLIBGGRcwjrTZGIiBpJVC/NeuXpogXNyRQpqU1zWPUigCphvApoCs9KIwDYh1eDuJ6dAFlQoi/QUyE5KQ6RBQ== dependencies: - ast-types "0.13.3" + ast-types "0.14.2" esprima "~4.0.0" - private "^0.1.8" source-map "~0.6.1" + tslib "^2.0.1" rechoir@^0.6.2: version "0.6.2" @@ -9771,6 +9683,11 @@ requires-port@^1.0.0: resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= +resolve-alpn@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.0.0.tgz#745ad60b3d6aff4b4a48e01b8c0bdc70959e0e8c" + integrity sha512-rTuiIEqFmGxne4IovivKSDzld2lWW9QCjqv80SYjPgf+gS35eaCAjaP54CCwGAwBtnCsvNLYtqxe1Nw+i6JEmA== + resolve-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" @@ -9827,14 +9744,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.3.2, resolve@^1.9.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -resolve@^1.18.1: +resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.9.0: version "1.18.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.18.1.tgz#018fcb2c5b207d2a6424aee361c5a266da8f4130" integrity sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA== @@ -9917,9 +9827,9 @@ run-async@^2.0.0, run-async@^2.2.0, run-async@^2.4.0: integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== run-parallel@^1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679" - integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q== + version "1.1.10" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.10.tgz#60a51b2ae836636c81377df16cb107351bcd13ef" + integrity sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw== run-queue@^1.0.0, run-queue@^1.0.3: version "1.0.3" @@ -10176,9 +10086,9 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== sinon@^9.0.1: - version "9.2.0" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-9.2.0.tgz#1d333967e30023609f7347351ebc0dc964c0f3c9" - integrity sha512-eSNXz1XMcGEMHw08NJXSyTHIu6qTCOiN8x9ODACmZpNQpr0aXTBXBnI4xTzQzR+TEpOmLiKowGf9flCuKIzsbw== + version "9.2.1" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-9.2.1.tgz#64cc88beac718557055bd8caa526b34a2231be6d" + integrity sha512-naPfsamB5KEE1aiioaoqJ6MEhdUs/2vtI5w1hPAXX/UwvoPjXcwh1m5HiKx0HGgKR8lQSoFIgY5jM6KK8VrS9w== dependencies: "@sinonjs/commons" "^1.8.1" "@sinonjs/fake-timers" "^6.0.1" @@ -10188,7 +10098,7 @@ sinon@^9.0.1: nise "^4.0.4" supports-color "^7.1.0" -sisteransi@^1.0.4: +sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== @@ -10557,20 +10467,20 @@ string-width@^4.1.0, string-width@^4.2.0: strip-ansi "^6.0.0" string.prototype.trimend@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" - integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== + version "1.0.2" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.2.tgz#6ddd9a8796bc714b489a3ae22246a208f37bfa46" + integrity sha512-8oAG/hi14Z4nOVP0z6mdiVZ/wqjDtWSLygMigTzAb+7aPEDTleeFf+WrF+alzecxIRkckkJVn+dTlwzJXORATw== dependencies: define-properties "^1.1.3" - es-abstract "^1.17.5" + es-abstract "^1.18.0-next.1" string.prototype.trimstart@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" - integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== + version "1.0.2" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.2.tgz#22d45da81015309cd0cdd79787e8919fc5c613e7" + integrity sha512-7F6CdBTl5zyu30BJFdzSTlSlLPwODC23Od+iLoVH8X6+3fvDPPuBVVj9iaB1GOsSTSIgVfsfm27R2FGrAPznWg== dependencies: define-properties "^1.1.3" - es-abstract "^1.17.5" + es-abstract "^1.18.0-next.1" string_decoder@^1.1.1: version "1.3.0" @@ -10805,10 +10715,11 @@ temp@^0.8.1: rimraf "~2.6.2" temp@^0.9.0: - version "0.9.1" - resolved "https://registry.yarnpkg.com/temp/-/temp-0.9.1.tgz#2d666114fafa26966cd4065996d7ceedd4dd4697" - integrity sha512-WMuOgiua1xb5R56lE0eH6ivpVmg/lq2OHm4+LtT/xtEtPQ+sz6N3bBM6WZ5FvO1lO4IKIOb43qnhoc4qxP5OeA== + version "0.9.2" + resolved "https://registry.yarnpkg.com/temp/-/temp-0.9.2.tgz#06728e6e4b847e3ea5579c69c44bcc3ee6a47100" + integrity sha512-KLVd6CXeUYsqmI/LBWDLg3bFkdZPg0Xr/Gn79GUuPNiISzp6v/EKUaCOrxqeH1w/wVNmrljyDRgKxhZV9JzyJA== dependencies: + mkdirp "^0.5.1" rimraf "~2.6.2" terminal-link@^2.0.0: @@ -10819,22 +10730,22 @@ terminal-link@^2.0.0: ansi-escapes "^4.2.1" supports-hyperlinks "^2.0.0" -terser-webpack-plugin@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.0.0.tgz#88f58d27d1c8244965c59540d3ccda1598fc958c" - integrity sha512-rf7l5a9xamIVX3enQeTl0MY2MNeZClo5yPX/tVPy22oY0nzu0b45h7JqyFi/bygqKWtzXMnml0u12mArhQPsBQ== +terser-webpack-plugin@^5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.0.3.tgz#ec60542db2421f45735c719d2e17dabfbb2e3e42" + integrity sha512-zFdGk8Lh9ZJGPxxPE6jwysOlATWB8GMW8HcfGULWA/nPal+3VdATflQvSBSLQJRCmYZnfFJl6vkRTiwJGNgPiQ== dependencies: - jest-worker "^26.5.0" + jest-worker "^26.6.1" p-limit "^3.0.2" schema-utils "^3.0.0" serialize-javascript "^5.0.1" source-map "^0.6.1" - terser "^5.3.5" + terser "^5.3.8" -terser@^5.3.5: - version "5.3.5" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.3.5.tgz#9e080baa0568f96654621b20eb9effa440b1484e" - integrity sha512-Qw3CZAMmmfU824AoGKalx+riwocSI5Cs0PoGp9RdSLfmxkmJgyBxqLBP/isDNtFyhHnitikvRMZzyVgeq+U+Tg== +terser@^5.3.8: + version "5.3.8" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.3.8.tgz#991ae8ba21a3d990579b54aa9af11586197a75dd" + integrity sha512-zVotuHoIfnYjtlurOouTazciEfL7V38QMAOhGqpXDEg6yT13cF4+fEP9b0rrCEQTn+tT46uxgFsTZzhygk+CzQ== dependencies: commander "^2.20.0" source-map "~0.7.2" @@ -10938,11 +10849,6 @@ to-object-path@^0.3.0: dependencies: kind-of "^3.0.2" -to-readable-stream@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-2.1.0.tgz#82880316121bea662cdc226adb30addb50cb06e8" - integrity sha512-o3Qa6DGg1CEXshSdvWNX2sN4QHqg03SPq7U6jPXRahlQdl5dK8oXjkU/2/sGrnOZKeGV1zLSO8qPwyKklPPE7w== - to-regex-range@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" @@ -11052,6 +10958,11 @@ tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c" + integrity sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ== + tsutils@^3.17.1: version "3.17.1" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" @@ -11090,11 +11001,6 @@ type-detect@4.0.8, type-detect@^4.0.8: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -type-fest@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.10.0.tgz#7f06b2b9fbfc581068d1341ffabd0349ceafc642" - integrity sha512-EUV9jo4sffrwlg8s0zDhP0T2WD3pru5Xi0+HTE3zTUmBaZNhfkite9PdSJwdXLwPVW0jnAHT56pZHIOYckPEiw== - type-fest@^0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" @@ -11151,9 +11057,9 @@ typical@^5.0.0, typical@^5.2.0: integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== uglify-js@^3.1.4: - version "3.11.2" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.11.2.tgz#9f50325544273c27b20e586def140e7726c525ea" - integrity sha512-G440NU6fewtnQftSgqRV1r2A5ChKbU1gqFCJ7I8S7MPpY/eZZfLGefaY6gUZYiWebMaO+txgiQ1ZyLDuNWJulg== + version "3.11.4" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.11.4.tgz#b47b7ae99d4bd1dca65b53aaa69caa0909e6fadf" + integrity sha512-FyYnoxVL1D6+jDGQpbK5jW6y/2JlVfRfEeQ67BPCUg5wfCjaKOpr2XeceE4QL+MkhxliLtf5EbrMDZgzpt2CNw== uid-number@0.0.6: version "0.0.6" @@ -11336,10 +11242,10 @@ uuid@^8.3.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31" integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg== -v8-compile-cache@^2.0.3, v8-compile-cache@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745" - integrity sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ== +v8-compile-cache@^2.0.3, v8-compile-cache@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz#9471efa3ef9128d2f7c6a7ca39c4dd6b5055b132" + integrity sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q== v8-to-istanbul@^6.0.1: version "6.0.1" @@ -11544,18 +11450,18 @@ webpack-merge@^4.2.2: dependencies: lodash "^4.17.15" -webpack-sources@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.1.1.tgz#6922dc1bf7f7f95aab56675535b6e20f87b9147f" - integrity sha512-hraq9n99K564zuZUsE61iATO3jvzxOmGo20UlOe3zgdHOBp8inTJgv7EY4RgvCv7Ywx0/vpQTyYSjnFpv4gNtQ== +webpack-sources@^2.1.1: + version "2.2.0" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.2.0.tgz#058926f39e3d443193b6c31547229806ffd02bac" + integrity sha512-bQsA24JLwcnWGArOKUxYKhX3Mz/nK1Xf6hxullKERyktjNMC4x8koOeaDNTA2fEJ09BdWLbM/iTW0ithREUP0w== dependencies: source-list-map "^2.0.1" source-map "^0.6.1" webpack@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.3.0.tgz#cfa5d9d235fff41e71de0c7c1cd1fc58c7a6ff28" - integrity sha512-0LumZ36pDaWsh+PO3i6FpNQYVqNu5Rs/Jn5AoYQyHpUxIlzn5H7omwApiEzaIUeWDccExOpkNZGO6agCVSqXPg== + version "5.3.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.3.1.tgz#733b2ab9e556bad5c29724a6d562b93e98694bbc" + integrity sha512-pQfG9Mjyis1HkHb5gpXYF+ymjnuq7/7ssE+m1VdiyulwmCpxjXDPNcNXyObb7vGBZ4vEXnsjPCXUYSQLf1TJAQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" @@ -11578,9 +11484,9 @@ webpack@^5.3.0: pkg-dir "^4.2.0" schema-utils "^3.0.0" tapable "^2.0.0" - terser-webpack-plugin "^5.0.0" + terser-webpack-plugin "^5.0.3" watchpack "^2.0.0" - webpack-sources "^2.1.0" + webpack-sources "^2.1.1" websocket-driver@0.6.5: version "0.6.5" @@ -11913,7 +11819,7 @@ yeoman-assert@^3.1.1: resolved "https://registry.yarnpkg.com/yeoman-assert/-/yeoman-assert-3.1.1.tgz#9f6fa0ecba7dd007c40f579668cb5dda18c79343" integrity sha512-bCuLb/j/WzpvrJZCTdJJLFzm7KK8IYQJ3+dF9dYtNs2CUYyezFJDuULiZ2neM4eqjf45GN1KH/MzCTT3i90wUQ== -yeoman-environment@^2.10.0, yeoman-environment@^2.10.3, yeoman-environment@^2.8.1, yeoman-environment@^2.9.5: +yeoman-environment@^2.10.0, yeoman-environment@^2.10.3, yeoman-environment@^2.9.5: version "2.10.3" resolved "https://registry.yarnpkg.com/yeoman-environment/-/yeoman-environment-2.10.3.tgz#9d8f42b77317414434cc0e51fb006a4bdd54688e" integrity sha512-pLIhhU9z/G+kjOXmJ2bPFm3nejfbH+f1fjYRSOteEXDBrv1EoJE/e+kuHixSXfCYfTkxjYsvRaDX+1QykLCnpQ== @@ -11938,7 +11844,7 @@ yeoman-environment@^2.10.0, yeoman-environment@^2.10.3, yeoman-environment@^2.8. untildify "^3.0.3" yeoman-generator "^4.8.2" -yeoman-generator@^4.10.0, yeoman-generator@^4.12.0, yeoman-generator@^4.7.2, yeoman-generator@^4.8.2: +yeoman-generator@^4.10.0, yeoman-generator@^4.12.0, yeoman-generator@^4.8.2: version "4.12.0" resolved "https://registry.yarnpkg.com/yeoman-generator/-/yeoman-generator-4.12.0.tgz#512e783a38b004c49265e71826a09ff7f1939f4b" integrity sha512-lozwklVQHwUXMM1o8BgxEB8F5BB7vkHW4pjAo1Zt5sJ7FOlWhd6DJ4ZxJ2OK0w+gNYkY/ocPMkUV7DTz/uqEEg== From 987e12baa1fe10568af69eb1f0daa3a4f127442a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2020 13:16:46 +0300 Subject: [PATCH 010/581] chore(deps-dev): bump webpack from 5.3.1 to 5.3.2 (#2002) Bumps [webpack](https://github.com/webpack/webpack) from 5.3.1 to 5.3.2. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.3.1...v5.3.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2135c198799..0c797061f61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11459,9 +11459,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.3.0: - version "5.3.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.3.1.tgz#733b2ab9e556bad5c29724a6d562b93e98694bbc" - integrity sha512-pQfG9Mjyis1HkHb5gpXYF+ymjnuq7/7ssE+m1VdiyulwmCpxjXDPNcNXyObb7vGBZ4vEXnsjPCXUYSQLf1TJAQ== + version "5.3.2" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.3.2.tgz#f88f6f2c54eaa1f68c8f37d8984657eaf68b00f0" + integrity sha512-DXsfHoI6lQAR3KnQh7+FsRfs9fs+TEvzXCA35UbKv4kVuzslg7QCMAcpFRZNDMjdtm9N/PoO54XEzGN9TeacQg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From f13346e6acb46e982a5d20fa1d2ae56fc52523dc Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Fri, 30 Oct 2020 14:41:54 +0300 Subject: [PATCH 011/581] feat: progress supports string argument (#2000) --- .../lib/plugins/WebpackCLIPlugin.js | 12 +++++++-- packages/webpack-cli/lib/utils/cli-flags.js | 2 +- test/progress/progress-flag.test.js | 27 ++++++++++++++++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js index c79c8654a95..0127163c3e3 100644 --- a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js @@ -8,6 +8,7 @@ class WebpackCLIPlugin { constructor(options) { this.options = options; } + async apply(compiler) { const compilers = compiler.compilers || [compiler]; @@ -18,11 +19,18 @@ class WebpackCLIPlugin { let progressPluginExists; if (compiler.options.plugins) { - progressPluginExists = Boolean(compiler.options.plugins.find((e) => e instanceof ProgressPlugin)); + progressPluginExists = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin)); } if (!progressPluginExists) { - new ProgressPlugin().apply(compiler); + if (typeof this.options.progress === 'string' && this.options.progress !== 'profile') { + logger.error(`Invalid ${this.options.progress} value for the progress option. Allowed value is profile.`); + process.exit(2); + } + + const isProfile = this.options.progress === 'profile'; + + new ProgressPlugin({ profile: isProfile }).apply(compiler); } } } diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 807d94c0677..091097dfc64 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -108,7 +108,7 @@ const core = [ { name: 'progress', usage: '--progress', - type: Boolean, + type: [Boolean, String], group: BASIC_GROUP, description: 'Print compilation progress during build', }, diff --git a/test/progress/progress-flag.test.js b/test/progress/progress-flag.test.js index b98aad11e83..51791710922 100644 --- a/test/progress/progress-flag.test.js +++ b/test/progress/progress-flag.test.js @@ -4,17 +4,38 @@ const { run } = require('../utils/test-utils'); describe('progress flag', () => { it('should show progress', () => { - const { stderr, stdout } = run(__dirname, ['--progress']); + const { stderr, stdout, exitCode } = run(__dirname, ['--progress']); + + expect(exitCode).toBe(0); + expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); + expect(stderr).toContain('[webpack.Progress] 100%'); + expect(stdout).toContain('main.js'); + }); + + it('should support the "profile" value', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--progress=profile']); + + expect(exitCode).toBe(0); + expect(stderr).toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); }); + it('should not support invalid value', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--progress=unknown']); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Invalid unknown value for the progress option. Allowed value is profile.'); + expect(stdout).toBeFalsy(); + }); + it('should not add duplicate plugins', () => { const { stderr, stdout, exitCode } = run(__dirname, ['-c', 'webpack.progress.config.js', '--progress']); - // Only 1 progress plugin should be applied to the compiler + + expect(exitCode).toEqual(0); expect(stdout.match(/ProgressPlugin/g)).toHaveLength(1); + expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); - expect(exitCode).toEqual(0); }); }); From 270efc678a164bb0c8ffa3709d08ffc157827767 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 1 Nov 2020 12:38:55 +0530 Subject: [PATCH 012/581] docs: update generators links (#2007) --- packages/generators/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/generators/README.md b/packages/generators/README.md index 3e94f4d5bcd..22e7a447242 100644 --- a/packages/generators/README.md +++ b/packages/generators/README.md @@ -26,10 +26,10 @@ const { addonGenerator, initGenerator, loaderGenerator, pluginGenerator } = requ ## Generators -- [**Plugin Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/plugin-generator.ts) : Creates a webpack plugin project, add starter plugin code and runs `webpack-defaults` -- [**Loader Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/loader-generator.ts) : Creates a webpack loader project, add starter loader code and runs `webpack-defaults` -- [**Init Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/init-generator.ts) : Generates new webapck configuration as per user requirements -- [**Addon Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/addon-generator.ts) : Generates a webpack project conforming to `webpack-defaults` +- [**Plugin Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/plugin-generator.ts) : Creates a webpack plugin project, add starter plugin code and runs `webpack-defaults` +- [**Loader Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/loader-generator.ts) : Creates a webpack loader project, add starter loader code and runs `webpack-defaults` +- [**Init Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/init-generator.ts) : Generates new webapck configuration as per user requirements +- [**Addon Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/addon-generator.ts) : Generates a webpack project conforming to `webpack-defaults` --- From e995923f974a2b03169aa7f2c7d243606d495b95 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 2 Nov 2020 12:46:21 +0530 Subject: [PATCH 013/581] tests: add tests for env in configGroup (#2012) --- .../__tests__/ConfigGroup/ConfigGroup.test.js | 10 ++++++++++ .../__tests__/ConfigGroup/env.webpack.config.cjs | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 packages/webpack-cli/__tests__/ConfigGroup/env.webpack.config.cjs diff --git a/packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js b/packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js index b724ed2b6d8..f82ba382478 100644 --- a/packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js +++ b/packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js @@ -55,4 +55,14 @@ describe('ConfigGroup', function () { expect(result.options).toEqual(expectedOptions); expect(result.outputOptions).toEqual({}); }); + + it('should handle different env formats', async () => { + const result = await ConfigGroup({ + env: { test: true, name: 'Hisoka' }, + config: [resolve(__dirname, './env.webpack.config.cjs')], + }); + const expectedOptions = { mode: 'staging', name: 'Hisoka' }; + expect(result.options).toEqual(expectedOptions); + expect(result.outputOptions).toEqual({}); + }); }); diff --git a/packages/webpack-cli/__tests__/ConfigGroup/env.webpack.config.cjs b/packages/webpack-cli/__tests__/ConfigGroup/env.webpack.config.cjs new file mode 100644 index 00000000000..d835806ac3c --- /dev/null +++ b/packages/webpack-cli/__tests__/ConfigGroup/env.webpack.config.cjs @@ -0,0 +1,7 @@ +module.exports = function (env) { + const configName = env.name; + return { + name: configName, + mode: env.test ? 'staging' : 'production', + }; +}; From f86ef2d6c0a4cba3b2002baf32b78e06cbaafc4a Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 2 Nov 2020 16:35:00 +0530 Subject: [PATCH 014/581] fix(generators): correct optimization.splitChunks option in config (#2008) * fix(generators): update optimization.splitChunks option * tests: init-generator --- .../__snapshots__/init-generator.test.ts.snap | 275 ++++++++++++++++++ .../__tests__/init-generator.test.ts | 14 + .../generators/src/utils/webpackConfig.ts | 2 +- 3 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap new file mode 100644 index 00000000000..fe0ae1fbe63 --- /dev/null +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -0,0 +1,275 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`init generator generates a webpack config that uses ES6 1`] = ` +Object { + "mode": "'development'", + "module": Object { + "rules": Array [ + Object { + "include": Array [ + "path.resolve(__dirname, 'src')", + ], + "loader": "'babel-loader'", + "test": "/\\\\.(js|jsx)$/", + }, + ], + }, + "optimization": Object { + "minimizer": Array [ + "new TerserPlugin()", + ], + "splitChunks": Object { + "cacheGroups": Object { + "vendors": Object { + "priority": -10, + "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", + }, + }, + "chunks": "'async'", + "minChunks": 1, + "minSize": 30000, + "name": false, + }, + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + ], +} +`; + +exports[`init generator generates a webpack config that uses Typescript 1`] = ` +Object { + "entry": "'./src/index.ts'", + "mode": "'development'", + "module": Object { + "rules": Array [ + Object { + "exclude": Array [ + "/node_modules/", + ], + "include": Array [ + "path.resolve(__dirname, 'src')", + ], + "loader": "'ts-loader'", + "test": "/\\\\.(ts|tsx)$/", + }, + ], + }, + "optimization": Object { + "minimizer": Array [ + "new TerserPlugin()", + ], + "splitChunks": Object { + "cacheGroups": Object { + "vendors": Object { + "priority": -10, + "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", + }, + }, + "chunks": "'async'", + "minChunks": 1, + "minSize": 30000, + "name": false, + }, + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + ], + "resolve": Object { + "extensions": Array [ + "'.tsx'", + "'.ts'", + "'.js'", + ], + }, +} +`; + +exports[`init generator generates a webpack config using CSS with mini-css-extract-plugin 1`] = ` +Object { + "mode": "'development'", + "module": Object { + "rules": Array [ + Object { + "test": "/.css$/", + "use": Array [ + Object { + "loader": "MiniCssExtractPlugin.loader", + }, + Object { + "loader": "\\"style-loader\\"", + }, + Object { + "loader": "\\"css-loader\\"", + "options": Object { + "sourceMap": true, + }, + }, + ], + }, + ], + }, + "optimization": Object { + "minimizer": Array [ + "new TerserPlugin()", + ], + "splitChunks": Object { + "cacheGroups": Object { + "vendors": Object { + "priority": -10, + "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", + }, + }, + "chunks": "'async'", + "minChunks": 1, + "minSize": 30000, + "name": false, + }, + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + "new MiniCssExtractPlugin({ filename:'main.[chunkhash].css' })", + ], +} +`; + +exports[`init generator generates a webpack config using CSS without mini-css-extract-plugin 1`] = ` +Object { + "mode": "'development'", + "module": Object { + "rules": Array [ + Object { + "test": "/.css$/", + "use": Array [ + Object { + "loader": "\\"style-loader\\"", + }, + Object { + "loader": "\\"css-loader\\"", + "options": Object { + "sourceMap": true, + }, + }, + ], + }, + ], + }, + "optimization": Object { + "minimizer": Array [ + "new TerserPlugin()", + ], + "splitChunks": Object { + "cacheGroups": Object { + "vendors": Object { + "priority": -10, + "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", + }, + }, + "chunks": "'async'", + "minChunks": 1, + "minSize": 30000, + "name": false, + }, + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + ], +} +`; + +exports[`init generator generates a webpack config with custom entry and output 1`] = ` +Object { + "entry": "'./src/index2.js'", + "mode": "'development'", + "module": Object { + "rules": Array [], + }, + "optimization": Object { + "minimizer": Array [ + "new TerserPlugin()", + ], + "splitChunks": Object { + "cacheGroups": Object { + "vendors": Object { + "priority": -10, + "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", + }, + }, + "chunks": "'async'", + "minChunks": 1, + "minSize": 30000, + "name": false, + }, + }, + "output": Object { + "path": "path.resolve(__dirname, 'dist2')", + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + ], +} +`; + +exports[`init generator generates a webpack config with default options 1`] = ` +Object { + "devServer": Object { + "open": true, + }, + "mode": "'production'", + "module": Object { + "rules": Array [], + }, + "optimization": Object { + "minimizer": Array [ + "new TerserPlugin()", + ], + "splitChunks": Object { + "chunks": "'all'", + }, + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + "new HtmlWebpackPlugin({ + template: 'index.html' + })", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", + ], +} +`; + +exports[`init generator generates a webpack config with multiple entries 1`] = ` +Object { + "entry": Object { + "test1": "'./dir1/test1.js'", + "test2": "'./dir2/test2.js'", + }, + "mode": "'development'", + "module": Object { + "rules": Array [], + }, + "optimization": Object { + "minimizer": Array [ + "new TerserPlugin()", + ], + "splitChunks": Object { + "cacheGroups": Object { + "vendors": Object { + "priority": -10, + "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", + }, + }, + "chunks": "'async'", + "minChunks": 1, + "minSize": 30000, + "name": false, + }, + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + ], +} +`; diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index 75785b1f03e..e2982256e3d 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -32,6 +32,8 @@ describe('init generator', () => { expect(config.output).toEqual(undefined); // there are no special loaders, so rules should be empty expect(config.module.rules).toEqual([]); + // match config snapshot + expect(config).toMatchSnapshot(); }); it('generates a webpack config with custom entry and output', async () => { @@ -61,6 +63,8 @@ describe('init generator', () => { expect(config.output.path).toEqual("path.resolve(__dirname, 'dist2')"); // there are no special loaders, so rules should be empty expect(config.module.rules).toEqual([]); + //match config snapshot + expect(config).toMatchSnapshot(); }); it('generates a webpack config using CSS without mini-css-extract-plugin', async () => { @@ -85,6 +89,8 @@ describe('init generator', () => { expect(config.module.rules[0].use.length).toEqual(2); expect(config.module.rules[0].use[0].loader).toEqual('"style-loader"'); expect(config.module.rules[0].use[1].loader).toEqual('"css-loader"'); + //match config snapshot + expect(config).toMatchSnapshot(); }); it('generates a webpack config using CSS with mini-css-extract-plugin', async () => { @@ -111,6 +117,8 @@ describe('init generator', () => { expect(config.module.rules[0].use[0].loader).toEqual('MiniCssExtractPlugin.loader'); expect(config.module.rules[0].use[1].loader).toEqual('"style-loader"'); expect(config.module.rules[0].use[2].loader).toEqual('"css-loader"'); + //match config snapshot + expect(config).toMatchSnapshot(); }); it('generates a webpack config with multiple entries', async () => { @@ -140,6 +148,8 @@ describe('init generator', () => { test1: "'./dir1/test1.js'", test2: "'./dir2/test2.js'", }); + //match config snapshot + expect(config).toMatchSnapshot(); }); it('generates a webpack config that uses ES6', async () => { @@ -166,6 +176,8 @@ describe('init generator', () => { loader: "'babel-loader'", }, ]); + //match config snapshot + expect(config).toMatchSnapshot(); }); it('generates a webpack config that uses Typescript', async () => { @@ -193,5 +205,7 @@ describe('init generator', () => { exclude: ['/node_modules/'], }, ]); + //match config snapshot + expect(config).toMatchSnapshot(); }); }); diff --git a/packages/generators/src/utils/webpackConfig.ts b/packages/generators/src/utils/webpackConfig.ts index 40a24444f7e..b849bd3745e 100644 --- a/packages/generators/src/utils/webpackConfig.ts +++ b/packages/generators/src/utils/webpackConfig.ts @@ -15,7 +15,7 @@ export function getDefaultOptimization(usingDefaults: boolean): WebpackOptions[' chunks: "'async'", minChunks: 1, minSize: 30000, - name: !usingDefaults, + name: false, }, }; } else { From 07d18b0179ca17eeedb2eced0160992709a2c6fc Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 2 Nov 2020 17:35:48 +0530 Subject: [PATCH 015/581] chore: cleanup cli (#2009) --- packages/serve/src/index.ts | 3 +- packages/webpack-cli/lib/utils/GroupHelper.js | 18 ---- packages/webpack-cli/lib/utils/cli-flags.js | 6 ++ packages/webpack-cli/lib/webpack-cli.js | 102 ++++-------------- 4 files changed, 28 insertions(+), 101 deletions(-) delete mode 100644 packages/webpack-cli/lib/utils/GroupHelper.js diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index c56ebacc4f4..833bd6b868e 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -11,11 +11,10 @@ import parseArgs from './parseArgs'; */ export default function serve(...args: string[]): void { const cli = new WebpackCLI(); - const core = cli.getCoreFlags(); const { webpackArgs, devServerArgs } = parseArgs(cli, args); - cli.getCompiler(webpackArgs, core).then((compiler): void => { + cli.getCompiler(webpackArgs).then((compiler): void => { startDevServer(compiler, devServerArgs); }); } diff --git a/packages/webpack-cli/lib/utils/GroupHelper.js b/packages/webpack-cli/lib/utils/GroupHelper.js deleted file mode 100644 index e5e802f28ae..00000000000 --- a/packages/webpack-cli/lib/utils/GroupHelper.js +++ /dev/null @@ -1,18 +0,0 @@ -const { arrayToObject } = require('../utils/arg-utils'); - -class GroupHelper { - constructor(options) { - this.args = arrayToObject(options); - this.opts = { - outputOptions: {}, - options: {}, - }; - this.strategy = undefined; - } - - run() { - throw new Error('You must implement the "run" function'); - } -} - -module.exports = GroupHelper; diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 091097dfc64..f10f6d42073 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -268,9 +268,15 @@ const duplicateFlags = core.map((flag) => flag.name); // remove duplicate flags flagsFromCore = flagsFromCore.filter((flag) => !duplicateFlags.includes(flag.name)); +const coreFlagMap = flagsFromCore.reduce((acc, cur) => { + acc.set(cur.name, cur); + return acc; +}, new Map()); + module.exports = { groups, commands, core: [...core, ...flagsFromCore], flagsFromCore, + coreFlagMap, }; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 9ae5c1ae010..defd3904b9e 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -2,11 +2,9 @@ const { packageExists } = require('./utils/package-exists'); const webpack = packageExists('webpack') ? require('webpack') : undefined; const logger = require('./utils/logger'); const webpackMerge = require('webpack-merge'); -const GroupHelper = require('./utils/GroupHelper'); -const { groups, core } = require('./utils/cli-flags'); +const { core, coreFlagMap } = require('./utils/cli-flags'); const argParser = require('./utils/arg-parser'); const { outputStrategy } = require('./utils/merge-strategies'); -const { toKebabCase } = require('./utils/helpers'); const assignFlagDefaults = require('./utils/flag-defaults'); const { writeFileSync } = require('fs'); const { options: coloretteOptions } = require('colorette'); @@ -19,30 +17,13 @@ const resolveStats = require('./groups/resolveStats'); const resolveOutput = require('./groups/resolveOutput'); const basicResolver = require('./groups/basicResolver'); const resolveAdvanced = require('./groups/resolveAdvanced'); +const { toKebabCase } = require('./utils/helpers'); -class WebpackCLI extends GroupHelper { +class WebpackCLI { constructor() { - super(); - this.groupMap = new Map(); this.compilerConfiguration = {}; this.outputConfiguration = {}; } - setMappedGroups(args, inlineOptions) { - Object.keys(args).forEach((key) => { - this.setGroupMap(toKebabCase(key), args[key], inlineOptions); - }); - } - setGroupMap(key, val, inlineOptions) { - if (val === undefined) return; - const opt = inlineOptions.find((opt) => opt.name === key); - const groupName = opt.group; - if (this.groupMap.has(groupName)) { - const pushToMap = this.groupMap.get(groupName); - pushToMap.push({ [opt.name]: val }); - } else { - this.groupMap.set(groupName, [{ [opt.name]: val }]); - } - } /** * Responsible for handling flags coming from webpack/webpack @@ -50,17 +31,19 @@ class WebpackCLI extends GroupHelper { * @returns {void} */ _handleCoreFlags(parsedArgs) { - if (this.groupMap.has('core')) { - const coreFlags = this.groupMap.get('core'); - - // convert all the flags from map to single object - const coreConfig = coreFlags.reduce((allFlag, curFlag) => ({ ...allFlag, ...curFlag }), {}); - const coreCliHelper = require('webpack').cli; - const coreCliArgs = coreCliHelper.getArguments(); - // Merge the core flag config with the compilerConfiguration - coreCliHelper.processArguments(coreCliArgs, this.compilerConfiguration, coreConfig); - // Assign some defaults to core flags - } + const coreConfig = Object.keys(parsedArgs) + .filter((arg) => { + return coreFlagMap.has(toKebabCase(arg)); + }) + .reduce((acc, cur) => { + acc[toKebabCase(cur)] = parsedArgs[cur]; + return acc; + }, {}); + const coreCliHelper = require('webpack').cli; + const coreCliArgs = coreCliHelper.getArguments(); + // Merge the core flag config with the compilerConfiguration + coreCliHelper.processArguments(coreCliArgs, this.compilerConfiguration, coreConfig); + // Assign some defaults to core flags const configWithDefaults = assignFlagDefaults(this.compilerConfiguration, parsedArgs); this._mergeOptionsToConfiguration(configWithDefaults); } @@ -83,24 +66,6 @@ class WebpackCLI extends GroupHelper { return core; } - /** - * Based on the parsed keys, the function will import and create - * a group that handles respective values - * - * @returns {void} - */ - resolveGroups() { - for (const [key] of this.groupMap.entries()) { - switch (key) { - case groups.HELP_GROUP: { - const HelpGroup = require('./groups/runHelp'); - this.helpGroup = new HelpGroup(); - break; - } - } - } - } - /** * Responsible to override webpack options. * @param {Object} options The options returned by a group helper @@ -171,22 +136,6 @@ class WebpackCLI extends GroupHelper { } } - /** - * It receives a group helper, it runs and it merges its result inside - * the file result that will be passed to the compiler - * - * @param {GroupHelper?} groupHelper A group helper - * @private - * @returns {void} - */ - async _handleGroupHelper(groupHelper) { - if (groupHelper) { - const result = await groupHelper.run(); - this._mergeOptionsToConfiguration(result.options, groupHelper.strategy); - this._mergeOptionsToOutputConfiguration(result.outputOptions); - } - } - /** * It runs in a fancy order all the expected groups. * Zero config and configuration goes first. @@ -202,15 +151,7 @@ class WebpackCLI extends GroupHelper { .then(() => this._handleCoreFlags(parsedArgs)) .then(() => this._baseResolver(basicResolver, parsedArgs)) .then(() => this._baseResolver(resolveAdvanced, parsedArgs)) - .then(() => this._baseResolver(resolveStats, parsedArgs)) - .then(() => this._handleGroupHelper(this.helpGroup)); - } - - async processArgs(args, cliOptions) { - this.setMappedGroups(args, cliOptions); - this.resolveGroups(args); - - return this.runOptionGroups(args); + .then(() => this._baseResolver(resolveStats, parsedArgs)); } handleError(error) { @@ -240,14 +181,13 @@ class WebpackCLI extends GroupHelper { return compiler; } - async getCompiler(args, cliOptions) { - await this.processArgs(args, cliOptions); - + async getCompiler(args) { + await this.runOptionGroups(args); return this.createCompiler(this.compilerConfiguration); } - async run(args, cliOptions) { - await this.processArgs(args, cliOptions); + async run(args) { + await this.runOptionGroups(args); let compiler; From 491a582620b64ed4acbccd04f687adc28a5e4cff Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 2 Nov 2020 18:41:01 +0530 Subject: [PATCH 016/581] feat: suggest the closest match based on the Levenshtein distance algorithm (#2010) * feat: suggest the closest match for an unknown flag * tests: add test case for flag suggestion * tests: assert for exit code --- packages/webpack-cli/lib/bootstrap.js | 6 ++++++ packages/webpack-cli/package.json | 1 + test/unknown/unknown.test.js | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index 56996ec64c7..b6fc82879c6 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -3,6 +3,7 @@ const { core } = require('./utils/cli-flags'); const logger = require('./utils/logger'); const { isCommandUsed } = require('./utils/arg-utils'); const argParser = require('./utils/arg-parser'); +const leven = require('leven'); process.title = 'webpack-cli'; @@ -39,6 +40,11 @@ const runCLI = async (cliArgs) => { if (parsedArgs.unknownArgs.length > 0) { parsedArgs.unknownArgs.forEach(async (unknown) => { logger.error(`Unknown argument: ${unknown}`); + const strippedFlag = unknown.substr(2); + const { name: suggestion } = core.find((flag) => leven(strippedFlag, flag.name) < 3); + if (suggestion) { + logger.raw(`Did you mean --${suggestion}?`); + } }); process.exit(2); diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index c6e0534cd41..67855ac6601 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -37,6 +37,7 @@ "execa": "^4.1.0", "import-local": "^3.0.2", "interpret": "^2.2.0", + "leven": "^3.1.0", "rechoir": "^0.7.0", "v8-compile-cache": "^2.2.0", "webpack-merge": "^4.2.2" diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index 8352b345d6f..903122b2495 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -2,8 +2,15 @@ const { run } = require('../utils/test-utils'); describe('unknown behaviour', () => { it('warns the user if an unknown flag is passed in', () => { - const { stderr } = run(__dirname, ['--unknown']); + const { stderr, exitCode } = run(__dirname, ['--unknown']); expect(stderr).toBeTruthy(); expect(stderr).toContain('Unknown argument: --unknown'); + expect(exitCode).toBe(2); + }); + it('suggests the closest match to an unknown flag', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--entyr', './a.js']); + expect(stderr).toContain('Unknown argument: --entyr'); + expect(stdout).toContain('Did you mean --entry?'); + expect(exitCode).toBe(2); }); }); From bd90732f81065d3377bf2b199c0a07b0a03922db Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 2 Nov 2020 18:53:55 +0530 Subject: [PATCH 017/581] tests: update anayze-flag test (#2015) --- test/analyze/analyze-flag.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/analyze/analyze-flag.test.js b/test/analyze/analyze-flag.test.js index ec27d3b78ac..54cac5d97a8 100644 --- a/test/analyze/analyze-flag.test.js +++ b/test/analyze/analyze-flag.test.js @@ -4,7 +4,7 @@ const { runAndGetWatchProc } = require('../utils/test-utils'); describe('--analyze flag', () => { it('should load webpack-bundle-analyzer plugin with --analyze flag', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--analyze', '--watch'], false, '', true); + const proc = runAndGetWatchProc(__dirname, ['--analyze'], false, '', true); proc.stdout.on('data', (chunk) => { const data = chunk.toString(); From a994d4b52a99b3b77d25aac88f741e036a1c44ec Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 2 Nov 2020 18:57:15 +0530 Subject: [PATCH 018/581] fix(info): throw error and exit for invalid --output value (#2020) --- packages/info/src/index.ts | 3 ++- test/info/info-output.test.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index 12594e1f6bc..91502a51c23 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -53,7 +53,8 @@ export default async function info(...args): Promise { envinfoConfig['json'] = true; break; default: - logger.error(`${infoArgs.output} is not a valid value for output\n`); + logger.error(`'${infoArgs.output}' is not a valid value for output`); + process.exit(2); } } diff --git a/test/info/info-output.test.js b/test/info/info-output.test.js index d85d3b8fedc..8742416eae6 100644 --- a/test/info/info-output.test.js +++ b/test/info/info-output.test.js @@ -39,8 +39,10 @@ describe('basic info usage', () => { }); it('shows a warning if an invalid value is supplied', () => { - const { stdout, stderr } = runInfo(['--output="unknown"'], __dirname); - expect(stderr).toContain(`[webpack-cli] ${red(`"unknown" is not a valid value for output\n`)}`); - expect(stdout).toBeTruthy(); + const { stdout, stderr, exitCode } = runInfo(['--output=unknown'], __dirname); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`[webpack-cli] ${red(`'unknown' is not a valid value for output`)}`); + expect(stdout).toBeFalsy(); }); }); From 718e48536abf9e8953f23aebc0cc82e72756edcc Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 2 Nov 2020 18:57:58 +0530 Subject: [PATCH 019/581] chore: improve error message for invalid progress value (#2014) --- packages/webpack-cli/README.md | 2 +- packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js | 4 +++- test/progress/progress-flag.test.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 6122d086fac..3b81dba641f 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -41,7 +41,7 @@ yarn add webpack-cli --dev -c, --config string[] Provide path to webpack configuration file(s) --config-name string[] Name of the configuration to use -m, --merge Merge several configurations using webpack-merge - --progress Print compilation progress during build + --progress string, boolean Print compilation progress during build --color Enables colors on console --no-color Disable colors on console --env string Environment passed to the configuration when it is a function diff --git a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js index 0127163c3e3..df1d2736ed9 100644 --- a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js @@ -24,7 +24,9 @@ class WebpackCLIPlugin { if (!progressPluginExists) { if (typeof this.options.progress === 'string' && this.options.progress !== 'profile') { - logger.error(`Invalid ${this.options.progress} value for the progress option. Allowed value is profile.`); + logger.error( + `'${this.options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`, + ); process.exit(2); } diff --git a/test/progress/progress-flag.test.js b/test/progress/progress-flag.test.js index 51791710922..35d372b94d3 100644 --- a/test/progress/progress-flag.test.js +++ b/test/progress/progress-flag.test.js @@ -25,7 +25,7 @@ describe('progress flag', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--progress=unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain('Invalid unknown value for the progress option. Allowed value is profile.'); + expect(stderr).toContain(`'unknown' is an invalid value for the --progress option. Only 'profile' is allowed.`); expect(stdout).toBeFalsy(); }); From bd24aa1fb787ac714f7f4c7e2a27031fe148dcc6 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 2 Nov 2020 18:59:07 +0530 Subject: [PATCH 020/581] chore: add more tmp test files to .prettierignore (#2017) --- .prettierignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.prettierignore b/.prettierignore index d037f141282..7050c6118d6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,3 +5,5 @@ test/**/bin/ test/**/binary/ test/**/index.js test/config/error/syntax-error.js +packages/webpack-cli/__tests__/test-assets/.yo-rc.json +test/build-errors/stats.json From 3004549c06b3fe00708d8e1eecf42419e0f72f66 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 2 Nov 2020 19:20:18 +0530 Subject: [PATCH 021/581] feat: export utils from core for other packages (#2011) Export utils from CLI core for other packages which were relying on absolute path of utils. --- packages/generate-loader/src/index.ts | 6 ++++-- packages/generate-plugin/src/index.ts | 4 +++- .../generators/__tests__/addon-generator.test.ts | 4 +++- packages/generators/src/addon-generator.ts | 6 ++++-- packages/generators/src/init-generator.ts | 5 +++-- packages/info/src/index.ts | 5 +++-- packages/migrate/src/index.ts | 4 +++- .../removeDeprecatedPlugins.ts | 6 ++++-- packages/serve/src/parseArgs.ts | 4 +++- .../utils/__tests__/global-packages-path.test.ts | 9 +++++---- packages/utils/src/global-packages-path.ts | 4 +++- packages/utils/src/modify-config-helper.ts | 5 +++-- packages/utils/src/recursive-parser.ts | 3 ++- packages/utils/src/resolve-packages.ts | 4 +++- packages/utils/src/run-prettier.ts | 4 +++- packages/utils/src/scaffold.ts | 5 +++-- packages/utils/src/spawn-child.ts | 4 +++- packages/webpack-cli/lib/index.js | 13 +++++++++++++ .../lib/utils/__tests__/get-package-manager.test.js | 2 +- .../lib/utils/__tests__/prompt-installation.test.js | 6 ++---- .../webpack-cli/lib/utils/get-package-manager.js | 4 +--- .../webpack-cli/lib/utils/prompt-installation.js | 2 +- packages/webpack-cli/package.json | 2 +- 23 files changed, 74 insertions(+), 37 deletions(-) create mode 100644 packages/webpack-cli/lib/index.js diff --git a/packages/generate-loader/src/index.ts b/packages/generate-loader/src/index.ts index 40ffcefc346..ee7a7a6fa63 100644 --- a/packages/generate-loader/src/index.ts +++ b/packages/generate-loader/src/index.ts @@ -1,6 +1,8 @@ -import { loaderGenerator } from '@webpack-cli/generators'; import yeoman from 'yeoman-environment'; -import logger from 'webpack-cli/lib/utils/logger'; +import { loaderGenerator } from '@webpack-cli/generators'; +import { utils } from 'webpack-cli'; + +const { logger } = utils; /** * Runs a yeoman generator to create a new webpack loader project diff --git a/packages/generate-plugin/src/index.ts b/packages/generate-plugin/src/index.ts index abc32312534..3e5d4d55568 100644 --- a/packages/generate-plugin/src/index.ts +++ b/packages/generate-plugin/src/index.ts @@ -1,6 +1,8 @@ import { pluginGenerator } from '@webpack-cli/generators'; import yeoman from 'yeoman-environment'; -import logger from 'webpack-cli/lib/utils/logger'; +import { utils } from 'webpack-cli'; + +const { logger } = utils; /** * Runs a yeoman generator to create a new webpack plugin project diff --git a/packages/generators/__tests__/addon-generator.test.ts b/packages/generators/__tests__/addon-generator.test.ts index d8690c29f25..5c67838f3d7 100644 --- a/packages/generators/__tests__/addon-generator.test.ts +++ b/packages/generators/__tests__/addon-generator.test.ts @@ -5,9 +5,11 @@ jest.setMock('@webpack-cli/utils', { import fs from 'fs'; import path from 'path'; import rimraf from 'rimraf'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; +import { utils } from 'webpack-cli'; import addonGenerator from '../src/addon-generator'; +const { getPackageManager } = utils; + // TODO: enable after jest release describe.skip('addon generator', () => { let gen, installMock, packageMock; diff --git a/packages/generators/src/addon-generator.ts b/packages/generators/src/addon-generator.ts index 538c837df20..37e99297852 100644 --- a/packages/generators/src/addon-generator.ts +++ b/packages/generators/src/addon-generator.ts @@ -1,9 +1,11 @@ -import logger from 'webpack-cli/lib/utils/logger'; import fs from 'fs'; import path from 'path'; import Generator from 'yeoman-generator'; import { generatorCopy, generatorCopyTpl } from '@webpack-cli/utils'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; + +import { utils } from 'webpack-cli'; + +const { logger, getPackageManager } = utils; /** * Creates a Yeoman Generator that generates a project conforming diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 3cc7fa85021..e77fdc3cb5a 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -1,8 +1,7 @@ import { blue, green, bold } from 'colorette'; -import logger from 'webpack-cli/lib/utils/logger'; +import { utils } from 'webpack-cli'; import logSymbols from 'log-symbols'; import path from 'path'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; import { Confirm, Input, List } from '@webpack-cli/webpack-scaffold'; import { @@ -17,6 +16,8 @@ import { } from './utils'; import { CustomGenerator } from './types'; +const { logger, getPackageManager } = utils; + /** * * Generator for initializing a webpack config diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index 91502a51c23..fc8e0c23eab 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -1,7 +1,8 @@ import envinfo from 'envinfo'; -import logger from 'webpack-cli/lib/utils/logger'; -import { commands } from 'webpack-cli/lib/utils/cli-flags'; import WebpackCLI from 'webpack-cli'; +import { utils } from 'webpack-cli'; + +const { logger, commands } = utils; interface Information { Binaries?: string[]; diff --git a/packages/migrate/src/index.ts b/packages/migrate/src/index.ts index cb499c0d832..1a14eccc127 100644 --- a/packages/migrate/src/index.ts +++ b/packages/migrate/src/index.ts @@ -2,7 +2,6 @@ import { green, red } from 'colorette'; import { Change, diffLines } from 'diff'; import fs from 'fs'; import inquirer from 'inquirer'; -import logger from 'webpack-cli/lib/utils/logger'; import Listr from 'listr'; import pLazy = require('p-lazy'); import path from 'path'; @@ -11,6 +10,9 @@ import { runPrettier } from '@webpack-cli/utils'; import { transformations } from './migrate'; import { Node } from './types/NodePath'; import jscodeshift from 'jscodeshift'; +import { utils } from 'webpack-cli'; + +const { logger } = utils; declare let process: { cwd: Function; diff --git a/packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts b/packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts index 9e48d1b6d52..12d270e48e8 100644 --- a/packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts +++ b/packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts @@ -1,11 +1,13 @@ import { red, underline } from 'colorette'; -import logger from 'webpack-cli/lib/utils/logger'; - import { findPluginsByName, isType, safeTraverse } from '@webpack-cli/utils'; import { JSCodeshift, Node } from '../types/NodePath'; +import { utils } from 'webpack-cli'; + +const { logger } = utils; + /** * * Find deprecated plugins and remove them from the `plugins` array, if possible. diff --git a/packages/serve/src/parseArgs.ts b/packages/serve/src/parseArgs.ts index ff4cb7ddf63..b42f902f95e 100644 --- a/packages/serve/src/parseArgs.ts +++ b/packages/serve/src/parseArgs.ts @@ -1,4 +1,6 @@ -import logger from 'webpack-cli/lib/utils/logger'; +import { utils } from 'webpack-cli'; + +const { logger } = utils; type WebpackCLIType = { getCoreFlags: Function; diff --git a/packages/utils/__tests__/global-packages-path.test.ts b/packages/utils/__tests__/global-packages-path.test.ts index 467057d4657..5aa77543595 100644 --- a/packages/utils/__tests__/global-packages-path.test.ts +++ b/packages/utils/__tests__/global-packages-path.test.ts @@ -1,10 +1,11 @@ 'use strict'; -jest.setMock('webpack-cli/lib/utils/get-package-manager', { - getPackageManager: jest.fn(), -}); +jest.setMock('webpack-cli/lib/utils/get-package-manager', jest.fn()); import { getPathToGlobalPackages } from '../lib/global-packages-path'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; +import { utils } from 'webpack-cli'; + +const { getPackageManager } = utils; + jest.mock('execa'); jest.mock('cross-spawn'); const globalModulesNpmValue = 'test-npm'; diff --git a/packages/utils/src/global-packages-path.ts b/packages/utils/src/global-packages-path.ts index acdc7fecc45..feac325b6d5 100644 --- a/packages/utils/src/global-packages-path.ts +++ b/packages/utils/src/global-packages-path.ts @@ -1,6 +1,8 @@ import spawn from 'cross-spawn'; import path from 'path'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; +import { utils } from 'webpack-cli'; + +const { getPackageManager } = utils; /** * diff --git a/packages/utils/src/modify-config-helper.ts b/packages/utils/src/modify-config-helper.ts index aba3b571725..7103b066f35 100644 --- a/packages/utils/src/modify-config-helper.ts +++ b/packages/utils/src/modify-config-helper.ts @@ -1,11 +1,12 @@ import { green } from 'colorette'; import fs from 'fs'; -import logger from 'webpack-cli/lib/utils/logger'; import path from 'path'; import yeoman from 'yeoman-environment'; import Generator from 'yeoman-generator'; import { runTransform } from './scaffold'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; +import { utils } from 'webpack-cli'; + +const { logger, getPackageManager } = utils; export interface Config extends Object { item?: { diff --git a/packages/utils/src/recursive-parser.ts b/packages/utils/src/recursive-parser.ts index 0bdcdf81ba0..ce8888082e8 100644 --- a/packages/utils/src/recursive-parser.ts +++ b/packages/utils/src/recursive-parser.ts @@ -1,7 +1,8 @@ import { parseTopScope, findRootNodesByName, addProperty, removeProperty, parseMerge, safeTraverse } from './ast-utils'; import { JSCodeshift, Node, valueType } from './types/NodePath'; +import { utils } from 'webpack-cli'; -import logger from 'webpack-cli/lib/utils/logger'; +const { logger } = utils; export function recursiveTransform(j: JSCodeshift, ast: Node, key: string, value: valueType, action: string): boolean | Node { if (key === 'topScope') { diff --git a/packages/utils/src/resolve-packages.ts b/packages/utils/src/resolve-packages.ts index 9fa19f2ca80..ce5eddae437 100644 --- a/packages/utils/src/resolve-packages.ts +++ b/packages/utils/src/resolve-packages.ts @@ -1,11 +1,13 @@ import { bold } from 'colorette'; -import logger from 'webpack-cli/lib/utils/logger'; import path from 'path'; import { modifyHelperUtil } from './modify-config-helper'; import { getPathToGlobalPackages } from './global-packages-path'; import { spawnChild } from './spawn-child'; import { isLocalPath } from './path-utils'; import { ExecaSyncReturnValue } from 'execa'; +import { utils } from 'webpack-cli'; + +const { logger } = utils; interface ChildProcess { status: number; diff --git a/packages/utils/src/run-prettier.ts b/packages/utils/src/run-prettier.ts index 6de24cab637..d2612d04849 100644 --- a/packages/utils/src/run-prettier.ts +++ b/packages/utils/src/run-prettier.ts @@ -1,5 +1,7 @@ import fs from 'fs'; -import logger from 'webpack-cli/lib/utils/logger'; +import { utils } from 'webpack-cli'; + +const { logger } = utils; /** * diff --git a/packages/utils/src/scaffold.ts b/packages/utils/src/scaffold.ts index 18383e30e6a..f4d21e130c6 100644 --- a/packages/utils/src/scaffold.ts +++ b/packages/utils/src/scaffold.ts @@ -1,9 +1,7 @@ import { green } from 'colorette'; import j from 'jscodeshift'; -import logger from 'webpack-cli/lib/utils/logger'; import pEachSeries = require('p-each-series'); import path from 'path'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; import { findProjectRoot } from './path-utils'; import { Error } from './types'; import { Config, TransformConfig } from './types'; @@ -11,6 +9,9 @@ import { PROP_TYPES } from './prop-types'; import { recursiveTransform } from './recursive-parser'; import { runPrettier } from './run-prettier'; import { Node } from './types/NodePath'; +import { utils } from 'webpack-cli'; + +const { logger, getPackageManager } = utils; /** * diff --git a/packages/utils/src/spawn-child.ts b/packages/utils/src/spawn-child.ts index 93b10a9f79e..a26e9f24379 100644 --- a/packages/utils/src/spawn-child.ts +++ b/packages/utils/src/spawn-child.ts @@ -2,7 +2,9 @@ import path from 'path'; import fs from 'fs'; import { ExecaSyncReturnValue, sync } from 'execa'; import { getPathToGlobalPackages } from './global-packages-path'; -import { getPackageManager } from 'webpack-cli/lib/utils/get-package-manager'; +import { utils } from 'webpack-cli'; + +const { getPackageManager } = utils; /** * diff --git a/packages/webpack-cli/lib/index.js b/packages/webpack-cli/lib/index.js new file mode 100644 index 00000000000..f284f9074db --- /dev/null +++ b/packages/webpack-cli/lib/index.js @@ -0,0 +1,13 @@ +const WebpackCLI = require('./webpack-cli'); +const { commands } = require('./utils/cli-flags'); +const logger = require('./utils/logger'); +const getPackageManager = require('./utils/get-package-manager'); + +module.exports = WebpackCLI; + +// export additional utils used by other packages +module.exports.utils = { + logger, + commands, + getPackageManager, +}; diff --git a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js index b11c0113d86..61350f3e520 100644 --- a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js @@ -9,7 +9,7 @@ const syncMock = jest.fn(() => { jest.setMock('execa', { sync: syncMock, }); -const { getPackageManager } = require('../get-package-manager'); +const getPackageManager = require('../get-package-manager'); jest.mock('cross-spawn'); const globalModulesNpmValue = 'test-npm'; diff --git a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js index 2108828c010..6a0b54e3f25 100644 --- a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js @@ -16,11 +16,9 @@ jest.setMock('../package-exists', { packageExists: jest.fn(), }); -jest.setMock('../get-package-manager', { - getPackageManager: jest.fn(), -}); +jest.setMock('../get-package-manager', jest.fn()); -const { getPackageManager } = require('../get-package-manager'); +const getPackageManager = require('../get-package-manager'); const { packageExists } = require('../package-exists'); const { promptInstallation } = require('../prompt-installation'); const { runCommand } = require('../run-command'); diff --git a/packages/webpack-cli/lib/utils/get-package-manager.js b/packages/webpack-cli/lib/utils/get-package-manager.js index 7ac3efb9c07..9d6b4125604 100644 --- a/packages/webpack-cli/lib/utils/get-package-manager.js +++ b/packages/webpack-cli/lib/utils/get-package-manager.js @@ -30,6 +30,4 @@ function getPackageManager() { return 'npm'; } -module.exports = { - getPackageManager, -}; +module.exports = getPackageManager; diff --git a/packages/webpack-cli/lib/utils/prompt-installation.js b/packages/webpack-cli/lib/utils/prompt-installation.js index 8b5b4c37800..377e58e7d3b 100644 --- a/packages/webpack-cli/lib/utils/prompt-installation.js +++ b/packages/webpack-cli/lib/utils/prompt-installation.js @@ -1,7 +1,7 @@ const { prompt } = require('enquirer'); const { green } = require('colorette'); const { runCommand } = require('./run-command'); -const { getPackageManager } = require('./get-package-manager'); +const getPackageManager = require('./get-package-manager'); const { packageExists } = require('./package-exists'); /** diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 67855ac6601..a825d95a580 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -10,7 +10,7 @@ "bin": { "webpack-cli": "./bin/cli.js" }, - "main": "./lib/webpack-cli.js", + "main": "./lib/index.js", "engines": { "node": ">=10.13.0" }, From ea66a7e3ec6eabcc439b96acb21e2a25be2e35e5 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 2 Nov 2020 19:49:16 +0530 Subject: [PATCH 022/581] fix: handle core flags for webpack 4 (#2023) --- packages/webpack-cli/lib/webpack-cli.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index defd3904b9e..7ea5eef84ce 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -31,6 +31,8 @@ class WebpackCLI { * @returns {void} */ _handleCoreFlags(parsedArgs) { + const coreCliHelper = require('webpack').cli; + if (!coreCliHelper) return; const coreConfig = Object.keys(parsedArgs) .filter((arg) => { return coreFlagMap.has(toKebabCase(arg)); @@ -39,7 +41,6 @@ class WebpackCLI { acc[toKebabCase(cur)] = parsedArgs[cur]; return acc; }, {}); - const coreCliHelper = require('webpack').cli; const coreCliArgs = coreCliHelper.getArguments(); // Merge the core flag config with the compilerConfiguration coreCliHelper.processArguments(coreCliArgs, this.compilerConfiguration, coreConfig); From 56d32285c96c367669d9bc1317e53d466ad153aa Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 3 Nov 2020 09:01:50 +0530 Subject: [PATCH 023/581] chore(deps): remove unused ansi-escapes (#2016) --- packages/webpack-cli/lib/utils/interactive.js | 3 +++ packages/webpack-cli/package.json | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/utils/interactive.js b/packages/webpack-cli/lib/utils/interactive.js index e6213f4b67d..f68d57342b4 100644 --- a/packages/webpack-cli/lib/utils/interactive.js +++ b/packages/webpack-cli/lib/utils/interactive.js @@ -1,3 +1,4 @@ +/*** const { gray, bold, white, cyan, yellow } = require('colorette'); const ansiEscapes = require('ansi-escapes'); const readline = require('readline'); @@ -170,3 +171,5 @@ module.exports = async function (compiler, config, outputOptions) { } }); }; +* +***/ diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index a825d95a580..29a60d64c2b 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -29,7 +29,6 @@ "dependencies": { "@webpack-cli/info": "^1.0.2", "@webpack-cli/serve": "^1.0.1", - "ansi-escapes": "^4.3.1", "colorette": "^1.2.1", "command-line-usage": "^6.1.0", "commander": "^6.2.0", From c261e65e1fa4d56a65b3c4f29b3791072980de6f Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 3 Nov 2020 14:08:12 +0530 Subject: [PATCH 024/581] chore: display running webpack version during tests (#2026) * chore: display running webpack version during tests * chore: disable cache for webpack install * tests: fix progress test for webpack 4 * chore: add endl Co-authored-by: Nitin Kumar Co-authored-by: Nitin Kumar --- .github/workflows/nodejs.yml | 1 - jest.config.js | 1 + scripts/globalSetup.js | 3 +++ test/progress/progress-flag.test.js | 6 ++++-- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 scripts/globalSetup.js diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 2c8c47b7d89..50e8e421afb 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -83,7 +83,6 @@ jobs: yarn bootstrap - name: Install webpack ${{ matrix.webpack-version }} - if: steps.cache.outputs.cache-hit != 'true' run: yarn add -W webpack@${{ matrix.webpack-version }} - name: Build diff --git a/jest.config.js b/jest.config.js index 3880b9e4ce2..f68ef946efa 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,5 +17,6 @@ module.exports = { watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'], setupFilesAfterEnv: ['/setupTest.js'], globalTeardown: '/scripts/cleanupTest.js', + globalSetup: '/scripts/globalSetup.js', modulePathIgnorePatterns: ['/test/loader/test-loader', '/test/plugin/test-plugin'], }; diff --git a/scripts/globalSetup.js b/scripts/globalSetup.js new file mode 100644 index 00000000000..d043a5903d0 --- /dev/null +++ b/scripts/globalSetup.js @@ -0,0 +1,3 @@ +const { version } = require('webpack'); + +module.exports = () => console.log(`\n Running tests for webpack @${version} \n`); diff --git a/test/progress/progress-flag.test.js b/test/progress/progress-flag.test.js index 35d372b94d3..7aebd90ab12 100644 --- a/test/progress/progress-flag.test.js +++ b/test/progress/progress-flag.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { run } = require('../utils/test-utils'); +const { run, isWebpack5 } = require('../utils/test-utils'); describe('progress flag', () => { it('should show progress', () => { @@ -16,7 +16,9 @@ describe('progress flag', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--progress=profile']); expect(exitCode).toBe(0); - expect(stderr).toMatch(/\[webpack\.Progress] \d+ ms setup/); + if (isWebpack5) { + expect(stderr).toMatch(/\[webpack\.Progress] \d+ ms setup/); + } expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); }); From 29ecf8dbcd1c5c7d75fc7fb1634107697832d952 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 3 Nov 2020 18:59:56 +0530 Subject: [PATCH 025/581] fix: --config-name behaviour for fuctional configs (#2006) --- .../env.webpack.config.cjs | 0 .../resolveConfig.test.js} | 16 +++---- .../webpack.config.cjs | 0 .../webpack.config1.cjs | 0 .../webpack.config2.cjs | 0 .../webpack.promise.config.cjs | 0 .../{ConfigGroup.js => resolveConfig.js} | 14 +++++- packages/webpack-cli/lib/webpack-cli.js | 2 +- test/config-name/config-name.test.js | 47 +++++++++++++++++++ test/config-name/function-config.js | 26 ++++++++++ test/config-name/webpack.config.js | 2 - .../config/function/functional-config.test.js | 40 ++++++++++++++++ test/config/function/multi-webpack.config.js | 20 ++++++++ test/config/function/single-webpack.config.js | 9 ++++ test/config/function/src/first.js | 1 + test/config/function/src/index.js | 1 + test/config/function/src/second.js | 1 + 17 files changed, 166 insertions(+), 13 deletions(-) rename packages/webpack-cli/__tests__/{ConfigGroup => resolveConfig}/env.webpack.config.cjs (100%) rename packages/webpack-cli/__tests__/{ConfigGroup/ConfigGroup.test.js => resolveConfig/resolveConfig.test.js} (82%) rename packages/webpack-cli/__tests__/{ConfigGroup => resolveConfig}/webpack.config.cjs (100%) rename packages/webpack-cli/__tests__/{ConfigGroup => resolveConfig}/webpack.config1.cjs (100%) rename packages/webpack-cli/__tests__/{ConfigGroup => resolveConfig}/webpack.config2.cjs (100%) rename packages/webpack-cli/__tests__/{ConfigGroup => resolveConfig}/webpack.promise.config.cjs (100%) rename packages/webpack-cli/lib/groups/{ConfigGroup.js => resolveConfig.js} (95%) create mode 100644 test/config-name/function-config.js create mode 100644 test/config/function/functional-config.test.js create mode 100644 test/config/function/multi-webpack.config.js create mode 100644 test/config/function/single-webpack.config.js create mode 100644 test/config/function/src/first.js create mode 100644 test/config/function/src/index.js create mode 100644 test/config/function/src/second.js diff --git a/packages/webpack-cli/__tests__/ConfigGroup/env.webpack.config.cjs b/packages/webpack-cli/__tests__/resolveConfig/env.webpack.config.cjs similarity index 100% rename from packages/webpack-cli/__tests__/ConfigGroup/env.webpack.config.cjs rename to packages/webpack-cli/__tests__/resolveConfig/env.webpack.config.cjs diff --git a/packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js similarity index 82% rename from packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js rename to packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js index f82ba382478..4ad49dfab67 100644 --- a/packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js +++ b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js @@ -1,13 +1,13 @@ -const ConfigGroup = require('../../lib/groups/ConfigGroup'); +const resolveConfig = require('../../lib/groups/resolveConfig.js'); const { resolve } = require('path'); const config1 = require('./webpack.config1.cjs'); const config2 = require('./webpack.config2.cjs'); const arrayConfig = require('./webpack.config.cjs'); const promiseConfig = require('./webpack.promise.config.cjs'); -describe('ConfigGroup', function () { +describe('resolveConfig', function () { it('should handle merge properly', async () => { - const result = await ConfigGroup({ + const result = await resolveConfig({ merge: true, config: [resolve(__dirname, './webpack.config.cjs')], }); @@ -25,7 +25,7 @@ describe('ConfigGroup', function () { }); it('should return array for multiple config', async () => { - const result = await ConfigGroup({ + const result = await resolveConfig({ config: [resolve(__dirname, './webpack.config1.cjs'), resolve(__dirname, './webpack.config2.cjs')], }); const expectedOptions = [config1, config2]; @@ -34,20 +34,20 @@ describe('ConfigGroup', function () { }); it('should return config object for single config', async () => { - const result = await ConfigGroup({ config: [resolve(__dirname, './webpack.config1.cjs')] }); + const result = await resolveConfig({ config: [resolve(__dirname, './webpack.config1.cjs')] }); expect(result.options).toEqual(config1); expect(result.outputOptions).toEqual({}); }); it('should return resolved config object for promise config', async () => { - const result = await ConfigGroup({ config: [resolve(__dirname, './webpack.promise.config.cjs')] }); + const result = await resolveConfig({ config: [resolve(__dirname, './webpack.promise.config.cjs')] }); const expectedOptions = await promiseConfig(); expect(result.options).toEqual(expectedOptions); expect(result.outputOptions).toEqual({}); }); it('should handle configs returning different types', async () => { - const result = await ConfigGroup({ + const result = await resolveConfig({ config: [resolve(__dirname, './webpack.promise.config.cjs'), resolve(__dirname, './webpack.config.cjs')], }); const resolvedPromiseConfig = await promiseConfig(); @@ -57,7 +57,7 @@ describe('ConfigGroup', function () { }); it('should handle different env formats', async () => { - const result = await ConfigGroup({ + const result = await resolveConfig({ env: { test: true, name: 'Hisoka' }, config: [resolve(__dirname, './env.webpack.config.cjs')], }); diff --git a/packages/webpack-cli/__tests__/ConfigGroup/webpack.config.cjs b/packages/webpack-cli/__tests__/resolveConfig/webpack.config.cjs similarity index 100% rename from packages/webpack-cli/__tests__/ConfigGroup/webpack.config.cjs rename to packages/webpack-cli/__tests__/resolveConfig/webpack.config.cjs diff --git a/packages/webpack-cli/__tests__/ConfigGroup/webpack.config1.cjs b/packages/webpack-cli/__tests__/resolveConfig/webpack.config1.cjs similarity index 100% rename from packages/webpack-cli/__tests__/ConfigGroup/webpack.config1.cjs rename to packages/webpack-cli/__tests__/resolveConfig/webpack.config1.cjs diff --git a/packages/webpack-cli/__tests__/ConfigGroup/webpack.config2.cjs b/packages/webpack-cli/__tests__/resolveConfig/webpack.config2.cjs similarity index 100% rename from packages/webpack-cli/__tests__/ConfigGroup/webpack.config2.cjs rename to packages/webpack-cli/__tests__/resolveConfig/webpack.config2.cjs diff --git a/packages/webpack-cli/__tests__/ConfigGroup/webpack.promise.config.cjs b/packages/webpack-cli/__tests__/resolveConfig/webpack.promise.config.cjs similarity index 100% rename from packages/webpack-cli/__tests__/ConfigGroup/webpack.promise.config.cjs rename to packages/webpack-cli/__tests__/resolveConfig/webpack.promise.config.cjs diff --git a/packages/webpack-cli/lib/groups/ConfigGroup.js b/packages/webpack-cli/lib/groups/resolveConfig.js similarity index 95% rename from packages/webpack-cli/lib/groups/ConfigGroup.js rename to packages/webpack-cli/lib/groups/resolveConfig.js index beac89662e8..ed66ebcca1c 100644 --- a/packages/webpack-cli/lib/groups/ConfigGroup.js +++ b/packages/webpack-cli/lib/groups/resolveConfig.js @@ -156,7 +156,9 @@ const finalize = async (moduleObj, args) => { const isMultiCompilerMode = Array.isArray(config); const rawConfigs = isMultiCompilerMode ? config : [config]; - let configs = await Promise.all( + let configs = []; + + const allConfigs = await Promise.all( rawConfigs.map(async (rawConfig) => { const isPromise = typeof rawConfig.then === 'function'; @@ -174,6 +176,14 @@ const finalize = async (moduleObj, args) => { }), ); + for (const singleConfig of allConfigs) { + if (Array.isArray(singleConfig)) { + configs.push(...singleConfig); + } else { + configs.push(singleConfig); + } + } + if (configName) { const foundConfigNames = []; @@ -204,7 +214,7 @@ const finalize = async (moduleObj, args) => { process.exit(2); } - newOptionsObject['options'] = isMultiCompilerMode ? configs : configs[0]; + newOptionsObject['options'] = configs.length > 1 ? configs : configs[0]; return newOptionsObject; }; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 7ea5eef84ce..918af585ebf 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -11,7 +11,7 @@ const { options: coloretteOptions } = require('colorette'); const WebpackCLIPlugin = require('./plugins/WebpackCLIPlugin'); // CLI arg resolvers -const handleConfigResolution = require('./groups/ConfigGroup'); +const handleConfigResolution = require('./groups/resolveConfig'); const resolveMode = require('./groups/resolveMode'); const resolveStats = require('./groups/resolveStats'); const resolveOutput = require('./groups/resolveOutput'); diff --git a/test/config-name/config-name.test.js b/test/config-name/config-name.test.js index de2fe509af4..deee81523b7 100644 --- a/test/config-name/config-name.test.js +++ b/test/config-name/config-name.test.js @@ -81,4 +81,51 @@ describe('--config-name flag', () => { expect(stdout).toBeFalsy(); expect(exitCode).toBe(2); }); + + it('should work with config as a function', (done) => { + const { stderr, stdout, exitCode } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'first'], false); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('first'); + expect(stdout).not.toContain('second'); + expect(stdout).not.toContain('third'); + expect(exitCode).toBe(0); + + stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); + }); + + it('should work with multiple values for --config-name when the config is a function', (done) => { + const { stderr, stdout, exitCode } = run( + __dirname, + ['--config', 'function-config.js', '--config-name', 'first', '--config-name', 'third'], + false, + ); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('first'); + expect(stdout).not.toContain('second'); + expect(stdout).toContain('third'); + expect(exitCode).toBe(0); + + stat(resolve(__dirname, './dist/dist-third.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + + stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); + }); + }); + + it('should log error if invalid config name is provided ', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'test'], false); + + expect(stderr).toContain('Configuration with name "test" was not found.'); + expect(stdout).toBeFalsy(); + expect(exitCode).toBe(2); + }); }); diff --git a/test/config-name/function-config.js b/test/config-name/function-config.js new file mode 100644 index 00000000000..ff198656a45 --- /dev/null +++ b/test/config-name/function-config.js @@ -0,0 +1,26 @@ +module.exports = () => [ + { + output: { + filename: './dist-first.js', + }, + name: 'first', + entry: './src/first.js', + mode: 'development', + }, + { + output: { + filename: './dist-second.js', + }, + name: 'second', + entry: './src/second.js', + mode: 'production', + }, + { + output: { + filename: './dist-third.js', + }, + name: 'third', + entry: './src/third.js', + mode: 'none', + }, +]; diff --git a/test/config-name/webpack.config.js b/test/config-name/webpack.config.js index 4580e6062d0..3504fa3ae9b 100644 --- a/test/config-name/webpack.config.js +++ b/test/config-name/webpack.config.js @@ -6,7 +6,6 @@ module.exports = [ name: 'first', entry: './src/first.js', mode: 'development', - stats: 'minimal', }, { output: { @@ -15,7 +14,6 @@ module.exports = [ name: 'second', entry: './src/second.js', mode: 'production', - stats: 'minimal', }, { output: { diff --git a/test/config/function/functional-config.test.js b/test/config/function/functional-config.test.js new file mode 100644 index 00000000000..ccc79d6aec1 --- /dev/null +++ b/test/config/function/functional-config.test.js @@ -0,0 +1,40 @@ +'use strict'; +const { resolve } = require('path'); +const { stat } = require('fs'); +const { run } = require('../../utils/test-utils'); + +describe('functional config', () => { + it('should work as expected in case of single config', (done) => { + const { stderr, stdout, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'single-webpack.config.js')]); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('./src/index.js'); + expect(exitCode).toBe(0); + + stat(resolve(__dirname, './bin/dist-single.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); + }); + + it('should work as expected in case of multiple config', (done) => { + const { stderr, stdout, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'multi-webpack.config.js')]); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('first'); + expect(stdout).toContain('second'); + expect(exitCode).toBe(0); + + stat(resolve(__dirname, './bin/dist-first.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); + stat(resolve(__dirname, './bin/dist-second.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); + }); +}); diff --git a/test/config/function/multi-webpack.config.js b/test/config/function/multi-webpack.config.js new file mode 100644 index 00000000000..1ea167bf529 --- /dev/null +++ b/test/config/function/multi-webpack.config.js @@ -0,0 +1,20 @@ +module.exports = () => [ + { + output: { + filename: './dist-first.js', + }, + name: 'first', + entry: './src/first.js', + mode: 'development', + stats: 'minimal', + }, + { + output: { + filename: './dist-second.js', + }, + name: 'second', + entry: './src/second.js', + mode: 'production', + stats: 'minimal', + }, +]; diff --git a/test/config/function/single-webpack.config.js b/test/config/function/single-webpack.config.js new file mode 100644 index 00000000000..dbf14dc44c9 --- /dev/null +++ b/test/config/function/single-webpack.config.js @@ -0,0 +1,9 @@ +module.exports = () => { + return { + output: { + filename: './dist-single.js', + }, + name: 'single', + mode: 'development', + }; +}; diff --git a/test/config/function/src/first.js b/test/config/function/src/first.js new file mode 100644 index 00000000000..5a33e8ffd02 --- /dev/null +++ b/test/config/function/src/first.js @@ -0,0 +1 @@ +console.log('first entry'); diff --git a/test/config/function/src/index.js b/test/config/function/src/index.js new file mode 100644 index 00000000000..398f16d07ee --- /dev/null +++ b/test/config/function/src/index.js @@ -0,0 +1 @@ +console.log('default index'); diff --git a/test/config/function/src/second.js b/test/config/function/src/second.js new file mode 100644 index 00000000000..3ce234df055 --- /dev/null +++ b/test/config/function/src/second.js @@ -0,0 +1 @@ +console.log('second entry'); From 0038ff282931748903fe746d1ce79b5dbf333a80 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 3 Nov 2020 19:19:57 +0530 Subject: [PATCH 026/581] chore: coverage (#1899) --- .codecov.yml | 2 +- .github/workflows/nodejs.yml | 13 +- .nycrc | 10 + jest.config.js | 2 +- package.json | 4 + scripts/setupBuild.js | 10 + test/config-format/typescript/tsconfig.json | 5 + .../typescript/typescript.test.js | 2 +- tsconfig.json | 1 - yarn.lock | 177 +++++++++++++++++- 10 files changed, 210 insertions(+), 16 deletions(-) create mode 100644 .nycrc create mode 100644 scripts/setupBuild.js create mode 100644 test/config-format/typescript/tsconfig.json diff --git a/.codecov.yml b/.codecov.yml index 58598d7c0e6..9d693da8d71 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,4 +1,4 @@ -comment: off +comment: on parsers: javascript: diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 50e8e421afb..be1637e991e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -49,7 +49,7 @@ jobs: run: yarn lint build: - name: Tests - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }} + name: Tests and Coverage - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }} runs-on: ${{ matrix.os }} @@ -86,15 +86,13 @@ jobs: run: yarn add -W webpack@${{ matrix.webpack-version }} - name: Build - run: yarn build + run: yarn build:ci - - name: Run tests for webpack version ${{ matrix.webpack-version }} + - name: Test and Generate Coverage run: | yarn run lerna bootstrap yarn prepsuite - yarn test:ci - env: - CI: true + yarn test:coverage - name: Smoke Tests # TODO fix for windows @@ -103,6 +101,9 @@ jobs: env: CI: true + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + commitlint: name: Lint Commit Messages runs-on: ubuntu-latest diff --git a/.nycrc b/.nycrc new file mode 100644 index 00000000000..23943f67603 --- /dev/null +++ b/.nycrc @@ -0,0 +1,10 @@ +{ + "all": true, + "reporter": [ + "html", + "json", + "cobertura" + ], + "source-map": true, + "exclude-after-remap": false +} \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index f68ef946efa..a2e0242435e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,7 +8,7 @@ module.exports = { // transformIgnorePatterns: ['.*(node_modules)(?!.*webpack-cli.*).*$'], testEnvironment: 'node', collectCoverage: true, - coverageReporters: ['json', 'html', 'cobertura'], + coverageReporters: ['none'], transform: { '^.+\\.(ts)?$': 'ts-jest', }, diff --git a/package.json b/package.json index 08d5ab483e9..a967b769a0a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,9 @@ "bootstrap": "lerna bootstrap", "clean": "del-cli \"*.tsbuildinfo\" \"packages/**/*.tsbuildinfo\" \"packages/!(webpack-cli)/lib/!(*.tpl)\" \"**/.yo-rc.json\"", "prebuild": "yarn clean", + "prebuild:ci": "yarn clean && node ./scripts/setupBuild.js", "build": "tsc --build", + "build:ci": "tsc --build", "watch": "tsc --build --watch", "commit": "git-cz", "lint:prettier": "prettier --list-different . \"!**/*.{js,ts}\" ", @@ -38,6 +40,7 @@ "test:cli": "jest test --reporters=default --forceExit", "test:packages": "jest packages/ --reporters=default --forceExit", "test:ci": "yarn test:cli && yarn test:packages", + "test:coverage": "nyc jest --forceExit", "test:watch": "jest test/ packages/ --watch", "test:smoke": "smoketests/smoketests.sh", "publish:monorepo": "yarn build && lerna version && lerna publish from-git" @@ -82,6 +85,7 @@ "jest-watch-typeahead": "^0.6.1", "lerna": "^3.22.1", "lint-staged": "^10.5.0", + "nyc": "^15.1.0", "prettier": "^2.1.2", "readable-stream": "^3.6.0", "rimraf": "^3.0.2", diff --git a/scripts/setupBuild.js b/scripts/setupBuild.js new file mode 100644 index 00000000000..47baf48f865 --- /dev/null +++ b/scripts/setupBuild.js @@ -0,0 +1,10 @@ +const { writeFileSync, readFileSync } = require('fs'); +const { resolve } = require('path'); + +const tsConfigPath = resolve(__dirname, '../tsconfig.json'); +const tsConfigRaw = readFileSync(tsConfigPath); +const tsConfig = JSON.parse(tsConfigRaw); + +tsConfig.compilerOptions.sourceMap = true; + +writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2)); diff --git a/test/config-format/typescript/tsconfig.json b/test/config-format/typescript/tsconfig.json new file mode 100644 index 00000000000..391488ab17f --- /dev/null +++ b/test/config-format/typescript/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/test/config-format/typescript/typescript.test.js b/test/config-format/typescript/typescript.test.js index 8070f2c47a3..03d30d3ab47 100644 --- a/test/config-format/typescript/typescript.test.js +++ b/test/config-format/typescript/typescript.test.js @@ -4,7 +4,7 @@ const { stat } = require('fs'); const { resolve } = require('path'); describe('webpack cli', () => { - it( + it.skip( 'should support typescript file', async () => { await runInstall(__dirname); diff --git a/tsconfig.json b/tsconfig.json index 6090b21c41a..011dd7ff9b7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,7 +28,6 @@ { "path": "packages/migrate" }, { "path": "packages/serve" }, { "path": "packages/utils" }, - // { "path": "packages/webpack-cli" }, { "path": "packages/webpack-scaffold" } ] } diff --git a/yarn.lock b/yarn.lock index 0c797061f61..019a69849aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2935,6 +2935,13 @@ app-root-path@~3.0.0: resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.0.0.tgz#210b6f43873227e18a4b810a032283311555d5ad" integrity sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw== +append-transform@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-2.0.0.tgz#99d9d29c7b38391e6f428d28ce136551f0b77e12" + integrity sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg== + dependencies: + default-require-extensions "^3.0.0" + aproba@^1.0.3, aproba@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -2945,6 +2952,11 @@ aproba@^2.0.0: resolved "https://registry.yarnpkg.com/aproba/-/aproba-2.0.0.tgz#52520b8ae5b569215b354efc0caa3fe1e45a8adc" integrity sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ== +archy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" + integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA= + are-we-there-yet@~1.1.2: version "1.1.5" resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" @@ -3462,6 +3474,16 @@ cacheable-request@^7.0.1: normalize-url "^4.1.0" responselike "^2.0.0" +caching-transform@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/caching-transform/-/caching-transform-4.0.0.tgz#00d297a4206d71e2163c39eaffa8157ac0651f0f" + integrity sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA== + dependencies: + hasha "^5.0.0" + make-dir "^3.0.0" + package-hash "^4.0.0" + write-file-atomic "^3.0.0" + call-me-maybe@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" @@ -4348,6 +4370,13 @@ default-gateway@^4.2.0: execa "^1.0.0" ip-regex "^2.1.0" +default-require-extensions@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-3.0.0.tgz#e03f93aac9b2b6443fc52e5e4a37b3ad9ad8df96" + integrity sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg== + dependencies: + strip-bom "^4.0.0" + defaults@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" @@ -4773,6 +4802,11 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +es6-error@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" + integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== + es6-promise@^4.0.3: version "4.2.8" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" @@ -5310,6 +5344,15 @@ find-cache-dir@^2.0.0: make-dir "^2.0.0" pkg-dir "^3.0.0" +find-cache-dir@^3.2.0: + version "3.3.1" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880" + integrity sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ== + dependencies: + commondir "^1.0.1" + make-dir "^3.0.2" + pkg-dir "^4.1.0" + find-config@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/find-config/-/find-config-1.0.0.tgz#eafa2b9bc07fa9c90e9a0c3ef9cecf1cc800f530" @@ -5423,6 +5466,14 @@ for-in@^1.0.2: resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= +foreground-child@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-2.0.0.tgz#71b32800c9f15aa8f2f83f4a6bd9bff35d861a53" + integrity sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^3.0.2" + forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -5471,6 +5522,11 @@ from2@^2.1.0: inherits "^2.0.1" readable-stream "^2.0.0" +fromentries@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/fromentries/-/fromentries-1.2.1.tgz#64c31665630479bc993cd800d53387920dc61b4d" + integrity sha512-Xu2Qh8yqYuDhQGOhD5iJGninErSfI9A3FrriD3tjUgV5VbJFeH8vfgZ9HnC6jWN80QDVNQK5vmxRAmEAp7Mevw== + fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -6031,6 +6087,14 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +hasha@^5.0.0: + version "5.2.2" + resolved "https://registry.yarnpkg.com/hasha/-/hasha-5.2.2.tgz#a48477989b3b327aea3c04f53096d816d97522a1" + integrity sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ== + dependencies: + is-stream "^2.0.0" + type-fest "^0.8.0" + homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" @@ -6801,11 +6865,18 @@ isstream@~0.1.2: resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= -istanbul-lib-coverage@^3.0.0: +istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.0.0-alpha.1: version "3.0.0" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz#f5944a37c70b550b02a78a5c3b2055b280cec8ec" integrity sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg== +istanbul-lib-hook@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz#8f84c9434888cc6b1d0a9d7092a76d239ebf0cc6" + integrity sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ== + dependencies: + append-transform "^2.0.0" + istanbul-lib-instrument@^4.0.0, istanbul-lib-instrument@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz#873c6fff897450118222774696a3f28902d77c1d" @@ -6816,6 +6887,19 @@ istanbul-lib-instrument@^4.0.0, istanbul-lib-instrument@^4.0.3: istanbul-lib-coverage "^3.0.0" semver "^6.3.0" +istanbul-lib-processinfo@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz#e1426514662244b2f25df728e8fd1ba35fe53b9c" + integrity sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw== + dependencies: + archy "^1.0.0" + cross-spawn "^7.0.0" + istanbul-lib-coverage "^3.0.0-alpha.1" + make-dir "^3.0.0" + p-map "^3.0.0" + rimraf "^3.0.0" + uuid "^3.3.3" + istanbul-lib-report@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6" @@ -7677,6 +7761,11 @@ lodash.clonedeep@^4.5.0, lodash.clonedeep@~4.5.0: resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= +lodash.flattendeep@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" + integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= + lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" @@ -7817,7 +7906,7 @@ make-dir@^2.0.0, make-dir@^2.1.0: pify "^4.0.1" semver "^5.6.0" -make-dir@^3.0.0: +make-dir@^3.0.0, make-dir@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== @@ -8400,6 +8489,13 @@ node-notifier@^8.0.0: uuid "^8.3.0" which "^2.0.2" +node-preload@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/node-preload/-/node-preload-0.2.1.tgz#c03043bb327f417a18fee7ab7ee57b408a144301" + integrity sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ== + dependencies: + process-on-spawn "^1.0.0" + node-releases@^1.1.61: version "1.1.64" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.64.tgz#71b4ae988e9b1dd7c1ffce58dd9e561752dfebc5" @@ -8545,6 +8641,39 @@ nwsapi@^2.2.0: resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7" integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ== +nyc@^15.1.0: + version "15.1.0" + resolved "https://registry.yarnpkg.com/nyc/-/nyc-15.1.0.tgz#1335dae12ddc87b6e249d5a1994ca4bdaea75f02" + integrity sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A== + dependencies: + "@istanbuljs/load-nyc-config" "^1.0.0" + "@istanbuljs/schema" "^0.1.2" + caching-transform "^4.0.0" + convert-source-map "^1.7.0" + decamelize "^1.2.0" + find-cache-dir "^3.2.0" + find-up "^4.1.0" + foreground-child "^2.0.0" + get-package-type "^0.1.0" + glob "^7.1.6" + istanbul-lib-coverage "^3.0.0" + istanbul-lib-hook "^3.0.0" + istanbul-lib-instrument "^4.0.0" + istanbul-lib-processinfo "^2.0.2" + istanbul-lib-report "^3.0.0" + istanbul-lib-source-maps "^4.0.0" + istanbul-reports "^3.0.2" + make-dir "^3.0.0" + node-preload "^0.2.1" + p-map "^3.0.0" + process-on-spawn "^1.0.0" + resolve-from "^5.0.0" + rimraf "^3.0.0" + signal-exit "^3.0.2" + spawn-wrap "^2.0.0" + test-exclude "^6.0.0" + yargs "^15.0.2" + oauth-sign@~0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" @@ -8867,6 +8996,16 @@ p-waterfall@^1.0.0: dependencies: p-reduce "^1.0.0" +package-hash@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/package-hash/-/package-hash-4.0.0.tgz#3537f654665ec3cc38827387fc904c163c54f506" + integrity sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ== + dependencies: + graceful-fs "^4.1.15" + hasha "^5.0.0" + lodash.flattendeep "^4.4.0" + release-zalgo "^1.0.0" + paged-request@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/paged-request/-/paged-request-2.0.1.tgz#91164f042231feb68643542d2530476a518ff4de" @@ -9089,7 +9228,7 @@ pkg-dir@^3.0.0: dependencies: find-up "^3.0.0" -pkg-dir@^4.2.0: +pkg-dir@^4.1.0, pkg-dir@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== @@ -9164,6 +9303,13 @@ process-nextick-args@^2.0.0, process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== +process-on-spawn@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/process-on-spawn/-/process-on-spawn-1.0.0.tgz#95b05a23073d30a17acfdc92a440efd2baefdc93" + integrity sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg== + dependencies: + fromentries "^1.2.0" + progress@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" @@ -9599,6 +9745,13 @@ regjsparser@^0.6.4: dependencies: jsesc "~0.5.0" +release-zalgo@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/release-zalgo/-/release-zalgo-1.0.0.tgz#09700b7e5074329739330e535c5a90fb67851730" + integrity sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA= + dependencies: + es6-error "^4.0.1" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -10278,6 +10431,18 @@ source-map@^0.7.3, source-map@~0.7.2: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== +spawn-wrap@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-2.0.0.tgz#103685b8b8f9b79771318827aa78650a610d457e" + integrity sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg== + dependencies: + foreground-child "^2.0.0" + is-windows "^1.0.2" + make-dir "^3.0.0" + rimraf "^3.0.0" + signal-exit "^3.0.2" + which "^2.0.1" + spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" @@ -11021,7 +11186,7 @@ type-fest@^0.6.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b" integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg== -type-fest@^0.8.1: +type-fest@^0.8.0, type-fest@^0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== @@ -11232,7 +11397,7 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= -uuid@^3.0.1, uuid@^3.3.2, uuid@^3.4.0: +uuid@^3.0.1, uuid@^3.3.2, uuid@^3.3.3, uuid@^3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== @@ -11797,7 +11962,7 @@ yargs@^14.2.2: y18n "^4.0.0" yargs-parser "^15.0.1" -yargs@^15.1.0, yargs@^15.4.1: +yargs@^15.0.2, yargs@^15.1.0, yargs@^15.4.1: version "15.4.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== From f4a72c5a5d7e5f70dfa4373f932b2086ae9dec69 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 4 Nov 2020 17:24:22 +0530 Subject: [PATCH 027/581] tests: check for proper exit code (#2025) --- test/bail/bail.test.js | 6 ++- test/cache/cache.test.js | 5 ++- test/config-format/coffee/coffee.test.js | 8 +++- test/config-format/commonjs/commonjs.test.js | 4 +- .../typescript/typescript.test.js | 4 +- .../dotfolder-array/dotfolder-array.test.js | 4 +- .../dotfolder-single/dotfolder-single.test.js | 4 +- .../defaults/all/multiple-config.test.js | 3 +- .../multiple-location-config.test.js | 3 +- .../none and dev/dev-none-config.test.js | 3 +- .../with-mode/multiple-config.test.js | 3 +- .../array-promises/array-promises.test.js | 4 +- test/config/type/array/array.test.js | 6 ++- .../function-with-env.test.js | 31 +++++++++---- test/config/type/function/function.test.js | 6 ++- .../type/promise-array/promise-array.test.js | 4 +- .../promise-function/promise-function.test.js | 4 +- test/config/type/promise/promise.test.js | 4 +- test/core-flags/amd-flag.test.js | 3 +- test/core-flags/bail-flag.test.js | 6 ++- test/core-flags/cache-flags.test.js | 40 ++++++++++++----- test/core-flags/dependencies-flag.test.js | 6 ++- test/core-flags/devtool-flag.test.js | 6 ++- test/core-flags/entry-reset-flag.test.js | 3 +- test/core-flags/experiments-flag.test.js | 8 +++- test/core-flags/externals-flags.test.js | 12 +++-- .../core-flags/infrastructure-logging.test.js | 9 ++-- test/core-flags/module-flags.test.js | 19 +++++--- test/core-flags/node-flags.test.js | 15 ++++--- test/core-flags/optimization-flags.test.js | 16 +++++-- test/core-flags/output-flags.test.js | 43 +++++++++++------- test/core-flags/parallelism-flag.test.js | 3 +- test/core-flags/performance-flags.test.js | 10 +++-- test/core-flags/profile-flag.test.js | 6 ++- test/core-flags/records-flag.test.js | 9 ++-- test/core-flags/resolve-flags.test.js | 12 +++-- test/core-flags/snapshot-flags.test.js | 7 ++- test/core-flags/stats-flags.test.js | 14 ++++-- test/core-flags/watch-flags.test.js | 6 ++- test/defaults/output-defaults.test.js | 5 ++- test/devtool/array/source-map-array.test.js | 14 ++++-- test/devtool/object/source-map-object.test.js | 13 ++++-- .../entry-with-command.test.js | 4 +- .../entry-with-config.test.js | 4 +- .../entry-with-config.test.js | 5 ++- .../defaults-empty/entry-single-arg.test.js | 6 ++- .../defaults-index/entry-multi-args.test.js | 4 +- test/entry/flag-entry/entry-with-flag.test.js | 44 ++++++++++++------- .../multiple-entries/multi-entries.test.js | 8 +++- test/env/array/array-env.test.js | 6 ++- test/env/object/object-env.test.js | 7 ++- test/help/help-commands.test.js | 26 ++++++++--- test/help/help-flags.test.js | 26 ++++++++--- test/help/help-multi-args.test.js | 8 +++- test/help/help-single-arg.test.js | 12 +++-- test/hot/hot-flag.test.js | 8 +++- test/info/info-help.test.js | 12 +++-- test/info/info-unknown.test.js | 5 ++- .../mode-single-arg/mode-single-arg.test.js | 24 +++++++--- .../mode-with-config/mode-with-config.test.js | 18 ++++++-- test/name/name.test.js | 4 +- test/no-hot/no-hot.test.js | 8 +++- test/node/node.test.js | 16 +++++-- test/optimization/optimization.test.js | 4 +- .../output-named-bundles.test.js | 21 +++++++-- test/prefetch/prefetch.test.js | 9 ++-- test/stats/cli-flags/stats.test.js | 9 +++- test/stats/config/stats.test.js | 8 +++- test/target/flag-test/target-flag.test.js | 16 +++++-- .../version/version-external-packages.test.js | 44 ++++++++++++++----- test/version/version-multi-args.test.js | 32 ++++++++++---- test/version/version-single-arg.test.js | 12 +++-- .../entry-absent/zero-config.test.js | 3 +- .../entry-present/zero-config.test.js | 3 +- 74 files changed, 587 insertions(+), 220 deletions(-) diff --git a/test/bail/bail.test.js b/test/bail/bail.test.js index 94551a627cf..c848403eb09 100644 --- a/test/bail/bail.test.js +++ b/test/bail/bail.test.js @@ -4,15 +4,17 @@ const { run, runWatch } = require('../utils/test-utils'); describe('bail and watch warning', () => { it('should not log warning in not watch mode', async () => { - const { stderr, stdout } = await run(__dirname, ['-c', 'bail-webpack.config.js']); + const { stderr, stdout, exitCode } = await run(__dirname, ['-c', 'bail-webpack.config.js']); + expect(exitCode).toEqual(0); expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); it('should not log warning in not watch mode without the "bail" option', async () => { - const { stderr, stdout } = await run(__dirname, ['-c', 'no-bail-webpack.config.js']); + const { stderr, stdout, exitCode } = await run(__dirname, ['-c', 'no-bail-webpack.config.js']); + expect(exitCode).toEqual(0); expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index 66a923670b1..5b0eeabbb39 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -4,13 +4,14 @@ const { run, isWebpack5 } = require('../utils/test-utils'); describe('cache related tests', () => { it('should log warning in case of single compiler', () => { - let { stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); + let { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); // run 2nd compilation - ({ stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false)); + ({ stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false)); if (isWebpack5) { expect(stderr).toContain('starting to restore cache content'); expect(stdout).toContain('[cached]'); + expect(exitCode).toEqual(0); } }); }); diff --git a/test/config-format/coffee/coffee.test.js b/test/config-format/coffee/coffee.test.js index 0a42e309352..ccb8b46cd16 100644 --- a/test/config-format/coffee/coffee.test.js +++ b/test/config-format/coffee/coffee.test.js @@ -5,16 +5,20 @@ const { resolve } = require('path'); describe('webpack cli', () => { it('should support coffeescript file as flag', () => { - const { stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', 'webpack.config.coffee'], false); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); }); it('should load coffeescript file by default', () => { - const { stderr, stdout } = run(__dirname, [], false); + const { stderr, stdout, exitCode } = run(__dirname, [], false); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); }); }); diff --git a/test/config-format/commonjs/commonjs.test.js b/test/config-format/commonjs/commonjs.test.js index 6da158d4f2b..0a60b8ffd02 100644 --- a/test/config-format/commonjs/commonjs.test.js +++ b/test/config-format/commonjs/commonjs.test.js @@ -4,9 +4,11 @@ const { resolve } = require('path'); describe('webpack cli', () => { it('should support CommonJS file', () => { - const { stderr, stdout } = run(__dirname, ['-c', 'webpack.config.cjs'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', 'webpack.config.cjs'], false); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); }); }); diff --git a/test/config-format/typescript/typescript.test.js b/test/config-format/typescript/typescript.test.js index 03d30d3ab47..e7f7bcfd696 100644 --- a/test/config-format/typescript/typescript.test.js +++ b/test/config-format/typescript/typescript.test.js @@ -8,9 +8,11 @@ describe('webpack cli', () => { 'should support typescript file', async () => { await runInstall(__dirname); - const { stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.config.ts']); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); stat(resolve(__dirname, 'bin/foo.bundle.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config-lookup/dotfolder-array/dotfolder-array.test.js b/test/config-lookup/dotfolder-array/dotfolder-array.test.js index 645f425f684..e2c305e9b4d 100644 --- a/test/config-lookup/dotfolder-array/dotfolder-array.test.js +++ b/test/config-lookup/dotfolder-array/dotfolder-array.test.js @@ -5,9 +5,11 @@ const { run } = require('../../utils/test-utils'); describe('dotfolder array config lookup', () => { it('should find a webpack array configuration in a dotfolder', (done) => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); + expect(stderr).not.toBeUndefined(); expect(stdout).not.toBeUndefined(); + expect(exitCode).toBe(0); stat(resolve(__dirname, './dist/dist-commonjs.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config-lookup/dotfolder-single/dotfolder-single.test.js b/test/config-lookup/dotfolder-single/dotfolder-single.test.js index bb7a2f74691..ee09ec2899f 100644 --- a/test/config-lookup/dotfolder-single/dotfolder-single.test.js +++ b/test/config-lookup/dotfolder-single/dotfolder-single.test.js @@ -7,9 +7,11 @@ const { run } = require('../../utils/test-utils'); describe('dotfolder single config lookup', () => { it('should find a webpack configuration in a dotfolder', (done) => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); + expect(stderr).not.toBeUndefined(); expect(stdout).not.toBeUndefined(); + expect(exitCode).toBe(0); expect(stdout).not.toContain('Module not found'); stat(resolve(__dirname, './dist/main.js'), (err, stats) => { diff --git a/test/config/defaults/all/multiple-config.test.js b/test/config/defaults/all/multiple-config.test.js index 793a4a93403..9b4d00e975b 100644 --- a/test/config/defaults/all/multiple-config.test.js +++ b/test/config/defaults/all/multiple-config.test.js @@ -5,8 +5,9 @@ const { run } = require('../../../utils/test-utils'); describe('Default configuration files: ', () => { it('Uses prod config from dot folder if present', (done) => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).not.toBe(undefined); stat(resolve(__dirname, './binary/prod.bundle.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/defaults/multiple-location/multiple-location-config.test.js b/test/config/defaults/multiple-location/multiple-location-config.test.js index 68c5aa4db63..a366a0165a9 100644 --- a/test/config/defaults/multiple-location/multiple-location-config.test.js +++ b/test/config/defaults/multiple-location/multiple-location-config.test.js @@ -5,8 +5,9 @@ const { run } = require('../../../utils/test-utils'); describe('multiple dev config files with webpack.config.js', () => { it('Uses webpack.config.development.js', (done) => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(stderr).toBeFalsy(); + expect(exitCode).toEqual(0); expect(stdout).not.toBe(undefined); stat(resolve(__dirname, './binary/dev.folder.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/defaults/none and dev/dev-none-config.test.js b/test/config/defaults/none and dev/dev-none-config.test.js index b61c5d8aee8..6c2a8778bbd 100644 --- a/test/config/defaults/none and dev/dev-none-config.test.js +++ b/test/config/defaults/none and dev/dev-none-config.test.js @@ -5,8 +5,9 @@ const { run } = require('../../../utils/test-utils'); describe('multiple config files', () => { it('Uses dev config when both dev and none are present', (done) => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(stderr).toBeFalsy(); + expect(exitCode).toEqual(0); expect(stdout).not.toBe(undefined); stat(resolve(__dirname, './binary/dev.bundle.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/defaults/with-mode/multiple-config.test.js b/test/config/defaults/with-mode/multiple-config.test.js index 489650530cc..75c1ce693a7 100644 --- a/test/config/defaults/with-mode/multiple-config.test.js +++ b/test/config/defaults/with-mode/multiple-config.test.js @@ -5,8 +5,9 @@ const { run } = require('../../../utils/test-utils'); describe('multiple config files', () => { it('Uses dev config when development mode is supplied', (done) => { - const { stdout, stderr } = run(__dirname, ['--mode', 'development'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'development'], false); expect(stderr).toBeFalsy(); + expect(exitCode).toEqual(0); expect(stdout).not.toBe(undefined); stat(resolve(__dirname, './binary/dev.bundle.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/array-promises/array-promises.test.js b/test/config/type/array-promises/array-promises.test.js index 7c831d99cff..b9527b1f2e2 100644 --- a/test/config/type/array-promises/array-promises.test.js +++ b/test/config/type/array-promises/array-promises.test.js @@ -5,9 +5,11 @@ const { run } = require('../../../utils/test-utils'); describe('array of promises', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr } = run(__dirname, ['-c', './webpack.config.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); stat(resolve(__dirname, './binary/a-promise.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/array/array.test.js b/test/config/type/array/array.test.js index 28149ff06dc..6fa581f100d 100644 --- a/test/config/type/array/array.test.js +++ b/test/config/type/array/array.test.js @@ -5,7 +5,11 @@ const { run } = require('../../../utils/test-utils'); describe('array', () => { it('is able to understand a configuration file in array format', (done) => { - run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './dist/dist-commonjs.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index bbb878377ee..491d85fa9c3 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -12,21 +12,23 @@ describe('function configuration', () => { expect(exitCode).toEqual(1); }); it('is able to understand a configuration file as a function', () => { - const { stderr, stdout } = run(__dirname, ['--env', 'isProd']); + const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'isProd']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/prod.js'))).toBeTruthy(); }); it('is able to understand a configuration file as a function', () => { - const { stderr, stdout } = run(__dirname, ['--env', 'isDev']); + const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'isDev']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/dev.js'))).toBeTruthy(); }); it('Supports passing string in env', () => { - const { stderr, stdout } = run(__dirname, [ + const { stderr, stdout, exitCode } = run(__dirname, [ '--env', 'environment=production', '--env', @@ -36,11 +38,12 @@ describe('function configuration', () => { ]); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Luffy.js'))).toBeTruthy(); }); it('Supports long nested values in env', () => { - const { stderr, stdout } = run(__dirname, [ + const { stderr, stdout, exitCode } = run(__dirname, [ '--env', 'file.name.is.this=Atsumu', '--env', @@ -50,11 +53,12 @@ describe('function configuration', () => { ]); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Atsumu.js'))).toBeTruthy(); }); it('Supports multiple equal in a string', () => { - const { stderr, stdout } = run(__dirname, [ + const { stderr, stdout, exitCode } = run(__dirname, [ '--env', 'file=name=is=Eren', '--env', @@ -64,27 +68,38 @@ describe('function configuration', () => { ]); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/name=is=Eren.js'))).toBeTruthy(); }); it('Supports dot at the end', () => { - const { stderr, stdout } = run(__dirname, ['--env', 'name.=Hisoka', '--env', 'environment=dot', '-c', 'webpack.env.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, [ + '--env', + 'name.=Hisoka', + '--env', + 'environment=dot', + '-c', + 'webpack.env.config.js', + ]); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Hisoka.js'))).toBeTruthy(); }); it('Supports dot at the end', () => { - const { stderr, stdout } = run(__dirname, ['--env', 'name.', '--env', 'environment=dot', '-c', 'webpack.env.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'name.', '--env', 'environment=dot', '-c', 'webpack.env.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/true.js'))).toBeTruthy(); }); it('is able to understand multiple env flags', (done) => { - const { stderr, stdout } = run(__dirname, ['--env', 'isDev', '--env', 'verboseStats', '--env', 'envMessage']); + const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'isDev', '--env', 'verboseStats', '--env', 'envMessage']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); // check that the verbose env is respected expect(stdout).toContain('LOG from webpack'); // check if the values from DefinePlugin make it to the compiled code diff --git a/test/config/type/function/function.test.js b/test/config/type/function/function.test.js index 80f30ad08d1..8c782889fbf 100644 --- a/test/config/type/function/function.test.js +++ b/test/config/type/function/function.test.js @@ -5,7 +5,11 @@ const { run } = require('../../../utils/test-utils'); describe('function', () => { it('is able to understand a configuration file as a function', (done) => { - run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); stat(resolve(__dirname, './binary/functor.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/type/promise-array/promise-array.test.js b/test/config/type/promise-array/promise-array.test.js index ba99a92449b..e83d7875038 100644 --- a/test/config/type/promise-array/promise-array.test.js +++ b/test/config/type/promise-array/promise-array.test.js @@ -5,9 +5,11 @@ const { run } = require('../../../utils/test-utils'); describe('promise array', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr } = run(__dirname, ['-c', './webpack.config.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); stat(resolve(__dirname, './binary/a-promise.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/promise-function/promise-function.test.js b/test/config/type/promise-function/promise-function.test.js index ad5f372201e..2fea09bce8e 100644 --- a/test/config/type/promise-function/promise-function.test.js +++ b/test/config/type/promise-function/promise-function.test.js @@ -5,9 +5,11 @@ const { run } = require('../../../utils/test-utils'); describe('promise function', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr } = run(__dirname, ['-c', './webpack.config.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); stat(resolve(__dirname, './binary/promise.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/type/promise/promise.test.js b/test/config/type/promise/promise.test.js index 3938804bf66..20a766f279b 100644 --- a/test/config/type/promise/promise.test.js +++ b/test/config/type/promise/promise.test.js @@ -5,9 +5,11 @@ const { run } = require('../../../utils/test-utils'); describe('promise', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr } = run(__dirname, ['-c', './webpack.config.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); stat(resolve(__dirname, './binary/promise.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/core-flags/amd-flag.test.js b/test/core-flags/amd-flag.test.js index a21db34196f..67c3df8ce37 100644 --- a/test/core-flags/amd-flag.test.js +++ b/test/core-flags/amd-flag.test.js @@ -4,9 +4,10 @@ const { run } = require('../utils/test-utils'); describe('--no-amd flag', () => { it('should accept --no-amd', () => { - const { stderr, stdout } = run(__dirname, ['--no-amd']); + const { stderr, stdout, exitCode } = run(__dirname, ['--no-amd']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('amd: false'); }); }); diff --git a/test/core-flags/bail-flag.test.js b/test/core-flags/bail-flag.test.js index 48587933155..23e953038e3 100644 --- a/test/core-flags/bail-flag.test.js +++ b/test/core-flags/bail-flag.test.js @@ -4,16 +4,18 @@ const { run } = require('../utils/test-utils'); describe('--bail flag', () => { it('should set bail to true', () => { - const { stderr, stdout } = run(__dirname, ['--bail']); + const { stderr, stdout, exitCode } = run(__dirname, ['--bail']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('bail: true'); }); it('should set bail to false', () => { - const { stderr, stdout } = run(__dirname, ['--no-bail']); + const { stderr, stdout, exitCode } = run(__dirname, ['--no-bail']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('bail: false'); }); }); diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index 57a1f0338ac..f4164965e14 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -14,74 +14,90 @@ describe('cache related flags from core', () => { }); it('should be successful with --cache ', () => { - const { stderr, stdout } = run(__dirname, ['--cache']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`type: 'memory'`); }); it('should be successful with --no-cache ', () => { - const { stderr, stdout } = run(__dirname, ['--no-cache']); + const { stderr, stdout, exitCode } = run(__dirname, ['--no-cache']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('cache: false'); }); it('should set cache.type', () => { - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`type: 'filesystem'`); }); it('should set cache.cacheDirectory with --cache-cache-directory', () => { - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', './test-cache-path']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', './test-cache-path']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('test-cache-path'); expect(existsSync(resolve(__dirname, './test-cache-path'))).toBeTruthy(); }); it('should set cache.cacheLocation with --cache-cache-locations', () => { - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', './test-locate-cache']); + const { stderr, stdout, exitCode } = run(__dirname, [ + '--cache-type', + 'filesystem', + '--cache-cache-location', + './test-locate-cache', + ]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('test-locate-cache'); expect(existsSync(resolve(__dirname, './test-locate-cache'))).toBeTruthy(); }); it('should set cache.hashAlgorithm with --cache-hash-algorithm', () => { - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-hash-algorithm', 'sha256']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-hash-algorithm', 'sha256']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`hashAlgorithm: 'sha256'`); }); it('should set cache.name with --cache-name', () => { - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-name', 'cli-test']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-name', 'cli-test']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`name: 'cli-test'`); }); it('should set cache.store with --cache-store', () => { - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-store', 'pack']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-store', 'pack']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`store: 'pack'`); }); it('should set cache.version with --cache-version', () => { - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-version', '1.1.3']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-version', '1.1.3']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`version: '1.1.3'`); }); it('should assign cache build dependencies correctly when cache type is filesystem', () => { // TODO: Fix on windows if (isWindows) return; - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('buildDependencies'); expect(stdout).toContain("config: [ './webpack.config.js' ]"); expect(stdout).not.toContain('[cached]'); @@ -95,8 +111,10 @@ describe('cache related flags from core', () => { it('should assign cache build dependencies correctly when cache type is filesystem in config', () => { // TODO: Fix on windows if (isWindows) return; - const { stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.cache.config.js']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('buildDependencies'); expect(stdout).toContain("config: [ './webpack.cache.config.js' ]"); expect(stdout).toContain("type: 'filesystem'"); diff --git a/test/core-flags/dependencies-flag.test.js b/test/core-flags/dependencies-flag.test.js index 251c6f51bf3..5b3ba3244fe 100644 --- a/test/core-flags/dependencies-flag.test.js +++ b/test/core-flags/dependencies-flag.test.js @@ -4,16 +4,18 @@ const { run } = require('../utils/test-utils'); describe('--dependencies and related flags', () => { it('should allow to set dependencies option', () => { - const { stderr, stdout } = run(__dirname, ['--dependencies', 'lodash']); + const { stderr, stdout, exitCode } = run(__dirname, ['--dependencies', 'lodash']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`dependencies: [ 'lodash' ]`); }); it('should reset dependencies option', () => { - const { stderr, stdout } = run(__dirname, ['--dependencies-reset']); + const { stderr, stdout, exitCode } = run(__dirname, ['--dependencies-reset']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('dependencies: []'); }); }); diff --git a/test/core-flags/devtool-flag.test.js b/test/core-flags/devtool-flag.test.js index fec3a3a30a3..387c642bea5 100644 --- a/test/core-flags/devtool-flag.test.js +++ b/test/core-flags/devtool-flag.test.js @@ -4,15 +4,17 @@ const { run } = require('../utils/test-utils'); describe('--devtool flag', () => { it('should set devtool option', () => { - const { stderr, stdout } = run(__dirname, ['--devtool', 'source-map']); + const { stderr, stdout, exitCode } = run(__dirname, ['--devtool', 'source-map']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`devtool: 'source-map'`); }); it('should throw error for invalid config', () => { - const { stderr } = run(__dirname, ['--devtool', 'invalid']); + const { stderr, exitCode } = run(__dirname, ['--devtool', 'invalid']); + expect(exitCode).toBe(2); expect(stderr).toContain('Invalid configuration object'); }); }); diff --git a/test/core-flags/entry-reset-flag.test.js b/test/core-flags/entry-reset-flag.test.js index fb5631cec19..07818863adc 100644 --- a/test/core-flags/entry-reset-flag.test.js +++ b/test/core-flags/entry-reset-flag.test.js @@ -4,9 +4,10 @@ const { run } = require('../utils/test-utils'); describe('--entry-reset flag', () => { it('should reset entry correctly', () => { - const { stderr, stdout } = run(__dirname, ['--entry-reset', '--entry', 'src/entry.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--entry-reset', '--entry', './src/entry.js']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('src/entry.js'); expect(stdout).not.toContain('src/main.js'); }); diff --git a/test/core-flags/experiments-flag.test.js b/test/core-flags/experiments-flag.test.js index b1d808c889a..f30059f7528 100644 --- a/test/core-flags/experiments-flag.test.js +++ b/test/core-flags/experiments-flag.test.js @@ -12,14 +12,18 @@ describe('experiments option related flag', () => { const propName = hyphenToUpperCase(property); it(`should config ${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: true`); }); it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: false`); }); }); diff --git a/test/core-flags/externals-flags.test.js b/test/core-flags/externals-flags.test.js index 83bc6f3c00f..83dafd5fc76 100644 --- a/test/core-flags/externals-flags.test.js +++ b/test/core-flags/externals-flags.test.js @@ -4,30 +4,34 @@ const { run } = require('../utils/test-utils'); describe('externals related flag', () => { it('should set externals properly', () => { - const { stderr, stdout } = run(__dirname, ['--externals', './main.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--externals', './main.js']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`externals: [ './main.js' ]`); }); it('should set externalsType properly', () => { - const { stderr, stdout } = run(__dirname, ['--externals', 'var']); + const { stderr, stdout, exitCode } = run(__dirname, ['--externals', 'var']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`externalsType: 'var'`); }); it('should accept --external-type values', () => { - const { stderr, stdout } = run(__dirname, ['--externals-type', 'var']); + const { stderr, stdout, exitCode } = run(__dirname, ['--externals-type', 'var']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`externalsType: 'var'`); }); it('should reset externals', () => { - const { stderr, stdout } = run(__dirname, ['--externals-reset']); + const { stderr, stdout, exitCode } = run(__dirname, ['--externals-reset']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`externals: []`); }); }); diff --git a/test/core-flags/infrastructure-logging.test.js b/test/core-flags/infrastructure-logging.test.js index 028523bb0d9..3c2c0e9b3c8 100644 --- a/test/core-flags/infrastructure-logging.test.js +++ b/test/core-flags/infrastructure-logging.test.js @@ -4,23 +4,26 @@ const { run } = require('../utils/test-utils'); describe('externals related flag', () => { it('should set infrastructureLogging.debug properly', () => { - const { stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']); + const { stderr, stdout, exitCode } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`debug: [ 'myPlugin' ]`); }); it('should reset infrastructureLogging.debug to []', () => { - const { stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug-reset']); + const { stderr, stdout, exitCode } = run(__dirname, ['--infrastructure-logging-debug-reset']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`debug: []`); }); it('should set infrastructureLogging.level properly', () => { - const { stderr, stdout } = run(__dirname, ['--infrastructure-logging-level', 'log']); + const { stderr, stdout, exitCode } = run(__dirname, ['--infrastructure-logging-level', 'log']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`level: 'log'`); }); }); diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index 51083e646a1..d65e712d765 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -16,8 +16,10 @@ describe('module config related flag', () => { if (flag.type === Boolean && !flag.name.includes('module-no-parse')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name.includes('-reset')) { const option = propName.split('Reset')[0]; expect(stdout).toContain(`${option}: []`); @@ -30,7 +32,9 @@ describe('module config related flag', () => { if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (flag.name.includes('rules-')) { expect(stdout).toContain('sideEffects: false'); @@ -43,16 +47,20 @@ describe('module config related flag', () => { if (flag.type === String) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'value']); + let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'value']); + if (flag.name === 'module-no-parse') { expect(stderr).toBeFalsy(); expect(stdout).toContain('value'); } else if (flag.name.includes('reg-exp')) { - stdout = run(__dirname, [`--${flag.name}`, '/ab?c*/']).stdout; + ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, '/ab?c*/'])); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: /ab?c*/`); } else if (flag.name.includes('module-rules-')) { - stdout = run(__dirname, [`--${flag.name}`, 'javascript/auto']).stdout; + ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, 'javascript/auto'])); + if (propName === 'use' || propName === 'type') { expect(stdout).toContain(`${propName}: 'javascript/auto'`); } else if (property.includes('use-')) { @@ -67,6 +75,7 @@ describe('module config related flag', () => { } } else { expect(stdout).toContain(`${propName}: 'value'`); + expect(exitCode).toBe(0); } }); } diff --git a/test/core-flags/node-flags.test.js b/test/core-flags/node-flags.test.js index 85522283ace..7b6f9cc1005 100644 --- a/test/core-flags/node-flags.test.js +++ b/test/core-flags/node-flags.test.js @@ -4,37 +4,42 @@ const { run } = require('../utils/test-utils'); describe('node option related flags', () => { it('should config node option', () => { - const { stderr, stdout } = run(__dirname, ['--node']); + const { stderr, stdout, exitCode } = run(__dirname, ['--node']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`node: { global: true, __filename: 'mock', __dirname: 'mock' }`); }); it('should config node option to false', () => { - const { stderr, stdout } = run(__dirname, ['--no-node']); + const { stderr, stdout, exitCode } = run(__dirname, ['--no-node']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('node: false'); }); it('should set node.global equals to true', () => { - const { stderr, stdout } = run(__dirname, ['--node']); + const { stderr, stdout, exitCode } = run(__dirname, ['--node']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('global: true'); }); it('should set node.filename correctly', () => { - const { stderr, stdout } = run(__dirname, ['--node-filename', 'mock']); + const { stderr, stdout, exitCode } = run(__dirname, ['--node-filename', 'mock']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`__filename: 'mock'`); }); it('should set node.filename correctly', () => { - const { stderr, stdout } = run(__dirname, ['--node-dirname', 'mock']); + const { stderr, stdout, exitCode } = run(__dirname, ['--node-dirname', 'mock']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`__dirname: 'mock'`); }); }); diff --git a/test/core-flags/optimization-flags.test.js b/test/core-flags/optimization-flags.test.js index 32b3de29f0d..4485865f567 100644 --- a/test/core-flags/optimization-flags.test.js +++ b/test/core-flags/optimization-flags.test.js @@ -20,8 +20,10 @@ describe('optimization config related flag', () => { if (flag.type === Boolean) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain(`chunks: 'async'`); expect(stdout).toContain(`minChunks: 1`); @@ -34,8 +36,10 @@ describe('optimization config related flag', () => { if (!flag.name.includes('reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain('splitChunks: false'); } else { @@ -49,8 +53,10 @@ describe('optimization config related flag', () => { // need improve the plugin to log for multi-level options i.e, optimization.runtime if (flag.type === String && !flag.name.includes('runtime-') && !flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'named']); + let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'named']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name === 'optimization-split-chunks-chunks') { stdout = run(__dirname, [`--${flag.name}`, 'initial']).stdout; expect(stdout).toContain(`chunks: 'initial'`); @@ -72,7 +78,9 @@ describe('optimization config related flag', () => { if (flag.type === Number && !flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain(`chunks: 'async'`); diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index c11e2206587..d1bfc94f392 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -16,11 +16,12 @@ describe('output config related flag', () => { if (flag.type === Boolean && !flag.name.includes('output-library')) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout } = run(__dirname, [`--${flag.name}`]); + let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); if (flag.name === 'output-module') { //'output.module: true' is only allowed when 'experiments.outputModule' is enabled - stdout = run(__dirname, [`--${flag.name}`, '--experiments-output-module']).stdout; + ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, '--experiments-output-module'])); + expect(exitCode).toBe(0); expect(stdout).toContain('module: true'); } else if (flag.name.includes('-reset')) { const option = propName.split('Reset')[0]; @@ -28,15 +29,17 @@ describe('output config related flag', () => { expect(stdout).toContain(`${option}: []`); } else { expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: true`); } }); if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: false`); }); } @@ -44,49 +47,56 @@ describe('output config related flag', () => { if (flag.type === Number) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 10`); }); } if (flag.type === String && !flag.name.includes('output-library')) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test']); + let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test']); if (flag.name === 'output-cross-origin-loading') { - stdout = run(__dirname, [`--${flag.name}`, 'anonymous']).stdout; + ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'anonymous'])); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 'anonymous'`); } else if (flag.name === 'output-chunk-format') { - stdout = run(__dirname, [`--${flag.name}`, 'commonjs']).stdout; + ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'commonjs'])); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 'commonjs'`); } else if (flag.name === 'output-chunk-loading') { - stdout = run(__dirname, [`--${flag.name}`, 'jsonp']).stdout; + ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'jsonp'])); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 'jsonp'`); } else if (flag.name === 'output-enabled-chunk-loading-types' || flag.name === 'output-enabled-wasm-loading-types') { - stdout = run(__dirname, [`--${flag.name}`, 'async-node']).stdout; + ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'async-node'])); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: [ 'async-node' ]`); } else if (flag.name === 'output-enabled-library-type') { - stdout = run(__dirname, [`--${flag.name}`, 'amd']).stdout; + ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'amd'])); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 'amd'`); } else if (flag.name === 'output-hash-function') { - stdout = run(__dirname, [`--${flag.name}`, 'sha256']).stdout; - stderr = run(__dirname, [`--${flag.name}`, 'sha256']).stderr; + ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, 'sha256'])); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`hashFunction: 'sha256'`); } else if (flag.name === 'output-script-type') { - stdout = run(__dirname, [`--${flag.name}`, 'module']).stdout; + ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'module'])); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 'module'`); } else if (flag.name === 'output-enabled-library-types') { stdout = run(__dirname, [`--${flag.name}`, 'var']).stdout; @@ -102,6 +112,7 @@ describe('output config related flag', () => { expect(stdout).toContain(`${propName}: 'async-node'`); } else { expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 'test'`); } }); @@ -109,7 +120,7 @@ describe('output config related flag', () => { if (flag.name.includes('output-library')) { it(`should config name, type and export correctly`, () => { - const { stderr, stdout } = run(__dirname, [ + const { stderr, stdout, exitCode } = run(__dirname, [ '--output-library-name', 'myLibrary', '--output-library-type', @@ -122,6 +133,7 @@ describe('output config related flag', () => { ]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('myLibrary'); expect(stdout).toContain(`type: 'var'`); expect(stdout).toContain('export: [Array]'); @@ -130,9 +142,10 @@ describe('output config related flag', () => { }); it('should be succesful with --output-library-reset correctly', () => { - const { stderr, stdout } = run(__dirname, ['--output-library-reset']); + const { stderr, stdout, exitCode } = run(__dirname, ['--output-library-reset']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('name: []'); }); } diff --git a/test/core-flags/parallelism-flag.test.js b/test/core-flags/parallelism-flag.test.js index 02f1f878be7..9c0d1ee7eea 100644 --- a/test/core-flags/parallelism-flag.test.js +++ b/test/core-flags/parallelism-flag.test.js @@ -4,9 +4,10 @@ const { run } = require('../utils/test-utils'); describe('--parallelism flag', () => { it('should set parallelism to the value passed', () => { - const { stderr, stdout } = run(__dirname, ['--parallelism', '50']); + const { stderr, stdout, exitCode } = run(__dirname, ['--parallelism', '50']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('parallelism: 50'); }); }); diff --git a/test/core-flags/performance-flags.test.js b/test/core-flags/performance-flags.test.js index 106f5af725f..ea27e0b1d5c 100644 --- a/test/core-flags/performance-flags.test.js +++ b/test/core-flags/performance-flags.test.js @@ -7,9 +7,10 @@ const performanceFlags = flagsFromCore.filter(({ name }) => name.startsWith('per describe('module config related flag', () => { it(`should config --performance option correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-performance`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--no-performance`]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('performance: false'); }); @@ -20,17 +21,20 @@ describe('module config related flag', () => { if (flag.type === Number) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 10`); }); } if (flag.type === String) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'warning']); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'warning']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`${propName}: 'warning'`); }); } diff --git a/test/core-flags/profile-flag.test.js b/test/core-flags/profile-flag.test.js index 2ba4d1169b2..9be89d464cf 100644 --- a/test/core-flags/profile-flag.test.js +++ b/test/core-flags/profile-flag.test.js @@ -4,16 +4,18 @@ const { run } = require('../utils/test-utils'); describe('--profile flag', () => { it('should set profile to true', () => { - const { stderr, stdout } = run(__dirname, ['--profile']); + const { stderr, stdout, exitCode } = run(__dirname, ['--profile']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('profile: true'); }); it('should set profile to false', () => { - const { stderr, stdout } = run(__dirname, ['--no-profile']); + const { stderr, stdout, exitCode } = run(__dirname, ['--no-profile']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('profile: false'); }); }); diff --git a/test/core-flags/records-flag.test.js b/test/core-flags/records-flag.test.js index e4724266dfb..db9b9308da2 100644 --- a/test/core-flags/records-flag.test.js +++ b/test/core-flags/records-flag.test.js @@ -4,23 +4,26 @@ const { run } = require('../utils/test-utils'); describe('module config related flag', () => { it('should config records-path correctly', () => { - const { stderr, stdout } = run(__dirname, ['--records-path', './bin/records.json']); + const { stderr, stdout, exitCode } = run(__dirname, ['--records-path', './bin/records.json']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('records.json'); }); it('should config records-input-path correctly', () => { - const { stderr, stdout } = run(__dirname, ['--records-input-path', './bin/records.json']); + const { stderr, stdout, exitCode } = run(__dirname, ['--records-input-path', './bin/records.json']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('records.json'); }); it('should config records-output-path correctly', () => { - const { stderr, stdout } = run(__dirname, ['--records-output-path', './bin/records.json']); + const { stderr, stdout, exitCode } = run(__dirname, ['--records-output-path', './bin/records.json']); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('records.json'); }); }); diff --git a/test/core-flags/resolve-flags.test.js b/test/core-flags/resolve-flags.test.js index a8ad663f9c4..abfaa74379f 100644 --- a/test/core-flags/resolve-flags.test.js +++ b/test/core-flags/resolve-flags.test.js @@ -30,19 +30,21 @@ describe('resolve config related flags', () => { if (flag.type === String && !flag.name.includes('alias-') && !flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'browser']); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'browser']); + expect(stderr).toBeFalsy(); if (propName === 'restrictions') { expect(stdout).toContain('browser'); } else { expect(stdout).toContain(`${propName}: [ 'browser' ]`); + expect(exitCode).toBe(0); } }); } if (flag.name.includes('alias-') || flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [ + const { stderr, stdout, exitCode } = run(__dirname, [ `--resolve-alias-alias`, 'alias', '--resolve-alias-name', @@ -64,7 +66,9 @@ describe('resolve config related flags', () => { '--resolve-loader-fallback-name', 'loader-fall-name', ]); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`alias: [ { alias: 'alias', name: 'name' } ]`); expect(stdout).toContain(`aliasFields: [ 'aliasField' ]`); expect(stdout).toContain(`alias: [ { alias: 'loaderAlias', name: 'loaderName' } ]`); @@ -77,7 +81,7 @@ describe('resolve config related flags', () => { if (flag.name.includes('reset')) { it(`should config --${flag.name} alias-reset flags correctly`, () => { - const { stderr, stdout } = run(__dirname, [ + const { stderr, stdout, exitCode } = run(__dirname, [ '--resolve-alias-reset', '--resolve-fallback-reset', '--resolve-alias-fields-reset', @@ -85,7 +89,9 @@ describe('resolve config related flags', () => { '--resolve-loader-alias-fields-reset', '--resolve-loader-fallback-reset', ]); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`alias: []`); expect(stdout).toContain(`aliasFields: []`); expect(stdout).toContain(`fallback: []`); diff --git a/test/core-flags/snapshot-flags.test.js b/test/core-flags/snapshot-flags.test.js index a5efc6c4a87..bcaa517f900 100644 --- a/test/core-flags/snapshot-flags.test.js +++ b/test/core-flags/snapshot-flags.test.js @@ -13,9 +13,10 @@ describe('snapshot config related flags', () => { if (flag.type === Boolean) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; expect(stdout).toContain(`${option}: []`); @@ -29,8 +30,10 @@ describe('snapshot config related flags', () => { if (flag.type === String) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test-snap-path']); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test-snap-path']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('test-snap-path'); }); } diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index f43076ee660..6deb653fd19 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -13,9 +13,10 @@ describe('stats config related flag', () => { if (flag.type === Boolean) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; expect(stdout).toContain(`stats: { ${option}: [] }`); @@ -26,9 +27,10 @@ describe('stats config related flag', () => { if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`stats: { ${propName}: false }`); }); } @@ -36,8 +38,10 @@ describe('stats config related flag', () => { if (flag.type === Number) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`stats: { ${propName}: 10 }`); }); } @@ -46,8 +50,10 @@ describe('stats config related flag', () => { const acceptsSingleValue = ['preset', 'modulesSort', 'logging', 'chunksSort', 'assetsSort']; it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); + let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name.includes('stats-colors')) { const option = flag.name.split('stats-colors-')[1]; stdout = run(__dirname, [`--${flag.name}`, 'u001b[32m']).stdout; diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index ef777ca7a33..16576aaf013 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -13,9 +13,10 @@ describe('watch config related flag', () => { if (flag.type === Boolean) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); if (flag.name.includes('reset')) { expect(stdout).toContain(`watchOptions: { ignored: [] }`); } else { @@ -25,9 +26,10 @@ describe('watch config related flag', () => { if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`watchOptions: { ${propName}: false }`); }); } diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index 18cd26d8e17..6166d346ab9 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -5,7 +5,10 @@ const { run } = require('../utils/test-utils'); describe('output flag defaults', () => { it('should create default file for a given directory', (done) => { - const { stdout } = run(__dirname, ['--entry', './a.js', '--output-path', './binary'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--entry', './a.js', '--output-path', './binary'], false); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); // Should not print warning about config fallback, as we have production as default expect(stdout).not.toContain('option has not been set, webpack will fallback to'); stat(resolve(__dirname, './binary/main.js'), (err, stats) => { diff --git a/test/devtool/array/source-map-array.test.js b/test/devtool/array/source-map-array.test.js index 3672c8eaba7..c5b72c2b80b 100644 --- a/test/devtool/array/source-map-array.test.js +++ b/test/devtool/array/source-map-array.test.js @@ -5,8 +5,11 @@ const { run } = require('../../utils/test-utils'); describe('source-map object', () => { it('should treat source-map settings right', (done) => { - const { stderr } = run(__dirname, [], false); - expect(stderr).toBe(''); + const { stderr, stdout, exitCode } = run(__dirname, [], false); + + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); readdir(resolve(__dirname, 'dist'), (err, files) => { expect(err).toBe(null); expect(files.length).toBe(3); @@ -14,8 +17,11 @@ describe('source-map object', () => { }); }); it('should override entire array on flag', (done) => { - const { stderr } = run(__dirname, ['--devtool', 'source-map', '--output-path', './binary'], false); - expect(stderr).toBe(''); + const { stderr, stdout, exitCode } = run(__dirname, ['--devtool', 'source-map', '--output-path', './binary'], false); + + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); readdir(resolve(__dirname, 'binary'), (err, files) => { expect(err).toBe(null); expect(files.length).toBe(4); diff --git a/test/devtool/object/source-map-object.test.js b/test/devtool/object/source-map-object.test.js index 9418f2eaa2e..c73ce7b2aa2 100644 --- a/test/devtool/object/source-map-object.test.js +++ b/test/devtool/object/source-map-object.test.js @@ -5,7 +5,11 @@ const { run } = require('../../utils/test-utils'); describe('source-map object', () => { it('should not write a source map for obj config', (done) => { - run(__dirname, ['-c', './webpack.eval.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.eval.config.js']); + + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); readdir(resolve(__dirname, 'bin'), (err, files) => { expect(files.length).toBeGreaterThanOrEqual(1); expect(err).toBe(null); @@ -14,8 +18,11 @@ describe('source-map object', () => { }); it('should write a sourcemap file', (done) => { - const { stderr } = run(__dirname, ['-c', './webpack.source.config.js'], false); - expect(stderr).toBe(''); + const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.source.config.js'], false); + + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); stat(resolve(__dirname, 'dist/dist-amd.js.map'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/entry/config-entry/entry-with-command/entry-with-command.test.js b/test/entry/config-entry/entry-with-command/entry-with-command.test.js index 7d83be6ce32..e8ae1a2c741 100644 --- a/test/entry/config-entry/entry-with-command/entry-with-command.test.js +++ b/test/entry/config-entry/entry-with-command/entry-with-command.test.js @@ -5,8 +5,10 @@ const { run } = require('../../../utils/test-utils'); describe('config entry and command entry all exist', () => { it('should use command entry if config command existed', (done) => { - const { stdout } = run(__dirname, ['-c', '../1.js', './index.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js', './index.js'], false); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./index.js'); stat(resolve(__dirname, './binary/main.bundle.js'), (err, stats) => { expect(err).toBeFalsy(); diff --git a/test/entry/config-entry/entry-with-config/entry-with-config.test.js b/test/entry/config-entry/entry-with-config/entry-with-config.test.js index 91880088239..d25ff38a830 100644 --- a/test/entry/config-entry/entry-with-config/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-config/entry-with-config.test.js @@ -5,8 +5,10 @@ const { run } = require('../../../utils/test-utils'); describe('default entry and config entry all exist', () => { it('should use config entry if config entry existed', (done) => { - const { stdout } = run(__dirname, ['-c', '../1.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js'], false); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./a.js'); stat(resolve(__dirname, './binary/index.bundle.js'), (err, stats) => { expect(err).toBeFalsy(); diff --git a/test/entry/config-entry/entry-with-index/entry-with-config.test.js b/test/entry/config-entry/entry-with-index/entry-with-config.test.js index c2cc73734da..d83ee8ab6b5 100644 --- a/test/entry/config-entry/entry-with-index/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-index/entry-with-config.test.js @@ -5,7 +5,10 @@ const { run } = require('../../../utils/test-utils'); describe('default entry and config entry all exist', () => { it('should use config entry if config entry existed', () => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); // Should contain the relevant entry expect(stdout).toContain('./src/app.js'); expect(stdout).toContain('./src/print.js'); diff --git a/test/entry/defaults-empty/entry-single-arg.test.js b/test/entry/defaults-empty/entry-single-arg.test.js index 4b5e8e433e3..b56c6808074 100644 --- a/test/entry/defaults-empty/entry-single-arg.test.js +++ b/test/entry/defaults-empty/entry-single-arg.test.js @@ -4,8 +4,10 @@ const { run } = require('../../utils/test-utils'); describe('single entry flag empty project', () => { it('sets default entry, compiles but throw missing module error', () => { - const { stdout, stderr } = run(__dirname); + const { stdout, stderr, exitCode } = run(__dirname); + + expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(stdout).toContain(`not found: Error: Can't resolve`); }); }); diff --git a/test/entry/defaults-index/entry-multi-args.test.js b/test/entry/defaults-index/entry-multi-args.test.js index 6ce53ebc2eb..9f900848637 100644 --- a/test/entry/defaults-index/entry-multi-args.test.js +++ b/test/entry/defaults-index/entry-multi-args.test.js @@ -7,9 +7,11 @@ const { run } = require('../../utils/test-utils'); describe('single entry flag index present', () => { it('finds default index file and compiles successfully', (done) => { - const { stderr } = run(__dirname); + const { stderr, stdout, exitCode } = run(__dirname); expect(stderr).not.toContain('Module not found'); + expect(exitCode).toBe(0); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './bin/main.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index 1f335734f3f..63798d5281f 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -1,12 +1,14 @@ 'use strict'; -const { run } = require('../../utils/test-utils'); +const { run, isWebpack5 } = require('../../utils/test-utils'); const { stat, readFile } = require('fs'); const { resolve } = require('path'); describe('entry flag', () => { it('should resolve the path to src/index.cjs', (done) => { - const { stderr, stdout } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/'], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); @@ -23,7 +25,9 @@ describe('entry flag', () => { }); it('should load ./src/a.js as entry', (done) => { - const { stderr, stdout } = run(__dirname, ['--entry', './src/a.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--entry', './src/a.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); @@ -39,21 +43,29 @@ describe('entry flag', () => { }); }); - it('should resolve the path to src/a.js as ./src/a.js', (done) => { - const { stderr, stdout } = run(__dirname, ['--entry', 'src/a.js']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + it('should resolve the path to /src/a.js as ./src/a.js for webpack-5 only', (done) => { + const { stderr, stdout, exitCode } = run(__dirname, ['--entry', '/src/a.js']); - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); + if (!isWebpack5) { + expect(exitCode).toBe(1); + expect(stdout).toContain(`Module not found: Error: Can't resolve`); done(); - }); - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(data).toContain('Hello from a.js'); - done(); - }); + } else { + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + + stat(resolve(__dirname, './bin/main.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); + readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { + expect(err).toBe(null); + expect(data).toContain('Hello from a.js'); + done(); + }); + } }); it('should throw error for invalid entry file', () => { diff --git a/test/entry/multiple-entries/multi-entries.test.js b/test/entry/multiple-entries/multi-entries.test.js index 61d278d1760..c0f1bc24d41 100644 --- a/test/entry/multiple-entries/multi-entries.test.js +++ b/test/entry/multiple-entries/multi-entries.test.js @@ -6,7 +6,9 @@ const { resolve } = require('path'); describe(' multiple entries', () => { it('should allow multiple entry files', (done) => { - const { stderr, stdout } = run(__dirname, ['./src/a.js', './src/b.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['./src/a.js', './src/b.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); @@ -24,7 +26,9 @@ describe(' multiple entries', () => { }); it('should allow multiple entry flags', (done) => { - const { stderr, stdout } = run(__dirname, ['--entry', 'src/a.js', '--entry', 'src/b.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--entry', './src/a.js', '--entry', './src/b.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); diff --git a/test/env/array/array-env.test.js b/test/env/array/array-env.test.js index a9571de67fc..2b4f7b4ba1c 100644 --- a/test/env/array/array-env.test.js +++ b/test/env/array/array-env.test.js @@ -11,7 +11,11 @@ const prodFile = path.join(__dirname, './bin/prod.js'); describe('env array', () => { it('is able to set two different environments for an array configuration', () => { - run(__dirname); + const { stderr, stdout, exitCode } = run(__dirname); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); const devScript = spawnSync('node', [devFile]); const prodScript = spawnSync('node', [prodFile]); diff --git a/test/env/object/object-env.test.js b/test/env/object/object-env.test.js index 124aadc5b04..b5a3a5878f6 100644 --- a/test/env/object/object-env.test.js +++ b/test/env/object/object-env.test.js @@ -8,7 +8,12 @@ const { run } = require('../../utils/test-utils'); describe('env object', () => { it('is able to set env for an object', () => { - run(__dirname); + const { stderr, stdout, exitCode } = run(__dirname); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + const executable = path.join(__dirname, './bin/main.js'); const bundledScript = spawnSync('node', [executable]); expect(bundledScript.stdout).toBe('environment is development'); diff --git a/test/help/help-commands.test.js b/test/help/help-commands.test.js index aa2f8dad0e1..a129994fd35 100644 --- a/test/help/help-commands.test.js +++ b/test/help/help-commands.test.js @@ -5,29 +5,41 @@ const helpHeader = 'The build tool for modern web applications'; describe('commands help', () => { it('shows help for subcommands', () => { - const { stderr, stdout } = run(__dirname, ['serve', 'help'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['serve', 'help'], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('webpack s | serve'); }); it('shows help information with subcommands as an arg', () => { - const { stdout, stderr } = run(__dirname, ['help', 'serve'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['help', 'serve'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain('webpack s | serve'); expect(stderr).toHaveLength(0); }); - it('throws error for invalid command with --help flag', () => { - const { stderr } = run(__dirname, ['--help', 'myCommand'], false); + it('shows warning for invalid command with --help flag', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--help', 'myCommand'], false); + + expect(exitCode).toBe(0); expect(stderr).toContain(`You provided an invalid command 'myCommand'`); + expect(stdout).toContain(helpHeader); }); - it('throws error for invalid command with help command', () => { - const { stderr } = run(__dirname, ['help', 'myCommand'], false); + it('shows warning for invalid command with help command', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['help', 'myCommand'], false); + + expect(exitCode).toBe(0); expect(stderr).toContain(`You provided an invalid command 'myCommand'`); + expect(stdout).toContain(helpHeader); }); it('gives precedence to earlier command in case of multiple commands', () => { - const { stdout, stderr } = run(__dirname, ['--help', 'init', 'info'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--help', 'init', 'info'], false); + + expect(exitCode).toBe(0); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain('webpack c | init [scaffold]'); expect(stderr).toHaveLength(0); diff --git a/test/help/help-flags.test.js b/test/help/help-flags.test.js index 0829d58a9be..4257f9a0781 100644 --- a/test/help/help-flags.test.js +++ b/test/help/help-flags.test.js @@ -4,25 +4,35 @@ const { run } = require('../utils/test-utils'); const helpHeader = 'The build tool for modern web applications'; describe('commands help', () => { - it('throws error for invalid flag with --help flag', () => { - const { stderr } = run(__dirname, ['--help', '--my-flag'], false); + it('log warning for invalid flag with --help flag', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--help', '--my-flag'], false); + + expect(exitCode).toBe(0); expect(stderr).toContain(`You provided an invalid option '--my-flag'`); + expect(stdout).toContain(helpHeader); }); - it('throws error for invalid flag with help command', () => { - const { stderr } = run(__dirname, ['help', '--my-flag'], false); + it('log warning for invalid flag with help command', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['help', '--my-flag'], false); + + expect(exitCode).toBe(0); expect(stderr).toContain(`You provided an invalid option '--my-flag'`); + expect(stdout).toContain(helpHeader); }); it('shows flag help with valid flag', () => { - const { stdout, stderr } = run(__dirname, ['--help', '--merge'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--merge'], false); + + expect(exitCode).toBe(0); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain('webpack -m, --merge'); expect(stderr).toHaveLength(0); }); it('should show help for --mode', () => { - const { stdout, stderr } = run(__dirname, ['--mode', '--help'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--mode', '--help'], false); + + expect(exitCode).toBe(0); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain('webpack --mode '); expect(stdout).toContain('Defines the mode to pass to webpack'); @@ -30,7 +40,9 @@ describe('commands help', () => { }); it('gives precedence to earlier flag in case of multiple flags', () => { - const { stdout, stderr } = run(__dirname, ['--help', '--entry', '--merge'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--entry', '--merge'], false); + + expect(exitCode).toBe(0); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain('webpack --entry '); expect(stderr).toHaveLength(0); diff --git a/test/help/help-multi-args.test.js b/test/help/help-multi-args.test.js index b3e8298a4d2..bddba916b41 100644 --- a/test/help/help-multi-args.test.js +++ b/test/help/help-multi-args.test.js @@ -7,7 +7,9 @@ const helpHeader = 'The build tool for modern web applications'; describe('help cmd with multiple arguments', () => { commands.forEach((cmd) => { it(`shows cmd help with ${cmd.name}`, () => { - const { stdout, stderr } = run(__dirname, ['--help', `${cmd.name}`], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--help', `${cmd.name}`], false); + + expect(exitCode).toBe(0); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain(`${cmd.name}`); expect(stdout).toContain(`${cmd.usage}`); @@ -17,7 +19,9 @@ describe('help cmd with multiple arguments', () => { }); it('should output help for --version by taking precedence', () => { - const { stdout, stderr } = run(__dirname, ['--help', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain('webpack -v, --version'); expect(stderr).toHaveLength(0); diff --git a/test/help/help-single-arg.test.js b/test/help/help-single-arg.test.js index 5583fc63ee1..a92326eefce 100644 --- a/test/help/help-single-arg.test.js +++ b/test/help/help-single-arg.test.js @@ -6,10 +6,12 @@ const helpHeader = 'The build tool for modern web applications'; describe('single help flag', () => { it('respects --no-color flag', () => { - const { stdout, stderr } = run(__dirname, ['--help', '--no-color'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--no-color'], false); const usage = 'webpack [...options] | '; const example = 'webpack help --flag | '; options.enabled = true; + + expect(exitCode).toBe(0); expect(stdout).not.toContain(yellow(usage)); expect(stdout).not.toContain(yellow(example)); expect(stdout).toContain(usage); @@ -18,13 +20,17 @@ describe('single help flag', () => { }); it('outputs help info with command syntax', () => { - const { stdout, stderr } = run(__dirname, ['help'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['help'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(helpHeader); expect(stderr).toHaveLength(0); }); it('outputs help info with dashed syntax', () => { - const { stdout, stderr } = run(__dirname, ['--help'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--help'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(helpHeader); expect(stderr).toHaveLength(0); }); diff --git a/test/hot/hot-flag.test.js b/test/hot/hot-flag.test.js index b9c30fe3f87..c7b75436954 100644 --- a/test/hot/hot-flag.test.js +++ b/test/hot/hot-flag.test.js @@ -6,7 +6,9 @@ const { yellow } = require('colorette'); describe('--hot flag', () => { it('should be successful when --hot is passed', (done) => { - const { stderr, stdout } = run(__dirname, ['--hot']); + const { stderr, stdout, exitCode } = run(__dirname, ['--hot']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('HotModuleReplacementPlugin'); @@ -18,7 +20,9 @@ describe('--hot flag', () => { }); it('should warn when --hot and --no-hot both are passed', (done) => { - const { stderr, stdout } = run(__dirname, ['--no-hot', '--hot']); + const { stderr, stdout, exitCode } = run(__dirname, ['--no-hot', '--hot']); + + expect(exitCode).toBe(0); expect(stderr).toContain( `[webpack-cli] ${yellow( 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', diff --git a/test/info/info-help.test.js b/test/info/info-help.test.js index 5544ce7df91..7b77f3e0d83 100644 --- a/test/info/info-help.test.js +++ b/test/info/info-help.test.js @@ -11,23 +11,29 @@ const descriptionText = 'Outputs information about your system and dependencies' describe('should print help for info command', () => { it('shows usage information on supplying help flag', () => { - const { stdout, stderr } = runInfo(['--help'], __dirname); + const { stdout, stderr, exitCode } = runInfo(['--help'], __dirname); + + expect(exitCode).toBe(0); expect(stdout).toContain(usageText); expect(stdout).toContain(descriptionText); expect(stderr).toHaveLength(0); }); it('should respect the --no-color flag', () => { - const { stdout, stderr } = runInfo(['--help', '--no-color'], __dirname); + const { stdout, stderr, exitCode } = runInfo(['--help', '--no-color'], __dirname); options.enabled = true; + + expect(exitCode).toBe(0); expect(stdout).not.toContain(yellow(usageText)); expect(stdout).toContain(descriptionText); expect(stderr).toHaveLength(0); }); it('should output all cli flags', () => { - const { stdout, stderr } = runInfo(['--help'], __dirname); + const { stdout, stderr, exitCode } = runInfo(['--help'], __dirname); + infoFlags.forEach((flag) => expect(stdout).toContain(`--${flag.name}`)); expect(stderr).toHaveLength(0); + expect(exitCode).toBe(0); }); }); diff --git a/test/info/info-unknown.test.js b/test/info/info-unknown.test.js index bcb071cf287..2cd8f8c7593 100644 --- a/test/info/info-unknown.test.js +++ b/test/info/info-unknown.test.js @@ -3,7 +3,10 @@ const { runInfo } = require('../utils/test-utils'); describe('should handle unknown args', () => { it('shows an appropriate warning on supplying unknown args', () => { - const { stderr } = runInfo(['--unknown'], __dirname); + const { stderr, stdout, exitCode } = runInfo(['--unknown'], __dirname); + + expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] ${red('Unknown argument: --unknown')}`); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 93dcc74cdc8..03a3be80584 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -3,37 +3,49 @@ const { run } = require('../../utils/test-utils'); describe('mode flags', () => { it('should set mode=production by default', () => { - const { stderr, stdout } = run(__dirname); + const { stderr, stdout, exitCode } = run(__dirname); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); }); it('should load a development config when --mode=development is passed', () => { - const { stderr, stdout } = run(__dirname, ['--mode', 'development']); + const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'development']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); it('should load a production config when --mode=production is passed', () => { - const { stderr, stdout } = run(__dirname, ['--mode', 'production']); + const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'production']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); }); it('should load a none config when --mode=none is passed', () => { - const { stderr, stdout } = run(__dirname, ['--mode', 'none']); + const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'none']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'none'`); }); it('should pick mode form NODE_ENV', () => { - const { stderr, stdout } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); + const { stderr, stdout, exitCode } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); it('should throw error when --mode=abcd is passed', () => { - const { stderr } = run(__dirname, ['--mode', 'abcd']); + const { stderr, exitCode } = run(__dirname, ['--mode', 'abcd']); + + expect(exitCode).toBe(2); expect(stderr).toContain('configuration.mode should be one of these'); expect(stderr).toContain(`"development" | "production" | "none"`); }); diff --git a/test/mode/mode-with-config/mode-with-config.test.js b/test/mode/mode-with-config/mode-with-config.test.js index 0609608f14d..9eee9f6f8d4 100644 --- a/test/mode/mode-with-config/mode-with-config.test.js +++ b/test/mode/mode-with-config/mode-with-config.test.js @@ -6,7 +6,9 @@ const { run } = require('../../utils/test-utils'); describe('mode flags with config', () => { it('should run in production mode when --mode=production is passed', (done) => { - const { stderr, stdout } = run(__dirname, ['--mode', 'production', '--config', './webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'production', '--config', './webpack.config.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); @@ -35,7 +37,9 @@ describe('mode flags with config', () => { }); it('should run in development mode when --mode=development is passed', (done) => { - const { stderr, stdout } = run(__dirname, ['--mode', 'development', '--config', './webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'development', '--config', './webpack.config.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); @@ -64,7 +68,9 @@ describe('mode flags with config', () => { }); it('should run in none mode when --mode=none is passed', (done) => { - const { stderr, stdout } = run(__dirname, ['--mode', 'none', '--config', './webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'none', '--config', './webpack.config.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); @@ -94,6 +100,7 @@ describe('mode flags with config', () => { it('should use mode flag over config', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'production', '-c', 'webpack.config2.js']); + expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); expect(stdout).toContain(`mode: 'production'`); @@ -103,6 +110,7 @@ describe('mode flags with config', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'none', '-c', 'webpack.config2.js'], false, [], { NODE_ENV: 'production', }); + expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); expect(stdout).toContain(`mode: 'none'`); @@ -110,6 +118,7 @@ describe('mode flags with config', () => { it('should use mode from config over NODE_ENV', () => { const { stdout, stderr, exitCode } = run(__dirname, ['-c', 'webpack.config2.js']); + expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); expect(stdout).toContain(`mode: 'development'`); @@ -117,6 +126,7 @@ describe('mode flags with config', () => { it('should use mode from config when multiple config are supplied', () => { const { stdout, stderr } = run(__dirname, ['-c', 'webpack.config3.js', '-c', 'webpack.config2.js']); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'development'", 'g')).length).toEqual(1); @@ -124,6 +134,7 @@ describe('mode flags with config', () => { it('mode flag should apply to all configs', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'none', '-c', './webpack.config3.js', '-c', './webpack.config2.js']); + expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); expect(stdout).toContain(`mode: 'none'`); @@ -134,6 +145,7 @@ describe('mode flags with config', () => { const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config3.js', '-c', './webpack.config2.js'], false, [], { NODE_ENV: 'production', }); + expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); expect(stdout).toContain(`mode: 'production'`); diff --git a/test/name/name.test.js b/test/name/name.test.js index 7321c6c99af..d615a55ee3f 100644 --- a/test/name/name.test.js +++ b/test/name/name.test.js @@ -3,8 +3,10 @@ const { run } = require('../utils/test-utils'); describe('name flag', () => { it('should set the flag in the config', () => { - const { stdout, stderr } = run(__dirname, ['--name', 'config-name'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--name', 'config-name'], false); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain("name: 'config-name'"); }); }); diff --git a/test/no-hot/no-hot.test.js b/test/no-hot/no-hot.test.js index b139d009dc0..bd80177cd9a 100644 --- a/test/no-hot/no-hot.test.js +++ b/test/no-hot/no-hot.test.js @@ -6,7 +6,9 @@ const { yellow } = require('colorette'); describe('no-hot flag', () => { it('should be successful when --no-hot is passed', (done) => { - const { stderr, stdout } = run(__dirname, ['--no-hot']); + const { stderr, stdout, exitCode } = run(__dirname, ['--no-hot']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(stdout).not.toContain('webpack/runtime/hot module replacement'); @@ -25,7 +27,9 @@ describe('no-hot flag', () => { }); it('should warn when --hot and --no-hot both are passed', (done) => { - const { stderr, stdout } = run(__dirname, ['--hot', '--no-hot']); + const { stderr, stdout, exitCode } = run(__dirname, ['--hot', '--no-hot']); + + expect(exitCode).toBe(0); expect(stderr).toContain( `[webpack-cli] ${yellow( 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', diff --git a/test/node/node.test.js b/test/node/node.test.js index 9807d8d13ed..077e34044a4 100644 --- a/test/node/node.test.js +++ b/test/node/node.test.js @@ -8,10 +8,12 @@ const { run } = require('../utils/test-utils'); // throws different error from what we manually see describe('node flags', () => { it('is able to pass the options flags to node js', async (done) => { - const { stdout, stderr } = await run(__dirname, ['--output-path', './bin'], false, [ + const { stdout, stderr, exitCode } = await run(__dirname, ['--output-path', './bin'], false, [ `--require=${resolve(__dirname, 'bootstrap.js')}`, `--require=${resolve(__dirname, 'bootstrap2.js')}`, ]); + + expect(exitCode).toBe(0); expect(stdout).toContain('---from bootstrap.js---'); expect(stdout).toContain('---from bootstrap2.js---'); expect(stderr).toBeFalsy(); @@ -23,18 +25,24 @@ describe('node flags', () => { }); it('throws an error on supplying unknown flags', async () => { - const { stderr } = await run(__dirname, [], false, ['--unknown']); + const { stderr, exitCode } = await run(__dirname, [], false, ['--unknown']); + + expect(exitCode).not.toBe(0); expect(stderr).toContain('bad option'); }); it('throws an error if no values were supplied with --max-old-space-size', async () => { - const { stderr, stdout } = await run(__dirname, [], false, ['--max-old-space-size']); + const { stderr, stdout, exitCode } = await run(__dirname, [], false, ['--max-old-space-size']); + + expect(exitCode).not.toBe(0); expect(stderr).toContain('value for flag --max-old-space-size'); expect(stdout).toBeFalsy(); }); it('throws an error if an illegal value was supplied with --max-old-space-size', async () => { - const { stderr, stdout } = await run(__dirname, [], true, ['--max_old_space_size=1024a']); + const { stderr, stdout, exitCode } = await run(__dirname, [], true, ['--max_old_space_size=1024a']); + + expect(exitCode).not.toBe(0); expect(stderr).toContain('Error: illegal value for flag --max_old_space_size=1024a of type size_t'); expect(stdout).toBeFalsy(); }); diff --git a/test/optimization/optimization.test.js b/test/optimization/optimization.test.js index 5cc52e669be..74e97f03e7f 100644 --- a/test/optimization/optimization.test.js +++ b/test/optimization/optimization.test.js @@ -5,16 +5,18 @@ const { run } = require('../utils/test-utils'); describe('optimization option in config', () => { it('should work with mangleExports disabled', () => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); // Should throw when webpack is less than 5 if (!version.startsWith('5')) { expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'"); + expect(exitCode).toBe(2); } else { // Should apply the provided optimization to the compiler expect(stdout).toContain('mangleExports: false'); // check that the output file exists expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeTruthy(); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); } }); }); diff --git a/test/output/named-bundles/output-named-bundles.test.js b/test/output/named-bundles/output-named-bundles.test.js index ecd7970531f..0743bb84f67 100644 --- a/test/output/named-bundles/output-named-bundles.test.js +++ b/test/output/named-bundles/output-named-bundles.test.js @@ -5,7 +5,9 @@ const { run } = require('../../utils/test-utils'); describe('output flag named bundles', () => { it('should output file given as flag instead of in configuration', () => { - const { stderr } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'], false); + const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const stats = statSync(resolve(__dirname, './binary/a.bundle.js')); @@ -13,7 +15,9 @@ describe('output flag named bundles', () => { }); it('should resolve the path to binary/a.bundle.js as ./binary/a.bundle.js', () => { - const { stderr } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', 'binary'], false); + const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', 'binary'], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const stats = statSync(resolve(__dirname, './binary/a.bundle.js')); @@ -21,7 +25,13 @@ describe('output flag named bundles', () => { }); it('should create multiple bundles with an overriding flag', () => { - const { stderr } = run(__dirname, ['-c', resolve(__dirname, 'webpack.single.config.js'), '--output-path', './bin'], false); + const { stderr, exitCode } = run( + __dirname, + ['-c', resolve(__dirname, 'webpack.single.config.js'), '--output-path', './bin'], + false, + ); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); let stats = statSync(resolve(__dirname, './bin/b.bundle.js')); @@ -31,7 +41,9 @@ describe('output flag named bundles', () => { }); it('should successfully compile multiple entries', () => { - const { stderr } = run(__dirname, ['-c', resolve(__dirname, 'webpack.multiple.config.js')], false); + const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.multiple.config.js')], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); let stats = statSync(resolve(__dirname, './bin/b.bundle.js')); @@ -42,6 +54,7 @@ describe('output flag named bundles', () => { it('should output file in bin directory using default webpack config with warning for empty output value', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--output-path'], false); + expect(stderr).toEqual("error: option '-o, --output-path ' argument missing"); expect(exitCode).toEqual(1); expect(stdout).toBeFalsy(); diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index 66dcb8933b1..2c5eafad51c 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -9,7 +9,7 @@ describe('Prefetch Flag', () => { }); it('Should load the prefetched file', () => { - const { stdout, stderr } = run(__dirname, ['--prefetch', './src/p.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch', './src/p.js'], false); // Should be able to find the entry file expect(stdout).toContain('./src/index.js'); // Should invoke the PrefetchPlugin with correct params @@ -17,21 +17,24 @@ describe('Prefetch Flag', () => { // check that the output file exists expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeTruthy(); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); }); it('Should err when the prefetched file is absent', () => { - const { stdout, stderr } = run(__dirname, ['--prefetch', './src/somefile.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch', './src/somefile.js'], false); // Should contain the error message expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); + expect(exitCode).toBe(1); // check that the output file does not exist since prefetched file is not found expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeFalsy(); expect(stderr).toBeFalsy(); }); it('Should err when flag value is not supplied', () => { - const { stdout, stderr } = run(__dirname, ['--prefetch'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch'], false); // Should contain the error message expect(stderr).toContain(`error: option '--prefetch ' argument missing`); expect(stdout).toBeFalsy(); + expect(exitCode).toBe(1); }); }); diff --git a/test/stats/cli-flags/stats.test.js b/test/stats/cli-flags/stats.test.js index e8baa9b0f20..ed461160782 100644 --- a/test/stats/cli-flags/stats.test.js +++ b/test/stats/cli-flags/stats.test.js @@ -12,7 +12,9 @@ if (isWebpack5) { describe('stats flag', () => { for (const preset of presets) { it(`should accept --stats "${preset}"`, () => { - const { stderr, stdout } = run(__dirname, ['--stats', `${preset}`]); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats', `${preset}`]); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: '${preset}' }`); @@ -23,7 +25,9 @@ describe('stats flag', () => { } it('should accept stats as boolean', () => { - const { stderr, stdout } = run(__dirname, ['--stats']); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: 'normal' }`); @@ -34,6 +38,7 @@ describe('stats flag', () => { it('should warn when an unknown flag stats value is passed', () => { const { stderr, exitCode } = run(__dirname, ['--stats', 'foo']); + expect(stderr).toBeTruthy(); expect(stderr).toContain('* configuration.stats should be one of these:'); if (isWebpack5) { diff --git a/test/stats/config/stats.test.js b/test/stats/config/stats.test.js index 8f44bbfb363..84c77b6e3ca 100644 --- a/test/stats/config/stats.test.js +++ b/test/stats/config/stats.test.js @@ -6,7 +6,9 @@ const { version } = require('webpack'); describe('stats flag with config', () => { it('should compile without stats flag', () => { - const { stderr, stdout } = run(__dirname, []); + const { stderr, stdout, exitCode } = run(__dirname, []); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'normal' }`); @@ -15,7 +17,9 @@ describe('stats flag with config', () => { } }); it('should compile with stats flag', () => { - const { stderr, stdout } = run(__dirname, ['--stats', 'errors-warnings']); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats', 'errors-warnings']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'errors-warnings' }`); diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index 0d15d20293a..23b01983600 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -8,7 +8,9 @@ const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', ' describe('--target flag', () => { targetValues.forEach((val) => { it(`should accept ${val} with --target flag`, (done) => { - const { stdout, stderr } = run(__dirname, ['--target', `${val}`]); + const { stdout, stderr, exitCode } = run(__dirname, ['--target', `${val}`]); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); @@ -24,7 +26,9 @@ describe('--target flag', () => { }); it(`should accept ${val} with -t alias`, (done) => { - const { stdout, stderr } = run(__dirname, ['-t', `${val}`]); + const { stdout, stderr, exitCode } = run(__dirname, ['-t', `${val}`]); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); @@ -41,7 +45,9 @@ describe('--target flag', () => { }); it(`should throw error with invalid value for --target`, () => { - const { stderr } = run(__dirname, ['--target', 'invalid']); + const { stderr, exitCode } = run(__dirname, ['--target', 'invalid']); + + expect(exitCode).toBe(2); if (isWebpack5) { expect(stderr).toContain(`Unknown target 'invalid'`); } else { @@ -51,7 +57,9 @@ describe('--target flag', () => { if (isWebpack5) { it('should allow multiple targets', () => { - const { stderr, stdout } = run(__dirname, ['--target', 'node', '--target', 'async-node']); + const { stderr, stdout, exitCode } = run(__dirname, ['--target', 'node', '--target', 'async-node']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: [ 'node', 'async-node' ]`); }); diff --git a/test/version/version-external-packages.test.js b/test/version/version-external-packages.test.js index 505a46a2c7d..7dfd06b5084 100644 --- a/test/version/version-external-packages.test.js +++ b/test/version/version-external-packages.test.js @@ -11,73 +11,95 @@ const cliPkgJSON = require('../../packages/webpack-cli/package.json'); describe('version flag with external packages', () => { it('outputs version with init', () => { - const { stdout, stderr } = run(__dirname, ['init', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['init', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(initPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs version with the alias c for init', () => { - const { stdout, stderr } = run(__dirname, ['c', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['c', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(initPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs version with info', () => { - const { stdout, stderr } = run(__dirname, ['info', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['info', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(infoPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs version with serve', () => { - const { stdout, stderr } = run(__dirname, ['serve', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['serve', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(servePkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs version with migrate', () => { - const { stdout, stderr } = run(__dirname, ['migrate', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['migrate', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(migratePkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs version with plugin', () => { - const { stdout, stderr } = run(__dirname, ['plugin', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['plugin', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(pluginPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs version with loader', () => { - const { stdout, stderr } = run(__dirname, ['loader', '--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['loader', '--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(loaderPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); expect(stderr).toHaveLength(0); }); it(' should throw error for multiple commands', () => { - const { stderr } = run(__dirname, ['init', 'migrate', '--version'], false); + const { stderr, exitCode } = run(__dirname, ['init', 'migrate', '--version'], false); + + expect(exitCode).toBe(2); expect(stderr).toContain('You provided multiple commands.'); }); it(' should throw error if invalid argument is present with --version flag', () => { - const { stderr, stdout } = run(__dirname, ['init', 'abc', '--version'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '--version'], false); + + expect(exitCode).toBe(2); expect(stderr).toContain(`Error: Invalid command 'abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); it(' should throw error if invalid argument is present with version command', () => { - const { stderr, stdout } = run(__dirname, ['init', 'abc', 'version'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', 'version'], false); + + expect(exitCode).toBe(2); expect(stderr).toContain(`Error: Invalid command 'abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); it(' should throw error if invalid argument is present with -v alias', () => { - const { stderr, stdout } = run(__dirname, ['init', 'abc', '-v'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '-v'], false); + + expect(exitCode).toBe(2); expect(stderr).toContain(`Error: Invalid command 'abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); diff --git a/test/version/version-multi-args.test.js b/test/version/version-multi-args.test.js index ada6c9917de..585bb59b792 100644 --- a/test/version/version-multi-args.test.js +++ b/test/version/version-multi-args.test.js @@ -5,8 +5,10 @@ const pkgJSON = require('../../packages/webpack-cli/package.json'); describe('version flag with multiple arguments', () => { it('does not output version with help command', () => { - const { stdout, stderr } = run(__dirname, ['version', 'help'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['version', 'help'], false); + expect(stdout).not.toContain(pkgJSON.version); + expect(exitCode).toBe(0); const uniqueIdentifier = 'The build tool for modern web applications'; expect(stdout).toContain(uniqueIdentifier); @@ -14,8 +16,10 @@ describe('version flag with multiple arguments', () => { }); it('does not output version with help dashed', () => { - const { stdout, stderr } = run(__dirname, ['version', '--help'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['version', '--help'], false); + expect(stdout).not.toContain(pkgJSON.version); + expect(exitCode).toBe(0); const uniqueIdentifier = 'The build tool for modern web applications'; expect(stdout).toContain(uniqueIdentifier); @@ -23,42 +27,54 @@ describe('version flag with multiple arguments', () => { }); it('throws error if invalid command is passed with version command', () => { - const { stdout, stderr } = run(__dirname, ['version', 'abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['version', 'abc'], false); + + expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`Error: Invalid command 'abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); it('throws error if invalid option is passed with version command', () => { - const { stdout, stderr } = run(__dirname, ['version', '--abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['version', '--abc'], false); + + expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`Error: Invalid option '--abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); it('throws error if invalid command is passed with --version flag', () => { - const { stdout, stderr } = run(__dirname, ['--version', 'abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--version', 'abc'], false); + + expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`Error: Invalid command 'abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); it('throws error if invalid option is passed with --version flag', () => { - const { stdout, stderr } = run(__dirname, ['--version', '--abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--version', '--abc'], false); + + expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`Error: Invalid option '--abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); it('throws error if invalid command is passed with -v alias', () => { - const { stdout, stderr } = run(__dirname, ['-v', 'abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-v', 'abc'], false); + + expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`Error: Invalid command 'abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); }); it('throws error if invalid option is passed with -v alias', () => { - const { stdout, stderr } = run(__dirname, ['-v', '--abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-v', '--abc'], false); + + expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`Error: Invalid option '--abc'`); expect(stdout).toContain('Run webpack --help to see available commands and arguments'); diff --git a/test/version/version-single-arg.test.js b/test/version/version-single-arg.test.js index 9f2b6a1f174..72a6114b8a3 100644 --- a/test/version/version-single-arg.test.js +++ b/test/version/version-single-arg.test.js @@ -5,19 +5,25 @@ const pkgJSON = require('../../packages/webpack-cli/package.json'); describe('single version flag', () => { it('outputs versions with command syntax', () => { - const { stdout, stderr } = run(__dirname, ['version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(pkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs versions with dashed syntax', () => { - const { stdout, stderr } = run(__dirname, ['--version'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--version'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(pkgJSON.version); expect(stderr).toHaveLength(0); }); it('outputs versions with alias syntax', () => { - const { stdout, stderr } = run(__dirname, ['-v'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-v'], false); + + expect(exitCode).toBe(0); expect(stdout).toContain(pkgJSON.version); expect(stderr).toHaveLength(0); }); diff --git a/test/zero-config/entry-absent/zero-config.test.js b/test/zero-config/entry-absent/zero-config.test.js index 9acc630d895..b67e707fba1 100644 --- a/test/zero-config/entry-absent/zero-config.test.js +++ b/test/zero-config/entry-absent/zero-config.test.js @@ -2,9 +2,10 @@ const { run } = require('../../utils/test-utils'); describe('Zero Config tests', () => { it('runs when config and entry are both absent', () => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); // Entry file is absent, should log the Error from the compiler expect(stdout).toContain("Error: Can't resolve './src'"); + expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); }); }); diff --git a/test/zero-config/entry-present/zero-config.test.js b/test/zero-config/entry-present/zero-config.test.js index 029c385cac3..dc551da4bcf 100644 --- a/test/zero-config/entry-present/zero-config.test.js +++ b/test/zero-config/entry-present/zero-config.test.js @@ -4,7 +4,7 @@ const { run } = require('../../utils/test-utils'); describe('Zero Config tests', () => { it('runs when no config is supplied but entry is present', () => { - const { stdout, stderr } = run(__dirname, [], false); + const { stdout, stderr, exitCode } = run(__dirname, [], false); // Should be able to find the entry file expect(stdout).toContain('./src/index.js'); // Should output at the default output dir and filename @@ -12,5 +12,6 @@ describe('Zero Config tests', () => { // check that the output file exists expect(fs.existsSync(path.join(__dirname, '/dist/main.js'))).toBeTruthy(); expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); }); }); From 28143656b3fb6f81f1b486c0e454882f1d866dd8 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 4 Nov 2020 17:29:52 +0530 Subject: [PATCH 028/581] chore: configure codecov reporting (#2032) --- .codecov.yml | 29 +++++++++++++++++------------ .nycrc | 12 +++++++----- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 9d693da8d71..d295391be7a 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,15 +1,20 @@ -comment: on +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: '50...100' parsers: - javascript: - enable_partials: yes + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no -coverage: - status: - project: - default: - threshold: 4% - if_not_found: success - patch: - default: - if_not_found: success +comment: + layout: 'reach,diff,flags,files,footer' + behavior: default + require_changes: no diff --git a/.nycrc b/.nycrc index 23943f67603..24934c6b2c5 100644 --- a/.nycrc +++ b/.nycrc @@ -1,10 +1,12 @@ { - "all": true, + "include": [ + "packages/**" + ], "reporter": [ - "html", - "json", - "cobertura" + "html", + "json", + "cobertura" ], "source-map": true, "exclude-after-remap": false -} \ No newline at end of file +} From 49c84de10da55512bbdfc63ea7f451ee78b3d378 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2020 15:02:42 +0300 Subject: [PATCH 029/581] chore(deps-dev): bump jest from 26.6.1 to 26.6.3 (#2034) Bumps [jest](https://github.com/facebook/jest) from 26.6.1 to 26.6.3. - [Release notes](https://github.com/facebook/jest/releases) - [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/facebook/jest/compare/v26.6.1...v26.6.3) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 678 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 393 insertions(+), 285 deletions(-) diff --git a/yarn.lock b/yarn.lock index 019a69849aa..2a7c6c97574 100644 --- a/yarn.lock +++ b/yarn.lock @@ -465,7 +465,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-top-level-await@^7.12.1": +"@babel/plugin-syntax-top-level-await@^7.12.1", "@babel/plugin-syntax-top-level-await@^7.8.3": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.12.1.tgz#dd6c0b357ac1bb142d98537450a319625d13d2a0" integrity sha512-i7ooMZFS+a/Om0crxZodrTzNEPJHZrlMVGMTEpFAj6rYY/bKCddB0Dk/YxfPuYXOopuhKk/e1jV6h+WUU9XN3A== @@ -1165,34 +1165,46 @@ jest-util "^26.6.1" slash "^3.0.0" -"@jest/core@^26.6.1": - version "26.6.1" - resolved "https://registry.yarnpkg.com/@jest/core/-/core-26.6.1.tgz#77426822f667a2cda82bf917cee11cc8ba71f9ac" - integrity sha512-p4F0pgK3rKnoS9olXXXOkbus1Bsu6fd8pcvLMPsUy4CVXZ8WSeiwQ1lK5hwkCIqJ+amZOYPd778sbPha/S8Srw== +"@jest/console@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-26.6.2.tgz#4e04bc464014358b03ab4937805ee36a0aeb98f2" + integrity sha512-IY1R2i2aLsLr7Id3S6p2BA82GNWryt4oSvEXLAKc+L2zdi89dSkE8xC1C+0kpATG4JhBJREnQOH7/zmccM2B0g== dependencies: - "@jest/console" "^26.6.1" - "@jest/reporters" "^26.6.1" - "@jest/test-result" "^26.6.1" - "@jest/transform" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" + "@types/node" "*" + chalk "^4.0.0" + jest-message-util "^26.6.2" + jest-util "^26.6.2" + slash "^3.0.0" + +"@jest/core@^26.6.3": + version "26.6.3" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-26.6.3.tgz#7639fcb3833d748a4656ada54bde193051e45fad" + integrity sha512-xvV1kKbhfUqFVuZ8Cyo+JPpipAHHAV3kcDBftiduK8EICXmTFddryy3P7NfZt8Pv37rA9nEJBKCCkglCPt/Xjw== + dependencies: + "@jest/console" "^26.6.2" + "@jest/reporters" "^26.6.2" + "@jest/test-result" "^26.6.2" + "@jest/transform" "^26.6.2" + "@jest/types" "^26.6.2" "@types/node" "*" ansi-escapes "^4.2.1" chalk "^4.0.0" exit "^0.1.2" graceful-fs "^4.2.4" - jest-changed-files "^26.6.1" - jest-config "^26.6.1" - jest-haste-map "^26.6.1" - jest-message-util "^26.6.1" + jest-changed-files "^26.6.2" + jest-config "^26.6.3" + jest-haste-map "^26.6.2" + jest-message-util "^26.6.2" jest-regex-util "^26.0.0" - jest-resolve "^26.6.1" - jest-resolve-dependencies "^26.6.1" - jest-runner "^26.6.1" - jest-runtime "^26.6.1" - jest-snapshot "^26.6.1" - jest-util "^26.6.1" - jest-validate "^26.6.1" - jest-watcher "^26.6.1" + jest-resolve "^26.6.2" + jest-resolve-dependencies "^26.6.3" + jest-runner "^26.6.3" + jest-runtime "^26.6.3" + jest-snapshot "^26.6.2" + jest-util "^26.6.2" + jest-validate "^26.6.2" + jest-watcher "^26.6.2" micromatch "^4.0.2" p-each-series "^2.1.0" rimraf "^3.0.0" @@ -1204,47 +1216,47 @@ resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-26.5.0.tgz#1d07947adc51ea17766d9f0ccf5a8d6ea94c47dc" integrity sha512-DJ+pEBUIqarrbv1W/C39f9YH0rJ4wsXZ/VC6JafJPlHW2HOucKceeaqTOQj9MEDQZjySxMLkOq5mfXZXNZcmWw== -"@jest/environment@^26.6.1": - version "26.6.1" - resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-26.6.1.tgz#38a56f1cc66f96bf53befcc5ebeaf1c2dce90e9a" - integrity sha512-GNvHwkOFJtNgSwdzH9flUPzF9AYAZhUg124CBoQcwcZCM9s5TLz8Y3fMtiaWt4ffbigoetjGk5PU2Dd8nLrSEw== +"@jest/environment@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-26.6.2.tgz#ba364cc72e221e79cc8f0a99555bf5d7577cf92c" + integrity sha512-nFy+fHl28zUrRsCeMB61VDThV1pVTtlEokBRgqPrcT1JNq4yRNIyTHfyht6PqtUvY9IsuLGTrbG8kPXjSZIZwA== dependencies: - "@jest/fake-timers" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/fake-timers" "^26.6.2" + "@jest/types" "^26.6.2" "@types/node" "*" - jest-mock "^26.6.1" + jest-mock "^26.6.2" -"@jest/fake-timers@^26.6.1": - version "26.6.1" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-26.6.1.tgz#5aafba1822075b7142e702b906094bea15f51acf" - integrity sha512-T/SkMLgOquenw/nIisBRD6XAYpFir0kNuclYLkse5BpzeDUukyBr+K31xgAo9M0hgjU9ORlekAYPSzc0DKfmKg== +"@jest/fake-timers@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-26.6.2.tgz#459c329bcf70cee4af4d7e3f3e67848123535aad" + integrity sha512-14Uleatt7jdzefLPYM3KLcnUl1ZNikaKq34enpb5XG9i81JpppDb5muZvonvKyrl7ftEHkKS5L5/eB/kxJ+bvA== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" "@sinonjs/fake-timers" "^6.0.1" "@types/node" "*" - jest-message-util "^26.6.1" - jest-mock "^26.6.1" - jest-util "^26.6.1" + jest-message-util "^26.6.2" + jest-mock "^26.6.2" + jest-util "^26.6.2" -"@jest/globals@^26.6.1": - version "26.6.1" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-26.6.1.tgz#b232c7611d8a2de62b4bf9eb9a007138322916f4" - integrity sha512-acxXsSguuLV/CeMYmBseefw6apO7NuXqpE+v5r3yD9ye2PY7h1nS20vY7Obk2w6S7eJO4OIAJeDnoGcLC/McEQ== +"@jest/globals@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-26.6.2.tgz#5b613b78a1aa2655ae908eba638cc96a20df720a" + integrity sha512-85Ltnm7HlB/KesBUuALwQ68YTU72w9H2xW9FjZ1eL1U3lhtefjjl5c2MiUbpXt/i6LaPRvoOFJ22yCBSfQ0JIA== dependencies: - "@jest/environment" "^26.6.1" - "@jest/types" "^26.6.1" - expect "^26.6.1" + "@jest/environment" "^26.6.2" + "@jest/types" "^26.6.2" + expect "^26.6.2" -"@jest/reporters@^26.6.1": - version "26.6.1" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-26.6.1.tgz#582ede05278cf5eeffe58bc519f4a35f54fbcb0d" - integrity sha512-J6OlXVFY3q1SXWJhjme5i7qT/BAZSikdOK2t8Ht5OS32BDo6KfG5CzIzzIFnAVd82/WWbc9Hb7SJ/jwSvVH9YA== +"@jest/reporters@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-26.6.2.tgz#1f518b99637a5f18307bd3ecf9275f6882a667f6" + integrity sha512-h2bW53APG4HvkOnVMo8q3QXa6pcaNt1HkwVsOPMBV6LD/q9oSpxNSYZQYkAnjdMjrJ86UuYeLo+aEZClV6opnw== dependencies: "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "^26.6.1" - "@jest/test-result" "^26.6.1" - "@jest/transform" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/console" "^26.6.2" + "@jest/test-result" "^26.6.2" + "@jest/transform" "^26.6.2" + "@jest/types" "^26.6.2" chalk "^4.0.0" collect-v8-coverage "^1.0.0" exit "^0.1.2" @@ -1255,22 +1267,22 @@ istanbul-lib-report "^3.0.0" istanbul-lib-source-maps "^4.0.0" istanbul-reports "^3.0.2" - jest-haste-map "^26.6.1" - jest-resolve "^26.6.1" - jest-util "^26.6.1" - jest-worker "^26.6.1" + jest-haste-map "^26.6.2" + jest-resolve "^26.6.2" + jest-util "^26.6.2" + jest-worker "^26.6.2" slash "^3.0.0" source-map "^0.6.0" string-length "^4.0.1" terminal-link "^2.0.0" - v8-to-istanbul "^6.0.1" + v8-to-istanbul "^7.0.0" optionalDependencies: node-notifier "^8.0.0" -"@jest/source-map@^26.5.0": - version "26.5.0" - resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-26.5.0.tgz#98792457c85bdd902365cd2847b58fff05d96367" - integrity sha512-jWAw9ZwYHJMe9eZq/WrsHlwF8E3hM9gynlcDpOyCb9bR8wEd9ZNBZCi7/jZyzHxC7t3thZ10gO2IDhu0bPKS5g== +"@jest/source-map@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-26.6.2.tgz#29af5e1e2e324cafccc936f218309f54ab69d535" + integrity sha512-YwYcCwAnNmOVsZ8mr3GfnzdXDAl4LaenZP5z+G0c8bzC9/dugL8zRmxZzdoTl4IaS3CryS1uWnROLPFmb6lVvA== dependencies: callsites "^3.0.0" graceful-fs "^4.2.4" @@ -1286,32 +1298,42 @@ "@types/istanbul-lib-coverage" "^2.0.0" collect-v8-coverage "^1.0.0" -"@jest/test-sequencer@^26.6.1": - version "26.6.1" - resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-26.6.1.tgz#34216ac2c194b0eeebde30d25424d1134703fd2e" - integrity sha512-0csqA/XApZiNeTIPYh6koIDCACSoR6hi29T61tKJMtCZdEC+tF3PoNt7MS0oK/zKC6daBgCbqXxia5ztr/NyCQ== +"@jest/test-result@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-26.6.2.tgz#55da58b62df134576cc95476efa5f7949e3f5f18" + integrity sha512-5O7H5c/7YlojphYNrK02LlDIV2GNPYisKwHm2QTKjNZeEzezCbwYs9swJySv2UfPMyZ0VdsmMv7jIlD/IKYQpQ== dependencies: - "@jest/test-result" "^26.6.1" + "@jest/console" "^26.6.2" + "@jest/types" "^26.6.2" + "@types/istanbul-lib-coverage" "^2.0.0" + collect-v8-coverage "^1.0.0" + +"@jest/test-sequencer@^26.6.3": + version "26.6.3" + resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-26.6.3.tgz#98e8a45100863886d074205e8ffdc5a7eb582b17" + integrity sha512-YHlVIjP5nfEyjlrSr8t/YdNfU/1XEt7c5b4OxcXCjyRhjzLYu/rO69/WHPuYcbCWkz8kAeZVZp2N2+IOLLEPGw== + dependencies: + "@jest/test-result" "^26.6.2" graceful-fs "^4.2.4" - jest-haste-map "^26.6.1" - jest-runner "^26.6.1" - jest-runtime "^26.6.1" + jest-haste-map "^26.6.2" + jest-runner "^26.6.3" + jest-runtime "^26.6.3" -"@jest/transform@^26.6.1": - version "26.6.1" - resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-26.6.1.tgz#f70786f96e0f765947b4fb4f54ffcfb7bd783711" - integrity sha512-oNFAqVtqRxZRx6vXL3I4bPKUK0BIlEeaalkwxyQGGI8oXDQBtYQBpiMe5F7qPs4QdvvFYB42gPGIMMcxXaBBxQ== +"@jest/transform@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-26.6.2.tgz#5ac57c5fa1ad17b2aae83e73e45813894dcf2e4b" + integrity sha512-E9JjhUgNzvuQ+vVAL21vlyfy12gP0GhazGgJC4h6qUt1jSdUXGWJ1wfu/X7Sd8etSgxV4ovT1pb9v5D6QW4XgA== dependencies: "@babel/core" "^7.1.0" - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" babel-plugin-istanbul "^6.0.0" chalk "^4.0.0" convert-source-map "^1.4.0" fast-json-stable-stringify "^2.0.0" graceful-fs "^4.2.4" - jest-haste-map "^26.6.1" + jest-haste-map "^26.6.2" jest-regex-util "^26.0.0" - jest-util "^26.6.1" + jest-util "^26.6.2" micromatch "^4.0.2" pirates "^4.0.1" slash "^3.0.0" @@ -1329,6 +1351,17 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@jest/types@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" + integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^15.0.0" + chalk "^4.0.0" + "@lerna/add@3.21.0": version "3.21.0" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.21.0.tgz#27007bde71cc7b0a2969ab3c2f0ae41578b4577b" @@ -3158,16 +3191,16 @@ babel-core@^7.0.0-bridge.0: resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg== -babel-jest@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.6.1.tgz#07bd7bec14de47fe0f2c9a139741329f1f41788b" - integrity sha512-duMWEOKrSBYRVTTNpL2SipNIWnZOjP77auOBMPQ3zXAdnDbyZQWU8r/RxNWpUf9N6cgPFecQYelYLytTVXVDtA== +babel-jest@^26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.6.3.tgz#d87d25cb0037577a0c89f82e5755c5d293c01056" + integrity sha512-pl4Q+GAVOHwvjrck6jKjvmGhnO3jHX/xuB9d27f+EJZ/6k+6nMuPjorrYp7s++bKKdANwzElBWnLWaObvTnaZA== dependencies: - "@jest/transform" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/transform" "^26.6.2" + "@jest/types" "^26.6.2" "@types/babel__core" "^7.1.7" babel-plugin-istanbul "^6.0.0" - babel-preset-jest "^26.5.0" + babel-preset-jest "^26.6.2" chalk "^4.0.0" graceful-fs "^4.2.4" slash "^3.0.0" @@ -3190,20 +3223,20 @@ babel-plugin-istanbul@^6.0.0: istanbul-lib-instrument "^4.0.0" test-exclude "^6.0.0" -babel-plugin-jest-hoist@^26.5.0: - version "26.5.0" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-26.5.0.tgz#3916b3a28129c29528de91e5784a44680db46385" - integrity sha512-ck17uZFD3CDfuwCLATWZxkkuGGFhMij8quP8CNhwj8ek1mqFgbFzRJ30xwC04LLscj/aKsVFfRST+b5PT7rSuw== +babel-plugin-jest-hoist@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-26.6.2.tgz#8185bd030348d254c6d7dd974355e6a28b21e62d" + integrity sha512-PO9t0697lNTmcEHH69mdtYiOIkkOlj9fySqfO3K1eCcdISevLAE0xY59VLLUj0SoiPiTX/JU2CYFpILydUa5Lw== dependencies: "@babel/template" "^7.3.3" "@babel/types" "^7.3.3" "@types/babel__core" "^7.0.0" "@types/babel__traverse" "^7.0.6" -babel-preset-current-node-syntax@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.4.tgz#826f1f8e7245ad534714ba001f84f7e906c3b615" - integrity sha512-5/INNCYhUGqw7VbVjT/hb3ucjgkVHKXY7lX3ZjlN4gm565VyFmJUrJ/h+h16ECVB38R/9SF6aACydpKMLZ/c9w== +babel-preset-current-node-syntax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.0.tgz#cf5feef29551253471cfa82fc8e0f5063df07a77" + integrity sha512-mGkvkpocWJes1CmMKtgGUwCeeq0pOhALyymozzDWYomHTbDLwueDYG6p4TK1YOeYHCzBzYPsWkgTto10JubI1Q== dependencies: "@babel/plugin-syntax-async-generators" "^7.8.4" "@babel/plugin-syntax-bigint" "^7.8.3" @@ -3216,14 +3249,15 @@ babel-preset-current-node-syntax@^0.1.3: "@babel/plugin-syntax-object-rest-spread" "^7.8.3" "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" "@babel/plugin-syntax-optional-chaining" "^7.8.3" + "@babel/plugin-syntax-top-level-await" "^7.8.3" -babel-preset-jest@^26.5.0: - version "26.5.0" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-26.5.0.tgz#f1b166045cd21437d1188d29f7fba470d5bdb0e7" - integrity sha512-F2vTluljhqkiGSJGBg/jOruA8vIIIL11YrxRcO7nviNTMbbofPSHwnm8mgP7d/wS7wRSexRoI6X1A6T74d4LQA== +babel-preset-jest@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-26.6.2.tgz#747872b1171df032252426586881d62d31798fee" + integrity sha512-YvdtlVm9t3k777c5NPQIv6cxFFFapys25HiUmuSgHwIZhfifweR5c5Sf5nwE3MAbfu327CYSvps8Yx6ANLyleQ== dependencies: - babel-plugin-jest-hoist "^26.5.0" - babel-preset-current-node-syntax "^0.1.3" + babel-plugin-jest-hoist "^26.6.2" + babel-preset-current-node-syntax "^1.0.0" balanced-match@^1.0.0: version "1.0.0" @@ -3660,10 +3694,10 @@ ci-info@^2.0.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== -cjs-module-lexer@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.4.3.tgz#9e31f7fe701f5fcee5793f77ab4e58fa8dcde8bc" - integrity sha512-5RLK0Qfs0PNDpEyBXIr3bIT1Muw3ojSlvpw6dAmkUcO0+uTrsBn7GuEIgx40u+OzbCBLDta7nvmud85P4EmTsQ== +cjs-module-lexer@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz#4186fcca0eae175970aee870b9fe2d6cf8d5655f" + integrity sha512-uc2Vix1frTfnuzxxu1Hp4ktSvM3QaI4oXl4ZUqL1wjTu/BGki9TrCWoqLTg/drR1KwAEarXuRFCG2Svr1GxPFw== class-utils@^0.3.5: version "0.3.6" @@ -4511,6 +4545,11 @@ diff-sequences@^26.5.0: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.5.0.tgz#ef766cf09d43ed40406611f11c6d8d9dd8b2fefd" integrity sha512-ZXx86srb/iYy6jG71k++wBN9P9J05UNQ5hQHQd9MtMPvcqXPx/vKU69jfHV637D00Q2gSgPk2D+jSx3l1lDW/Q== +diff-sequences@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" + integrity sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q== + diff@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -5081,16 +5120,16 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -expect@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/expect/-/expect-26.6.1.tgz#e1e053cdc43b21a452b36fc7cc9401e4603949c1" - integrity sha512-BRfxIBHagghMmr1D2MRY0Qv5d3Nc8HCqgbDwNXw/9izmM5eBb42a2YjLKSbsqle76ozGkAEPELQX4IdNHAKRNA== +expect@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/expect/-/expect-26.6.2.tgz#c6b996bf26bf3fe18b67b2d0f51fc981ba934417" + integrity sha512-9/hlOBkQl2l/PLHJx6JjoDF6xPKcJEsUlWKb23rKE7KzeDqUZKXKNMW27KIue5JMdBV9HgmoJPcc8HtO85t9IA== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" ansi-styles "^4.0.0" jest-get-type "^26.3.0" - jest-matcher-utils "^26.6.1" - jest-message-util "^26.6.1" + jest-matcher-utils "^26.6.2" + jest-message-util "^26.6.2" jest-regex-util "^26.0.0" express@^4.16.3, express@^4.17.1: @@ -6945,59 +6984,59 @@ jake@^10.6.1: filelist "^1.0.1" minimatch "^3.0.4" -jest-changed-files@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-26.6.1.tgz#2fac3dc51297977ee883347948d8e3d37c417fba" - integrity sha512-NhSdZ5F6b/rIN5V46x1l31vrmukD/bJUXgYAY8VtP1SknYdJwjYDRxuLt7Z8QryIdqCjMIn2C0Cd98EZ4umo8Q== +jest-changed-files@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-26.6.2.tgz#f6198479e1cc66f22f9ae1e22acaa0b429c042d0" + integrity sha512-fDS7szLcY9sCtIip8Fjry9oGf3I2ht/QT21bAHm5Dmf0mD4X3ReNUf17y+bO6fR8WgbIZTlbyG1ak/53cbRzKQ== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" execa "^4.0.0" throat "^5.0.0" -jest-cli@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-26.6.1.tgz#8952242fa812c05bd129abf7c022424045b7fd67" - integrity sha512-aPLoEjlwFrCWhiPpW5NUxQA1X1kWsAnQcQ0SO/fHsCvczL3W75iVAcH9kP6NN+BNqZcHNEvkhxT5cDmBfEAh+w== +jest-cli@^26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-26.6.3.tgz#43117cfef24bc4cd691a174a8796a532e135e92a" + integrity sha512-GF9noBSa9t08pSyl3CY4frMrqp+aQXFGFkf5hEPbh/pIUFYWMK6ZLTfbmadxJVcJrdRoChlWQsA2VkJcDFK8hg== dependencies: - "@jest/core" "^26.6.1" - "@jest/test-result" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/core" "^26.6.3" + "@jest/test-result" "^26.6.2" + "@jest/types" "^26.6.2" chalk "^4.0.0" exit "^0.1.2" graceful-fs "^4.2.4" import-local "^3.0.2" is-ci "^2.0.0" - jest-config "^26.6.1" - jest-util "^26.6.1" - jest-validate "^26.6.1" + jest-config "^26.6.3" + jest-util "^26.6.2" + jest-validate "^26.6.2" prompts "^2.0.1" yargs "^15.4.1" -jest-config@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-26.6.1.tgz#8c343fbdd9c24ad003e261f73583c3c020f32b42" - integrity sha512-mtJzIynIwW1d1nMlKCNCQiSgWaqFn8cH/fOSNY97xG7Y9tBCZbCSuW2GTX0RPmceSJGO7l27JgwC18LEg0Vg+g== +jest-config@^26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-26.6.3.tgz#64f41444eef9eb03dc51d5c53b75c8c71f645349" + integrity sha512-t5qdIj/bCj2j7NFVHb2nFB4aUdfucDn3JRKgrZnplb8nieAirAzRSHP8uDEd+qV6ygzg9Pz4YG7UTJf94LPSyg== dependencies: "@babel/core" "^7.1.0" - "@jest/test-sequencer" "^26.6.1" - "@jest/types" "^26.6.1" - babel-jest "^26.6.1" + "@jest/test-sequencer" "^26.6.3" + "@jest/types" "^26.6.2" + babel-jest "^26.6.3" chalk "^4.0.0" deepmerge "^4.2.2" glob "^7.1.1" graceful-fs "^4.2.4" - jest-environment-jsdom "^26.6.1" - jest-environment-node "^26.6.1" + jest-environment-jsdom "^26.6.2" + jest-environment-node "^26.6.2" jest-get-type "^26.3.0" - jest-jasmine2 "^26.6.1" + jest-jasmine2 "^26.6.3" jest-regex-util "^26.0.0" - jest-resolve "^26.6.1" - jest-util "^26.6.1" - jest-validate "^26.6.1" + jest-resolve "^26.6.2" + jest-util "^26.6.2" + jest-validate "^26.6.2" micromatch "^4.0.2" - pretty-format "^26.6.1" + pretty-format "^26.6.2" -jest-diff@^26.0.0, jest-diff@^26.6.1: +jest-diff@^26.0.0: version "26.6.1" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.1.tgz#38aa194979f454619bb39bdee299fb64ede5300c" integrity sha512-BBNy/zin2m4kG5In126O8chOBxLLS/XMTuuM2+YhgyHk87ewPzKTuTJcqj3lOWOi03NNgrl+DkMeV/exdvG9gg== @@ -7007,6 +7046,16 @@ jest-diff@^26.0.0, jest-diff@^26.6.1: jest-get-type "^26.3.0" pretty-format "^26.6.1" +jest-diff@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394" + integrity sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA== + dependencies: + chalk "^4.0.0" + diff-sequences "^26.6.2" + jest-get-type "^26.3.0" + pretty-format "^26.6.2" + jest-docblock@^26.0.0: version "26.0.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-26.0.0.tgz#3e2fa20899fc928cb13bd0ff68bd3711a36889b5" @@ -7014,109 +7063,109 @@ jest-docblock@^26.0.0: dependencies: detect-newline "^3.0.0" -jest-each@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-26.6.1.tgz#e968e88309a3e2ae9648634af8f89d8ee5acfddd" - integrity sha512-gSn8eB3buchuq45SU7pLB7qmCGax1ZSxfaWuEFblCyNMtyokYaKFh9dRhYPujK6xYL57dLIPhLKatjmB5XWzGA== +jest-each@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-26.6.2.tgz#02526438a77a67401c8a6382dfe5999952c167cb" + integrity sha512-Mer/f0KaATbjl8MCJ+0GEpNdqmnVmDYqCTJYTvoo7rqmRiDllmp2AYN+06F93nXcY3ur9ShIjS+CO/uD+BbH4A== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" chalk "^4.0.0" jest-get-type "^26.3.0" - jest-util "^26.6.1" - pretty-format "^26.6.1" + jest-util "^26.6.2" + pretty-format "^26.6.2" -jest-environment-jsdom@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-26.6.1.tgz#63093bf89daee6139616568a43633b84cf7aac21" - integrity sha512-A17RiXuHYNVlkM+3QNcQ6n5EZyAc6eld8ra9TW26luounGWpku4tj03uqRgHJCI1d4uHr5rJiuCH5JFRtdmrcA== +jest-environment-jsdom@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-26.6.2.tgz#78d09fe9cf019a357009b9b7e1f101d23bd1da3e" + integrity sha512-jgPqCruTlt3Kwqg5/WVFyHIOJHsiAvhcp2qiR2QQstuG9yWox5+iHpU3ZrcBxW14T4fe5Z68jAfLRh7joCSP2Q== dependencies: - "@jest/environment" "^26.6.1" - "@jest/fake-timers" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/environment" "^26.6.2" + "@jest/fake-timers" "^26.6.2" + "@jest/types" "^26.6.2" "@types/node" "*" - jest-mock "^26.6.1" - jest-util "^26.6.1" + jest-mock "^26.6.2" + jest-util "^26.6.2" jsdom "^16.4.0" -jest-environment-node@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-26.6.1.tgz#4d73d8b33c26989a92a0ed3ad0bfd6f7a196d9bd" - integrity sha512-YffaCp6h0j1kbcf1NVZ7umC6CPgD67YS+G1BeornfuSkx5s3xdhuwG0DCxSiHPXyT81FfJzA1L7nXvhq50OWIg== +jest-environment-node@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-26.6.2.tgz#824e4c7fb4944646356f11ac75b229b0035f2b0c" + integrity sha512-zhtMio3Exty18dy8ee8eJ9kjnRyZC1N4C1Nt/VShN1apyXc8rWGtJ9lI7vqiWcyyXS4BVSEn9lxAM2D+07/Tag== dependencies: - "@jest/environment" "^26.6.1" - "@jest/fake-timers" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/environment" "^26.6.2" + "@jest/fake-timers" "^26.6.2" + "@jest/types" "^26.6.2" "@types/node" "*" - jest-mock "^26.6.1" - jest-util "^26.6.1" + jest-mock "^26.6.2" + jest-util "^26.6.2" jest-get-type@^26.3.0: version "26.3.0" resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0" integrity sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig== -jest-haste-map@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.6.1.tgz#97e96f5fd7576d980307fbe6160b10c016b543d4" - integrity sha512-9kPafkv0nX6ta1PrshnkiyhhoQoFWncrU/uUBt3/AP1r78WSCU5iLceYRTwDvJl67H3RrXqSlSVDDa/AsUB7OQ== +jest-haste-map@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-26.6.2.tgz#dd7e60fe7dc0e9f911a23d79c5ff7fb5c2cafeaa" + integrity sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" "@types/graceful-fs" "^4.1.2" "@types/node" "*" anymatch "^3.0.3" fb-watchman "^2.0.0" graceful-fs "^4.2.4" jest-regex-util "^26.0.0" - jest-serializer "^26.5.0" - jest-util "^26.6.1" - jest-worker "^26.6.1" + jest-serializer "^26.6.2" + jest-util "^26.6.2" + jest-worker "^26.6.2" micromatch "^4.0.2" sane "^4.0.3" walker "^1.0.7" optionalDependencies: fsevents "^2.1.2" -jest-jasmine2@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-26.6.1.tgz#11c92603d1fa97e3c33404359e69d6cec7e57017" - integrity sha512-2uYdT32o/ZzSxYAPduAgokO8OlAL1YdG/9oxcEY138EDNpIK5XRRJDaGzTZdIBWSxk0aR8XxN44FvfXtHB+Fiw== +jest-jasmine2@^26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-26.6.3.tgz#adc3cf915deacb5212c93b9f3547cd12958f2edd" + integrity sha512-kPKUrQtc8aYwBV7CqBg5pu+tmYXlvFlSFYn18ev4gPFtrRzB15N2gW/Roew3187q2w2eHuu0MU9TJz6w0/nPEg== dependencies: "@babel/traverse" "^7.1.0" - "@jest/environment" "^26.6.1" - "@jest/source-map" "^26.5.0" - "@jest/test-result" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/environment" "^26.6.2" + "@jest/source-map" "^26.6.2" + "@jest/test-result" "^26.6.2" + "@jest/types" "^26.6.2" "@types/node" "*" chalk "^4.0.0" co "^4.6.0" - expect "^26.6.1" + expect "^26.6.2" is-generator-fn "^2.0.0" - jest-each "^26.6.1" - jest-matcher-utils "^26.6.1" - jest-message-util "^26.6.1" - jest-runtime "^26.6.1" - jest-snapshot "^26.6.1" - jest-util "^26.6.1" - pretty-format "^26.6.1" + jest-each "^26.6.2" + jest-matcher-utils "^26.6.2" + jest-message-util "^26.6.2" + jest-runtime "^26.6.3" + jest-snapshot "^26.6.2" + jest-util "^26.6.2" + pretty-format "^26.6.2" throat "^5.0.0" -jest-leak-detector@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-26.6.1.tgz#f63e46dc4e3aa30d29b40ae49966a15730d25bbe" - integrity sha512-j9ZOtJSJKlHjrs4aIxWjiQUjyrffPdiAQn2Iw0916w7qZE5Lk0T2KhIH6E9vfhzP6sw0Q0jtnLLb4vQ71o1HlA== +jest-leak-detector@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-26.6.2.tgz#7717cf118b92238f2eba65054c8a0c9c653a91af" + integrity sha512-i4xlXpsVSMeKvg2cEKdfhh0H39qlJlP5Ex1yQxwF9ubahboQYMgTtz5oML35AVA3B4Eu+YsmwaiKVev9KCvLxg== dependencies: jest-get-type "^26.3.0" - pretty-format "^26.6.1" + pretty-format "^26.6.2" -jest-matcher-utils@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-26.6.1.tgz#bc90822d352c91c2ec1814731327691d06598400" - integrity sha512-9iu3zrsYlUnl8pByhREF9rr5eYoiEb1F7ymNKg6lJr/0qD37LWS5FSW/JcoDl8UdMX2+zAzabDs7sTO+QFKjCg== +jest-matcher-utils@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-26.6.2.tgz#8e6fd6e863c8b2d31ac6472eeb237bc595e53e7a" + integrity sha512-llnc8vQgYcNqDrqRDXWwMr9i7rS5XFiCwvh6DTP7Jqa2mqpcCBBlpCbn+trkG0KNhPu/h8rzyBkriOtBstvWhw== dependencies: chalk "^4.0.0" - jest-diff "^26.6.1" + jest-diff "^26.6.2" jest-get-type "^26.3.0" - pretty-format "^26.6.1" + pretty-format "^26.6.2" jest-message-util@^26.6.1: version "26.6.1" @@ -7132,12 +7181,27 @@ jest-message-util@^26.6.1: slash "^3.0.0" stack-utils "^2.0.2" -jest-mock@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-26.6.1.tgz#6c12a92a82fc833f81a5b6de6b67d78386e276a3" - integrity sha512-my0lPTBu1awY8iVG62sB2sx9qf8zxNDVX+5aFgoB8Vbqjb6LqIOsfyFA8P1z6H2IsqMbvOX9oCJnK67Y3yUIMA== +jest-message-util@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-26.6.2.tgz#58173744ad6fc0506b5d21150b9be56ef001ca07" + integrity sha512-rGiLePzQ3AzwUshu2+Rn+UMFk0pHN58sOG+IaJbk5Jxuqo3NYO1U2/MIR4S1sKgsoYSXSzdtSa0TgrmtUwEbmA== dependencies: - "@jest/types" "^26.6.1" + "@babel/code-frame" "^7.0.0" + "@jest/types" "^26.6.2" + "@types/stack-utils" "^2.0.0" + chalk "^4.0.0" + graceful-fs "^4.2.4" + micromatch "^4.0.2" + pretty-format "^26.6.2" + slash "^3.0.0" + stack-utils "^2.0.2" + +jest-mock@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-26.6.2.tgz#d6cb712b041ed47fe0d9b6fc3474bc6543feb302" + integrity sha512-YyFjePHHp1LzpzYcmgqkJ0nm0gg/lJx2aZFzFy1S6eUqNjXsOqTK10zNRff2dNfssgokjkG65OlWNcIlgd3zew== + dependencies: + "@jest/types" "^26.6.2" "@types/node" "*" jest-pnp-resolver@^1.2.2: @@ -7150,84 +7214,84 @@ jest-regex-util@^26.0.0: resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-26.0.0.tgz#d25e7184b36e39fd466c3bc41be0971e821fee28" integrity sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A== -jest-resolve-dependencies@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-26.6.1.tgz#e9d091a159ad198c029279737a8b4c507791d75c" - integrity sha512-MN6lufbZJ3RBfTnJesZtHu3hUCBqPdHRe2+FhIt0yiqJ3fMgzWRqMRQyN/d/QwOE7KXwAG2ekZutbPhuD7s51A== +jest-resolve-dependencies@^26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-26.6.3.tgz#6680859ee5d22ee5dcd961fe4871f59f4c784fb6" + integrity sha512-pVwUjJkxbhe4RY8QEWzN3vns2kqyuldKpxlxJlzEYfKSvY6/bMvxoFrYYzUO1Gx28yKWN37qyV7rIoIp2h8fTg== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" jest-regex-util "^26.0.0" - jest-snapshot "^26.6.1" + jest-snapshot "^26.6.2" -jest-resolve@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-26.6.1.tgz#e9a9130cc069620d5aeeb87043dd9e130b68c6a1" - integrity sha512-hiHfQH6rrcpAmw9xCQ0vD66SDuU+7ZulOuKwc4jpbmFFsz0bQG/Ib92K+9/489u5rVw0btr/ZhiHqBpmkbCvuQ== +jest-resolve@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-26.6.2.tgz#a3ab1517217f469b504f1b56603c5bb541fbb507" + integrity sha512-sOxsZOq25mT1wRsfHcbtkInS+Ek7Q8jCHUB0ZUTP0tc/c41QHriU/NunqMfCUWsL4H3MHpvQD4QR9kSYhS7UvQ== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" chalk "^4.0.0" graceful-fs "^4.2.4" jest-pnp-resolver "^1.2.2" - jest-util "^26.6.1" + jest-util "^26.6.2" read-pkg-up "^7.0.1" resolve "^1.18.1" slash "^3.0.0" -jest-runner@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-26.6.1.tgz#a945971b5a23740c1fe20e372a38de668b7c76bf" - integrity sha512-DmpNGdgsbl5s0FGkmsInmqnmqCtliCSnjWA2TFAJS1m1mL5atwfPsf+uoZ8uYQ2X0uDj4NM+nPcDnUpbNTRMBA== +jest-runner@^26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-26.6.3.tgz#2d1fed3d46e10f233fd1dbd3bfaa3fe8924be159" + integrity sha512-atgKpRHnaA2OvByG/HpGA4g6CSPS/1LK0jK3gATJAoptC1ojltpmVlYC3TYgdmGp+GLuhzpH30Gvs36szSL2JQ== dependencies: - "@jest/console" "^26.6.1" - "@jest/environment" "^26.6.1" - "@jest/test-result" "^26.6.1" - "@jest/types" "^26.6.1" + "@jest/console" "^26.6.2" + "@jest/environment" "^26.6.2" + "@jest/test-result" "^26.6.2" + "@jest/types" "^26.6.2" "@types/node" "*" chalk "^4.0.0" emittery "^0.7.1" exit "^0.1.2" graceful-fs "^4.2.4" - jest-config "^26.6.1" + jest-config "^26.6.3" jest-docblock "^26.0.0" - jest-haste-map "^26.6.1" - jest-leak-detector "^26.6.1" - jest-message-util "^26.6.1" - jest-resolve "^26.6.1" - jest-runtime "^26.6.1" - jest-util "^26.6.1" - jest-worker "^26.6.1" + jest-haste-map "^26.6.2" + jest-leak-detector "^26.6.2" + jest-message-util "^26.6.2" + jest-resolve "^26.6.2" + jest-runtime "^26.6.3" + jest-util "^26.6.2" + jest-worker "^26.6.2" source-map-support "^0.5.6" throat "^5.0.0" -jest-runtime@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-26.6.1.tgz#9a131e7b4f0bc6beefd62e7443f757c1d5fa9dec" - integrity sha512-7uOCNeezXDWgjEyzYbRN2ViY7xNZzusNVGAMmU0UHRUNXuY4j4GBHKGMqPo/cBPZA9bSYp+lwK2DRRBU5Dv6YQ== - dependencies: - "@jest/console" "^26.6.1" - "@jest/environment" "^26.6.1" - "@jest/fake-timers" "^26.6.1" - "@jest/globals" "^26.6.1" - "@jest/source-map" "^26.5.0" - "@jest/test-result" "^26.6.1" - "@jest/transform" "^26.6.1" - "@jest/types" "^26.6.1" +jest-runtime@^26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-26.6.3.tgz#4f64efbcfac398331b74b4b3c82d27d401b8fa2b" + integrity sha512-lrzyR3N8sacTAMeonbqpnSka1dHNux2uk0qqDXVkMv2c/A3wYnvQ4EXuI013Y6+gSKSCxdaczvf4HF0mVXHRdw== + dependencies: + "@jest/console" "^26.6.2" + "@jest/environment" "^26.6.2" + "@jest/fake-timers" "^26.6.2" + "@jest/globals" "^26.6.2" + "@jest/source-map" "^26.6.2" + "@jest/test-result" "^26.6.2" + "@jest/transform" "^26.6.2" + "@jest/types" "^26.6.2" "@types/yargs" "^15.0.0" chalk "^4.0.0" - cjs-module-lexer "^0.4.2" + cjs-module-lexer "^0.6.0" collect-v8-coverage "^1.0.0" exit "^0.1.2" glob "^7.1.3" graceful-fs "^4.2.4" - jest-config "^26.6.1" - jest-haste-map "^26.6.1" - jest-message-util "^26.6.1" - jest-mock "^26.6.1" + jest-config "^26.6.3" + jest-haste-map "^26.6.2" + jest-message-util "^26.6.2" + jest-mock "^26.6.2" jest-regex-util "^26.0.0" - jest-resolve "^26.6.1" - jest-snapshot "^26.6.1" - jest-util "^26.6.1" - jest-validate "^26.6.1" + jest-resolve "^26.6.2" + jest-snapshot "^26.6.2" + jest-util "^26.6.2" + jest-validate "^26.6.2" slash "^3.0.0" strip-bom "^4.0.0" yargs "^15.4.1" @@ -7241,34 +7305,34 @@ jest-serializer-ansi@^1.0.3: lodash "^4.17.4" strip-ansi "^4.0.0" -jest-serializer@^26.5.0: - version "26.5.0" - resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-26.5.0.tgz#f5425cc4c5f6b4b355f854b5f0f23ec6b962bc13" - integrity sha512-+h3Gf5CDRlSLdgTv7y0vPIAoLgX/SI7T4v6hy+TEXMgYbv+ztzbg5PSN6mUXAT/hXYHvZRWm+MaObVfqkhCGxA== +jest-serializer@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-26.6.2.tgz#d139aafd46957d3a448f3a6cdabe2919ba0742d1" + integrity sha512-S5wqyz0DXnNJPd/xfIzZ5Xnp1HrJWBczg8mMfMpN78OJ5eDxXyf+Ygld9wX1DnUWbIbhM1YDY95NjR4CBXkb2g== dependencies: "@types/node" "*" graceful-fs "^4.2.4" -jest-snapshot@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-26.6.1.tgz#469e9d0b749496aea7dad0d7e5e5c88b91cdb4cc" - integrity sha512-JA7bZp7HRTIJYAi85pJ/OZ2eur2dqmwIToA5/6d7Mn90isGEfeF9FvuhDLLEczgKP1ihreBzrJ6Vr7zteP5JNA== +jest-snapshot@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-26.6.2.tgz#f3b0af1acb223316850bd14e1beea9837fb39c84" + integrity sha512-OLhxz05EzUtsAmOMzuupt1lHYXCNib0ECyuZ/PZOx9TrZcC8vL0x+DUG3TL+GLX3yHG45e6YGjIm0XwDc3q3og== dependencies: "@babel/types" "^7.0.0" - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" "@types/babel__traverse" "^7.0.4" "@types/prettier" "^2.0.0" chalk "^4.0.0" - expect "^26.6.1" + expect "^26.6.2" graceful-fs "^4.2.4" - jest-diff "^26.6.1" + jest-diff "^26.6.2" jest-get-type "^26.3.0" - jest-haste-map "^26.6.1" - jest-matcher-utils "^26.6.1" - jest-message-util "^26.6.1" - jest-resolve "^26.6.1" + jest-haste-map "^26.6.2" + jest-matcher-utils "^26.6.2" + jest-message-util "^26.6.2" + jest-resolve "^26.6.2" natural-compare "^1.4.0" - pretty-format "^26.6.1" + pretty-format "^26.6.2" semver "^7.3.2" jest-util@^26.1.0, jest-util@^26.6.1: @@ -7283,17 +7347,29 @@ jest-util@^26.1.0, jest-util@^26.6.1: is-ci "^2.0.0" micromatch "^4.0.2" -jest-validate@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-26.6.1.tgz#28730eb8570d60968d9d06f1a8c94d922167bd2a" - integrity sha512-BEFpGbylKocnNPZULcnk+TGaz1oFZQH/wcaXlaXABbu0zBwkOGczuWgdLucUouuQqn7VadHZZeTvo8VSFDLMOA== +jest-util@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1" + integrity sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q== dependencies: - "@jest/types" "^26.6.1" + "@jest/types" "^26.6.2" + "@types/node" "*" + chalk "^4.0.0" + graceful-fs "^4.2.4" + is-ci "^2.0.0" + micromatch "^4.0.2" + +jest-validate@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-26.6.2.tgz#23d380971587150467342911c3d7b4ac57ab20ec" + integrity sha512-NEYZ9Aeyj0i5rQqbq+tpIOom0YS1u2MVu6+euBsvpgIme+FOfRmoC4R5p0JiAUpaFvFy24xgrpMknarR/93XjQ== + dependencies: + "@jest/types" "^26.6.2" camelcase "^6.0.0" chalk "^4.0.0" jest-get-type "^26.3.0" leven "^3.1.0" - pretty-format "^26.6.1" + pretty-format "^26.6.2" jest-watch-typeahead@^0.6.1: version "0.6.1" @@ -7308,7 +7384,7 @@ jest-watch-typeahead@^0.6.1: string-length "^4.0.1" strip-ansi "^6.0.0" -jest-watcher@^26.3.0, jest-watcher@^26.6.1: +jest-watcher@^26.3.0: version "26.6.1" resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-26.6.1.tgz#debfa34e9c5c3e735593403794fe53d2955bfabc" integrity sha512-0LBIPPncNi9CaLKK15bnxyd2E8OMl4kJg0PTiNOI+MXztXw1zVdtX/x9Pr6pXaQYps+eS/ts43O4+HByZ7yJSw== @@ -7321,6 +7397,19 @@ jest-watcher@^26.3.0, jest-watcher@^26.6.1: jest-util "^26.6.1" string-length "^4.0.1" +jest-watcher@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-26.6.2.tgz#a5b683b8f9d68dbcb1d7dae32172d2cca0592975" + integrity sha512-WKJob0P/Em2csiVthsI68p6aGKTIcsfjH9Gsx1f0A3Italz43e3ho0geSAVsmj09RWOELP1AZ/DXyJgOgDKxXQ== + dependencies: + "@jest/test-result" "^26.6.2" + "@jest/types" "^26.6.2" + "@types/node" "*" + ansi-escapes "^4.2.1" + chalk "^4.0.0" + jest-util "^26.6.2" + string-length "^4.0.1" + jest-worker@^26.6.1: version "26.6.1" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.1.tgz#c2ae8cde6802cc14056043f997469ec170d9c32a" @@ -7330,14 +7419,23 @@ jest-worker@^26.6.1: merge-stream "^2.0.0" supports-color "^7.0.0" +jest-worker@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" + integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== + dependencies: + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^7.0.0" + jest@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest/-/jest-26.6.1.tgz#821e8280d2bdeeed40ac7bc43941dceff0f1b650" - integrity sha512-f+ahfqw3Ffy+9vA7sWFGpTmhtKEMsNAZiWBVXDkrpIO73zIz22iimjirnV78kh/eWlylmvLh/0WxHN6fZraZdA== + version "26.6.3" + resolved "https://registry.yarnpkg.com/jest/-/jest-26.6.3.tgz#40e8fdbe48f00dfa1f0ce8121ca74b88ac9148ef" + integrity sha512-lGS5PXGAzR4RF7V5+XObhqz2KZIDUA1yD0DG6pBVmy10eh0ZIXQImRuzocsI/N2XZ1GrLFwTS27In2i2jlpq1Q== dependencies: - "@jest/core" "^26.6.1" + "@jest/core" "^26.6.3" import-local "^3.0.2" - jest-cli "^26.6.1" + jest-cli "^26.6.3" js-tokens@^4.0.0: version "4.0.0" @@ -9298,6 +9396,16 @@ pretty-format@^26.0.0, pretty-format@^26.6.1: ansi-styles "^4.0.0" react-is "^17.0.1" +pretty-format@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93" + integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg== + dependencies: + "@jest/types" "^26.6.2" + ansi-regex "^5.0.0" + ansi-styles "^4.0.0" + react-is "^17.0.1" + process-nextick-args@^2.0.0, process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" @@ -11412,10 +11520,10 @@ v8-compile-cache@^2.0.3, v8-compile-cache@^2.2.0: resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz#9471efa3ef9128d2f7c6a7ca39c4dd6b5055b132" integrity sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q== -v8-to-istanbul@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-6.0.1.tgz#7ef0e32faa10f841fe4c1b0f8de96ed067c0be1e" - integrity sha512-PzM1WlqquhBvsV+Gco6WSFeg1AGdD53ccMRkFeyHRE/KRZaVacPOmQYP3EeVgDBtKD2BJ8kgynBQ5OtKiHCH+w== +v8-to-istanbul@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-7.0.0.tgz#b4fe00e35649ef7785a9b7fcebcea05f37c332fc" + integrity sha512-fLL2rFuQpMtm9r8hrAV2apXX/WqHJ6+IC4/eQVdMDGBUgH/YMV4Gv3duk3kjmyg6uiQWBAA9nJwue4iJUOkHeA== dependencies: "@types/istanbul-lib-coverage" "^2.0.1" convert-source-map "^1.6.0" From ec6d8b361903d4c3d6b99640ca41d520b1059be6 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2020 17:02:15 +0300 Subject: [PATCH 030/581] chore(deps-dev): bump lint-staged from 10.5.0 to 10.5.1 (#2005) Bumps [lint-staged](https://github.com/okonet/lint-staged) from 10.5.0 to 10.5.1. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v10.5.0...v10.5.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2a7c6c97574..297c7d5dd41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3916,7 +3916,7 @@ commander@^2.18.0, commander@^2.20.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^6.0.0, commander@^6.2.0: +commander@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q== @@ -4322,7 +4322,7 @@ debug@^3.1.0, debug@^3.1.1, debug@^3.2.5: dependencies: ms "^2.1.1" -debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: +debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== @@ -5080,7 +5080,7 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execa@^4.0.0, execa@^4.0.3, execa@^4.1.0: +execa@^4.0.0, execa@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a" integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA== @@ -7704,19 +7704,19 @@ lines-and-columns@^1.1.6: integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= lint-staged@^10.5.0: - version "10.5.0" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.0.tgz#c923c2447a84c595874f3de696778736227e7a7a" - integrity sha512-gjC9+HGkBubOF+Yyoj9pd52Qfm/kYB+dRX1UOgWjHKvSDYl+VHkZXlBMlqSZa2cH3Kp5/uNL480sV6e2dTgXSg== + version "10.5.1" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.1.tgz#901e915c2360072dded0e7d752a0d9a49e079daa" + integrity sha512-fTkTGFtwFIJJzn/PbUO3RXyEBHIhbfYBE7+rJyLcOXabViaO/h6OslgeK6zpeUtzkDrzkgyAYDTLAwx6JzDTHw== dependencies: chalk "^4.1.0" cli-truncate "^2.1.0" - commander "^6.0.0" + commander "^6.2.0" cosmiconfig "^7.0.0" - debug "^4.1.1" + debug "^4.2.0" dedent "^0.7.0" enquirer "^2.3.6" - execa "^4.0.3" - listr2 "^2.6.0" + execa "^4.1.0" + listr2 "^3.2.2" log-symbols "^4.0.0" micromatch "^4.0.2" normalize-path "^3.0.0" @@ -7753,10 +7753,10 @@ listr-verbose-renderer@^0.5.0: date-fns "^1.27.2" figures "^2.0.0" -listr2@^2.6.0: - version "2.6.2" - resolved "https://registry.yarnpkg.com/listr2/-/listr2-2.6.2.tgz#4912eb01e1e2dd72ec37f3895a56bf2622d6f36a" - integrity sha512-6x6pKEMs8DSIpA/tixiYY2m/GcbgMplMVmhQAaLFxEtNSKLeWTGjtmU57xvv6QCm2XcqzyNXL/cTSVf4IChCRA== +listr2@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.2.2.tgz#d20feb75015e506992b55af40722ba1af168b8f1" + integrity sha512-AajqcZEUikF2ioph6PfH3dIuxJclhr3i3kHgTOP0xeXdWQohrvJAAmqVcV43/GI987HFY/vzT73jYXoa4esDHg== dependencies: chalk "^4.1.0" cli-truncate "^2.1.0" @@ -7764,7 +7764,7 @@ listr2@^2.6.0: indent-string "^4.0.0" log-update "^4.0.0" p-map "^4.0.0" - rxjs "^6.6.2" + rxjs "^6.6.3" through "^2.3.8" listr@^0.14.3: @@ -10099,7 +10099,7 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.6.0, rxjs@^6.6.2: +rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.6.0, rxjs@^6.6.3: version "6.6.3" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== From 172da462b9c09ea9c8f34de1a79dffbd34194684 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 4 Nov 2020 20:36:02 +0530 Subject: [PATCH 031/581] tests: add a case for invalid context value (#2030) --- test/core-flags/context-flag.test.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/core-flags/context-flag.test.js b/test/core-flags/context-flag.test.js index 98f13ea2c24..f725b129d00 100644 --- a/test/core-flags/context-flag.test.js +++ b/test/core-flags/context-flag.test.js @@ -1,12 +1,27 @@ 'use strict'; -const { run } = require('../utils/test-utils'); +const { resolve } = require('path'); +const { run, isWindows } = require('../utils/test-utils'); describe('--context flag', () => { it('should allow to set context', () => { - const { stderr, stdout } = run(__dirname, ['--context', '/test-context-path']); + const { stderr, stdout, exitCode } = run(__dirname, ['--context', './']); expect(stderr).toBeFalsy(); - expect(stdout).toContain('test-context-path'); + expect(exitCode).toBe(0); + if (isWindows) { + const windowsPath = resolve(__dirname, './').replace(/\\/g, '\\\\'); + expect(stdout).toContain(`context: '${windowsPath}'`); + } else { + expect(stdout).toContain(`context: '${resolve(__dirname, './')}'`); + } + }); + + it('should throw module not found error for invalid context', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--context', '/invalid-context-path']); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(1); + expect(stdout).toContain(`Module not found: Error: Can't resolve './src/main.js'`); }); }); From ba6f3046a6fb7c1936995d2277fbfe27eced02dc Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 4 Nov 2020 20:52:50 +0530 Subject: [PATCH 032/581] docs: update readme.md (#2037) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d54b11821c1..bd3214acdb5 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Get to know what are the available commands and arguments [here](./packages/webp ## Packages -We organize webpack CLI as a multi-package repository using [lerna](https://github.com/lerna/lerna). Every command has a dedicated subfolder in the `packages` Folder. Here's a summary of commands provided by the CLI. +We organize webpack CLI as a multi-package repository using [lerna](https://github.com/lerna/lerna). Every command has a dedicated subfolder in the `packages` folder. Here's a summary of commands provided by the CLI. ### Commands From 7c5a2bae49625ee4982d7478b7e741968731cea2 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Wed, 4 Nov 2020 21:10:40 +0530 Subject: [PATCH 033/581] fix: resolve dev server hot options correctly (#2022) --- packages/serve/__tests__/createConfig.test.ts | 5 +++-- packages/serve/src/createConfig.ts | 17 +++++++++++++++-- packages/serve/src/index.ts | 11 ++++++++++- packages/serve/src/parseArgs.ts | 5 +++-- packages/serve/src/startDevServer.ts | 1 - test/serve/basic/serve-basic.test.js | 9 ++++++++- test/utils/test-utils.js | 3 +++ 7 files changed, 42 insertions(+), 9 deletions(-) diff --git a/packages/serve/__tests__/createConfig.test.ts b/packages/serve/__tests__/createConfig.test.ts index 3f23534a8cd..96a08c483e0 100644 --- a/packages/serve/__tests__/createConfig.test.ts +++ b/packages/serve/__tests__/createConfig.test.ts @@ -27,7 +27,7 @@ describe('createConfig', () => { hotOnly: true, }; expect(createConfig(args)).toEqual({ - hot: 'only', + hotOnly: true, }); }); @@ -37,7 +37,8 @@ describe('createConfig', () => { hotOnly: true, }; expect(createConfig(args)).toEqual({ - hot: 'only', + hot: true, + hotOnly: true, }); }); }); diff --git a/packages/serve/src/createConfig.ts b/packages/serve/src/createConfig.ts index bf5d23d909e..94571608122 100644 --- a/packages/serve/src/createConfig.ts +++ b/packages/serve/src/createConfig.ts @@ -1,5 +1,9 @@ +import { utils } from 'webpack-cli'; + import { devServerOptionsType } from './types'; +const { logger } = utils; + /** * * Creates a devServer config from CLI args @@ -10,6 +14,16 @@ import { devServerOptionsType } from './types'; */ export default function createConfig(args): devServerOptionsType { const options = { ...args }; + let isDevServer4 = false, + devServerVersion; + try { + // eslint-disable-next-line node/no-extraneous-require + devServerVersion = require('webpack-dev-server/package.json').version; + } catch (err) { + logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); + process.exit(2); + } + isDevServer4 = devServerVersion.startsWith('4'); if (options.clientLogging) { options.client = { @@ -18,8 +32,7 @@ export default function createConfig(args): devServerOptionsType { // clientLogging is not a valid devServer option delete options.clientLogging; } - - if (options.hotOnly) { + if (isDevServer4 && options.hotOnly) { options.hot = 'only'; // hotOnly is not a valid devServer option delete options.hotOnly; diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 833bd6b868e..2fddad08321 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -1,7 +1,9 @@ -import WebpackCLI from 'webpack-cli'; +import WebpackCLI, { utils } from 'webpack-cli'; import startDevServer from './startDevServer'; import parseArgs from './parseArgs'; +const { logger } = utils; + /** * * Creates a webpack compiler and runs the devServer @@ -10,6 +12,13 @@ import parseArgs from './parseArgs'; * @returns {Function} invokes the devServer API */ export default function serve(...args: string[]): void { + try { + // eslint-disable-next-line node/no-extraneous-require + require('webpack-dev-server'); + } catch (err) { + logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); + process.exit(2); + } const cli = new WebpackCLI(); const { webpackArgs, devServerArgs } = parseArgs(cli, args); diff --git a/packages/serve/src/parseArgs.ts b/packages/serve/src/parseArgs.ts index b42f902f95e..4a6154698a8 100644 --- a/packages/serve/src/parseArgs.ts +++ b/packages/serve/src/parseArgs.ts @@ -23,12 +23,13 @@ type ArgsType = { * @returns {Object} parsed webpack args and dev server args objects */ export default function parseArgs(cli: WebpackCLIType, args: string[]): ArgsType { - let devServerFlags: object[]; + let devServerFlags; try { // eslint-disable-next-line node/no-extraneous-require devServerFlags = require('webpack-dev-server/bin/cli-flags').devServer; } catch (err) { - throw new Error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); + logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); + process.exit(2); } const core = cli.getCoreFlags(); diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index cb930d98aec..4388ae77d97 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -22,7 +22,6 @@ export default function startDevServer(compiler, devServerArgs): object[] { const usedPorts: number[] = []; devServerOptions.forEach((devServerOpts): void => { const options = mergeOptions(cliOptions, devServerOpts); - options.host = options.host || 'localhost'; options.port = options.port || 8080; diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index b7ff5d2c847..2ad37284524 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -3,7 +3,7 @@ const { yellow, options } = require('colorette'); const path = require('path'); const getPort = require('get-port'); -const { runServe } = require('../../utils/test-utils'); +const { runServe, isDevServer4 } = require('../../utils/test-utils'); const testPath = path.resolve(__dirname); @@ -56,6 +56,13 @@ describe('basic serve usage', () => { expect(stderr).toHaveLength(0); }); + it('uses hot-only flag to alter bundle', async () => { + const { stdout, stderr } = await runServe(['--port', port, isDevServer4 ? '--hot only' : '--hot-only'], testPath); + expect(stdout).toContain('main.js'); + expect(stdout).toContain('HotModuleReplacementPlugin'); + expect(stderr).toBeFalsy(); + }); + it('uses no-hot flag', async () => { const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); expect(stdout).toContain('main.js'); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 2968602be01..5f24458ad91 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -7,11 +7,13 @@ const { sync: spawnSync, node: execaNode } = execa; const { Writable } = require('readable-stream'); const concat = require('concat-stream'); const { version } = require('webpack'); +const { version: devServerVersion } = require('webpack-dev-server/package.json'); const { hyphenToUpperCase } = require('../../packages/webpack-cli/lib/utils/arg-utils'); const WEBPACK_PATH = path.resolve(__dirname, '../../packages/webpack-cli/bin/cli.js'); const ENABLE_LOG_COMPILATION = process.env.ENABLE_PIPE || false; const isWebpack5 = version.startsWith('5'); +const isDevServer4 = devServerVersion.startsWith('4'); const isWindows = process.platform === 'win32'; /** @@ -248,5 +250,6 @@ module.exports = { runInfo, hyphenToUpperCase, isWebpack5, + isDevServer4, isWindows, }; From ea369a98ea5ec366b688caebcb1276d9fbe0c651 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 4 Nov 2020 21:31:48 +0530 Subject: [PATCH 034/581] feat: add WEBPACK_SERVE environment variable (#2027) * tests: add test case for requirement * feat: add WEBPACK_SERVE variable * refactor: declare into variable * feat: enforce use of env variable * chore: update variable defination * chore: update snapshots --- .../__snapshots__/parseArgs.test.ts.snap | 6 ++++ packages/serve/src/parseArgs.ts | 7 ++++ test/serve/serve-variable/serve-basic.test.js | 33 +++++++++++++++++++ test/serve/serve-variable/src/index.js | 1 + test/serve/serve-variable/webpack.config.js | 24 ++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 test/serve/serve-variable/serve-basic.test.js create mode 100644 test/serve/serve-variable/src/index.js create mode 100644 test/serve/serve-variable/webpack.config.js diff --git a/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap b/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap index 16d37efbca2..ed8b7e3084c 100644 --- a/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap +++ b/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap @@ -11,6 +11,9 @@ Object { }, "webpackArgs": Object { "color": true, + "env": Object { + "WEBPACK_SERVE": true, + }, "hot": true, }, } @@ -39,6 +42,9 @@ Object { }, "webpackArgs": Object { "color": true, + "env": Object { + "WEBPACK_SERVE": true, + }, "mode": "development", }, } diff --git a/packages/serve/src/parseArgs.ts b/packages/serve/src/parseArgs.ts index 4a6154698a8..0b956f43932 100644 --- a/packages/serve/src/parseArgs.ts +++ b/packages/serve/src/parseArgs.ts @@ -39,6 +39,13 @@ export default function parseArgs(cli: WebpackCLIType, args: string[]): ArgsType const parsedWebpackArgs = cli.argParser(core, parsedDevServerArgs.unknownArgs, true, process.title); const webpackArgs = parsedWebpackArgs.opts; + // Add WEBPACK_SERVE environment variable + if (webpackArgs.env) { + webpackArgs.env.WEBPACK_SERVE = true; + } else { + webpackArgs.env = { WEBPACK_SERVE: true }; + } + // pass along the 'hot' argument to the dev server if it exists if (webpackArgs && webpackArgs.hot !== undefined) { devServerArgs['hot'] = webpackArgs.hot; diff --git a/test/serve/serve-variable/serve-basic.test.js b/test/serve/serve-variable/serve-basic.test.js new file mode 100644 index 00000000000..d8e6bc12c77 --- /dev/null +++ b/test/serve/serve-variable/serve-basic.test.js @@ -0,0 +1,33 @@ +'use strict'; + +const path = require('path'); +const getPort = require('get-port'); +const { runServe } = require('../../utils/test-utils'); + +const testPath = path.resolve(__dirname); + +describe('serve variable', () => { + let port; + + beforeEach(async () => { + port = await getPort(); + }); + + const isWindows = process.platform === 'win32'; + + // TODO fix me on windows + if (isWindows) { + it('TODO: Fix on windows', () => { + expect(true).toBe(true); + }); + return; + } + + it('compiles without flags and export variable', async () => { + const { stdout, stderr } = await runServe(['--port', port], testPath); + expect(stdout).toContain('main.js'); + expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stderr).toHaveLength(0); + expect(stdout).toContain('PASS'); + }); +}); diff --git a/test/serve/serve-variable/src/index.js b/test/serve/serve-variable/src/index.js new file mode 100644 index 00000000000..6be02374db1 --- /dev/null +++ b/test/serve/serve-variable/src/index.js @@ -0,0 +1 @@ +console.log('hello world'); diff --git a/test/serve/serve-variable/webpack.config.js b/test/serve/serve-variable/webpack.config.js new file mode 100644 index 00000000000..435b8b21190 --- /dev/null +++ b/test/serve/serve-variable/webpack.config.js @@ -0,0 +1,24 @@ +const isInProcess = process.env.WEBPACK_SERVE; + +class CustomTestPlugin { + constructor(isInEnvironment) { + this.isInEnvironment = isInEnvironment; + } + apply(compiler) { + compiler.hooks.done.tap('testPlugin', () => { + if (!isInProcess && this.isInEnvironment) { + console.log('PASS'); + } else { + console.log('FAIL'); + } + }); + } +} + +module.exports = (env) => { + return { + mode: 'development', + devtool: false, + plugins: [new CustomTestPlugin(env.WEBPACK_SERVE)], + }; +}; From 19fa6625e96b8cf550a19bbf915b63e18d8370d3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2020 20:49:37 +0300 Subject: [PATCH 035/581] chore(deps-dev): bump webpack from 5.3.2 to 5.4.0 (#2031) Bumps [webpack](https://github.com/webpack/webpack) from 5.3.2 to 5.4.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.3.2...v5.4.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 297c7d5dd41..5334012e590 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11732,9 +11732,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.3.0: - version "5.3.2" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.3.2.tgz#f88f6f2c54eaa1f68c8f37d8984657eaf68b00f0" - integrity sha512-DXsfHoI6lQAR3KnQh7+FsRfs9fs+TEvzXCA35UbKv4kVuzslg7QCMAcpFRZNDMjdtm9N/PoO54XEzGN9TeacQg== + version "5.4.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.4.0.tgz#4fdc6ec8a0ff9160701fb8f2eb8d06b33ecbae0f" + integrity sha512-udpYTyqz8toTTdaOsL2QKPLeZLt2IEm9qY7yTXuFEQhKu5bk0yQD9BtAdVQksmz4jFbbWOiWmm3NHarO0zr/ng== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From d2e3c74d32b0141c694259cf4f31e6c48b0f681d Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Thu, 5 Nov 2020 00:10:59 +0530 Subject: [PATCH 036/581] fix: assign cache value for default configs (#2013) --- packages/webpack-cli/lib/groups/resolveConfig.js | 10 +++++++--- packages/webpack-cli/lib/utils/flag-defaults.js | 14 ++++++++------ packages/webpack-cli/lib/webpack-cli.js | 2 +- test/core-flags/cache-flags.test.js | 11 +++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/packages/webpack-cli/lib/groups/resolveConfig.js b/packages/webpack-cli/lib/groups/resolveConfig.js index ed66ebcca1c..de33eba34e4 100644 --- a/packages/webpack-cli/lib/groups/resolveConfig.js +++ b/packages/webpack-cli/lib/groups/resolveConfig.js @@ -126,13 +126,13 @@ const resolveConfigFiles = async (args) => { const defaultConfig = configFiles.find((p) => p.path.includes(mode) || p.path.includes(modeAlias[mode])); if (defaultConfig) { - opts = await finalize(defaultConfig, args); + opts = await finalize(defaultConfig, args, true); return; } const foundConfig = configFiles.pop(); - opts = await finalize(foundConfig, args); + opts = await finalize(foundConfig, args, true); return; } @@ -140,7 +140,7 @@ const resolveConfigFiles = async (args) => { // Given config data, determines the type of config and // returns final config -const finalize = async (moduleObj, args) => { +const finalize = async (moduleObj, args, isDefaultConfig = false) => { const { env, configName } = args; const newOptionsObject = { outputOptions: {}, @@ -151,6 +151,10 @@ const finalize = async (moduleObj, args) => { return newOptionsObject; } + if (isDefaultConfig) { + newOptionsObject.outputOptions.defaultConfig = moduleObj.path; + } + const config = moduleObj.config; const isMultiCompilerMode = Array.isArray(config); diff --git a/packages/webpack-cli/lib/utils/flag-defaults.js b/packages/webpack-cli/lib/utils/flag-defaults.js index 10940d05d42..c2484fb53ea 100644 --- a/packages/webpack-cli/lib/utils/flag-defaults.js +++ b/packages/webpack-cli/lib/utils/flag-defaults.js @@ -1,23 +1,25 @@ -const cacheDefaults = (finalConfig, parsedArgs) => { +const cacheDefaults = (finalConfig, parsedArgs, outputOptions) => { // eslint-disable-next-line no-prototype-builtins const hasCache = finalConfig.hasOwnProperty('cache'); let cacheConfig = {}; - if (hasCache && parsedArgs.config) { + if (hasCache && (parsedArgs.config || (outputOptions && outputOptions.defaultConfig))) { if (finalConfig.cache && finalConfig.cache.type === 'filesystem') { cacheConfig.buildDependencies = { - config: parsedArgs.config, + config: parsedArgs.config || [outputOptions.defaultConfig], }; + } else { + cacheConfig = finalConfig.cache; } return { cache: cacheConfig }; } return cacheConfig; }; -const assignFlagDefaults = (compilerConfig, parsedArgs) => { +const assignFlagDefaults = (compilerConfig, parsedArgs, outputOptions) => { if (Array.isArray(compilerConfig)) { - return compilerConfig.map((config) => cacheDefaults(config, parsedArgs)); + return compilerConfig.map((config) => cacheDefaults(config, parsedArgs, outputOptions)); } - return cacheDefaults(compilerConfig, parsedArgs); + return cacheDefaults(compilerConfig, parsedArgs, outputOptions); }; module.exports = assignFlagDefaults; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 918af585ebf..9a2957003eb 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -45,7 +45,7 @@ class WebpackCLI { // Merge the core flag config with the compilerConfiguration coreCliHelper.processArguments(coreCliArgs, this.compilerConfiguration, coreConfig); // Assign some defaults to core flags - const configWithDefaults = assignFlagDefaults(this.compilerConfiguration, parsedArgs); + const configWithDefaults = assignFlagDefaults(this.compilerConfiguration, parsedArgs, this.outputConfiguration); this._mergeOptionsToConfiguration(configWithDefaults); } diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index f4164965e14..767c61d924e 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -136,6 +136,17 @@ describe('cache related flags from core', () => { expect(exitCode).toEqual(0); }); + it('should assign cache build dependencies with default config', () => { + // TODO: Fix on windows + if (isWindows) return; + const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem']); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('buildDependencies'); + expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); + expect(stdout).toContain("type: 'filesystem'"); + expect(exitCode).toEqual(0); + }); + it('should assign cache build dependencies with merged configs', () => { // TODO: Fix on windows if (isWindows) return; From 0caa9184e22ed857e175c8dc0dd1e0a26f216374 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 4 Nov 2020 21:42:32 +0300 Subject: [PATCH 037/581] chore(release): publish new version - @webpack-cli/generate-loader@1.1.0 - @webpack-cli/generate-plugin@1.1.0 - @webpack-cli/generators@1.1.0 - @webpack-cli/info@1.1.0 - @webpack-cli/init@1.0.3 - @webpack-cli/migrate@1.1.0 - @webpack-cli/serve@1.1.0 - @webpack-cli/utils@1.1.0 - webpack-cli@4.2.0 - @webpack-cli/webpack-scaffold@1.0.3 --- packages/generate-loader/CHANGELOG.md | 6 ++++++ packages/generate-loader/package.json | 4 ++-- packages/generate-plugin/CHANGELOG.md | 6 ++++++ packages/generate-plugin/package.json | 4 ++-- packages/generators/CHANGELOG.md | 10 ++++++++++ packages/generators/package.json | 6 +++--- packages/info/CHANGELOG.md | 10 ++++++++++ packages/info/package.json | 2 +- packages/init/CHANGELOG.md | 4 ++++ packages/init/package.json | 6 +++--- packages/migrate/CHANGELOG.md | 6 ++++++ packages/migrate/package.json | 4 ++-- packages/serve/CHANGELOG.md | 11 +++++++++++ packages/serve/package.json | 2 +- packages/utils/CHANGELOG.md | 6 ++++++ packages/utils/package.json | 2 +- packages/webpack-cli/CHANGELOG.md | 16 ++++++++++++++++ packages/webpack-cli/package.json | 6 +++--- packages/webpack-scaffold/CHANGELOG.md | 4 ++++ packages/webpack-scaffold/package.json | 2 +- 20 files changed, 98 insertions(+), 19 deletions(-) diff --git a/packages/generate-loader/CHANGELOG.md b/packages/generate-loader/CHANGELOG.md index f6f137046de..ee9faaeb027 100644 --- a/packages/generate-loader/CHANGELOG.md +++ b/packages/generate-loader/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.2...@webpack-cli/generate-loader@1.1.0) (2020-11-04) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1...@webpack-cli/generate-loader@1.0.2) (2020-10-19) **Note:** Version bump only for package @webpack-cli/generate-loader diff --git a/packages/generate-loader/package.json b/packages/generate-loader/package.json index 69b6e741566..fb8c6b72db1 100644 --- a/packages/generate-loader/package.json +++ b/packages/generate-loader/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generate-loader", - "version": "1.0.2", + "version": "1.1.0", "description": "A scaffold for generating a loader", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -18,7 +18,7 @@ "templates" ], "dependencies": { - "@webpack-cli/generators": "^1.0.2", + "@webpack-cli/generators": "^1.1.0", "yeoman-environment": "^2.10.3" }, "peerDependencies": { diff --git a/packages/generate-plugin/CHANGELOG.md b/packages/generate-plugin/CHANGELOG.md index 3021a3e02a7..c23551f2743 100644 --- a/packages/generate-plugin/CHANGELOG.md +++ b/packages/generate-plugin/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.2...@webpack-cli/generate-plugin@1.1.0) (2020-11-04) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1...@webpack-cli/generate-plugin@1.0.2) (2020-10-19) **Note:** Version bump only for package @webpack-cli/generate-plugin diff --git a/packages/generate-plugin/package.json b/packages/generate-plugin/package.json index 1dffd191dd5..9d49f9d1ab4 100644 --- a/packages/generate-plugin/package.json +++ b/packages/generate-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generate-plugin", - "version": "1.0.2", + "version": "1.1.0", "description": "A scaffold for generating a plugin", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -18,7 +18,7 @@ "templates" ], "dependencies": { - "@webpack-cli/generators": "^1.0.2", + "@webpack-cli/generators": "^1.1.0", "yeoman-environment": "^2.10.3" }, "peerDependencies": { diff --git a/packages/generators/CHANGELOG.md b/packages/generators/CHANGELOG.md index 609dd559028..4d555e018ea 100644 --- a/packages/generators/CHANGELOG.md +++ b/packages/generators/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.0.2...@webpack-cli/generators@1.1.0) (2020-11-04) + +### Bug Fixes + +- **generators:** correct optimization.splitChunks option in config ([#2008](https://github.com/webpack/webpack-cli/issues/2008)) ([f86ef2d](https://github.com/webpack/webpack-cli/commit/f86ef2d6c0a4cba3b2002baf32b78e06cbaafc4a)) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.0.1...@webpack-cli/generators@1.0.2) (2020-10-19) ### Bug Fixes diff --git a/packages/generators/package.json b/packages/generators/package.json index 347039741ed..571b8ff9f80 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generators", - "version": "1.0.2", + "version": "1.1.0", "description": "Webpack-CLI generators", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -14,8 +14,8 @@ "templates" ], "dependencies": { - "@webpack-cli/utils": "^1.0.2", - "@webpack-cli/webpack-scaffold": "^1.0.2", + "@webpack-cli/utils": "^1.1.0", + "@webpack-cli/webpack-scaffold": "^1.0.3", "colorette": "^1.2.1", "log-symbols": "^4.0.0", "yeoman-generator": "^4.12.0" diff --git a/packages/info/CHANGELOG.md b/packages/info/CHANGELOG.md index 17a07d5a558..10bea6d66c9 100644 --- a/packages/info/CHANGELOG.md +++ b/packages/info/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.2...@webpack-cli/info@1.1.0) (2020-11-04) + +### Bug Fixes + +- **info:** throw error and exit for invalid --output value ([#2020](https://github.com/webpack/webpack-cli/issues/2020)) ([a994d4b](https://github.com/webpack/webpack-cli/commit/a994d4b52a99b3b77d25aac88f741e036a1c44ec)) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.1...@webpack-cli/info@1.0.2) (2020-10-19) **Note:** Version bump only for package @webpack-cli/info diff --git a/packages/info/package.json b/packages/info/package.json index c58d97bdd4d..b046d31af49 100644 --- a/packages/info/package.json +++ b/packages/info/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/info", - "version": "1.0.2", + "version": "1.1.0", "description": "Outputs info about system and webpack config", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/init/CHANGELOG.md b/packages/init/CHANGELOG.md index 2876ca46540..862a63fe3ad 100644 --- a/packages/init/CHANGELOG.md +++ b/packages/init/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.2...@webpack-cli/init@1.0.3) (2020-11-04) + +**Note:** Version bump only for package @webpack-cli/init + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.1...@webpack-cli/init@1.0.2) (2020-10-19) **Note:** Version bump only for package @webpack-cli/init diff --git a/packages/init/package.json b/packages/init/package.json index 9d95ee69556..7a407d6f876 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/init", - "version": "1.0.2", + "version": "1.0.3", "description": "init command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,8 +12,8 @@ "lib" ], "dependencies": { - "@webpack-cli/generators": "^1.0.2", - "@webpack-cli/utils": "^1.0.2" + "@webpack-cli/generators": "^1.1.0", + "@webpack-cli/utils": "^1.1.0" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", diff --git a/packages/migrate/CHANGELOG.md b/packages/migrate/CHANGELOG.md index 1896dad1798..660698111cb 100644 --- a/packages/migrate/CHANGELOG.md +++ b/packages/migrate/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.2...@webpack-cli/migrate@1.1.0) (2020-11-04) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.1...@webpack-cli/migrate@1.0.2) (2020-10-19) **Note:** Version bump only for package @webpack-cli/migrate diff --git a/packages/migrate/package.json b/packages/migrate/package.json index c06ff92d938..3646191812b 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/migrate", - "version": "1.0.2", + "version": "1.1.0", "description": "Migrate command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,7 +12,7 @@ "lib" ], "dependencies": { - "@webpack-cli/utils": "^1.0.2", + "@webpack-cli/utils": "^1.1.0", "colorette": "^1.2.1", "diff": "^4.0.2", "inquirer": "^7.3.3", diff --git a/packages/serve/CHANGELOG.md b/packages/serve/CHANGELOG.md index 3d788f5f3da..6c0ba1a0279 100644 --- a/packages/serve/CHANGELOG.md +++ b/packages/serve/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1...@webpack-cli/serve@1.1.0) (2020-11-04) + +### Bug Fixes + +- resolve dev server hot options correctly ([#2022](https://github.com/webpack/webpack-cli/issues/2022)) ([7c5a2ba](https://github.com/webpack/webpack-cli/commit/7c5a2bae49625ee4982d7478b7e741968731cea2)) + +### Features + +- add WEBPACK_SERVE environment variable ([#2027](https://github.com/webpack/webpack-cli/issues/2027)) ([ea369a9](https://github.com/webpack/webpack-cli/commit/ea369a98ea5ec366b688caebcb1276d9fbe0c651)) +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) + ## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1-rc.1...@webpack-cli/serve@1.0.1) (2020-10-10) **Note:** Version bump only for package @webpack-cli/serve diff --git a/packages/serve/package.json b/packages/serve/package.json index d68d206f1a8..e752d1e7fd3 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/serve", - "version": "1.0.1", + "version": "1.1.0", "description": "", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 6d302c95d4d..7736c48bd47 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.2...@webpack-cli/utils@1.1.0) (2020-11-04) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.1...@webpack-cli/utils@1.0.2) (2020-10-19) **Note:** Version bump only for package @webpack-cli/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 87c1ef7fbc7..36bd4bbb257 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/utils", - "version": "1.0.2", + "version": "1.1.0", "description": "webpack-cli utility files", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/webpack-cli/CHANGELOG.md b/packages/webpack-cli/CHANGELOG.md index a1a2772cbee..26b8d4ee3a6 100644 --- a/packages/webpack-cli/CHANGELOG.md +++ b/packages/webpack-cli/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.2.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.1.0...webpack-cli@4.2.0) (2020-11-04) + +### Bug Fixes + +- --config-name behaviour for fuctional configs ([#2006](https://github.com/webpack/webpack-cli/issues/2006)) ([29ecf8d](https://github.com/webpack/webpack-cli/commit/29ecf8dbcd1c5c7d75fc7fb1634107697832d952)) +- assign cache value for default configs ([#2013](https://github.com/webpack/webpack-cli/issues/2013)) ([d2e3c74](https://github.com/webpack/webpack-cli/commit/d2e3c74d32b0141c694259cf4f31e6c48b0f681d)) +- callback deprecation ([#1977](https://github.com/webpack/webpack-cli/issues/1977)) ([2cb0c0e](https://github.com/webpack/webpack-cli/commit/2cb0c0e383670949ce31231edbfda514f47c3dfc)) +- handle core flags for webpack 4 ([#2023](https://github.com/webpack/webpack-cli/issues/2023)) ([ea66a7e](https://github.com/webpack/webpack-cli/commit/ea66a7e3ec6eabcc439b96acb21e2a25be2e35e5)) +- help and version functionality ([#1972](https://github.com/webpack/webpack-cli/issues/1972)) ([e8010b3](https://github.com/webpack/webpack-cli/commit/e8010b3aac695971e542ad4d3584ce534da39b8f)) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) +- progress supports string argument ([#2000](https://github.com/webpack/webpack-cli/issues/2000)) ([f13346e](https://github.com/webpack/webpack-cli/commit/f13346e6acb46e982a5d20fa1d2ae56fc52523dc)) +- suggest the closest match based on the Levenshtein distance algorithm ([#2010](https://github.com/webpack/webpack-cli/issues/2010)) ([491a582](https://github.com/webpack/webpack-cli/commit/491a582620b64ed4acbccd04f687adc28a5e4cff)) + # [4.1.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.0.0...webpack-cli@4.1.0) (2020-10-19) ### Bug Fixes diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 29a60d64c2b..a9e87239e16 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -1,6 +1,6 @@ { "name": "webpack-cli", - "version": "4.1.0", + "version": "4.2.0", "description": "CLI for webpack & friends", "license": "MIT", "repository": { @@ -27,8 +27,8 @@ "lib" ], "dependencies": { - "@webpack-cli/info": "^1.0.2", - "@webpack-cli/serve": "^1.0.1", + "@webpack-cli/info": "^1.1.0", + "@webpack-cli/serve": "^1.1.0", "colorette": "^1.2.1", "command-line-usage": "^6.1.0", "commander": "^6.2.0", diff --git a/packages/webpack-scaffold/CHANGELOG.md b/packages/webpack-scaffold/CHANGELOG.md index a2c8f691a00..251ff6529bf 100644 --- a/packages/webpack-scaffold/CHANGELOG.md +++ b/packages/webpack-scaffold/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.2...@webpack-cli/webpack-scaffold@1.0.3) (2020-11-04) + +**Note:** Version bump only for package @webpack-cli/webpack-scaffold + ## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1...@webpack-cli/webpack-scaffold@1.0.2) (2020-10-19) ### Bug Fixes diff --git a/packages/webpack-scaffold/package.json b/packages/webpack-scaffold/package.json index 41e238c8e1a..b5c914bb29d 100644 --- a/packages/webpack-scaffold/package.json +++ b/packages/webpack-scaffold/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/webpack-scaffold", - "version": "1.0.2", + "version": "1.0.3", "description": "Utility files for webpack-scaffold", "main": "lib/index.js", "types": "lib/index.d.ts", From a7863013ad8b6de5c5bee76816066424c730eda0 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Thu, 5 Nov 2020 06:23:48 +0530 Subject: [PATCH 038/581] docs: cleanup readme (#2035) --- packages/webpack-cli/README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 3b81dba641f..5a28b869fc4 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -1,4 +1,12 @@ -# `webpack-cli` + + +# webpack CLI + +The official CLI of webpack ## About @@ -647,7 +655,3 @@ yarn add webpack-cli --dev --no-stats-warnings Negates stats-warnings --no-watch-options-stdin Negates watch-options-stdin ``` - -## Defaults - -TODO: explain defaults From e5780a99e9a9a53464d72db6cff1feccc1a27a44 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 5 Nov 2020 17:17:38 +0530 Subject: [PATCH 039/581] docs: add configuration.externalsPrestes related flags (#2044) --- packages/webpack-cli/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 5a28b869fc4..c70419016e0 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -113,6 +113,23 @@ yarn add webpack-cli --dev --experiments-top-level-await Allow using top-level-await in EcmaScript Modules. --externals string[] Every matched dependency becomes external. An exact matched dependency becomes external. The same string is used as external dependency. + --externals-presets-electron Treat common electron built-in modules in main and preload context like 'electron', + 'ipc' or 'shell' as external and load them via require() when used. + --externals-presets-electron-main Treat electron built-in modules in the main context like 'app', 'ipc-main' or + 'shell' as external and load them via require() when used. + --externals-presets-electron-preload Treat electron built-in modules in the preload context like 'web-frame', + 'ipc-renderer' or 'shell' as external and load them via require() when used. + --externals-presets-electron-renderer Treat electron built-in modules in the renderer context like 'web-frame', + 'ipc-renderer' or 'shell' as external and load them via require() when used. + --externals-presets-node Treat node.js built-in modules like fs, path or vm as external and load them via + require() when used. + --externals-presets-nwjs Treat NW.js legacy nw.gui module as external and load it via require() when used. + --externals-presets-web Treat references to 'http(s)://...' and 'std:...' as external and load them via import + when used (Note that this changes execution order as externals are executed before + any other code in the chunk). + --externals-presets-web-async Treat references to 'http(s)://...' and 'std:...' as external and load them via async + import() when used (Note that this external type is an async module, which has various + effects on the execution). --externals-reset Clear all items provided in configuration. Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on @@ -557,6 +574,14 @@ yarn add webpack-cli --dev --no-experiments-output-module Negates experiments-output-module --no-experiments-sync-web-assembly Negates experiments-sync-web-assembly --no-experiments-top-level-await Negates experiments-top-level-await + --no-externals-presets-electron Negates externals-presets-electron + --no-externals-presets-electron-main Negates externals-presets-electron-main + --no-externals-presets-electron-preload Negates externals-presets-electron-preload + --no-externals-presets-electron-renderer Negates externals-presets-electron-renderer + --no-externals-presets-node Negates externals-presets-node + --no-externals-presets-nwjs Negates externals-presets-nwjs + --no-externals-presets-web Negates externals-presets-web + --no-externals-presets-web-async Negates externals-presets-web-async --no-module-expr-context-critical Negates module-expr-context-critical --no-module-expr-context-recursive Negates module-expr-context-recursive --no-module-rules-side-effects Negates module-rules-side-effects From efe67af098ebf964da2cd8c292417df1b661b55e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 5 Nov 2020 20:33:00 +0530 Subject: [PATCH 040/581] refactor: remove redundant merge-strategies util (#2043) --- packages/webpack-cli/lib/utils/merge-strategies.js | 8 -------- packages/webpack-cli/lib/webpack-cli.js | 3 +-- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 packages/webpack-cli/lib/utils/merge-strategies.js diff --git a/packages/webpack-cli/lib/utils/merge-strategies.js b/packages/webpack-cli/lib/utils/merge-strategies.js deleted file mode 100644 index a1f64247c44..00000000000 --- a/packages/webpack-cli/lib/utils/merge-strategies.js +++ /dev/null @@ -1,8 +0,0 @@ -const outputStrategy = { - 'output.filename': 'prepend', - 'output.path': 'prepend', -}; - -module.exports = { - outputStrategy, -}; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 9a2957003eb..d6e3c2b769b 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -4,7 +4,6 @@ const logger = require('./utils/logger'); const webpackMerge = require('webpack-merge'); const { core, coreFlagMap } = require('./utils/cli-flags'); const argParser = require('./utils/arg-parser'); -const { outputStrategy } = require('./utils/merge-strategies'); const assignFlagDefaults = require('./utils/flag-defaults'); const { writeFileSync } = require('fs'); const { options: coloretteOptions } = require('colorette'); @@ -148,7 +147,7 @@ class WebpackCLI { await Promise.resolve() .then(() => this._baseResolver(handleConfigResolution, parsedArgs)) .then(() => this._baseResolver(resolveMode, parsedArgs)) - .then(() => this._baseResolver(resolveOutput, parsedArgs, outputStrategy)) + .then(() => this._baseResolver(resolveOutput, parsedArgs)) .then(() => this._handleCoreFlags(parsedArgs)) .then(() => this._baseResolver(basicResolver, parsedArgs)) .then(() => this._baseResolver(resolveAdvanced, parsedArgs)) From 53bc4ee007b64227fc53746cb7f780909c789ed0 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Thu, 5 Nov 2020 22:36:45 +0530 Subject: [PATCH 041/581] refactor: utils (#2046) --- packages/webpack-cli/bin/cli.js | 4 +-- .../webpack-cli/lib/groups/resolveAdvanced.js | 4 +-- packages/webpack-cli/lib/groups/runVersion.js | 2 +- .../lib/plugins/WebpackCLIPlugin.js | 2 +- .../utils/__tests__/package-exists.test.js | 8 +++--- .../__tests__/prompt-installation.test.js | 14 ++++------- packages/webpack-cli/lib/utils/arg-parser.js | 2 +- packages/webpack-cli/lib/utils/cli-flags.js | 12 ++++++++- packages/webpack-cli/lib/utils/commands.js | 25 ------------------- packages/webpack-cli/lib/utils/core-flags.js | 14 ----------- .../webpack-cli/lib/utils/package-exists.js | 4 +-- .../lib/utils/prompt-installation.js | 8 +++--- .../webpack-cli/lib/utils/resolve-command.js | 4 +-- packages/webpack-cli/lib/utils/run-command.js | 4 +-- .../utils/{helpers.js => to-kebab-case.js} | 2 +- .../webpack-cli/lib/utils/unknown-args.js | 24 ++++++++++++++++-- packages/webpack-cli/lib/webpack-cli.js | 4 +-- 17 files changed, 58 insertions(+), 79 deletions(-) delete mode 100644 packages/webpack-cli/lib/utils/commands.js delete mode 100644 packages/webpack-cli/lib/utils/core-flags.js rename packages/webpack-cli/lib/utils/{helpers.js => to-kebab-case.js} (87%) diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index 9b7bb3392cd..cef11ded399 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -8,8 +8,8 @@ const importLocal = require('import-local'); const runCLI = require('../lib/bootstrap'); const { yellow } = require('colorette'); const { error, success } = require('../lib/utils/logger'); -const { packageExists } = require('../lib/utils/package-exists'); -const { promptInstallation } = require('../lib/utils/prompt-installation'); +const packageExists = require('../lib/utils/package-exists'); +const promptInstallation = require('../lib/utils/prompt-installation'); // Prefer the local installation of `webpack-cli` if (importLocal(__filename)) { diff --git a/packages/webpack-cli/lib/groups/resolveAdvanced.js b/packages/webpack-cli/lib/groups/resolveAdvanced.js index dc7fd01186b..7f24b8b205a 100644 --- a/packages/webpack-cli/lib/groups/resolveAdvanced.js +++ b/packages/webpack-cli/lib/groups/resolveAdvanced.js @@ -1,5 +1,5 @@ -const { packageExists } = require('../utils/package-exists'); -const { promptInstallation } = require('../utils/prompt-installation'); +const packageExists = require('../utils/package-exists'); +const promptInstallation = require('../utils/prompt-installation'); const { yellow } = require('colorette'); const { error, success } = require('../utils/logger'); diff --git a/packages/webpack-cli/lib/groups/runVersion.js b/packages/webpack-cli/lib/groups/runVersion.js index 94212d5b172..9db978bb3dd 100644 --- a/packages/webpack-cli/lib/groups/runVersion.js +++ b/packages/webpack-cli/lib/groups/runVersion.js @@ -1,5 +1,5 @@ const logger = require('../utils/logger'); -const { defaultCommands } = require('../utils/commands'); +const { defaultCommands } = require('../utils/cli-flags'); const { isCommandUsed } = require('../utils/arg-utils'); const { commands, allNames, hasUnknownArgs } = require('../utils/unknown-args'); diff --git a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js index df1d2736ed9..764c8e2b070 100644 --- a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js @@ -1,4 +1,4 @@ -const { packageExists } = require('../utils/package-exists'); +const packageExists = require('../utils/package-exists'); const webpack = packageExists('webpack') ? require('webpack') : undefined; const logger = require('../utils/logger'); diff --git a/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js b/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js index f16b263f695..cc8979088ab 100644 --- a/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js @@ -1,10 +1,8 @@ -jest.setMock('../prompt-installation', { - promptInstallation: jest.fn(), -}); +jest.setMock('../prompt-installation', jest.fn()); const ExternalCommand = require('../resolve-command'); -const { packageExists } = require('../package-exists'); -const { promptInstallation } = require('../prompt-installation'); +const packageExists = require('../package-exists'); +const promptInstallation = require('../prompt-installation'); describe('@webpack-cli/utils', () => { it('should check existence of package', () => { diff --git a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js index 6a0b54e3f25..e8b4e83b2bf 100644 --- a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js @@ -8,20 +8,16 @@ jest.setMock('enquirer', { prompt: jest.fn(), }); -jest.setMock('../run-command', { - runCommand: jest.fn(), -}); +jest.setMock('../run-command', jest.fn()); -jest.setMock('../package-exists', { - packageExists: jest.fn(), -}); +jest.setMock('../package-exists', jest.fn()); jest.setMock('../get-package-manager', jest.fn()); const getPackageManager = require('../get-package-manager'); -const { packageExists } = require('../package-exists'); -const { promptInstallation } = require('../prompt-installation'); -const { runCommand } = require('../run-command'); +const packageExists = require('../package-exists'); +const promptInstallation = require('../prompt-installation'); +const runCommand = require('../run-command'); const { prompt } = require('enquirer'); describe('promptInstallation', () => { diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index 896362c2503..dd239e6e2b2 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -3,7 +3,7 @@ const logger = require('./logger'); const { commands } = require('./cli-flags'); const runHelp = require('../groups/runHelp'); const runVersion = require('../groups/runVersion'); -const { defaultCommands } = require('./commands'); +const { defaultCommands } = require('./cli-flags'); /** * Creates Argument parser corresponding to the supplied options diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index f10f6d42073..7d44343c5d5 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -1,4 +1,4 @@ -const { packageExists } = require('./package-exists'); +const packageExists = require('./package-exists'); const cli = packageExists('webpack') ? require('webpack').cli : undefined; const HELP_GROUP = 'help'; @@ -273,10 +273,20 @@ const coreFlagMap = flagsFromCore.reduce((acc, cur) => { return acc; }, new Map()); +const defaultCommands = { + init: 'init', + loader: 'generate-loader', + plugin: 'generate-plugin', + info: 'info', + migrate: 'migrate', + serve: 'serve', +}; + module.exports = { groups, commands, core: [...core, ...flagsFromCore], flagsFromCore, coreFlagMap, + defaultCommands, }; diff --git a/packages/webpack-cli/lib/utils/commands.js b/packages/webpack-cli/lib/utils/commands.js deleted file mode 100644 index 17c51d85f52..00000000000 --- a/packages/webpack-cli/lib/utils/commands.js +++ /dev/null @@ -1,25 +0,0 @@ -const { commands } = require('./cli-flags'); - -const defaultCommands = { - init: 'init', - loader: 'generate-loader', - plugin: 'generate-plugin', - info: 'info', - migrate: 'migrate', - serve: 'serve', -}; - -// Contains an array of strings with commands and their aliases that the cli supports -const names = commands - .map(({ alias, name }) => { - if (alias) { - return [name, alias]; - } - return [name]; - }) - .reduce((arr, val) => arr.concat(val), []); - -module.exports = { - defaultCommands, - names, -}; diff --git a/packages/webpack-cli/lib/utils/core-flags.js b/packages/webpack-cli/lib/utils/core-flags.js deleted file mode 100644 index 52a3be4cccb..00000000000 --- a/packages/webpack-cli/lib/utils/core-flags.js +++ /dev/null @@ -1,14 +0,0 @@ -const { core } = require('./cli-flags'); - -// Contains an array of strings with core cli flags and their aliases -const names = core - .map(({ alias, name }) => { - if (name === 'help') return []; - if (alias) { - return [`--${name}`, `-${alias}`]; - } - return [`--${name}`]; - }) - .reduce((arr, val) => arr.concat(val), []); - -module.exports = { names }; diff --git a/packages/webpack-cli/lib/utils/package-exists.js b/packages/webpack-cli/lib/utils/package-exists.js index ebb8c3d9321..44d7f521980 100644 --- a/packages/webpack-cli/lib/utils/package-exists.js +++ b/packages/webpack-cli/lib/utils/package-exists.js @@ -7,6 +7,4 @@ function packageExists(packageName) { } } -module.exports = { - packageExists, -}; +module.exports = packageExists; diff --git a/packages/webpack-cli/lib/utils/prompt-installation.js b/packages/webpack-cli/lib/utils/prompt-installation.js index 377e58e7d3b..1acb49669cd 100644 --- a/packages/webpack-cli/lib/utils/prompt-installation.js +++ b/packages/webpack-cli/lib/utils/prompt-installation.js @@ -1,8 +1,8 @@ const { prompt } = require('enquirer'); const { green } = require('colorette'); -const { runCommand } = require('./run-command'); +const runCommand = require('./run-command'); const getPackageManager = require('./get-package-manager'); -const { packageExists } = require('./package-exists'); +const packageExists = require('./package-exists'); /** * @@ -34,6 +34,4 @@ async function promptInstallation(packageName, preMessage) { process.exitCode = 2; } -module.exports = { - promptInstallation, -}; +module.exports = promptInstallation; diff --git a/packages/webpack-cli/lib/utils/resolve-command.js b/packages/webpack-cli/lib/utils/resolve-command.js index 0d115cd3a91..7c39f7067a0 100644 --- a/packages/webpack-cli/lib/utils/resolve-command.js +++ b/packages/webpack-cli/lib/utils/resolve-command.js @@ -1,7 +1,7 @@ const { yellow, cyan } = require('colorette'); const logger = require('./logger'); -const { packageExists } = require('./package-exists'); -const { promptInstallation } = require('./prompt-installation'); +const packageExists = require('./package-exists'); +const promptInstallation = require('./prompt-installation'); const packagePrefix = '@webpack-cli'; diff --git a/packages/webpack-cli/lib/utils/run-command.js b/packages/webpack-cli/lib/utils/run-command.js index 47c13d7b791..12e1bd1a4f5 100644 --- a/packages/webpack-cli/lib/utils/run-command.js +++ b/packages/webpack-cli/lib/utils/run-command.js @@ -11,6 +11,4 @@ async function runCommand(command, args = []) { } } -module.exports = { - runCommand, -}; +module.exports = runCommand; diff --git a/packages/webpack-cli/lib/utils/helpers.js b/packages/webpack-cli/lib/utils/to-kebab-case.js similarity index 87% rename from packages/webpack-cli/lib/utils/helpers.js rename to packages/webpack-cli/lib/utils/to-kebab-case.js index 4a3fd9f3382..d21b80d8c98 100644 --- a/packages/webpack-cli/lib/utils/helpers.js +++ b/packages/webpack-cli/lib/utils/to-kebab-case.js @@ -7,4 +7,4 @@ function toKebabCase(str) { return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); } -module.exports = { toKebabCase }; +module.exports = toKebabCase; diff --git a/packages/webpack-cli/lib/utils/unknown-args.js b/packages/webpack-cli/lib/utils/unknown-args.js index 9ceee537f49..675b1b7539d 100644 --- a/packages/webpack-cli/lib/utils/unknown-args.js +++ b/packages/webpack-cli/lib/utils/unknown-args.js @@ -1,5 +1,25 @@ -const commandNames = require('./commands').names; -const flagNames = require('./core-flags').names; +const { commands, core } = require('./cli-flags'); + +// Contains an array of strings with commands and their aliases that the cli supports +const commandNames = commands + .map(({ alias, name }) => { + if (alias) { + return [name, alias]; + } + return [name]; + }) + .reduce((arr, val) => arr.concat(val), []); + +// Contains an array of strings with core cli flags and their aliases +const flagNames = core + .map(({ alias, name }) => { + if (name === 'help') return []; + if (alias) { + return [`--${name}`, `-${alias}`]; + } + return [`--${name}`]; + }) + .reduce((arr, val) => arr.concat(val), []); module.exports = { commands: [...commandNames], diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index d6e3c2b769b..cb6f15999ae 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1,4 +1,4 @@ -const { packageExists } = require('./utils/package-exists'); +const packageExists = require('./utils/package-exists'); const webpack = packageExists('webpack') ? require('webpack') : undefined; const logger = require('./utils/logger'); const webpackMerge = require('webpack-merge'); @@ -16,7 +16,7 @@ const resolveStats = require('./groups/resolveStats'); const resolveOutput = require('./groups/resolveOutput'); const basicResolver = require('./groups/basicResolver'); const resolveAdvanced = require('./groups/resolveAdvanced'); -const { toKebabCase } = require('./utils/helpers'); +const toKebabCase = require('./utils/to-kebab-case'); class WebpackCLI { constructor() { From 69a467acbdffadf3b651b72fabb87a0d072d1476 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Fri, 6 Nov 2020 10:29:51 +0530 Subject: [PATCH 042/581] chore: remove help group properties (#2047) --- packages/webpack-cli/lib/utils/cli-flags.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 7d44343c5d5..4bffe1a905a 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -1,11 +1,9 @@ const packageExists = require('./package-exists'); const cli = packageExists('webpack') ? require('webpack').cli : undefined; -const HELP_GROUP = 'help'; const BASIC_GROUP = 'basic'; const groups = { - HELP_GROUP, BASIC_GROUP, }; @@ -116,7 +114,6 @@ const core = [ name: 'help', usage: '--help', type: Boolean, - group: HELP_GROUP, description: 'Outputs list of supported flags', }, { @@ -190,7 +187,6 @@ const core = [ usage: '--version | --version ', alias: 'v', type: Boolean, - group: HELP_GROUP, description: 'Get current version', }, { From 46cba367f06a6354fe98fcb15e7771e819feeac0 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 6 Nov 2020 18:08:44 +0530 Subject: [PATCH 043/581] feat: add pnpm support for package installation (#2040) --- .../__tests__/get-package-manager.test.js | 21 ++++++++++++++++--- .../__tests__/prompt-installation.test.js | 16 ++++++++++++++ .../package-lock.json | 0 .../pnpm-lock.yaml} | 0 .../utils/__tests__/test-all-lock/yarn.lock | 0 .../test-npm-and-pnpm/package-lock.json | 0 .../test-npm-and-pnpm/pnpm-lock.yaml | 0 .../__tests__/test-pnpm-lock/pnpm-lock.yaml | 0 .../lib/utils/get-package-manager.js | 5 +++++ .../lib/utils/prompt-installation.js | 1 + 10 files changed, 40 insertions(+), 3 deletions(-) rename packages/webpack-cli/lib/utils/__tests__/{test-both => test-all-lock}/package-lock.json (100%) rename packages/webpack-cli/lib/utils/__tests__/{test-both/yarn.lock => test-all-lock/pnpm-lock.yaml} (100%) create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-all-lock/yarn.lock create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/package-lock.json create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/pnpm-lock.yaml create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-pnpm-lock/pnpm-lock.yaml diff --git a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js index 61350f3e520..3abe09e9c46 100644 --- a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js @@ -22,7 +22,9 @@ describe('packageUtils', () => { describe('getPackageManager', () => { const testYarnLockPath = path.resolve(__dirname, 'test-yarn-lock'); const testNpmLockPath = path.resolve(__dirname, 'test-npm-lock'); - const testBothPath = path.resolve(__dirname, 'test-both'); + const testPnpmLockPath = path.resolve(__dirname, 'test-pnpm-lock'); + const testNpmAndPnpmPath = path.resolve(__dirname, 'test-npm-and-pnpm'); + const testAllPath = path.resolve(__dirname, 'test-all-lock'); const cwdSpy = jest.spyOn(process, 'cwd'); @@ -33,7 +35,8 @@ describe('packageUtils', () => { fs.mkdirSync(testNpmLockPath); } fs.writeFileSync(path.resolve(testNpmLockPath, 'package-lock.json'), ''); - fs.writeFileSync(path.resolve(testBothPath, 'package-lock.json'), ''); + fs.writeFileSync(path.resolve(testNpmAndPnpmPath, 'package-lock.json'), ''); + fs.writeFileSync(path.resolve(testAllPath, 'package-lock.json'), ''); }); beforeEach(() => { @@ -52,8 +55,20 @@ describe('packageUtils', () => { expect(syncMock.mock.calls.length).toEqual(0); }); + it('should find pnpm-lock.yaml', () => { + cwdSpy.mockReturnValue(testPnpmLockPath); + expect(getPackageManager()).toEqual('pnpm'); + expect(syncMock.mock.calls.length).toEqual(0); + }); + + it('should prioritize npm over pnpm', () => { + cwdSpy.mockReturnValue(testNpmAndPnpmPath); + expect(getPackageManager()).toEqual('npm'); + expect(syncMock.mock.calls.length).toEqual(0); + }); + it('should prioritize yarn with many lock files', () => { - cwdSpy.mockReturnValue(testBothPath); + cwdSpy.mockReturnValue(testAllPath); expect(getPackageManager()).toEqual('yarn'); expect(syncMock.mock.calls.length).toEqual(0); }); diff --git a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js index e8b4e83b2bf..b31ce6c6746 100644 --- a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js @@ -60,6 +60,22 @@ describe('promptInstallation', () => { expect(runCommand.mock.calls[0][0]).toEqual('yarn add -D test-package'); }); + it('should prompt to install using pnpm if pnpm is package manager', async () => { + prompt.mockReturnValue({ + installConfirm: true, + }); + getPackageManager.mockReturnValue('pnpm'); + const preMessage = jest.fn(); + const promptResult = await promptInstallation('test-package', preMessage); + expect(promptResult).toBeTruthy(); + expect(preMessage.mock.calls.length).toEqual(1); + expect(prompt.mock.calls.length).toEqual(1); + expect(runCommand.mock.calls.length).toEqual(1); + expect(prompt.mock.calls[0][0][0].message).toMatch(/Would you like to install test-package\?/); + // install the package using npm + expect(runCommand.mock.calls[0][0]).toEqual('pnpm install -D test-package'); + }); + it('should not install if install is not confirmed', async () => { prompt.mockReturnValue({ installConfirm: false, diff --git a/packages/webpack-cli/lib/utils/__tests__/test-both/package-lock.json b/packages/webpack-cli/lib/utils/__tests__/test-all-lock/package-lock.json similarity index 100% rename from packages/webpack-cli/lib/utils/__tests__/test-both/package-lock.json rename to packages/webpack-cli/lib/utils/__tests__/test-all-lock/package-lock.json diff --git a/packages/webpack-cli/lib/utils/__tests__/test-both/yarn.lock b/packages/webpack-cli/lib/utils/__tests__/test-all-lock/pnpm-lock.yaml similarity index 100% rename from packages/webpack-cli/lib/utils/__tests__/test-both/yarn.lock rename to packages/webpack-cli/lib/utils/__tests__/test-all-lock/pnpm-lock.yaml diff --git a/packages/webpack-cli/lib/utils/__tests__/test-all-lock/yarn.lock b/packages/webpack-cli/lib/utils/__tests__/test-all-lock/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/package-lock.json b/packages/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/package-lock.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/pnpm-lock.yaml b/packages/webpack-cli/lib/utils/__tests__/test-npm-and-pnpm/pnpm-lock.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/__tests__/test-pnpm-lock/pnpm-lock.yaml b/packages/webpack-cli/lib/utils/__tests__/test-pnpm-lock/pnpm-lock.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/get-package-manager.js b/packages/webpack-cli/lib/utils/get-package-manager.js index 9d6b4125604..4c165664f4b 100644 --- a/packages/webpack-cli/lib/utils/get-package-manager.js +++ b/packages/webpack-cli/lib/utils/get-package-manager.js @@ -12,11 +12,16 @@ const { sync } = require('execa'); function getPackageManager() { const hasLocalYarn = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock')); const hasLocalNpm = fs.existsSync(path.resolve(process.cwd(), 'package-lock.json')); + const hasLocalPnpm = fs.existsSync(path.resolve(process.cwd(), 'pnpm-lock.yaml')); + if (hasLocalYarn) { return 'yarn'; } else if (hasLocalNpm) { return 'npm'; + } else if (hasLocalPnpm) { + return 'pnpm'; } + try { // if the sync function below fails because yarn is not installed, // an error will be thrown diff --git a/packages/webpack-cli/lib/utils/prompt-installation.js b/packages/webpack-cli/lib/utils/prompt-installation.js index 1acb49669cd..e9988943af5 100644 --- a/packages/webpack-cli/lib/utils/prompt-installation.js +++ b/packages/webpack-cli/lib/utils/prompt-installation.js @@ -11,6 +11,7 @@ const packageExists = require('./package-exists'); */ async function promptInstallation(packageName, preMessage) { const packageManager = getPackageManager(); + // yarn uses 'add' command, rest npm and pnpm both use 'install' const options = [packageManager === 'yarn' ? 'add' : 'install', '-D', packageName]; const commandToBeRun = `${packageManager} ${options.join(' ')}`; From 1e0b0b4c83afc4c73cf35d4d9064b4c2eb193efc Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 6 Nov 2020 18:30:41 +0530 Subject: [PATCH 044/581] chore: add links to cli-flags for help output (#2039) --- packages/webpack-cli/lib/utils/cli-flags.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 4bffe1a905a..195330f92e3 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -203,6 +203,7 @@ const core = [ type: String, multipleType: true, description: 'Environment passed to the configuration when it is a function', + link: 'https://webpack.js.org/api/cli/#environment-options', }, { name: 'name', @@ -210,6 +211,7 @@ const core = [ type: String, group: BASIC_GROUP, description: 'Name of the configuration. Used when loading multiple configurations.', + link: 'https://webpack.js.org/configuration/other-options/#name', }, { name: 'config-name', @@ -224,6 +226,7 @@ const core = [ type: Boolean, multiple: false, description: 'It invokes webpack-bundle-analyzer plugin to get bundle information', + link: 'https://github.com/webpack-contrib/webpack-bundle-analyzer', }, /* { name: "interactive", From 3feaae6189f2e83739154e4b71348b598a20a05f Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Sat, 7 Nov 2020 08:04:47 +0530 Subject: [PATCH 045/581] refactor: merge resolvers (#2049) --- .../__tests__/resolveAdvanced.test.js | 37 ---- .../webpack-cli/__tests__/resolveArgs.test.js | 142 +++++++++++++++ .../webpack-cli/__tests__/resolveMode.test.js | 82 --------- .../__tests__/resolveOutput.test.js | 11 -- .../webpack-cli/__tests__/resolveStats.js | 19 --- .../webpack-cli/lib/groups/basicResolver.js | 40 ----- .../webpack-cli/lib/groups/resolveMode.js | 49 ------ .../webpack-cli/lib/groups/resolveOutput.js | 19 --- .../webpack-cli/lib/groups/resolveStats.js | 22 --- packages/webpack-cli/lib/utils/arg-parser.js | 1 - packages/webpack-cli/lib/webpack-cli.js | 161 ++++++++++++++++-- .../mode-single-arg/mode-single-arg.test.js | 1 - 12 files changed, 289 insertions(+), 295 deletions(-) delete mode 100644 packages/webpack-cli/__tests__/resolveAdvanced.test.js create mode 100644 packages/webpack-cli/__tests__/resolveArgs.test.js delete mode 100644 packages/webpack-cli/__tests__/resolveMode.test.js delete mode 100644 packages/webpack-cli/__tests__/resolveOutput.test.js delete mode 100644 packages/webpack-cli/__tests__/resolveStats.js delete mode 100644 packages/webpack-cli/lib/groups/basicResolver.js delete mode 100644 packages/webpack-cli/lib/groups/resolveMode.js delete mode 100644 packages/webpack-cli/lib/groups/resolveOutput.js delete mode 100644 packages/webpack-cli/lib/groups/resolveStats.js diff --git a/packages/webpack-cli/__tests__/resolveAdvanced.test.js b/packages/webpack-cli/__tests__/resolveAdvanced.test.js deleted file mode 100644 index 390f22bc995..00000000000 --- a/packages/webpack-cli/__tests__/resolveAdvanced.test.js +++ /dev/null @@ -1,37 +0,0 @@ -const resolveAdvanced = require('../lib/groups/resolveAdvanced'); - -const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; - -describe('advanced options', function () { - it('should load the HMR plugin', async () => { - const result = await resolveAdvanced({ - hot: true, - }); - expect(result.options.plugins[0].constructor.name).toEqual('HotModuleReplacementPlugin'); - }); - - it('should load the prefetch plugin', async () => { - const result = await resolveAdvanced({ - prefetch: 'url', - }); - expect(result.options.plugins[0].constructor.name).toEqual('PrefetchPlugin'); - }); - - it('should load the webpack-bundle-analyzer plugin', async () => { - const result = await resolveAdvanced({ - analyze: true, - }); - expect(result.options.plugins[0].constructor.name).toEqual('BundleAnalyzerPlugin'); - }); - - { - targetValues.map((option) => { - it(`should handle ${option} option`, async () => { - const result = await resolveAdvanced({ - target: option, - }); - expect(result.options.target).toEqual(option); - }); - }); - } -}); diff --git a/packages/webpack-cli/__tests__/resolveArgs.test.js b/packages/webpack-cli/__tests__/resolveArgs.test.js new file mode 100644 index 00000000000..d5347ba23fd --- /dev/null +++ b/packages/webpack-cli/__tests__/resolveArgs.test.js @@ -0,0 +1,142 @@ +const { resolve } = require('path'); +const webpackCLI = require('../lib/webpack-cli'); + +const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; + +const basicResolver = new webpackCLI().resolveArgs; + +describe('BasicResolver', () => { + it('should handle the output option', async () => { + const result = await basicResolver({ + outputPath: './bundle', + }); + expect(result.options.output.path).toEqual(resolve('bundle')); + }); + + it('should handle the mode option [production]', async () => { + const result = await basicResolver( + { + mode: 'production', + }, + {}, + ); + // ensure no other properties are added + expect(result.options).toMatchObject({ mode: 'production' }); + expect(result.options.mode).toEqual('production'); + }); + + it('should handle the mode option [development]', async () => { + const result = await basicResolver( + { + mode: 'development', + }, + {}, + ); + + // ensure no other properties are added + expect(result.options).toMatchObject({ mode: 'development' }); + expect(result.options.mode).toEqual('development'); + }); + + it('should handle the mode option [none]', async () => { + const result = await basicResolver( + { + mode: 'none', + }, + {}, + ); + + // ensure no other properties are added + expect(result.options).toMatchObject({ mode: 'none' }); + expect(result.options.mode).toEqual('none'); + }); + + it('should prefer supplied move flag over NODE_ENV', async () => { + process.env.NODE_ENV = 'production'; + const result = await basicResolver( + { + mode: 'development', + }, + {}, + ); + + // ensure no other properties are added + expect(result.options).toMatchObject({ mode: 'development' }); + }); + + it('should prefer supplied move flag over mode from config', async () => { + const result = await basicResolver( + { + mode: 'development', + }, + { mode: 'production' }, + ); + + // ensure no other properties are added + expect(result.options).toMatchObject({ mode: 'development' }); + }); + + it('should prefer mode form config over NODE_ENV', async () => { + process.env.NODE_ENV = 'development'; + const result = await basicResolver({}, { mode: 'production' }); + + // ensure no other properties are added + expect(result.options).toMatchObject({ mode: 'production' }); + }); + + it('should prefer mode form flag over NODE_ENV and config', async () => { + process.env.NODE_ENV = 'development'; + const result = await basicResolver({ mode: 'none' }, { mode: 'production' }); + + // ensure no other properties are added + expect(result.options).toMatchObject({ mode: 'none' }); + }); + + it('should assign json correctly', async () => { + const result = await basicResolver({ + json: true, + }); + expect(result.options.stats).toBeFalsy(); + expect(result.outputOptions.json).toBeTruthy(); + }); + + it('should assign stats correctly', async () => { + const result = await basicResolver({ + stats: 'warning', + }); + expect(result.options.stats).toEqual('warning'); + expect(result.outputOptions.json).toBeFalsy(); + }); + + it('should load the HMR plugin', async () => { + const result = await basicResolver({ + hot: true, + }); + expect(result.options.plugins[0].constructor.name).toEqual('HotModuleReplacementPlugin'); + }); + + it('should load the prefetch plugin', async () => { + const result = await basicResolver({ + prefetch: 'url', + }); + expect(result.options.plugins[0].constructor.name).toEqual('PrefetchPlugin'); + }); + + it('should load the webpack-bundle-analyzer plugin', async () => { + const result = await basicResolver({ + analyze: true, + }); + expect(result.options.plugins[0].constructor.name).toEqual('BundleAnalyzerPlugin'); + }); + + { + targetValues.map((option) => { + it(`should handle ${option} option`, async () => { + const result = await basicResolver({ + target: option, + }); + expect(result.options.target).toEqual(option); + }); + }); + } +}); diff --git a/packages/webpack-cli/__tests__/resolveMode.test.js b/packages/webpack-cli/__tests__/resolveMode.test.js deleted file mode 100644 index 3db6f889273..00000000000 --- a/packages/webpack-cli/__tests__/resolveMode.test.js +++ /dev/null @@ -1,82 +0,0 @@ -const resolveMode = require('../lib/groups/resolveMode'); - -describe('resolveMode', function () { - it('should handle the mode option [production]', () => { - const result = resolveMode( - { - mode: 'production', - }, - {}, - ); - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'production' }); - expect(result.options.mode).toEqual('production'); - }); - - it('should handle the mode option [development]', () => { - const result = resolveMode( - { - mode: 'development', - }, - {}, - ); - - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'development' }); - expect(result.options.mode).toEqual('development'); - }); - - it('should handle the mode option [none]', () => { - const result = resolveMode( - { - mode: 'none', - }, - {}, - ); - - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'none' }); - expect(result.options.mode).toEqual('none'); - }); - - it('should prefer supplied move flag over NODE_ENV', () => { - process.env.NODE_ENV = 'production'; - const result = resolveMode( - { - mode: 'development', - }, - {}, - ); - - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'development' }); - }); - - it('should prefer supplied move flag over mode from config', () => { - const result = resolveMode( - { - mode: 'development', - }, - { mode: 'production' }, - ); - - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'development' }); - }); - - it('should prefer mode form config over NODE_ENV', () => { - process.env.NODE_ENV = 'development'; - const result = resolveMode({}, { mode: 'production' }); - - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'production' }); - }); - - it('should prefer mode form flag over NODE_ENV and config', () => { - process.env.NODE_ENV = 'development'; - const result = resolveMode({ mode: 'none' }, { mode: 'production' }); - - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'none' }); - }); -}); diff --git a/packages/webpack-cli/__tests__/resolveOutput.test.js b/packages/webpack-cli/__tests__/resolveOutput.test.js deleted file mode 100644 index 3522d5b1068..00000000000 --- a/packages/webpack-cli/__tests__/resolveOutput.test.js +++ /dev/null @@ -1,11 +0,0 @@ -const { resolve } = require('path'); -const resolveOutput = require('../lib/groups/resolveOutput'); - -describe('OutputGroup', function () { - it('should handle the output option', () => { - const result = resolveOutput({ - outputPath: './bundle', - }); - expect(result.options.output.path).toEqual(resolve('bundle')); - }); -}); diff --git a/packages/webpack-cli/__tests__/resolveStats.js b/packages/webpack-cli/__tests__/resolveStats.js deleted file mode 100644 index 2b71a292960..00000000000 --- a/packages/webpack-cli/__tests__/resolveStats.js +++ /dev/null @@ -1,19 +0,0 @@ -const resolveStats = require('../lib/groups/resolveStats'); - -describe('StatsGroup', function () { - it('should assign json correctly', () => { - const result = resolveStats({ - json: true, - }); - expect(result.options.stats).toBeFalsy(); - expect(result.outputOptions.json).toBeTruthy(); - }); - - it('should assign stats correctly', () => { - const result = resolveStats({ - stats: 'warning', - }); - expect(result.options.stats).toEqual('warning'); - expect(result.outputOptions.json).toBeFalsy(); - }); -}); diff --git a/packages/webpack-cli/lib/groups/basicResolver.js b/packages/webpack-cli/lib/groups/basicResolver.js deleted file mode 100644 index f4e548f7ae6..00000000000 --- a/packages/webpack-cli/lib/groups/basicResolver.js +++ /dev/null @@ -1,40 +0,0 @@ -const { core, groups } = require('../utils/cli-flags'); - -const WEBPACK_OPTION_FLAGS = core - .filter((coreFlag) => { - return coreFlag.group === groups.BASIC_GROUP; - }) - .reduce((result, flagObject) => { - result.push(flagObject.name); - if (flagObject.alias) { - result.push(flagObject.alias); - } - return result; - }, []); - -function resolveArgs(args) { - const finalOptions = { - options: {}, - outputOptions: {}, - }; - Object.keys(args).forEach((arg) => { - if (WEBPACK_OPTION_FLAGS.includes(arg)) { - finalOptions.outputOptions[arg] = args[arg]; - } - if (arg === 'devtool') { - finalOptions.options.devtool = args[arg]; - } - if (arg === 'name') { - finalOptions.options.name = args[arg]; - } - if (arg === 'watch') { - finalOptions.options.watch = true; - } - if (arg === 'entry') { - finalOptions.options[arg] = args[arg]; - } - }); - return finalOptions; -} - -module.exports = resolveArgs; diff --git a/packages/webpack-cli/lib/groups/resolveMode.js b/packages/webpack-cli/lib/groups/resolveMode.js deleted file mode 100644 index 2e3a8a15acd..00000000000 --- a/packages/webpack-cli/lib/groups/resolveMode.js +++ /dev/null @@ -1,49 +0,0 @@ -const PRODUCTION = 'production'; -const DEVELOPMENT = 'development'; - -/* -Mode priority: - - Mode flag - - Mode from config - - Mode form NODE_ENV -*/ - -/** - * - * @param {string} mode - mode flag value - * @param {Object} configObject - contains relevant loaded config - */ -const assignMode = (mode, configObject) => { - const { - env: { NODE_ENV }, - } = process; - const { mode: configMode } = configObject; - let finalMode; - if (mode) { - finalMode = mode; - } else if (configMode) { - finalMode = configMode; - } else if (NODE_ENV && (NODE_ENV === PRODUCTION || NODE_ENV === DEVELOPMENT)) { - finalMode = NODE_ENV; - } else { - finalMode = PRODUCTION; - } - return { mode: finalMode }; -}; - -/** - * - * @param {Object} args - parsedArgs from the CLI - * @param {Object | Array} configOptions - Contains loaded config or array of configs - */ -const resolveMode = (args, configOptions) => { - const { mode } = args; - let resolvedMode; - if (Array.isArray(configOptions)) { - resolvedMode = configOptions.map((configObject) => assignMode(mode, configObject)); - } else resolvedMode = assignMode(mode, configOptions); - - return { options: resolvedMode }; -}; - -module.exports = resolveMode; diff --git a/packages/webpack-cli/lib/groups/resolveOutput.js b/packages/webpack-cli/lib/groups/resolveOutput.js deleted file mode 100644 index b658a9e8a55..00000000000 --- a/packages/webpack-cli/lib/groups/resolveOutput.js +++ /dev/null @@ -1,19 +0,0 @@ -const path = require('path'); - -/** - * Resolves the output flag - * @param {args} args - Parsed arguments passed to the CLI - */ -const resolveOutput = (args) => { - const { outputPath } = args; - const finalOptions = { - options: { output: {} }, - outputOptions: {}, - }; - if (outputPath) { - finalOptions.options.output.path = path.resolve(outputPath); - } - return finalOptions; -}; - -module.exports = resolveOutput; diff --git a/packages/webpack-cli/lib/groups/resolveStats.js b/packages/webpack-cli/lib/groups/resolveStats.js deleted file mode 100644 index be538f0352b..00000000000 --- a/packages/webpack-cli/lib/groups/resolveStats.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Resolve flags which deal with compilation stats - * @param {args} args - Parsed args passed to CLI - */ -const resolveStats = (args) => { - const { stats, json } = args; - - const finalOptions = { - options: {}, - outputOptions: {}, - }; - - if (stats !== undefined) { - finalOptions.options.stats = stats; - } - if (json) { - finalOptions.outputOptions.json = json; - } - return finalOptions; -}; - -module.exports = resolveStats; diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index dd239e6e2b2..73dbfb350c0 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -16,7 +16,6 @@ const { defaultCommands } = require('./cli-flags'); */ const argParser = (options, args, argsOnly = false, name = '') => { const parser = new commander.Command(); - // Set parser name parser.name(name); parser.storeOptionsAsProperties(false); diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index cb6f15999ae..d661a7cb865 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1,21 +1,19 @@ +const path = require('path'); const packageExists = require('./utils/package-exists'); const webpack = packageExists('webpack') ? require('webpack') : undefined; -const logger = require('./utils/logger'); const webpackMerge = require('webpack-merge'); -const { core, coreFlagMap } = require('./utils/cli-flags'); +const { writeFileSync } = require('fs'); +const { options: coloretteOptions, yellow } = require('colorette'); + +const logger = require('./utils/logger'); +const { core, groups, coreFlagMap } = require('./utils/cli-flags'); const argParser = require('./utils/arg-parser'); const assignFlagDefaults = require('./utils/flag-defaults'); -const { writeFileSync } = require('fs'); -const { options: coloretteOptions } = require('colorette'); const WebpackCLIPlugin = require('./plugins/WebpackCLIPlugin'); +const promptInstallation = require('./utils/prompt-installation'); // CLI arg resolvers const handleConfigResolution = require('./groups/resolveConfig'); -const resolveMode = require('./groups/resolveMode'); -const resolveStats = require('./groups/resolveStats'); -const resolveOutput = require('./groups/resolveOutput'); -const basicResolver = require('./groups/basicResolver'); -const resolveAdvanced = require('./groups/resolveAdvanced'); const toKebabCase = require('./utils/to-kebab-case'); class WebpackCLI { @@ -48,6 +46,145 @@ class WebpackCLI { this._mergeOptionsToConfiguration(configWithDefaults); } + async resolveArgs(args, configOptions = {}) { + // Since color flag has a default value, when there are no other args then exit + // eslint-disable-next-line no-prototype-builtins + if (Object.keys(args).length === 1 && args.hasOwnProperty('color') && !process.env.NODE_ENV) return {}; + + const { outputPath, stats, json, mode, target, prefetch, hot, analyze } = args; + const finalOptions = { + options: {}, + outputOptions: {}, + }; + + const WEBPACK_OPTION_FLAGS = core + .filter((coreFlag) => { + return coreFlag.group === groups.BASIC_GROUP; + }) + .reduce((result, flagObject) => { + result.push(flagObject.name); + if (flagObject.alias) { + result.push(flagObject.alias); + } + return result; + }, []); + + const PRODUCTION = 'production'; + const DEVELOPMENT = 'development'; + + /* + Mode priority: + - Mode flag + - Mode from config + - Mode form NODE_ENV + */ + + /** + * + * @param {string} mode - mode flag value + * @param {Object} configObject - contains relevant loaded config + */ + const assignMode = (mode, configObject) => { + const { + env: { NODE_ENV }, + } = process; + const { mode: configMode } = configObject; + let finalMode; + if (mode) { + finalMode = mode; + } else if (configMode) { + finalMode = configMode; + } else if (NODE_ENV && (NODE_ENV === PRODUCTION || NODE_ENV === DEVELOPMENT)) { + finalMode = NODE_ENV; + } else { + finalMode = PRODUCTION; + } + return finalMode; + }; + + Object.keys(args).forEach((arg) => { + if (WEBPACK_OPTION_FLAGS.includes(arg)) { + finalOptions.outputOptions[arg] = args[arg]; + } + if (arg === 'devtool') { + finalOptions.options.devtool = args[arg]; + } + if (arg === 'name') { + finalOptions.options.name = args[arg]; + } + if (arg === 'watch') { + finalOptions.options.watch = true; + } + if (arg === 'entry') { + finalOptions.options[arg] = args[arg]; + } + }); + if (outputPath) { + finalOptions.options.output = { path: path.resolve(outputPath) }; + } + + if (stats !== undefined) { + finalOptions.options.stats = stats; + } + if (json) { + finalOptions.outputOptions.json = json; + } + + if (hot) { + const { HotModuleReplacementPlugin } = require('webpack'); + const hotModuleVal = new HotModuleReplacementPlugin(); + if (finalOptions.options && finalOptions.options.plugins) { + finalOptions.options.plugins.unshift(hotModuleVal); + } else { + finalOptions.options.plugins = [hotModuleVal]; + } + } + if (prefetch) { + const { PrefetchPlugin } = require('webpack'); + const prefetchVal = new PrefetchPlugin(null, args.prefetch); + if (finalOptions.options && finalOptions.options.plugins) { + finalOptions.options.plugins.unshift(prefetchVal); + } else { + finalOptions.options.plugins = [prefetchVal]; + } + } + if (analyze) { + if (packageExists('webpack-bundle-analyzer')) { + // eslint-disable-next-line node/no-extraneous-require + const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); + const bundleAnalyzerVal = new BundleAnalyzerPlugin(); + if (finalOptions.options && finalOptions.options.plugins) { + finalOptions.options.plugins.unshift(bundleAnalyzerVal); + } else { + finalOptions.options.plugins = [bundleAnalyzerVal]; + } + } else { + await promptInstallation('webpack-bundle-analyzer', () => { + logger.error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); + }) + .then(() => logger.success(`${yellow('webpack-bundle-analyzer')} was installed sucessfully.`)) + .catch(() => { + logger.error(`Action Interrupted, Please try once again or install ${yellow('webpack-bundle-analyzer')} manually.`); + process.exit(2); + }); + } + } + if (target) { + finalOptions.options.target = args.target; + } + + if (Array.isArray(configOptions)) { + // Todo - handle multi config for all flags + finalOptions.options = configOptions.map(() => ({ ...finalOptions.options })); + configOptions.forEach((configObject, index) => { + finalOptions.options[index].mode = assignMode(mode, configObject); + }); + } else { + finalOptions.options.mode = assignMode(mode, configOptions); + } + return finalOptions; + } + async _baseResolver(cb, parsedArgs, strategy) { const resolvedConfig = await cb(parsedArgs, this.compilerConfiguration); this._mergeOptionsToConfiguration(resolvedConfig.options, strategy); @@ -146,12 +283,8 @@ class WebpackCLI { async runOptionGroups(parsedArgs) { await Promise.resolve() .then(() => this._baseResolver(handleConfigResolution, parsedArgs)) - .then(() => this._baseResolver(resolveMode, parsedArgs)) - .then(() => this._baseResolver(resolveOutput, parsedArgs)) .then(() => this._handleCoreFlags(parsedArgs)) - .then(() => this._baseResolver(basicResolver, parsedArgs)) - .then(() => this._baseResolver(resolveAdvanced, parsedArgs)) - .then(() => this._baseResolver(resolveStats, parsedArgs)); + .then(() => this._baseResolver(this.resolveArgs, parsedArgs)); } handleError(error) { diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 03a3be80584..c3577ac844c 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -36,7 +36,6 @@ describe('mode flags', () => { it('should pick mode form NODE_ENV', () => { const { stderr, stdout, exitCode } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); - expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); From 68bdbb4d783d1edfff9adf5f3f67eef0a69d7780 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 7 Nov 2020 17:00:53 +0530 Subject: [PATCH 046/581] chore: add ISSUE_TEMPLATE (#2059) --- .github/ISSUE_TEMPLATE.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000000..f68cbd3e629 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,16 @@ + From 95f1b7312a778f4d0c7dd0c29ed7c1df36357b89 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 7 Nov 2020 14:33:52 +0300 Subject: [PATCH 047/581] chore(deps-dev): bump eslint from 7.12.1 to 7.13.0 (#2056) Bumps [eslint](https://github.com/eslint/eslint) from 7.12.1 to 7.13.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.12.1...v7.13.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5334012e590..af91026e1a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4950,9 +4950,9 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.12.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.12.1.tgz#bd9a81fa67a6cfd51656cdb88812ce49ccec5801" - integrity sha512-HlMTEdr/LicJfN08LB3nM1rRYliDXOmfoO4vj39xN6BLpFzF00hbwBoqHk8UcJ2M/3nlARZWy/mslvGEuZFvsg== + version "7.13.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.13.0.tgz#7f180126c0dcdef327bfb54b211d7802decc08da" + integrity sha512-uCORMuOO8tUzJmsdRtrvcGq5qposf7Rw0LwkTJkoDbOycVQtQjmnhZSuLQnozLE4TmAzlMVV45eCHmQ1OpDKUQ== dependencies: "@babel/code-frame" "^7.0.0" "@eslint/eslintrc" "^0.2.1" From 6618243c60e322aef0ea0c52b347b38aa0819caf Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Sat, 7 Nov 2020 17:28:25 +0530 Subject: [PATCH 048/581] refactor: remove devtool flag default (#2053) --- packages/webpack-cli/lib/utils/cli-flags.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 195330f92e3..62163cef897 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -156,7 +156,6 @@ const core = [ usage: '--devtool ', type: String, alias: 'd', - defaultValue: undefined, group: BASIC_GROUP, description: 'Determine source maps to use', link: 'https://webpack.js.org/configuration/devtool/#devtool', From e59805aad7c54062bb4038b470b69fb6af2f028e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 8 Nov 2020 09:50:39 +0530 Subject: [PATCH 049/581] docs: update stats option related flags (#2057) --- packages/webpack-cli/README.md | 64 +++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index c70419016e0..258f7f14c80 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -483,18 +483,24 @@ yarn add webpack-cli --dev --snapshot-resolve-timestamp Use timestamps of the files/directories to determine invalidation. --snapshot-resolve-build-dependencies-hash Use hashes of the content of the files/directories to determine invalidation. --snapshot-resolve-build-dependencies-timestamp Use timestamps of the files/directories to determine invalidation. + --stats-all Fallback value for stats options when an option is not defined (has + precedence over local webpack defaults). --stats-assets Add assets information. --stats-assets-sort string Sort the assets by that field. + --stats-assets-space number Space to display assets (groups will be collapsed to fit this space). --stats-built-at Add built at time information. --stats-cached Add information about cached (not built) modules. --stats-cached-assets Show cached assets (setting this to `false` only shows emitted files). + --stats-cached-modules Add information about cached (not built) modules. --stats-children Add children information. + --stats-chunk-group-auxiliary Display auxiliary assets in chunk groups. + --stats-chunk-group-children Display children of chunk groups. + --stats-chunk-group-max-assets number Limit of assets displayed in chunk groups. --stats-chunk-groups Display all chunk groups with the corresponding bundles. --stats-chunk-modules Add built modules information to chunk information. --stats-chunk-origins Add the origins of chunks and chunk merging info. --stats-chunk-relations Add information about parent, children and sibling chunks to chunk information. - --stats-chunk-root-modules Add root modules information to chunk information. --stats-chunks Add chunk information. --stats-chunks-sort string Sort the chunks by that field. --stats-colors Enables/Disables colorful output. @@ -505,12 +511,14 @@ yarn add webpack-cli --dev --stats-colors-red string Custom color for red text. --stats-colors-yellow string Custom color for yellow text. --stats-context string Context directory for request shortening. + --stats-dependent-modules Show chunk modules that are dependencies of other modules of the chunk. --stats-depth Add module depth in module graph. - --stats-entrypoints Display the entry points with the corresponding bundles. + --stats-entrypoints string Display the entry points with the corresponding bundles. --stats-env Add --env information. --stats-error-details Add details to errors (like resolving log). --stats-error-stack Add internal stack trace to errors. --stats-errors Add errors. + --stats-errors-count Add errors count. --stats-exclude-assets string[] Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions. --stats-exclude-assets-reset Clear all items provided in configuration. Suppress assets that match the @@ -519,6 +527,17 @@ yarn add webpack-cli --dev RegExps, Booleans or Functions. --stats-exclude-modules-reset Clear all items provided in configuration. Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions. + --stats-group-assets-by-chunk Group assets by how their are related to chunks. + --stats-group-assets-by-emit-status Group assets by their status (emitted, compared for emit or cached). + --stats-group-assets-by-extension Group assets by their extension. + --stats-group-assets-by-info Group assets by their asset info (immutable, development, + hotModuleReplacement, etc). + --stats-group-assets-by-path Group assets by their path. + --stats-group-modules-by-attributes Group modules by their attributes (errors, warnings, assets, optional, + orphan, or dependent). + --stats-group-modules-by-cache-status Group modules by their status (cached or built and cacheable). + --stats-group-modules-by-extension Group modules by their extension. + --stats-group-modules-by-path Group modules by their path. --stats-hash Add the hash of the compilation. --stats-ids Add ids. --stats-logging string Specify log level of logging output. Enable/disable logging output (`true`: @@ -530,11 +549,12 @@ yarn add webpack-cli --dev loggers (i. e. for plugins or loaders). Filters can be Strings, RegExps or Functions. --stats-logging-trace Add stack traces to logging output. - --stats-max-modules number Set the maximum number of modules to be shown. --stats-module-assets Add information about assets inside modules. --stats-module-trace Add dependencies and origin of warnings/errors. --stats-modules Add built modules information. --stats-modules-sort string Sort the modules by that field. + --stats-modules-space number Space to display modules (groups will be collapsed to fit this space, values + is in number of modules/groups). --stats-nested-modules Add information about modules nested in other modules (like with module concatenation). --stats-optimization-bailout Show reasons why optimization bailed out for modules. @@ -545,16 +565,20 @@ yarn add webpack-cli --dev --stats-provided-exports Show exports provided by modules. --stats-public-path Add public path information. --stats-reasons Add information about the reasons why modules are included. - --stats-runtime Add information about runtime modules. - --stats-source Add the source code of modules. + --stats-related-assets Add information about assets that are related to other assets (like + SourceMaps for assets). + --stats-runtime-modules Add information about runtime modules. --stats-timings Add timing information. - --stats-used-exports Show exports used by modules. + --stats-source Add the source code of modules. --stats-version Add webpack version information. + --stats-used-exports Show exports used by modules. + --stats-warnings-count Add warnings count. --stats-warnings Add warnings. - --stats-warnings-filter string[] Suppress warnings that match the specified filters. Filters can be Strings, - RegExps or Functions. - --stats-warnings-filter-reset Clear all items provided in configuration. Suppress warnings that match the - specified filters. Filters can be Strings, RegExps or Functions. + --stats-warnings-filter string[] Suppress listing warnings that match the specified filters (they will still + be counted). Filters can be Strings, RegExps or Functions. + --stats-warnings-filter-reset Clear all items provided in configuration. Suppress listing warnings that + match the specified filters (they will still be counted). Filters can be + Strings, RegExps or Functions. --watch-options-aggregate-timeout number Delay the rebuilt after the first change. Value is a time in ms. --watch-options-ignored string[] A glob pattern for files that should be ignored from watching. --watch-options-ignored-reset Clear all items provided in configuration. Ignore some files from watching @@ -644,20 +668,32 @@ yarn add webpack-cli --dev --no-stats-built-at Negates stats-built-at --no-stats-cached Negates stats-cached --no-stats-cached-assets Negates stats-cached-assets + --no-stats-cached-modules Negates stats-cached-modules --no-stats-children Negates stats-children + --no-stats-chunk-group-auxiliary Negates stats-chunk-group-auxiliary + --no-stats-chunk-group-children Negates stats-chunk-group-children --no-stats-chunk-groups Negates stats-chunk-groups --no-stats-chunk-modules Negates stats-chunk-modules --no-stats-chunk-origins Negates stats-chunk-origins --no-stats-chunk-relations Negates stats-chunk-relations - --no-stats-chunk-root-modules Negates stats-chunk-root-modules --no-stats-chunks Negates stats-chunks --no-stats-colors Negates stats-colors + --no-stats-dependent-modules Negates stats-dependent-modules --no-stats-depth Negates stats-depth - --no-stats-entrypoints Negates stats-entrypoints --no-stats-env Negates stats-env --no-stats-error-details Negates stats-error-details --no-stats-error-stack Negates stats-error-stack --no-stats-errors Negates stats-errors + --no-stats-errors-count Negates stats-errors-count + --no-stats-group-assets-by-chunk Negates stats-group-assets-by-chunk + --no-stats-group-assets-by-emit-status Negates stats-group-assets-by-emit-status + --no-stats-group-assets-by-extension Negates stats-group-assets-by-extension + --no-stats-group-assets-by-info Negates stats-group-assets-by-info + --no-stats-group-assets-by-path Negates stats-group-assets-by-path + --no-stats-group-modules-by-attributes Negates stats-group-modules-by-attributes + --no-stats-group-modules-by-cache-status Negates stats-group-modules-by-cache-status + --no-stats-group-modules-by-extension Negates stats-group-modules-by-extension + --no-stats-group-modules-by-path Negates stats-group-modules-by-path --no-stats-hash Negates stats-hash --no-stats-ids Negates stats-ids --no-stats-logging-trace Negates stats-logging-trace @@ -672,11 +708,13 @@ yarn add webpack-cli --dev --no-stats-provided-exports Negates stats-provided-exports --no-stats-public-path Negates stats-public-path --no-stats-reasons Negates stats-reasons - --no-stats-runtime Negates stats-runtime + --no-stats-related-assets Negates stats-related-assets + --no-stats-runtime-modules Negates stats-runtime-modules --no-stats-source Negates stats-source --no-stats-timings Negates stats-timings --no-stats-used-exports Negates stats-used-exports --no-stats-version Negates stats-version --no-stats-warnings Negates stats-warnings + --no-stats-warnings-count Negates stats-warnings-count --no-watch-options-stdin Negates watch-options-stdin ``` From 8651f49b6f03d1ae750c2bfc2630e0312e7126c9 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 8 Nov 2020 09:59:29 +0530 Subject: [PATCH 050/581] fix: update --output-path link (#2058) --- packages/webpack-cli/lib/utils/cli-flags.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 62163cef897..057f308fcc3 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -122,7 +122,7 @@ const core = [ alias: 'o', type: String, description: 'Output location of the file generated by webpack e.g. ./dist/', - link: 'https://webpack.js.org/concepts/#output', + link: 'https://webpack.js.org/configuration/output/#outputpath', }, { name: 'target', From 5942cb99a5a60bea1685189b9e6f62436979a1dc Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 9 Nov 2020 15:43:20 +0530 Subject: [PATCH 051/581] chore: rm stale utils and batch them (#2069) --- packages/webpack-cli/lib/utils/arg-utils.js | 18 ++++++++---------- .../webpack-cli/lib/utils/to-kebab-case.js | 10 ---------- packages/webpack-cli/lib/webpack-cli.js | 2 +- 3 files changed, 9 insertions(+), 21 deletions(-) delete mode 100644 packages/webpack-cli/lib/utils/to-kebab-case.js diff --git a/packages/webpack-cli/lib/utils/arg-utils.js b/packages/webpack-cli/lib/utils/arg-utils.js index 90505240fae..a5f4179909c 100644 --- a/packages/webpack-cli/lib/utils/arg-utils.js +++ b/packages/webpack-cli/lib/utils/arg-utils.js @@ -9,15 +9,13 @@ const hyphenToUpperCase = (name) => { }); }; -const arrayToObject = (arr) => { - if (!arr) { - return; - } - return arr.reduce((result, currentItem) => { - const key = Object.keys(currentItem)[0]; - result[hyphenToUpperCase(key)] = currentItem[key]; - return result; - }, {}); +/** + * Convert camelCase to kebab-case + * @param {string} str input string in camelCase + * @returns {string} output string in kebab-case + */ +const toKebabCase = (str) => { + return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); }; const isCommandUsed = (args) => @@ -26,7 +24,7 @@ const isCommandUsed = (args) => }); module.exports = { - arrayToObject, + toKebabCase, hyphenToUpperCase, isCommandUsed, }; diff --git a/packages/webpack-cli/lib/utils/to-kebab-case.js b/packages/webpack-cli/lib/utils/to-kebab-case.js deleted file mode 100644 index d21b80d8c98..00000000000 --- a/packages/webpack-cli/lib/utils/to-kebab-case.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Convert camelCase to kebab-case - * @param {string} str input string in camelCase - * @returns {string} output string in kebab-case - */ -function toKebabCase(str) { - return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); -} - -module.exports = toKebabCase; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index d661a7cb865..ab8c9d64373 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -14,7 +14,7 @@ const promptInstallation = require('./utils/prompt-installation'); // CLI arg resolvers const handleConfigResolution = require('./groups/resolveConfig'); -const toKebabCase = require('./utils/to-kebab-case'); +const { toKebabCase } = require('./utils/arg-utils'); class WebpackCLI { constructor() { From 1ba9704d3ed48431876d6763adb6af6df068b075 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2020 13:24:10 +0300 Subject: [PATCH 052/581] chore(deps): bump command-line-usage from 6.1.0 to 6.1.1 (#2061) Bumps [command-line-usage](https://github.com/75lb/command-line-usage) from 6.1.0 to 6.1.1. - [Release notes](https://github.com/75lb/command-line-usage/releases) - [Commits](https://github.com/75lb/command-line-usage/compare/v6.1.0...v6.1.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index af91026e1a7..85875653445 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3020,7 +3020,7 @@ arr-union@^3.1.0: resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= -array-back@^4.0.0, array-back@^4.0.1: +array-back@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.1.tgz#9b80312935a52062e1a233a9c7abeb5481b30e90" integrity sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg== @@ -3902,13 +3902,13 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: delayed-stream "~1.0.0" command-line-usage@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.0.tgz#f28376a3da3361ff3d36cfd31c3c22c9a64c7cb6" - integrity sha512-Ew1clU4pkUeo6AFVDFxCbnN7GIZfXl48HIOQeFQnkO3oOqvpI7wdqtLRwv9iOCZ/7A+z4csVZeiDdEcj8g6Wiw== + version "6.1.1" + resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.1.tgz#c908e28686108917758a49f45efb4f02f76bc03f" + integrity sha512-F59pEuAR9o1SF/bD0dQBDluhpT4jJQNWUHEuVBqpDmCUo6gPjCi+m9fCWnWZVR/oG6cMTUms4h+3NPl74wGXvA== dependencies: - array-back "^4.0.0" + array-back "^4.0.1" chalk "^2.4.2" - table-layout "^1.0.0" + table-layout "^1.0.1" typical "^5.2.0" commander@^2.18.0, commander@^2.20.0: @@ -10925,7 +10925,7 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -table-layout@^1.0.0: +table-layout@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.1.tgz#8411181ee951278ad0638aea2f779a9ce42894f9" integrity sha512-dEquqYNJiGwY7iPfZ3wbXDI944iqanTSchrACLL2nOB+1r+h1Nzu2eH+DuPPvWvm5Ry7iAPeFlgEtP5bIp5U7Q== From b0f279683216790b1a832a5443b83ce9d92c5be5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2020 13:24:23 +0300 Subject: [PATCH 053/581] chore(deps-dev): bump ts-jest from 26.4.3 to 26.4.4 (#2065) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.4.3 to 26.4.4. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v26.4.3...v26.4.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/yarn.lock b/yarn.lock index 85875653445..0c6c314b41f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1211,11 +1211,6 @@ slash "^3.0.0" strip-ansi "^6.0.0" -"@jest/create-cache-key-function@^26.5.0": - version "26.5.0" - resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-26.5.0.tgz#1d07947adc51ea17766d9f0ccf5a8d6ea94c47dc" - integrity sha512-DJ+pEBUIqarrbv1W/C39f9YH0rJ4wsXZ/VC6JafJPlHW2HOucKceeaqTOQj9MEDQZjySxMLkOq5mfXZXNZcmWw== - "@jest/environment@^26.6.2": version "26.6.2" resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-26.6.2.tgz#ba364cc72e221e79cc8f0a99555bf5d7577cf92c" @@ -7335,19 +7330,7 @@ jest-snapshot@^26.6.2: pretty-format "^26.6.2" semver "^7.3.2" -jest-util@^26.1.0, jest-util@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.1.tgz#4cc0d09ec57f28d12d053887eec5dc976a352e9b" - integrity sha512-xCLZUqVoqhquyPLuDXmH7ogceGctbW8SMyQVjD9o+1+NPWI7t0vO08udcFLVPLgKWcvc+zotaUv/RuaR6l8HIA== - dependencies: - "@jest/types" "^26.6.1" - "@types/node" "*" - chalk "^4.0.0" - graceful-fs "^4.2.4" - is-ci "^2.0.0" - micromatch "^4.0.2" - -jest-util@^26.6.2: +jest-util@^26.1.0, jest-util@^26.6.1, jest-util@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1" integrity sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q== @@ -11209,11 +11192,10 @@ tryer@^1.0.1: integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== ts-jest@^26.4.3: - version "26.4.3" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.3.tgz#d153a616033e7ec8544b97ddbe2638cbe38d53db" - integrity sha512-pFDkOKFGY+nL9v5pkhm+BIFpoAuno96ff7GMnIYr/3L6slFOS365SI0fGEVYx2RKGji5M2elxhWjDMPVcOCdSw== + version "26.4.4" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.4.tgz#61f13fb21ab400853c532270e52cc0ed7e502c49" + integrity sha512-3lFWKbLxJm34QxyVNNCgXX1u4o/RV0myvA2y2Bxm46iGIjKlaY0own9gIckbjZJPn+WaJEnfPPJ20HHGpoq4yg== dependencies: - "@jest/create-cache-key-function" "^26.5.0" "@types/jest" "26.x" bs-logger "0.x" buffer-from "1.x" From ad08980ae926ce9e0d290b122533828902cfca8d Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 9 Nov 2020 15:55:34 +0530 Subject: [PATCH 054/581] chore: rm redundant group files (#2068) --- .../webpack-cli/lib/groups/resolveAdvanced.js | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 packages/webpack-cli/lib/groups/resolveAdvanced.js diff --git a/packages/webpack-cli/lib/groups/resolveAdvanced.js b/packages/webpack-cli/lib/groups/resolveAdvanced.js deleted file mode 100644 index 7f24b8b205a..00000000000 --- a/packages/webpack-cli/lib/groups/resolveAdvanced.js +++ /dev/null @@ -1,64 +0,0 @@ -const packageExists = require('../utils/package-exists'); -const promptInstallation = require('../utils/prompt-installation'); -const { yellow } = require('colorette'); -const { error, success } = require('../utils/logger'); - -/** - * Resolve advanced flags - * @param {args} args - Parsed args passed to CLI - */ -const resolveAdvanced = async (args) => { - const { target, prefetch, hot, analyze } = args; - - const finalOptions = { - options: {}, - outputOptions: {}, - }; - - if (hot) { - const { HotModuleReplacementPlugin } = require('webpack'); - const hotModuleVal = new HotModuleReplacementPlugin(); - if (finalOptions.options && finalOptions.options.plugins) { - finalOptions.options.plugins.unshift(hotModuleVal); - } else { - finalOptions.options.plugins = [hotModuleVal]; - } - } - if (prefetch) { - const { PrefetchPlugin } = require('webpack'); - const prefetchVal = new PrefetchPlugin(null, args.prefetch); - if (finalOptions.options && finalOptions.options.plugins) { - finalOptions.options.plugins.unshift(prefetchVal); - } else { - finalOptions.options.plugins = [prefetchVal]; - } - } - if (analyze) { - if (packageExists('webpack-bundle-analyzer')) { - // eslint-disable-next-line node/no-extraneous-require - const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); - const bundleAnalyzerVal = new BundleAnalyzerPlugin(); - if (finalOptions.options && finalOptions.options.plugins) { - finalOptions.options.plugins.unshift(bundleAnalyzerVal); - } else { - finalOptions.options.plugins = [bundleAnalyzerVal]; - } - } else { - await promptInstallation('webpack-bundle-analyzer', () => { - error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); - }) - .then(() => success(`${yellow('webpack-bundle-analyzer')} was installed sucessfully.`)) - .catch(() => { - error(`Action Interrupted, Please try once again or install ${yellow('webpack-bundle-analyzer')} manually.`); - process.exit(2); - }); - } - } - if (target) { - finalOptions.options.target = args.target; - } - - return finalOptions; -}; - -module.exports = resolveAdvanced; From b06d691402a80728825d9081173bff05bf2dd442 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 9 Nov 2020 15:58:22 +0530 Subject: [PATCH 055/581] docs: update INIT.md (#2078) --- INIT.md | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/INIT.md b/INIT.md index 6b774d07df4..54c8882cd9a 100644 --- a/INIT.md +++ b/INIT.md @@ -8,13 +8,14 @@ - [Local Setup](#local-setup) - [Global Setup](#global-setup) - [Usage](#usage) - - [Running Globally](#running-globally) - [Running Locally](#running-locally) + - [Running Globally](#running-globally) + - [CLI options](#cli-options) - [Description of questions asked by generator](#description-of-questions-asked-by-generator) ## Initial Setup -### a. Local Setup +### Local Setup These are the steps necessary to set up `webpack-cli init` locally: @@ -36,7 +37,7 @@ These are the steps necessary to set up `webpack-cli init` locally: npm install --save-dev @webpack-cli/init ``` -### b. Global Setup +### Global Setup These are the steps necessary to set up `webpack-cli init` globally: @@ -54,18 +55,44 @@ These are the steps necessary to set up `webpack-cli init` globally: ## Usage -### a. Running Locally +### Running Locally -```shell +```bash npx webpack-cli init ``` -### b. Running Globally +### Running Globally ```shell webpack-cli init ``` +### CLI options + +**Via defaults** + +```bash +webpack-cli init +``` + +**To generate default configs** + +```bash +webpack-cli init --auto +``` + +**To force config generation** + +```bash +webpack-cli init --force +``` + +**Via custom scaffold** + +```bash +webpack-cli init webpack-scaffold-[name] +``` + ### Description of questions asked by the generator 1. `Will your application have multiple bundles? (y/N)` From 7d97efec34ca255ccedb667092e818ecd5091fac Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Mon, 9 Nov 2020 15:59:16 +0530 Subject: [PATCH 056/581] docs: add code coverage badge (#2080) --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index bd3214acdb5..82712688d96 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ [![npm][npm]][npm-url] [![Build Status][build-status]][build-status-url] +[![codecov][codecov-badge]][codecov-url] [![Dependencies][deps]][deps-url] [![Install Size][size]][size-url] [![Chat on gitter][chat]][chat-url] @@ -112,6 +113,8 @@ If you like **webpack**, please consider donating to our [Open Collective](https [npm-url]: https://www.npmjs.com/package/webpack-cli [build-status]: https://github.com/webpack/webpack-cli/workflows/webpack-cli/badge.svg?branch=master [build-status-url]: https://github.com/webpack/webpack-cli/actions +[codecov-badge]: https://codecov.io/gh/webpack/webpack-cli/branch/master/graph/badge.svg?token=6B6NxtsZc3 +[codecov-url]: https://codecov.io/gh/webpack/webpack-cli [deps]: https://img.shields.io/david/webpack/webpack.svg [deps-url]: https://david-dm.org/webpack/webpack-cli [size]: https://packagephobia.com/badge?p=webpack-cli From 35b9d695a4ed56ce554da7a8231bf29eec14e30a Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 9 Nov 2020 16:10:03 +0530 Subject: [PATCH 057/581] fix: improve package-exists util (#2067) --- packages/webpack-cli/lib/utils/package-exists.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/utils/package-exists.js b/packages/webpack-cli/lib/utils/package-exists.js index 44d7f521980..5ba91f3f9f2 100644 --- a/packages/webpack-cli/lib/utils/package-exists.js +++ b/packages/webpack-cli/lib/utils/package-exists.js @@ -1,6 +1,6 @@ function packageExists(packageName) { try { - require(packageName); + require.resolve(packageName); return true; } catch (err) { return false; From 70bf7708c21dffe6521f1800b9dec2a62d21cfe2 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 9 Nov 2020 16:33:14 +0530 Subject: [PATCH 058/581] fix: catch dev server import during webpack serve (#2070) --- packages/serve/src/startDevServer.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index 4388ae77d97..74ebc208b43 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -1,7 +1,11 @@ +import { utils } from 'webpack-cli'; + import createConfig from './createConfig'; import getDevServerOptions from './getDevServerOptions'; import mergeOptions from './mergeOptions'; +const { logger } = utils; + /** * * Starts the devServer @@ -12,8 +16,14 @@ import mergeOptions from './mergeOptions'; * @returns {Object[]} array of resulting servers */ export default function startDevServer(compiler, devServerArgs): object[] { - // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-extraneous-require - const Server = require('webpack-dev-server/lib/Server'); + let Server; + try { + // eslint-disable-next-line node/no-extraneous-require + Server = require('webpack-dev-server/lib/Server'); + } catch (err) { + logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); + process.exit(2); + } const cliOptions = createConfig(devServerArgs); const devServerOptions = getDevServerOptions(compiler); From 413eb8cf2add4978763a4c9ee6b983582685768b Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 16:34:49 +0530 Subject: [PATCH 059/581] feat(init): add --generation-path flag (#2050) * feat: new --generate-path flag for init * tests: test case for init --generate-path * tests: cleanup * chore: rename to --generation-path * docs: add info regarding --generation-path --- packages/generators/src/init-generator.ts | 4 +- packages/init/README.md | 6 +++ packages/init/src/index.ts | 14 +++++- packages/utils/src/modify-config-helper.ts | 10 +++-- packages/utils/src/scaffold.ts | 4 +- .../init-generation-path.test.js | 45 +++++++++++++++++++ 6 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 test/init/generation-path/init-generation-path.test.js diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index e77fdc3cb5a..002007b1f70 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -30,6 +30,7 @@ const { logger, getPackageManager } = utils; export default class InitGenerator extends CustomGenerator { public usingDefaults: boolean; public autoGenerateConfig: boolean; + public generationPath: string; private langType: string; public constructor(args, opts) { @@ -37,6 +38,7 @@ export default class InitGenerator extends CustomGenerator { this.usingDefaults = true; this.autoGenerateConfig = opts.autoSetDefaults ? true : false; + this.generationPath = opts.generationPath; this.dependencies = ['webpack', 'webpack-cli', 'babel-plugin-syntax-dynamic-import']; @@ -243,7 +245,7 @@ export default class InitGenerator extends CustomGenerator { 'save-dev'?: boolean; } = packager === 'yarn' ? { dev: true } : { 'save-dev': true }; - this.scheduleInstallTask(packager, this.dependencies, opts); + this.scheduleInstallTask(packager, this.dependencies, opts, { cwd: this.generationPath }); } public writing(): void { diff --git a/packages/init/README.md b/packages/init/README.md index 97f563c38ee..2db8be4df6e 100644 --- a/packages/init/README.md +++ b/packages/init/README.md @@ -48,6 +48,12 @@ npx webpack-cli init --auto npx webpack-cli init --force ``` +**To scaffold in a specified path** + +```bash +npx webpack-cli init --generation-path [path] +``` + **Via custom scaffold** 1. Using package on `npm` diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index 4812f07e68b..9d743b88825 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -3,6 +3,8 @@ import { modifyHelperUtil, npmPackagesExists } from '@webpack-cli/utils'; const AUTO_PREFIX = '--auto'; const CONFIG_PREFIX = '--force'; +const PATH_PREFIX = '--generation-path'; + /** * * First function to be called after running the init flag. This is a check, @@ -18,8 +20,16 @@ export default function initializeInquirer(...args: string[]): Function | void { const packages = args; const includesDefaultPrefix = packages.includes(AUTO_PREFIX); const generateConfig = packages.includes(CONFIG_PREFIX); - if (packages.length === 0 || includesDefaultPrefix || generateConfig) { - return modifyHelperUtil('init', initGenerator, null, null, includesDefaultPrefix, generateConfig); + const genPathPrefix = packages.includes(PATH_PREFIX); + + let generationPath: string; + if (genPathPrefix) { + const idx = packages.indexOf(PATH_PREFIX); + // Retrieve the path supplied along with --generation-path + generationPath = packages[idx + 1]; + } + if (packages.length === 0 || includesDefaultPrefix || generateConfig || genPathPrefix) { + return modifyHelperUtil('init', initGenerator, null, null, includesDefaultPrefix, generateConfig, generationPath); } return npmPackagesExists(packages); } diff --git a/packages/utils/src/modify-config-helper.ts b/packages/utils/src/modify-config-helper.ts index 7103b066f35..a5ea55a48db 100644 --- a/packages/utils/src/modify-config-helper.ts +++ b/packages/utils/src/modify-config-helper.ts @@ -54,10 +54,11 @@ export function modifyHelperUtil( packages?: string[], autoSetDefaults = false, generateConfig = false, + generationPath = '.', ): void { const configPath: string | null = null; - const env = yeoman.createEnv('webpack', null); + const env = yeoman.createEnv('webpack', { cwd: generationPath }); const generatorName = 'webpack-init-generator'; if (!generator) { @@ -77,7 +78,7 @@ export function modifyHelperUtil( // see: https://github.com/yeoman/generator/blob/v4.5.0/lib/index.js#L773 let packageName = '*'; try { - const packagePath = path.resolve(process.cwd(), 'package.json'); + const packagePath = path.resolve(generationPath, 'package.json'); if (fs.existsSync(packagePath)) { // eslint-disable-next-line @typescript-eslint/no-var-requires const packageData = require(packagePath); @@ -97,6 +98,7 @@ export function modifyHelperUtil( { configFile, autoSetDefaults, + generationPath, }, () => { let configModule: object; @@ -104,7 +106,7 @@ export function modifyHelperUtil( config: {}, }; try { - const confPath = path.resolve(process.cwd(), '.yo-rc.json'); + const confPath = path.resolve(generationPath, '.yo-rc.json'); configModule = require(confPath); } catch (err) { logger.error('\nCould not find a yeoman configuration file (.yo-rc.json).\n'); @@ -146,7 +148,7 @@ export function modifyHelperUtil( } // scaffold webpack config file from using .yo-rc.json - return runTransform(transformConfig, 'init', generateConfig); + return runTransform(transformConfig, 'init', generateConfig, generationPath); } catch (err) { logger.error(err); process.exitCode = 2; diff --git a/packages/utils/src/scaffold.ts b/packages/utils/src/scaffold.ts index f4d21e130c6..ebeb3b2a0d9 100644 --- a/packages/utils/src/scaffold.ts +++ b/packages/utils/src/scaffold.ts @@ -37,7 +37,7 @@ function mapOptionsToTransform(config: Config): string[] { * and writes the file */ -export function runTransform(transformConfig: TransformConfig, action: string, generateConfig: boolean): void { +export function runTransform(transformConfig: TransformConfig, action: string, generateConfig: boolean, generationPath: string): void { // webpackOptions.name sent to nameTransform if match const webpackConfig = Object.keys(transformConfig).filter((p: string): boolean => { if (p == 'usingDefaults') { @@ -80,7 +80,7 @@ export function runTransform(transformConfig: TransformConfig, action: string, g } else { configurationName = 'webpack.' + config.configName + '.js'; } - const projectRoot = findProjectRoot(); + const projectRoot = findProjectRoot(generationPath); const outputPath: string = initActionNotDefined ? transformConfig.configPath : path.join(projectRoot || process.cwd(), configurationName); diff --git a/test/init/generation-path/init-generation-path.test.js b/test/init/generation-path/init-generation-path.test.js new file mode 100644 index 00000000000..5d4712b04ac --- /dev/null +++ b/test/init/generation-path/init-generation-path.test.js @@ -0,0 +1,45 @@ +'use strict'; + +const fs = require('fs'); +const rimraf = require('rimraf'); +const { join, resolve } = require('path'); +const { run } = require('../../utils/test-utils'); + +const firstPrompt = 'Will your application have multiple bundles?'; + +const genPath = join(__dirname, 'test-assets'); + +describe('init generate-path flag', () => { + beforeAll(() => { + rimraf.sync(genPath); + }); + + it('should scaffold in the specified path with --generation-path', () => { + const { stdout } = run(__dirname, ['init', '--generation-path', 'test-assets', '--auto'], false); + // Test no prompts are present + expect(stdout).toBeTruthy(); + expect(stdout).not.toContain(firstPrompt); + + // Skip test in case installation fails + if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { + return; + } + + // Test regressively files are scaffolded + const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; + + files.forEach((file) => { + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); + }); + + // Check package json is correctly configured + const pkgJsonTests = () => { + const pkgJson = require(join(genPath, './package.json')); + expect(pkgJson).toBeTruthy(); + expect(pkgJson['devDependencies']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + }; + expect(pkgJsonTests).not.toThrow(); + }); +}); From 02babea6f3860f9c5624f6ad23d1b5de356f1fe9 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 16:37:01 +0530 Subject: [PATCH 060/581] feat(generate-plugin): scaffold in a specified path (#2073) * feat: add the ability to specify a path for scaffolding * tests: add test case for scaffolding in a specified path * docs: update usage info --- packages/generate-plugin/README.md | 8 +++++- packages/generate-plugin/src/index.ts | 5 ++-- test/plugin/plugin.test.js | 37 +++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/packages/generate-plugin/README.md b/packages/generate-plugin/README.md index 43d58cd3dde..a4ed13673e7 100644 --- a/packages/generate-plugin/README.md +++ b/packages/generate-plugin/README.md @@ -27,7 +27,13 @@ generatePlugin(); ### CLI (via `webpack-cli`) ```bash -npx webpack-cli generate-plugin +npx webpack-cli plugin +``` + +> Optionally specify a path for generating the plugin template. + +```bash +npx webpack-cli plugin [path] ``` [downloads]: https://img.shields.io/npm/dm/@webpack-cli/generate-plugin.svg diff --git a/packages/generate-plugin/src/index.ts b/packages/generate-plugin/src/index.ts index 3e5d4d55568..08bdb4b9a8e 100644 --- a/packages/generate-plugin/src/index.ts +++ b/packages/generate-plugin/src/index.ts @@ -9,8 +9,9 @@ const { logger } = utils; * @returns {void} */ -export default function pluginCreator(): void { - const env = yeoman.createEnv(); +export default function pluginCreator(...args: string[]): void { + const generationPath = args[0]; + const env = yeoman.createEnv([], { cwd: generationPath }); const generatorName = 'webpack-plugin-generator'; env.registerStub(pluginGenerator, generatorName); diff --git a/test/plugin/plugin.test.js b/test/plugin/plugin.test.js index 7d4055adff1..6b98e27a426 100644 --- a/test/plugin/plugin.test.js +++ b/test/plugin/plugin.test.js @@ -7,13 +7,15 @@ const ENTER = '\x0D'; const firstPrompt = '? Plugin name'; const pluginName = 'test-plugin'; const pluginPath = join(__dirname, pluginName); +const customPluginPath = join(__dirname, 'test-assets', 'my-webpack-plugin'); describe('plugin command', () => { beforeAll(() => { rimraf.sync(pluginPath); + rimraf.sync(customPluginPath); }); - it('Should ask the plugin name when invoked', () => { + it('should ask the plugin name when invoked', () => { const { stdout, stderr } = run(__dirname, ['plugin'], false); expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); @@ -25,8 +27,8 @@ describe('plugin command', () => { expect(stripAnsi(stdout)).toContain(firstPrompt); - // check if the output directory exists with the appropriate plugin name - expect(existsSync(join(__dirname, pluginName))).toBeTruthy(); + // Check if the output directory exists with the appropriate plugin name + expect(existsSync(pluginPath)).toBeTruthy(); // Skip test in case installation fails if (!existsSync(resolve(pluginPath, './yarn.lock'))) { @@ -37,10 +39,35 @@ describe('plugin command', () => { const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; files.forEach((file) => { - expect(existsSync(join(__dirname, `${pluginName}/${file}`))).toBeTruthy(); + expect(existsSync(join(pluginPath, file))).toBeTruthy(); }); - //check if the the generated plugin works successfully + // Check if the the generated plugin works successfully + stdout = run(__dirname, ['--config', './test-plugin/examples/simple/webpack.config.js'], false).stdout; + expect(stdout).toContain('Hello World!'); + }); + + it('should scaffold plugin template in the specified path', async () => { + let { stdout } = await runPromptWithAnswers(__dirname, ['plugin', 'test-assets'], [ENTER]); + + expect(stripAnsi(stdout)).toContain(firstPrompt); + + // Check if the output directory exists with the appropriate plugin name + expect(existsSync(customPluginPath)).toBeTruthy(); + + // Skip test in case installation fails + if (!existsSync(resolve(customPluginPath, './yarn.lock'))) { + return; + } + + // Test regressively files are scaffolded + const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; + + files.forEach((file) => { + expect(existsSync(join(customPluginPath, file))).toBeTruthy(); + }); + + // Check if the the generated plugin works successfully stdout = run(__dirname, ['--config', './test-plugin/examples/simple/webpack.config.js'], false).stdout; expect(stdout).toContain('Hello World!'); }); From 56f7c261605c0767e2e52eeac0db6d63bcd8c3a6 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 9 Nov 2020 16:38:29 +0530 Subject: [PATCH 061/581] tests: add more cases for core-flags tests (#2045) --- test/core-flags/entry-reset-flag.test.js | 8 ++++++ test/core-flags/externals-flags.test.js | 27 ++++++++++++++++++- .../core-flags/infrastructure-logging.test.js | 2 +- test/core-flags/parallelism-flag.test.js | 8 ++++++ test/target/flag-test/target-flag.test.js | 16 +++++++++++ test/target/flag-test/webpack.config.js | 1 + 6 files changed, 60 insertions(+), 2 deletions(-) diff --git a/test/core-flags/entry-reset-flag.test.js b/test/core-flags/entry-reset-flag.test.js index 07818863adc..545d57e6ba6 100644 --- a/test/core-flags/entry-reset-flag.test.js +++ b/test/core-flags/entry-reset-flag.test.js @@ -11,4 +11,12 @@ describe('--entry-reset flag', () => { expect(stdout).toContain('src/entry.js'); expect(stdout).not.toContain('src/main.js'); }); + + it('should throw error if entry is an empty array', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--entry-reset']); + + expect(stderr).toContain('Invalid configuration object'); + expect(exitCode).toBe(2); + expect(stdout).toBeFalsy(); + }); }); diff --git a/test/core-flags/externals-flags.test.js b/test/core-flags/externals-flags.test.js index 83dafd5fc76..7d6e8d5dbff 100644 --- a/test/core-flags/externals-flags.test.js +++ b/test/core-flags/externals-flags.test.js @@ -1,6 +1,9 @@ 'use strict'; -const { run } = require('../utils/test-utils'); +const { run, hyphenToUpperCase } = require('../utils/test-utils'); +const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); + +const externalsPresetsFlags = flagsFromCore.filter(({ name }) => name.startsWith('externals-presets-')); describe('externals related flag', () => { it('should set externals properly', () => { @@ -34,4 +37,26 @@ describe('externals related flag', () => { expect(exitCode).toBe(0); expect(stdout).toContain(`externals: []`); }); + + externalsPresetsFlags.forEach((flag) => { + // extract property name from flag name + const property = flag.name.split('externals-presets-')[1]; + const propName = hyphenToUpperCase(property); + + it(`should config --${flag.name} correctly`, () => { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stdout).toContain(`${propName}: true`); + }); + + it(`should config --no-${flag.name} correctly`, () => { + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stdout).toContain(`${propName}: false`); + }); + }); }); diff --git a/test/core-flags/infrastructure-logging.test.js b/test/core-flags/infrastructure-logging.test.js index 3c2c0e9b3c8..8bebd29d056 100644 --- a/test/core-flags/infrastructure-logging.test.js +++ b/test/core-flags/infrastructure-logging.test.js @@ -2,7 +2,7 @@ const { run } = require('../utils/test-utils'); -describe('externals related flag', () => { +describe('infrastructure logging related flag', () => { it('should set infrastructureLogging.debug properly', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']); diff --git a/test/core-flags/parallelism-flag.test.js b/test/core-flags/parallelism-flag.test.js index 9c0d1ee7eea..7f2a8bcce38 100644 --- a/test/core-flags/parallelism-flag.test.js +++ b/test/core-flags/parallelism-flag.test.js @@ -10,4 +10,12 @@ describe('--parallelism flag', () => { expect(exitCode).toBe(0); expect(stdout).toContain('parallelism: 50'); }); + + it('should throw error for invalid parallelism value', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--parallelism', '0']); + + expect(stderr).toContain('configuration.parallelism should be >= 1'); + expect(exitCode).toBe(2); + expect(stdout).toBeFalsy(); + }); }); diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index 23b01983600..cf7b7f6cf37 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -63,5 +63,21 @@ describe('--target flag', () => { expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: [ 'node', 'async-node' ]`); }); + + it('should reset target from node to async-node with --target-reset', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--target-reset', '--target', 'async-node']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`target: [ 'async-node' ]`); + }); + + it('should throw error if target is an empty array', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--target-reset']); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Invalid configuration object'); + expect(stdout).toBeFalsy(); + }); } }); diff --git a/test/target/flag-test/webpack.config.js b/test/target/flag-test/webpack.config.js index 5d1850d0c36..5b0174c6daa 100644 --- a/test/target/flag-test/webpack.config.js +++ b/test/target/flag-test/webpack.config.js @@ -3,5 +3,6 @@ const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); module.exports = { entry: './index.js', mode: 'production', + target: 'node', plugins: [new WebpackCLITestPlugin()], }; From bb11f195dc14338ef45b646953bcfc7e0cdc2a6d Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 9 Nov 2020 16:38:36 +0530 Subject: [PATCH 062/581] fix: use content hash for css assets in init-generator (#2071) --- .../__tests__/__snapshots__/init-generator.test.ts.snap | 2 +- packages/generators/src/init-generator.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index fe0ae1fbe63..f170c890108 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -128,7 +128,7 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new MiniCssExtractPlugin({ filename:'main.[chunkhash].css' })", + "new MiniCssExtractPlugin({ filename:'main.[contenthash].css' })", ], } `; diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 002007b1f70..b1110c8dd7d 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -179,8 +179,7 @@ export default class InitGenerator extends CustomGenerator { ); if (cssBundleName.length !== 0) { (this.configuration.config.webpackOptions.plugins as string[]).push( - // TODO: use [contenthash] after it is supported - `new MiniCssExtractPlugin({ filename:'${cssBundleName}.[chunkhash].css' })`, + `new MiniCssExtractPlugin({ filename:'${cssBundleName}.[contenthash].css' })`, ); } else { (this.configuration.config.webpackOptions.plugins as string[]).push( From cd567127fe3651a9a7d0bc21cf79ae4a78c0e3c4 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 9 Nov 2020 17:17:42 +0530 Subject: [PATCH 063/581] docs: update --env & --target types (#2064) --- packages/webpack-cli/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 258f7f14c80..0657e6ea251 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -52,11 +52,11 @@ yarn add webpack-cli --dev --progress string, boolean Print compilation progress during build --color Enables colors on console --no-color Disable colors on console - --env string Environment passed to the configuration when it is a function + --env string[] Environment passed to the configuration when it is a function --name string Name of the configuration. Used when loading multiple configurations --help Outputs list of supported flags -o, --output-path string Output location of the generated bundle - -t, --target string Sets the build target + -t, --target string[] Sets the build target -w, --watch Watch for files changes -h, --hot Enables Hot Module Replacement --no-hot Disables Hot Module Replacement From 2f375388e3cd12e376a12dbfc7a383b80ec35ce8 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 19:17:11 +0530 Subject: [PATCH 064/581] tests: add test case for supplying relative path (#2082) --- test/plugin/plugin.test.js | 44 ++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/test/plugin/plugin.test.js b/test/plugin/plugin.test.js index 6b98e27a426..ac41d218dd6 100644 --- a/test/plugin/plugin.test.js +++ b/test/plugin/plugin.test.js @@ -1,18 +1,22 @@ -const { existsSync } = require('fs'); +const { existsSync, mkdirSync } = require('fs'); const { join, resolve } = require('path'); const rimraf = require('rimraf'); const stripAnsi = require('strip-ansi'); const { run, runPromptWithAnswers } = require('../utils/test-utils'); + const ENTER = '\x0D'; + const firstPrompt = '? Plugin name'; const pluginName = 'test-plugin'; + const pluginPath = join(__dirname, pluginName); -const customPluginPath = join(__dirname, 'test-assets', 'my-webpack-plugin'); +const genPath = join(__dirname, 'test-assets'); +const customPluginPath = join(genPath, pluginName); describe('plugin command', () => { - beforeAll(() => { + beforeEach(() => { rimraf.sync(pluginPath); - rimraf.sync(customPluginPath); + rimraf.sync(genPath); }); it('should ask the plugin name when invoked', () => { @@ -48,7 +52,7 @@ describe('plugin command', () => { }); it('should scaffold plugin template in the specified path', async () => { - let { stdout } = await runPromptWithAnswers(__dirname, ['plugin', 'test-assets'], [ENTER]); + let { stdout } = await runPromptWithAnswers(__dirname, ['plugin', 'test-assets'], [`${pluginName}${ENTER}`]); expect(stripAnsi(stdout)).toContain(firstPrompt); @@ -68,7 +72,35 @@ describe('plugin command', () => { }); // Check if the the generated plugin works successfully - stdout = run(__dirname, ['--config', './test-plugin/examples/simple/webpack.config.js'], false).stdout; + stdout = run(customPluginPath, ['--config', './examples/simple/webpack.config.js'], false).stdout; + expect(stdout).toContain('Hello World!'); + }); + + it('should scaffold plugin template in the current directory', async () => { + // Create test-assets directory + mkdirSync(genPath); + + let { stdout } = await runPromptWithAnswers(genPath, ['plugin', './'], [`${pluginName}${ENTER}`]); + + expect(stripAnsi(stdout)).toContain(firstPrompt); + + // Check if the output directory exists with the appropriate plugin name + expect(existsSync(customPluginPath)).toBeTruthy(); + + // Skip test in case installation fails + if (!existsSync(resolve(customPluginPath, './yarn.lock'))) { + return; + } + + // Test regressively files are scaffolded + const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; + + files.forEach((file) => { + expect(existsSync(join(customPluginPath, file))).toBeTruthy(); + }); + + // Check if the the generated plugin works successfully + stdout = run(customPluginPath, ['--config', './examples/simple/webpack.config.js'], false).stdout; expect(stdout).toContain('Hello World!'); }); }); From d68705007fde5956e060d52ed306f8c0e2c664fc Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 19:17:22 +0530 Subject: [PATCH 065/581] tests: add test case for supplying relative path (#2083) --- .../init-generation-path.test.js | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/test/init/generation-path/init-generation-path.test.js b/test/init/generation-path/init-generation-path.test.js index 5d4712b04ac..87c0734e50e 100644 --- a/test/init/generation-path/init-generation-path.test.js +++ b/test/init/generation-path/init-generation-path.test.js @@ -10,7 +10,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const genPath = join(__dirname, 'test-assets'); describe('init generate-path flag', () => { - beforeAll(() => { + beforeEach(() => { rimraf.sync(genPath); }); @@ -42,4 +42,36 @@ describe('init generate-path flag', () => { }; expect(pkgJsonTests).not.toThrow(); }); + + it('should scaffold in the current directory', () => { + // Create test-assets directory + fs.mkdirSync(genPath); + + const { stdout } = run(genPath, ['init', '--generation-path', './', '--auto'], false); + // Test no prompts are present + expect(stdout).toBeTruthy(); + expect(stdout).not.toContain(firstPrompt); + + // Skip test in case installation fails + if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { + return; + } + + // Test regressively files are scaffolded + const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; + + files.forEach((file) => { + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); + }); + + // Check package json is correctly configured + const pkgJsonTests = () => { + const pkgJson = require(join(genPath, './package.json')); + expect(pkgJson).toBeTruthy(); + expect(pkgJson['devDependencies']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + }; + expect(pkgJsonTests).not.toThrow(); + }); }); From 112068dc5b962a773c5db00e4e1140e8733ea9ec Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 19:32:46 +0530 Subject: [PATCH 066/581] fix: remove duplicate log (#2079) --- packages/utils/src/modify-config-helper.ts | 8 +------- test/init/auto/init-auto.test.js | 6 ++++++ test/init/force/init-force.test.js | 6 ++++++ test/init/generator/init-inquirer.test.js | 6 ++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/utils/src/modify-config-helper.ts b/packages/utils/src/modify-config-helper.ts index a5ea55a48db..9af8b1862e9 100644 --- a/packages/utils/src/modify-config-helper.ts +++ b/packages/utils/src/modify-config-helper.ts @@ -1,4 +1,3 @@ -import { green } from 'colorette'; import fs from 'fs'; import path from 'path'; import yeoman from 'yeoman-environment'; @@ -6,7 +5,7 @@ import Generator from 'yeoman-generator'; import { runTransform } from './scaffold'; import { utils } from 'webpack-cli'; -const { logger, getPackageManager } = utils; +const { logger } = utils; export interface Config extends Object { item?: { @@ -141,11 +140,6 @@ export function modifyHelperUtil( }, finalConfig, ) as TransformConfig; - if (finalConfig.usingDefaults && finalConfig.usingDefaults === true) { - const runCommand = getPackageManager() === 'yarn' ? 'yarn build' : 'npm run build'; - - logger.log(`\nYou can now run ${green(runCommand)} to bundle your application!\n`); - } // scaffold webpack config file from using .yo-rc.json return runTransform(transformConfig, 'init', generateConfig, generationPath); diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 11705a3d38c..4cfebb86c95 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -1,5 +1,6 @@ 'use strict'; +const { green } = require('colorette'); const fs = require('fs'); const rimraf = require('rimraf'); const { join, resolve } = require('path'); @@ -8,6 +9,8 @@ const { run } = require('../../utils/test-utils'); const firstPrompt = 'Will your application have multiple bundles?'; const genPath = join(__dirname, 'test-assets'); +const successLog = `You can now run ${green('yarn build')} to bundle your application!`; + describe('init auto flag', () => { beforeAll(() => { rimraf.sync(genPath); @@ -48,5 +51,8 @@ describe('init auto flag', () => { expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); + + // Check we are not logging twice + expect(stdout.split(successLog).length - 1).toBe(1); }); }); diff --git a/test/init/force/init-force.test.js b/test/init/force/init-force.test.js index 90060387ea1..98f7aea1fbe 100644 --- a/test/init/force/init-force.test.js +++ b/test/init/force/init-force.test.js @@ -1,5 +1,6 @@ 'use strict'; +const { green } = require('colorette'); const fs = require('fs'); const { join, resolve } = require('path'); const rimraf = require('rimraf'); @@ -9,6 +10,8 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = join(__dirname, 'test-assets'); +const successLog = `You can now run ${green('yarn build')} to bundle your application!`; + describe('init force flag', () => { beforeAll(() => { rimraf.sync(genPath); @@ -42,5 +45,8 @@ describe('init force flag', () => { expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); + + // Check we are not logging twice + expect(stdout.split(successLog).length - 1).toBe(1); }); }); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 27af589ee4b..edd95a1f230 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -1,5 +1,6 @@ 'use strict'; +const { green } = require('colorette'); const fs = require('fs'); const { join, resolve } = require('path'); const rimraf = require('rimraf'); @@ -9,6 +10,8 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = join(__dirname, 'test-assets'); +const successLog = `You can now run ${green('yarn build')} to bundle your application!`; + describe('init', () => { beforeAll(() => { rimraf.sync(genPath); @@ -42,5 +45,8 @@ describe('init', () => { expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); + + // Check we are not logging twice + expect(stdout.split(successLog).length - 1).toBe(1); }); }); From c1aaa808701f3208c06322e51ce310dececa37d1 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 9 Nov 2020 20:15:27 +0530 Subject: [PATCH 067/581] docs: add --generation-path for init (#2085) --- INIT.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/INIT.md b/INIT.md index 54c8882cd9a..8cf285c332b 100644 --- a/INIT.md +++ b/INIT.md @@ -87,6 +87,12 @@ webpack-cli init --auto webpack-cli init --force ``` +**To scaffold in a specified path** + +```bash +webpack-cli init --generation-path [path] +``` + **Via custom scaffold** ```bash From 65e6b744610a237070b15548e4aa01c55c780ea0 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 20:17:17 +0530 Subject: [PATCH 068/581] feat: display options as part of help info (#2084) --- packages/webpack-cli/lib/utils/cli-flags.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 057f308fcc3..4d0120f817b 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -14,6 +14,23 @@ const commands = [ type: String, usage: 'init [scaffold]', description: 'Initialize a new webpack configuration', + flags: [ + { + name: 'auto', + type: Boolean, + description: 'To generate default config', + }, + { + name: 'force', + type: Boolean, + description: 'To force config generation', + }, + { + name: 'generation-path', + type: String, + description: 'To scaffold in a specified path', + }, + ], }, { name: 'migrate', From 2c159ad230cc9cc764edb7c34982304276b7f4f2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 9 Nov 2020 20:20:48 +0530 Subject: [PATCH 069/581] tests: enable tests for generators (#2063) --- packages/generators/__tests__/addon-generator.test.ts | 7 ++----- .../generators/__tests__/utils/languageSupport.test.ts | 3 +-- packages/generators/__tests__/utils/styleSupport.test.ts | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/generators/__tests__/addon-generator.test.ts b/packages/generators/__tests__/addon-generator.test.ts index 5c67838f3d7..92f108e6fc4 100644 --- a/packages/generators/__tests__/addon-generator.test.ts +++ b/packages/generators/__tests__/addon-generator.test.ts @@ -1,6 +1,4 @@ -jest.setMock('@webpack-cli/utils', { - getPackageManager: jest.fn(), -}); +jest.mock('webpack-cli/lib/utils/get-package-manager', () => jest.fn()); import fs from 'fs'; import path from 'path'; @@ -10,8 +8,7 @@ import addonGenerator from '../src/addon-generator'; const { getPackageManager } = utils; -// TODO: enable after jest release -describe.skip('addon generator', () => { +describe('addon generator', () => { let gen, installMock, packageMock; const genName = 'test-addon'; const testAssetsPath = path.join(__dirname, 'test-assets'); diff --git a/packages/generators/__tests__/utils/languageSupport.test.ts b/packages/generators/__tests__/utils/languageSupport.test.ts index 858eef018cf..a70a7c5b611 100644 --- a/packages/generators/__tests__/utils/languageSupport.test.ts +++ b/packages/generators/__tests__/utils/languageSupport.test.ts @@ -1,8 +1,7 @@ import language, { LangType, getBabelLoader, getTypescriptLoader } from '../../lib/utils/languageSupport'; import { CustomGenerator } from '../../lib/types'; -// TODO: enable after jest release -describe.skip('languageSupport', () => { +describe('languageSupport', () => { const getMockGenerator = (): CustomGenerator => { const gen = new CustomGenerator(null, null); gen.entryOption = "'./path/to/index.js'"; diff --git a/packages/generators/__tests__/utils/styleSupport.test.ts b/packages/generators/__tests__/utils/styleSupport.test.ts index 550b95a9ebb..4864771e554 100644 --- a/packages/generators/__tests__/utils/styleSupport.test.ts +++ b/packages/generators/__tests__/utils/styleSupport.test.ts @@ -1,8 +1,7 @@ import style, { StylingType } from '../../lib/utils/styleSupport'; import { CustomGenerator } from '../../lib/types'; -// TODO: enable after jest release -describe.skip('styleSupport', () => { +describe('styleSupport', () => { const getMockGenerator = (): CustomGenerator => { const gen = new CustomGenerator(null, null); gen.dependencies = []; From cd09f85e0e8247fcafcc5592dd2d272a2f9cd543 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 20:25:01 +0530 Subject: [PATCH 070/581] feat(generate-loader): scaffold in a specified path (#2072) * feat: add the ability to specify a path for scaffolding * tests: add test case for scaffolding in a specified path * docs: update usage info * tests: add test case for supplying relative path --- packages/generate-loader/README.md | 8 ++- packages/generate-loader/src/index.ts | 5 +- test/loader/loader.test.js | 72 ++++++++++++++++++++++++--- 3 files changed, 75 insertions(+), 10 deletions(-) diff --git a/packages/generate-loader/README.md b/packages/generate-loader/README.md index 8f23e52343c..8d719e8062a 100644 --- a/packages/generate-loader/README.md +++ b/packages/generate-loader/README.md @@ -27,7 +27,13 @@ generateLoader(); ### CLI (via `webpack-cli`) ```bash -npx webpack-cli generate-loader +npx webpack-cli loader +``` + +> Optionally specify a path for generating the loader template. + +```bash +npx webpack-cli loader [path] ``` [downloads]: https://img.shields.io/npm/dm/@webpack-cli/generate-loader.svg diff --git a/packages/generate-loader/src/index.ts b/packages/generate-loader/src/index.ts index ee7a7a6fa63..599d39abf6d 100644 --- a/packages/generate-loader/src/index.ts +++ b/packages/generate-loader/src/index.ts @@ -9,8 +9,9 @@ const { logger } = utils; * @returns {void} */ -export default function loaderCreator(): void { - const env = yeoman.createEnv(); +export default function loaderCreator(...args: string[]): void { + const generationPath = args[0]; + const env = yeoman.createEnv([], { cwd: generationPath }); const generatorName = 'webpack-loader-generator'; env.registerStub(loaderGenerator, generatorName); diff --git a/test/loader/loader.test.js b/test/loader/loader.test.js index 239e69247d2..bf1638a239d 100644 --- a/test/loader/loader.test.js +++ b/test/loader/loader.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { existsSync } = require('fs'); +const { existsSync, mkdirSync } = require('fs'); const { join, resolve } = require('path'); const rimraf = require('rimraf'); const stripAnsi = require('strip-ansi'); @@ -10,13 +10,16 @@ const firstPrompt = '? Loader name (my-loader)'; const ENTER = '\x0D'; const loaderName = 'test-loader'; const loaderPath = join(__dirname, loaderName); +const genPath = join(__dirname, 'test-assets'); +const customLoaderPath = join(genPath, loaderName); describe('loader command', () => { - beforeAll(() => { + beforeEach(() => { rimraf.sync(loaderPath); + rimraf.sync(genPath); }); - it('Should ask the loader name when invoked', () => { + it('should ask the loader name when invoked', () => { const { stdout, stderr } = run(__dirname, ['loader'], false); expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); @@ -33,19 +36,74 @@ describe('loader command', () => { return; } - // check if the output directory exists with the appropriate loader name - expect(existsSync(join(__dirname, loaderName))).toBeTruthy(); + // Check if the output directory exists with the appropriate loader name + expect(existsSync(loaderPath)).toBeTruthy(); // All test files are scaffolded const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; files.forEach((file) => { - expect(existsSync(join(__dirname, `${loaderName}/${file}`))).toBeTruthy(); + expect(existsSync(loaderPath, file)).toBeTruthy(); }); - //check if the the generated plugin works successfully + // Check if the the generated loader works successfully const path = resolve(__dirname, './test-loader/examples/simple/'); ({ stdout } = run(path, [], false)); expect(stdout).toContain('test-loader'); }); + + it('should scaffold loader template in the specified path', async () => { + let { stdout } = await runPromptWithAnswers(__dirname, ['loader', 'test-assets'], [`${loaderName}${ENTER}`]); + + expect(stripAnsi(stdout)).toContain(firstPrompt); + + // Skip test in case installation fails + if (!existsSync(resolve(customLoaderPath, './yarn.lock'))) { + return; + } + + // Check if the output directory exists with the appropriate loader name + expect(existsSync(customLoaderPath)).toBeTruthy(); + + // All test files are scaffolded + const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; + + files.forEach((file) => { + expect(existsSync(customLoaderPath, file)).toBeTruthy(); + }); + + // Check if the the generated loader works successfully + const path = resolve(customLoaderPath, './examples/simple/'); + ({ stdout } = run(path, [], false)); + expect(stdout).toContain('test-loader'); + }); + + it('should scaffold loader template in the current directory', async () => { + // Create test-assets directory + mkdirSync(genPath); + + let { stdout } = await runPromptWithAnswers(genPath, ['loader', './'], [`${loaderName}${ENTER}`]); + + expect(stripAnsi(stdout)).toContain(firstPrompt); + + // Skip test in case installation fails + if (!existsSync(resolve(customLoaderPath, './yarn.lock'))) { + return; + } + + // Check if the output directory exists with the appropriate loader name + expect(existsSync(customLoaderPath)).toBeTruthy(); + + // All test files are scaffolded + const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; + + files.forEach((file) => { + expect(existsSync(customLoaderPath, file)).toBeTruthy(); + }); + + // Check if the the generated loader works successfully + const path = resolve(customLoaderPath, './examples/simple/'); + ({ stdout } = run(path, [], false)); + expect(stdout).toContain('test-loader'); + }); }); From 3965dcb49a6dc751962248d8f0c1229593774a58 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 9 Nov 2020 23:52:52 +0530 Subject: [PATCH 071/581] chore: update usage info for subcommands (#2086) --- packages/webpack-cli/lib/utils/cli-flags.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 4d0120f817b..9da24fd3a1c 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -12,7 +12,7 @@ const commands = [ name: 'init', alias: 'c', type: String, - usage: 'init [scaffold]', + usage: 'init [scaffold] [options]', description: 'Initialize a new webpack configuration', flags: [ { @@ -44,7 +44,7 @@ const commands = [ scope: 'external', alias: 'l', type: String, - usage: 'loader', + usage: 'loader [path]', description: 'Scaffold a loader repository', }, { @@ -52,7 +52,7 @@ const commands = [ alias: 'p', scope: 'external', type: String, - usage: 'plugin', + usage: 'plugin [path]', description: 'Scaffold a plugin repository', }, { @@ -80,7 +80,7 @@ const commands = [ alias: 's', scope: 'external', type: String, - usage: 'serve', + usage: 'serve [options]', description: 'Run the webpack Dev Server', }, ]; From 09bd8126e95c9675b1f6862451f629cd4c439adb Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 10 Nov 2020 01:48:58 +0530 Subject: [PATCH 072/581] fix: resplect `color`/`--no-color` arguments (#2042) --- .../__snapshots__/parseArgs.test.ts.snap | 2 - packages/webpack-cli/lib/bootstrap.js | 6 ++ packages/webpack-cli/lib/utils/cli-flags.js | 1 - packages/webpack-cli/lib/webpack-cli.js | 20 ++++++- test/colors/colors.test.js | 55 ++++++++++++++++++- test/colors/multiple-configs.js | 12 ++++ test/colors/src/first.js | 1 + test/colors/src/second.js | 1 + .../function-with-argv.test.js | 2 +- test/json/json.test.js | 49 +++++++++++++++-- test/unknown/unknown.test.js | 21 ++++++- 11 files changed, 157 insertions(+), 13 deletions(-) create mode 100644 test/colors/multiple-configs.js create mode 100644 test/colors/src/first.js create mode 100644 test/colors/src/second.js diff --git a/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap b/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap index ed8b7e3084c..1a5efa72526 100644 --- a/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap +++ b/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap @@ -10,7 +10,6 @@ Object { "serveIndex": true, }, "webpackArgs": Object { - "color": true, "env": Object { "WEBPACK_SERVE": true, }, @@ -41,7 +40,6 @@ Object { "serveIndex": true, }, "webpackArgs": Object { - "color": true, "env": Object { "WEBPACK_SERVE": true, }, diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index b6fc82879c6..6ff74f315cf 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -4,6 +4,7 @@ const logger = require('./utils/logger'); const { isCommandUsed } = require('./utils/arg-utils'); const argParser = require('./utils/arg-parser'); const leven = require('leven'); +const { options: coloretteOptions } = require('colorette'); process.title = 'webpack-cli'; @@ -23,6 +24,11 @@ const runCLI = async (cliArgs) => { // If the unknown arg starts with a '-', it will be considered an unknown flag rather than an entry let entry; + // enable/disable colors + if (typeof parsedArgs.opts.color !== 'undefined') { + coloretteOptions.enabled = Boolean(parsedArgs.opts.color); + } + if (parsedArgs.unknownArgs.length > 0) { entry = []; diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 9da24fd3a1c..80ab6021e11 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -109,7 +109,6 @@ const core = [ usage: '--color', type: Boolean, negative: true, - defaultValue: true, description: 'Enable/Disable colors on console', }, { diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index ab8c9d64373..0377f77f993 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -47,9 +47,9 @@ class WebpackCLI { } async resolveArgs(args, configOptions = {}) { - // Since color flag has a default value, when there are no other args then exit + // when there are no args then exit // eslint-disable-next-line no-prototype-builtins - if (Object.keys(args).length === 1 && args.hasOwnProperty('color') && !process.env.NODE_ENV) return {}; + if (Object.keys(args).length === 0 && !process.env.NODE_ENV) return {}; const { outputPath, stats, json, mode, target, prefetch, hot, analyze } = args; const finalOptions = { @@ -367,7 +367,21 @@ class WebpackCLI { } } - stats.colors = typeof stats.colors !== 'undefined' ? stats.colors : coloretteOptions.enabled; + let colors; + // From flags + if (typeof args.color !== 'undefined') { + colors = args.color; + } + // From stats + else if (typeof stats.colors !== 'undefined') { + colors = stats.colors; + } + // Default + else { + colors = coloretteOptions.enabled; + } + + stats.colors = colors; return stats; }; diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 4bc9e30fbfb..946f54ce8fa 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -43,6 +43,25 @@ describe('colorts', () => { expect(exitCode).toBe(0); }); + it('should disable colored output with --no-color', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--no-color']); + + expect(stderr).toBeFalsy(); + const output = isWebpack5 ? 'successfully' : 'main.js'; + expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); + expect(stdout).toContain(output); + expect(exitCode).toBe(0); + }); + + it('should work with the "stats" option and --color flags', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--color']); + + expect(stderr).toBeFalsy(); + const output = isWebpack5 ? 'successfully' : 'main.js'; + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); + expect(exitCode).toBe(0); + }); + it('should work with the "stats" option from the configuration', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js']); @@ -84,9 +103,43 @@ describe('colorts', () => { expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - console.log(stdout); + expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); expect(exitCode).toBe(0); }); + + it('should prioritize --color over colors in config', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js', '--color']); + + expect(stderr).toBeFalsy(); + const output = isWebpack5 ? 'successfully' : 'main.js'; + + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); + expect(exitCode).toBe(0); + }); + + it('should prioratize --no-color over colors in config', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js', '--no-color']); + + expect(stderr).toBeFalsy(); + const output = isWebpack5 ? 'successfully' : 'main.js'; + + expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); + expect(stdout).toContain(output); + expect(exitCode).toBe(0); + }); + + it('should work in multicompiler mode', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--config=multiple-configs.js', '--color']); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + + if (isWebpack5) { + expect(stdout).toContain(`\u001b[1mfirst-config`); + expect(stdout).toContain(`\u001b[1msecond-config`); + expect(stdout).toContain(`\u001b[1m\u001b[32msuccessfully\u001b[39m\u001b[22m`); + } + }); }); diff --git a/test/colors/multiple-configs.js b/test/colors/multiple-configs.js new file mode 100644 index 00000000000..b175991ac4d --- /dev/null +++ b/test/colors/multiple-configs.js @@ -0,0 +1,12 @@ +module.exports = [ + { + name: 'first-config', + entry: './src/first.js', + stats: 'normal', + }, + { + name: 'second-config', + entry: './src/second.js', + stats: 'normal', + }, +]; diff --git a/test/colors/src/first.js b/test/colors/src/first.js new file mode 100644 index 00000000000..e5ba023838e --- /dev/null +++ b/test/colors/src/first.js @@ -0,0 +1 @@ +console.log('first'); diff --git a/test/colors/src/second.js b/test/colors/src/second.js new file mode 100644 index 00000000000..e1595dffb00 --- /dev/null +++ b/test/colors/src/second.js @@ -0,0 +1 @@ +console.log('second'); diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index 26d7cb94240..efbb0e2b33c 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -9,7 +9,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); - expect(stdout).toContain("argv: { color: true, mode: 'development' }"); + expect(stdout).toContain("argv: { mode: 'development' }"); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './dist/dev.js'))).toBeTruthy(); }); diff --git a/test/json/json.test.js b/test/json/json.test.js index a248412bc0d..a389356e7cc 100644 --- a/test/json/json.test.js +++ b/test/json/json.test.js @@ -3,20 +3,20 @@ const { run } = require('../utils/test-utils'); const { stat, readFile } = require('fs'); const { resolve } = require('path'); +const successMessage = 'stats are successfully stored as json to stats.json'; + describe('json flag', () => { it('should return valid json', () => { const { stdout, exitCode } = run(__dirname, ['--json']); - expect(() => JSON.parse(stdout)).not.toThrow(); expect(exitCode).toBe(0); - expect(JSON.parse(stdout)['hash']).toBeDefined(); }); it('should store json to a file', (done) => { const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json']); - expect(stdout).toContain('stats are successfully stored as json to stats.json'); + expect(stdout).toContain(successMessage); expect(exitCode).toBe(0); stat(resolve(__dirname, './stats.json'), (err, stats) => { @@ -34,11 +34,52 @@ describe('json flag', () => { }); }); + it('should store json to a file and respect --color flag', (done) => { + const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json', '--color']); + + expect(stdout).toContain(`[webpack-cli] \u001b[32m${successMessage}`); + expect(exitCode).toBe(0); + + stat(resolve(__dirname, './stats.json'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { + expect(err).toBe(null); + expect(JSON.parse(data)['hash']).toBeTruthy(); + expect(JSON.parse(data)['version']).toBeTruthy(); + expect(JSON.parse(data)['time']).toBeTruthy(); + expect(() => JSON.parse(data)).not.toThrow(); + done(); + }); + }); + }); + + it('should store json to a file and respect --no-color', (done) => { + const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json', '--no-color']); + + expect(stdout).not.toContain(`[webpack-cli] \u001b[32m${successMessage}`); + expect(stdout).toContain(`[webpack-cli] ${successMessage}`); + expect(exitCode).toBe(0); + + stat(resolve(__dirname, './stats.json'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { + expect(err).toBe(null); + expect(JSON.parse(data)['hash']).toBeTruthy(); + expect(JSON.parse(data)['version']).toBeTruthy(); + expect(JSON.parse(data)['time']).toBeTruthy(); + expect(() => JSON.parse(data)).not.toThrow(); + done(); + }); + }); + }); + it('should return valid json with -j alias', () => { const { stdout, exitCode } = run(__dirname, ['-j']); expect(() => JSON.parse(stdout)).not.toThrow(); expect(exitCode).toBe(0); - expect(JSON.parse(stdout)['hash']).toBeDefined(); }); }); diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index 903122b2495..8a35f1dd749 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -1,12 +1,31 @@ const { run } = require('../utils/test-utils'); +const unknownError = 'Unknown argument: --unknown'; + describe('unknown behaviour', () => { - it('warns the user if an unknown flag is passed in', () => { + it('throws error if an unknown flag is passed in', () => { const { stderr, exitCode } = run(__dirname, ['--unknown']); expect(stderr).toBeTruthy(); expect(stderr).toContain('Unknown argument: --unknown'); + expect(stderr).toContain(unknownError); + expect(exitCode).toBe(2); + }); + + it('should throw error and respect --color flag', () => { + const { stderr, exitCode } = run(__dirname, ['--unknown', '--color']); + expect(stderr).toBeTruthy(); + expect(stderr).toContain(`[webpack-cli] \u001b[31m${unknownError}`); expect(exitCode).toBe(2); }); + + it('throws error for unknow flag and respect --no-color', () => { + const { stderr, exitCode } = run(__dirname, ['--unknown', '--no-color']); + expect(stderr).toBeTruthy(); + expect(stderr).not.toContain(`[webpack-cli] \u001b[31m${unknownError}`); + expect(stderr).toContain(unknownError); + expect(exitCode).toBe(2); + }); + it('suggests the closest match to an unknown flag', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--entyr', './a.js']); expect(stderr).toContain('Unknown argument: --entyr'); From 195810c7aec6ee83c4ac3e570ad580a194696c8b Mon Sep 17 00:00:00 2001 From: James George Date: Tue, 10 Nov 2020 16:47:08 +0530 Subject: [PATCH 073/581] docs: update reference to subcommands (#2093) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82712688d96..010c86a7683 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ Thus, webpack CLI provides different commands for many common tasks. - [`webpack-cli init`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration. - [`webpack-cli info`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment. - [`webpack-cli migrate`](./packages/migrate/README.md#webpack-cli-migrate) - Migrate project from one version to another. -- [`webpack-cli generate-plugin`](./packages/generate-plugin/README.md#webpack-cli-generate-plugin) - Initiate new plugin project. -- [`webpack-cli generate-loader`](./packages/generate-loader/README.md#webpack-cli-generate-loader) - Initiate new loader project. +- [`webpack-cli plugin`](./packages/generate-plugin/README.md#webpack-cli-generate-plugin) - Initiate new plugin project. +- [`webpack-cli loader`](./packages/generate-loader/README.md#webpack-cli-generate-loader) - Initiate new loader project. - [`webpack-cli serve`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading. > Removed commands since v3.3.3 From c87cf690585f1827ba7d508cd434728bfda7a41f Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 10 Nov 2020 17:39:24 +0530 Subject: [PATCH 074/581] docs: add configuration.ignoreWarnings related flags (#2088) --- packages/webpack-cli/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 0657e6ea251..1d8cb691433 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -136,6 +136,11 @@ yarn add webpack-cli --dev `output.libraryTarget`. --externals-type string Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value). + --ignore-warnings string[] A RegExp to select the warning message. + --ignore-warnings-file string[] A RegExp to select the origin file for the warning. + --ignore-warnings-message string[] A RegExp to select the warning message. + --ignore-warnings-module string[] A RegExp to select the origin module for the warning. + --ignore-warnings-reset Clear all items provided in configuration. Ignore specific warnings. --infrastructure-logging-debug string[] Enable/Disable debug logging for all loggers. Enable debug logging for specific loggers. --infrastructure-logging-debug-reset Clear all items provided in configuration. Enable debug logging for specific From 2ae99c2a878d785e0959bb59e7dee90386b02c39 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 10 Nov 2020 17:39:36 +0530 Subject: [PATCH 075/581] tests: fix (#2092) --- test/env/array/array-env.test.js | 12 +++++++----- test/env/array/webpack.config.js | 4 ++-- test/env/object/object-env.test.js | 10 ++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/test/env/array/array-env.test.js b/test/env/array/array-env.test.js index 2b4f7b4ba1c..90c3707162d 100644 --- a/test/env/array/array-env.test.js +++ b/test/env/array/array-env.test.js @@ -4,7 +4,7 @@ const path = require('path'); const execa = require('execa'); const { sync: spawnSync } = execa; -const { run } = require('../../utils/test-utils'); +const { run, isWebpack5 } = require('../../utils/test-utils'); const devFile = path.join(__dirname, './bin/dev.js'); const prodFile = path.join(__dirname, './bin/prod.js'); @@ -17,10 +17,12 @@ describe('env array', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - const devScript = spawnSync('node', [devFile]); - const prodScript = spawnSync('node', [prodFile]); + if (isWebpack5) { + const devScript = spawnSync('node', [devFile]); + const prodScript = spawnSync('node', [prodFile]); - expect(devScript.stdout).toBe('environment is development'); - expect(prodScript.stdout).toBe('environment is production'); + expect(devScript.stdout).toBe('environment is development'); + expect(prodScript.stdout).toBe('environment is production'); + } }); }); diff --git a/test/env/array/webpack.config.js b/test/env/array/webpack.config.js index 013ab0a133b..ec67e7da042 100644 --- a/test/env/array/webpack.config.js +++ b/test/env/array/webpack.config.js @@ -3,7 +3,7 @@ const webpack = require('webpack'); module.exports = [ { output: { - filename: './prod.js', + filename: 'prod.js', }, mode: 'production', devtool: 'eval-cheap-module-source-map', @@ -16,7 +16,7 @@ module.exports = [ }, { output: { - filename: './dev.js', + filename: 'dev.js', }, mode: 'development', target: 'node', diff --git a/test/env/object/object-env.test.js b/test/env/object/object-env.test.js index b5a3a5878f6..2365e4c3ea8 100644 --- a/test/env/object/object-env.test.js +++ b/test/env/object/object-env.test.js @@ -4,7 +4,7 @@ const path = require('path'); const execa = require('execa'); const { sync: spawnSync } = execa; -const { run } = require('../../utils/test-utils'); +const { run, isWebpack5 } = require('../../utils/test-utils'); describe('env object', () => { it('is able to set env for an object', () => { @@ -14,8 +14,10 @@ describe('env object', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - const executable = path.join(__dirname, './bin/main.js'); - const bundledScript = spawnSync('node', [executable]); - expect(bundledScript.stdout).toBe('environment is development'); + if (isWebpack5) { + const executable = path.join(__dirname, './bin/main.js'); + const bundledScript = spawnSync('node', [executable]); + expect(bundledScript.stdout).toBe('environment is development'); + } }); }); From 2c9069fd1f7c0fb70f019900e4b841c5ea33975e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 10 Nov 2020 17:59:04 +0530 Subject: [PATCH 076/581] fix: use logger for error with proper exit code (#2076) --- .../utils/__tests__/resolve-command.test.js | 32 +++++++++++++++++++ .../webpack-cli/lib/utils/resolve-command.js | 1 + packages/webpack-cli/lib/utils/run-command.js | 4 ++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js diff --git a/packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js b/packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js new file mode 100644 index 00000000000..df10101355e --- /dev/null +++ b/packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js @@ -0,0 +1,32 @@ +jest.setMock('../prompt-installation', jest.fn()); + +const resolveCommand = require('../resolve-command'); +const promptInstallation = require('../prompt-installation'); + +describe('resolve-command util', () => { + const processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {}); + const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + + beforeEach(() => { + processExitSpy.mockClear(); + consoleErrorSpy.mockClear(); + }); + + it('should not throw error', async () => { + promptInstallation.mockImplementation(() => {}); + + await expect(resolveCommand('info')).resolves.not.toThrow(); + expect(processExitSpy.mock.calls.length).toBe(0); + expect(consoleErrorSpy.mock.calls.length).toBe(0); + }); + + it('should throw error and exit with invalid command', async () => { + promptInstallation.mockImplementation(() => { + throw new Error(); + }); + + await resolveCommand('invalid'); + expect(processExitSpy).toBeCalledWith(2); + expect(consoleErrorSpy.mock.calls.length).toBe(1); + }); +}); diff --git a/packages/webpack-cli/lib/utils/resolve-command.js b/packages/webpack-cli/lib/utils/resolve-command.js index 7c39f7067a0..fc4d4e1d08e 100644 --- a/packages/webpack-cli/lib/utils/resolve-command.js +++ b/packages/webpack-cli/lib/utils/resolve-command.js @@ -17,6 +17,7 @@ const run = async (name, ...args) => { }); } catch (err) { logger.error(`Action Interrupted, use ${cyan('webpack-cli help')} to see possible commands.`); + process.exit(2); } } diff --git a/packages/webpack-cli/lib/utils/run-command.js b/packages/webpack-cli/lib/utils/run-command.js index 12e1bd1a4f5..bd5477c1ed1 100644 --- a/packages/webpack-cli/lib/utils/run-command.js +++ b/packages/webpack-cli/lib/utils/run-command.js @@ -1,4 +1,5 @@ const execa = require('execa'); +const logger = require('./logger'); async function runCommand(command, args = []) { try { @@ -7,7 +8,8 @@ async function runCommand(command, args = []) { shell: true, }); } catch (e) { - throw new Error(e); + logger.error(e); + process.exit(2); } } From 6581ce934d25bbf6e831456834c6a102041407d5 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 10 Nov 2020 17:59:58 +0530 Subject: [PATCH 077/581] refactor: get-package-manger logic for perf improvements (#2060) --- .../__tests__/get-package-manager.test.js | 38 ++++++++++++----- .../test-npm-and-yarn/package-lock.json | 0 .../__tests__/test-npm-and-yarn/yarn.lock | 0 .../test-yarn-and-pnpm/pnpm-lock.yaml | 0 .../__tests__/test-yarn-and-pnpm/yarn.lock | 0 .../lib/utils/get-package-manager.js | 42 +++++++++++++++---- 6 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/package-lock.json create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/yarn.lock create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/pnpm-lock.yaml create mode 100644 packages/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/yarn.lock diff --git a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js index 3abe09e9c46..bd9d38a2791 100644 --- a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js @@ -12,6 +12,7 @@ jest.setMock('execa', { const getPackageManager = require('../get-package-manager'); jest.mock('cross-spawn'); +jest.mock('../get-package-manager', () => jest.fn()); const globalModulesNpmValue = 'test-npm'; jest.setMock('global-modules', globalModulesNpmValue); jest.setMock('enquirer', { @@ -24,7 +25,10 @@ describe('packageUtils', () => { const testNpmLockPath = path.resolve(__dirname, 'test-npm-lock'); const testPnpmLockPath = path.resolve(__dirname, 'test-pnpm-lock'); const testNpmAndPnpmPath = path.resolve(__dirname, 'test-npm-and-pnpm'); + const testNpmAndYarnPath = path.resolve(__dirname, 'test-npm-and-yarn'); + const testYarnAndPnpmPath = path.resolve(__dirname, 'test-yarn-and-pnpm'); const testAllPath = path.resolve(__dirname, 'test-all-lock'); + const noLockPath = path.resolve(__dirname, 'no-lock-files'); const cwdSpy = jest.spyOn(process, 'cwd'); @@ -36,6 +40,7 @@ describe('packageUtils', () => { } fs.writeFileSync(path.resolve(testNpmLockPath, 'package-lock.json'), ''); fs.writeFileSync(path.resolve(testNpmAndPnpmPath, 'package-lock.json'), ''); + fs.writeFileSync(path.resolve(testNpmAndYarnPath, 'package-lock.json'), ''); fs.writeFileSync(path.resolve(testAllPath, 'package-lock.json'), ''); }); @@ -67,27 +72,38 @@ describe('packageUtils', () => { expect(syncMock.mock.calls.length).toEqual(0); }); - it('should prioritize yarn with many lock files', () => { - cwdSpy.mockReturnValue(testAllPath); - expect(getPackageManager()).toEqual('yarn'); + it('should prioritize npm over yarn', () => { + cwdSpy.mockReturnValue(testNpmAndYarnPath); + expect(getPackageManager()).toEqual('npm'); expect(syncMock.mock.calls.length).toEqual(0); }); - it('should use yarn if yarn command works', () => { - // yarn should output a version number to stdout if - // it is installed - cwdSpy.mockReturnValue(path.resolve(__dirname)); + it('should prioritize yarn over pnpm', () => { + cwdSpy.mockReturnValue(testYarnAndPnpmPath); expect(getPackageManager()).toEqual('yarn'); + expect(syncMock.mock.calls.length).toEqual(0); + }); + + it('should prioritize npm with many lock files', () => { + cwdSpy.mockReturnValue(testAllPath); + expect(getPackageManager()).toEqual('npm'); + expect(syncMock.mock.calls.length).toEqual(0); + }); + + it('should prioritize global npm over other package managers', () => { + cwdSpy.mockReturnValue(noLockPath); + expect(getPackageManager()).toEqual('npm'); expect(syncMock.mock.calls.length).toEqual(1); }); - it('should use npm if yarn command fails', () => { + it('should throw error if no package manager is found', () => { syncMock.mockImplementation(() => { throw new Error(); }); - cwdSpy.mockReturnValue(path.resolve(__dirname)); - expect(getPackageManager()).toEqual('npm'); - expect(syncMock.mock.calls.length).toEqual(1); + const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {}); + expect(getPackageManager()).toBeFalsy(); + expect(mockExit).toBeCalledWith(2); + expect(syncMock.mock.calls.length).toEqual(3); // 3 calls for npm, yarn and pnpm }); }); }); diff --git a/packages/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/package-lock.json b/packages/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/package-lock.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/yarn.lock b/packages/webpack-cli/lib/utils/__tests__/test-npm-and-yarn/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/pnpm-lock.yaml b/packages/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/pnpm-lock.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/yarn.lock b/packages/webpack-cli/lib/utils/__tests__/test-yarn-and-pnpm/yarn.lock new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/webpack-cli/lib/utils/get-package-manager.js b/packages/webpack-cli/lib/utils/get-package-manager.js index 4c165664f4b..d25f3564778 100644 --- a/packages/webpack-cli/lib/utils/get-package-manager.js +++ b/packages/webpack-cli/lib/utils/get-package-manager.js @@ -1,29 +1,46 @@ const fs = require('fs'); const path = require('path'); +const logger = require('./logger'); const { sync } = require('execa'); /** * * Returns the name of package manager to use, - * preferring yarn over npm if available + * preference order - npm > yarn > pnpm * * @returns {String} - The package manager name */ function getPackageManager() { - const hasLocalYarn = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock')); const hasLocalNpm = fs.existsSync(path.resolve(process.cwd(), 'package-lock.json')); - const hasLocalPnpm = fs.existsSync(path.resolve(process.cwd(), 'pnpm-lock.yaml')); + + if (hasLocalNpm) { + return 'npm'; + } + + const hasLocalYarn = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock')); if (hasLocalYarn) { return 'yarn'; - } else if (hasLocalNpm) { - return 'npm'; - } else if (hasLocalPnpm) { + } + + const hasLocalPnpm = fs.existsSync(path.resolve(process.cwd(), 'pnpm-lock.yaml')); + + if (hasLocalPnpm) { return 'pnpm'; } try { - // if the sync function below fails because yarn is not installed, + // the sync function below will fail if npm is not installed, + // an error will be thrown + if (sync('npm', ['--version'])) { + return 'npm'; + } + } catch (e) { + // Nothing + } + + try { + // the sync function below will fail if yarn is not installed, // an error will be thrown if (sync('yarn', ['--version'])) { return 'yarn'; @@ -32,7 +49,16 @@ function getPackageManager() { // Nothing } - return 'npm'; + try { + // the sync function below will fail if pnpm is not installed, + // an error will be thrown + if (sync('pnpm', ['--version'])) { + return 'pnpm'; + } + } catch (e) { + logger.error('No package manager found.'); + process.exit(2); + } } module.exports = getPackageManager; From a3f235b3067b674d6bacdcefdb9ce1c16ddf1aa2 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 10 Nov 2020 19:35:40 +0530 Subject: [PATCH 078/581] fix: union webpack-scaffold and generators package (#2074) * fix: union webpack-scaffold and generators package * fix: union webpack-scaffold and generators package * fix: tests * chore: update docs --- .eslintignore | 1 - .eslintrc.js | 2 +- README.md | 1 - packages/README.md | 1 - .../__snapshots__/scaffold-utils.test.ts.snap | 20 + .../generators/__tests__/utils/entry.test.ts | 6 +- .../__tests__/utils/scaffold-utils.test.ts} | 73 +- packages/generators/package.json | 1 - packages/generators/src/init-generator.ts | 2 +- packages/generators/src/utils/entry.ts | 2 +- .../generators/src/utils/scaffold-utils.ts | 71 ++ packages/generators/tsconfig.json | 2 +- packages/webpack-scaffold/CHANGELOG.md | 42 - packages/webpack-scaffold/README.md | 215 ----- .../__snapshots__/index.test.ts.snap | 761 ------------------ packages/webpack-scaffold/package.json | 22 - packages/webpack-scaffold/src/index.ts | 148 ---- packages/webpack-scaffold/tsconfig.json | 8 - tsconfig.json | 3 +- 19 files changed, 100 insertions(+), 1281 deletions(-) create mode 100644 packages/generators/__tests__/utils/__snapshots__/scaffold-utils.test.ts.snap rename packages/{webpack-scaffold/__tests__/index.test.ts => generators/__tests__/utils/scaffold-utils.test.ts} (52%) create mode 100644 packages/generators/src/utils/scaffold-utils.ts delete mode 100644 packages/webpack-scaffold/CHANGELOG.md delete mode 100755 packages/webpack-scaffold/README.md delete mode 100755 packages/webpack-scaffold/__tests__/__snapshots__/index.test.ts.snap delete mode 100644 packages/webpack-scaffold/package.json delete mode 100755 packages/webpack-scaffold/src/index.ts delete mode 100644 packages/webpack-scaffold/tsconfig.json diff --git a/.eslintignore b/.eslintignore index d1514bd87ba..dad8534184d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -9,7 +9,6 @@ packages/init/lib packages/migrate/lib packages/serve/lib packages/utils/lib -packages/webpack-scaffold/lib test/**/dist/ test/**/bin/ test/**/binary/ diff --git a/.eslintrc.js b/.eslintrc.js index e07032771a8..6d5203bcfb2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,7 +6,7 @@ module.exports = { plugins: ['node'], settings: { node: { - allowModules: ['@webpack-cli/generators', '@webpack-cli/webpack-scaffold', '@webpack-cli/utils'], + allowModules: ['@webpack-cli/generators', '@webpack-cli/utils'], }, }, env: { diff --git a/README.md b/README.md index 010c86a7683..432b673c228 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,6 @@ The project also has several utility packages which are used by other commands - [`utils`](./packages/utils/README.md) - Several utilities used across webpack-cli. - [`generators`](./packages/generators/README.md) - Contains all webpack-cli related yeoman generators. -- [`webpack-scaffold`](./packages/webpack-scaffold/README.md) - Utilities to create a webpack scaffold. ## Getting started diff --git a/packages/README.md b/packages/README.md index 78ef9f9a932..c9fee58bc04 100644 --- a/packages/README.md +++ b/packages/README.md @@ -22,7 +22,6 @@ This folder is the collection of those packages. 7. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) 8. [utils](https://github.com/webpack/webpack-cli/tree/master/packages/utils) 9. [webpack-cli](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli) -10. [webpack-scaffold](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-scaffold) ## Generic Installation diff --git a/packages/generators/__tests__/utils/__snapshots__/scaffold-utils.test.ts.snap b/packages/generators/__tests__/utils/__snapshots__/scaffold-utils.test.ts.snap new file mode 100644 index 00000000000..30a587aff74 --- /dev/null +++ b/packages/generators/__tests__/utils/__snapshots__/scaffold-utils.test.ts.snap @@ -0,0 +1,20 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`utils Inquirer should make an Input object with validation 1`] = ` +Object { + "message": "what is your plugin?", + "name": "plugins", + "type": "input", + "validate": [Function], +} +`; + +exports[`utils Inquirer should make an Input object with validation and default value 1`] = ` +Object { + "default": "my-plugin", + "message": "what is your plugin?", + "name": "plugins", + "type": "input", + "validate": [Function], +} +`; diff --git a/packages/generators/__tests__/utils/entry.test.ts b/packages/generators/__tests__/utils/entry.test.ts index 688382d4781..00adb5e880c 100644 --- a/packages/generators/__tests__/utils/entry.test.ts +++ b/packages/generators/__tests__/utils/entry.test.ts @@ -1,10 +1,10 @@ -jest.setMock('@webpack-cli/webpack-scaffold', { +jest.setMock('../../src/utils/scaffold-utils', { Input: jest.fn(), InputValidate: jest.fn(), }); -import { Input, InputValidate } from '@webpack-cli/webpack-scaffold'; -import entry from '../../lib/utils/entry'; +import { Input, InputValidate } from '../../src/utils/scaffold-utils'; +import entry from '../../src/utils/entry'; describe('entry', () => { const InputMock = Input as jest.Mock; diff --git a/packages/webpack-scaffold/__tests__/index.test.ts b/packages/generators/__tests__/utils/scaffold-utils.test.ts similarity index 52% rename from packages/webpack-scaffold/__tests__/index.test.ts rename to packages/generators/__tests__/utils/scaffold-utils.test.ts index 0568da7e136..6508e3dfdf5 100755 --- a/packages/webpack-scaffold/__tests__/index.test.ts +++ b/packages/generators/__tests__/utils/scaffold-utils.test.ts @@ -1,18 +1,4 @@ -import { - createArrowFunction, - createAssetFilterFunction, - createDynamicPromise, - createRegularFunction, - parseValue, - CheckList, - Confirm, - createExternalFunction, - createRequire, - List, - RawList, - InputValidate, - Input, -} from '../src'; +import { Confirm, List, InputValidate, Input } from '../../src/utils/scaffold-utils'; describe('utils', () => { beforeEach(() => { @@ -23,47 +9,6 @@ describe('utils', () => { }, }; }); - describe('createArrowFunction', () => { - it('should stringify an arrow function', () => { - expect(createArrowFunction('app.js')).toMatchSnapshot(); - }); - }); - describe('createRegularFunction', () => { - it('should stringify a regular function', () => { - expect(createRegularFunction('app.js')).toMatchSnapshot(); - }); - }); - describe('createDynamicPromise', () => { - it('should stringify an single value', () => { - expect(createDynamicPromise('app.js')).toMatchSnapshot(); - }); - it('should stringify an array', () => { - expect(createDynamicPromise(['app.js', 'index.js'])).toMatchSnapshot(); - }); - }); - describe('createAssetFilterFunction', () => { - it('should stringify an assetFilterFunction', () => { - expect(createAssetFilterFunction('js')).toMatchSnapshot(); - }); - }); - describe('parseValue', () => { - it('should parse value', () => { - expect(parseValue('\t')).toMatchSnapshot(); - }); - it('should parse value with raw value', () => { - expect(parseValue('hell\u{6F}')).toMatchSnapshot(); - }); - }); - describe('createExternalFunction', () => { - it('should stringify an ExternalFunction', () => { - expect(createExternalFunction('js')).toMatchSnapshot(); - }); - }); - describe('createRequire', () => { - it('should stringify a require statement', () => { - expect(createRequire('webpack')).toMatchSnapshot(); - }); - }); describe('Inquirer', () => { it('should emulate a prompt for List', () => { expect(List(this.mockSelf, 'entry', 'does it work?', ['Yes', 'Maybe'], 'Yes')).toEqual({ @@ -80,22 +25,6 @@ describe('utils', () => { entry: 'Yes', }); }); - it('should make a RawList object', () => { - expect(RawList('output', 'does it work?', ['Yes', 'Maybe'])).toEqual({ - choices: ['Yes', 'Maybe'], - message: 'does it work?', - name: 'output', - type: 'rawlist', - }); - }); - it('should make a CheckList object', () => { - expect(CheckList('context', 'does it work?', ['Yes', 'Maybe'])).toEqual({ - choices: ['Yes', 'Maybe'], - message: 'does it work?', - name: 'context', - type: 'checkbox', - }); - }); it('should emulate a prompt for list input', () => { expect(Input(this.mockSelf, 'plugins', 'what is your plugin?', 'openJSF')).toEqual({ type: 'input', diff --git a/packages/generators/package.json b/packages/generators/package.json index 571b8ff9f80..2604b593e69 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -15,7 +15,6 @@ ], "dependencies": { "@webpack-cli/utils": "^1.1.0", - "@webpack-cli/webpack-scaffold": "^1.0.3", "colorette": "^1.2.1", "log-symbols": "^4.0.0", "yeoman-generator": "^4.12.0" diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index b1110c8dd7d..b6e3f47e0c8 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -2,7 +2,7 @@ import { blue, green, bold } from 'colorette'; import { utils } from 'webpack-cli'; import logSymbols from 'log-symbols'; import path from 'path'; -import { Confirm, Input, List } from '@webpack-cli/webpack-scaffold'; +import { Confirm, Input, List } from './utils/scaffold-utils'; import { getDefaultOptimization, diff --git a/packages/generators/src/utils/entry.ts b/packages/generators/src/utils/entry.ts index 53328a920a9..19bf41ac195 100644 --- a/packages/generators/src/utils/entry.ts +++ b/packages/generators/src/utils/entry.ts @@ -1,5 +1,5 @@ import Generator from 'yeoman-generator'; -import { Input, InputValidate } from '@webpack-cli/webpack-scaffold'; +import { Input, InputValidate } from './scaffold-utils'; import validate from './validate'; diff --git a/packages/generators/src/utils/scaffold-utils.ts b/packages/generators/src/utils/scaffold-utils.ts new file mode 100644 index 00000000000..e4611ec066b --- /dev/null +++ b/packages/generators/src/utils/scaffold-utils.ts @@ -0,0 +1,71 @@ +import Generator from 'yeoman-generator'; + +type CustomGeneratorStringPrompt = { [x: string]: string } | Promise<{ [x: string]: string }>; +type CustomGeneratorBoolPrompt = { [x: string]: boolean } | Promise<{ [x: string]: boolean }>; + +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export function List( + self: Generator, + name: string, + message: string, + choices: string[], + defaultChoice?: string, + skip = false, +): CustomGeneratorStringPrompt { + if (skip) return { [name]: defaultChoice }; + + return self.prompt([ + { + choices, + message, + name, + type: 'list', + default: defaultChoice, + }, + ]); +} + +export function Input(self: Generator, name: string, message: string, defaultChoice?: string, skip = false): CustomGeneratorStringPrompt { + if (skip) return { [name]: defaultChoice }; + return self.prompt([ + { + default: defaultChoice, + message, + name, + type: 'input', + }, + ]); +} + +export function InputValidate( + self: Generator, + name: string, + message: string, + cb?: (input: string) => string | boolean, + defaultChoice?: string, + skip = false, +): object | any { + if (skip) return { [name]: defaultChoice }; + const input: Generator.Question = { + message, + name, + type: 'input', + validate: cb, + }; + if (defaultChoice) input.default = defaultChoice; + return self.prompt([input]); +} + +export function Confirm(self: Generator, name: string, message: string, defaultChoice = true, skip = false): CustomGeneratorBoolPrompt { + if (skip) return { [name]: defaultChoice }; + + return self.prompt([ + { + default: defaultChoice, + message, + name, + type: 'confirm', + }, + ]); +} diff --git a/packages/generators/tsconfig.json b/packages/generators/tsconfig.json index 63a4818f8b2..b5df5fb69be 100644 --- a/packages/generators/tsconfig.json +++ b/packages/generators/tsconfig.json @@ -5,5 +5,5 @@ "rootDir": "src" }, "include": ["src"], - "references": [{ "path": "../utils" }, { "path": "../webpack-scaffold" }] + "references": [{ "path": "../utils" }] } diff --git a/packages/webpack-scaffold/CHANGELOG.md b/packages/webpack-scaffold/CHANGELOG.md deleted file mode 100644 index 251ff6529bf..00000000000 --- a/packages/webpack-scaffold/CHANGELOG.md +++ /dev/null @@ -1,42 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [1.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.2...@webpack-cli/webpack-scaffold@1.0.3) (2020-11-04) - -**Note:** Version bump only for package @webpack-cli/webpack-scaffold - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1...@webpack-cli/webpack-scaffold@1.0.2) (2020-10-19) - -### Bug Fixes - -- support array of functions and promises ([#1946](https://github.com/webpack/webpack-cli/issues/1946)) ([2ace39b](https://github.com/webpack/webpack-cli/commit/2ace39b06117f558c0d8528cea9248253cbdf593)) - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1-rc.1...@webpack-cli/webpack-scaffold@1.0.1) (2020-10-10) - -### Bug Fixes - -- upgrade lock file ([#1885](https://github.com/webpack/webpack-cli/issues/1885)) ([8df291e](https://github.com/webpack/webpack-cli/commit/8df291eef0fad7c91d912b158b3c2915cddfacd1)) - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1-alpha.4...@webpack-cli/webpack-scaffold@1.0.1-rc.1) (2020-10-06) - -**Note:** Version bump only for package @webpack-cli/webpack-scaffold - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1-alpha.3...@webpack-cli/webpack-scaffold@1.0.1-alpha.4) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/webpack-scaffold - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1-alpha.2...@webpack-cli/webpack-scaffold@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/webpack-scaffold - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1-alpha.1...@webpack-cli/webpack-scaffold@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/webpack-scaffold - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/webpack-scaffold@1.0.1-alpha.0...@webpack-cli/webpack-scaffold@1.0.1-alpha.1) (2020-02-23) - -### Bug Fixes - -- **init:** fix webpack config scaffold ([#1231](https://github.com/webpack/webpack-cli/issues/1231)) ([2dc495a](https://github.com/webpack/webpack-cli/commit/2dc495a8d050d28478c6c2533d7839e9ff78d76c)), closes [#1230](https://github.com/webpack/webpack-cli/issues/1230) diff --git a/packages/webpack-scaffold/README.md b/packages/webpack-scaffold/README.md deleted file mode 100755 index bf5315ea88d..00000000000 --- a/packages/webpack-scaffold/README.md +++ /dev/null @@ -1,215 +0,0 @@ -# webpack-scaffold - -[![NPM Downloads][downloads]][downloads-url] - -This is the utility suite for creating a webpack `scaffold`, it contains utility functions to help you work with [Inquirer](https://github.com/SBoudrias/Inquirer.js/) prompting and scaffolding. - -# Installation - -```bash -npm i -D webpack-cli @webpack-cli/webpack-scaffold -``` - -# API - -- [parseValue](#parsevalue) -- [createArrowFunction](#createarrowfunction) -- [createRegularFunction](#createregularfunction) -- [createDynamicPromise](#createdynamicpromise) -- [createAssetFilterFunction](#createassetfilterfunction) -- [createExternalFunction](#createexternalfunction) -- [createRequire](#createrequire) -- [Inquirer](#inquirer) - - [List](#list) - - [RawList](#rawlist) - - [CheckList](#checklist) - - [Input](#input) - - [InputValidate](#inputvalidate) - - [Confirm](#confirm) - -## parseValue - -Param: `String` - -Used when you cannot use regular conventions. Handy for examples like `RegExp` or `output.sourcePrefix` - -```js -const parseValue = require('@webpack-cli/webpack-scaffold').parseValue; - -this.configuration.myScaffold.webpackOptions.output.sourcePrefix = parseValue('\t'); -// sourcePrefix: '\t' -``` - -## createArrowFunction - -Param: `String` - -Generally used when dealing with an entry point as an arrow function - -```js -const createArrowFunction = require('@webpack-cli/webpack-scaffold').createArrowFunction; - -this.configuration.myScaffold.webpackOptions.entry = createArrowFunction('app.js'); -// entry: () => 'app.js' -``` - -## createRegularFunction - -Param: `String` - -Used when creating a function that returns a single value - -```js -const createRegularFunction = require('@webpack-cli/webpack-scaffold').createRegularFunction; - -this.configuration.myScaffold.webpackOptions.entry = createRegularFunction('app.js'); -// entry: function() { return 'app.js' } -``` - -## createDynamicPromise - -Param: `Array` | `String` - -Used to create a dynamic entry point - -```js -const createDynamicPromise = require('@webpack-cli/webpack-scaffold').createDynamicPromise; - -this.confguration.myScaffold.webpackOptions.entry = createDynamicPromise('app.js'); -// entry: () => new Promise((resolve) => resolve('app.js')) - -this.configuration.myScaffold.webpackOptions.entry = createDynamicPromise(['app.js', 'index.js']); -// entry: () => new Promise((resolve) => resolve(['app.js','index.js'])) -``` - -## createAssetFilterFunction - -Param: `String` - -Used to create an [assetFilterFunction](https://webpack.js.org/configuration/performance/#performance-assetfilter) - -```js -const createAssetFilterFunction = require('@webpack-cli/webpack-scaffold').createAssetFilterFunction; - -this.configuration.myScaffold.webpackOptions.performance.assetFilter = createAssetFilterFunction('js'); -// assetFilter: function (assetFilename) { return assetFilename.endsWith('.js'); } -``` - -## createExternalFunction - -Param: `String` - -Used to create a [general function from Externals](https://webpack.js.org/configuration/externals/#function) - -```js -const createExternalFunction = require('@webpack-cli/webpack-scaffold').createExternalFunction; - -this.configuration.myScaffold.webpackOptions.externals = [createExternalFunction('^yourregex$')]; -/* -externals: [ - function(context, request, callback) { - if (/^yourregex$/.test(request)){ - return callback(null, 'commonjs ' + request); - } - callback(); - } -*/ -``` - -## createRequire - -Param: `String` - -Used to create a module in `topScope` - -```js -const createRequire = require('@webpack-cli/webpack-scaffold').createRequire; - -this.configuration.myScaffold.topScope = [createRequire('webpack')]; -// const webpack = require('webpack') -``` - -## [Inquirer](https://github.com/SBoudrias/Inquirer.js/#prompt-types) - -### List - -Param: `name, message, choices` - -Creates a List from Inquirer - -```js -const List = require('@webpack-cli/webpack-scaffold').List; - -List('entry', 'what kind of entry do you want?', ['Array', 'Function']); -``` - -### RawList - -Param: `name, message, choices` - -Creates a RawList from Inquirer - -```js -const RawList = require('@webpack-cli/webpack-scaffold').RawList; - -RawList('entry', 'what kind of entry do you want?', ['Array', 'Function']); -``` - -### CheckList - -Param: `name, message, choices` - -Creates a CheckList(`checkbox`) from Inquirer - -```js -const CheckList = require('@webpack-cli/webpack-scaffold').CheckList; - -CheckList('entry', 'what kind of entry do you want?', ['Array', 'Function']); -``` - -### Input - -Param: `name, message, [default]` - -Creates an Input from Inquirer - -```js -const Input = require('@webpack-cli/webpack-scaffold').Input; - -Input('entry', 'what is your entry point?', 'src/index'); -``` - -### InputValidate - -Param: `name, message, [validate, default]` - -Creates an Input from Inquirer - -```js -const InputValidate = require('@webpack-cli/webpack-scaffold').InputValidate; - -const validation = (value) => { - if (value.length > 4) { - return true; - } else { - return 'Your answer must be longer than 4 characters, try again'; - } -}; - -InputValidate('entry', 'what is your entry point?', validation, 'src/index'); -``` - -### Confirm - -Param: `name, message, [default]` - -Creates an Input from Inquirer - -```js -const Confirm = require('@webpack-cli/webpack-scaffold').Confirm; - -Confirm('contextConfirm', 'Is this your context?'); -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/webpack-scaffold.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/webpack-scaffold diff --git a/packages/webpack-scaffold/__tests__/__snapshots__/index.test.ts.snap b/packages/webpack-scaffold/__tests__/__snapshots__/index.test.ts.snap deleted file mode 100755 index 126c853a068..00000000000 --- a/packages/webpack-scaffold/__tests__/__snapshots__/index.test.ts.snap +++ /dev/null @@ -1,761 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`utils Inquirer should make an Input object with validation 1`] = ` -Object { - "message": "what is your plugin?", - "name": "plugins", - "type": "input", - "validate": [Function], -} -`; - -exports[`utils Inquirer should make an Input object with validation and default value 1`] = ` -Object { - "default": "my-plugin", - "message": "what is your plugin?", - "name": "plugins", - "type": "input", - "validate": [Function], -} -`; - -exports[`utils createArrowFunction should stringify an arrow function 1`] = `"() => 'app.js'"`; - -exports[`utils createAssetFilterFunction should stringify an assetFilterFunction 1`] = ` -"function (assetFilename) { - return assetFilename.endsWith('.js'); -}" -`; - -exports[`utils createDynamicPromise should stringify an array 1`] = `"() => new Promise((resolve) => resolve(['app.js','index.js']))"`; - -exports[`utils createDynamicPromise should stringify an single value 1`] = `"() => new Promise((resolve) => resolve('app.js'))"`; - -exports[`utils createExternalFunction should stringify an ExternalFunction 1`] = ` -" - function (context, request, callback) { - if (/js/.test(request)){ - return callback(null, 'commonjs' + request); -} -callback(); -}" -`; - -exports[`utils createRegularFunction should stringify a regular function 1`] = ` -"function () { - return 'app.js' -}" -`; - -exports[`utils createRequire should stringify a require statement 1`] = `"const webpack = require('webpack');"`; - -exports[`utils parseValue should parse value 1`] = ` -Collection { - "__paths": Array [ - NodePath { - "__childCache": null, - "name": null, - "parentPath": null, - "value": Node { - "end": 4, - "errors": Array [], - "extra": undefined, - "innerComments": undefined, - "leadingComments": undefined, - "loc": SourceLocation { - "end": Object { - "column": 4, - "line": 1, - "token": 1, - }, - "filename": undefined, - "identifierName": undefined, - "indent": 0, - "lines": Lines { - "cachedSourceMap": null, - "cachedTabWidth": undefined, - "infos": Array [ - Object { - "indent": 4, - "line": " ", - "locked": false, - "sliceEnd": 1, - "sliceStart": 1, - }, - ], - "length": 1, - "mappings": Array [], - "name": null, - }, - "start": Object { - "column": 0, - "line": 1, - "token": 0, - }, - "tokens": Array [ - Token { - "end": 4, - "loc": SourceLocation { - "end": Position { - "column": 4, - "line": 1, - "token": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 4, - "line": 1, - }, - }, - "start": 4, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - }, - "program": Node { - "body": Array [], - "end": 4, - "extra": undefined, - "innerComments": undefined, - "interpreter": null, - "leadingComments": undefined, - "loc": SourceLocation { - "end": Position { - "column": 4, - "line": 1, - "token": 1, - }, - "filename": undefined, - "identifierName": undefined, - "indent": 4, - "lines": Lines { - "cachedSourceMap": null, - "cachedTabWidth": undefined, - "infos": Array [ - Object { - "indent": 4, - "line": " ", - "locked": false, - "sliceEnd": 1, - "sliceStart": 1, - }, - ], - "length": 1, - "mappings": Array [], - "name": null, - }, - "start": Object { - "column": 4, - "line": 1, - "token": 0, - }, - "tokens": Array [ - Token { - "end": 4, - "loc": SourceLocation { - "end": Position { - "column": 4, - "line": 1, - "token": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 4, - "line": 1, - }, - }, - "start": 4, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - }, - "range": undefined, - "sourceType": "module", - "start": 0, - "trailingComments": undefined, - "type": "Program", - }, - "range": undefined, - "start": 0, - "tokens": Array [ - Token { - "end": 4, - "loc": SourceLocation { - "end": Position { - "column": 4, - "line": 1, - "token": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 4, - "line": 1, - }, - }, - "start": 4, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - "trailingComments": undefined, - "type": "File", - }, - }, - ], - "_parent": undefined, - "_types": Array [ - "File", - "Node", - "Printable", - ], -} -`; - -exports[`utils parseValue should parse value with raw value 1`] = ` -Collection { - "__paths": Array [ - NodePath { - "__childCache": null, - "name": null, - "parentPath": null, - "value": Node { - "end": 5, - "errors": Array [], - "extra": undefined, - "innerComments": undefined, - "leadingComments": undefined, - "loc": SourceLocation { - "end": Object { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "indent": 0, - "lines": Lines { - "cachedSourceMap": null, - "cachedTabWidth": undefined, - "infos": Array [ - Object { - "indent": 0, - "line": "hello", - "locked": false, - "sliceEnd": 5, - "sliceStart": 0, - }, - ], - "length": 1, - "mappings": Array [], - "name": null, - }, - "start": Object { - "column": 0, - "line": 1, - "token": 0, - }, - "tokens": Array [ - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "line": 1, - "token": 0, - }, - }, - "start": 0, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "name", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": true, - "updateContext": [Function], - }, - "value": "hello", - }, - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 5, - "line": 1, - }, - }, - "start": 5, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - }, - "program": Node { - "body": Array [ - Node { - "end": 5, - "expression": Node { - "end": 5, - "extra": undefined, - "innerComments": undefined, - "leadingComments": undefined, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": "hello", - "indent": 0, - "lines": Lines { - "cachedSourceMap": null, - "cachedTabWidth": undefined, - "infos": Array [ - Object { - "indent": 0, - "line": "hello", - "locked": false, - "sliceEnd": 5, - "sliceStart": 0, - }, - ], - "length": 1, - "mappings": Array [], - "name": null, - }, - "start": Position { - "column": 0, - "line": 1, - "token": 0, - }, - "tokens": Array [ - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "line": 1, - "token": 0, - }, - }, - "start": 0, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "name", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": true, - "updateContext": [Function], - }, - "value": "hello", - }, - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 5, - "line": 1, - }, - }, - "start": 5, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - }, - "name": "hello", - "range": undefined, - "start": 0, - "trailingComments": undefined, - "type": "Identifier", - }, - "extra": undefined, - "innerComments": undefined, - "leadingComments": undefined, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "indent": 0, - "lines": Lines { - "cachedSourceMap": null, - "cachedTabWidth": undefined, - "infos": Array [ - Object { - "indent": 0, - "line": "hello", - "locked": false, - "sliceEnd": 5, - "sliceStart": 0, - }, - ], - "length": 1, - "mappings": Array [], - "name": null, - }, - "start": Position { - "column": 0, - "line": 1, - "token": 0, - }, - "tokens": Array [ - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "line": 1, - "token": 0, - }, - }, - "start": 0, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "name", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": true, - "updateContext": [Function], - }, - "value": "hello", - }, - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 5, - "line": 1, - }, - }, - "start": 5, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - }, - "range": undefined, - "start": 0, - "trailingComments": undefined, - "type": "ExpressionStatement", - }, - ], - "end": 5, - "extra": undefined, - "innerComments": undefined, - "interpreter": null, - "leadingComments": undefined, - "loc": SourceLocation { - "end": Object { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "indent": 0, - "lines": Lines { - "cachedSourceMap": null, - "cachedTabWidth": undefined, - "infos": Array [ - Object { - "indent": 0, - "line": "hello", - "locked": false, - "sliceEnd": 5, - "sliceStart": 0, - }, - ], - "length": 1, - "mappings": Array [], - "name": null, - }, - "start": Object { - "column": 0, - "line": 1, - "token": 0, - }, - "tokens": Array [ - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "line": 1, - "token": 0, - }, - }, - "start": 0, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "name", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": true, - "updateContext": [Function], - }, - "value": "hello", - }, - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 5, - "line": 1, - }, - }, - "start": 5, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - }, - "range": undefined, - "sourceType": "module", - "start": 0, - "trailingComments": undefined, - "type": "Program", - }, - "range": undefined, - "start": 0, - "tokens": Array [ - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - "token": 2, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 0, - "line": 1, - "token": 0, - }, - }, - "start": 0, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "name", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": true, - "updateContext": [Function], - }, - "value": "hello", - }, - Token { - "end": 5, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 1, - }, - "filename": undefined, - "identifierName": undefined, - "start": Position { - "column": 5, - "line": 1, - }, - }, - "start": 5, - "type": TokenType { - "beforeExpr": false, - "binop": null, - "isAssign": false, - "isLoop": false, - "keyword": undefined, - "label": "eof", - "postfix": false, - "prefix": false, - "rightAssociative": false, - "startsExpr": false, - "updateContext": null, - }, - "value": "", - }, - ], - "trailingComments": undefined, - "type": "File", - }, - }, - ], - "_parent": undefined, - "_types": Array [ - "File", - "Node", - "Printable", - ], -} -`; diff --git a/packages/webpack-scaffold/package.json b/packages/webpack-scaffold/package.json deleted file mode 100644 index b5c914bb29d..00000000000 --- a/packages/webpack-scaffold/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "@webpack-cli/webpack-scaffold", - "version": "1.0.3", - "description": "Utility files for webpack-scaffold", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "publishConfig": { - "access": "public" - }, - "license": "MIT", - "files": [ - "lib" - ], - "dependencies": { - "jscodeshift": "^0.11.0", - "yeoman-generator": "^4.12.0" - }, - "devDependencies": { - "@types/yeoman-generator": "^4.11.3" - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/webpack-scaffold/src/index.ts b/packages/webpack-scaffold/src/index.ts deleted file mode 100755 index 6052b7582f4..00000000000 --- a/packages/webpack-scaffold/src/index.ts +++ /dev/null @@ -1,148 +0,0 @@ -import jscodeshift from 'jscodeshift'; -import Generator from 'yeoman-generator'; - -type CustomGeneratorStringPrompt = { [x: string]: string } | Promise<{ [x: string]: string }>; -type CustomGeneratorBoolPrompt = { [x: string]: boolean } | Promise<{ [x: string]: boolean }>; - -/* eslint-disable @typescript-eslint/no-explicit-any */ - -export function createArrowFunction(value: string): string { - return `() => '${value}'`; -} - -export function createRegularFunction(value: string): string { - return `function () {\n return '${value}'\n}`; -} - -export function createDynamicPromise(arrOrString: string[] | string): string { - if (Array.isArray(arrOrString)) { - return ( - '() => new Promise((resolve) => resolve([' + - arrOrString.map((func: string): string => { - return "'" + func + "'"; - }) + - ']))' - ); - } else { - return `() => new Promise((resolve) => resolve('${arrOrString}'))`; - } -} - -export function createAssetFilterFunction(value: string): string { - return `function (assetFilename) {\n return assetFilename.endsWith('.${value}');\n}`; -} - -export function createExternalFunction(regexp: string): string { - return ( - '\n function (context, request, callback) {\n if (' + - '/' + - regexp + - '/.test(request)){' + - '\n' + - " return callback(null, 'commonjs' + request);\n}\n" + - 'callback();\n}' - ); -} - -export function parseValue(regexp: string): string { - return jscodeshift(regexp); -} - -export function createRequire(val: string): string { - return `const ${val} = require('${val}');`; -} - -export function List( - self: Generator, - name: string, - message: string, - choices: string[], - defaultChoice?: string, - skip = false, -): CustomGeneratorStringPrompt { - if (skip) return { [name]: defaultChoice }; - - return self.prompt([ - { - choices, - message, - name, - type: 'list', - default: defaultChoice, - }, - ]); -} - -export function RawList(name: string, message: string, choices: string[]): Generator.Question { - return { - choices, - message, - name, - type: 'rawlist', - }; -} - -export function CheckList(name: string, message: string, choices: string[]): Generator.Question { - return { - choices, - message, - name, - type: 'checkbox', - }; -} - -export function Input(self: Generator, name: string, message: string, defaultChoice?: string, skip = false): CustomGeneratorStringPrompt { - if (skip) return { [name]: defaultChoice }; - return self.prompt([ - { - default: defaultChoice, - message, - name, - type: 'input', - }, - ]); -} - -export function InputValidate( - self: Generator, - name: string, - message: string, - cb?: (input: string) => string | boolean, - defaultChoice?: string, - skip = false, -): object | any { - if (skip) return { [name]: defaultChoice }; - const input: Generator.Question = { - message, - name, - type: 'input', - validate: cb, - }; - if (defaultChoice) input.default = defaultChoice; - return self.prompt([input]); -} - -export function Confirm(self: Generator, name: string, message: string, defaultChoice = true, skip = false): CustomGeneratorBoolPrompt { - if (skip) return { [name]: defaultChoice }; - - return self.prompt([ - { - default: defaultChoice, - message, - name, - type: 'confirm', - }, - ]); -} - -// TODO: to understand this type -export function AutoComplete(name: string, message: string, options: object = {}): any { - return Object.assign( - { - message, - name, - type: 'autocomplete', - }, - options, - ); -} diff --git a/packages/webpack-scaffold/tsconfig.json b/packages/webpack-scaffold/tsconfig.json deleted file mode 100644 index 488b493e472..00000000000 --- a/packages/webpack-scaffold/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "lib", - "rootDir": "src" - }, - "include": ["./src"] -} diff --git a/tsconfig.json b/tsconfig.json index 011dd7ff9b7..a4c30e6b785 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,7 +27,6 @@ { "path": "packages/init" }, { "path": "packages/migrate" }, { "path": "packages/serve" }, - { "path": "packages/utils" }, - { "path": "packages/webpack-scaffold" } + { "path": "packages/utils" } ] } From f9875e96f247bb4948d17d59776593fc97c816e0 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 10 Nov 2020 19:52:31 +0530 Subject: [PATCH 079/581] chore: remove instances of interactive (#2096) --- packages/webpack-cli/lib/utils/cli-flags.js | 7 - packages/webpack-cli/lib/utils/interactive.js | 175 ------------------ packages/webpack-cli/lib/webpack-cli.js | 7 - 3 files changed, 189 deletions(-) delete mode 100644 packages/webpack-cli/lib/utils/interactive.js diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 80ab6021e11..2949b4b9459 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -243,13 +243,6 @@ const core = [ description: 'It invokes webpack-bundle-analyzer plugin to get bundle information', link: 'https://github.com/webpack-contrib/webpack-bundle-analyzer', }, - /* { - name: "interactive", - type: Boolean, - alias: "i", - description: "Use webpack interactively", - group: BASIC_GROUP - } */ ]; // Extract all the flags being exported from core. A list of cli flags generated by core diff --git a/packages/webpack-cli/lib/utils/interactive.js b/packages/webpack-cli/lib/utils/interactive.js deleted file mode 100644 index f68d57342b4..00000000000 --- a/packages/webpack-cli/lib/utils/interactive.js +++ /dev/null @@ -1,175 +0,0 @@ -/*** -const { gray, bold, white, cyan, yellow } = require('colorette'); -const ansiEscapes = require('ansi-escapes'); -const readline = require('readline'); - -let isSub = false; -const generateSingleOption = (option) => { - const { key, description } = option; - const optionString = gray('> Press') + ` ${bold(white(key))} ` + gray(`${description}\n`); - return optionString; -}; -const generateConfigDescription = (config) => { - let configDescString = '\n'; - const headerString = bold(white('Interactive Usage')); - configDescString += headerString; - configDescString += '\n'; - Object.keys(config).forEach((option) => { - configDescString += generateSingleOption(config[option]); - }); - configDescString += '\n'; - return configDescString; -}; - -const setupInteractive = () => { - const usagePrompt = generateConfigDescription(interactiveConfig); - console.clear(); - console.log(usagePrompt); -}; - -const informActions = () => { - console.log('You can now analyze your build, press c to continue...\n'); -}; - -const writeFilterConsole = () => { - if (state.length) { - const latestCompilation = state[state.length - 1]; - const data = []; - - for (let i = 0; i < latestCompilation.chunks.length; i++) { - const name = latestCompilation.chunks[i].id; - const chunksArr = []; - for (let j = 0; j < latestCompilation.chunks[i].modules.length; j++) { - const size = latestCompilation.chunks[i].modules[j].size; - const path = latestCompilation.chunks[i].modules[j].name.replace('./', ''); - const issuerPath = latestCompilation.chunks[i].modules[j].issuerPath; - chunksArr.push({ path, size, issuerPath }); - } - data.push({ [name]: chunksArr }); - } - console.clear(); - data.forEach((chunk) => { - Object.keys(chunk).forEach((mod) => { - console.log(bold(cyan(mod))); - chunk[mod].forEach((sub) => { - console.log('> ', yellow(sub.path)); - }); - }); - }); - process.stdout.write(ansiEscapes.cursorTo(0, 1)); - } -}; - -const state = []; -const interactiveConfig = [ - { - key: 'a', - description: 'Analyze build for performance improvements', - onShowMore: [], - }, - { - key: 'p', - description: 'Pause compilation at a given time', - onShowMore: [], - }, - { - key: 'm', - description: 'Filter a module and get stats on why a module was included', - onShowMore: [], - }, - { - key: 'Enter', - description: 'Run webpack', - onShowMore: [], - }, - { - key: 'q', - description: 'Exit interactive mode', - onShowMore: [], - }, -]; - -const EXIT_KEY = 'q'; -const ANALYZE_KEY = 'a'; -const FILTER_KEY = 'm'; -const ENTER_KEY = '\n'; -const B_KEY = 'b'; -const C_KEY = 'c'; - -module.exports = async function (compiler, config, outputOptions) { - const stdin = process.stdin; - stdin.setEncoding('utf-8'); - stdin.setRawMode(true); - readline.emitKeypressEvents(stdin); - - outputOptions.interactive = false; - - state.push(compiler); - - setupInteractive(); - - const isExitCtrl = (key) => key.ctrl && key.name === 'c'; - - stdin.on('keypress', (str, key) => { - stdin.setRawMode(true); - if (isExitCtrl(key)) { - console.clear(); - process.exit(); - } - switch (key.name) { - case 'down': - process.stdout.write(ansiEscapes.cursorNextLine); - break; - case 'up': - process.stdout.write(ansiEscapes.cursorPrevLine); - break; - case 'return': - // TODO: get line and do stuff - break; - default: - break; - } - }); - - stdin.on('data', async function (data) { - if (isSub === true) { - console.log(data, 'yo'); - return; - } - switch (data) { - case C_KEY: - setupInteractive(); - break; - case EXIT_KEY: - console.log('exit'); - process.exit(0); - case ANALYZE_KEY: - console.log('analyzing modules'); - break; - case FILTER_KEY: - isSub = true; - writeFilterConsole(); - break; - case B_KEY: - console.clear(); - stdin.setEncoding('utf-8'); - setupInteractive(); - break; - case ENTER_KEY: { - console.clear(); - console.log('Running webpack'); - if (state.length) { - state.pop(); - } - state.push(compiler); - informActions(); - isSub = true; - return; - } - default: - break; - } - }); -}; -* -***/ diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 0377f77f993..3ca68f4f32d 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -412,13 +412,6 @@ class WebpackCLI { }; compiler = this.createCompiler(options, callback); - - if (compiler && outputOptions.interactive) { - const interactive = require('./utils/interactive'); - - interactive(compiler, options, outputOptions); - } - return Promise.resolve(); } } From 8f132def9a13bdb9e400ebee6c33348e8951884a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2020 17:34:08 +0300 Subject: [PATCH 080/581] chore(deps-dev): bump @types/node from 14.14.6 to 14.14.7 (#2090) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.6 to 14.14.7. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0c6c314b41f..3b80a4ea410 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2451,9 +2451,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.6.tgz#146d3da57b3c636cc0d1769396ce1cfa8991147f" - integrity sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw== + version "14.14.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.7.tgz#8ea1e8f8eae2430cf440564b98c6dfce1ec5945d" + integrity sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg== "@types/normalize-package-data@^2.4.0": version "2.4.0" From c3271e2d5f5231f7fe37a1bf3780be4cee72aecc Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 10 Nov 2020 20:09:02 +0530 Subject: [PATCH 081/581] chore: fix typo (#2094) --- test/colors/colors.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 946f54ce8fa..85815bc1d9e 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -3,7 +3,7 @@ const { run, isWebpack5 } = require('../utils/test-utils'); const { resolve } = require('path'); const { options: coloretteOptions } = require('colorette'); -describe('colorts', () => { +describe('colors related tests', () => { it('should output by default', () => { const { stderr, stdout, exitCode } = run(__dirname); From 363f1200dbc163a754186604d1ddabc7d6f99f94 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 10 Nov 2020 22:08:19 +0530 Subject: [PATCH 082/581] feat: expose config resolving as CLI instance (#2066) * feat: expose config resolving as CLI instance * fix: tests * fix: tests --- .../resolveConfig/resolveConfig.test.js | 4 +- .../webpack-cli/lib/groups/resolveConfig.js | 251 ------------------ packages/webpack-cli/lib/webpack-cli.js | 242 ++++++++++++++++- 3 files changed, 241 insertions(+), 256 deletions(-) delete mode 100644 packages/webpack-cli/lib/groups/resolveConfig.js diff --git a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js index 4ad49dfab67..9b4162eba1c 100644 --- a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js +++ b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js @@ -1,10 +1,12 @@ -const resolveConfig = require('../../lib/groups/resolveConfig.js'); const { resolve } = require('path'); +const WebpackCLI = require('../../lib/webpack-cli'); const config1 = require('./webpack.config1.cjs'); const config2 = require('./webpack.config2.cjs'); const arrayConfig = require('./webpack.config.cjs'); const promiseConfig = require('./webpack.promise.config.cjs'); +const resolveConfig = new WebpackCLI().resolveConfig; + describe('resolveConfig', function () { it('should handle merge properly', async () => { const result = await resolveConfig({ diff --git a/packages/webpack-cli/lib/groups/resolveConfig.js b/packages/webpack-cli/lib/groups/resolveConfig.js deleted file mode 100644 index de33eba34e4..00000000000 --- a/packages/webpack-cli/lib/groups/resolveConfig.js +++ /dev/null @@ -1,251 +0,0 @@ -const { existsSync } = require('fs'); -const { resolve, extname } = require('path'); -const webpackMerge = require('webpack-merge'); -const { extensions, jsVariants } = require('interpret'); -const rechoir = require('rechoir'); -const logger = require('../utils/logger'); - -// Order defines the priority, in increasing order -// example - config file lookup will be in order of .webpack/webpack.config.development.js -> webpack.config.development.js -> webpack.config.js -const DEFAULT_CONFIG_LOC = [ - 'webpack.config', - 'webpack.config.dev', - 'webpack.config.development', - 'webpack.config.prod', - 'webpack.config.production', - '.webpack/webpack.config', - '.webpack/webpack.config.none', - '.webpack/webpack.config.dev', - '.webpack/webpack.config.development', - '.webpack/webpack.config.prod', - '.webpack/webpack.config.production', - '.webpack/webpackfile', -]; - -const modeAlias = { - production: 'prod', - development: 'dev', -}; - -let opts = { - outputOptions: {}, - options: {}, -}; - -// Return a list of default configs in various formats -const getDefaultConfigFiles = () => { - return DEFAULT_CONFIG_LOC.map((filename) => { - // Since .cjs is not available on interpret side add it manually to default config extension list - return [...Object.keys(extensions), '.cjs'].map((ext) => { - return { - path: resolve(filename + ext), - ext: ext, - module: extensions[ext], - }; - }); - }).reduce((a, i) => a.concat(i), []); -}; - -const getConfigInfoFromFileName = (filename) => { - const ext = extname(filename); - // since we support only one config for now - const allFiles = [filename]; - // return all the file metadata - return allFiles - .map((file) => { - return { - path: resolve(file), - ext: ext, - module: extensions[ext] || null, - }; - }) - .filter((e) => existsSync(e.path)); -}; - -// Reads a config file given the config metadata -const requireConfig = (configModule) => { - const extension = Object.keys(jsVariants).find((t) => configModule.ext.endsWith(t)); - - if (extension) { - rechoir.prepare(extensions, configModule.path, process.cwd()); - } - - let config = require(configModule.path); - - if (config.default) { - config = config.default; - } - - return { config, path: configModule.path }; -}; - -// Responsible for reading user configuration files -// else does a default config lookup and resolves it. -const resolveConfigFiles = async (args) => { - const { config, mode } = args; - - if (config && config.length > 0) { - const resolvedOptions = []; - const finalizedConfigs = config.map(async (webpackConfig) => { - const configPath = resolve(webpackConfig); - const configFiles = getConfigInfoFromFileName(configPath); - - if (!configFiles.length) { - logger.error(`The specified config file doesn't exist in ${configPath}`); - process.exit(2); - } - - const foundConfig = configFiles[0]; - const resolvedConfig = requireConfig(foundConfig); - - return finalize(resolvedConfig, args); - }); - - // resolve all the configs - for await (const resolvedOption of finalizedConfigs) { - if (Array.isArray(resolvedOption.options)) { - resolvedOptions.push(...resolvedOption.options); - } else { - resolvedOptions.push(resolvedOption.options); - } - } - - opts['options'] = resolvedOptions.length > 1 ? resolvedOptions : resolvedOptions[0] || {}; - - return; - } - - // When no config is supplied, lookup for default configs - const defaultConfigFiles = getDefaultConfigFiles(); - const tmpConfigFiles = defaultConfigFiles.filter((file) => { - return existsSync(file.path); - }); - - const configFiles = tmpConfigFiles.map(requireConfig); - if (configFiles.length) { - const defaultConfig = configFiles.find((p) => p.path.includes(mode) || p.path.includes(modeAlias[mode])); - - if (defaultConfig) { - opts = await finalize(defaultConfig, args, true); - return; - } - - const foundConfig = configFiles.pop(); - - opts = await finalize(foundConfig, args, true); - - return; - } -}; - -// Given config data, determines the type of config and -// returns final config -const finalize = async (moduleObj, args, isDefaultConfig = false) => { - const { env, configName } = args; - const newOptionsObject = { - outputOptions: {}, - options: {}, - }; - - if (!moduleObj) { - return newOptionsObject; - } - - if (isDefaultConfig) { - newOptionsObject.outputOptions.defaultConfig = moduleObj.path; - } - - const config = moduleObj.config; - - const isMultiCompilerMode = Array.isArray(config); - const rawConfigs = isMultiCompilerMode ? config : [config]; - - let configs = []; - - const allConfigs = await Promise.all( - rawConfigs.map(async (rawConfig) => { - const isPromise = typeof rawConfig.then === 'function'; - - if (isPromise) { - rawConfig = await rawConfig; - } - - // `Promise` may return `Function` - if (typeof rawConfig === 'function') { - // when config is a function, pass the env from args to the config function - rawConfig = await rawConfig(env, args); - } - - return rawConfig; - }), - ); - - for (const singleConfig of allConfigs) { - if (Array.isArray(singleConfig)) { - configs.push(...singleConfig); - } else { - configs.push(singleConfig); - } - } - - if (configName) { - const foundConfigNames = []; - - configs = configs.filter((options) => { - const found = configName.includes(options.name); - - if (found) { - foundConfigNames.push(options.name); - } - - return found; - }); - - if (foundConfigNames.length !== configName.length) { - // Configuration with name "test" was not found. - logger.error( - configName - .filter((name) => !foundConfigNames.includes(name)) - .map((configName) => `Configuration with name "${configName}" was not found.`) - .join('\n'), - ); - process.exit(2); - } - } - - if (configs.length === 0) { - logger.error('No configurations found'); - process.exit(2); - } - - newOptionsObject['options'] = configs.length > 1 ? configs : configs[0]; - - return newOptionsObject; -}; - -const resolveConfigMerging = async (args) => { - const { merge } = args; - - if (merge) { - // Get the current configuration options - const { options: configOptions } = opts; - - // we can only merge when there are multiple configurations - // either by passing multiple configs by flags or passing a - // single config exporting an array - if (!Array.isArray(configOptions)) { - logger.error('At least two configurations are required for merge.'); - process.exit(2); - } - - // We return a single config object which is passed to the compiler - opts['options'] = configOptions.reduce((currentConfig, mergedConfig) => webpackMerge(currentConfig, mergedConfig), {}); - } -}; - -module.exports = async (args) => { - await resolveConfigFiles(args); - await resolveConfigMerging(args); - - return opts; -}; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 3ca68f4f32d..cb498da4f91 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -2,7 +2,7 @@ const path = require('path'); const packageExists = require('./utils/package-exists'); const webpack = packageExists('webpack') ? require('webpack') : undefined; const webpackMerge = require('webpack-merge'); -const { writeFileSync } = require('fs'); +const { writeFileSync, existsSync } = require('fs'); const { options: coloretteOptions, yellow } = require('colorette'); const logger = require('./utils/logger'); @@ -11,11 +11,13 @@ const argParser = require('./utils/arg-parser'); const assignFlagDefaults = require('./utils/flag-defaults'); const WebpackCLIPlugin = require('./plugins/WebpackCLIPlugin'); const promptInstallation = require('./utils/prompt-installation'); +const { extensions, jsVariants } = require('interpret'); +const rechoir = require('rechoir'); -// CLI arg resolvers -const handleConfigResolution = require('./groups/resolveConfig'); const { toKebabCase } = require('./utils/arg-utils'); +const { resolve, extname } = path; + class WebpackCLI { constructor() { this.compilerConfiguration = {}; @@ -185,6 +187,238 @@ class WebpackCLI { return finalOptions; } + async resolveConfig(args) { + // Order defines the priority, in increasing order + // example - config file lookup will be in order of .webpack/webpack.config.development.js -> webpack.config.development.js -> webpack.config.js + const DEFAULT_CONFIG_LOC = [ + 'webpack.config', + 'webpack.config.dev', + 'webpack.config.development', + 'webpack.config.prod', + 'webpack.config.production', + '.webpack/webpack.config', + '.webpack/webpack.config.none', + '.webpack/webpack.config.dev', + '.webpack/webpack.config.development', + '.webpack/webpack.config.prod', + '.webpack/webpack.config.production', + '.webpack/webpackfile', + ]; + + const modeAlias = { + production: 'prod', + development: 'dev', + }; + + let opts = { + outputOptions: {}, + options: {}, + }; + + // Return a list of default configs in various formats + const getDefaultConfigFiles = () => { + return DEFAULT_CONFIG_LOC.map((filename) => { + // Since .cjs is not available on interpret side add it manually to default config extension list + return [...Object.keys(extensions), '.cjs'].map((ext) => { + return { + path: resolve(filename + ext), + ext: ext, + module: extensions[ext], + }; + }); + }).reduce((a, i) => a.concat(i), []); + }; + + const getConfigInfoFromFileName = (filename) => { + const ext = extname(filename); + // since we support only one config for now + const allFiles = [filename]; + // return all the file metadata + return allFiles + .map((file) => { + return { + path: resolve(file), + ext: ext, + module: extensions[ext] || null, + }; + }) + .filter((e) => existsSync(e.path)); + }; + + // Reads a config file given the config metadata + const requireConfig = (configModule) => { + const extension = Object.keys(jsVariants).find((t) => configModule.ext.endsWith(t)); + + if (extension) { + rechoir.prepare(extensions, configModule.path, process.cwd()); + } + + let config = require(configModule.path); + + if (config.default) { + config = config.default; + } + + return { config, path: configModule.path }; + }; + + // Given config data, determines the type of config and + // returns final config + const finalize = async (moduleObj, args, isDefaultConfig = false) => { + const { env, configName } = args; + const newOptionsObject = { + outputOptions: {}, + options: {}, + }; + + if (!moduleObj) { + return newOptionsObject; + } + + if (isDefaultConfig) { + newOptionsObject.outputOptions.defaultConfig = moduleObj.path; + } + + const config = moduleObj.config; + + const isMultiCompilerMode = Array.isArray(config); + const rawConfigs = isMultiCompilerMode ? config : [config]; + + let configs = []; + + const allConfigs = await Promise.all( + rawConfigs.map(async (rawConfig) => { + const isPromise = typeof rawConfig.then === 'function'; + + if (isPromise) { + rawConfig = await rawConfig; + } + + // `Promise` may return `Function` + if (typeof rawConfig === 'function') { + // when config is a function, pass the env from args to the config function + rawConfig = await rawConfig(env, args); + } + + return rawConfig; + }), + ); + + for (const singleConfig of allConfigs) { + if (Array.isArray(singleConfig)) { + configs.push(...singleConfig); + } else { + configs.push(singleConfig); + } + } + + if (configName) { + const foundConfigNames = []; + + configs = configs.filter((options) => { + const found = configName.includes(options.name); + + if (found) { + foundConfigNames.push(options.name); + } + + return found; + }); + + if (foundConfigNames.length !== configName.length) { + // Configuration with name "test" was not found. + logger.error( + configName + .filter((name) => !foundConfigNames.includes(name)) + .map((configName) => `Configuration with name "${configName}" was not found.`) + .join('\n'), + ); + process.exit(2); + } + } + + if (configs.length === 0) { + logger.error('No configurations found'); + process.exit(2); + } + + newOptionsObject['options'] = configs.length > 1 ? configs : configs[0]; + + return newOptionsObject; + }; + + // Responsible for reading user configuration files + // else does a default config lookup and resolves it. + const { config, mode } = args; + + if (config && config.length > 0) { + const resolvedOptions = []; + const finalizedConfigs = config.map(async (webpackConfig) => { + const configPath = resolve(webpackConfig); + const configFiles = getConfigInfoFromFileName(configPath); + + if (!configFiles.length) { + logger.error(`The specified config file doesn't exist in ${configPath}`); + process.exit(2); + } + + const foundConfig = configFiles[0]; + const resolvedConfig = requireConfig(foundConfig); + + return finalize(resolvedConfig, args); + }); + + // resolve all the configs + for await (const resolvedOption of finalizedConfigs) { + if (Array.isArray(resolvedOption.options)) { + resolvedOptions.push(...resolvedOption.options); + } else { + resolvedOptions.push(resolvedOption.options); + } + } + + opts['options'] = resolvedOptions.length > 1 ? resolvedOptions : resolvedOptions[0] || {}; + } else { + // When no config is supplied, lookup for default configs + const defaultConfigFiles = getDefaultConfigFiles(); + const tmpConfigFiles = defaultConfigFiles.filter((file) => { + return existsSync(file.path); + }); + + const configFiles = tmpConfigFiles.map(requireConfig); + if (configFiles.length) { + const defaultConfig = configFiles.find((p) => p.path.includes(mode) || p.path.includes(modeAlias[mode])); + if (defaultConfig) { + opts = await finalize(defaultConfig, args, true); + } else { + const foundConfig = configFiles.pop(); + + opts = await finalize(foundConfig, args, true); + } + } + } + + const { merge } = args; + + if (merge) { + // Get the current configuration options + const { options: configOptions } = opts; + + // we can only merge when there are multiple configurations + // either by passing multiple configs by flags or passing a + // single config exporting an array + if (!Array.isArray(configOptions)) { + logger.error('At least two configurations are required for merge.'); + process.exit(2); + } + + // We return a single config object which is passed to the compiler + opts['options'] = configOptions.reduce((currentConfig, mergedConfig) => webpackMerge(currentConfig, mergedConfig), {}); + } + + return opts; + } + async _baseResolver(cb, parsedArgs, strategy) { const resolvedConfig = await cb(parsedArgs, this.compilerConfiguration); this._mergeOptionsToConfiguration(resolvedConfig.options, strategy); @@ -282,7 +516,7 @@ class WebpackCLI { */ async runOptionGroups(parsedArgs) { await Promise.resolve() - .then(() => this._baseResolver(handleConfigResolution, parsedArgs)) + .then(() => this._baseResolver(this.resolveConfig, parsedArgs)) .then(() => this._handleCoreFlags(parsedArgs)) .then(() => this._baseResolver(this.resolveArgs, parsedArgs)); } From b4289c0a2e531ecfa1cfd66dc90c71189788bc36 Mon Sep 17 00:00:00 2001 From: James George Date: Tue, 10 Nov 2020 22:20:45 +0530 Subject: [PATCH 083/581] chore: remove cross-spawn (#2097) --- packages/utils/__tests__/global-packages-path.test.ts | 10 +++------- packages/utils/package.json | 2 -- packages/utils/src/global-packages-path.ts | 4 ++-- yarn.lock | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/utils/__tests__/global-packages-path.test.ts b/packages/utils/__tests__/global-packages-path.test.ts index 5aa77543595..91bfde39677 100644 --- a/packages/utils/__tests__/global-packages-path.test.ts +++ b/packages/utils/__tests__/global-packages-path.test.ts @@ -12,7 +12,7 @@ const globalModulesNpmValue = 'test-npm'; jest.setMock('global-modules', globalModulesNpmValue); import * as path from 'path'; -import * as spawn from 'cross-spawn'; +import * as execa from 'execa'; describe('getPathToGlobalPackages', () => { it('uses global-modules if package manager is npm', () => { @@ -22,12 +22,8 @@ describe('getPathToGlobalPackages', () => { it('executes a command to find yarn global dir if package manager is yarn', () => { (getPackageManager as jest.Mock).mockReturnValue('yarn'); - (spawn.sync as jest.Mock).mockReturnValue({ - stdout: { - toString: (): string => { - return 'test-yarn'; - }, - }, + (execa.sync as jest.Mock).mockReturnValue({ + stdout: 'test-yarn', }); // after the yarn global dir is found, the node_modules directory // is added on to the path diff --git a/packages/utils/package.json b/packages/utils/package.json index 36bd4bbb257..8ceef2af2f9 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -13,7 +13,6 @@ ], "dependencies": { "colorette": "^1.2.1", - "cross-spawn": "^7.0.3", "execa": "^4.1.0", "findup-sync": "^4.0.0", "global-modules": "^2.0.0", @@ -28,7 +27,6 @@ "webpack-cli": "4.x.x" }, "devDependencies": { - "@types/cross-spawn": "^6.0.2", "@types/got": "^9.6.11", "@types/prettier": "^2.1.5", "@types/yeoman-generator": "^4.11.3" diff --git a/packages/utils/src/global-packages-path.ts b/packages/utils/src/global-packages-path.ts index feac325b6d5..8dde1dd5354 100644 --- a/packages/utils/src/global-packages-path.ts +++ b/packages/utils/src/global-packages-path.ts @@ -1,4 +1,4 @@ -import spawn from 'cross-spawn'; +import { sync } from 'execa'; import path from 'path'; import { utils } from 'webpack-cli'; @@ -16,7 +16,7 @@ export function getPathToGlobalPackages(): string { const manager: string = getPackageManager(); if (manager === 'yarn') { try { - const yarnDir = spawn.sync('yarn', ['global', 'dir']).stdout.toString().trim(); + const yarnDir = sync('yarn', ['global', 'dir']).stdout; return path.join(yarnDir, 'node_modules'); } catch (e) { // Default to the global npm path below diff --git a/yarn.lock b/yarn.lock index 3b80a4ea410..5cf56c3cfbe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4203,7 +4203,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== From f6f4585a71b8f5cbb5dcb54a464ac3489e61ba36 Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Wed, 11 Nov 2020 17:22:19 +0300 Subject: [PATCH 084/581] refactor: code --- .../webpack-cli/__tests__/arg-parser.test.js | 4 +- packages/webpack-cli/lib/bootstrap.js | 25 ++- packages/webpack-cli/lib/groups/runHelp.js | 208 ++++++++++-------- packages/webpack-cli/lib/groups/runVersion.js | 80 ++++--- .../utils/__tests__/package-exists.test.js | 4 +- packages/webpack-cli/lib/utils/arg-parser.js | 29 +-- packages/webpack-cli/lib/utils/arg-utils.js | 30 --- packages/webpack-cli/lib/utils/cli-flags.js | 32 ++- .../webpack-cli/lib/utils/resolve-command.js | 22 +- .../webpack-cli/lib/utils/to-kebab-case.js | 5 + .../webpack-cli/lib/utils/unknown-args.js | 30 --- packages/webpack-cli/lib/webpack-cli.js | 93 +++++--- test/help/help-commands.test.js | 32 +-- test/help/help-flags.test.js | 38 ++-- test/info/info-help.test.js | 7 +- test/utils/test-utils.js | 10 +- .../version/version-external-packages.test.js | 25 ++- test/version/version-multi-args.test.js | 48 ++-- 18 files changed, 371 insertions(+), 351 deletions(-) delete mode 100644 packages/webpack-cli/lib/utils/arg-utils.js create mode 100644 packages/webpack-cli/lib/utils/to-kebab-case.js delete mode 100644 packages/webpack-cli/lib/utils/unknown-args.js diff --git a/packages/webpack-cli/__tests__/arg-parser.test.js b/packages/webpack-cli/__tests__/arg-parser.test.js index 018a27679ec..f61aab4d3a3 100644 --- a/packages/webpack-cli/__tests__/arg-parser.test.js +++ b/packages/webpack-cli/__tests__/arg-parser.test.js @@ -13,7 +13,7 @@ const processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {}); const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const argParser = require('../lib/utils/arg-parser'); -const { core } = require('../lib/utils/cli-flags'); +const { flags } = require('../lib/utils/cli-flags'); const basicOptions = [ { @@ -362,7 +362,7 @@ describe('arg-parser', () => { }); it('parses webpack args', () => { - const res = argParser(core, ['--entry', 'test.js', '--hot', '-o', './dist/', '--stats'], true); + const res = argParser(flags, ['--entry', 'test.js', '--hot', '-o', './dist/', '--stats'], true); expect(res.unknownArgs.length).toEqual(0); expect(res.opts.entry).toEqual(['test.js']); expect(res.opts.hot).toBeTruthy(); diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index 6ff74f315cf..3291885ee46 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -1,7 +1,7 @@ const WebpackCLI = require('./webpack-cli'); -const { core } = require('./utils/cli-flags'); +const { flags } = require('./utils/cli-flags'); const logger = require('./utils/logger'); -const { isCommandUsed } = require('./utils/arg-utils'); +const { isCommandUsed } = require('./utils/cli-flags'); const argParser = require('./utils/arg-parser'); const leven = require('leven'); const { options: coloretteOptions } = require('colorette'); @@ -9,9 +9,15 @@ const { options: coloretteOptions } = require('colorette'); process.title = 'webpack-cli'; const runCLI = async (cliArgs) => { - const parsedArgs = argParser(core, cliArgs, true, process.title); + const parsedArgs = argParser(flags, cliArgs, true, process.title); + + // Enable/Disable colors + if (typeof parsedArgs.opts.color !== 'undefined') { + coloretteOptions.enabled = Boolean(parsedArgs.opts.color); + } const commandIsUsed = isCommandUsed(cliArgs); + if (commandIsUsed) { return; } @@ -24,11 +30,6 @@ const runCLI = async (cliArgs) => { // If the unknown arg starts with a '-', it will be considered an unknown flag rather than an entry let entry; - // enable/disable colors - if (typeof parsedArgs.opts.color !== 'undefined') { - coloretteOptions.enabled = Boolean(parsedArgs.opts.color); - } - if (parsedArgs.unknownArgs.length > 0) { entry = []; @@ -44,10 +45,12 @@ const runCLI = async (cliArgs) => { } if (parsedArgs.unknownArgs.length > 0) { - parsedArgs.unknownArgs.forEach(async (unknown) => { + parsedArgs.unknownArgs.forEach((unknown) => { logger.error(`Unknown argument: ${unknown}`); + const strippedFlag = unknown.substr(2); - const { name: suggestion } = core.find((flag) => leven(strippedFlag, flag.name) < 3); + const { name: suggestion } = flags.find((flag) => leven(strippedFlag, flag.name) < 3); + if (suggestion) { logger.raw(`Did you mean --${suggestion}?`); } @@ -62,7 +65,7 @@ const runCLI = async (cliArgs) => { parsedArgsOpts.entry = entry; } - await cli.run(parsedArgsOpts, core); + await cli.run(parsedArgsOpts, flags); } catch (error) { logger.error(error); process.exit(2); diff --git a/packages/webpack-cli/lib/groups/runHelp.js b/packages/webpack-cli/lib/groups/runHelp.js index 389437511f0..fddbc79e38a 100644 --- a/packages/webpack-cli/lib/groups/runHelp.js +++ b/packages/webpack-cli/lib/groups/runHelp.js @@ -1,116 +1,138 @@ -const { yellow, bold, underline, options } = require('colorette'); +const { options, green, bold, underline } = require('colorette'); const commandLineUsage = require('command-line-usage'); -const { core, commands } = require('../utils/cli-flags'); -const { hasUnknownArgs, allNames, commands: commandNames } = require('../utils/unknown-args'); +const { commands, flags } = require('../utils/cli-flags'); const logger = require('../utils/logger'); -// This function prints a warning about invalid flag -const printInvalidArgWarning = (args) => { - const invalidArgs = hasUnknownArgs(args, allNames); +const outputHelp = (args) => { + if (args.includes('--color')) { + options.enabled = true; + } else if (args.includes('--no-color')) { + options.enabled = false; + } + + const hasUnknownVersionArgs = (args, commands, flags) => { + return args.filter((arg) => { + if (arg === 'version' || arg === 'help' || arg === '--help' || arg === '-h' || arg === '--no-color') { + return false; + } + + const foundCommand = commands.find((command) => { + return command.name === arg || command.alias === arg; + }); + const foundFlag = flags.find((command) => { + return `--${command.name}` === arg || `-${command.alias}` === arg; + }); + + return !foundCommand && !foundFlag; + }); + }; + + const invalidArgs = hasUnknownVersionArgs(args, commands, flags); + if (invalidArgs.length > 0) { const argType = invalidArgs[0].startsWith('-') ? 'option' : 'command'; - logger.warn(`You provided an invalid ${argType} '${invalidArgs[0]}'.`); + logger.error(`Invalid ${argType} '${invalidArgs[0]}'.`); + logger.error('Run webpack --help to see available commands and arguments.'); + process.exit(2); } -}; -// This function is responsible for printing command/flag scoped help -const printSubHelp = (subject, isCommand) => { - const info = isCommand ? commands : core; - // Contains object with details about given subject - const options = info.find((commandOrFlag) => { - if (isCommand) { - return commandOrFlag.name == subject || commandOrFlag.alias == subject; + const usedCommand = commands.filter((command) => { + return args.includes(command.name) || args.includes(command.alias); + }); + const usedFlag = flags.filter((flag) => { + if (flag.name === 'help' || flag.name === 'color') { + return false; } - return commandOrFlag.name === subject.slice(2) || commandOrFlag.alias === subject.slice(1); + + return args.includes(`--${flag.name}`) || args.includes(`-${flag.alias}`); }); - const header = (head) => bold(underline(head)); - const flagAlias = options.alias ? (isCommand ? ` ${options.alias} |` : ` -${options.alias},`) : ''; - const usage = yellow(`webpack${flagAlias} ${options.usage}`); - const description = options.description; - const link = options.link; + const usedCommandOrFlag = [].concat(usedCommand).concat(usedFlag); - logger.raw(`${header('Usage')}: ${usage}`); - logger.raw(`${header('Description')}: ${description}`); + if (usedCommandOrFlag.length > 1) { + logger.error( + `You provided multiple commands or arguments - ${usedCommandOrFlag + .map((usedFlagOrCommand) => { + const isCommand = usedFlagOrCommand.packageName; - if (link) { - logger.raw(`${header('Documentation')}: ${link}`); + return `${isCommand ? 'command ' : 'argument '}'${isCommand ? usedFlagOrCommand.name : `--${usedFlagOrCommand.name}`}'${ + usedFlagOrCommand.alias ? ` (alias '${isCommand ? usedFlagOrCommand.alias : `-${usedFlagOrCommand.alias}`}')` : '' + }`; + }) + .join(', ')}. Please use only one command at a time.`, + ); + process.exit(2); } - if (options.flags) { - const flags = commandLineUsage({ - header: 'Options', - optionList: options.flags, - }); - logger.raw(flags); - } -}; + // Print full help when no flag or command is supplied with help + if (usedCommandOrFlag.length === 1) { + const [item] = usedCommandOrFlag; + const isCommand = item.packageName; + const header = (head) => bold(underline(head)); + const flagAlias = item.alias ? (isCommand ? ` ${item.alias} |` : ` -${item.alias},`) : ''; + const usage = green(`webpack${flagAlias} ${item.usage}`); + const description = item.description; + const link = item.link; -const printHelp = () => { - const o = (s) => yellow(s); - const options = require('../utils/cli-flags'); - const negatedFlags = options.core - .filter((flag) => flag.negative) - .reduce((allFlags, flag) => { - return [...allFlags, { name: `no-${flag.name}`, description: `Negates ${flag.name}`, type: Boolean }]; - }, []); - const title = bold('⬡ ') + underline('webpack') + bold(' ⬡'); - const desc = 'The build tool for modern web applications'; - const websitelink = ' ' + underline('https://webpack.js.org'); - - const usage = bold('Usage') + ': ' + '`' + o('webpack [...options] | ') + '`'; - const examples = bold('Example') + ': ' + '`' + o('webpack help --flag | ') + '`'; - - const hh = ` ${title}\n - ${websitelink}\n - ${desc}\n - ${usage}\n - ${examples}\n -`; - return commandLineUsage([ - { - content: hh, - raw: true, - }, - { - header: 'Available Commands', - content: options.commands.map((cmd) => { - return { name: `${cmd.name} | ${cmd.alias}`, summary: cmd.description }; - }), - }, - { - header: 'Options', - optionList: options.core - .map((e) => { - if (e.type.length > 1) e.type = e.type[0]; - // Here we replace special characters with chalk's escape - // syntax (`\$&`) to avoid chalk trying to re-process our input. - // This is needed because chalk supports a form of `{var}` - // interpolation. - e.description = e.description.replace(/[{}\\]/g, '\\$&'); - return e; - }) - .concat(negatedFlags), - }, - ]); -}; + logger.raw(`${header('Usage')}: ${usage}`); + logger.raw(`${header('Description')}: ${description}`); -const outputHelp = (cliArgs) => { - options.enabled = !cliArgs.includes('--no-color'); - printInvalidArgWarning(cliArgs); - const flagOrCommandUsed = allNames.filter((name) => { - return cliArgs.includes(name); - })[0]; - const isCommand = commandNames.includes(flagOrCommandUsed); + if (link) { + logger.raw(`${header('Documentation')}: ${link}`); + } - // Print full help when no flag or command is supplied with help - if (flagOrCommandUsed) { - printSubHelp(flagOrCommandUsed, isCommand); + if (item.flags) { + const flags = commandLineUsage({ + header: 'Options', + optionList: item.flags, + }); + logger.raw(flags); + } } else { - logger.raw(printHelp()); + const negatedFlags = flags + .filter((flag) => flag.negative) + .reduce((allFlags, flag) => { + return [...allFlags, { name: `no-${flag.name}`, description: `Negates ${flag.name}`, type: Boolean }]; + }, []); + const title = bold('⬡ ') + underline('webpack') + bold(' ⬡'); + const desc = 'The build tool for modern web applications'; + const websitelink = ' ' + underline('https://webpack.js.org'); + const usage = bold('Usage') + ': ' + '`' + green('webpack [...options] | ') + '`'; + const examples = bold('Example') + ': ' + '`' + green('webpack help --flag | ') + '`'; + const hh = ` ${title}\n\n${websitelink}\n\n${desc}\n\n${usage}\n${examples}`; + const output = commandLineUsage([ + { content: hh, raw: true }, + { + header: 'Available Commands', + content: commands.map((cmd) => { + return { name: `${cmd.name} | ${cmd.alias}`, summary: cmd.description }; + }), + }, + { + header: 'Options', + optionList: flags + .map((e) => { + if (e.type.length > 1) { + e.type = e.type[0]; + } + + // Here we replace special characters with chalk's escape + // syntax (`\$&`) to avoid chalk trying to re-process our input. + // This is needed because chalk supports a form of `{var}` + // interpolation. + e.description = e.description.replace(/[{}\\]/g, '\\$&'); + + return e; + }) + .concat(negatedFlags), + }, + ]); + + logger.raw(output); } - logger.raw('\n Made with ♥️ by the webpack team'); + + logger.raw(' Made with ♥️ by the webpack team'); }; module.exports = outputHelp; diff --git a/packages/webpack-cli/lib/groups/runVersion.js b/packages/webpack-cli/lib/groups/runVersion.js index 9db978bb3dd..757131c5743 100644 --- a/packages/webpack-cli/lib/groups/runVersion.js +++ b/packages/webpack-cli/lib/groups/runVersion.js @@ -1,46 +1,68 @@ const logger = require('../utils/logger'); -const { defaultCommands } = require('../utils/cli-flags'); -const { isCommandUsed } = require('../utils/arg-utils'); -const { commands, allNames, hasUnknownArgs } = require('../utils/unknown-args'); +const { commands, flags } = require('../utils/cli-flags'); +const { options } = require('colorette'); const outputVersion = (args) => { - // This is used to throw err when there are multiple command along with version - const commandsUsed = args.filter((val) => commands.includes(val)); + if (args.includes('--color')) { + options.enabled = true; + } else if (args.includes('--no-color')) { + options.enabled = false; + } - // The command with which version is invoked - const commandUsed = isCommandUsed(args); - const invalidArgs = hasUnknownArgs(args, allNames); - if (commandsUsed && commandsUsed.length === 1 && invalidArgs.length === 0) { - try { - if ([commandUsed.alias, commandUsed.name].some((pkg) => commandsUsed.includes(pkg))) { - const { name, version } = require(`@webpack-cli/${defaultCommands[commandUsed.name]}/package.json`); - logger.raw(`\n${name} ${version}`); - } else { - const { name, version } = require(`${commandUsed.name}/package.json`); - logger.raw(`\n${name} ${version}`); + const hasUnknownVersionArgs = (args, commands, flags) => { + return args.filter((arg) => { + if (arg === 'version' || arg === '--version' || arg === '-v' || arg === '--color' || arg === '--no-color') { + return false; } - } catch (e) { - logger.error('Error: External package not found.'); - process.exit(2); - } - } - if (commandsUsed.length > 1) { - logger.error('You provided multiple commands. Please use only one command at a time.\n'); - process.exit(2); - } + const foundCommand = commands.find((command) => { + return command.name === arg || command.alias === arg; + }); + const foundFlag = flags.find((command) => { + return `--${command.name}` === arg || `-${command.alias}` === arg; + }); + + return !foundCommand && !foundFlag; + }); + }; + + const invalidArgs = hasUnknownVersionArgs(args, commands, flags); if (invalidArgs.length > 0) { const argType = invalidArgs[0].startsWith('-') ? 'option' : 'command'; - logger.error(`Error: Invalid ${argType} '${invalidArgs[0]}'.`); - logger.info('Run webpack --help to see available commands and arguments.\n'); + logger.error(`Invalid ${argType} '${invalidArgs[0]}'.`); + logger.error('Run webpack --help to see available commands and arguments.'); process.exit(2); } + const usedCommands = commands.filter((command) => { + return args.includes(command.name) || args.includes(command.alias); + }); + + if (usedCommands.length > 1) { + logger.error( + `You provided multiple commands - ${usedCommands + .map((command) => `'${command.name}'${command.alias ? ` (alias '${command.alias}')` : ''}`) + .join(', ')}. Please use only one command at a time.`, + ); + process.exit(2); + } + + if (usedCommands.length === 1) { + try { + const { name, version } = require(`${usedCommands[0].packageName}/package.json`); + logger.raw(`${name} ${version}`); + } catch (e) { + logger.error('Error: External package not found.'); + process.exit(2); + } + } + const pkgJSON = require('../../package.json'); const webpack = require('webpack'); - logger.raw(`\nwebpack-cli ${pkgJSON.version}`); - logger.raw(`\nwebpack ${webpack.version}\n`); + + logger.raw(`webpack-cli ${pkgJSON.version}`); + logger.raw(`webpack ${webpack.version}`); }; module.exports = outputVersion; diff --git a/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js b/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js index cc8979088ab..a684ea214c0 100644 --- a/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js @@ -11,10 +11,10 @@ describe('@webpack-cli/utils', () => { expect(packageExists('./nonexistent-package')).toBeFalsy(); }); - it('should not throw if the user interrupts', async () => { + it.skip('should not throw if the user interrupts', async () => { promptInstallation.mockImplementation(() => { throw new Error(); }); - await expect(ExternalCommand('info')).resolves.not.toThrow(); + await expect(ExternalCommand('@webpack-cli/info')).resolves.not.toThrow(); }); }); diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index 73dbfb350c0..7cbab371fa3 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -3,7 +3,6 @@ const logger = require('./logger'); const { commands } = require('./cli-flags'); const runHelp = require('../groups/runHelp'); const runVersion = require('../groups/runVersion'); -const { defaultCommands } = require('./cli-flags'); /** * Creates Argument parser corresponding to the supplied options @@ -12,10 +11,24 @@ const { defaultCommands } = require('./cli-flags'); * @param {object[]} options Array of objects with details about flags * @param {string[]} args process.argv or it's subset * @param {boolean} argsOnly false if all of process.argv has been provided, true if + * @param {string} name Parser name * args is only a subset of process.argv that removes the first couple elements */ const argParser = (options, args, argsOnly = false, name = '') => { + // Use customized help output + if (args.includes('--help') || args.includes('help')) { + runHelp(args); + process.exit(0); + } + + // Use Customized version + if (args.includes('--version') || args.includes('version') || args.includes('-v')) { + runVersion(args); + process.exit(0); + } + const parser = new commander.Command(); + // Set parser name parser.name(name); parser.storeOptionsAsProperties(false); @@ -30,7 +43,7 @@ const argParser = (options, args, argsOnly = false, name = '') => { .action(async () => { const cliArgs = args.slice(args.indexOf(cmd.name) + 1 || args.indexOf(cmd.alias) + 1); - return await require('./resolve-command')(defaultCommands[cmd.name], ...cliArgs); + return await require('./resolve-command')(cmd.packageName, ...cliArgs); }); return parser; @@ -39,18 +52,6 @@ const argParser = (options, args, argsOnly = false, name = '') => { // Prevent default behavior parser.on('command:*', () => {}); - // Use customized help output - if (args.includes('--help') || args.includes('help')) { - runHelp(args); - process.exit(0); - } - - // Use Customized version - if (args.includes('--version') || args.includes('version') || args.includes('-v')) { - runVersion(args); - process.exit(0); - } - // Allow execution if unknown arguments are present parser.allowUnknownOption(true); diff --git a/packages/webpack-cli/lib/utils/arg-utils.js b/packages/webpack-cli/lib/utils/arg-utils.js deleted file mode 100644 index a5f4179909c..00000000000 --- a/packages/webpack-cli/lib/utils/arg-utils.js +++ /dev/null @@ -1,30 +0,0 @@ -const { commands } = require('./cli-flags'); - -const hyphenToUpperCase = (name) => { - if (!name) { - return name; - } - return name.replace(/-([a-z])/g, function (g) { - return g[1].toUpperCase(); - }); -}; - -/** - * Convert camelCase to kebab-case - * @param {string} str input string in camelCase - * @returns {string} output string in kebab-case - */ -const toKebabCase = (str) => { - return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); -}; - -const isCommandUsed = (args) => - commands.find((cmd) => { - return args.includes(cmd.name) || args.includes(cmd.alias); - }); - -module.exports = { - toKebabCase, - hyphenToUpperCase, - isCommandUsed, -}; diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 2949b4b9459..72ea25577d1 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -9,6 +9,7 @@ const groups = { const commands = [ { + packageName: '@webpack-cli/init', name: 'init', alias: 'c', type: String, @@ -33,6 +34,7 @@ const commands = [ ], }, { + packageName: '@webpack-cli/migrate', name: 'migrate', alias: 'm', type: String, @@ -40,6 +42,7 @@ const commands = [ description: 'Migrate a configuration to a new version', }, { + packageName: '@webpack-cli/generate-loader', name: 'loader', scope: 'external', alias: 'l', @@ -48,6 +51,7 @@ const commands = [ description: 'Scaffold a loader repository', }, { + packageName: '@webpack-cli/generate-plugin', name: 'plugin', alias: 'p', scope: 'external', @@ -56,6 +60,7 @@ const commands = [ description: 'Scaffold a plugin repository', }, { + packageName: '@webpack-cli/info', name: 'info', scope: 'external', alias: 'i', @@ -76,6 +81,7 @@ const commands = [ ], }, { + packageName: '@webpack-cli/serve', name: 'serve', alias: 's', scope: 'external', @@ -85,7 +91,7 @@ const commands = [ }, ]; -const core = [ +const builtInFlags = [ { name: 'entry', usage: '--entry | --entry --entry ', @@ -270,30 +276,20 @@ let flagsFromCore = : []; // duplicate flags -const duplicateFlags = core.map((flag) => flag.name); +const duplicateFlags = builtInFlags.map((flag) => flag.name); // remove duplicate flags flagsFromCore = flagsFromCore.filter((flag) => !duplicateFlags.includes(flag.name)); -const coreFlagMap = flagsFromCore.reduce((acc, cur) => { - acc.set(cur.name, cur); - return acc; -}, new Map()); - -const defaultCommands = { - init: 'init', - loader: 'generate-loader', - plugin: 'generate-plugin', - info: 'info', - migrate: 'migrate', - serve: 'serve', -}; +const isCommandUsed = (args) => + commands.find((cmd) => { + return args.includes(cmd.name) || args.includes(cmd.alias); + }); module.exports = { groups, commands, - core: [...core, ...flagsFromCore], flagsFromCore, - coreFlagMap, - defaultCommands, + flags: [...builtInFlags, ...flagsFromCore], + isCommandUsed, }; diff --git a/packages/webpack-cli/lib/utils/resolve-command.js b/packages/webpack-cli/lib/utils/resolve-command.js index fc4d4e1d08e..c896d190f01 100644 --- a/packages/webpack-cli/lib/utils/resolve-command.js +++ b/packages/webpack-cli/lib/utils/resolve-command.js @@ -3,17 +3,13 @@ const logger = require('./logger'); const packageExists = require('./package-exists'); const promptInstallation = require('./prompt-installation'); -const packagePrefix = '@webpack-cli'; - const run = async (name, ...args) => { - const scopeName = packagePrefix + '/' + name; - - let pkgLoc = packageExists(scopeName); + let packageLocation = packageExists(name); - if (!pkgLoc) { + if (!packageLocation) { try { - pkgLoc = await promptInstallation(`${scopeName}`, () => { - logger.error(`The command moved into a separate package: ${yellow(scopeName)}\n`); + packageLocation = await promptInstallation(`${name}`, () => { + logger.error(`The command moved into a separate package: ${yellow(name)}\n`); }); } catch (err) { logger.error(`Action Interrupted, use ${cyan('webpack-cli help')} to see possible commands.`); @@ -21,17 +17,17 @@ const run = async (name, ...args) => { } } - if (!pkgLoc) { + if (!packageLocation) { return; } - let mod = require(scopeName); + let loaded = require(name); - if (mod.default) { - mod = mod.default; + if (loaded.default) { + loaded = loaded.default; } - return mod(...args); + return loaded(...args); }; module.exports = run; diff --git a/packages/webpack-cli/lib/utils/to-kebab-case.js b/packages/webpack-cli/lib/utils/to-kebab-case.js new file mode 100644 index 00000000000..fb241fbdc94 --- /dev/null +++ b/packages/webpack-cli/lib/utils/to-kebab-case.js @@ -0,0 +1,5 @@ +const toKebabCase = (str) => { + return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); +}; + +module.exports = toKebabCase; diff --git a/packages/webpack-cli/lib/utils/unknown-args.js b/packages/webpack-cli/lib/utils/unknown-args.js deleted file mode 100644 index 675b1b7539d..00000000000 --- a/packages/webpack-cli/lib/utils/unknown-args.js +++ /dev/null @@ -1,30 +0,0 @@ -const { commands, core } = require('./cli-flags'); - -// Contains an array of strings with commands and their aliases that the cli supports -const commandNames = commands - .map(({ alias, name }) => { - if (alias) { - return [name, alias]; - } - return [name]; - }) - .reduce((arr, val) => arr.concat(val), []); - -// Contains an array of strings with core cli flags and their aliases -const flagNames = core - .map(({ alias, name }) => { - if (name === 'help') return []; - if (alias) { - return [`--${name}`, `-${alias}`]; - } - return [`--${name}`]; - }) - .reduce((arr, val) => arr.concat(val), []); - -module.exports = { - commands: [...commandNames], - flags: [...flagNames], - allNames: [...commandNames, ...flagNames], - hasUnknownArgs: (args, names) => - args.filter((e) => !names.includes(e) && !e.includes('color') && e !== 'version' && e !== '-v' && !e.includes('help')), -}; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index cb498da4f91..f195e18de90 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -6,7 +6,7 @@ const { writeFileSync, existsSync } = require('fs'); const { options: coloretteOptions, yellow } = require('colorette'); const logger = require('./utils/logger'); -const { core, groups, coreFlagMap } = require('./utils/cli-flags'); +const { groups, flags, flagsFromCore } = require('./utils/cli-flags'); const argParser = require('./utils/arg-parser'); const assignFlagDefaults = require('./utils/flag-defaults'); const WebpackCLIPlugin = require('./plugins/WebpackCLIPlugin'); @@ -14,7 +14,7 @@ const promptInstallation = require('./utils/prompt-installation'); const { extensions, jsVariants } = require('interpret'); const rechoir = require('rechoir'); -const { toKebabCase } = require('./utils/arg-utils'); +const toKebabCase = require('./utils/to-kebab-case'); const { resolve, extname } = path; @@ -31,27 +31,39 @@ class WebpackCLI { */ _handleCoreFlags(parsedArgs) { const coreCliHelper = require('webpack').cli; - if (!coreCliHelper) return; + + if (!coreCliHelper) { + return; + } + + const coreFlagMap = flagsFromCore.reduce((acc, cur) => { + acc.set(cur.name, cur); + + return acc; + }, new Map()); const coreConfig = Object.keys(parsedArgs) - .filter((arg) => { - return coreFlagMap.has(toKebabCase(arg)); - }) + .filter((arg) => coreFlagMap.has(toKebabCase(arg))) .reduce((acc, cur) => { acc[toKebabCase(cur)] = parsedArgs[cur]; + return acc; }, {}); const coreCliArgs = coreCliHelper.getArguments(); + // Merge the core flag config with the compilerConfiguration coreCliHelper.processArguments(coreCliArgs, this.compilerConfiguration, coreConfig); + // Assign some defaults to core flags const configWithDefaults = assignFlagDefaults(this.compilerConfiguration, parsedArgs, this.outputConfiguration); + this._mergeOptionsToConfiguration(configWithDefaults); } async resolveArgs(args, configOptions = {}) { // when there are no args then exit - // eslint-disable-next-line no-prototype-builtins - if (Object.keys(args).length === 0 && !process.env.NODE_ENV) return {}; + if (Object.keys(args).length === 0 && !process.env.NODE_ENV) { + return {}; + } const { outputPath, stats, json, mode, target, prefetch, hot, analyze } = args; const finalOptions = { @@ -59,15 +71,15 @@ class WebpackCLI { outputOptions: {}, }; - const WEBPACK_OPTION_FLAGS = core - .filter((coreFlag) => { - return coreFlag.group === groups.BASIC_GROUP; - }) + const WEBPACK_OPTION_FLAGS = flags + .filter((coreFlag) => coreFlag.group === groups.BASIC_GROUP) .reduce((result, flagObject) => { result.push(flagObject.name); + if (flagObject.alias) { result.push(flagObject.alias); } + return result; }, []); @@ -91,7 +103,9 @@ class WebpackCLI { env: { NODE_ENV }, } = process; const { mode: configMode } = configObject; + let finalMode; + if (mode) { finalMode = mode; } else if (configMode) { @@ -101,6 +115,7 @@ class WebpackCLI { } else { finalMode = PRODUCTION; } + return finalMode; }; @@ -108,19 +123,24 @@ class WebpackCLI { if (WEBPACK_OPTION_FLAGS.includes(arg)) { finalOptions.outputOptions[arg] = args[arg]; } + if (arg === 'devtool') { finalOptions.options.devtool = args[arg]; } + if (arg === 'name') { finalOptions.options.name = args[arg]; } + if (arg === 'watch') { finalOptions.options.watch = true; } + if (arg === 'entry') { finalOptions.options[arg] = args[arg]; } }); + if (outputPath) { finalOptions.options.output = { path: path.resolve(outputPath) }; } @@ -128,6 +148,7 @@ class WebpackCLI { if (stats !== undefined) { finalOptions.options.stats = stats; } + if (json) { finalOptions.outputOptions.json = json; } @@ -135,42 +156,50 @@ class WebpackCLI { if (hot) { const { HotModuleReplacementPlugin } = require('webpack'); const hotModuleVal = new HotModuleReplacementPlugin(); + if (finalOptions.options && finalOptions.options.plugins) { finalOptions.options.plugins.unshift(hotModuleVal); } else { finalOptions.options.plugins = [hotModuleVal]; } } + if (prefetch) { const { PrefetchPlugin } = require('webpack'); const prefetchVal = new PrefetchPlugin(null, args.prefetch); + if (finalOptions.options && finalOptions.options.plugins) { finalOptions.options.plugins.unshift(prefetchVal); } else { finalOptions.options.plugins = [prefetchVal]; } } + if (analyze) { if (packageExists('webpack-bundle-analyzer')) { // eslint-disable-next-line node/no-extraneous-require const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); const bundleAnalyzerVal = new BundleAnalyzerPlugin(); + if (finalOptions.options && finalOptions.options.plugins) { finalOptions.options.plugins.unshift(bundleAnalyzerVal); } else { finalOptions.options.plugins = [bundleAnalyzerVal]; } } else { - await promptInstallation('webpack-bundle-analyzer', () => { - logger.error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); - }) - .then(() => logger.success(`${yellow('webpack-bundle-analyzer')} was installed sucessfully.`)) - .catch(() => { - logger.error(`Action Interrupted, Please try once again or install ${yellow('webpack-bundle-analyzer')} manually.`); - process.exit(2); + try { + await promptInstallation('webpack-bundle-analyzer', () => { + logger.error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); }); + } catch (error) { + logger.error(`Action Interrupted, Please try once again or install ${yellow('webpack-bundle-analyzer')} manually.`); + process.exit(2); + } + + logger.success(`${yellow('webpack-bundle-analyzer')} was installed successfully.`); } } + if (target) { finalOptions.options.target = args.target; } @@ -184,6 +213,7 @@ class WebpackCLI { } else { finalOptions.options.mode = assignMode(mode, configOptions); } + return finalOptions; } @@ -421,8 +451,12 @@ class WebpackCLI { async _baseResolver(cb, parsedArgs, strategy) { const resolvedConfig = await cb(parsedArgs, this.compilerConfiguration); + this._mergeOptionsToConfiguration(resolvedConfig.options, strategy); - this._mergeOptionsToOutputConfiguration(resolvedConfig.outputOptions); + + if (resolvedConfig.outputOptions) { + this.outputConfiguration = Object.assign(this.outputConfiguration, resolvedConfig.outputOptions); + } } /** @@ -434,7 +468,7 @@ class WebpackCLI { } getCoreFlags() { - return core; + return flags; } /** @@ -453,9 +487,11 @@ class WebpackCLI { if (Array.isArray(options) && Array.isArray(this.compilerConfiguration)) { this.compilerConfiguration = options.map((option, index) => { const compilerConfig = this.compilerConfiguration[index]; + if (strategy) { return webpackMerge.strategy(strategy)(compilerConfig, option); } + return webpackMerge(compilerConfig, option); }); return; @@ -482,6 +518,7 @@ class WebpackCLI { if (strategy) { return webpackMerge.strategy(strategy)(thisConfiguration, options); } + return webpackMerge(thisConfiguration, options); }); } else { @@ -494,19 +531,6 @@ class WebpackCLI { } } - /** - * Responsible for creating and updating the new output configuration - * - * @param {Object} options Output options emitted by the group helper - * @private - * @returns {void} - */ - _mergeOptionsToOutputConfiguration(options) { - if (options) { - this.outputConfiguration = Object.assign(this.outputConfiguration, options); - } - } - /** * It runs in a fancy order all the expected groups. * Zero config and configuration goes first. @@ -602,6 +626,7 @@ class WebpackCLI { } let colors; + // From flags if (typeof args.color !== 'undefined') { colors = args.color; diff --git a/test/help/help-commands.test.js b/test/help/help-commands.test.js index a129994fd35..54510f68c60 100644 --- a/test/help/help-commands.test.js +++ b/test/help/help-commands.test.js @@ -1,10 +1,9 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const helpHeader = 'The build tool for modern web applications'; describe('commands help', () => { - it('shows help for subcommands', () => { + it('log help for subcommands', () => { const { stderr, stdout, exitCode } = run(__dirname, ['serve', 'help'], false); expect(exitCode).toBe(0); @@ -12,7 +11,7 @@ describe('commands help', () => { expect(stdout).toContain('webpack s | serve'); }); - it('shows help information with subcommands as an arg', () => { + it('log help information with subcommands as an arg', () => { const { stdout, stderr, exitCode } = run(__dirname, ['help', 'serve'], false); expect(exitCode).toBe(0); @@ -20,28 +19,29 @@ describe('commands help', () => { expect(stderr).toHaveLength(0); }); - it('shows warning for invalid command with --help flag', () => { + it('log error for invalid command with --help flag', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--help', 'myCommand'], false); - expect(exitCode).toBe(0); - expect(stderr).toContain(`You provided an invalid command 'myCommand'`); - expect(stdout).toContain(helpHeader); + expect(exitCode).toBe(2); + expect(stderr).toContain("Invalid command 'myCommand'."); + expect(stderr).toContain('Run webpack --help to see available commands and arguments.'); + expect(stdout).toHaveLength(0); }); - it('shows warning for invalid command with help command', () => { + it('log error for invalid command with help command', () => { const { stderr, stdout, exitCode } = run(__dirname, ['help', 'myCommand'], false); - expect(exitCode).toBe(0); - expect(stderr).toContain(`You provided an invalid command 'myCommand'`); - expect(stdout).toContain(helpHeader); + expect(exitCode).toBe(2); + expect(stderr).toContain("Invalid command 'myCommand'."); + expect(stderr).toContain('Run webpack --help to see available commands and arguments.'); + expect(stdout).toHaveLength(0); }); - it('gives precedence to earlier command in case of multiple commands', () => { + it('log error for multiple commands', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--help', 'init', 'info'], false); - expect(exitCode).toBe(0); - expect(stdout).not.toContain(helpHeader); - expect(stdout).toContain('webpack c | init [scaffold]'); - expect(stderr).toHaveLength(0); + expect(exitCode).toBe(2); + expect(stderr).toContain("You provided multiple commands or arguments - command 'init' (alias 'c'), command 'info' (alias 'i')."); + expect(stdout).toHaveLength(0); }); }); diff --git a/test/help/help-flags.test.js b/test/help/help-flags.test.js index 4257f9a0781..a415986ecc6 100644 --- a/test/help/help-flags.test.js +++ b/test/help/help-flags.test.js @@ -1,50 +1,52 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const helpHeader = 'The build tool for modern web applications'; describe('commands help', () => { - it('log warning for invalid flag with --help flag', () => { + it('log error for invalid flag with --help flag', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--help', '--my-flag'], false); - expect(exitCode).toBe(0); - expect(stderr).toContain(`You provided an invalid option '--my-flag'`); - expect(stdout).toContain(helpHeader); + expect(exitCode).toBe(2); + expect(stderr).toContain(`Invalid option '--my-flag'`); + expect(stderr).toContain(`Run webpack --help to see available commands and arguments.`); + expect(stdout).toHaveLength(0); }); - it('log warning for invalid flag with help command', () => { + it('log error for invalid flag with help command', () => { const { stderr, stdout, exitCode } = run(__dirname, ['help', '--my-flag'], false); - expect(exitCode).toBe(0); - expect(stderr).toContain(`You provided an invalid option '--my-flag'`); - expect(stdout).toContain(helpHeader); + expect(exitCode).toBe(2); + expect(stderr).toContain(`Invalid option '--my-flag'.`); + expect(stderr).toContain(`Run webpack --help to see available commands and arguments.`); + expect(stdout).toHaveLength(0); }); - it('shows flag help with valid flag', () => { + it('log flag help with valid flag', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--merge'], false); expect(exitCode).toBe(0); - expect(stdout).not.toContain(helpHeader); + expect(stdout).not.toContain('The build tool for modern web applications'); expect(stdout).toContain('webpack -m, --merge'); expect(stderr).toHaveLength(0); }); - it('should show help for --mode', () => { + it('log show help for --mode', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--mode', '--help'], false); expect(exitCode).toBe(0); - expect(stdout).not.toContain(helpHeader); + expect(stdout).not.toContain('The build tool for modern web applications'); expect(stdout).toContain('webpack --mode '); expect(stdout).toContain('Defines the mode to pass to webpack'); expect(stderr).toHaveLength(0); }); - it('gives precedence to earlier flag in case of multiple flags', () => { + it('log error for multiple flags', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--entry', '--merge'], false); - expect(exitCode).toBe(0); - expect(stdout).not.toContain(helpHeader); - expect(stdout).toContain('webpack --entry '); - expect(stderr).toHaveLength(0); + expect(exitCode).toBe(2); + expect(stderr).toContain( + `You provided multiple commands or arguments - argument '--entry', argument '--merge' (alias '-m'). Please use only one command at a time.`, + ); + expect(stdout).toHaveLength(0); }); }); diff --git a/test/info/info-help.test.js b/test/info/info-help.test.js index 7b77f3e0d83..46b914de71c 100644 --- a/test/info/info-help.test.js +++ b/test/info/info-help.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { yellow, options } = require('colorette'); +const { green } = require('colorette'); const { runInfo } = require('../utils/test-utils'); const { commands } = require('../../packages/webpack-cli/lib/utils/cli-flags'); @@ -19,12 +19,11 @@ describe('should print help for info command', () => { expect(stderr).toHaveLength(0); }); - it('should respect the --no-color flag', () => { + it.skip('should work and respect the --no-color flag', () => { const { stdout, stderr, exitCode } = runInfo(['--help', '--no-color'], __dirname); - options.enabled = true; expect(exitCode).toBe(0); - expect(stdout).not.toContain(yellow(usageText)); + expect(stdout).not.toContain(green(usageText)); expect(stdout).toContain(descriptionText); expect(stderr).toHaveLength(0); }); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 5f24458ad91..ea749f130bf 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -8,7 +8,6 @@ const { Writable } = require('readable-stream'); const concat = require('concat-stream'); const { version } = require('webpack'); const { version: devServerVersion } = require('webpack-dev-server/package.json'); -const { hyphenToUpperCase } = require('../../packages/webpack-cli/lib/utils/arg-utils'); const WEBPACK_PATH = path.resolve(__dirname, '../../packages/webpack-cli/bin/cli.js'); const ENABLE_LOG_COMPILATION = process.env.ENABLE_PIPE || false; @@ -16,6 +15,15 @@ const isWebpack5 = version.startsWith('5'); const isDevServer4 = devServerVersion.startsWith('4'); const isWindows = process.platform === 'win32'; +const hyphenToUpperCase = (name) => { + if (!name) { + return name; + } + return name.replace(/-([a-z])/g, function (g) { + return g[1].toUpperCase(); + }); +}; + /** * Run the webpack CLI for a test case. * diff --git a/test/version/version-external-packages.test.js b/test/version/version-external-packages.test.js index 7dfd06b5084..47c21ab9be7 100644 --- a/test/version/version-external-packages.test.js +++ b/test/version/version-external-packages.test.js @@ -77,30 +77,35 @@ describe('version flag with external packages', () => { const { stderr, exitCode } = run(__dirname, ['init', 'migrate', '--version'], false); expect(exitCode).toBe(2); - expect(stderr).toContain('You provided multiple commands.'); + expect(stderr).toContain( + "You provided multiple commands - 'init' (alias 'c'), 'migrate' (alias 'm'). Please use only one command at a time.", + ); }); it(' should throw error if invalid argument is present with --version flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '--version'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '--version', '--no-color'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`Error: Invalid command 'abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).toBe(''); }); it(' should throw error if invalid argument is present with version command', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', 'version'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', 'version', '--no-color'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`Error: Invalid command 'abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).toBe(''); }); it(' should throw error if invalid argument is present with -v alias', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '-v'], false); + const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '-v', '--no-color'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`Error: Invalid command 'abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).toBe(''); }); }); diff --git a/test/version/version-multi-args.test.js b/test/version/version-multi-args.test.js index 585bb59b792..1051f44ee45 100644 --- a/test/version/version-multi-args.test.js +++ b/test/version/version-multi-args.test.js @@ -7,76 +7,72 @@ describe('version flag with multiple arguments', () => { it('does not output version with help command', () => { const { stdout, stderr, exitCode } = run(__dirname, ['version', 'help'], false); - expect(stdout).not.toContain(pkgJSON.version); expect(exitCode).toBe(0); - - const uniqueIdentifier = 'The build tool for modern web applications'; - expect(stdout).toContain(uniqueIdentifier); + expect(stdout).not.toContain(pkgJSON.version); + expect(stdout).toContain('The build tool for modern web applications'); expect(stderr).toHaveLength(0); }); it('does not output version with help dashed', () => { const { stdout, stderr, exitCode } = run(__dirname, ['version', '--help'], false); - expect(stdout).not.toContain(pkgJSON.version); expect(exitCode).toBe(0); - - const uniqueIdentifier = 'The build tool for modern web applications'; - expect(stdout).toContain(uniqueIdentifier); + expect(stdout).not.toContain(pkgJSON.version); + expect(stdout).toContain('The build tool for modern web applications'); expect(stderr).toHaveLength(0); }); it('throws error if invalid command is passed with version command', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['version', 'abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); - expect(stderr).toContain(`Error: Invalid command 'abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); }); it('throws error if invalid option is passed with version command', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['version', '--abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); - expect(stderr).toContain(`Error: Invalid option '--abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); }); it('throws error if invalid command is passed with --version flag', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--version', 'abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); - expect(stderr).toContain(`Error: Invalid command 'abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); }); it('throws error if invalid option is passed with --version flag', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--version', '--abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['--version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); - expect(stderr).toContain(`Error: Invalid option '--abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); }); it('throws error if invalid command is passed with -v alias', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-v', 'abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-v', 'abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); - expect(stderr).toContain(`Error: Invalid command 'abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); }); it('throws error if invalid option is passed with -v alias', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-v', '--abc'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-v', '--abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); - expect(stderr).toContain(`Error: Invalid option '--abc'`); - expect(stdout).toContain('Run webpack --help to see available commands and arguments'); + expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); + expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); }); }); From 2d6e5c6f4ed967368a81742bf347e39f24ee16c8 Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Wed, 11 Nov 2020 17:24:16 +0300 Subject: [PATCH 085/581] fix: respect `stats` from the config for webpack@4 (#2098) --- packages/webpack-cli/lib/webpack-cli.js | 13 ++++++++- test/stats/watch/multi-webpack.config.js | 10 +++++++ test/stats/watch/src/index.js | 1 + test/stats/watch/stats-and-watch.test.js | 35 ++++++++++++++++++++++++ test/stats/watch/webpack.config.js | 4 +++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 test/stats/watch/multi-webpack.config.js create mode 100644 test/stats/watch/src/index.js create mode 100644 test/stats/watch/stats-and-watch.test.js create mode 100644 test/stats/watch/webpack.config.js diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index f195e18de90..327216f3c08 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -666,11 +666,22 @@ class WebpackCLI { process.exit(2); } } else { - logger.raw(`${stats.toString(foundStats)}`); + const printedStats = stats.toString(foundStats); + + // Avoid extra empty line when `stats: 'none'` + if (printedStats) { + logger.raw(`${stats.toString(foundStats)}`); + } } }; compiler = this.createCompiler(options, callback); + + // TODO webpack@4 return Watching and MultiWathing instead Compiler and MultiCompiler, remove this after drop webpack@4 + if (compiler && compiler.compiler) { + compiler = compiler.compiler; + } + return Promise.resolve(); } } diff --git a/test/stats/watch/multi-webpack.config.js b/test/stats/watch/multi-webpack.config.js new file mode 100644 index 00000000000..7d116eda8b8 --- /dev/null +++ b/test/stats/watch/multi-webpack.config.js @@ -0,0 +1,10 @@ +module.exports = [ + { + watch: true, + stats: 'none', + }, + { + watch: true, + stats: 'none', + }, +]; diff --git a/test/stats/watch/src/index.js b/test/stats/watch/src/index.js new file mode 100644 index 00000000000..8340384261d --- /dev/null +++ b/test/stats/watch/src/index.js @@ -0,0 +1 @@ +console.log('TEST'); \ No newline at end of file diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js new file mode 100644 index 00000000000..907ea00148b --- /dev/null +++ b/test/stats/watch/stats-and-watch.test.js @@ -0,0 +1,35 @@ +'use strict'; + +const { runWatch, isWebpack5 } = require('../../utils/test-utils'); + +describe('stats and watch', () => { + it('should not log stats with the "none" value from the configuration', async () => { + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); + + expect(stdout).toContain('[webpack-cli] Compilation starting...'); + expect(stdout).toContain('[webpack-cli] Compilation finished'); + expect(stdout).toContain('[webpack-cli] watching files for updates...'); + expect(stderr).toBeFalsy(); + }); + + it('should not log stats with the "none" value from the configuration and multi compiler mode', async () => { + const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); + + expect(stdout).toContain('[webpack-cli] Compilation starting...'); + expect(stdout).toContain('[webpack-cli] Compilation finished'); + expect(stdout).toContain('[webpack-cli] watching files for updates...'); + expect(stderr).toBeFalsy(); + }); + + it('should log stats with the "normal" value in arguments', async () => { + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); + + const output = isWebpack5 ? 'successfully' : 'main.js'; + + expect(stdout).toContain('[webpack-cli] Compilation starting...'); + expect(stdout).toContain('[webpack-cli] Compilation finished'); + expect(stdout).toContain('[webpack-cli] watching files for updates...'); + expect(stdout).toContain(output); + expect(stderr).toBeFalsy(); + }); +}); diff --git a/test/stats/watch/webpack.config.js b/test/stats/watch/webpack.config.js new file mode 100644 index 00000000000..e7e1987f001 --- /dev/null +++ b/test/stats/watch/webpack.config.js @@ -0,0 +1,4 @@ +module.exports = { + watch: true, + stats: 'none', +}; From 3eb410e5d8f8e2149910b65f4a028c85f8af5d28 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Wed, 11 Nov 2020 22:38:16 +0530 Subject: [PATCH 086/581] fix: defer setting default mode to core (#2095) --- packages/webpack-cli/lib/webpack-cli.js | 12 ++++++++---- test/build-warnings/warnings.test.js | 4 ++-- test/colors/colors-false.webpack.config.js | 1 + test/colors/colors-true.webpack.config.js | 1 + test/colors/multiple-configs.js | 2 ++ test/colors/no-stats.webpack.config.js | 1 + test/colors/stats-boolean.webpack.config.js | 1 + test/colors/stats-string.webpack.config.js | 1 + test/colors/webpack.config.js | 3 +++ test/defaults/output-defaults.test.js | 4 ++-- test/merge/config/merge-config.test.js | 2 +- test/mode/mode-single-arg/mode-single-arg.test.js | 5 +++-- test/stats/watch/webpack.config.js | 1 + test/watch/watch-flag.test.js | 4 ++-- 14 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 test/colors/webpack.config.js diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 327216f3c08..f57b5bd2e7f 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -112,8 +112,6 @@ class WebpackCLI { finalMode = configMode; } else if (NODE_ENV && (NODE_ENV === PRODUCTION || NODE_ENV === DEVELOPMENT)) { finalMode = NODE_ENV; - } else { - finalMode = PRODUCTION; } return finalMode; @@ -208,10 +206,16 @@ class WebpackCLI { // Todo - handle multi config for all flags finalOptions.options = configOptions.map(() => ({ ...finalOptions.options })); configOptions.forEach((configObject, index) => { - finalOptions.options[index].mode = assignMode(mode, configObject); + const resolvedMode = assignMode(mode, configObject); + if (resolvedMode) { + finalOptions.options[index].mode = resolvedMode; + } }); } else { - finalOptions.options.mode = assignMode(mode, configOptions); + const resolvedMode = assignMode(mode, configOptions); + if (resolvedMode) { + finalOptions.options.mode = resolvedMode; + } } return finalOptions; diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index cb049a150b8..576f59a4848 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -21,7 +21,7 @@ describe('warnings', () => { const json = JSON.parse(stdout); expect(json['hash']).toBeDefined(); - expect(json['warnings']).toHaveLength(1); + expect(json['warnings']).toHaveLength(2); // `message` for `webpack@5` expect(json['warnings'][0].message ? json['warnings'][0].message : json['warnings'][0]).toMatch(/Can't resolve/); }); @@ -43,7 +43,7 @@ describe('warnings', () => { const json = JSON.parse(data); expect(json['hash']).toBeDefined(); - expect(json['warnings']).toHaveLength(1); + expect(json['warnings']).toHaveLength(2); // `message` for `webpack@5` expect(json['warnings'][0].message ? json['warnings'][0].message : json['warnings'][0]).toMatch(/Can't resolve/); diff --git a/test/colors/colors-false.webpack.config.js b/test/colors/colors-false.webpack.config.js index b0f58638bfa..ca20696f2e3 100644 --- a/test/colors/colors-false.webpack.config.js +++ b/test/colors/colors-false.webpack.config.js @@ -2,4 +2,5 @@ module.exports = { stats: { colors: false, }, + mode: 'production', }; diff --git a/test/colors/colors-true.webpack.config.js b/test/colors/colors-true.webpack.config.js index 15fc57eafd8..76255bff92d 100644 --- a/test/colors/colors-true.webpack.config.js +++ b/test/colors/colors-true.webpack.config.js @@ -2,4 +2,5 @@ module.exports = { stats: { colors: true, }, + mode: 'production', }; diff --git a/test/colors/multiple-configs.js b/test/colors/multiple-configs.js index b175991ac4d..0828c36394a 100644 --- a/test/colors/multiple-configs.js +++ b/test/colors/multiple-configs.js @@ -3,10 +3,12 @@ module.exports = [ name: 'first-config', entry: './src/first.js', stats: 'normal', + mode: 'production', }, { name: 'second-config', entry: './src/second.js', stats: 'normal', + mode: 'production', }, ]; diff --git a/test/colors/no-stats.webpack.config.js b/test/colors/no-stats.webpack.config.js index 34672801b3d..71af9d200a9 100644 --- a/test/colors/no-stats.webpack.config.js +++ b/test/colors/no-stats.webpack.config.js @@ -1,3 +1,4 @@ module.exports = { name: 'test', + mode: 'production', }; diff --git a/test/colors/stats-boolean.webpack.config.js b/test/colors/stats-boolean.webpack.config.js index 1c9b636be33..9f947b31986 100644 --- a/test/colors/stats-boolean.webpack.config.js +++ b/test/colors/stats-boolean.webpack.config.js @@ -1,3 +1,4 @@ module.exports = { stats: true, + mode: 'production', }; diff --git a/test/colors/stats-string.webpack.config.js b/test/colors/stats-string.webpack.config.js index 5c13e746a6a..d3712a1cf09 100644 --- a/test/colors/stats-string.webpack.config.js +++ b/test/colors/stats-string.webpack.config.js @@ -1,3 +1,4 @@ module.exports = { stats: 'verbose', + mode: 'production', }; diff --git a/test/colors/webpack.config.js b/test/colors/webpack.config.js new file mode 100644 index 00000000000..5b69c702150 --- /dev/null +++ b/test/colors/webpack.config.js @@ -0,0 +1,3 @@ +module.exports = { + mode: 'production', +}; diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index 6166d346ab9..d96c9dd4c1d 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -9,8 +9,8 @@ describe('output flag defaults', () => { expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); - // Should not print warning about config fallback, as we have production as default - expect(stdout).not.toContain('option has not been set, webpack will fallback to'); + // Should print warning about config fallback + expect(stdout).toContain('option has not been set, webpack will fallback to'); stat(resolve(__dirname, './binary/main.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/merge/config/merge-config.test.js b/test/merge/config/merge-config.test.js index 926ff5e4bbb..cf9afc5f647 100644 --- a/test/merge/config/merge-config.test.js +++ b/test/merge/config/merge-config.test.js @@ -8,7 +8,7 @@ const { run } = require('../../utils/test-utils'); describe('merge flag configuration', () => { it('merges two configurations together', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--config', './1.js', '-c', './2.js', '--merge'], false); - expect(stdout).not.toContain('option has not been set, webpack will fallback to'); + expect(stdout).toContain('option has not been set, webpack will fallback to'); expect(existsSync(resolve(__dirname, './dist/merged.js'))).toBeTruthy(); expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index c3577ac844c..d586c687049 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -2,12 +2,13 @@ const { run } = require('../../utils/test-utils'); describe('mode flags', () => { - it('should set mode=production by default', () => { + it('should not set mode=production by default', () => { const { stderr, stdout, exitCode } = run(__dirname); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`mode: 'production'`); + expect(stdout).not.toContain(`mode: 'production'`); + expect(stdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); }); it('should load a development config when --mode=development is passed', () => { diff --git a/test/stats/watch/webpack.config.js b/test/stats/watch/webpack.config.js index e7e1987f001..65a1ecbbe75 100644 --- a/test/stats/watch/webpack.config.js +++ b/test/stats/watch/webpack.config.js @@ -1,4 +1,5 @@ module.exports = { watch: true, stats: 'none', + mode: 'production', }; diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index e326fed48d8..fc6d3c153a8 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -10,7 +10,7 @@ const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; describe('--watch flag', () => { it('should recompile upon file change', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch'], false, '', true); + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'production'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); @@ -45,7 +45,7 @@ describe('--watch flag', () => { }); it('should print compilation lifecycle', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch'], false, '', true); + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'production'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); From aff9bcd3ad9a6fd7f6a41202b6c56f41dcb1a10b Mon Sep 17 00:00:00 2001 From: ylemkimon Date: Thu, 12 Nov 2020 02:37:19 +0900 Subject: [PATCH 087/581] chore(ci): upgrade to using environment files (#2091) --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index be1637e991e..593cd6263d1 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -117,5 +117,5 @@ jobs: - run: npm install - name: conventional-changelog-lint-config-cz # $GITHUB_WORKSPACE is the path to your repository - run: echo "::set-env name=NODE_PATH::$GITHUB_WORKSPACE/node_modules" + run: echo "NODE_PATH=$GITHUB_WORKSPACE/node_modules" >> $GITHUB_ENV - uses: wagoid/commitlint-github-action@v2 From fc8a5a623bf3009c0ce351d903aae99d960409eb Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:21:52 +0300 Subject: [PATCH 088/581] chore(deps-dev): bump git-cz from 4.7.1 to 4.7.3 (#2101) Bumps [git-cz](https://github.com/streamich/git-cz) from 4.7.1 to 4.7.3. - [Release notes](https://github.com/streamich/git-cz/releases) - [Changelog](https://github.com/streamich/git-cz/blob/master/CHANGELOG.md) - [Commits](https://github.com/streamich/git-cz/compare/v4.7.1...v4.7.3) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5cf56c3cfbe..e0e26a3bdda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5740,9 +5740,9 @@ gh-got@^5.0.0: is-plain-obj "^1.1.0" git-cz@^4.7.1: - version "4.7.1" - resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.1.tgz#90edaa8dba1ec8be689b22fbf8d006c44b21b31f" - integrity sha512-Emb/Xz/LcL3SGxA/PD6RUrhUT6m2v0O9nWTjwCBAoE2UXxj9HkJcfphL3RkePtiTNFkVZMk0q5EUfHnO7HAfiw== + version "4.7.3" + resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.3.tgz#2dc67b0231937946f602fd0320f6c983c40f7071" + integrity sha512-Z+iy1G5qsbICeHBj4EZI438C8T1bh+m953jTT5hcQZggzSnjDdrUahM7O+ETspr3f3iWXONqC8e+zMuDT+ODJg== git-raw-commits@2.0.0: version "2.0.0" From ff4c6dcbec891a40466efee77098059dd3e0f786 Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Fri, 13 Nov 2020 13:50:47 +0300 Subject: [PATCH 089/581] tests: speedup (#2105) --- test/config-lookup/dotfolder-array/.webpack/webpack.config.js | 4 ++-- test/config-name/function-config.js | 2 +- test/config-name/webpack.config.js | 2 +- test/config/function/multi-webpack.config.js | 2 +- test/config/multiple/webpack1.config.js | 2 +- test/config/multiple/webpack2.config.js | 2 +- test/config/type/array/webpack.config.js | 4 ++-- test/devtool/array/webpack.config.js | 4 ++-- test/devtool/object/webpack.eval.config.js | 2 +- test/devtool/object/webpack.source.config.js | 2 +- test/entry/scss/webpack.config.js | 2 +- test/target/flag-test/webpack.config.js | 2 +- test/target/node/webpack.config.js | 2 +- test/watch/watch-flag.test.js | 4 ++-- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/config-lookup/dotfolder-array/.webpack/webpack.config.js b/test/config-lookup/dotfolder-array/.webpack/webpack.config.js index 825f8298b57..ffc4f604abb 100644 --- a/test/config-lookup/dotfolder-array/.webpack/webpack.config.js +++ b/test/config-lookup/dotfolder-array/.webpack/webpack.config.js @@ -6,7 +6,7 @@ module.exports = [ }, name: 'amd', entry: './a.js', - mode: 'production', + mode: 'development', devtool: 'eval-cheap-module-source-map', }, { @@ -16,7 +16,7 @@ module.exports = [ }, name: 'commonjs', entry: './a.js', - mode: 'production', + mode: 'development', target: 'node', }, ]; diff --git a/test/config-name/function-config.js b/test/config-name/function-config.js index ff198656a45..aea6af2f9fb 100644 --- a/test/config-name/function-config.js +++ b/test/config-name/function-config.js @@ -13,7 +13,7 @@ module.exports = () => [ }, name: 'second', entry: './src/second.js', - mode: 'production', + mode: 'development', }, { output: { diff --git a/test/config-name/webpack.config.js b/test/config-name/webpack.config.js index 3504fa3ae9b..e3ea1bc7020 100644 --- a/test/config-name/webpack.config.js +++ b/test/config-name/webpack.config.js @@ -13,7 +13,7 @@ module.exports = [ }, name: 'second', entry: './src/second.js', - mode: 'production', + mode: 'development', }, { output: { diff --git a/test/config/function/multi-webpack.config.js b/test/config/function/multi-webpack.config.js index 1ea167bf529..17546d938aa 100644 --- a/test/config/function/multi-webpack.config.js +++ b/test/config/function/multi-webpack.config.js @@ -14,7 +14,7 @@ module.exports = () => [ }, name: 'second', entry: './src/second.js', - mode: 'production', + mode: 'development', stats: 'minimal', }, ]; diff --git a/test/config/multiple/webpack1.config.js b/test/config/multiple/webpack1.config.js index 788a7689cdf..88edf6386be 100644 --- a/test/config/multiple/webpack1.config.js +++ b/test/config/multiple/webpack1.config.js @@ -5,6 +5,6 @@ module.exports = { }, name: 'amd', entry: './init.js', - mode: 'production', + mode: 'development', devtool: 'eval-cheap-module-source-map', }; diff --git a/test/config/multiple/webpack2.config.js b/test/config/multiple/webpack2.config.js index efa5ecd44ad..2b96dbfda64 100644 --- a/test/config/multiple/webpack2.config.js +++ b/test/config/multiple/webpack2.config.js @@ -5,6 +5,6 @@ module.exports = { }, name: 'commonjs', entry: './init.js', - mode: 'production', + mode: 'development', target: 'node', }; diff --git a/test/config/type/array/webpack.config.js b/test/config/type/array/webpack.config.js index 825f8298b57..ffc4f604abb 100644 --- a/test/config/type/array/webpack.config.js +++ b/test/config/type/array/webpack.config.js @@ -6,7 +6,7 @@ module.exports = [ }, name: 'amd', entry: './a.js', - mode: 'production', + mode: 'development', devtool: 'eval-cheap-module-source-map', }, { @@ -16,7 +16,7 @@ module.exports = [ }, name: 'commonjs', entry: './a.js', - mode: 'production', + mode: 'development', target: 'node', }, ]; diff --git a/test/devtool/array/webpack.config.js b/test/devtool/array/webpack.config.js index 515e9a6e684..e59ce251d17 100644 --- a/test/devtool/array/webpack.config.js +++ b/test/devtool/array/webpack.config.js @@ -6,7 +6,7 @@ module.exports = [ }, name: 'amd', entry: './index.js', - mode: 'production', + mode: 'development', devtool: 'eval-cheap-module-source-map', }, { @@ -16,7 +16,7 @@ module.exports = [ }, name: 'commonjs', entry: './index.js', - mode: 'production', + mode: 'development', devtool: 'source-map', target: 'node', }, diff --git a/test/devtool/object/webpack.eval.config.js b/test/devtool/object/webpack.eval.config.js index a8279f8352e..ba392ae1c35 100644 --- a/test/devtool/object/webpack.eval.config.js +++ b/test/devtool/object/webpack.eval.config.js @@ -5,6 +5,6 @@ module.exports = { }, name: 'amd', entry: './index.js', - mode: 'production', + mode: 'development', devtool: 'eval-cheap-module-source-map', }; diff --git a/test/devtool/object/webpack.source.config.js b/test/devtool/object/webpack.source.config.js index a3775aa6de5..d4999a8ef78 100644 --- a/test/devtool/object/webpack.source.config.js +++ b/test/devtool/object/webpack.source.config.js @@ -5,6 +5,6 @@ module.exports = { }, name: 'amd', entry: './index.js', - mode: 'production', + mode: 'development', devtool: 'source-map', }; diff --git a/test/entry/scss/webpack.config.js b/test/entry/scss/webpack.config.js index 64514583482..d8d1ce1a57e 100644 --- a/test/entry/scss/webpack.config.js +++ b/test/entry/scss/webpack.config.js @@ -2,7 +2,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { - mode: 'production', + mode: 'development', entry: { home: ['./home.js', './home.scss'], }, diff --git a/test/target/flag-test/webpack.config.js b/test/target/flag-test/webpack.config.js index 5b0174c6daa..63a27c462dd 100644 --- a/test/target/flag-test/webpack.config.js +++ b/test/target/flag-test/webpack.config.js @@ -2,7 +2,7 @@ const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); module.exports = { entry: './index.js', - mode: 'production', + mode: 'development', target: 'node', plugins: [new WebpackCLITestPlugin()], }; diff --git a/test/target/node/webpack.config.js b/test/target/node/webpack.config.js index 3d5322e6f08..59b1da703f8 100644 --- a/test/target/node/webpack.config.js +++ b/test/target/node/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { entry: './main.js', - mode: 'production', + mode: 'development', target: 'node', }; diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index fc6d3c153a8..96063c4ec9a 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -10,7 +10,7 @@ const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; describe('--watch flag', () => { it('should recompile upon file change', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'production'], false, '', true); + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); @@ -45,7 +45,7 @@ describe('--watch flag', () => { }); it('should print compilation lifecycle', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'production'], false, '', true); + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); From 1175e27081106bbe2b6297e3ecc6d23cbdb14ffe Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 13 Nov 2020 16:33:46 +0530 Subject: [PATCH 090/581] fix(init): add field in tsconfig.json (#2108) --- .../__snapshots__/init-generator.test.ts.snap | 15 +++++++++++++++ .../generators/__tests__/init-generator.test.ts | 4 ++++ packages/generators/templates/tsconfig.json.js | 1 + 3 files changed, 20 insertions(+) diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index f170c890108..115d8c266cd 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -85,6 +85,21 @@ Object { } `; +exports[`init generator generates a webpack config that uses Typescript 2`] = ` +Object { + "compilerOptions": Object { + "allowJs": true, + "allowSyntheticDefaultImports": true, + "module": "es6", + "noImplicitAny": true, + "target": "es5", + }, + "files": Array [ + "src/index.ts", + ], +} +`; + exports[`init generator generates a webpack config using CSS with mini-css-extract-plugin 1`] = ` Object { "mode": "'development'", diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index e2982256e3d..d363740ecf9 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -207,5 +207,9 @@ describe('init generator', () => { ]); //match config snapshot expect(config).toMatchSnapshot(); + + // eslint-disable-next-line @typescript-eslint/no-var-requires + const tsconfigContents = require(join(outputDir, 'tsconfig.json')); + expect(tsconfigContents).toMatchSnapshot(); }); }); diff --git a/packages/generators/templates/tsconfig.json.js b/packages/generators/templates/tsconfig.json.js index 21d29717d94..9866c8523ed 100644 --- a/packages/generators/templates/tsconfig.json.js +++ b/packages/generators/templates/tsconfig.json.js @@ -6,4 +6,5 @@ module.exports = { target: 'es5', allowJs: true, }, + files: ['src/index.ts'], }; From 4769c9a462e746aea6be8bcc6f669e1c356f21f0 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 18 Nov 2020 01:33:48 +0530 Subject: [PATCH 091/581] chore: link to SO's guide for reproduction in bug template (#2109) --- .github/ISSUE_TEMPLATE/Bug_report.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index 08eaa35fa15..a96266fed03 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -16,10 +16,7 @@ labels: 'Bug' Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error + **Expected behavior** From bd0a71086ade097e9f4914caa8f8c1450644a6b9 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2020 13:51:43 +0300 Subject: [PATCH 092/581] chore(deps-dev): bump git-cz from 4.7.3 to 4.7.4 (#2116) Bumps [git-cz](https://github.com/streamich/git-cz) from 4.7.3 to 4.7.4. - [Release notes](https://github.com/streamich/git-cz/releases) - [Changelog](https://github.com/streamich/git-cz/blob/master/CHANGELOG.md) - [Commits](https://github.com/streamich/git-cz/compare/v4.7.3...v4.7.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index e0e26a3bdda..bdafc77823f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5740,9 +5740,9 @@ gh-got@^5.0.0: is-plain-obj "^1.1.0" git-cz@^4.7.1: - version "4.7.3" - resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.3.tgz#2dc67b0231937946f602fd0320f6c983c40f7071" - integrity sha512-Z+iy1G5qsbICeHBj4EZI438C8T1bh+m953jTT5hcQZggzSnjDdrUahM7O+ETspr3f3iWXONqC8e+zMuDT+ODJg== + version "4.7.4" + resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.4.tgz#abb119676fc5869d1f3470a54032c6a95d53d010" + integrity sha512-s8r6JPuuFJXCiwB6uBlWYjDE6GlvIReSgVqYCfpRB+JbiBVNQLcBb93mH6bIJzz1lQU4R8+qlChhQIK8xp58Tg== git-raw-commits@2.0.0: version "2.0.0" From 7f1549db8893cd5556d411b0365188be7a2a9c3e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2020 13:56:52 +0300 Subject: [PATCH 093/581] chore(deps-dev): bump @types/node from 14.14.7 to 14.14.8 (#2115) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.7 to 14.14.8. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index bdafc77823f..95bae3a364a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2451,9 +2451,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.7" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.7.tgz#8ea1e8f8eae2430cf440564b98c6dfce1ec5945d" - integrity sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg== + version "14.14.8" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.8.tgz#2127bd81949a95c8b7d3240f3254352d72563aec" + integrity sha512-z/5Yd59dCKI5kbxauAJgw6dLPzW+TNOItNE00PkpzNwUIEwdj/Lsqwq94H5DdYBX7C13aRA0CY32BK76+neEUA== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 6426bb781aec7b7e312b30bfd7ece5306ad047b4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2020 14:34:06 +0300 Subject: [PATCH 094/581] chore(deps): bump p-each-series from 2.1.0 to 2.2.0 (#2118) Bumps [p-each-series](https://github.com/sindresorhus/p-each-series) from 2.1.0 to 2.2.0. - [Release notes](https://github.com/sindresorhus/p-each-series/releases) - [Commits](https://github.com/sindresorhus/p-each-series/compare/v2.1.0...v2.2.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 95bae3a364a..8afe2c09b25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8947,9 +8947,9 @@ p-cancelable@^2.0.0: integrity sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg== p-each-series@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.1.0.tgz#961c8dd3f195ea96c747e636b262b800a6b1af48" - integrity sha512-ZuRs1miPT4HrjFa+9fRfOFXxGJfORgelKV9f9nNOWw2gl6gVsRaVDOQP0+MI0G0wGKns1Yacsu0GjOFbTK0JFQ== + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.2.0.tgz#105ab0357ce72b202a8a8b94933672657b5e2a9a" + integrity sha512-ycIL2+1V32th+8scbpTvyHNaHe02z0sjgh91XXjAk+ZeXoPN4Z46DVUnzdso0aX4KckKw0FNNFHdjZ2UsZvxiA== p-finally@^1.0.0: version "1.0.0" From 5f92deea1b97979e565788d1a8999250e735621a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2020 14:34:57 +0300 Subject: [PATCH 095/581] chore(deps-dev): bump webpack from 5.4.0 to 5.5.1 (#2117) Bumps [webpack](https://github.com/webpack/webpack) from 5.4.0 to 5.5.1. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.4.0...v5.5.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8afe2c09b25..f6d9c0cc355 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11714,9 +11714,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.3.0: - version "5.4.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.4.0.tgz#4fdc6ec8a0ff9160701fb8f2eb8d06b33ecbae0f" - integrity sha512-udpYTyqz8toTTdaOsL2QKPLeZLt2IEm9qY7yTXuFEQhKu5bk0yQD9BtAdVQksmz4jFbbWOiWmm3NHarO0zr/ng== + version "5.5.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.5.1.tgz#d6537f85554a0e59f15e6e683af11befdd0476aa" + integrity sha512-v4RzZP9BG2xxMLhxcFIo89M+nyIqGjh35Bhm5EE+I2N8y3dc9jT5OSb1HewUMkzMPyyDscOkVD6pSn6EMtTwNQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From 4b5ea4a4fc32f6eb21909d83dd65248a637a2537 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2020 17:04:31 +0300 Subject: [PATCH 096/581] chore(deps-dev): bump webpack from 5.5.1 to 5.6.0 (#2119) Bumps [webpack](https://github.com/webpack/webpack) from 5.5.1 to 5.6.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.5.1...v5.6.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f6d9c0cc355..d2fd6f4bd22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11714,9 +11714,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.3.0: - version "5.5.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.5.1.tgz#d6537f85554a0e59f15e6e683af11befdd0476aa" - integrity sha512-v4RzZP9BG2xxMLhxcFIo89M+nyIqGjh35Bhm5EE+I2N8y3dc9jT5OSb1HewUMkzMPyyDscOkVD6pSn6EMtTwNQ== + version "5.6.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.6.0.tgz#282d10434c403b070ed91d459b385e873b51a07d" + integrity sha512-SIeFuBhuheKElRbd84O35UhKc0nxlgSwtzm2ksZ0BVhRJqxVJxEguT/pYhfiR0le/pxTa1VsCp7EOYyTsa6XOA== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From cf5d1cf93d4b0fb57cc223ff603c933bb0cb5c6f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2020 14:13:13 +0300 Subject: [PATCH 097/581] chore(deps-dev): bump @types/node from 14.14.8 to 14.14.9 (#2123) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.8 to 14.14.9. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d2fd6f4bd22..cdf17e3e462 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2451,9 +2451,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.8" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.8.tgz#2127bd81949a95c8b7d3240f3254352d72563aec" - integrity sha512-z/5Yd59dCKI5kbxauAJgw6dLPzW+TNOItNE00PkpzNwUIEwdj/Lsqwq94H5DdYBX7C13aRA0CY32BK76+neEUA== + version "14.14.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.9.tgz#04afc9a25c6ff93da14deabd65dc44485b53c8d6" + integrity sha512-JsoLXFppG62tWTklIoO4knA+oDTYsmqWxHRvd4lpmfQRNhX6osheUOWETP2jMoV/2bEHuMra8Pp3Dmo/stBFcw== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 63ce0843a7b8f4f72b32b629e695b36b83c8e0e0 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2020 13:55:53 +0300 Subject: [PATCH 098/581] chore(deps-dev): bump eslint from 7.13.0 to 7.14.0 (#2129) Bumps [eslint](https://github.com/eslint/eslint) from 7.13.0 to 7.14.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.13.0...v7.14.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index cdf17e3e462..ae2125ad990 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4945,9 +4945,9 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.13.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.13.0.tgz#7f180126c0dcdef327bfb54b211d7802decc08da" - integrity sha512-uCORMuOO8tUzJmsdRtrvcGq5qposf7Rw0LwkTJkoDbOycVQtQjmnhZSuLQnozLE4TmAzlMVV45eCHmQ1OpDKUQ== + version "7.14.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.14.0.tgz#2d2cac1d28174c510a97b377f122a5507958e344" + integrity sha512-5YubdnPXrlrYAFCKybPuHIAH++PINe1pmKNc5wQRB9HSbqIK1ywAnntE3Wwua4giKu0bjligf1gLF6qxMGOYRA== dependencies: "@babel/code-frame" "^7.0.0" "@eslint/eslintrc" "^0.2.1" From f9a2d09d064ebae73c928ea406d512d6d18d0f95 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Nov 2020 03:45:22 +0300 Subject: [PATCH 099/581] chore(deps-dev): bump @babel/core from 7.12.3 to 7.12.8 (#2130) Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.12.3 to 7.12.8. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.8/packages/babel-core) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 82 +++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/yarn.lock b/yarn.lock index ae2125ad990..a4dfa57388f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,18 +15,18 @@ integrity sha512-725AQupWJZ8ba0jbKceeFblZTY90McUBWMwHhkFQ9q1zKPJ95GUktljFcgcsIVwRnTnRKlcYzfiNImg5G9m6ZQ== "@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.12.3", "@babel/core@^7.7.5": - version "7.12.3" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.3.tgz#1b436884e1e3bff6fb1328dc02b208759de92ad8" - integrity sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g== + version "7.12.8" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.8.tgz#8ad76c1a7d2a6a3beecc4395fa4f7b4cb88390e6" + integrity sha512-ra28JXL+5z73r1IC/t+FT1ApXU5LsulFDnTDntNfLQaScJUJmcHL5Qxm/IWanCToQk3bPWQo5bflbplU5r15pg== dependencies: "@babel/code-frame" "^7.10.4" - "@babel/generator" "^7.12.1" + "@babel/generator" "^7.12.5" "@babel/helper-module-transforms" "^7.12.1" - "@babel/helpers" "^7.12.1" - "@babel/parser" "^7.12.3" - "@babel/template" "^7.10.4" - "@babel/traverse" "^7.12.1" - "@babel/types" "^7.12.1" + "@babel/helpers" "^7.12.5" + "@babel/parser" "^7.12.7" + "@babel/template" "^7.12.7" + "@babel/traverse" "^7.12.8" + "@babel/types" "^7.12.7" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.1" @@ -36,12 +36,12 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/generator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.1.tgz#0d70be32bdaa03d7c51c8597dda76e0df1f15468" - integrity sha512-DB+6rafIdc9o72Yc3/Ph5h+6hUjeOp66pF0naQBgUFFuPqzQwIlPTm3xZR7YNvduIMtkDIj2t21LSQwnbCrXvg== +"@babel/generator@^7.12.5": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.5.tgz#a2c50de5c8b6d708ab95be5e6053936c1884a4de" + integrity sha512-m16TQQJ8hPt7E+OS/XVQg/7U184MLXtvuGbCdA7na61vha+ImkyyNM/9DDA0unYCVZn3ZOhng+qz48/KBOT96A== dependencies: - "@babel/types" "^7.12.1" + "@babel/types" "^7.12.5" jsesc "^2.5.1" source-map "^0.5.0" @@ -237,14 +237,14 @@ "@babel/traverse" "^7.10.4" "@babel/types" "^7.10.4" -"@babel/helpers@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.12.1.tgz#8a8261c1d438ec18cb890434df4ec768734c1e79" - integrity sha512-9JoDSBGoWtmbay98efmT2+mySkwjzeFeAL9BuWNoVQpkPFQF8SIIFUfY5os9u8wVzglzoiPRSW7cuJmBDUt43g== +"@babel/helpers@^7.12.5": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.12.5.tgz#1a1ba4a768d9b58310eda516c449913fe647116e" + integrity sha512-lgKGMQlKqA8meJqKsW6rUnc4MdUk35Ln0ATDqdM1a/UpARODdI4j5Y5lVfUScnSNkJcdCRAaWkspykNoFg9sJA== dependencies: "@babel/template" "^7.10.4" - "@babel/traverse" "^7.12.1" - "@babel/types" "^7.12.1" + "@babel/traverse" "^7.12.5" + "@babel/types" "^7.12.5" "@babel/highlight@^7.10.4": version "7.10.4" @@ -255,10 +255,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.10.4", "@babel/parser@^7.12.1", "@babel/parser@^7.12.3": - version "7.12.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.3.tgz#a305415ebe7a6c7023b40b5122a0662d928334cd" - integrity sha512-kFsOS0IbsuhO5ojF8Hc8z/8vEIOkylVBrjiZUbLTE3XFe0Qi+uu6HjzQixkFaqr0ZPAMZcBVxEwmsnsLPZ2Xsw== +"@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.12.7": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.7.tgz#fee7b39fe809d0e73e5b25eecaf5780ef3d73056" + integrity sha512-oWR02Ubp4xTLCAqPRiNIuMVgNO5Aif/xpXtabhzW2HWUD47XJsAB4Zd/Rg30+XeQA3juXigV7hlquOTmwqLiwg== "@babel/plugin-proposal-async-generator-functions@^7.12.1": version "7.12.1" @@ -863,34 +863,34 @@ dependencies: regenerator-runtime "^0.13.4" -"@babel/template@^7.10.4", "@babel/template@^7.3.3": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278" - integrity sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA== +"@babel/template@^7.10.4", "@babel/template@^7.12.7", "@babel/template@^7.3.3": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc" + integrity sha512-GkDzmHS6GV7ZeXfJZ0tLRBhZcMcY0/Lnb+eEbXDBfCAcZCjrZKe6p3J4we/D24O9Y8enxWAg1cWwof59yLh2ow== dependencies: "@babel/code-frame" "^7.10.4" - "@babel/parser" "^7.10.4" - "@babel/types" "^7.10.4" + "@babel/parser" "^7.12.7" + "@babel/types" "^7.12.7" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.1.tgz#941395e0c5cc86d5d3e75caa095d3924526f0c1e" - integrity sha512-MA3WPoRt1ZHo2ZmoGKNqi20YnPt0B1S0GTZEPhhd+hw2KGUzBlHuVunj6K4sNuK+reEvyiPwtp0cpaqLzJDmAw== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.5", "@babel/traverse@^7.12.8": + version "7.12.8" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.8.tgz#c1c2983bf9ba0f4f0eaa11dff7e77fa63307b2a4" + integrity sha512-EIRQXPTwFEGRZyu6gXbjfpNORN1oZvwuzJbxcXjAgWV0iqXYDszN1Hx3FVm6YgZfu1ZQbCVAk3l+nIw95Xll9Q== dependencies: "@babel/code-frame" "^7.10.4" - "@babel/generator" "^7.12.1" + "@babel/generator" "^7.12.5" "@babel/helper-function-name" "^7.10.4" "@babel/helper-split-export-declaration" "^7.11.0" - "@babel/parser" "^7.12.1" - "@babel/types" "^7.12.1" + "@babel/parser" "^7.12.7" + "@babel/types" "^7.12.7" debug "^4.1.0" globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.1.tgz#e109d9ab99a8de735be287ee3d6a9947a190c4ae" - integrity sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA== +"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.7.tgz#6039ff1e242640a29452c9ae572162ec9a8f5d13" + integrity sha512-MNyI92qZq6jrQkXvtIiykvl4WtoRrVV9MPn+ZfsoEENjiWcBQ3ZSHrkxnJWgWtLX3XXqX5hrSQ+X69wkmesXuQ== dependencies: "@babel/helper-validator-identifier" "^7.10.4" lodash "^4.17.19" From cda30471f51db4631a0f54b852c553de270f7f64 Mon Sep 17 00:00:00 2001 From: ylemkimon Date: Tue, 24 Nov 2020 20:25:04 +0900 Subject: [PATCH 100/581] fix(serve): do not default port in webpack-dev-server v4 (#2126) --- packages/serve/__tests__/createConfig.test.ts | 17 ++++++++--- packages/serve/src/createConfig.ts | 17 ++--------- packages/serve/src/startDevServer.ts | 29 +++++++++++++------ 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/packages/serve/__tests__/createConfig.test.ts b/packages/serve/__tests__/createConfig.test.ts index 96a08c483e0..199df84b4a1 100644 --- a/packages/serve/__tests__/createConfig.test.ts +++ b/packages/serve/__tests__/createConfig.test.ts @@ -8,14 +8,14 @@ describe('createConfig', () => { hot: true, openPage: 'main', }; - expect(createConfig(args)).toEqual(args); + expect(createConfig(args, false)).toEqual(args); }); it('sets client object using clientLogging argument', () => { const args = { clientLogging: 'verbose', }; - expect(createConfig(args)).toEqual({ + expect(createConfig(args, false)).toEqual({ client: { logging: 'verbose', }, @@ -26,17 +26,26 @@ describe('createConfig', () => { const args = { hotOnly: true, }; - expect(createConfig(args)).toEqual({ + expect(createConfig(args, false)).toEqual({ hotOnly: true, }); }); + it('sets hot using hotOnly argument with devServer 4', () => { + const args = { + hotOnly: true, + }; + expect(createConfig(args, true)).toEqual({ + hot: 'only', + }); + }); + it('overrides hot with hotOnly', () => { const args = { hot: true, hotOnly: true, }; - expect(createConfig(args)).toEqual({ + expect(createConfig(args, false)).toEqual({ hot: true, hotOnly: true, }); diff --git a/packages/serve/src/createConfig.ts b/packages/serve/src/createConfig.ts index 94571608122..0c60ccf6099 100644 --- a/packages/serve/src/createConfig.ts +++ b/packages/serve/src/createConfig.ts @@ -1,29 +1,16 @@ -import { utils } from 'webpack-cli'; - import { devServerOptionsType } from './types'; -const { logger } = utils; - /** * * Creates a devServer config from CLI args * * @param {Object} args - devServer args + * @param {boolean} isDevServer4 - is devServer v4 * * @returns {Object} valid devServer options object */ -export default function createConfig(args): devServerOptionsType { +export default function createConfig(args, isDevServer4): devServerOptionsType { const options = { ...args }; - let isDevServer4 = false, - devServerVersion; - try { - // eslint-disable-next-line node/no-extraneous-require - devServerVersion = require('webpack-dev-server/package.json').version; - } catch (err) { - logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); - process.exit(2); - } - isDevServer4 = devServerVersion.startsWith('4'); if (options.clientLogging) { options.client = { diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index 74ebc208b43..945f74a45a1 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -16,15 +16,21 @@ const { logger } = utils; * @returns {Object[]} array of resulting servers */ export default function startDevServer(compiler, devServerArgs): object[] { - let Server; + let isDevServer4 = false, + devServerVersion, + Server; try { + // eslint-disable-next-line node/no-extraneous-require + devServerVersion = require('webpack-dev-server/package.json').version; // eslint-disable-next-line node/no-extraneous-require Server = require('webpack-dev-server/lib/Server'); } catch (err) { logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); process.exit(2); } - const cliOptions = createConfig(devServerArgs); + isDevServer4 = devServerVersion.startsWith('4'); + + const cliOptions = createConfig(devServerArgs, isDevServer4); const devServerOptions = getDevServerOptions(compiler); const servers = []; @@ -33,16 +39,21 @@ export default function startDevServer(compiler, devServerArgs): object[] { devServerOptions.forEach((devServerOpts): void => { const options = mergeOptions(cliOptions, devServerOpts); options.host = options.host || 'localhost'; - options.port = options.port || 8080; + // devSever v4 handles the default port itself + if (!isDevServer4) { + options.port = options.port || 8080; + } - const portNum = +options.port; + if (options.port) { + const portNum = +options.port; - if (usedPorts.find((port) => portNum === port)) { - throw new Error( - 'Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.', - ); + if (usedPorts.find((port) => portNum === port)) { + throw new Error( + 'Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.', + ); + } + usedPorts.push(portNum); } - usedPorts.push(portNum); const server = new Server(compiler, options); server.listen(options.port, options.host, (err): void => { From 2cd4f1f5d4e99fe5b825d1105e5babe292d99c63 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Nov 2020 14:28:48 +0300 Subject: [PATCH 101/581] chore(deps-dev): bump lint-staged from 10.5.1 to 10.5.2 (#2131) Bumps [lint-staged](https://github.com/okonet/lint-staged) from 10.5.1 to 10.5.2. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v10.5.1...v10.5.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index a4dfa57388f..19bcb0ada20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7687,9 +7687,9 @@ lines-and-columns@^1.1.6: integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= lint-staged@^10.5.0: - version "10.5.1" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.1.tgz#901e915c2360072dded0e7d752a0d9a49e079daa" - integrity sha512-fTkTGFtwFIJJzn/PbUO3RXyEBHIhbfYBE7+rJyLcOXabViaO/h6OslgeK6zpeUtzkDrzkgyAYDTLAwx6JzDTHw== + version "10.5.2" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.2.tgz#acfaa0093af3262aee3130b2e22438941530bdd1" + integrity sha512-e8AYR1TDlzwB8VVd38Xu2lXDZf6BcshVqKVuBQThDJRaJLobqKnpbm4dkwJ2puypQNbLr9KF/9mfA649mAGvjA== dependencies: chalk "^4.1.0" cli-truncate "^2.1.0" From 3144b540be4fddd492f54ca706078f7bf6c3298a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2020 14:39:40 +0300 Subject: [PATCH 102/581] chore(deps-dev): bump @babel/core from 7.12.8 to 7.12.9 (#2135) Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.12.8 to 7.12.9. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.9/packages/babel-core) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 19bcb0ada20..4e66aedd235 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,9 +15,9 @@ integrity sha512-725AQupWJZ8ba0jbKceeFblZTY90McUBWMwHhkFQ9q1zKPJ95GUktljFcgcsIVwRnTnRKlcYzfiNImg5G9m6ZQ== "@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.12.3", "@babel/core@^7.7.5": - version "7.12.8" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.8.tgz#8ad76c1a7d2a6a3beecc4395fa4f7b4cb88390e6" - integrity sha512-ra28JXL+5z73r1IC/t+FT1ApXU5LsulFDnTDntNfLQaScJUJmcHL5Qxm/IWanCToQk3bPWQo5bflbplU5r15pg== + version "7.12.9" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.9.tgz#fd450c4ec10cdbb980e2928b7aa7a28484593fc8" + integrity sha512-gTXYh3M5wb7FRXQy+FErKFAv90BnlOuNn1QkCK2lREoPAjrQCO49+HVSrFoe5uakFAF5eenS75KbO2vQiLrTMQ== dependencies: "@babel/code-frame" "^7.10.4" "@babel/generator" "^7.12.5" @@ -25,7 +25,7 @@ "@babel/helpers" "^7.12.5" "@babel/parser" "^7.12.7" "@babel/template" "^7.12.7" - "@babel/traverse" "^7.12.8" + "@babel/traverse" "^7.12.9" "@babel/types" "^7.12.7" convert-source-map "^1.7.0" debug "^4.1.0" @@ -872,10 +872,10 @@ "@babel/parser" "^7.12.7" "@babel/types" "^7.12.7" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.5", "@babel/traverse@^7.12.8": - version "7.12.8" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.8.tgz#c1c2983bf9ba0f4f0eaa11dff7e77fa63307b2a4" - integrity sha512-EIRQXPTwFEGRZyu6gXbjfpNORN1oZvwuzJbxcXjAgWV0iqXYDszN1Hx3FVm6YgZfu1ZQbCVAk3l+nIw95Xll9Q== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.5", "@babel/traverse@^7.12.9": + version "7.12.9" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.9.tgz#fad26c972eabbc11350e0b695978de6cc8e8596f" + integrity sha512-iX9ajqnLdoU1s1nHt36JDI9KG4k+vmI8WgjK5d+aDTwQbL2fUnzedNedssA645Ede3PM2ma1n8Q4h2ohwXgMXw== dependencies: "@babel/code-frame" "^7.10.4" "@babel/generator" "^7.12.5" From 1e5c7d259117fec0714163ce2a2e495c394da79a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2020 14:39:50 +0300 Subject: [PATCH 103/581] chore(deps-dev): bump @types/node from 14.14.9 to 14.14.10 (#2136) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.9 to 14.14.10. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4e66aedd235..c1609b82fd9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2451,9 +2451,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.9" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.9.tgz#04afc9a25c6ff93da14deabd65dc44485b53c8d6" - integrity sha512-JsoLXFppG62tWTklIoO4knA+oDTYsmqWxHRvd4lpmfQRNhX6osheUOWETP2jMoV/2bEHuMra8Pp3Dmo/stBFcw== + version "14.14.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.10.tgz#5958a82e41863cfc71f2307b3748e3491ba03785" + integrity sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 3c4b20ca06e412c3407da2530303d26ba100a8c6 Mon Sep 17 00:00:00 2001 From: ylemkimon Date: Wed, 25 Nov 2020 20:53:30 +0900 Subject: [PATCH 104/581] feat(webpack-cli): add arg postprocessing (#2133) --- packages/serve/__tests__/createConfig.test.ts | 53 ------------------- packages/serve/src/createConfig.ts | 29 ---------- packages/serve/src/startDevServer.ts | 4 +- .../webpack-cli/__tests__/arg-parser.test.js | 20 +++++++ packages/webpack-cli/lib/utils/arg-parser.js | 12 +++++ 5 files changed, 33 insertions(+), 85 deletions(-) delete mode 100644 packages/serve/__tests__/createConfig.test.ts delete mode 100644 packages/serve/src/createConfig.ts diff --git a/packages/serve/__tests__/createConfig.test.ts b/packages/serve/__tests__/createConfig.test.ts deleted file mode 100644 index 199df84b4a1..00000000000 --- a/packages/serve/__tests__/createConfig.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -import createConfig from '../src/createConfig'; - -describe('createConfig', () => { - it('creates config with arguments', () => { - const args = { - hot: true, - openPage: 'main', - }; - expect(createConfig(args, false)).toEqual(args); - }); - - it('sets client object using clientLogging argument', () => { - const args = { - clientLogging: 'verbose', - }; - expect(createConfig(args, false)).toEqual({ - client: { - logging: 'verbose', - }, - }); - }); - - it('sets hot using hotOnly argument', () => { - const args = { - hotOnly: true, - }; - expect(createConfig(args, false)).toEqual({ - hotOnly: true, - }); - }); - - it('sets hot using hotOnly argument with devServer 4', () => { - const args = { - hotOnly: true, - }; - expect(createConfig(args, true)).toEqual({ - hot: 'only', - }); - }); - - it('overrides hot with hotOnly', () => { - const args = { - hot: true, - hotOnly: true, - }; - expect(createConfig(args, false)).toEqual({ - hot: true, - hotOnly: true, - }); - }); -}); diff --git a/packages/serve/src/createConfig.ts b/packages/serve/src/createConfig.ts deleted file mode 100644 index 0c60ccf6099..00000000000 --- a/packages/serve/src/createConfig.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { devServerOptionsType } from './types'; - -/** - * - * Creates a devServer config from CLI args - * - * @param {Object} args - devServer args - * @param {boolean} isDevServer4 - is devServer v4 - * - * @returns {Object} valid devServer options object - */ -export default function createConfig(args, isDevServer4): devServerOptionsType { - const options = { ...args }; - - if (options.clientLogging) { - options.client = { - logging: options.clientLogging, - }; - // clientLogging is not a valid devServer option - delete options.clientLogging; - } - if (isDevServer4 && options.hotOnly) { - options.hot = 'only'; - // hotOnly is not a valid devServer option - delete options.hotOnly; - } - - return options; -} diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index 945f74a45a1..5c372888435 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -1,6 +1,5 @@ import { utils } from 'webpack-cli'; -import createConfig from './createConfig'; import getDevServerOptions from './getDevServerOptions'; import mergeOptions from './mergeOptions'; @@ -15,7 +14,7 @@ const { logger } = utils; * * @returns {Object[]} array of resulting servers */ -export default function startDevServer(compiler, devServerArgs): object[] { +export default function startDevServer(compiler, cliOptions): object[] { let isDevServer4 = false, devServerVersion, Server; @@ -30,7 +29,6 @@ export default function startDevServer(compiler, devServerArgs): object[] { } isDevServer4 = devServerVersion.startsWith('4'); - const cliOptions = createConfig(devServerArgs, isDevServer4); const devServerOptions = getDevServerOptions(compiler); const servers = []; diff --git a/packages/webpack-cli/__tests__/arg-parser.test.js b/packages/webpack-cli/__tests__/arg-parser.test.js index f61aab4d3a3..60dc543030d 100644 --- a/packages/webpack-cli/__tests__/arg-parser.test.js +++ b/packages/webpack-cli/__tests__/arg-parser.test.js @@ -96,6 +96,16 @@ const basicOptions = [ multiple: true, description: 'multi flag', }, + { + name: 'processor-flag', + usage: '--processor-flag', + type: Boolean, + description: 'flag with processor', + processor(opts) { + opts.processed = opts.processorFlag; + delete opts.processorFlag; + }, + }, ]; const helpAndVersionOptions = basicOptions.slice(0); @@ -421,4 +431,14 @@ describe('arg-parser', () => { }); expect(warnMock.mock.calls.length).toEqual(0); }); + + it('parses --processor-flag', () => { + const res = argParser(basicOptions, ['--processor-flag'], true); + expect(res.unknownArgs.length).toEqual(0); + expect(res.opts).toEqual({ + processed: true, + stringFlagWithDefault: 'default-value', + }); + expect(warnMock.mock.calls.length).toEqual(0); + }); }); diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index 7cbab371fa3..708ff698b28 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -28,6 +28,7 @@ const argParser = (options, args, argsOnly = false, name = '') => { } const parser = new commander.Command(); + const processors = {}; // Set parser name parser.name(name); @@ -151,6 +152,15 @@ const argParser = (options, args, argsOnly = false, name = '') => { parserInstance.option(negatedFlag, `negates ${option.name}`).action(() => {}); } + if (option.processor) { + // camel-case + const attributeName = option.name.split('-').reduce((str, word) => { + return str + word[0].toUpperCase() + word.slice(1); + }); + + processors[attributeName] = option.processor; + } + return parserInstance; }, parser); @@ -192,6 +202,8 @@ const argParser = (options, args, argsOnly = false, name = '') => { Object.keys(opts).forEach((key) => { if (opts[key] === undefined) { delete opts[key]; + } else if (processors[key]) { + processors[key](opts); } }); From 1398295cd8f3d952fb23cd2584459b01f6ba581b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2020 14:03:28 +0300 Subject: [PATCH 105/581] chore(deps-dev): bump webpack from 5.6.0 to 5.7.0 (#2137) Bumps [webpack](https://github.com/webpack/webpack) from 5.6.0 to 5.7.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.6.0...v5.7.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c1609b82fd9..631739563a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11714,9 +11714,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.3.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.6.0.tgz#282d10434c403b070ed91d459b385e873b51a07d" - integrity sha512-SIeFuBhuheKElRbd84O35UhKc0nxlgSwtzm2ksZ0BVhRJqxVJxEguT/pYhfiR0le/pxTa1VsCp7EOYyTsa6XOA== + version "5.7.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.7.0.tgz#bb752a5a54aa66dfd24ff5b80256e6c609bbc4cb" + integrity sha512-U0AshArzQX5X+L2eViVEjrE7nNLUs80BQYcPUyRnaUMT2EyZiIbXAYWL7GLx6qRu0ykxAwXytRoC1+jqWQZExw== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From de4546d67e671053e1bf2e52aee5aa84f9632750 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 27 Nov 2020 14:37:37 +0300 Subject: [PATCH 106/581] chore(deps-dev): bump webpack from 5.7.0 to 5.8.0 (#2139) Bumps [webpack](https://github.com/webpack/webpack) from 5.7.0 to 5.8.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.7.0...v5.8.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 631739563a7..a9bda1558a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10928,10 +10928,10 @@ table@^5.2.3: slice-ansi "^2.1.0" string-width "^3.0.0" -tapable@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.0.0.tgz#a49c3d6a8a2bb606e7db372b82904c970d537a08" - integrity sha512-bjzn0C0RWoffnNdTzNi7rNDhs1Zlwk2tRXgk8EiHKAOX1Mag3d6T0Y5zNa7l9CJ+EoUne/0UHdwS8tMbkh9zDg== +tapable@^2.0.0, tapable@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.1.1.tgz#b01cc1902d42a7bb30514e320ce21c456f72fd3f" + integrity sha512-Wib1S8m2wdpLbmQz0RBEVosIyvb/ykfKXf3ZIDqvWoMg/zTNm6G/tDSuUM61J1kNCDXWJrLHGSFeMhAG+gAGpQ== tar@^4.4.10, tar@^4.4.12, tar@^4.4.8: version "4.4.13" @@ -11714,9 +11714,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.3.0: - version "5.7.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.7.0.tgz#bb752a5a54aa66dfd24ff5b80256e6c609bbc4cb" - integrity sha512-U0AshArzQX5X+L2eViVEjrE7nNLUs80BQYcPUyRnaUMT2EyZiIbXAYWL7GLx6qRu0ykxAwXytRoC1+jqWQZExw== + version "5.8.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.8.0.tgz#65f00a181708279ff982c2d7338e1dd5505364c4" + integrity sha512-X2yosPiHip3L0TE+ylruzrOqSgEgsdGyBOGFWKYChcwlKChaw9VodZIUovG1oo7s0ss6e3ZxBMn9tXR+nkPThA== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" @@ -11738,7 +11738,7 @@ webpack@^5.3.0: neo-async "^2.6.2" pkg-dir "^4.2.0" schema-utils "^3.0.0" - tapable "^2.0.0" + tapable "^2.1.1" terser-webpack-plugin "^5.0.3" watchpack "^2.0.0" webpack-sources "^2.1.1" From dbbe4d4bc93ff9147ba43fae2d2352fa3583558d Mon Sep 17 00:00:00 2001 From: ylemkimon Date: Fri, 27 Nov 2020 22:53:09 +0900 Subject: [PATCH 107/581] fix(serve): do not default host in webpack-dev-server v4 (#2141) --- packages/serve/src/startDevServer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index 5c372888435..28eaeee6e4c 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -36,9 +36,9 @@ export default function startDevServer(compiler, cliOptions): object[] { const usedPorts: number[] = []; devServerOptions.forEach((devServerOpts): void => { const options = mergeOptions(cliOptions, devServerOpts); - options.host = options.host || 'localhost'; - // devSever v4 handles the default port itself + // devSever v4 handles the default host and port itself if (!isDevServer4) { + options.host = options.host || 'localhost'; options.port = options.port || 8080; } From 91d518d4065c6e1b9074694e0df0ce85e0242443 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 27 Nov 2020 18:17:57 +0300 Subject: [PATCH 108/581] refactor: code (#2132) fix: default config resolution, default cache values and multi compiler mode (potential breaking change - resolution based on the `mode` argument without the `config` argument was removed due to a situation where we cannot determine an incorrect configuration, which leads to unpredictable result, we are very sorry about the current situation, but this is the only way out) --- .../webpack-cli/__tests__/resolveArgs.test.js | 94 +-- .../resolveConfig/resolveConfig.test.js | 12 +- packages/webpack-cli/lib/bootstrap.js | 11 +- packages/webpack-cli/lib/plugins/CLIPlugin.js | 107 +++ .../lib/plugins/WebpackCLIPlugin.js | 63 -- packages/webpack-cli/lib/utils/cli-flags.js | 233 +++--- .../webpack-cli/lib/utils/flag-defaults.js | 25 - .../lib/utils/prompt-installation.js | 4 + packages/webpack-cli/lib/webpack-cli.js | 750 +++++++----------- test/analyze/analyze-flag.test.js | 11 +- test/analyze/analyze.config.js | 6 + test/analyze/webpack.config.js | 4 +- test/cache/cache.test.js | 60 +- test/cache/webpack.config.js | 6 +- test/colors/colors.test.js | 25 +- test/config-name/config-name.test.js | 109 ++- test/config-name/single-other-config.js | 8 + test/config/absent/config-absent.test.js | 2 +- .../all/.webpack/webpack.config.none.js | 9 - .../all/.webpack/webpack.config.prod.js | 9 - .../defaults/all/multiple-config.test.js | 18 - .../.webpack/webpackfile.js} | 0 .../index.js | 0 .../multiple-location-config.test.js | 0 .../.webpack/webpack.config.js} | 0 .../dev-none-config.test.js | 0 .../{all => dot-webpack-directory}/index.js | 0 .../webpack.config.development.js | 9 - .../multiple-location/webpack.config.js | 9 - .../.webpack/webpack.config.dev.js | 9 - .../.webpack/webpack.config.none.js | 9 - test/config/defaults/none and dev/index.js | 1 - ...onfig.development.js => webpack.config.js} | 0 .../defaults/with-mode/webpack.config.none.js | 9 - .../with-mode/webpack.config.production.js | 9 - .../invalid-export/invalid-export.test.js | 8 +- .../{no-config-array => invalid-path}/a.js | 0 test/config/invalid-path/invalid-path.test.js | 12 + test/config/invalid-path/webpack.config.js | 9 + .../config/multiple-with-one-compilation/a.js | 1 + .../multiple-with-one-compilation.test.js | 18 + .../webpack.config.js | 11 + .../no-config-array/no-config-array.test.js | 5 +- test/config/no-config-array/src/index.js | 1 + test/config/no-config-object/a.js | 1 + .../no-config-object/no-config-object.test.js | 17 + test/config/no-config-object/src/index.js | 1 + .../config/no-config-object/webpack.config.js | 1 + test/core-flags/bail-flag.test.js | 4 +- test/core-flags/cache-flags.test.js | 102 +-- test/core-flags/devtool-flag.test.js | 17 +- test/core-flags/experiments-flag.test.js | 4 +- test/core-flags/externals-flags.test.js | 4 +- test/core-flags/invalid-flag.test.js | 13 + test/core-flags/module-flags.test.js | 20 +- test/core-flags/node-flags.test.js | 16 - test/core-flags/optimization-flags.test.js | 54 +- test/core-flags/output-flags.test.js | 53 +- test/core-flags/performance-flags.test.js | 4 +- test/core-flags/resolve-flags.test.js | 4 +- test/core-flags/snapshot-flags.test.js | 4 +- test/core-flags/stats-flags.test.js | 30 +- test/core-flags/watch-flags.test.js | 20 +- test/devtool/array/source-map-array.test.js | 2 + test/help/help-flags.test.js | 2 +- test/hot/hot-flag.test.js | 29 +- test/hot/webpack.config.js | 3 - test/invalid-schema/invalid-schema.test.js | 24 +- .../mode-single-arg/mode-single-arg.test.js | 11 +- .../mode-with-config/mode-with-config.test.js | 4 +- test/prefetch/prefetch.test.js | 24 +- test/prefetch/src/index.js | 12 +- test/prefetch/src/p.js | 4 +- test/prefetch/webpack.config.js | 6 +- test/stats/cli-flags/stats.test.js | 17 +- test/stats/watch/stats-and-watch.test.js | 6 +- test/unknown/unknown.test.js | 39 +- test/utils/test-utils.js | 8 +- test/watch/watch-flag.test.js | 53 +- test/watch/watch.config.js | 3 + 80 files changed, 1103 insertions(+), 1199 deletions(-) create mode 100644 packages/webpack-cli/lib/plugins/CLIPlugin.js delete mode 100644 packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js delete mode 100644 packages/webpack-cli/lib/utils/flag-defaults.js create mode 100644 test/analyze/analyze.config.js create mode 100644 test/config-name/single-other-config.js delete mode 100644 test/config/defaults/all/.webpack/webpack.config.none.js delete mode 100644 test/config/defaults/all/.webpack/webpack.config.prod.js delete mode 100644 test/config/defaults/all/multiple-config.test.js rename test/config/defaults/{multiple-location/.webpack/webpack.config.development.js => dot-webpack-directory-webpackfile/.webpack/webpackfile.js} (100%) rename test/config/defaults/{multiple-location => dot-webpack-directory-webpackfile}/index.js (100%) rename test/config/defaults/{multiple-location => dot-webpack-directory-webpackfile}/multiple-location-config.test.js (100%) rename test/config/defaults/{all/.webpack/webpack.config.dev.js => dot-webpack-directory/.webpack/webpack.config.js} (100%) rename test/config/defaults/{none and dev => dot-webpack-directory}/dev-none-config.test.js (100%) rename test/config/defaults/{all => dot-webpack-directory}/index.js (100%) delete mode 100644 test/config/defaults/multiple-location/webpack.config.development.js delete mode 100644 test/config/defaults/multiple-location/webpack.config.js delete mode 100644 test/config/defaults/none and dev/.webpack/webpack.config.dev.js delete mode 100644 test/config/defaults/none and dev/.webpack/webpack.config.none.js delete mode 100644 test/config/defaults/none and dev/index.js rename test/config/defaults/with-mode/{webpack.config.development.js => webpack.config.js} (100%) delete mode 100644 test/config/defaults/with-mode/webpack.config.none.js delete mode 100644 test/config/defaults/with-mode/webpack.config.production.js rename test/config/{no-config-array => invalid-path}/a.js (100%) create mode 100644 test/config/invalid-path/invalid-path.test.js create mode 100644 test/config/invalid-path/webpack.config.js create mode 100644 test/config/multiple-with-one-compilation/a.js create mode 100644 test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js create mode 100644 test/config/multiple-with-one-compilation/webpack.config.js create mode 100644 test/config/no-config-array/src/index.js create mode 100644 test/config/no-config-object/a.js create mode 100644 test/config/no-config-object/no-config-object.test.js create mode 100644 test/config/no-config-object/src/index.js create mode 100644 test/config/no-config-object/webpack.config.js create mode 100644 test/core-flags/invalid-flag.test.js create mode 100644 test/watch/watch.config.js diff --git a/packages/webpack-cli/__tests__/resolveArgs.test.js b/packages/webpack-cli/__tests__/resolveArgs.test.js index d5347ba23fd..f199870cfb3 100644 --- a/packages/webpack-cli/__tests__/resolveArgs.test.js +++ b/packages/webpack-cli/__tests__/resolveArgs.test.js @@ -3,140 +3,84 @@ const webpackCLI = require('../lib/webpack-cli'); const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; -const basicResolver = new webpackCLI().resolveArgs; +const basicResolver = new webpackCLI().resolveArguments; describe('BasicResolver', () => { it('should handle the output option', async () => { - const result = await basicResolver({ - outputPath: './bundle', - }); + const result = await basicResolver({ options: {} }, { outputPath: './bundle' }); + expect(result.options.output.path).toEqual(resolve('bundle')); }); it('should handle the mode option [production]', async () => { - const result = await basicResolver( - { - mode: 'production', - }, - {}, - ); - // ensure no other properties are added + const result = await basicResolver({ options: {} }, { mode: 'production' }); + expect(result.options).toMatchObject({ mode: 'production' }); expect(result.options.mode).toEqual('production'); }); it('should handle the mode option [development]', async () => { const result = await basicResolver( + { options: {} }, { mode: 'development', }, - {}, ); - // ensure no other properties are added expect(result.options).toMatchObject({ mode: 'development' }); expect(result.options.mode).toEqual('development'); }); it('should handle the mode option [none]', async () => { const result = await basicResolver( + { options: {} }, { mode: 'none', }, - {}, ); - // ensure no other properties are added expect(result.options).toMatchObject({ mode: 'none' }); expect(result.options.mode).toEqual('none'); }); it('should prefer supplied move flag over NODE_ENV', async () => { process.env.NODE_ENV = 'production'; - const result = await basicResolver( - { - mode: 'development', - }, - {}, - ); + const result = await basicResolver({ options: {} }, { mode: 'development' }); - // ensure no other properties are added expect(result.options).toMatchObject({ mode: 'development' }); }); it('should prefer supplied move flag over mode from config', async () => { - const result = await basicResolver( - { - mode: 'development', - }, - { mode: 'production' }, - ); + const result = await basicResolver({ options: { mode: 'development' } }, { mode: 'production' }); - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'development' }); + expect(result.options).toMatchObject({ mode: 'production' }); }); it('should prefer mode form config over NODE_ENV', async () => { process.env.NODE_ENV = 'development'; - const result = await basicResolver({}, { mode: 'production' }); + const result = await basicResolver({ options: {} }, { mode: 'production' }); - // ensure no other properties are added expect(result.options).toMatchObject({ mode: 'production' }); }); it('should prefer mode form flag over NODE_ENV and config', async () => { process.env.NODE_ENV = 'development'; - const result = await basicResolver({ mode: 'none' }, { mode: 'production' }); - - // ensure no other properties are added - expect(result.options).toMatchObject({ mode: 'none' }); - }); + const result = await basicResolver({ options: {} }, {}); - it('should assign json correctly', async () => { - const result = await basicResolver({ - json: true, - }); - expect(result.options.stats).toBeFalsy(); - expect(result.outputOptions.json).toBeTruthy(); + expect(result.options).toMatchObject({ mode: 'development' }); }); it('should assign stats correctly', async () => { - const result = await basicResolver({ - stats: 'warning', - }); - expect(result.options.stats).toEqual('warning'); - expect(result.outputOptions.json).toBeFalsy(); - }); + const result = await basicResolver({ options: {} }, { stats: 'errors-warnings' }); - it('should load the HMR plugin', async () => { - const result = await basicResolver({ - hot: true, - }); - expect(result.options.plugins[0].constructor.name).toEqual('HotModuleReplacementPlugin'); + expect(result.options.stats).toEqual('errors-warnings'); }); - it('should load the prefetch plugin', async () => { - const result = await basicResolver({ - prefetch: 'url', - }); - expect(result.options.plugins[0].constructor.name).toEqual('PrefetchPlugin'); - }); + targetValues.map((option) => { + it(`should handle ${option} option`, async () => { + const result = await basicResolver({ options: {} }, { target: option }); - it('should load the webpack-bundle-analyzer plugin', async () => { - const result = await basicResolver({ - analyze: true, + expect(result.options.target).toEqual(option); }); - expect(result.options.plugins[0].constructor.name).toEqual('BundleAnalyzerPlugin'); }); - - { - targetValues.map((option) => { - it(`should handle ${option} option`, async () => { - const result = await basicResolver({ - target: option, - }); - expect(result.options.target).toEqual(option); - }); - }); - } }); diff --git a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js index 9b4162eba1c..674e357444c 100644 --- a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js +++ b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js @@ -22,8 +22,8 @@ describe('resolveConfig', function () { devtool: 'eval-cheap-module-source-map', target: 'node', }; + expect(result.options).toEqual(expectedOptions); - expect(result.outputOptions).toEqual({}); }); it('should return array for multiple config', async () => { @@ -31,21 +31,21 @@ describe('resolveConfig', function () { config: [resolve(__dirname, './webpack.config1.cjs'), resolve(__dirname, './webpack.config2.cjs')], }); const expectedOptions = [config1, config2]; + expect(result.options).toEqual(expectedOptions); - expect(result.outputOptions).toEqual({}); }); it('should return config object for single config', async () => { const result = await resolveConfig({ config: [resolve(__dirname, './webpack.config1.cjs')] }); + expect(result.options).toEqual(config1); - expect(result.outputOptions).toEqual({}); }); it('should return resolved config object for promise config', async () => { const result = await resolveConfig({ config: [resolve(__dirname, './webpack.promise.config.cjs')] }); const expectedOptions = await promiseConfig(); + expect(result.options).toEqual(expectedOptions); - expect(result.outputOptions).toEqual({}); }); it('should handle configs returning different types', async () => { @@ -54,8 +54,8 @@ describe('resolveConfig', function () { }); const resolvedPromiseConfig = await promiseConfig(); const expectedOptions = [resolvedPromiseConfig, ...arrayConfig]; + expect(result.options).toEqual(expectedOptions); - expect(result.outputOptions).toEqual({}); }); it('should handle different env formats', async () => { @@ -64,7 +64,7 @@ describe('resolveConfig', function () { config: [resolve(__dirname, './env.webpack.config.cjs')], }); const expectedOptions = { mode: 'staging', name: 'Hisoka' }; + expect(result.options).toEqual(expectedOptions); - expect(result.outputOptions).toEqual({}); }); }); diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index 3291885ee46..f61786c28b6 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -1,7 +1,6 @@ +const { flags, isCommandUsed } = require('./utils/cli-flags'); const WebpackCLI = require('./webpack-cli'); -const { flags } = require('./utils/cli-flags'); const logger = require('./utils/logger'); -const { isCommandUsed } = require('./utils/cli-flags'); const argParser = require('./utils/arg-parser'); const leven = require('leven'); const { options: coloretteOptions } = require('colorette'); @@ -46,13 +45,13 @@ const runCLI = async (cliArgs) => { if (parsedArgs.unknownArgs.length > 0) { parsedArgs.unknownArgs.forEach((unknown) => { - logger.error(`Unknown argument: ${unknown}`); + logger.error(`Unknown argument: '${unknown}'`); const strippedFlag = unknown.substr(2); - const { name: suggestion } = flags.find((flag) => leven(strippedFlag, flag.name) < 3); + const found = flags.find((flag) => leven(strippedFlag, flag.name) < 3); - if (suggestion) { - logger.raw(`Did you mean --${suggestion}?`); + if (found) { + logger.raw(`Did you mean '--${found.name}'?`); } }); diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js new file mode 100644 index 00000000000..72efe8bd44d --- /dev/null +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -0,0 +1,107 @@ +const packageExists = require('../utils/package-exists'); +const webpack = packageExists('webpack') ? require('webpack') : undefined; +const logger = require('../utils/logger'); + +class CLIPlugin { + constructor(options) { + this.options = options; + } + + setupHotPlugin(compiler) { + const { HotModuleReplacementPlugin } = compiler.webpack || webpack; + const hotModuleReplacementPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof HotModuleReplacementPlugin)); + + if (!hotModuleReplacementPlugin) { + new HotModuleReplacementPlugin().apply(compiler); + } + } + + setupPrefetchPlugin(compiler) { + const { PrefetchPlugin } = compiler.webpack || webpack; + + new PrefetchPlugin(null, this.options.prefetch).apply(compiler); + } + + async setupBundleAnalyzerPlugin(compiler) { + // eslint-disable-next-line node/no-extraneous-require + const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); + const bundleAnalyzerPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof BundleAnalyzerPlugin)); + + if (!bundleAnalyzerPlugin) { + new BundleAnalyzerPlugin().apply(compiler); + } + } + + setupProgressPlugin(compiler) { + const { ProgressPlugin } = compiler.webpack || webpack; + const progressPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin)); + + if (!progressPlugin) { + if (typeof this.options.progress === 'string' && this.options.progress !== 'profile') { + logger.error(`'${this.options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`); + process.exit(2); + } + + new ProgressPlugin({ profile: this.options.progress === 'profile' }).apply(compiler); + } + } + + setupHelpfulOutput(compiler) { + const pluginName = 'webpack-cli'; + const getCompilationName = (compilation) => (compilation.name ? ` '${compilation.name}'` : ''); + + compiler.hooks.run.tap(pluginName, (compiler) => { + logger.success(`Compilation${getCompilationName(compiler)} starting...`); + }); + + compiler.hooks.watchRun.tap(pluginName, (compiler) => { + const { bail, watch } = compiler.options; + + if (bail && watch) { + logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); + } + + logger.success(`Compilation${getCompilationName(compiler)} starting...`); + }); + + compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => { + const date = new Date(changeTime * 1000); + + logger.log(`File '${filename}' was modified, changed time is ${date} (timestamp is ${changeTime})`); + }); + + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, (stats) => { + logger.success(`Compilation${getCompilationName(stats.compilation)} finished`); + + process.nextTick(() => { + if (compiler.watchMode) { + logger.success(`Compilation${getCompilationName(stats.compilation)} is watching files for updates...`); + } + }); + }); + } + + apply(compiler) { + if (this.options.progress && this.options.helpfulOutput) { + this.setupProgressPlugin(compiler); + } + + if (this.options.hot) { + this.setupHotPlugin(compiler); + } + + if (this.options.prefetch) { + this.setupPrefetchPlugin(compiler); + } + + if (this.options.analyze) { + this.setupBundleAnalyzerPlugin(compiler); + } + + if (this.options.helpfulOutput) { + this.setupHelpfulOutput(compiler); + } + } +} + +module.exports = CLIPlugin; diff --git a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js b/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js deleted file mode 100644 index 764c8e2b070..00000000000 --- a/packages/webpack-cli/lib/plugins/WebpackCLIPlugin.js +++ /dev/null @@ -1,63 +0,0 @@ -const packageExists = require('../utils/package-exists'); -const webpack = packageExists('webpack') ? require('webpack') : undefined; -const logger = require('../utils/logger'); - -const PluginName = 'webpack-cli'; - -class WebpackCLIPlugin { - constructor(options) { - this.options = options; - } - - async apply(compiler) { - const compilers = compiler.compilers || [compiler]; - - for (const compiler of compilers) { - if (this.options.progress) { - const { ProgressPlugin } = compiler.webpack || webpack; - - let progressPluginExists; - - if (compiler.options.plugins) { - progressPluginExists = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin)); - } - - if (!progressPluginExists) { - if (typeof this.options.progress === 'string' && this.options.progress !== 'profile') { - logger.error( - `'${this.options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`, - ); - process.exit(2); - } - - const isProfile = this.options.progress === 'profile'; - - new ProgressPlugin({ profile: isProfile }).apply(compiler); - } - } - } - - const compilationName = (compilation) => (compilation.name ? ` ${compilation.name}` : ''); - - compiler.hooks.watchRun.tap(PluginName, (compilation) => { - const { bail, watch } = compilation.options; - if (bail && watch) { - logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); - } - - logger.success(`Compilation${compilationName(compilation)} starting...`); - }); - - compiler.hooks.done.tap(PluginName, (compilation) => { - logger.success(`Compilation${compilationName(compilation)} finished`); - - process.nextTick(() => { - if (compiler.watchMode) { - logger.success('watching files for updates...'); - } - }); - }); - } -} - -module.exports = WebpackCLIPlugin; diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 72ea25577d1..c0888924133 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -1,12 +1,6 @@ const packageExists = require('./package-exists'); const cli = packageExists('webpack') ? require('webpack').cli : undefined; -const BASIC_GROUP = 'basic'; - -const groups = { - BASIC_GROUP, -}; - const commands = [ { packageName: '@webpack-cli/init', @@ -92,15 +86,7 @@ const commands = [ ]; const builtInFlags = [ - { - name: 'entry', - usage: '--entry | --entry --entry ', - type: String, - multiple: true, - group: BASIC_GROUP, - description: 'The entry point(s) of your application e.g. ./src/main.js', - link: 'https://webpack.js.org/concepts/#entry', - }, + // For configs { name: 'config', usage: '--config ', @@ -111,11 +97,11 @@ const builtInFlags = [ link: 'https://webpack.js.org/configuration/', }, { - name: 'color', - usage: '--color', - type: Boolean, - negative: true, - description: 'Enable/Disable colors on console', + name: 'config-name', + usage: '--config-name ', + type: String, + multiple: true, + description: 'Name of the configuration to use', }, { name: 'merge', @@ -125,19 +111,88 @@ const builtInFlags = [ description: 'Merge two or more configurations using webpack-merge e.g. -c ./webpack.config.js -c ./webpack.test.config.js --merge', link: 'https://github.com/survivejs/webpack-merge', }, + // Complex configs + { + name: 'env', + usage: '--env', + type: String, + multipleType: true, + description: 'Environment passed to the configuration when it is a function', + link: 'https://webpack.js.org/api/cli/#environment-options', + }, + + // Adding more plugins + { + name: 'hot', + usage: '--hot', + alias: 'h', + type: Boolean, + negative: true, + description: 'Enables Hot Module Replacement', + link: 'https://webpack.js.org/concepts/hot-module-replacement/', + }, + { + name: 'analyze', + usage: '--analyze', + type: Boolean, + multiple: false, + description: 'It invokes webpack-bundle-analyzer plugin to get bundle information', + link: 'https://github.com/webpack-contrib/webpack-bundle-analyzer', + }, { name: 'progress', usage: '--progress', type: [Boolean, String], - group: BASIC_GROUP, description: 'Print compilation progress during build', }, + { + name: 'prefetch', + usage: '--prefetch ', + type: String, + description: 'Prefetch this request', + link: 'https://webpack.js.org/plugins/prefetch-plugin/', + }, + + // Help and versions { name: 'help', usage: '--help', type: Boolean, description: 'Outputs list of supported flags', }, + { + name: 'version', + usage: '--version | --version ', + alias: 'v', + type: Boolean, + description: 'Get current version', + }, + + // Output options + { + name: 'json', + usage: '--json', + type: [String, Boolean], + alias: 'j', + description: 'Prints result as JSON or store it in a file', + }, + { + name: 'color', + usage: '--color', + type: Boolean, + negative: true, + description: 'Enable/Disable colors on console', + }, + + // For webpack@4 + { + name: 'entry', + usage: '--entry | --entry --entry ', + type: String, + multiple: true, + description: 'The entry point(s) of your application e.g. ./src/main.js', + link: 'https://webpack.js.org/concepts/#entry', + }, { name: 'output-path', usage: '--output-path ', @@ -155,47 +210,15 @@ const builtInFlags = [ description: 'Sets the build target e.g. node', link: 'https://webpack.js.org/configuration/target/#target', }, - { - name: 'watch', - usage: '--watch', - type: Boolean, - alias: 'w', - group: BASIC_GROUP, - description: 'Watch for files changes', - link: 'https://webpack.js.org/configuration/watch/', - }, - { - name: 'hot', - usage: '--hot', - alias: 'h', - type: Boolean, - negative: true, - description: 'Enables Hot Module Replacement', - link: 'https://webpack.js.org/concepts/hot-module-replacement/', - }, { name: 'devtool', usage: '--devtool ', type: String, + negative: true, alias: 'd', - group: BASIC_GROUP, description: 'Determine source maps to use', link: 'https://webpack.js.org/configuration/devtool/#devtool', }, - { - name: 'prefetch', - usage: '--prefetch ', - type: String, - description: 'Prefetch this request', - link: 'https://webpack.js.org/plugins/prefetch-plugin/', - }, - { - name: 'json', - usage: '--json', - type: [String, Boolean], - alias: 'j', - description: 'Prints result as JSON or store it in a file', - }, { name: 'mode', usage: '--mode ', @@ -204,11 +227,11 @@ const builtInFlags = [ link: 'https://webpack.js.org/concepts/#mode', }, { - name: 'version', - usage: '--version | --version ', - alias: 'v', - type: Boolean, - description: 'Get current version', + name: 'name', + usage: '--name', + type: String, + description: 'Name of the configuration. Used when loading multiple configurations.', + link: 'https://webpack.js.org/configuration/other-options/#name', }, { name: 'stats', @@ -219,67 +242,44 @@ const builtInFlags = [ link: 'https://webpack.js.org/configuration/stats/#stats', }, { - name: 'env', - usage: '--env', - type: String, - multipleType: true, - description: 'Environment passed to the configuration when it is a function', - link: 'https://webpack.js.org/api/cli/#environment-options', - }, - { - name: 'name', - usage: '--name', - type: String, - group: BASIC_GROUP, - description: 'Name of the configuration. Used when loading multiple configurations.', - link: 'https://webpack.js.org/configuration/other-options/#name', - }, - { - name: 'config-name', - usage: '--config-name ', - type: String, - multiple: true, - description: 'Name of the configuration to use', - }, - { - name: 'analyze', - usage: '--analyze', + name: 'watch', + usage: '--watch', type: Boolean, - multiple: false, - description: 'It invokes webpack-bundle-analyzer plugin to get bundle information', - link: 'https://github.com/webpack-contrib/webpack-bundle-analyzer', + negative: true, + alias: 'w', + description: 'Watch for files changes', + link: 'https://webpack.js.org/configuration/watch/', }, ]; -// Extract all the flags being exported from core. A list of cli flags generated by core -// can be found here https://github.com/webpack/webpack/blob/master/test/__snapshots__/Cli.test.js.snap -let flagsFromCore = - cli !== undefined - ? Object.entries(cli.getArguments()).map(([flag, meta]) => { - if (meta.simpleType === 'string') { - meta.type = String; - meta.usage = `--${flag} `; - } else if (meta.simpleType === 'number') { - meta.type = Number; - meta.usage = `--${flag} `; - } else { - meta.type = Boolean; - meta.negative = !flag.endsWith('-reset'); - meta.usage = `--${flag}`; - } - return { - ...meta, - name: flag, - group: 'core', - }; - }) - : []; +// Extract all the flags being exported from core. +// A list of cli flags generated by core can be found here https://github.com/webpack/webpack/blob/master/test/__snapshots__/Cli.test.js.snap +const coreFlags = cli + ? Object.entries(cli.getArguments()).map(([flag, meta]) => { + if (meta.simpleType === 'string') { + meta.type = String; + meta.usage = `--${flag} `; + } else if (meta.simpleType === 'number') { + meta.type = Number; + meta.usage = `--${flag} `; + } else { + meta.type = Boolean; + meta.negative = !flag.endsWith('-reset'); + meta.usage = `--${flag}`; + } + + const inBuiltIn = builtInFlags.find((builtInFlag) => builtInFlag.name === flag); -// duplicate flags -const duplicateFlags = builtInFlags.map((flag) => flag.name); + if (inBuiltIn) { + return { ...meta, name: flag, group: 'core', ...inBuiltIn }; + } -// remove duplicate flags -flagsFromCore = flagsFromCore.filter((flag) => !duplicateFlags.includes(flag.name)); + return { ...meta, name: flag, group: 'core' }; + }) + : []; +const flags = [] + .concat(builtInFlags.filter((builtInFlag) => !coreFlags.find((coreFlag) => builtInFlag.name === coreFlag.name))) + .concat(coreFlags); const isCommandUsed = (args) => commands.find((cmd) => { @@ -287,9 +287,8 @@ const isCommandUsed = (args) => }); module.exports = { - groups, commands, - flagsFromCore, - flags: [...builtInFlags, ...flagsFromCore], + cli, + flags, isCommandUsed, }; diff --git a/packages/webpack-cli/lib/utils/flag-defaults.js b/packages/webpack-cli/lib/utils/flag-defaults.js deleted file mode 100644 index c2484fb53ea..00000000000 --- a/packages/webpack-cli/lib/utils/flag-defaults.js +++ /dev/null @@ -1,25 +0,0 @@ -const cacheDefaults = (finalConfig, parsedArgs, outputOptions) => { - // eslint-disable-next-line no-prototype-builtins - const hasCache = finalConfig.hasOwnProperty('cache'); - let cacheConfig = {}; - if (hasCache && (parsedArgs.config || (outputOptions && outputOptions.defaultConfig))) { - if (finalConfig.cache && finalConfig.cache.type === 'filesystem') { - cacheConfig.buildDependencies = { - config: parsedArgs.config || [outputOptions.defaultConfig], - }; - } else { - cacheConfig = finalConfig.cache; - } - return { cache: cacheConfig }; - } - return cacheConfig; -}; - -const assignFlagDefaults = (compilerConfig, parsedArgs, outputOptions) => { - if (Array.isArray(compilerConfig)) { - return compilerConfig.map((config) => cacheDefaults(config, parsedArgs, outputOptions)); - } - return cacheDefaults(compilerConfig, parsedArgs, outputOptions); -}; - -module.exports = assignFlagDefaults; diff --git a/packages/webpack-cli/lib/utils/prompt-installation.js b/packages/webpack-cli/lib/utils/prompt-installation.js index e9988943af5..2a6d0ca3743 100644 --- a/packages/webpack-cli/lib/utils/prompt-installation.js +++ b/packages/webpack-cli/lib/utils/prompt-installation.js @@ -15,9 +15,11 @@ async function promptInstallation(packageName, preMessage) { const options = [packageManager === 'yarn' ? 'add' : 'install', '-D', packageName]; const commandToBeRun = `${packageManager} ${options.join(' ')}`; + if (preMessage) { preMessage(); } + const question = `Would you like to install ${packageName}? (That will run ${green(commandToBeRun)})`; const { installConfirm } = await prompt([ { @@ -27,8 +29,10 @@ async function promptInstallation(packageName, preMessage) { initial: 'Y', }, ]); + if (installConfirm) { await runCommand(commandToBeRun); + return packageExists(packageName); } diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index f57b5bd2e7f..b76b4016d0e 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -6,10 +6,9 @@ const { writeFileSync, existsSync } = require('fs'); const { options: coloretteOptions, yellow } = require('colorette'); const logger = require('./utils/logger'); -const { groups, flags, flagsFromCore } = require('./utils/cli-flags'); +const { cli, flags } = require('./utils/cli-flags'); const argParser = require('./utils/arg-parser'); -const assignFlagDefaults = require('./utils/flag-defaults'); -const WebpackCLIPlugin = require('./plugins/WebpackCLIPlugin'); +const CLIPlugin = require('./plugins/CLIPlugin'); const promptInstallation = require('./utils/prompt-installation'); const { extensions, jsVariants } = require('interpret'); const rechoir = require('rechoir'); @@ -19,448 +18,368 @@ const toKebabCase = require('./utils/to-kebab-case'); const { resolve, extname } = path; class WebpackCLI { - constructor() { - this.compilerConfiguration = {}; - this.outputConfiguration = {}; - } + constructor() {} - /** - * Responsible for handling flags coming from webpack/webpack - * @private\ - * @returns {void} - */ - _handleCoreFlags(parsedArgs) { - const coreCliHelper = require('webpack').cli; + async resolveConfig(args) { + const loadConfig = (configPath) => { + const ext = extname(configPath); + const interpreted = Object.keys(jsVariants).find((variant) => variant === ext); - if (!coreCliHelper) { - return; - } + if (interpreted) { + rechoir.prepare(extensions, configPath); + } - const coreFlagMap = flagsFromCore.reduce((acc, cur) => { - acc.set(cur.name, cur); + let options; - return acc; - }, new Map()); - const coreConfig = Object.keys(parsedArgs) - .filter((arg) => coreFlagMap.has(toKebabCase(arg))) - .reduce((acc, cur) => { - acc[toKebabCase(cur)] = parsedArgs[cur]; + try { + options = require(configPath); + } catch (error) { + logger.error(`Failed to load '${configPath}'`); + logger.error(error); + process.exit(2); + } - return acc; - }, {}); - const coreCliArgs = coreCliHelper.getArguments(); + if (options.default) { + options = options.default; + } - // Merge the core flag config with the compilerConfiguration - coreCliHelper.processArguments(coreCliArgs, this.compilerConfiguration, coreConfig); + return { options, path: configPath }; + }; - // Assign some defaults to core flags - const configWithDefaults = assignFlagDefaults(this.compilerConfiguration, parsedArgs, this.outputConfiguration); + const evaluateConfig = async (loadedConfig, args) => { + const isMultiCompiler = Array.isArray(loadedConfig.options); + const config = isMultiCompiler ? loadedConfig.options : [loadedConfig.options]; - this._mergeOptionsToConfiguration(configWithDefaults); - } + let evaluatedConfig = await Promise.all( + config.map(async (rawConfig) => { + if (typeof rawConfig.then === 'function') { + rawConfig = await rawConfig; + } - async resolveArgs(args, configOptions = {}) { - // when there are no args then exit - if (Object.keys(args).length === 0 && !process.env.NODE_ENV) { - return {}; - } + // `Promise` may return `Function` + if (typeof rawConfig === 'function') { + // when config is a function, pass the env from args to the config function + rawConfig = await rawConfig(args.env, args); + } - const { outputPath, stats, json, mode, target, prefetch, hot, analyze } = args; - const finalOptions = { - options: {}, - outputOptions: {}, - }; + return rawConfig; + }), + ); - const WEBPACK_OPTION_FLAGS = flags - .filter((coreFlag) => coreFlag.group === groups.BASIC_GROUP) - .reduce((result, flagObject) => { - result.push(flagObject.name); + loadedConfig.options = isMultiCompiler ? evaluatedConfig : evaluatedConfig[0]; - if (flagObject.alias) { - result.push(flagObject.alias); - } + const isObject = (value) => typeof value === 'object' && value !== null; - return result; - }, []); - - const PRODUCTION = 'production'; - const DEVELOPMENT = 'development'; - - /* - Mode priority: - - Mode flag - - Mode from config - - Mode form NODE_ENV - */ - - /** - * - * @param {string} mode - mode flag value - * @param {Object} configObject - contains relevant loaded config - */ - const assignMode = (mode, configObject) => { - const { - env: { NODE_ENV }, - } = process; - const { mode: configMode } = configObject; - - let finalMode; - - if (mode) { - finalMode = mode; - } else if (configMode) { - finalMode = configMode; - } else if (NODE_ENV && (NODE_ENV === PRODUCTION || NODE_ENV === DEVELOPMENT)) { - finalMode = NODE_ENV; + if (!isObject(loadedConfig.options) && !Array.isArray(loadedConfig.options)) { + logger.error(`Invalid configuration in '${loadedConfig.path}'`); + process.exit(2); } - return finalMode; + return loadedConfig; }; - Object.keys(args).forEach((arg) => { - if (WEBPACK_OPTION_FLAGS.includes(arg)) { - finalOptions.outputOptions[arg] = args[arg]; - } + let config = { options: {}, path: new WeakMap() }; - if (arg === 'devtool') { - finalOptions.options.devtool = args[arg]; - } + if (args.config && args.config.length > 0) { + const evaluatedConfigs = await Promise.all( + args.config.map(async (value) => { + const configPath = resolve(value); - if (arg === 'name') { - finalOptions.options.name = args[arg]; - } + if (!existsSync(configPath)) { + logger.error(`The specified config file doesn't exist in '${configPath}'`); + process.exit(2); + } - if (arg === 'watch') { - finalOptions.options.watch = true; - } + const loadedConfig = loadConfig(configPath); - if (arg === 'entry') { - finalOptions.options[arg] = args[arg]; - } - }); + return evaluateConfig(loadedConfig, args); + }), + ); - if (outputPath) { - finalOptions.options.output = { path: path.resolve(outputPath) }; - } + config.options = []; - if (stats !== undefined) { - finalOptions.options.stats = stats; - } + evaluatedConfigs.forEach((evaluatedConfig) => { + if (Array.isArray(evaluatedConfig.options)) { + evaluatedConfig.options.forEach((options) => { + config.options.push(options); + config.path.set(options, evaluatedConfig.path); + }); + } else { + config.options.push(evaluatedConfig.options); + config.path.set(evaluatedConfig.options, evaluatedConfig.path); + } + }); - if (json) { - finalOptions.outputOptions.json = json; - } + config.options = config.options.length === 1 ? config.options[0] : config.options; + } else { + // Order defines the priority, in increasing order + const defaultConfigFiles = ['webpack.config', '.webpack/webpack.config', '.webpack/webpackfile'] + // .filter((value) => value.includes(args.mode)) + .map((filename) => + // Since .cjs is not available on interpret side add it manually to default config extension list + [...Object.keys(extensions), '.cjs'].map((ext) => ({ + path: resolve(filename + ext), + ext: ext, + module: extensions[ext], + })), + ) + .reduce((accumulator, currentValue) => accumulator.concat(currentValue), []); - if (hot) { - const { HotModuleReplacementPlugin } = require('webpack'); - const hotModuleVal = new HotModuleReplacementPlugin(); + let foundDefaultConfigFile; - if (finalOptions.options && finalOptions.options.plugins) { - finalOptions.options.plugins.unshift(hotModuleVal); - } else { - finalOptions.options.plugins = [hotModuleVal]; + for (const defaultConfigFile of defaultConfigFiles) { + if (existsSync(defaultConfigFile.path)) { + foundDefaultConfigFile = defaultConfigFile; + break; + } } - } - if (prefetch) { - const { PrefetchPlugin } = require('webpack'); - const prefetchVal = new PrefetchPlugin(null, args.prefetch); + if (foundDefaultConfigFile) { + const loadedConfig = loadConfig(foundDefaultConfigFile.path); + const evaluatedConfig = await evaluateConfig(loadedConfig, args); - if (finalOptions.options && finalOptions.options.plugins) { - finalOptions.options.plugins.unshift(prefetchVal); - } else { - finalOptions.options.plugins = [prefetchVal]; + config.options = evaluatedConfig.options; + + if (Array.isArray(config.options)) { + config.options.forEach((options) => { + config.path.set(options, evaluatedConfig.path); + }); + } else { + config.path.set(evaluatedConfig.options, evaluatedConfig.path); + } } } - if (analyze) { - if (packageExists('webpack-bundle-analyzer')) { - // eslint-disable-next-line node/no-extraneous-require - const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); - const bundleAnalyzerVal = new BundleAnalyzerPlugin(); + if (args.configName) { + const notfoundConfigNames = []; - if (finalOptions.options && finalOptions.options.plugins) { - finalOptions.options.plugins.unshift(bundleAnalyzerVal); + config.options = args.configName.map((configName) => { + let found; + + if (Array.isArray(config.options)) { + found = config.options.find((options) => options.name === configName); } else { - finalOptions.options.plugins = [bundleAnalyzerVal]; + found = config.options.name === configName ? config.options : undefined; } - } else { - try { - await promptInstallation('webpack-bundle-analyzer', () => { - logger.error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); - }); - } catch (error) { - logger.error(`Action Interrupted, Please try once again or install ${yellow('webpack-bundle-analyzer')} manually.`); - process.exit(2); + + if (!found) { + notfoundConfigNames.push(configName); } - logger.success(`${yellow('webpack-bundle-analyzer')} was installed successfully.`); - } - } + return found; + }); - if (target) { - finalOptions.options.target = args.target; + if (notfoundConfigNames.length > 0) { + logger.error( + notfoundConfigNames.map((configName) => `Configuration with the "${configName}" name was not found.`).join(' '), + ); + process.exit(2); + } } - if (Array.isArray(configOptions)) { - // Todo - handle multi config for all flags - finalOptions.options = configOptions.map(() => ({ ...finalOptions.options })); - configOptions.forEach((configObject, index) => { - const resolvedMode = assignMode(mode, configObject); - if (resolvedMode) { - finalOptions.options[index].mode = resolvedMode; - } - }); - } else { - const resolvedMode = assignMode(mode, configOptions); - if (resolvedMode) { - finalOptions.options.mode = resolvedMode; + if (args.merge) { + // we can only merge when there are multiple configurations + // either by passing multiple configs by flags or passing a + // single config exporting an array + if (!Array.isArray(config.options) || config.options.length <= 1) { + logger.error('At least two configurations are required for merge.'); + process.exit(2); } - } - return finalOptions; - } + const mergedConfigPaths = []; - async resolveConfig(args) { - // Order defines the priority, in increasing order - // example - config file lookup will be in order of .webpack/webpack.config.development.js -> webpack.config.development.js -> webpack.config.js - const DEFAULT_CONFIG_LOC = [ - 'webpack.config', - 'webpack.config.dev', - 'webpack.config.development', - 'webpack.config.prod', - 'webpack.config.production', - '.webpack/webpack.config', - '.webpack/webpack.config.none', - '.webpack/webpack.config.dev', - '.webpack/webpack.config.development', - '.webpack/webpack.config.prod', - '.webpack/webpack.config.production', - '.webpack/webpackfile', - ]; - - const modeAlias = { - production: 'prod', - development: 'dev', - }; + config.options = config.options.reduce((accumulator, options) => { + const configPath = config.path.get(options); + const mergedOptions = webpackMerge(accumulator, options); - let opts = { - outputOptions: {}, - options: {}, - }; + mergedConfigPaths.push(configPath); - // Return a list of default configs in various formats - const getDefaultConfigFiles = () => { - return DEFAULT_CONFIG_LOC.map((filename) => { - // Since .cjs is not available on interpret side add it manually to default config extension list - return [...Object.keys(extensions), '.cjs'].map((ext) => { - return { - path: resolve(filename + ext), - ext: ext, - module: extensions[ext], - }; - }); - }).reduce((a, i) => a.concat(i), []); - }; + return mergedOptions; + }, {}); + config.path.set(config.options, mergedConfigPaths); + } - const getConfigInfoFromFileName = (filename) => { - const ext = extname(filename); - // since we support only one config for now - const allFiles = [filename]; - // return all the file metadata - return allFiles - .map((file) => { - return { - path: resolve(file), - ext: ext, - module: extensions[ext] || null, - }; - }) - .filter((e) => existsSync(e.path)); - }; + return config; + } - // Reads a config file given the config metadata - const requireConfig = (configModule) => { - const extension = Object.keys(jsVariants).find((t) => configModule.ext.endsWith(t)); + // TODO refactor + async resolveArguments(config, args) { + if (args.analyze) { + if (!packageExists('webpack-bundle-analyzer')) { + try { + await promptInstallation('webpack-bundle-analyzer', () => { + logger.error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); + }); + } catch (error) { + logger.error(`Action Interrupted, Please try once again or install ${yellow('webpack-bundle-analyzer')} manually.`); + process.exit(2); + } - if (extension) { - rechoir.prepare(extensions, configModule.path, process.cwd()); + logger.success(`${yellow('webpack-bundle-analyzer')} was installed successfully.`); } + } - let config = require(configModule.path); - - if (config.default) { - config = config.default; - } + if (Object.keys(args).length === 0 && !process.env.NODE_ENV) { + return config; + } - return { config, path: configModule.path }; - }; + if (cli) { + const processArguments = (options) => { + const coreFlagMap = flags + .filter((flag) => flag.group === 'core') + .reduce((accumulator, flag) => { + accumulator[flag.name] = flag; - // Given config data, determines the type of config and - // returns final config - const finalize = async (moduleObj, args, isDefaultConfig = false) => { - const { env, configName } = args; - const newOptionsObject = { - outputOptions: {}, - options: {}, - }; + return accumulator; + }, {}); + const coreConfig = Object.keys(args).reduce((accumulator, name) => { + const kebabName = toKebabCase(name); - if (!moduleObj) { - return newOptionsObject; - } + if (coreFlagMap[kebabName]) { + accumulator[kebabName] = args[name]; + } - if (isDefaultConfig) { - newOptionsObject.outputOptions.defaultConfig = moduleObj.path; - } + return accumulator; + }, {}); + const problems = cli.processArguments(coreFlagMap, options, coreConfig); + + if (problems) { + problems.forEach((problem) => { + logger.error( + `Found the '${problem.type}' problem with the '--${problem.argument}' argument${ + problem.path ? ` by path '${problem.path}'` : '' + }`, + ); + }); - const config = moduleObj.config; + process.exit(2); + } - const isMultiCompilerMode = Array.isArray(config); - const rawConfigs = isMultiCompilerMode ? config : [config]; + return options; + }; - let configs = []; + config.options = Array.isArray(config.options) + ? config.options.map((options) => processArguments(options)) + : processArguments(config.options); + } - const allConfigs = await Promise.all( - rawConfigs.map(async (rawConfig) => { - const isPromise = typeof rawConfig.then === 'function'; + const setupDefaultOptions = (options) => { + // No need to run for webpack@4 + if (cli && options.cache && options.cache.type === 'filesystem') { + const configPath = config.path.get(options); - if (isPromise) { - rawConfig = await rawConfig; + if (configPath) { + if (!options.cache.buildDependencies) { + options.cache.buildDependencies = {}; } - // `Promise` may return `Function` - if (typeof rawConfig === 'function') { - // when config is a function, pass the env from args to the config function - rawConfig = await rawConfig(env, args); + if (!options.cache.buildDependencies.config) { + options.cache.buildDependencies.config = []; } - return rawConfig; - }), - ); - - for (const singleConfig of allConfigs) { - if (Array.isArray(singleConfig)) { - configs.push(...singleConfig); - } else { - configs.push(singleConfig); + if (Array.isArray(configPath)) { + configPath.forEach((item) => { + options.cache.buildDependencies.config.push(item); + }); + } else { + options.cache.buildDependencies.config.push(configPath); + } } } - if (configName) { - const foundConfigNames = []; + return options; + }; - configs = configs.filter((options) => { - const found = configName.includes(options.name); + config.options = Array.isArray(config.options) + ? config.options.map((options) => setupDefaultOptions(options)) + : setupDefaultOptions(config.options); - if (found) { - foundConfigNames.push(options.name); - } - - return found; - }); - - if (foundConfigNames.length !== configName.length) { - // Configuration with name "test" was not found. - logger.error( - configName - .filter((name) => !foundConfigNames.includes(name)) - .map((configName) => `Configuration with name "${configName}" was not found.`) - .join('\n'), - ); - process.exit(2); - } + // Logic for webpack@4 + // TODO remove after drop webpack@4 + const processLegacyArguments = (options) => { + if (args.entry) { + options.entry = args.entry; } - if (configs.length === 0) { - logger.error('No configurations found'); - process.exit(2); + if (args.outputPath) { + options.output = { ...options.output, ...{ path: path.resolve(args.outputPath) } }; } - newOptionsObject['options'] = configs.length > 1 ? configs : configs[0]; - - return newOptionsObject; - }; - - // Responsible for reading user configuration files - // else does a default config lookup and resolves it. - const { config, mode } = args; + if (args.target) { + options.target = args.target; + } - if (config && config.length > 0) { - const resolvedOptions = []; - const finalizedConfigs = config.map(async (webpackConfig) => { - const configPath = resolve(webpackConfig); - const configFiles = getConfigInfoFromFileName(configPath); + if (typeof args.devtool !== 'undefined') { + options.devtool = args.devtool; + } - if (!configFiles.length) { - logger.error(`The specified config file doesn't exist in ${configPath}`); - process.exit(2); - } + if (args.mode) { + options.mode = args.mode; + } else if ( + !options.mode && + process.env && + process.env.NODE_ENV && + (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'node') + ) { + options.mode = process.env.NODE_ENV; + } - const foundConfig = configFiles[0]; - const resolvedConfig = requireConfig(foundConfig); + if (args.name) { + options.name = args.name; + } - return finalize(resolvedConfig, args); - }); + if (typeof args.stats !== 'undefined') { + options.stats = args.stats; + } - // resolve all the configs - for await (const resolvedOption of finalizedConfigs) { - if (Array.isArray(resolvedOption.options)) { - resolvedOptions.push(...resolvedOption.options); - } else { - resolvedOptions.push(resolvedOption.options); - } + if (typeof args.watch !== 'undefined') { + options.watch = args.watch; } - opts['options'] = resolvedOptions.length > 1 ? resolvedOptions : resolvedOptions[0] || {}; - } else { - // When no config is supplied, lookup for default configs - const defaultConfigFiles = getDefaultConfigFiles(); - const tmpConfigFiles = defaultConfigFiles.filter((file) => { - return existsSync(file.path); - }); + return options; + }; - const configFiles = tmpConfigFiles.map(requireConfig); - if (configFiles.length) { - const defaultConfig = configFiles.find((p) => p.path.includes(mode) || p.path.includes(modeAlias[mode])); - if (defaultConfig) { - opts = await finalize(defaultConfig, args, true); - } else { - const foundConfig = configFiles.pop(); + config.options = Array.isArray(config.options) + ? config.options.map((options) => processLegacyArguments(options)) + : processLegacyArguments(config.options); - opts = await finalize(foundConfig, args, true); - } - } - } + return config; + } - const { merge } = args; + async resolveCLIPlugin(config, args) { + const addCLIPlugin = (options) => { + if (!options.plugins) { + options.plugins = []; + } - if (merge) { - // Get the current configuration options - const { options: configOptions } = opts; + options.plugins.unshift( + new CLIPlugin({ + configPath: config.path, + helpfulOutput: !args.json, + hot: args.hot, + progress: args.progress, + prefetch: args.prefetch, + analyze: args.analyze, + }), + ); - // we can only merge when there are multiple configurations - // either by passing multiple configs by flags or passing a - // single config exporting an array - if (!Array.isArray(configOptions)) { - logger.error('At least two configurations are required for merge.'); - process.exit(2); - } + return options; + }; - // We return a single config object which is passed to the compiler - opts['options'] = configOptions.reduce((currentConfig, mergedConfig) => webpackMerge(currentConfig, mergedConfig), {}); - } + config.options = Array.isArray(config.options) + ? config.options.map((options) => addCLIPlugin(options)) + : addCLIPlugin(config.options); - return opts; + return config; } - async _baseResolver(cb, parsedArgs, strategy) { - const resolvedConfig = await cb(parsedArgs, this.compilerConfiguration); + async resolve(parsedArgs) { + let config = await this.resolveConfig(parsedArgs); - this._mergeOptionsToConfiguration(resolvedConfig.options, strategy); + config = await this.resolveArguments(config, parsedArgs); + config = await this.resolveCLIPlugin(config, parsedArgs); - if (resolvedConfig.outputOptions) { - this.outputConfiguration = Object.assign(this.outputConfiguration, resolvedConfig.outputOptions); - } + return config; } /** @@ -475,80 +394,6 @@ class WebpackCLI { return flags; } - /** - * Responsible to override webpack options. - * @param {Object} options The options returned by a group helper - * @param {Object} strategy The strategy to pass to webpack-merge. The strategy - * is implemented inside the group helper - * @private - * @returns {void} - */ - _mergeOptionsToConfiguration(options, strategy) { - /** - * options where they differ per config use this method to apply relevant option to relevant config - * eg mode flag applies per config - */ - if (Array.isArray(options) && Array.isArray(this.compilerConfiguration)) { - this.compilerConfiguration = options.map((option, index) => { - const compilerConfig = this.compilerConfiguration[index]; - - if (strategy) { - return webpackMerge.strategy(strategy)(compilerConfig, option); - } - - return webpackMerge(compilerConfig, option); - }); - return; - } - - /** - * options is an array (multiple configuration) so we create a new - * configuration where each element is individually merged - */ - if (Array.isArray(options)) { - this.compilerConfiguration = options.map((configuration) => { - if (strategy) { - return webpackMerge.strategy(strategy)(this.compilerConfiguration, configuration); - } - return webpackMerge(this.compilerConfiguration, configuration); - }); - } else { - /** - * The compiler configuration is already an array, so for each element - * we merge the options - */ - if (Array.isArray(this.compilerConfiguration)) { - this.compilerConfiguration = this.compilerConfiguration.map((thisConfiguration) => { - if (strategy) { - return webpackMerge.strategy(strategy)(thisConfiguration, options); - } - - return webpackMerge(thisConfiguration, options); - }); - } else { - if (strategy) { - this.compilerConfiguration = webpackMerge.strategy(strategy)(this.compilerConfiguration, options); - } else { - this.compilerConfiguration = webpackMerge(this.compilerConfiguration, options); - } - } - } - } - - /** - * It runs in a fancy order all the expected groups. - * Zero config and configuration goes first. - * - * The next groups will override existing parameters - * @returns {Promise} A Promise - */ - async runOptionGroups(parsedArgs) { - await Promise.resolve() - .then(() => this._baseResolver(this.resolveConfig, parsedArgs)) - .then(() => this._handleCoreFlags(parsedArgs)) - .then(() => this._baseResolver(this.resolveArgs, parsedArgs)); - } - handleError(error) { // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 @@ -577,38 +422,15 @@ class WebpackCLI { } async getCompiler(args) { - await this.runOptionGroups(args); - return this.createCompiler(this.compilerConfiguration); + // TODO test with serve + const config = await this.resolve(args); + + return this.createCompiler(config.options); } async run(args) { - await this.runOptionGroups(args); - let compiler; - let options = this.compilerConfiguration; - let outputOptions = this.outputConfiguration; - - const isRawOutput = typeof outputOptions.json === 'undefined'; - - if (isRawOutput) { - const webpackCLIPlugin = new WebpackCLIPlugin({ - progress: outputOptions.progress, - }); - - const addPlugin = (options) => { - if (!options.plugins) { - options.plugins = []; - } - options.plugins.unshift(webpackCLIPlugin); - }; - if (Array.isArray(options)) { - options.forEach(addPlugin); - } else { - addPlugin(options); - } - } - const callback = (error, stats) => { if (error) { this.handleError(error); @@ -651,19 +473,23 @@ class WebpackCLI { const getStatsOptionsFromCompiler = (compiler) => getStatsOptions(compiler.options ? compiler.options.stats : undefined); + if (!compiler) { + return; + } + const foundStats = compiler.compilers ? { children: compiler.compilers.map(getStatsOptionsFromCompiler) } : getStatsOptionsFromCompiler(compiler); - if (outputOptions.json === true) { + if (args.json === true) { process.stdout.write(JSON.stringify(stats.toJson(foundStats), null, 2) + '\n'); - } else if (typeof outputOptions.json === 'string') { + } else if (typeof args.json === 'string') { const JSONStats = JSON.stringify(stats.toJson(foundStats), null, 2); try { - writeFileSync(outputOptions.json, JSONStats); + writeFileSync(args.json, JSONStats); - logger.success(`stats are successfully stored as json to ${outputOptions.json}`); + logger.success(`stats are successfully stored as json to ${args.json}`); } catch (error) { logger.error(error); @@ -679,7 +505,9 @@ class WebpackCLI { } }; - compiler = this.createCompiler(options, callback); + const config = await this.resolve(args); + + compiler = this.createCompiler(config.options, callback); // TODO webpack@4 return Watching and MultiWathing instead Compiler and MultiCompiler, remove this after drop webpack@4 if (compiler && compiler.compiler) { diff --git a/test/analyze/analyze-flag.test.js b/test/analyze/analyze-flag.test.js index 54cac5d97a8..972a00223eb 100644 --- a/test/analyze/analyze-flag.test.js +++ b/test/analyze/analyze-flag.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { runAndGetWatchProc } = require('../utils/test-utils'); +const { run, runAndGetWatchProc } = require('../utils/test-utils'); describe('--analyze flag', () => { it('should load webpack-bundle-analyzer plugin with --analyze flag', (done) => { @@ -17,4 +17,13 @@ describe('--analyze flag', () => { } }); }); + + it('should not load webpack-bundle-analyzer plugin twice with --analyze flag and plugin', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './analyze.config.js', '--analyze']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Webpack Bundle Analyzer saved report to'); + expect(stdout.match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); + }); }); diff --git a/test/analyze/analyze.config.js b/test/analyze/analyze.config.js new file mode 100644 index 00000000000..7d793b708c3 --- /dev/null +++ b/test/analyze/analyze.config.js @@ -0,0 +1,6 @@ +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); + +module.exports = { + mode: 'development', + plugins: [new BundleAnalyzerPlugin({ analyzerMode: 'static', openAnalyzer: false })], +}; diff --git a/test/analyze/webpack.config.js b/test/analyze/webpack.config.js index fae2148515b..1bd7a2cee42 100644 --- a/test/analyze/webpack.config.js +++ b/test/analyze/webpack.config.js @@ -1,6 +1,4 @@ -const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin'); - module.exports = { mode: 'development', - plugins: [new WebpackCLITestPlugin(['plugins'], false)], + plugins: [], }; diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index 5b0eeabbb39..c9a84017b08 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -1,17 +1,63 @@ 'use strict'; +const path = require('path'); +const rimraf = require('rimraf'); const { run, isWebpack5 } = require('../utils/test-utils'); -describe('cache related tests', () => { - it('should log warning in case of single compiler', () => { - let { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); - // run 2nd compilation - ({ stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false)); +describe('cache', () => { + beforeEach((done) => { + rimraf(path.join(__dirname, '../../node_modules/.cache/webpack/test'), () => { + rimraf(path.join(__dirname, '../../node_modules/.cache/webpack/test-1'), () => { + done(); + }); + }); + }); + + it('should work', () => { + let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false); + + if (isWebpack5) { + expect(stderr).toContain('No pack exists at'); + expect(stderr).toContain('Stored pack'); + expect(stdout).toBeTruthy(); + } else { + expect(exitCode).toEqual(2); + } + + ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false)); + + if (isWebpack5) { + expect(exitCode).toEqual(0); + expect(stderr).toContain('restore cache container'); + expect(stderr).toContain('restore cache content metadata'); + expect(stderr).toContain('restore cache content'); + expect(stdout).toBeTruthy(); + } else { + expect(exitCode).toEqual(2); + } + }); + + it('should work with autoloading configuration', () => { + let { exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false); + + if (isWebpack5) { + expect(stderr).toContain('No pack exists at'); + expect(stderr).toContain('Stored pack'); + expect(stdout).toBeTruthy(); + } else { + expect(exitCode).toEqual(2); + } + + ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false)); if (isWebpack5) { - expect(stderr).toContain('starting to restore cache content'); - expect(stdout).toContain('[cached]'); expect(exitCode).toEqual(0); + expect(stderr).toContain('restore cache container'); + expect(stderr).toContain('restore cache content metadata'); + expect(stderr).toContain('restore cache content'); + expect(stdout).toBeTruthy(); + } else { + expect(exitCode).toEqual(2); } }); }); diff --git a/test/cache/webpack.config.js b/test/cache/webpack.config.js index 0a609684e07..84bd663f43c 100644 --- a/test/cache/webpack.config.js +++ b/test/cache/webpack.config.js @@ -1,21 +1,19 @@ const path = require('path'); module.exports = { + mode: 'development', cache: { type: 'filesystem', - name: 'cache-config-tests', buildDependencies: { config: [__filename], }, }, infrastructureLogging: { - debug: /webpack\.cache/, + debug: /cache/, }, entry: { app: './src/main.js', }, - devtool: 'inline-source-map', - plugins: [], output: { filename: '[name].bundle.js', chunkFilename: '[name].bundle.js', diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 85815bc1d9e..58bd36a6dfc 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -5,7 +5,7 @@ const { options: coloretteOptions } = require('colorette'); describe('colors related tests', () => { it('should output by default', () => { - const { stderr, stdout, exitCode } = run(__dirname); + const { stderr, stdout, exitCode } = run(__dirname, [], true, [], { FORCE_COLOR: true }); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -14,7 +14,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from flags', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose']); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose'], true, [], { FORCE_COLOR: true }); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -23,10 +23,13 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from flags and from configuration', () => { - const { stderr, stdout, exitCode } = run(__dirname, [ - '--stats=verbose', - `--config=${resolve(__dirname, './no-stats.webpack.config.js')}`, - ]); + const { stderr, stdout, exitCode } = run( + __dirname, + ['--stats=verbose', `--config=${resolve(__dirname, './no-stats.webpack.config.js')}`], + true, + [], + { FORCE_COLOR: true }, + ); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -35,7 +38,9 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from flags and from configuration #2', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js'], true, [], { + FORCE_COLOR: true, + }); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -63,7 +68,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js'], true, [], { FORCE_COLOR: true }); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -72,7 +77,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration #1', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-boolean.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-boolean.webpack.config.js'], true, [], { FORCE_COLOR: true }); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; @@ -81,7 +86,7 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration #2', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=no-stats.webpack.config.js']); + const { stderr, stdout, exitCode } = run(__dirname, ['--config=no-stats.webpack.config.js'], true, [], { FORCE_COLOR: true }); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; diff --git a/test/config-name/config-name.test.js b/test/config-name/config-name.test.js index deee81523b7..7f800ffdfd8 100644 --- a/test/config-name/config-name.test.js +++ b/test/config-name/config-name.test.js @@ -1,131 +1,114 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const { stat } = require('fs'); -const { resolve } = require('path'); describe('--config-name flag', () => { - it('should select only the config whose name is passed with --config-name', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config-name', 'first'], false); + it('should select only the config whose name is passed with --config-name', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first'], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); - expect(exitCode).toBe(0); - - stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); }); - it('should work with multiple values for --config-name', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false); + it('should work with multiple values for --config-name', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); - expect(exitCode).toBe(0); + }); - stat(resolve(__dirname, './dist/dist-third.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); + it('should work with multiple values for --config-name and multiple configurations', () => { + const { stderr, stdout, exitCode } = run( + __dirname, + ['-c', './function-config.js', '-c', './single-other-config.js', '--config-name', 'first', '--config-name', 'four'], + false, + ); - stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - }); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('first'); + expect(stdout).not.toContain('second'); + expect(stdout).not.toContain('third'); + expect(stdout).toContain('four'); }); it('should log error if invalid config name is provided', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config-name', 'test'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test'], false); - expect(stderr).toContain('Configuration with name "test" was not found.'); - expect(stdout).toBeFalsy(); expect(exitCode).toBe(2); + expect(stderr).toContain('Configuration with the "test" name was not found.'); + expect(stdout).toBeFalsy(); }); it('should log error if multiple configurations are not found', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config-name', 'test', '-c', 'single-config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test', '-c', 'single-config.js'], false); - expect(stderr).toContain('Configuration with name "test" was not found.'); - expect(stdout).toBeFalsy(); expect(exitCode).toBe(2); + expect(stderr).toContain('Configuration with the "test" name was not found.'); + expect(stdout).toBeFalsy(); }); it('should log error if multiple configurations are not found #1', () => { - const { stderr, stdout, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['--config-name', 'test', '--config-name', 'bar', '-c', 'single-config.js'], false, ); - expect(stderr).toContain('Configuration with name "test" was not found.'); - expect(stderr).toContain('Configuration with name "bar" was not found.'); - expect(stdout).toBeFalsy(); expect(exitCode).toBe(2); + expect(stderr).toContain('Configuration with the "test" name was not found.'); + expect(stderr).toContain('Configuration with the "bar" name was not found.'); + expect(stdout).toBeFalsy(); }); it('should log error if multiple configurations are not found #2', () => { - const { stderr, stdout, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['--config-name', 'first', '--config-name', 'bar', '-c', 'single-config.js'], false, ); - expect(stderr).not.toContain('Configuration with name "first" was not found.'); - expect(stderr).toContain('Configuration with name "bar" was not found.'); - expect(stdout).toBeFalsy(); expect(exitCode).toBe(2); + expect(stderr).not.toContain('Configuration with the "first" name was not found.'); + expect(stderr).toContain('Configuration with the "bar" name was not found.'); + expect(stdout).toBeFalsy(); }); - it('should work with config as a function', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'first'], false); + it('should work with config as a function', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'first'], false); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); - expect(exitCode).toBe(0); - - stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); }); - it('should work with multiple values for --config-name when the config is a function', (done) => { - const { stderr, stdout, exitCode } = run( + it('should work with multiple values for --config-name when the config is a function', () => { + const { exitCode, stderr, stdout } = run( __dirname, ['--config', 'function-config.js', '--config-name', 'first', '--config-name', 'third'], false, ); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); - expect(exitCode).toBe(0); - - stat(resolve(__dirname, './dist/dist-third.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - - stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - }); }); it('should log error if invalid config name is provided ', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'test'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'test'], false); - expect(stderr).toContain('Configuration with name "test" was not found.'); - expect(stdout).toBeFalsy(); expect(exitCode).toBe(2); + expect(stderr).toContain('Configuration with the "test" name was not found.'); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/config-name/single-other-config.js b/test/config-name/single-other-config.js new file mode 100644 index 00000000000..fd4c4a325a8 --- /dev/null +++ b/test/config-name/single-other-config.js @@ -0,0 +1,8 @@ +module.exports = { + output: { + filename: './dist-single.js', + }, + name: 'four', + entry: './src/first.js', + mode: 'development', +}; diff --git a/test/config/absent/config-absent.test.js b/test/config/absent/config-absent.test.js index f2c2ee6fc7c..6990cdd1c04 100644 --- a/test/config/absent/config-absent.test.js +++ b/test/config/absent/config-absent.test.js @@ -11,7 +11,7 @@ describe('Config:', () => { expect(stdout).toBeFalsy(); const configPath = resolve(__dirname, 'webpack.config.js'); // Should contain the correct error message - expect(stderr).toContain(`The specified config file doesn't exist in ${configPath}`); + expect(stderr).toContain(`The specified config file doesn't exist in '${configPath}'`); // Should not bundle expect(existsSync(resolve(__dirname, './binary/a.bundle.js'))).toBeFalsy(); }); diff --git a/test/config/defaults/all/.webpack/webpack.config.none.js b/test/config/defaults/all/.webpack/webpack.config.none.js deleted file mode 100644 index be0482a8df2..00000000000 --- a/test/config/defaults/all/.webpack/webpack.config.none.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, '../binary'), - filename: 'none.bundle.js', - }, -}; diff --git a/test/config/defaults/all/.webpack/webpack.config.prod.js b/test/config/defaults/all/.webpack/webpack.config.prod.js deleted file mode 100644 index d96ed85f2f3..00000000000 --- a/test/config/defaults/all/.webpack/webpack.config.prod.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, '../binary'), - filename: 'prod.bundle.js', - }, -}; diff --git a/test/config/defaults/all/multiple-config.test.js b/test/config/defaults/all/multiple-config.test.js deleted file mode 100644 index 9b4d00e975b..00000000000 --- a/test/config/defaults/all/multiple-config.test.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); -const { run } = require('../../../utils/test-utils'); - -describe('Default configuration files: ', () => { - it('Uses prod config from dot folder if present', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); - expect(stdout).not.toBe(undefined); - stat(resolve(__dirname, './binary/prod.bundle.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - }); -}); diff --git a/test/config/defaults/multiple-location/.webpack/webpack.config.development.js b/test/config/defaults/dot-webpack-directory-webpackfile/.webpack/webpackfile.js similarity index 100% rename from test/config/defaults/multiple-location/.webpack/webpack.config.development.js rename to test/config/defaults/dot-webpack-directory-webpackfile/.webpack/webpackfile.js diff --git a/test/config/defaults/multiple-location/index.js b/test/config/defaults/dot-webpack-directory-webpackfile/index.js similarity index 100% rename from test/config/defaults/multiple-location/index.js rename to test/config/defaults/dot-webpack-directory-webpackfile/index.js diff --git a/test/config/defaults/multiple-location/multiple-location-config.test.js b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js similarity index 100% rename from test/config/defaults/multiple-location/multiple-location-config.test.js rename to test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js diff --git a/test/config/defaults/all/.webpack/webpack.config.dev.js b/test/config/defaults/dot-webpack-directory/.webpack/webpack.config.js similarity index 100% rename from test/config/defaults/all/.webpack/webpack.config.dev.js rename to test/config/defaults/dot-webpack-directory/.webpack/webpack.config.js diff --git a/test/config/defaults/none and dev/dev-none-config.test.js b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js similarity index 100% rename from test/config/defaults/none and dev/dev-none-config.test.js rename to test/config/defaults/dot-webpack-directory/dev-none-config.test.js diff --git a/test/config/defaults/all/index.js b/test/config/defaults/dot-webpack-directory/index.js similarity index 100% rename from test/config/defaults/all/index.js rename to test/config/defaults/dot-webpack-directory/index.js diff --git a/test/config/defaults/multiple-location/webpack.config.development.js b/test/config/defaults/multiple-location/webpack.config.development.js deleted file mode 100644 index 3ce4e5a7356..00000000000 --- a/test/config/defaults/multiple-location/webpack.config.development.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, './binary'), - filename: 'development.bundle.js', - }, -}; diff --git a/test/config/defaults/multiple-location/webpack.config.js b/test/config/defaults/multiple-location/webpack.config.js deleted file mode 100644 index be128f00ca0..00000000000 --- a/test/config/defaults/multiple-location/webpack.config.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, './binary'), - filename: 'root.bundle.js', - }, -}; diff --git a/test/config/defaults/none and dev/.webpack/webpack.config.dev.js b/test/config/defaults/none and dev/.webpack/webpack.config.dev.js deleted file mode 100644 index ba00a518a7d..00000000000 --- a/test/config/defaults/none and dev/.webpack/webpack.config.dev.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, '../binary'), - filename: 'dev.bundle.js', - }, -}; diff --git a/test/config/defaults/none and dev/.webpack/webpack.config.none.js b/test/config/defaults/none and dev/.webpack/webpack.config.none.js deleted file mode 100644 index be0482a8df2..00000000000 --- a/test/config/defaults/none and dev/.webpack/webpack.config.none.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, '../binary'), - filename: 'none.bundle.js', - }, -}; diff --git a/test/config/defaults/none and dev/index.js b/test/config/defaults/none and dev/index.js deleted file mode 100644 index 0483dbadb45..00000000000 --- a/test/config/defaults/none and dev/index.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Kageyama") diff --git a/test/config/defaults/with-mode/webpack.config.development.js b/test/config/defaults/with-mode/webpack.config.js similarity index 100% rename from test/config/defaults/with-mode/webpack.config.development.js rename to test/config/defaults/with-mode/webpack.config.js diff --git a/test/config/defaults/with-mode/webpack.config.none.js b/test/config/defaults/with-mode/webpack.config.none.js deleted file mode 100644 index ade0d9bb8e8..00000000000 --- a/test/config/defaults/with-mode/webpack.config.none.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, './binary'), - filename: 'none.bundle.js', - }, -}; diff --git a/test/config/defaults/with-mode/webpack.config.production.js b/test/config/defaults/with-mode/webpack.config.production.js deleted file mode 100644 index 462320690d9..00000000000 --- a/test/config/defaults/with-mode/webpack.config.production.js +++ /dev/null @@ -1,9 +0,0 @@ -const { resolve } = require('path'); - -module.exports = { - entry: './index.js', - output: { - path: resolve(__dirname, './binary'), - filename: 'prod.bundle.js', - }, -}; diff --git a/test/config/invalid-export/invalid-export.test.js b/test/config/invalid-export/invalid-export.test.js index ca1abec6ab5..e4dc82b1c18 100644 --- a/test/config/invalid-export/invalid-export.test.js +++ b/test/config/invalid-export/invalid-export.test.js @@ -4,11 +4,9 @@ const { run } = require('../../utils/test-utils'); describe('invalid export', () => { it('should throw error with no configuration or index file', () => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); - - expect(stderr).toBeTruthy(); - expect(stderr).toContain('Invalid configuration object'); - + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(2); + expect(stderr).toContain(`Invalid configuration in '${resolve(__dirname, 'webpack.config.js')}'`); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/config/no-config-array/a.js b/test/config/invalid-path/a.js similarity index 100% rename from test/config/no-config-array/a.js rename to test/config/invalid-path/a.js diff --git a/test/config/invalid-path/invalid-path.test.js b/test/config/invalid-path/invalid-path.test.js new file mode 100644 index 00000000000..6600899ef06 --- /dev/null +++ b/test/config/invalid-path/invalid-path.test.js @@ -0,0 +1,12 @@ +'use strict'; +const { resolve } = require('path'); +const { run } = require('../../utils/test-utils'); + +describe('basic config file', () => { + it('is able to understand and parse a very basic configuration file', () => { + const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'invalid-webpack.config.js')], false); + expect(exitCode).toBe(2); + expect(stderr).toContain(`The specified config file doesn't exist in '${resolve(__dirname, 'invalid-webpack.config.js')}'`); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/config/invalid-path/webpack.config.js b/test/config/invalid-path/webpack.config.js new file mode 100644 index 00000000000..b58f8a91f0d --- /dev/null +++ b/test/config/invalid-path/webpack.config.js @@ -0,0 +1,9 @@ +const { resolve } = require('path'); + +module.exports = { + entry: './a.js', + output: { + path: resolve(__dirname, 'binary'), + filename: 'a.bundle.js', + }, +}; diff --git a/test/config/multiple-with-one-compilation/a.js b/test/config/multiple-with-one-compilation/a.js new file mode 100644 index 00000000000..735d820f253 --- /dev/null +++ b/test/config/multiple-with-one-compilation/a.js @@ -0,0 +1 @@ +module.exports = 'a.js'; diff --git a/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js new file mode 100644 index 00000000000..6372c65afa9 --- /dev/null +++ b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js @@ -0,0 +1,18 @@ +'use strict'; +const { existsSync } = require('fs'); +const { resolve } = require('path'); +const { run } = require('../../utils/test-utils'); + +describe('basic config file', () => { + it('is able to understand and parse a very basic configuration file', () => { + const { stdout, stderr, exitCode } = run( + __dirname, + ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'], + false, + ); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); + expect(existsSync(resolve(__dirname, './binary/a.bundle.js'))).toBeTruthy(); + }); +}); diff --git a/test/config/multiple-with-one-compilation/webpack.config.js b/test/config/multiple-with-one-compilation/webpack.config.js new file mode 100644 index 00000000000..fde09e6bba1 --- /dev/null +++ b/test/config/multiple-with-one-compilation/webpack.config.js @@ -0,0 +1,11 @@ +const { resolve } = require('path'); + +module.exports = [ + { + entry: './a.js', + output: { + path: resolve(__dirname, 'binary'), + filename: 'a.bundle.js', + }, + }, +]; diff --git a/test/config/no-config-array/no-config-array.test.js b/test/config/no-config-array/no-config-array.test.js index 2be56276b57..ee5b81b9627 100644 --- a/test/config/no-config-array/no-config-array.test.js +++ b/test/config/no-config-array/no-config-array.test.js @@ -6,8 +6,9 @@ const { run } = require('../../utils/test-utils'); describe('no configs in array', () => { it('is able to understand and parse a very basic configuration file', () => { const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); - expect(stderr).toContain('No configurations found'); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toBeFalsy(); - expect(exitCode).toBe(2); }); }); diff --git a/test/config/no-config-array/src/index.js b/test/config/no-config-array/src/index.js new file mode 100644 index 00000000000..c8bfc30c221 --- /dev/null +++ b/test/config/no-config-array/src/index.js @@ -0,0 +1 @@ +module.exports = 1; \ No newline at end of file diff --git a/test/config/no-config-object/a.js b/test/config/no-config-object/a.js new file mode 100644 index 00000000000..735d820f253 --- /dev/null +++ b/test/config/no-config-object/a.js @@ -0,0 +1 @@ +module.exports = 'a.js'; diff --git a/test/config/no-config-object/no-config-object.test.js b/test/config/no-config-object/no-config-object.test.js new file mode 100644 index 00000000000..dad17223896 --- /dev/null +++ b/test/config/no-config-object/no-config-object.test.js @@ -0,0 +1,17 @@ +'use strict'; + +const { resolve } = require('path'); +const { run } = require('../../utils/test-utils'); + +describe('empty config', () => { + it('should work', () => { + const { stdout, stderr, exitCode } = run( + __dirname, + ['-c', resolve(__dirname, 'webpack.config.js'), '--mode', 'development'], + false, + ); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); +}); diff --git a/test/config/no-config-object/src/index.js b/test/config/no-config-object/src/index.js new file mode 100644 index 00000000000..c8bfc30c221 --- /dev/null +++ b/test/config/no-config-object/src/index.js @@ -0,0 +1 @@ +module.exports = 1; \ No newline at end of file diff --git a/test/config/no-config-object/webpack.config.js b/test/config/no-config-object/webpack.config.js new file mode 100644 index 00000000000..f053ebf7976 --- /dev/null +++ b/test/config/no-config-object/webpack.config.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/test/core-flags/bail-flag.test.js b/test/core-flags/bail-flag.test.js index 23e953038e3..300f2841edb 100644 --- a/test/core-flags/bail-flag.test.js +++ b/test/core-flags/bail-flag.test.js @@ -6,16 +6,16 @@ describe('--bail flag', () => { it('should set bail to true', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--bail']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('bail: true'); }); it('should set bail to false', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--no-bail']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('bail: false'); }); }); diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index 767c61d924e..562b0c51f5d 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -2,7 +2,7 @@ const path = require('path'); const rimraf = require('rimraf'); -const { run, isWindows } = require('../utils/test-utils'); +const { run } = require('../utils/test-utils'); const { existsSync, writeFileSync, unlinkSync } = require('fs'); const { resolve } = require('path'); @@ -15,34 +15,35 @@ describe('cache related flags from core', () => { it('should be successful with --cache ', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--cache']); - expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`type: 'memory'`); }); it('should be successful with --no-cache ', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--no-cache']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('cache: false'); }); it('should set cache.type', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`type: 'filesystem'`); }); it('should set cache.cacheDirectory with --cache-cache-directory', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', './test-cache-path']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('test-cache-path'); - expect(existsSync(resolve(__dirname, './test-cache-path'))).toBeTruthy(); }); it('should set cache.cacheLocation with --cache-cache-locations', () => { @@ -53,8 +54,9 @@ describe('cache related flags from core', () => { './test-locate-cache', ]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('test-locate-cache'); expect(existsSync(resolve(__dirname, './test-locate-cache'))).toBeTruthy(); }); @@ -62,121 +64,131 @@ describe('cache related flags from core', () => { it('should set cache.hashAlgorithm with --cache-hash-algorithm', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-hash-algorithm', 'sha256']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`hashAlgorithm: 'sha256'`); }); it('should set cache.name with --cache-name', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-name', 'cli-test']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`name: 'cli-test'`); }); it('should set cache.store with --cache-store', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-store', 'pack']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`store: 'pack'`); }); it('should set cache.version with --cache-version', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-version', '1.1.3']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`version: '1.1.3'`); }); it('should assign cache build dependencies correctly when cache type is filesystem', () => { - // TODO: Fix on windows - if (isWindows) return; - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js']); + let { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); - expect(stdout).toContain("config: [ './webpack.config.js' ]"); + // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); expect(stdout).not.toContain('[cached]'); + // Run again to check for cache - const newRun = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js']); - expect(newRun.stdout).toContain('[cached]'); - expect(newRun.stderr).toBeFalsy(); - expect(newRun.exitCode).toEqual(0); + ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js'])); + + expect(exitCode).toEqual(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('[cached]'); }); it('should assign cache build dependencies correctly when cache type is filesystem in config', () => { - // TODO: Fix on windows - if (isWindows) return; const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.cache.config.js']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); - expect(stdout).toContain('buildDependencies'); - expect(stdout).toContain("config: [ './webpack.cache.config.js' ]"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); + expect(stdout).toContain('buildDependencies'); + // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); + // Run again to check for cache const newRun = run(__dirname, ['-c', './webpack.cache.config.js']); - expect(newRun.stdout).toContain('[cached]'); + + expect(newRun.exitCode).toBe(0); expect(newRun.stderr).toBeFalsy(); - expect(newRun.exitCode).toEqual(0); + expect(newRun.stdout).toContain('[cached]'); }); it('should assign cache build dependencies with multiple configs', () => { - // TODO: Fix on windows - if (isWindows) return; const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('buildDependencies'); - expect(stdout).toContain("config: [ './webpack.cache.config.js', './webpack.config.js' ]"); expect(stdout).toContain("type: 'filesystem'"); - expect(exitCode).toEqual(0); + expect(stdout).toContain('buildDependencies'); + // expect(stdout).toContain(`'${resolve(__dirname, 'webpack.cache.config.js')}'`); + expect(stdout).not.toContain(`'${resolve(__dirname, 'webpack.config.js')}'`); }); it('should assign cache build dependencies with default config', () => { - // TODO: Fix on windows - if (isWindows) return; const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('buildDependencies'); - expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); + // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); expect(stdout).toContain("type: 'filesystem'"); - expect(exitCode).toEqual(0); }); it('should assign cache build dependencies with merged configs', () => { - // TODO: Fix on windows - if (isWindows) return; const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js', '--merge']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('buildDependencies'); - expect(stdout).toContain("config: [ './webpack.cache.config.js', './webpack.config.js' ]"); expect(stdout).toContain("type: 'filesystem'"); - expect(exitCode).toEqual(0); + expect(stdout).toContain('buildDependencies'); + // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); + // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); }); it('should invalidate cache when config changes', () => { - // TODO: Fix on windows - if (isWindows) return; // Creating a temporary webpack config writeFileSync(resolve(__dirname, './webpack.test.config.js'), 'module.exports = {mode: "development"}'); - const { stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); + + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); + + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).not.toContain('[cached]'); // Running again should use the cache const newRun = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); + + expect(newRun.exitCode).toBe(0); + expect(newRun.stderr).toBeFalsy(); expect(newRun.stdout).toContain('[cached]'); // Change config to invalidate cache writeFileSync(resolve(__dirname, './webpack.test.config.js'), 'module.exports = {mode: "production"}'); const newRun2 = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); + unlinkSync(resolve(__dirname, './webpack.test.config.js')); + + expect(newRun2.exitCode).toBe(0); expect(newRun2).not.toContain('[cached]'); - expect(newRun2.exitCode).toEqual(0); }); }); diff --git a/test/core-flags/devtool-flag.test.js b/test/core-flags/devtool-flag.test.js index 387c642bea5..fa37bc37b43 100644 --- a/test/core-flags/devtool-flag.test.js +++ b/test/core-flags/devtool-flag.test.js @@ -4,17 +4,26 @@ const { run } = require('../utils/test-utils'); describe('--devtool flag', () => { it('should set devtool option', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--devtool', 'source-map']); + const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'source-map']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`devtool: 'source-map'`); }); - it('should throw error for invalid config', () => { - const { stderr, exitCode } = run(__dirname, ['--devtool', 'invalid']); + it('should set devtool option to false', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--no-devtool']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`devtool: false`); + }); + + it('should log error for invalid config', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'invalid']); expect(exitCode).toBe(2); expect(stderr).toContain('Invalid configuration object'); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/core-flags/experiments-flag.test.js b/test/core-flags/experiments-flag.test.js index f30059f7528..96b32734256 100644 --- a/test/core-flags/experiments-flag.test.js +++ b/test/core-flags/experiments-flag.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const experimentsFlags = flagsFromCore.filter(({ name }) => name.startsWith('experiments-')); +const experimentsFlags = flags.filter(({ name }) => name.startsWith('experiments-')); describe('experiments option related flag', () => { experimentsFlags.forEach((flag) => { diff --git a/test/core-flags/externals-flags.test.js b/test/core-flags/externals-flags.test.js index 7d6e8d5dbff..295ca4525aa 100644 --- a/test/core-flags/externals-flags.test.js +++ b/test/core-flags/externals-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const externalsPresetsFlags = flagsFromCore.filter(({ name }) => name.startsWith('externals-presets-')); +const externalsPresetsFlags = flags.filter(({ name }) => name.startsWith('externals-presets-')); describe('externals related flag', () => { it('should set externals properly', () => { diff --git a/test/core-flags/invalid-flag.test.js b/test/core-flags/invalid-flag.test.js new file mode 100644 index 00000000000..da7462a851b --- /dev/null +++ b/test/core-flags/invalid-flag.test.js @@ -0,0 +1,13 @@ +'use strict'; + +const { run } = require('../utils/test-utils'); + +describe('--parallelism flag', () => { + it('should set parallelism to the value passed', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--output-script-type', 'unknown']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Found the 'invalid-value' problem with the '--output-script-type' argument by path 'output.scriptType'"); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index d65e712d765..d2e813cd92b 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const moduleFlags = flagsFromCore.filter(({ name }) => name.startsWith('module-')); +const moduleFlags = flags.filter(({ name }) => name.startsWith('module-')); describe('module config related flag', () => { moduleFlags.forEach((flag) => { @@ -16,16 +16,24 @@ describe('module config related flag', () => { if (flag.type === Boolean && !flag.name.includes('module-no-parse')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); if (flag.name.includes('-reset')) { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); const option = propName.split('Reset')[0]; + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${option}: []`); } else if (flag.name.includes('rules-')) { + const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain("sideEffects: 'flag'"); } else { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); diff --git a/test/core-flags/node-flags.test.js b/test/core-flags/node-flags.test.js index 7b6f9cc1005..ac7f060322f 100644 --- a/test/core-flags/node-flags.test.js +++ b/test/core-flags/node-flags.test.js @@ -3,14 +3,6 @@ const { run } = require('../utils/test-utils'); describe('node option related flags', () => { - it('should config node option', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--node']); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); - expect(stdout).toContain(`node: { global: true, __filename: 'mock', __dirname: 'mock' }`); - }); - it('should config node option to false', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--no-node']); @@ -19,14 +11,6 @@ describe('node option related flags', () => { expect(stdout).toContain('node: false'); }); - it('should set node.global equals to true', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--node']); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); - expect(stdout).toContain('global: true'); - }); - it('should set node.filename correctly', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--node-filename', 'mock']); diff --git a/test/core-flags/optimization-flags.test.js b/test/core-flags/optimization-flags.test.js index 4485865f567..2af3c4b8a57 100644 --- a/test/core-flags/optimization-flags.test.js +++ b/test/core-flags/optimization-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const optimizationFlags = flagsFromCore.filter(({ name }) => name.startsWith('optimization-')); +const optimizationFlags = flags.filter(({ name }) => name.startsWith('optimization-')); describe('optimization config related flag', () => { optimizationFlags.forEach((flag) => { @@ -20,16 +20,23 @@ describe('optimization config related flag', () => { if (flag.type === Boolean) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); if (flag.name === 'optimization-split-chunks') { - expect(stdout).toContain(`chunks: 'async'`); - expect(stdout).toContain(`minChunks: 1`); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`splitChunks: false`); } else if (flag.name.includes('reset')) { + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: []`); } else { + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); @@ -53,24 +60,41 @@ describe('optimization config related flag', () => { // need improve the plugin to log for multi-level options i.e, optimization.runtime if (flag.type === String && !flag.name.includes('runtime-') && !flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'named']); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); if (flag.name === 'optimization-split-chunks-chunks') { - stdout = run(__dirname, [`--${flag.name}`, 'initial']).stdout; + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'initial']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`chunks: 'initial'`); } else if (flag.name === 'optimization-mangle-exports') { - stdout = run(__dirname, ['--optimization-mangle-exports', 'size']).stdout; + const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-mangle-exports', 'size']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mangleExports: 'size'`); } else if (flag.name === 'optimization-used-exports') { - stdout = run(__dirname, ['--optimization-used-exports', 'global']).stdout; + const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-used-exports', 'global']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`usedExports: 'global'`); } else if (flag.name === 'optimization-split-chunks-default-size-types') { + const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-split-chunks-default-size-types', 'global']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`defaultSizeTypes: [Array]`); } else if (flag.name === 'optimization-side-effects') { + const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-side-effects', 'flag']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'flag'`); } else { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'named']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'named'`); } }); diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index d1bfc94f392..88b75211943 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const outputFlags = flagsFromCore.filter(({ name }) => name.startsWith('output-')); +const outputFlags = flags.filter(({ name }) => name.startsWith('output-')); describe('output config related flag', () => { outputFlags.forEach((flag) => { @@ -57,62 +57,77 @@ describe('output config related flag', () => { if (flag.type === String && !flag.name.includes('output-library')) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test']); - if (flag.name === 'output-cross-origin-loading') { - ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'anonymous'])); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'anonymous']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'anonymous'`); } else if (flag.name === 'output-chunk-format') { - ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'commonjs'])); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'commonjs']); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'commonjs'`); } else if (flag.name === 'output-chunk-loading') { - ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'jsonp'])); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'jsonp']); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'jsonp'`); } else if (flag.name === 'output-enabled-chunk-loading-types' || flag.name === 'output-enabled-wasm-loading-types') { - ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'async-node'])); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: [ 'async-node' ]`); } else if (flag.name === 'output-enabled-library-type') { - ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'amd'])); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'amd']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'amd'`); } else if (flag.name === 'output-hash-function') { - ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, 'sha256'])); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'sha256']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`hashFunction: 'sha256'`); } else if (flag.name === 'output-script-type') { - ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'module'])); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'module']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'module'`); } else if (flag.name === 'output-enabled-library-types') { - stdout = run(__dirname, [`--${flag.name}`, 'var']).stdout; + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'var']); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: [ 'var' ]`); } else if (flag.name === 'output-path') { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('test'); } else if (flag.name === 'output-worker-chunk-loading') { - stdout = run(__dirname, [`--${flag.name}`, 'async-node']).stdout; + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'async-node'`); } else if (flag.name.includes('wasm')) { - stdout = run(__dirname, [`--${flag.name}`, 'async-node']).stdout; + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'async-node'`); } else { - expect(stderr).toBeFalsy(); + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test']); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'test'`); } }); diff --git a/test/core-flags/performance-flags.test.js b/test/core-flags/performance-flags.test.js index ea27e0b1d5c..35a3be6799c 100644 --- a/test/core-flags/performance-flags.test.js +++ b/test/core-flags/performance-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const performanceFlags = flagsFromCore.filter(({ name }) => name.startsWith('performance-')); +const performanceFlags = flags.filter(({ name }) => name.startsWith('performance-')); describe('module config related flag', () => { it(`should config --performance option correctly`, () => { diff --git a/test/core-flags/resolve-flags.test.js b/test/core-flags/resolve-flags.test.js index abfaa74379f..71e4337c5ce 100644 --- a/test/core-flags/resolve-flags.test.js +++ b/test/core-flags/resolve-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const resolveFlags = flagsFromCore.filter(({ name }) => name.startsWith('resolve')); +const resolveFlags = flags.filter(({ name }) => name.startsWith('resolve')); describe('resolve config related flags', () => { resolveFlags.forEach((flag) => { diff --git a/test/core-flags/snapshot-flags.test.js b/test/core-flags/snapshot-flags.test.js index bcaa517f900..fea4e059d41 100644 --- a/test/core-flags/snapshot-flags.test.js +++ b/test/core-flags/snapshot-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const snapshotFlags = flagsFromCore.filter(({ name }) => name.startsWith('snapshot')); +const snapshotFlags = flags.filter(({ name }) => name.startsWith('snapshot')); describe('snapshot config related flags', () => { snapshotFlags.forEach((flag) => { diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index 6deb653fd19..ebdaeddfa71 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const statsFlags = flagsFromCore.filter(({ name }) => name.startsWith('stats-')); +const statsFlags = flags.filter(({ name }) => name.startsWith('stats-')); describe('stats config related flag', () => { statsFlags.forEach((flag) => { @@ -17,6 +17,7 @@ describe('stats config related flag', () => { expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; expect(stdout).toContain(`stats: { ${option}: [] }`); @@ -50,23 +51,36 @@ describe('stats config related flag', () => { const acceptsSingleValue = ['preset', 'modulesSort', 'logging', 'chunksSort', 'assetsSort']; it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); if (flag.name.includes('stats-colors')) { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'u001b[32m']); const option = flag.name.split('stats-colors-')[1]; - stdout = run(__dirname, [`--${flag.name}`, 'u001b[32m']).stdout; + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`stats: { colors: { ${option}: 'u001b[32m' } }`); } else if (acceptsSingleValue.includes(propName)) { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`stats: { ${propName}: 'log' }`); } else if (flag.name === 'stats-context') { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain('log'); } else if (flag.name === 'stats-entrypoints') { - stdout = run(__dirname, [`--${flag.name}`, 'auto']).stdout; + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'auto']); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`stats: { ${propName}: 'auto' }`); } else { + const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); + + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); expect(stdout).toContain(`stats: { ${propName}: [ 'log' ] }`); } }); diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index 16576aaf013..0981dd9ee3d 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -1,9 +1,9 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const watchFlags = flagsFromCore.filter(({ name }) => name.startsWith('watch')); +const watchFlags = flags.filter(({ name }) => name.startsWith('watch')); describe('watch config related flag', () => { watchFlags.forEach((flag) => { @@ -11,12 +11,13 @@ describe('watch config related flag', () => { const property = flag.name.split('watch-options-')[1]; const propName = hyphenToUpperCase(property); - if (flag.type === Boolean) { + if (flag.type === Boolean && flag.name !== 'watch') { it(`should config --${flag.name} correctly`, () => { const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + if (flag.name.includes('reset')) { expect(stdout).toContain(`watchOptions: { ignored: [] }`); } else { @@ -46,12 +47,17 @@ describe('watch config related flag', () => { if (flag.type === String) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'ignore.js']); - expect(stderr).toBeFalsy(); if (propName === 'poll') { - stdout = run(__dirname, [`--${flag.name}`, '10']).stdout; - expect(stdout).toContain(`watchOptions: { ${propName}: 10 }`); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '200']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`watchOptions: { ${propName}: 200 }`); } else { + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'ignore.js']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: [ 'ignore.js' ] }`); } }); diff --git a/test/devtool/array/source-map-array.test.js b/test/devtool/array/source-map-array.test.js index c5b72c2b80b..765ace54950 100644 --- a/test/devtool/array/source-map-array.test.js +++ b/test/devtool/array/source-map-array.test.js @@ -10,6 +10,7 @@ describe('source-map object', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); + readdir(resolve(__dirname, 'dist'), (err, files) => { expect(err).toBe(null); expect(files.length).toBe(3); @@ -22,6 +23,7 @@ describe('source-map object', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); + readdir(resolve(__dirname, 'binary'), (err, files) => { expect(err).toBe(null); expect(files.length).toBe(4); diff --git a/test/help/help-flags.test.js b/test/help/help-flags.test.js index a415986ecc6..5b463133dfd 100644 --- a/test/help/help-flags.test.js +++ b/test/help/help-flags.test.js @@ -45,7 +45,7 @@ describe('commands help', () => { expect(exitCode).toBe(2); expect(stderr).toContain( - `You provided multiple commands or arguments - argument '--entry', argument '--merge' (alias '-m'). Please use only one command at a time.`, + `You provided multiple commands or arguments - argument '--merge' (alias '-m'), argument '--entry'. Please use only one command at a time.`, ); expect(stdout).toHaveLength(0); }); diff --git a/test/hot/hot-flag.test.js b/test/hot/hot-flag.test.js index c7b75436954..f888c8558dd 100644 --- a/test/hot/hot-flag.test.js +++ b/test/hot/hot-flag.test.js @@ -1,39 +1,26 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const { stat } = require('fs'); +const { readFileSync } = require('fs'); const { resolve } = require('path'); -const { yellow } = require('colorette'); describe('--hot flag', () => { - it('should be successful when --hot is passed', (done) => { + it('should be successful when --hot is passed', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--hot']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('HotModuleReplacementPlugin'); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stdout).toBeTruthy(); + expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); }); - it('should warn when --hot and --no-hot both are passed', (done) => { + it('should warn when --hot and --no-hot both are passed', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--no-hot', '--hot']); expect(exitCode).toBe(0); expect(stderr).toContain( - `[webpack-cli] ${yellow( - 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', - )}`, + 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', ); - expect(stdout).toContain('HotModuleReplacementPlugin'); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stdout).toBeTruthy(); + expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); }); }); diff --git a/test/hot/webpack.config.js b/test/hot/webpack.config.js index 2b5516318de..f2c3976d5d3 100644 --- a/test/hot/webpack.config.js +++ b/test/hot/webpack.config.js @@ -1,6 +1,3 @@ -const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin'); - module.exports = { mode: 'development', - plugins: [new WebpackCLITestPlugin()], }; diff --git a/test/invalid-schema/invalid-schema.test.js b/test/invalid-schema/invalid-schema.test.js index c107f966f9e..52cd44bebde 100644 --- a/test/invalid-schema/invalid-schema.test.js +++ b/test/invalid-schema/invalid-schema.test.js @@ -1,20 +1,26 @@ 'use strict'; -const { run, isWindows } = require('../utils/test-utils'); +const { run, isWebpack5 } = require('../utils/test-utils'); describe('invalid schema', () => { it('should log webpack error and exit process on invalid config', () => { - const { stderr, exitCode } = run(__dirname, ['--config', './webpack.config.mock.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']); + + expect(exitCode).toEqual(2); expect(stderr).toContain('Invalid configuration object'); - if (!isWindows) { - expect(exitCode).toEqual(2); - } + expect(stdout).toBeFalsy(); }); it('should log webpack error and exit process on invalid flag', () => { - const { stderr, exitCode } = run(__dirname, ['--mode', 'Yukihira']); - expect(stderr).toContain('Invalid configuration object'); - if (!isWindows) { - expect(exitCode).toEqual(2); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Found the 'invalid-value' problem with the '--mode' argument by path 'mode'"); + } else { + expect(stderr).toContain('Invalid configuration object'); } + + expect(stdout).toBeFalsy(); }); }); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index d586c687049..061595d506b 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -1,5 +1,5 @@ 'use strict'; -const { run } = require('../../utils/test-utils'); +const { run, isWebpack5 } = require('../../utils/test-utils'); describe('mode flags', () => { it('should not set mode=production by default', () => { @@ -46,7 +46,12 @@ describe('mode flags', () => { const { stderr, exitCode } = run(__dirname, ['--mode', 'abcd']); expect(exitCode).toBe(2); - expect(stderr).toContain('configuration.mode should be one of these'); - expect(stderr).toContain(`"development" | "production" | "none"`); + + if (isWebpack5) { + expect(stderr).toContain("Found the 'invalid-value' problem with the '--mode' argument by path 'mode'"); + } else { + expect(stderr).toContain('configuration.mode should be one of these'); + expect(stderr).toContain(`"development" | "production" | "none"`); + } }); }); diff --git a/test/mode/mode-with-config/mode-with-config.test.js b/test/mode/mode-with-config/mode-with-config.test.js index 9eee9f6f8d4..45363bd6e92 100644 --- a/test/mode/mode-with-config/mode-with-config.test.js +++ b/test/mode/mode-with-config/mode-with-config.test.js @@ -142,12 +142,12 @@ describe('mode flags with config', () => { }); it('only config where mode is absent pick up from NODE_ENV', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config3.js', '-c', './webpack.config2.js'], false, [], { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config3.js', '-c', './webpack.config2.js'], false, [], { NODE_ENV: 'production', }); - expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'production'", 'g')).length).toEqual(1); diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index 2c5eafad51c..dbeaf4f7138 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -3,24 +3,24 @@ const { join } = require('path'); const { run } = require('../utils/test-utils'); const rimraf = require('rimraf'); -describe('Prefetch Flag', () => { +describe('prefetch', () => { afterEach(() => { rimraf.sync(join(__dirname, 'dist')); }); - it('Should load the prefetched file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch', './src/p.js'], false); - // Should be able to find the entry file - expect(stdout).toContain('./src/index.js'); - // Should invoke the PrefetchPlugin with correct params - expect(stdout).toContain(`PrefetchPlugin { context: null, request: './src/p.js' }`); - // check that the output file exists - expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeTruthy(); - expect(stderr).toBeFalsy(); + it('should load the prefetched file', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch', './src/p.js', '--mode', 'development'], false); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + + const content = fs.readFileSync(join(__dirname, '/dist/main.js'), 'utf-8'); + + expect(content).not.toContain('// no prefetching'); }); - it('Should err when the prefetched file is absent', () => { + it('should log error when the prefetched file is absent', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch', './src/somefile.js'], false); // Should contain the error message expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); @@ -30,7 +30,7 @@ describe('Prefetch Flag', () => { expect(stderr).toBeFalsy(); }); - it('Should err when flag value is not supplied', () => { + it('should log error when flag value is not supplied', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch'], false); // Should contain the error message expect(stderr).toContain(`error: option '--prefetch ' argument missing`); diff --git a/test/prefetch/src/index.js b/test/prefetch/src/index.js index 655f0d1539f..59d0025c017 100644 --- a/test/prefetch/src/index.js +++ b/test/prefetch/src/index.js @@ -1 +1,11 @@ -console.log("Shoyo") +async function load() { + const value = await import ( + /* webpackMode: "lazy" */ + /* webpackPrefetch: true */ + './p.js' + ); + + console.log(value); +} + +load(); diff --git a/test/prefetch/src/p.js b/test/prefetch/src/p.js index a5147067b1e..3bf8b892c52 100644 --- a/test/prefetch/src/p.js +++ b/test/prefetch/src/p.js @@ -1 +1,3 @@ -console.log('Prefetched code'); +console.log('HERE'); + +module.exports = 'async-value'; diff --git a/test/prefetch/webpack.config.js b/test/prefetch/webpack.config.js index 385cb2ac035..f053ebf7976 100644 --- a/test/prefetch/webpack.config.js +++ b/test/prefetch/webpack.config.js @@ -1,5 +1 @@ -const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin'); - -module.exports = { - plugins: [new WebpackCLITestPlugin()], -}; +module.exports = {}; diff --git a/test/stats/cli-flags/stats.test.js b/test/stats/cli-flags/stats.test.js index ed461160782..ee612408123 100644 --- a/test/stats/cli-flags/stats.test.js +++ b/test/stats/cli-flags/stats.test.js @@ -1,7 +1,7 @@ /* eslint-disable node/no-unpublished-require */ 'use strict'; -const { run, isWebpack5, isWindows } = require('../../utils/test-utils'); +const { run, isWebpack5 } = require('../../utils/test-utils'); const presets = ['normal', 'detailed', 'errors-only', 'errors-warnings', 'minimal', 'verbose', 'none']; @@ -16,6 +16,7 @@ describe('stats flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + if (isWebpack5) { expect(stdout).toContain(`stats: { preset: '${preset}' }`); } else { @@ -37,20 +38,16 @@ describe('stats flag', () => { }); it('should warn when an unknown flag stats value is passed', () => { - const { stderr, exitCode } = run(__dirname, ['--stats', 'foo']); + const { exitCode, stderr } = run(__dirname, ['--stats', 'foo']); + expect(exitCode).toEqual(2); expect(stderr).toBeTruthy(); - expect(stderr).toContain('* configuration.stats should be one of these:'); + if (isWebpack5) { - expect(stderr).toContain( - `"none" | "summary" | "errors-only" | "errors-warnings" | "minimal" | "normal" | "detailed" | "verbose"`, - ); + expect(stderr).toContain("Found the 'invalid-value' problem with the '--stats' argument by path 'stats'"); } else { + expect(stderr).toContain('* configuration.stats should be one of these:'); expect(stderr).toContain('"none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose" | "errors-warnings"'); } - // TODO - Fix exitcode check on windows - if (!isWindows) { - expect(exitCode).toEqual(2); - } }); }); diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js index 907ea00148b..bb0c78bec2f 100644 --- a/test/stats/watch/stats-and-watch.test.js +++ b/test/stats/watch/stats-and-watch.test.js @@ -8,7 +8,7 @@ describe('stats and watch', () => { expect(stdout).toContain('[webpack-cli] Compilation starting...'); expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] watching files for updates...'); + expect(stdout).toContain('[webpack-cli] Compilation is watching files for updates...'); expect(stderr).toBeFalsy(); }); @@ -17,7 +17,7 @@ describe('stats and watch', () => { expect(stdout).toContain('[webpack-cli] Compilation starting...'); expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] watching files for updates...'); + expect(stdout).toContain('[webpack-cli] Compilation is watching files for updates...'); expect(stderr).toBeFalsy(); }); @@ -28,7 +28,7 @@ describe('stats and watch', () => { expect(stdout).toContain('[webpack-cli] Compilation starting...'); expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] watching files for updates...'); + expect(stdout).toContain('[webpack-cli] Compilation is watching files for updates...'); expect(stdout).toContain(output); expect(stderr).toBeFalsy(); }); diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index 8a35f1dd749..9e6ed7bb5e3 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -1,35 +1,42 @@ -const { run } = require('../utils/test-utils'); - -const unknownError = 'Unknown argument: --unknown'; +const { run, isWebpack5 } = require('../utils/test-utils'); describe('unknown behaviour', () => { - it('throws error if an unknown flag is passed in', () => { + it('should log error if an unknown flag is passed in', () => { const { stderr, exitCode } = run(__dirname, ['--unknown']); - expect(stderr).toBeTruthy(); - expect(stderr).toContain('Unknown argument: --unknown'); - expect(stderr).toContain(unknownError); + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown argument: '--unknown'"); }); - it('should throw error and respect --color flag', () => { + it('should log error and respect --color flag', () => { const { stderr, exitCode } = run(__dirname, ['--unknown', '--color']); - expect(stderr).toBeTruthy(); - expect(stderr).toContain(`[webpack-cli] \u001b[31m${unknownError}`); + expect(exitCode).toBe(2); + expect(stderr).toContain(`[webpack-cli] \u001b[31mUnknown argument: '--unknown'`); }); - it('throws error for unknow flag and respect --no-color', () => { + it('should log error for unknown flag and respect --no-color', () => { const { stderr, exitCode } = run(__dirname, ['--unknown', '--no-color']); - expect(stderr).toBeTruthy(); - expect(stderr).not.toContain(`[webpack-cli] \u001b[31m${unknownError}`); - expect(stderr).toContain(unknownError); + expect(exitCode).toBe(2); + expect(stderr).not.toContain(`[webpack-cli] \u001b[31mUnknown argument: '--unknown'`); + expect(stderr).toContain("Unknown argument: '--unknown'"); }); it('suggests the closest match to an unknown flag', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--entyr', './a.js']); - expect(stderr).toContain('Unknown argument: --entyr'); - expect(stdout).toContain('Did you mean --entry?'); expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown argument: '--entyr'"); + expect(stdout).toContain("Did you mean '--entry'?"); + }); + + it('suggests the closest match to an unknown flag #2', () => { + const { stderr, stdout, exitCode } = run(__dirname, ['--output-fileneme', '[name].js']); + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown argument: '--output-fileneme'"); + + if (isWebpack5) { + expect(stdout).toContain("Did you mean '--output-filename'?"); + } }); }); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index ea749f130bf..4b3a50091af 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -30,18 +30,20 @@ const hyphenToUpperCase = (name) => { * @param {String} testCase The path to folder that contains the webpack.config.js * @param {Array} args Array of arguments to pass to webpack * @param {Boolean} setOutput Boolean that decides if a default output path will be set or not + * @param {Array} nodeOptions Boolean that decides if a default output path will be set or not + * @param {Record} env Boolean that decides if a default output path will be set or not * @returns {Object} The webpack output or Promise when nodeOptions are present */ -const run = (testCase, args = [], setOutput = true, nodeArgs = [], env) => { +const run = (testCase, args = [], setOutput = true, nodeOptions = [], env) => { const cwd = path.resolve(testCase); const outputPath = path.resolve(testCase, 'bin'); - const processExecutor = nodeArgs.length ? execaNode : spawnSync; + const processExecutor = nodeOptions.length ? execaNode : spawnSync; const argsWithOutput = setOutput ? args.concat('--output-path', outputPath) : args; const result = processExecutor(WEBPACK_PATH, argsWithOutput, { cwd, reject: false, - nodeOptions: nodeArgs, + nodeOptions: nodeOptions, env, stdio: ENABLE_LOG_COMPILATION ? 'inherit' : 'pipe', }); diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index 96063c4ec9a..0610c6cfcc4 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -1,7 +1,7 @@ 'use strict'; const stripAnsi = require('strip-ansi'); -const { runAndGetWatchProc, isWebpack5 } = require('../utils/test-utils'); +const { run, runAndGetWatchProc, isWebpack5 } = require('../utils/test-utils'); const { writeFileSync } = require('fs'); const { resolve } = require('path'); @@ -9,13 +9,21 @@ const wordsInStatsv4 = ['Hash', 'Version', 'Time', 'Built at:', 'main.js']; const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; describe('--watch flag', () => { + it('should work with negative value', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './watch.config.js', '--no-watch']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + it('should recompile upon file change', (done) => { const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); let semaphore = 0; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); - if (semaphore === 0 && data.includes('watching files for updates')) { + if (semaphore === 0 && data.includes('Compilation is watching files for updates...')) { process.nextTick(() => { writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); @@ -23,39 +31,12 @@ describe('--watch flag', () => { }); } - if (semaphore === 1 && data.includes('index.js')) { - if (isWebpack5) { - for (const word of wordsInStatsv5) { - expect(data).toContain(word); - } - } else { - for (const word of wordsInStatsv4) { - expect(data).toContain(word); - } - } - - semaphore++; - } - - if (semaphore === 2 && data.includes('watching files for updates')) { - proc.kill(); - done(); - } - }); - }); - - it('should print compilation lifecycle', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); - let semaphore = 0; - proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); - - if (semaphore === 0 && data.includes('Compilation starting')) { - semaphore++; - } + if (semaphore === 1 && data.includes('was modified')) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); - if (semaphore === 1 && data.includes('Compilation finished')) { - semaphore++; + semaphore++; + }); } if (semaphore === 2 && data.includes('index.js')) { @@ -72,9 +53,7 @@ describe('--watch flag', () => { semaphore++; } - if (semaphore === 3 && data.includes('watching files for updates...')) { - semaphore++; - + if (semaphore === 3 && data.includes('Compilation is watching files for updates...')) { proc.kill(); done(); } diff --git a/test/watch/watch.config.js b/test/watch/watch.config.js new file mode 100644 index 00000000000..861575d0712 --- /dev/null +++ b/test/watch/watch.config.js @@ -0,0 +1,3 @@ +module.exports = { + watch: true, +}; From d59dc9795ed63c8c5a2aa020afd7d9dccf1bb125 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 27 Nov 2020 18:18:35 +0300 Subject: [PATCH 109/581] chore(deps-dev): bump @babel/preset-env from 7.12.1 to 7.12.7 (#2127) Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.12.1 to 7.12.7. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.7/packages/babel-preset-env) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 117 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 46 deletions(-) diff --git a/yarn.lock b/yarn.lock index a9bda1558a9..a154eecc9a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9,10 +9,10 @@ dependencies: "@babel/highlight" "^7.10.4" -"@babel/compat-data@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.1.tgz#d7386a689aa0ddf06255005b4b991988021101a0" - integrity sha512-725AQupWJZ8ba0jbKceeFblZTY90McUBWMwHhkFQ9q1zKPJ95GUktljFcgcsIVwRnTnRKlcYzfiNImg5G9m6ZQ== +"@babel/compat-data@^7.12.5", "@babel/compat-data@^7.12.7": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.7.tgz#9329b4782a7d6bbd7eef57e11addf91ee3ef1e41" + integrity sha512-YaxPMGs/XIWtYqrdEOZOCPsVWfEoriXopnsz3/i7apYPXQ3698UFhS6dVT1KN5qOsWmVgw/FOrmQgpRaZayGsw== "@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.12.3", "@babel/core@^7.7.5": version "7.12.9" @@ -60,14 +60,14 @@ "@babel/helper-explode-assignable-expression" "^7.10.4" "@babel/types" "^7.10.4" -"@babel/helper-compilation-targets@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.12.1.tgz#310e352888fbdbdd8577be8dfdd2afb9e7adcf50" - integrity sha512-jtBEif7jsPwP27GPHs06v4WBV0KrE8a/P7n0N0sSvHn2hwUCYnolP/CLmz51IzAW4NlN+HuoBtb9QcwnRo9F/g== +"@babel/helper-compilation-targets@^7.12.5": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.12.5.tgz#cb470c76198db6a24e9dbc8987275631e5d29831" + integrity sha512-+qH6NrscMolUlzOYngSBMIOQpKUGPPsc61Bu5W10mg84LxZ7cmvnBHzARKbDoFxVvqqAbj6Tg6N7bSrWSPXMyw== dependencies: - "@babel/compat-data" "^7.12.1" + "@babel/compat-data" "^7.12.5" "@babel/helper-validator-option" "^7.12.1" - browserslist "^4.12.0" + browserslist "^4.14.5" semver "^5.5.0" "@babel/helper-create-class-features-plugin@^7.12.1": @@ -136,12 +136,12 @@ dependencies: "@babel/types" "^7.12.1" -"@babel/helper-module-imports@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.1.tgz#1644c01591a15a2f084dd6d092d9430eb1d1216c" - integrity sha512-ZeC1TlMSvikvJNy1v/wPIazCu3NdOwgYZLIkmIyAsGhqkNpiDoQQRmaCK8YP4Pq3GPTLPV9WXaPCJKvx06JxKA== +"@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.12.5": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.5.tgz#1bfc0229f794988f76ed0a4d4e90860850b54dfb" + integrity sha512-SR713Ogqg6++uexFRORf/+nPXMmWIn80TALu0uaFb+iQIUoR7bOC7zBWyzBs5b3tBBJXuyD0cRu1F15GyzjOWA== dependencies: - "@babel/types" "^7.12.1" + "@babel/types" "^7.12.5" "@babel/helper-module-transforms@^7.12.1": version "7.12.1" @@ -317,10 +317,10 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.0" -"@babel/plugin-proposal-numeric-separator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.12.1.tgz#0e2c6774c4ce48be412119b4d693ac777f7685a6" - integrity sha512-MR7Ok+Af3OhNTCxYVjJZHS0t97ydnJZt/DbR4WISO39iDnhiD8XHrY12xuSJ90FFEGjir0Fzyyn7g/zY6hxbxA== +"@babel/plugin-proposal-numeric-separator@^7.12.7": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.12.7.tgz#8bf253de8139099fea193b297d23a9d406ef056b" + integrity sha512-8c+uy0qmnRTeukiGsjLGy6uVs/TFjJchGXUeBqlG4VWYOdJWkhhVPdQ3uHwbmalfJwv2JsV0qffXP4asRfL2SQ== dependencies: "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-numeric-separator" "^7.10.4" @@ -342,10 +342,10 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-optional-catch-binding" "^7.8.0" -"@babel/plugin-proposal-optional-chaining@^7.1.0", "@babel/plugin-proposal-optional-chaining@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.12.1.tgz#cce122203fc8a32794296fc377c6dedaf4363797" - integrity sha512-c2uRpY6WzaVDzynVY9liyykS+kVU+WRZPMPYpkelXH8KBt1oXoI89kPbZKKG/jDT5UK92FTW2fZkZaJhdiBabw== +"@babel/plugin-proposal-optional-chaining@^7.1.0", "@babel/plugin-proposal-optional-chaining@^7.12.7": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.12.7.tgz#e02f0ea1b5dc59d401ec16fb824679f683d3303c" + integrity sha512-4ovylXZ0PWmwoOvhU2vhnzVNnm88/Sm9nx7V8BPgMvAzn5zDou3/Awy0EjglyubVHasJj+XCEkr/r1X3P5elCA== dependencies: "@babel/helper-plugin-utils" "^7.10.4" "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" @@ -700,13 +700,12 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" -"@babel/plugin-transform-sticky-regex@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.12.1.tgz#5c24cf50de396d30e99afc8d1c700e8bce0f5caf" - integrity sha512-CiUgKQ3AGVk7kveIaPEET1jNDhZZEl1RPMWdTBE1799bdz++SwqDHStmxfCtDfBhQgCl38YRiSnrMuUMZIWSUQ== +"@babel/plugin-transform-sticky-regex@^7.12.7": + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.12.7.tgz#560224613ab23987453948ed21d0b0b193fa7fad" + integrity sha512-VEiqZL5N/QvDbdjfYQBhruN0HYjSPjC4XkeqW4ny/jNtH9gcbgaqBIXYEZCNnESMAGs0/K/R7oFGMhOyu/eIxg== dependencies: "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-regex" "^7.10.4" "@babel/plugin-transform-template-literals@^7.12.1": version "7.12.1" @@ -747,13 +746,13 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/preset-env@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.1.tgz#9c7e5ca82a19efc865384bb4989148d2ee5d7ac2" - integrity sha512-H8kxXmtPaAGT7TyBvSSkoSTUK6RHh61So05SyEbpmr0MCZrsNYn7mGMzzeYoOUCdHzww61k8XBft2TaES+xPLg== + version "7.12.7" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.7.tgz#54ea21dbe92caf6f10cb1a0a576adc4ebf094b55" + integrity sha512-OnNdfAr1FUQg7ksb7bmbKoby4qFOHw6DKWWUNB9KqnnCldxhxJlP+21dpyaWFmf2h0rTbOkXJtAGevY3XW1eew== dependencies: - "@babel/compat-data" "^7.12.1" - "@babel/helper-compilation-targets" "^7.12.1" - "@babel/helper-module-imports" "^7.12.1" + "@babel/compat-data" "^7.12.7" + "@babel/helper-compilation-targets" "^7.12.5" + "@babel/helper-module-imports" "^7.12.5" "@babel/helper-plugin-utils" "^7.10.4" "@babel/helper-validator-option" "^7.12.1" "@babel/plugin-proposal-async-generator-functions" "^7.12.1" @@ -763,10 +762,10 @@ "@babel/plugin-proposal-json-strings" "^7.12.1" "@babel/plugin-proposal-logical-assignment-operators" "^7.12.1" "@babel/plugin-proposal-nullish-coalescing-operator" "^7.12.1" - "@babel/plugin-proposal-numeric-separator" "^7.12.1" + "@babel/plugin-proposal-numeric-separator" "^7.12.7" "@babel/plugin-proposal-object-rest-spread" "^7.12.1" "@babel/plugin-proposal-optional-catch-binding" "^7.12.1" - "@babel/plugin-proposal-optional-chaining" "^7.12.1" + "@babel/plugin-proposal-optional-chaining" "^7.12.7" "@babel/plugin-proposal-private-methods" "^7.12.1" "@babel/plugin-proposal-unicode-property-regex" "^7.12.1" "@babel/plugin-syntax-async-generators" "^7.8.0" @@ -808,14 +807,14 @@ "@babel/plugin-transform-reserved-words" "^7.12.1" "@babel/plugin-transform-shorthand-properties" "^7.12.1" "@babel/plugin-transform-spread" "^7.12.1" - "@babel/plugin-transform-sticky-regex" "^7.12.1" + "@babel/plugin-transform-sticky-regex" "^7.12.7" "@babel/plugin-transform-template-literals" "^7.12.1" "@babel/plugin-transform-typeof-symbol" "^7.12.1" "@babel/plugin-transform-unicode-escapes" "^7.12.1" "@babel/plugin-transform-unicode-regex" "^7.12.1" "@babel/preset-modules" "^0.1.3" - "@babel/types" "^7.12.1" - core-js-compat "^3.6.2" + "@babel/types" "^7.12.7" + core-js-compat "^3.7.0" semver "^5.5.0" "@babel/preset-flow@^7.0.0": @@ -3385,7 +3384,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4.8.5: +browserslist@^4.14.5: version "4.14.5" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.5.tgz#1c751461a102ddc60e40993639b709be7f2c4015" integrity sha512-Z+vsCZIvCBvqLoYkBFTwEYH3v5MCQbsAjp50ERycpOjnPmolg1Gjy4+KaWWpm8QOJt9GHkhdqAl14NpCX73CWA== @@ -3395,6 +3394,17 @@ browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4.8.5: escalade "^3.1.0" node-releases "^1.1.61" +browserslist@^4.14.6: + version "4.14.7" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.7.tgz#c071c1b3622c1c2e790799a37bb09473a4351cb6" + integrity sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ== + dependencies: + caniuse-lite "^1.0.30001157" + colorette "^1.2.1" + electron-to-chromium "^1.3.591" + escalade "^3.1.1" + node-releases "^1.1.66" + bs-logger@0.x: version "0.2.6" resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" @@ -3593,6 +3603,11 @@ caniuse-lite@^1.0.30001135: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001153.tgz#9a0942fe777cd7178fb084693b79415ff747ecd9" integrity sha512-qv14w7kWwm2IW7DBvAKWlCqGTmV2XxNtSejJBVplwRjhkohHuhRUpeSlPjtu9erru0+A12zCDUiSmvx/AcqVRA== +caniuse-lite@^1.0.30001157: + version "1.0.30001159" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001159.tgz#bebde28f893fa9594dadcaa7d6b8e2aa0299df20" + integrity sha512-w9Ph56jOsS8RL20K9cLND3u/+5WASWdhC/PPrf+V3/HsM3uHOavWOR1Xzakbv4Puo/srmPHudkmCRWM7Aq+/UA== + capture-exit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4" @@ -4146,12 +4161,12 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= -core-js-compat@^3.6.2: - version "3.6.5" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.6.5.tgz#2a51d9a4e25dfd6e690251aa81f99e3c05481f1c" - integrity sha512-7ItTKOhOZbznhXAQ2g/slGg1PJV5zDO/WdkTwi7UEOJmkvsE32PWvx6mKtDjiMpjnR2CNf6BAD6sSxIlv7ptng== +core-js-compat@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.7.0.tgz#8479c5d3d672d83f1f5ab94cf353e57113e065ed" + integrity sha512-V8yBI3+ZLDVomoWICO6kq/CD28Y4r1M7CWeO4AGpMdMfseu8bkSubBmUPySMGKRTS+su4XQ07zUkAsiu9FCWTg== dependencies: - browserslist "^4.8.5" + browserslist "^4.14.6" semver "7.0.0" core-js@^3.6.1: @@ -4697,6 +4712,11 @@ electron-to-chromium@^1.3.571: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.584.tgz#506cf7ba5895aafa8241876ab028654b61fd9ceb" integrity sha512-NB3DzrTzJFhWkUp+nl2KtUtoFzrfGXTir2S+BU4tXGyXH9vlluPuFpE3pTKeH7+PY460tHLjKzh6K2+TWwW+Ww== +electron-to-chromium@^1.3.591: + version "1.3.603" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.603.tgz#1b71bec27fb940eccd79245f6824c63d5f7e8abf" + integrity sha512-J8OHxOeJkoSLgBXfV9BHgKccgfLMHh+CoeRo6wJsi6m0k3otaxS/5vrHpMNSEYY4MISwewqanPOuhAtuE8riQQ== + elegant-spinner@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/elegant-spinner/-/elegant-spinner-1.0.1.tgz#db043521c95d7e303fd8f345bedc3349cfb0729e" @@ -4853,7 +4873,7 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" -escalade@^3.1.0: +escalade@^3.1.0, escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== @@ -8582,6 +8602,11 @@ node-releases@^1.1.61: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.64.tgz#71b4ae988e9b1dd7c1ffce58dd9e561752dfebc5" integrity sha512-Iec8O9166/x2HRMJyLLLWkd0sFFLrFNy+Xf+JQfSQsdBJzPcHpNl3JQ9gD4j+aJxmCa25jNsIbM4bmACtSbkSg== +node-releases@^1.1.66: + version "1.1.67" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.67.tgz#28ebfcccd0baa6aad8e8d4d8fe4cbc49ae239c12" + integrity sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg== + nopt@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" From 2219927144df645e0da9f5aae0ab39a382a2d959 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 28 Nov 2020 00:15:42 +0530 Subject: [PATCH 110/581] chore: replace compilation to complier (#2142) * chore: replace compilation to complier * chore: update in stats watch test --- packages/webpack-cli/lib/plugins/CLIPlugin.js | 2 +- test/stats/watch/stats-and-watch.test.js | 6 +++--- test/watch/watch-flag.test.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js index 72efe8bd44d..ec267adced0 100644 --- a/packages/webpack-cli/lib/plugins/CLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -75,7 +75,7 @@ class CLIPlugin { process.nextTick(() => { if (compiler.watchMode) { - logger.success(`Compilation${getCompilationName(stats.compilation)} is watching files for updates...`); + logger.success(`Compiler${getCompilationName(stats.compilation)} is watching files for updates...`); } }); }); diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js index bb0c78bec2f..4c308975371 100644 --- a/test/stats/watch/stats-and-watch.test.js +++ b/test/stats/watch/stats-and-watch.test.js @@ -8,7 +8,7 @@ describe('stats and watch', () => { expect(stdout).toContain('[webpack-cli] Compilation starting...'); expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] Compilation is watching files for updates...'); + expect(stdout).toContain('[webpack-cli] Compiler is watching files for updates...'); expect(stderr).toBeFalsy(); }); @@ -17,7 +17,7 @@ describe('stats and watch', () => { expect(stdout).toContain('[webpack-cli] Compilation starting...'); expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] Compilation is watching files for updates...'); + expect(stdout).toContain('[webpack-cli] Compiler is watching files for updates...'); expect(stderr).toBeFalsy(); }); @@ -28,7 +28,7 @@ describe('stats and watch', () => { expect(stdout).toContain('[webpack-cli] Compilation starting...'); expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] Compilation is watching files for updates...'); + expect(stdout).toContain('[webpack-cli] Compiler is watching files for updates...'); expect(stdout).toContain(output); expect(stderr).toBeFalsy(); }); diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index 0610c6cfcc4..f95b54759b7 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -23,7 +23,7 @@ describe('--watch flag', () => { proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); - if (semaphore === 0 && data.includes('Compilation is watching files for updates...')) { + if (semaphore === 0 && data.includes('Compiler is watching files for updates...')) { process.nextTick(() => { writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); @@ -53,7 +53,7 @@ describe('--watch flag', () => { semaphore++; } - if (semaphore === 3 && data.includes('Compilation is watching files for updates...')) { + if (semaphore === 3 && data.includes('Compiler is watching files for updates...')) { proc.kill(); done(); } From eae913b47c03353f50b8137ad23ac905ff8b5e74 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 28 Nov 2020 17:11:25 +0300 Subject: [PATCH 111/581] chore(deps-dev): bump prettier from 2.1.2 to 2.2.1 (#2143) Bumps [prettier](https://github.com/prettier/prettier) from 2.1.2 to 2.2.1. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.1.2...2.2.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index a154eecc9a1..afe52f8eacc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9385,9 +9385,9 @@ prettier-linter-helpers@^1.0.0: fast-diff "^1.1.2" prettier@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" - integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg== + version "2.2.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" + integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== pretty-bytes@^5.2.0: version "5.4.1" From ae78411a56136151b25f88d6f80a001db788de10 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 29 Nov 2020 17:43:14 +0530 Subject: [PATCH 112/581] docs: update SECURITY.md (#2146) --- SECURITY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 544e35b994e..9f3479c7a72 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,10 +8,10 @@ webpack CLI is currently supporting webpack v4 and webpack v5. Security fixes ar | webpack version | webpack-cli version | Supported | | --------------- | ----------------------------- | ------------------ | -| >= 4.20.x | ^3.1.2 | :white_check_mark: | -| <= 4.19.x | ^3.1.1 | :white_check_mark: | -| 5.x.0 | ^3.1.2 | :white_check_mark: | -| 5.0.x | ^3.1.2 | :white_check_mark: | +| >= 4.20.x | ^4.2.0 | :white_check_mark: | +| <= 4.19.x | ^4.2.0 | :white_check_mark: | +| 5.x.0 | ^4.2.0 | :white_check_mark: | +| 5.0.x | ^4.2.0 | :white_check_mark: | | < 4.x.x | (CLI included in webpack < 4) | :x: | **Note: Using webpack < 4 with webpack CLI is not required as CLI was [included](https://github.com/webpack/webpack/commit/4b0332d3909eea8115d84f9a03da2d52478daa70#diff-b9cfc7f2cdf78a7f4b91a753d10865a2) in webpack.** From 08d435578a67756769c8ded39cc4fe847a252379 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2020 13:50:19 +0300 Subject: [PATCH 113/581] chore(deps-dev): bump webpack from 5.8.0 to 5.9.0 (#2145) Bumps [webpack](https://github.com/webpack/webpack) from 5.8.0 to 5.9.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.8.0...v5.9.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/yarn.lock b/yarn.lock index afe52f8eacc..c4fe32bd154 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3384,17 +3384,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browserslist@^4.14.5: - version "4.14.5" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.5.tgz#1c751461a102ddc60e40993639b709be7f2c4015" - integrity sha512-Z+vsCZIvCBvqLoYkBFTwEYH3v5MCQbsAjp50ERycpOjnPmolg1Gjy4+KaWWpm8QOJt9GHkhdqAl14NpCX73CWA== - dependencies: - caniuse-lite "^1.0.30001135" - electron-to-chromium "^1.3.571" - escalade "^3.1.0" - node-releases "^1.1.61" - -browserslist@^4.14.6: +browserslist@^4.14.5, browserslist@^4.14.6: version "4.14.7" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.7.tgz#c071c1b3622c1c2e790799a37bb09473a4351cb6" integrity sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ== @@ -3598,11 +3588,6 @@ camelcase@^6.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== -caniuse-lite@^1.0.30001135: - version "1.0.30001153" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001153.tgz#9a0942fe777cd7178fb084693b79415ff747ecd9" - integrity sha512-qv14w7kWwm2IW7DBvAKWlCqGTmV2XxNtSejJBVplwRjhkohHuhRUpeSlPjtu9erru0+A12zCDUiSmvx/AcqVRA== - caniuse-lite@^1.0.30001157: version "1.0.30001159" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001159.tgz#bebde28f893fa9594dadcaa7d6b8e2aa0299df20" @@ -4707,11 +4692,6 @@ ejs@^3.0.1: dependencies: jake "^10.6.1" -electron-to-chromium@^1.3.571: - version "1.3.584" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.584.tgz#506cf7ba5895aafa8241876ab028654b61fd9ceb" - integrity sha512-NB3DzrTzJFhWkUp+nl2KtUtoFzrfGXTir2S+BU4tXGyXH9vlluPuFpE3pTKeH7+PY460tHLjKzh6K2+TWwW+Ww== - electron-to-chromium@^1.3.591: version "1.3.603" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.603.tgz#1b71bec27fb940eccd79245f6824c63d5f7e8abf" @@ -4873,7 +4853,7 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" -escalade@^3.1.0, escalade@^3.1.1: +escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== @@ -8597,11 +8577,6 @@ node-preload@^0.2.1: dependencies: process-on-spawn "^1.0.0" -node-releases@^1.1.61: - version "1.1.64" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.64.tgz#71b4ae988e9b1dd7c1ffce58dd9e561752dfebc5" - integrity sha512-Iec8O9166/x2HRMJyLLLWkd0sFFLrFNy+Xf+JQfSQsdBJzPcHpNl3JQ9gD4j+aJxmCa25jNsIbM4bmACtSbkSg== - node-releases@^1.1.66: version "1.1.67" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.67.tgz#28ebfcccd0baa6aad8e8d4d8fe4cbc49ae239c12" @@ -11739,9 +11714,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.3.0: - version "5.8.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.8.0.tgz#65f00a181708279ff982c2d7338e1dd5505364c4" - integrity sha512-X2yosPiHip3L0TE+ylruzrOqSgEgsdGyBOGFWKYChcwlKChaw9VodZIUovG1oo7s0ss6e3ZxBMn9tXR+nkPThA== + version "5.9.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.9.0.tgz#af2e9cf9d6c7867cdcf214ea3bb5eb77aece6895" + integrity sha512-YnnqIV/uAS5ZrNpctSv378qV7HmbJ74DL+XfvMxzbX1bV9e7eeT6eEWU4wuUw33CNr/HspBh7R/xQlVjTEyAeA== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From 293bb8396243a34aa39298fe781eff85a84895fc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2020 18:47:43 +0300 Subject: [PATCH 114/581] chore(deps-dev): bump git-cz from 4.7.4 to 4.7.5 (#2149) Bumps [git-cz](https://github.com/streamich/git-cz) from 4.7.4 to 4.7.5. - [Release notes](https://github.com/streamich/git-cz/releases) - [Changelog](https://github.com/streamich/git-cz/blob/master/CHANGELOG.md) - [Commits](https://github.com/streamich/git-cz/compare/v4.7.4...v4.7.5) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c4fe32bd154..75b0c7baff4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5740,9 +5740,9 @@ gh-got@^5.0.0: is-plain-obj "^1.1.0" git-cz@^4.7.1: - version "4.7.4" - resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.4.tgz#abb119676fc5869d1f3470a54032c6a95d53d010" - integrity sha512-s8r6JPuuFJXCiwB6uBlWYjDE6GlvIReSgVqYCfpRB+JbiBVNQLcBb93mH6bIJzz1lQU4R8+qlChhQIK8xp58Tg== + version "4.7.5" + resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.5.tgz#9707efabc60ebb23e8d1e61469d195bdb91c49ad" + integrity sha512-FBzBE2gbadDXQEIV/yq5lPZt4UTXLK1+RwsnAM6K6AA9/Wwtvr6pLgX1+g/V7h1grl9gXIlIXu7srbdGxoJPqA== git-raw-commits@2.0.0: version "2.0.0" From 057fccff417348d8244bd4da66902714e6cb2f6e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 1 Dec 2020 16:28:38 +0530 Subject: [PATCH 115/581] docs: add --no-devtool & --no-watch (#2153) --- packages/webpack-cli/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 1d8cb691433..70379c8ceba 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -58,9 +58,11 @@ yarn add webpack-cli --dev -o, --output-path string Output location of the generated bundle -t, --target string[] Sets the build target -w, --watch Watch for files changes + --no-watch Negates watch -h, --hot Enables Hot Module Replacement --no-hot Disables Hot Module Replacement -d, --devtool string Controls if and how source maps are generated. + --no-devtool Negates devtool --prefetch string Prefetch this request -j, --json string, boolean Prints result as JSON or store it in a file --mode string Defines the mode to pass to webpack From b4f3f8baabc698896cb00915cca38931cc6e3e4b Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 1 Dec 2020 16:36:02 +0530 Subject: [PATCH 116/581] chore: remove stale tmp files from .eslintignore (#2150) --- .eslintignore | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.eslintignore b/.eslintignore index dad8534184d..27d5a60ae35 100644 --- a/.eslintignore +++ b/.eslintignore @@ -15,16 +15,3 @@ test/**/binary/ test/**/index.js test/typescript/webpack.config.ts test/config/error/syntax-error.js -test/plugin/test-plugin/test/test-utils.js -test/plugin/test-plugin/test/functional.test.js -test/plugin/test-plugin/examples/simple/src/static-esm-module.js -test/plugin/test-plugin/examples/simple/src/lazy-module.js -test/plugin/test-plugin/examples/simple/webpack.config.js -test/loader/test-loader/test/unit.test.js -test/loader/test-loader/test/test-utils.js -test/loader/test-loader/test/functional.test.js -test/loader/test-loader/examples/simple/webpack.config.js -test/loader/test-loader/examples/simple/src/static-esm-module.js -test/loader/test-loader/examples/simple/src/lazy-module.js -test/loader/test-loader/examples/simple/example_dist/** -lib/test/loader/error-test/src/index.d.ts From 7daccc786a0eb4eeae4c5b3632fc28240a696170 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 1 Dec 2020 17:49:49 +0300 Subject: [PATCH 117/581] feat: respect the `infrastructureLogging.level` option (potential breaking change, logger uses `stderr`) (#2144) --- .../webpack-cli/__tests__/serve/serve.test.js | 12 ++- packages/webpack-cli/lib/plugins/CLIPlugin.js | 21 ++-- packages/webpack-cli/lib/webpack-cli.js | 5 + test/analyze/analyze-flag.test.js | 3 +- test/bail/bail.test.js | 33 +++++- test/build-errors/errors.test.js | 18 ++-- test/build-warnings/warnings.test.js | 19 ++-- test/cache/cache.test.js | 9 ++ test/colors/colors.test.js | 75 +++++++------ test/config-format/coffee/coffee.test.js | 18 ++-- test/config-format/commonjs/commonjs.test.js | 10 +- .../typescript/typescript.test.js | 2 +- .../custom-name/custom-name.test.js | 11 +- .../dotfolder-array/dotfolder-array.test.js | 24 ++--- .../dotfolder-single/dotfolder-single.test.js | 18 +--- .../relative/basic-config.test.js | 21 ++-- test/config-name/config-name.test.js | 33 ++++-- test/config/absent/config-absent.test.js | 14 +-- test/config/basic/basic-config.test.js | 10 +- .../basic-config/default-js-config.test.js | 12 ++- .../cjs-config/default-cjs-config.test.js | 11 +- .../multiple-location-config.test.js | 9 +- .../dev-none-config.test.js | 9 +- .../with-mode/multiple-config.test.js | 9 +- test/config/empty-array/empty-array.test.js | 8 +- .../empty-function/empty-function.test.js | 8 +- .../empty-promise/empty-promise.test.js | 8 +- test/config/empty/empty.test.js | 8 +- test/config/error/config-error.test.js | 10 +- .../config/function/functional-config.test.js | 39 +++---- .../invalid-export/invalid-export.test.js | 1 + test/config/invalid-path/invalid-path.test.js | 3 +- .../multiple-with-one-compilation.test.js | 10 +- test/config/multiple/multiple-config.test.js | 17 ++- .../no-config-array/no-config-array.test.js | 2 +- .../no-config-object/no-config-object.test.js | 6 +- .../function-with-argv.test.js | 27 +++-- .../webpack.config.js | 2 + .../array-function-with-env.test.js | 27 +++-- .../array-function-with-env/webpack.config.js | 2 + .../array-functions/array-functions.test.js | 8 +- .../type/array-functions/webpack.config.js | 2 + .../array-promises/array-promises.test.js | 9 +- .../type/array-promises/webpack.config.js | 2 + test/config/type/array/array.test.js | 8 +- .../function-array/function-array.test.js | 8 +- .../type/function-array/webpack.config.js | 2 + .../function-async/function-async.test.js | 6 +- .../function-promise/function-promise.test.js | 6 +- .../function-with-argv.test.js | 20 ++-- .../function-with-env.test.js | 82 +++++++++----- test/config/type/function/function.test.js | 8 +- .../type/promise-array/promise-array.test.js | 7 +- .../promise-function/promise-function.test.js | 8 +- test/config/type/promise/promise.test.js | 8 +- test/core-flags/amd-flag.test.js | 5 +- test/core-flags/bail-flag.test.js | 10 +- test/core-flags/cache-flags.test.js | 102 +++++++++++------- test/core-flags/context-flag.test.js | 11 +- test/core-flags/dependencies-flag.test.js | 10 +- test/core-flags/devtool-flag.test.js | 8 +- test/core-flags/entry-reset-flag.test.js | 11 +- test/core-flags/experiments-flag.test.js | 10 +- test/core-flags/externals-flags.test.js | 30 +++--- .../core-flags/infrastructure-logging.test.js | 15 +-- test/core-flags/invalid-flag.test.js | 2 +- test/core-flags/module-flags.test.js | 37 ++++--- test/core-flags/node-flags.test.js | 15 +-- test/core-flags/optimization-flags.test.js | 43 +++++--- test/core-flags/output-flags.test.js | 75 ++++++++----- test/core-flags/parallelism-flag.test.js | 11 +- test/core-flags/performance-flags.test.js | 15 +-- test/core-flags/profile-flag.test.js | 10 +- test/core-flags/records-flag.test.js | 15 +-- test/core-flags/resolve-flags.test.js | 25 +++-- test/core-flags/snapshot-flags.test.js | 11 +- test/core-flags/stats-flags.test.js | 40 ++++--- test/core-flags/watch-flags.test.js | 22 ++-- test/defaults/output-defaults.test.js | 18 +++- test/devtool/array/source-map-array.test.js | 18 ++-- test/devtool/object/source-map-object.test.js | 28 +++-- .../entry-with-command.test.js | 15 +-- .../entry-with-config.test.js | 15 +-- .../entry-with-config.test.js | 14 +-- .../defaults-empty/entry-single-arg.test.js | 5 +- .../defaults-index/entry-multi-args.test.js | 30 ++---- test/entry/flag-entry/entry-with-flag.test.js | 51 ++++----- .../multiple-entries/multi-entries.test.js | 10 +- test/entry/scss/scss.test.js | 2 + test/env/array/array-env.test.js | 5 +- test/env/object/object-env.test.js | 5 +- test/error/error.test.js | 6 +- test/help/help-commands.test.js | 10 +- test/help/help-flags.test.js | 10 +- test/help/help-multi-args.test.js | 8 +- test/help/help-single-arg.test.js | 15 +-- test/hot/hot-flag.test.js | 9 +- test/info/info-help.test.js | 6 +- test/info/info-output.test.js | 2 +- test/info/info-unknown.test.js | 2 +- test/invalid-schema/invalid-schema.test.js | 4 + .../config-absent/merge-config-absent.test.js | 10 +- test/merge/config/merge-config.test.js | 30 +++--- .../mode-single-arg/mode-single-arg.test.js | 31 ++++-- .../mode-with-config/mode-with-config.test.js | 44 +++++--- test/name/name.test.js | 5 +- test/no-hot/no-hot.test.js | 15 +-- test/no-stats/with-config/main.js | 3 - .../with-config/no-stats-with-config.test.js | 14 ++- test/no-stats/with-flags/main.js | 3 - test/no-stats/with-flags/no-stats.test.js | 19 +++- test/node/node.test.js | 27 ++--- test/optimization/optimization.test.js | 27 +++-- .../output-named-bundles.test.js | 54 +++++----- test/prefetch/prefetch.test.js | 21 ++-- test/progress/progress-flag.test.js | 20 +++- test/serve/basic/serve-basic.test.js | 39 ++++--- test/serve/serve-variable/serve-basic.test.js | 4 +- .../serve-custom-config.test.js | 16 ++- test/stats/cli-flags/stats.test.js | 18 ++-- test/stats/config/stats.test.js | 12 ++- test/stats/watch/stats-and-watch.test.js | 37 ++++--- test/target/flag-test/target-flag.test.js | 48 ++++----- test/target/node/node-test.test.js | 18 ++-- test/unknown/unknown.test.js | 13 ++- test/utils/cli-plugin-test/plugin.test.js | 9 +- test/utils/test-utils.js | 6 +- test/utils/test-utils.test.js | 24 +++-- .../version/version-external-packages.test.js | 23 ++-- test/version/version-multi-args.test.js | 16 +-- test/version/version-single-arg.test.js | 6 +- test/watch/watch-flag.test.js | 45 ++++---- .../entry-absent/zero-config.test.js | 8 +- .../entry-present/zero-config.test.js | 12 +-- 134 files changed, 1338 insertions(+), 928 deletions(-) diff --git a/packages/webpack-cli/__tests__/serve/serve.test.js b/packages/webpack-cli/__tests__/serve/serve.test.js index edebe9bd2a5..77df7668eb2 100644 --- a/packages/webpack-cli/__tests__/serve/serve.test.js +++ b/packages/webpack-cli/__tests__/serve/serve.test.js @@ -12,16 +12,20 @@ describe('Serve', () => { } it('should run with cli', async () => { - const { stdout, stderr } = await runServe([], __dirname); + const { stderr, stdout } = await runServe([], __dirname); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); - expect(stderr).toHaveLength(0); }); it('should work with flags', async () => { - const { stdout, stderr } = await runServe(['--hot'], __dirname); + const { stderr, stdout } = await runServe(['--hot'], __dirname); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); - expect(stderr).toHaveLength(0); }); }); diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js index ec267adced0..a57a1d17846 100644 --- a/packages/webpack-cli/lib/plugins/CLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -1,6 +1,5 @@ const packageExists = require('../utils/package-exists'); const webpack = packageExists('webpack') ? require('webpack') : undefined; -const logger = require('../utils/logger'); class CLIPlugin { constructor(options) { @@ -37,11 +36,6 @@ class CLIPlugin { const progressPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin)); if (!progressPlugin) { - if (typeof this.options.progress === 'string' && this.options.progress !== 'profile') { - logger.error(`'${this.options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`); - process.exit(2); - } - new ProgressPlugin({ profile: this.options.progress === 'profile' }).apply(compiler); } } @@ -51,37 +45,40 @@ class CLIPlugin { const getCompilationName = (compilation) => (compilation.name ? ` '${compilation.name}'` : ''); compiler.hooks.run.tap(pluginName, (compiler) => { - logger.success(`Compilation${getCompilationName(compiler)} starting...`); + this.logger.info(`Compilation${getCompilationName(compiler)} starting...`); }); compiler.hooks.watchRun.tap(pluginName, (compiler) => { const { bail, watch } = compiler.options; if (bail && watch) { - logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); + this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); } - logger.success(`Compilation${getCompilationName(compiler)} starting...`); + this.logger.info(`Compilation${getCompilationName(compiler)} starting...`); }); compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => { const date = new Date(changeTime * 1000); - logger.log(`File '${filename}' was modified, changed time is ${date} (timestamp is ${changeTime})`); + this.logger.info(`File '${filename}' was modified`); + this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`); }); (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, (stats) => { - logger.success(`Compilation${getCompilationName(stats.compilation)} finished`); + this.logger.info(`Compilation${getCompilationName(stats.compilation)} finished`); process.nextTick(() => { if (compiler.watchMode) { - logger.success(`Compiler${getCompilationName(stats.compilation)} is watching files for updates...`); + this.logger.info(`Compiler${getCompilationName(stats.compilation)} is watching files for updates...`); } }); }); } apply(compiler) { + this.logger = compiler.getInfrastructureLogger('webpack-cli'); + if (this.options.progress && this.options.helpfulOutput) { this.setupProgressPlugin(compiler); } diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index b76b4016d0e..5830df34c34 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -219,6 +219,11 @@ class WebpackCLI { } } + if (typeof args.progress === 'string' && args.progress !== 'profile') { + logger.error(`'${args.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`); + process.exit(2); + } + if (Object.keys(args).length === 0 && !process.env.NODE_ENV) { return config; } diff --git a/test/analyze/analyze-flag.test.js b/test/analyze/analyze-flag.test.js index 972a00223eb..15274c16c6e 100644 --- a/test/analyze/analyze-flag.test.js +++ b/test/analyze/analyze-flag.test.js @@ -22,7 +22,8 @@ describe('--analyze flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './analyze.config.js', '--analyze']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('Webpack Bundle Analyzer saved report to'); expect(stdout.match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); }); diff --git a/test/bail/bail.test.js b/test/bail/bail.test.js index c848403eb09..bddea2f0136 100644 --- a/test/bail/bail.test.js +++ b/test/bail/bail.test.js @@ -4,17 +4,21 @@ const { run, runWatch } = require('../utils/test-utils'); describe('bail and watch warning', () => { it('should not log warning in not watch mode', async () => { - const { stderr, stdout, exitCode } = await run(__dirname, ['-c', 'bail-webpack.config.js']); + const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'bail-webpack.config.js']); expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); it('should not log warning in not watch mode without the "bail" option', async () => { - const { stderr, stdout, exitCode } = await run(__dirname, ['-c', 'no-bail-webpack.config.js']); + const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'no-bail-webpack.config.js']); expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); @@ -22,6 +26,8 @@ describe('bail and watch warning', () => { it('should not log warning in not watch mode without the "watch" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'watch-webpack.config.js']); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); @@ -29,6 +35,8 @@ describe('bail and watch warning', () => { it('should not log warning without the "bail" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); @@ -36,6 +44,8 @@ describe('bail and watch warning', () => { it('should not log warning without the "bail" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); @@ -43,6 +53,8 @@ describe('bail and watch warning', () => { it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-webpack.config.js', '--watch']); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); @@ -50,13 +62,26 @@ describe('bail and watch warning', () => { it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-and-watch-webpack.config.js']); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); it('should log warning in case of multiple compilers', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js']); - + const { stderr, stdout } = await runWatch( + __dirname, + ['-c', 'multi-webpack.config.js'], + true, + "Compiler 'second' is watching files for updates...", + ); + + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compiler 'first' is watching files for updates..."); + expect(stderr).toContain("Compilation 'second' starting..."); + expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toContain("Compiler 'second' is watching files for updates..."); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); diff --git a/test/build-errors/errors.test.js b/test/build-errors/errors.test.js index 5ff6bbc617b..36d4cf0924e 100644 --- a/test/build-errors/errors.test.js +++ b/test/build-errors/errors.test.js @@ -5,18 +5,22 @@ const { resolve } = require('path'); describe('errors', () => { it('should output by default', () => { - const { stdout, exitCode } = run(__dirname); + const { exitCode, stderr, stdout } = run(__dirname); + expect(exitCode).toBe(1); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toMatch(/ERROR/); expect(stdout).toMatch(/Error: Can't resolve/); - expect(exitCode).toBe(1); }); it('should output JSON with the "json" flag', () => { - const { stdout, exitCode } = run(__dirname, ['--json']); + const { exitCode, stderr, stdout } = run(__dirname, ['--json']); - expect(() => JSON.parse(stdout)).not.toThrow(); expect(exitCode).toBe(1); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); + expect(() => JSON.parse(stdout)).not.toThrow(); const json = JSON.parse(stdout); @@ -27,10 +31,12 @@ describe('errors', () => { }); it('should store json to a file', (done) => { - const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json']); + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); - expect(stdout).toContain('stats are successfully stored as json to stats.json'); expect(exitCode).toBe(1); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); + expect(stdout).toContain('stats are successfully stored as json to stats.json'); stat(resolve(__dirname, './stats.json'), (err, stats) => { expect(err).toBe(null); diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index 576f59a4848..6bf7c918513 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -5,18 +5,23 @@ const { resolve } = require('path'); describe('warnings', () => { it('should output by default', () => { - const { stdout, exitCode } = run(__dirname); + const { exitCode, stderr, stdout } = run(__dirname); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toMatch(/WARNING/); expect(stdout).toMatch(/Error: Can't resolve/); - expect(exitCode).toBe(0); }); it('should output JSON with the "json" flag', () => { - const { stdout, exitCode } = run(__dirname, ['--json']); + const { exitCode, stderr, stdout } = run(__dirname, ['--json']); - expect(() => JSON.parse(stdout)).not.toThrow(); expect(exitCode).toBe(0); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); + + expect(() => JSON.parse(stdout)).not.toThrow(); const json = JSON.parse(stdout); @@ -27,10 +32,12 @@ describe('warnings', () => { }); it('should store json to a file', (done) => { - const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json']); + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); - expect(stdout).toContain('stats are successfully stored as json to stats.json'); expect(exitCode).toBe(0); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); + expect(stdout).toContain('stats are successfully stored as json to stats.json'); stat(resolve(__dirname, './stats.json'), (err, stats) => { expect(err).toBe(null); diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index c9a84017b08..7a31586a97d 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -17,6 +17,8 @@ describe('cache', () => { let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false); if (isWebpack5) { + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain('No pack exists at'); expect(stderr).toContain('Stored pack'); expect(stdout).toBeTruthy(); @@ -28,6 +30,8 @@ describe('cache', () => { if (isWebpack5) { expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain('restore cache container'); expect(stderr).toContain('restore cache content metadata'); expect(stderr).toContain('restore cache content'); @@ -41,6 +45,9 @@ describe('cache', () => { let { exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false); if (isWebpack5) { + expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain('No pack exists at'); expect(stderr).toContain('Stored pack'); expect(stdout).toBeTruthy(); @@ -52,6 +59,8 @@ describe('cache', () => { if (isWebpack5) { expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain('restore cache container'); expect(stderr).toContain('restore cache content metadata'); expect(stderr).toContain('restore cache content'); diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 58bd36a6dfc..2add37e2178 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -5,25 +5,27 @@ const { options: coloretteOptions } = require('colorette'); describe('colors related tests', () => { it('should output by default', () => { - const { stderr, stdout, exitCode } = run(__dirname, [], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, [], true, [], { FORCE_COLOR: true }); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose'], true, [], { FORCE_COLOR: true }); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags and from configuration', () => { - const { stderr, stdout, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['--stats=verbose', `--config=${resolve(__dirname, './no-stats.webpack.config.js')}`], true, @@ -31,27 +33,30 @@ describe('colors related tests', () => { { FORCE_COLOR: true }, ); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'test' starting..."); + expect(stderr).toContain("Compilation 'test' finished"); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags and from configuration #2', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js'], true, [], { + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js'], true, [], { FORCE_COLOR: true, }); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should disable colored output with --no-color', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--no-color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--no-color']); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); @@ -59,87 +64,95 @@ describe('colors related tests', () => { }); it('should work with the "stats" option and --color flags', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats=verbose', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--color']); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-string.webpack.config.js'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-string.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #1', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=stats-boolean.webpack.config.js'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-boolean.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #2', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=no-stats.webpack.config.js'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=no-stats.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'test' starting..."); + expect(stderr).toContain("Compilation 'test' finished"); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #3', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-true.webpack.config.js']); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #4', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-false.webpack.config.js']); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); expect(exitCode).toBe(0); }); it('should prioritize --color over colors in config', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-false.webpack.config.js', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-false.webpack.config.js', '--color']); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(exitCode).toBe(0); }); it('should prioratize --no-color over colors in config', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=colors-true.webpack.config.js', '--no-color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-true.webpack.config.js', '--no-color']); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); expect(exitCode).toBe(0); }); it('should work in multicompiler mode', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config=multiple-configs.js', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=multiple-configs.js', '--color']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'first-config' starting..."); + expect(stderr).toContain("Compilation 'first-config' finished"); + expect(stderr).toContain("Compilation 'second-config' starting..."); + expect(stderr).toContain("Compilation 'second-config' finished"); if (isWebpack5) { expect(stdout).toContain(`\u001b[1mfirst-config`); diff --git a/test/config-format/coffee/coffee.test.js b/test/config-format/coffee/coffee.test.js index ccb8b46cd16..e0ab6310dfc 100644 --- a/test/config-format/coffee/coffee.test.js +++ b/test/config-format/coffee/coffee.test.js @@ -1,24 +1,22 @@ // eslint-disable-next-line node/no-unpublished-require const { run } = require('../../utils/test-utils'); -const { existsSync } = require('fs'); -const { resolve } = require('path'); describe('webpack cli', () => { it('should support coffeescript file as flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', 'webpack.config.coffee'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); it('should load coffeescript file by default', () => { - const { stderr, stdout, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-format/commonjs/commonjs.test.js b/test/config-format/commonjs/commonjs.test.js index 0a60b8ffd02..73a9232f94a 100644 --- a/test/config-format/commonjs/commonjs.test.js +++ b/test/config-format/commonjs/commonjs.test.js @@ -1,14 +1,12 @@ const { run } = require('../../utils/test-utils'); -const { existsSync } = require('fs'); -const { resolve } = require('path'); describe('webpack cli', () => { it('should support CommonJS file', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', 'webpack.config.cjs'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.cjs'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-format/typescript/typescript.test.js b/test/config-format/typescript/typescript.test.js index e7f7bcfd696..61e3945d134 100644 --- a/test/config-format/typescript/typescript.test.js +++ b/test/config-format/typescript/typescript.test.js @@ -8,7 +8,7 @@ describe('webpack cli', () => { 'should support typescript file', async () => { await runInstall(__dirname); - const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.config.ts']); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); diff --git a/test/config-lookup/custom-name/custom-name.test.js b/test/config-lookup/custom-name/custom-name.test.js index 66ecfe8a93a..06e57a4bdf7 100644 --- a/test/config-lookup/custom-name/custom-name.test.js +++ b/test/config-lookup/custom-name/custom-name.test.js @@ -1,14 +1,15 @@ 'use strict'; -const { existsSync } = require('fs'); + const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('custom config file', () => { it('should work', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'config.webpack.js')], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'config.webpack.js')], false); + expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, './binary/a.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-lookup/dotfolder-array/dotfolder-array.test.js b/test/config-lookup/dotfolder-array/dotfolder-array.test.js index e2c305e9b4d..face65c4450 100644 --- a/test/config-lookup/dotfolder-array/dotfolder-array.test.js +++ b/test/config-lookup/dotfolder-array/dotfolder-array.test.js @@ -1,24 +1,16 @@ 'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); + const { run } = require('../../utils/test-utils'); describe('dotfolder array config lookup', () => { - it('should find a webpack array configuration in a dotfolder', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + it('should find a webpack array configuration in a dotfolder', () => { + const { exitCode, stderr, stdout } = run(__dirname, [], false); - expect(stderr).not.toBeUndefined(); - expect(stdout).not.toBeUndefined(); expect(exitCode).toBe(0); - - stat(resolve(__dirname, './dist/dist-commonjs.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - stat(resolve(__dirname, './dist/dist-amd.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toContain("Compilation 'commonjs' starting..."); + expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-lookup/dotfolder-single/dotfolder-single.test.js b/test/config-lookup/dotfolder-single/dotfolder-single.test.js index ee09ec2899f..ae62b1dd94f 100644 --- a/test/config-lookup/dotfolder-single/dotfolder-single.test.js +++ b/test/config-lookup/dotfolder-single/dotfolder-single.test.js @@ -1,23 +1,15 @@ 'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); - const { run } = require('../../utils/test-utils'); describe('dotfolder single config lookup', () => { - it('should find a webpack configuration in a dotfolder', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + it('should find a webpack configuration in a dotfolder', () => { + const { exitCode, stderr, stdout } = run(__dirname, [], false); - expect(stderr).not.toBeUndefined(); - expect(stdout).not.toBeUndefined(); expect(exitCode).toBe(0); - + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).not.toContain('Module not found'); - stat(resolve(__dirname, './dist/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-lookup/relative/basic-config.test.js b/test/config-lookup/relative/basic-config.test.js index ad568ba330d..723a904373f 100644 --- a/test/config-lookup/relative/basic-config.test.js +++ b/test/config-lookup/relative/basic-config.test.js @@ -1,22 +1,23 @@ 'use strict'; -const { existsSync } = require('fs'); -const { resolve } = require('path'); + const { run } = require('../../utils/test-utils'); describe('relative path to config', () => { it('should work', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', 'webpack.config.js', '--output-path', './binary/a'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.js', '--output-path', './binary/a'], false); + expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, './binary/a/a.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); it('should work #2', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js', '--output-path', './binary/b'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--output-path', './binary/b'], false); + expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, './binary/b/a.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-name/config-name.test.js b/test/config-name/config-name.test.js index 7f800ffdfd8..fa0cd7a554c 100644 --- a/test/config-name/config-name.test.js +++ b/test/config-name/config-name.test.js @@ -7,7 +7,8 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first'], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -17,21 +18,27 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'third' starting..."); + expect(stderr).toContain("Compilation 'third' finished"); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); }); it('should work with multiple values for --config-name and multiple configurations', () => { - const { stderr, stdout, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['-c', './function-config.js', '-c', './single-other-config.js', '--config-name', 'first', '--config-name', 'four'], false, ); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'four' starting..."); + expect(stderr).toContain("Compilation 'four' finished"); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -42,6 +49,8 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test'], false); expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the "test" name was not found.'); expect(stdout).toBeFalsy(); }); @@ -50,6 +59,8 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test', '-c', 'single-config.js'], false); expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the "test" name was not found.'); expect(stdout).toBeFalsy(); }); @@ -62,6 +73,8 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the "test" name was not found.'); expect(stderr).toContain('Configuration with the "bar" name was not found.'); expect(stdout).toBeFalsy(); @@ -75,6 +88,8 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).not.toContain('Configuration with the "first" name was not found.'); expect(stderr).toContain('Configuration with the "bar" name was not found.'); expect(stdout).toBeFalsy(); @@ -84,7 +99,8 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'first'], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -98,7 +114,10 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'third' starting..."); + expect(stderr).toContain("Compilation 'third' finished"); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); @@ -108,6 +127,8 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'test'], false); expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the "test" name was not found.'); expect(stdout).toBeFalsy(); }); diff --git a/test/config/absent/config-absent.test.js b/test/config/absent/config-absent.test.js index 6990cdd1c04..7cfbe24a490 100644 --- a/test/config/absent/config-absent.test.js +++ b/test/config/absent/config-absent.test.js @@ -1,18 +1,18 @@ 'use strict'; -const { existsSync } = require('fs'); + const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('Config:', () => { it('supplied config file is absent', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + // should throw with correct exit code expect(exitCode).toBe(2); - expect(stdout).toBeFalsy(); - const configPath = resolve(__dirname, 'webpack.config.js'); // Should contain the correct error message - expect(stderr).toContain(`The specified config file doesn't exist in '${configPath}'`); - // Should not bundle - expect(existsSync(resolve(__dirname, './binary/a.bundle.js'))).toBeFalsy(); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toContain(`The specified config file doesn't exist in '${resolve(__dirname, 'webpack.config.js')}'`); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/config/basic/basic-config.test.js b/test/config/basic/basic-config.test.js index 6372c65afa9..fa061bbdbb3 100644 --- a/test/config/basic/basic-config.test.js +++ b/test/config/basic/basic-config.test.js @@ -1,18 +1,18 @@ 'use strict'; -const { existsSync } = require('fs'); + const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('basic config file', () => { it('is able to understand and parse a very basic configuration file', () => { - const { stdout, stderr, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'], false, ); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, './binary/a.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/defaults/basic-config/default-js-config.test.js b/test/config/defaults/basic-config/default-js-config.test.js index c01f5b54b52..95e875c044b 100644 --- a/test/config/defaults/basic-config/default-js-config.test.js +++ b/test/config/defaults/basic-config/default-js-config.test.js @@ -4,21 +4,25 @@ const { run, isWebpack5 } = require('../../../utils/test-utils'); describe('Zero Config', () => { it('runs when config is present but not supplied via flag', () => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); + + expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + // default entry should be used expect(stdout).toContain('./src/index.js'); // should pick up the output path from config expect(stdout).toContain('test-output'); + if (!isWebpack5) { expect(stdout).toContain('Hash'); expect(stdout).toContain('Version'); expect(stdout).toContain('Built at'); expect(stdout).toContain('Time'); } - // Should return the correct exit code - expect(exitCode).toEqual(0); + // check that the output file exists expect(fs.existsSync(path.join(__dirname, '/dist/test-output.js'))).toBeTruthy(); - expect(stderr).toBeFalsy(); }); }); diff --git a/test/config/defaults/cjs-config/default-cjs-config.test.js b/test/config/defaults/cjs-config/default-cjs-config.test.js index 81e4077347c..6e52b89d3ab 100644 --- a/test/config/defaults/cjs-config/default-cjs-config.test.js +++ b/test/config/defaults/cjs-config/default-cjs-config.test.js @@ -4,21 +4,24 @@ const { run, isWebpack5 } = require('../../../utils/test-utils'); describe('Default Config:', () => { it('Should be able to pick cjs config by default', () => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); + + expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // default entry should be used expect(stdout).toContain('./src/index.js'); // should pick up the output path from config expect(stdout).toContain('test-output'); + if (!isWebpack5) { expect(stdout).toContain('Hash'); expect(stdout).toContain('Version'); expect(stdout).toContain('Built at'); expect(stdout).toContain('Time'); } - // Should return the correct exit code - expect(exitCode).toEqual(0); + // check that the output file exists expect(fs.existsSync(path.join(__dirname, '/dist/test-output.js'))).toBeTruthy(); - expect(stderr).toBeFalsy(); }); }); diff --git a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js index a366a0165a9..5b08b1a5b42 100644 --- a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js +++ b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js @@ -5,10 +5,13 @@ const { run } = require('../../../utils/test-utils'); describe('multiple dev config files with webpack.config.js', () => { it('Uses webpack.config.development.js', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); - expect(stderr).toBeFalsy(); + const { exitCode, stderr, stdout } = run(__dirname, [], false); + expect(exitCode).toEqual(0); - expect(stdout).not.toBe(undefined); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, './binary/dev.folder.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js index 6c2a8778bbd..33537daffb7 100644 --- a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js +++ b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js @@ -5,10 +5,13 @@ const { run } = require('../../../utils/test-utils'); describe('multiple config files', () => { it('Uses dev config when both dev and none are present', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); - expect(stderr).toBeFalsy(); + const { exitCode, stderr, stdout } = run(__dirname, [], false); + expect(exitCode).toEqual(0); - expect(stdout).not.toBe(undefined); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, './binary/dev.bundle.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/defaults/with-mode/multiple-config.test.js b/test/config/defaults/with-mode/multiple-config.test.js index 75c1ce693a7..43ebe7e0cb4 100644 --- a/test/config/defaults/with-mode/multiple-config.test.js +++ b/test/config/defaults/with-mode/multiple-config.test.js @@ -5,10 +5,13 @@ const { run } = require('../../../utils/test-utils'); describe('multiple config files', () => { it('Uses dev config when development mode is supplied', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'development'], false); - expect(stderr).toBeFalsy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); + expect(exitCode).toEqual(0); - expect(stdout).not.toBe(undefined); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, './binary/dev.bundle.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/empty-array/empty-array.test.js b/test/config/empty-array/empty-array.test.js index 0c34474487d..a466a1c108b 100644 --- a/test/config/empty-array/empty-array.test.js +++ b/test/config/empty-array/empty-array.test.js @@ -4,9 +4,11 @@ const { run } = require('../../utils/test-utils'); describe('config flag with empty config file', () => { it('should throw error with no configuration or index file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty-function/empty-function.test.js b/test/config/empty-function/empty-function.test.js index 0c34474487d..a466a1c108b 100644 --- a/test/config/empty-function/empty-function.test.js +++ b/test/config/empty-function/empty-function.test.js @@ -4,9 +4,11 @@ const { run } = require('../../utils/test-utils'); describe('config flag with empty config file', () => { it('should throw error with no configuration or index file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty-promise/empty-promise.test.js b/test/config/empty-promise/empty-promise.test.js index 0c34474487d..a466a1c108b 100644 --- a/test/config/empty-promise/empty-promise.test.js +++ b/test/config/empty-promise/empty-promise.test.js @@ -4,9 +4,11 @@ const { run } = require('../../utils/test-utils'); describe('config flag with empty config file', () => { it('should throw error with no configuration or index file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty/empty.test.js b/test/config/empty/empty.test.js index 0c34474487d..a466a1c108b 100644 --- a/test/config/empty/empty.test.js +++ b/test/config/empty/empty.test.js @@ -4,9 +4,11 @@ const { run } = require('../../utils/test-utils'); describe('config flag with empty config file', () => { it('should throw error with no configuration or index file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/error/config-error.test.js b/test/config/error/config-error.test.js index d11e29e29a7..e0adeeb31d9 100644 --- a/test/config/error/config-error.test.js +++ b/test/config/error/config-error.test.js @@ -4,17 +4,19 @@ const { run } = require('../../utils/test-utils'); describe('config error', () => { it('should throw error with invalid configuration', () => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + expect(exitCode).toBe(2); expect(stderr).toContain('Invalid configuration object'); expect(stderr).toContain(`"development" | "production" | "none"`); - expect(exitCode).toBe(2); + expect(stdout).toBeFalsy(); }); it('should throw syntax error and exit with non-zero exit code', () => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.js')]); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.js')]); - expect(stderr).toContain('SyntaxError: Unexpected token'); expect(exitCode).toBe(2); + expect(stderr).toContain('SyntaxError: Unexpected token'); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/config/function/functional-config.test.js b/test/config/function/functional-config.test.js index ccc79d6aec1..19b55870c1a 100644 --- a/test/config/function/functional-config.test.js +++ b/test/config/function/functional-config.test.js @@ -1,40 +1,27 @@ 'use strict'; + const { resolve } = require('path'); -const { stat } = require('fs'); const { run } = require('../../utils/test-utils'); describe('functional config', () => { - it('should work as expected in case of single config', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'single-webpack.config.js')]); + it('should work as expected in case of single config', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'single-webpack.config.js')]); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('./src/index.js'); expect(exitCode).toBe(0); - - stat(resolve(__dirname, './bin/dist-single.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stderr).toContain("Compilation 'single' starting..."); + expect(stderr).toContain("Compilation 'single' finished"); + expect(stdout).toContain('./src/index.js'); }); - it('should work as expected in case of multiple config', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'multi-webpack.config.js')]); + it('should work as expected in case of multiple config', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'multi-webpack.config.js')]); - expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'second' starting..."); + expect(stderr).toContain("Compilation 'second' finished"); expect(stdout).toContain('first'); expect(stdout).toContain('second'); - expect(exitCode).toBe(0); - - stat(resolve(__dirname, './bin/dist-first.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - stat(resolve(__dirname, './bin/dist-second.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); }); }); diff --git a/test/config/invalid-export/invalid-export.test.js b/test/config/invalid-export/invalid-export.test.js index e4dc82b1c18..7d081411006 100644 --- a/test/config/invalid-export/invalid-export.test.js +++ b/test/config/invalid-export/invalid-export.test.js @@ -5,6 +5,7 @@ const { run } = require('../../utils/test-utils'); describe('invalid export', () => { it('should throw error with no configuration or index file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); + expect(exitCode).toBe(2); expect(stderr).toContain(`Invalid configuration in '${resolve(__dirname, 'webpack.config.js')}'`); expect(stdout).toBeFalsy(); diff --git a/test/config/invalid-path/invalid-path.test.js b/test/config/invalid-path/invalid-path.test.js index 6600899ef06..b571740a71f 100644 --- a/test/config/invalid-path/invalid-path.test.js +++ b/test/config/invalid-path/invalid-path.test.js @@ -4,7 +4,8 @@ const { run } = require('../../utils/test-utils'); describe('basic config file', () => { it('is able to understand and parse a very basic configuration file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'invalid-webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'invalid-webpack.config.js')], false); + expect(exitCode).toBe(2); expect(stderr).toContain(`The specified config file doesn't exist in '${resolve(__dirname, 'invalid-webpack.config.js')}'`); expect(stdout).toBeFalsy(); diff --git a/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js index 6372c65afa9..fa061bbdbb3 100644 --- a/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js +++ b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js @@ -1,18 +1,18 @@ 'use strict'; -const { existsSync } = require('fs'); + const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('basic config file', () => { it('is able to understand and parse a very basic configuration file', () => { - const { stdout, stderr, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'], false, ); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, './binary/a.bundle.js'))).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/multiple/multiple-config.test.js b/test/config/multiple/multiple-config.test.js index f29651bf8ef..097a99d9b48 100644 --- a/test/config/multiple/multiple-config.test.js +++ b/test/config/multiple/multiple-config.test.js @@ -1,20 +1,19 @@ -const { existsSync } = require('fs'); -const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('Multiple config flag: ', () => { it('spawns multiple compilers for multiple configs', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', 'webpack1.config.js', '-c', 'webpack2.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack1.config.js', '-c', 'webpack2.config.js'], false); + // Should contain the correct exit code expect(exitCode).toEqual(0); + + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toContain("Compilation 'commonjs' starting..."); + expect(stderr).toContain("Compilation 'commonjs' finished"); + // Should spawn multiple compilers expect(stdout).toContain('amd:'); expect(stdout).toContain('commonjs:'); - - expect(stderr).toBeFalsy(); - - // should generate the correct output files - expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); }); }); diff --git a/test/config/no-config-array/no-config-array.test.js b/test/config/no-config-array/no-config-array.test.js index ee5b81b9627..79fad1ae71e 100644 --- a/test/config/no-config-array/no-config-array.test.js +++ b/test/config/no-config-array/no-config-array.test.js @@ -5,7 +5,7 @@ const { run } = require('../../utils/test-utils'); describe('no configs in array', () => { it('is able to understand and parse a very basic configuration file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); diff --git a/test/config/no-config-object/no-config-object.test.js b/test/config/no-config-object/no-config-object.test.js index dad17223896..ba6cdfd4ab3 100644 --- a/test/config/no-config-object/no-config-object.test.js +++ b/test/config/no-config-object/no-config-object.test.js @@ -5,13 +5,15 @@ const { run } = require('../../utils/test-utils'); describe('empty config', () => { it('should work', () => { - const { stdout, stderr, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--mode', 'development'], false, ); + expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/type/array-function-with-argv/function-with-argv.test.js b/test/config/type/array-function-with-argv/function-with-argv.test.js index 1685a9a110c..82077a230a5 100644 --- a/test/config/type/array-function-with-argv/function-with-argv.test.js +++ b/test/config/type/array-function-with-argv/function-with-argv.test.js @@ -1,15 +1,28 @@ 'use strict'; -const { existsSync } = require('fs'); +const { stat } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('array of function with args', () => { - it('is able to understand a configuration file as a function', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'development'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + it('is able to understand a configuration file as a function', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); + expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, './dist/a-dev.js'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/b-dev.js'))).toBeTruthy(); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'second' starting..."); + expect(stderr).toContain("Compilation 'second' finished"); + expect(stdout).toBeTruthy(); + + stat(resolve(__dirname, './dist/a-dev.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + }); + + stat(resolve(__dirname, './dist/b-dev.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); }); }); diff --git a/test/config/type/array-function-with-argv/webpack.config.js b/test/config/type/array-function-with-argv/webpack.config.js index 2ced6f132a5..8c3b60bfde5 100644 --- a/test/config/type/array-function-with-argv/webpack.config.js +++ b/test/config/type/array-function-with-argv/webpack.config.js @@ -4,6 +4,7 @@ module.exports = [ const { mode } = argv; return { entry: './a.js', + name: 'first', output: { filename: mode === 'production' ? 'a-prod.js' : 'a-dev.js', }, @@ -14,6 +15,7 @@ module.exports = [ const { mode } = argv; return { entry: './b.js', + name: 'second', output: { filename: mode === 'production' ? 'b-prod.js' : 'b-dev.js', }, diff --git a/test/config/type/array-function-with-env/array-function-with-env.test.js b/test/config/type/array-function-with-env/array-function-with-env.test.js index c51cef8e060..5f1621b9c98 100644 --- a/test/config/type/array-function-with-env/array-function-with-env.test.js +++ b/test/config/type/array-function-with-env/array-function-with-env.test.js @@ -1,17 +1,28 @@ 'use strict'; -const { existsSync } = require('fs'); +const { stat } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('array of functions with env', () => { - it('is able to understand a configuration file as a function', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'development'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + it('is able to understand a configuration file as a function', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'second' starting..."); + expect(stderr).toContain("Compilation 'second' finished"); + expect(stdout).toBeTruthy(); + + stat(resolve(__dirname, './dist/a-dev.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + }); - // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './dist/a-dev.js'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/b-dev.js'))).toBeTruthy(); + stat(resolve(__dirname, './dist/b-dev.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); }); }); diff --git a/test/config/type/array-function-with-env/webpack.config.js b/test/config/type/array-function-with-env/webpack.config.js index 2ced6f132a5..8c3b60bfde5 100644 --- a/test/config/type/array-function-with-env/webpack.config.js +++ b/test/config/type/array-function-with-env/webpack.config.js @@ -4,6 +4,7 @@ module.exports = [ const { mode } = argv; return { entry: './a.js', + name: 'first', output: { filename: mode === 'production' ? 'a-prod.js' : 'a-dev.js', }, @@ -14,6 +15,7 @@ module.exports = [ const { mode } = argv; return { entry: './b.js', + name: 'second', output: { filename: mode === 'production' ? 'b-prod.js' : 'b-dev.js', }, diff --git a/test/config/type/array-functions/array-functions.test.js b/test/config/type/array-functions/array-functions.test.js index 920852f4aa0..fd584ec597f 100644 --- a/test/config/type/array-functions/array-functions.test.js +++ b/test/config/type/array-functions/array-functions.test.js @@ -5,10 +5,14 @@ const { run } = require('../../../utils/test-utils'); describe('array of functions', () => { it('is able to understand a configuration file as a function', (done) => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'second' starting..."); + expect(stderr).toContain("Compilation 'second' finished"); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './binary/a-functor.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/array-functions/webpack.config.js b/test/config/type/array-functions/webpack.config.js index a10065bb402..2d60cddbafb 100644 --- a/test/config/type/array-functions/webpack.config.js +++ b/test/config/type/array-functions/webpack.config.js @@ -2,6 +2,7 @@ module.exports = [ () => { return { entry: './a', + name: 'first', output: { path: __dirname + '/binary', filename: 'a-functor.js', @@ -11,6 +12,7 @@ module.exports = [ () => { return { entry: './b', + name: 'second', output: { path: __dirname + '/binary', filename: 'b-functor.js', diff --git a/test/config/type/array-promises/array-promises.test.js b/test/config/type/array-promises/array-promises.test.js index b9527b1f2e2..798086428b4 100644 --- a/test/config/type/array-promises/array-promises.test.js +++ b/test/config/type/array-promises/array-promises.test.js @@ -5,11 +5,14 @@ const { run } = require('../../../utils/test-utils'); describe('array of promises', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); - expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'second' starting..."); + expect(stderr).toContain("Compilation 'second' finished"); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './binary/a-promise.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/array-promises/webpack.config.js b/test/config/type/array-promises/webpack.config.js index 8d7498a200f..9456d7a6bbd 100644 --- a/test/config/type/array-promises/webpack.config.js +++ b/test/config/type/array-promises/webpack.config.js @@ -3,6 +3,7 @@ module.exports = [ setTimeout(() => { resolve({ entry: './a', + name: 'first', output: { path: __dirname + '/binary', filename: 'a-promise.js', @@ -14,6 +15,7 @@ module.exports = [ setTimeout(() => { resolve({ entry: './b', + name: 'second', output: { path: __dirname + '/binary', filename: 'b-promise.js', diff --git a/test/config/type/array/array.test.js b/test/config/type/array/array.test.js index 6fa581f100d..6d7392493f2 100644 --- a/test/config/type/array/array.test.js +++ b/test/config/type/array/array.test.js @@ -5,11 +5,15 @@ const { run } = require('../../../utils/test-utils'); describe('array', () => { it('is able to understand a configuration file in array format', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toContain("Compilation 'commonjs' starting..."); + expect(stderr).toContain("Compilation 'commonjs' finished"); expect(stdout).toBeTruthy(); + stat(resolve(__dirname, './dist/dist-commonjs.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/type/function-array/function-array.test.js b/test/config/type/function-array/function-array.test.js index c7312b734e5..22ab749ceb7 100644 --- a/test/config/type/function-array/function-array.test.js +++ b/test/config/type/function-array/function-array.test.js @@ -5,10 +5,14 @@ const { run } = require('../../../utils/test-utils'); describe('function array', () => { it('is able to understand a configuration file as a function', (done) => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'first' starting..."); + expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toContain("Compilation 'second' starting..."); + expect(stderr).toContain("Compilation 'second' finished"); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './binary/a-functor.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/function-array/webpack.config.js b/test/config/type/function-array/webpack.config.js index 5bd0287a4bb..8e46701080a 100644 --- a/test/config/type/function-array/webpack.config.js +++ b/test/config/type/function-array/webpack.config.js @@ -1,6 +1,7 @@ module.exports = () => [ { entry: './a', + name: 'first', output: { path: __dirname + '/binary', filename: 'a-functor.js', @@ -8,6 +9,7 @@ module.exports = () => [ }, { entry: './b', + name: 'second', output: { path: __dirname + '/binary', filename: 'b-functor.js', diff --git a/test/config/type/function-async/function-async.test.js b/test/config/type/function-async/function-async.test.js index 3b8fa277d98..af7e99bf71d 100644 --- a/test/config/type/function-async/function-async.test.js +++ b/test/config/type/function-async/function-async.test.js @@ -5,10 +5,12 @@ const { run } = require('../../../utils/test-utils'); describe('function async', () => { it('is able to understand a configuration file as a function', (done) => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './binary/functor.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/function-promise/function-promise.test.js b/test/config/type/function-promise/function-promise.test.js index ba42b3c57e5..bbd4887a9f9 100644 --- a/test/config/type/function-promise/function-promise.test.js +++ b/test/config/type/function-promise/function-promise.test.js @@ -5,10 +5,12 @@ const { run } = require('../../../utils/test-utils'); describe('function promise', () => { it('is able to understand a configuration file as a function', (done) => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './binary/functor.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index efbb0e2b33c..35b6c34527c 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -1,16 +1,22 @@ 'use strict'; -const { existsSync } = require('fs'); +const { stat } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('function configuration', () => { - it('is able to understand a configuration file as a function', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'development'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + it('is able to understand a configuration file as a function', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); expect(stdout).toContain("argv: { mode: 'development' }"); - // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './dist/dev.js'))).toBeTruthy(); + + stat(resolve(__dirname, './dist/dev.js'), (err, stats) => { + expect(err).toBe(null); + expect(stats.isFile()).toBe(true); + done(); + }); }); }); diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index 491d85fa9c3..1fb719b1b05 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -5,30 +5,38 @@ const { run } = require('../../../utils/test-utils'); describe('function configuration', () => { it('should throw when env is not supplied', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--env'], false); - expect(stdout).toBeFalsy(); - expect(stderr).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--env'], false); + + // TODO Bug, need to fix + expect(exitCode).toBe(1); expect(stderr).toContain(`option '--env ' argument missing`); - expect(exitCode).toEqual(1); + expect(stdout).toBeFalsy(); }); + it('is able to understand a configuration file as a function', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'isProd']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isProd']); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/prod.js'))).toBeTruthy(); }); + it('is able to understand a configuration file as a function', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'isDev']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isDev']); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/dev.js'))).toBeTruthy(); }); + it('Supports passing string in env', () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ '--env', 'environment=production', '--env', @@ -36,14 +44,17 @@ describe('function configuration', () => { '-c', 'webpack.env.config.js', ]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Luffy.js'))).toBeTruthy(); }); + it('Supports long nested values in env', () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ '--env', 'file.name.is.this=Atsumu', '--env', @@ -51,14 +62,17 @@ describe('function configuration', () => { '-c', 'webpack.env.config.js', ]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Atsumu.js'))).toBeTruthy(); }); + it('Supports multiple equal in a string', () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ '--env', 'file=name=is=Eren', '--env', @@ -66,14 +80,17 @@ describe('function configuration', () => { '-c', 'webpack.env.config.js', ]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/name=is=Eren.js'))).toBeTruthy(); }); + it('Supports dot at the end', () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ '--env', 'name.=Hisoka', '--env', @@ -81,27 +98,36 @@ describe('function configuration', () => { '-c', 'webpack.env.config.js', ]); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Hisoka.js'))).toBeTruthy(); }); + it('Supports dot at the end', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'name.', '--env', 'environment=dot', '-c', 'webpack.env.config.js']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'name.', '--env', 'environment=dot', '-c', 'webpack.env.config.js']); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/true.js'))).toBeTruthy(); }); + it('is able to understand multiple env flags', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--env', 'isDev', '--env', 'verboseStats', '--env', 'envMessage']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isDev', '--env', 'verboseStats', '--env', 'envMessage']); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); // check that the verbose env is respected expect(stdout).toContain('LOG from webpack'); + // check if the values from DefinePlugin make it to the compiled code readFile(resolve(__dirname, './bin/dev.js'), 'utf-8', (err, data) => { expect(err).toBe(null); diff --git a/test/config/type/function/function.test.js b/test/config/type/function/function.test.js index 8c782889fbf..44908c8882c 100644 --- a/test/config/type/function/function.test.js +++ b/test/config/type/function/function.test.js @@ -5,11 +5,13 @@ const { run } = require('../../../utils/test-utils'); describe('function', () => { it('is able to understand a configuration file as a function', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, './binary/functor.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/type/promise-array/promise-array.test.js b/test/config/type/promise-array/promise-array.test.js index e83d7875038..25f76a66e52 100644 --- a/test/config/type/promise-array/promise-array.test.js +++ b/test/config/type/promise-array/promise-array.test.js @@ -5,11 +5,12 @@ const { run } = require('../../../utils/test-utils'); describe('promise array', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); - expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stdout).toBeTruthy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); stat(resolve(__dirname, './binary/a-promise.js'), (err, stats) => { expect(err).toBe(null); diff --git a/test/config/type/promise-function/promise-function.test.js b/test/config/type/promise-function/promise-function.test.js index 2fea09bce8e..e53c9e2b0ad 100644 --- a/test/config/type/promise-function/promise-function.test.js +++ b/test/config/type/promise-function/promise-function.test.js @@ -5,11 +5,13 @@ const { run } = require('../../../utils/test-utils'); describe('promise function', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); - expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, './binary/promise.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/config/type/promise/promise.test.js b/test/config/type/promise/promise.test.js index 20a766f279b..019106ea3ec 100644 --- a/test/config/type/promise/promise.test.js +++ b/test/config/type/promise/promise.test.js @@ -5,11 +5,13 @@ const { run } = require('../../../utils/test-utils'); describe('promise', () => { it('is able to understand a configuration file as a promise', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', './webpack.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); - expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, './binary/promise.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/core-flags/amd-flag.test.js b/test/core-flags/amd-flag.test.js index 67c3df8ce37..2cac616a060 100644 --- a/test/core-flags/amd-flag.test.js +++ b/test/core-flags/amd-flag.test.js @@ -4,10 +4,11 @@ const { run } = require('../utils/test-utils'); describe('--no-amd flag', () => { it('should accept --no-amd', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--no-amd']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-amd']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('amd: false'); }); }); diff --git a/test/core-flags/bail-flag.test.js b/test/core-flags/bail-flag.test.js index 300f2841edb..27a38f18a3d 100644 --- a/test/core-flags/bail-flag.test.js +++ b/test/core-flags/bail-flag.test.js @@ -4,18 +4,20 @@ const { run } = require('../utils/test-utils'); describe('--bail flag', () => { it('should set bail to true', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--bail']); + const { exitCode, stderr, stdout } = run(__dirname, ['--bail']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('bail: true'); }); it('should set bail to false', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--no-bail']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-bail']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('bail: false'); }); }); diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index 562b0c51f5d..dbe2193f7b1 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -14,40 +14,44 @@ describe('cache related flags from core', () => { }); it('should be successful with --cache ', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`type: 'memory'`); }); it('should be successful with --no-cache ', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--no-cache']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-cache']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('cache: false'); }); it('should set cache.type', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`type: 'filesystem'`); }); it('should set cache.cacheDirectory with --cache-cache-directory', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', './test-cache-path']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', './test-cache-path']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('test-cache-path'); }); it('should set cache.cacheLocation with --cache-cache-locations', () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ '--cache-type', 'filesystem', '--cache-cache-location', @@ -55,44 +59,49 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('test-locate-cache'); expect(existsSync(resolve(__dirname, './test-locate-cache'))).toBeTruthy(); }); it('should set cache.hashAlgorithm with --cache-hash-algorithm', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-hash-algorithm', 'sha256']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-hash-algorithm', 'sha256']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`hashAlgorithm: 'sha256'`); }); it('should set cache.name with --cache-name', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-name', 'cli-test']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-name', 'cli-test']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`name: 'cli-test'`); }); it('should set cache.store with --cache-store', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-store', 'pack']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-store', 'pack']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`store: 'pack'`); }); it('should set cache.version with --cache-version', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '--cache-version', '1.1.3']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-version', '1.1.3']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`version: '1.1.3'`); }); @@ -101,7 +110,8 @@ describe('cache related flags from core', () => { let { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); @@ -111,32 +121,36 @@ describe('cache related flags from core', () => { ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js'])); expect(exitCode).toEqual(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('[cached]'); }); it('should assign cache build dependencies correctly when cache type is filesystem in config', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.cache.config.js']); + let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler-cache' starting..."); + expect(stderr).toContain("Compilation 'compiler-cache' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); // Run again to check for cache - const newRun = run(__dirname, ['-c', './webpack.cache.config.js']); + ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js'])); - expect(newRun.exitCode).toBe(0); - expect(newRun.stderr).toBeFalsy(); - expect(newRun.stdout).toContain('[cached]'); + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler-cache' starting..."); + expect(stderr).toContain("Compilation 'compiler-cache' finished"); + expect(stdout).toContain('[cached]'); }); it('should assign cache build dependencies with multiple configs', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${resolve(__dirname, 'webpack.cache.config.js')}'`); @@ -144,20 +158,22 @@ describe('cache related flags from core', () => { }); it('should assign cache build dependencies with default config', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem']); + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); expect(stdout).toContain("type: 'filesystem'"); }); it('should assign cache build dependencies with merged configs', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js', '--merge']); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js', '--merge']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); @@ -168,27 +184,31 @@ describe('cache related flags from core', () => { // Creating a temporary webpack config writeFileSync(resolve(__dirname, './webpack.test.config.js'), 'module.exports = {mode: "development"}'); - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); + let { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).not.toContain('[cached]'); // Running again should use the cache - const newRun = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); + ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js'])); - expect(newRun.exitCode).toBe(0); - expect(newRun.stderr).toBeFalsy(); - expect(newRun.stdout).toContain('[cached]'); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toContain('[cached]'); // Change config to invalidate cache writeFileSync(resolve(__dirname, './webpack.test.config.js'), 'module.exports = {mode: "production"}'); - const newRun2 = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); + ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js'])); unlinkSync(resolve(__dirname, './webpack.test.config.js')); - expect(newRun2.exitCode).toBe(0); - expect(newRun2).not.toContain('[cached]'); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).not.toContain('[cached]'); }); }); diff --git a/test/core-flags/context-flag.test.js b/test/core-flags/context-flag.test.js index f725b129d00..804bc6cd3d7 100644 --- a/test/core-flags/context-flag.test.js +++ b/test/core-flags/context-flag.test.js @@ -5,10 +5,12 @@ const { run, isWindows } = require('../utils/test-utils'); describe('--context flag', () => { it('should allow to set context', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--context', './']); + const { exitCode, stderr, stdout } = run(__dirname, ['--context', './']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); + if (isWindows) { const windowsPath = resolve(__dirname, './').replace(/\\/g, '\\\\'); expect(stdout).toContain(`context: '${windowsPath}'`); @@ -18,10 +20,11 @@ describe('--context flag', () => { }); it('should throw module not found error for invalid context', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--context', '/invalid-context-path']); + const { exitCode, stderr, stdout } = run(__dirname, ['--context', '/invalid-context-path']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(1); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`Module not found: Error: Can't resolve './src/main.js'`); }); }); diff --git a/test/core-flags/dependencies-flag.test.js b/test/core-flags/dependencies-flag.test.js index 5b3ba3244fe..1cc0ff6536b 100644 --- a/test/core-flags/dependencies-flag.test.js +++ b/test/core-flags/dependencies-flag.test.js @@ -4,18 +4,20 @@ const { run } = require('../utils/test-utils'); describe('--dependencies and related flags', () => { it('should allow to set dependencies option', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--dependencies', 'lodash']); + const { exitCode, stderr, stdout } = run(__dirname, ['--dependencies', 'lodash']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`dependencies: [ 'lodash' ]`); }); it('should reset dependencies option', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--dependencies-reset']); + const { exitCode, stderr, stdout } = run(__dirname, ['--dependencies-reset']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('dependencies: []'); }); }); diff --git a/test/core-flags/devtool-flag.test.js b/test/core-flags/devtool-flag.test.js index fa37bc37b43..269396b21a2 100644 --- a/test/core-flags/devtool-flag.test.js +++ b/test/core-flags/devtool-flag.test.js @@ -7,7 +7,8 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'source-map']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`devtool: 'source-map'`); }); @@ -15,7 +16,8 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-devtool']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`devtool: false`); }); @@ -23,6 +25,8 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'invalid']); expect(exitCode).toBe(2); + expect(stderr).not.toContain("Compilation 'compiler' starting..."); + expect(stderr).not.toContain("Compilation 'compiler' finished"); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/entry-reset-flag.test.js b/test/core-flags/entry-reset-flag.test.js index 545d57e6ba6..660c40bf39e 100644 --- a/test/core-flags/entry-reset-flag.test.js +++ b/test/core-flags/entry-reset-flag.test.js @@ -4,19 +4,22 @@ const { run } = require('../utils/test-utils'); describe('--entry-reset flag', () => { it('should reset entry correctly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--entry-reset', '--entry', './src/entry.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry-reset', '--entry', './src/entry.js']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('src/entry.js'); expect(stdout).not.toContain('src/main.js'); }); it('should throw error if entry is an empty array', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--entry-reset']); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry-reset']); - expect(stderr).toContain('Invalid configuration object'); expect(exitCode).toBe(2); + expect(stderr).not.toContain("Compilation 'compiler' starting..."); + expect(stderr).not.toContain("Compilation 'compiler' finished"); + expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); }); diff --git a/test/core-flags/experiments-flag.test.js b/test/core-flags/experiments-flag.test.js index 96b32734256..741463cfedb 100644 --- a/test/core-flags/experiments-flag.test.js +++ b/test/core-flags/experiments-flag.test.js @@ -12,18 +12,20 @@ describe('experiments option related flag', () => { const propName = hyphenToUpperCase(property); it(`should config ${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: true`); }); it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: false`); }); }); diff --git a/test/core-flags/externals-flags.test.js b/test/core-flags/externals-flags.test.js index 295ca4525aa..dd0afaaf86a 100644 --- a/test/core-flags/externals-flags.test.js +++ b/test/core-flags/externals-flags.test.js @@ -7,34 +7,38 @@ const externalsPresetsFlags = flags.filter(({ name }) => name.startsWith('extern describe('externals related flag', () => { it('should set externals properly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--externals', './main.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--externals', './main.js']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`externals: [ './main.js' ]`); }); it('should set externalsType properly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--externals', 'var']); + const { exitCode, stderr, stdout } = run(__dirname, ['--externals', 'var']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`externalsType: 'var'`); }); it('should accept --external-type values', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--externals-type', 'var']); + const { exitCode, stderr, stdout } = run(__dirname, ['--externals-type', 'var']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`externalsType: 'var'`); }); it('should reset externals', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--externals-reset']); + const { exitCode, stderr, stdout } = run(__dirname, ['--externals-reset']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`externals: []`); }); @@ -44,18 +48,20 @@ describe('externals related flag', () => { const propName = hyphenToUpperCase(property); it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: true`); }); it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: false`); }); }); diff --git a/test/core-flags/infrastructure-logging.test.js b/test/core-flags/infrastructure-logging.test.js index 8bebd29d056..f04966f215b 100644 --- a/test/core-flags/infrastructure-logging.test.js +++ b/test/core-flags/infrastructure-logging.test.js @@ -4,26 +4,29 @@ const { run } = require('../utils/test-utils'); describe('infrastructure logging related flag', () => { it('should set infrastructureLogging.debug properly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']); + const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`debug: [ 'myPlugin' ]`); }); it('should reset infrastructureLogging.debug to []', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--infrastructure-logging-debug-reset']); + const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug-reset']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`debug: []`); }); it('should set infrastructureLogging.level properly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--infrastructure-logging-level', 'log']); + const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-level', 'log']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`level: 'log'`); }); }); diff --git a/test/core-flags/invalid-flag.test.js b/test/core-flags/invalid-flag.test.js index da7462a851b..451a3ef6176 100644 --- a/test/core-flags/invalid-flag.test.js +++ b/test/core-flags/invalid-flag.test.js @@ -4,7 +4,7 @@ const { run } = require('../utils/test-utils'); describe('--parallelism flag', () => { it('should set parallelism to the value passed', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--output-script-type', 'unknown']); + const { exitCode, stderr, stdout } = run(__dirname, ['--output-script-type', 'unknown']); expect(exitCode).toBe(2); expect(stderr).toContain("Found the 'invalid-value' problem with the '--output-script-type' argument by path 'output.scriptType'"); diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index d2e813cd92b..b02f3aade81 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -9,41 +9,47 @@ describe('module config related flag', () => { moduleFlags.forEach((flag) => { // extract property name from flag name let property = flag.name.split('module-')[1]; + if (property.includes('rules-') && property !== 'rules-reset') { property = flag.name.split('rules-')[1]; } + const propName = hyphenToUpperCase(property); if (flag.type === Boolean && !flag.name.includes('module-no-parse')) { it(`should config --${flag.name} correctly`, () => { if (flag.name.includes('-reset')) { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); const option = propName.split('Reset')[0]; - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${option}: []`); } else if (flag.name.includes('rules-')) { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("sideEffects: 'flag'"); } else { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: true`); } }); if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); + if (flag.name.includes('rules-')) { expect(stdout).toContain('sideEffects: false'); } else { @@ -58,16 +64,19 @@ describe('module config related flag', () => { let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'value']); if (flag.name === 'module-no-parse') { - expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('value'); } else if (flag.name.includes('reg-exp')) { ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, '/ab?c*/'])); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: /ab?c*/`); } else if (flag.name.includes('module-rules-')) { - ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, 'javascript/auto'])); + ({ stdout } = run(__dirname, [`--${flag.name}`, 'javascript/auto'])); if (propName === 'use' || propName === 'type') { expect(stdout).toContain(`${propName}: 'javascript/auto'`); @@ -82,8 +91,10 @@ describe('module config related flag', () => { expect(stdout).toContain('rules-value'); } } else { - expect(stdout).toContain(`${propName}: 'value'`); expect(exitCode).toBe(0); + expect(stdout).toContain(`${propName}: 'value'`); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); } }); } diff --git a/test/core-flags/node-flags.test.js b/test/core-flags/node-flags.test.js index ac7f060322f..437f0c1d778 100644 --- a/test/core-flags/node-flags.test.js +++ b/test/core-flags/node-flags.test.js @@ -4,26 +4,29 @@ const { run } = require('../utils/test-utils'); describe('node option related flags', () => { it('should config node option to false', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--no-node']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-node']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('node: false'); }); it('should set node.filename correctly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--node-filename', 'mock']); + const { exitCode, stderr, stdout } = run(__dirname, ['--node-filename', 'mock']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`__filename: 'mock'`); }); it('should set node.filename correctly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--node-dirname', 'mock']); + const { exitCode, stderr, stdout } = run(__dirname, ['--node-dirname', 'mock']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`__dirname: 'mock'`); }); }); diff --git a/test/core-flags/optimization-flags.test.js b/test/core-flags/optimization-flags.test.js index 2af3c4b8a57..6e579f40129 100644 --- a/test/core-flags/optimization-flags.test.js +++ b/test/core-flags/optimization-flags.test.js @@ -9,11 +9,13 @@ describe('optimization config related flag', () => { optimizationFlags.forEach((flag) => { // extract property name from flag name let property = flag.name.split('optimization-')[1]; + if (flag.name.includes('split-chunks')) { property = flag.name.split('optimization-split-chunks-')[1]; } let propName = hyphenToUpperCase(property); + if (flag.name.includes('-reset')) { propName = propName.split('Reset')[0]; } @@ -24,29 +26,34 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`splitChunks: false`); } else if (flag.name.includes('reset')) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: []`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: true`); } }); if (!flag.name.includes('reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); + if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain('splitChunks: false'); } else { @@ -64,37 +71,43 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'initial']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`chunks: 'initial'`); } else if (flag.name === 'optimization-mangle-exports') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-mangle-exports', 'size']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`mangleExports: 'size'`); } else if (flag.name === 'optimization-used-exports') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-used-exports', 'global']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`usedExports: 'global'`); } else if (flag.name === 'optimization-split-chunks-default-size-types') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-split-chunks-default-size-types', 'global']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`defaultSizeTypes: [Array]`); } else if (flag.name === 'optimization-side-effects') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-side-effects', 'flag']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'flag'`); } else { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'named']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'named']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'named'`); } }); @@ -102,10 +115,12 @@ describe('optimization config related flag', () => { if (flag.type === Number && !flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); + if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain(`chunks: 'async'`); expect(stdout).toContain(`minChunks: 1`); diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index 88b75211943..a186374f048 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -9,9 +9,11 @@ describe('output config related flag', () => { outputFlags.forEach((flag) => { // extract property name from flag name let property = flag.name.split('output-')[1]; + if (property.includes('environment-')) { property = property.split('environment-')[1]; } + const propName = hyphenToUpperCase(property); if (flag.type === Boolean && !flag.name.includes('output-library')) { @@ -20,26 +22,34 @@ describe('output config related flag', () => { if (flag.name === 'output-module') { //'output.module: true' is only allowed when 'experiments.outputModule' is enabled - ({ stdout, exitCode } = run(__dirname, [`--${flag.name}`, '--experiments-output-module'])); + ({ exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '--experiments-output-module'])); + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('module: true'); } else if (flag.name.includes('-reset')) { const option = propName.split('Reset')[0]; - expect(stderr).toBeFalsy(); + + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${option}: []`); } else { - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: true`); } }); if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: false`); }); } @@ -47,10 +57,11 @@ describe('output config related flag', () => { if (flag.type === Number) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 10`); }); } @@ -61,73 +72,85 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'anonymous']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'anonymous'`); } else if (flag.name === 'output-chunk-format') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'commonjs']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'commonjs'`); } else if (flag.name === 'output-chunk-loading') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'jsonp']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'jsonp'`); } else if (flag.name === 'output-enabled-chunk-loading-types' || flag.name === 'output-enabled-wasm-loading-types') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: [ 'async-node' ]`); } else if (flag.name === 'output-enabled-library-type') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'amd']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'amd'`); } else if (flag.name === 'output-hash-function') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'sha256']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`hashFunction: 'sha256'`); } else if (flag.name === 'output-script-type') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'module']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'module'`); } else if (flag.name === 'output-enabled-library-types') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'var']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: [ 'var' ]`); } else if (flag.name === 'output-path') { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('test'); } else if (flag.name === 'output-worker-chunk-loading') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'async-node'`); } else if (flag.name.includes('wasm')) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'async-node'`); } else { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'test'`); } }); @@ -135,7 +158,7 @@ describe('output config related flag', () => { if (flag.name.includes('output-library')) { it(`should config name, type and export correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ '--output-library-name', 'myLibrary', '--output-library-type', @@ -147,8 +170,9 @@ describe('output config related flag', () => { '--output-library-umd-named-define', ]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('myLibrary'); expect(stdout).toContain(`type: 'var'`); expect(stdout).toContain('export: [Array]'); @@ -157,10 +181,11 @@ describe('output config related flag', () => { }); it('should be succesful with --output-library-reset correctly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--output-library-reset']); + const { exitCode, stderr, stdout } = run(__dirname, ['--output-library-reset']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('name: []'); }); } diff --git a/test/core-flags/parallelism-flag.test.js b/test/core-flags/parallelism-flag.test.js index 7f2a8bcce38..1bf2f1462db 100644 --- a/test/core-flags/parallelism-flag.test.js +++ b/test/core-flags/parallelism-flag.test.js @@ -4,18 +4,21 @@ const { run } = require('../utils/test-utils'); describe('--parallelism flag', () => { it('should set parallelism to the value passed', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--parallelism', '50']); + const { exitCode, stderr, stdout } = run(__dirname, ['--parallelism', '50']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('parallelism: 50'); }); it('should throw error for invalid parallelism value', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--parallelism', '0']); + const { exitCode, stderr, stdout } = run(__dirname, ['--parallelism', '0']); - expect(stderr).toContain('configuration.parallelism should be >= 1'); expect(exitCode).toBe(2); + expect(stderr).not.toContain("Compilation 'compiler' starting..."); + expect(stderr).not.toContain("Compilation 'compiler' finished"); + expect(stderr).toContain('configuration.parallelism should be >= 1'); expect(stdout).toBeFalsy(); }); }); diff --git a/test/core-flags/performance-flags.test.js b/test/core-flags/performance-flags.test.js index 35a3be6799c..bfaf42b2c4d 100644 --- a/test/core-flags/performance-flags.test.js +++ b/test/core-flags/performance-flags.test.js @@ -7,10 +7,11 @@ const performanceFlags = flags.filter(({ name }) => name.startsWith('performance describe('module config related flag', () => { it(`should config --performance option correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-performance`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-performance`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('performance: false'); }); @@ -21,20 +22,22 @@ describe('module config related flag', () => { if (flag.type === Number) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 10`); }); } if (flag.type === String) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'warning']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'warning']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`${propName}: 'warning'`); }); } diff --git a/test/core-flags/profile-flag.test.js b/test/core-flags/profile-flag.test.js index 9be89d464cf..5c702ae77d9 100644 --- a/test/core-flags/profile-flag.test.js +++ b/test/core-flags/profile-flag.test.js @@ -4,18 +4,20 @@ const { run } = require('../utils/test-utils'); describe('--profile flag', () => { it('should set profile to true', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--profile']); + const { exitCode, stderr, stdout } = run(__dirname, ['--profile']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('profile: true'); }); it('should set profile to false', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--no-profile']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-profile']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('profile: false'); }); }); diff --git a/test/core-flags/records-flag.test.js b/test/core-flags/records-flag.test.js index db9b9308da2..831c0d97142 100644 --- a/test/core-flags/records-flag.test.js +++ b/test/core-flags/records-flag.test.js @@ -4,26 +4,29 @@ const { run } = require('../utils/test-utils'); describe('module config related flag', () => { it('should config records-path correctly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--records-path', './bin/records.json']); + const { exitCode, stderr, stdout } = run(__dirname, ['--records-path', './bin/records.json']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('records.json'); }); it('should config records-input-path correctly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--records-input-path', './bin/records.json']); + const { exitCode, stderr, stdout } = run(__dirname, ['--records-input-path', './bin/records.json']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('records.json'); }); it('should config records-output-path correctly', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--records-output-path', './bin/records.json']); + const { exitCode, stderr, stdout } = run(__dirname, ['--records-output-path', './bin/records.json']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('records.json'); }); }); diff --git a/test/core-flags/resolve-flags.test.js b/test/core-flags/resolve-flags.test.js index 71e4337c5ce..719a94e9dbe 100644 --- a/test/core-flags/resolve-flags.test.js +++ b/test/core-flags/resolve-flags.test.js @@ -9,16 +9,21 @@ describe('resolve config related flags', () => { resolveFlags.forEach((flag) => { // extract property name from flag name let property = flag.name.split('resolve-')[1]; + if (flag.name.startsWith('resolve-loader')) { property = flag.name.split('resolve-loader-')[1]; } + const propName = hyphenToUpperCase(property); if (flag.type === Boolean && !flag.name.includes('alias-') && !flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); - expect(stderr).toBeFalsy(); + // expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); + if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; expect(stdout).toContain(`${option}: []`); @@ -30,21 +35,23 @@ describe('resolve config related flags', () => { if (flag.type === String && !flag.name.includes('alias-') && !flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'browser']); + const { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'browser']); + + // expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); - expect(stderr).toBeFalsy(); if (propName === 'restrictions') { expect(stdout).toContain('browser'); } else { expect(stdout).toContain(`${propName}: [ 'browser' ]`); - expect(exitCode).toBe(0); } }); } if (flag.name.includes('alias-') || flag.name.includes('fallback-')) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ `--resolve-alias-alias`, 'alias', '--resolve-alias-name', @@ -67,8 +74,9 @@ describe('resolve config related flags', () => { 'loader-fall-name', ]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`alias: [ { alias: 'alias', name: 'name' } ]`); expect(stdout).toContain(`aliasFields: [ 'aliasField' ]`); expect(stdout).toContain(`alias: [ { alias: 'loaderAlias', name: 'loaderName' } ]`); @@ -81,7 +89,7 @@ describe('resolve config related flags', () => { if (flag.name.includes('reset')) { it(`should config --${flag.name} alias-reset flags correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [ + const { exitCode, stderr, stdout } = run(__dirname, [ '--resolve-alias-reset', '--resolve-fallback-reset', '--resolve-alias-fields-reset', @@ -90,8 +98,9 @@ describe('resolve config related flags', () => { '--resolve-loader-fallback-reset', ]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`alias: []`); expect(stdout).toContain(`aliasFields: []`); expect(stdout).toContain(`fallback: []`); diff --git a/test/core-flags/snapshot-flags.test.js b/test/core-flags/snapshot-flags.test.js index fea4e059d41..15005dd57b8 100644 --- a/test/core-flags/snapshot-flags.test.js +++ b/test/core-flags/snapshot-flags.test.js @@ -13,10 +13,12 @@ describe('snapshot config related flags', () => { if (flag.type === Boolean) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); + if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; expect(stdout).toContain(`${option}: []`); @@ -30,10 +32,11 @@ describe('snapshot config related flags', () => { if (flag.type === String) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'test-snap-path']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test-snap-path']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('test-snap-path'); }); } diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index ebdaeddfa71..39f57c7faf8 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -13,10 +13,11 @@ describe('stats config related flag', () => { if (flag.type === Boolean) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; @@ -28,10 +29,11 @@ describe('stats config related flag', () => { if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`stats: { ${propName}: false }`); }); } @@ -39,10 +41,11 @@ describe('stats config related flag', () => { if (flag.type === Number) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, '10']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`stats: { ${propName}: 10 }`); }); } @@ -52,35 +55,40 @@ describe('stats config related flag', () => { it(`should config --${flag.name} correctly`, () => { if (flag.name.includes('stats-colors')) { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'u001b[32m']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'u001b[32m']); const option = flag.name.split('stats-colors-')[1]; - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`stats: { colors: { ${option}: 'u001b[32m' } }`); } else if (acceptsSingleValue.includes(propName)) { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`stats: { ${propName}: 'log' }`); } else if (flag.name === 'stats-context') { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('log'); } else if (flag.name === 'stats-entrypoints') { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'auto']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'auto']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`stats: { ${propName}: 'auto' }`); } else { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'log']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`stats: { ${propName}: [ 'log' ] }`); } }); diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index 0981dd9ee3d..e1263020b8c 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -13,10 +13,11 @@ describe('watch config related flag', () => { if (flag.type === Boolean && flag.name !== 'watch') { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); if (flag.name.includes('reset')) { expect(stdout).toContain(`watchOptions: { ignored: [] }`); @@ -27,10 +28,11 @@ describe('watch config related flag', () => { if (!flag.name.endsWith('-reset')) { it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout, exitCode } = run(__dirname, [`--no-${flag.name}`]); + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`watchOptions: { ${propName}: false }`); }); } @@ -38,9 +40,11 @@ describe('watch config related flag', () => { if (flag.type === Number) { it(`should config --${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); - expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`watchOptions: { ${propName}: 10 }`); }); } @@ -51,13 +55,15 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '200']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`watchOptions: { ${propName}: 200 }`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'ignore.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain(`watchOptions: { ${propName}: [ 'ignore.js' ] }`); } }); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index d96c9dd4c1d..88f70420a6c 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -5,12 +5,14 @@ const { run } = require('../utils/test-utils'); describe('output flag defaults', () => { it('should create default file for a given directory', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['--entry', './a.js', '--output-path', './binary'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js', '--output-path', './binary'], false); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should print warning about config fallback expect(stdout).toContain('option has not been set, webpack will fallback to'); + stat(resolve(__dirname, './binary/main.js'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); @@ -19,7 +21,12 @@ describe('output flag defaults', () => { }); it('set default output directory on no output flag', (done) => { - run(__dirname, ['--entry', './a.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); stat(resolve(__dirname, './dist/main.js'), (err, stats) => { expect(err).toBe(null); @@ -29,7 +36,10 @@ describe('output flag defaults', () => { }); it('throw error on empty output flag', () => { - const { stderr } = run(__dirname, ['--entry', './a.js', '--output-path'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js', '--output-path'], false); + + expect(exitCode).toBe(1); expect(stderr).toContain("error: option '-o, --output-path ' argument missing"); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/devtool/array/source-map-array.test.js b/test/devtool/array/source-map-array.test.js index 765ace54950..ae9bbabfe41 100644 --- a/test/devtool/array/source-map-array.test.js +++ b/test/devtool/array/source-map-array.test.js @@ -5,11 +5,14 @@ const { run } = require('../../utils/test-utils'); describe('source-map object', () => { it('should treat source-map settings right', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'commonjs' starting..."); + expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'dist'), (err, files) => { expect(err).toBe(null); @@ -18,11 +21,14 @@ describe('source-map object', () => { }); }); it('should override entire array on flag', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--devtool', 'source-map', '--output-path', './binary'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'source-map', '--output-path', './binary'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'commonjs' starting..."); + expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'binary'), (err, files) => { expect(err).toBe(null); diff --git a/test/devtool/object/source-map-object.test.js b/test/devtool/object/source-map-object.test.js index c73ce7b2aa2..0e2c379144d 100644 --- a/test/devtool/object/source-map-object.test.js +++ b/test/devtool/object/source-map-object.test.js @@ -5,11 +5,13 @@ const { run } = require('../../utils/test-utils'); describe('source-map object', () => { it('should not write a source map for obj config', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.eval.config.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.eval.config.js']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stdout).toBeTruthy(); + readdir(resolve(__dirname, 'bin'), (err, files) => { expect(files.length).toBeGreaterThanOrEqual(1); expect(err).toBe(null); @@ -18,11 +20,13 @@ describe('source-map object', () => { }); it('should write a sourcemap file', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', './webpack.source.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.source.config.js'], false); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, 'dist/dist-amd.js.map'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); @@ -31,7 +35,17 @@ describe('source-map object', () => { }); it('should override config with source-map', (done) => { - run(__dirname, ['-c', './webpack.eval.config.js', '--devtool', 'source-map', '-o', './binary'], false); + const { exitCode, stderr, stdout } = run( + __dirname, + ['-c', './webpack.eval.config.js', '--devtool', 'source-map', '-o', './binary'], + false, + ); + + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stdout).toBeTruthy(); + stat(resolve(__dirname, 'binary/dist-amd.js.map'), (err, stats) => { expect(err).toBe(null); expect(stats.isFile()).toBe(true); diff --git a/test/entry/config-entry/entry-with-command/entry-with-command.test.js b/test/entry/config-entry/entry-with-command/entry-with-command.test.js index e8ae1a2c741..dba46409a83 100644 --- a/test/entry/config-entry/entry-with-command/entry-with-command.test.js +++ b/test/entry/config-entry/entry-with-command/entry-with-command.test.js @@ -1,19 +1,14 @@ 'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); + const { run } = require('../../../utils/test-utils'); describe('config entry and command entry all exist', () => { - it('should use command entry if config command existed', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js', './index.js'], false); + it('should use command entry if config command existed', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', '../1.js', './index.js'], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('./index.js'); - stat(resolve(__dirname, './binary/main.bundle.js'), (err, stats) => { - expect(err).toBeFalsy(); - expect(stats.isFile()).toBe(true); - done(); - }); }); }); diff --git a/test/entry/config-entry/entry-with-config/entry-with-config.test.js b/test/entry/config-entry/entry-with-config/entry-with-config.test.js index d25ff38a830..effa0df6daa 100644 --- a/test/entry/config-entry/entry-with-config/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-config/entry-with-config.test.js @@ -1,19 +1,14 @@ 'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); + const { run } = require('../../../utils/test-utils'); describe('default entry and config entry all exist', () => { - it('should use config entry if config entry existed', (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js'], false); + it('should use config entry if config entry existed', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', '../1.js'], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('./a.js'); - stat(resolve(__dirname, './binary/index.bundle.js'), (err, stats) => { - expect(err).toBeFalsy(); - expect(stats.isFile()).toBe(true); - done(); - }); }); }); diff --git a/test/entry/config-entry/entry-with-index/entry-with-config.test.js b/test/entry/config-entry/entry-with-index/entry-with-config.test.js index d83ee8ab6b5..18fe3c879fb 100644 --- a/test/entry/config-entry/entry-with-index/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-index/entry-with-config.test.js @@ -1,14 +1,14 @@ 'use strict'; -const { join } = require('path'); -const { existsSync } = require('fs'); + const { run } = require('../../../utils/test-utils'); describe('default entry and config entry all exist', () => { it('should use config entry if config entry existed', () => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should contain the relevant entry expect(stdout).toContain('./src/app.js'); expect(stdout).toContain('./src/print.js'); @@ -17,11 +17,5 @@ describe('default entry and config entry all exist', () => { expect(stdout).toContain('app.bundle.js'); expect(stdout).toContain('print.bundle.js'); expect(stdout).not.toContain('index.js'); - // Should only generate the files as per the entry in config - expect(existsSync(join(__dirname, '/dist/app.bundle.js'))).toBeTruthy(); - expect(existsSync(join(__dirname, '/dist/print.bundle.js'))).toBeTruthy(); - // index fallback should not be used even when the file is present - expect(existsSync(join(__dirname, '/dist/index.bundle.js'))).toBeFalsy(); - expect(stderr).toBeFalsy(); }); }); diff --git a/test/entry/defaults-empty/entry-single-arg.test.js b/test/entry/defaults-empty/entry-single-arg.test.js index b56c6808074..6218698926d 100644 --- a/test/entry/defaults-empty/entry-single-arg.test.js +++ b/test/entry/defaults-empty/entry-single-arg.test.js @@ -4,10 +4,11 @@ const { run } = require('../../utils/test-utils'); describe('single entry flag empty project', () => { it('sets default entry, compiles but throw missing module error', () => { - const { stdout, stderr, exitCode } = run(__dirname); + const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(1); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`not found: Error: Can't resolve`); }); }); diff --git a/test/entry/defaults-index/entry-multi-args.test.js b/test/entry/defaults-index/entry-multi-args.test.js index 9f900848637..c4b64f094aa 100644 --- a/test/entry/defaults-index/entry-multi-args.test.js +++ b/test/entry/defaults-index/entry-multi-args.test.js @@ -1,32 +1,24 @@ 'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); - const { run } = require('../../utils/test-utils'); describe('single entry flag index present', () => { - it('finds default index file and compiles successfully', (done) => { - const { stderr, stdout, exitCode } = run(__dirname); + it('finds default index file and compiles successfully', () => { + const { exitCode, stderr, stdout } = run(__dirname); - expect(stderr).not.toContain('Module not found'); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stderr).not.toContain('Module not found'); expect(stdout).toBeTruthy(); - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); }); - it('finds default index file, compiles and overrides with flags successfully', (done) => { - const { stderr } = run(__dirname, ['--output-path', 'bin']); - expect(stderr).toBeFalsy(); + it('finds default index file, compiles and overrides with flags successfully', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--output-path', 'bin']); - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index 63798d5281f..5afc6457249 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -5,54 +5,37 @@ const { stat, readFile } = require('fs'); const { resolve } = require('path'); describe('entry flag', () => { - it('should resolve the path to src/index.cjs', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/'], false); + it('should resolve the path to src/index.cjs', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/'], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './dist/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(data).toContain('Kazuya Miyuki'); - done(); - }); }); - it('should load ./src/a.js as entry', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--entry', './src/a.js']); + it('should load ./src/a.js as entry', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/a.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(data).toContain('Hello from a.js'); - done(); - }); }); it('should resolve the path to /src/a.js as ./src/a.js for webpack-5 only', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--entry', '/src/a.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', '/src/a.js']); if (!isWebpack5) { expect(exitCode).toBe(1); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`Module not found: Error: Can't resolve`); done(); } else { expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); stat(resolve(__dirname, './bin/main.js'), (err, stats) => { @@ -69,9 +52,11 @@ describe('entry flag', () => { }); it('should throw error for invalid entry file', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--entry', './src/test.js']); - expect(stdout).toContain("Module not found: Error: Can't resolve"); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/test.js']); + expect(exitCode).toEqual(1); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toContain("Module not found: Error: Can't resolve"); }); }); diff --git a/test/entry/multiple-entries/multi-entries.test.js b/test/entry/multiple-entries/multi-entries.test.js index c0f1bc24d41..c7ed5aa2c13 100644 --- a/test/entry/multiple-entries/multi-entries.test.js +++ b/test/entry/multiple-entries/multi-entries.test.js @@ -6,10 +6,11 @@ const { resolve } = require('path'); describe(' multiple entries', () => { it('should allow multiple entry files', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['./src/a.js', './src/b.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['./src/a.js', './src/b.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); stat(resolve(__dirname, './bin/main.js'), (err, stats) => { @@ -26,10 +27,11 @@ describe(' multiple entries', () => { }); it('should allow multiple entry flags', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--entry', './src/a.js', '--entry', './src/b.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/a.js', '--entry', './src/b.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); stat(resolve(__dirname, './bin/main.js'), (err, stats) => { diff --git a/test/entry/scss/scss.test.js b/test/entry/scss/scss.test.js index 565fb273c10..21ffd3703d5 100644 --- a/test/entry/scss/scss.test.js +++ b/test/entry/scss/scss.test.js @@ -4,7 +4,9 @@ const { run, runInstall } = require('../../utils/test-utils'); describe('entry point', () => { it('should support SCSS files', async () => { await runInstall(__dirname); + const { stdout } = run(__dirname); + expect(stdout).toBeTruthy(); expect(stdout).toContain('home.scss'); expect(stdout).toContain('home.js'); diff --git a/test/env/array/array-env.test.js b/test/env/array/array-env.test.js index 90c3707162d..caf8f7054b9 100644 --- a/test/env/array/array-env.test.js +++ b/test/env/array/array-env.test.js @@ -11,10 +11,11 @@ const prodFile = path.join(__dirname, './bin/prod.js'); describe('env array', () => { it('is able to set two different environments for an array configuration', () => { - const { stderr, stdout, exitCode } = run(__dirname); + const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); if (isWebpack5) { diff --git a/test/env/object/object-env.test.js b/test/env/object/object-env.test.js index 2365e4c3ea8..91b889f461e 100644 --- a/test/env/object/object-env.test.js +++ b/test/env/object/object-env.test.js @@ -8,10 +8,11 @@ const { run, isWebpack5 } = require('../../utils/test-utils'); describe('env object', () => { it('is able to set env for an object', () => { - const { stderr, stdout, exitCode } = run(__dirname); + const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); if (isWebpack5) { diff --git a/test/error/error.test.js b/test/error/error.test.js index de30128d161..de227ce0ec6 100644 --- a/test/error/error.test.js +++ b/test/error/error.test.js @@ -4,11 +4,13 @@ const { run } = require('../utils/test-utils'); describe('error', () => { it('should log error with stacktrace', async () => { - const { stderr, stdout, exitCode } = await run(__dirname); + const { exitCode, stderr, stdout } = await run(__dirname); + expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Error: test'); expect(stderr).toMatch(/at .+ (.+)/); expect(stdout).toBeFalsy(); - expect(exitCode).toBe(2); }); }); diff --git a/test/help/help-commands.test.js b/test/help/help-commands.test.js index 54510f68c60..89beb0bd0b4 100644 --- a/test/help/help-commands.test.js +++ b/test/help/help-commands.test.js @@ -4,7 +4,7 @@ const { run } = require('../utils/test-utils'); describe('commands help', () => { it('log help for subcommands', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['serve', 'help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'help'], false); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -12,7 +12,7 @@ describe('commands help', () => { }); it('log help information with subcommands as an arg', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['help', 'serve'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve'], false); expect(exitCode).toBe(0); expect(stdout).toContain('webpack s | serve'); @@ -20,7 +20,7 @@ describe('commands help', () => { }); it('log error for invalid command with --help flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--help', 'myCommand'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'myCommand'], false); expect(exitCode).toBe(2); expect(stderr).toContain("Invalid command 'myCommand'."); @@ -29,7 +29,7 @@ describe('commands help', () => { }); it('log error for invalid command with help command', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['help', 'myCommand'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'myCommand'], false); expect(exitCode).toBe(2); expect(stderr).toContain("Invalid command 'myCommand'."); @@ -38,7 +38,7 @@ describe('commands help', () => { }); it('log error for multiple commands', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help', 'init', 'info'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'init', 'info'], false); expect(exitCode).toBe(2); expect(stderr).toContain("You provided multiple commands or arguments - command 'init' (alias 'c'), command 'info' (alias 'i')."); diff --git a/test/help/help-flags.test.js b/test/help/help-flags.test.js index 5b463133dfd..9be66b51dda 100644 --- a/test/help/help-flags.test.js +++ b/test/help/help-flags.test.js @@ -4,7 +4,7 @@ const { run } = require('../utils/test-utils'); describe('commands help', () => { it('log error for invalid flag with --help flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--help', '--my-flag'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--my-flag'], false); expect(exitCode).toBe(2); expect(stderr).toContain(`Invalid option '--my-flag'`); @@ -13,7 +13,7 @@ describe('commands help', () => { }); it('log error for invalid flag with help command', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['help', '--my-flag'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--my-flag'], false); expect(exitCode).toBe(2); expect(stderr).toContain(`Invalid option '--my-flag'.`); @@ -22,7 +22,7 @@ describe('commands help', () => { }); it('log flag help with valid flag', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--merge'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--merge'], false); expect(exitCode).toBe(0); expect(stdout).not.toContain('The build tool for modern web applications'); @@ -31,7 +31,7 @@ describe('commands help', () => { }); it('log show help for --mode', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--mode', '--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', '--help'], false); expect(exitCode).toBe(0); expect(stdout).not.toContain('The build tool for modern web applications'); @@ -41,7 +41,7 @@ describe('commands help', () => { }); it('log error for multiple flags', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--entry', '--merge'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--entry', '--merge'], false); expect(exitCode).toBe(2); expect(stderr).toContain( diff --git a/test/help/help-multi-args.test.js b/test/help/help-multi-args.test.js index bddba916b41..07fa8d1b744 100644 --- a/test/help/help-multi-args.test.js +++ b/test/help/help-multi-args.test.js @@ -7,23 +7,23 @@ const helpHeader = 'The build tool for modern web applications'; describe('help cmd with multiple arguments', () => { commands.forEach((cmd) => { it(`shows cmd help with ${cmd.name}`, () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help', `${cmd.name}`], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', `${cmd.name}`], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain(`${cmd.name}`); expect(stdout).toContain(`${cmd.usage}`); expect(stdout).toContain(`${cmd.description}`); - expect(stderr).toHaveLength(0); }); }); it('should output help for --version by taking precedence', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(helpHeader); expect(stdout).toContain('webpack -v, --version'); - expect(stderr).toHaveLength(0); }); }); diff --git a/test/help/help-single-arg.test.js b/test/help/help-single-arg.test.js index a92326eefce..5ca743f87fd 100644 --- a/test/help/help-single-arg.test.js +++ b/test/help/help-single-arg.test.js @@ -6,41 +6,42 @@ const helpHeader = 'The build tool for modern web applications'; describe('single help flag', () => { it('respects --no-color flag', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--no-color'], false); const usage = 'webpack [...options] | '; const example = 'webpack help --flag | '; options.enabled = true; expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(yellow(usage)); expect(stdout).not.toContain(yellow(example)); expect(stdout).toContain(usage); expect(stdout).toContain(example); - expect(stderr).toHaveLength(0); }); it('outputs help info with command syntax', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(helpHeader); - expect(stderr).toHaveLength(0); }); it('outputs help info with dashed syntax', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(helpHeader); - expect(stderr).toHaveLength(0); }); it('creates a readable snapshot', () => { const { stderr } = run(__dirname, ['--help'], false); const serializer = require('jest-serializer-ansi'); + expect.addSnapshotSerializer(serializer); - expect(stderr).toHaveLength(0); + expect(stderr).toBeFalsy(); }); }); diff --git a/test/hot/hot-flag.test.js b/test/hot/hot-flag.test.js index f888c8558dd..9ee1764d6fb 100644 --- a/test/hot/hot-flag.test.js +++ b/test/hot/hot-flag.test.js @@ -5,18 +5,21 @@ const { resolve } = require('path'); describe('--hot flag', () => { it('should be successful when --hot is passed', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--hot']); + const { exitCode, stderr, stdout } = run(__dirname, ['--hot']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); }); it('should warn when --hot and --no-hot both are passed', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--no-hot', '--hot']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot', '--hot']); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain( 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', ); diff --git a/test/info/info-help.test.js b/test/info/info-help.test.js index 46b914de71c..5511133bb4a 100644 --- a/test/info/info-help.test.js +++ b/test/info/info-help.test.js @@ -11,7 +11,7 @@ const descriptionText = 'Outputs information about your system and dependencies' describe('should print help for info command', () => { it('shows usage information on supplying help flag', () => { - const { stdout, stderr, exitCode } = runInfo(['--help'], __dirname); + const { exitCode, stderr, stdout } = runInfo(['--help'], __dirname); expect(exitCode).toBe(0); expect(stdout).toContain(usageText); @@ -20,7 +20,7 @@ describe('should print help for info command', () => { }); it.skip('should work and respect the --no-color flag', () => { - const { stdout, stderr, exitCode } = runInfo(['--help', '--no-color'], __dirname); + const { exitCode, stderr, stdout } = runInfo(['--help', '--no-color'], __dirname); expect(exitCode).toBe(0); expect(stdout).not.toContain(green(usageText)); @@ -29,7 +29,7 @@ describe('should print help for info command', () => { }); it('should output all cli flags', () => { - const { stdout, stderr, exitCode } = runInfo(['--help'], __dirname); + const { exitCode, stderr, stdout } = runInfo(['--help'], __dirname); infoFlags.forEach((flag) => expect(stdout).toContain(`--${flag.name}`)); expect(stderr).toHaveLength(0); diff --git a/test/info/info-output.test.js b/test/info/info-output.test.js index 8742416eae6..715ae9528b3 100644 --- a/test/info/info-output.test.js +++ b/test/info/info-output.test.js @@ -39,7 +39,7 @@ describe('basic info usage', () => { }); it('shows a warning if an invalid value is supplied', () => { - const { stdout, stderr, exitCode } = runInfo(['--output=unknown'], __dirname); + const { exitCode, stderr, stdout } = runInfo(['--output=unknown'], __dirname); expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] ${red(`'unknown' is not a valid value for output`)}`); diff --git a/test/info/info-unknown.test.js b/test/info/info-unknown.test.js index 2cd8f8c7593..2451331bf30 100644 --- a/test/info/info-unknown.test.js +++ b/test/info/info-unknown.test.js @@ -3,7 +3,7 @@ const { runInfo } = require('../utils/test-utils'); describe('should handle unknown args', () => { it('shows an appropriate warning on supplying unknown args', () => { - const { stderr, stdout, exitCode } = runInfo(['--unknown'], __dirname); + const { exitCode, stderr, stdout } = runInfo(['--unknown'], __dirname); expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] ${red('Unknown argument: --unknown')}`); diff --git a/test/invalid-schema/invalid-schema.test.js b/test/invalid-schema/invalid-schema.test.js index 52cd44bebde..e5e42f06b77 100644 --- a/test/invalid-schema/invalid-schema.test.js +++ b/test/invalid-schema/invalid-schema.test.js @@ -6,6 +6,8 @@ describe('invalid schema', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']); expect(exitCode).toEqual(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); @@ -14,6 +16,8 @@ describe('invalid schema', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'Yukihira']); expect(exitCode).toEqual(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); if (isWebpack5) { expect(stderr).toContain("Found the 'invalid-value' problem with the '--mode' argument by path 'mode'"); diff --git a/test/merge/config-absent/merge-config-absent.test.js b/test/merge/config-absent/merge-config-absent.test.js index c595fb7e34c..454d5856747 100644 --- a/test/merge/config-absent/merge-config-absent.test.js +++ b/test/merge/config-absent/merge-config-absent.test.js @@ -1,22 +1,16 @@ 'use strict'; -const fs = require('fs'); -const { join } = require('path'); - const { run } = require('../../utils/test-utils'); describe('merge flag configuration', () => { it('Show warning message when the merge config is absent', () => { // 2.js doesn't exist, let's try merging with it - const { stdout, stderr } = run(__dirname, ['--config', './1.js', '--merge', './2.js'], false); + const { exitCode, stdout, stderr } = run(__dirname, ['--config', './1.js', '--merge', './2.js'], false); + expect(exitCode).toBe(2); // Since the process will exit, nothing on stdout expect(stdout).toBeFalsy(); // Confirm that the user is notified expect(stderr).toContain('At least two configurations are required for merge.'); - // Default config would be used - expect(fs.existsSync(join(__dirname, './dist/merged.js'))).toBeFalsy(); - // Since the process will exit so no compilation will be done - expect(fs.existsSync(join(__dirname, './dist/main.js'))).toBeFalsy(); }); }); diff --git a/test/merge/config/merge-config.test.js b/test/merge/config/merge-config.test.js index cf9afc5f647..55ee4d7a132 100644 --- a/test/merge/config/merge-config.test.js +++ b/test/merge/config/merge-config.test.js @@ -1,29 +1,33 @@ 'use strict'; -const { existsSync } = require('fs'); -const { resolve } = require('path'); - const { run } = require('../../utils/test-utils'); describe('merge flag configuration', () => { it('merges two configurations together', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--config', './1.js', '-c', './2.js', '--merge'], false); - expect(stdout).toContain('option has not been set, webpack will fallback to'); - expect(existsSync(resolve(__dirname, './dist/merged.js'))).toBeTruthy(); - expect(stderr).toBeFalsy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '-c', './2.js', '--merge'], false); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toContain('option has not been set, webpack will fallback to'); }); + it('merges two configurations together with flag alias', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--config', './1.js', '--config', './2.js', '-m'], false); - expect(stdout).toContain('merged.js'); - expect(existsSync(resolve(__dirname, './dist/merged.js'))).toBeTruthy(); - expect(stderr).toBeFalsy(); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--config', './2.js', '-m'], false); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toContain('merged.js'); }); + it('fails when there are less than 2 configurations to merge', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--config', './1.js', '-m'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '-m'], false); + + expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('At least two configurations are required for merge.'); expect(stdout).toBeFalsy(); - expect(exitCode).toBe(2); }); }); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 061595d506b..90e4abb7e02 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -1,49 +1,56 @@ 'use strict'; + const { run, isWebpack5 } = require('../../utils/test-utils'); describe('mode flags', () => { it('should not set mode=production by default', () => { - const { stderr, stdout, exitCode } = run(__dirname); + const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).not.toContain(`mode: 'production'`); expect(stdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); }); it('should load a development config when --mode=development is passed', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'development']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'development'`); }); it('should load a production config when --mode=production is passed', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'production']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'production'`); }); it('should load a none config when --mode=none is passed', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'none']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'none'`); }); it('should pick mode form NODE_ENV', () => { - const { stderr, stdout, exitCode } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); + const { exitCode, stderr, stdout } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); + expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'development'`); }); it('should throw error when --mode=abcd is passed', () => { - const { stderr, exitCode } = run(__dirname, ['--mode', 'abcd']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'abcd']); expect(exitCode).toBe(2); @@ -53,5 +60,7 @@ describe('mode flags', () => { expect(stderr).toContain('configuration.mode should be one of these'); expect(stderr).toContain(`"development" | "production" | "none"`); } + + expect(stdout).toBeFalsy(); }); }); diff --git a/test/mode/mode-with-config/mode-with-config.test.js b/test/mode/mode-with-config/mode-with-config.test.js index 45363bd6e92..0ff605a4386 100644 --- a/test/mode/mode-with-config/mode-with-config.test.js +++ b/test/mode/mode-with-config/mode-with-config.test.js @@ -6,10 +6,11 @@ const { run } = require('../../utils/test-utils'); describe('mode flags with config', () => { it('should run in production mode when --mode=production is passed', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'production', '--config', './webpack.config.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -37,10 +38,11 @@ describe('mode flags with config', () => { }); it('should run in development mode when --mode=development is passed', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'development', '--config', './webpack.config.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -68,10 +70,11 @@ describe('mode flags with config', () => { }); it('should run in none mode when --mode=none is passed', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--mode', 'none', '--config', './webpack.config.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -99,44 +102,50 @@ describe('mode flags with config', () => { }); it('should use mode flag over config', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'production', '-c', 'webpack.config2.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production', '-c', 'webpack.config2.js']); - expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'production'`); }); it('should use mode from flag over NODE_ENV', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'none', '-c', 'webpack.config2.js'], false, [], { + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none', '-c', 'webpack.config2.js'], false, [], { NODE_ENV: 'production', }); - expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'none'`); }); it('should use mode from config over NODE_ENV', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', 'webpack.config2.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config2.js']); - expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'development'`); }); it('should use mode from config when multiple config are supplied', () => { - const { stdout, stderr } = run(__dirname, ['-c', 'webpack.config3.js', '-c', 'webpack.config2.js']); + const { exitCode, stdout, stderr } = run(__dirname, ['-c', 'webpack.config3.js', '-c', 'webpack.config2.js']); - expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'development'", 'g')).length).toEqual(1); }); it('mode flag should apply to all configs', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'none', '-c', './webpack.config3.js', '-c', './webpack.config2.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none', '-c', './webpack.config3.js', '-c', './webpack.config2.js']); - expect(stderr).toBeFalsy(); expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'none'`); expect(stdout.match(new RegExp("mode: 'none'", 'g')).length).toEqual(2); }); @@ -147,7 +156,8 @@ describe('mode flags with config', () => { }); expect(exitCode).toEqual(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`mode: 'production'`); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'production'", 'g')).length).toEqual(1); diff --git a/test/name/name.test.js b/test/name/name.test.js index d615a55ee3f..f05dab56270 100644 --- a/test/name/name.test.js +++ b/test/name/name.test.js @@ -3,10 +3,11 @@ const { run } = require('../utils/test-utils'); describe('name flag', () => { it('should set the flag in the config', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--name', 'config-name'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--name', 'config-name'], false); - expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'config-name' starting..."); + expect(stderr).toContain("Compilation 'config-name' finished"); expect(stdout).toContain("name: 'config-name'"); }); }); diff --git a/test/no-hot/no-hot.test.js b/test/no-hot/no-hot.test.js index bd80177cd9a..b3f8665e4ff 100644 --- a/test/no-hot/no-hot.test.js +++ b/test/no-hot/no-hot.test.js @@ -1,15 +1,16 @@ 'use strict'; + const { run } = require('../utils/test-utils'); const { stat, readFile } = require('fs'); const { resolve } = require('path'); -const { yellow } = require('colorette'); describe('no-hot flag', () => { it('should be successful when --no-hot is passed', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--no-hot']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); expect(stdout).not.toContain('webpack/runtime/hot module replacement'); @@ -27,13 +28,13 @@ describe('no-hot flag', () => { }); it('should warn when --hot and --no-hot both are passed', (done) => { - const { stderr, stdout, exitCode } = run(__dirname, ['--hot', '--no-hot']); + const { exitCode, stderr, stdout } = run(__dirname, ['--hot', '--no-hot']); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain( - `[webpack-cli] ${yellow( - 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', - )}`, + 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', ); expect(stdout).toBeTruthy(); diff --git a/test/no-stats/with-config/main.js b/test/no-stats/with-config/main.js index 1f23f48394d..a0a157ceeef 100644 --- a/test/no-stats/with-config/main.js +++ b/test/no-stats/with-config/main.js @@ -1,4 +1 @@ -require('url'); -require('path'); - console.log('--no-stats with config test'); diff --git a/test/no-stats/with-config/no-stats-with-config.test.js b/test/no-stats/with-config/no-stats-with-config.test.js index 5b7031253f1..46a49569c46 100644 --- a/test/no-stats/with-config/no-stats-with-config.test.js +++ b/test/no-stats/with-config/no-stats-with-config.test.js @@ -5,9 +5,12 @@ const { version } = require('webpack'); describe('stats flag', () => { it(`should use stats 'detailed' as defined in webpack config`, () => { - const { stderr, stdout } = run(__dirname, []); + const { exitCode, stderr, stdout } = run(__dirname, []); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); - expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'detailed' }`); } else { @@ -16,9 +19,12 @@ describe('stats flag', () => { }); it(`should use --no-stats and override value in config`, () => { - const { stderr, stdout } = run(__dirname, ['--no-stats']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); - expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'none' }`); } else { diff --git a/test/no-stats/with-flags/main.js b/test/no-stats/with-flags/main.js index 0a41cfe5c6e..412593d4ef7 100644 --- a/test/no-stats/with-flags/main.js +++ b/test/no-stats/with-flags/main.js @@ -1,4 +1 @@ -require('url'); -require('path'); - console.log('--no-stats test'); diff --git a/test/no-stats/with-flags/no-stats.test.js b/test/no-stats/with-flags/no-stats.test.js index 34ae453eb69..679461326af 100644 --- a/test/no-stats/with-flags/no-stats.test.js +++ b/test/no-stats/with-flags/no-stats.test.js @@ -5,9 +5,12 @@ const { version } = require('webpack'); describe('stats flag', () => { it('should accept --no-stats as boolean', () => { - const { stderr, stdout } = run(__dirname, ['--no-stats']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); - expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'none' }`); } else { @@ -16,9 +19,13 @@ describe('stats flag', () => { }); it('should warn and use --no-stats when stats and no-stats both are provided', () => { - const { stderr, stdout } = run(__dirname, ['--stats', 'verbose', '--no-stats']); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'verbose', '--no-stats']); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); + if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'none' }`); } else { @@ -27,9 +34,13 @@ describe('stats flag', () => { }); it('should warn and use --stats when stats and no-stats both are provided', () => { - const { stderr, stdout } = run(__dirname, ['--no-stats', '--stats', 'verbose']); + const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats', '--stats', 'verbose']); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); + if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'verbose' }`); } else { diff --git a/test/node/node.test.js b/test/node/node.test.js index 077e34044a4..4a05f2432d5 100644 --- a/test/node/node.test.js +++ b/test/node/node.test.js @@ -1,5 +1,5 @@ 'use strict'; -const { stat } = require('fs'); + const { resolve } = require('path'); const { run } = require('../utils/test-utils'); @@ -7,42 +7,45 @@ const { run } = require('../utils/test-utils'); // passing via NODE_OPTIONS= in env in execa // throws different error from what we manually see describe('node flags', () => { - it('is able to pass the options flags to node js', async (done) => { - const { stdout, stderr, exitCode } = await run(__dirname, ['--output-path', './bin'], false, [ + it('is able to pass the options flags to node js', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ['--output-path', './bin'], false, [ `--require=${resolve(__dirname, 'bootstrap.js')}`, `--require=${resolve(__dirname, 'bootstrap2.js')}`, ]); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('---from bootstrap.js---'); expect(stdout).toContain('---from bootstrap2.js---'); - expect(stderr).toBeFalsy(); - stat(resolve(__dirname, './bin/main.bundle.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); }); it('throws an error on supplying unknown flags', async () => { - const { stderr, exitCode } = await run(__dirname, [], false, ['--unknown']); + const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--unknown']); expect(exitCode).not.toBe(0); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('bad option'); + expect(stdout).toBeFalsy(); }); it('throws an error if no values were supplied with --max-old-space-size', async () => { - const { stderr, stdout, exitCode } = await run(__dirname, [], false, ['--max-old-space-size']); + const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--max-old-space-size']); expect(exitCode).not.toBe(0); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('value for flag --max-old-space-size'); expect(stdout).toBeFalsy(); }); it('throws an error if an illegal value was supplied with --max-old-space-size', async () => { - const { stderr, stdout, exitCode } = await run(__dirname, [], true, ['--max_old_space_size=1024a']); + const { exitCode, stderr, stdout } = await run(__dirname, [], true, ['--max_old_space_size=1024a']); expect(exitCode).not.toBe(0); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Error: illegal value for flag --max_old_space_size=1024a of type size_t'); expect(stdout).toBeFalsy(); }); diff --git a/test/optimization/optimization.test.js b/test/optimization/optimization.test.js index 74e97f03e7f..f30060e850e 100644 --- a/test/optimization/optimization.test.js +++ b/test/optimization/optimization.test.js @@ -1,22 +1,21 @@ -const fs = require('fs'); -const { join } = require('path'); -const { version } = require('webpack'); -const { run } = require('../utils/test-utils'); +const { run, isWebpack5 } = require('../utils/test-utils'); describe('optimization option in config', () => { it('should work with mangleExports disabled', () => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); + // Should throw when webpack is less than 5 - if (!version.startsWith('5')) { - expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'"); - expect(exitCode).toBe(2); - } else { - // Should apply the provided optimization to the compiler - expect(stdout).toContain('mangleExports: false'); - // check that the output file exists - expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeTruthy(); - expect(stderr).toBeFalsy(); + if (isWebpack5) { expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toContain('mangleExports: false'); + } else { + expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'"); + expect(stdout).toBeFalsy(); } }); }); diff --git a/test/output/named-bundles/output-named-bundles.test.js b/test/output/named-bundles/output-named-bundles.test.js index 0743bb84f67..ecb694c74a3 100644 --- a/test/output/named-bundles/output-named-bundles.test.js +++ b/test/output/named-bundles/output-named-bundles.test.js @@ -1,62 +1,62 @@ 'use strict'; -const { statSync } = require('fs'); + const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('output flag named bundles', () => { it('should output file given as flag instead of in configuration', () => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'], false); + const { exitCode, stderr, stdout } = run( + __dirname, + ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', './binary'], + false, + ); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - - const stats = statSync(resolve(__dirname, './binary/a.bundle.js')); - expect(stats.isFile()).toBe(true); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); it('should resolve the path to binary/a.bundle.js as ./binary/a.bundle.js', () => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', 'binary'], false); + const { exitCode, stderr, stdout } = run( + __dirname, + ['-c', resolve(__dirname, 'webpack.config.js'), '--output-path', 'binary'], + false, + ); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - - const stats = statSync(resolve(__dirname, './binary/a.bundle.js')); - expect(stats.isFile()).toBe(true); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); it('should create multiple bundles with an overriding flag', () => { - const { stderr, exitCode } = run( + const { exitCode, stderr, stdout } = run( __dirname, ['-c', resolve(__dirname, 'webpack.single.config.js'), '--output-path', './bin'], false, ); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - - let stats = statSync(resolve(__dirname, './bin/b.bundle.js')); - expect(stats.isFile()).toBe(true); - stats = statSync(resolve(__dirname, './bin/c.bundle.js')); - expect(stats.isFile()).toBe(true); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); it('should successfully compile multiple entries', () => { - const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.multiple.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.multiple.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - - let stats = statSync(resolve(__dirname, './bin/b.bundle.js')); - expect(stats.isFile()).toBe(true); - stats = statSync(resolve(__dirname, './bin/c.bundle.js')); - expect(stats.isFile()).toBe(true); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); it('should output file in bin directory using default webpack config with warning for empty output value', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--output-path'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--output-path'], false); - expect(stderr).toEqual("error: option '-o, --output-path ' argument missing"); expect(exitCode).toEqual(1); + expect(stderr).toEqual("error: option '-o, --output-path ' argument missing"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index dbeaf4f7138..30def73ad77 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -12,7 +12,8 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch', './src/p.js', '--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); const content = fs.readFileSync(join(__dirname, '/dist/main.js'), 'utf-8'); @@ -21,20 +22,22 @@ describe('prefetch', () => { }); it('should log error when the prefetched file is absent', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch', './src/somefile.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch', './src/somefile.js'], false); + + expect(exitCode).toBe(1); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should contain the error message expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); - expect(exitCode).toBe(1); - // check that the output file does not exist since prefetched file is not found - expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeFalsy(); - expect(stderr).toBeFalsy(); }); it('should log error when flag value is not supplied', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--prefetch'], false); - // Should contain the error message + const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch'], false); + + expect(exitCode).toBe(1); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`error: option '--prefetch ' argument missing`); expect(stdout).toBeFalsy(); - expect(exitCode).toBe(1); }); }); diff --git a/test/progress/progress-flag.test.js b/test/progress/progress-flag.test.js index 7aebd90ab12..6a5a8d1dd39 100644 --- a/test/progress/progress-flag.test.js +++ b/test/progress/progress-flag.test.js @@ -4,40 +4,50 @@ const { run, isWebpack5 } = require('../utils/test-utils'); describe('progress flag', () => { it('should show progress', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--progress']); + const { exitCode, stderr, stdout } = run(__dirname, ['--progress']); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); }); it('should support the "profile" value', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--progress=profile']); + const { exitCode, stderr, stdout } = run(__dirname, ['--progress=profile']); expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + if (isWebpack5) { expect(stderr).toMatch(/\[webpack\.Progress] \d+ ms setup/); } + expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); }); it('should not support invalid value', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--progress=unknown']); + const { exitCode, stderr, stdout } = run(__dirname, ['--progress=unknown']); expect(exitCode).toBe(2); + expect(stderr).not.toContain('Compilation starting...'); + expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`'unknown' is an invalid value for the --progress option. Only 'profile' is allowed.`); expect(stdout).toBeFalsy(); }); it('should not add duplicate plugins', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['-c', 'webpack.progress.config.js', '--progress']); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.progress.config.js', '--progress']); expect(exitCode).toEqual(0); - expect(stdout.match(/ProgressPlugin/g)).toHaveLength(1); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); + expect(stdout.match(/ProgressPlugin/g)).toHaveLength(1); }); }); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 2ad37284524..64c112648f4 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -1,6 +1,5 @@ 'use strict'; -const { yellow, options } = require('colorette'); const path = require('path'); const getPort = require('get-port'); const { runServe, isDevServer4 } = require('../../utils/test-utils'); @@ -29,58 +28,72 @@ describe('basic serve usage', () => { it('should respect the --no-color flag', async () => { const { stdout, stderr } = await runServe(['--help', '--no-color'], __dirname); - options.enabled = true; - expect(stdout).not.toContain(yellow(usageText)); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain(usageText); expect(stdout).toContain(descriptionText); - expect(stderr).toHaveLength(0); }); it('should not invoke info subcommand', async () => { const { stdout, stderr } = await runServe(['--client-log-level', 'info'], testPath); + + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compilation starting...'); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); - expect(stderr).toHaveLength(0); }); it('compiles without flags', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); + + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compilation starting...'); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); - expect(stderr).toHaveLength(0); }); it('uses hot flag to alter bundle', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); + + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compilation starting...'); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); - expect(stderr).toHaveLength(0); }); it('uses hot-only flag to alter bundle', async () => { const { stdout, stderr } = await runServe(['--port', port, isDevServer4 ? '--hot only' : '--hot-only'], testPath); + + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compilation starting...'); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); - expect(stderr).toBeFalsy(); }); it('uses no-hot flag', async () => { const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + expect(stdout).toContain('main.js'); + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compilation starting...'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); - expect(stderr).toHaveLength(0); }); it('uses hot flag and progress flag', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot', '--progress'], testPath); + + expect(stderr).toContain('webpack.Progress'); + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compilation starting...'); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); - // progress flag makes use of stderr - expect(stderr).not.toHaveLength(0); }); it('throws error on unknown flag', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--unknown-flag'], testPath); - expect(stdout).toHaveLength(0); + const { exitCode, stdout, stderr } = await runServe(['--port', port, '--unknown-flag'], testPath); + + expect(exitCode).toBe(2); expect(stderr).toContain('Unknown argument: --unknown-flag'); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/serve/serve-variable/serve-basic.test.js b/test/serve/serve-variable/serve-basic.test.js index d8e6bc12c77..7bab5984b4d 100644 --- a/test/serve/serve-variable/serve-basic.test.js +++ b/test/serve/serve-variable/serve-basic.test.js @@ -25,9 +25,11 @@ describe('serve variable', () => { it('compiles without flags and export variable', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); - expect(stderr).toHaveLength(0); expect(stdout).toContain('PASS'); }); }); diff --git a/test/serve/with-custom-port/serve-custom-config.test.js b/test/serve/with-custom-port/serve-custom-config.test.js index e0e0b55e8fb..bac94e4accf 100644 --- a/test/serve/with-custom-port/serve-custom-config.test.js +++ b/test/serve/with-custom-port/serve-custom-config.test.js @@ -25,43 +25,51 @@ describe('serve with devServer in config', () => { it('Should pick up the host and port from config', async () => { const { stdout, stderr } = await runServe([], testPath); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should output the correct bundle file expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); // Runs at correct host and port expect(stdout).toContain('http://0.0.0.0:1234'); - expect(stderr).toBeFalsy(); }); it('Port flag should override the config port', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should output the correct bundle file expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); // Runs at correct host and port expect(stdout).toContain(`http://0.0.0.0:${port}`); - expect(stderr).toBeFalsy(); }); it('Passing hot flag works alongside other server config', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should output the correct bundle file expect(stdout).toContain('main.js'); // HMR is being used expect(stdout).toContain('HotModuleReplacementPlugin'); // Runs at correct host and port expect(stdout).toContain(`http://0.0.0.0:${port}`); - expect(stderr).toBeFalsy(); }); it('works fine when no-hot flag is passed alongside other server config', async () => { const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should output the correct bundle file expect(stdout).toContain('main.js'); // HMR is not being used expect(stdout).not.toContain('HotModuleReplacementPlugin'); // Runs at correct host and port expect(stdout).toContain(`http://0.0.0.0:${port}`); - expect(stderr).toBeFalsy(); }); }); diff --git a/test/stats/cli-flags/stats.test.js b/test/stats/cli-flags/stats.test.js index ee612408123..21e5a4566ff 100644 --- a/test/stats/cli-flags/stats.test.js +++ b/test/stats/cli-flags/stats.test.js @@ -12,10 +12,11 @@ if (isWebpack5) { describe('stats flag', () => { for (const preset of presets) { it(`should accept --stats "${preset}"`, () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats', `${preset}`]); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats', `${preset}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: '${preset}' }`); @@ -26,10 +27,12 @@ describe('stats flag', () => { } it('should accept stats as boolean', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats']); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + if (isWebpack5) { expect(stdout).toContain(`stats: { preset: 'normal' }`); } else { @@ -37,11 +40,10 @@ describe('stats flag', () => { } }); - it('should warn when an unknown flag stats value is passed', () => { - const { exitCode, stderr } = run(__dirname, ['--stats', 'foo']); + it('should log error when an unknown flag stats value is passed', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'foo']); expect(exitCode).toEqual(2); - expect(stderr).toBeTruthy(); if (isWebpack5) { expect(stderr).toContain("Found the 'invalid-value' problem with the '--stats' argument by path 'stats'"); @@ -49,5 +51,7 @@ describe('stats flag', () => { expect(stderr).toContain('* configuration.stats should be one of these:'); expect(stderr).toContain('"none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose" | "errors-warnings"'); } + + expect(stdout).toBeFalsy(); }); }); diff --git a/test/stats/config/stats.test.js b/test/stats/config/stats.test.js index 84c77b6e3ca..932e57f56ab 100644 --- a/test/stats/config/stats.test.js +++ b/test/stats/config/stats.test.js @@ -6,10 +6,12 @@ const { version } = require('webpack'); describe('stats flag with config', () => { it('should compile without stats flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, []); + const { exitCode, stderr, stdout } = run(__dirname, []); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'normal' }`); } else { @@ -17,10 +19,12 @@ describe('stats flag with config', () => { } }); it('should compile with stats flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--stats', 'errors-warnings']); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'errors-warnings']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'errors-warnings' }`); } else { diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js index 4c308975371..86ef24df20e 100644 --- a/test/stats/watch/stats-and-watch.test.js +++ b/test/stats/watch/stats-and-watch.test.js @@ -1,35 +1,34 @@ 'use strict'; -const { runWatch, isWebpack5 } = require('../../utils/test-utils'); +const { runWatch } = require('../../utils/test-utils'); + +// const output = isWebpack5 ? 'successfully' : 'main.js'; describe('stats and watch', () => { it('should not log stats with the "none" value from the configuration', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); + const { stderr } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); - expect(stdout).toContain('[webpack-cli] Compilation starting...'); - expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] Compiler is watching files for updates...'); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compiler is watching files for updates...'); + // expect(stdout).toContain(output); }); it('should not log stats with the "none" value from the configuration and multi compiler mode', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); + const { stderr } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); - expect(stdout).toContain('[webpack-cli] Compilation starting...'); - expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] Compiler is watching files for updates...'); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compiler is watching files for updates...'); + // expect(stdout).toContain(output); }); it('should log stats with the "normal" value in arguments', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); - - const output = isWebpack5 ? 'successfully' : 'main.js'; + const { stderr } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); - expect(stdout).toContain('[webpack-cli] Compilation starting...'); - expect(stdout).toContain('[webpack-cli] Compilation finished'); - expect(stdout).toContain('[webpack-cli] Compiler is watching files for updates...'); - expect(stdout).toContain(output); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compiler is watching files for updates...'); + // expect(stdout).toContain(output); }); }); diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index cf7b7f6cf37..4df47f8edcf 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -1,79 +1,75 @@ 'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); + const { run, isWebpack5 } = require('../../utils/test-utils'); const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; describe('--target flag', () => { targetValues.forEach((val) => { - it(`should accept ${val} with --target flag`, (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['--target', `${val}`]); + it(`should accept ${val} with --target flag`, () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--target', `${val}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); } else { expect(stdout).toContain(`target: '${val}'`); } - - stat(resolve(__dirname, 'bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); }); - it(`should accept ${val} with -t alias`, (done) => { - const { stdout, stderr, exitCode } = run(__dirname, ['-t', `${val}`]); + it(`should accept ${val} with -t alias`, () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-t', `${val}`]); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); } else { expect(stdout).toContain(`target: '${val}'`); } - - stat(resolve(__dirname, 'bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); }); }); it(`should throw error with invalid value for --target`, () => { - const { stderr, exitCode } = run(__dirname, ['--target', 'invalid']); + const { exitCode, stderr, stdout } = run(__dirname, ['--target', 'invalid']); expect(exitCode).toBe(2); + if (isWebpack5) { expect(stderr).toContain(`Unknown target 'invalid'`); } else { expect(stderr).toContain('Invalid configuration object'); } + + expect(stdout).toBeFalsy(); }); if (isWebpack5) { it('should allow multiple targets', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--target', 'node', '--target', 'async-node']); + const { exitCode, stderr, stdout } = run(__dirname, ['--target', 'node', '--target', 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`target: [ 'node', 'async-node' ]`); }); it('should reset target from node to async-node with --target-reset', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--target-reset', '--target', 'async-node']); + const { exitCode, stderr, stdout } = run(__dirname, ['--target-reset', '--target', 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`target: [ 'async-node' ]`); }); it('should throw error if target is an empty array', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--target-reset']); + const { exitCode, stderr, stdout } = run(__dirname, ['--target-reset']); expect(exitCode).toBe(2); expect(stderr).toContain('Invalid configuration object'); diff --git a/test/target/node/node-test.test.js b/test/target/node/node-test.test.js index f6719d9629e..0fdd23b8a77 100644 --- a/test/target/node/node-test.test.js +++ b/test/target/node/node-test.test.js @@ -1,16 +1,14 @@ 'use strict'; -const { stat } = require('fs'); -const { resolve } = require('path'); + const { run } = require('../../utils/test-utils'); describe('Node target', () => { - it('should emit the correct code', (done) => { - const { stderr } = run(__dirname, ['-c', './webpack.config.js']); - expect(stderr).toBeFalsy(); - stat(resolve(__dirname, 'bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + it('should emit the correct code', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js']); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index 9e6ed7bb5e3..dd5a8ea78b3 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -2,36 +2,39 @@ const { run, isWebpack5 } = require('../utils/test-utils'); describe('unknown behaviour', () => { it('should log error if an unknown flag is passed in', () => { - const { stderr, exitCode } = run(__dirname, ['--unknown']); + const { exitCode, stderr, stdout } = run(__dirname, ['--unknown']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown argument: '--unknown'"); + expect(stdout).toBeFalsy(); }); it('should log error and respect --color flag', () => { - const { stderr, exitCode } = run(__dirname, ['--unknown', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--color']); expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] \u001b[31mUnknown argument: '--unknown'`); + expect(stdout).toBeFalsy(); }); it('should log error for unknown flag and respect --no-color', () => { - const { stderr, exitCode } = run(__dirname, ['--unknown', '--no-color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--no-color']); expect(exitCode).toBe(2); expect(stderr).not.toContain(`[webpack-cli] \u001b[31mUnknown argument: '--unknown'`); expect(stderr).toContain("Unknown argument: '--unknown'"); + expect(stdout).toBeFalsy(); }); it('suggests the closest match to an unknown flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--entyr', './a.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--entyr', './a.js']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown argument: '--entyr'"); expect(stdout).toContain("Did you mean '--entry'?"); }); it('suggests the closest match to an unknown flag #2', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--output-fileneme', '[name].js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--output-fileneme', '[name].js']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown argument: '--output-fileneme'"); diff --git a/test/utils/cli-plugin-test/plugin.test.js b/test/utils/cli-plugin-test/plugin.test.js index 14e4810a3fa..9473f01064f 100644 --- a/test/utils/cli-plugin-test/plugin.test.js +++ b/test/utils/cli-plugin-test/plugin.test.js @@ -4,12 +4,17 @@ const { run } = require('../test-utils'); describe('webpack-cli-test-plugin Test', () => { it('should log the webpack configuration', () => { - const { stderr, stdout } = run(__dirname); - expect(stderr).toBeFalsy(); + const { exitCode, stderr, stdout } = run(__dirname); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toContain(`target: 'node'`); + if (typeof cli !== 'undefined') { expect(stdout).toContain(`alias: { alias: [ 'alias1', 'alias2' ] }`); } + expect(stdout).toContain(` WebpackCLITestPlugin { opts: [Array], showAll: true }`); }); }); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 4b3a50091af..7b57ff9db22 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -51,7 +51,7 @@ const run = (testCase, args = [], setOutput = true, nodeOptions = [], env) => { return result; }; -const runWatch = (testCase, args = [], setOutput = true, outputKillStr = 'watching files for updates...') => { +const runWatch = (testCase, args = [], setOutput = true, outputKillStr = 'Compiler is watching files for updates...') => { const cwd = path.resolve(testCase); const outputPath = path.resolve(testCase, 'bin'); @@ -64,7 +64,7 @@ const runWatch = (testCase, args = [], setOutput = true, outputKillStr = 'watchi stdio: 'pipe', }); - proc.stdout.pipe( + proc.stderr.pipe( new Writable({ write(chunk, encoding, callback) { const output = chunk.toString('utf8'); @@ -241,7 +241,7 @@ const runInstall = async (cwd) => { }; const runServe = (args, testPath) => { - return runWatch(testPath, ['serve'].concat(args), false, 'main'); + return runWatch(testPath, ['serve'].concat(args), false); }; const runInfo = (args, testPath) => { diff --git a/test/utils/test-utils.test.js b/test/utils/test-utils.test.js index a7e19b7b970..daff27b08e9 100644 --- a/test/utils/test-utils.test.js +++ b/test/utils/test-utils.test.js @@ -17,8 +17,10 @@ describe('appendFile', () => { afterEach(() => { unlinkSync(junkFilePath); }); + it('should append data to file if file exists', () => { appendDataIfFileExists(__dirname, junkFile, junkComment); + const actualData = readFileSync(junkFilePath).toString(); expect(actualData).toBe(initialJunkData + junkComment); @@ -35,21 +37,23 @@ describe('appendFile', () => { describe('run function', () => { it('should work correctly by default', () => { const { command, stdout, stderr } = run(__dirname); + + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Executes the correct command expect(command).toContain('cli.js'); // Should use apply a default output dir expect(command).toContain('--output-path'); expect(command).toContain('bin'); expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); }); it('executes cli with passed commands and params', () => { const { stdout, stderr, command } = run(__dirname, ['info', '--output', 'markdown'], false); + // execution command contains info command expect(command).toContain('info'); expect(command).toContain('--output markdown'); - // Contains info command output expect(stdout).toContain('System:'); expect(stdout).toContain('Node'); @@ -60,31 +64,35 @@ describe('run function', () => { it('uses default output when output param is false', () => { const { stdout, stderr, command } = run(__dirname, [], false); + // execution command contains info command expect(command).not.toContain('--output-path'); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); }); }); describe('runAndGetWatchProc function', () => { it('should work correctly by default', async () => { const { command, stdout, stderr } = await runAndGetWatchProc(__dirname); + // Executes the correct command expect(command).toContain('cli.js'); // Should use apply a default output dir expect(command).toContain('--output-path'); expect(command).toContain('bin'); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); }); it('executes cli with passed commands and params', async () => { const { stdout, stderr, command } = await runAndGetWatchProc(__dirname, ['info', '--output', 'markdown'], false); + // execution command contains info command expect(command).toContain('info'); expect(command).toContain('--output markdown'); - // Contains info command output expect(stdout).toContain('System:'); expect(stdout).toContain('Node'); @@ -95,14 +103,17 @@ describe('runAndGetWatchProc function', () => { it('uses default output when output param is false', async () => { const { stdout, stderr, command } = await runAndGetWatchProc(__dirname, [], false); + // execution command contains info command expect(command).not.toContain('--output-path'); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); }); it('writes to stdin', async () => { const { stdout } = await runAndGetWatchProc(__dirname, ['init'], false, 'n'); + expect(stdout).toContain('Which will be your application entry point?'); }); }); @@ -110,6 +121,7 @@ describe('runAndGetWatchProc function', () => { describe('hyphenToUpperCase function', () => { it('changes value from hypen to upperCase', () => { const result = hyphenToUpperCase('test-value'); + expect(result).toEqual('testValue'); }); }); diff --git a/test/version/version-external-packages.test.js b/test/version/version-external-packages.test.js index 47c21ab9be7..f149527f1fd 100644 --- a/test/version/version-external-packages.test.js +++ b/test/version/version-external-packages.test.js @@ -11,7 +11,7 @@ const cliPkgJSON = require('../../packages/webpack-cli/package.json'); describe('version flag with external packages', () => { it('outputs version with init', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['init', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['init', '--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(initPkgJSON.version); @@ -20,7 +20,7 @@ describe('version flag with external packages', () => { }); it('outputs version with the alias c for init', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['c', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['c', '--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(initPkgJSON.version); @@ -29,7 +29,7 @@ describe('version flag with external packages', () => { }); it('outputs version with info', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['info', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(infoPkgJSON.version); @@ -38,7 +38,7 @@ describe('version flag with external packages', () => { }); it('outputs version with serve', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['serve', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(servePkgJSON.version); @@ -47,7 +47,7 @@ describe('version flag with external packages', () => { }); it('outputs version with migrate', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['migrate', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(migratePkgJSON.version); @@ -56,7 +56,7 @@ describe('version flag with external packages', () => { }); it('outputs version with plugin', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['plugin', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(pluginPkgJSON.version); @@ -65,7 +65,7 @@ describe('version flag with external packages', () => { }); it('outputs version with loader', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['loader', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['loader', '--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(loaderPkgJSON.version); @@ -74,16 +74,17 @@ describe('version flag with external packages', () => { }); it(' should throw error for multiple commands', () => { - const { stderr, exitCode } = run(__dirname, ['init', 'migrate', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['init', 'migrate', '--version'], false); expect(exitCode).toBe(2); expect(stderr).toContain( "You provided multiple commands - 'init' (alias 'c'), 'migrate' (alias 'm'). Please use only one command at a time.", ); + expect(stdout).toBeFalsy(); }); it(' should throw error if invalid argument is present with --version flag', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '--version', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '--version', '--no-color'], false); expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); @@ -92,7 +93,7 @@ describe('version flag with external packages', () => { }); it(' should throw error if invalid argument is present with version command', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', 'version', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', 'version', '--no-color'], false); expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); @@ -101,7 +102,7 @@ describe('version flag with external packages', () => { }); it(' should throw error if invalid argument is present with -v alias', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['init', 'abc', '-v', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '-v', '--no-color'], false); expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); diff --git a/test/version/version-multi-args.test.js b/test/version/version-multi-args.test.js index 1051f44ee45..f5de6205cb6 100644 --- a/test/version/version-multi-args.test.js +++ b/test/version/version-multi-args.test.js @@ -5,7 +5,7 @@ const pkgJSON = require('../../packages/webpack-cli/package.json'); describe('version flag with multiple arguments', () => { it('does not output version with help command', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['version', 'help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'help'], false); expect(exitCode).toBe(0); expect(stdout).not.toContain(pkgJSON.version); @@ -14,7 +14,7 @@ describe('version flag with multiple arguments', () => { }); it('does not output version with help dashed', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['version', '--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--help'], false); expect(exitCode).toBe(0); expect(stdout).not.toContain(pkgJSON.version); @@ -23,7 +23,7 @@ describe('version flag with multiple arguments', () => { }); it('throws error if invalid command is passed with version command', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['version', 'abc', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); @@ -32,7 +32,7 @@ describe('version flag with multiple arguments', () => { }); it('throws error if invalid option is passed with version command', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['version', '--abc', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); @@ -41,7 +41,7 @@ describe('version flag with multiple arguments', () => { }); it('throws error if invalid command is passed with --version flag', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--version', 'abc', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); @@ -50,7 +50,7 @@ describe('version flag with multiple arguments', () => { }); it('throws error if invalid option is passed with --version flag', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--version', '--abc', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); @@ -59,7 +59,7 @@ describe('version flag with multiple arguments', () => { }); it('throws error if invalid command is passed with -v alias', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-v', 'abc', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-v', 'abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); @@ -68,7 +68,7 @@ describe('version flag with multiple arguments', () => { }); it('throws error if invalid option is passed with -v alias', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-v', '--abc', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-v', '--abc', '--no-color'], false); expect(exitCode).toBe(2); expect(stdout).not.toContain(pkgJSON.version); diff --git a/test/version/version-single-arg.test.js b/test/version/version-single-arg.test.js index 72a6114b8a3..8516f802bb9 100644 --- a/test/version/version-single-arg.test.js +++ b/test/version/version-single-arg.test.js @@ -5,7 +5,7 @@ const pkgJSON = require('../../packages/webpack-cli/package.json'); describe('single version flag', () => { it('outputs versions with command syntax', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(pkgJSON.version); @@ -13,7 +13,7 @@ describe('single version flag', () => { }); it('outputs versions with dashed syntax', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--version'], false); expect(exitCode).toBe(0); expect(stdout).toContain(pkgJSON.version); @@ -21,7 +21,7 @@ describe('single version flag', () => { }); it('outputs versions with alias syntax', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-v'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-v'], false); expect(exitCode).toBe(0); expect(stdout).toContain(pkgJSON.version); diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index f95b54759b7..caa2f970530 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -13,33 +13,20 @@ describe('--watch flag', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './watch.config.js', '--no-watch']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); }); it('should recompile upon file change', (done) => { const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); - let semaphore = 0; - proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); - - if (semaphore === 0 && data.includes('Compiler is watching files for updates...')) { - process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); - - semaphore++; - }); - } - if (semaphore === 1 && data.includes('was modified')) { - process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + let modified = false; - semaphore++; - }); - } + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); - if (semaphore === 2 && data.includes('index.js')) { + if (data.includes('index.js')) { if (isWebpack5) { for (const word of wordsInStatsv5) { expect(data).toContain(word); @@ -49,13 +36,23 @@ describe('--watch flag', () => { expect(data).toContain(word); } } - - semaphore++; } + }); + + proc.stderr.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); - if (semaphore === 3 && data.includes('Compiler is watching files for updates...')) { - proc.kill(); - done(); + if (data.includes('Compiler is watching files for updates...')) { + if (!modified) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } } }); }); diff --git a/test/zero-config/entry-absent/zero-config.test.js b/test/zero-config/entry-absent/zero-config.test.js index b67e707fba1..005e22689e2 100644 --- a/test/zero-config/entry-absent/zero-config.test.js +++ b/test/zero-config/entry-absent/zero-config.test.js @@ -2,10 +2,12 @@ const { run } = require('../../utils/test-utils'); describe('Zero Config tests', () => { it('runs when config and entry are both absent', () => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); + + expect(exitCode).toBe(1); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Entry file is absent, should log the Error from the compiler expect(stdout).toContain("Error: Can't resolve './src'"); - expect(exitCode).toBe(1); - expect(stderr).toBeFalsy(); }); }); diff --git a/test/zero-config/entry-present/zero-config.test.js b/test/zero-config/entry-present/zero-config.test.js index dc551da4bcf..b39db4d1243 100644 --- a/test/zero-config/entry-present/zero-config.test.js +++ b/test/zero-config/entry-present/zero-config.test.js @@ -1,17 +1,15 @@ -const fs = require('fs'); -const path = require('path'); const { run } = require('../../utils/test-utils'); describe('Zero Config tests', () => { it('runs when no config is supplied but entry is present', () => { - const { stdout, stderr, exitCode } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, [], false); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); // Should be able to find the entry file expect(stdout).toContain('./src/index.js'); // Should output at the default output dir and filename expect(stdout).toContain('main.js'); - // check that the output file exists - expect(fs.existsSync(path.join(__dirname, '/dist/main.js'))).toBeTruthy(); - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); }); }); From 8e96ef856cbfa923c5cbde88c7bd217a782d3f04 Mon Sep 17 00:00:00 2001 From: James George Date: Tue, 1 Dec 2020 20:20:40 +0530 Subject: [PATCH 118/581] tests: remove unnecessary mocking of modules (#2156) --- packages/utils/__tests__/global-packages-path.test.ts | 1 - .../webpack-cli/lib/utils/__tests__/get-package-manager.test.js | 1 - .../webpack-cli/lib/utils/__tests__/prompt-installation.test.js | 2 -- 3 files changed, 4 deletions(-) diff --git a/packages/utils/__tests__/global-packages-path.test.ts b/packages/utils/__tests__/global-packages-path.test.ts index 91bfde39677..e70441e974e 100644 --- a/packages/utils/__tests__/global-packages-path.test.ts +++ b/packages/utils/__tests__/global-packages-path.test.ts @@ -7,7 +7,6 @@ import { utils } from 'webpack-cli'; const { getPackageManager } = utils; jest.mock('execa'); -jest.mock('cross-spawn'); const globalModulesNpmValue = 'test-npm'; jest.setMock('global-modules', globalModulesNpmValue); diff --git a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js index bd9d38a2791..35fc7939cbb 100644 --- a/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/get-package-manager.test.js @@ -11,7 +11,6 @@ jest.setMock('execa', { }); const getPackageManager = require('../get-package-manager'); -jest.mock('cross-spawn'); jest.mock('../get-package-manager', () => jest.fn()); const globalModulesNpmValue = 'test-npm'; jest.setMock('global-modules', globalModulesNpmValue); diff --git a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js index b31ce6c6746..91a0562e5ec 100644 --- a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js @@ -1,7 +1,5 @@ 'use strict'; -jest.mock('execa'); -jest.mock('cross-spawn'); const globalModulesNpmValue = 'test-npm'; jest.setMock('global-modules', globalModulesNpmValue); jest.setMock('enquirer', { From 4b973488a42c4e12d86e0324a4c7051d1380a6fa Mon Sep 17 00:00:00 2001 From: Joel Denning Date: Tue, 1 Dec 2020 07:52:32 -0700 Subject: [PATCH 119/581] fix(serve): set client port when using default port (#2147) --- packages/serve/__tests__/mergeOptions.test.ts | 5 ++-- .../serve/__tests__/startDevServer.test.ts | 24 +++++++++---------- packages/serve/src/startDevServer.ts | 19 ++++++++++----- packages/serve/src/types.ts | 19 ++++++++++++++- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/packages/serve/__tests__/mergeOptions.test.ts b/packages/serve/__tests__/mergeOptions.test.ts index 308c4c11be1..5b97dacfb87 100644 --- a/packages/serve/__tests__/mergeOptions.test.ts +++ b/packages/serve/__tests__/mergeOptions.test.ts @@ -1,12 +1,13 @@ 'use strict'; import mergeOptions from '../src/mergeOptions'; +import { devServerClientLogging } from '../src/types'; describe('mergeOptions', () => { it('merges CLI and devServer options correctly', () => { const cliOptions = { client: { - logging: 'verbose', + logging: devServerClientLogging.verbose, }, hot: true, bonjour: true, @@ -14,7 +15,7 @@ describe('mergeOptions', () => { const devServerOptions = { client: { host: 'localhost', - logging: 'none', + logging: devServerClientLogging.none, }, hot: false, liveReload: false, diff --git a/packages/serve/__tests__/startDevServer.test.ts b/packages/serve/__tests__/startDevServer.test.ts index 3e998ea0573..44eabb02a4c 100644 --- a/packages/serve/__tests__/startDevServer.test.ts +++ b/packages/serve/__tests__/startDevServer.test.ts @@ -14,7 +14,7 @@ describe('startDevServer', () => { DevServer.mockClear(); }); - it('should start dev server correctly for single compiler', () => { + it('should start dev server correctly for single compiler', async () => { const config = { devServer: { port: 9000, @@ -24,7 +24,7 @@ describe('startDevServer', () => { }; const compiler = webpack(config); - const servers = startDevServer(compiler, { + const servers = await startDevServer(compiler, { host: 'my.host', hot: true, progress: true, @@ -43,13 +43,13 @@ describe('startDevServer', () => { expect(DevServer.mock.instances[0].listen.mock.calls[0]).toMatchSnapshot(); }); - it('should set default port and host if not provided', () => { + it('should set default port and host if not provided', async () => { const config = { devServer: {}, }; const compiler = webpack(config); - const servers = startDevServer(compiler, {}); + const servers = await startDevServer(compiler, {}); expect(servers.length).toEqual(1); expect(servers).toEqual(DevServer.mock.instances); @@ -64,7 +64,7 @@ describe('startDevServer', () => { expect(DevServer.mock.instances[0].listen.mock.calls[0]).toMatchSnapshot(); }); - it('should start dev server correctly for multi compiler with 1 devServer config', () => { + it('should start dev server correctly for multi compiler with 1 devServer config', async () => { const config = [ { devServer: { @@ -77,7 +77,7 @@ describe('startDevServer', () => { ]; const compiler = webpack(config); - const servers = startDevServer(compiler, { + const servers = await startDevServer(compiler, { host: 'my.host', hot: true, progress: true, @@ -96,7 +96,7 @@ describe('startDevServer', () => { expect(DevServer.mock.instances[0].listen.mock.calls[0]).toMatchSnapshot(); }); - it('should start dev servers correctly for multi compiler with 2 devServer configs', () => { + it('should start dev servers correctly for multi compiler with 2 devServer configs', async () => { const config = [ { devServer: { @@ -113,7 +113,7 @@ describe('startDevServer', () => { ]; const compiler = webpack(config); - const servers = startDevServer(compiler, { + const servers = await startDevServer(compiler, { // this progress CLI flag should override progress: false above progress: true, }); @@ -137,8 +137,8 @@ describe('startDevServer', () => { expect(DevServer.mock.instances[1].listen.mock.calls[0]).toMatchSnapshot(); }); - it('should handle 2 multi compiler devServer configs with conflicting ports', () => { - expect(() => { + it('should handle 2 multi compiler devServer configs with conflicting ports', async () => { + await expect(async () => { const config = [ { devServer: { @@ -153,8 +153,8 @@ describe('startDevServer', () => { ]; const compiler = webpack(config); - startDevServer(compiler, {}); - }).toThrow( + await startDevServer(compiler, {}); + }).rejects.toThrow( 'Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.', ); }); diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index 28eaeee6e4c..a2418389680 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -14,15 +14,18 @@ const { logger } = utils; * * @returns {Object[]} array of resulting servers */ -export default function startDevServer(compiler, cliOptions): object[] { +export default async function startDevServer(compiler, cliOptions): Promise { let isDevServer4 = false, devServerVersion, - Server; + Server, + findPort; try { // eslint-disable-next-line node/no-extraneous-require devServerVersion = require('webpack-dev-server/package.json').version; // eslint-disable-next-line node/no-extraneous-require Server = require('webpack-dev-server/lib/Server'); + // eslint-disable-next-line node/no-extraneous-require + findPort = require('webpack-dev-server/lib/utils/findPort'); } catch (err) { logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); process.exit(2); @@ -34,10 +37,14 @@ export default function startDevServer(compiler, cliOptions): object[] { const servers = []; const usedPorts: number[] = []; - devServerOptions.forEach((devServerOpts): void => { + + for (const devServerOpts of devServerOptions) { const options = mergeOptions(cliOptions, devServerOpts); - // devSever v4 handles the default host and port itself - if (!isDevServer4) { + if (isDevServer4) { + options.port = await findPort(options.port); + options.client = options.client || {}; + options.client.port = options.client.port || options.port; + } else { options.host = options.host || 'localhost'; options.port = options.port || 8080; } @@ -61,7 +68,7 @@ export default function startDevServer(compiler, cliOptions): object[] { }); servers.push(server); - }); + } return servers; } diff --git a/packages/serve/src/types.ts b/packages/serve/src/types.ts index 7857236a663..61c59c5543a 100644 --- a/packages/serve/src/types.ts +++ b/packages/serve/src/types.ts @@ -1,6 +1,6 @@ export type devServerOptionsType = { bonjour?: boolean; - client?: object; + client?: devServerClientOptions; compress?: boolean; dev?: object; firewall?: boolean | string[]; @@ -28,3 +28,20 @@ export type devServerOptionsType = { transportMode?: object | string; useLocalIp?: boolean; }; + +type devServerClientOptions = { + host?: string; + path?: string; + port?: string | number | null; + logging?: devServerClientLogging; + progress?: boolean; +}; + +export enum devServerClientLogging { + none = 'none', + error = 'error', + warn = 'warn', + info = 'info', + log = 'log', + verbose = 'verbose', +} From dea422715796a13bb90f05a51dbb58f2acdde5a4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2020 13:59:05 +0300 Subject: [PATCH 120/581] chore(deps-dev): bump @types/jest from 26.0.15 to 26.0.16 (#2159) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.15 to 26.0.16. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/yarn.lock b/yarn.lock index 75b0c7baff4..aa1ce1f11d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2392,9 +2392,9 @@ "@types/istanbul-lib-report" "*" "@types/jest@26.x", "@types/jest@^26.0.15": - version "26.0.15" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe" - integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog== + version "26.0.16" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c" + integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g== dependencies: jest-diff "^26.0.0" pretty-format "^26.0.0" @@ -4535,11 +4535,6 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" -diff-sequences@^26.5.0: - version "26.5.0" - resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.5.0.tgz#ef766cf09d43ed40406611f11c6d8d9dd8b2fefd" - integrity sha512-ZXx86srb/iYy6jG71k++wBN9P9J05UNQ5hQHQd9MtMPvcqXPx/vKU69jfHV637D00Q2gSgPk2D+jSx3l1lDW/Q== - diff-sequences@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" @@ -7031,17 +7026,7 @@ jest-config@^26.6.3: micromatch "^4.0.2" pretty-format "^26.6.2" -jest-diff@^26.0.0: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.1.tgz#38aa194979f454619bb39bdee299fb64ede5300c" - integrity sha512-BBNy/zin2m4kG5In126O8chOBxLLS/XMTuuM2+YhgyHk87ewPzKTuTJcqj3lOWOi03NNgrl+DkMeV/exdvG9gg== - dependencies: - chalk "^4.0.0" - diff-sequences "^26.5.0" - jest-get-type "^26.3.0" - pretty-format "^26.6.1" - -jest-diff@^26.6.2: +jest-diff@^26.0.0, jest-diff@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394" integrity sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA== @@ -9369,17 +9354,7 @@ pretty-bytes@^5.2.0: resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.4.1.tgz#cd89f79bbcef21e3d21eb0da68ffe93f803e884b" integrity sha512-s1Iam6Gwz3JI5Hweaz4GoCD1WUNUIyzePFy5+Js2hjwGVt2Z79wNN+ZKOZ2vB6C+Xs6njyB84Z1IthQg8d9LxA== -pretty-format@^26.0.0, pretty-format@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.1.tgz#af9a2f63493a856acddeeb11ba6bcf61989660a8" - integrity sha512-MeqqsP5PYcRBbGMvwzsyBdmAJ4EFX7pWFyl7x4+dMVg5pE0ZDdBIvEH2ergvIO+Gvwv1wh64YuOY9y5LuyY/GA== - dependencies: - "@jest/types" "^26.6.1" - ansi-regex "^5.0.0" - ansi-styles "^4.0.0" - react-is "^17.0.1" - -pretty-format@^26.6.2: +pretty-format@^26.0.0, pretty-format@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93" integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg== From 5de77098aa2a81aa72a3ce9b766fbad5550e461e Mon Sep 17 00:00:00 2001 From: James George Date: Wed, 2 Dec 2020 16:31:44 +0530 Subject: [PATCH 121/581] chore: remove stale type definition (#2162) --- package.json | 1 - yarn.lock | 7 ------- 2 files changed, 8 deletions(-) diff --git a/package.json b/package.json index a967b769a0a..93ebe097a0e 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "@babel/preset-env": "^7.12.1", "@commitlint/cli": "^11.0.0", "@commitlint/config-lerna-scopes": "^11.0.0", - "@types/cross-spawn": "^6.0.2", "@types/jest": "^26.0.15", "@types/node": "^14.14.6", "@typescript-eslint/eslint-plugin": "^2.34.0", diff --git a/yarn.lock b/yarn.lock index aa1ce1f11d8..d18f0229496 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2282,13 +2282,6 @@ "@types/node" "*" "@types/responselike" "*" -"@types/cross-spawn@^6.0.2": - version "6.0.2" - resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.2.tgz#168309de311cd30a2b8ae720de6475c2fbf33ac7" - integrity sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw== - dependencies: - "@types/node" "*" - "@types/debug@*": version "4.1.5" resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd" From 417ff30d66184e84af990488b20d7fbddd09822a Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 2 Dec 2020 16:39:42 +0530 Subject: [PATCH 122/581] tests: correct merge-config-absent test (#2154) --- test/merge/config-absent/merge-config-absent.test.js | 6 +++--- test/merge/config/merge-config.test.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/merge/config-absent/merge-config-absent.test.js b/test/merge/config-absent/merge-config-absent.test.js index 454d5856747..5c9d6e05d03 100644 --- a/test/merge/config-absent/merge-config-absent.test.js +++ b/test/merge/config-absent/merge-config-absent.test.js @@ -5,12 +5,12 @@ const { run } = require('../../utils/test-utils'); describe('merge flag configuration', () => { it('Show warning message when the merge config is absent', () => { // 2.js doesn't exist, let's try merging with it - const { exitCode, stdout, stderr } = run(__dirname, ['--config', './1.js', '--merge', './2.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--config', './2.js', '--merge'], false); - expect(exitCode).toBe(2); + expect(exitCode).toEqual(2); // Since the process will exit, nothing on stdout expect(stdout).toBeFalsy(); // Confirm that the user is notified - expect(stderr).toContain('At least two configurations are required for merge.'); + expect(stderr).toContain(`The specified config file doesn't exist`); }); }); diff --git a/test/merge/config/merge-config.test.js b/test/merge/config/merge-config.test.js index 55ee4d7a132..ffbdb19a795 100644 --- a/test/merge/config/merge-config.test.js +++ b/test/merge/config/merge-config.test.js @@ -4,7 +4,7 @@ const { run } = require('../../utils/test-utils'); describe('merge flag configuration', () => { it('merges two configurations together', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '-c', './2.js', '--merge'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--config', './2.js', '--merge'], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); From 2823c29e66aa72d17e6a957550ac9a013d8cb0f0 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Wed, 2 Dec 2020 16:45:26 +0530 Subject: [PATCH 123/581] tests: use sync api for fs tests (#2099) --- test/build-errors/errors.test.js | 25 ++++---- test/build-warnings/warnings.test.js | 25 ++++---- .../typescript/typescript.test.js | 7 +-- .../dotfolder-array/dotfolder-array.test.js | 5 +- .../dotfolder-single/dotfolder-single.test.js | 4 ++ .../multiple-location-config.test.js | 16 ++--- .../dev-none-config.test.js | 16 ++--- .../with-mode/multiple-config.test.js | 16 ++--- .../config/function/functional-config.test.js | 6 +- .../array-functions/array-functions.test.js | 17 ++---- .../array-promises/array-promises.test.js | 16 ++--- test/config/type/array/array.test.js | 16 ++--- .../function-array/function-array.test.js | 16 ++--- .../function-async/function-async.test.js | 11 +--- .../function-promise/function-promise.test.js | 11 +--- test/config/type/function/function.test.js | 11 +--- .../type/promise-array/promise-array.test.js | 17 ++---- .../promise-function/promise-function.test.js | 10 +--- test/config/type/promise/promise.test.js | 11 +--- test/defaults/output-defaults.test.js | 19 ++---- test/devtool/object/source-map-object.test.js | 20 ++----- .../entry-with-command.test.js | 6 +- .../entry-with-config.test.js | 6 +- .../defaults-index/entry-multi-args.test.js | 6 +- test/entry/flag-entry/entry-with-flag.test.js | 9 +-- .../multiple-entries/multi-entries.test.js | 15 +---- test/json/json.test.js | 58 ++++++++----------- .../mode-with-config/mode-with-config.test.js | 55 ++++-------------- test/no-hot/no-hot.test.js | 16 ++--- test/node/node.test.js | 1 - test/target/flag-test/target-flag.test.js | 1 - test/target/node/node-test.test.js | 1 - 32 files changed, 153 insertions(+), 316 deletions(-) diff --git a/test/build-errors/errors.test.js b/test/build-errors/errors.test.js index 36d4cf0924e..8da5bc0b2cf 100644 --- a/test/build-errors/errors.test.js +++ b/test/build-errors/errors.test.js @@ -1,6 +1,6 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const { stat, readFile } = require('fs'); +const { readFile } = require('fs'); const { resolve } = require('path'); describe('errors', () => { @@ -38,23 +38,18 @@ describe('errors', () => { expect(stderr).not.toContain('Compilation finished'); expect(stdout).toContain('stats are successfully stored as json to stats.json'); - stat(resolve(__dirname, './stats.json'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { + expect(error).toBe(null); + expect(() => JSON.parse(data)).not.toThrow(); - readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { - expect(error).toBe(null); - expect(() => JSON.parse(data)).not.toThrow(); + const json = JSON.parse(data); - const json = JSON.parse(data); + expect(json['hash']).toBeDefined(); + expect(json['errors']).toHaveLength(1); + // `message` for `webpack@5` + expect(json['errors'][0].message ? json['errors'][0].message : json['errors'][0]).toMatch(/Can't resolve/); - expect(json['hash']).toBeDefined(); - expect(json['errors']).toHaveLength(1); - // `message` for `webpack@5` - expect(json['errors'][0].message ? json['errors'][0].message : json['errors'][0]).toMatch(/Can't resolve/); - - done(); - }); + done(); }); }); }); diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index 6bf7c918513..dd054091313 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -1,6 +1,6 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const { stat, readFile } = require('fs'); +const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); describe('warnings', () => { @@ -39,23 +39,20 @@ describe('warnings', () => { expect(stderr).not.toContain('Compilation finished'); expect(stdout).toContain('stats are successfully stored as json to stats.json'); - stat(resolve(__dirname, './stats.json'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); + expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); - readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { - expect(error).toBe(null); - expect(() => JSON.parse(data)).not.toThrow(); + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { + expect(error).toBe(null); + expect(() => JSON.parse(data)).not.toThrow(); - const json = JSON.parse(data); + const json = JSON.parse(data); - expect(json['hash']).toBeDefined(); - expect(json['warnings']).toHaveLength(2); - // `message` for `webpack@5` - expect(json['warnings'][0].message ? json['warnings'][0].message : json['warnings'][0]).toMatch(/Can't resolve/); + expect(json['hash']).toBeDefined(); + expect(json['warnings']).toHaveLength(2); + // `message` for `webpack@5` + expect(json['warnings'][0].message ? json['warnings'][0].message : json['warnings'][0]).toMatch(/Can't resolve/); - done(); - }); + done(); }); }); }); diff --git a/test/config-format/typescript/typescript.test.js b/test/config-format/typescript/typescript.test.js index 61e3945d134..21fadb957e7 100644 --- a/test/config-format/typescript/typescript.test.js +++ b/test/config-format/typescript/typescript.test.js @@ -1,6 +1,6 @@ /* eslint-disable node/no-unpublished-require */ const { run, runInstall } = require('../../utils/test-utils'); -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); describe('webpack cli', () => { @@ -13,10 +13,7 @@ describe('webpack cli', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(exitCode).toBe(0); - stat(resolve(__dirname, 'bin/foo.bundle.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); + expect(existsSync(resolve(__dirname, 'bin/foo.bundle.js'))).toBeTruthy(); }, 1000 * 60 * 5, ); diff --git a/test/config-lookup/dotfolder-array/dotfolder-array.test.js b/test/config-lookup/dotfolder-array/dotfolder-array.test.js index face65c4450..3e139c59eee 100644 --- a/test/config-lookup/dotfolder-array/dotfolder-array.test.js +++ b/test/config-lookup/dotfolder-array/dotfolder-array.test.js @@ -1,5 +1,6 @@ 'use strict'; - +const { existsSync } = require('fs'); +const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('dotfolder array config lookup', () => { @@ -12,5 +13,7 @@ describe('dotfolder array config lookup', () => { expect(stderr).toContain("Compilation 'commonjs' starting..."); expect(stderr).toContain("Compilation 'commonjs' finished"); expect(stdout).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); }); }); diff --git a/test/config-lookup/dotfolder-single/dotfolder-single.test.js b/test/config-lookup/dotfolder-single/dotfolder-single.test.js index ae62b1dd94f..49287f1a2c4 100644 --- a/test/config-lookup/dotfolder-single/dotfolder-single.test.js +++ b/test/config-lookup/dotfolder-single/dotfolder-single.test.js @@ -1,5 +1,8 @@ 'use strict'; +const { existsSync } = require('fs'); +const { resolve } = require('path'); + const { run } = require('../../utils/test-utils'); describe('dotfolder single config lookup', () => { @@ -11,5 +14,6 @@ describe('dotfolder single config lookup', () => { expect(stderr).toContain('Compilation finished'); expect(stdout).not.toContain('Module not found'); expect(stdout).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); }); }); diff --git a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js index 5b08b1a5b42..c1e586dac7d 100644 --- a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js +++ b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js @@ -1,21 +1,15 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('multiple dev config files with webpack.config.js', () => { - it('Uses webpack.config.development.js', (done) => { - const { exitCode, stderr, stdout } = run(__dirname, [], false); - + it('Uses webpack.config.development.js', () => { + const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(exitCode).toEqual(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); - expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/dev.folder.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stdout).not.toBe(undefined); + expect(existsSync(resolve(__dirname, './binary/dev.folder.js'))).toBeTruthy(); }); }); diff --git a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js index 33537daffb7..34ff1498b2c 100644 --- a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js +++ b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js @@ -1,21 +1,15 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('multiple config files', () => { - it('Uses dev config when both dev and none are present', (done) => { - const { exitCode, stderr, stdout } = run(__dirname, [], false); - + it('Uses dev config when both dev and none are present', () => { + const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(exitCode).toEqual(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); - expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/dev.bundle.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stdout).not.toBe(undefined); + expect(existsSync(resolve(__dirname, './binary/dev.bundle.js'))).toBeTruthy(); }); }); diff --git a/test/config/defaults/with-mode/multiple-config.test.js b/test/config/defaults/with-mode/multiple-config.test.js index 43ebe7e0cb4..1515eb64dcc 100644 --- a/test/config/defaults/with-mode/multiple-config.test.js +++ b/test/config/defaults/with-mode/multiple-config.test.js @@ -1,21 +1,15 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('multiple config files', () => { - it('Uses dev config when development mode is supplied', (done) => { - const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); - + it('Uses dev config when development mode is supplied', () => { + const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toEqual(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); - expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/dev.bundle.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(stdout).not.toBe(undefined); + expect(existsSync(resolve(__dirname, './binary/dev.bundle.js'))).toBeTruthy(); }); }); diff --git a/test/config/function/functional-config.test.js b/test/config/function/functional-config.test.js index 19b55870c1a..c135ef86845 100644 --- a/test/config/function/functional-config.test.js +++ b/test/config/function/functional-config.test.js @@ -1,16 +1,18 @@ 'use strict'; const { resolve } = require('path'); +const { existsSync } = require('fs'); const { run } = require('../../utils/test-utils'); describe('functional config', () => { it('should work as expected in case of single config', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'single-webpack.config.js')]); + const { stderr, stdout, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'single-webpack.config.js')]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'single' starting..."); expect(stderr).toContain("Compilation 'single' finished"); expect(stdout).toContain('./src/index.js'); + expect(existsSync(resolve(__dirname, './bin/dist-single.js'))).toBeTruthy(); }); it('should work as expected in case of multiple config', () => { @@ -23,5 +25,7 @@ describe('functional config', () => { expect(stderr).toContain("Compilation 'second' finished"); expect(stdout).toContain('first'); expect(stdout).toContain('second'); + expect(existsSync(resolve(__dirname, './bin/dist-first.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/dist-second.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/array-functions/array-functions.test.js b/test/config/type/array-functions/array-functions.test.js index fd584ec597f..9223d92fff1 100644 --- a/test/config/type/array-functions/array-functions.test.js +++ b/test/config/type/array-functions/array-functions.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('array of functions', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); @@ -13,16 +13,7 @@ describe('array of functions', () => { expect(stderr).toContain("Compilation 'second' starting..."); expect(stderr).toContain("Compilation 'second' finished"); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/a-functor.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - - stat(resolve(__dirname, './binary/b-functor.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - }); + expect(existsSync(resolve(__dirname, './binary/a-functor.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './binary/b-functor.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/array-promises/array-promises.test.js b/test/config/type/array-promises/array-promises.test.js index 798086428b4..e618726d3e9 100644 --- a/test/config/type/array-promises/array-promises.test.js +++ b/test/config/type/array-promises/array-promises.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('array of promises', () => { - it('is able to understand a configuration file as a promise', (done) => { + it('is able to understand a configuration file as a promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); @@ -14,15 +14,7 @@ describe('array of promises', () => { expect(stderr).toContain("Compilation 'second' finished"); expect(stdout).toBeTruthy(); - stat(resolve(__dirname, './binary/a-promise.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - - stat(resolve(__dirname, './binary/b-promise.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - }); + expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './binary/b-promise.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/array/array.test.js b/test/config/type/array/array.test.js index 6d7392493f2..c4757aa379f 100644 --- a/test/config/type/array/array.test.js +++ b/test/config/type/array/array.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('array', () => { - it('is able to understand a configuration file in array format', (done) => { + it('is able to understand a configuration file in array format', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); @@ -13,15 +13,7 @@ describe('array', () => { expect(stderr).toContain("Compilation 'commonjs' starting..."); expect(stderr).toContain("Compilation 'commonjs' finished"); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './dist/dist-commonjs.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - stat(resolve(__dirname, './dist/dist-amd.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/function-array/function-array.test.js b/test/config/type/function-array/function-array.test.js index 22ab749ceb7..a081360b620 100644 --- a/test/config/type/function-array/function-array.test.js +++ b/test/config/type/function-array/function-array.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('function array', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); @@ -14,15 +14,7 @@ describe('function array', () => { expect(stderr).toContain("Compilation 'second' finished"); expect(stdout).toBeTruthy(); - stat(resolve(__dirname, './binary/a-functor.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - - stat(resolve(__dirname, './binary/b-functor.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - }); + expect(existsSync(resolve(__dirname, './binary/a-functor.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './binary/b-functor.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/function-async/function-async.test.js b/test/config/type/function-async/function-async.test.js index af7e99bf71d..86a1766a3df 100644 --- a/test/config/type/function-async/function-async.test.js +++ b/test/config/type/function-async/function-async.test.js @@ -1,21 +1,16 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('function async', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/functor.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/function-promise/function-promise.test.js b/test/config/type/function-promise/function-promise.test.js index bbd4887a9f9..074f276933c 100644 --- a/test/config/type/function-promise/function-promise.test.js +++ b/test/config/type/function-promise/function-promise.test.js @@ -1,21 +1,16 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('function promise', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/functor.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/function/function.test.js b/test/config/type/function/function.test.js index 44908c8882c..6f90a6cd065 100644 --- a/test/config/type/function/function.test.js +++ b/test/config/type/function/function.test.js @@ -1,21 +1,16 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('function', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/functor.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/promise-array/promise-array.test.js b/test/config/type/promise-array/promise-array.test.js index 25f76a66e52..0d38f7b6682 100644 --- a/test/config/type/promise-array/promise-array.test.js +++ b/test/config/type/promise-array/promise-array.test.js @@ -1,26 +1,17 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('promise array', () => { - it('is able to understand a configuration file as a promise', (done) => { + it('is able to understand a configuration file as a promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); expect(stdout).toBeTruthy(); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); - - stat(resolve(__dirname, './binary/a-promise.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - - stat(resolve(__dirname, './binary/b-promise.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); - }); + expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/promise-function/promise-function.test.js b/test/config/type/promise-function/promise-function.test.js index e53c9e2b0ad..9f662f2d6f8 100644 --- a/test/config/type/promise-function/promise-function.test.js +++ b/test/config/type/promise-function/promise-function.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('promise function', () => { - it('is able to understand a configuration file as a promise', (done) => { + it('is able to understand a configuration file as a promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); @@ -12,10 +12,6 @@ describe('promise function', () => { expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - stat(resolve(__dirname, './binary/promise.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './binary/promise.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/promise/promise.test.js b/test/config/type/promise/promise.test.js index 019106ea3ec..34e93c57f26 100644 --- a/test/config/type/promise/promise.test.js +++ b/test/config/type/promise/promise.test.js @@ -1,21 +1,16 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('promise', () => { - it('is able to understand a configuration file as a promise', (done) => { + it('is able to understand a configuration file as a promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './binary/promise.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './binary/promise.js'))).toBeTruthy(); }); }); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index 88f70420a6c..c727226adf5 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../utils/test-utils'); describe('output flag defaults', () => { - it('should create default file for a given directory', (done) => { + it('should create default file for a given directory', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js', '--output-path', './binary'], false); expect(exitCode).toBe(0); @@ -13,26 +13,17 @@ describe('output flag defaults', () => { // Should print warning about config fallback expect(stdout).toContain('option has not been set, webpack will fallback to'); - stat(resolve(__dirname, './binary/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './binary/main.js'))).toBeTruthy(); }); - it('set default output directory on no output flag', (done) => { + it('set default output directory on no output flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js'], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './dist/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './binary/main.js'))).toBeTruthy(); }); it('throw error on empty output flag', () => { diff --git a/test/devtool/object/source-map-object.test.js b/test/devtool/object/source-map-object.test.js index 0e2c379144d..8a13e79aa61 100644 --- a/test/devtool/object/source-map-object.test.js +++ b/test/devtool/object/source-map-object.test.js @@ -1,5 +1,5 @@ 'use strict'; -const { readdir, stat } = require('fs'); +const { readdir, existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); @@ -19,22 +19,17 @@ describe('source-map object', () => { }); }); - it('should write a sourcemap file', (done) => { + it('should write a sourcemap file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.source.config.js'], false); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'amd' starting..."); expect(stderr).toContain("Compilation 'amd' finished"); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, 'dist/dist-amd.js.map'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, 'dist/dist-amd.js.map'))).toBeTruthy(); }); - it('should override config with source-map', (done) => { + it('should override config with source-map', () => { const { exitCode, stderr, stdout } = run( __dirname, ['-c', './webpack.eval.config.js', '--devtool', 'source-map', '-o', './binary'], @@ -45,11 +40,6 @@ describe('source-map object', () => { expect(stderr).toContain("Compilation 'amd' starting..."); expect(stderr).toContain("Compilation 'amd' finished"); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, 'binary/dist-amd.js.map'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, 'binary/dist-amd.js.map'))).toBeTruthy(); }); }); diff --git a/test/entry/config-entry/entry-with-command/entry-with-command.test.js b/test/entry/config-entry/entry-with-command/entry-with-command.test.js index dba46409a83..ac8bc9505ef 100644 --- a/test/entry/config-entry/entry-with-command/entry-with-command.test.js +++ b/test/entry/config-entry/entry-with-command/entry-with-command.test.js @@ -1,14 +1,16 @@ 'use strict'; - +const { existsSync } = require('fs'); +const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('config entry and command entry all exist', () => { it('should use command entry if config command existed', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', '../1.js', './index.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js', './index.js'], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('./index.js'); + expect(existsSync(resolve(__dirname, './binary/main.bundle.js'))).toBeTruthy(); }); }); diff --git a/test/entry/config-entry/entry-with-config/entry-with-config.test.js b/test/entry/config-entry/entry-with-config/entry-with-config.test.js index effa0df6daa..69dba9616fa 100644 --- a/test/entry/config-entry/entry-with-config/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-config/entry-with-config.test.js @@ -1,14 +1,16 @@ 'use strict'; - +const { existsSync } = require('fs'); +const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('default entry and config entry all exist', () => { it('should use config entry if config entry existed', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', '../1.js'], false); + const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js'], false); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toContain('./a.js'); + expect(existsSync(resolve(__dirname, './binary/index.bundle.js'))).toBeTruthy(); }); }); diff --git a/test/entry/defaults-index/entry-multi-args.test.js b/test/entry/defaults-index/entry-multi-args.test.js index c4b64f094aa..a91113d40ba 100644 --- a/test/entry/defaults-index/entry-multi-args.test.js +++ b/test/entry/defaults-index/entry-multi-args.test.js @@ -1,10 +1,13 @@ 'use strict'; +const { existsSync } = require('fs'); +const { resolve } = require('path'); + const { run } = require('../../utils/test-utils'); describe('single entry flag index present', () => { it('finds default index file and compiles successfully', () => { - const { exitCode, stderr, stdout } = run(__dirname); + const { stderr, stdout, exitCode } = run(__dirname); expect(exitCode).toBe(0); expect(stderr).toContain('Compilation starting...'); @@ -20,5 +23,6 @@ describe('single entry flag index present', () => { expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); }); }); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index 5afc6457249..fc2072a901f 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -1,7 +1,7 @@ 'use strict'; const { run, isWebpack5 } = require('../../utils/test-utils'); -const { stat, readFile } = require('fs'); +const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); describe('entry flag', () => { @@ -37,12 +37,7 @@ describe('entry flag', () => { expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('Hello from a.js'); diff --git a/test/entry/multiple-entries/multi-entries.test.js b/test/entry/multiple-entries/multi-entries.test.js index c7ed5aa2c13..d9b5598cbd4 100644 --- a/test/entry/multiple-entries/multi-entries.test.js +++ b/test/entry/multiple-entries/multi-entries.test.js @@ -1,7 +1,7 @@ 'use strict'; const { run } = require('../../utils/test-utils'); -const { stat, readFile } = require('fs'); +const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); describe(' multiple entries', () => { @@ -12,12 +12,7 @@ describe(' multiple entries', () => { expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('Hello from a.js'); @@ -33,12 +28,8 @@ describe(' multiple entries', () => { expect(stderr).toContain('Compilation starting...'); expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('Hello from a.js'); diff --git a/test/json/json.test.js b/test/json/json.test.js index a389356e7cc..6bc74116ada 100644 --- a/test/json/json.test.js +++ b/test/json/json.test.js @@ -1,6 +1,6 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const { stat, readFile } = require('fs'); +const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); const successMessage = 'stats are successfully stored as json to stats.json'; @@ -18,19 +18,14 @@ describe('json flag', () => { expect(stdout).toContain(successMessage); expect(exitCode).toBe(0); - - stat(resolve(__dirname, './stats.json'), (err, stats) => { + expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - - readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(JSON.parse(data)['hash']).toBeTruthy(); - expect(JSON.parse(data)['version']).toBeTruthy(); - expect(JSON.parse(data)['time']).toBeTruthy(); - expect(() => JSON.parse(data)).not.toThrow(); - done(); - }); + expect(JSON.parse(data)['hash']).toBeTruthy(); + expect(JSON.parse(data)['version']).toBeTruthy(); + expect(JSON.parse(data)['time']).toBeTruthy(); + expect(() => JSON.parse(data)).not.toThrow(); + done(); }); }); @@ -40,18 +35,15 @@ describe('json flag', () => { expect(stdout).toContain(`[webpack-cli] \u001b[32m${successMessage}`); expect(exitCode).toBe(0); - stat(resolve(__dirname, './stats.json'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); + expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); - readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(JSON.parse(data)['hash']).toBeTruthy(); - expect(JSON.parse(data)['version']).toBeTruthy(); - expect(JSON.parse(data)['time']).toBeTruthy(); - expect(() => JSON.parse(data)).not.toThrow(); - done(); - }); + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { + expect(err).toBe(null); + expect(JSON.parse(data)['hash']).toBeTruthy(); + expect(JSON.parse(data)['version']).toBeTruthy(); + expect(JSON.parse(data)['time']).toBeTruthy(); + expect(() => JSON.parse(data)).not.toThrow(); + done(); }); }); @@ -62,17 +54,15 @@ describe('json flag', () => { expect(stdout).toContain(`[webpack-cli] ${successMessage}`); expect(exitCode).toBe(0); - stat(resolve(__dirname, './stats.json'), (err, stats) => { + expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); + + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(JSON.parse(data)['hash']).toBeTruthy(); - expect(JSON.parse(data)['version']).toBeTruthy(); - expect(JSON.parse(data)['time']).toBeTruthy(); - expect(() => JSON.parse(data)).not.toThrow(); - done(); - }); + expect(JSON.parse(data)['hash']).toBeTruthy(); + expect(JSON.parse(data)['version']).toBeTruthy(); + expect(JSON.parse(data)['time']).toBeTruthy(); + expect(() => JSON.parse(data)).not.toThrow(); + done(); }); }); diff --git a/test/mode/mode-with-config/mode-with-config.test.js b/test/mode/mode-with-config/mode-with-config.test.js index 0ff605a4386..f3cb00f3ed9 100644 --- a/test/mode/mode-with-config/mode-with-config.test.js +++ b/test/mode/mode-with-config/mode-with-config.test.js @@ -1,5 +1,5 @@ 'use strict'; -const { stat, readFile } = require('fs'); +const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); // eslint-disable-next-line node/no-unpublished-require const { run } = require('../../utils/test-utils'); @@ -14,21 +14,9 @@ describe('mode flags with config', () => { expect(stdout).toBeTruthy(); // Should generate the appropriate files - stat(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - // Should not generate source maps when not specified - stat(resolve(__dirname, './bin/main.js.map'), (err) => { - expect(err).toBeTruthy(); - }); - + expect(existsSync(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js.map'))).toBeFalsy(); // Correct mode should be propagated to the compiler readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); @@ -46,20 +34,9 @@ describe('mode flags with config', () => { expect(stdout).toBeTruthy(); // Should generate the appropriate files - stat(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - // Should not generate source maps when not specified - stat(resolve(__dirname, './bin/main.js.map'), (err) => { - expect(err).toBeTruthy(); - }); + expect(existsSync(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js.map'))).toBeFalsy(); // Correct mode should be propagated to the compiler readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { @@ -78,20 +55,10 @@ describe('mode flags with config', () => { expect(stdout).toBeTruthy(); // Should generate the appropriate files - stat(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - // Should not generate source maps when not specified - stat(resolve(__dirname, './bin/main.js.map'), (err) => { - expect(err).toBeTruthy(); - }); + // Should generate the appropriate files + expect(existsSync(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './bin/main.js.map'))).toBeFalsy(); // Correct mode should be propagated to the compiler readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { diff --git a/test/no-hot/no-hot.test.js b/test/no-hot/no-hot.test.js index b3f8665e4ff..a381d52e9bd 100644 --- a/test/no-hot/no-hot.test.js +++ b/test/no-hot/no-hot.test.js @@ -1,7 +1,7 @@ 'use strict'; const { run } = require('../utils/test-utils'); -const { stat, readFile } = require('fs'); +const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); describe('no-hot flag', () => { @@ -13,12 +13,7 @@ describe('no-hot flag', () => { expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); expect(stdout).not.toContain('webpack/runtime/hot module replacement'); - - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); // check for absence of special functions invoked by HMR plugin only @@ -38,11 +33,8 @@ describe('no-hot flag', () => { ); expect(stdout).toBeTruthy(); - stat(resolve(__dirname, './bin/main.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); + readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); // check for absence of special functions invoked by HMR plugin only diff --git a/test/node/node.test.js b/test/node/node.test.js index 4a05f2432d5..d98ae225b3f 100644 --- a/test/node/node.test.js +++ b/test/node/node.test.js @@ -1,5 +1,4 @@ 'use strict'; - const { resolve } = require('path'); const { run } = require('../utils/test-utils'); diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index 4df47f8edcf..9a3d69bbccb 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -1,5 +1,4 @@ 'use strict'; - const { run, isWebpack5 } = require('../../utils/test-utils'); const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; diff --git a/test/target/node/node-test.test.js b/test/target/node/node-test.test.js index 0fdd23b8a77..d672dcb2d01 100644 --- a/test/target/node/node-test.test.js +++ b/test/target/node/node-test.test.js @@ -1,5 +1,4 @@ 'use strict'; - const { run } = require('../../utils/test-utils'); describe('Node target', () => { From ab1ad0e9053d84a7a848e43cfb0e2a5892b5aaff Mon Sep 17 00:00:00 2001 From: James George Date: Wed, 2 Dec 2020 17:18:27 +0530 Subject: [PATCH 124/581] docs: better description for negated flags (#2158) --- packages/webpack-cli/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 70379c8ceba..98f473c502a 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -58,11 +58,11 @@ yarn add webpack-cli --dev -o, --output-path string Output location of the generated bundle -t, --target string[] Sets the build target -w, --watch Watch for files changes - --no-watch Negates watch + --no-watch Do not watch for file changes -h, --hot Enables Hot Module Replacement --no-hot Disables Hot Module Replacement -d, --devtool string Controls if and how source maps are generated. - --no-devtool Negates devtool + --no-devtool Do not generate source maps --prefetch string Prefetch this request -j, --json string, boolean Prints result as JSON or store it in a file --mode string Defines the mode to pass to webpack From 0339a101be852ab6e020c8b814f382b2b06ab18e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 2 Dec 2020 17:49:28 +0530 Subject: [PATCH 125/581] chore: fix invalid-flag test description (#2160) * chore: fix invalid-flag test description * chore: update test/core-flags/invalid-flag.test.js Co-authored-by: James George Co-authored-by: James George --- test/core-flags/invalid-flag.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core-flags/invalid-flag.test.js b/test/core-flags/invalid-flag.test.js index 451a3ef6176..c7233f9c03d 100644 --- a/test/core-flags/invalid-flag.test.js +++ b/test/core-flags/invalid-flag.test.js @@ -2,8 +2,8 @@ const { run } = require('../utils/test-utils'); -describe('--parallelism flag', () => { - it('should set parallelism to the value passed', () => { +describe('invalid flag value', () => { + it('should throw an error for the invalid value passed', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-script-type', 'unknown']); expect(exitCode).toBe(2); From bae3aaab8f6b3ec60521d5fd2303a9c4bb052b1b Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Thu, 3 Dec 2020 11:06:33 +0530 Subject: [PATCH 126/581] chore: fix args to run method (#2165) --- packages/webpack-cli/lib/bootstrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index f61786c28b6..f569f099e8c 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -64,7 +64,7 @@ const runCLI = async (cliArgs) => { parsedArgsOpts.entry = entry; } - await cli.run(parsedArgsOpts, flags); + await cli.run(parsedArgsOpts); } catch (error) { logger.error(error); process.exit(2); From 6171c822bfdaea045007ff7b4cef4cec7ca8133e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 3 Dec 2020 15:31:01 +0530 Subject: [PATCH 127/581] chore: improve help output for --merge (#2167) * chore: improve help output for --merge * tests: update --- packages/webpack-cli/lib/utils/cli-flags.js | 4 ++-- test/help/help-flags.test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index c0888924133..20649d51f08 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -105,10 +105,10 @@ const builtInFlags = [ }, { name: 'merge', - usage: '--merge', + usage: '--config --config --merge', alias: 'm', type: Boolean, - description: 'Merge two or more configurations using webpack-merge e.g. -c ./webpack.config.js -c ./webpack.test.config.js --merge', + description: 'Merge two or more configurations using webpack-merge', link: 'https://github.com/survivejs/webpack-merge', }, // Complex configs diff --git a/test/help/help-flags.test.js b/test/help/help-flags.test.js index 9be66b51dda..fdaf9feeacb 100644 --- a/test/help/help-flags.test.js +++ b/test/help/help-flags.test.js @@ -26,7 +26,7 @@ describe('commands help', () => { expect(exitCode).toBe(0); expect(stdout).not.toContain('The build tool for modern web applications'); - expect(stdout).toContain('webpack -m, --merge'); + expect(stdout).toContain('webpack -m, --config --config --merge'); expect(stderr).toHaveLength(0); }); From 351c645ef3a2dbb3a51da7458936104d53283a8e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 3 Dec 2020 14:09:19 +0300 Subject: [PATCH 128/581] chore(deps-dev): bump eslint-plugin-prettier from 3.1.4 to 3.2.0 (#2171) Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.1.4 to 3.2.0. - [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases) - [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-plugin-prettier/compare/v3.1.4...v3.2.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d18f0229496..759c9b4e343 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4901,9 +4901,9 @@ eslint-plugin-node@^11.1.0: semver "^6.1.0" eslint-plugin-prettier@^3.1.4: - version "3.1.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.4.tgz#168ab43154e2ea57db992a2cd097c828171f75c2" - integrity sha512-jZDa8z76klRqo+TdGDTFJSavwbnWK2ZpqGKNZ+VvweMW516pDUMmQ2koXvxEE4JhzNvTv+radye/bWGBmA6jmg== + version "3.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.2.0.tgz#af391b2226fa0e15c96f36c733f6e9035dbd952c" + integrity sha512-kOUSJnFjAUFKwVxuzy6sA5yyMx6+o9ino4gCdShzBNx4eyFRudWRYKCFolKjoM40PEiuU6Cn7wBLfq3WsGg7qg== dependencies: prettier-linter-helpers "^1.0.0" From dcd7e3228d889ed09f1ce68b620529e064c4b846 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 3 Dec 2020 16:12:29 +0300 Subject: [PATCH 129/581] tests: cache (#2166) --- test/cache/cache.test.js | 241 +++++++++++++++++++++++----- test/cache/multi.config.js | 48 ++++++ test/cache/webpack.config.js | 1 + test/core-flags/cache-flags.test.js | 152 ++++++++++++++---- 4 files changed, 374 insertions(+), 68 deletions(-) create mode 100644 test/cache/multi.config.js diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index 7a31586a97d..dae6085dc3a 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -5,68 +5,229 @@ const rimraf = require('rimraf'); const { run, isWebpack5 } = require('../utils/test-utils'); describe('cache', () => { - beforeEach((done) => { - rimraf(path.join(__dirname, '../../node_modules/.cache/webpack/test'), () => { - rimraf(path.join(__dirname, '../../node_modules/.cache/webpack/test-1'), () => { - done(); - }); - }); + it('should work', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-default-development')); + + let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-default' starting..."); + expect(stderr).toContain("Compilation 'cache-test-default' finished"); + expect(stderr.match(/No pack exists at/g)).toHaveLength(1); + expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stdout).toBeTruthy(); + } + + ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false)); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-default' starting..."); + expect(stderr).toContain("Compilation 'cache-test-default' finished"); + expect(stderr.match(/restore cache container:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stdout).toBeTruthy(); + } }); - it('should work', () => { - let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false); + it('should work in multi compiler mode', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-{first,second}-development')); + + let { exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'], false); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-first' starting..."); + expect(stderr).toContain("Compilation 'cache-test-first' finished"); + expect(stderr).toContain("Compilation 'cache-test-second' starting..."); + expect(stderr).toContain("Compilation 'cache-test-second' finished"); + expect(stderr.match(/No pack exists at/g)).toHaveLength(2); + expect(stderr.match(/Stored pack/g)).toHaveLength(2); + expect(stdout).toBeTruthy(); + } + + ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'], false)); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-first' starting..."); + expect(stderr).toContain("Compilation 'cache-test-first' finished"); + expect(stderr).toContain("Compilation 'cache-test-second' starting..."); + expect(stderr).toContain("Compilation 'cache-test-second' finished"); + expect(stderr.match(/restore cache container:/g)).toHaveLength(2); + expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(2); + expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(2); + expect(stdout).toBeTruthy(); + } + }); + + it('should work in multi compiler mode with the `--config-name` argument', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-third-development')); + + let { exitCode, stderr, stdout } = run( + __dirname, + ['-c', './multi.config.js', '--config-name', 'cache-test-first', '--name', 'cache-test-third'], + false, + ); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-third' starting..."); + expect(stderr).toContain("Compilation 'cache-test-third' finished"); + expect(stderr.match(/No pack exists at/g)).toHaveLength(1); + expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stdout).toBeTruthy(); + } + + ({ exitCode, stderr, stdout } = run( + __dirname, + ['-c', './multi.config.js', '--config-name', 'cache-test-first', '--name', 'cache-test-third'], + false, + )); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-third' starting..."); + expect(stderr).toContain("Compilation 'cache-test-third' finished"); + expect(stderr.match(/restore cache container:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stdout).toBeTruthy(); + } + }); + + it('should work with the `--merge` argument', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-fourth-development')); + + let { exitCode, stderr, stdout } = run( + __dirname, + ['-c', './multi.config.js', '-c', './webpack.config.js', '--merge', '--name', 'cache-test-fourth'], + false, + ); + + expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('No pack exists at'); - expect(stderr).toContain('Stored pack'); + expect(stderr).toContain("Compilation 'cache-test-fourth' starting..."); + expect(stderr).toContain("Compilation 'cache-test-fourth' finished"); + expect(stderr.match(/No pack exists at/g)).toHaveLength(1); + expect(stderr.match(/Stored pack/g)).toHaveLength(1); expect(stdout).toBeTruthy(); - } else { - expect(exitCode).toEqual(2); } - ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--cache-name', 'test'], false)); + ({ exitCode, stderr, stdout } = run( + __dirname, + ['-c', './multi.config.js', '-c', './webpack.config.js', '--merge', '--name', 'cache-test-fourth'], + false, + )); + + expect(exitCode).toEqual(0); if (isWebpack5) { - expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('restore cache container'); - expect(stderr).toContain('restore cache content metadata'); - expect(stderr).toContain('restore cache content'); + expect(stderr).toContain("Compilation 'cache-test-fourth' starting..."); + expect(stderr).toContain("Compilation 'cache-test-fourth' finished"); + expect(stderr.match(/restore cache container:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stdout).toBeTruthy(); + } + }); + + it('should work with the `--config-name` and `--merge` argument', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-fifth-development')); + + let { exitCode, stderr, stdout } = run( + __dirname, + [ + '-c', + './multi.config.js', + '-c', + './webpack.config.js', + '--merge', + '--config-name', + 'cache-test-first', + '--config-name', + 'cache-test-second', + '--name', + 'cache-test-fifth', + ], + false, + ); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-fifth' starting..."); + expect(stderr).toContain("Compilation 'cache-test-fifth' finished"); + expect(stderr.match(/No pack exists at/g)).toHaveLength(1); + expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stdout).toBeTruthy(); + } + + ({ exitCode, stderr, stdout } = run( + __dirname, + [ + '-c', + './multi.config.js', + '-c', + './webpack.config.js', + '--merge', + '--config-name', + 'cache-test-first', + '--config-name', + 'cache-test-second', + '--name', + 'cache-test-fifth', + ], + false, + )); + + expect(exitCode).toEqual(0); + + if (isWebpack5) { + expect(stderr).toContain("Compilation 'cache-test-fifth' starting..."); + expect(stderr).toContain("Compilation 'cache-test-fifth' finished"); + expect(stderr.match(/restore cache container:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); expect(stdout).toBeTruthy(); - } else { - expect(exitCode).toEqual(2); } }); it('should work with autoloading configuration', () => { - let { exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-autoloading-development')); + + let { exitCode, stderr, stdout } = run(__dirname, ['--name', 'cache-test-autoloading'], false); + + expect(exitCode).toEqual(0); if (isWebpack5) { - expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('No pack exists at'); - expect(stderr).toContain('Stored pack'); + expect(stderr).toContain("Compilation 'cache-test-autoloading' starting..."); + expect(stderr).toContain("Compilation 'cache-test-autoloading' finished"); + expect(stderr.match(/No pack exists at/g)).toHaveLength(1); + expect(stderr.match(/Stored pack/g)).toHaveLength(1); expect(stdout).toBeTruthy(); - } else { - expect(exitCode).toEqual(2); } - ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-name', 'test-1'], false)); + ({ exitCode, stderr, stdout } = run(__dirname, ['--name', 'cache-test-autoloading'], false)); + + expect(exitCode).toEqual(0); if (isWebpack5) { - expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('restore cache container'); - expect(stderr).toContain('restore cache content metadata'); - expect(stderr).toContain('restore cache content'); + expect(stderr).toContain("Compilation 'cache-test-autoloading' starting..."); + expect(stderr).toContain("Compilation 'cache-test-autoloading' finished"); + expect(stderr.match(/restore cache container:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); + expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); expect(stdout).toBeTruthy(); - } else { - expect(exitCode).toEqual(2); } }); }); diff --git a/test/cache/multi.config.js b/test/cache/multi.config.js new file mode 100644 index 00000000000..d0b6222af3c --- /dev/null +++ b/test/cache/multi.config.js @@ -0,0 +1,48 @@ +const path = require('path'); + +module.exports = [ + { + mode: 'development', + name: 'cache-test-first', + cache: { + type: 'filesystem', + buildDependencies: { + config: [__filename], + }, + }, + infrastructureLogging: { + debug: /cache/, + }, + entry: { + app: './src/main.js', + }, + output: { + filename: '[name].bundle.js', + chunkFilename: '[name].bundle.js', + path: path.resolve(__dirname, 'dist'), + publicPath: '/', + }, + }, + { + mode: 'development', + name: 'cache-test-second', + cache: { + type: 'filesystem', + buildDependencies: { + config: [__filename], + }, + }, + infrastructureLogging: { + debug: /cache/, + }, + entry: { + app: './src/main.js', + }, + output: { + filename: '[name].bundle.js', + chunkFilename: '[name].bundle.js', + path: path.resolve(__dirname, 'dist'), + publicPath: '/', + }, + }, +]; diff --git a/test/cache/webpack.config.js b/test/cache/webpack.config.js index 84bd663f43c..e089c3d4b53 100644 --- a/test/cache/webpack.config.js +++ b/test/cache/webpack.config.js @@ -2,6 +2,7 @@ const path = require('path'); module.exports = { mode: 'development', + name: 'cache-test-default', cache: { type: 'filesystem', buildDependencies: { diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index dbe2193f7b1..d2eb845fbee 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -7,12 +7,6 @@ const { existsSync, writeFileSync, unlinkSync } = require('fs'); const { resolve } = require('path'); describe('cache related flags from core', () => { - beforeEach((done) => { - rimraf(path.join(__dirname, '../../node_modules/.cache/webpack/*'), () => { - done(); - }); - }); - it('should be successful with --cache ', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache']); @@ -32,7 +26,11 @@ describe('cache related flags from core', () => { }); it('should set cache.type', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-type'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -41,7 +39,18 @@ describe('cache related flags from core', () => { }); it('should set cache.cacheDirectory with --cache-cache-directory', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-directory', './test-cache-path']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-cache-directory'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, [ + '--cache-type', + 'filesystem', + '--cache-cache-directory', + './test-cache-path', + '--cache-cache-location', + cacheLocation, + ]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -51,23 +60,33 @@ describe('cache related flags from core', () => { }); it('should set cache.cacheLocation with --cache-cache-locations', () => { - const { exitCode, stderr, stdout } = run(__dirname, [ - '--cache-type', - 'filesystem', - '--cache-cache-location', - './test-locate-cache', - ]); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-cache-location'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain("type: 'filesystem'"); - expect(stdout).toContain('test-locate-cache'); - expect(existsSync(resolve(__dirname, './test-locate-cache'))).toBeTruthy(); + expect(stdout).toContain('cache-core-flag-test-cache-location'); + expect(existsSync(cacheLocation)).toBeTruthy(); }); it('should set cache.hashAlgorithm with --cache-hash-algorithm', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-hash-algorithm', 'sha256']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-hash-algorithm'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, [ + '--cache-type', + 'filesystem', + '--cache-hash-algorithm', + 'sha256', + '--cache-cache-location', + cacheLocation, + ]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -77,7 +96,18 @@ describe('cache related flags from core', () => { }); it('should set cache.name with --cache-name', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-name', 'cli-test']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-name'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, [ + '--cache-type', + 'filesystem', + '--cache-name', + 'cli-test', + '--cache-cache-location', + cacheLocation, + ]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -87,7 +117,18 @@ describe('cache related flags from core', () => { }); it('should set cache.store with --cache-store', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-store', 'pack']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-store'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, [ + '--cache-type', + 'filesystem', + '--cache-store', + 'pack', + '--cache-cache-location', + cacheLocation, + ]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -97,7 +138,18 @@ describe('cache related flags from core', () => { }); it('should set cache.version with --cache-version', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-version', '1.1.3']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-version'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, [ + '--cache-type', + 'filesystem', + '--cache-version', + '1.1.3', + '--cache-cache-location', + cacheLocation, + ]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -107,7 +159,18 @@ describe('cache related flags from core', () => { }); it('should assign cache build dependencies correctly when cache type is filesystem', () => { - let { stderr, stdout, exitCode } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-build-dependencies'); + + rimraf.sync(cacheLocation); + + let { stderr, stdout, exitCode } = run(__dirname, [ + '--cache-type', + 'filesystem', + '-c', + './webpack.config.js', + '--cache-cache-location', + cacheLocation, + ]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -118,7 +181,14 @@ describe('cache related flags from core', () => { expect(stdout).not.toContain('[cached]'); // Run again to check for cache - ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.config.js'])); + ({ exitCode, stderr, stdout } = run(__dirname, [ + '--cache-type', + 'filesystem', + '-c', + './webpack.config.js', + '--cache-cache-location', + cacheLocation, + ])); expect(exitCode).toEqual(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -127,7 +197,14 @@ describe('cache related flags from core', () => { }); it('should assign cache build dependencies correctly when cache type is filesystem in config', () => { - let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js']); + const cacheLocation = path.resolve( + __dirname, + '../../node_modules/.cache/webpack/cache-core-flag-test-build-dependencies-in-config', + ); + + rimraf.sync(cacheLocation); + + let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler-cache' starting..."); @@ -137,7 +214,7 @@ describe('cache related flags from core', () => { // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); // Run again to check for cache - ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js'])); + ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '--cache-cache-location', cacheLocation])); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler-cache' starting..."); @@ -146,6 +223,8 @@ describe('cache related flags from core', () => { }); it('should assign cache build dependencies with multiple configs', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/config-cache')); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js']); expect(exitCode).toBe(0); @@ -158,18 +237,32 @@ describe('cache related flags from core', () => { }); it('should assign cache build dependencies with default config', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem']); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-development')); + + const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--name', 'cache-core-flag-test']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toContain("Compilation 'cache-core-flag-test' starting..."); + expect(stderr).toContain("Compilation 'cache-core-flag-test' finished"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); expect(stdout).toContain("type: 'filesystem'"); }); it('should assign cache build dependencies with merged configs', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js', '--merge']); + const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-merge'); + + rimraf.sync(cacheLocation); + + const { exitCode, stderr, stdout } = run(__dirname, [ + '-c', + './webpack.cache.config.js', + '-c', + './webpack.config.js', + '--merge', + '--cache-cache-location', + cacheLocation, + ]); expect(exitCode).toBe(0); expect(stderr).toContain("Compilation 'compiler' starting..."); @@ -181,6 +274,9 @@ describe('cache related flags from core', () => { }); it('should invalidate cache when config changes', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/default-development')); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/default-production')); + // Creating a temporary webpack config writeFileSync(resolve(__dirname, './webpack.test.config.js'), 'module.exports = {mode: "development"}'); From 69e6cdf4cf1bb12336af924995d6fc14612d117e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 3 Dec 2020 21:42:50 +0530 Subject: [PATCH 130/581] docs: remove old commands references (#2168) --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 432b673c228..b663b3f5956 100644 --- a/README.md +++ b/README.md @@ -62,12 +62,6 @@ Thus, webpack CLI provides different commands for many common tasks. - [`webpack-cli loader`](./packages/generate-loader/README.md#webpack-cli-generate-loader) - Initiate new loader project. - [`webpack-cli serve`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading. -> Removed commands since v3.3.3 - -- `webpack-cli add` - Add new properties to a webpack configuration file. -- `webpack-cli remove` - Remove properties from a webpack configuration file. -- `webpack-cli update` - Update properties in a webpack configuration file. - ### Utilities The project also has several utility packages which are used by other commands From dfe76674d83289bf61377fee437f1bee70744a0e Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 3 Dec 2020 20:01:41 +0300 Subject: [PATCH 131/581] fix: size of json stats (#2174) --- packages/webpack-cli/lib/webpack-cli.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 5830df34c34..97aecfda24f 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -487,9 +487,9 @@ class WebpackCLI { : getStatsOptionsFromCompiler(compiler); if (args.json === true) { - process.stdout.write(JSON.stringify(stats.toJson(foundStats), null, 2) + '\n'); + process.stdout.write(JSON.stringify(stats.toJson(foundStats)) + '\n'); } else if (typeof args.json === 'string') { - const JSONStats = JSON.stringify(stats.toJson(foundStats), null, 2); + const JSONStats = JSON.stringify(stats.toJson(foundStats)); try { writeFileSync(args.json, JSONStats); From 5c0aaddc4197cfa53304e4e5625a3583ff8e1b33 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 4 Dec 2020 17:01:43 +0530 Subject: [PATCH 132/581] tests: add more unit tests for info (#2169) --- packages/info/__tests__/info.test.ts | 33 +++++++++++++++++++++ packages/info/src/index.ts | 2 +- packages/webpack-cli/__tests__/info.test.js | 33 +++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 packages/info/__tests__/info.test.ts diff --git a/packages/info/__tests__/info.test.ts b/packages/info/__tests__/info.test.ts new file mode 100644 index 00000000000..4af729dd408 --- /dev/null +++ b/packages/info/__tests__/info.test.ts @@ -0,0 +1,33 @@ +import info from '../src/index'; + +describe('info tests', () => { + it('should log environment info', async () => { + const envInfo = await info(); + + expect(envInfo).toContain('System'); + expect(envInfo).toContain('Binaries'); + expect(envInfo).toContain('Browsers'); + }); + + it('should log environment info as json', async () => { + const envInfo = await info('--output', 'json'); + + const parse = (): void => { + const output = JSON.parse(envInfo); + expect(output['System']).toBeTruthy(); + expect(output['Binaries']).toBeTruthy(); + expect(output['System']['OS']).toBeTruthy(); + expect(output['System']['CPU']).toBeTruthy(); + }; + + expect(parse).not.toThrow(); + }); + + it('should log environment info as markdown', async () => { + const envInfo = await info('--output', 'markdown'); + + expect(envInfo).toContain('## System'); + expect(envInfo).toContain('## Binaries'); + expect(envInfo).toContain('## Browsers'); + }); +}); diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index fc8e0c23eab..abebf8db9a8 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -31,7 +31,7 @@ const DEFAULT_DETAILS: Information = { npmPackages: '*webpack*', }; -export default async function info(...args): Promise { +export default async function info(...args): Promise { const cli = new WebpackCLI(); const { flags: infoFlags } = commands.find((cmd) => cmd.name === 'info'); const parsedArgs = cli.argParser(infoFlags, args, true); diff --git a/packages/webpack-cli/__tests__/info.test.js b/packages/webpack-cli/__tests__/info.test.js index a09309e7311..1011216ed38 100644 --- a/packages/webpack-cli/__tests__/info.test.js +++ b/packages/webpack-cli/__tests__/info.test.js @@ -3,22 +3,25 @@ const path = require('path'); describe('Info', () => { it('should run with cli', () => { - const { stdout, stderr } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info'], { + const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info'], { cwd: path.resolve(__dirname), reject: false, }); + + expect(exitCode).toBe(0); expect(stdout).toContain('System'); expect(stdout).toContain('Binaries'); expect(stdout).toContain('OS'); expect(stderr).toBeFalsy(); }); - it('should work with flags', () => { - const { stdout, stderr } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=json'], { + it('should respect --output=json', () => { + const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=json'], { cwd: path.resolve(__dirname), reject: false, }); + expect(exitCode).toBe(0); const testJSON = () => { const output = JSON.parse(stdout); expect(output['System']).toBeTruthy(); @@ -27,4 +30,28 @@ describe('Info', () => { expect(testJSON).not.toThrow(); expect(stderr).toBeFalsy(); }); + + it('should respect --output=markdown', () => { + const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=markdown'], { + cwd: path.resolve(__dirname), + reject: false, + }); + + expect(exitCode).toBe(0); + expect(stdout).toContain('## System'); + expect(stdout).toContain('## Binaries'); + expect(stdout).toContain('## Browsers'); + expect(stderr).toBeFalsy(); + }); + + it('should throw an error for invalid output type', () => { + const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=test'], { + cwd: path.resolve(__dirname), + reject: false, + }); + + expect(exitCode).toBe(2); + expect(stderr).toContain("'test' is not a valid value for output"); + expect(stdout).toBeFalsy(); + }); }); From 27edb2f1be321cc77bff24dce862f2378f50f7b2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 4 Dec 2020 17:08:22 +0530 Subject: [PATCH 133/581] docs: update output config related flags (#2176) --- packages/webpack-cli/README.md | 66 ++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 98f473c502a..9e5a8a9f482 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -266,11 +266,16 @@ yarn add webpack-cli --dev unused exports and generate more efficient code. --output-asset-module-filename string The filename of asset modules as relative path inside the `output.path` directory. - --output-chunk-callback-name string The callback function name used by webpack for loading of chunks in - WebWorkers. - --output-chunk-filename string The filename of non-entry chunks as relative path inside the `output.path` + --output-charset Add charset attribute for script tag. + --output-chunk-filename string The filename of non-initial chunks as relative path inside the `output.path` directory. + --output-chunk-format string The format of chunks (formats included by default are 'array-push' + (web/WebWorker), 'commonjs' (node.js), but others might be added by plugins). --output-chunk-load-timeout number Number of milliseconds before chunk request expires. + --output-chunk-loading string The method of loading chunks (methods included by default are 'jsonp' (web), + 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async + node.js), but others might be added by plugins). + --output-chunk-loading-global string The global variable used by webpack for loading of chunks. --output-compare-before-emit Check if to be emitted file already exists and have the same content before writing to output filesystem. --output-cross-origin-loading string This option enables cross-origin loading of chunks. @@ -282,11 +287,32 @@ yarn add webpack-cli --dev sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries. - --output-ecma-version number The maximum EcmaScript version of the webpack generated code (doesn't include - input source code from modules). - --output-enabled-library-types string[] Type of library. + --output-enabled-chunk-loading-types string[] The method of loading chunks (methods included by default are 'jsonp' (web), + 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async + node.js), but others might be added by plugins). + --output-enabled-chunk-loading-types-reset Clear all items provided in configuration. List of chunk loading types + enabled for use by entry points. + --output-enabled-library-types string[] Type of library (types included by default are 'var', 'module', 'assign', + 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs- + module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others + might be added by plugins). --output-enabled-library-types-reset Clear all items provided in configuration. List of library types enabled for use by entry points. + --output-enabled-wasm-loading-types string[] The method of loading WebAssembly Modules (methods included by default are + 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by + plugins). + --output-enabled-wasm-loading-types-reset Clear all items provided in configuration. List of wasm loading types enabled + for use by entry points. + --output-environment-arrow-function The environment supports arrow functions ('() => { ... }'). + --output-environment-big-int-literal The environment supports BigInt as literal (123n). + --output-environment-const The environment supports const and let for variable declarations. + --output-environment-destructuring The environment supports destructuring ('{ a, b } = obj'). + --output-environment-dynamic-import The environment supports an async import() function to import EcmaScript + modules. + --output-environment-for-of The environment supports 'for of' iteration ('for (const x of array) { ... + }'). + --output-environment-module The environment supports EcmaScript Module syntax to import EcmaScript + modules (import ... from '...'). --output-filename string Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual @@ -299,12 +325,12 @@ yarn add webpack-cli --dev --output-hash-salt string Any string which is added to the hash to salt it. --output-hot-update-chunk-filename string The filename of the Hot Update Chunks. They are inside the output.path directory. - --output-hot-update-function string The JSONP function used by webpack for async loading of hot update chunks. + --output-hot-update-global string The global variable used by webpack for loading of hot update chunks. --output-hot-update-main-filename string The filename of the Hot Update Main File. It is inside the `output.path` directory. --output-iife Wrap javascript code into IIFE's to avoid leaking into global scope. --output-import-function-name string The name of the native import() function (can be exchanged for a polyfill). - --output-jsonp-function string The JSONP function used by webpack for async loading of chunks. + --output-import-meta-name string The name of the native import.meta object (can be exchanged for a polyfill). --output-library string[] A part of the library name. --output-library-reset Clear all items provided in configuration. The name of the library (some types allow unnamed libraries too). @@ -329,11 +355,14 @@ yarn add webpack-cli --dev --output-library-name-root string[] Part of the name of the property exposed globally by a UMD library. --output-library-name-root-reset Clear all items provided in configuration. Name of the property exposed globally by a UMD library. - --output-library-type string Type of library. + --output-library-type string Type of library (types included by default are 'var', 'module', 'assign', + 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs- + module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others + might be added by plugins). --output-library-umd-named-define If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module. --output-module Output javascript files as module source type. - --output-path string The output directory as **absolute path** (required). + -o, --output-path string Output location of the file generated by webpack e.g. ./dist/ --output-pathinfo Include comments with information about the modules. --output-public-path string The `publicPath` specifies the public URL address of the output files when referenced in a browser. @@ -345,8 +374,17 @@ yarn add webpack-cli --dev --output-strict-module-exception-handling Handles exceptions in module loading correctly at a performance cost. --output-unique-name string A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. + --output-wasm-loading string The method of loading WebAssembly Modules (methods included by default are + 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by + plugins). --output-webassembly-module-filename string The filename of WebAssembly modules as relative path inside the `output.path` directory. + --output-worker-chunk-loading string The method of loading chunks (methods included by default are 'jsonp' (web), + 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async + node.js), but others might be added by plugins). + --output-worker-wasm-loading string The method of loading WebAssembly Modules (methods included by default are + 'fetch' (web/WebWorker), 'async-node' (node.js), but others migby + plugins). --parallelism number The number of parallel processed modules in the compilation. --performance Configuration for web performance recommendations. --performance-hints string Sets the format of the hints: warnings, errors or nothing at all. @@ -642,7 +680,15 @@ yarn add webpack-cli --dev --no-optimization-split-chunks Negates optimization-split-chunks --no-optimization-split-chunks-hide-path-info Negates optimization-split-chunks-hide-path-info --no-optimization-used-exports Negates optimization-used-exports + --no-output-charset Negates output-charset --no-output-compare-before-emit Negates output-compare-before-emit + --no-output-environment-arrow-function Negates output-environment-arrow-function + --no-output-environment-big-int-literal Negates output-environment-big-int-literal + --no-output-environment-const Negates output-environment-const + --no-output-environment-destructuring Negates output-environment-destructuring + --no-output-environment-dynamic-import Negates output-environment-dynamic-import + --no-output-environment-for-of Negates output-environment-for-of + --no-output-environment-module Negates output-environment-module --no-output-iife Negates output-iife --no-output-library-umd-named-define Negates output-library-umd-named-define --no-output-module Negates output-module From 9049205612ff71fa131d4324feb9d9d0c796d11a Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Sat, 5 Dec 2020 13:59:49 +0530 Subject: [PATCH 134/581] tests: add test for array config err (#2179) * tests: add test for array config err * tests: add test for array config err --- .eslintignore | 1 + test/config/error-array/config-array-error.test.js | 11 +++++++++++ test/config/error-array/src/index.js | 1 + test/config/error-array/webpack.config.js | 10 ++++++++++ 4 files changed, 23 insertions(+) create mode 100644 test/config/error-array/config-array-error.test.js create mode 100644 test/config/error-array/src/index.js create mode 100644 test/config/error-array/webpack.config.js diff --git a/.eslintignore b/.eslintignore index 27d5a60ae35..74003544d4f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -15,3 +15,4 @@ test/**/binary/ test/**/index.js test/typescript/webpack.config.ts test/config/error/syntax-error.js +test/config/error-array/webpack.config.js diff --git a/test/config/error-array/config-array-error.test.js b/test/config/error-array/config-array-error.test.js new file mode 100644 index 00000000000..6d125ece893 --- /dev/null +++ b/test/config/error-array/config-array-error.test.js @@ -0,0 +1,11 @@ +'use strict'; +const { run } = require('../../utils/test-utils'); + +describe('array config error', () => { + it('should throw syntax error and exit with non-zero exit code when even 1 object has syntax error', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js']); + expect(exitCode).toBe(2); + expect(stderr).toContain('SyntaxError: Unexpected token'); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/config/error-array/src/index.js b/test/config/error-array/src/index.js new file mode 100644 index 00000000000..cbea29ce7a9 --- /dev/null +++ b/test/config/error-array/src/index.js @@ -0,0 +1 @@ +console.log('Tartaglia Childe'); diff --git a/test/config/error-array/webpack.config.js b/test/config/error-array/webpack.config.js new file mode 100644 index 00000000000..643c58c2168 --- /dev/null +++ b/test/config/error-array/webpack.config.js @@ -0,0 +1,10 @@ +module.exports = [ + { + name: 'kiryu', + target: 'node', // no error + }, + { + name: 'config-error', + target: 'node'; // error eslint-ignore + } +] From d78f26a7d2bc362943eda742a8e42c9c118eb422 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 5 Dec 2020 14:03:45 +0530 Subject: [PATCH 135/581] chore: update webpack to 5.10.0 (#2183) --- package.json | 2 +- test/core-flags/output-flags.test.js | 7 +++++++ yarn.lock | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 93ebe097a0e..434defb46bd 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", "typescript": "^3.9.7", - "webpack": "^5.3.0", + "webpack": "^5.10.0", "webpack-bundle-analyzer": "^3.9.0", "webpack-dev-server": "^3.11.0", "yeoman-test": "^2.7.0" diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index a186374f048..ab6e9067667 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -131,6 +131,13 @@ describe('output config related flag', () => { expect(stderr).toContain("Compilation 'compiler' starting..."); expect(stderr).toContain("Compilation 'compiler' finished"); expect(stdout).toContain('test'); + } else if (flag.name === 'output-pathinfo') { + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'verbose']); + + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'compiler' starting..."); + expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stdout).toContain(`pathinfo: 'verbose'`); } else if (flag.name === 'output-worker-chunk-loading') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); diff --git a/yarn.lock b/yarn.lock index 759c9b4e343..38d21cab521 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9294,6 +9294,13 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +pkg-dir@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-5.0.0.tgz#a02d6aebe6ba133a928f74aec20bafdfe6b8e760" + integrity sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA== + dependencies: + find-up "^5.0.0" + please-upgrade-node@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942" @@ -11681,10 +11688,10 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.3.0: - version "5.9.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.9.0.tgz#af2e9cf9d6c7867cdcf214ea3bb5eb77aece6895" - integrity sha512-YnnqIV/uAS5ZrNpctSv378qV7HmbJ74DL+XfvMxzbX1bV9e7eeT6eEWU4wuUw33CNr/HspBh7R/xQlVjTEyAeA== +webpack@^5.10.0: + version "5.10.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.10.0.tgz#6f77c31522a2c525152d9c344f9765d168b3df08" + integrity sha512-P0bHAXmIz0zsNcHNLqFmLY1ZtrT+jtBr7FqpuDtA2o7GiHC+zBsfhgK7SmJ1HG7BAEb3G9JoMdSVi7mEDvG3Zg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" @@ -11704,7 +11711,7 @@ webpack@^5.3.0: loader-runner "^4.1.0" mime-types "^2.1.27" neo-async "^2.6.2" - pkg-dir "^4.2.0" + pkg-dir "^5.0.0" schema-utils "^3.0.0" tapable "^2.1.1" terser-webpack-plugin "^5.0.3" From f3c7b064c69126426d919a06a327430d1a29eefa Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Sat, 5 Dec 2020 15:29:57 +0530 Subject: [PATCH 136/581] tests: use sync fs for output check (#2177) --- .../function-with-argv.test.js | 16 ++++------------ .../array-function-with-env.test.js | 16 ++++------------ .../function-with-argv.test.js | 11 +++-------- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/test/config/type/array-function-with-argv/function-with-argv.test.js b/test/config/type/array-function-with-argv/function-with-argv.test.js index 82077a230a5..9a65b47e4cb 100644 --- a/test/config/type/array-function-with-argv/function-with-argv.test.js +++ b/test/config/type/array-function-with-argv/function-with-argv.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('array of function with args', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); @@ -14,15 +14,7 @@ describe('array of function with args', () => { expect(stderr).toContain("Compilation 'second' finished"); expect(stdout).toBeTruthy(); - stat(resolve(__dirname, './dist/a-dev.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - stat(resolve(__dirname, './dist/b-dev.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './dist/a-dev.js'))); + expect(existsSync(resolve(__dirname, './dist/b-dev.js'))); }); }); diff --git a/test/config/type/array-function-with-env/array-function-with-env.test.js b/test/config/type/array-function-with-env/array-function-with-env.test.js index 5f1621b9c98..a90d258a55f 100644 --- a/test/config/type/array-function-with-env/array-function-with-env.test.js +++ b/test/config/type/array-function-with-env/array-function-with-env.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('array of functions with env', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); @@ -14,15 +14,7 @@ describe('array of functions with env', () => { expect(stderr).toContain("Compilation 'second' finished"); expect(stdout).toBeTruthy(); - stat(resolve(__dirname, './dist/a-dev.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - }); - - stat(resolve(__dirname, './dist/b-dev.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './dist/a-dev.js'))); + expect(existsSync(resolve(__dirname, './dist/b-dev.js'))); }); }); diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index 35b6c34527c..c75e62c1a78 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -1,10 +1,10 @@ 'use strict'; -const { stat } = require('fs'); +const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); describe('function configuration', () => { - it('is able to understand a configuration file as a function', (done) => { + it('is able to understand a configuration file as a function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); @@ -12,11 +12,6 @@ describe('function configuration', () => { expect(stderr).toContain('Compilation finished'); expect(stdout).toBeTruthy(); expect(stdout).toContain("argv: { mode: 'development' }"); - - stat(resolve(__dirname, './dist/dev.js'), (err, stats) => { - expect(err).toBe(null); - expect(stats.isFile()).toBe(true); - done(); - }); + expect(existsSync(resolve(__dirname, './dist/dev.js'))); }); }); From 3e5f946be58a4a8bc3f00c2d86f4ad1913af1715 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 5 Dec 2020 15:50:18 +0300 Subject: [PATCH 137/581] chore(deps-dev): bump husky from 4.3.0 to 4.3.4 (#2187) Bumps [husky](https://github.com/typicode/husky) from 4.3.0 to 4.3.4. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](https://github.com/typicode/husky/compare/v4.3.0...v4.3.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 38d21cab521..dbd81da87ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6278,9 +6278,9 @@ humanize-ms@^1.2.1: ms "^2.0.0" husky@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.0.tgz#0b2ec1d66424e9219d359e26a51c58ec5278f0de" - integrity sha512-tTMeLCLqSBqnflBZnlVDhpaIMucSGaYyX6855jM4AguGeWCeSzNdb1mfyWduTZ3pe3SJVvVWGL0jO1iKZVPfTA== + version "4.3.4" + resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.4.tgz#676275a10ec5be2e893bd6ff71113bb829cc1f5b" + integrity sha512-wykHsss5kQtmbFrjQv0R7YyW1uFd7fv7gT1sA54potoDYmOTENJtBC/X1/AyoSAi1obp8CiGODOIdOGnPxSmFg== dependencies: chalk "^4.0.0" ci-info "^2.0.0" From 39c1eec3a6ed431884e088ecd1a4887af7c20965 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Sat, 5 Dec 2020 18:30:21 +0530 Subject: [PATCH 138/581] tests: add tests for multitype flag (#2186) --- .../webpack-cli/__tests__/arg-parser.test.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/webpack-cli/__tests__/arg-parser.test.js b/packages/webpack-cli/__tests__/arg-parser.test.js index 60dc543030d..e70a39279bb 100644 --- a/packages/webpack-cli/__tests__/arg-parser.test.js +++ b/packages/webpack-cli/__tests__/arg-parser.test.js @@ -106,6 +106,13 @@ const basicOptions = [ delete opts.processorFlag; }, }, + { + name: 'env', + usage: '--env', + type: String, + multipleType: true, + description: 'Environment passed to the configuration when it is a function', + }, ]; const helpAndVersionOptions = basicOptions.slice(0); @@ -432,12 +439,12 @@ describe('arg-parser', () => { expect(warnMock.mock.calls.length).toEqual(0); }); - it('parses --processor-flag', () => { - const res = argParser(basicOptions, ['--processor-flag'], true); + it('parses --env flag', () => { + const res = argParser(basicOptions, ['--env', 'production', '--env', 'platform=staging'], true); expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - processed: true, - stringFlagWithDefault: 'default-value', + expect(res.opts.env).toEqual({ + platform: 'staging', + production: true, }); expect(warnMock.mock.calls.length).toEqual(0); }); From 615dafd86baa67daa0d3c86408e34bdd66e57458 Mon Sep 17 00:00:00 2001 From: James George Date: Sat, 5 Dec 2020 19:47:54 +0530 Subject: [PATCH 139/581] fix: update description for --color flag (#2188) --- packages/webpack-cli/lib/utils/cli-flags.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 20649d51f08..4f9c56b08bc 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -181,7 +181,7 @@ const builtInFlags = [ usage: '--color', type: Boolean, negative: true, - description: 'Enable/Disable colors on console', + description: 'Enable colors on console', }, // For webpack@4 From eda0663fc842f5655615a6dd917aced9439e1b46 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 5 Dec 2020 17:29:11 +0300 Subject: [PATCH 140/581] chore(deps-dev): bump lint-staged from 10.5.2 to 10.5.3 (#2181) Bumps [lint-staged](https://github.com/okonet/lint-staged) from 10.5.2 to 10.5.3. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v10.5.2...v10.5.3) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index dbd81da87ee..453450df01e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7665,9 +7665,9 @@ lines-and-columns@^1.1.6: integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= lint-staged@^10.5.0: - version "10.5.2" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.2.tgz#acfaa0093af3262aee3130b2e22438941530bdd1" - integrity sha512-e8AYR1TDlzwB8VVd38Xu2lXDZf6BcshVqKVuBQThDJRaJLobqKnpbm4dkwJ2puypQNbLr9KF/9mfA649mAGvjA== + version "10.5.3" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.3.tgz#c682838b3eadd4c864d1022da05daa0912fb1da5" + integrity sha512-TanwFfuqUBLufxCc3RUtFEkFraSPNR3WzWcGF39R3f2J7S9+iF9W0KTVLfSy09lYGmZS5NDCxjNvhGMSJyFCWg== dependencies: chalk "^4.1.0" cli-truncate "^2.1.0" From ec426069b7fb5680416e1ffe82ff4eee6e56e3af Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 7 Dec 2020 15:34:14 +0530 Subject: [PATCH 141/581] docs: add example commit messages (#2192) --- .github/CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 267f4227d61..5d090dcee53 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -230,6 +230,14 @@ to read on GitHub as well as in several git tools. For more information about what each part of the template mean, head up to the documentation in the [angular repo](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits) +#### Example commit message + +``` +feat(webpack-cli): allow multiple values for --stats + +docs: update README.md +``` + ## Migrate with the CLI ```sh From 0e37183dffabf2acb5779d3af02186d387663aae Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 7 Dec 2020 16:05:42 +0530 Subject: [PATCH 142/581] tests: respect cli args when config is an array (#2198) --- test/config/type/array/array.test.js | 16 +++++++++++++++- test/config/type/array/webpack.config.js | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/config/type/array/array.test.js b/test/config/type/array/array.test.js index c4757aa379f..5cb2267e933 100644 --- a/test/config/type/array/array.test.js +++ b/test/config/type/array/array.test.js @@ -3,7 +3,7 @@ const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../../../utils/test-utils'); -describe('array', () => { +describe('array config', () => { it('is able to understand a configuration file in array format', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); @@ -16,4 +16,18 @@ describe('array', () => { expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); }); + + it('respect cli args with config as an array', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'none'], false); + + expect(exitCode).toBe(0); + expect(stderr).toContain("Compilation 'amd' starting..."); + expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toContain("Compilation 'commonjs' starting..."); + expect(stderr).toContain("Compilation 'commonjs' finished"); + // should not print anything because of stats: none + expect(stdout).toBeFalsy(); + expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); + }); }); diff --git a/test/config/type/array/webpack.config.js b/test/config/type/array/webpack.config.js index ffc4f604abb..e8ca27db5fa 100644 --- a/test/config/type/array/webpack.config.js +++ b/test/config/type/array/webpack.config.js @@ -7,6 +7,7 @@ module.exports = [ name: 'amd', entry: './a.js', mode: 'development', + stats: 'verbose', devtool: 'eval-cheap-module-source-map', }, { @@ -17,6 +18,7 @@ module.exports = [ name: 'commonjs', entry: './a.js', mode: 'development', + stats: 'detailed', target: 'node', }, ]; From 9bf4e925757b02f7252073501562c95e762dc59b Mon Sep 17 00:00:00 2001 From: Roman Dvornov Date: Mon, 7 Dec 2020 11:53:41 +0100 Subject: [PATCH 143/581] fix: stringify stats using streaming approach (#2190) --- packages/webpack-cli/lib/webpack-cli.js | 29 ++++++++++++++----------- packages/webpack-cli/package.json | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 97aecfda24f..9525ad689a9 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -2,8 +2,9 @@ const path = require('path'); const packageExists = require('./utils/package-exists'); const webpack = packageExists('webpack') ? require('webpack') : undefined; const webpackMerge = require('webpack-merge'); -const { writeFileSync, existsSync } = require('fs'); +const { createWriteStream, existsSync } = require('fs'); const { options: coloretteOptions, yellow } = require('colorette'); +const { stringifyStream: createJsonStringifyStream } = require('@discoveryjs/json-ext'); const logger = require('./utils/logger'); const { cli, flags } = require('./utils/cli-flags'); @@ -485,21 +486,23 @@ class WebpackCLI { const foundStats = compiler.compilers ? { children: compiler.compilers.map(getStatsOptionsFromCompiler) } : getStatsOptionsFromCompiler(compiler); + const handleWriteError = (error) => { + logger.error(error); + process.exit(2); + }; if (args.json === true) { - process.stdout.write(JSON.stringify(stats.toJson(foundStats)) + '\n'); + createJsonStringifyStream(stats.toJson(foundStats)) + .on('error', handleWriteError) + .pipe(process.stdout) + .on('error', handleWriteError) + .on('close', () => process.stdout.write('\n')); } else if (typeof args.json === 'string') { - const JSONStats = JSON.stringify(stats.toJson(foundStats)); - - try { - writeFileSync(args.json, JSONStats); - - logger.success(`stats are successfully stored as json to ${args.json}`); - } catch (error) { - logger.error(error); - - process.exit(2); - } + createJsonStringifyStream(stats.toJson(foundStats)) + .on('error', handleWriteError) + .pipe(createWriteStream(args.json)) + .on('error', handleWriteError) + .on('close', () => logger.success(`stats are successfully stored as json to ${args.json}`)); } else { const printedStats = stats.toString(foundStats); diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index a9e87239e16..75bafaf5d32 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -27,6 +27,7 @@ "lib" ], "dependencies": { + "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/info": "^1.1.0", "@webpack-cli/serve": "^1.1.0", "colorette": "^1.2.1", From b8ff4220b310105c346720dff300155cf24aa2c5 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 7 Dec 2020 16:35:51 +0530 Subject: [PATCH 144/581] chore: better description for built-in negated flags (#2180) --- packages/webpack-cli/lib/groups/runHelp.js | 4 +++- packages/webpack-cli/lib/utils/cli-flags.js | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/groups/runHelp.js b/packages/webpack-cli/lib/groups/runHelp.js index fddbc79e38a..bc85fc5bb98 100644 --- a/packages/webpack-cli/lib/groups/runHelp.js +++ b/packages/webpack-cli/lib/groups/runHelp.js @@ -93,7 +93,9 @@ const outputHelp = (args) => { const negatedFlags = flags .filter((flag) => flag.negative) .reduce((allFlags, flag) => { - return [...allFlags, { name: `no-${flag.name}`, description: `Negates ${flag.name}`, type: Boolean }]; + // Use available description for built-in negated flags + const description = flag.negatedDescription ? flag.negatedDescription : `Negates ${flag.name}`; + return [...allFlags, { name: `no-${flag.name}`, description, type: Boolean }]; }, []); const title = bold('⬡ ') + underline('webpack') + bold(' ⬡'); const desc = 'The build tool for modern web applications'; diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 4f9c56b08bc..320054ab06d 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -129,6 +129,7 @@ const builtInFlags = [ type: Boolean, negative: true, description: 'Enables Hot Module Replacement', + negatedDescription: 'Disables Hot Module Replacement', link: 'https://webpack.js.org/concepts/hot-module-replacement/', }, { @@ -182,6 +183,7 @@ const builtInFlags = [ type: Boolean, negative: true, description: 'Enable colors on console', + negatedDescription: 'Disable colors on console', }, // For webpack@4 @@ -217,6 +219,7 @@ const builtInFlags = [ negative: true, alias: 'd', description: 'Determine source maps to use', + negatedDescription: 'Do not generate source maps', link: 'https://webpack.js.org/configuration/devtool/#devtool', }, { @@ -239,6 +242,7 @@ const builtInFlags = [ type: [String, Boolean], negative: true, description: 'It instructs webpack on how to treat the stats e.g. verbose', + negatedDescription: 'Disable stats output', link: 'https://webpack.js.org/configuration/stats/#stats', }, { @@ -248,6 +252,7 @@ const builtInFlags = [ negative: true, alias: 'w', description: 'Watch for files changes', + negatedDescription: 'Do not watch for file changes', link: 'https://webpack.js.org/configuration/watch/', }, ]; From a050109a645f3e30efe3fc916e8a9f14d264fdac Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 7 Dec 2020 16:52:24 +0530 Subject: [PATCH 145/581] fix: update usage of flags with multiple types (#2195) --- packages/webpack-cli/lib/utils/cli-flags.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 320054ab06d..55748c5b78a 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -142,7 +142,7 @@ const builtInFlags = [ }, { name: 'progress', - usage: '--progress', + usage: '--progress | --progress profile', type: [Boolean, String], description: 'Print compilation progress during build', }, @@ -172,7 +172,7 @@ const builtInFlags = [ // Output options { name: 'json', - usage: '--json', + usage: '--json | --json ', type: [String, Boolean], alias: 'j', description: 'Prints result as JSON or store it in a file', @@ -238,7 +238,7 @@ const builtInFlags = [ }, { name: 'stats', - usage: '--stats ', + usage: '--stats | --stats ', type: [String, Boolean], negative: true, description: 'It instructs webpack on how to treat the stats e.g. verbose', From 8c6a89deb9185a199c956dbbff4f84f604399233 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 7 Dec 2020 19:06:19 +0530 Subject: [PATCH 146/581] chore: update yarn.lock (#2202) --- yarn.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yarn.lock b/yarn.lock index 453450df01e..db627b5bc66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1046,6 +1046,11 @@ resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-11.0.0.tgz#719cf05fcc1abb6533610a2e0f5dd1e61eac14fe" integrity sha512-VoNqai1vR5anRF5Tuh/+SWDFk7xi7oMwHrHrbm1BprYXjB2RJsWLhUrStMssDxEl5lW/z3EUdg8RvH/IUBccSQ== +"@discoveryjs/json-ext@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.0.tgz#d6cf8951ceb673db41861d544cef2f2e07ebcb4d" + integrity sha512-gX9Hx+2BMP5+yXfr4Agb+iBd9YiI729x38wbhfvRSkxQqfXnJUNy1nnyJWetYCvxnL1caWd1HqJnbQwVrgvgeA== + "@eslint/eslintrc@^0.2.1": version "0.2.1" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" From f411aed8fcd869598cbcaff9e052ce48aeea2c2c Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 7 Dec 2020 19:06:54 +0530 Subject: [PATCH 147/581] tests: add tests for nested multitype flag (#2193) --- .../webpack-cli/__tests__/arg-parser.test.js | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/__tests__/arg-parser.test.js b/packages/webpack-cli/__tests__/arg-parser.test.js index e70a39279bb..465672f5311 100644 --- a/packages/webpack-cli/__tests__/arg-parser.test.js +++ b/packages/webpack-cli/__tests__/arg-parser.test.js @@ -439,7 +439,7 @@ describe('arg-parser', () => { expect(warnMock.mock.calls.length).toEqual(0); }); - it('parses --env flag', () => { + it('parses multiType flag', () => { const res = argParser(basicOptions, ['--env', 'production', '--env', 'platform=staging'], true); expect(res.unknownArgs.length).toEqual(0); expect(res.opts.env).toEqual({ @@ -448,4 +448,33 @@ describe('arg-parser', () => { }); expect(warnMock.mock.calls.length).toEqual(0); }); + + it('parses nested multiType flag', () => { + const res = argParser(basicOptions, ['--env', 'a.b=d', '--env', 'a.b.c=d'], true); + expect(res.unknownArgs.length).toEqual(0); + expect(res.opts.env).toEqual({ + a: { + b: { + c: 'd', + }, + }, + }); + expect(warnMock.mock.calls.length).toEqual(0); + }); + + it('parses nested multiType flag with diff keys', () => { + const res = argParser(basicOptions, ['--env', 'a.b=c', '--env', 'd.e.f=g'], true); + expect(res.unknownArgs.length).toEqual(0); + expect(res.opts.env).toEqual({ + a: { + b: 'c', + }, + d: { + e: { + f: 'g', + }, + }, + }); + expect(warnMock.mock.calls.length).toEqual(0); + }); }); From 3f31702f622a54a7ccc378b878a87bad85508dac Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Mon, 7 Dec 2020 19:12:10 +0530 Subject: [PATCH 148/581] refactor: add mjs support (#2172) --- .eslintignore | 4 +-- .prettierignore | 3 +- packages/webpack-cli/lib/webpack-cli.js | 32 +++++++++++++++--- test/config-format/mjs/main.js | 1 + test/config-format/mjs/mjs.test.js | 18 ++++++++++ test/config-format/mjs/webpack.config.mjs | 11 +++++++ .../mjs-config/default-mjs-config.test.js | 33 +++++++++++++++++++ test/config/defaults/mjs-config/src/index.js | 1 + .../defaults/mjs-config/webpack.config.mjs | 6 ++++ .../config-error.test.js | 0 .../{error => error-commonjs}/src/index.js | 0 .../{error => error-commonjs}/syntax-error.js | 0 .../webpack.config.js | 0 test/config/error-mjs/config-error.test.js | 25 ++++++++++++++ test/config/error-mjs/src/index.js | 1 + test/config/error-mjs/syntax-error.mjs | 5 +++ test/config/error-mjs/webpack.config.mjs | 5 +++ 17 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 test/config-format/mjs/main.js create mode 100644 test/config-format/mjs/mjs.test.js create mode 100644 test/config-format/mjs/webpack.config.mjs create mode 100644 test/config/defaults/mjs-config/default-mjs-config.test.js create mode 100644 test/config/defaults/mjs-config/src/index.js create mode 100644 test/config/defaults/mjs-config/webpack.config.mjs rename test/config/{error => error-commonjs}/config-error.test.js (100%) rename test/config/{error => error-commonjs}/src/index.js (100%) rename test/config/{error => error-commonjs}/syntax-error.js (100%) rename test/config/{error => error-commonjs}/webpack.config.js (100%) create mode 100644 test/config/error-mjs/config-error.test.js create mode 100644 test/config/error-mjs/src/index.js create mode 100644 test/config/error-mjs/syntax-error.mjs create mode 100644 test/config/error-mjs/webpack.config.mjs diff --git a/.eslintignore b/.eslintignore index 74003544d4f..a61e3d3d029 100644 --- a/.eslintignore +++ b/.eslintignore @@ -14,5 +14,5 @@ test/**/bin/ test/**/binary/ test/**/index.js test/typescript/webpack.config.ts -test/config/error/syntax-error.js -test/config/error-array/webpack.config.js +test/config/error-commonjs/syntax-error.js +test/config/error-mjs/syntax-error.mjs diff --git a/.prettierignore b/.prettierignore index 7050c6118d6..b9e12bb5f96 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ test/**/dist/ test/**/bin/ test/**/binary/ test/**/index.js -test/config/error/syntax-error.js +test/config/error-commonjs/syntax-error.js +test/config/error-mjs/syntax-error.mjs packages/webpack-cli/__tests__/test-assets/.yo-rc.json test/build-errors/stats.json diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 9525ad689a9..6b3c7091037 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -22,7 +22,7 @@ class WebpackCLI { constructor() {} async resolveConfig(args) { - const loadConfig = (configPath) => { + const loadConfig = async (configPath) => { const ext = extname(configPath); const interpreted = Object.keys(jsVariants).find((variant) => variant === ext); @@ -30,10 +30,32 @@ class WebpackCLI { rechoir.prepare(extensions, configPath); } - let options; + const { pathToFileURL } = require('url'); + + let importESM; try { - options = require(configPath); + importESM = new Function('id', 'return import(id);'); + } catch (e) { + importESM = null; + } + + let options; + try { + try { + options = require(configPath); + } catch (error) { + if (pathToFileURL && importESM && error.code === 'ERR_REQUIRE_ESM') { + const urlForConfig = pathToFileURL(configPath); + + options = await importESM(urlForConfig); + options = options.default; + + return { options, path: configPath }; + } + + throw error; + } } catch (error) { logger.error(`Failed to load '${configPath}'`); logger.error(error); @@ -91,7 +113,7 @@ class WebpackCLI { process.exit(2); } - const loadedConfig = loadConfig(configPath); + const loadedConfig = await loadConfig(configPath); return evaluateConfig(loadedConfig, args); }), @@ -136,7 +158,7 @@ class WebpackCLI { } if (foundDefaultConfigFile) { - const loadedConfig = loadConfig(foundDefaultConfigFile.path); + const loadedConfig = await loadConfig(foundDefaultConfigFile.path); const evaluatedConfig = await evaluateConfig(loadedConfig, args); config.options = evaluatedConfig.options; diff --git a/test/config-format/mjs/main.js b/test/config-format/mjs/main.js new file mode 100644 index 00000000000..a00a3125ea3 --- /dev/null +++ b/test/config-format/mjs/main.js @@ -0,0 +1 @@ +console.log('You know who'); diff --git a/test/config-format/mjs/mjs.test.js b/test/config-format/mjs/mjs.test.js new file mode 100644 index 00000000000..20b6c4764f0 --- /dev/null +++ b/test/config-format/mjs/mjs.test.js @@ -0,0 +1,18 @@ +const { run } = require('../../utils/test-utils'); + +describe('webpack cli', () => { + it('should support mjs config format', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.mjs'], false, [], { DISABLE_V8_COMPILE_CACHE: true }); + + if (exitCode === 0) { + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + expect(stdout).toBeTruthy(); + } else { + expect(exitCode).toBe(2); + expect(/Cannot use import statement outside a module/.test(stderr) || /Unexpected token/.test(stderr)).toBe(true); + expect(stdout).toBeFalsy(); + } + }); +}); diff --git a/test/config-format/mjs/webpack.config.mjs b/test/config-format/mjs/webpack.config.mjs new file mode 100644 index 00000000000..6717d84042e --- /dev/null +++ b/test/config-format/mjs/webpack.config.mjs @@ -0,0 +1,11 @@ +import { fileURLToPath } from 'url'; +import path from 'path'; + +export default { + mode: 'production', + entry: './main.js', + output: { + path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), 'dist'), + filename: 'foo.bundle.js', + }, +}; diff --git a/test/config/defaults/mjs-config/default-mjs-config.test.js b/test/config/defaults/mjs-config/default-mjs-config.test.js new file mode 100644 index 00000000000..2c920c0e492 --- /dev/null +++ b/test/config/defaults/mjs-config/default-mjs-config.test.js @@ -0,0 +1,33 @@ +const fs = require('fs'); +const path = require('path'); +const { run, isWebpack5 } = require('../../../utils/test-utils'); + +describe('Default Config:', () => { + it('Should be able to pick mjs config by default', () => { + const { exitCode, stderr, stdout } = run(__dirname, [], false, [], { DISABLE_V8_COMPILE_CACHE: true }); + + if (exitCode === 0) { + expect(exitCode).toEqual(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + // default entry should be used + expect(stdout).toContain('./src/index.js'); + // should pick up the output path from config + expect(stdout).toContain('test-output'); + + if (!isWebpack5) { + expect(stdout).toContain('Hash'); + expect(stdout).toContain('Version'); + expect(stdout).toContain('Built at'); + expect(stdout).toContain('Time'); + } + + // check that the output file exists + expect(fs.existsSync(path.join(__dirname, '/dist/test-output.js'))).toBeTruthy(); + } else { + expect(exitCode).toEqual(2); + expect(stderr).toContain('Unexpected token'); + expect(stdout).toBeFalsy(); + } + }); +}); diff --git a/test/config/defaults/mjs-config/src/index.js b/test/config/defaults/mjs-config/src/index.js new file mode 100644 index 00000000000..278b015b7f7 --- /dev/null +++ b/test/config/defaults/mjs-config/src/index.js @@ -0,0 +1 @@ +console.log("Jotaro Kujo") diff --git a/test/config/defaults/mjs-config/webpack.config.mjs b/test/config/defaults/mjs-config/webpack.config.mjs new file mode 100644 index 00000000000..3c5c06d4449 --- /dev/null +++ b/test/config/defaults/mjs-config/webpack.config.mjs @@ -0,0 +1,6 @@ +export default { + mode: 'development', + output: { + filename: 'test-output.js', + }, +}; diff --git a/test/config/error/config-error.test.js b/test/config/error-commonjs/config-error.test.js similarity index 100% rename from test/config/error/config-error.test.js rename to test/config/error-commonjs/config-error.test.js diff --git a/test/config/error/src/index.js b/test/config/error-commonjs/src/index.js similarity index 100% rename from test/config/error/src/index.js rename to test/config/error-commonjs/src/index.js diff --git a/test/config/error/syntax-error.js b/test/config/error-commonjs/syntax-error.js similarity index 100% rename from test/config/error/syntax-error.js rename to test/config/error-commonjs/syntax-error.js diff --git a/test/config/error/webpack.config.js b/test/config/error-commonjs/webpack.config.js similarity index 100% rename from test/config/error/webpack.config.js rename to test/config/error-commonjs/webpack.config.js diff --git a/test/config/error-mjs/config-error.test.js b/test/config/error-mjs/config-error.test.js new file mode 100644 index 00000000000..3493cd2d472 --- /dev/null +++ b/test/config/error-mjs/config-error.test.js @@ -0,0 +1,25 @@ +'use strict'; +const { resolve } = require('path'); +const { run } = require('../../utils/test-utils'); + +describe('config error', () => { + it('should throw error with invalid configuration', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.mjs')], false, [], { + DISABLE_V8_COMPILE_CACHE: true, + }); + + expect(exitCode).toBe(2); + expect(/Invalid configuration object/.test(stderr) || /Unexpected token/.test(stderr)).toBe(true); + expect(stdout).toBeFalsy(); + }); + + it('should throw syntax error and exit with non-zero exit code', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.mjs')], false, [], { + DISABLE_V8_COMPILE_CACHE: true, + }); + + expect(exitCode).toBe(2); + expect(stderr).toContain('SyntaxError: Unexpected token'); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/config/error-mjs/src/index.js b/test/config/error-mjs/src/index.js new file mode 100644 index 00000000000..97bfc742a9b --- /dev/null +++ b/test/config/error-mjs/src/index.js @@ -0,0 +1 @@ +console.log('config error test'); diff --git a/test/config/error-mjs/syntax-error.mjs b/test/config/error-mjs/syntax-error.mjs new file mode 100644 index 00000000000..fec871d7a2b --- /dev/null +++ b/test/config/error-mjs/syntax-error.mjs @@ -0,0 +1,5 @@ +export default { + name: 'config-error', + mode: 'development', + target: 'node'; //SyntaxError: Unexpected token ';' +}; diff --git a/test/config/error-mjs/webpack.config.mjs b/test/config/error-mjs/webpack.config.mjs new file mode 100644 index 00000000000..2f7dc4a7e49 --- /dev/null +++ b/test/config/error-mjs/webpack.config.mjs @@ -0,0 +1,5 @@ +export default { + name: 'config-error', + mode: 'unknown', //error + target: 'node', +}; From 6cf6e4caca712ddb74d015052061745b60e79a27 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 7 Dec 2020 19:13:58 +0530 Subject: [PATCH 149/581] refactor: union loader and plugin generators to single package (#2075) --- packages/generate-loader/CHANGELOG.md | 48 ------------------ packages/generate-loader/README.md | 40 --------------- packages/generate-loader/package.json | 28 ----------- packages/generate-loader/src/index.ts | 22 --------- packages/generate-loader/tsconfig.json | 9 ---- packages/generate-plugin/CHANGELOG.md | 49 ------------------- packages/generate-plugin/README.md | 40 --------------- packages/generate-plugin/package.json | 28 ----------- packages/generate-plugin/src/index.ts | 22 --------- packages/generate-plugin/tsconfig.json | 9 ---- .../examples/simple/src/index.js.tpl | 0 .../examples/simple/src/lazy-module.js.tpl | 0 .../simple/src/static-esm-module.js.tpl | 0 .../examples/simple/webpack.config.js.tpl | 0 .../loader-template}/src/_index.js.tpl | 0 .../loader-template}/src/cjs.js.tpl | 0 .../test/fixtures/simple-file.js.tpl | 0 .../test/functional.test.js.tpl | 0 .../loader-template}/test/test-utils.js.tpl | 0 .../loader-template}/test/unit.test.js.tpl | 0 packages/generators/package.json | 1 + .../examples/simple/_webpack.config.js.tpl | 0 .../examples/simple/src/index.js.tpl | 0 .../examples/simple/src/lazy-module.js.tpl | 0 .../simple/src/static-esm-module.js.tpl | 0 .../plugin-template}/src/_index.js.tpl | 0 .../plugin-template}/src/cjs.js.tpl | 0 .../test/fixtures/simple-file.js.tpl | 0 .../test/functional.test.js.tpl | 0 .../plugin-template}/test/test-utils.js.tpl | 0 packages/generators/src/index.ts | 34 +++++++++++-- packages/generators/src/loader-generator.ts | 5 +- packages/generators/src/plugin-generator.ts | 5 +- packages/info/__tests__/info.test.ts | 4 +- packages/info/src/index.ts | 2 +- packages/init/src/index.ts | 2 +- packages/migrate/src/index.ts | 2 +- packages/serve/src/index.ts | 2 +- packages/webpack-cli/lib/utils/arg-parser.js | 2 +- packages/webpack-cli/lib/utils/cli-flags.js | 4 +- .../webpack-cli/lib/utils/resolve-command.js | 4 +- .../version/version-external-packages.test.js | 4 +- tsconfig.json | 2 - 43 files changed, 51 insertions(+), 317 deletions(-) delete mode 100644 packages/generate-loader/CHANGELOG.md delete mode 100644 packages/generate-loader/README.md delete mode 100644 packages/generate-loader/package.json delete mode 100644 packages/generate-loader/src/index.ts delete mode 100644 packages/generate-loader/tsconfig.json delete mode 100644 packages/generate-plugin/CHANGELOG.md delete mode 100644 packages/generate-plugin/README.md delete mode 100644 packages/generate-plugin/package.json delete mode 100644 packages/generate-plugin/src/index.ts delete mode 100644 packages/generate-plugin/tsconfig.json rename packages/{generate-loader/templates => generators/loader-template}/examples/simple/src/index.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/examples/simple/src/lazy-module.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/examples/simple/src/static-esm-module.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/examples/simple/webpack.config.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/src/_index.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/src/cjs.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/test/fixtures/simple-file.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/test/functional.test.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/test/test-utils.js.tpl (100%) rename packages/{generate-loader/templates => generators/loader-template}/test/unit.test.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/examples/simple/_webpack.config.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/examples/simple/src/index.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/examples/simple/src/lazy-module.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/examples/simple/src/static-esm-module.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/src/_index.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/src/cjs.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/test/fixtures/simple-file.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/test/functional.test.js.tpl (100%) rename packages/{generate-plugin/templates => generators/plugin-template}/test/test-utils.js.tpl (100%) diff --git a/packages/generate-loader/CHANGELOG.md b/packages/generate-loader/CHANGELOG.md deleted file mode 100644 index ee9faaeb027..00000000000 --- a/packages/generate-loader/CHANGELOG.md +++ /dev/null @@ -1,48 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.2...@webpack-cli/generate-loader@1.1.0) (2020-11-04) - -### Features - -- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1...@webpack-cli/generate-loader@1.0.2) (2020-10-19) - -**Note:** Version bump only for package @webpack-cli/generate-loader - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1-rc.1...@webpack-cli/generate-loader@1.0.1) (2020-10-10) - -### Bug Fixes - -- upgrade lock file ([#1885](https://github.com/webpack/webpack-cli/issues/1885)) ([8df291e](https://github.com/webpack/webpack-cli/commit/8df291eef0fad7c91d912b158b3c2915cddfacd1)) - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1-alpha.5...@webpack-cli/generate-loader@1.0.1-rc.1) (2020-10-06) - -### Bug Fixes - -- generated loader template ([#1720](https://github.com/webpack/webpack-cli/issues/1720)) ([a380a78](https://github.com/webpack/webpack-cli/commit/a380a785c296208af7017f547cd34cf72517f9da)) - -## [1.0.1-alpha.5](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1-alpha.4...@webpack-cli/generate-loader@1.0.1-alpha.5) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/generate-loader - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1-alpha.3...@webpack-cli/generate-loader@1.0.1-alpha.4) (2020-02-29) - -**Note:** Version bump only for package @webpack-cli/generate-loader - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1-alpha.2...@webpack-cli/generate-loader@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/generate-loader - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1-alpha.1...@webpack-cli/generate-loader@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/generate-loader - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-loader@1.0.1-alpha.0...@webpack-cli/generate-loader@1.0.1-alpha.1) (2020-02-23) - -### Bug Fixes - -- **init:** fix webpack config scaffold ([#1231](https://github.com/webpack/webpack-cli/issues/1231)) ([2dc495a](https://github.com/webpack/webpack-cli/commit/2dc495a8d050d28478c6c2533d7839e9ff78d76c)), closes [#1230](https://github.com/webpack/webpack-cli/issues/1230) diff --git a/packages/generate-loader/README.md b/packages/generate-loader/README.md deleted file mode 100644 index 8d719e8062a..00000000000 --- a/packages/generate-loader/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# webpack-cli generate-loader - -[![NPM Downloads][downloads]][downloads-url] - -## Description - -This package contains the logic to initiate new loader projects. - -## Installation - -```bash -npm i -D webpack-cli @webpack-cli/generate-loader -``` - -## Usage - -To run the package programmatically, install it as a dependency. When using the package programmatically, one does not have to install webpack-cli. - -### Node - -```js -const generateLoader = require('@webpack-cli/generate-loader').default; - -generateLoader(); -``` - -### CLI (via `webpack-cli`) - -```bash -npx webpack-cli loader -``` - -> Optionally specify a path for generating the loader template. - -```bash -npx webpack-cli loader [path] -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/generate-loader.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/generate-loader diff --git a/packages/generate-loader/package.json b/packages/generate-loader/package.json deleted file mode 100644 index fb8c6b72db1..00000000000 --- a/packages/generate-loader/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@webpack-cli/generate-loader", - "version": "1.1.0", - "description": "A scaffold for generating a loader", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "directories": { - "example": "examples", - "test": "test" - }, - "publishConfig": { - "access": "public" - }, - "keywords": [], - "license": "MIT", - "files": [ - "lib", - "templates" - ], - "dependencies": { - "@webpack-cli/generators": "^1.1.0", - "yeoman-environment": "^2.10.3" - }, - "peerDependencies": { - "webpack-cli": "4.x.x" - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/generate-loader/src/index.ts b/packages/generate-loader/src/index.ts deleted file mode 100644 index 599d39abf6d..00000000000 --- a/packages/generate-loader/src/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import yeoman from 'yeoman-environment'; -import { loaderGenerator } from '@webpack-cli/generators'; -import { utils } from 'webpack-cli'; - -const { logger } = utils; - -/** - * Runs a yeoman generator to create a new webpack loader project - * @returns {void} - */ - -export default function loaderCreator(...args: string[]): void { - const generationPath = args[0]; - const env = yeoman.createEnv([], { cwd: generationPath }); - const generatorName = 'webpack-loader-generator'; - - env.registerStub(loaderGenerator, generatorName); - - env.run(generatorName, () => { - logger.success('Loader template has been successfully scaffolded.'); - }); -} diff --git a/packages/generate-loader/tsconfig.json b/packages/generate-loader/tsconfig.json deleted file mode 100644 index ba2474fb584..00000000000 --- a/packages/generate-loader/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [{ "path": "../generators" }] -} diff --git a/packages/generate-plugin/CHANGELOG.md b/packages/generate-plugin/CHANGELOG.md deleted file mode 100644 index c23551f2743..00000000000 --- a/packages/generate-plugin/CHANGELOG.md +++ /dev/null @@ -1,49 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.2...@webpack-cli/generate-plugin@1.1.0) (2020-11-04) - -### Features - -- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1...@webpack-cli/generate-plugin@1.0.2) (2020-10-19) - -**Note:** Version bump only for package @webpack-cli/generate-plugin - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1-rc.1...@webpack-cli/generate-plugin@1.0.1) (2020-10-10) - -### Bug Fixes - -- upgrade lock file ([#1885](https://github.com/webpack/webpack-cli/issues/1885)) ([8df291e](https://github.com/webpack/webpack-cli/commit/8df291eef0fad7c91d912b158b3c2915cddfacd1)) - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1-alpha.5...@webpack-cli/generate-plugin@1.0.1-rc.1) (2020-10-06) - -### Bug Fixes - -- **packages:** make packages have correct main paths to index ([#1366](https://github.com/webpack/webpack-cli/issues/1366)) ([5dd7bd6](https://github.com/webpack/webpack-cli/commit/5dd7bd62046568481996e48328b15a335557f8ae)) -- generated plugin template ([#1717](https://github.com/webpack/webpack-cli/issues/1717)) ([1249e1e](https://github.com/webpack/webpack-cli/commit/1249e1e2c10ad2e2c1832fa1f2ac6f4b12dabd6c)) - -## [1.0.1-alpha.5](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1-alpha.4...@webpack-cli/generate-plugin@1.0.1-alpha.5) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/generate-plugin - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1-alpha.3...@webpack-cli/generate-plugin@1.0.1-alpha.4) (2020-02-29) - -**Note:** Version bump only for package @webpack-cli/generate-plugin - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1-alpha.2...@webpack-cli/generate-plugin@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/generate-plugin - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1-alpha.1...@webpack-cli/generate-plugin@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/generate-plugin - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generate-plugin@1.0.1-alpha.0...@webpack-cli/generate-plugin@1.0.1-alpha.1) (2020-02-23) - -### Bug Fixes - -- **init:** fix webpack config scaffold ([#1231](https://github.com/webpack/webpack-cli/issues/1231)) ([2dc495a](https://github.com/webpack/webpack-cli/commit/2dc495a8d050d28478c6c2533d7839e9ff78d76c)), closes [#1230](https://github.com/webpack/webpack-cli/issues/1230) diff --git a/packages/generate-plugin/README.md b/packages/generate-plugin/README.md deleted file mode 100644 index a4ed13673e7..00000000000 --- a/packages/generate-plugin/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# webpack-cli generate-plugin - -[![NPM Downloads][downloads]][downloads-url] - -## Description - -This package contains the logic to initiate new plugin projects. - -## Installation - -```bash -npm i -D webpack-cli @webpack-cli/generate-plugin -``` - -## Usage - -To run the package programmatically, install it as a dependency. When using the package programmatically, one does not have to install webpack-cli. - -### Node - -```js -const generatePlugin = require('@webpack-cli/generate-plugin').default; - -generatePlugin(); -``` - -### CLI (via `webpack-cli`) - -```bash -npx webpack-cli plugin -``` - -> Optionally specify a path for generating the plugin template. - -```bash -npx webpack-cli plugin [path] -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/generate-plugin.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/generate-plugin diff --git a/packages/generate-plugin/package.json b/packages/generate-plugin/package.json deleted file mode 100644 index 9d49f9d1ab4..00000000000 --- a/packages/generate-plugin/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@webpack-cli/generate-plugin", - "version": "1.1.0", - "description": "A scaffold for generating a plugin", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "directories": { - "example": "examples", - "test": "test" - }, - "publishConfig": { - "access": "public" - }, - "keywords": [], - "license": "MIT", - "files": [ - "lib", - "templates" - ], - "dependencies": { - "@webpack-cli/generators": "^1.1.0", - "yeoman-environment": "^2.10.3" - }, - "peerDependencies": { - "webpack-cli": "4.x.x" - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/generate-plugin/src/index.ts b/packages/generate-plugin/src/index.ts deleted file mode 100644 index 08bdb4b9a8e..00000000000 --- a/packages/generate-plugin/src/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { pluginGenerator } from '@webpack-cli/generators'; -import yeoman from 'yeoman-environment'; -import { utils } from 'webpack-cli'; - -const { logger } = utils; - -/** - * Runs a yeoman generator to create a new webpack plugin project - * @returns {void} - */ - -export default function pluginCreator(...args: string[]): void { - const generationPath = args[0]; - const env = yeoman.createEnv([], { cwd: generationPath }); - const generatorName = 'webpack-plugin-generator'; - - env.registerStub(pluginGenerator, generatorName); - - env.run(generatorName, () => { - logger.success('Plugin template has been successfully scaffolded.'); - }); -} diff --git a/packages/generate-plugin/tsconfig.json b/packages/generate-plugin/tsconfig.json deleted file mode 100644 index ba2474fb584..00000000000 --- a/packages/generate-plugin/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [{ "path": "../generators" }] -} diff --git a/packages/generate-loader/templates/examples/simple/src/index.js.tpl b/packages/generators/loader-template/examples/simple/src/index.js.tpl similarity index 100% rename from packages/generate-loader/templates/examples/simple/src/index.js.tpl rename to packages/generators/loader-template/examples/simple/src/index.js.tpl diff --git a/packages/generate-loader/templates/examples/simple/src/lazy-module.js.tpl b/packages/generators/loader-template/examples/simple/src/lazy-module.js.tpl similarity index 100% rename from packages/generate-loader/templates/examples/simple/src/lazy-module.js.tpl rename to packages/generators/loader-template/examples/simple/src/lazy-module.js.tpl diff --git a/packages/generate-loader/templates/examples/simple/src/static-esm-module.js.tpl b/packages/generators/loader-template/examples/simple/src/static-esm-module.js.tpl similarity index 100% rename from packages/generate-loader/templates/examples/simple/src/static-esm-module.js.tpl rename to packages/generators/loader-template/examples/simple/src/static-esm-module.js.tpl diff --git a/packages/generate-loader/templates/examples/simple/webpack.config.js.tpl b/packages/generators/loader-template/examples/simple/webpack.config.js.tpl similarity index 100% rename from packages/generate-loader/templates/examples/simple/webpack.config.js.tpl rename to packages/generators/loader-template/examples/simple/webpack.config.js.tpl diff --git a/packages/generate-loader/templates/src/_index.js.tpl b/packages/generators/loader-template/src/_index.js.tpl similarity index 100% rename from packages/generate-loader/templates/src/_index.js.tpl rename to packages/generators/loader-template/src/_index.js.tpl diff --git a/packages/generate-loader/templates/src/cjs.js.tpl b/packages/generators/loader-template/src/cjs.js.tpl similarity index 100% rename from packages/generate-loader/templates/src/cjs.js.tpl rename to packages/generators/loader-template/src/cjs.js.tpl diff --git a/packages/generate-loader/templates/test/fixtures/simple-file.js.tpl b/packages/generators/loader-template/test/fixtures/simple-file.js.tpl similarity index 100% rename from packages/generate-loader/templates/test/fixtures/simple-file.js.tpl rename to packages/generators/loader-template/test/fixtures/simple-file.js.tpl diff --git a/packages/generate-loader/templates/test/functional.test.js.tpl b/packages/generators/loader-template/test/functional.test.js.tpl similarity index 100% rename from packages/generate-loader/templates/test/functional.test.js.tpl rename to packages/generators/loader-template/test/functional.test.js.tpl diff --git a/packages/generate-loader/templates/test/test-utils.js.tpl b/packages/generators/loader-template/test/test-utils.js.tpl similarity index 100% rename from packages/generate-loader/templates/test/test-utils.js.tpl rename to packages/generators/loader-template/test/test-utils.js.tpl diff --git a/packages/generate-loader/templates/test/unit.test.js.tpl b/packages/generators/loader-template/test/unit.test.js.tpl similarity index 100% rename from packages/generate-loader/templates/test/unit.test.js.tpl rename to packages/generators/loader-template/test/unit.test.js.tpl diff --git a/packages/generators/package.json b/packages/generators/package.json index 2604b593e69..741d7cdef0e 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -17,6 +17,7 @@ "@webpack-cli/utils": "^1.1.0", "colorette": "^1.2.1", "log-symbols": "^4.0.0", + "yeoman-environment": "^2.10.3", "yeoman-generator": "^4.12.0" }, "peerDependencies": { diff --git a/packages/generate-plugin/templates/examples/simple/_webpack.config.js.tpl b/packages/generators/plugin-template/examples/simple/_webpack.config.js.tpl similarity index 100% rename from packages/generate-plugin/templates/examples/simple/_webpack.config.js.tpl rename to packages/generators/plugin-template/examples/simple/_webpack.config.js.tpl diff --git a/packages/generate-plugin/templates/examples/simple/src/index.js.tpl b/packages/generators/plugin-template/examples/simple/src/index.js.tpl similarity index 100% rename from packages/generate-plugin/templates/examples/simple/src/index.js.tpl rename to packages/generators/plugin-template/examples/simple/src/index.js.tpl diff --git a/packages/generate-plugin/templates/examples/simple/src/lazy-module.js.tpl b/packages/generators/plugin-template/examples/simple/src/lazy-module.js.tpl similarity index 100% rename from packages/generate-plugin/templates/examples/simple/src/lazy-module.js.tpl rename to packages/generators/plugin-template/examples/simple/src/lazy-module.js.tpl diff --git a/packages/generate-plugin/templates/examples/simple/src/static-esm-module.js.tpl b/packages/generators/plugin-template/examples/simple/src/static-esm-module.js.tpl similarity index 100% rename from packages/generate-plugin/templates/examples/simple/src/static-esm-module.js.tpl rename to packages/generators/plugin-template/examples/simple/src/static-esm-module.js.tpl diff --git a/packages/generate-plugin/templates/src/_index.js.tpl b/packages/generators/plugin-template/src/_index.js.tpl similarity index 100% rename from packages/generate-plugin/templates/src/_index.js.tpl rename to packages/generators/plugin-template/src/_index.js.tpl diff --git a/packages/generate-plugin/templates/src/cjs.js.tpl b/packages/generators/plugin-template/src/cjs.js.tpl similarity index 100% rename from packages/generate-plugin/templates/src/cjs.js.tpl rename to packages/generators/plugin-template/src/cjs.js.tpl diff --git a/packages/generate-plugin/templates/test/fixtures/simple-file.js.tpl b/packages/generators/plugin-template/test/fixtures/simple-file.js.tpl similarity index 100% rename from packages/generate-plugin/templates/test/fixtures/simple-file.js.tpl rename to packages/generators/plugin-template/test/fixtures/simple-file.js.tpl diff --git a/packages/generate-plugin/templates/test/functional.test.js.tpl b/packages/generators/plugin-template/test/functional.test.js.tpl similarity index 100% rename from packages/generate-plugin/templates/test/functional.test.js.tpl rename to packages/generators/plugin-template/test/functional.test.js.tpl diff --git a/packages/generate-plugin/templates/test/test-utils.js.tpl b/packages/generators/plugin-template/test/test-utils.js.tpl similarity index 100% rename from packages/generate-plugin/templates/test/test-utils.js.tpl rename to packages/generators/plugin-template/test/test-utils.js.tpl diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index c4b9a6dbbb1..ee56ed718e8 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -1,6 +1,34 @@ -import addonGenerator from './addon-generator'; -import initGenerator from './init-generator'; +import yeoman from 'yeoman-environment'; import loaderGenerator from './loader-generator'; import pluginGenerator from './plugin-generator'; +import addonGenerator from './addon-generator'; +import initGenerator from './init-generator'; + +import { utils } from 'webpack-cli'; + +const { logger } = utils; + +export { addonGenerator, initGenerator }; + +export default (args: Array, name: string): void => { + const generationPath = args[0]; + const env = yeoman.createEnv([], { cwd: generationPath }); + if (name === 'loader') { + const generatorName = 'webpack-loader-generator'; + + env.registerStub(loaderGenerator, generatorName); + + env.run(generatorName, () => { + logger.success('Loader template has been successfully scaffolded.'); + }); + } + if (name === 'plugin') { + const generatorName = 'webpack-plugin-generator'; + + env.registerStub(pluginGenerator, generatorName); -export { addonGenerator, initGenerator, loaderGenerator, pluginGenerator }; + env.run(generatorName, () => { + logger.success('Plugin template has been successfully scaffolded.'); + }); + } +}; diff --git a/packages/generators/src/loader-generator.ts b/packages/generators/src/loader-generator.ts index daf635206fb..e1b0c1ce33f 100644 --- a/packages/generators/src/loader-generator.ts +++ b/packages/generators/src/loader-generator.ts @@ -1,6 +1,7 @@ import path from 'path'; import addonGenerator from './addon-generator'; import { toKebabCase } from './utils/helpers'; + /** * Formats a string into webpack loader format * (eg: 'style-loader', 'raw-loader') @@ -25,7 +26,7 @@ export function makeLoaderName(name: string): string { * @extends {Generator} */ -const LoaderGenerator = addonGenerator( +export const LoaderGenerator = addonGenerator( [ { default: 'my-loader', @@ -36,7 +37,7 @@ const LoaderGenerator = addonGenerator( validate: (str: string): boolean => str.length > 0, }, ], - path.resolve(__dirname, '../../generate-loader/templates'), + path.resolve(__dirname, '../loader-template'), [ 'src/cjs.js.tpl', 'test/test-utils.js.tpl', diff --git a/packages/generators/src/plugin-generator.ts b/packages/generators/src/plugin-generator.ts index eada3e1de32..113bdf8322e 100644 --- a/packages/generators/src/plugin-generator.ts +++ b/packages/generators/src/plugin-generator.ts @@ -1,6 +1,7 @@ import path from 'path'; import addonGenerator from './addon-generator'; import { toKebabCase, toUpperCamelCase } from './utils/helpers'; + /** * A yeoman generator class for creating a webpack * plugin project. It adds some starter plugin code @@ -9,7 +10,7 @@ import { toKebabCase, toUpperCamelCase } from './utils/helpers'; * @class PluginGenerator * @extends {Generator} */ -const PluginGenerator = addonGenerator( +export const PluginGenerator = addonGenerator( [ { default: 'my-webpack-plugin', @@ -20,7 +21,7 @@ const PluginGenerator = addonGenerator( validate: (str: string): boolean => str.length > 0, }, ], - path.resolve(__dirname, '../../generate-plugin/templates'), + path.resolve(__dirname, '../plugin-template'), [ 'src/cjs.js.tpl', 'test/test-utils.js.tpl', diff --git a/packages/info/__tests__/info.test.ts b/packages/info/__tests__/info.test.ts index 4af729dd408..09327f8cbc1 100644 --- a/packages/info/__tests__/info.test.ts +++ b/packages/info/__tests__/info.test.ts @@ -10,7 +10,7 @@ describe('info tests', () => { }); it('should log environment info as json', async () => { - const envInfo = await info('--output', 'json'); + const envInfo = await info(['--output', 'json']); const parse = (): void => { const output = JSON.parse(envInfo); @@ -24,7 +24,7 @@ describe('info tests', () => { }); it('should log environment info as markdown', async () => { - const envInfo = await info('--output', 'markdown'); + const envInfo = await info(['--output', 'markdown']); expect(envInfo).toContain('## System'); expect(envInfo).toContain('## Binaries'); diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index abebf8db9a8..61ed9ffaac1 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -31,7 +31,7 @@ const DEFAULT_DETAILS: Information = { npmPackages: '*webpack*', }; -export default async function info(...args): Promise { +export default async function info(args = []): Promise { const cli = new WebpackCLI(); const { flags: infoFlags } = commands.find((cmd) => cmd.name === 'info'); const parsedArgs = cli.argParser(infoFlags, args, true); diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index 9d743b88825..290c4aa7763 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -16,7 +16,7 @@ const PATH_PREFIX = '--generation-path'; * followed up with a yeoman instance if there are packages. If not, it creates a defaultGenerator */ -export default function initializeInquirer(...args: string[]): Function | void { +export default function initializeInquirer(args: string[]): Function | void { const packages = args; const includesDefaultPrefix = packages.includes(AUTO_PREFIX); const generateConfig = packages.includes(CONFIG_PREFIX); diff --git a/packages/migrate/src/index.ts b/packages/migrate/src/index.ts index 1a14eccc127..1ff970c11f3 100644 --- a/packages/migrate/src/index.ts +++ b/packages/migrate/src/index.ts @@ -173,7 +173,7 @@ function runMigration(currentConfigPath: string, outputConfigPath: string): Prom * function. */ -export default async function migrate(...args: string[]): Promise { +export default async function migrate(args: string[]): Promise { const filePaths = args; if (!filePaths.length) { logger.error('\n ✖ Please specify a path to your webpack config\n'); diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 2fddad08321..e93ea60324e 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -11,7 +11,7 @@ const { logger } = utils; * @param {String[]} args - args processed from the CLI * @returns {Function} invokes the devServer API */ -export default function serve(...args: string[]): void { +export default function serve(args: string[]): void { try { // eslint-disable-next-line node/no-extraneous-require require('webpack-dev-server'); diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index 708ff698b28..13af2d47feb 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -44,7 +44,7 @@ const argParser = (options, args, argsOnly = false, name = '') => { .action(async () => { const cliArgs = args.slice(args.indexOf(cmd.name) + 1 || args.indexOf(cmd.alias) + 1); - return await require('./resolve-command')(cmd.packageName, ...cliArgs); + return await require('./resolve-command')(cmd.packageName, cliArgs, cmd.name); }); return parser; diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 55748c5b78a..b523de83e93 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -36,7 +36,7 @@ const commands = [ description: 'Migrate a configuration to a new version', }, { - packageName: '@webpack-cli/generate-loader', + packageName: '@webpack-cli/generators', name: 'loader', scope: 'external', alias: 'l', @@ -45,7 +45,7 @@ const commands = [ description: 'Scaffold a loader repository', }, { - packageName: '@webpack-cli/generate-plugin', + packageName: '@webpack-cli/generators', name: 'plugin', alias: 'p', scope: 'external', diff --git a/packages/webpack-cli/lib/utils/resolve-command.js b/packages/webpack-cli/lib/utils/resolve-command.js index c896d190f01..63ab6b85d57 100644 --- a/packages/webpack-cli/lib/utils/resolve-command.js +++ b/packages/webpack-cli/lib/utils/resolve-command.js @@ -3,7 +3,7 @@ const logger = require('./logger'); const packageExists = require('./package-exists'); const promptInstallation = require('./prompt-installation'); -const run = async (name, ...args) => { +const run = async (name, args, commandName) => { let packageLocation = packageExists(name); if (!packageLocation) { @@ -27,7 +27,7 @@ const run = async (name, ...args) => { loaded = loaded.default; } - return loaded(...args); + return loaded(args, commandName); }; module.exports = run; diff --git a/test/version/version-external-packages.test.js b/test/version/version-external-packages.test.js index f149527f1fd..bfd6f4ba23b 100644 --- a/test/version/version-external-packages.test.js +++ b/test/version/version-external-packages.test.js @@ -5,8 +5,8 @@ const initPkgJSON = require('../../packages/init/package.json'); const servePkgJSON = require('../../packages/serve/package.json'); const migratePkgJSON = require('../../packages/migrate/package.json'); const infoPkgJSON = require('../../packages/info/package.json'); -const pluginPkgJSON = require('../../packages/generate-plugin/package.json'); -const loaderPkgJSON = require('../../packages/generate-loader/package.json'); +const pluginPkgJSON = require('../../packages/generators/package.json'); +const loaderPkgJSON = require('../../packages/generators/package.json'); const cliPkgJSON = require('../../packages/webpack-cli/package.json'); describe('version flag with external packages', () => { diff --git a/tsconfig.json b/tsconfig.json index a4c30e6b785..2a8277f0cfb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,8 +20,6 @@ "declaration": true }, "references": [ - { "path": "packages/generate-loader" }, - { "path": "packages/generate-plugin" }, { "path": "packages/generators" }, { "path": "packages/info" }, { "path": "packages/init" }, From 12edbe3641380530158427a5d0342103f9ef597f Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 7 Dec 2020 19:17:38 +0530 Subject: [PATCH 150/581] tests: add tests for cli plugin resolver (#2194) --- .../__tests__/CLIPluginResolver.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 packages/webpack-cli/__tests__/CLIPluginResolver.test.js diff --git a/packages/webpack-cli/__tests__/CLIPluginResolver.test.js b/packages/webpack-cli/__tests__/CLIPluginResolver.test.js new file mode 100644 index 00000000000..ce71d6e935b --- /dev/null +++ b/packages/webpack-cli/__tests__/CLIPluginResolver.test.js @@ -0,0 +1,19 @@ +const webpackCLI = require('../lib/webpack-cli'); +const CLIPlugin = require('../lib/plugins/CLIPlugin'); + +const CLIPluginResolver = new webpackCLI().resolveCLIPlugin; + +describe('CLIPluginResolver', () => { + it('should add CLI plugin to single compiler object', async () => { + const result = await CLIPluginResolver({ options: {} }, { hot: true, prefetch: true }); + expect(result.options.plugins[0] instanceof CLIPlugin).toBeTruthy(); + expect(result.options.plugins[0].options).toEqual({ + configPath: undefined, + helpfulOutput: true, + hot: true, + progress: undefined, + prefetch: true, + analyze: undefined, + }); + }); +}); From 988d83d179f65083540c2a83247f6df264e5f2a2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 7 Dec 2020 19:22:54 +0530 Subject: [PATCH 151/581] tests: add more cases for stats tests (#2178) --- .../webpack-cli/__tests__/resolveArgs.test.js | 14 ++++++++ test/stats/config/stats.test.js | 34 ++++++++++++------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/packages/webpack-cli/__tests__/resolveArgs.test.js b/packages/webpack-cli/__tests__/resolveArgs.test.js index f199870cfb3..1eff36c414f 100644 --- a/packages/webpack-cli/__tests__/resolveArgs.test.js +++ b/packages/webpack-cli/__tests__/resolveArgs.test.js @@ -1,7 +1,13 @@ const { resolve } = require('path'); +const { version } = require('webpack'); const webpackCLI = require('../lib/webpack-cli'); const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; +const statsPresets = ['normal', 'detailed', 'errors-only', 'errors-warnings', 'minimal', 'verbose', 'none']; + +if (version.startsWith('5')) { + statsPresets.push('summary'); +} const basicResolver = new webpackCLI().resolveArguments; @@ -83,4 +89,12 @@ describe('BasicResolver', () => { expect(result.options.target).toEqual(option); }); }); + + statsPresets.map((preset) => { + it(`should handle ${preset} preset`, async () => { + const result = await basicResolver({ options: {} }, { stats: preset }); + + expect(result.options.stats).toEqual(preset); + }); + }); }); diff --git a/test/stats/config/stats.test.js b/test/stats/config/stats.test.js index 932e57f56ab..2eeb66671c7 100644 --- a/test/stats/config/stats.test.js +++ b/test/stats/config/stats.test.js @@ -1,9 +1,16 @@ /* eslint-disable node/no-extraneous-require */ 'use strict'; // eslint-disable-next-line node/no-unpublished-require -const { run } = require('../../utils/test-utils'); +const { run, isWebpack5 } = require('../../utils/test-utils'); const { version } = require('webpack'); +// 'normal' is used in webpack.config.js +const statsPresets = ['detailed', 'errors-only', 'errors-warnings', 'minimal', 'verbose', 'none']; + +if (isWebpack5) { + statsPresets.push('summary'); +} + describe('stats flag with config', () => { it('should compile without stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, []); @@ -18,17 +25,20 @@ describe('stats flag with config', () => { expect(stdout).toContain(`stats: 'normal'`); } }); - it('should compile with stats flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'errors-warnings']); - expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + for (const preset of statsPresets) { + it(`should override 'noramal' value in config with "${preset}"`, () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--stats', `${preset}`]); - if (version.startsWith('5')) { - expect(stdout).toContain(`stats: { preset: 'errors-warnings' }`); - } else { - expect(stdout).toContain(`stats: 'errors-warnings'`); - } - }); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting...'); + expect(stderr).toContain('Compilation finished'); + + if (isWebpack5) { + expect(stdout).toContain(`stats: { preset: '${preset}' }`); + } else { + expect(stdout).toContain(`stats: '${preset}'`); + } + }); + } }); From 53ed92616bd6050dccbc07a4a77010faceacc508 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 7 Dec 2020 20:33:20 +0530 Subject: [PATCH 152/581] refactor: rephrase error message (#2204) --- packages/webpack-cli/lib/webpack-cli.js | 2 +- test/config-name/config-name.test.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 6b3c7091037..084d1b6a992 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -194,7 +194,7 @@ class WebpackCLI { if (notfoundConfigNames.length > 0) { logger.error( - notfoundConfigNames.map((configName) => `Configuration with the "${configName}" name was not found.`).join(' '), + notfoundConfigNames.map((configName) => `Configuration with the name "${configName}" was not found.`).join(' '), ); process.exit(2); } diff --git a/test/config-name/config-name.test.js b/test/config-name/config-name.test.js index fa0cd7a554c..26d7a2324e0 100644 --- a/test/config-name/config-name.test.js +++ b/test/config-name/config-name.test.js @@ -51,7 +51,7 @@ describe('--config-name flag', () => { expect(exitCode).toBe(2); expect(stderr).not.toContain('Compilation starting...'); expect(stderr).not.toContain('Compilation finished'); - expect(stderr).toContain('Configuration with the "test" name was not found.'); + expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); @@ -61,7 +61,7 @@ describe('--config-name flag', () => { expect(exitCode).toBe(2); expect(stderr).not.toContain('Compilation starting...'); expect(stderr).not.toContain('Compilation finished'); - expect(stderr).toContain('Configuration with the "test" name was not found.'); + expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); @@ -75,8 +75,8 @@ describe('--config-name flag', () => { expect(exitCode).toBe(2); expect(stderr).not.toContain('Compilation starting...'); expect(stderr).not.toContain('Compilation finished'); - expect(stderr).toContain('Configuration with the "test" name was not found.'); - expect(stderr).toContain('Configuration with the "bar" name was not found.'); + expect(stderr).toContain('Configuration with the name "test" was not found.'); + expect(stderr).toContain('Configuration with the name "bar" was not found.'); expect(stdout).toBeFalsy(); }); @@ -90,8 +90,8 @@ describe('--config-name flag', () => { expect(exitCode).toBe(2); expect(stderr).not.toContain('Compilation starting...'); expect(stderr).not.toContain('Compilation finished'); - expect(stderr).not.toContain('Configuration with the "first" name was not found.'); - expect(stderr).toContain('Configuration with the "bar" name was not found.'); + expect(stderr).not.toContain('Configuration with the name "first" was not found.'); + expect(stderr).toContain('Configuration with the name "bar" was not found.'); expect(stdout).toBeFalsy(); }); @@ -129,7 +129,7 @@ describe('--config-name flag', () => { expect(exitCode).toBe(2); expect(stderr).not.toContain('Compilation starting...'); expect(stderr).not.toContain('Compilation finished'); - expect(stderr).toContain('Configuration with the "test" name was not found.'); + expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); }); From 5872d35af7d3cdba598bbaab601c6f29ba623de3 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 7 Dec 2020 21:10:45 +0530 Subject: [PATCH 153/581] ci: fix lint (#2208) --- .eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintignore b/.eslintignore index a61e3d3d029..7593c797b4a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -16,3 +16,4 @@ test/**/index.js test/typescript/webpack.config.ts test/config/error-commonjs/syntax-error.js test/config/error-mjs/syntax-error.mjs +test/config/error-array/webpack.config.js From c8fc7d1f195800c4fbe54ed6533e694f40fa7a1b Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 7 Dec 2020 23:08:47 +0530 Subject: [PATCH 154/581] fix: correct usage of cli-flags (#2205) --- packages/webpack-cli/lib/utils/cli-flags.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index b523de83e93..6a0c9ce10a9 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -89,7 +89,7 @@ const builtInFlags = [ // For configs { name: 'config', - usage: '--config ', + usage: '--config | --config --config ', alias: 'c', type: String, multiple: true, @@ -98,7 +98,7 @@ const builtInFlags = [ }, { name: 'config-name', - usage: '--config-name ', + usage: '--config-name | --config-name --config-name ', type: String, multiple: true, description: 'Name of the configuration to use', @@ -114,7 +114,7 @@ const builtInFlags = [ // Complex configs { name: 'env', - usage: '--env', + usage: '--env | --env --env ', type: String, multipleType: true, description: 'Environment passed to the configuration when it is a function', @@ -189,7 +189,7 @@ const builtInFlags = [ // For webpack@4 { name: 'entry', - usage: '--entry | --entry --entry ', + usage: '--entry | --entry --entry ', type: String, multiple: true, description: 'The entry point(s) of your application e.g. ./src/main.js', @@ -197,7 +197,7 @@ const builtInFlags = [ }, { name: 'output-path', - usage: '--output-path ', + usage: '--output-path ', alias: 'o', type: String, description: 'Output location of the file generated by webpack e.g. ./dist/', @@ -205,7 +205,7 @@ const builtInFlags = [ }, { name: 'target', - usage: '--target ', + usage: '--target | --target --target ', alias: 't', type: String, multiple: cli !== undefined, From d0acf3072edd8182c95e37997ac91789da899d66 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 8 Dec 2020 15:12:23 +0530 Subject: [PATCH 155/581] feat: display monorepos in info output (#2203) --- packages/info/src/index.ts | 2 ++ test/info/info-output.test.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index 61ed9ffaac1..db1fee91f4e 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -7,6 +7,7 @@ const { logger, commands } = utils; interface Information { Binaries?: string[]; Browsers?: string[]; + Monorepos?: string[]; System?: string[]; npmGlobalPackages?: string[]; npmPackages?: string | string[]; @@ -26,6 +27,7 @@ const DEFAULT_DETAILS: Information = { 'Safari', 'Safari Technology Preview', ], + Monorepos: ['Yarn Workspaces', 'Lerna'], System: ['OS', 'CPU', 'Memory'], npmGlobalPackages: ['webpack', 'webpack-cli'], npmPackages: '*webpack*', diff --git a/test/info/info-output.test.js b/test/info/info-output.test.js index 715ae9528b3..1587bcd611c 100644 --- a/test/info/info-output.test.js +++ b/test/info/info-output.test.js @@ -1,7 +1,7 @@ 'use strict'; const { red } = require('colorette'); - +const { join } = require('path'); const { runInfo } = require('../utils/test-utils'); describe('basic info usage', () => { @@ -16,6 +16,19 @@ describe('basic info usage', () => { expect(stderr).toHaveLength(0); }); + it('gets more info in project root', () => { + const { stdout, stderr } = runInfo([], join(__dirname, '../../')); + // stdout should include many details which will be + // unique for each computer + expect(stdout).toContain('System:'); + expect(stdout).toContain('Monorepos:'); + expect(stdout).toContain('Packages:'); + expect(stdout).toContain('Node'); + expect(stdout).toContain('npm'); + expect(stdout).toContain('Yarn'); + expect(stderr).toHaveLength(0); + }); + it('gets info as json', () => { const { stdout, stderr } = runInfo(['--output="json"'], __dirname); expect(stdout).toContain('"System":'); From 5ce9c771ec1503e0ed532e0fd50fd0e44cb8b833 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 13:06:50 +0300 Subject: [PATCH 156/581] chore(deps-dev): bump git-cz from 4.7.5 to 4.7.6 (#2210) Bumps [git-cz](https://github.com/streamich/git-cz) from 4.7.5 to 4.7.6. - [Release notes](https://github.com/streamich/git-cz/releases) - [Changelog](https://github.com/streamich/git-cz/blob/master/CHANGELOG.md) - [Commits](https://github.com/streamich/git-cz/compare/v4.7.5...v4.7.6) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index db627b5bc66..5e9279ed707 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5733,9 +5733,9 @@ gh-got@^5.0.0: is-plain-obj "^1.1.0" git-cz@^4.7.1: - version "4.7.5" - resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.5.tgz#9707efabc60ebb23e8d1e61469d195bdb91c49ad" - integrity sha512-FBzBE2gbadDXQEIV/yq5lPZt4UTXLK1+RwsnAM6K6AA9/Wwtvr6pLgX1+g/V7h1grl9gXIlIXu7srbdGxoJPqA== + version "4.7.6" + resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.6.tgz#1250c486f01724e801a630b848fd8786f7e67e90" + integrity sha512-WtQEXqetJSi9LKPI77bMdSQWvLGjE93egVbR0zjXd1KFKrFvo/YE/UuGNcMeBDiwzxfQBhjyV7Hn0YUZ8Q0BcQ== git-raw-commits@2.0.0: version "2.0.0" From a13f5e9d6d60384378eaa9ee2a5264005263487f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 13:07:01 +0300 Subject: [PATCH 157/581] chore(deps-dev): bump @types/jest from 26.0.16 to 26.0.17 (#2211) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.16 to 26.0.17. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5e9279ed707..111dd03d60d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2390,9 +2390,9 @@ "@types/istanbul-lib-report" "*" "@types/jest@26.x", "@types/jest@^26.0.15": - version "26.0.16" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c" - integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g== + version "26.0.17" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.17.tgz#c63b44af7528bbc05974dfacc2c90fe13ed5534d" + integrity sha512-5sy3dHuiT/nJGM0XZ8ozFgdR4Y/gmi89n2OCDthTULSi8nG3YdcSDVuxYT3X7eN62NGXWJYz2oNOpDp/aIaynQ== dependencies: jest-diff "^26.0.0" pretty-format "^26.0.0" From 34e661ed39c19c1794dce4f99e4cee18107296bd Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 13:07:11 +0300 Subject: [PATCH 158/581] chore(deps-dev): bump husky from 4.3.4 to 4.3.5 (#2200) Bumps [husky](https://github.com/typicode/husky) from 4.3.4 to 4.3.5. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](https://github.com/typicode/husky/compare/v4.3.4...v4.3.5) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 111dd03d60d..ecc3abbf51a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6283,9 +6283,9 @@ humanize-ms@^1.2.1: ms "^2.0.0" husky@^4.3.0: - version "4.3.4" - resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.4.tgz#676275a10ec5be2e893bd6ff71113bb829cc1f5b" - integrity sha512-wykHsss5kQtmbFrjQv0R7YyW1uFd7fv7gT1sA54potoDYmOTENJtBC/X1/AyoSAi1obp8CiGODOIdOGnPxSmFg== + version "4.3.5" + resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.5.tgz#ab8d2a0eb6b62fef2853ee3d442c927d89290902" + integrity sha512-E5S/1HMoDDaqsH8kDF5zeKEQbYqe3wL9zJDyqyYqc8I4vHBtAoxkDBGXox0lZ9RI+k5GyB728vZdmnM4bYap+g== dependencies: chalk "^4.0.0" ci-info "^2.0.0" From 718338c8d725f4a2f361b437bc01763a218bdf8e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 13:07:22 +0300 Subject: [PATCH 159/581] chore(deps-dev): bump eslint from 7.14.0 to 7.15.0 (#2185) Bumps [eslint](https://github.com/eslint/eslint) from 7.14.0 to 7.15.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.14.0...v7.15.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 84 +++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/yarn.lock b/yarn.lock index ecc3abbf51a..7dd6361d8b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1051,10 +1051,10 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.0.tgz#d6cf8951ceb673db41861d544cef2f2e07ebcb4d" integrity sha512-gX9Hx+2BMP5+yXfr4Agb+iBd9YiI729x38wbhfvRSkxQqfXnJUNy1nnyJWetYCvxnL1caWd1HqJnbQwVrgvgeA== -"@eslint/eslintrc@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" - integrity sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA== +"@eslint/eslintrc@^0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.2.tgz#d01fc791e2fc33e88a29d6f3dc7e93d0cd784b76" + integrity sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ== dependencies: ajv "^6.12.4" debug "^4.1.1" @@ -2794,7 +2794,7 @@ acorn-globals@^6.0.0: acorn "^7.1.1" acorn-walk "^7.1.1" -acorn-jsx@^5.2.0: +acorn-jsx@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b" integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng== @@ -4938,12 +4938,12 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.14.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.14.0.tgz#2d2cac1d28174c510a97b377f122a5507958e344" - integrity sha512-5YubdnPXrlrYAFCKybPuHIAH++PINe1pmKNc5wQRB9HSbqIK1ywAnntE3Wwua4giKu0bjligf1gLF6qxMGOYRA== + version "7.15.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.15.0.tgz#eb155fb8ed0865fcf5d903f76be2e5b6cd7e0bc7" + integrity sha512-Vr64xFDT8w30wFll643e7cGrIkPEU50yIiI36OdSIDoSGguIeaLzBo0vpGvzo9RECUqq7htURfwEtKqwytkqzA== dependencies: "@babel/code-frame" "^7.0.0" - "@eslint/eslintrc" "^0.2.1" + "@eslint/eslintrc" "^0.2.2" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -4953,10 +4953,10 @@ eslint@^7.12.1: eslint-scope "^5.1.1" eslint-utils "^2.1.0" eslint-visitor-keys "^2.0.0" - espree "^7.3.0" + espree "^7.3.1" esquery "^1.2.0" esutils "^2.0.2" - file-entry-cache "^5.0.1" + file-entry-cache "^6.0.0" functional-red-black-tree "^1.0.1" glob-parent "^5.0.0" globals "^12.1.0" @@ -4980,13 +4980,13 @@ eslint@^7.12.1: text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^7.3.0: - version "7.3.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" - integrity sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw== +espree@^7.3.0, espree@^7.3.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" + integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g== dependencies: acorn "^7.4.0" - acorn-jsx "^5.2.0" + acorn-jsx "^5.3.1" eslint-visitor-keys "^1.3.0" esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0: @@ -5308,12 +5308,12 @@ figures@^3.0.0, figures@^3.2.0: dependencies: escape-string-regexp "^1.0.5" -file-entry-cache@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" - integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== +file-entry-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.0.tgz#7921a89c391c6d93efec2169ac6bf300c527ea0a" + integrity sha512-fqoO76jZ3ZnYrXLDRxBR1YvOvc0k844kcOg40bgsPrE25LAb/PDqTY+ho64Xh2c8ZXgIKldchCFHczG2UVRcWA== dependencies: - flat-cache "^2.0.1" + flat-cache "^3.0.4" file-uri-to-path@1.0.0: version "1.0.0" @@ -5449,19 +5449,18 @@ first-chunk-stream@^2.0.0: dependencies: readable-stream "^2.0.2" -flat-cache@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" - integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== +flat-cache@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" + integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== dependencies: - flatted "^2.0.0" - rimraf "2.6.3" - write "1.0.3" + flatted "^3.1.0" + rimraf "^3.0.2" -flatted@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" - integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== +flatted@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.0.tgz#a5d06b4a8b01e3a63771daa5cb7a1903e2e57067" + integrity sha512-tW+UkmtNg/jv9CSofAKvgVcO7c2URjhTdW1ZTkcAritblu8tajiYy7YisnIflEwtKssCtOxpnBRoCB7iap0/TA== flow-parser@0.*: version "0.137.0" @@ -10019,13 +10018,6 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@2.6.3, rimraf@~2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== - dependencies: - glob "^7.1.3" - rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" @@ -10040,6 +10032,13 @@ rimraf@^3.0.0, rimraf@^3.0.2: dependencies: glob "^7.1.3" +rimraf@~2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + rsvp@^4.8.4: version "4.8.5" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" @@ -11921,13 +11920,6 @@ write-pkg@^3.1.0: sort-keys "^2.0.0" write-json-file "^2.2.0" -write@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" - integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== - dependencies: - mkdirp "^0.5.1" - ws@^6.0.0, ws@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb" From e540d21082a62b8ccf7159c5046bf8bdf68c7d14 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 8 Dec 2020 15:38:02 +0530 Subject: [PATCH 160/581] feat: allow basic & verbose help output (#2151) --- packages/webpack-cli/README.md | 20 +++ packages/webpack-cli/lib/groups/runHelp.js | 125 +++++++++++++------ packages/webpack-cli/lib/utils/arg-parser.js | 4 +- packages/webpack-cli/lib/utils/cli-flags.js | 22 +++- test/help/help-single-arg.test.js | 34 ++++- 5 files changed, 160 insertions(+), 45 deletions(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 9e5a8a9f482..9c9312ad353 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -30,6 +30,26 @@ yarn add webpack-cli --dev ## Supported arguments and commands +### Help Usage + +You display basic commands and arguments - + +```bash +npx webpack-cli --help +``` + +To display all supported commands and arguments - + +```bash +npx webpack-cli --help=verbose +``` + +or + +```bash +npx webpack-cli --help verbose +``` + ### Available Commands ``` diff --git a/packages/webpack-cli/lib/groups/runHelp.js b/packages/webpack-cli/lib/groups/runHelp.js index bc85fc5bb98..d9499ead471 100644 --- a/packages/webpack-cli/lib/groups/runHelp.js +++ b/packages/webpack-cli/lib/groups/runHelp.js @@ -13,7 +13,15 @@ const outputHelp = (args) => { const hasUnknownVersionArgs = (args, commands, flags) => { return args.filter((arg) => { - if (arg === 'version' || arg === 'help' || arg === '--help' || arg === '-h' || arg === '--no-color') { + if ( + arg === 'version' || + arg === 'help' || + arg === '--help' || + arg === '-h' || + arg === '--no-color' || + arg === 'verbose' || + arg === '--help=verbose' + ) { return false; } @@ -90,48 +98,91 @@ const outputHelp = (args) => { logger.raw(flags); } } else { - const negatedFlags = flags - .filter((flag) => flag.negative) - .reduce((allFlags, flag) => { - // Use available description for built-in negated flags - const description = flag.negatedDescription ? flag.negatedDescription : `Negates ${flag.name}`; - return [...allFlags, { name: `no-${flag.name}`, description, type: Boolean }]; - }, []); + let flagsToDisplay = flags.filter(({ help }) => help === 'base'); // basic options only one word + + const negatedFlags = (allFlags) => { + return allFlags + .filter((flag) => flag.negative) + .reduce((allFlags, flag) => { + // Use available description for built-in negated flags + const description = flag.negatedDescription ? flag.negatedDescription : `Negates ${flag.name}`; + return [...allFlags, { name: `no-${flag.name}`, description, type: Boolean }]; + }, []); + }; + const title = bold('⬡ ') + underline('webpack') + bold(' ⬡'); const desc = 'The build tool for modern web applications'; const websitelink = ' ' + underline('https://webpack.js.org'); const usage = bold('Usage') + ': ' + '`' + green('webpack [...options] | ') + '`'; const examples = bold('Example') + ': ' + '`' + green('webpack help --flag | ') + '`'; const hh = ` ${title}\n\n${websitelink}\n\n${desc}\n\n${usage}\n${examples}`; - const output = commandLineUsage([ - { content: hh, raw: true }, - { - header: 'Available Commands', - content: commands.map((cmd) => { - return { name: `${cmd.name} | ${cmd.alias}`, summary: cmd.description }; - }), - }, - { - header: 'Options', - optionList: flags - .map((e) => { - if (e.type.length > 1) { - e.type = e.type[0]; - } - - // Here we replace special characters with chalk's escape - // syntax (`\$&`) to avoid chalk trying to re-process our input. - // This is needed because chalk supports a form of `{var}` - // interpolation. - e.description = e.description.replace(/[{}\\]/g, '\\$&'); - - return e; - }) - .concat(negatedFlags), - }, - ]); - - logger.raw(output); + + if (args.includes('verbose') || args.includes('--help=verbose')) { + flagsToDisplay = [...flags, ...negatedFlags(flags)]; + + const headerAndCommands = commandLineUsage([ + { content: hh, raw: true }, + { + header: 'Commands', + content: commands.map((cmd) => { + return { name: `${cmd.name} | ${cmd.alias}`, summary: cmd.description }; + }), + }, + { header: 'Options', raw: true }, + ]); + + // print help-header & commands + logger.raw(headerAndCommands); + // print all options + for (const flag of flagsToDisplay) { + let flagType; + + if (Array.isArray(flag.type)) { + const allowedTypes = flag.type.reduce((allTypes, type) => { + const currentType = flag.multiple ? `${type.name.toLowerCase()}[]` : type.name.toLowerCase(); + return [...allTypes, currentType]; + }, []); + flagType = allowedTypes.join(', '); + } else { + flagType = `${flag.type.name.toLowerCase()}${flag.multiple ? '[]' : ''}`; + } + + logger.raw(`${underline(bold('Option'))} : --${flag.name}`); + logger.raw(`${underline(bold('Type'))} : ${flagType}`); + logger.raw(`${underline(bold('Description'))} : ${flag.description}\n`); + } + } else { + const output = commandLineUsage([ + { content: hh, raw: true }, + { header: "To see list of all supported commands and options run 'webpack-cli --help=verbose'" }, + { + header: 'Commands', + content: commands.map((cmd) => { + return { name: `${cmd.name} | ${cmd.alias}`, summary: cmd.description }; + }), + }, + { + header: 'Options', + optionList: flagsToDisplay + .map((e) => { + if (e.type.length > 1) { + e.type = e.type[0]; + } + + // Here we replace special characters with chalk's escape + // syntax (`\$&`) to avoid chalk trying to re-process our input. + // This is needed because chalk supports a form of `{var}` + // interpolation. + e.description = e.description.replace(/[{}\\]/g, '\\$&'); + + return e; + }) + .concat(negatedFlags(flagsToDisplay)), + }, + ]); + + logger.raw(output); + } } logger.raw(' Made with ♥️ by the webpack team'); diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index 13af2d47feb..68cbff6a1b3 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -16,7 +16,9 @@ const runVersion = require('../groups/runVersion'); */ const argParser = (options, args, argsOnly = false, name = '') => { // Use customized help output - if (args.includes('--help') || args.includes('help')) { + const showHelp = args.includes('--help') || args.includes('help') || args.includes('--help=verbose'); + // allow --help=verbose and --help verbose + if (showHelp || (showHelp && args.includes('verbose'))) { runHelp(args); process.exit(0); } diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 6a0c9ce10a9..34739ddd4f5 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -92,6 +92,7 @@ const builtInFlags = [ usage: '--config | --config --config ', alias: 'c', type: String, + help: 'base', multiple: true, description: 'Provide path to a webpack configuration file e.g. ./webpack.config.js', link: 'https://webpack.js.org/configuration/', @@ -100,6 +101,7 @@ const builtInFlags = [ name: 'config-name', usage: '--config-name | --config-name --config-name ', type: String, + help: 'verbose', multiple: true, description: 'Name of the configuration to use', }, @@ -108,6 +110,7 @@ const builtInFlags = [ usage: '--config --config --merge', alias: 'm', type: Boolean, + help: 'base', description: 'Merge two or more configurations using webpack-merge', link: 'https://github.com/survivejs/webpack-merge', }, @@ -116,6 +119,7 @@ const builtInFlags = [ name: 'env', usage: '--env | --env --env ', type: String, + help: 'base', multipleType: true, description: 'Environment passed to the configuration when it is a function', link: 'https://webpack.js.org/api/cli/#environment-options', @@ -127,6 +131,7 @@ const builtInFlags = [ usage: '--hot', alias: 'h', type: Boolean, + help: 'base', negative: true, description: 'Enables Hot Module Replacement', negatedDescription: 'Disables Hot Module Replacement', @@ -136,6 +141,7 @@ const builtInFlags = [ name: 'analyze', usage: '--analyze', type: Boolean, + help: 'base', multiple: false, description: 'It invokes webpack-bundle-analyzer plugin to get bundle information', link: 'https://github.com/webpack-contrib/webpack-bundle-analyzer', @@ -144,12 +150,14 @@ const builtInFlags = [ name: 'progress', usage: '--progress | --progress profile', type: [Boolean, String], + help: 'base', description: 'Print compilation progress during build', }, { name: 'prefetch', usage: '--prefetch ', type: String, + help: 'base', description: 'Prefetch this request', link: 'https://webpack.js.org/plugins/prefetch-plugin/', }, @@ -158,7 +166,8 @@ const builtInFlags = [ { name: 'help', usage: '--help', - type: Boolean, + type: [Boolean, String], + help: 'base', description: 'Outputs list of supported flags', }, { @@ -166,6 +175,7 @@ const builtInFlags = [ usage: '--version | --version ', alias: 'v', type: Boolean, + help: 'base', description: 'Get current version', }, @@ -174,6 +184,7 @@ const builtInFlags = [ name: 'json', usage: '--json | --json ', type: [String, Boolean], + help: 'base', alias: 'j', description: 'Prints result as JSON or store it in a file', }, @@ -181,6 +192,7 @@ const builtInFlags = [ name: 'color', usage: '--color', type: Boolean, + help: 'base', negative: true, description: 'Enable colors on console', negatedDescription: 'Disable colors on console', @@ -192,6 +204,7 @@ const builtInFlags = [ usage: '--entry | --entry --entry ', type: String, multiple: true, + help: 'base', description: 'The entry point(s) of your application e.g. ./src/main.js', link: 'https://webpack.js.org/concepts/#entry', }, @@ -200,6 +213,7 @@ const builtInFlags = [ usage: '--output-path ', alias: 'o', type: String, + help: 'verbose', description: 'Output location of the file generated by webpack e.g. ./dist/', link: 'https://webpack.js.org/configuration/output/#outputpath', }, @@ -208,6 +222,7 @@ const builtInFlags = [ usage: '--target | --target --target ', alias: 't', type: String, + help: 'base', multiple: cli !== undefined, description: 'Sets the build target e.g. node', link: 'https://webpack.js.org/configuration/target/#target', @@ -216,6 +231,7 @@ const builtInFlags = [ name: 'devtool', usage: '--devtool ', type: String, + help: 'base', negative: true, alias: 'd', description: 'Determine source maps to use', @@ -225,6 +241,7 @@ const builtInFlags = [ { name: 'mode', usage: '--mode ', + help: 'base', type: String, description: 'Defines the mode to pass to webpack', link: 'https://webpack.js.org/concepts/#mode', @@ -233,6 +250,7 @@ const builtInFlags = [ name: 'name', usage: '--name', type: String, + help: 'base', description: 'Name of the configuration. Used when loading multiple configurations.', link: 'https://webpack.js.org/configuration/other-options/#name', }, @@ -241,6 +259,7 @@ const builtInFlags = [ usage: '--stats | --stats ', type: [String, Boolean], negative: true, + help: 'base', description: 'It instructs webpack on how to treat the stats e.g. verbose', negatedDescription: 'Disable stats output', link: 'https://webpack.js.org/configuration/stats/#stats', @@ -249,6 +268,7 @@ const builtInFlags = [ name: 'watch', usage: '--watch', type: Boolean, + help: 'base', negative: true, alias: 'w', description: 'Watch for files changes', diff --git a/test/help/help-single-arg.test.js b/test/help/help-single-arg.test.js index 5ca743f87fd..afd7435fba3 100644 --- a/test/help/help-single-arg.test.js +++ b/test/help/help-single-arg.test.js @@ -19,7 +19,7 @@ describe('single help flag', () => { expect(stdout).toContain(example); }); - it('outputs help info with command syntax', () => { + it('outputs basic help info with command syntax', () => { const { exitCode, stderr, stdout } = run(__dirname, ['help'], false); expect(exitCode).toBe(0); @@ -27,21 +27,43 @@ describe('single help flag', () => { expect(stdout).toContain(helpHeader); }); - it('outputs help info with dashed syntax', () => { + it('outputs basic help info with dashed syntax', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--help'], false); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(helpHeader); + expect(stdout).toContain('--merge'); + expect(stdout).not.toContain('--config-name'); // verbose }); - it('creates a readable snapshot', () => { - const { stderr } = run(__dirname, ['--help'], false); + it('outputs advanced help info with dashed syntax', () => { + const { stdout, stderr, exitCode } = run(__dirname, ['--help', 'verbose'], false); - const serializer = require('jest-serializer-ansi'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(helpHeader); + expect(stdout).toContain('--config-name'); // verbose + expect(stdout).toContain('--config'); // base + }); + + it('outputs advanced help info with command syntax', () => { + const { stdout, stderr, exitCode } = run(__dirname, ['help', 'verbose'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(helpHeader); + expect(stdout).toContain('--config-name'); // verbose + expect(stdout).toContain('--config'); // base + }); - expect.addSnapshotSerializer(serializer); + it('outputs advanced help info with --help=verbose', () => { + const { stdout, stderr, exitCode } = run(__dirname, ['--help=verbose'], false); + expect(exitCode).toBe(0); + expect(stdout).toContain(helpHeader); + expect(stdout).toContain('--config-name'); // verbose + expect(stdout).toContain('--config'); // base expect(stderr).toBeFalsy(); }); }); From 581b928fffc9fab4e390696cb92cfc75d2de4f72 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 8 Dec 2020 13:31:58 +0300 Subject: [PATCH 161/581] tests: fix --- test/cache/cache.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index dae6085dc3a..6b257214427 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -34,8 +34,9 @@ describe('cache', () => { } }); - it('should work in multi compiler mode', () => { - rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-{first,second}-development')); + it.only('should work in multi compiler mode', () => { + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-first-development')); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-second-development')); let { exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'], false); From 99e2fbb3b36666cb37a94f6032960fd29d28e056 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 8 Dec 2020 16:41:56 +0530 Subject: [PATCH 162/581] tests: add more cases for target (#2207) --- test/target/flag-test/target-flag.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index 9a3d69bbccb..b761b9c7cc8 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -58,6 +58,22 @@ describe('--target flag', () => { expect(stdout).toContain(`target: [ 'node', 'async-node' ]`); }); + it('should throw an error for invalid target in multiple syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--target', 'node', '--target', 'invalid']); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`Error: Unknown target 'invalid'`); + expect(stdout).toBeFalsy(); + }); + + it('should throw an error for incompatible multiple targets', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--target', 'node', '--target', 'web']); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Error: Universal Chunk Loading is not implemented yet'); + expect(stdout).toBeFalsy(); + }); + it('should reset target from node to async-node with --target-reset', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target-reset', '--target', 'async-node']); From fd8f3d5abedca2df1a1cf0b0ad3655216b446cdb Mon Sep 17 00:00:00 2001 From: James George Date: Tue, 8 Dec 2020 16:56:18 +0530 Subject: [PATCH 163/581] fix: update usage info for migrate command (#2213) --- packages/webpack-cli/lib/utils/cli-flags.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 34739ddd4f5..dbbf824d2d0 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -32,7 +32,7 @@ const commands = [ name: 'migrate', alias: 'm', type: String, - usage: 'migrate', + usage: 'migrate [output-path]', description: 'Migrate a configuration to a new version', }, { From 9b3cc283d7b74aa3bb26fe36c6110436b016e0d9 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 8 Dec 2020 16:41:41 +0300 Subject: [PATCH 164/581] fix: reduce spammy logs (#2206) --- .../webpack-cli/__tests__/serve/serve.test.js | 6 +- packages/webpack-cli/lib/plugins/CLIPlugin.js | 16 ++--- test/analyze/analyze-flag.test.js | 3 +- test/bail/bail.test.js | 39 ++--------- test/build-errors/errors.test.js | 9 +-- test/build-warnings/warnings.test.js | 9 +-- test/cache/cache.test.js | 44 ++++-------- test/colors/colors.test.js | 70 +++++++------------ test/config-format/coffee/coffee.test.js | 6 +- test/config-format/commonjs/commonjs.test.js | 3 +- test/config-format/mjs/mjs.test.js | 3 +- .../custom-name/custom-name.test.js | 3 +- .../dotfolder-array/dotfolder-array.test.js | 5 +- .../dotfolder-single/dotfolder-single.test.js | 3 +- .../relative/basic-config.test.js | 6 +- test/config-name/config-name.test.js | 32 ++------- test/config/absent/config-absent.test.js | 2 - test/config/basic/basic-config.test.js | 3 +- .../basic-config/default-js-config.test.js | 3 +- .../cjs-config/default-cjs-config.test.js | 3 +- .../multiple-location-config.test.js | 3 +- .../dev-none-config.test.js | 3 +- .../mjs-config/default-mjs-config.test.js | 3 +- .../with-mode/multiple-config.test.js | 3 +- test/config/empty-array/empty-array.test.js | 3 +- .../empty-function/empty-function.test.js | 3 +- .../empty-promise/empty-promise.test.js | 3 +- test/config/empty/empty.test.js | 3 +- .../config/function/functional-config.test.js | 8 +-- .../multiple-with-one-compilation.test.js | 3 +- test/config/multiple/multiple-config.test.js | 7 +- .../no-config-object/no-config-object.test.js | 3 +- .../function-with-argv.test.js | 6 +- .../array-function-with-env.test.js | 6 +- .../array-functions/array-functions.test.js | 5 +- .../array-promises/array-promises.test.js | 6 +- test/config/type/array/array.test.js | 10 +-- .../function-array/function-array.test.js | 6 +- .../function-async/function-async.test.js | 3 +- .../function-promise/function-promise.test.js | 3 +- .../function-with-argv.test.js | 3 +- .../function-with-env.test.js | 24 +++---- test/config/type/function/function.test.js | 3 +- .../type/promise-array/promise-array.test.js | 3 +- .../promise-function/promise-function.test.js | 3 +- test/config/type/promise/promise.test.js | 3 +- test/core-flags/amd-flag.test.js | 3 +- test/core-flags/bail-flag.test.js | 6 +- test/core-flags/cache-flags.test.js | 57 +++++---------- test/core-flags/context-flag.test.js | 6 +- test/core-flags/dependencies-flag.test.js | 6 +- test/core-flags/devtool-flag.test.js | 8 +-- test/core-flags/entry-reset-flag.test.js | 5 +- test/core-flags/experiments-flag.test.js | 6 +- test/core-flags/externals-flags.test.js | 18 ++--- .../core-flags/infrastructure-logging.test.js | 6 +- test/core-flags/module-flags.test.js | 21 ++---- test/core-flags/node-flags.test.js | 9 +-- test/core-flags/optimization-flags.test.js | 33 +++------ test/core-flags/output-flags.test.js | 60 ++++++---------- test/core-flags/parallelism-flag.test.js | 5 +- test/core-flags/performance-flags.test.js | 9 +-- test/core-flags/profile-flag.test.js | 6 +- test/core-flags/records-flag.test.js | 9 +-- test/core-flags/resolve-flags.test.js | 12 ++-- test/core-flags/snapshot-flags.test.js | 6 +- test/core-flags/stats-flags.test.js | 24 +++---- test/core-flags/watch-flags.test.js | 15 ++-- test/defaults/output-defaults.test.js | 6 +- test/devtool/array/source-map-array.test.js | 10 +-- test/devtool/object/source-map-object.test.js | 9 +-- .../entry-with-command.test.js | 3 +- .../entry-with-config.test.js | 3 +- .../entry-with-config.test.js | 3 +- .../defaults-empty/entry-single-arg.test.js | 3 +- .../defaults-index/entry-multi-args.test.js | 6 +- test/entry/flag-entry/entry-with-flag.test.js | 15 ++-- .../multiple-entries/multi-entries.test.js | 6 +- test/env/array/array-env.test.js | 3 +- test/env/object/object-env.test.js | 3 +- test/error/error.test.js | 2 - test/hot/hot-flag.test.js | 5 +- test/invalid-schema/invalid-schema.test.js | 4 -- test/merge/config/merge-config.test.js | 8 +-- .../mode-single-arg/mode-single-arg.test.js | 15 ++-- .../mode-with-config/mode-with-config.test.js | 27 +++---- test/name/name.test.js | 3 +- test/no-hot/no-hot.test.js | 7 +- .../with-config/no-stats-with-config.test.js | 6 +- test/no-stats/with-flags/no-stats.test.js | 7 +- test/node/node.test.js | 9 +-- test/optimization/optimization.test.js | 5 +- .../output-named-bundles.test.js | 12 ++-- test/prefetch/prefetch.test.js | 8 +-- test/progress/progress-flag.test.js | 8 --- test/serve/basic/serve-basic.test.js | 17 ++--- test/serve/serve-variable/serve-basic.test.js | 3 +- .../serve-custom-config.test.js | 12 ++-- test/stats/cli-flags/stats.test.js | 6 +- test/stats/config/stats.test.js | 6 +- test/stats/watch/multi-webpack.config.js | 22 ++++++ test/stats/watch/stats-and-watch.test.js | 26 +++---- test/stats/watch/webpack.config.js | 13 +++- test/target/flag-test/target-flag.test.js | 12 ++-- test/target/node/node-test.test.js | 3 +- test/utils/cli-plugin-test/plugin.test.js | 3 +- test/utils/test-utils.js | 9 +-- test/utils/test-utils.test.js | 12 ++-- .../version/version-external-packages.test.js | 20 +++--- test/version/version-multi-args.test.js | 16 ++--- test/version/version-single-arg.test.js | 6 +- test/watch/watch-flag.test.js | 9 +-- .../entry-absent/zero-config.test.js | 3 +- .../entry-present/zero-config.test.js | 3 +- 114 files changed, 375 insertions(+), 749 deletions(-) diff --git a/packages/webpack-cli/__tests__/serve/serve.test.js b/packages/webpack-cli/__tests__/serve/serve.test.js index 77df7668eb2..de1111b9820 100644 --- a/packages/webpack-cli/__tests__/serve/serve.test.js +++ b/packages/webpack-cli/__tests__/serve/serve.test.js @@ -14,8 +14,7 @@ describe('Serve', () => { it('should run with cli', async () => { const { stderr, stdout } = await runServe([], __dirname); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -23,8 +22,7 @@ describe('Serve', () => { it('should work with flags', async () => { const { stderr, stdout } = await runServe(['--hot'], __dirname); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js index a57a1d17846..643088643e5 100644 --- a/packages/webpack-cli/lib/plugins/CLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -42,10 +42,10 @@ class CLIPlugin { setupHelpfulOutput(compiler) { const pluginName = 'webpack-cli'; - const getCompilationName = (compilation) => (compilation.name ? ` '${compilation.name}'` : ''); + const getCompilationName = () => (compiler.name ? ` '${compiler.name}'` : ''); - compiler.hooks.run.tap(pluginName, (compiler) => { - this.logger.info(`Compilation${getCompilationName(compiler)} starting...`); + compiler.hooks.run.tap(pluginName, () => { + this.logger.log(`Compilation${getCompilationName()} starting...`); }); compiler.hooks.watchRun.tap(pluginName, (compiler) => { @@ -55,22 +55,22 @@ class CLIPlugin { this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); } - this.logger.info(`Compilation${getCompilationName(compiler)} starting...`); + this.logger.log(`Compilation${getCompilationName()} starting...`); }); compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => { const date = new Date(changeTime * 1000); - this.logger.info(`File '${filename}' was modified`); + this.logger.log(`File '${filename}' was modified`); this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`); }); - (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, (stats) => { - this.logger.info(`Compilation${getCompilationName(stats.compilation)} finished`); + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => { + this.logger.log(`Compilation${getCompilationName()} finished`); process.nextTick(() => { if (compiler.watchMode) { - this.logger.info(`Compiler${getCompilationName(stats.compilation)} is watching files for updates...`); + this.logger.log(`Compiler${getCompilationName()} is watching files for updates...`); } }); }); diff --git a/test/analyze/analyze-flag.test.js b/test/analyze/analyze-flag.test.js index 15274c16c6e..972a00223eb 100644 --- a/test/analyze/analyze-flag.test.js +++ b/test/analyze/analyze-flag.test.js @@ -22,8 +22,7 @@ describe('--analyze flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './analyze.config.js', '--analyze']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('Webpack Bundle Analyzer saved report to'); expect(stdout.match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); }); diff --git a/test/bail/bail.test.js b/test/bail/bail.test.js index bddea2f0136..51f0121fc40 100644 --- a/test/bail/bail.test.js +++ b/test/bail/bail.test.js @@ -7,9 +7,7 @@ describe('bail and watch warning', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'bail-webpack.config.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -17,44 +15,34 @@ describe('bail and watch warning', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'no-bail-webpack.config.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should not log warning in not watch mode without the "watch" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'watch-webpack.config.js']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should not log warning without the "bail" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should not log warning without the "bail" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-webpack.config.js', '--watch']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); @@ -62,26 +50,13 @@ describe('bail and watch warning', () => { it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-and-watch-webpack.config.js']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); it('should log warning in case of multiple compilers', async () => { - const { stderr, stdout } = await runWatch( - __dirname, - ['-c', 'multi-webpack.config.js'], - true, - "Compiler 'second' is watching files for updates...", - ); - - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compiler 'first' is watching files for updates..."); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); - expect(stderr).toContain("Compiler 'second' is watching files for updates..."); + const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js'], true); + expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); diff --git a/test/build-errors/errors.test.js b/test/build-errors/errors.test.js index 8da5bc0b2cf..50a397ebffa 100644 --- a/test/build-errors/errors.test.js +++ b/test/build-errors/errors.test.js @@ -8,8 +8,7 @@ describe('errors', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toMatch(/ERROR/); expect(stdout).toMatch(/Error: Can't resolve/); }); @@ -18,8 +17,7 @@ describe('errors', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json']); expect(exitCode).toBe(1); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(() => JSON.parse(stdout)).not.toThrow(); const json = JSON.parse(stdout); @@ -34,8 +32,7 @@ describe('errors', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); expect(exitCode).toBe(1); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('stats are successfully stored as json to stats.json'); readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index dd054091313..27422faf42e 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -8,8 +8,7 @@ describe('warnings', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toMatch(/WARNING/); expect(stdout).toMatch(/Error: Can't resolve/); }); @@ -18,8 +17,7 @@ describe('warnings', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json']); expect(exitCode).toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(() => JSON.parse(stdout)).not.toThrow(); @@ -35,8 +33,7 @@ describe('warnings', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); expect(exitCode).toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('stats are successfully stored as json to stats.json'); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index dae6085dc3a..f0898708ce1 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -13,10 +13,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-default' starting..."); - expect(stderr).toContain("Compilation 'cache-test-default' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -25,29 +24,27 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-default' starting..."); - expect(stderr).toContain("Compilation 'cache-test-default' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); it('should work in multi compiler mode', () => { - rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-{first,second}-development')); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-first-development')); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-second-development')); let { exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'], false); expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-first' starting..."); - expect(stderr).toContain("Compilation 'cache-test-first' finished"); - expect(stderr).toContain("Compilation 'cache-test-second' starting..."); - expect(stderr).toContain("Compilation 'cache-test-second' finished"); + console.log(stderr); expect(stderr.match(/No pack exists at/g)).toHaveLength(2); expect(stderr.match(/Stored pack/g)).toHaveLength(2); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -56,13 +53,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-first' starting..."); - expect(stderr).toContain("Compilation 'cache-test-first' finished"); - expect(stderr).toContain("Compilation 'cache-test-second' starting..."); - expect(stderr).toContain("Compilation 'cache-test-second' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(2); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(2); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(2); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -79,10 +73,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-third' starting..."); - expect(stderr).toContain("Compilation 'cache-test-third' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -95,11 +88,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-third' starting..."); - expect(stderr).toContain("Compilation 'cache-test-third' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -116,10 +108,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fourth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fourth' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -132,11 +123,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fourth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fourth' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -165,10 +155,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fifth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fifth' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -193,11 +182,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fifth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fifth' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -210,10 +198,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-autoloading' starting..."); - expect(stderr).toContain("Compilation 'cache-test-autoloading' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -222,11 +209,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-autoloading' starting..."); - expect(stderr).toContain("Compilation 'cache-test-autoloading' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 2add37e2178..31f3d7e88c9 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -7,21 +7,19 @@ describe('colors related tests', () => { it('should output by default', () => { const { exitCode, stderr, stdout } = run(__dirname, [], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags and from configuration', () => { @@ -33,11 +31,10 @@ describe('colors related tests', () => { { FORCE_COLOR: true }, ); - expect(stderr).toContain("Compilation 'test' starting..."); - expect(stderr).toContain("Compilation 'test' finished"); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags and from configuration #2', () => { @@ -45,114 +42,101 @@ describe('colors related tests', () => { FORCE_COLOR: true, }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should disable colored output with --no-color', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--no-color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option and --color flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-string.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #1', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-boolean.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #2', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=no-stats.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain("Compilation 'test' starting..."); - expect(stderr).toContain("Compilation 'test' finished"); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #3', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-true.webpack.config.js']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #4', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-false.webpack.config.js']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); - expect(exitCode).toBe(0); }); it('should prioritize --color over colors in config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-false.webpack.config.js', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); - expect(exitCode).toBe(0); }); it('should prioratize --no-color over colors in config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-true.webpack.config.js', '--no-color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); - expect(exitCode).toBe(0); }); it('should work in multicompiler mode', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=multiple-configs.js', '--color']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first-config' starting..."); - expect(stderr).toContain("Compilation 'first-config' finished"); - expect(stderr).toContain("Compilation 'second-config' starting..."); - expect(stderr).toContain("Compilation 'second-config' finished"); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`\u001b[1mfirst-config`); diff --git a/test/config-format/coffee/coffee.test.js b/test/config-format/coffee/coffee.test.js index e0ab6310dfc..ac853526f7d 100644 --- a/test/config-format/coffee/coffee.test.js +++ b/test/config-format/coffee/coffee.test.js @@ -6,8 +6,7 @@ describe('webpack cli', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -15,8 +14,7 @@ describe('webpack cli', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-format/commonjs/commonjs.test.js b/test/config-format/commonjs/commonjs.test.js index 73a9232f94a..b31d62a3655 100644 --- a/test/config-format/commonjs/commonjs.test.js +++ b/test/config-format/commonjs/commonjs.test.js @@ -5,8 +5,7 @@ describe('webpack cli', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.cjs'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-format/mjs/mjs.test.js b/test/config-format/mjs/mjs.test.js index 20b6c4764f0..5da18d95c16 100644 --- a/test/config-format/mjs/mjs.test.js +++ b/test/config-format/mjs/mjs.test.js @@ -6,8 +6,7 @@ describe('webpack cli', () => { if (exitCode === 0) { expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); } else { expect(exitCode).toBe(2); diff --git a/test/config-lookup/custom-name/custom-name.test.js b/test/config-lookup/custom-name/custom-name.test.js index 06e57a4bdf7..aa9bcd1c439 100644 --- a/test/config-lookup/custom-name/custom-name.test.js +++ b/test/config-lookup/custom-name/custom-name.test.js @@ -8,8 +8,7 @@ describe('custom config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'config.webpack.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-lookup/dotfolder-array/dotfolder-array.test.js b/test/config-lookup/dotfolder-array/dotfolder-array.test.js index 3e139c59eee..db296a2a46d 100644 --- a/test/config-lookup/dotfolder-array/dotfolder-array.test.js +++ b/test/config-lookup/dotfolder-array/dotfolder-array.test.js @@ -8,10 +8,7 @@ describe('dotfolder array config lookup', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); diff --git a/test/config-lookup/dotfolder-single/dotfolder-single.test.js b/test/config-lookup/dotfolder-single/dotfolder-single.test.js index 49287f1a2c4..4ab02015988 100644 --- a/test/config-lookup/dotfolder-single/dotfolder-single.test.js +++ b/test/config-lookup/dotfolder-single/dotfolder-single.test.js @@ -10,8 +10,7 @@ describe('dotfolder single config lookup', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain('Module not found'); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); diff --git a/test/config-lookup/relative/basic-config.test.js b/test/config-lookup/relative/basic-config.test.js index 723a904373f..1d4655bc236 100644 --- a/test/config-lookup/relative/basic-config.test.js +++ b/test/config-lookup/relative/basic-config.test.js @@ -7,8 +7,7 @@ describe('relative path to config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.js', '--output-path', './binary/a'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -16,8 +15,7 @@ describe('relative path to config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--output-path', './binary/b'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-name/config-name.test.js b/test/config-name/config-name.test.js index 26d7a2324e0..607eb97fa08 100644 --- a/test/config-name/config-name.test.js +++ b/test/config-name/config-name.test.js @@ -7,8 +7,7 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -18,10 +17,7 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'third' starting..."); - expect(stderr).toContain("Compilation 'third' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); @@ -35,10 +31,7 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'four' starting..."); - expect(stderr).toContain("Compilation 'four' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -49,8 +42,6 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); @@ -59,8 +50,6 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test', '-c', 'single-config.js'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); @@ -73,8 +62,6 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stderr).toContain('Configuration with the name "bar" was not found.'); expect(stdout).toBeFalsy(); @@ -88,9 +75,6 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); - expect(stderr).not.toContain('Configuration with the name "first" was not found.'); expect(stderr).toContain('Configuration with the name "bar" was not found.'); expect(stdout).toBeFalsy(); }); @@ -99,8 +83,7 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'first'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -114,10 +97,7 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'third' starting..."); - expect(stderr).toContain("Compilation 'third' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); @@ -127,8 +107,6 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'test'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); diff --git a/test/config/absent/config-absent.test.js b/test/config/absent/config-absent.test.js index 7cfbe24a490..2a10305273c 100644 --- a/test/config/absent/config-absent.test.js +++ b/test/config/absent/config-absent.test.js @@ -10,8 +10,6 @@ describe('Config:', () => { // should throw with correct exit code expect(exitCode).toBe(2); // Should contain the correct error message - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`The specified config file doesn't exist in '${resolve(__dirname, 'webpack.config.js')}'`); expect(stdout).toBeFalsy(); }); diff --git a/test/config/basic/basic-config.test.js b/test/config/basic/basic-config.test.js index fa061bbdbb3..2661f445e02 100644 --- a/test/config/basic/basic-config.test.js +++ b/test/config/basic/basic-config.test.js @@ -11,8 +11,7 @@ describe('basic config file', () => { false, ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/defaults/basic-config/default-js-config.test.js b/test/config/defaults/basic-config/default-js-config.test.js index 95e875c044b..ca1d5ab4fc0 100644 --- a/test/config/defaults/basic-config/default-js-config.test.js +++ b/test/config/defaults/basic-config/default-js-config.test.js @@ -7,8 +7,7 @@ describe('Zero Config', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // default entry should be used expect(stdout).toContain('./src/index.js'); diff --git a/test/config/defaults/cjs-config/default-cjs-config.test.js b/test/config/defaults/cjs-config/default-cjs-config.test.js index 6e52b89d3ab..cacc8166a21 100644 --- a/test/config/defaults/cjs-config/default-cjs-config.test.js +++ b/test/config/defaults/cjs-config/default-cjs-config.test.js @@ -7,8 +7,7 @@ describe('Default Config:', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // default entry should be used expect(stdout).toContain('./src/index.js'); // should pick up the output path from config diff --git a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js index c1e586dac7d..b851b223453 100644 --- a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js +++ b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js @@ -7,8 +7,7 @@ describe('multiple dev config files with webpack.config.js', () => { it('Uses webpack.config.development.js', () => { const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toBe(undefined); expect(existsSync(resolve(__dirname, './binary/dev.folder.js'))).toBeTruthy(); }); diff --git a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js index 34ff1498b2c..a085b31e6ea 100644 --- a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js +++ b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js @@ -7,8 +7,7 @@ describe('multiple config files', () => { it('Uses dev config when both dev and none are present', () => { const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toBe(undefined); expect(existsSync(resolve(__dirname, './binary/dev.bundle.js'))).toBeTruthy(); }); diff --git a/test/config/defaults/mjs-config/default-mjs-config.test.js b/test/config/defaults/mjs-config/default-mjs-config.test.js index 2c920c0e492..434de374fd8 100644 --- a/test/config/defaults/mjs-config/default-mjs-config.test.js +++ b/test/config/defaults/mjs-config/default-mjs-config.test.js @@ -8,8 +8,7 @@ describe('Default Config:', () => { if (exitCode === 0) { expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // default entry should be used expect(stdout).toContain('./src/index.js'); // should pick up the output path from config diff --git a/test/config/defaults/with-mode/multiple-config.test.js b/test/config/defaults/with-mode/multiple-config.test.js index 1515eb64dcc..163779cf95b 100644 --- a/test/config/defaults/with-mode/multiple-config.test.js +++ b/test/config/defaults/with-mode/multiple-config.test.js @@ -7,8 +7,7 @@ describe('multiple config files', () => { it('Uses dev config when development mode is supplied', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toBe(undefined); expect(existsSync(resolve(__dirname, './binary/dev.bundle.js'))).toBeTruthy(); }); diff --git a/test/config/empty-array/empty-array.test.js b/test/config/empty-array/empty-array.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty-array/empty-array.test.js +++ b/test/config/empty-array/empty-array.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty-function/empty-function.test.js b/test/config/empty-function/empty-function.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty-function/empty-function.test.js +++ b/test/config/empty-function/empty-function.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty-promise/empty-promise.test.js b/test/config/empty-promise/empty-promise.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty-promise/empty-promise.test.js +++ b/test/config/empty-promise/empty-promise.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty/empty.test.js b/test/config/empty/empty.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty/empty.test.js +++ b/test/config/empty/empty.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/function/functional-config.test.js b/test/config/function/functional-config.test.js index c135ef86845..3f8f2eabc11 100644 --- a/test/config/function/functional-config.test.js +++ b/test/config/function/functional-config.test.js @@ -9,8 +9,7 @@ describe('functional config', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'single-webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'single' starting..."); - expect(stderr).toContain("Compilation 'single' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./src/index.js'); expect(existsSync(resolve(__dirname, './bin/dist-single.js'))).toBeTruthy(); }); @@ -19,10 +18,7 @@ describe('functional config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'multi-webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).toContain('second'); expect(existsSync(resolve(__dirname, './bin/dist-first.js'))).toBeTruthy(); diff --git a/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js index fa061bbdbb3..2661f445e02 100644 --- a/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js +++ b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js @@ -11,8 +11,7 @@ describe('basic config file', () => { false, ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/multiple/multiple-config.test.js b/test/config/multiple/multiple-config.test.js index 097a99d9b48..3daf66584a9 100644 --- a/test/config/multiple/multiple-config.test.js +++ b/test/config/multiple/multiple-config.test.js @@ -6,12 +6,7 @@ describe('Multiple config flag: ', () => { // Should contain the correct exit code expect(exitCode).toEqual(0); - - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); - + expect(stderr).toBeFalsy(); // Should spawn multiple compilers expect(stdout).toContain('amd:'); expect(stdout).toContain('commonjs:'); diff --git a/test/config/no-config-object/no-config-object.test.js b/test/config/no-config-object/no-config-object.test.js index ba6cdfd4ab3..6e27769c970 100644 --- a/test/config/no-config-object/no-config-object.test.js +++ b/test/config/no-config-object/no-config-object.test.js @@ -12,8 +12,7 @@ describe('empty config', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/type/array-function-with-argv/function-with-argv.test.js b/test/config/type/array-function-with-argv/function-with-argv.test.js index 9a65b47e4cb..8599e533bce 100644 --- a/test/config/type/array-function-with-argv/function-with-argv.test.js +++ b/test/config/type/array-function-with-argv/function-with-argv.test.js @@ -8,12 +8,8 @@ describe('array of function with args', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/a-dev.js'))); expect(existsSync(resolve(__dirname, './dist/b-dev.js'))); }); diff --git a/test/config/type/array-function-with-env/array-function-with-env.test.js b/test/config/type/array-function-with-env/array-function-with-env.test.js index a90d258a55f..33dcd38aee2 100644 --- a/test/config/type/array-function-with-env/array-function-with-env.test.js +++ b/test/config/type/array-function-with-env/array-function-with-env.test.js @@ -8,12 +8,8 @@ describe('array of functions with env', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/a-dev.js'))); expect(existsSync(resolve(__dirname, './dist/b-dev.js'))); }); diff --git a/test/config/type/array-functions/array-functions.test.js b/test/config/type/array-functions/array-functions.test.js index 9223d92fff1..6f9bf1f5d7a 100644 --- a/test/config/type/array-functions/array-functions.test.js +++ b/test/config/type/array-functions/array-functions.test.js @@ -8,10 +8,7 @@ describe('array of functions', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/a-functor.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/b-functor.js'))).toBeTruthy(); diff --git a/test/config/type/array-promises/array-promises.test.js b/test/config/type/array-promises/array-promises.test.js index e618726d3e9..7fbd9bdf0e6 100644 --- a/test/config/type/array-promises/array-promises.test.js +++ b/test/config/type/array-promises/array-promises.test.js @@ -8,12 +8,8 @@ describe('array of promises', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/b-promise.js'))).toBeTruthy(); }); diff --git a/test/config/type/array/array.test.js b/test/config/type/array/array.test.js index 5cb2267e933..0634759ff9a 100644 --- a/test/config/type/array/array.test.js +++ b/test/config/type/array/array.test.js @@ -8,10 +8,7 @@ describe('array config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); @@ -21,10 +18,7 @@ describe('array config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'none'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toBeFalsy(); // should not print anything because of stats: none expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); diff --git a/test/config/type/function-array/function-array.test.js b/test/config/type/function-array/function-array.test.js index a081360b620..66a1fa260eb 100644 --- a/test/config/type/function-array/function-array.test.js +++ b/test/config/type/function-array/function-array.test.js @@ -8,12 +8,8 @@ describe('function array', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './binary/a-functor.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/b-functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/function-async/function-async.test.js b/test/config/type/function-async/function-async.test.js index 86a1766a3df..1bd458b19e8 100644 --- a/test/config/type/function-async/function-async.test.js +++ b/test/config/type/function-async/function-async.test.js @@ -8,8 +8,7 @@ describe('function async', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/function-promise/function-promise.test.js b/test/config/type/function-promise/function-promise.test.js index 074f276933c..243589bf329 100644 --- a/test/config/type/function-promise/function-promise.test.js +++ b/test/config/type/function-promise/function-promise.test.js @@ -8,8 +8,7 @@ describe('function promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index c75e62c1a78..0c5d24e749a 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -8,8 +8,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(stdout).toContain("argv: { mode: 'development' }"); expect(existsSync(resolve(__dirname, './dist/dev.js'))); diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index 1fb719b1b05..359df2f24a1 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -17,8 +17,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isProd']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/prod.js'))).toBeTruthy(); @@ -28,8 +27,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isDev']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/dev.js'))).toBeTruthy(); @@ -46,8 +44,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Luffy.js'))).toBeTruthy(); @@ -64,8 +61,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Atsumu.js'))).toBeTruthy(); @@ -82,8 +78,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/name=is=Eren.js'))).toBeTruthy(); @@ -100,8 +95,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Hisoka.js'))).toBeTruthy(); @@ -111,8 +105,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'name.', '--env', 'environment=dot', '-c', 'webpack.env.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/true.js'))).toBeTruthy(); @@ -122,8 +115,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isDev', '--env', 'verboseStats', '--env', 'envMessage']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // check that the verbose env is respected expect(stdout).toContain('LOG from webpack'); diff --git a/test/config/type/function/function.test.js b/test/config/type/function/function.test.js index 6f90a6cd065..a850fd16eab 100644 --- a/test/config/type/function/function.test.js +++ b/test/config/type/function/function.test.js @@ -8,8 +8,7 @@ describe('function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/promise-array/promise-array.test.js b/test/config/type/promise-array/promise-array.test.js index 0d38f7b6682..89c1b4a905e 100644 --- a/test/config/type/promise-array/promise-array.test.js +++ b/test/config/type/promise-array/promise-array.test.js @@ -9,8 +9,7 @@ describe('promise array', () => { expect(exitCode).toBe(0); expect(stdout).toBeTruthy(); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); }); diff --git a/test/config/type/promise-function/promise-function.test.js b/test/config/type/promise-function/promise-function.test.js index 9f662f2d6f8..bd93e6d3162 100644 --- a/test/config/type/promise-function/promise-function.test.js +++ b/test/config/type/promise-function/promise-function.test.js @@ -8,8 +8,7 @@ describe('promise function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/promise.js'))).toBeTruthy(); diff --git a/test/config/type/promise/promise.test.js b/test/config/type/promise/promise.test.js index 34e93c57f26..0284dc243bc 100644 --- a/test/config/type/promise/promise.test.js +++ b/test/config/type/promise/promise.test.js @@ -8,8 +8,7 @@ describe('promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/promise.js'))).toBeTruthy(); }); diff --git a/test/core-flags/amd-flag.test.js b/test/core-flags/amd-flag.test.js index 2cac616a060..48acfe5aad4 100644 --- a/test/core-flags/amd-flag.test.js +++ b/test/core-flags/amd-flag.test.js @@ -7,8 +7,7 @@ describe('--no-amd flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-amd']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('amd: false'); }); }); diff --git a/test/core-flags/bail-flag.test.js b/test/core-flags/bail-flag.test.js index 27a38f18a3d..dd3a5920ded 100644 --- a/test/core-flags/bail-flag.test.js +++ b/test/core-flags/bail-flag.test.js @@ -7,8 +7,7 @@ describe('--bail flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--bail']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('bail: true'); }); @@ -16,8 +15,7 @@ describe('--bail flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-bail']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('bail: false'); }); }); diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index d2eb845fbee..a7e6c54d64f 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -11,8 +11,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`type: 'memory'`); }); @@ -20,8 +19,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-cache']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('cache: false'); }); @@ -33,8 +31,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`type: 'filesystem'`); }); @@ -53,8 +50,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('test-cache-path'); }); @@ -67,8 +63,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('cache-core-flag-test-cache-location'); expect(existsSync(cacheLocation)).toBeTruthy(); @@ -89,8 +84,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`hashAlgorithm: 'sha256'`); }); @@ -110,8 +104,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`name: 'cli-test'`); }); @@ -131,8 +124,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`store: 'pack'`); }); @@ -152,8 +144,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`version: '1.1.3'`); }); @@ -173,8 +164,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); @@ -191,8 +181,7 @@ describe('cache related flags from core', () => { ])); expect(exitCode).toEqual(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('[cached]'); }); @@ -207,8 +196,7 @@ describe('cache related flags from core', () => { let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler-cache' starting..."); - expect(stderr).toContain("Compilation 'compiler-cache' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); @@ -217,8 +205,7 @@ describe('cache related flags from core', () => { ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '--cache-cache-location', cacheLocation])); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler-cache' starting..."); - expect(stderr).toContain("Compilation 'compiler-cache' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('[cached]'); }); @@ -228,8 +215,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${resolve(__dirname, 'webpack.cache.config.js')}'`); @@ -242,8 +228,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--name', 'cache-core-flag-test']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'cache-core-flag-test' starting..."); - expect(stderr).toContain("Compilation 'cache-core-flag-test' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); expect(stdout).toContain("type: 'filesystem'"); @@ -265,8 +250,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); @@ -283,16 +267,14 @@ describe('cache related flags from core', () => { let { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain('[cached]'); // Running again should use the cache ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js'])); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('[cached]'); // Change config to invalidate cache @@ -303,8 +285,7 @@ describe('cache related flags from core', () => { unlinkSync(resolve(__dirname, './webpack.test.config.js')); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain('[cached]'); }); }); diff --git a/test/core-flags/context-flag.test.js b/test/core-flags/context-flag.test.js index 804bc6cd3d7..bac4667b0f9 100644 --- a/test/core-flags/context-flag.test.js +++ b/test/core-flags/context-flag.test.js @@ -8,8 +8,7 @@ describe('--context flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--context', './']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (isWindows) { const windowsPath = resolve(__dirname, './').replace(/\\/g, '\\\\'); @@ -23,8 +22,7 @@ describe('--context flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--context', '/invalid-context-path']); expect(exitCode).toBe(1); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`Module not found: Error: Can't resolve './src/main.js'`); }); }); diff --git a/test/core-flags/dependencies-flag.test.js b/test/core-flags/dependencies-flag.test.js index 1cc0ff6536b..035e460f45e 100644 --- a/test/core-flags/dependencies-flag.test.js +++ b/test/core-flags/dependencies-flag.test.js @@ -7,8 +7,7 @@ describe('--dependencies and related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--dependencies', 'lodash']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`dependencies: [ 'lodash' ]`); }); @@ -16,8 +15,7 @@ describe('--dependencies and related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--dependencies-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('dependencies: []'); }); }); diff --git a/test/core-flags/devtool-flag.test.js b/test/core-flags/devtool-flag.test.js index 269396b21a2..fa37bc37b43 100644 --- a/test/core-flags/devtool-flag.test.js +++ b/test/core-flags/devtool-flag.test.js @@ -7,8 +7,7 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'source-map']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`devtool: 'source-map'`); }); @@ -16,8 +15,7 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-devtool']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`devtool: false`); }); @@ -25,8 +23,6 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'invalid']); expect(exitCode).toBe(2); - expect(stderr).not.toContain("Compilation 'compiler' starting..."); - expect(stderr).not.toContain("Compilation 'compiler' finished"); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/entry-reset-flag.test.js b/test/core-flags/entry-reset-flag.test.js index 660c40bf39e..91e7bfec4cc 100644 --- a/test/core-flags/entry-reset-flag.test.js +++ b/test/core-flags/entry-reset-flag.test.js @@ -7,8 +7,7 @@ describe('--entry-reset flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry-reset', '--entry', './src/entry.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('src/entry.js'); expect(stdout).not.toContain('src/main.js'); }); @@ -17,8 +16,6 @@ describe('--entry-reset flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry-reset']); expect(exitCode).toBe(2); - expect(stderr).not.toContain("Compilation 'compiler' starting..."); - expect(stderr).not.toContain("Compilation 'compiler' finished"); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/experiments-flag.test.js b/test/core-flags/experiments-flag.test.js index 741463cfedb..07704d3c825 100644 --- a/test/core-flags/experiments-flag.test.js +++ b/test/core-flags/experiments-flag.test.js @@ -15,8 +15,7 @@ describe('experiments option related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); }); @@ -24,8 +23,7 @@ describe('experiments option related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: false`); }); }); diff --git a/test/core-flags/externals-flags.test.js b/test/core-flags/externals-flags.test.js index dd0afaaf86a..f402a194691 100644 --- a/test/core-flags/externals-flags.test.js +++ b/test/core-flags/externals-flags.test.js @@ -10,8 +10,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals', './main.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externals: [ './main.js' ]`); }); @@ -19,8 +18,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals', 'var']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externalsType: 'var'`); }); @@ -28,8 +26,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals-type', 'var']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externalsType: 'var'`); }); @@ -37,8 +34,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externals: []`); }); @@ -51,8 +47,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); }); @@ -60,8 +55,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: false`); }); }); diff --git a/test/core-flags/infrastructure-logging.test.js b/test/core-flags/infrastructure-logging.test.js index f04966f215b..9e408f2d46b 100644 --- a/test/core-flags/infrastructure-logging.test.js +++ b/test/core-flags/infrastructure-logging.test.js @@ -7,8 +7,7 @@ describe('infrastructure logging related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`debug: [ 'myPlugin' ]`); }); @@ -16,8 +15,7 @@ describe('infrastructure logging related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`debug: []`); }); diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index b02f3aade81..22510b4849b 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -22,22 +22,19 @@ describe('module config related flag', () => { const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); const option = propName.split('Reset')[0]; - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${option}: []`); } else if (flag.name.includes('rules-')) { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("sideEffects: 'flag'"); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); @@ -47,8 +44,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('rules-')) { expect(stdout).toContain('sideEffects: false'); @@ -65,15 +61,13 @@ describe('module config related flag', () => { if (flag.name === 'module-no-parse') { expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('value'); } else if (flag.name.includes('reg-exp')) { ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, '/ab?c*/'])); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: /ab?c*/`); } else if (flag.name.includes('module-rules-')) { ({ stdout } = run(__dirname, [`--${flag.name}`, 'javascript/auto'])); @@ -92,9 +86,8 @@ describe('module config related flag', () => { } } else { expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'value'`); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); } }); } diff --git a/test/core-flags/node-flags.test.js b/test/core-flags/node-flags.test.js index 437f0c1d778..b3d24a4198f 100644 --- a/test/core-flags/node-flags.test.js +++ b/test/core-flags/node-flags.test.js @@ -7,8 +7,7 @@ describe('node option related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('node: false'); }); @@ -16,8 +15,7 @@ describe('node option related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--node-filename', 'mock']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`__filename: 'mock'`); }); @@ -25,8 +23,7 @@ describe('node option related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--node-dirname', 'mock']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`__dirname: 'mock'`); }); }); diff --git a/test/core-flags/optimization-flags.test.js b/test/core-flags/optimization-flags.test.js index 6e579f40129..72cd235c357 100644 --- a/test/core-flags/optimization-flags.test.js +++ b/test/core-flags/optimization-flags.test.js @@ -26,22 +26,19 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`splitChunks: false`); } else if (flag.name.includes('reset')) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: []`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); @@ -51,8 +48,7 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain('splitChunks: false'); @@ -71,43 +67,37 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'initial']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`chunks: 'initial'`); } else if (flag.name === 'optimization-mangle-exports') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-mangle-exports', 'size']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mangleExports: 'size'`); } else if (flag.name === 'optimization-used-exports') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-used-exports', 'global']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`usedExports: 'global'`); } else if (flag.name === 'optimization-split-chunks-default-size-types') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-split-chunks-default-size-types', 'global']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`defaultSizeTypes: [Array]`); } else if (flag.name === 'optimization-side-effects') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-side-effects', 'flag']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'flag'`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'named']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'named'`); } }); @@ -118,8 +108,7 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain(`chunks: 'async'`); diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index ab6e9067667..fb08268a5a1 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -25,20 +25,17 @@ describe('output config related flag', () => { ({ exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '--experiments-output-module'])); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('module: true'); } else if (flag.name.includes('-reset')) { const option = propName.split('Reset')[0]; expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${option}: []`); } else { expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); @@ -48,8 +45,7 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: false`); }); } @@ -60,8 +56,7 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 10`); }); } @@ -72,92 +67,79 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'anonymous']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'anonymous'`); } else if (flag.name === 'output-chunk-format') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'commonjs']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'commonjs'`); } else if (flag.name === 'output-chunk-loading') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'jsonp']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'jsonp'`); } else if (flag.name === 'output-enabled-chunk-loading-types' || flag.name === 'output-enabled-wasm-loading-types') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: [ 'async-node' ]`); } else if (flag.name === 'output-enabled-library-type') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'amd']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'amd'`); } else if (flag.name === 'output-hash-function') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'sha256']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`hashFunction: 'sha256'`); } else if (flag.name === 'output-script-type') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'module']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'module'`); } else if (flag.name === 'output-enabled-library-types') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'var']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: [ 'var' ]`); } else if (flag.name === 'output-path') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('test'); } else if (flag.name === 'output-pathinfo') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'verbose']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`pathinfo: 'verbose'`); } else if (flag.name === 'output-worker-chunk-loading') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'async-node'`); } else if (flag.name.includes('wasm')) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'async-node'`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'test'`); } }); @@ -178,8 +160,7 @@ describe('output config related flag', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('myLibrary'); expect(stdout).toContain(`type: 'var'`); expect(stdout).toContain('export: [Array]'); @@ -191,8 +172,7 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-library-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('name: []'); }); } diff --git a/test/core-flags/parallelism-flag.test.js b/test/core-flags/parallelism-flag.test.js index 1bf2f1462db..95902729986 100644 --- a/test/core-flags/parallelism-flag.test.js +++ b/test/core-flags/parallelism-flag.test.js @@ -7,8 +7,7 @@ describe('--parallelism flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--parallelism', '50']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('parallelism: 50'); }); @@ -16,8 +15,6 @@ describe('--parallelism flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--parallelism', '0']); expect(exitCode).toBe(2); - expect(stderr).not.toContain("Compilation 'compiler' starting..."); - expect(stderr).not.toContain("Compilation 'compiler' finished"); expect(stderr).toContain('configuration.parallelism should be >= 1'); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/performance-flags.test.js b/test/core-flags/performance-flags.test.js index bfaf42b2c4d..f13d1ca0221 100644 --- a/test/core-flags/performance-flags.test.js +++ b/test/core-flags/performance-flags.test.js @@ -10,8 +10,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-performance`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('performance: false'); }); @@ -25,8 +24,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 10`); }); } @@ -36,8 +34,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'warning']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'warning'`); }); } diff --git a/test/core-flags/profile-flag.test.js b/test/core-flags/profile-flag.test.js index 5c702ae77d9..a4806015904 100644 --- a/test/core-flags/profile-flag.test.js +++ b/test/core-flags/profile-flag.test.js @@ -7,8 +7,7 @@ describe('--profile flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--profile']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('profile: true'); }); @@ -16,8 +15,7 @@ describe('--profile flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-profile']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('profile: false'); }); }); diff --git a/test/core-flags/records-flag.test.js b/test/core-flags/records-flag.test.js index 831c0d97142..1b3ba08787a 100644 --- a/test/core-flags/records-flag.test.js +++ b/test/core-flags/records-flag.test.js @@ -7,8 +7,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--records-path', './bin/records.json']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('records.json'); }); @@ -16,8 +15,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--records-input-path', './bin/records.json']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('records.json'); }); @@ -25,8 +23,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--records-output-path', './bin/records.json']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('records.json'); }); }); diff --git a/test/core-flags/resolve-flags.test.js b/test/core-flags/resolve-flags.test.js index 719a94e9dbe..e2c069ff02c 100644 --- a/test/core-flags/resolve-flags.test.js +++ b/test/core-flags/resolve-flags.test.js @@ -21,8 +21,7 @@ describe('resolve config related flags', () => { const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); // expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; @@ -38,8 +37,7 @@ describe('resolve config related flags', () => { const { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'browser']); // expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (propName === 'restrictions') { expect(stdout).toContain('browser'); @@ -75,8 +73,7 @@ describe('resolve config related flags', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`alias: [ { alias: 'alias', name: 'name' } ]`); expect(stdout).toContain(`aliasFields: [ 'aliasField' ]`); expect(stdout).toContain(`alias: [ { alias: 'loaderAlias', name: 'loaderName' } ]`); @@ -99,8 +96,7 @@ describe('resolve config related flags', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`alias: []`); expect(stdout).toContain(`aliasFields: []`); expect(stdout).toContain(`fallback: []`); diff --git a/test/core-flags/snapshot-flags.test.js b/test/core-flags/snapshot-flags.test.js index 15005dd57b8..5860127cb3b 100644 --- a/test/core-flags/snapshot-flags.test.js +++ b/test/core-flags/snapshot-flags.test.js @@ -16,8 +16,7 @@ describe('snapshot config related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; @@ -35,8 +34,7 @@ describe('snapshot config related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test-snap-path']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('test-snap-path'); }); } diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index 39f57c7faf8..904e5f774da 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -16,8 +16,7 @@ describe('stats config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; @@ -32,8 +31,7 @@ describe('stats config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: false }`); }); } @@ -44,8 +42,7 @@ describe('stats config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: 10 }`); }); } @@ -59,36 +56,31 @@ describe('stats config related flag', () => { const option = flag.name.split('stats-colors-')[1]; expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { colors: { ${option}: 'u001b[32m' } }`); } else if (acceptsSingleValue.includes(propName)) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: 'log' }`); } else if (flag.name === 'stats-context') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('log'); } else if (flag.name === 'stats-entrypoints') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'auto']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: 'auto' }`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: [ 'log' ] }`); } }); diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index e1263020b8c..b0f9e8f2892 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -16,8 +16,7 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { expect(stdout).toContain(`watchOptions: { ignored: [] }`); @@ -31,8 +30,7 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: false }`); }); } @@ -43,8 +41,7 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: 10 }`); }); } @@ -55,15 +52,13 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '200']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: 200 }`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'ignore.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: [ 'ignore.js' ] }`); } }); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index c727226adf5..555ca1204b4 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -8,8 +8,7 @@ describe('output flag defaults', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js', '--output-path', './binary'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should print warning about config fallback expect(stdout).toContain('option has not been set, webpack will fallback to'); @@ -20,8 +19,7 @@ describe('output flag defaults', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/main.js'))).toBeTruthy(); }); diff --git a/test/devtool/array/source-map-array.test.js b/test/devtool/array/source-map-array.test.js index ae9bbabfe41..d6e1624ec47 100644 --- a/test/devtool/array/source-map-array.test.js +++ b/test/devtool/array/source-map-array.test.js @@ -8,10 +8,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'dist'), (err, files) => { @@ -24,10 +21,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'source-map', '--output-path', './binary'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'binary'), (err, files) => { diff --git a/test/devtool/object/source-map-object.test.js b/test/devtool/object/source-map-object.test.js index 8a13e79aa61..4237b08d520 100644 --- a/test/devtool/object/source-map-object.test.js +++ b/test/devtool/object/source-map-object.test.js @@ -8,8 +8,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.eval.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'bin'), (err, files) => { @@ -23,8 +22,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.source.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, 'dist/dist-amd.js.map'))).toBeTruthy(); }); @@ -37,8 +35,7 @@ describe('source-map object', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, 'binary/dist-amd.js.map'))).toBeTruthy(); }); diff --git a/test/entry/config-entry/entry-with-command/entry-with-command.test.js b/test/entry/config-entry/entry-with-command/entry-with-command.test.js index ac8bc9505ef..2cd0595f3f9 100644 --- a/test/entry/config-entry/entry-with-command/entry-with-command.test.js +++ b/test/entry/config-entry/entry-with-command/entry-with-command.test.js @@ -8,8 +8,7 @@ describe('config entry and command entry all exist', () => { const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js', './index.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./index.js'); expect(existsSync(resolve(__dirname, './binary/main.bundle.js'))).toBeTruthy(); }); diff --git a/test/entry/config-entry/entry-with-config/entry-with-config.test.js b/test/entry/config-entry/entry-with-config/entry-with-config.test.js index 69dba9616fa..5906cf5919f 100644 --- a/test/entry/config-entry/entry-with-config/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-config/entry-with-config.test.js @@ -8,8 +8,7 @@ describe('default entry and config entry all exist', () => { const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./a.js'); expect(existsSync(resolve(__dirname, './binary/index.bundle.js'))).toBeTruthy(); }); diff --git a/test/entry/config-entry/entry-with-index/entry-with-config.test.js b/test/entry/config-entry/entry-with-index/entry-with-config.test.js index 18fe3c879fb..5c998e1a621 100644 --- a/test/entry/config-entry/entry-with-index/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-index/entry-with-config.test.js @@ -7,8 +7,7 @@ describe('default entry and config entry all exist', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should contain the relevant entry expect(stdout).toContain('./src/app.js'); expect(stdout).toContain('./src/print.js'); diff --git a/test/entry/defaults-empty/entry-single-arg.test.js b/test/entry/defaults-empty/entry-single-arg.test.js index 6218698926d..d6274bf2e8f 100644 --- a/test/entry/defaults-empty/entry-single-arg.test.js +++ b/test/entry/defaults-empty/entry-single-arg.test.js @@ -7,8 +7,7 @@ describe('single entry flag empty project', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`not found: Error: Can't resolve`); }); }); diff --git a/test/entry/defaults-index/entry-multi-args.test.js b/test/entry/defaults-index/entry-multi-args.test.js index a91113d40ba..dbacb46d325 100644 --- a/test/entry/defaults-index/entry-multi-args.test.js +++ b/test/entry/defaults-index/entry-multi-args.test.js @@ -10,8 +10,7 @@ describe('single entry flag index present', () => { const { stderr, stdout, exitCode } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stderr).not.toContain('Module not found'); expect(stdout).toBeTruthy(); }); @@ -20,8 +19,7 @@ describe('single entry flag index present', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-path', 'bin']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); }); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index fc2072a901f..22d0ff09f95 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -9,8 +9,7 @@ describe('entry flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -18,8 +17,7 @@ describe('entry flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/a.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -28,14 +26,12 @@ describe('entry flag', () => { if (!isWebpack5) { expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`Module not found: Error: Can't resolve`); done(); } else { expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { @@ -50,8 +46,7 @@ describe('entry flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/test.js']); expect(exitCode).toEqual(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain("Module not found: Error: Can't resolve"); }); }); diff --git a/test/entry/multiple-entries/multi-entries.test.js b/test/entry/multiple-entries/multi-entries.test.js index d9b5598cbd4..339a21786bc 100644 --- a/test/entry/multiple-entries/multi-entries.test.js +++ b/test/entry/multiple-entries/multi-entries.test.js @@ -9,8 +9,7 @@ describe(' multiple entries', () => { const { exitCode, stderr, stdout } = run(__dirname, ['./src/a.js', './src/b.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { @@ -25,8 +24,7 @@ describe(' multiple entries', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/a.js', '--entry', './src/b.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); diff --git a/test/env/array/array-env.test.js b/test/env/array/array-env.test.js index caf8f7054b9..83e75c74fb6 100644 --- a/test/env/array/array-env.test.js +++ b/test/env/array/array-env.test.js @@ -14,8 +14,7 @@ describe('env array', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); if (isWebpack5) { diff --git a/test/env/object/object-env.test.js b/test/env/object/object-env.test.js index 91b889f461e..d886da0eaf8 100644 --- a/test/env/object/object-env.test.js +++ b/test/env/object/object-env.test.js @@ -11,8 +11,7 @@ describe('env object', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); if (isWebpack5) { diff --git a/test/error/error.test.js b/test/error/error.test.js index de227ce0ec6..5096f198b1a 100644 --- a/test/error/error.test.js +++ b/test/error/error.test.js @@ -7,8 +7,6 @@ describe('error', () => { const { exitCode, stderr, stdout } = await run(__dirname); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Error: test'); expect(stderr).toMatch(/at .+ (.+)/); expect(stdout).toBeFalsy(); diff --git a/test/hot/hot-flag.test.js b/test/hot/hot-flag.test.js index 9ee1764d6fb..361c1dfe9ab 100644 --- a/test/hot/hot-flag.test.js +++ b/test/hot/hot-flag.test.js @@ -8,8 +8,7 @@ describe('--hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); }); @@ -18,8 +17,6 @@ describe('--hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot', '--hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain( 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', ); diff --git a/test/invalid-schema/invalid-schema.test.js b/test/invalid-schema/invalid-schema.test.js index e5e42f06b77..52cd44bebde 100644 --- a/test/invalid-schema/invalid-schema.test.js +++ b/test/invalid-schema/invalid-schema.test.js @@ -6,8 +6,6 @@ describe('invalid schema', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']); expect(exitCode).toEqual(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); @@ -16,8 +14,6 @@ describe('invalid schema', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'Yukihira']); expect(exitCode).toEqual(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); if (isWebpack5) { expect(stderr).toContain("Found the 'invalid-value' problem with the '--mode' argument by path 'mode'"); diff --git a/test/merge/config/merge-config.test.js b/test/merge/config/merge-config.test.js index ffbdb19a795..916eb44c750 100644 --- a/test/merge/config/merge-config.test.js +++ b/test/merge/config/merge-config.test.js @@ -7,8 +7,7 @@ describe('merge flag configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--config', './2.js', '--merge'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('option has not been set, webpack will fallback to'); }); @@ -16,8 +15,7 @@ describe('merge flag configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--config', './2.js', '-m'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('merged.js'); }); @@ -25,8 +23,6 @@ describe('merge flag configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '-m'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('At least two configurations are required for merge.'); expect(stdout).toBeFalsy(); }); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 90e4abb7e02..74a768bdd11 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -7,8 +7,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(`mode: 'production'`); expect(stdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); }); @@ -17,8 +16,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); @@ -26,8 +24,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); }); @@ -35,8 +32,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'none'`); }); @@ -44,8 +40,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); diff --git a/test/mode/mode-with-config/mode-with-config.test.js b/test/mode/mode-with-config/mode-with-config.test.js index f3cb00f3ed9..c158d1b4d61 100644 --- a/test/mode/mode-with-config/mode-with-config.test.js +++ b/test/mode/mode-with-config/mode-with-config.test.js @@ -9,8 +9,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -29,8 +28,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -50,8 +48,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -72,8 +69,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production', '-c', 'webpack.config2.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); }); @@ -83,8 +79,7 @@ describe('mode flags with config', () => { }); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'none'`); }); @@ -92,8 +87,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config2.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); @@ -101,8 +95,7 @@ describe('mode flags with config', () => { const { exitCode, stdout, stderr } = run(__dirname, ['-c', 'webpack.config3.js', '-c', 'webpack.config2.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'development'", 'g')).length).toEqual(1); }); @@ -111,8 +104,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none', '-c', './webpack.config3.js', '-c', './webpack.config2.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'none'`); expect(stdout.match(new RegExp("mode: 'none'", 'g')).length).toEqual(2); }); @@ -123,8 +115,7 @@ describe('mode flags with config', () => { }); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'production'", 'g')).length).toEqual(1); diff --git a/test/name/name.test.js b/test/name/name.test.js index f05dab56270..a40682f66c8 100644 --- a/test/name/name.test.js +++ b/test/name/name.test.js @@ -6,8 +6,7 @@ describe('name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--name', 'config-name'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'config-name' starting..."); - expect(stderr).toContain("Compilation 'config-name' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("name: 'config-name'"); }); }); diff --git a/test/no-hot/no-hot.test.js b/test/no-hot/no-hot.test.js index a381d52e9bd..91b268603be 100644 --- a/test/no-hot/no-hot.test.js +++ b/test/no-hot/no-hot.test.js @@ -9,11 +9,11 @@ describe('no-hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(stdout).not.toContain('webpack/runtime/hot module replacement'); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); + readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); // check for absence of special functions invoked by HMR plugin only @@ -26,13 +26,10 @@ describe('no-hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--hot', '--no-hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain( 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', ); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { diff --git a/test/no-stats/with-config/no-stats-with-config.test.js b/test/no-stats/with-config/no-stats-with-config.test.js index 46a49569c46..1c4ab3da1a0 100644 --- a/test/no-stats/with-config/no-stats-with-config.test.js +++ b/test/no-stats/with-config/no-stats-with-config.test.js @@ -8,8 +8,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, []); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'detailed' }`); @@ -22,8 +21,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'none' }`); diff --git a/test/no-stats/with-flags/no-stats.test.js b/test/no-stats/with-flags/no-stats.test.js index 679461326af..20e9ffcb820 100644 --- a/test/no-stats/with-flags/no-stats.test.js +++ b/test/no-stats/with-flags/no-stats.test.js @@ -8,8 +8,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'none' }`); @@ -22,8 +21,6 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'verbose', '--no-stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); if (version.startsWith('5')) { @@ -37,8 +34,6 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats', '--stats', 'verbose']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); if (version.startsWith('5')) { diff --git a/test/node/node.test.js b/test/node/node.test.js index d98ae225b3f..79c143d1e2e 100644 --- a/test/node/node.test.js +++ b/test/node/node.test.js @@ -13,8 +13,7 @@ describe('node flags', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('---from bootstrap.js---'); expect(stdout).toContain('---from bootstrap2.js---'); }); @@ -23,8 +22,6 @@ describe('node flags', () => { const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--unknown']); expect(exitCode).not.toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('bad option'); expect(stdout).toBeFalsy(); }); @@ -33,8 +30,6 @@ describe('node flags', () => { const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--max-old-space-size']); expect(exitCode).not.toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('value for flag --max-old-space-size'); expect(stdout).toBeFalsy(); }); @@ -43,8 +38,6 @@ describe('node flags', () => { const { exitCode, stderr, stdout } = await run(__dirname, [], true, ['--max_old_space_size=1024a']); expect(exitCode).not.toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Error: illegal value for flag --max_old_space_size=1024a of type size_t'); expect(stdout).toBeFalsy(); }); diff --git a/test/optimization/optimization.test.js b/test/optimization/optimization.test.js index f30060e850e..ea28769da3a 100644 --- a/test/optimization/optimization.test.js +++ b/test/optimization/optimization.test.js @@ -7,13 +7,10 @@ describe('optimization option in config', () => { // Should throw when webpack is less than 5 if (isWebpack5) { expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('mangleExports: false'); } else { expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'"); expect(stdout).toBeFalsy(); } diff --git a/test/output/named-bundles/output-named-bundles.test.js b/test/output/named-bundles/output-named-bundles.test.js index ecb694c74a3..a6a5aed9e93 100644 --- a/test/output/named-bundles/output-named-bundles.test.js +++ b/test/output/named-bundles/output-named-bundles.test.js @@ -12,8 +12,7 @@ describe('output flag named bundles', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -25,8 +24,7 @@ describe('output flag named bundles', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -38,8 +36,7 @@ describe('output flag named bundles', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -47,8 +44,7 @@ describe('output flag named bundles', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.multiple.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index 30def73ad77..95ece6bd8e8 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -12,8 +12,7 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch', './src/p.js', '--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); const content = fs.readFileSync(join(__dirname, '/dist/main.js'), 'utf-8'); @@ -25,8 +24,7 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch', './src/somefile.js'], false); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should contain the error message expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); }); @@ -35,8 +33,6 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch'], false); expect(exitCode).toBe(1); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`error: option '--prefetch ' argument missing`); expect(stdout).toBeFalsy(); }); diff --git a/test/progress/progress-flag.test.js b/test/progress/progress-flag.test.js index 6a5a8d1dd39..d3dd1a7c9cd 100644 --- a/test/progress/progress-flag.test.js +++ b/test/progress/progress-flag.test.js @@ -7,8 +7,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--progress']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); @@ -18,8 +16,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--progress=profile']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); if (isWebpack5) { expect(stderr).toMatch(/\[webpack\.Progress] \d+ ms setup/); @@ -33,8 +29,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--progress=unknown']); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`'unknown' is an invalid value for the --progress option. Only 'profile' is allowed.`); expect(stdout).toBeFalsy(); }); @@ -43,8 +37,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.progress.config.js', '--progress']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 64c112648f4..64f8f2f07c8 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -37,8 +37,7 @@ describe('basic serve usage', () => { it('should not invoke info subcommand', async () => { const { stdout, stderr } = await runServe(['--client-log-level', 'info'], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -46,8 +45,7 @@ describe('basic serve usage', () => { it('compiles without flags', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -55,8 +53,7 @@ describe('basic serve usage', () => { it('uses hot flag to alter bundle', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); @@ -64,8 +61,7 @@ describe('basic serve usage', () => { it('uses hot-only flag to alter bundle', async () => { const { stdout, stderr } = await runServe(['--port', port, isDevServer4 ? '--hot only' : '--hot-only'], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); @@ -73,9 +69,8 @@ describe('basic serve usage', () => { it('uses no-hot flag', async () => { const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -83,8 +78,6 @@ describe('basic serve usage', () => { const { stdout, stderr } = await runServe(['--port', port, '--hot', '--progress'], testPath); expect(stderr).toContain('webpack.Progress'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); diff --git a/test/serve/serve-variable/serve-basic.test.js b/test/serve/serve-variable/serve-basic.test.js index 7bab5984b4d..ee4b3b93c62 100644 --- a/test/serve/serve-variable/serve-basic.test.js +++ b/test/serve/serve-variable/serve-basic.test.js @@ -26,8 +26,7 @@ describe('serve variable', () => { it('compiles without flags and export variable', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); expect(stdout).toContain('PASS'); diff --git a/test/serve/with-custom-port/serve-custom-config.test.js b/test/serve/with-custom-port/serve-custom-config.test.js index bac94e4accf..4903e7ea7eb 100644 --- a/test/serve/with-custom-port/serve-custom-config.test.js +++ b/test/serve/with-custom-port/serve-custom-config.test.js @@ -26,8 +26,7 @@ describe('serve with devServer in config', () => { it('Should pick up the host and port from config', async () => { const { stdout, stderr } = await runServe([], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); @@ -38,8 +37,7 @@ describe('serve with devServer in config', () => { it('Port flag should override the config port', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); @@ -50,8 +48,7 @@ describe('serve with devServer in config', () => { it('Passing hot flag works alongside other server config', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); // HMR is being used @@ -63,8 +60,7 @@ describe('serve with devServer in config', () => { it('works fine when no-hot flag is passed alongside other server config', async () => { const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); // HMR is not being used diff --git a/test/stats/cli-flags/stats.test.js b/test/stats/cli-flags/stats.test.js index 21e5a4566ff..71c1fcb495a 100644 --- a/test/stats/cli-flags/stats.test.js +++ b/test/stats/cli-flags/stats.test.js @@ -15,8 +15,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', `${preset}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: '${preset}' }`); @@ -30,8 +29,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: 'normal' }`); diff --git a/test/stats/config/stats.test.js b/test/stats/config/stats.test.js index 2eeb66671c7..6d4510b5224 100644 --- a/test/stats/config/stats.test.js +++ b/test/stats/config/stats.test.js @@ -16,8 +16,7 @@ describe('stats flag with config', () => { const { exitCode, stderr, stdout } = run(__dirname, []); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'normal' }`); @@ -31,8 +30,7 @@ describe('stats flag with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', `${preset}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: '${preset}' }`); diff --git a/test/stats/watch/multi-webpack.config.js b/test/stats/watch/multi-webpack.config.js index 7d116eda8b8..f2c12cc6680 100644 --- a/test/stats/watch/multi-webpack.config.js +++ b/test/stats/watch/multi-webpack.config.js @@ -1,10 +1,32 @@ +const webpack = require('webpack'); + module.exports = [ { + name: 'first', watch: true, stats: 'none', + plugins: [ + { + apply(compiler) { + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap('webpack-cli-test', () => { + console.log(`webpack ${webpack.version}`); + }); + }, + }, + ], }, { + name: 'two', watch: true, stats: 'none', + plugins: [ + { + apply(compiler) { + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap('webpack-cli-test', () => { + console.log(`webpack ${webpack.version}`); + }); + }, + }, + ], }, ]; diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js index 86ef24df20e..e180b31741e 100644 --- a/test/stats/watch/stats-and-watch.test.js +++ b/test/stats/watch/stats-and-watch.test.js @@ -2,33 +2,25 @@ const { runWatch } = require('../../utils/test-utils'); -// const output = isWebpack5 ? 'successfully' : 'main.js'; - describe('stats and watch', () => { it('should not log stats with the "none" value from the configuration', async () => { - const { stderr } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compiler is watching files for updates...'); - // expect(stdout).toContain(output); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); it('should not log stats with the "none" value from the configuration and multi compiler mode', async () => { - const { stderr } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compiler is watching files for updates...'); - // expect(stdout).toContain(output); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); it('should log stats with the "normal" value in arguments', async () => { - const { stderr } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compiler is watching files for updates...'); - // expect(stdout).toContain(output); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/stats/watch/webpack.config.js b/test/stats/watch/webpack.config.js index 65a1ecbbe75..d98762eafc4 100644 --- a/test/stats/watch/webpack.config.js +++ b/test/stats/watch/webpack.config.js @@ -1,5 +1,16 @@ +const webpack = require('webpack'); + module.exports = { watch: true, stats: 'none', - mode: 'production', + mode: 'development', + plugins: [ + { + apply(compiler) { + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap('webpack-cli-test', () => { + console.log(`webpack ${webpack.version}`); + }); + }, + }, + ], }; diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index b761b9c7cc8..0705a117cee 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -9,8 +9,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target', `${val}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); @@ -23,8 +22,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-t', `${val}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); @@ -53,8 +51,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target', 'node', '--target', 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: [ 'node', 'async-node' ]`); }); @@ -78,8 +75,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target-reset', '--target', 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: [ 'async-node' ]`); }); diff --git a/test/target/node/node-test.test.js b/test/target/node/node-test.test.js index d672dcb2d01..7eecf415504 100644 --- a/test/target/node/node-test.test.js +++ b/test/target/node/node-test.test.js @@ -6,8 +6,7 @@ describe('Node target', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/utils/cli-plugin-test/plugin.test.js b/test/utils/cli-plugin-test/plugin.test.js index 9473f01064f..77b4a6e8d09 100644 --- a/test/utils/cli-plugin-test/plugin.test.js +++ b/test/utils/cli-plugin-test/plugin.test.js @@ -7,8 +7,7 @@ describe('webpack-cli-test-plugin Test', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: 'node'`); if (typeof cli !== 'undefined') { diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 7b57ff9db22..329ae19a3d0 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -7,6 +7,7 @@ const { sync: spawnSync, node: execaNode } = execa; const { Writable } = require('readable-stream'); const concat = require('concat-stream'); const { version } = require('webpack'); +const stripAnsi = require('strip-ansi'); const { version: devServerVersion } = require('webpack-dev-server/package.json'); const WEBPACK_PATH = path.resolve(__dirname, '../../packages/webpack-cli/bin/cli.js'); @@ -51,7 +52,7 @@ const run = (testCase, args = [], setOutput = true, nodeOptions = [], env) => { return result; }; -const runWatch = (testCase, args = [], setOutput = true, outputKillStr = 'Compiler is watching files for updates...') => { +const runWatch = (testCase, args = [], setOutput = true, outputKillStr = /webpack \d+\.\d+\.\d/) => { const cwd = path.resolve(testCase); const outputPath = path.resolve(testCase, 'bin'); @@ -64,12 +65,12 @@ const runWatch = (testCase, args = [], setOutput = true, outputKillStr = 'Compil stdio: 'pipe', }); - proc.stderr.pipe( + proc.stdout.pipe( new Writable({ write(chunk, encoding, callback) { - const output = chunk.toString('utf8'); + const output = stripAnsi(chunk.toString('utf8')); - if (output.includes(outputKillStr)) { + if (outputKillStr.test(output)) { if (isWindows) { exec('taskkill /pid ' + proc.pid + ' /T /F'); } else { diff --git a/test/utils/test-utils.test.js b/test/utils/test-utils.test.js index daff27b08e9..0e4d3aeafb6 100644 --- a/test/utils/test-utils.test.js +++ b/test/utils/test-utils.test.js @@ -38,8 +38,7 @@ describe('run function', () => { it('should work correctly by default', () => { const { command, stdout, stderr } = run(__dirname); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Executes the correct command expect(command).toContain('cli.js'); // Should use apply a default output dir @@ -67,8 +66,7 @@ describe('run function', () => { // execution command contains info command expect(command).not.toContain('--output-path'); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); @@ -82,8 +80,7 @@ describe('runAndGetWatchProc function', () => { // Should use apply a default output dir expect(command).toContain('--output-path'); expect(command).toContain('bin'); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -106,8 +103,7 @@ describe('runAndGetWatchProc function', () => { // execution command contains info command expect(command).not.toContain('--output-path'); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); diff --git a/test/version/version-external-packages.test.js b/test/version/version-external-packages.test.js index bfd6f4ba23b..d936da17f0d 100644 --- a/test/version/version-external-packages.test.js +++ b/test/version/version-external-packages.test.js @@ -14,63 +14,63 @@ describe('version flag with external packages', () => { const { exitCode, stderr, stdout } = run(__dirname, ['init', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(initPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with the alias c for init', () => { const { exitCode, stderr, stdout } = run(__dirname, ['c', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(initPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with info', () => { const { exitCode, stderr, stdout } = run(__dirname, ['info', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(infoPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with serve', () => { const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(servePkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with migrate', () => { const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(migratePkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with plugin', () => { const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pluginPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with loader', () => { const { exitCode, stderr, stdout } = run(__dirname, ['loader', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(loaderPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it(' should throw error for multiple commands', () => { @@ -89,7 +89,7 @@ describe('version flag with external packages', () => { expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBe(''); + expect(stdout).toBeFalsy(); }); it(' should throw error if invalid argument is present with version command', () => { @@ -98,7 +98,7 @@ describe('version flag with external packages', () => { expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBe(''); + expect(stdout).toBeFalsy(); }); it(' should throw error if invalid argument is present with -v alias', () => { @@ -107,6 +107,6 @@ describe('version flag with external packages', () => { expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBe(''); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/version/version-multi-args.test.js b/test/version/version-multi-args.test.js index f5de6205cb6..8059926546f 100644 --- a/test/version/version-multi-args.test.js +++ b/test/version/version-multi-args.test.js @@ -8,71 +8,71 @@ describe('version flag with multiple arguments', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', 'help'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(pkgJSON.version); expect(stdout).toContain('The build tool for modern web applications'); - expect(stderr).toHaveLength(0); }); it('does not output version with help dashed', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', '--help'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(pkgJSON.version); expect(stdout).toContain('The build tool for modern web applications'); - expect(stderr).toHaveLength(0); }); it('throws error if invalid command is passed with version command', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid option is passed with version command', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid command is passed with --version flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid option is passed with --version flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid command is passed with -v alias', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-v', 'abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid option is passed with -v alias', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-v', '--abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); }); diff --git a/test/version/version-single-arg.test.js b/test/version/version-single-arg.test.js index 8516f802bb9..72b34cbcff6 100644 --- a/test/version/version-single-arg.test.js +++ b/test/version/version-single-arg.test.js @@ -8,23 +8,23 @@ describe('single version flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs versions with dashed syntax', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs versions with alias syntax', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-v'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pkgJSON.version); - expect(stderr).toHaveLength(0); }); }); diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index caa2f970530..404a17fc568 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -13,8 +13,7 @@ describe('--watch flag', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './watch.config.js', '--no-watch']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -36,13 +35,7 @@ describe('--watch flag', () => { expect(data).toContain(word); } } - } - }); - - proc.stderr.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); - if (data.includes('Compiler is watching files for updates...')) { if (!modified) { process.nextTick(() => { writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); diff --git a/test/zero-config/entry-absent/zero-config.test.js b/test/zero-config/entry-absent/zero-config.test.js index 005e22689e2..c55f05e049a 100644 --- a/test/zero-config/entry-absent/zero-config.test.js +++ b/test/zero-config/entry-absent/zero-config.test.js @@ -5,8 +5,7 @@ describe('Zero Config tests', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Entry file is absent, should log the Error from the compiler expect(stdout).toContain("Error: Can't resolve './src'"); }); diff --git a/test/zero-config/entry-present/zero-config.test.js b/test/zero-config/entry-present/zero-config.test.js index b39db4d1243..671cf74933d 100644 --- a/test/zero-config/entry-present/zero-config.test.js +++ b/test/zero-config/entry-present/zero-config.test.js @@ -5,8 +5,7 @@ describe('Zero Config tests', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should be able to find the entry file expect(stdout).toContain('./src/index.js'); // Should output at the default output dir and filename From ed474c60af8d6e26b0647d9fa89dadd4ee9913be Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 8 Dec 2020 19:19:55 +0530 Subject: [PATCH 165/581] docs: info package docs (#2215) --- packages/info/README.md | 65 ++++++++++------------------------------- 1 file changed, 15 insertions(+), 50 deletions(-) diff --git a/packages/info/README.md b/packages/info/README.md index c1140dbedd2..ed1603fc691 100644 --- a/packages/info/README.md +++ b/packages/info/README.md @@ -15,70 +15,35 @@ npm i -D @webpack-cli/info #yarn yarn add @webpack-cli/info -D +``` + +## Usage + +```bash #npx npx webpack info [options] -``` +#local installation +webpack info [options] -## Usage +``` ### Args / Flags #### Output format -| Flag | Description | Type | -| ------------------------------- | ------------------------------------- | ---------- | -| `--output < json or markdown >` | To get the output in specified format | [ string ] | +| Flag | Description | Type | +| ------------------------------- | ------------------------------------- | ------ | +| `--output < json or markdown >` | To get the output in specified format | string | _Not supported for config_ #### Options -| Flag | Description | Type | -| ----------- | ------------------------------------------ | ----------- | -| `--help` | Show help | [ boolean ] | -| `--version` | Show version number of `@webpack-cli/info` | [ boolean ] | - -### Node - -```js -const info = require('@webpack-cli/info').default; - -async function wrapperFunc() { - await info({ - /* Custom Config */ - }); -} -wrapperFunc(); -``` - -#### Custom config - -> Config has higher precedence than system flags - -```json -// Config's relative path -{ - - "config": [string] -} - // System info -{ - "binaries": [boolean], - "system": [boolean], - "browsers": [boolean], - "npmg": [boolean], - "npmPackages": [boolean], -} -``` - -The function returns `string` for `system` info, and returns an array of strings (`string[]`) for `config` - -### CLI (via `webpack-cli`) - -```bash -webpack-cli info --FLAGS #Flags are optional for custom output -``` +| Flag | Description | Type | +| ----------- | ------------------------------------------ | ------- | +| `--help` | Show help | boolean | +| `--version` | Show version number of `@webpack-cli/info` | boolean | [downloads]: https://img.shields.io/npm/dm/@webpack-cli/info.svg [downloads-url]: https://www.npmjs.com/package/@webpack-cli/info From 9c761789a87abe3459fd753a9e4accf320969f88 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Thu, 10 Dec 2020 17:01:20 +0530 Subject: [PATCH 166/581] tests: rm redundant tests (#2222) --- packages/webpack-cli/__tests__/info.test.js | 57 -------------------- packages/webpack-cli/__tests__/init.test.js | 60 --------------------- 2 files changed, 117 deletions(-) delete mode 100644 packages/webpack-cli/__tests__/info.test.js delete mode 100644 packages/webpack-cli/__tests__/init.test.js diff --git a/packages/webpack-cli/__tests__/info.test.js b/packages/webpack-cli/__tests__/info.test.js deleted file mode 100644 index 1011216ed38..00000000000 --- a/packages/webpack-cli/__tests__/info.test.js +++ /dev/null @@ -1,57 +0,0 @@ -const { sync: spawnSync } = require('execa'); -const path = require('path'); - -describe('Info', () => { - it('should run with cli', () => { - const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info'], { - cwd: path.resolve(__dirname), - reject: false, - }); - - expect(exitCode).toBe(0); - expect(stdout).toContain('System'); - expect(stdout).toContain('Binaries'); - expect(stdout).toContain('OS'); - expect(stderr).toBeFalsy(); - }); - - it('should respect --output=json', () => { - const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=json'], { - cwd: path.resolve(__dirname), - reject: false, - }); - - expect(exitCode).toBe(0); - const testJSON = () => { - const output = JSON.parse(stdout); - expect(output['System']).toBeTruthy(); - expect(output['System']['OS']).toBeTruthy(); - }; - expect(testJSON).not.toThrow(); - expect(stderr).toBeFalsy(); - }); - - it('should respect --output=markdown', () => { - const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=markdown'], { - cwd: path.resolve(__dirname), - reject: false, - }); - - expect(exitCode).toBe(0); - expect(stdout).toContain('## System'); - expect(stdout).toContain('## Binaries'); - expect(stdout).toContain('## Browsers'); - expect(stderr).toBeFalsy(); - }); - - it('should throw an error for invalid output type', () => { - const { exitCode, stderr, stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=test'], { - cwd: path.resolve(__dirname), - reject: false, - }); - - expect(exitCode).toBe(2); - expect(stderr).toContain("'test' is not a valid value for output"); - expect(stdout).toBeFalsy(); - }); -}); diff --git a/packages/webpack-cli/__tests__/init.test.js b/packages/webpack-cli/__tests__/init.test.js deleted file mode 100644 index 26db5236f37..00000000000 --- a/packages/webpack-cli/__tests__/init.test.js +++ /dev/null @@ -1,60 +0,0 @@ -/* eslint-disable node/no-extraneous-require */ -const { sync: spawnSync } = require('execa'); -const path = require('path'); -const fs = require('fs'); -const rimraf = require('rimraf'); - -const genPath = path.resolve(__dirname, './test-assets'); -const firstPrompt = 'Will your application have multiple bundles?'; - -describe('init', () => { - beforeAll(() => { - rimraf.sync(genPath); - fs.mkdirSync(genPath); - }); - - afterAll(() => { - rimraf.sync(genPath); - }); - - it('should work with cli', () => { - const { stdout, stderr } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['init'], { - cwd: genPath, - reject: false, - }); - expect(stdout).toBeTruthy(); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(firstPrompt); - }); - it('should run with cli when auto is supplied', () => { - const { stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['init', '--auto'], { - cwd: genPath, - reject: false, - }); - // Test no prompts are present - expect(stdout).toBeTruthy(); - expect(stdout).not.toContain(firstPrompt); - - // Skip test in case installation fails - if (!fs.existsSync(path.resolve(genPath, './yarn.lock'))) { - return; - } - - // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js']; - - files.forEach((file) => { - expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); - }); - - // Check package json is correctly configured - const pkgJsonTests = () => { - const pkgJson = require(path.join(genPath, './package.json')); - expect(pkgJson).toBeTruthy(); - expect(pkgJson['devDependencies']).toBeTruthy(); - expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); - expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); - }; - expect(pkgJsonTests).not.toThrow(); - }); -}); From cf278b1e55cfe23a35f632286fd142067b3ebc35 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:52:37 +0300 Subject: [PATCH 167/581] chore(deps-dev): bump webpack from 5.10.0 to 5.10.2 (#2241) Bumps [webpack](https://github.com/webpack/webpack) from 5.10.0 to 5.10.2. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.10.0...v5.10.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 242 +++++++++++++++++++++++++++--------------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7dd6361d8b0..d7d86d24718 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2596,149 +2596,149 @@ semver "^7.3.2" tsutils "^3.17.1" -"@webassemblyjs/ast@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" - integrity sha512-C6wW5L+b7ogSDVqymbkkvuW9kruN//YisMED04xzeBBqjHa2FYnmvOlS6Xj68xWQRgWvI9cIglsjFowH/RJyEA== +"@webassemblyjs/ast@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.1.tgz#76c6937716d68bf1484c15139f5ed30b9abc8bb4" + integrity sha512-uMu1nCWn2Wxyy126LlGqRVlhdTOsO/bsBRI4dNq3+6SiSuRKRQX6ejjKgh82LoGAPSq72lDUiQ4FWVaf0PecYw== dependencies: - "@webassemblyjs/helper-module-context" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/wast-parser" "1.9.0" + "@webassemblyjs/helper-module-context" "1.9.1" + "@webassemblyjs/helper-wasm-bytecode" "1.9.1" + "@webassemblyjs/wast-parser" "1.9.1" -"@webassemblyjs/floating-point-hex-parser@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.0.tgz#3c3d3b271bddfc84deb00f71344438311d52ffb4" - integrity sha512-TG5qcFsS8QB4g4MhrxK5TqfdNe7Ey/7YL/xN+36rRjl/BlGE/NcBvJcqsRgCP6Z92mRE+7N50pRIi8SmKUbcQA== +"@webassemblyjs/floating-point-hex-parser@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.1.tgz#9eb0ff90a1cdeef51f36ba533ed9f06b5cdadd09" + integrity sha512-5VEKu024RySmLKTTBl9q1eO/2K5jk9ZS+2HXDBLA9s9p5IjkaXxWiDb/+b7wSQp6FRdLaH1IVGIfOex58Na2pg== -"@webassemblyjs/helper-api-error@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.0.tgz#203f676e333b96c9da2eeab3ccef33c45928b6a2" - integrity sha512-NcMLjoFMXpsASZFxJ5h2HZRcEhDkvnNFOAKneP5RbKRzaWJN36NC4jqQHKwStIhGXu5mUWlUUk7ygdtrO8lbmw== +"@webassemblyjs/helper-api-error@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.1.tgz#ad89015c4246cd7f5ed0556700237f8b9c2c752f" + integrity sha512-y1lGmfm38djrScwpeL37rRR9f1D6sM8RhMpvM7CYLzOlHVboouZokXK/G88BpzW0NQBSvCCOnW5BFhten4FPfA== -"@webassemblyjs/helper-buffer@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.9.0.tgz#a1442d269c5feb23fcbc9ef759dac3547f29de00" - integrity sha512-qZol43oqhq6yBPx7YM3m9Bv7WMV9Eevj6kMi6InKOuZxhw+q9hOkvq5e/PpKSiLfyetpaBnogSbNCfBwyB00CA== +"@webassemblyjs/helper-buffer@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.9.1.tgz#186e67ac25f9546ea7939759413987f157524133" + integrity sha512-uS6VSgieHbk/m4GSkMU5cqe/5TekdCzQso4revCIEQ3vpGZgqSSExi4jWpTWwDpAHOIAb1Jfrs0gUB9AA4n71w== -"@webassemblyjs/helper-code-frame@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.9.0.tgz#647f8892cd2043a82ac0c8c5e75c36f1d9159f27" - integrity sha512-ERCYdJBkD9Vu4vtjUYe8LZruWuNIToYq/ME22igL+2vj2dQ2OOujIZr3MEFvfEaqKoVqpsFKAGsRdBSBjrIvZA== +"@webassemblyjs/helper-code-frame@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.9.1.tgz#aab177b7cc87a318a8f8664ad68e2c3828ebc42b" + integrity sha512-ZQ2ZT6Evk4DPIfD+92AraGYaFIqGm4U20e7FpXwl7WUo2Pn1mZ1v8VGH8i+Y++IQpxPbQo/UyG0Khs7eInskzA== dependencies: - "@webassemblyjs/wast-printer" "1.9.0" + "@webassemblyjs/wast-printer" "1.9.1" -"@webassemblyjs/helper-fsm@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.9.0.tgz#c05256b71244214671f4b08ec108ad63b70eddb8" - integrity sha512-OPRowhGbshCb5PxJ8LocpdX9Kl0uB4XsAjl6jH/dWKlk/mzsANvhwbiULsaiqT5GZGT9qinTICdj6PLuM5gslw== +"@webassemblyjs/helper-fsm@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.9.1.tgz#527e91628e84d13d3573884b3dc4c53a81dcb911" + integrity sha512-J32HGpveEqqcKFS0YbgicB0zAlpfIxJa5MjxDxhu3i5ltPcVfY5EPvKQ1suRguFPehxiUs+/hfkwPEXom/l0lw== -"@webassemblyjs/helper-module-context@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.9.0.tgz#25d8884b76839871a08a6c6f806c3979ef712f07" - integrity sha512-MJCW8iGC08tMk2enck1aPW+BE5Cw8/7ph/VGZxwyvGbJwjktKkDK7vy7gAmMDx88D7mhDTCNKAW5tED+gZ0W8g== +"@webassemblyjs/helper-module-context@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.9.1.tgz#778670b3d471f7cf093d1e7c0dde431b54310e16" + integrity sha512-IEH2cMmEQKt7fqelLWB5e/cMdZXf2rST1JIrzWmf4XBt3QTxGdnnLvV4DYoN8pJjOx0VYXsWg+yF16MmJtolZg== dependencies: - "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/ast" "1.9.1" -"@webassemblyjs/helper-wasm-bytecode@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.0.tgz#4fed8beac9b8c14f8c58b70d124d549dd1fe5790" - integrity sha512-R7FStIzyNcd7xKxCZH5lE0Bqy+hGTwS3LJjuv1ZVxd9O7eHCedSdrId/hMOd20I+v8wDXEn+bjfKDLzTepoaUw== +"@webassemblyjs/helper-wasm-bytecode@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.1.tgz#563f59bcf409ccf469edde168b9426961ffbf6df" + integrity sha512-i2rGTBqFUcSXxyjt2K4vm/3kkHwyzG6o427iCjcIKjOqpWH8SEem+xe82jUk1iydJO250/CvE5o7hzNAMZf0dQ== -"@webassemblyjs/helper-wasm-section@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.9.0.tgz#5a4138d5a6292ba18b04c5ae49717e4167965346" - integrity sha512-XnMB8l3ek4tvrKUUku+IVaXNHz2YsJyOOmz+MMkZvh8h1uSJpSen6vYnw3IoQ7WwEuAhL8Efjms1ZWjqh2agvw== +"@webassemblyjs/helper-wasm-section@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.9.1.tgz#f7988f94c12b01b99a16120cb01dc099b00e4798" + integrity sha512-FetqzjtXZr2d57IECK+aId3D0IcGweeM0CbAnJHkYJkcRTHP+YcMb7Wmc0j21h5UWBpwYGb9dSkK/93SRCTrGg== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-buffer" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/wasm-gen" "1.9.0" + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/helper-buffer" "1.9.1" + "@webassemblyjs/helper-wasm-bytecode" "1.9.1" + "@webassemblyjs/wasm-gen" "1.9.1" -"@webassemblyjs/ieee754@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.9.0.tgz#15c7a0fbaae83fb26143bbacf6d6df1702ad39e4" - integrity sha512-dcX8JuYU/gvymzIHc9DgxTzUUTLexWwt8uCTWP3otys596io0L5aW02Gb1RjYpx2+0Jus1h4ZFqjla7umFniTg== +"@webassemblyjs/ieee754@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.9.1.tgz#3b715871ca7d75784717cf9ceca9d7b81374b8af" + integrity sha512-EvTG9M78zP1MmkBpUjGQHZc26DzPGZSLIPxYHCjQsBMo60Qy2W34qf8z0exRDtxBbRIoiKa5dFyWer/7r1aaSQ== dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.9.0.tgz#f19ca0b76a6dc55623a09cffa769e838fa1e1c95" - integrity sha512-ENVzM5VwV1ojs9jam6vPys97B/S65YQtv/aanqnU7D8aSoHFX8GyhGg0CMfyKNIHBuAVjy3tlzd5QMMINa7wpw== +"@webassemblyjs/leb128@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.9.1.tgz#b2ecaa39f9e8277cc9c707c1ca8b2aa7b27d0b72" + integrity sha512-Oc04ub0vFfLnF+2/+ki3AE+anmW4sv9uNBqb+79fgTaPv6xJsOT0dhphNfL3FrME84CbX/D1T9XT8tjFo0IIiw== dependencies: "@xtuc/long" "4.2.2" -"@webassemblyjs/utf8@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.9.0.tgz#04d33b636f78e6a6813227e82402f7637b6229ab" - integrity sha512-GZbQlWtopBTP0u7cHrEx+73yZKrQoBMpwkGEIqlacljhXCkVM1kMQge/Mf+csMJAjEdSwhOyLAS0AoR3AG5P8w== +"@webassemblyjs/utf8@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.9.1.tgz#d02d9daab85cda3211e43caf31dca74c260a73b0" + integrity sha512-llkYtppagjCodFjo0alWOUhAkfOiQPQDIc5oA6C9sFAXz7vC9QhZf/f8ijQIX+A9ToM3c9Pq85X0EX7nx9gVhg== -"@webassemblyjs/wasm-edit@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.9.0.tgz#3fe6d79d3f0f922183aa86002c42dd256cfee9cf" - integrity sha512-FgHzBm80uwz5M8WKnMTn6j/sVbqilPdQXTWraSjBwFXSYGirpkSWE2R9Qvz9tNiTKQvoKILpCuTjBKzOIm0nxw== - dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-buffer" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/helper-wasm-section" "1.9.0" - "@webassemblyjs/wasm-gen" "1.9.0" - "@webassemblyjs/wasm-opt" "1.9.0" - "@webassemblyjs/wasm-parser" "1.9.0" - "@webassemblyjs/wast-printer" "1.9.0" - -"@webassemblyjs/wasm-gen@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.9.0.tgz#50bc70ec68ded8e2763b01a1418bf43491a7a49c" - integrity sha512-cPE3o44YzOOHvlsb4+E9qSqjc9Qf9Na1OO/BHFy4OI91XDE14MjFN4lTMezzaIWdPqHnsTodGGNP+iRSYfGkjA== +"@webassemblyjs/wasm-edit@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.9.1.tgz#e27a6bdbf78e5c72fa812a2fc3cbaad7c3e37578" + integrity sha512-S2IaD6+x9B2Xi8BCT0eGsrXXd8UxAh2LVJpg1ZMtHXnrDcsTtIX2bDjHi40Hio6Lc62dWHmKdvksI+MClCYbbw== + dependencies: + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/helper-buffer" "1.9.1" + "@webassemblyjs/helper-wasm-bytecode" "1.9.1" + "@webassemblyjs/helper-wasm-section" "1.9.1" + "@webassemblyjs/wasm-gen" "1.9.1" + "@webassemblyjs/wasm-opt" "1.9.1" + "@webassemblyjs/wasm-parser" "1.9.1" + "@webassemblyjs/wast-printer" "1.9.1" + +"@webassemblyjs/wasm-gen@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.9.1.tgz#56a0787d1fa7994fdc7bea59004e5bec7189c5fc" + integrity sha512-bqWI0S4lBQsEN5FTZ35vYzfKUJvtjNnBobB1agCALH30xNk1LToZ7Z8eiaR/Z5iVECTlBndoRQV3F6mbEqE/fg== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/ieee754" "1.9.0" - "@webassemblyjs/leb128" "1.9.0" - "@webassemblyjs/utf8" "1.9.0" + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/helper-wasm-bytecode" "1.9.1" + "@webassemblyjs/ieee754" "1.9.1" + "@webassemblyjs/leb128" "1.9.1" + "@webassemblyjs/utf8" "1.9.1" -"@webassemblyjs/wasm-opt@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.0.tgz#2211181e5b31326443cc8112eb9f0b9028721a61" - integrity sha512-Qkjgm6Anhm+OMbIL0iokO7meajkzQD71ioelnfPEj6r4eOFuqm4YC3VBPqXjFyyNwowzbMD+hizmprP/Fwkl2A== +"@webassemblyjs/wasm-opt@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.1.tgz#fbdf8943a825e6dcc4cd69c3e092289fa4aec96c" + integrity sha512-gSf7I7YWVXZ5c6XqTEqkZjVs8K1kc1k57vsB6KBQscSagDNbAdxt6MwuJoMjsE1yWY1tsuL+pga268A6u+Fdkg== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-buffer" "1.9.0" - "@webassemblyjs/wasm-gen" "1.9.0" - "@webassemblyjs/wasm-parser" "1.9.0" + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/helper-buffer" "1.9.1" + "@webassemblyjs/wasm-gen" "1.9.1" + "@webassemblyjs/wasm-parser" "1.9.1" -"@webassemblyjs/wasm-parser@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.9.0.tgz#9d48e44826df4a6598294aa6c87469d642fff65e" - integrity sha512-9+wkMowR2AmdSWQzsPEjFU7njh8HTO5MqO8vjwEHuM+AMHioNqSBONRdr0NQQ3dVQrzp0s8lTcYqzUdb7YgELA== +"@webassemblyjs/wasm-parser@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.9.1.tgz#5e8352a246d3f605312c8e414f7990de55aaedfa" + integrity sha512-ImM4N2T1MEIond0MyE3rXvStVxEmivQrDKf/ggfh5pP6EHu3lL/YTAoSrR7shrbKNPpeKpGesW1LIK/L4kqduw== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-api-error" "1.9.0" - "@webassemblyjs/helper-wasm-bytecode" "1.9.0" - "@webassemblyjs/ieee754" "1.9.0" - "@webassemblyjs/leb128" "1.9.0" - "@webassemblyjs/utf8" "1.9.0" + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/helper-api-error" "1.9.1" + "@webassemblyjs/helper-wasm-bytecode" "1.9.1" + "@webassemblyjs/ieee754" "1.9.1" + "@webassemblyjs/leb128" "1.9.1" + "@webassemblyjs/utf8" "1.9.1" -"@webassemblyjs/wast-parser@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.9.0.tgz#3031115d79ac5bd261556cecc3fa90a3ef451914" - integrity sha512-qsqSAP3QQ3LyZjNC/0jBJ/ToSxfYJ8kYyuiGvtn/8MK89VrNEfwj7BPQzJVHi0jGTRK2dGdJ5PRqhtjzoww+bw== - dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/floating-point-hex-parser" "1.9.0" - "@webassemblyjs/helper-api-error" "1.9.0" - "@webassemblyjs/helper-code-frame" "1.9.0" - "@webassemblyjs/helper-fsm" "1.9.0" +"@webassemblyjs/wast-parser@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.9.1.tgz#e25ef13585c060073c1db0d6bd94340fdeee7596" + integrity sha512-2xVxejXSvj3ls/o2TR/zI6p28qsGupjHhnHL6URULQRcXmryn3w7G83jQMcT7PHqUfyle65fZtWLukfdLdE7qw== + dependencies: + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/floating-point-hex-parser" "1.9.1" + "@webassemblyjs/helper-api-error" "1.9.1" + "@webassemblyjs/helper-code-frame" "1.9.1" + "@webassemblyjs/helper-fsm" "1.9.1" "@xtuc/long" "4.2.2" -"@webassemblyjs/wast-printer@1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.9.0.tgz#4935d54c85fef637b00ce9f52377451d00d47899" - integrity sha512-2J0nE95rHXHyQ24cWjMKJ1tqB/ds8z/cyeOZxJhcb+rW+SQASVjuznUSmdz5GpVJTzU8JkhYut0D3siFDD6wsA== +"@webassemblyjs/wast-printer@1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.9.1.tgz#b9f38e93652037d4f3f9c91584635af4191ed7c1" + integrity sha512-tDV8V15wm7mmbAH6XvQRU1X+oPGmeOzYsd6h7hlRLz6QpV4Ec/KKxM8OpLtFmQPLCreGxTp+HuxtH4pRIZyL9w== dependencies: - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/wast-parser" "1.9.0" + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/wast-parser" "1.9.1" "@xtuc/long" "4.2.2" "@xtuc/ieee754@^1.2.0": @@ -11693,16 +11693,16 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.10.0: - version "5.10.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.10.0.tgz#6f77c31522a2c525152d9c344f9765d168b3df08" - integrity sha512-P0bHAXmIz0zsNcHNLqFmLY1ZtrT+jtBr7FqpuDtA2o7GiHC+zBsfhgK7SmJ1HG7BAEb3G9JoMdSVi7mEDvG3Zg== + version "5.10.2" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.10.2.tgz#990ad134b8a6406b5e40e63da1870e0de40215dc" + integrity sha512-KpYTJerfb2KGxcOJNA1SMWXAf8/dxCDaQOhPIrfoV5rYceqet7OY/h3941/kuapx0noMcpTiVoNN3EHXsTYlsg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" - "@webassemblyjs/ast" "1.9.0" - "@webassemblyjs/helper-module-context" "1.9.0" - "@webassemblyjs/wasm-edit" "1.9.0" - "@webassemblyjs/wasm-parser" "1.9.0" + "@webassemblyjs/ast" "1.9.1" + "@webassemblyjs/helper-module-context" "1.9.1" + "@webassemblyjs/wasm-edit" "1.9.1" + "@webassemblyjs/wasm-parser" "1.9.1" acorn "^8.0.4" browserslist "^4.14.5" chrome-trace-event "^1.0.2" From 525504e08eab499b7f3d8c5eaa34f59a077761a1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:04:35 +0300 Subject: [PATCH 168/581] chore(deps): bump commander from 6.2.0 to 6.2.1 (#2240) Bumps [commander](https://github.com/tj/commander.js) from 6.2.0 to 6.2.1. - [Release notes](https://github.com/tj/commander.js/releases) - [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/tj/commander.js/compare/v6.2.0...v6.2.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d7d86d24718..b430ffa86f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3910,9 +3910,9 @@ commander@^2.18.0, commander@^2.20.0: integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== commander@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" - integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q== + version "6.2.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" + integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== commitlint-config-cz@^0.13.2: version "0.13.2" From 671b0ee226c9bd4da4cbf343efc3cc9ed91e467b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:05:01 +0300 Subject: [PATCH 169/581] chore(deps-dev): bump eslint-plugin-prettier from 3.2.0 to 3.3.0 (#2239) Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases) - [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-plugin-prettier/compare/v3.2.0...v3.3.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b430ffa86f2..d1a3b5156c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4906,9 +4906,9 @@ eslint-plugin-node@^11.1.0: semver "^6.1.0" eslint-plugin-prettier@^3.1.4: - version "3.2.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.2.0.tgz#af391b2226fa0e15c96f36c733f6e9035dbd952c" - integrity sha512-kOUSJnFjAUFKwVxuzy6sA5yyMx6+o9ino4gCdShzBNx4eyFRudWRYKCFolKjoM40PEiuU6Cn7wBLfq3WsGg7qg== + version "3.3.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.0.tgz#61e295349a65688ffac0b7808ef0a8244bdd8d40" + integrity sha512-tMTwO8iUWlSRZIwS9k7/E4vrTsfvsrcM5p1eftyuqWH25nKsz/o6/54I7jwQ/3zobISyC7wMy9ZsFwgTxOcOpQ== dependencies: prettier-linter-helpers "^1.0.0" From 1717c404913fd09ff36cd9b059b57e80aa81505c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:05:11 +0300 Subject: [PATCH 170/581] chore(deps-dev): bump husky from 4.3.5 to 4.3.6 (#2238) Bumps [husky](https://github.com/typicode/husky) from 4.3.5 to 4.3.6. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](https://github.com/typicode/husky/compare/v4.3.5...v4.3.6) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d1a3b5156c2..42739139562 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6282,9 +6282,9 @@ humanize-ms@^1.2.1: ms "^2.0.0" husky@^4.3.0: - version "4.3.5" - resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.5.tgz#ab8d2a0eb6b62fef2853ee3d442c927d89290902" - integrity sha512-E5S/1HMoDDaqsH8kDF5zeKEQbYqe3wL9zJDyqyYqc8I4vHBtAoxkDBGXox0lZ9RI+k5GyB728vZdmnM4bYap+g== + version "4.3.6" + resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.6.tgz#ebd9dd8b9324aa851f1587318db4cccb7665a13c" + integrity sha512-o6UjVI8xtlWRL5395iWq9LKDyp/9TE7XMOTvIpEVzW638UcGxTmV5cfel6fsk/jbZSTlvfGVJf2svFtybcIZag== dependencies: chalk "^4.0.0" ci-info "^2.0.0" From 00a8d63ad7809c38cc1bb186b6b006268f42afdb Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:05:21 +0300 Subject: [PATCH 171/581] chore(deps-dev): bump @types/node from 14.14.10 to 14.14.13 (#2237) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.10 to 14.14.13. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 42739139562..b1838585775 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2448,9 +2448,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.10" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.10.tgz#5958a82e41863cfc71f2307b3748e3491ba03785" - integrity sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ== + version "14.14.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.13.tgz#9e425079799322113ae8477297ae6ef51b8e0cdf" + integrity sha512-vbxr0VZ8exFMMAjCW8rJwaya0dMCDyYW2ZRdTyjtrCvJoENMpdUHOT/eTzvgyA5ZnqRZ/sI0NwqAxNHKYokLJQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" From a88112ce48f6f2747cdb01b97f01e657e91f76ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:05:27 +0300 Subject: [PATCH 172/581] chore(deps): bump ini from 1.3.5 to 1.3.8 (#2236) Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b1838585775..4ba523409d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6423,9 +6423,9 @@ inherits@2.0.3: integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= ini@^1.3.2, ini@^1.3.4, ini@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== init-package-json@^1.10.3: version "1.10.3" From f1e1359462128ad1de5c1826fe1b413ecdcfeb71 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:10:48 +0300 Subject: [PATCH 173/581] chore(deps-dev): bump @babel/preset-env from 7.12.7 to 7.12.10 (#2224) Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.12.7 to 7.12.10. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.10/packages/babel-preset-env) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 63 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4ba523409d4..da54d06e249 100644 --- a/yarn.lock +++ b/yarn.lock @@ -714,10 +714,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-typeof-symbol@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.12.1.tgz#9ca6be343d42512fbc2e68236a82ae64bc7af78a" - integrity sha512-EPGgpGy+O5Kg5pJFNDKuxt9RdmTgj5sgrus2XVeMp/ZIbOESadgILUbm50SNpghOh3/6yrbsH+NB5+WJTmsA7Q== +"@babel/plugin-transform-typeof-symbol@^7.12.10": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.12.10.tgz#de01c4c8f96580bd00f183072b0d0ecdcf0dec4b" + integrity sha512-JQ6H8Rnsogh//ijxspCjc21YPd3VLVoYtAwv3zQmqAt8YGYUtdo5usNhdl4b9/Vir2kPFZl6n1h0PfUz4hJhaA== dependencies: "@babel/helper-plugin-utils" "^7.10.4" @@ -746,9 +746,9 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/preset-env@^7.12.1": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.7.tgz#54ea21dbe92caf6f10cb1a0a576adc4ebf094b55" - integrity sha512-OnNdfAr1FUQg7ksb7bmbKoby4qFOHw6DKWWUNB9KqnnCldxhxJlP+21dpyaWFmf2h0rTbOkXJtAGevY3XW1eew== + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.10.tgz#ca981b95f641f2610531bd71948656306905e6ab" + integrity sha512-Gz9hnBT/tGeTE2DBNDkD7BiWRELZt+8lSysHuDwmYXUIvtwZl0zI+D6mZgXZX0u8YBlLS4tmai9ONNY9tjRgRA== dependencies: "@babel/compat-data" "^7.12.7" "@babel/helper-compilation-targets" "^7.12.5" @@ -809,12 +809,12 @@ "@babel/plugin-transform-spread" "^7.12.1" "@babel/plugin-transform-sticky-regex" "^7.12.7" "@babel/plugin-transform-template-literals" "^7.12.1" - "@babel/plugin-transform-typeof-symbol" "^7.12.1" + "@babel/plugin-transform-typeof-symbol" "^7.12.10" "@babel/plugin-transform-unicode-escapes" "^7.12.1" "@babel/plugin-transform-unicode-regex" "^7.12.1" "@babel/preset-modules" "^0.1.3" - "@babel/types" "^7.12.7" - core-js-compat "^3.7.0" + "@babel/types" "^7.12.10" + core-js-compat "^3.8.0" semver "^5.5.0" "@babel/preset-flow@^7.0.0": @@ -886,10 +886,10 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.7.tgz#6039ff1e242640a29452c9ae572162ec9a8f5d13" - integrity sha512-MNyI92qZq6jrQkXvtIiykvl4WtoRrVV9MPn+ZfsoEENjiWcBQ3ZSHrkxnJWgWtLX3XXqX5hrSQ+X69wkmesXuQ== +"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.10.tgz#7965e4a7260b26f09c56bcfcb0498af1f6d9b260" + integrity sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw== dependencies: "@babel/helper-validator-identifier" "^7.10.4" lodash "^4.17.19" @@ -3382,7 +3382,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browserslist@^4.14.5, browserslist@^4.14.6: +browserslist@^4.14.5: version "4.14.7" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.7.tgz#c071c1b3622c1c2e790799a37bb09473a4351cb6" integrity sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ== @@ -3393,6 +3393,17 @@ browserslist@^4.14.5, browserslist@^4.14.6: escalade "^3.1.1" node-releases "^1.1.66" +browserslist@^4.15.0: + version "4.15.0" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.15.0.tgz#3d48bbca6a3f378e86102ffd017d9a03f122bdb0" + integrity sha512-IJ1iysdMkGmjjYeRlDU8PQejVwxvVO5QOfXH7ylW31GO6LwNRSmm/SgRXtNsEXqMLl2e+2H5eEJ7sfynF8TCaQ== + dependencies: + caniuse-lite "^1.0.30001164" + colorette "^1.2.1" + electron-to-chromium "^1.3.612" + escalade "^3.1.1" + node-releases "^1.1.67" + bs-logger@0.x: version "0.2.6" resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" @@ -3591,6 +3602,11 @@ caniuse-lite@^1.0.30001157: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001159.tgz#bebde28f893fa9594dadcaa7d6b8e2aa0299df20" integrity sha512-w9Ph56jOsS8RL20K9cLND3u/+5WASWdhC/PPrf+V3/HsM3uHOavWOR1Xzakbv4Puo/srmPHudkmCRWM7Aq+/UA== +caniuse-lite@^1.0.30001164: + version "1.0.30001165" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001165.tgz#32955490d2f60290bb186bb754f2981917fa744f" + integrity sha512-8cEsSMwXfx7lWSUMA2s08z9dIgsnR5NAqjXP23stdsU3AUWkCr/rr4s4OFtHXn5XXr6+7kam3QFVoYyXNPdJPA== + capture-exit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4" @@ -4144,12 +4160,12 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= -core-js-compat@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.7.0.tgz#8479c5d3d672d83f1f5ab94cf353e57113e065ed" - integrity sha512-V8yBI3+ZLDVomoWICO6kq/CD28Y4r1M7CWeO4AGpMdMfseu8bkSubBmUPySMGKRTS+su4XQ07zUkAsiu9FCWTg== +core-js-compat@^3.8.0: + version "3.8.1" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.8.1.tgz#8d1ddd341d660ba6194cbe0ce60f4c794c87a36e" + integrity sha512-a16TLmy9NVD1rkjUGbwuyWkiDoN0FDpAwrfLONvHFQx0D9k7J9y0srwMT8QP/Z6HE3MIFaVynEeYwZwPX1o5RQ== dependencies: - browserslist "^4.14.6" + browserslist "^4.15.0" semver "7.0.0" core-js@^3.6.1: @@ -4690,6 +4706,11 @@ electron-to-chromium@^1.3.591: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.603.tgz#1b71bec27fb940eccd79245f6824c63d5f7e8abf" integrity sha512-J8OHxOeJkoSLgBXfV9BHgKccgfLMHh+CoeRo6wJsi6m0k3otaxS/5vrHpMNSEYY4MISwewqanPOuhAtuE8riQQ== +electron-to-chromium@^1.3.612: + version "1.3.621" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.621.tgz#0bbe2100ef0b28f88d0b1101fbdf433312f69be0" + integrity sha512-FeIuBzArONbAmKmZIsZIFGu/Gc9AVGlVeVbhCq+G2YIl6QkT0TDn2HKN/FMf1btXEB9kEmIuQf3/lBTVAbmFOg== + elegant-spinner@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/elegant-spinner/-/elegant-spinner-1.0.1.tgz#db043521c95d7e303fd8f345bedc3349cfb0729e" @@ -8559,7 +8580,7 @@ node-preload@^0.2.1: dependencies: process-on-spawn "^1.0.0" -node-releases@^1.1.66: +node-releases@^1.1.66, node-releases@^1.1.67: version "1.1.67" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.67.tgz#28ebfcccd0baa6aad8e8d4d8fe4cbc49ae239c12" integrity sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg== From b03bfd6e24d8a41738dfccb24dc3f1e3c7801573 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 18:43:46 +0300 Subject: [PATCH 174/581] chore(deps-dev): bump @types/jest from 26.0.17 to 26.0.19 (#2231) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.17 to 26.0.19. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index da54d06e249..314b32e233b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2390,9 +2390,9 @@ "@types/istanbul-lib-report" "*" "@types/jest@26.x", "@types/jest@^26.0.15": - version "26.0.17" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.17.tgz#c63b44af7528bbc05974dfacc2c90fe13ed5534d" - integrity sha512-5sy3dHuiT/nJGM0XZ8ozFgdR4Y/gmi89n2OCDthTULSi8nG3YdcSDVuxYT3X7eN62NGXWJYz2oNOpDp/aIaynQ== + version "26.0.19" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.19.tgz#e6fa1e3def5842ec85045bd5210e9bb8289de790" + integrity sha512-jqHoirTG61fee6v6rwbnEuKhpSKih0tuhqeFbCmMmErhtu3BYlOZaXWjffgOstMM4S/3iQD31lI5bGLTrs97yQ== dependencies: jest-diff "^26.0.0" pretty-format "^26.0.0" From 8403eb540115e1c4435cab26e8b3e20b9da098b8 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 18:44:12 +0300 Subject: [PATCH 175/581] chore(deps): bump got from 11.8.0 to 11.8.1 (#2228) Bumps [got](https://github.com/sindresorhus/got) from 11.8.0 to 11.8.1. - [Release notes](https://github.com/sindresorhus/got/releases) - [Commits](https://github.com/sindresorhus/got/compare/v11.8.0...v11.8.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 314b32e233b..4c33c77903f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5969,9 +5969,9 @@ globby@^9.2.0: slash "^2.0.0" got@^11.8.0: - version "11.8.0" - resolved "https://registry.yarnpkg.com/got/-/got-11.8.0.tgz#be0920c3586b07fd94add3b5b27cb28f49e6545f" - integrity sha512-k9noyoIIY9EejuhaBNLyZ31D5328LeqnyPNXJQb2XlJZcKakLqN5m6O/ikhq/0lw56kUYS54fVm+D1x57YC9oQ== + version "11.8.1" + resolved "https://registry.yarnpkg.com/got/-/got-11.8.1.tgz#df04adfaf2e782babb3daabc79139feec2f7e85d" + integrity sha512-9aYdZL+6nHmvJwHALLwKSUZ0hMwGaJGYv3hoPLPgnT8BoBXm1SjnZeky+91tfwJaDzun2s4RsBRy48IEYv2q2Q== dependencies: "@sindresorhus/is" "^4.0.0" "@szmarczak/http-timer" "^4.0.5" From 0bce2188384ac8a898a24b71b76525f4a99cda55 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 18:44:25 +0300 Subject: [PATCH 176/581] chore(deps-dev): bump @babel/core from 7.12.9 to 7.12.10 (#2225) Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.12.9 to 7.12.10. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.10/packages/babel-core) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4c33c77903f..ba721b9966a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,33 +15,32 @@ integrity sha512-YaxPMGs/XIWtYqrdEOZOCPsVWfEoriXopnsz3/i7apYPXQ3698UFhS6dVT1KN5qOsWmVgw/FOrmQgpRaZayGsw== "@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.12.3", "@babel/core@^7.7.5": - version "7.12.9" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.9.tgz#fd450c4ec10cdbb980e2928b7aa7a28484593fc8" - integrity sha512-gTXYh3M5wb7FRXQy+FErKFAv90BnlOuNn1QkCK2lREoPAjrQCO49+HVSrFoe5uakFAF5eenS75KbO2vQiLrTMQ== + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.10.tgz#b79a2e1b9f70ed3d84bbfb6d8c4ef825f606bccd" + integrity sha512-eTAlQKq65zHfkHZV0sIVODCPGVgoo1HdBlbSLi9CqOzuZanMv2ihzY+4paiKr1mH+XmYESMAmJ/dpZ68eN6d8w== dependencies: "@babel/code-frame" "^7.10.4" - "@babel/generator" "^7.12.5" + "@babel/generator" "^7.12.10" "@babel/helper-module-transforms" "^7.12.1" "@babel/helpers" "^7.12.5" - "@babel/parser" "^7.12.7" + "@babel/parser" "^7.12.10" "@babel/template" "^7.12.7" - "@babel/traverse" "^7.12.9" - "@babel/types" "^7.12.7" + "@babel/traverse" "^7.12.10" + "@babel/types" "^7.12.10" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.1" json5 "^2.1.2" lodash "^4.17.19" - resolve "^1.3.2" semver "^5.4.1" source-map "^0.5.0" -"@babel/generator@^7.12.5": - version "7.12.5" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.5.tgz#a2c50de5c8b6d708ab95be5e6053936c1884a4de" - integrity sha512-m16TQQJ8hPt7E+OS/XVQg/7U184MLXtvuGbCdA7na61vha+ImkyyNM/9DDA0unYCVZn3ZOhng+qz48/KBOT96A== +"@babel/generator@^7.12.10": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.10.tgz#2b188fc329fb8e4f762181703beffc0fe6df3460" + integrity sha512-6mCdfhWgmqLdtTkhXjnIz0LcdVCd26wS2JXRtj2XY0u5klDsXBREA/pG5NVOuVnF2LUrBGNFtQkIqqTbblg0ww== dependencies: - "@babel/types" "^7.12.5" + "@babel/types" "^7.12.10" jsesc "^2.5.1" source-map "^0.5.0" @@ -255,10 +254,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.12.7": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.7.tgz#fee7b39fe809d0e73e5b25eecaf5780ef3d73056" - integrity sha512-oWR02Ubp4xTLCAqPRiNIuMVgNO5Aif/xpXtabhzW2HWUD47XJsAB4Zd/Rg30+XeQA3juXigV7hlquOTmwqLiwg== +"@babel/parser@^7.1.0", "@babel/parser@^7.1.6", "@babel/parser@^7.12.10", "@babel/parser@^7.12.7": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.10.tgz#824600d59e96aea26a5a2af5a9d812af05c3ae81" + integrity sha512-PJdRPwyoOqFAWfLytxrWwGrAxghCgh/yTNCYciOz8QgjflA7aZhECPZAa2VUedKg2+QMWkI0L9lynh2SNmNEgA== "@babel/plugin-proposal-async-generator-functions@^7.12.1": version "7.12.1" @@ -871,17 +870,17 @@ "@babel/parser" "^7.12.7" "@babel/types" "^7.12.7" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.5", "@babel/traverse@^7.12.9": - version "7.12.9" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.9.tgz#fad26c972eabbc11350e0b695978de6cc8e8596f" - integrity sha512-iX9ajqnLdoU1s1nHt36JDI9KG4k+vmI8WgjK5d+aDTwQbL2fUnzedNedssA645Ede3PM2ma1n8Q4h2ohwXgMXw== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.10", "@babel/traverse@^7.12.5": + version "7.12.10" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.10.tgz#2d1f4041e8bf42ea099e5b2dc48d6a594c00017a" + integrity sha512-6aEtf0IeRgbYWzta29lePeYSk+YAFIC3kyqESeft8o5CkFlYIMX+EQDDWEiAQ9LHOA3d0oHdgrSsID/CKqXJlg== dependencies: "@babel/code-frame" "^7.10.4" - "@babel/generator" "^7.12.5" + "@babel/generator" "^7.12.10" "@babel/helper-function-name" "^7.10.4" "@babel/helper-split-export-declaration" "^7.11.0" - "@babel/parser" "^7.12.7" - "@babel/types" "^7.12.7" + "@babel/parser" "^7.12.10" + "@babel/types" "^7.12.10" debug "^4.1.0" globals "^11.1.0" lodash "^4.17.19" @@ -9988,7 +9987,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.9.0: +resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.18.1, resolve@^1.9.0: version "1.18.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.18.1.tgz#018fcb2c5b207d2a6424aee361c5a266da8f4130" integrity sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA== From 10fb66ecd46f6d1c83122cc039a274e737834610 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:33:58 +0300 Subject: [PATCH 177/581] refactor: code --- jest.config.js | 3 +- package.json | 2 +- packages/generators/README.md | 6 +- packages/generators/src/index.ts | 74 +- packages/info/__tests__/info.test.ts | 33 - packages/info/src/index.ts | 82 +- packages/init/README.md | 14 - packages/init/src/index.ts | 65 +- packages/migrate/src/index.ts | 109 +- .../__snapshots__/parseArgs.test.ts.snap | 49 - .../__tests__/getDevServerOptions.test.ts | 51 - packages/serve/__tests__/parseArgs.test.ts | 49 - .../serve/__tests__/startDevServer.test.ts | 44 +- packages/serve/src/getDevServerOptions.ts | 28 - packages/serve/src/index.ts | 122 ++- packages/serve/src/parseArgs.ts | 67 -- packages/serve/src/startDevServer.ts | 28 +- packages/utils/src/modify-config-helper.ts | 25 +- ...esolver.test.js => applyCLIPlugin.test.js} | 4 +- .../webpack-cli/__tests__/arg-parser.test.js | 12 +- .../webpack-cli/__tests__/resolveArgs.test.js | 24 +- .../webpack-cli/__tests__/serve/serve.test.js | 29 - .../__tests__/serve/webpack.config.js | 7 - packages/webpack-cli/bin/cli.js | 6 +- packages/webpack-cli/lib/bootstrap.js | 60 +- packages/webpack-cli/lib/groups/runHelp.js | 191 ---- packages/webpack-cli/lib/groups/runVersion.js | 68 -- .../utils/__tests__/package-exists.test.js | 20 - .../__tests__/prompt-installation.test.js | 76 +- .../utils/__tests__/resolve-command.test.js | 32 - packages/webpack-cli/lib/utils/arg-parser.js | 218 ---- packages/webpack-cli/lib/utils/cli-flags.js | 207 +--- .../webpack-cli/lib/utils/package-exists.js | 9 +- .../lib/utils/prompt-installation.js | 41 +- .../webpack-cli/lib/utils/resolve-command.js | 33 - packages/webpack-cli/lib/utils/run-command.js | 9 +- packages/webpack-cli/lib/webpack-cli.js | 935 +++++++++++++++--- packages/webpack-cli/package.json | 1 - test/analyze/analyze-flag.test.js | 5 +- test/bail/bail-and-watch-webpack.config.js | 1 + test/bail/bail-multi-webpack.config.js | 4 +- test/bail/bail-webpack.config.js | 1 + test/bail/multi-webpack.config.js | 4 +- test/bail/no-bail-webpack.config.js | 1 + test/bail/watch-webpack.config.js | 1 + test/bundle/basic/basic.test.js | 41 + .../serve => test/bundle/basic}/src/index.js | 0 .../bundle-variable/bundle-variable.test.js | 13 + test/bundle/bundle-variable/src/index.js | 1 + test/bundle/bundle-variable/webpack.config.js | 24 + test/cache/cache.test.js | 4 +- test/colors/colors-false.webpack.config.js | 2 +- test/colors/colors-true.webpack.config.js | 2 +- test/colors/colors.test.js | 2 +- test/colors/multiple-configs.js | 4 +- test/colors/no-stats.webpack.config.js | 2 +- test/colors/stats-boolean.webpack.config.js | 2 +- test/colors/stats-string.webpack.config.js | 2 +- test/colors/webpack.config.js | 2 +- .../function-with-argv.test.js | 2 +- .../function-with-env.test.js | 3 +- test/core-flags/context-flag.test.js | 4 +- test/core-flags/invalid-flag.test.js | 3 +- test/core-flags/module-flags.test.js | 18 +- test/defaults/output-defaults.test.js | 2 +- .../entry-with-command.test.js | 15 - .../config-entry/entry-with-command/index.js | 0 .../multiple-entries/multi-entries.test.js | 15 - test/help/help-commands.test.js | 47 - test/help/help-flags.test.js | 52 - test/help/help-multi-args.test.js | 29 - test/help/help-single-arg.test.js | 69 -- test/help/help.test.js | 252 +++++ test/hot/hot-flag.test.js | 10 +- test/hot/webpack.config.js | 1 + test/info/info-help.test.js | 38 - test/info/info-output.test.js | 35 +- test/info/info-unknown.test.js | 7 +- test/init/auto/init-auto.test.js | 5 +- test/init/coreFlags/init-flags.test.js | 1 + test/invalid-schema/invalid-schema.test.js | 3 +- test/json/json.test.js | 6 +- test/migrate/config/migrate-config.test.js | 5 +- .../mode-single-arg/mode-single-arg.test.js | 3 +- test/no-hot/no-hot.test.js | 42 - test/no-hot/src/index.js | 1 - test/no-hot/webpack.config.js | 4 - test/no-stats/with-flags/main.js | 1 - test/no-stats/with-flags/no-stats.test.js | 45 - test/no-stats/with-flags/webpack.config.js | 7 - test/output/{named-bundles => }/a.js | 0 test/output/{named-bundles => }/b.js | 0 test/output/{named-bundles => }/c.js | 0 .../output-named-bundles.test.js | 7 +- .../{named-bundles => }/webpack.config.js | 1 + .../webpack.defaults.config.js | 1 + .../webpack.multiple.config.js | 1 + .../webpack.single.config.js | 1 + test/prefetch/prefetch.test.js | 2 +- test/serve/basic/serve-basic.test.js | 22 +- .../invalid-schema/invalid-schema.test.js | 27 + .../invalid-schema/webpack.config.mock.js | 3 + .../with-config => stats/config-no}/main.js | 0 .../config-no}/no-stats-with-config.test.js | 0 .../config-no}/webpack.config.js | 0 test/stats/{cli-flags => flags}/index.js | 0 test/stats/{cli-flags => flags}/package.json | 0 test/stats/{cli-flags => flags}/stats.test.js | 18 +- .../{cli-flags => flags}/webpack.config.js | 0 test/stats/watch/multi-webpack.config.js | 2 + test/unknown/unknown.test.js | 172 +++- test/utils/test-utils.js | 6 +- .../version/version-external-packages.test.js | 112 --- test/version/version-multi-args.test.js | 78 -- test/version/version-single-arg.test.js | 30 - test/version/version.test.js | 383 +++++++ yarn.lock | 45 +- 117 files changed, 2313 insertions(+), 2274 deletions(-) delete mode 100644 packages/info/__tests__/info.test.ts delete mode 100644 packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap delete mode 100644 packages/serve/__tests__/getDevServerOptions.test.ts delete mode 100644 packages/serve/__tests__/parseArgs.test.ts delete mode 100644 packages/serve/src/getDevServerOptions.ts delete mode 100644 packages/serve/src/parseArgs.ts rename packages/webpack-cli/__tests__/{CLIPluginResolver.test.js => applyCLIPlugin.test.js} (78%) delete mode 100644 packages/webpack-cli/__tests__/serve/serve.test.js delete mode 100644 packages/webpack-cli/__tests__/serve/webpack.config.js delete mode 100644 packages/webpack-cli/lib/groups/runHelp.js delete mode 100644 packages/webpack-cli/lib/groups/runVersion.js delete mode 100644 packages/webpack-cli/lib/utils/__tests__/package-exists.test.js delete mode 100644 packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js delete mode 100644 packages/webpack-cli/lib/utils/arg-parser.js delete mode 100644 packages/webpack-cli/lib/utils/resolve-command.js create mode 100644 test/bundle/basic/basic.test.js rename {packages/webpack-cli/__tests__/serve => test/bundle/basic}/src/index.js (100%) create mode 100644 test/bundle/bundle-variable/bundle-variable.test.js create mode 100644 test/bundle/bundle-variable/src/index.js create mode 100644 test/bundle/bundle-variable/webpack.config.js delete mode 100644 test/entry/config-entry/entry-with-command/entry-with-command.test.js delete mode 100644 test/entry/config-entry/entry-with-command/index.js delete mode 100644 test/help/help-commands.test.js delete mode 100644 test/help/help-flags.test.js delete mode 100644 test/help/help-multi-args.test.js delete mode 100644 test/help/help-single-arg.test.js create mode 100644 test/help/help.test.js delete mode 100644 test/info/info-help.test.js delete mode 100644 test/no-hot/no-hot.test.js delete mode 100644 test/no-hot/src/index.js delete mode 100644 test/no-hot/webpack.config.js delete mode 100644 test/no-stats/with-flags/main.js delete mode 100644 test/no-stats/with-flags/no-stats.test.js delete mode 100644 test/no-stats/with-flags/webpack.config.js rename test/output/{named-bundles => }/a.js (100%) rename test/output/{named-bundles => }/b.js (100%) rename test/output/{named-bundles => }/c.js (100%) rename test/output/{named-bundles => }/output-named-bundles.test.js (87%) rename test/output/{named-bundles => }/webpack.config.js (87%) rename test/output/{named-bundles => }/webpack.defaults.config.js (77%) rename test/output/{named-bundles => }/webpack.multiple.config.js (89%) rename test/output/{named-bundles => }/webpack.single.config.js (89%) create mode 100644 test/serve/invalid-schema/invalid-schema.test.js create mode 100644 test/serve/invalid-schema/webpack.config.mock.js rename test/{no-stats/with-config => stats/config-no}/main.js (100%) rename test/{no-stats/with-config => stats/config-no}/no-stats-with-config.test.js (100%) rename test/{no-stats/with-config => stats/config-no}/webpack.config.js (100%) rename test/stats/{cli-flags => flags}/index.js (100%) rename test/stats/{cli-flags => flags}/package.json (100%) rename test/stats/{cli-flags => flags}/stats.test.js (68%) rename test/stats/{cli-flags => flags}/webpack.config.js (100%) delete mode 100644 test/version/version-external-packages.test.js delete mode 100644 test/version/version-multi-args.test.js delete mode 100644 test/version/version-single-arg.test.js create mode 100644 test/version/version.test.js diff --git a/jest.config.js b/jest.config.js index a2e0242435e..207f4f0eb73 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,11 +1,10 @@ const { cli } = require('webpack'); -//ignore core-flags test for webpack@4 +// Ignore core-flags test for webpack@4 const ignorePattern = typeof cli !== 'undefined' ? ['/node_modules/'] : ['/node_modules/', '/test/core-flags']; module.exports = { testPathIgnorePatterns: ignorePattern, - // transformIgnorePatterns: ['.*(node_modules)(?!.*webpack-cli.*).*$'], testEnvironment: 'node', collectCoverage: true, coverageReporters: ['none'], diff --git a/package.json b/package.json index 434defb46bd..10677c1eeb1 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,10 @@ "prepsuite": "node scripts/prepareSuite.js", "pretest": "yarn build && yarn lint && yarn prepsuite", "test": "jest --reporters=default", + "test:coverage": "nyc jest --forceExit", "test:cli": "jest test --reporters=default --forceExit", "test:packages": "jest packages/ --reporters=default --forceExit", "test:ci": "yarn test:cli && yarn test:packages", - "test:coverage": "nyc jest --forceExit", "test:watch": "jest test/ packages/ --watch", "test:smoke": "smoketests/smoketests.sh", "publish:monorepo": "yarn build && lerna version && lerna publish from-git" diff --git a/packages/generators/README.md b/packages/generators/README.md index 22e7a447242..5b66e5a9690 100644 --- a/packages/generators/README.md +++ b/packages/generators/README.md @@ -26,9 +26,9 @@ const { addonGenerator, initGenerator, loaderGenerator, pluginGenerator } = requ ## Generators -- [**Plugin Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/plugin-generator.ts) : Creates a webpack plugin project, add starter plugin code and runs `webpack-defaults` -- [**Loader Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/loader-generator.ts) : Creates a webpack loader project, add starter loader code and runs `webpack-defaults` -- [**Init Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/init-generator.ts) : Generates new webapck configuration as per user requirements +- [**Plugin Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/plugin-generator.ts) : Creates a webpack plugin project, add starter plugin code +- [**Loader Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/loader-generator.ts) : Creates a webpack loader project, add starter loader code +- [**Init Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/init-generator.ts) : Generates new webpack configuration as per user requirements - [**Addon Generator**](https://github.com/webpack/webpack-cli/blob/master/packages/generators/src/addon-generator.ts) : Generates a webpack project conforming to `webpack-defaults` --- diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index ee56ed718e8..d423d9caee6 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -4,31 +4,53 @@ import pluginGenerator from './plugin-generator'; import addonGenerator from './addon-generator'; import initGenerator from './init-generator'; -import { utils } from 'webpack-cli'; - -const { logger } = utils; - -export { addonGenerator, initGenerator }; - -export default (args: Array, name: string): void => { - const generationPath = args[0]; - const env = yeoman.createEnv([], { cwd: generationPath }); - if (name === 'loader') { - const generatorName = 'webpack-loader-generator'; - - env.registerStub(loaderGenerator, generatorName); - - env.run(generatorName, () => { - logger.success('Loader template has been successfully scaffolded.'); - }); +class GeneratorsCommand { + apply(cli): void { + const { logger } = cli; + + cli.makeCommand( + { + name: 'loader [output-path]', + alias: 'l', + description: 'Scaffold a loader.', + usage: 'loader [output-path]', + pkg: '@webpack-cli/generators', + }, + [], + async (outputPath) => { + const env = yeoman.createEnv([], { cwd: outputPath }); + const generatorName = 'webpack-loader-generator'; + + env.registerStub(loaderGenerator, generatorName); + + env.run(generatorName, () => { + logger.success('Loader template has been successfully scaffolded.'); + }); + }, + ); + + cli.makeCommand( + { + name: 'plugin [output-path]', + alias: 'p', + description: 'Scaffold a plugin.', + usage: 'plugin [output-path]', + pkg: '@webpack-cli/generators', + }, + [], + async (outputPath) => { + const env = yeoman.createEnv([], { cwd: outputPath }); + const generatorName = 'webpack-plugin-generator'; + + env.registerStub(pluginGenerator, generatorName); + + env.run(generatorName, () => { + logger.success('Plugin template has been successfully scaffolded.'); + }); + }, + ); } - if (name === 'plugin') { - const generatorName = 'webpack-plugin-generator'; - - env.registerStub(pluginGenerator, generatorName); +} - env.run(generatorName, () => { - logger.success('Plugin template has been successfully scaffolded.'); - }); - } -}; +export default GeneratorsCommand; +export { addonGenerator, initGenerator }; diff --git a/packages/info/__tests__/info.test.ts b/packages/info/__tests__/info.test.ts deleted file mode 100644 index 09327f8cbc1..00000000000 --- a/packages/info/__tests__/info.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import info from '../src/index'; - -describe('info tests', () => { - it('should log environment info', async () => { - const envInfo = await info(); - - expect(envInfo).toContain('System'); - expect(envInfo).toContain('Binaries'); - expect(envInfo).toContain('Browsers'); - }); - - it('should log environment info as json', async () => { - const envInfo = await info(['--output', 'json']); - - const parse = (): void => { - const output = JSON.parse(envInfo); - expect(output['System']).toBeTruthy(); - expect(output['Binaries']).toBeTruthy(); - expect(output['System']['OS']).toBeTruthy(); - expect(output['System']['CPU']).toBeTruthy(); - }; - - expect(parse).not.toThrow(); - }); - - it('should log environment info as markdown', async () => { - const envInfo = await info(['--output', 'markdown']); - - expect(envInfo).toContain('## System'); - expect(envInfo).toContain('## Binaries'); - expect(envInfo).toContain('## Browsers'); - }); -}); diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index db1fee91f4e..d61d2b67303 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -1,8 +1,4 @@ import envinfo from 'envinfo'; -import WebpackCLI from 'webpack-cli'; -import { utils } from 'webpack-cli'; - -const { logger, commands } = utils; interface Information { Binaries?: string[]; @@ -33,39 +29,55 @@ const DEFAULT_DETAILS: Information = { npmPackages: '*webpack*', }; -export default async function info(args = []): Promise { - const cli = new WebpackCLI(); - const { flags: infoFlags } = commands.find((cmd) => cmd.name === 'info'); - const parsedArgs = cli.argParser(infoFlags, args, true); - const infoArgs = parsedArgs.opts; - const envinfoConfig = {}; +class InfoCommand { + apply(cli): void { + cli.makeCommand( + { + name: 'info', + alias: 'i', + description: 'Outputs information about your system.', + usage: '[options]', + pkg: '@webpack-cli/info', + }, + [ + { + name: 'output', + type: String, + description: 'To get the output in specified format ( accept json or markdown )', + }, + ], + async (program) => { + let { output } = program.opts(); - if (parsedArgs.unknownArgs.length > 0) { - logger.error(`Unknown argument: ${parsedArgs.unknownArgs}`); - process.exit(2); - } + const { logger } = cli; + const envinfoConfig = {}; - if (infoArgs.output) { - // Remove quotes if exist - const output = infoArgs.output.replace(/['"]+/g, ''); - switch (output) { - case 'markdown': - envinfoConfig['markdown'] = true; - break; - case 'json': - envinfoConfig['json'] = true; - break; - default: - logger.error(`'${infoArgs.output}' is not a valid value for output`); - process.exit(2); - } - } + if (output) { + // Remove quotes if exist + output = output.replace(/['"]+/g, ''); + + switch (output) { + case 'markdown': + envinfoConfig['markdown'] = true; + break; + case 'json': + envinfoConfig['json'] = true; + break; + default: + logger.error(`'${output}' is not a valid value for output`); + process.exit(2); + } + } - let output = await envinfo.run(DEFAULT_DETAILS, envinfoConfig); - output = output.replace(/npmPackages/g, 'Packages'); - output = output.replace(/npmGlobalPackages/g, 'Global Packages'); + let info = await envinfo.run(DEFAULT_DETAILS, envinfoConfig); - const finalOutput = output; - logger.raw(finalOutput); - return finalOutput; + info = info.replace(/npmPackages/g, 'Packages'); + info = info.replace(/npmGlobalPackages/g, 'Global Packages'); + + logger.raw(info); + }, + ); + } } + +export default InfoCommand; diff --git a/packages/init/README.md b/packages/init/README.md index 2db8be4df6e..fc6ea999a16 100644 --- a/packages/init/README.md +++ b/packages/init/README.md @@ -14,20 +14,6 @@ npm i -D webpack-cli @webpack-cli/init ## Usage -To run the package programmatically, install it as a dependency. When using the package programmatically, one does not have to install webpack-cli. - -### Node - -```js -const init = require('@webpack-cli/init').default; - -// this will run the default init instance -init(); - -// we're slicing node.process, ...myPackages is a webpack-scaffold name/path -init([null, null, ...myPackages]); -``` - ### CLI (via `webpack-cli`) **Via defaults** diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index 290c4aa7763..1de1b7e0331 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -1,35 +1,46 @@ import { initGenerator } from '@webpack-cli/generators'; import { modifyHelperUtil, npmPackagesExists } from '@webpack-cli/utils'; -const AUTO_PREFIX = '--auto'; -const CONFIG_PREFIX = '--force'; -const PATH_PREFIX = '--generation-path'; +class InitCommand { + apply(cli): void { + cli.makeCommand( + { + name: 'init [scaffold...]', + alias: 'c', + description: 'Initialize a new webpack configuration.', + usage: '[scaffold...] [options]', + pkg: '@webpack-cli/init', + }, + [ + { + name: 'auto', + type: Boolean, + description: 'To generate default config', + }, + { + name: 'force', + type: Boolean, + description: 'To force config generation', + }, + { + name: 'generation-path', + type: String, + description: 'To scaffold in a specified path', + }, + ], + async (scaffold, program) => { + const options = program.opts(); -/** - * - * First function to be called after running the init flag. This is a check, - * if we are running the init command with no arguments or if we got dependencies - * - * @param {String[]} args - array of arguments such as - * packages included when running the init command - * @returns {Function} creator/npmPackagesExists - returns an installation of the package, - * followed up with a yeoman instance if there are packages. If not, it creates a defaultGenerator - */ + if (scaffold && scaffold.length > 0) { + await npmPackagesExists(scaffold); -export default function initializeInquirer(args: string[]): Function | void { - const packages = args; - const includesDefaultPrefix = packages.includes(AUTO_PREFIX); - const generateConfig = packages.includes(CONFIG_PREFIX); - const genPathPrefix = packages.includes(PATH_PREFIX); + return; + } - let generationPath: string; - if (genPathPrefix) { - const idx = packages.indexOf(PATH_PREFIX); - // Retrieve the path supplied along with --generation-path - generationPath = packages[idx + 1]; + modifyHelperUtil('init', initGenerator, null, null, options.auto, options.force, options.generationPath); + }, + ); } - if (packages.length === 0 || includesDefaultPrefix || generateConfig || genPathPrefix) { - return modifyHelperUtil('init', initGenerator, null, null, includesDefaultPrefix, generateConfig, generationPath); - } - return npmPackagesExists(packages); } + +export default InitCommand; diff --git a/packages/migrate/src/index.ts b/packages/migrate/src/index.ts index 1ff970c11f3..c9f458a0877 100644 --- a/packages/migrate/src/index.ts +++ b/packages/migrate/src/index.ts @@ -10,9 +10,6 @@ import { runPrettier } from '@webpack-cli/utils'; import { transformations } from './migrate'; import { Node } from './types/NodePath'; import jscodeshift from 'jscodeshift'; -import { utils } from 'webpack-cli'; - -const { logger } = utils; declare let process: { cwd: Function; @@ -32,19 +29,8 @@ declare let process: { exitCode: number; }; -/** - * - * Runs migration on a given configuration using AST's and promises - * to sequentially transform a configuration file. - * - * @param {String} currentConfigPath - input path for config - * @param {String} outputConfigPath - output path for config - * @returns {Promise} Runs the migration using a promise that - * will throw any errors during each transform or output if the - * user decides to abort the migration - */ - -function runMigration(currentConfigPath: string, outputConfigPath: string): Promise | void { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function runMigration(currentConfigPath: string, outputConfigPath: string, logger: any): Promise | void { const recastOptions: object = { quote: 'single', }; @@ -87,7 +73,7 @@ function runMigration(currentConfigPath: string, outputConfigPath: string): Prom }, ]); - tasks + return tasks .run() .then((ctx: Node): void | Promise => { const result: string = ctx.ast.toSource(recastOptions); @@ -162,48 +148,53 @@ function runMigration(currentConfigPath: string, outputConfigPath: string): Prom }); } -/** - * - * Runs migration on a given configuration using AST's and promises - * to sequentially transform a configuration file. - * - * @param {Array} args - Migrate arguments such as input and - * output path - * @returns {Function} Runs the migration using the 'runMigrate' - * function. - */ - -export default async function migrate(args: string[]): Promise { - const filePaths = args; - if (!filePaths.length) { - logger.error('\n ✖ Please specify a path to your webpack config\n'); - return; - } +class MigrationCommand { + apply(cli): void { + const { logger } = cli; - const currentConfigPath = path.resolve(filePaths[0]); - let outputConfigPath: string; - - if (!filePaths[1]) { - try { - const { confirmPath } = await inquirer.prompt([ - { - default: 'Y', - message: 'Migration output path not specified. Do you want to use your existing webpack configuration?', - name: 'confirmPath', - type: 'confirm', - }, - ]); - if (!confirmPath) { - logger.error('✖ ︎Migration aborted due to no output path'); - return; - } - outputConfigPath = path.resolve(filePaths[0]); - return runMigration(currentConfigPath, outputConfigPath); - } catch (err) { - logger.error(err); - return; - } + cli.makeCommand( + { + name: 'migrate [new-config-path]', + alias: 'm', + description: 'Migrate a configuration to a new version.', + pkg: '@webpack-cli/migrate', + }, + [], + async (configPath: string, newConfigPath: string | undefined) => { + const currentConfigPath = path.resolve(configPath); + let outputConfigPath: string; + + if (!newConfigPath) { + try { + const { confirmPath } = await inquirer.prompt([ + { + default: 'Y', + message: 'Migration output path not specified. Do you want to use your existing webpack configuration?', + name: 'confirmPath', + type: 'confirm', + }, + ]); + if (!confirmPath) { + logger.error('︎Migration aborted due to no output path'); + return; + } + outputConfigPath = path.resolve(configPath); + + await runMigration(currentConfigPath, outputConfigPath, logger); + } catch (err) { + logger.error(err); + return; + } + + return; + } + + outputConfigPath = path.resolve(newConfigPath); + + await runMigration(currentConfigPath, outputConfigPath, logger); + }, + ); } - outputConfigPath = path.resolve(filePaths[1]); - return runMigration(currentConfigPath, outputConfigPath); } + +export default MigrationCommand; diff --git a/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap b/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap deleted file mode 100644 index 1a5efa72526..00000000000 --- a/packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap +++ /dev/null @@ -1,49 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`parseArgs handles hot arg 1`] = ` -Object { - "devServerArgs": Object { - "clientLogLevel": "info", - "hot": true, - "inline": true, - "liveReload": true, - "serveIndex": true, - }, - "webpackArgs": Object { - "env": Object { - "WEBPACK_SERVE": true, - }, - "hot": true, - }, -} -`; - -exports[`parseArgs handles unknown args 1`] = ` -Array [ - Array [ - "Unknown argument: --unknown-arg", - ], - Array [ - "Unknown argument: --unknown-arg-2", - ], -] -`; - -exports[`parseArgs parses webpack and dev server args 1`] = ` -Object { - "devServerArgs": Object { - "bonjour": true, - "clientLogLevel": "info", - "inline": true, - "liveReload": true, - "port": 8080, - "serveIndex": true, - }, - "webpackArgs": Object { - "env": Object { - "WEBPACK_SERVE": true, - }, - "mode": "development", - }, -} -`; diff --git a/packages/serve/__tests__/getDevServerOptions.test.ts b/packages/serve/__tests__/getDevServerOptions.test.ts deleted file mode 100644 index 5304c617cd6..00000000000 --- a/packages/serve/__tests__/getDevServerOptions.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -import getDevServerOptions from '../src/getDevServerOptions'; - -describe('getDevServerOptions', () => { - // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-extraneous-require - const webpack = require('webpack'); - - it('gets dev server options from single compiler', () => { - const compiler = webpack({ - devServer: { - hot: true, - host: 'my.host', - }, - }); - expect(getDevServerOptions(compiler)).toEqual([ - { - hot: true, - host: 'my.host', - }, - ]); - }); - - it('gets dev server options from multi compiler', () => { - const compiler = webpack([ - { - devServer: { - hot: true, - host: 'my.host', - }, - }, - { - devServer: { - hot: false, - host: 'other.host', - }, - }, - ]); - - expect(getDevServerOptions(compiler)).toEqual([ - { - hot: true, - host: 'my.host', - }, - { - hot: false, - host: 'other.host', - }, - ]); - }); -}); diff --git a/packages/serve/__tests__/parseArgs.test.ts b/packages/serve/__tests__/parseArgs.test.ts deleted file mode 100644 index 742d56b0ad3..00000000000 --- a/packages/serve/__tests__/parseArgs.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -// TODO: update snapshots once we update to webpack-dev-server@4 - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const errorMock: any = jest.fn(); -jest.mock('webpack-cli/lib/utils/logger', () => { - return { - error: errorMock, - }; -}); - -import WebpackCLI from 'webpack-cli'; -import parseArgs from '../src/parseArgs'; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const processExitSpy: any = jest.spyOn(process, 'exit'); -// eslint-disable-next-line @typescript-eslint/no-empty-function -processExitSpy.mockImplementation(() => {}); - -describe('parseArgs', () => { - const cli = new WebpackCLI(); - - beforeEach(() => { - errorMock.mockClear(); - processExitSpy.mockClear(); - }); - - it('parses webpack and dev server args', () => { - const args = parseArgs(cli, ['--bonjour', '--mode=development', '--port', '8080']); - expect(args).toMatchSnapshot(); - expect(errorMock.mock.calls.length).toEqual(0); - expect(processExitSpy.mock.calls.length).toEqual(0); - }); - - it('handles hot arg', () => { - const args = parseArgs(cli, ['--hot']); - expect(args).toMatchSnapshot(); - expect(errorMock.mock.calls.length).toEqual(0); - expect(processExitSpy.mock.calls.length).toEqual(0); - }); - - it('handles unknown args', () => { - parseArgs(cli, ['--unknown-arg', '--unknown-arg-2']); - expect(errorMock.mock.calls).toMatchSnapshot(); - expect(processExitSpy.mock.calls.length).toEqual(1); - expect(processExitSpy.mock.calls[0]).toEqual([2]); - }); -}); diff --git a/packages/serve/__tests__/startDevServer.test.ts b/packages/serve/__tests__/startDevServer.test.ts index 44eabb02a4c..e6377ca2ec1 100644 --- a/packages/serve/__tests__/startDevServer.test.ts +++ b/packages/serve/__tests__/startDevServer.test.ts @@ -24,11 +24,15 @@ describe('startDevServer', () => { }; const compiler = webpack(config); - const servers = await startDevServer(compiler, { - host: 'my.host', - hot: true, - progress: true, - }); + const servers = await startDevServer( + compiler, + { + host: 'my.host', + hot: true, + progress: true, + }, + console, + ); expect(servers.length).toEqual(1); expect(servers).toEqual(DevServer.mock.instances); @@ -49,7 +53,7 @@ describe('startDevServer', () => { }; const compiler = webpack(config); - const servers = await startDevServer(compiler, {}); + const servers = await startDevServer(compiler, {}, console); expect(servers.length).toEqual(1); expect(servers).toEqual(DevServer.mock.instances); @@ -77,11 +81,15 @@ describe('startDevServer', () => { ]; const compiler = webpack(config); - const servers = await startDevServer(compiler, { - host: 'my.host', - hot: true, - progress: true, - }); + const servers = await startDevServer( + compiler, + { + host: 'my.host', + hot: true, + progress: true, + }, + console, + ); expect(servers.length).toEqual(1); expect(servers).toEqual(DevServer.mock.instances); @@ -113,10 +121,14 @@ describe('startDevServer', () => { ]; const compiler = webpack(config); - const servers = await startDevServer(compiler, { - // this progress CLI flag should override progress: false above - progress: true, - }); + const servers = await startDevServer( + compiler, + { + // this progress CLI flag should override progress: false above + progress: true, + }, + console, + ); // there are 2 devServer configs, so both are run expect(servers.length).toEqual(2); @@ -153,7 +165,7 @@ describe('startDevServer', () => { ]; const compiler = webpack(config); - await startDevServer(compiler, {}); + await startDevServer(compiler, {}, console); }).rejects.toThrow( 'Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.', ); diff --git a/packages/serve/src/getDevServerOptions.ts b/packages/serve/src/getDevServerOptions.ts deleted file mode 100644 index 3a7bdd6b788..00000000000 --- a/packages/serve/src/getDevServerOptions.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { devServerOptionsType } from './types'; - -/** - * - * Get the devServer option from the user's compiler options - * - * @param {Object} compiler - webpack compiler - * @param {Object} webpackArgs - webpack args - * - * @returns {Object} - */ -export default function getDevServerOptions(compiler): devServerOptionsType[] { - const defaultOpts = {}; - const devServerOptions = []; - const compilers = compiler.compilers || [compiler]; - - compilers.forEach((comp) => { - if (comp.options.devServer) { - devServerOptions.push(comp.options.devServer); - } - }); - - if (devServerOptions.length === 0) { - devServerOptions.push(defaultOpts); - } - - return devServerOptions; -} diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index e93ea60324e..45a903e7ce7 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -1,29 +1,101 @@ -import WebpackCLI, { utils } from 'webpack-cli'; import startDevServer from './startDevServer'; -import parseArgs from './parseArgs'; - -const { logger } = utils; - -/** - * - * Creates a webpack compiler and runs the devServer - * - * @param {String[]} args - args processed from the CLI - * @returns {Function} invokes the devServer API - */ -export default function serve(args: string[]): void { - try { - // eslint-disable-next-line node/no-extraneous-require - require('webpack-dev-server'); - } catch (err) { - logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); - process.exit(2); - } - const cli = new WebpackCLI(); - const { webpackArgs, devServerArgs } = parseArgs(cli, args); +class ServeCommand { + async apply(cli): Promise { + const { logger, utils } = cli; + const isPackageExist = utils.getPkg('webpack-dev-server'); + + if (!isPackageExist) { + try { + await utils.promptInstallation('webpack-dev-server', () => { + // TODO colors + logger.error("For using this command you need to install: 'webpack-dev-server' package"); + }); + } catch (error) { + logger.error("Action Interrupted, use 'webpack-cli help' to see possible commands."); + process.exit(2); + } + } + + let devServerFlags = []; + + try { + // eslint-disable-next-line node/no-extraneous-require + require('webpack-dev-server'); + // eslint-disable-next-line node/no-extraneous-require + devServerFlags = require('webpack-dev-server/bin/cli-flags').devServer; + } catch (err) { + logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); + process.exit(2); + } + + const builtInOptions = cli.getBuiltInOptions(); + + cli.makeCommand( + { + name: 'serve', + alias: 's', + description: 'Run the webpack dev server.', + usage: '[options]', + pkg: '@webpack-cli/serve', + }, + [...builtInOptions, ...devServerFlags], + async (program) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const webpackOptions: Record = {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const devServerOptions: Record = {}; + const options = program.opts(); + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const processors: Array<(opts: Record) => void> = []; + + for (const optionName in options) { + if (optionName === 'hot' || optionName === 'progress') { + devServerOptions[optionName] = options[optionName]; + webpackOptions[optionName] = options[optionName]; + } else { + const kebabedOption = cli.utils.toKebabCase(optionName); + const isBuiltInOption = builtInOptions.find((builtInOption) => builtInOption.name === kebabedOption); + + if (isBuiltInOption) { + webpackOptions[optionName] = options[optionName]; + } else { + const needToProcess = devServerFlags.find( + (devServerOption) => devServerOption.name === kebabedOption && devServerOption.processor, + ); - cli.getCompiler(webpackArgs).then((compiler): void => { - startDevServer(compiler, devServerArgs); - }); + if (needToProcess) { + processors.push(needToProcess.processor); + } + + devServerOptions[optionName] = options[optionName]; + } + } + } + + for (const processor of processors) { + processor(devServerOptions); + } + + webpackOptions.env = { WEBPACK_SERVE: true, ...options.env }; + + const compiler = await cli.createCompiler(webpackOptions); + + try { + await startDevServer(compiler, devServerOptions, logger); + } catch (error) { + if (error.name === 'ValidationError') { + logger.error(error.message); + } else { + logger.error(error); + } + + process.exit(2); + } + }, + ); + } } + +export default ServeCommand; diff --git a/packages/serve/src/parseArgs.ts b/packages/serve/src/parseArgs.ts deleted file mode 100644 index 0b956f43932..00000000000 --- a/packages/serve/src/parseArgs.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { utils } from 'webpack-cli'; - -const { logger } = utils; - -type WebpackCLIType = { - getCoreFlags: Function; - argParser: Function; -}; - -type ArgsType = { - devServerArgs: object; - webpackArgs: object; -}; - -/** - * - * Parses raw dev server CLI args - * - * @param {Object} cli - webpack CLI object - * @param {Object[]} devServerFlags - devServer flags - * @param {String[]} args - unparsed devServer args processed from the CLI - * - * @returns {Object} parsed webpack args and dev server args objects - */ -export default function parseArgs(cli: WebpackCLIType, args: string[]): ArgsType { - let devServerFlags; - try { - // eslint-disable-next-line node/no-extraneous-require - devServerFlags = require('webpack-dev-server/bin/cli-flags').devServer; - } catch (err) { - logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); - process.exit(2); - } - - const core = cli.getCoreFlags(); - - const parsedDevServerArgs = cli.argParser(devServerFlags, args, true); - const devServerArgs = parsedDevServerArgs.opts; - const parsedWebpackArgs = cli.argParser(core, parsedDevServerArgs.unknownArgs, true, process.title); - const webpackArgs = parsedWebpackArgs.opts; - - // Add WEBPACK_SERVE environment variable - if (webpackArgs.env) { - webpackArgs.env.WEBPACK_SERVE = true; - } else { - webpackArgs.env = { WEBPACK_SERVE: true }; - } - - // pass along the 'hot' argument to the dev server if it exists - if (webpackArgs && webpackArgs.hot !== undefined) { - devServerArgs['hot'] = webpackArgs.hot; - } - - if (parsedWebpackArgs.unknownArgs.length > 0) { - parsedWebpackArgs.unknownArgs - .filter((e) => e) - .forEach((unknown) => { - logger.error(`Unknown argument: ${unknown}`); - }); - process.exit(2); - } - - return { - devServerArgs, - webpackArgs, - }; -} diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index a2418389680..51ce17b9e45 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -1,24 +1,23 @@ import { utils } from 'webpack-cli'; -import getDevServerOptions from './getDevServerOptions'; import mergeOptions from './mergeOptions'; -const { logger } = utils; - /** * * Starts the devServer * * @param {Object} compiler - a webpack compiler - * @param {Object} devServerArgs - devServer args + * @param {Object} cliOptions - devServer args + * @param {Object} logger - logger * * @returns {Object[]} array of resulting servers */ -export default async function startDevServer(compiler, cliOptions): Promise { +export default async function startDevServer(compiler, cliOptions, logger): Promise { let isDevServer4 = false, devServerVersion, Server, findPort; + try { // eslint-disable-next-line node/no-extraneous-require devServerVersion = require('webpack-dev-server/package.json').version; @@ -30,16 +29,29 @@ export default async function startDevServer(compiler, cliOptions): Promise { + if (compiler.options.devServer) { + devServerOptions.push(compiler.options.devServer); + } + }); + if (devServerOptions.length === 0) { + devServerOptions.push(defaultOpts); + } + + const servers = []; const usedPorts: number[] = []; for (const devServerOpts of devServerOptions) { const options = mergeOptions(cliOptions, devServerOpts); + if (isDevServer4) { options.port = await findPort(options.port); options.client = options.client || {}; @@ -57,10 +69,12 @@ export default async function startDevServer(compiler, cliOptions): Promise { if (err) { throw err; diff --git a/packages/utils/src/modify-config-helper.ts b/packages/utils/src/modify-config-helper.ts index 9af8b1862e9..b08dcfc4995 100644 --- a/packages/utils/src/modify-config-helper.ts +++ b/packages/utils/src/modify-config-helper.ts @@ -34,18 +34,6 @@ export interface WebpackScaffoldObject extends Object { const DEFAULT_WEBPACK_CONFIG_FILENAME = 'webpack.config.js'; -/** - * - * Looks up the webpack.config in the user's path and runs a given - * generator scaffold followed up by a transform - * - * @param {String} action — action to be done (add, remove, update, init) - * @param {Class} generator - Yeoman generator class - * @param {String} configFile - Name of the existing/default webpack configuration file - * @param {Array} packages - List of packages to resolve - * @returns {Function} runTransform - Returns a transformation instance - */ - export function modifyHelperUtil( action: string, generator: Generator.GeneratorConstructor, @@ -76,8 +64,10 @@ export function modifyHelperUtil( // to .yo-rc.json // see: https://github.com/yeoman/generator/blob/v4.5.0/lib/index.js#L773 let packageName = '*'; + try { const packagePath = path.resolve(generationPath, 'package.json'); + if (fs.existsSync(packagePath)) { // eslint-disable-next-line @typescript-eslint/no-var-requires const packageData = require(packagePath); @@ -86,7 +76,7 @@ export function modifyHelperUtil( } } } catch (err) { - logger.error('\nYour package.json was incorrectly formatted.\n'); + logger.error('Your package.json was incorrectly formatted.'); Error.stackTraceLimit = 0; process.exitCode = 2; } @@ -108,9 +98,9 @@ export function modifyHelperUtil( const confPath = path.resolve(generationPath, '.yo-rc.json'); configModule = require(confPath); } catch (err) { - logger.error('\nCould not find a yeoman configuration file (.yo-rc.json).\n'); + logger.error('Could not find a yeoman configuration file (.yo-rc.json).'); logger.error( - "\nPlease make sure to use 'this.config.set('configuration', this.configuration);' at the end of the generator.\n", + "Please make sure to use 'this.config.set('configuration', this.configuration);' at the end of the generator.", ); Error.stackTraceLimit = 0; process.exitCode = 2; @@ -128,6 +118,7 @@ export function modifyHelperUtil( logger.error(err); logger.error(`${err.stack}\n`); logger.error('Your yeoman configuration file (.yo-rc.json) was incorrectly formatted. Deleting it may fix the problem.\n'); + Error.stackTraceLimit = 0; process.exitCode = 2; } @@ -143,8 +134,8 @@ export function modifyHelperUtil( // scaffold webpack config file from using .yo-rc.json return runTransform(transformConfig, 'init', generateConfig, generationPath); - } catch (err) { - logger.error(err); + } catch (error) { + logger.error(error); process.exitCode = 2; } }, diff --git a/packages/webpack-cli/__tests__/CLIPluginResolver.test.js b/packages/webpack-cli/__tests__/applyCLIPlugin.test.js similarity index 78% rename from packages/webpack-cli/__tests__/CLIPluginResolver.test.js rename to packages/webpack-cli/__tests__/applyCLIPlugin.test.js index ce71d6e935b..f23c038108d 100644 --- a/packages/webpack-cli/__tests__/CLIPluginResolver.test.js +++ b/packages/webpack-cli/__tests__/applyCLIPlugin.test.js @@ -1,11 +1,11 @@ const webpackCLI = require('../lib/webpack-cli'); const CLIPlugin = require('../lib/plugins/CLIPlugin'); -const CLIPluginResolver = new webpackCLI().resolveCLIPlugin; +const applyCLIPlugin = new webpackCLI().applyCLIPlugin; describe('CLIPluginResolver', () => { it('should add CLI plugin to single compiler object', async () => { - const result = await CLIPluginResolver({ options: {} }, { hot: true, prefetch: true }); + const result = await applyCLIPlugin({ options: {} }, { hot: true, prefetch: true }); expect(result.options.plugins[0] instanceof CLIPlugin).toBeTruthy(); expect(result.options.plugins[0].options).toEqual({ configPath: undefined, diff --git a/packages/webpack-cli/__tests__/arg-parser.test.js b/packages/webpack-cli/__tests__/arg-parser.test.js index 465672f5311..55956e85d88 100644 --- a/packages/webpack-cli/__tests__/arg-parser.test.js +++ b/packages/webpack-cli/__tests__/arg-parser.test.js @@ -7,12 +7,10 @@ jest.mock('../lib/utils/logger', () => { }; }); -const helpMock = jest.fn(); -jest.mock('../lib/groups/runHelp', () => helpMock); const processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {}); const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); -const argParser = require('../lib/utils/arg-parser'); +const argParser = () => {}; const { flags } = require('../lib/utils/cli-flags'); const basicOptions = [ @@ -132,7 +130,7 @@ helpAndVersionOptions.push( }, ); -describe('arg-parser', () => { +describe.skip('arg-parser', () => { beforeEach(() => { warnMock.mockClear(); processExitSpy.mockClear(); @@ -372,12 +370,6 @@ describe('arg-parser', () => { expect(warnMock.mock.calls.length).toEqual(0); }); - it('calls help callback on --help', () => { - argParser(helpAndVersionOptions, ['--help'], true, ''); - expect(helpMock.mock.calls.length).toEqual(1); - expect(helpMock.mock.calls[0][0]).toEqual(['--help']); - }); - it('parses webpack args', () => { const res = argParser(flags, ['--entry', 'test.js', '--hot', '-o', './dist/', '--stats'], true); expect(res.unknownArgs.length).toEqual(0); diff --git a/packages/webpack-cli/__tests__/resolveArgs.test.js b/packages/webpack-cli/__tests__/resolveArgs.test.js index 1eff36c414f..c57bc89589d 100644 --- a/packages/webpack-cli/__tests__/resolveArgs.test.js +++ b/packages/webpack-cli/__tests__/resolveArgs.test.js @@ -9,24 +9,24 @@ if (version.startsWith('5')) { statsPresets.push('summary'); } -const basicResolver = new webpackCLI().resolveArguments; +const applyOptions = new webpackCLI().applyOptions; describe('BasicResolver', () => { it('should handle the output option', async () => { - const result = await basicResolver({ options: {} }, { outputPath: './bundle' }); + const result = await applyOptions({ options: {} }, { outputPath: './bundle' }); expect(result.options.output.path).toEqual(resolve('bundle')); }); it('should handle the mode option [production]', async () => { - const result = await basicResolver({ options: {} }, { mode: 'production' }); + const result = await applyOptions({ options: {} }, { mode: 'production' }); expect(result.options).toMatchObject({ mode: 'production' }); expect(result.options.mode).toEqual('production'); }); it('should handle the mode option [development]', async () => { - const result = await basicResolver( + const result = await applyOptions( { options: {} }, { mode: 'development', @@ -38,7 +38,7 @@ describe('BasicResolver', () => { }); it('should handle the mode option [none]', async () => { - const result = await basicResolver( + const result = await applyOptions( { options: {} }, { mode: 'none', @@ -51,40 +51,40 @@ describe('BasicResolver', () => { it('should prefer supplied move flag over NODE_ENV', async () => { process.env.NODE_ENV = 'production'; - const result = await basicResolver({ options: {} }, { mode: 'development' }); + const result = await applyOptions({ options: {} }, { mode: 'development' }); expect(result.options).toMatchObject({ mode: 'development' }); }); it('should prefer supplied move flag over mode from config', async () => { - const result = await basicResolver({ options: { mode: 'development' } }, { mode: 'production' }); + const result = await applyOptions({ options: { mode: 'development' } }, { mode: 'production' }); expect(result.options).toMatchObject({ mode: 'production' }); }); it('should prefer mode form config over NODE_ENV', async () => { process.env.NODE_ENV = 'development'; - const result = await basicResolver({ options: {} }, { mode: 'production' }); + const result = await applyOptions({ options: {} }, { mode: 'production' }); expect(result.options).toMatchObject({ mode: 'production' }); }); it('should prefer mode form flag over NODE_ENV and config', async () => { process.env.NODE_ENV = 'development'; - const result = await basicResolver({ options: {} }, {}); + const result = await applyOptions({ options: {} }, {}); expect(result.options).toMatchObject({ mode: 'development' }); }); it('should assign stats correctly', async () => { - const result = await basicResolver({ options: {} }, { stats: 'errors-warnings' }); + const result = await applyOptions({ options: {} }, { stats: 'errors-warnings' }); expect(result.options.stats).toEqual('errors-warnings'); }); targetValues.map((option) => { it(`should handle ${option} option`, async () => { - const result = await basicResolver({ options: {} }, { target: option }); + const result = await applyOptions({ options: {} }, { target: option }); expect(result.options.target).toEqual(option); }); @@ -92,7 +92,7 @@ describe('BasicResolver', () => { statsPresets.map((preset) => { it(`should handle ${preset} preset`, async () => { - const result = await basicResolver({ options: {} }, { stats: preset }); + const result = await applyOptions({ options: {} }, { stats: preset }); expect(result.options.stats).toEqual(preset); }); diff --git a/packages/webpack-cli/__tests__/serve/serve.test.js b/packages/webpack-cli/__tests__/serve/serve.test.js deleted file mode 100644 index de1111b9820..00000000000 --- a/packages/webpack-cli/__tests__/serve/serve.test.js +++ /dev/null @@ -1,29 +0,0 @@ -const { runServe } = require('../../../../test/utils/test-utils'); - -describe('Serve', () => { - const isWindows = process.platform === 'win32'; - - // TODO fix me on windows - if (isWindows) { - it('TODO: Fix on windows', () => { - expect(true).toBe(true); - }); - return; - } - - it('should run with cli', async () => { - const { stderr, stdout } = await runServe([], __dirname); - - expect(stderr).toBeFalsy(); - expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); - }); - - it('should work with flags', async () => { - const { stderr, stdout } = await runServe(['--hot'], __dirname); - - expect(stderr).toBeFalsy(); - expect(stdout).toContain('main.js'); - expect(stdout).toContain('HotModuleReplacementPlugin'); - }); -}); diff --git a/packages/webpack-cli/__tests__/serve/webpack.config.js b/packages/webpack-cli/__tests__/serve/webpack.config.js deleted file mode 100644 index 81f34fcc1ce..00000000000 --- a/packages/webpack-cli/__tests__/serve/webpack.config.js +++ /dev/null @@ -1,7 +0,0 @@ -const WebpackCLITestPlugin = require('../../../../test/utils/webpack-cli-test-plugin'); - -module.exports = { - mode: 'development', - devtool: false, - plugins: [new WebpackCLITestPlugin(['plugins'], false)], -}; diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index cef11ded399..23030a2c92b 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -18,10 +18,8 @@ if (importLocal(__filename)) { process.title = 'webpack'; -const [, , ...rawArgs] = process.argv; - if (packageExists('webpack')) { - runCLI(rawArgs); + runCLI(process.argv); } else { promptInstallation('webpack -W', () => { error(`It looks like ${yellow('webpack')} is not installed.`); @@ -29,7 +27,7 @@ if (packageExists('webpack')) { .then(() => { success(`${yellow('webpack')} was installed sucessfully.`); - runCLI(rawArgs); + runCLI(process.argv); }) .catch(() => { error(`Action Interrupted, Please try once again or install ${yellow('webpack')} manually.`); diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index f569f099e8c..ffb65e53c08 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -1,70 +1,14 @@ -const { flags, isCommandUsed } = require('./utils/cli-flags'); const WebpackCLI = require('./webpack-cli'); const logger = require('./utils/logger'); -const argParser = require('./utils/arg-parser'); -const leven = require('leven'); -const { options: coloretteOptions } = require('colorette'); process.title = 'webpack-cli'; -const runCLI = async (cliArgs) => { - const parsedArgs = argParser(flags, cliArgs, true, process.title); - - // Enable/Disable colors - if (typeof parsedArgs.opts.color !== 'undefined') { - coloretteOptions.enabled = Boolean(parsedArgs.opts.color); - } - - const commandIsUsed = isCommandUsed(cliArgs); - - if (commandIsUsed) { - return; - } - +const runCLI = async (args) => { try { // Create a new instance of the CLI object const cli = new WebpackCLI(); - // Handle the default webpack entry CLI argument, where instead of doing 'webpack-cli --entry ./index.js' you can simply do 'webpack-cli ./index.js' - // If the unknown arg starts with a '-', it will be considered an unknown flag rather than an entry - let entry; - - if (parsedArgs.unknownArgs.length > 0) { - entry = []; - - parsedArgs.unknownArgs = parsedArgs.unknownArgs.filter((item) => { - if (item.startsWith('-')) { - return true; - } - - entry.push(item); - - return false; - }); - } - - if (parsedArgs.unknownArgs.length > 0) { - parsedArgs.unknownArgs.forEach((unknown) => { - logger.error(`Unknown argument: '${unknown}'`); - - const strippedFlag = unknown.substr(2); - const found = flags.find((flag) => leven(strippedFlag, flag.name) < 3); - - if (found) { - logger.raw(`Did you mean '--${found.name}'?`); - } - }); - - process.exit(2); - } - - const parsedArgsOpts = parsedArgs.opts; - - if (entry) { - parsedArgsOpts.entry = entry; - } - - await cli.run(parsedArgsOpts); + await cli.run(args); } catch (error) { logger.error(error); process.exit(2); diff --git a/packages/webpack-cli/lib/groups/runHelp.js b/packages/webpack-cli/lib/groups/runHelp.js deleted file mode 100644 index d9499ead471..00000000000 --- a/packages/webpack-cli/lib/groups/runHelp.js +++ /dev/null @@ -1,191 +0,0 @@ -const { options, green, bold, underline } = require('colorette'); -const commandLineUsage = require('command-line-usage'); - -const { commands, flags } = require('../utils/cli-flags'); -const logger = require('../utils/logger'); - -const outputHelp = (args) => { - if (args.includes('--color')) { - options.enabled = true; - } else if (args.includes('--no-color')) { - options.enabled = false; - } - - const hasUnknownVersionArgs = (args, commands, flags) => { - return args.filter((arg) => { - if ( - arg === 'version' || - arg === 'help' || - arg === '--help' || - arg === '-h' || - arg === '--no-color' || - arg === 'verbose' || - arg === '--help=verbose' - ) { - return false; - } - - const foundCommand = commands.find((command) => { - return command.name === arg || command.alias === arg; - }); - const foundFlag = flags.find((command) => { - return `--${command.name}` === arg || `-${command.alias}` === arg; - }); - - return !foundCommand && !foundFlag; - }); - }; - - const invalidArgs = hasUnknownVersionArgs(args, commands, flags); - - if (invalidArgs.length > 0) { - const argType = invalidArgs[0].startsWith('-') ? 'option' : 'command'; - logger.error(`Invalid ${argType} '${invalidArgs[0]}'.`); - logger.error('Run webpack --help to see available commands and arguments.'); - process.exit(2); - } - - const usedCommand = commands.filter((command) => { - return args.includes(command.name) || args.includes(command.alias); - }); - const usedFlag = flags.filter((flag) => { - if (flag.name === 'help' || flag.name === 'color') { - return false; - } - - return args.includes(`--${flag.name}`) || args.includes(`-${flag.alias}`); - }); - - const usedCommandOrFlag = [].concat(usedCommand).concat(usedFlag); - - if (usedCommandOrFlag.length > 1) { - logger.error( - `You provided multiple commands or arguments - ${usedCommandOrFlag - .map((usedFlagOrCommand) => { - const isCommand = usedFlagOrCommand.packageName; - - return `${isCommand ? 'command ' : 'argument '}'${isCommand ? usedFlagOrCommand.name : `--${usedFlagOrCommand.name}`}'${ - usedFlagOrCommand.alias ? ` (alias '${isCommand ? usedFlagOrCommand.alias : `-${usedFlagOrCommand.alias}`}')` : '' - }`; - }) - .join(', ')}. Please use only one command at a time.`, - ); - process.exit(2); - } - - // Print full help when no flag or command is supplied with help - if (usedCommandOrFlag.length === 1) { - const [item] = usedCommandOrFlag; - const isCommand = item.packageName; - const header = (head) => bold(underline(head)); - const flagAlias = item.alias ? (isCommand ? ` ${item.alias} |` : ` -${item.alias},`) : ''; - const usage = green(`webpack${flagAlias} ${item.usage}`); - const description = item.description; - const link = item.link; - - logger.raw(`${header('Usage')}: ${usage}`); - logger.raw(`${header('Description')}: ${description}`); - - if (link) { - logger.raw(`${header('Documentation')}: ${link}`); - } - - if (item.flags) { - const flags = commandLineUsage({ - header: 'Options', - optionList: item.flags, - }); - logger.raw(flags); - } - } else { - let flagsToDisplay = flags.filter(({ help }) => help === 'base'); // basic options only one word - - const negatedFlags = (allFlags) => { - return allFlags - .filter((flag) => flag.negative) - .reduce((allFlags, flag) => { - // Use available description for built-in negated flags - const description = flag.negatedDescription ? flag.negatedDescription : `Negates ${flag.name}`; - return [...allFlags, { name: `no-${flag.name}`, description, type: Boolean }]; - }, []); - }; - - const title = bold('⬡ ') + underline('webpack') + bold(' ⬡'); - const desc = 'The build tool for modern web applications'; - const websitelink = ' ' + underline('https://webpack.js.org'); - const usage = bold('Usage') + ': ' + '`' + green('webpack [...options] | ') + '`'; - const examples = bold('Example') + ': ' + '`' + green('webpack help --flag | ') + '`'; - const hh = ` ${title}\n\n${websitelink}\n\n${desc}\n\n${usage}\n${examples}`; - - if (args.includes('verbose') || args.includes('--help=verbose')) { - flagsToDisplay = [...flags, ...negatedFlags(flags)]; - - const headerAndCommands = commandLineUsage([ - { content: hh, raw: true }, - { - header: 'Commands', - content: commands.map((cmd) => { - return { name: `${cmd.name} | ${cmd.alias}`, summary: cmd.description }; - }), - }, - { header: 'Options', raw: true }, - ]); - - // print help-header & commands - logger.raw(headerAndCommands); - // print all options - for (const flag of flagsToDisplay) { - let flagType; - - if (Array.isArray(flag.type)) { - const allowedTypes = flag.type.reduce((allTypes, type) => { - const currentType = flag.multiple ? `${type.name.toLowerCase()}[]` : type.name.toLowerCase(); - return [...allTypes, currentType]; - }, []); - flagType = allowedTypes.join(', '); - } else { - flagType = `${flag.type.name.toLowerCase()}${flag.multiple ? '[]' : ''}`; - } - - logger.raw(`${underline(bold('Option'))} : --${flag.name}`); - logger.raw(`${underline(bold('Type'))} : ${flagType}`); - logger.raw(`${underline(bold('Description'))} : ${flag.description}\n`); - } - } else { - const output = commandLineUsage([ - { content: hh, raw: true }, - { header: "To see list of all supported commands and options run 'webpack-cli --help=verbose'" }, - { - header: 'Commands', - content: commands.map((cmd) => { - return { name: `${cmd.name} | ${cmd.alias}`, summary: cmd.description }; - }), - }, - { - header: 'Options', - optionList: flagsToDisplay - .map((e) => { - if (e.type.length > 1) { - e.type = e.type[0]; - } - - // Here we replace special characters with chalk's escape - // syntax (`\$&`) to avoid chalk trying to re-process our input. - // This is needed because chalk supports a form of `{var}` - // interpolation. - e.description = e.description.replace(/[{}\\]/g, '\\$&'); - - return e; - }) - .concat(negatedFlags(flagsToDisplay)), - }, - ]); - - logger.raw(output); - } - } - - logger.raw(' Made with ♥️ by the webpack team'); -}; - -module.exports = outputHelp; diff --git a/packages/webpack-cli/lib/groups/runVersion.js b/packages/webpack-cli/lib/groups/runVersion.js deleted file mode 100644 index 757131c5743..00000000000 --- a/packages/webpack-cli/lib/groups/runVersion.js +++ /dev/null @@ -1,68 +0,0 @@ -const logger = require('../utils/logger'); -const { commands, flags } = require('../utils/cli-flags'); -const { options } = require('colorette'); - -const outputVersion = (args) => { - if (args.includes('--color')) { - options.enabled = true; - } else if (args.includes('--no-color')) { - options.enabled = false; - } - - const hasUnknownVersionArgs = (args, commands, flags) => { - return args.filter((arg) => { - if (arg === 'version' || arg === '--version' || arg === '-v' || arg === '--color' || arg === '--no-color') { - return false; - } - - const foundCommand = commands.find((command) => { - return command.name === arg || command.alias === arg; - }); - const foundFlag = flags.find((command) => { - return `--${command.name}` === arg || `-${command.alias}` === arg; - }); - - return !foundCommand && !foundFlag; - }); - }; - - const invalidArgs = hasUnknownVersionArgs(args, commands, flags); - - if (invalidArgs.length > 0) { - const argType = invalidArgs[0].startsWith('-') ? 'option' : 'command'; - logger.error(`Invalid ${argType} '${invalidArgs[0]}'.`); - logger.error('Run webpack --help to see available commands and arguments.'); - process.exit(2); - } - - const usedCommands = commands.filter((command) => { - return args.includes(command.name) || args.includes(command.alias); - }); - - if (usedCommands.length > 1) { - logger.error( - `You provided multiple commands - ${usedCommands - .map((command) => `'${command.name}'${command.alias ? ` (alias '${command.alias}')` : ''}`) - .join(', ')}. Please use only one command at a time.`, - ); - process.exit(2); - } - - if (usedCommands.length === 1) { - try { - const { name, version } = require(`${usedCommands[0].packageName}/package.json`); - logger.raw(`${name} ${version}`); - } catch (e) { - logger.error('Error: External package not found.'); - process.exit(2); - } - } - - const pkgJSON = require('../../package.json'); - const webpack = require('webpack'); - - logger.raw(`webpack-cli ${pkgJSON.version}`); - logger.raw(`webpack ${webpack.version}`); -}; - -module.exports = outputVersion; diff --git a/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js b/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js deleted file mode 100644 index a684ea214c0..00000000000 --- a/packages/webpack-cli/lib/utils/__tests__/package-exists.test.js +++ /dev/null @@ -1,20 +0,0 @@ -jest.setMock('../prompt-installation', jest.fn()); - -const ExternalCommand = require('../resolve-command'); -const packageExists = require('../package-exists'); -const promptInstallation = require('../prompt-installation'); - -describe('@webpack-cli/utils', () => { - it('should check existence of package', () => { - // use an actual path relative to the packageUtils file - expect(packageExists('./logger')).toBeTruthy(); - expect(packageExists('./nonexistent-package')).toBeFalsy(); - }); - - it.skip('should not throw if the user interrupts', async () => { - promptInstallation.mockImplementation(() => { - throw new Error(); - }); - await expect(ExternalCommand('@webpack-cli/info')).resolves.not.toThrow(); - }); -}); diff --git a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js index 91a0562e5ec..f2df0a02e69 100644 --- a/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js +++ b/packages/webpack-cli/lib/utils/__tests__/prompt-installation.test.js @@ -1,15 +1,13 @@ 'use strict'; +// eslint-disable-next-line node/no-extraneous-require +const stripAnsi = require('strip-ansi'); const globalModulesNpmValue = 'test-npm'; -jest.setMock('global-modules', globalModulesNpmValue); -jest.setMock('enquirer', { - prompt: jest.fn(), -}); +jest.setMock('global-modules', globalModulesNpmValue); +jest.setMock('enquirer', { prompt: jest.fn() }); jest.setMock('../run-command', jest.fn()); - jest.setMock('../package-exists', jest.fn()); - jest.setMock('../get-package-manager', jest.fn()); const getPackageManager = require('../get-package-manager'); @@ -28,63 +26,93 @@ describe('promptInstallation', () => { }); it('should prompt to install using npm if npm is package manager', async () => { - prompt.mockReturnValue({ - installConfirm: true, - }); + prompt.mockReturnValue({ installConfirm: true }); + getPackageManager.mockReturnValue('npm'); + const preMessage = jest.fn(); const promptResult = await promptInstallation('test-package', preMessage); + expect(promptResult).toBeTruthy(); expect(preMessage.mock.calls.length).toEqual(1); expect(prompt.mock.calls.length).toEqual(1); expect(runCommand.mock.calls.length).toEqual(1); - expect(prompt.mock.calls[0][0][0].message).toMatch(/Would you like to install test-package\?/); + expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain( + "Would you like to install 'test-package' package? (That will run 'npm install -D test-package')", + ); + // install the package using npm expect(runCommand.mock.calls[0][0]).toEqual('npm install -D test-package'); }); it('should prompt to install using yarn if yarn is package manager', async () => { - prompt.mockReturnValue({ - installConfirm: true, - }); + prompt.mockReturnValue({ installConfirm: true }); + getPackageManager.mockReturnValue('yarn'); const promptResult = await promptInstallation('test-package'); + expect(promptResult).toBeTruthy(); expect(prompt.mock.calls.length).toEqual(1); expect(runCommand.mock.calls.length).toEqual(1); - expect(prompt.mock.calls[0][0][0].message).toMatch(/Would you like to install test-package\?/); + expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain( + "Would you like to install 'test-package' package? (That will run 'yarn add -D test-package')", + ); + // install the package using yarn expect(runCommand.mock.calls[0][0]).toEqual('yarn add -D test-package'); }); it('should prompt to install using pnpm if pnpm is package manager', async () => { - prompt.mockReturnValue({ - installConfirm: true, - }); + prompt.mockReturnValue({ installConfirm: true }); + getPackageManager.mockReturnValue('pnpm'); + + const promptResult = await promptInstallation('test-package'); + + expect(promptResult).toBeTruthy(); + expect(prompt.mock.calls.length).toEqual(1); + expect(runCommand.mock.calls.length).toEqual(1); + expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain( + "Would you like to install 'test-package' package? (That will run 'pnpm install -D test-package')", + ); + + // install the package using npm + expect(runCommand.mock.calls[0][0]).toEqual('pnpm install -D test-package'); + }); + + it('should support pre message', async () => { + prompt.mockReturnValue({ installConfirm: true }); + + getPackageManager.mockReturnValue('npm'); + const preMessage = jest.fn(); const promptResult = await promptInstallation('test-package', preMessage); + expect(promptResult).toBeTruthy(); expect(preMessage.mock.calls.length).toEqual(1); expect(prompt.mock.calls.length).toEqual(1); expect(runCommand.mock.calls.length).toEqual(1); - expect(prompt.mock.calls[0][0][0].message).toMatch(/Would you like to install test-package\?/); + expect(stripAnsi(prompt.mock.calls[0][0][0].message)).toContain( + "Would you like to install 'test-package' package? (That will run 'npm install -D test-package')", + ); + // install the package using npm - expect(runCommand.mock.calls[0][0]).toEqual('pnpm install -D test-package'); + expect(runCommand.mock.calls[0][0]).toEqual('npm install -D test-package'); }); it('should not install if install is not confirmed', async () => { - prompt.mockReturnValue({ - installConfirm: false, - }); + prompt.mockReturnValue({ installConfirm: false }); + const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {}); const promptResult = await promptInstallation('test-package'); + expect(promptResult).toBeUndefined(); expect(prompt.mock.calls.length).toEqual(1); // runCommand should not be called, because the installation is not confirmed expect(runCommand.mock.calls.length).toEqual(0); - expect(prompt.mock.calls[0][0][0].message).toMatch(/Would you like to install test-package\?/); - expect(process.exitCode).toEqual(2); + expect(mockExit.mock.calls[0][0]).toEqual(2); + + mockExit.mockRestore(); }); }); diff --git a/packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js b/packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js deleted file mode 100644 index df10101355e..00000000000 --- a/packages/webpack-cli/lib/utils/__tests__/resolve-command.test.js +++ /dev/null @@ -1,32 +0,0 @@ -jest.setMock('../prompt-installation', jest.fn()); - -const resolveCommand = require('../resolve-command'); -const promptInstallation = require('../prompt-installation'); - -describe('resolve-command util', () => { - const processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {}); - const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); - - beforeEach(() => { - processExitSpy.mockClear(); - consoleErrorSpy.mockClear(); - }); - - it('should not throw error', async () => { - promptInstallation.mockImplementation(() => {}); - - await expect(resolveCommand('info')).resolves.not.toThrow(); - expect(processExitSpy.mock.calls.length).toBe(0); - expect(consoleErrorSpy.mock.calls.length).toBe(0); - }); - - it('should throw error and exit with invalid command', async () => { - promptInstallation.mockImplementation(() => { - throw new Error(); - }); - - await resolveCommand('invalid'); - expect(processExitSpy).toBeCalledWith(2); - expect(consoleErrorSpy.mock.calls.length).toBe(1); - }); -}); diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js deleted file mode 100644 index 68cbff6a1b3..00000000000 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ /dev/null @@ -1,218 +0,0 @@ -const commander = require('commander'); -const logger = require('./logger'); -const { commands } = require('./cli-flags'); -const runHelp = require('../groups/runHelp'); -const runVersion = require('../groups/runVersion'); - -/** - * Creates Argument parser corresponding to the supplied options - * parse the args and return the result - * - * @param {object[]} options Array of objects with details about flags - * @param {string[]} args process.argv or it's subset - * @param {boolean} argsOnly false if all of process.argv has been provided, true if - * @param {string} name Parser name - * args is only a subset of process.argv that removes the first couple elements - */ -const argParser = (options, args, argsOnly = false, name = '') => { - // Use customized help output - const showHelp = args.includes('--help') || args.includes('help') || args.includes('--help=verbose'); - // allow --help=verbose and --help verbose - if (showHelp || (showHelp && args.includes('verbose'))) { - runHelp(args); - process.exit(0); - } - - // Use Customized version - if (args.includes('--version') || args.includes('version') || args.includes('-v')) { - runVersion(args); - process.exit(0); - } - - const parser = new commander.Command(); - const processors = {}; - - // Set parser name - parser.name(name); - parser.storeOptionsAsProperties(false); - - commands.reduce((parserInstance, cmd) => { - parser - .command(cmd.name) - .alias(cmd.alias) - .description(cmd.description) - .usage(cmd.usage) - .allowUnknownOption(true) - .action(async () => { - const cliArgs = args.slice(args.indexOf(cmd.name) + 1 || args.indexOf(cmd.alias) + 1); - - return await require('./resolve-command')(cmd.packageName, cliArgs, cmd.name); - }); - - return parser; - }, parser); - - // Prevent default behavior - parser.on('command:*', () => {}); - - // Allow execution if unknown arguments are present - parser.allowUnknownOption(true); - - // Register options on the parser - options.reduce((parserInstance, option) => { - let optionType = option.type; - let isStringOrBool = false; - - if (Array.isArray(optionType)) { - // filter out duplicate types - optionType = optionType.filter((type, index) => { - return optionType.indexOf(type) === index; - }); - - // the only multi type currently supported is String and Boolean, - // if there is a case where a different multi type is needed it - // must be added here - if (optionType.length === 0) { - // if no type is provided in the array fall back to Boolean - optionType = Boolean; - } else if (optionType.length === 1 || optionType.length > 2) { - // treat arrays with 1 or > 2 args as a single type - optionType = optionType[0]; - } else { - // only String and Boolean multi type is supported - if (optionType.includes(Boolean) && optionType.includes(String)) { - isStringOrBool = true; - } else { - optionType = optionType[0]; - } - } - } - - const flags = option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`; - - let flagsWithType = flags; - - if (isStringOrBool) { - // commander recognizes [value] as an optional placeholder, - // making this flag work either as a string or a boolean - flagsWithType = `${flags} [value]`; - } else if (optionType !== Boolean) { - // is a required placeholder for any non-Boolean types - flagsWithType = `${flags} `; - } - - if (isStringOrBool || optionType === Boolean || optionType === String) { - if (option.multiple) { - // a multiple argument parsing function - const multiArg = (value, previous = []) => previous.concat([value]); - parserInstance.option(flagsWithType, option.description, multiArg, option.defaultValue).action(() => {}); - } else if (option.multipleType) { - // for options which accept multiple types like env - // so you can do `--env platform=staging --env production` - // { platform: "staging", production: true } - const multiArg = (value, previous = {}) => { - // this ensures we're only splitting by the first `=` - const [allKeys, val] = value.split(/=(.+)/, 2); - const splitKeys = allKeys.split(/\.(?!$)/); - - let prevRef = previous; - - splitKeys.forEach((someKey, index) => { - if (!prevRef[someKey]) { - prevRef[someKey] = {}; - } - - if ('string' === typeof prevRef[someKey]) { - prevRef[someKey] = {}; - } - - if (index === splitKeys.length - 1) { - prevRef[someKey] = val || true; - } - - prevRef = prevRef[someKey]; - }); - - return previous; - }; - parserInstance.option(flagsWithType, option.description, multiArg, option.defaultValue).action(() => {}); - } else { - // Prevent default behavior for standalone options - parserInstance.option(flagsWithType, option.description, option.defaultValue).action(() => {}); - } - } else if (optionType === Number) { - // this will parse the flag as a number - parserInstance.option(flagsWithType, option.description, Number, option.defaultValue); - } else { - // in this case the type is a parsing function - parserInstance.option(flagsWithType, option.description, optionType, option.defaultValue).action(() => {}); - } - - if (option.negative) { - // commander requires explicitly adding the negated version of boolean flags - const negatedFlag = `--no-${option.name}`; - parserInstance.option(negatedFlag, `negates ${option.name}`).action(() => {}); - } - - if (option.processor) { - // camel-case - const attributeName = option.name.split('-').reduce((str, word) => { - return str + word[0].toUpperCase() + word.slice(1); - }); - - processors[attributeName] = option.processor; - } - - return parserInstance; - }, parser); - - // if we are parsing a subset of process.argv that includes - // only the arguments themselves (e.g. ['--option', 'value']) - // then we need from: 'user' passed into commander parse - // otherwise we are parsing a full process.argv - // (e.g. ['node', '/path/to/...', '--option', 'value']) - const parseOptions = argsOnly ? { from: 'user' } : {}; - - const result = parser.parse(args, parseOptions); - const opts = result.opts(); - const unknownArgs = result.args; - - args.forEach((arg) => { - const flagName = arg.slice(5); - const option = options.find((opt) => opt.name === flagName); - const flag = `--${flagName}`; - const flagUsed = args.includes(flag) && !unknownArgs.includes(flag); - let alias = ''; - let aliasUsed = false; - - if (option && option.alias) { - alias = `-${option.alias}`; - aliasUsed = args.includes(alias) && !unknownArgs.includes(alias); - } - - // this is a negated flag that is not an unknown flag, but the flag - // it is negating was also provided - if (arg.startsWith('--no-') && (flagUsed || aliasUsed) && !unknownArgs.includes(arg)) { - logger.warn( - `You provided both ${ - flagUsed ? flag : alias - } and ${arg}. We will use only the last of these flags that you provided in your CLI arguments`, - ); - } - }); - - Object.keys(opts).forEach((key) => { - if (opts[key] === undefined) { - delete opts[key]; - } else if (processors[key]) { - processors[key](opts); - } - }); - - return { - unknownArgs, - opts, - }; -}; - -module.exports = argParser; diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index dbbf824d2d0..57ecfa67651 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -1,88 +1,21 @@ const packageExists = require('./package-exists'); const cli = packageExists('webpack') ? require('webpack').cli : undefined; -const commands = [ - { - packageName: '@webpack-cli/init', - name: 'init', - alias: 'c', - type: String, - usage: 'init [scaffold] [options]', - description: 'Initialize a new webpack configuration', - flags: [ - { - name: 'auto', - type: Boolean, - description: 'To generate default config', - }, - { - name: 'force', - type: Boolean, - description: 'To force config generation', - }, - { - name: 'generation-path', - type: String, - description: 'To scaffold in a specified path', - }, - ], - }, - { - packageName: '@webpack-cli/migrate', - name: 'migrate', - alias: 'm', - type: String, - usage: 'migrate [output-path]', - description: 'Migrate a configuration to a new version', - }, - { - packageName: '@webpack-cli/generators', - name: 'loader', - scope: 'external', - alias: 'l', - type: String, - usage: 'loader [path]', - description: 'Scaffold a loader repository', - }, - { - packageName: '@webpack-cli/generators', - name: 'plugin', - alias: 'p', - scope: 'external', - type: String, - usage: 'plugin [path]', - description: 'Scaffold a plugin repository', - }, - { - packageName: '@webpack-cli/info', - name: 'info', - scope: 'external', - alias: 'i', - type: String, - usage: 'info [options]', - description: 'Outputs information about your system and dependencies', - flags: [ - { - name: 'output', - type: String, - description: 'To get the output in specified format ( accept json or markdown )', - }, - { - name: 'version', - type: Boolean, - description: 'Print version information of info package', - }, - ], - }, - { - packageName: '@webpack-cli/serve', - name: 'serve', - alias: 's', - scope: 'external', - type: String, - usage: 'serve [options]', - description: 'Run the webpack Dev Server', - }, +const minimumHelpFlags = [ + 'config', + 'config-name', + 'merge', + 'env', + 'mode', + 'watch', + 'stats', + 'devtool', + 'entry', + 'target', + 'progress', + 'json', + 'name', + 'output-path', ]; const builtInFlags = [ @@ -92,37 +25,30 @@ const builtInFlags = [ usage: '--config | --config --config ', alias: 'c', type: String, - help: 'base', multiple: true, - description: 'Provide path to a webpack configuration file e.g. ./webpack.config.js', - link: 'https://webpack.js.org/configuration/', + description: 'Provide path to a webpack configuration file e.g. ./webpack.config.js.', }, { name: 'config-name', usage: '--config-name | --config-name --config-name ', type: String, - help: 'verbose', multiple: true, - description: 'Name of the configuration to use', + description: 'Name of the configuration to use.', }, { name: 'merge', usage: '--config --config --merge', alias: 'm', type: Boolean, - help: 'base', - description: 'Merge two or more configurations using webpack-merge', - link: 'https://github.com/survivejs/webpack-merge', + description: "Merge two or more configurations using 'webpack-merge'.", }, // Complex configs { name: 'env', usage: '--env | --env --env ', type: String, - help: 'base', multipleType: true, - description: 'Environment passed to the configuration when it is a function', - link: 'https://webpack.js.org/api/cli/#environment-options', + description: 'Environment passed to the configuration when it is a function.', }, // Adding more plugins @@ -131,52 +57,28 @@ const builtInFlags = [ usage: '--hot', alias: 'h', type: Boolean, - help: 'base', negative: true, description: 'Enables Hot Module Replacement', - negatedDescription: 'Disables Hot Module Replacement', - link: 'https://webpack.js.org/concepts/hot-module-replacement/', + negatedDescription: 'Disables Hot Module Replacement.', }, { name: 'analyze', usage: '--analyze', type: Boolean, - help: 'base', multiple: false, - description: 'It invokes webpack-bundle-analyzer plugin to get bundle information', - link: 'https://github.com/webpack-contrib/webpack-bundle-analyzer', + description: 'It invokes webpack-bundle-analyzer plugin to get bundle information.', }, { name: 'progress', usage: '--progress | --progress profile', type: [Boolean, String], - help: 'base', - description: 'Print compilation progress during build', + description: 'Print compilation progress during build.', }, { name: 'prefetch', usage: '--prefetch ', type: String, - help: 'base', - description: 'Prefetch this request', - link: 'https://webpack.js.org/plugins/prefetch-plugin/', - }, - - // Help and versions - { - name: 'help', - usage: '--help', - type: [Boolean, String], - help: 'base', - description: 'Outputs list of supported flags', - }, - { - name: 'version', - usage: '--version | --version ', - alias: 'v', - type: Boolean, - help: 'base', - description: 'Get current version', + description: 'Prefetch this request.', }, // Output options @@ -184,18 +86,8 @@ const builtInFlags = [ name: 'json', usage: '--json | --json ', type: [String, Boolean], - help: 'base', alias: 'j', - description: 'Prints result as JSON or store it in a file', - }, - { - name: 'color', - usage: '--color', - type: Boolean, - help: 'base', - negative: true, - description: 'Enable colors on console', - negatedDescription: 'Disable colors on console', + description: 'Prints result as JSON or store it in a file.', }, // For webpack@4 @@ -204,76 +96,60 @@ const builtInFlags = [ usage: '--entry | --entry --entry ', type: String, multiple: true, - help: 'base', - description: 'The entry point(s) of your application e.g. ./src/main.js', - link: 'https://webpack.js.org/concepts/#entry', + description: 'The entry point(s) of your application e.g. ./src/main.js.', }, { name: 'output-path', usage: '--output-path ', alias: 'o', type: String, - help: 'verbose', - description: 'Output location of the file generated by webpack e.g. ./dist/', - link: 'https://webpack.js.org/configuration/output/#outputpath', + description: 'Output location of the file generated by webpack e.g. ./dist/.', }, { name: 'target', usage: '--target | --target --target ', alias: 't', type: String, - help: 'base', multiple: cli !== undefined, - description: 'Sets the build target e.g. node', - link: 'https://webpack.js.org/configuration/target/#target', + description: 'Sets the build target e.g. node.', }, { name: 'devtool', usage: '--devtool ', type: String, - help: 'base', negative: true, alias: 'd', - description: 'Determine source maps to use', - negatedDescription: 'Do not generate source maps', - link: 'https://webpack.js.org/configuration/devtool/#devtool', + description: 'Determine source maps to use.', + negatedDescription: 'Do not generate source maps.', }, { name: 'mode', usage: '--mode ', - help: 'base', type: String, - description: 'Defines the mode to pass to webpack', - link: 'https://webpack.js.org/concepts/#mode', + description: 'Defines the mode to pass to webpack.', }, { name: 'name', usage: '--name', type: String, - help: 'base', description: 'Name of the configuration. Used when loading multiple configurations.', - link: 'https://webpack.js.org/configuration/other-options/#name', }, { name: 'stats', usage: '--stats | --stats ', type: [String, Boolean], negative: true, - help: 'base', - description: 'It instructs webpack on how to treat the stats e.g. verbose', - negatedDescription: 'Disable stats output', - link: 'https://webpack.js.org/configuration/stats/#stats', + description: 'It instructs webpack on how to treat the stats e.g. verbose.', + negatedDescription: 'Disable stats output.', }, { name: 'watch', usage: '--watch', type: Boolean, - help: 'base', negative: true, alias: 'w', - description: 'Watch for files changes', - negatedDescription: 'Do not watch for file changes', - link: 'https://webpack.js.org/configuration/watch/', + description: 'Watch for files changes.', + negatedDescription: 'Do not watch for file changes.', }, ]; @@ -304,16 +180,11 @@ const coreFlags = cli : []; const flags = [] .concat(builtInFlags.filter((builtInFlag) => !coreFlags.find((coreFlag) => builtInFlag.name === coreFlag.name))) - .concat(coreFlags); + .concat(coreFlags) + .map((option) => { + option.help = minimumHelpFlags.includes(option.name) ? 'minimum' : 'verbose'; -const isCommandUsed = (args) => - commands.find((cmd) => { - return args.includes(cmd.name) || args.includes(cmd.alias); + return option; }); -module.exports = { - commands, - cli, - flags, - isCommandUsed, -}; +module.exports = { cli, flags }; diff --git a/packages/webpack-cli/lib/utils/package-exists.js b/packages/webpack-cli/lib/utils/package-exists.js index 5ba91f3f9f2..48211cfb938 100644 --- a/packages/webpack-cli/lib/utils/package-exists.js +++ b/packages/webpack-cli/lib/utils/package-exists.js @@ -1,10 +1,9 @@ -function packageExists(packageName) { +function getPkg(packageName) { try { - require.resolve(packageName); - return true; - } catch (err) { + return require.resolve(packageName); + } catch (error) { return false; } } -module.exports = packageExists; +module.exports = getPkg; diff --git a/packages/webpack-cli/lib/utils/prompt-installation.js b/packages/webpack-cli/lib/utils/prompt-installation.js index 2a6d0ca3743..5f77893cb95 100644 --- a/packages/webpack-cli/lib/utils/prompt-installation.js +++ b/packages/webpack-cli/lib/utils/prompt-installation.js @@ -3,6 +3,7 @@ const { green } = require('colorette'); const runCommand = require('./run-command'); const getPackageManager = require('./get-package-manager'); const packageExists = require('./package-exists'); +const logger = require('./logger'); /** * @@ -11,6 +12,12 @@ const packageExists = require('./package-exists'); */ async function promptInstallation(packageName, preMessage) { const packageManager = getPackageManager(); + + if (!packageManager) { + logger.error("Can't find package manager"); + process.exit(2); + } + // yarn uses 'add' command, rest npm and pnpm both use 'install' const options = [packageManager === 'yarn' ? 'add' : 'install', '-D', packageName]; @@ -20,23 +27,35 @@ async function promptInstallation(packageName, preMessage) { preMessage(); } - const question = `Would you like to install ${packageName}? (That will run ${green(commandToBeRun)})`; - const { installConfirm } = await prompt([ - { - type: 'confirm', - name: 'installConfirm', - message: question, - initial: 'Y', - }, - ]); + let installConfirm; + + try { + ({ installConfirm } = await prompt([ + { + type: 'confirm', + name: 'installConfirm', + message: `Would you like to install '${packageName}' package? (That will run '${green(commandToBeRun)}')`, + initial: 'Y', + stdout: process.stderr, + }, + ])); + } catch (error) { + logger.error(error); + process.exit(2); + } if (installConfirm) { - await runCommand(commandToBeRun); + try { + await runCommand(commandToBeRun); + } catch (error) { + logger.error(error); + process.exit(2); + } return packageExists(packageName); } - process.exitCode = 2; + process.exit(2); } module.exports = promptInstallation; diff --git a/packages/webpack-cli/lib/utils/resolve-command.js b/packages/webpack-cli/lib/utils/resolve-command.js deleted file mode 100644 index 63ab6b85d57..00000000000 --- a/packages/webpack-cli/lib/utils/resolve-command.js +++ /dev/null @@ -1,33 +0,0 @@ -const { yellow, cyan } = require('colorette'); -const logger = require('./logger'); -const packageExists = require('./package-exists'); -const promptInstallation = require('./prompt-installation'); - -const run = async (name, args, commandName) => { - let packageLocation = packageExists(name); - - if (!packageLocation) { - try { - packageLocation = await promptInstallation(`${name}`, () => { - logger.error(`The command moved into a separate package: ${yellow(name)}\n`); - }); - } catch (err) { - logger.error(`Action Interrupted, use ${cyan('webpack-cli help')} to see possible commands.`); - process.exit(2); - } - } - - if (!packageLocation) { - return; - } - - let loaded = require(name); - - if (loaded.default) { - loaded = loaded.default; - } - - return loaded(args, commandName); -}; - -module.exports = run; diff --git a/packages/webpack-cli/lib/utils/run-command.js b/packages/webpack-cli/lib/utils/run-command.js index bd5477c1ed1..4ed493f3ea3 100644 --- a/packages/webpack-cli/lib/utils/run-command.js +++ b/packages/webpack-cli/lib/utils/run-command.js @@ -3,12 +3,9 @@ const logger = require('./logger'); async function runCommand(command, args = []) { try { - await execa(command, args, { - stdio: 'inherit', - shell: true, - }); - } catch (e) { - logger.error(e); + await execa(command, args, { stdio: 'inherit', shell: true }); + } catch (error) { + logger.error(error.message); process.exit(2); } } diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 084d1b6a992..5bd48b4c701 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1,27 +1,661 @@ const path = require('path'); -const packageExists = require('./utils/package-exists'); -const webpack = packageExists('webpack') ? require('webpack') : undefined; +const { program } = require('commander'); +const getPkg = require('./utils/package-exists'); +const webpack = getPkg('webpack') ? require('webpack') : undefined; const webpackMerge = require('webpack-merge'); +const { extensions, jsVariants } = require('interpret'); +const rechoir = require('rechoir'); const { createWriteStream, existsSync } = require('fs'); -const { options: coloretteOptions, yellow } = require('colorette'); +const leven = require('leven'); +const { options: coloretteOptions, yellow, cyan, green, bold } = require('colorette'); const { stringifyStream: createJsonStringifyStream } = require('@discoveryjs/json-ext'); const logger = require('./utils/logger'); const { cli, flags } = require('./utils/cli-flags'); -const argParser = require('./utils/arg-parser'); const CLIPlugin = require('./plugins/CLIPlugin'); const promptInstallation = require('./utils/prompt-installation'); -const { extensions, jsVariants } = require('interpret'); -const rechoir = require('rechoir'); const toKebabCase = require('./utils/to-kebab-case'); const { resolve, extname } = path; class WebpackCLI { - constructor() {} + constructor() { + this.logger = logger; + // Initialize program + this.program = program; + this.program.name('webpack'); + this.program.storeOptionsAsProperties(false); + this.utils = { toKebabCase, getPkg, promptInstallation }; + } + + makeCommand(commandOptions, optionsForCommand = [], action) { + const command = program.command(commandOptions.name, { + noHelp: commandOptions.noHelp, + hidden: commandOptions.hidden, + isDefault: commandOptions.isDefault, + }); + + if (commandOptions.description) { + command.description(commandOptions.description); + } + + if (commandOptions.usage) { + command.usage(commandOptions.usage); + } + + if (Array.isArray(commandOptions.alias)) { + command.aliases(commandOptions.alias); + } else { + command.alias(commandOptions.alias); + } + + if (commandOptions.pkg) { + command.pkg = commandOptions.pkg; + } else { + command.pkg = 'webpack-cli'; + } + + if (optionsForCommand.length > 0) { + optionsForCommand.forEach((optionForCommand) => { + this.makeOption(command, optionForCommand); + }); + } + + command.action(action); + + return command; + } + + // TODO refactor this terrible stuff + makeOption(command, option) { + let optionType = option.type; + let isStringOrBool = false; + + if (Array.isArray(optionType)) { + // filter out duplicate types + optionType = optionType.filter((type, index) => { + return optionType.indexOf(type) === index; + }); + + // the only multi type currently supported is String and Boolean, + // if there is a case where a different multi type is needed it + // must be added here + if (optionType.length === 0) { + // if no type is provided in the array fall back to Boolean + optionType = Boolean; + } else if (optionType.length === 1 || optionType.length > 2) { + // treat arrays with 1 or > 2 args as a single type + optionType = optionType[0]; + } else { + // only String and Boolean multi type is supported + if (optionType.includes(Boolean) && optionType.includes(String)) { + isStringOrBool = true; + } else { + optionType = optionType[0]; + } + } + } + + const flags = option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`; + + let flagsWithType = flags; + + if (isStringOrBool) { + // commander recognizes [value] as an optional placeholder, + // making this flag work either as a string or a boolean + flagsWithType = `${flags} [value]`; + } else if (optionType !== Boolean) { + // is a required placeholder for any non-Boolean types + flagsWithType = `${flags} `; + } + + if (isStringOrBool || optionType === Boolean || optionType === String) { + if (option.multiple) { + // a multiple argument parsing function + const multiArg = (value, previous = []) => previous.concat([value]); + + command.option(flagsWithType, option.description, multiArg, option.defaultValue); + } else if (option.multipleType) { + // for options which accept multiple types like env + // so you can do `--env platform=staging --env production` + // { platform: "staging", production: true } + const multiArg = (value, previous = {}) => { + // this ensures we're only splitting by the first `=` + const [allKeys, val] = value.split(/=(.+)/, 2); + const splitKeys = allKeys.split(/\.(?!$)/); + + let prevRef = previous; + + splitKeys.forEach((someKey, index) => { + if (!prevRef[someKey]) { + prevRef[someKey] = {}; + } + + if (typeof prevRef[someKey] === 'string') { + prevRef[someKey] = {}; + } + + if (index === splitKeys.length - 1) { + prevRef[someKey] = val || true; + } + + prevRef = prevRef[someKey]; + }); + + return previous; + }; + + command.option(flagsWithType, option.description, multiArg, option.defaultValue); + } else { + // Prevent default behavior for standalone options + command.option(flagsWithType, option.description, option.defaultValue); + } + } else if (optionType === Number) { + // this will parse the flag as a number + command.option(flagsWithType, option.description, Number, option.defaultValue); + } else { + // in this case the type is a parsing function + command.option(flagsWithType, option.description, optionType, option.defaultValue); + } + + if (option.negative) { + // commander requires explicitly adding the negated version of boolean flags + const negatedFlag = `--no-${option.name}`; + + command.option(negatedFlag, option.negatedDescription ? option.negatedDescription : `Negative '${option.name}' option.`); + } + } + + getBuiltInOptions() { + return flags; + } + + async run(args) { + // Built-in internal commands + const bundleCommandOptions = { + name: 'bundle', + alias: 'b', + description: 'Run webpack (default command, can be omitted).', + usage: '[options]', + }; + const versionCommandOptions = { + name: 'version', + alias: 'v', + description: "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", + usage: '[commands...]', + }; + const helpCommandOptions = { + name: 'help', + alias: 'h', + description: 'Display help for commands and options.', + usage: '[command]', + }; + // Built-in external commands + const externalBuiltInCommandsInfo = [ + { + name: 'serve', + alias: 's', + pkg: '@webpack-cli/serve', + }, + { + name: 'info', + alias: 'i', + pkg: '@webpack-cli/info', + }, + { + name: 'init', + alias: 'c', + pkg: '@webpack-cli/init', + }, + { + name: 'loader', + alias: 'l', + pkg: '@webpack-cli/generators', + }, + { + name: 'plugin', + alias: 'p', + pkg: '@webpack-cli/generators', + }, + { + name: 'migrate', + alias: 'm', + pkg: '@webpack-cli/migrate', + }, + ]; + + const getCommandNameAndOptions = (args) => { + let commandName; + const options = []; + + let allowToSearchCommand = true; + + args.forEach((arg) => { + if (!arg.startsWith('-') && allowToSearchCommand) { + commandName = arg; + + allowToSearchCommand = false; + + return; + } + + allowToSearchCommand = false; + + options.push(arg); + }); + + const isDefault = typeof commandName === 'undefined'; + + return { commandName: isDefault ? bundleCommandOptions.name : commandName, options, isDefault }; + }; + const loadCommandByName = async (commandName, allowToInstall = false) => { + if (commandName === bundleCommandOptions.name || commandName === bundleCommandOptions.alias) { + // Make `bundle|b [options]` command + this.makeCommand(bundleCommandOptions, this.getBuiltInOptions(), async (program) => { + const options = program.opts(); + + if (typeof colorFromArguments !== 'undefined') { + options.color = colorFromArguments; + } + + if (program.args.length > 0) { + const possibleCommands = [].concat([bundleCommandOptions.name]).concat(program.args); + + logger.error('Running multiple commands at the same time is not possible'); + logger.error(`Found commands: ${possibleCommands.map((item) => `'${item}'`).join(', ')}`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + await this.bundleCommand(options); + }); + } else if (commandName === helpCommandOptions.name || commandName === helpCommandOptions.alias) { + this.makeCommand( + { + name: 'help [command]', + alias: 'h', + description: 'Display help for commands and options', + usage: '[command]', + }, + [], + // Stub for the `help` command + () => {}, + ); + } else if (commandName === versionCommandOptions.name || commandName === helpCommandOptions.alias) { + this.makeCommand( + { + name: 'version [commands...]', + alias: 'v', + description: "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands", + usage: '[commands...]', + }, + [], + // Stub for the `help` command + () => {}, + ); + } else { + const builtInExternalCommandInfo = externalBuiltInCommandsInfo.find( + (externalBuiltInCommandInfo) => + externalBuiltInCommandInfo.name === commandName || externalBuiltInCommandInfo.alias === commandName, + ); + + let pkg; + + if (builtInExternalCommandInfo) { + ({ pkg } = builtInExternalCommandInfo); + } else { + pkg = commandName; + } + + if (pkg !== 'webpack-cli' && !getPkg(pkg)) { + if (!allowToInstall) { + const isOptions = commandName.startsWith('-'); + + logger.error(`Unknown ${isOptions ? 'option' : 'command'} '${commandName}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + try { + pkg = await promptInstallation(pkg, () => { + logger.error(`For using this command you need to install: '${green(commandName)}' package`); + }); + } catch (error) { + logger.error(`Action Interrupted, use '${cyan('webpack-cli help')}' to see possible commands`); + process.exit(2); + } + } + + let loadedCommand; + + try { + loadedCommand = require(pkg); + } catch (error) { + // Ignore, command is not installed + + return; + } + + if (loadedCommand.default) { + loadedCommand = loadedCommand.default; + } - async resolveConfig(args) { + let command; + + try { + command = new loadedCommand(); + + await command.apply(this); + } catch (error) { + logger.error(`Unable to load '${pkg}' command`); + logger.error(error); + process.exit(2); + } + } + }; + + // Register own exit + this.program.exitOverride(async (error) => { + if (error.exitCode === 0) { + process.exit(0); + } + + if (error.code === 'executeSubCommandAsync') { + process.exit(2); + } + + if (error.code === 'commander.help') { + process.exit(0); + } + + if (error.code === 'commander.unknownOption') { + let name = error.message.match(/'(.+)'/); + + if (name) { + name = name[1].substr(2); + + if (name.includes('=')) { + name = name.split('=')[0]; + } + + const { commandName } = getCommandNameAndOptions(this.program.args); + + if (commandName) { + const command = this.program.commands.find( + (command) => command.name() === commandName || command.alias() === commandName, + ); + + if (!command) { + logger.error(`Can't find and load command '${commandName}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + const found = command.options.find((option) => leven(name, option.long.slice(2)) < 3); + + if (found) { + logger.error(`Did you mean '--${found.name()}'?`); + } + } + } + } + + // Codes: + // - commander.unknownCommand + // - commander.missingArgument + // - commander.missingMandatoryOptionValue + // - commander.optionMissingArgument + + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + }); + + // Default `--color` and `--no-color` options + // TODO doesn't work with `webpack serve` (never work, need fix), `--stats` doesn't work too, other options are fine + let colorFromArguments; + + this.program.option('--color', 'Enable colors on console.'); + this.program.on('option:color', function () { + const { color } = this.opts(); + + colorFromArguments = color; + coloretteOptions.enabled = color; + }); + this.program.option('--no-color', 'Disable colors on console.'); + this.program.on('option:no-color', function () { + const { color } = this.opts(); + + colorFromArguments = color; + coloretteOptions.enabled = color; + }); + + // Make `-v, --version` options + // Make `version|v [commands...]` command + const outputVersion = async (options) => { + // Filter `bundle`, `version` and `help` commands + const possibleCommandNames = options.filter( + (options) => + options !== bundleCommandOptions.name && + options !== bundleCommandOptions.alias && + options !== versionCommandOptions.name && + options !== versionCommandOptions.alias && + options !== helpCommandOptions.name && + options !== helpCommandOptions.alias, + ); + + possibleCommandNames.forEach((possibleCommandName) => { + const isOption = possibleCommandName.startsWith('-'); + + if (!isOption) { + return; + } + + logger.error(`Unknown option '${possibleCommandName}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + }); + + if (possibleCommandNames.length > 0) { + await Promise.all(possibleCommandNames.map((possibleCommand) => loadCommandByName(possibleCommand))); + + for (const possibleCommandName of possibleCommandNames) { + const foundCommand = this.program.commands.find( + (command) => command.name() === possibleCommandName || command.alias() === possibleCommandName, + ); + + try { + const { name, version } = require(`${foundCommand.pkg}/package.json`); + + logger.raw(`${name} ${version}`); + } catch (e) { + logger.error(`Error: External package '${foundCommand.pkg}' not found`); + process.exit(2); + } + } + } + + const pkgJSON = require('../package.json'); + + logger.raw(`webpack ${webpack.version}`); + logger.raw(`webpack-cli ${pkgJSON.version}`); + + if (getPkg('webpack-dev-server')) { + // eslint-disable-next-line node/no-extraneous-require + const { version } = require('webpack-dev-server/package.json'); + + logger.raw(`webpack-dev-server ${version}`); + } + + process.exit(0); + }; + this.program.option( + '-v, --version', + "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", + ); + + // Default global `help` command + const outputHelp = async (options, isVerbose, program) => { + const isGlobal = options.length === 0; + const hideVerboseOptions = (command) => { + command.options = command.options.filter((option) => { + const foundOption = flags.find((flag) => { + if (option.negate && flag.negative) { + return `no-${flag.name}` === option.name(); + } + + return flag.name === option.name(); + }); + + if (foundOption && foundOption.help) { + return foundOption.help === 'minimum'; + } + + return true; + }); + }; + + if (isGlobal) { + const commandsToLoad = [] + .concat(bundleCommandOptions) + .concat(helpCommandOptions) + .concat(versionCommandOptions) + .concat(externalBuiltInCommandsInfo); + + for (const commandToLoad of commandsToLoad) { + await loadCommandByName(commandToLoad.name); + } + + const bundleCommand = this.program.commands.find( + (command) => command.name() === bundleCommandOptions.name || command.alias() === bundleCommandOptions.alias, + ); + + if (!isVerbose) { + hideVerboseOptions(bundleCommand); + } + + let helpInformation = bundleCommand + .helpInformation() + .trimRight() + .replace(bundleCommandOptions.description, 'The build tool for modern web applications.') + .replace( + /Usage:.+/, + 'Usage: webpack [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack bundle --config [options]', + ); + + logger.raw(helpInformation); + } else { + const [name, ...optionsWithoutCommandName] = options; + + optionsWithoutCommandName.forEach((option) => { + logger.error(`Unknown option '${option}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + }); + + await loadCommandByName(name); + + const command = this.program.commands.find((command) => command.name() === name || command.alias() === name); + + if (!command) { + logger.error(`Can't find and load command '${name}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + if (!isVerbose) { + hideVerboseOptions(command); + } + + let helpInformation = command.helpInformation().trimRight(); + + if (name === bundleCommandOptions.name || name === bundleCommandOptions.alias) { + helpInformation = helpInformation + .replace(bundleCommandOptions.description, 'The build tool for modern web applications.') + .replace( + /Usage:.+/, + 'Usage: webpack [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack bundle --config [options]', + ); + } + + logger.raw(helpInformation); + } + + const globalOptions = program.helpInformation().match(/Options:\n(?.+)\nCommands:\n/s); + + if (globalOptions && globalOptions.groups.globalOptions) { + logger.raw('\nGlobal options:'); + logger.raw(globalOptions.groups.globalOptions.trimRight()); + } + + if (isGlobal) { + const globalCommands = program.helpInformation().match(/Commands:\n(?.+)/s); + + logger.raw('\nCommands:'); + logger.raw(globalCommands.groups.globalCommands.trimRight()); + } + + logger.raw("\nTo see list of all supported commands and options run 'webpack --help=verbose'.\n"); + logger.raw('Webpack documentation: https://webpack.js.org/.'); + logger.raw('CLI documentation: https://webpack.js.org/api/cli/.'); + logger.raw(`${bold('Made with ♥ by the webpack team')}.`); + process.exit(0); + }; + this.program.helpOption(false); + this.program.addHelpCommand(false); + this.program.option('-h, --help [verbose]', 'Display help for commands and options.'); + + let isInternalActionCalled = false; + + // Default action + this.program.usage('[options]'); + this.program.allowUnknownOption(true); + this.program.action(async (program) => { + if (!isInternalActionCalled) { + isInternalActionCalled = true; + } else { + logger.error('No commands found to run'); + process.exit(2); + } + + const { commandName, options, isDefault } = getCommandNameAndOptions(program.args); + + const opts = program.opts(); + + if (opts.help || commandName === helpCommandOptions.name || commandName === helpCommandOptions.alias) { + let isVerbose = false; + + if (opts.help) { + if (typeof opts.help === 'string') { + if (opts.help !== 'verbose') { + logger.error("Unknown value for '--help' option, please use '--help=verbose'"); + process.exit(2); + } + + isVerbose = true; + } + } + + const optionsForHelp = [].concat(opts.help && !isDefault ? [commandName] : []).concat(options); + + await outputHelp(optionsForHelp, isVerbose, program); + } + + if (opts.version || commandName === versionCommandOptions.name || commandName === versionCommandOptions.alias) { + const optionsForVersion = [].concat(opts.version ? [commandName] : []).concat(options); + + await outputVersion(optionsForVersion, program); + } + + await loadCommandByName(commandName, true); + + await this.program.parseAsync([commandName, ...options], { from: 'user' }); + }); + + await this.program.parseAsync(args); + } + + async resolveConfig(options) { const loadConfig = async (configPath) => { const ext = extname(configPath); const interpreted = Object.keys(jsVariants).find((variant) => variant === ext); @@ -41,6 +675,7 @@ class WebpackCLI { } let options; + try { try { options = require(configPath); @@ -103,9 +738,9 @@ class WebpackCLI { let config = { options: {}, path: new WeakMap() }; - if (args.config && args.config.length > 0) { + if (options.config && options.config.length > 0) { const evaluatedConfigs = await Promise.all( - args.config.map(async (value) => { + options.config.map(async (value) => { const configPath = resolve(value); if (!existsSync(configPath)) { @@ -115,7 +750,7 @@ class WebpackCLI { const loadedConfig = await loadConfig(configPath); - return evaluateConfig(loadedConfig, args); + return evaluateConfig(loadedConfig, options); }), ); @@ -137,7 +772,6 @@ class WebpackCLI { } else { // Order defines the priority, in increasing order const defaultConfigFiles = ['webpack.config', '.webpack/webpack.config', '.webpack/webpackfile'] - // .filter((value) => value.includes(args.mode)) .map((filename) => // Since .cjs is not available on interpret side add it manually to default config extension list [...Object.keys(extensions), '.cjs'].map((ext) => ({ @@ -159,7 +793,7 @@ class WebpackCLI { if (foundDefaultConfigFile) { const loadedConfig = await loadConfig(foundDefaultConfigFile.path); - const evaluatedConfig = await evaluateConfig(loadedConfig, args); + const evaluatedConfig = await evaluateConfig(loadedConfig, options); config.options = evaluatedConfig.options; @@ -173,10 +807,10 @@ class WebpackCLI { } } - if (args.configName) { + if (options.configName) { const notfoundConfigNames = []; - config.options = args.configName.map((configName) => { + config.options = options.configName.map((configName) => { let found; if (Array.isArray(config.options)) { @@ -200,7 +834,7 @@ class WebpackCLI { } } - if (args.merge) { + if (options.merge) { // we can only merge when there are multiple configurations // either by passing multiple configs by flags or passing a // single config exporting an array @@ -226,9 +860,9 @@ class WebpackCLI { } // TODO refactor - async resolveArguments(config, args) { - if (args.analyze) { - if (!packageExists('webpack-bundle-analyzer')) { + async applyOptions(config, options) { + if (options.analyze) { + if (!getPkg('webpack-bundle-analyzer')) { try { await promptInstallation('webpack-bundle-analyzer', () => { logger.error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); @@ -242,17 +876,17 @@ class WebpackCLI { } } - if (typeof args.progress === 'string' && args.progress !== 'profile') { - logger.error(`'${args.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`); + if (typeof options.progress === 'string' && options.progress !== 'profile') { + logger.error(`'${options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`); process.exit(2); } - if (Object.keys(args).length === 0 && !process.env.NODE_ENV) { + if (Object.keys(options).length === 0 && !process.env.NODE_ENV) { return config; } if (cli) { - const processArguments = (options) => { + const processArguments = (configOptions) => { const coreFlagMap = flags .filter((flag) => flag.group === 'core') .reduce((accumulator, flag) => { @@ -260,111 +894,134 @@ class WebpackCLI { return accumulator; }, {}); - const coreConfig = Object.keys(args).reduce((accumulator, name) => { + const CLIoptions = Object.keys(options).reduce((accumulator, name) => { const kebabName = toKebabCase(name); if (coreFlagMap[kebabName]) { - accumulator[kebabName] = args[name]; + accumulator[kebabName] = options[name]; } return accumulator; }, {}); - const problems = cli.processArguments(coreFlagMap, options, coreConfig); + const problems = cli.processArguments(coreFlagMap, configOptions, CLIoptions); if (problems) { - problems.forEach((problem) => { - logger.error( - `Found the '${problem.type}' problem with the '--${problem.argument}' argument${ - problem.path ? ` by path '${problem.path}'` : '' - }`, - ); - }); + const capitalizeFirstLetter = (string) => { + return string.charAt(0).toUpperCase() + string.slice(1); + }; + const groupBy = (xs, key) => { + return xs.reduce((rv, x) => { + (rv[x[key]] = rv[x[key]] || []).push(x); + + return rv; + }, {}); + }; + const problemsByPath = groupBy(problems, 'path'); + + for (const path in problemsByPath) { + const problems = problemsByPath[path]; + + problems.forEach((problem) => { + logger.error( + `${capitalizeFirstLetter(problem.type.replace(/-/g, ' '))}${ + problem.value ? ` '${problem.value}'` : '' + } for the '--${problem.argument}' option${problem.index ? ` by index '${problem.index}'` : ''}`, + ); + + if (problem.expected) { + logger.error(`Expected: '${problem.expected}'`); + } + }); + } process.exit(2); } - return options; + return configOptions; }; config.options = Array.isArray(config.options) ? config.options.map((options) => processArguments(options)) : processArguments(config.options); - } - - const setupDefaultOptions = (options) => { - // No need to run for webpack@4 - if (cli && options.cache && options.cache.type === 'filesystem') { - const configPath = config.path.get(options); - if (configPath) { - if (!options.cache.buildDependencies) { - options.cache.buildDependencies = {}; - } - - if (!options.cache.buildDependencies.config) { - options.cache.buildDependencies.config = []; - } - - if (Array.isArray(configPath)) { - configPath.forEach((item) => { - options.cache.buildDependencies.config.push(item); - }); - } else { - options.cache.buildDependencies.config.push(configPath); + const setupDefaultOptions = (configOptions) => { + // No need to run for webpack@4 + if (configOptions.cache && configOptions.cache.type === 'filesystem') { + const configPath = config.path.get(configOptions); + + if (configPath) { + if (!configOptions.cache.buildDependencies) { + configOptions.cache.buildDependencies = {}; + } + + if (!configOptions.cache.buildDependencies.defaultConfig) { + configOptions.cache.buildDependencies.defaultConfig = []; + } + + if (Array.isArray(configPath)) { + configPath.forEach((item) => { + configOptions.cache.buildDependencies.defaultConfig.push(item); + }); + } else { + configOptions.cache.buildDependencies.defaultConfig.push(configPath); + } } } - } - return options; - }; + return configOptions; + }; - config.options = Array.isArray(config.options) - ? config.options.map((options) => setupDefaultOptions(options)) - : setupDefaultOptions(config.options); + config.options = Array.isArray(config.options) + ? config.options.map((options) => setupDefaultOptions(options)) + : setupDefaultOptions(config.options); + } // Logic for webpack@4 // TODO remove after drop webpack@4 - const processLegacyArguments = (options) => { - if (args.entry) { - options.entry = args.entry; + const processLegacyArguments = (configOptions) => { + if (options.entry) { + configOptions.entry = options.entry; } - if (args.outputPath) { - options.output = { ...options.output, ...{ path: path.resolve(args.outputPath) } }; + if (options.outputPath) { + configOptions.output = { + ...configOptions.output, + ...{ path: path.resolve(options.outputPath) }, + }; } - if (args.target) { - options.target = args.target; + if (options.target) { + configOptions.target = options.target; } - if (typeof args.devtool !== 'undefined') { - options.devtool = args.devtool; + if (typeof options.devtool !== 'undefined') { + configOptions.devtool = options.devtool; } - if (args.mode) { - options.mode = args.mode; + if (options.mode) { + configOptions.mode = options.mode; } else if ( - !options.mode && + !configOptions.mode && process.env && process.env.NODE_ENV && (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'node') ) { - options.mode = process.env.NODE_ENV; + configOptions.mode = process.env.NODE_ENV; } - if (args.name) { - options.name = args.name; + if (options.name) { + configOptions.name = options.name; } - if (typeof args.stats !== 'undefined') { - options.stats = args.stats; + if (typeof options.stats !== 'undefined') { + configOptions.stats = options.stats; } - if (typeof args.watch !== 'undefined') { - options.watch = args.watch; + if (typeof options.watch !== 'undefined') { + configOptions.watch = options.watch; } - return options; + return configOptions; }; config.options = Array.isArray(config.options) @@ -374,24 +1031,24 @@ class WebpackCLI { return config; } - async resolveCLIPlugin(config, args) { - const addCLIPlugin = (options) => { - if (!options.plugins) { - options.plugins = []; + async applyCLIPlugin(config, options) { + const addCLIPlugin = (configOptions) => { + if (!configOptions.plugins) { + configOptions.plugins = []; } - options.plugins.unshift( + configOptions.plugins.unshift( new CLIPlugin({ configPath: config.path, - helpfulOutput: !args.json, - hot: args.hot, - progress: args.progress, - prefetch: args.prefetch, - analyze: args.analyze, + helpfulOutput: !options.json, + hot: options.hot, + progress: options.progress, + prefetch: options.prefetch, + analyze: options.analyze, }), ); - return options; + return configOptions; }; config.options = Array.isArray(config.options) @@ -401,67 +1058,55 @@ class WebpackCLI { return config; } - async resolve(parsedArgs) { - let config = await this.resolveConfig(parsedArgs); - - config = await this.resolveArguments(config, parsedArgs); - config = await this.resolveCLIPlugin(config, parsedArgs); + async createCompiler(options, callback) { + const isValidationError = (error) => { + // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 + // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 + const ValidationError = webpack.ValidationError || webpack.WebpackOptionsValidationError; - return config; - } - - /** - * Expose commander argParser - * @param {...any} args args for argParser - */ - argParser(...args) { - return argParser(...args); - } - - getCoreFlags() { - return flags; - } + return error instanceof ValidationError; + }; - handleError(error) { - // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 - // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 - const ValidationError = webpack.ValidationError || webpack.WebpackOptionsValidationError; + let config = await this.resolveConfig(options); - // In case of schema errors print and exit process - // For webpack@4 and webpack@5 - if (error instanceof ValidationError) { - logger.error(error.message); - } else { - logger.error(error); - } - } + config = await this.applyOptions(config, options); + config = await this.applyCLIPlugin(config, options); - createCompiler(options, callback) { let compiler; try { - compiler = webpack(options, callback); + compiler = webpack( + config.options, + callback + ? (error, stats) => { + if (isValidationError(error)) { + logger.error(error.message); + process.exit(2); + } + + callback(error, stats); + } + : callback, + ); } catch (error) { - this.handleError(error); + if (isValidationError(error)) { + logger.error(error.message); + } else { + logger.error(error); + } + process.exit(2); } return compiler; } - async getCompiler(args) { - // TODO test with serve - const config = await this.resolve(args); - - return this.createCompiler(config.options); - } - - async run(args) { + async bundleCommand(options) { let compiler; const callback = (error, stats) => { if (error) { - this.handleError(error); + logger.error(error); process.exit(2); } @@ -481,9 +1126,9 @@ class WebpackCLI { let colors; - // From flags - if (typeof args.color !== 'undefined') { - colors = args.color; + // From arguments + if (typeof options.color !== 'undefined') { + colors = options.color; } // From stats else if (typeof stats.colors !== 'undefined') { @@ -513,18 +1158,18 @@ class WebpackCLI { process.exit(2); }; - if (args.json === true) { + if (options.json === true) { createJsonStringifyStream(stats.toJson(foundStats)) .on('error', handleWriteError) .pipe(process.stdout) .on('error', handleWriteError) .on('close', () => process.stdout.write('\n')); - } else if (typeof args.json === 'string') { + } else if (typeof options.json === 'string') { createJsonStringifyStream(stats.toJson(foundStats)) .on('error', handleWriteError) - .pipe(createWriteStream(args.json)) + .pipe(createWriteStream(options.json)) .on('error', handleWriteError) - .on('close', () => logger.success(`stats are successfully stored as json to ${args.json}`)); + .on('close', () => logger.success(`stats are successfully stored as json to ${options.json}`)); } else { const printedStats = stats.toString(foundStats); @@ -535,16 +1180,14 @@ class WebpackCLI { } }; - const config = await this.resolve(args); + options.env = { WEBPACK_BUNDLE: true, ...options.env }; - compiler = this.createCompiler(config.options, callback); + compiler = await this.createCompiler(options, callback); // TODO webpack@4 return Watching and MultiWathing instead Compiler and MultiCompiler, remove this after drop webpack@4 if (compiler && compiler.compiler) { compiler = compiler.compiler; } - - return Promise.resolve(); } } diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 75bafaf5d32..edb1166d5d8 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -31,7 +31,6 @@ "@webpack-cli/info": "^1.1.0", "@webpack-cli/serve": "^1.1.0", "colorette": "^1.2.1", - "command-line-usage": "^6.1.0", "commander": "^6.2.0", "enquirer": "^2.3.6", "execa": "^4.1.0", diff --git a/test/analyze/analyze-flag.test.js b/test/analyze/analyze-flag.test.js index 972a00223eb..9f86a3dc3c8 100644 --- a/test/analyze/analyze-flag.test.js +++ b/test/analyze/analyze-flag.test.js @@ -1,5 +1,6 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); const { run, runAndGetWatchProc } = require('../utils/test-utils'); describe('--analyze flag', () => { @@ -23,7 +24,7 @@ describe('--analyze flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Webpack Bundle Analyzer saved report to'); - expect(stdout.match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); + expect(stripAnsi(stdout)).toContain('Webpack Bundle Analyzer saved report to'); + expect(stripAnsi(stdout).match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); }); }); diff --git a/test/bail/bail-and-watch-webpack.config.js b/test/bail/bail-and-watch-webpack.config.js index 132930c4f13..85d95542909 100644 --- a/test/bail/bail-and-watch-webpack.config.js +++ b/test/bail/bail-and-watch-webpack.config.js @@ -1,5 +1,6 @@ module.exports = { entry: './src/first.js', + devtool: false, mode: 'development', bail: true, watch: true, diff --git a/test/bail/bail-multi-webpack.config.js b/test/bail/bail-multi-webpack.config.js index c8ee4390baf..d36a8ba9fe3 100644 --- a/test/bail/bail-multi-webpack.config.js +++ b/test/bail/bail-multi-webpack.config.js @@ -1,5 +1,6 @@ module.exports = [ { + devtool: false, output: { filename: './dist-first.js', }, @@ -9,11 +10,12 @@ module.exports = [ bail: true, }, { + devtool: false, output: { filename: './dist-second.js', }, name: 'second', entry: './src/second.js', - mode: 'production', + mode: 'development', }, ]; diff --git a/test/bail/bail-webpack.config.js b/test/bail/bail-webpack.config.js index b0b7ac2f33c..d3f445c8782 100644 --- a/test/bail/bail-webpack.config.js +++ b/test/bail/bail-webpack.config.js @@ -1,4 +1,5 @@ module.exports = { + devtool: false, entry: './src/first.js', mode: 'development', bail: true, diff --git a/test/bail/multi-webpack.config.js b/test/bail/multi-webpack.config.js index 1c13ab36f2d..b36638f118f 100644 --- a/test/bail/multi-webpack.config.js +++ b/test/bail/multi-webpack.config.js @@ -1,5 +1,6 @@ module.exports = [ { + devtool: false, output: { filename: './dist-first.js', }, @@ -10,11 +11,12 @@ module.exports = [ watch: true, }, { + devtool: false, output: { filename: './dist-second.js', }, name: 'second', entry: './src/second.js', - mode: 'production', + mode: 'development', }, ]; diff --git a/test/bail/no-bail-webpack.config.js b/test/bail/no-bail-webpack.config.js index 6b70bf3cf22..8cf031757bd 100644 --- a/test/bail/no-bail-webpack.config.js +++ b/test/bail/no-bail-webpack.config.js @@ -1,4 +1,5 @@ module.exports = { + devtool: false, entry: './src/first.js', mode: 'development', }; diff --git a/test/bail/watch-webpack.config.js b/test/bail/watch-webpack.config.js index 447c8d35986..fa93f3f225b 100644 --- a/test/bail/watch-webpack.config.js +++ b/test/bail/watch-webpack.config.js @@ -1,4 +1,5 @@ module.exports = { + devtool: false, entry: './src/first.js', mode: 'development', watch: true, diff --git a/test/bundle/basic/basic.test.js b/test/bundle/basic/basic.test.js new file mode 100644 index 00000000000..595d09863f8 --- /dev/null +++ b/test/bundle/basic/basic.test.js @@ -0,0 +1,41 @@ +'use strict'; + +const { run } = require('../../utils/test-utils'); + +describe('bundle command', () => { + it('should work', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with alias', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['b'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should log error with multi commands', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', 'info'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Running multiple commands at the same time is not possible'); + expect(stderr).toContain("Found commands: 'bundle', 'info'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error with multi commands', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['b', 'i'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Running multiple commands at the same time is not possible'); + expect(stderr).toContain("Found commands: 'bundle', 'i'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/packages/webpack-cli/__tests__/serve/src/index.js b/test/bundle/basic/src/index.js similarity index 100% rename from packages/webpack-cli/__tests__/serve/src/index.js rename to test/bundle/basic/src/index.js diff --git a/test/bundle/bundle-variable/bundle-variable.test.js b/test/bundle/bundle-variable/bundle-variable.test.js new file mode 100644 index 00000000000..8458e95e483 --- /dev/null +++ b/test/bundle/bundle-variable/bundle-variable.test.js @@ -0,0 +1,13 @@ +'use strict'; + +const { run } = require('../../utils/test-utils'); + +describe('bundle variable', () => { + it('compiles without flags and export variable', async () => { + const { exitCode, stderr, stdout } = run(__dirname, [], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('PASS'); + }); +}); diff --git a/test/bundle/bundle-variable/src/index.js b/test/bundle/bundle-variable/src/index.js new file mode 100644 index 00000000000..6be02374db1 --- /dev/null +++ b/test/bundle/bundle-variable/src/index.js @@ -0,0 +1 @@ +console.log('hello world'); diff --git a/test/bundle/bundle-variable/webpack.config.js b/test/bundle/bundle-variable/webpack.config.js new file mode 100644 index 00000000000..574cefc527c --- /dev/null +++ b/test/bundle/bundle-variable/webpack.config.js @@ -0,0 +1,24 @@ +const isInProcess = process.env.WEBPACK_BUNDLE; + +class CustomTestPlugin { + constructor(isInEnvironment) { + this.isInEnvironment = isInEnvironment; + } + apply(compiler) { + compiler.hooks.done.tap('testPlugin', () => { + if (!isInProcess && this.isInEnvironment) { + console.log('PASS'); + } else { + console.log('FAIL'); + } + }); + } +} + +module.exports = (env) => { + return { + mode: 'development', + devtool: false, + plugins: [new CustomTestPlugin(env.WEBPACK_BUNDLE)], + }; +}; diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index f0898708ce1..7247ead765c 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -41,9 +41,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - console.log(stderr); expect(stderr.match(/No pack exists at/g)).toHaveLength(2); - expect(stderr.match(/Stored pack/g)).toHaveLength(2); + // TODO buggy + // expect(stderr.match(/Stored pack/g)).toHaveLength(2); expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } diff --git a/test/colors/colors-false.webpack.config.js b/test/colors/colors-false.webpack.config.js index ca20696f2e3..048815fb07d 100644 --- a/test/colors/colors-false.webpack.config.js +++ b/test/colors/colors-false.webpack.config.js @@ -2,5 +2,5 @@ module.exports = { stats: { colors: false, }, - mode: 'production', + mode: 'development', }; diff --git a/test/colors/colors-true.webpack.config.js b/test/colors/colors-true.webpack.config.js index 76255bff92d..21995734c9e 100644 --- a/test/colors/colors-true.webpack.config.js +++ b/test/colors/colors-true.webpack.config.js @@ -2,5 +2,5 @@ module.exports = { stats: { colors: true, }, - mode: 'production', + mode: 'development', }; diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 31f3d7e88c9..52d842821b5 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -132,7 +132,7 @@ describe('colors related tests', () => { expect(stdout).toContain(output); }); - it('should work in multicompiler mode', () => { + it('should work in multi compiler mode', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=multiple-configs.js', '--color']); expect(exitCode).toBe(0); diff --git a/test/colors/multiple-configs.js b/test/colors/multiple-configs.js index 0828c36394a..75a5ac19fd2 100644 --- a/test/colors/multiple-configs.js +++ b/test/colors/multiple-configs.js @@ -3,12 +3,12 @@ module.exports = [ name: 'first-config', entry: './src/first.js', stats: 'normal', - mode: 'production', + mode: 'development', }, { name: 'second-config', entry: './src/second.js', stats: 'normal', - mode: 'production', + mode: 'development', }, ]; diff --git a/test/colors/no-stats.webpack.config.js b/test/colors/no-stats.webpack.config.js index 71af9d200a9..8b2d7eb877e 100644 --- a/test/colors/no-stats.webpack.config.js +++ b/test/colors/no-stats.webpack.config.js @@ -1,4 +1,4 @@ module.exports = { name: 'test', - mode: 'production', + mode: 'development', }; diff --git a/test/colors/stats-boolean.webpack.config.js b/test/colors/stats-boolean.webpack.config.js index 9f947b31986..4b5a5355c76 100644 --- a/test/colors/stats-boolean.webpack.config.js +++ b/test/colors/stats-boolean.webpack.config.js @@ -1,4 +1,4 @@ module.exports = { stats: true, - mode: 'production', + mode: 'development', }; diff --git a/test/colors/stats-string.webpack.config.js b/test/colors/stats-string.webpack.config.js index d3712a1cf09..f539326edb7 100644 --- a/test/colors/stats-string.webpack.config.js +++ b/test/colors/stats-string.webpack.config.js @@ -1,4 +1,4 @@ module.exports = { stats: 'verbose', - mode: 'production', + mode: 'development', }; diff --git a/test/colors/webpack.config.js b/test/colors/webpack.config.js index 5b69c702150..f2c3976d5d3 100644 --- a/test/colors/webpack.config.js +++ b/test/colors/webpack.config.js @@ -1,3 +1,3 @@ module.exports = { - mode: 'production', + mode: 'development', }; diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index 0c5d24e749a..c4ee065e975 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -10,7 +10,7 @@ describe('function configuration', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(stdout).toContain("argv: { mode: 'development' }"); + expect(stdout).toContain("{ argv: { mode: 'development', env: { WEBPACK_BUNDLE: true } } }"); expect(existsSync(resolve(__dirname, './dist/dev.js'))); }); }); diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index 359df2f24a1..d498a5d582a 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -7,8 +7,7 @@ describe('function configuration', () => { it('should throw when env is not supplied', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env'], false); - // TODO Bug, need to fix - expect(exitCode).toBe(1); + expect(exitCode).toBe(2); expect(stderr).toContain(`option '--env ' argument missing`); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/context-flag.test.js b/test/core-flags/context-flag.test.js index bac4667b0f9..df4050e94a7 100644 --- a/test/core-flags/context-flag.test.js +++ b/test/core-flags/context-flag.test.js @@ -12,9 +12,9 @@ describe('--context flag', () => { if (isWindows) { const windowsPath = resolve(__dirname, './').replace(/\\/g, '\\\\'); - expect(stdout).toContain(`context: '${windowsPath}'`); + expect(stdout).toContain(`'${windowsPath}'`); } else { - expect(stdout).toContain(`context: '${resolve(__dirname, './')}'`); + expect(stdout).toContain(`'${resolve(__dirname, './')}'`); } }); diff --git a/test/core-flags/invalid-flag.test.js b/test/core-flags/invalid-flag.test.js index c7233f9c03d..23efe7269b0 100644 --- a/test/core-flags/invalid-flag.test.js +++ b/test/core-flags/invalid-flag.test.js @@ -7,7 +7,8 @@ describe('invalid flag value', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-script-type', 'unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("Found the 'invalid-value' problem with the '--output-script-type' argument by path 'output.scriptType'"); + expect(stderr).toContain("Invalid value 'unknown' for the '--output-script-type' option"); + expect(stderr).toContain("Expected: 'false | text/javascript | module'"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index 22510b4849b..b166f248c63 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -57,34 +57,36 @@ describe('module config related flag', () => { if (flag.type === String) { it(`should config --${flag.name} correctly`, () => { - let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'value']); - if (flag.name === 'module-no-parse') { + let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'value']); + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('value'); } else if (flag.name.includes('reg-exp')) { - ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, '/ab?c*/'])); + let { stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, '/ab?c*/']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: /ab?c*/`); } else if (flag.name.includes('module-rules-')) { - ({ stdout } = run(__dirname, [`--${flag.name}`, 'javascript/auto'])); - if (propName === 'use' || propName === 'type') { + let { stdout } = run(__dirname, [`--${flag.name}`, 'javascript/auto']); + expect(stdout).toContain(`${propName}: 'javascript/auto'`); } else if (property.includes('use-')) { - stdout = run(__dirname, ['--module-rules-use-loader', 'myLoader']).stdout; + let stdout = run(__dirname, ['--module-rules-use-loader', 'myLoader']).stdout; expect(stdout).toContain(`use: [Object]`); } else if (propName === 'enforce') { - stdout = run(__dirname, [`--${flag.name}`, 'pre', '--module-rules-use-loader', 'myLoader']).stdout; + let stdout = run(__dirname, [`--${flag.name}`, 'pre', '--module-rules-use-loader', 'myLoader']).stdout; expect(stdout).toContain(`${propName}: 'pre'`); } else { - stdout = run(__dirname, [`--${flag.name}`, '/rules-value']).stdout; + let stdout = run(__dirname, [`--${flag.name}`, '/rules-value']).stdout; expect(stdout).toContain('rules-value'); } } else { + let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'value']); + expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'value'`); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index 555ca1204b4..71f83302c7e 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -27,7 +27,7 @@ describe('output flag defaults', () => { it('throw error on empty output flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js', '--output-path'], false); - expect(exitCode).toBe(1); + expect(exitCode).toBe(2); expect(stderr).toContain("error: option '-o, --output-path ' argument missing"); expect(stdout).toBeFalsy(); }); diff --git a/test/entry/config-entry/entry-with-command/entry-with-command.test.js b/test/entry/config-entry/entry-with-command/entry-with-command.test.js deleted file mode 100644 index 2cd0595f3f9..00000000000 --- a/test/entry/config-entry/entry-with-command/entry-with-command.test.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; -const { existsSync } = require('fs'); -const { resolve } = require('path'); -const { run } = require('../../../utils/test-utils'); - -describe('config entry and command entry all exist', () => { - it('should use command entry if config command existed', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js', './index.js'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('./index.js'); - expect(existsSync(resolve(__dirname, './binary/main.bundle.js'))).toBeTruthy(); - }); -}); diff --git a/test/entry/config-entry/entry-with-command/index.js b/test/entry/config-entry/entry-with-command/index.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/entry/multiple-entries/multi-entries.test.js b/test/entry/multiple-entries/multi-entries.test.js index 339a21786bc..6d236139a38 100644 --- a/test/entry/multiple-entries/multi-entries.test.js +++ b/test/entry/multiple-entries/multi-entries.test.js @@ -5,21 +5,6 @@ const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); describe(' multiple entries', () => { - it('should allow multiple entry files', (done) => { - const { exitCode, stderr, stdout } = run(__dirname, ['./src/a.js', './src/b.js']); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(data).toContain('Hello from a.js'); - expect(data).toContain('Hello from b.js'); - done(); - }); - }); - it('should allow multiple entry flags', (done) => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/a.js', '--entry', './src/b.js']); diff --git a/test/help/help-commands.test.js b/test/help/help-commands.test.js deleted file mode 100644 index 89beb0bd0b4..00000000000 --- a/test/help/help-commands.test.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); - -describe('commands help', () => { - it('log help for subcommands', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'help'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack s | serve'); - }); - - it('log help information with subcommands as an arg', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve'], false); - - expect(exitCode).toBe(0); - expect(stdout).toContain('webpack s | serve'); - expect(stderr).toHaveLength(0); - }); - - it('log error for invalid command with --help flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'myCommand'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain("Invalid command 'myCommand'."); - expect(stderr).toContain('Run webpack --help to see available commands and arguments.'); - expect(stdout).toHaveLength(0); - }); - - it('log error for invalid command with help command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'myCommand'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain("Invalid command 'myCommand'."); - expect(stderr).toContain('Run webpack --help to see available commands and arguments.'); - expect(stdout).toHaveLength(0); - }); - - it('log error for multiple commands', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'init', 'info'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain("You provided multiple commands or arguments - command 'init' (alias 'c'), command 'info' (alias 'i')."); - expect(stdout).toHaveLength(0); - }); -}); diff --git a/test/help/help-flags.test.js b/test/help/help-flags.test.js deleted file mode 100644 index fdaf9feeacb..00000000000 --- a/test/help/help-flags.test.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); - -describe('commands help', () => { - it('log error for invalid flag with --help flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--my-flag'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`Invalid option '--my-flag'`); - expect(stderr).toContain(`Run webpack --help to see available commands and arguments.`); - expect(stdout).toHaveLength(0); - }); - - it('log error for invalid flag with help command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--my-flag'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`Invalid option '--my-flag'.`); - expect(stderr).toContain(`Run webpack --help to see available commands and arguments.`); - expect(stdout).toHaveLength(0); - }); - - it('log flag help with valid flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--merge'], false); - - expect(exitCode).toBe(0); - expect(stdout).not.toContain('The build tool for modern web applications'); - expect(stdout).toContain('webpack -m, --config --config --merge'); - expect(stderr).toHaveLength(0); - }); - - it('log show help for --mode', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--mode', '--help'], false); - - expect(exitCode).toBe(0); - expect(stdout).not.toContain('The build tool for modern web applications'); - expect(stdout).toContain('webpack --mode '); - expect(stdout).toContain('Defines the mode to pass to webpack'); - expect(stderr).toHaveLength(0); - }); - - it('log error for multiple flags', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--entry', '--merge'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain( - `You provided multiple commands or arguments - argument '--merge' (alias '-m'), argument '--entry'. Please use only one command at a time.`, - ); - expect(stdout).toHaveLength(0); - }); -}); diff --git a/test/help/help-multi-args.test.js b/test/help/help-multi-args.test.js deleted file mode 100644 index 07fa8d1b744..00000000000 --- a/test/help/help-multi-args.test.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); -const { commands } = require('../../packages/webpack-cli/lib/utils/cli-flags'); -const helpHeader = 'The build tool for modern web applications'; - -describe('help cmd with multiple arguments', () => { - commands.forEach((cmd) => { - it(`shows cmd help with ${cmd.name}`, () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', `${cmd.name}`], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).not.toContain(helpHeader); - expect(stdout).toContain(`${cmd.name}`); - expect(stdout).toContain(`${cmd.usage}`); - expect(stdout).toContain(`${cmd.description}`); - }); - }); - - it('should output help for --version by taking precedence', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).not.toContain(helpHeader); - expect(stdout).toContain('webpack -v, --version'); - }); -}); diff --git a/test/help/help-single-arg.test.js b/test/help/help-single-arg.test.js deleted file mode 100644 index afd7435fba3..00000000000 --- a/test/help/help-single-arg.test.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -const { yellow, options } = require('colorette'); -const { run } = require('../utils/test-utils'); -const helpHeader = 'The build tool for modern web applications'; - -describe('single help flag', () => { - it('respects --no-color flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--no-color'], false); - const usage = 'webpack [...options] | '; - const example = 'webpack help --flag | '; - options.enabled = true; - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).not.toContain(yellow(usage)); - expect(stdout).not.toContain(yellow(example)); - expect(stdout).toContain(usage); - expect(stdout).toContain(example); - }); - - it('outputs basic help info with command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(helpHeader); - }); - - it('outputs basic help info with dashed syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(helpHeader); - expect(stdout).toContain('--merge'); - expect(stdout).not.toContain('--config-name'); // verbose - }); - - it('outputs advanced help info with dashed syntax', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help', 'verbose'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(helpHeader); - expect(stdout).toContain('--config-name'); // verbose - expect(stdout).toContain('--config'); // base - }); - - it('outputs advanced help info with command syntax', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['help', 'verbose'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(helpHeader); - expect(stdout).toContain('--config-name'); // verbose - expect(stdout).toContain('--config'); // base - }); - - it('outputs advanced help info with --help=verbose', () => { - const { stdout, stderr, exitCode } = run(__dirname, ['--help=verbose'], false); - - expect(exitCode).toBe(0); - expect(stdout).toContain(helpHeader); - expect(stdout).toContain('--config-name'); // verbose - expect(stdout).toContain('--config'); // base - expect(stderr).toBeFalsy(); - }); -}); diff --git a/test/help/help.test.js b/test/help/help.test.js new file mode 100644 index 00000000000..35c4c568acb --- /dev/null +++ b/test/help/help.test.js @@ -0,0 +1,252 @@ +'use strict'; + +const stripAnsi = require('strip-ansi'); +const { bold, enabled: coloretteEnabled } = require('colorette'); +const { run, isWebpack5 } = require('../utils/test-utils'); + +const helpDefaultHeader = 'The build tool for modern web applications.'; + +describe('help', () => { + it('should show help information using the "--help" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + // TODO buggy on windows + // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + }); + + it.skip('should show help information using the "--help" option with the "verbose" value', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'verbose'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + + if (isWebpack5) { + expect(stdout).toContain('--cache-type'); // verbose + } + + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + }); + + it.skip('should show help information using the "--help" option with the "verbose" value #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help=verbose'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + + if (isWebpack5) { + expect(stdout).toContain('--cache-type'); // verbose + } + + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + }); + + it('should show help information using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + // TODO buggy on windows + // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + }); + + it('should show the same information using the "--help" option and command syntax', () => { + const { exitCode: exitCodeFromOption, stderr: stderrFromOption, stdout: stdoutFromOption } = run(__dirname, ['--help'], false); + const { exitCode: exitCodeFromCommandSyntax, stderr: stderrFromCommandSyntax, stdout: stdoutFromCommandSyntax } = run( + __dirname, + ['help'], + false, + ); + + expect(exitCodeFromOption).toBe(0); + expect(exitCodeFromCommandSyntax).toBe(0); + expect(stderrFromOption).toBeFalsy(); + expect(stderrFromCommandSyntax).toBeFalsy(); + expect(stdoutFromOption).toBe(stdoutFromCommandSyntax); + }); + + it('should show help information and respect the "--color" flag using the "--help" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); + }); + + it('should show help information and respect the "--no-color" flag using the "--help" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--no-color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + // TODO bug in tests + // expect(stdout).not.toContain(bold('Made with ♥ by the webpack team')); + expect(stdout).toContain('Made with ♥ by the webpack team'); + }); + + const commands = ['bundle', 'loader', 'plugin', 'info', 'init', 'migrate', 'serve']; + + commands.forEach((command) => { + it(`should show help information for '${command}' command using the "--help" option`, () => { + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + }); + + it(`should show help information for '${command}' command using command syntax`, () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', command], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + }); + + it('should show help information and respect the "--color" flag using the "--help" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + expect(stdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); + }); + + it('should show help information and respect the "--no-color" flag using the "--help" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--no-color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + // TODO bug in tests + // expect(stdout).not.toContain(bold('Made with ♥ by the webpack team')); + expect(stdout).toContain('Made with ♥ by the webpack team'); + }); + }); + + it('should show help information with options for sub commands', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--help'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack info|i [options]'); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--output '); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team'); + }); + + it('should show help information and taking precedence when "--help" and "--verison" option using together', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + // TODO buggy on windows + // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + }); + + it('should log error for invalid command using the "--help" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'myCommand'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown value for '--help' option, please use '--help=verbose'"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for invalid command using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'myCommand'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'myCommand'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for invalid command using command syntax #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'verbose'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'verbose'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for invalid flag with the "--help" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--my-flag'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown option '--my-flag'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for invalid flag with the "--help" option #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'init', 'info'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown value for '--help' option, please use '--help=verbose'"); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/hot/hot-flag.test.js b/test/hot/hot-flag.test.js index 361c1dfe9ab..d029a66fff0 100644 --- a/test/hot/hot-flag.test.js +++ b/test/hot/hot-flag.test.js @@ -13,14 +13,12 @@ describe('--hot flag', () => { expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); }); - it('should warn when --hot and --no-hot both are passed', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot', '--hot']); + it('should be successful when --no-hot is passed', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot']); expect(exitCode).toBe(0); - expect(stderr).toContain( - 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', - ); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); + expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).not.toContain('webpackHotUpdate'); }); }); diff --git a/test/hot/webpack.config.js b/test/hot/webpack.config.js index f2c3976d5d3..37c48e745b2 100644 --- a/test/hot/webpack.config.js +++ b/test/hot/webpack.config.js @@ -1,3 +1,4 @@ module.exports = { mode: 'development', + stats: 'verbose', }; diff --git a/test/info/info-help.test.js b/test/info/info-help.test.js deleted file mode 100644 index 5511133bb4a..00000000000 --- a/test/info/info-help.test.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -const { green } = require('colorette'); -const { runInfo } = require('../utils/test-utils'); -const { commands } = require('../../packages/webpack-cli/lib/utils/cli-flags'); - -const infoFlags = commands.find((c) => c.name === 'info').flags; - -const usageText = 'webpack i | info [options]'; -const descriptionText = 'Outputs information about your system and dependencies'; - -describe('should print help for info command', () => { - it('shows usage information on supplying help flag', () => { - const { exitCode, stderr, stdout } = runInfo(['--help'], __dirname); - - expect(exitCode).toBe(0); - expect(stdout).toContain(usageText); - expect(stdout).toContain(descriptionText); - expect(stderr).toHaveLength(0); - }); - - it.skip('should work and respect the --no-color flag', () => { - const { exitCode, stderr, stdout } = runInfo(['--help', '--no-color'], __dirname); - - expect(exitCode).toBe(0); - expect(stdout).not.toContain(green(usageText)); - expect(stdout).toContain(descriptionText); - expect(stderr).toHaveLength(0); - }); - - it('should output all cli flags', () => { - const { exitCode, stderr, stdout } = runInfo(['--help'], __dirname); - - infoFlags.forEach((flag) => expect(stdout).toContain(`--${flag.name}`)); - expect(stderr).toHaveLength(0); - expect(exitCode).toBe(0); - }); -}); diff --git a/test/info/info-output.test.js b/test/info/info-output.test.js index 1587bcd611c..88f420f4f7e 100644 --- a/test/info/info-output.test.js +++ b/test/info/info-output.test.js @@ -1,38 +1,39 @@ 'use strict'; -const { red } = require('colorette'); const { join } = require('path'); -const { runInfo } = require('../utils/test-utils'); +const { run } = require('../utils/test-utils'); describe('basic info usage', () => { it('gets info without flags', () => { - const { stdout, stderr } = runInfo([], __dirname); - // stdout should include many details which will be - // unique for each computer + const { exitCode, stdout, stderr } = run(__dirname, ['info'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('System:'); expect(stdout).toContain('Node'); expect(stdout).toContain('npm'); expect(stdout).toContain('Yarn'); - expect(stderr).toHaveLength(0); }); it('gets more info in project root', () => { - const { stdout, stderr } = runInfo([], join(__dirname, '../../')); - // stdout should include many details which will be - // unique for each computer + const { exitCode, stderr, stdout } = run(join(__dirname, '../../'), ['info'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('System:'); expect(stdout).toContain('Monorepos:'); expect(stdout).toContain('Packages:'); expect(stdout).toContain('Node'); expect(stdout).toContain('npm'); expect(stdout).toContain('Yarn'); - expect(stderr).toHaveLength(0); }); it('gets info as json', () => { - const { stdout, stderr } = runInfo(['--output="json"'], __dirname); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--output=json'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('"System":'); - expect(stderr).toHaveLength(0); const parse = () => { const output = JSON.parse(stdout); @@ -46,16 +47,18 @@ describe('basic info usage', () => { }); it('gets info as markdown', () => { - const { stdout, stderr } = runInfo(['--output="markdown"'], __dirname); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--output', 'markdown'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain('## System:'); - expect(stderr).toHaveLength(0); }); it('shows a warning if an invalid value is supplied', () => { - const { exitCode, stderr, stdout } = runInfo(['--output=unknown'], __dirname); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--output', 'unknown'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] ${red(`'unknown' is not a valid value for output`)}`); + expect(stderr).toContain(`'unknown' is not a valid value for output`); expect(stdout).toBeFalsy(); }); }); diff --git a/test/info/info-unknown.test.js b/test/info/info-unknown.test.js index 2451331bf30..545e4d71a55 100644 --- a/test/info/info-unknown.test.js +++ b/test/info/info-unknown.test.js @@ -1,12 +1,11 @@ -const { red } = require('colorette'); -const { runInfo } = require('../utils/test-utils'); +const { run } = require('../utils/test-utils'); describe('should handle unknown args', () => { it('shows an appropriate warning on supplying unknown args', () => { - const { exitCode, stderr, stdout } = runInfo(['--unknown'], __dirname); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--unknown'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] ${red('Unknown argument: --unknown')}`); + expect(stderr).toContain("unknown option '--unknown'"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 4cfebb86c95..c6dae9e4316 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -1,13 +1,12 @@ -'use strict'; - const { green } = require('colorette'); const fs = require('fs'); +const path = require('path'); const rimraf = require('rimraf'); const { join, resolve } = require('path'); const { run } = require('../../utils/test-utils'); +const genPath = path.resolve(__dirname, './test-assets'); const firstPrompt = 'Will your application have multiple bundles?'; -const genPath = join(__dirname, 'test-assets'); const successLog = `You can now run ${green('yarn build')} to bundle your application!`; diff --git a/test/init/coreFlags/init-flags.test.js b/test/init/coreFlags/init-flags.test.js index d9234cacb4d..4f26e95b3e1 100644 --- a/test/init/coreFlags/init-flags.test.js +++ b/test/init/coreFlags/init-flags.test.js @@ -12,6 +12,7 @@ describe('init with core flags', () => { expect(stdout).not.toContain(firstPrompt); expect(stdout).toContain('Initialize a new webpack configuration'); }); + it('should throw error with invalid scaffolder package', () => { const { stdout, stderr } = run(__dirname, ['init', 'webpack-rocks'], false); diff --git a/test/invalid-schema/invalid-schema.test.js b/test/invalid-schema/invalid-schema.test.js index 52cd44bebde..bfea3e8e5e1 100644 --- a/test/invalid-schema/invalid-schema.test.js +++ b/test/invalid-schema/invalid-schema.test.js @@ -16,7 +16,8 @@ describe('invalid schema', () => { expect(exitCode).toEqual(2); if (isWebpack5) { - expect(stderr).toContain("Found the 'invalid-value' problem with the '--mode' argument by path 'mode'"); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); } else { expect(stderr).toContain('Invalid configuration object'); } diff --git a/test/json/json.test.js b/test/json/json.test.js index 6bc74116ada..9fd1ef88964 100644 --- a/test/json/json.test.js +++ b/test/json/json.test.js @@ -32,7 +32,7 @@ describe('json flag', () => { it('should store json to a file and respect --color flag', (done) => { const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json', '--color']); - expect(stdout).toContain(`[webpack-cli] \u001b[32m${successMessage}`); + expect(stdout).toContain(`\u001b[32m${successMessage}`); expect(exitCode).toBe(0); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); @@ -50,8 +50,8 @@ describe('json flag', () => { it('should store json to a file and respect --no-color', (done) => { const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json', '--no-color']); - expect(stdout).not.toContain(`[webpack-cli] \u001b[32m${successMessage}`); - expect(stdout).toContain(`[webpack-cli] ${successMessage}`); + expect(stdout).not.toContain(`\u001b[32m${successMessage}`); + expect(stdout).toContain(`${successMessage}`); expect(exitCode).toBe(0); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); diff --git a/test/migrate/config/migrate-config.test.js b/test/migrate/config/migrate-config.test.js index 732906f1f5b..35dcb6000b9 100644 --- a/test/migrate/config/migrate-config.test.js +++ b/test/migrate/config/migrate-config.test.js @@ -1,6 +1,5 @@ 'use strict'; -const { red } = require('colorette'); const fs = require('fs'); const path = require('path'); const rimraf = require('rimraf'); @@ -21,7 +20,7 @@ describe('migrate command', () => { it('should warn if the source config file is not specified', () => { const { stderr } = run(__dirname, ['migrate'], false); - expect(stderr).toContain('Please specify a path to your webpack config'); + expect(stderr).toContain("missing required argument 'config-path'"); }); it('should prompt accordingly if an output path is not specified', () => { @@ -31,7 +30,7 @@ describe('migrate command', () => { it('should throw an error if the user refused to overwrite the source file and no output path is provided', async () => { const { stderr } = await runAndGetWatchProc(__dirname, ['migrate', 'webpack.config.js'], false, 'n'); - expect(stderr).toContain(`[webpack-cli] ${red('✖ ︎Migration aborted due to no output path')}`); + expect(stderr).toContain('︎Migration aborted due to no output path'); }); it('should prompt for config validation when an output path is provided', async () => { diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 74a768bdd11..63dae85005e 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -50,7 +50,8 @@ describe('mode flags', () => { expect(exitCode).toBe(2); if (isWebpack5) { - expect(stderr).toContain("Found the 'invalid-value' problem with the '--mode' argument by path 'mode'"); + expect(stderr).toContain("Invalid value 'abcd' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); } else { expect(stderr).toContain('configuration.mode should be one of these'); expect(stderr).toContain(`"development" | "production" | "none"`); diff --git a/test/no-hot/no-hot.test.js b/test/no-hot/no-hot.test.js deleted file mode 100644 index 91b268603be..00000000000 --- a/test/no-hot/no-hot.test.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); -const { existsSync, readFile } = require('fs'); -const { resolve } = require('path'); - -describe('no-hot flag', () => { - it('should be successful when --no-hot is passed', (done) => { - const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot']); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); - expect(stdout).not.toContain('webpack/runtime/hot module replacement'); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); - - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { - expect(err).toBe(null); - // check for absence of special functions invoked by HMR plugin only - expect(data).not.toContain('/* webpack/runtime/hot module replacement */'); - done(); - }); - }); - - it('should warn when --hot and --no-hot both are passed', (done) => { - const { exitCode, stderr, stdout } = run(__dirname, ['--hot', '--no-hot']); - - expect(exitCode).toBe(0); - expect(stderr).toContain( - 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', - ); - expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); - - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { - expect(err).toBe(null); - // check for absence of special functions invoked by HMR plugin only - expect(data).not.toContain('/* webpack/runtime/hot module replacement */'); - done(); - }); - }); -}); diff --git a/test/no-hot/src/index.js b/test/no-hot/src/index.js deleted file mode 100644 index 6e995fcc00e..00000000000 --- a/test/no-hot/src/index.js +++ /dev/null @@ -1 +0,0 @@ -console.log('no-hot test'); diff --git a/test/no-hot/webpack.config.js b/test/no-hot/webpack.config.js deleted file mode 100644 index 37c48e745b2..00000000000 --- a/test/no-hot/webpack.config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - mode: 'development', - stats: 'verbose', -}; diff --git a/test/no-stats/with-flags/main.js b/test/no-stats/with-flags/main.js deleted file mode 100644 index 412593d4ef7..00000000000 --- a/test/no-stats/with-flags/main.js +++ /dev/null @@ -1 +0,0 @@ -console.log('--no-stats test'); diff --git a/test/no-stats/with-flags/no-stats.test.js b/test/no-stats/with-flags/no-stats.test.js deleted file mode 100644 index 20e9ffcb820..00000000000 --- a/test/no-stats/with-flags/no-stats.test.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -const { run } = require('../../utils/test-utils'); -const { version } = require('webpack'); - -describe('stats flag', () => { - it('should accept --no-stats as boolean', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - - if (version.startsWith('5')) { - expect(stdout).toContain(`stats: { preset: 'none' }`); - } else { - expect(stdout).toContain('stats: false'); - } - }); - - it('should warn and use --no-stats when stats and no-stats both are provided', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'verbose', '--no-stats']); - - expect(exitCode).toBe(0); - expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); - - if (version.startsWith('5')) { - expect(stdout).toContain(`stats: { preset: 'none' }`); - } else { - expect(stdout).toContain('stats: false'); - } - }); - - it('should warn and use --stats when stats and no-stats both are provided', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats', '--stats', 'verbose']); - - expect(exitCode).toBe(0); - expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); - - if (version.startsWith('5')) { - expect(stdout).toContain(`stats: { preset: 'verbose' }`); - } else { - expect(stdout).toContain(`stats: 'verbose'`); - } - }); -}); diff --git a/test/no-stats/with-flags/webpack.config.js b/test/no-stats/with-flags/webpack.config.js deleted file mode 100644 index 95e2766b9ae..00000000000 --- a/test/no-stats/with-flags/webpack.config.js +++ /dev/null @@ -1,7 +0,0 @@ -const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); - -module.exports = { - mode: 'development', - entry: './main.js', - plugins: [new WebpackCLITestPlugin()], -}; diff --git a/test/output/named-bundles/a.js b/test/output/a.js similarity index 100% rename from test/output/named-bundles/a.js rename to test/output/a.js diff --git a/test/output/named-bundles/b.js b/test/output/b.js similarity index 100% rename from test/output/named-bundles/b.js rename to test/output/b.js diff --git a/test/output/named-bundles/c.js b/test/output/c.js similarity index 100% rename from test/output/named-bundles/c.js rename to test/output/c.js diff --git a/test/output/named-bundles/output-named-bundles.test.js b/test/output/output-named-bundles.test.js similarity index 87% rename from test/output/named-bundles/output-named-bundles.test.js rename to test/output/output-named-bundles.test.js index a6a5aed9e93..e93e0fe70d5 100644 --- a/test/output/named-bundles/output-named-bundles.test.js +++ b/test/output/output-named-bundles.test.js @@ -1,7 +1,7 @@ 'use strict'; const { resolve } = require('path'); -const { run } = require('../../utils/test-utils'); +const { run } = require('../utils/test-utils'); describe('output flag named bundles', () => { it('should output file given as flag instead of in configuration', () => { @@ -51,8 +51,9 @@ describe('output flag named bundles', () => { it('should output file in bin directory using default webpack config with warning for empty output value', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-path'], false); - expect(exitCode).toEqual(1); - expect(stderr).toEqual("error: option '-o, --output-path ' argument missing"); + expect(exitCode).toEqual(2); + expect(stderr).toContain("option '-o, --output-path ' argument missing"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/output/named-bundles/webpack.config.js b/test/output/webpack.config.js similarity index 87% rename from test/output/named-bundles/webpack.config.js rename to test/output/webpack.config.js index e6d61551f48..f1be65a15cc 100644 --- a/test/output/named-bundles/webpack.config.js +++ b/test/output/webpack.config.js @@ -2,6 +2,7 @@ const { resolve } = require('path'); module.exports = { entry: './a.js', + mode: 'development', output: { path: resolve(__dirname, 'bin'), filename: 'a.bundle.js', diff --git a/test/output/named-bundles/webpack.defaults.config.js b/test/output/webpack.defaults.config.js similarity index 77% rename from test/output/named-bundles/webpack.defaults.config.js rename to test/output/webpack.defaults.config.js index eed6bafa708..69a38fff1c5 100644 --- a/test/output/named-bundles/webpack.defaults.config.js +++ b/test/output/webpack.defaults.config.js @@ -3,4 +3,5 @@ module.exports = { b: './b.js', c: './c.js', }, + mode: 'development', }; diff --git a/test/output/named-bundles/webpack.multiple.config.js b/test/output/webpack.multiple.config.js similarity index 89% rename from test/output/named-bundles/webpack.multiple.config.js rename to test/output/webpack.multiple.config.js index 32f35d14cd0..a047b31864d 100644 --- a/test/output/named-bundles/webpack.multiple.config.js +++ b/test/output/webpack.multiple.config.js @@ -9,4 +9,5 @@ module.exports = { path: resolve(__dirname, 'bin'), filename: '[name].bundle.js', }, + mode: 'development', }; diff --git a/test/output/named-bundles/webpack.single.config.js b/test/output/webpack.single.config.js similarity index 89% rename from test/output/named-bundles/webpack.single.config.js rename to test/output/webpack.single.config.js index 32f35d14cd0..a047b31864d 100644 --- a/test/output/named-bundles/webpack.single.config.js +++ b/test/output/webpack.single.config.js @@ -9,4 +9,5 @@ module.exports = { path: resolve(__dirname, 'bin'), filename: '[name].bundle.js', }, + mode: 'development', }; diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index 95ece6bd8e8..a9404a5a110 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -32,7 +32,7 @@ describe('prefetch', () => { it('should log error when flag value is not supplied', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch'], false); - expect(exitCode).toBe(1); + expect(exitCode).toBe(2); expect(stderr).toContain(`error: option '--prefetch ' argument missing`); expect(stdout).toBeFalsy(); }); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 64f8f2f07c8..dff4a541882 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -6,8 +6,8 @@ const { runServe, isDevServer4 } = require('../../utils/test-utils'); const testPath = path.resolve(__dirname); -const usageText = 'webpack s | serve'; -const descriptionText = 'Run the webpack Dev Server'; +const usageText = 'webpack serve|s [options]'; +const descriptionText = 'Run the webpack dev server'; describe('basic serve usage', () => { let port; @@ -26,6 +26,22 @@ describe('basic serve usage', () => { return; } + it('should work', async () => { + const { stderr, stdout } = await runServe(['--no-hot'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout).not.toContain('HotModuleReplacementPlugin'); + }); + + it('should work with flags', async () => { + const { stderr, stdout } = await runServe(['--hot'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout).toContain('HotModuleReplacementPlugin'); + }); + it('should respect the --no-color flag', async () => { const { stdout, stderr } = await runServe(['--help', '--no-color'], __dirname); @@ -86,7 +102,7 @@ describe('basic serve usage', () => { const { exitCode, stdout, stderr } = await runServe(['--port', port, '--unknown-flag'], testPath); expect(exitCode).toBe(2); - expect(stderr).toContain('Unknown argument: --unknown-flag'); + expect(stderr).toContain("unknown option '--unknown-flag'"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/serve/invalid-schema/invalid-schema.test.js b/test/serve/invalid-schema/invalid-schema.test.js new file mode 100644 index 00000000000..36134fe6818 --- /dev/null +++ b/test/serve/invalid-schema/invalid-schema.test.js @@ -0,0 +1,27 @@ +'use strict'; +const { run, isWebpack5 } = require('../../utils/test-utils'); + +describe('invalid schema', () => { + it('should log webpack error and exit process on invalid config', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--config', './webpack.config.mock.js']); + + expect(exitCode).toEqual(2); + expect(stderr).toContain('Invalid configuration object'); + expect(stdout).toBeFalsy(); + }); + + it('should log webpack error and exit process on invalid flag', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/serve/invalid-schema/webpack.config.mock.js b/test/serve/invalid-schema/webpack.config.mock.js new file mode 100644 index 00000000000..f6d8ff0ce80 --- /dev/null +++ b/test/serve/invalid-schema/webpack.config.mock.js @@ -0,0 +1,3 @@ +module.exports = { + mode: 'Nishinoya Yuu', +}; diff --git a/test/no-stats/with-config/main.js b/test/stats/config-no/main.js similarity index 100% rename from test/no-stats/with-config/main.js rename to test/stats/config-no/main.js diff --git a/test/no-stats/with-config/no-stats-with-config.test.js b/test/stats/config-no/no-stats-with-config.test.js similarity index 100% rename from test/no-stats/with-config/no-stats-with-config.test.js rename to test/stats/config-no/no-stats-with-config.test.js diff --git a/test/no-stats/with-config/webpack.config.js b/test/stats/config-no/webpack.config.js similarity index 100% rename from test/no-stats/with-config/webpack.config.js rename to test/stats/config-no/webpack.config.js diff --git a/test/stats/cli-flags/index.js b/test/stats/flags/index.js similarity index 100% rename from test/stats/cli-flags/index.js rename to test/stats/flags/index.js diff --git a/test/stats/cli-flags/package.json b/test/stats/flags/package.json similarity index 100% rename from test/stats/cli-flags/package.json rename to test/stats/flags/package.json diff --git a/test/stats/cli-flags/stats.test.js b/test/stats/flags/stats.test.js similarity index 68% rename from test/stats/cli-flags/stats.test.js rename to test/stats/flags/stats.test.js index 71c1fcb495a..0f37921c315 100644 --- a/test/stats/cli-flags/stats.test.js +++ b/test/stats/flags/stats.test.js @@ -38,13 +38,29 @@ describe('stats flag', () => { } }); + it('should accept --no-stats as boolean', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + + if (isWebpack5) { + expect(stdout).toContain(`stats: { preset: 'none' }`); + } else { + expect(stdout).toContain('stats: false'); + } + }); + it('should log error when an unknown flag stats value is passed', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'foo']); expect(exitCode).toEqual(2); if (isWebpack5) { - expect(stderr).toContain("Found the 'invalid-value' problem with the '--stats' argument by path 'stats'"); + expect(stderr).toContain("Invalid value 'foo' for the '--stats' option"); + expect(stderr).toContain("Expected: 'none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose'"); + expect(stderr).toContain("Invalid value 'foo' for the '--stats' option"); + expect(stderr).toContain("Expected: 'true | false'"); } else { expect(stderr).toContain('* configuration.stats should be one of these:'); expect(stderr).toContain('"none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose" | "errors-warnings"'); diff --git a/test/stats/cli-flags/webpack.config.js b/test/stats/flags/webpack.config.js similarity index 100% rename from test/stats/cli-flags/webpack.config.js rename to test/stats/flags/webpack.config.js diff --git a/test/stats/watch/multi-webpack.config.js b/test/stats/watch/multi-webpack.config.js index f2c12cc6680..2d865091b99 100644 --- a/test/stats/watch/multi-webpack.config.js +++ b/test/stats/watch/multi-webpack.config.js @@ -3,6 +3,7 @@ const webpack = require('webpack'); module.exports = [ { name: 'first', + mode: 'development', watch: true, stats: 'none', plugins: [ @@ -17,6 +18,7 @@ module.exports = [ }, { name: 'two', + mode: 'development', watch: true, stats: 'none', plugins: [ diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index dd5a8ea78b3..bb8ba841b06 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -1,11 +1,103 @@ +const stripAnsi = require('strip-ansi'); const { run, isWebpack5 } = require('../utils/test-utils'); describe('unknown behaviour', () => { - it('should log error if an unknown flag is passed in', () => { + it('should log an error if an unknown flag is passed', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown argument: '--unknown'"); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-u']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed #3', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-u', '--unknown']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed #4', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-u', '-u']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed #5', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-u', 'foo']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed using "bundle" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--unknown']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed using "b" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['b', '--unknown']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed using "bundle" command #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', 'bundle']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed using "info" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--unknown']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed using "i" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['i', '--unknown']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed using "i" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', 'i']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -13,7 +105,8 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--color']); expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] \u001b[31mUnknown argument: '--unknown'`); + expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("\u001b[31mRun 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -21,25 +114,82 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--no-color']); expect(exitCode).toBe(2); - expect(stderr).not.toContain(`[webpack-cli] \u001b[31mUnknown argument: '--unknown'`); - expect(stderr).toContain("Unknown argument: '--unknown'"); + expect(stderr).not.toContain(`\u001b[31munknown option '--unknown'`); + expect(stderr).not.toContain("\u001b[31mRun 'webpack --help' to see available commands and options"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); - it('suggests the closest match to an unknown flag', () => { + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entyr', './a.js']); + expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown argument: '--entyr'"); - expect(stdout).toContain("Did you mean '--entry'?"); + expect(stderr).toContain("unknown option '--entyr'"); + expect(stderr).toContain("Did you mean '--entry'?"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); }); - it('suggests the closest match to an unknown flag #2', () => { + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag #2', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-fileneme', '[name].js']); + expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown argument: '--output-fileneme'"); + expect(stderr).toContain("unknown option '--output-fileneme'"); if (isWebpack5) { - expect(stdout).toContain("Did you mean '--output-filename'?"); + expect(stderr).toContain("Did you mean '--output-filename'?"); } + + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "bundle" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--entyr', './a.js']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--entyr'"); + expect(stderr).toContain("Did you mean '--entry'?"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "b" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['b', '--entyr', './a.js']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--entyr'"); + expect(stderr).toContain("Did you mean '--entry'?"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "info" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--outpyt']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--outpyt'"); + expect(stderr).toContain("Did you mean '--output'?"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "i" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['i', '--outpyt']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--outpyt'"); + expect(stderr).toContain("Did you mean '--output'?"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should ask to install command if an unknown command passed', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['qqq'], true, [], { TERM_PROGRAM: false }); + + expect(exitCode).toBe(0); + expect(stripAnsi(stderr)).toContain("For using this command you need to install: 'qqq' package"); + expect(stripAnsi(stderr)).toContain("Would you like to install 'qqq' package? (That will run 'npm install -D qqq')"); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 329ae19a3d0..52d4af7bf56 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -47,6 +47,7 @@ const run = (testCase, args = [], setOutput = true, nodeOptions = [], env) => { nodeOptions: nodeOptions, env, stdio: ENABLE_LOG_COMPILATION ? 'inherit' : 'pipe', + maxBuffer: Infinity, }); return result; @@ -245,10 +246,6 @@ const runServe = (args, testPath) => { return runWatch(testPath, ['serve'].concat(args), false); }; -const runInfo = (args, testPath) => { - return run(testPath, ['info'].concat(args), false); -}; - module.exports = { run, runWatch, @@ -258,7 +255,6 @@ module.exports = { appendDataIfFileExists, copyFileAsync, runInstall, - runInfo, hyphenToUpperCase, isWebpack5, isDevServer4, diff --git a/test/version/version-external-packages.test.js b/test/version/version-external-packages.test.js deleted file mode 100644 index d936da17f0d..00000000000 --- a/test/version/version-external-packages.test.js +++ /dev/null @@ -1,112 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); -const initPkgJSON = require('../../packages/init/package.json'); -const servePkgJSON = require('../../packages/serve/package.json'); -const migratePkgJSON = require('../../packages/migrate/package.json'); -const infoPkgJSON = require('../../packages/info/package.json'); -const pluginPkgJSON = require('../../packages/generators/package.json'); -const loaderPkgJSON = require('../../packages/generators/package.json'); -const cliPkgJSON = require('../../packages/webpack-cli/package.json'); - -describe('version flag with external packages', () => { - it('outputs version with init', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(initPkgJSON.version); - expect(stdout).toContain(cliPkgJSON.version); - }); - - it('outputs version with the alias c for init', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['c', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(initPkgJSON.version); - expect(stdout).toContain(cliPkgJSON.version); - }); - - it('outputs version with info', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['info', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(infoPkgJSON.version); - expect(stdout).toContain(cliPkgJSON.version); - }); - - it('outputs version with serve', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(servePkgJSON.version); - expect(stdout).toContain(cliPkgJSON.version); - }); - - it('outputs version with migrate', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(migratePkgJSON.version); - expect(stdout).toContain(cliPkgJSON.version); - }); - - it('outputs version with plugin', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(pluginPkgJSON.version); - expect(stdout).toContain(cliPkgJSON.version); - }); - - it('outputs version with loader', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['loader', '--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(loaderPkgJSON.version); - expect(stdout).toContain(cliPkgJSON.version); - }); - - it(' should throw error for multiple commands', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', 'migrate', '--version'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain( - "You provided multiple commands - 'init' (alias 'c'), 'migrate' (alias 'm'). Please use only one command at a time.", - ); - expect(stdout).toBeFalsy(); - }); - - it(' should throw error if invalid argument is present with --version flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '--version', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBeFalsy(); - }); - - it(' should throw error if invalid argument is present with version command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', 'version', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBeFalsy(); - }); - - it(' should throw error if invalid argument is present with -v alias', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '-v', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBeFalsy(); - }); -}); diff --git a/test/version/version-multi-args.test.js b/test/version/version-multi-args.test.js deleted file mode 100644 index 8059926546f..00000000000 --- a/test/version/version-multi-args.test.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); -const pkgJSON = require('../../packages/webpack-cli/package.json'); - -describe('version flag with multiple arguments', () => { - it('does not output version with help command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'help'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).not.toContain(pkgJSON.version); - expect(stdout).toContain('The build tool for modern web applications'); - }); - - it('does not output version with help dashed', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--help'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).not.toContain(pkgJSON.version); - expect(stdout).toContain('The build tool for modern web applications'); - }); - - it('throws error if invalid command is passed with version command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'abc', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).not.toContain(pkgJSON.version); - }); - - it('throws error if invalid option is passed with version command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--abc', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).not.toContain(pkgJSON.version); - }); - - it('throws error if invalid command is passed with --version flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version', 'abc', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).not.toContain(pkgJSON.version); - }); - - it('throws error if invalid option is passed with --version flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--abc', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).not.toContain(pkgJSON.version); - }); - - it('throws error if invalid command is passed with -v alias', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-v', 'abc', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).not.toContain(pkgJSON.version); - }); - - it('throws error if invalid option is passed with -v alias', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-v', '--abc', '--no-color'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); - expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).not.toContain(pkgJSON.version); - }); -}); diff --git a/test/version/version-single-arg.test.js b/test/version/version-single-arg.test.js deleted file mode 100644 index 72b34cbcff6..00000000000 --- a/test/version/version-single-arg.test.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); -const pkgJSON = require('../../packages/webpack-cli/package.json'); - -describe('single version flag', () => { - it('outputs versions with command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(pkgJSON.version); - }); - - it('outputs versions with dashed syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(pkgJSON.version); - }); - - it('outputs versions with alias syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-v'], false); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(pkgJSON.version); - }); -}); diff --git a/test/version/version.test.js b/test/version/version.test.js new file mode 100644 index 00000000000..b9a953703d4 --- /dev/null +++ b/test/version/version.test.js @@ -0,0 +1,383 @@ +'use strict'; + +const webpack = require('webpack'); + +const { run } = require('../utils/test-utils'); +const pkgJSON = require('../../packages/webpack-cli/package.json'); +const initPkgJSON = require('../../packages/init/package.json'); +const servePkgJSON = require('../../packages/serve/package.json'); +const migratePkgJSON = require('../../packages/migrate/package.json'); +const infoPkgJSON = require('../../packages/info/package.json'); +const generatorsPkgJSON = require('../../packages/generators/package.json'); +const webpackDevServerPkgJSON = require('webpack-dev-server/package.json'); + +describe('single version flag', () => { + it('outputs versions with command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs versions with dashed syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs versions with alias syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-v'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with info', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with info using option alias', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['info', '-v'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with info using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with info using command alias', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['v', 'info'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with bundle', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with plugin', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/generators ${generatorsPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with loader', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['loader', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/generators ${generatorsPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with init', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['init', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/init ${initPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with serve', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/serve ${servePkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with migrate', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/migrate ${migratePkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with the alias c for init', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['i', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('should log error when unknown command using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'unknown'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error when command using command syntax with multi commands', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'unknown'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should work for multiple commands', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['info', 'serve', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`@webpack-cli/serve ${servePkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('should output versions for multiple commands using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'serve'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`@webpack-cli/serve ${servePkgJSON.version}`); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('should output versions with help command using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'help'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('should log error when unknown command used with --version flag', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '--version'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'abc'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error when unknown command used with -v alias', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '-v'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'abc'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should not output version with help dashed', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--help'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('webpack version|v [commands...]'); + }); + + it('outputs versions with --color using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs versions with --no-color using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--no-color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs versions with --color using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs versions with --no-color using command syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--no-color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('should log error when unknown command used', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'abc'], false, []); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'abc'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('throws error if invalid option is passed with version command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--abc'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`Unknown option '--abc`); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error when unknown command used with --version flag', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--version', 'abc'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'abc'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('throws error if invalid option is passed with --version flag', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--abc'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`Unknown option '--abc'`); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error when unknown command used with -v alias', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-v', 'abc'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'abc'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('throws error if invalid option is passed with -v alias', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-v', '--abc'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown option '--abc'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should work using command syntax with the "version" value', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('should work using command syntax and the "--version" argument', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('should log an error using command syntax with unknown argument', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--unknown'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown option '--unknown'"); + expect(stderr).toContain(`Run 'webpack --help' to see available commands and options`); + expect(stdout).toBeFalsy(); + }); + + it('should log an error using command syntax with unknown argument #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', '--unknown'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error using command syntax with multiple commands with unknown argument', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'serve', '--unknown'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown option '--unknown'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/yarn.lock b/yarn.lock index ba721b9966a..9062fed673b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3011,11 +3011,6 @@ arr-union@^3.1.0: resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= -array-back@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.1.tgz#9b80312935a52062e1a233a9c7abeb5481b30e90" - integrity sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg== - array-differ@^2.0.3: version "2.1.0" resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-2.1.0.tgz#4b9c1c3f14b906757082925769e8ab904f4801b1" @@ -3909,16 +3904,6 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -command-line-usage@^6.1.0: - version "6.1.1" - resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.1.tgz#c908e28686108917758a49f45efb4f02f76bc03f" - integrity sha512-F59pEuAR9o1SF/bD0dQBDluhpT4jJQNWUHEuVBqpDmCUo6gPjCi+m9fCWnWZVR/oG6cMTUms4h+3NPl74wGXvA== - dependencies: - array-back "^4.0.1" - chalk "^2.4.2" - table-layout "^1.0.1" - typical "^5.2.0" - commander@^2.18.0, commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -4389,7 +4374,7 @@ deep-equal@^1.0.1: object-keys "^1.1.1" regexp.prototype.flags "^1.2.0" -deep-extend@^0.6.0, deep-extend@~0.6.0: +deep-extend@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== @@ -9761,11 +9746,6 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" -reduce-flatten@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" - integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== - regenerate-unicode-properties@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" @@ -10907,16 +10887,6 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -table-layout@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.1.tgz#8411181ee951278ad0638aea2f779a9ce42894f9" - integrity sha512-dEquqYNJiGwY7iPfZ3wbXDI944iqanTSchrACLL2nOB+1r+h1Nzu2eH+DuPPvWvm5Ry7iAPeFlgEtP5bIp5U7Q== - dependencies: - array-back "^4.0.1" - deep-extend "~0.6.0" - typical "^5.2.0" - wordwrapjs "^4.0.0" - table@^5.2.3: version "5.4.6" resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" @@ -11305,11 +11275,6 @@ typescript@^3.9.7: resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== -typical@^5.0.0, typical@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" - integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== - uglify-js@^3.1.4: version "3.11.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.11.4.tgz#b47b7ae99d4bd1dca65b53aaa69caa0909e6fadf" @@ -11850,14 +11815,6 @@ wordwrap@^1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= -wordwrapjs@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.0.tgz#9aa9394155993476e831ba8e59fb5795ebde6800" - integrity sha512-Svqw723a3R34KvsMgpjFBYCgNOSdcW3mQFK4wIfhGQhtaFVOJmdYoXgi63ne3dTlWgatVcUc7t4HtQ/+bUVIzQ== - dependencies: - reduce-flatten "^2.0.0" - typical "^5.0.0" - wrap-ansi@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-3.0.1.tgz#288a04d87eda5c286e060dfe8f135ce8d007f8ba" From c53175f06ede2a3330f84e61a61ee1b1a93da622 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:35:10 +0300 Subject: [PATCH 178/581] chore(deps): [security] bump node-notifier from 8.0.0 to 8.0.1 (#2250) Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1. **This update includes a security fix.** - [Release notes](https://github.com/mikaelbr/node-notifier/releases) - [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md) - [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9062fed673b..a45e46a8dec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7954,6 +7954,13 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + macos-release@^2.2.0: version "2.4.1" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.4.1.tgz#64033d0ec6a5e6375155a74b1a1eba8e509820ac" @@ -8546,9 +8553,9 @@ node-modules-regexp@^1.0.0: integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= node-notifier@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-8.0.0.tgz#a7eee2d51da6d0f7ff5094bc7108c911240c1620" - integrity sha512-46z7DUmcjoYdaWyXouuFNNfUo6eFa94t23c53c+lG/9Cvauk4a98rAUp9672X5dxGdQmLpPzTxzu8f/OeEPaFA== + version "8.0.1" + resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-8.0.1.tgz#f86e89bbc925f2b068784b31f382afdc6ca56be1" + integrity sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA== dependencies: growly "^1.3.0" is-wsl "^2.2.0" @@ -10167,11 +10174,18 @@ semver@7.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== -semver@7.3.2, semver@7.x, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2: +semver@7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== +semver@7.x, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2: + version "7.3.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" + integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== + dependencies: + lru-cache "^6.0.0" + semver@^6.0.0, semver@^6.1.0, semver@^6.2.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" @@ -11457,9 +11471,9 @@ uuid@^3.0.1, uuid@^3.3.2, uuid@^3.3.3, uuid@^3.4.0: integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== uuid@^8.3.0: - version "8.3.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31" - integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg== + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== v8-compile-cache@^2.0.3, v8-compile-cache@^2.2.0: version "2.2.0" @@ -11934,6 +11948,11 @@ yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + yaml@^1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" From c735e8c85f809ea248463da48addce7003f5bf1c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:35:23 +0300 Subject: [PATCH 179/581] chore(deps): bump @discoveryjs/json-ext from 0.5.0 to 0.5.1 (#2248) Bumps [@discoveryjs/json-ext](https://github.com/discoveryjs/json-ext) from 0.5.0 to 0.5.1. - [Release notes](https://github.com/discoveryjs/json-ext/releases) - [Changelog](https://github.com/discoveryjs/json-ext/blob/master/CHANGELOG.md) - [Commits](https://github.com/discoveryjs/json-ext/compare/v0.5.0...v0.5.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index a45e46a8dec..ce372e40f15 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1046,9 +1046,9 @@ integrity sha512-VoNqai1vR5anRF5Tuh/+SWDFk7xi7oMwHrHrbm1BprYXjB2RJsWLhUrStMssDxEl5lW/z3EUdg8RvH/IUBccSQ== "@discoveryjs/json-ext@^0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.0.tgz#d6cf8951ceb673db41861d544cef2f2e07ebcb4d" - integrity sha512-gX9Hx+2BMP5+yXfr4Agb+iBd9YiI729x38wbhfvRSkxQqfXnJUNy1nnyJWetYCvxnL1caWd1HqJnbQwVrgvgeA== + version "0.5.1" + resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.1.tgz#cf87081ac9b0f3eb3b5740415b50b7966bac8fc5" + integrity sha512-Oee4NT60Lxe90m7VTYBU4UbABNaz0N4Q3G62CPB+6mGE4KuLMsTACmH8q3PH5u9pSZCuOdE9JClJ9vBqsp6DQg== "@eslint/eslintrc@^0.2.2": version "0.2.2" From 42719e42e65c1527f4a71c952ecdbc0205cd3eaa Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:35:53 +0300 Subject: [PATCH 180/581] chore(deps-dev): bump @types/node from 14.14.13 to 14.14.14 (#2243) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.13 to 14.14.14. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ce372e40f15..bfbef501c64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2447,9 +2447,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.13" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.13.tgz#9e425079799322113ae8477297ae6ef51b8e0cdf" - integrity sha512-vbxr0VZ8exFMMAjCW8rJwaya0dMCDyYW2ZRdTyjtrCvJoENMpdUHOT/eTzvgyA5ZnqRZ/sI0NwqAxNHKYokLJQ== + version "14.14.14" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae" + integrity sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" From ed627272b32db3ae714dff6c1d9f6d51b6823263 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:36:02 +0300 Subject: [PATCH 181/581] chore(deps-dev): bump @babel/preset-env from 7.12.10 to 7.12.11 (#2245) Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.12.10 to 7.12.11. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.11/packages/babel-preset-env) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/yarn.lock b/yarn.lock index bfbef501c64..6a0889500a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -221,10 +221,15 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== -"@babel/helper-validator-option@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.12.1.tgz#175567380c3e77d60ff98a54bb015fe78f2178d9" - integrity sha512-YpJabsXlJVWP0USHjnC/AQDTLlZERbON577YUVO/wLpqyj6HAtVYnWaQaN0iUN+1/tWn3c+uKKXjRut5115Y2A== +"@babel/helper-validator-identifier@^7.12.11": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed" + integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw== + +"@babel/helper-validator-option@^7.12.1", "@babel/helper-validator-option@^7.12.11": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.12.11.tgz#d66cb8b7a3e7fe4c6962b32020a131ecf0847f4f" + integrity sha512-TBFCyj939mFSdeX7U7DDj32WtzYY7fDcalgq8v3fBZMNOJQNn7nOYzMaUCiPxPYfCup69mtIpqlKgMZLvQ8Xhw== "@babel/helper-wrap-function@^7.10.4": version "7.12.3" @@ -501,10 +506,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-block-scoping@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.12.1.tgz#f0ee727874b42a208a48a586b84c3d222c2bbef1" - integrity sha512-zJyAC9sZdE60r1nVQHblcfCj29Dh2Y0DOvlMkcqSo0ckqjiCwNiUezUKw+RjOCwGfpLRwnAeQ2XlLpsnGkvv9w== +"@babel/plugin-transform-block-scoping@^7.12.11": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.12.11.tgz#83ae92a104dbb93a7d6c6dd1844f351083c46b4f" + integrity sha512-atR1Rxc3hM+VPg/NvNvfYw0npQEAcHuJ+MGZnFn6h3bo+1U3BWXMdFMlvVRApBTWKQMX7SOwRJZA5FBF/JQbvA== dependencies: "@babel/helper-plugin-utils" "^7.10.4" @@ -745,15 +750,15 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/preset-env@^7.12.1": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.10.tgz#ca981b95f641f2610531bd71948656306905e6ab" - integrity sha512-Gz9hnBT/tGeTE2DBNDkD7BiWRELZt+8lSysHuDwmYXUIvtwZl0zI+D6mZgXZX0u8YBlLS4tmai9ONNY9tjRgRA== + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.11.tgz#55d5f7981487365c93dbbc84507b1c7215e857f9" + integrity sha512-j8Tb+KKIXKYlDBQyIOy4BLxzv1NUOwlHfZ74rvW+Z0Gp4/cI2IMDPBWAgWceGcE7aep9oL/0K9mlzlMGxA8yNw== dependencies: "@babel/compat-data" "^7.12.7" "@babel/helper-compilation-targets" "^7.12.5" "@babel/helper-module-imports" "^7.12.5" "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-validator-option" "^7.12.1" + "@babel/helper-validator-option" "^7.12.11" "@babel/plugin-proposal-async-generator-functions" "^7.12.1" "@babel/plugin-proposal-class-properties" "^7.12.1" "@babel/plugin-proposal-dynamic-import" "^7.12.1" @@ -782,7 +787,7 @@ "@babel/plugin-transform-arrow-functions" "^7.12.1" "@babel/plugin-transform-async-to-generator" "^7.12.1" "@babel/plugin-transform-block-scoped-functions" "^7.12.1" - "@babel/plugin-transform-block-scoping" "^7.12.1" + "@babel/plugin-transform-block-scoping" "^7.12.11" "@babel/plugin-transform-classes" "^7.12.1" "@babel/plugin-transform-computed-properties" "^7.12.1" "@babel/plugin-transform-destructuring" "^7.12.1" @@ -812,7 +817,7 @@ "@babel/plugin-transform-unicode-escapes" "^7.12.1" "@babel/plugin-transform-unicode-regex" "^7.12.1" "@babel/preset-modules" "^0.1.3" - "@babel/types" "^7.12.10" + "@babel/types" "^7.12.11" core-js-compat "^3.8.0" semver "^5.5.0" @@ -885,12 +890,12 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.10.tgz#7965e4a7260b26f09c56bcfcb0498af1f6d9b260" - integrity sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw== +"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.11", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.11.tgz#a86e4d71e30a9b6ee102590446c98662589283ce" + integrity sha512-ukA9SQtKThINm++CX1CwmliMrE54J6nIYB5XTwL5f/CLFW9owfls+YSU8tVW15RQ2w+a3fSbPjC6HdQNtWZkiA== dependencies: - "@babel/helper-validator-identifier" "^7.10.4" + "@babel/helper-validator-identifier" "^7.12.11" lodash "^4.17.19" to-fast-properties "^2.0.0" From 197d2754b35d4f43067d05a5f39abe6ad29ad67b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:36:11 +0300 Subject: [PATCH 182/581] chore(deps-dev): bump webpack from 5.10.2 to 5.11.0 (#2246) Bumps [webpack](https://github.com/webpack/webpack) from 5.10.2 to 5.11.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.10.2...v5.11.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6a0889500a7..3a86a17577e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3381,18 +3381,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browserslist@^4.14.5: - version "4.14.7" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.7.tgz#c071c1b3622c1c2e790799a37bb09473a4351cb6" - integrity sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ== - dependencies: - caniuse-lite "^1.0.30001157" - colorette "^1.2.1" - electron-to-chromium "^1.3.591" - escalade "^3.1.1" - node-releases "^1.1.66" - -browserslist@^4.15.0: +browserslist@^4.14.5, browserslist@^4.15.0: version "4.15.0" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.15.0.tgz#3d48bbca6a3f378e86102ffd017d9a03f122bdb0" integrity sha512-IJ1iysdMkGmjjYeRlDU8PQejVwxvVO5QOfXH7ylW31GO6LwNRSmm/SgRXtNsEXqMLl2e+2H5eEJ7sfynF8TCaQ== @@ -3596,11 +3585,6 @@ camelcase@^6.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== -caniuse-lite@^1.0.30001157: - version "1.0.30001159" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001159.tgz#bebde28f893fa9594dadcaa7d6b8e2aa0299df20" - integrity sha512-w9Ph56jOsS8RL20K9cLND3u/+5WASWdhC/PPrf+V3/HsM3uHOavWOR1Xzakbv4Puo/srmPHudkmCRWM7Aq+/UA== - caniuse-lite@^1.0.30001164: version "1.0.30001165" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001165.tgz#32955490d2f60290bb186bb754f2981917fa744f" @@ -4690,11 +4674,6 @@ ejs@^3.0.1: dependencies: jake "^10.6.1" -electron-to-chromium@^1.3.591: - version "1.3.603" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.603.tgz#1b71bec27fb940eccd79245f6824c63d5f7e8abf" - integrity sha512-J8OHxOeJkoSLgBXfV9BHgKccgfLMHh+CoeRo6wJsi6m0k3otaxS/5vrHpMNSEYY4MISwewqanPOuhAtuE8riQQ== - electron-to-chromium@^1.3.612: version "1.3.621" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.621.tgz#0bbe2100ef0b28f88d0b1101fbdf433312f69be0" @@ -8576,7 +8555,7 @@ node-preload@^0.2.1: dependencies: process-on-spawn "^1.0.0" -node-releases@^1.1.66, node-releases@^1.1.67: +node-releases@^1.1.67: version "1.1.67" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.67.tgz#28ebfcccd0baa6aad8e8d4d8fe4cbc49ae239c12" integrity sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg== @@ -11697,9 +11676,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.10.0: - version "5.10.2" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.10.2.tgz#990ad134b8a6406b5e40e63da1870e0de40215dc" - integrity sha512-KpYTJerfb2KGxcOJNA1SMWXAf8/dxCDaQOhPIrfoV5rYceqet7OY/h3941/kuapx0noMcpTiVoNN3EHXsTYlsg== + version "5.11.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.11.0.tgz#1647abc060441d86d01d8835b8f0fc1dae2fe76f" + integrity sha512-ubWv7iP54RqAC/VjixgpnLLogCFbAfSOREcSWnnOlZEU8GICC5eKmJSu6YEnph2N2amKqY9rvxSwgyHxVqpaRw== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From 7a0c019847854e96707b098632bcd101228c0160 Mon Sep 17 00:00:00 2001 From: ka-weihe Date: Wed, 23 Dec 2020 13:34:04 +0100 Subject: [PATCH 183/581] refactor: faster levenshtein (#2251) --- packages/webpack-cli/lib/webpack-cli.js | 4 ++-- packages/webpack-cli/package.json | 2 +- yarn.lock | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 5bd48b4c701..5b7affc6f61 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -6,7 +6,7 @@ const webpackMerge = require('webpack-merge'); const { extensions, jsVariants } = require('interpret'); const rechoir = require('rechoir'); const { createWriteStream, existsSync } = require('fs'); -const leven = require('leven'); +const { distance } = require('fastest-levenshtein'); const { options: coloretteOptions, yellow, cyan, green, bold } = require('colorette'); const { stringifyStream: createJsonStringifyStream } = require('@discoveryjs/json-ext'); @@ -392,7 +392,7 @@ class WebpackCLI { process.exit(2); } - const found = command.options.find((option) => leven(name, option.long.slice(2)) < 3); + const found = command.options.find((option) => distance(name, option.long.slice(2)) < 3); if (found) { logger.error(`Did you mean '--${found.name()}'?`); diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index edb1166d5d8..2d76c9e8aef 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -34,9 +34,9 @@ "commander": "^6.2.0", "enquirer": "^2.3.6", "execa": "^4.1.0", + "fastest-levenshtein": "^1.0.12", "import-local": "^3.0.2", "interpret": "^2.2.0", - "leven": "^3.1.0", "rechoir": "^0.7.0", "v8-compile-cache": "^2.2.0", "webpack-merge": "^4.2.2" diff --git a/yarn.lock b/yarn.lock index 3a86a17577e..105a482a5de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5242,6 +5242,11 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= +fastest-levenshtein@^1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" + integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== + fastq@^1.6.0: version "1.9.0" resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.9.0.tgz#e16a72f338eaca48e91b5c23593bcc2ef66b7947" From d5222f6e7146848e78d96486ab69aed2ee420e02 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 23 Dec 2020 16:46:52 +0300 Subject: [PATCH 184/581] chore(deps-dev): bump eslint from 7.15.0 to 7.16.0 (#2249) Bumps [eslint](https://github.com/eslint/eslint) from 7.15.0 to 7.16.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.15.0...v7.16.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/yarn.lock b/yarn.lock index 105a482a5de..77cc2d6711f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2857,7 +2857,7 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: +ajv@^6.1.0, ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -3107,11 +3107,6 @@ ast-types@0.14.2: dependencies: tslib "^2.0.1" -astral-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" - integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== - astral-regex@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" @@ -4927,9 +4922,9 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.15.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.15.0.tgz#eb155fb8ed0865fcf5d903f76be2e5b6cd7e0bc7" - integrity sha512-Vr64xFDT8w30wFll643e7cGrIkPEU50yIiI36OdSIDoSGguIeaLzBo0vpGvzo9RECUqq7htURfwEtKqwytkqzA== + version "7.16.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.16.0.tgz#a761605bf9a7b32d24bb7cde59aeb0fd76f06092" + integrity sha512-iVWPS785RuDA4dWuhhgXTNrGxHHK3a8HLSMBgbbU59ruJDubUraXN8N5rn7kb8tG6sjg74eE0RA3YWT51eusEw== dependencies: "@babel/code-frame" "^7.0.0" "@eslint/eslintrc" "^0.2.2" @@ -4965,7 +4960,7 @@ eslint@^7.12.1: semver "^7.2.1" strip-ansi "^6.0.0" strip-json-comments "^3.1.0" - table "^5.2.3" + table "^6.0.4" text-table "^0.2.0" v8-compile-cache "^2.0.3" @@ -7868,7 +7863,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.2.1: +lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4, lodash@^4.2.1: version "4.17.20" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== @@ -10349,15 +10344,6 @@ slice-ansi@0.0.4: resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" integrity sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU= -slice-ansi@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" - integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== - dependencies: - ansi-styles "^3.2.0" - astral-regex "^1.0.0" - is-fullwidth-code-point "^2.0.0" - slice-ansi@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-3.0.0.tgz#31ddc10930a1b7e0b67b08c96c2f49b77a789787" @@ -10890,15 +10876,15 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -table@^5.2.3: - version "5.4.6" - resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" - integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== +table@^6.0.4: + version "6.0.4" + resolved "https://registry.yarnpkg.com/table/-/table-6.0.4.tgz#c523dd182177e926c723eb20e1b341238188aa0d" + integrity sha512-sBT4xRLdALd+NFBvwOz8bw4b15htyythha+q+DVZqy2RS08PPC8O2sZFgJYEY7bJvbCFKccs+WIZ/cd+xxTWCw== dependencies: - ajv "^6.10.2" - lodash "^4.17.14" - slice-ansi "^2.1.0" - string-width "^3.0.0" + ajv "^6.12.4" + lodash "^4.17.20" + slice-ansi "^4.0.0" + string-width "^4.2.0" tapable@^2.0.0, tapable@^2.1.1: version "2.1.1" From cc37c73de9b67404eb12a5f2065977191ca72014 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 23 Dec 2020 18:12:14 +0300 Subject: [PATCH 185/581] chore: remove broken smoketests --- .github/workflows/nodejs.yml | 7 -- package.json | 1 - smoketests/smoketests.sh | 10 -- smoketests/watch.sh | 55 ---------- smoketests/watch/watch.array.smoketest.js | 113 --------------------- smoketests/watch/watch.single.smoketest.js | 90 ---------------- smoketests/watch/webpack.array.config.js | 32 ------ 7 files changed, 308 deletions(-) delete mode 100755 smoketests/smoketests.sh delete mode 100755 smoketests/watch.sh delete mode 100644 smoketests/watch/watch.array.smoketest.js delete mode 100644 smoketests/watch/watch.single.smoketest.js delete mode 100644 smoketests/watch/webpack.array.config.js diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 593cd6263d1..efa797aa162 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -94,13 +94,6 @@ jobs: yarn prepsuite yarn test:coverage - - name: Smoke Tests - # TODO fix for windows - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' - run: yarn test:smoke - env: - CI: true - - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 diff --git a/package.json b/package.json index 10677c1eeb1..199f5c9337a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "test:packages": "jest packages/ --reporters=default --forceExit", "test:ci": "yarn test:cli && yarn test:packages", "test:watch": "jest test/ packages/ --watch", - "test:smoke": "smoketests/smoketests.sh", "publish:monorepo": "yarn build && lerna version && lerna publish from-git" }, "config": { diff --git a/smoketests/smoketests.sh b/smoketests/smoketests.sh deleted file mode 100755 index 01b3bfd4732..00000000000 --- a/smoketests/smoketests.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -shopt -s extglob - -cd smoketests - -./watch.sh $@ - - -cd ../ \ No newline at end of file diff --git a/smoketests/watch.sh b/smoketests/watch.sh deleted file mode 100755 index 0d233bacae4..00000000000 --- a/smoketests/watch.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash - -# usage sh ./smoketests/watch.sh - - -test_folders=( - watch -) -iterations=100 - -if [ "$1" != "" ]; then - iterations=$1 -fi - -function setup() { -cat << EOL >> ./watch/index.js -console.log('index'); -EOL - -cat << EOL >> ./watch/dev.js -module.exports = 'more jank'; -EOL - -cat << EOL >> ./watch/prod.js -module.exports = 'jank'; -EOL - -} - -function del_files() { - rm -rf ./$i/bin* ./$i/*_copy* ./$i/dist - rm -rf ./watch/index.js ./watch/dev.js ./watch/prod.js -} -function teardown() { - del_files - cd ../ - exit -} - - -setup - -for i in "${test_folders[@]}"; do - echo "============================ RUNNING FOLDER: $i ============================" - for j in `seq 1 $iterations`; do - echo "============================ ITERATION: $j/$iterations =====================================" - ls ./watch/*.smoketest.js | xargs -I{} echo "Running:" {} | tee /dev/tty | cut -d':' -f 2 | xargs -I{} node {} - if [ "$?" != "0" ]; then - teardown - fi - done - echo "============================ DONE RUNNING $i $iterations times ============================" -done - -teardown diff --git a/smoketests/watch/watch.array.smoketest.js b/smoketests/watch/watch.array.smoketest.js deleted file mode 100644 index bf615dc606e..00000000000 --- a/smoketests/watch/watch.array.smoketest.js +++ /dev/null @@ -1,113 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const { unlinkSync, renameSync } = require('fs'); -const { resolve } = require('path'); -// eslint-disable-next-line node/no-unpublished-require -const { appendDataIfFileExists, runAndGetWatchProc, copyFileAsync } = require('../../test/utils/test-utils'); - -console.log('\n============================ ARRAY/CHILD COMPILATION ============================\n'); - -const testEntryFiles = [ - { - name: 'dev.js', - fp: resolve(__dirname, 'dev.js'), - cpFp: null, - }, - { - name: 'prod.js', - fp: resolve(__dirname, 'prod.js'), - cpFP: null, - }, -]; - -/** - * Make a copy of each file - * @returns {void} - */ -async function setup() { - await testEntryFiles.forEach(async (file) => { - file.cpFP = await copyFileAsync(__dirname, file.name); - }); -} - -/** - * Remove symlinks, restore file - * @returns {void} - */ -async function teardown() { - testEntryFiles.forEach((file) => { - try { - unlinkSync(file.fp); - } catch (e) { - console.warn('could not remove the file:' + file.fp + '\n' + e.message); - } finally { - renameSync(file.cpFP, file.fp); - } - }); -} - -(async () => { - try { - await setup(); - - // Spawn one process in watch mode and fill up a buffer of results - const webpackProc = runAndGetWatchProc(__dirname, ['--watch', '--config', './webpack.array.config.js']); - const dataBuffer = []; - - setInterval(() => { - // Close process if time is over 5s - if (process.uptime() > 5) { - assert.strictEqual(true, false, 'Test for child compilation hang, exiting'); - process.exit(-1); - } - appendDataIfFileExists(__dirname, testEntryFiles[0].name, '//junk-comment'); - appendDataIfFileExists(__dirname, testEntryFiles[1].name, '//junk2-comment'); - }, 10e3); - - // Array based configuration with child compilation - webpackProc.stdout.on('data', (data) => { - data = data.toString(); - console.log(data); - - if (data.includes('Output Directory')) { - let formattedData = data; - if (data.includes('\u001b')) { - formattedData = data.slice(data.indexOf('Output Directory'), data.indexOf('\u001b')); - } - dataBuffer.push(formattedData); - } - // Close process if buffer is full enough - if (dataBuffer.length > 3) { - webpackProc.kill('SIGINT'); - return; - } - }); - - // Buffer should have compiled equal amount of each compilation and have diff output directories - webpackProc.stderr.on('close', async () => { - assert.strictEqual(dataBuffer.length > 3, true, 'expected buffer for array configuration to be more than 3'); - const nCompilationBufferOne = []; - const nCompilationBufferTwo = []; - dataBuffer.forEach((chunk) => { - const outputDirStr = chunk.indexOf('Output Directory'); - const outputDirChunk = chunk.slice(outputDirStr).trim('\n'); - - const isInArr = nCompilationBufferOne.find((s) => s === outputDirChunk); - if (isInArr || !nCompilationBufferOne.length) { - nCompilationBufferOne.push(outputDirChunk); - return; - } - nCompilationBufferTwo.push(outputDirChunk); - }); - - assert.strictEqual(nCompilationBufferOne.length > 1, true, 'expected first buffer of array compilation to be > 1'); - assert.strictEqual(nCompilationBufferTwo.length > 1, true, 'expected second buffer of array compilation to be > 1'); - assert.strictEqual(nCompilationBufferOne[1] !== nCompilationBufferTwo[1], true, 'expected buffer output dir to be different'); - await teardown(); - process.exit(0); - }); - } catch (e) { - // Nothing - } -})(); diff --git a/smoketests/watch/watch.single.smoketest.js b/smoketests/watch/watch.single.smoketest.js deleted file mode 100644 index 277bd0950f4..00000000000 --- a/smoketests/watch/watch.single.smoketest.js +++ /dev/null @@ -1,90 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const { unlinkSync, renameSync } = require('fs'); -const { resolve } = require('path'); -// eslint-disable-next-line node/no-unpublished-require -const { appendDataIfFileExists, runAndGetWatchProc, copyFileAsync } = require('../../test/utils/test-utils'); - -console.log('\n============================ SINGLE COMPILATION ============================\n'); - -const testEntryFiles = [ - { - name: 'index.js', - fp: resolve(__dirname, 'index.js'), - cpFp: null, - }, -]; - -/** - * Make a copy of each file - * @returns {void} - */ -async function setup() { - await testEntryFiles.forEach(async (file) => { - file.cpFP = await copyFileAsync(__dirname, file.name); - }); -} - -/** - * Remove symlinks, restore file - * @returns {void} - */ -async function teardown() { - await testEntryFiles.forEach(async (file) => { - try { - unlinkSync(file.fp); - } catch (e) { - console.warn('could not remove the file:' + file.fp + '\n' + e.message); - } finally { - renameSync(file.cpFP, file.fp); - } - }); -} - -(async () => { - try { - await setup(); - - // Spawn one process in watch mode and fill up a buffer of results - const webpackProc = runAndGetWatchProc(__dirname, ['--watch']); - const dataBuffer = []; - - setInterval(() => { - // Close process if time is over 5s - if (process.uptime() > 5) { - assert.strictEqual(true, false, 'Test for child compilation hang, exiting'); - process.exit(-1); - } - appendDataIfFileExists(__dirname, testEntryFiles[0].name, '//junk-comment'); - }, 1000); - - // Array based configuration with child compilation - webpackProc.stdout.on('data', (data) => { - data = data.toString(); - console.log(data); - - if (data.includes('Built')) { - let formattedData = data; - if (data.includes('\u001b')) { - formattedData = data.slice(data.indexOf('Built'), data.indexOf('\u001b')); - } - dataBuffer.push(formattedData); - } - // Close process if buffer is full enough - if (dataBuffer.length > 3) { - webpackProc.kill('SIGINT'); - return; - } - }); - - // Buffer should have compiled equal amount of each compilation and have diff output directories - webpackProc.stderr.on('close', async () => { - assert.strictEqual(dataBuffer.length >= 1, true, 'expected single configuration to re-compile'); - await teardown(); - process.exit(0); - }); - } catch (e) { - // Nothing - } -})(); diff --git a/smoketests/watch/webpack.array.config.js b/smoketests/watch/webpack.array.config.js deleted file mode 100644 index c56a3460b45..00000000000 --- a/smoketests/watch/webpack.array.config.js +++ /dev/null @@ -1,32 +0,0 @@ -const webpack = require('webpack'); -const { join } = require('path'); - -module.exports = [ - { - output: { - path: join(__dirname, 'binary2'), - filename: './prod.js', - }, - mode: 'production', - devtool: 'eval-cheap-module-source-map', - target: 'node', - plugins: [ - new webpack.DefinePlugin({ - PRODUCTION: JSON.stringify(true), - }), - ], - }, - { - output: { - path: join(__dirname, 'binary'), - filename: './dev.js', - }, - mode: 'development', - target: 'node', - plugins: [ - new webpack.DefinePlugin({ - PRODUCTION: JSON.stringify(false), - }), - ], - }, -]; From 1d3e6a736431c2c453c5f6c21be9ad29257ec72e Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 23 Dec 2020 19:36:09 +0300 Subject: [PATCH 186/581] fix: typo in installation message --- packages/webpack-cli/bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index 23030a2c92b..dde3da09046 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -25,7 +25,7 @@ if (packageExists('webpack')) { error(`It looks like ${yellow('webpack')} is not installed.`); }) .then(() => { - success(`${yellow('webpack')} was installed sucessfully.`); + success(`${yellow('webpack')} was installed successfully.`); runCLI(process.argv); }) From 59ca25a344dc1302ccc310062ee1abe696ca26f7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:14:09 +0300 Subject: [PATCH 187/581] chore(deps-dev): bump @types/prettier from 2.1.5 to 2.1.6 (#2257) Bumps [@types/prettier](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/prettier) from 2.1.5 to 2.1.6. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/prettier) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 77cc2d6711f..739043b9db7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2467,9 +2467,9 @@ integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== "@types/prettier@^2.0.0", "@types/prettier@^2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.5.tgz#b6ab3bba29e16b821d84e09ecfaded462b816b00" - integrity sha512-UEyp8LwZ4Dg30kVU2Q3amHHyTn1jEdhCIE59ANed76GaT1Vp76DD3ZWSAxgCrw6wJ0TqeoBpqmfUHiUDPs//HQ== + version "2.1.6" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.6.tgz#f4b1efa784e8db479cdb8b14403e2144b1e9ff03" + integrity sha512-6gOkRe7OIioWAXfnO/2lFiv+SJichKVSys1mSsgyrYHSEjk8Ctv4tSR/Odvnu+HWlH2C8j53dahU03XmQdd5fA== "@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" From 6002c239a0b71aedaf8b75b4bcf5ffdc6d096164 Mon Sep 17 00:00:00 2001 From: Raj Aryan <65965202+Creatoon@users.noreply.github.com> Date: Fri, 25 Dec 2020 17:33:07 +0530 Subject: [PATCH 188/581] docs: fixed articles error in the CONTRIBUTING.md file (#2260) --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5d090dcee53..6b6fb20f151 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -48,7 +48,7 @@ that include your `webpack.config.js` and relevant files. This way you help othe First of all, you will need to create an issue in Github for the feature or bugfix that you want to work on. When you open a new issue, there will be a template that will be automatically added to the text of the issue, which you would need to fill in. Doing this will help us to understand better what the ticket is about. -After you've created the issue, we will have a look, and provide feedback to your ticket. +After you've created an issue, we will have a look, and provide feedback to your ticket. In case it is a bug that you want to fix, we might help you with background information about the issue, so you can make an informed fix. From 05636b70f50338ac122685821f757435596245e2 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 25 Dec 2020 19:04:08 +0300 Subject: [PATCH 189/581] tests: core options for serve --- test/serve/basic/serve-basic.test.js | 27 +++++++++++++++++++++++++++ test/serve/basic/webpack.config.js | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index dff4a541882..16549148b67 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -34,6 +34,33 @@ describe('basic serve usage', () => { expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); + it('should work with the "--mode" option', async () => { + const { stderr, stdout } = await runServe([], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('development'); + expect(stdout).toContain('main.js'); + expect(stdout).not.toContain('HotModuleReplacementPlugin'); + }); + + it('should work with the "--mode" option #2', async () => { + const { stderr, stdout } = await runServe(['--mode', 'production'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('production'); + expect(stdout).toContain('main.js'); + expect(stdout).not.toContain('HotModuleReplacementPlugin'); + }); + + it('should work with the "--mode" option #2', async () => { + const { stderr, stdout } = await runServe(['--mode', 'development'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('development'); + expect(stdout).toContain('main.js'); + expect(stdout).not.toContain('HotModuleReplacementPlugin'); + }); + it('should work with flags', async () => { const { stderr, stdout } = await runServe(['--hot'], __dirname); diff --git a/test/serve/basic/webpack.config.js b/test/serve/basic/webpack.config.js index 39850bab850..98b22edfdc9 100644 --- a/test/serve/basic/webpack.config.js +++ b/test/serve/basic/webpack.config.js @@ -3,5 +3,5 @@ const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); module.exports = { mode: 'development', devtool: false, - plugins: [new WebpackCLITestPlugin(['plugins'], false)], + plugins: [new WebpackCLITestPlugin(['mode', 'plugins'], false)], }; From 2d1e001e7f4f560c2b36607bd1b29dfe2aa32066 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 25 Dec 2020 20:09:34 +0300 Subject: [PATCH 190/581] fix: respect `--watch-options-stdin` --- package.json | 2 +- packages/serve/src/index.ts | 32 ++++- packages/webpack-cli/lib/utils/cli-flags.js | 8 ++ packages/webpack-cli/lib/webpack-cli.js | 91 +++++++++---- test/config/multiple/multiple-config.test.js | 6 +- test/core-flags/watch-flags.test.js | 2 +- test/error/error-in-plugin/error.test.js | 32 +++++ test/error/{ => error-in-plugin}/src/index.js | 0 .../{ => error-in-plugin}/webpack.config.js | 0 test/error/error.test.js | 14 -- .../invalid-schema/invalid-schema.test.js | 73 +++++++++++ .../invalid-schema/webpack.config.mock.js | 0 test/invalid-schema/invalid-schema.test.js | 27 ---- test/watch/{ => simple}/src/index.js | 0 test/watch/{ => simple}/watch.config.js | 0 .../watch.test.js} | 2 +- test/watch/stdin/multi-serve.config.js | 10 ++ test/watch/stdin/multi-watch.config.js | 11 ++ test/watch/stdin/serve.config.js | 5 + test/watch/stdin/src/index.js | 1 + test/watch/stdin/src/second.js | 1 + test/watch/stdin/stdin.test.js | 120 ++++++++++++++++++ test/watch/stdin/watch.config.js | 6 + yarn.lock | 80 ++++++------ 24 files changed, 410 insertions(+), 113 deletions(-) create mode 100644 test/error/error-in-plugin/error.test.js rename test/error/{ => error-in-plugin}/src/index.js (100%) rename test/error/{ => error-in-plugin}/webpack.config.js (100%) delete mode 100644 test/error/error.test.js create mode 100644 test/error/invalid-schema/invalid-schema.test.js rename test/{ => error}/invalid-schema/webpack.config.mock.js (100%) delete mode 100644 test/invalid-schema/invalid-schema.test.js rename test/watch/{ => simple}/src/index.js (100%) rename test/watch/{ => simple}/watch.config.js (100%) rename test/watch/{watch-flag.test.js => simple/watch.test.js} (95%) create mode 100644 test/watch/stdin/multi-serve.config.js create mode 100644 test/watch/stdin/multi-watch.config.js create mode 100644 test/watch/stdin/serve.config.js create mode 100644 test/watch/stdin/src/index.js create mode 100644 test/watch/stdin/src/second.js create mode 100644 test/watch/stdin/stdin.test.js create mode 100644 test/watch/stdin/watch.config.js diff --git a/package.json b/package.json index 199f5c9337a..7ddcd2bc6fb 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", "typescript": "^3.9.7", - "webpack": "^5.10.0", + "webpack": "^5.11.0", "webpack-bundle-analyzer": "^3.9.0", "webpack-dev-server": "^3.11.0", "yeoman-test": "^2.7.0" diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 45a903e7ce7..c8fe5dfc1dd 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -82,8 +82,38 @@ class ServeCommand { const compiler = await cli.createCompiler(webpackOptions); + if (!compiler) { + return; + } + + let servers; + + if (cli.needWatchStdin(compiler) || devServerOptions.stdin) { + // TODO + // Compatibility with old `stdin` option for `webpack-dev-server` + // Should be removed for the next major release on both sides + if (devServerOptions.stdin) { + delete devServerOptions.stdin; + } + + process.stdin.on('end', () => { + Promise.all( + servers.map((server) => { + return new Promise((resolve) => { + server.close(() => { + resolve(); + }); + }); + }), + ).then(() => { + process.exit(0); + }); + }); + process.stdin.resume(); + } + try { - await startDevServer(compiler, devServerOptions, logger); + servers = await startDevServer(compiler, devServerOptions, logger); } catch (error) { if (error.name === 'ValidationError') { logger.error(error.message); diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 57ecfa67651..49272981835 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -8,6 +8,7 @@ const minimumHelpFlags = [ 'env', 'mode', 'watch', + 'watch-options-stdin', 'stats', 'devtool', 'entry', @@ -151,6 +152,13 @@ const builtInFlags = [ description: 'Watch for files changes.', negatedDescription: 'Do not watch for file changes.', }, + { + name: 'watch-options-stdin', + usage: '--watch-options-stdin', + type: Boolean, + negative: true, + description: 'Stop watching when stdin stream has ended.', + }, ]; // Extract all the flags being exported from core. diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 5b7affc6f61..b4ede2b8d62 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1021,6 +1021,13 @@ class WebpackCLI { configOptions.watch = options.watch; } + if (typeof options.watchOptionsStdin !== 'undefined') { + configOptions.watchOptions = { + ...configOptions.watchOptions, + ...{ stdin: options.watchOptionsStdin }, + }; + } + return configOptions; }; @@ -1058,6 +1065,14 @@ class WebpackCLI { return config; } + needWatchStdin(compiler) { + if (compiler.compilers) { + return compiler.compilers.some((compiler) => compiler.options.watchOptions && compiler.options.watchOptions.stdin); + } + + return compiler.options.watchOptions && compiler.options.watchOptions.stdin; + } + async createCompiler(options, callback) { const isValidationError = (error) => { // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 @@ -1098,6 +1113,11 @@ class WebpackCLI { process.exit(2); } + // TODO webpack@4 return Watching and MultiWatching instead Compiler and MultiCompiler, remove this after drop webpack@4 + if (compiler && compiler.compiler) { + compiler = compiler.compiler; + } + return compiler; } @@ -1114,9 +1134,11 @@ class WebpackCLI { process.exitCode = 1; } + // TODO remove after drop webpack@4 + const statsForWebpack4 = webpack.Stats && webpack.Stats.presetToOptions; + const getStatsOptions = (stats) => { - // TODO remove after drop webpack@4 - if (webpack.Stats && webpack.Stats.presetToOptions) { + if (statsForWebpack4) { if (!stats) { stats = {}; } else if (typeof stats === 'boolean' || typeof stats === 'string') { @@ -1144,32 +1166,42 @@ class WebpackCLI { return stats; }; - const getStatsOptionsFromCompiler = (compiler) => getStatsOptions(compiler.options ? compiler.options.stats : undefined); - if (!compiler) { return; } const foundStats = compiler.compilers - ? { children: compiler.compilers.map(getStatsOptionsFromCompiler) } - : getStatsOptionsFromCompiler(compiler); - const handleWriteError = (error) => { - logger.error(error); - process.exit(2); - }; + ? { + children: compiler.compilers.map((compiler) => + getStatsOptions(compiler.options ? compiler.options.stats : undefined), + ), + } + : getStatsOptions(compiler.options ? compiler.options.stats : undefined); + + // TODO webpack@4 doesn't support `{ children: [{ colors: true }, { colors: true }] }` for stats + if (statsForWebpack4 && compiler.compilers) { + foundStats.colors = foundStats.children.some((child) => child.colors); + } + + if (options.json) { + const handleWriteError = (error) => { + logger.error(error); + process.exit(2); + }; - if (options.json === true) { - createJsonStringifyStream(stats.toJson(foundStats)) - .on('error', handleWriteError) - .pipe(process.stdout) - .on('error', handleWriteError) - .on('close', () => process.stdout.write('\n')); - } else if (typeof options.json === 'string') { - createJsonStringifyStream(stats.toJson(foundStats)) - .on('error', handleWriteError) - .pipe(createWriteStream(options.json)) - .on('error', handleWriteError) - .on('close', () => logger.success(`stats are successfully stored as json to ${options.json}`)); + if (options.json === true) { + createJsonStringifyStream(stats.toJson(foundStats)) + .on('error', handleWriteError) + .pipe(process.stdout) + .on('error', handleWriteError) + .on('close', () => process.stdout.write('\n')); + } else { + createJsonStringifyStream(stats.toJson(foundStats)) + .on('error', handleWriteError) + .pipe(createWriteStream(options.json)) + .on('error', handleWriteError) + .on('close', () => logger.success(`stats are successfully stored as json to ${options.json}`)); + } } else { const printedStats = stats.toString(foundStats); @@ -1184,9 +1216,18 @@ class WebpackCLI { compiler = await this.createCompiler(options, callback); - // TODO webpack@4 return Watching and MultiWathing instead Compiler and MultiCompiler, remove this after drop webpack@4 - if (compiler && compiler.compiler) { - compiler = compiler.compiler; + if (!compiler) { + return; + } + + const isWatch = (compiler) => + compiler.compilers ? compiler.compilers.some((compiler) => compiler.options.watch) : compiler.options.watch; + + if (isWatch(compiler) && this.needWatchStdin(compiler)) { + process.stdin.on('end', () => { + process.exit(0); + }); + process.stdin.resume(); } } } diff --git a/test/config/multiple/multiple-config.test.js b/test/config/multiple/multiple-config.test.js index 3daf66584a9..feee98f7bda 100644 --- a/test/config/multiple/multiple-config.test.js +++ b/test/config/multiple/multiple-config.test.js @@ -1,3 +1,5 @@ +const stripAnsi = require('strip-ansi'); + const { run } = require('../../utils/test-utils'); describe('Multiple config flag: ', () => { @@ -8,7 +10,7 @@ describe('Multiple config flag: ', () => { expect(exitCode).toEqual(0); expect(stderr).toBeFalsy(); // Should spawn multiple compilers - expect(stdout).toContain('amd:'); - expect(stdout).toContain('commonjs:'); + expect(stripAnsi(stdout)).toContain('amd:'); + expect(stripAnsi(stdout)).toContain('commonjs:'); }); }); diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index b0f9e8f2892..ddb47635f17 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -11,7 +11,7 @@ describe('watch config related flag', () => { const property = flag.name.split('watch-options-')[1]; const propName = hyphenToUpperCase(property); - if (flag.type === Boolean && flag.name !== 'watch') { + if (flag.type === Boolean && flag.name !== 'watch' && flag.name !== 'watch-options-stdin') { it(`should config --${flag.name} correctly`, () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); diff --git a/test/error/error-in-plugin/error.test.js b/test/error/error-in-plugin/error.test.js new file mode 100644 index 00000000000..159bc0579e3 --- /dev/null +++ b/test/error/error-in-plugin/error.test.js @@ -0,0 +1,32 @@ +'use strict'; + +const { run } = require('../../utils/test-utils'); + +describe('error', () => { + it('should log error with stacktrace', async () => { + const { exitCode, stderr, stdout } = await run(__dirname); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Error: test'); + expect(stderr).toMatch(/at .+ (.+)/); + expect(stdout).toBeFalsy(); + }); + + it('should log error with stacktrace using the "bundle" command', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ['bundle']); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Error: test'); + expect(stderr).toMatch(/at .+ (.+)/); + expect(stdout).toBeFalsy(); + }); + + it('should log error with stacktrace using the "serve" command', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ['serve']); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Error: test'); + expect(stderr).toMatch(/at .+ (.+)/); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/error/src/index.js b/test/error/error-in-plugin/src/index.js similarity index 100% rename from test/error/src/index.js rename to test/error/error-in-plugin/src/index.js diff --git a/test/error/webpack.config.js b/test/error/error-in-plugin/webpack.config.js similarity index 100% rename from test/error/webpack.config.js rename to test/error/error-in-plugin/webpack.config.js diff --git a/test/error/error.test.js b/test/error/error.test.js deleted file mode 100644 index 5096f198b1a..00000000000 --- a/test/error/error.test.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -const { run } = require('../utils/test-utils'); - -describe('error', () => { - it('should log error with stacktrace', async () => { - const { exitCode, stderr, stdout } = await run(__dirname); - - expect(exitCode).toBe(2); - expect(stderr).toContain('Error: test'); - expect(stderr).toMatch(/at .+ (.+)/); - expect(stdout).toBeFalsy(); - }); -}); diff --git a/test/error/invalid-schema/invalid-schema.test.js b/test/error/invalid-schema/invalid-schema.test.js new file mode 100644 index 00000000000..cfcb54542da --- /dev/null +++ b/test/error/invalid-schema/invalid-schema.test.js @@ -0,0 +1,73 @@ +'use strict'; +const { run, isWebpack5 } = require('../../utils/test-utils'); + +describe('invalid schema', () => { + it('should log error on invalid config', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']); + + expect(exitCode).toEqual(2); + expect(stderr).toContain('Invalid configuration object'); + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid config using the "bundle" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--config', './webpack.config.mock.js']); + + expect(exitCode).toEqual(2); + expect(stderr).toContain('Invalid configuration object'); + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid config using the "serve" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--config', './webpack.config.mock.js']); + + expect(exitCode).toEqual(2); + expect(stderr).toContain('Invalid configuration object'); + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid option using "bundle" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid option using "server" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/invalid-schema/webpack.config.mock.js b/test/error/invalid-schema/webpack.config.mock.js similarity index 100% rename from test/invalid-schema/webpack.config.mock.js rename to test/error/invalid-schema/webpack.config.mock.js diff --git a/test/invalid-schema/invalid-schema.test.js b/test/invalid-schema/invalid-schema.test.js deleted file mode 100644 index bfea3e8e5e1..00000000000 --- a/test/invalid-schema/invalid-schema.test.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const { run, isWebpack5 } = require('../utils/test-utils'); - -describe('invalid schema', () => { - it('should log webpack error and exit process on invalid config', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']); - - expect(exitCode).toEqual(2); - expect(stderr).toContain('Invalid configuration object'); - expect(stdout).toBeFalsy(); - }); - - it('should log webpack error and exit process on invalid flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'Yukihira']); - - expect(exitCode).toEqual(2); - - if (isWebpack5) { - expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); - expect(stderr).toContain("Expected: 'development | production | none'"); - } else { - expect(stderr).toContain('Invalid configuration object'); - } - - expect(stdout).toBeFalsy(); - }); -}); diff --git a/test/watch/src/index.js b/test/watch/simple/src/index.js similarity index 100% rename from test/watch/src/index.js rename to test/watch/simple/src/index.js diff --git a/test/watch/watch.config.js b/test/watch/simple/watch.config.js similarity index 100% rename from test/watch/watch.config.js rename to test/watch/simple/watch.config.js diff --git a/test/watch/watch-flag.test.js b/test/watch/simple/watch.test.js similarity index 95% rename from test/watch/watch-flag.test.js rename to test/watch/simple/watch.test.js index 404a17fc568..4ddf7386acb 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/simple/watch.test.js @@ -1,7 +1,7 @@ 'use strict'; const stripAnsi = require('strip-ansi'); -const { run, runAndGetWatchProc, isWebpack5 } = require('../utils/test-utils'); +const { run, runAndGetWatchProc, isWebpack5 } = require('../../utils/test-utils'); const { writeFileSync } = require('fs'); const { resolve } = require('path'); diff --git a/test/watch/stdin/multi-serve.config.js b/test/watch/stdin/multi-serve.config.js new file mode 100644 index 00000000000..ff242580667 --- /dev/null +++ b/test/watch/stdin/multi-serve.config.js @@ -0,0 +1,10 @@ +module.exports = [ + { + entry: './src/second.js', + }, + { + watchOptions: { + stdin: true, + }, + }, +]; diff --git a/test/watch/stdin/multi-watch.config.js b/test/watch/stdin/multi-watch.config.js new file mode 100644 index 00000000000..d722eda347a --- /dev/null +++ b/test/watch/stdin/multi-watch.config.js @@ -0,0 +1,11 @@ +module.exports = [ + { + entry: './src/second.js', + }, + { + watch: true, + watchOptions: { + stdin: true, + }, + }, +]; diff --git a/test/watch/stdin/serve.config.js b/test/watch/stdin/serve.config.js new file mode 100644 index 00000000000..dadb8eaff5c --- /dev/null +++ b/test/watch/stdin/serve.config.js @@ -0,0 +1,5 @@ +module.exports = { + watchOptions: { + stdin: true, + }, +}; diff --git a/test/watch/stdin/src/index.js b/test/watch/stdin/src/index.js new file mode 100644 index 00000000000..efc51ca0a97 --- /dev/null +++ b/test/watch/stdin/src/index.js @@ -0,0 +1 @@ +console.log('watch flag test'); \ No newline at end of file diff --git a/test/watch/stdin/src/second.js b/test/watch/stdin/src/second.js new file mode 100644 index 00000000000..1d8734ee1c8 --- /dev/null +++ b/test/watch/stdin/src/second.js @@ -0,0 +1 @@ +console.log('watch flag test'); diff --git a/test/watch/stdin/stdin.test.js b/test/watch/stdin/stdin.test.js new file mode 100644 index 00000000000..06d285d53ab --- /dev/null +++ b/test/watch/stdin/stdin.test.js @@ -0,0 +1,120 @@ +const { runAndGetWatchProc } = require('../../utils/test-utils'); + +describe('--watch-options-stdin', () => { + it.only('should stop the process when stdin ends using "--watch" and "--watch-options-stdin" options', (done) => { + const proc = runAndGetWatchProc(__dirname, ['--watch', '--watch-options-stdin'], false, '', true); + + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + + proc.kill(); + + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); + + it('should stop the process when stdin ends using the config file', (done) => { + const proc = runAndGetWatchProc(__dirname, ['--config', './watch.config.js'], false, '', true); + + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + + proc.kill(); + + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); + + it('should stop the process when stdin ends using the config file in multi compiler mode', (done) => { + const proc = runAndGetWatchProc(__dirname, ['--config', './multi-watch.config.js'], false, '', true); + + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + + proc.kill(); + + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); + + it('should stop the process when stdin ends using the "serve" command and the "--watch-options-stdin" option', (done) => { + const proc = runAndGetWatchProc(__dirname, ['serve', '--watch-options-stdin'], false, '', true); + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + proc.kill(); + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); + + it('should stop the process when stdin ends using the "serve" command and the "--stdin" option', (done) => { + const proc = runAndGetWatchProc(__dirname, ['serve', '--stdin'], false, '', true); + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + proc.kill(); + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); + + it('should stop the process when stdin ends using the "serve" command and configuration', (done) => { + const proc = runAndGetWatchProc(__dirname, ['serve', '--config', './serve.config.js'], false, '', true); + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + proc.kill(); + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); + + it('should stop the process when stdin ends using the "serve" command and the config file in multi compiler mode', (done) => { + const proc = runAndGetWatchProc(__dirname, ['--config', './multi-watch.config.js'], false, '', true); + + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + + proc.kill(); + + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); +}); diff --git a/test/watch/stdin/watch.config.js b/test/watch/stdin/watch.config.js new file mode 100644 index 00000000000..1299830a892 --- /dev/null +++ b/test/watch/stdin/watch.config.js @@ -0,0 +1,6 @@ +module.exports = { + watch: true, + watchOptions: { + stdin: true, + }, +}; diff --git a/yarn.lock b/yarn.lock index 739043b9db7..3a780f28088 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2320,9 +2320,9 @@ integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== "@types/eslint@*": - version "7.2.4" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.4.tgz#d12eeed7741d2491b69808576ac2d20c14f74c41" - integrity sha512-YCY4kzHMsHoyKspQH+nwSe+70Kep7Vjt2X+dZe5Vs2vkRudqtoFoUIv1RlJmZB8Hbp7McneupoZij4PadxsK5Q== + version "7.2.6" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.6.tgz#5e9aff555a975596c03a98b59ecd103decc70c3c" + integrity sha512-I+1sYH+NPQ3/tVqCeUSBwTE/0heyvtXqpIopUUArlBm0Kpocb8FbMa3AZ/ASKIFpN3rnEx932TTXDbt9OXsNDw== dependencies: "@types/estree" "*" "@types/json-schema" "*" @@ -4292,13 +4292,20 @@ debug@3.1.0, debug@=3.1.0: dependencies: ms "2.0.0" -debug@^3.1.0, debug@^3.1.1, debug@^3.2.5: +debug@^3.1.0, debug@^3.1.1: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== dependencies: ms "^2.1.1" +debug@^3.2.5: + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== + dependencies: + ms "^2.1.1" + debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" @@ -4714,12 +4721,12 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: once "^1.4.0" enhanced-resolve@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.3.1.tgz#3f988d0d7775bdc2d96ede321dc81f8249492f57" - integrity sha512-G1XD3MRGrGfNcf6Hg0LVZG7GIKcYkbfHa5QMxt1HDUTdYoXH0JR1xXyg+MaKLF73E9A27uWNVxvFivNRYeUB6w== + version "5.4.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.4.1.tgz#c89b0c34f17f931902ef2913a125d4b825b49b6f" + integrity sha512-4GbyIMzYktTFoRSmkbgZ1LU+RXwf4AQ8Z+rSuuh1dC8plp0PPeaWvx6+G4hh4KnUJ48VoxKbNyA1QQQIUpXjYA== dependencies: graceful-fs "^4.2.4" - tapable "^2.0.0" + tapable "^2.2.0" enquirer@^2.3.5, enquirer@^2.3.6: version "2.3.6" @@ -4749,9 +4756,9 @@ errlop@^2.0.0: integrity sha512-e64Qj9+4aZzjzzFpZC7p5kmm/ccCrbLhAJplhsDXQFs87XTsXwOpH4s1Io2s90Tau/8r2j9f4l/thhDevRjzxw== errno@^0.1.3: - version "0.1.7" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618" - integrity sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg== + version "0.1.8" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" + integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== dependencies: prr "~1.0.1" @@ -7364,16 +7371,7 @@ jest-watcher@^26.6.2: jest-util "^26.6.2" string-length "^4.0.1" -jest-worker@^26.6.1: - version "26.6.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.1.tgz#c2ae8cde6802cc14056043f997469ec170d9c32a" - integrity sha512-R5IE3qSGz+QynJx8y+ICEkdI2OJ3RJjRQVEyCcFAd3yVhQSEtquziPO29Mlzgn07LOVE8u8jhJ1FqcwegiXWOw== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^7.0.0" - -jest-worker@^26.6.2: +jest-worker@^26.6.1, jest-worker@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== @@ -7909,9 +7907,9 @@ log-update@^4.0.0: wrap-ansi "^6.2.0" loglevel@^1.6.8: - version "1.7.0" - resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.0.tgz#728166855a740d59d38db01cf46f042caa041bb0" - integrity sha512-i2sY04nal5jDcagM3FMfG++T69GEEM8CYuOfeOIvmXzOIcwE9a/CJPR0MFM97pYMj/u10lzz7/zd7+qwhrBTqQ== + version "1.7.1" + resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197" + integrity sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw== loud-rejection@^1.0.0: version "1.6.0" @@ -8219,9 +8217,9 @@ mime@1.6.0: integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== mime@^2.4.4: - version "2.4.6" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1" - integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA== + version "2.4.7" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.7.tgz#962aed9be0ed19c91fd7dc2ece5d7f4e89a90d74" + integrity sha512-dhNd1uA2u397uQk3Nv5LM4lm93WYDUXFn3Fu291FJerns4jyTudqhIWe4W04YLy7Uk1tm1Ore04NpjRvQp/NPA== mimic-fn@^1.0.0: version "1.2.0" @@ -10886,10 +10884,10 @@ table@^6.0.4: slice-ansi "^4.0.0" string-width "^4.2.0" -tapable@^2.0.0, tapable@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.1.1.tgz#b01cc1902d42a7bb30514e320ce21c456f72fd3f" - integrity sha512-Wib1S8m2wdpLbmQz0RBEVosIyvb/ykfKXf3ZIDqvWoMg/zTNm6G/tDSuUM61J1kNCDXWJrLHGSFeMhAG+gAGpQ== +tapable@^2.1.1, tapable@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b" + integrity sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw== tar@^4.4.10, tar@^4.4.12, tar@^4.4.8: version "4.4.13" @@ -10957,9 +10955,9 @@ terser-webpack-plugin@^5.0.3: terser "^5.3.8" terser@^5.3.8: - version "5.3.8" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.3.8.tgz#991ae8ba21a3d990579b54aa9af11586197a75dd" - integrity sha512-zVotuHoIfnYjtlurOouTazciEfL7V38QMAOhGqpXDEg6yT13cF4+fEP9b0rrCEQTn+tT46uxgFsTZzhygk+CzQ== + version "5.5.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.5.1.tgz#540caa25139d6f496fdea056e414284886fb2289" + integrity sha512-6VGWZNVP2KTUcltUQJ25TtNjx/XgdDsBDKGt8nN0MpydU36LmbPPcMBd2kmtZNNGVVDLg44k7GKeHHj+4zPIBQ== dependencies: commander "^2.20.0" source-map "~0.7.2" @@ -11538,9 +11536,9 @@ walker@^1.0.7, walker@~1.0.5: makeerror "1.0.x" watchpack@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0.tgz#b12248f32f0fd4799b7be0802ad1f6573a45955c" - integrity sha512-xSdCxxYZWNk3VK13bZRYhsQpfa8Vg63zXG+3pyU8ouqSLRCv4IGXIp9Kr226q6GBkGRlZrST2wwKtjfKz2m7Cg== + version "2.1.0" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.1.0.tgz#e63194736bf3aa22026f7b191cd57907b0f9f696" + integrity sha512-UjgD1mqjkG99+3lgG36at4wPnUXNvis2v1utwTgQ43C22c4LD71LsYMExdWXh4HZ+RmW+B0t1Vrg2GpXAkTOQw== dependencies: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" @@ -11594,9 +11592,9 @@ webpack-bundle-analyzer@^3.9.0: ws "^6.0.0" webpack-dev-middleware@^3.7.2: - version "3.7.2" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-3.7.2.tgz#0019c3db716e3fa5cecbf64f2ab88a74bab331f3" - integrity sha512-1xC42LxbYoqLNAhV6YzTYacicgMZQTqRd27Sim9wn5hJrX3I5nxYy1SxSd4+gjUFsz1dQFj+yEe6zEVmSkeJjw== + version "3.7.3" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-3.7.3.tgz#0639372b143262e2b84ab95d3b91a7597061c2c5" + integrity sha512-djelc/zGiz9nZj/U7PTBi2ViorGJXEWo/3ltkPbDyxCXhhEXkW0ce99falaok4TPj+AsxLiXJR0EBOb0zh9fKQ== dependencies: memory-fs "^0.4.1" mime "^2.4.4" @@ -11666,7 +11664,7 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.10.0: +webpack@^5.11.0: version "5.11.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.11.0.tgz#1647abc060441d86d01d8835b8f0fc1dae2fe76f" integrity sha512-ubWv7iP54RqAC/VjixgpnLLogCFbAfSOREcSWnnOlZEU8GICC5eKmJSu6YEnph2N2amKqY9rvxSwgyHxVqpaRw== From 7c2311a541d93e67d9c328f26b96d36418eac823 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Fri, 25 Dec 2020 20:23:21 +0300 Subject: [PATCH 191/581] chore(release): publish new version - @webpack-cli/generators@1.2.0 - @webpack-cli/info@1.2.0 - @webpack-cli/init@1.1.0 - @webpack-cli/migrate@1.1.1 - @webpack-cli/serve@1.2.0 - @webpack-cli/utils@1.2.0 - webpack-cli@4.3.0 --- CHANGELOG.md | 56 +++++++++++++++++++++++++++++++ packages/generators/CHANGELOG.md | 10 ++++++ packages/generators/package.json | 4 +-- packages/info/CHANGELOG.md | 6 ++++ packages/info/package.json | 2 +- packages/init/CHANGELOG.md | 6 ++++ packages/init/package.json | 6 ++-- packages/migrate/CHANGELOG.md | 4 +++ packages/migrate/package.json | 4 +-- packages/serve/CHANGELOG.md | 11 ++++++ packages/serve/package.json | 2 +- packages/utils/CHANGELOG.md | 10 ++++++ packages/utils/package.json | 2 +- packages/webpack-cli/CHANGELOG.md | 23 +++++++++++++ packages/webpack-cli/package.json | 6 ++-- 15 files changed, 139 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9cecac5a2c..2296eaf03c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,59 @@ +# [4.3.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.2.0...webpack-cli@4.3.0) (2020-12-25) + +### Bug Fixes + +- fix problems with `--mode` and config resolution, there are situations when we resolve an invalid config file, the `--mode` option does not affect on config resolution, if you faced with an error after updating, please use the `--config` option +- correct usage of cli-flags ([#2205](https://github.com/webpack/webpack-cli/issues/2205)) ([c8fc7d1](https://github.com/webpack/webpack-cli/commit/c8fc7d1f195800c4fbe54ed6533e694f40fa7a1b)) +- defer setting default mode to core ([#2095](https://github.com/webpack/webpack-cli/issues/2095)) ([3eb410e](https://github.com/webpack/webpack-cli/commit/3eb410e5d8f8e2149910b65f4a028c85f8af5d28)) +- respect the `--watch-options-stdin` option ([2d1e001](https://github.com/webpack/webpack-cli/commit/2d1e001e7f4f560c2b36607bd1b29dfe2aa32066)) +- respect `--color`/`--no-color` option ([#2042](https://github.com/webpack/webpack-cli/issues/2042)) ([09bd812](https://github.com/webpack/webpack-cli/commit/09bd8126e95c9675b1f6862451f629cd4c439adb)) +- stringify stats using streaming approach ([#2190](https://github.com/webpack/webpack-cli/issues/2190)) ([9bf4e92](https://github.com/webpack/webpack-cli/commit/9bf4e925757b02f7252073501562c95e762dc59b)) +- use logger for error with proper exit code ([#2076](https://github.com/webpack/webpack-cli/issues/2076)) ([2c9069f](https://github.com/webpack/webpack-cli/commit/2c9069fd1f7c0fb70f019900e4b841c5ea33975e)) +- reduce spammy logs ([#2206](https://github.com/webpack/webpack-cli/issues/2206)) ([9b3cc28](https://github.com/webpack/webpack-cli/commit/9b3cc283d7b74aa3bb26fe36c6110436b016e0d9)) +- respect the `infrastructureLogging.level` option (logger uses `stderr`) ([#2144](https://github.com/webpack/webpack-cli/issues/2144)) ([7daccc7](https://github.com/webpack/webpack-cli/commit/7daccc786a0eb4eeae4c5b3632fc28240a696170)) +- respect all options from command line for the `server` command +- `help` and `version` output +- respect `stats` from the config (webpack@4) ([#2098](https://github.com/webpack/webpack-cli/issues/2098)) ([2d6e5c6](https://github.com/webpack/webpack-cli/commit/2d6e5c6f4ed967368a81742bf347e39f24ee16c8)) +- fixed colors work with multi compiler mode (webpack@4) + +### Features + +- add `bundle` command (alias for `webpack [options]`) +- add `pnpm` support for package installation ([#2040](https://github.com/webpack/webpack-cli/issues/2040)) ([46cba36](https://github.com/webpack/webpack-cli/commit/46cba367f06a6354fe98fcb15e7771e819feeac0)) + +# [4.2.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.1.0...webpack-cli@4.2.0) (2020-11-04) + +### Bug Fixes + +- --config-name behaviour for fuctional configs ([#2006](https://github.com/webpack/webpack-cli/issues/2006)) ([29ecf8d](https://github.com/webpack/webpack-cli/commit/29ecf8dbcd1c5c7d75fc7fb1634107697832d952)) +- assign cache value for default configs ([#2013](https://github.com/webpack/webpack-cli/issues/2013)) ([d2e3c74](https://github.com/webpack/webpack-cli/commit/d2e3c74d32b0141c694259cf4f31e6c48b0f681d)) +- callback deprecation ([#1977](https://github.com/webpack/webpack-cli/issues/1977)) ([2cb0c0e](https://github.com/webpack/webpack-cli/commit/2cb0c0e383670949ce31231edbfda514f47c3dfc)) +- handle core flags for webpack 4 ([#2023](https://github.com/webpack/webpack-cli/issues/2023)) ([ea66a7e](https://github.com/webpack/webpack-cli/commit/ea66a7e3ec6eabcc439b96acb21e2a25be2e35e5)) +- help and version functionality ([#1972](https://github.com/webpack/webpack-cli/issues/1972)) ([e8010b3](https://github.com/webpack/webpack-cli/commit/e8010b3aac695971e542ad4d3584ce534da39b8f)) + +### Features + +- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) +- progress supports string argument ([#2000](https://github.com/webpack/webpack-cli/issues/2000)) ([f13346e](https://github.com/webpack/webpack-cli/commit/f13346e6acb46e982a5d20fa1d2ae56fc52523dc)) +- suggest the closest match based on the Levenshtein distance algorithm ([#2010](https://github.com/webpack/webpack-cli/issues/2010)) ([491a582](https://github.com/webpack/webpack-cli/commit/491a582620b64ed4acbccd04f687adc28a5e4cff)) + +# [4.1.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.0.0...webpack-cli@4.1.0) (2020-10-19) + +### Bug Fixes + +- avoid unnecessary stringify ([#1920](https://github.com/webpack/webpack-cli/issues/1920)) ([5ef1e7b](https://github.com/webpack/webpack-cli/commit/5ef1e7b074390406b76cb3e25dd90f045e1bd8a2)) +- colored output ([#1944](https://github.com/webpack/webpack-cli/issues/1944)) ([2bbbb14](https://github.com/webpack/webpack-cli/commit/2bbbb14ca9a404f2205c0f5a5515e73832ee6173)) +- move init command to separate package ([#1950](https://github.com/webpack/webpack-cli/issues/1950)) ([92ad475](https://github.com/webpack/webpack-cli/commit/92ad475d4b9606b5db7c31dd3666658301c95597)) +- output stacktrace on errors ([#1949](https://github.com/webpack/webpack-cli/issues/1949)) ([9ba9d6f](https://github.com/webpack/webpack-cli/commit/9ba9d6f460fb25fb79d52f4360239b8c4b471451)) +- run CLI after webpack installation ([#1951](https://github.com/webpack/webpack-cli/issues/1951)) ([564279e](https://github.com/webpack/webpack-cli/commit/564279e5b634a399647bcdb21449e5e6a7f0637e)) +- support any config name ([#1926](https://github.com/webpack/webpack-cli/issues/1926)) ([6f95b26](https://github.com/webpack/webpack-cli/commit/6f95b267bf6a3a3e71360f4de176a4ebbec3afa1)) +- support array of functions and promises ([#1946](https://github.com/webpack/webpack-cli/issues/1946)) ([2ace39b](https://github.com/webpack/webpack-cli/commit/2ace39b06117f558c0d8528cea9248253cbdf593)) +- watch mode and options ([#1931](https://github.com/webpack/webpack-cli/issues/1931)) ([258219a](https://github.com/webpack/webpack-cli/commit/258219a3bb606b228636e6373a3d20413c1f660e)) + +### Features + +- allow passing strings in env flag ([#1939](https://github.com/webpack/webpack-cli/issues/1939)) ([cc081a2](https://github.com/webpack/webpack-cli/commit/cc081a256181e34137a89d2e9d37b04280b3f180)) + # [4.0.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.0.0-rc.1...webpack-cli@4.0.0) (2020-10-10) ### Bug Fixes diff --git a/packages/generators/CHANGELOG.md b/packages/generators/CHANGELOG.md index 4d555e018ea..34b698e7486 100644 --- a/packages/generators/CHANGELOG.md +++ b/packages/generators/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.1.0...@webpack-cli/generators@1.2.0) (2020-12-25) + +### Bug Fixes + +- typos in options + +### Features + +- union generators + # [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.0.2...@webpack-cli/generators@1.1.0) (2020-11-04) ### Bug Fixes diff --git a/packages/generators/package.json b/packages/generators/package.json index 741d7cdef0e..95463bc867c 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generators", - "version": "1.1.0", + "version": "1.2.0", "description": "Webpack-CLI generators", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -14,7 +14,7 @@ "templates" ], "dependencies": { - "@webpack-cli/utils": "^1.1.0", + "@webpack-cli/utils": "^1.2.0", "colorette": "^1.2.1", "log-symbols": "^4.0.0", "yeoman-environment": "^2.10.3", diff --git a/packages/info/CHANGELOG.md b/packages/info/CHANGELOG.md index 10bea6d66c9..ba92309543f 100644 --- a/packages/info/CHANGELOG.md +++ b/packages/info/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.1.0...@webpack-cli/info@1.2.0) (2020-12-25) + +### Features + +- display monorepos in info output ([#2203](https://github.com/webpack/webpack-cli/issues/2203)) ([d0acf30](https://github.com/webpack/webpack-cli/commit/d0acf3072edd8182c95e37997ac91789da899d66)) + # [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.2...@webpack-cli/info@1.1.0) (2020-11-04) ### Bug Fixes diff --git a/packages/info/package.json b/packages/info/package.json index b046d31af49..44a6eb34749 100644 --- a/packages/info/package.json +++ b/packages/info/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/info", - "version": "1.1.0", + "version": "1.2.0", "description": "Outputs info about system and webpack config", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/init/CHANGELOG.md b/packages/init/CHANGELOG.md index 862a63fe3ad..97e89695a3f 100644 --- a/packages/init/CHANGELOG.md +++ b/packages/init/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.3...@webpack-cli/init@1.1.0) (2020-12-25) + +### Features + +- add `--generation-path` option ([#2050](https://github.com/webpack/webpack-cli/issues/2050)) ([413eb8c](https://github.com/webpack/webpack-cli/commit/413eb8cf2add4978763a4c9ee6b983582685768b)) + ## [1.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.2...@webpack-cli/init@1.0.3) (2020-11-04) **Note:** Version bump only for package @webpack-cli/init diff --git a/packages/init/package.json b/packages/init/package.json index 7a407d6f876..8cd6773dd3d 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/init", - "version": "1.0.3", + "version": "1.1.0", "description": "init command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,8 +12,8 @@ "lib" ], "dependencies": { - "@webpack-cli/generators": "^1.1.0", - "@webpack-cli/utils": "^1.1.0" + "@webpack-cli/generators": "^1.2.0", + "@webpack-cli/utils": "^1.2.0" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", diff --git a/packages/migrate/CHANGELOG.md b/packages/migrate/CHANGELOG.md index 660698111cb..cd4609fd11f 100644 --- a/packages/migrate/CHANGELOG.md +++ b/packages/migrate/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.1.0...@webpack-cli/migrate@1.1.1) (2020-12-25) + +**Note:** Version bump only for package @webpack-cli/migrate + # [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.2...@webpack-cli/migrate@1.1.0) (2020-11-04) ### Features diff --git a/packages/migrate/package.json b/packages/migrate/package.json index 3646191812b..b5d55622eda 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/migrate", - "version": "1.1.0", + "version": "1.1.1", "description": "Migrate command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,7 +12,7 @@ "lib" ], "dependencies": { - "@webpack-cli/utils": "^1.1.0", + "@webpack-cli/utils": "^1.2.0", "colorette": "^1.2.1", "diff": "^4.0.2", "inquirer": "^7.3.3", diff --git a/packages/serve/CHANGELOG.md b/packages/serve/CHANGELOG.md index 6c0ba1a0279..6d717309c1d 100644 --- a/packages/serve/CHANGELOG.md +++ b/packages/serve/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.1.0...@webpack-cli/serve@1.2.0) (2020-12-25) + +### Bug Fixes + +- respect `--watch-options-stdin` ([2d1e001](https://github.com/webpack/webpack-cli/commit/2d1e001e7f4f560c2b36607bd1b29dfe2aa32066)) +- do not default host in webpack-dev-server v4 ([#2141](https://github.com/webpack/webpack-cli/issues/2141)) ([dbbe4d4](https://github.com/webpack/webpack-cli/commit/dbbe4d4bc93ff9147ba43fae2d2352fa3583558d)) +- do not default port in webpack-dev-server v4 ([#2126](https://github.com/webpack/webpack-cli/issues/2126)) ([cda3047](https://github.com/webpack/webpack-cli/commit/cda30471f51db4631a0f54b852c553de270f7f64)) +- set client port when using default port ([#2147](https://github.com/webpack/webpack-cli/issues/2147)) ([4b97348](https://github.com/webpack/webpack-cli/commit/4b973488a42c4e12d86e0324a4c7051d1380a6fa)) +- catch dev server import during webpack serve ([#2070](https://github.com/webpack/webpack-cli/issues/2070)) ([70bf770](https://github.com/webpack/webpack-cli/commit/70bf7708c21dffe6521f1800b9dec2a62d21cfe2)) +- respect `--color`/`--no-color` options ([#2042](https://github.com/webpack/webpack-cli/issues/2042)) ([09bd812](https://github.com/webpack/webpack-cli/commit/09bd8126e95c9675b1f6862451f629cd4c439adb)) + # [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1...@webpack-cli/serve@1.1.0) (2020-11-04) ### Bug Fixes diff --git a/packages/serve/package.json b/packages/serve/package.json index e752d1e7fd3..8494acaeafc 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/serve", - "version": "1.1.0", + "version": "1.2.0", "description": "", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 7736c48bd47..8772374651c 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.1.0...@webpack-cli/utils@1.2.0) (2020-12-25) + +### Bug Fixes + +- remove duplicate log ([#2079](https://github.com/webpack/webpack-cli/issues/2079)) ([112068d](https://github.com/webpack/webpack-cli/commit/112068dc5b962a773c5db00e4e1140e8733ea9ec)) + +### Features + +- **init:** add --generation-path flag ([#2050](https://github.com/webpack/webpack-cli/issues/2050)) ([413eb8c](https://github.com/webpack/webpack-cli/commit/413eb8cf2add4978763a4c9ee6b983582685768b)) + # [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.2...@webpack-cli/utils@1.1.0) (2020-11-04) ### Features diff --git a/packages/utils/package.json b/packages/utils/package.json index 8ceef2af2f9..7ef4459979d 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/utils", - "version": "1.1.0", + "version": "1.2.0", "description": "webpack-cli utility files", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/webpack-cli/CHANGELOG.md b/packages/webpack-cli/CHANGELOG.md index 26b8d4ee3a6..aca420758ac 100644 --- a/packages/webpack-cli/CHANGELOG.md +++ b/packages/webpack-cli/CHANGELOG.md @@ -3,6 +3,29 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.3.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.2.0...webpack-cli@4.3.0) (2020-12-25) + +### Bug Fixes + +- fix problems with `--mode` and config resolution, there are situations when we resolve an invalid config file, the `--mode` option does not affect on config resolution, if you faced with an error after updating, please use the `--config` option +- correct usage of cli-flags ([#2205](https://github.com/webpack/webpack-cli/issues/2205)) ([c8fc7d1](https://github.com/webpack/webpack-cli/commit/c8fc7d1f195800c4fbe54ed6533e694f40fa7a1b)) +- defer setting default mode to core ([#2095](https://github.com/webpack/webpack-cli/issues/2095)) ([3eb410e](https://github.com/webpack/webpack-cli/commit/3eb410e5d8f8e2149910b65f4a028c85f8af5d28)) +- respect the `--watch-options-stdin` option ([2d1e001](https://github.com/webpack/webpack-cli/commit/2d1e001e7f4f560c2b36607bd1b29dfe2aa32066)) +- respect `--color`/`--no-color` option ([#2042](https://github.com/webpack/webpack-cli/issues/2042)) ([09bd812](https://github.com/webpack/webpack-cli/commit/09bd8126e95c9675b1f6862451f629cd4c439adb)) +- stringify stats using streaming approach ([#2190](https://github.com/webpack/webpack-cli/issues/2190)) ([9bf4e92](https://github.com/webpack/webpack-cli/commit/9bf4e925757b02f7252073501562c95e762dc59b)) +- use logger for error with proper exit code ([#2076](https://github.com/webpack/webpack-cli/issues/2076)) ([2c9069f](https://github.com/webpack/webpack-cli/commit/2c9069fd1f7c0fb70f019900e4b841c5ea33975e)) +- reduce spammy logs ([#2206](https://github.com/webpack/webpack-cli/issues/2206)) ([9b3cc28](https://github.com/webpack/webpack-cli/commit/9b3cc283d7b74aa3bb26fe36c6110436b016e0d9)) +- respect the `infrastructureLogging.level` option (logger uses `stderr`) ([#2144](https://github.com/webpack/webpack-cli/issues/2144)) ([7daccc7](https://github.com/webpack/webpack-cli/commit/7daccc786a0eb4eeae4c5b3632fc28240a696170)) +- respect all options from command line for the `server` command +- `help` and `version` output +- respect `stats` from the config (webpack@4) ([#2098](https://github.com/webpack/webpack-cli/issues/2098)) ([2d6e5c6](https://github.com/webpack/webpack-cli/commit/2d6e5c6f4ed967368a81742bf347e39f24ee16c8)) +- fixed colors work with multi compiler mode (webpack@4) + +### Features + +- add `bundle` command (alias for `webpack [options]`) +- add `pnpm` support for package installation ([#2040](https://github.com/webpack/webpack-cli/issues/2040)) ([46cba36](https://github.com/webpack/webpack-cli/commit/46cba367f06a6354fe98fcb15e7771e819feeac0)) + # [4.2.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.1.0...webpack-cli@4.2.0) (2020-11-04) ### Bug Fixes diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 2d76c9e8aef..84e827d69f3 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -1,6 +1,6 @@ { "name": "webpack-cli", - "version": "4.2.0", + "version": "4.3.0", "description": "CLI for webpack & friends", "license": "MIT", "repository": { @@ -28,8 +28,8 @@ ], "dependencies": { "@discoveryjs/json-ext": "^0.5.0", - "@webpack-cli/info": "^1.1.0", - "@webpack-cli/serve": "^1.1.0", + "@webpack-cli/info": "^1.2.0", + "@webpack-cli/serve": "^1.2.0", "colorette": "^1.2.1", "commander": "^6.2.0", "enquirer": "^2.3.6", From b5f494d6255a7e209ade52a1b66fde3814199e84 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 26 Dec 2020 18:51:05 +0300 Subject: [PATCH 192/581] chore(deps-dev): bump @types/node from 14.14.14 to 14.14.16 (#2255) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.14 to 14.14.16. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3a780f28088..b07154704e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2452,9 +2452,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.14" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae" - integrity sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ== + version "14.14.16" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.16.tgz#3cc351f8d48101deadfed4c9e4f116048d437b4b" + integrity sha512-naXYePhweTi+BMv11TgioE2/FXU4fSl29HAH1ffxVciNsH3rYXjNP2yM8wqmSm7jS20gM8TIklKiTen+1iVncw== "@types/normalize-package-data@^2.4.0": version "2.4.0" From e6f99439fe0668a18488b74f10fa5175089d0a14 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 26 Dec 2020 18:51:21 +0300 Subject: [PATCH 193/581] chore(deps): bump @discoveryjs/json-ext from 0.5.1 to 0.5.2 (#2264) Bumps [@discoveryjs/json-ext](https://github.com/discoveryjs/json-ext) from 0.5.1 to 0.5.2. - [Release notes](https://github.com/discoveryjs/json-ext/releases) - [Changelog](https://github.com/discoveryjs/json-ext/blob/master/CHANGELOG.md) - [Commits](https://github.com/discoveryjs/json-ext/compare/v0.5.1...v0.5.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b07154704e6..5eb31c139ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1051,9 +1051,9 @@ integrity sha512-VoNqai1vR5anRF5Tuh/+SWDFk7xi7oMwHrHrbm1BprYXjB2RJsWLhUrStMssDxEl5lW/z3EUdg8RvH/IUBccSQ== "@discoveryjs/json-ext@^0.5.0": - version "0.5.1" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.1.tgz#cf87081ac9b0f3eb3b5740415b50b7966bac8fc5" - integrity sha512-Oee4NT60Lxe90m7VTYBU4UbABNaz0N4Q3G62CPB+6mGE4KuLMsTACmH8q3PH5u9pSZCuOdE9JClJ9vBqsp6DQg== + version "0.5.2" + resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz#8f03a22a04de437254e8ce8cc84ba39689288752" + integrity sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg== "@eslint/eslintrc@^0.2.2": version "0.2.2" From 952a1883b1a18c4fb38e8eb7bbbdb2aefc7942f4 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Sat, 26 Dec 2020 19:27:04 +0300 Subject: [PATCH 194/581] fix: the `--progress` option with the `serve` command (#2265) --- packages/serve/__tests__/mergeOptions.test.ts | 34 ------------------- packages/serve/src/index.ts | 2 +- packages/serve/src/mergeOptions.ts | 24 ------------- packages/serve/src/startDevServer.ts | 17 ++++++++-- test/serve/basic/serve-basic.test.js | 16 +++++++++ 5 files changed, 31 insertions(+), 62 deletions(-) delete mode 100644 packages/serve/__tests__/mergeOptions.test.ts delete mode 100644 packages/serve/src/mergeOptions.ts diff --git a/packages/serve/__tests__/mergeOptions.test.ts b/packages/serve/__tests__/mergeOptions.test.ts deleted file mode 100644 index 5b97dacfb87..00000000000 --- a/packages/serve/__tests__/mergeOptions.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -import mergeOptions from '../src/mergeOptions'; -import { devServerClientLogging } from '../src/types'; - -describe('mergeOptions', () => { - it('merges CLI and devServer options correctly', () => { - const cliOptions = { - client: { - logging: devServerClientLogging.verbose, - }, - hot: true, - bonjour: true, - }; - const devServerOptions = { - client: { - host: 'localhost', - logging: devServerClientLogging.none, - }, - hot: false, - liveReload: false, - }; - // CLI should take priority - expect(mergeOptions(cliOptions, devServerOptions)).toEqual({ - client: { - host: 'localhost', - logging: 'verbose', - }, - hot: true, - bonjour: true, - liveReload: false, - }); - }); -}); diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index c8fe5dfc1dd..0987e357b90 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -51,7 +51,7 @@ class ServeCommand { const processors: Array<(opts: Record) => void> = []; for (const optionName in options) { - if (optionName === 'hot' || optionName === 'progress') { + if (optionName === 'hot') { devServerOptions[optionName] = options[optionName]; webpackOptions[optionName] = options[optionName]; } else { diff --git a/packages/serve/src/mergeOptions.ts b/packages/serve/src/mergeOptions.ts deleted file mode 100644 index 6022dc4ffb8..00000000000 --- a/packages/serve/src/mergeOptions.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { devServerOptionsType } from './types'; - -/** - * - * Merges CLI options and devServer options from config file - * - * @param {Object} cliOptions - devServer CLI args - * @param {Object} devServerOptions - devServer config options - * - * @returns {Object} merged options object - */ -export default function mergeOptions(cliOptions: devServerOptionsType, devServerOptions: devServerOptionsType): devServerOptionsType { - // CLI options should take precedence over devServer options, - // and CLI options should have no default values included - const options = { ...devServerOptions, ...cliOptions }; - - if (devServerOptions.client && cliOptions.client) { - // the user could set some client options in their devServer config, - // then also specify client options on the CLI - options.client = { ...devServerOptions.client, ...cliOptions.client }; - } - - return options; -} diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index 51ce17b9e45..08a9478cc76 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -1,6 +1,4 @@ -import { utils } from 'webpack-cli'; - -import mergeOptions from './mergeOptions'; +import { devServerOptionsType } from './types'; /** * @@ -48,6 +46,19 @@ export default async function startDevServer(compiler, cliOptions, logger): Prom const servers = []; const usedPorts: number[] = []; + const mergeOptions = (cliOptions: devServerOptionsType, devServerOptions: devServerOptionsType): devServerOptionsType => { + // CLI options should take precedence over devServer options, + // and CLI options should have no default values included + const options = { ...devServerOptions, ...cliOptions }; + + if (devServerOptions.client && cliOptions.client) { + // the user could set some client options in their devServer config, + // then also specify client options on the CLI + options.client = { ...devServerOptions.client, ...cliOptions.client }; + } + + return options; + }; for (const devServerOpts of devServerOptions) { const options = mergeOptions(cliOptions, devServerOpts); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 16549148b67..923dea3fff2 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -61,6 +61,22 @@ describe('basic serve usage', () => { expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); + it('should work with the "--progress" option', async () => { + const { stderr, stdout } = await runServe(['--progress'], __dirname); + + expect(stderr).toContain('webpack.Progress'); + expect(stdout).toContain('main.js'); + expect(stdout).not.toContain('HotModuleReplacementPlugin'); + }); + + it('should work with the "--progress" option using the "profile" value', async () => { + const { stderr, stdout } = await runServe(['--progress', 'profile'], __dirname); + + expect(stderr).toContain('webpack.Progress'); + expect(stdout).toContain('main.js'); + expect(stdout).not.toContain('HotModuleReplacementPlugin'); + }); + it('should work with flags', async () => { const { stderr, stdout } = await runServe(['--hot'], __dirname); From 1dae54da94d3220437b9257efe512447023de1d3 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Mon, 28 Dec 2020 20:00:50 +0300 Subject: [PATCH 195/581] fix: the `--help` option is working without `webpack-dev-server` (#2267) --- packages/generators/src/index.ts | 4 +- packages/info/src/index.ts | 4 +- packages/init/src/index.ts | 4 +- packages/migrate/src/index.ts | 4 +- packages/serve/src/index.ts | 62 ++++++------ .../lib/utils/prompt-installation.js | 10 +- packages/webpack-cli/lib/webpack-cli.js | 98 +++++++++++++------ test/help/help.test.js | 4 +- test/optimization/optimization.test.js | 18 ---- test/optimization/src/index.js | 1 - test/optimization/webpack.config.js | 8 -- test/utils/test-utils.js | 16 ++- test/version/version.test.js | 12 +-- 13 files changed, 129 insertions(+), 116 deletions(-) delete mode 100644 test/optimization/optimization.test.js delete mode 100644 test/optimization/src/index.js delete mode 100644 test/optimization/webpack.config.js diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index d423d9caee6..d4f0a93d18a 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -5,10 +5,10 @@ import addonGenerator from './addon-generator'; import initGenerator from './init-generator'; class GeneratorsCommand { - apply(cli): void { + async apply(cli): Promise { const { logger } = cli; - cli.makeCommand( + await cli.makeCommand( { name: 'loader [output-path]', alias: 'l', diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index d61d2b67303..83b3884d7c1 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -30,8 +30,8 @@ const DEFAULT_DETAILS: Information = { }; class InfoCommand { - apply(cli): void { - cli.makeCommand( + async apply(cli): Promise { + await cli.makeCommand( { name: 'info', alias: 'i', diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index 1de1b7e0331..e0ddd3b209b 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -2,8 +2,8 @@ import { initGenerator } from '@webpack-cli/generators'; import { modifyHelperUtil, npmPackagesExists } from '@webpack-cli/utils'; class InitCommand { - apply(cli): void { - cli.makeCommand( + async apply(cli): Promise { + await cli.makeCommand( { name: 'init [scaffold...]', alias: 'c', diff --git a/packages/migrate/src/index.ts b/packages/migrate/src/index.ts index c9f458a0877..3e7789a5e6c 100644 --- a/packages/migrate/src/index.ts +++ b/packages/migrate/src/index.ts @@ -149,10 +149,10 @@ function runMigration(currentConfigPath: string, outputConfigPath: string, logge } class MigrationCommand { - apply(cli): void { + async apply(cli): Promise { const { logger } = cli; - cli.makeCommand( + await cli.makeCommand( { name: 'migrate [new-config-path]', alias: 'm', diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 0987e357b90..240031b69dc 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -2,45 +2,43 @@ import startDevServer from './startDevServer'; class ServeCommand { async apply(cli): Promise { - const { logger, utils } = cli; - const isPackageExist = utils.getPkg('webpack-dev-server'); - - if (!isPackageExist) { - try { - await utils.promptInstallation('webpack-dev-server', () => { - // TODO colors - logger.error("For using this command you need to install: 'webpack-dev-server' package"); - }); - } catch (error) { - logger.error("Action Interrupted, use 'webpack-cli help' to see possible commands."); - process.exit(2); - } - } - - let devServerFlags = []; - - try { - // eslint-disable-next-line node/no-extraneous-require - require('webpack-dev-server'); - // eslint-disable-next-line node/no-extraneous-require - devServerFlags = require('webpack-dev-server/bin/cli-flags').devServer; - } catch (err) { - logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`); - process.exit(2); - } - - const builtInOptions = cli.getBuiltInOptions(); - - cli.makeCommand( + const { logger } = cli; + + await cli.makeCommand( { name: 'serve', alias: 's', description: 'Run the webpack dev server.', usage: '[options]', pkg: '@webpack-cli/serve', + dependencies: ['webpack-dev-server'], + }, + () => { + let devServerFlags = []; + + try { + // eslint-disable-next-line + devServerFlags = require('webpack-dev-server/bin/cli-flags').devServer; + } catch (error) { + logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${error}`); + process.exit(2); + } + + const builtInOptions = cli.getBuiltInOptions(); + + return [...builtInOptions, ...devServerFlags]; }, - [...builtInOptions, ...devServerFlags], async (program) => { + const builtInOptions = cli.getBuiltInOptions(); + let devServerFlags = []; + + try { + // eslint-disable-next-line + devServerFlags = require('webpack-dev-server/bin/cli-flags').devServer; + } catch (error) { + // Nothing, to prevent future updates + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any const webpackOptions: Record = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -89,7 +87,7 @@ class ServeCommand { let servers; if (cli.needWatchStdin(compiler) || devServerOptions.stdin) { - // TODO + // TODO remove in the next major release // Compatibility with old `stdin` option for `webpack-dev-server` // Should be removed for the next major release on both sides if (devServerOptions.stdin) { diff --git a/packages/webpack-cli/lib/utils/prompt-installation.js b/packages/webpack-cli/lib/utils/prompt-installation.js index 5f77893cb95..d025d80e6ff 100644 --- a/packages/webpack-cli/lib/utils/prompt-installation.js +++ b/packages/webpack-cli/lib/utils/prompt-installation.js @@ -18,15 +18,13 @@ async function promptInstallation(packageName, preMessage) { process.exit(2); } - // yarn uses 'add' command, rest npm and pnpm both use 'install' - const options = [packageManager === 'yarn' ? 'add' : 'install', '-D', packageName]; - - const commandToBeRun = `${packageManager} ${options.join(' ')}`; - if (preMessage) { preMessage(); } + // yarn uses 'add' command, rest npm and pnpm both use 'install' + const commandToBeRun = `${packageManager} ${[packageManager === 'yarn' ? 'add' : 'install', '-D', packageName].join(' ')}`; + let installConfirm; try { @@ -34,7 +32,7 @@ async function promptInstallation(packageName, preMessage) { { type: 'confirm', name: 'installConfirm', - message: `Would you like to install '${packageName}' package? (That will run '${green(commandToBeRun)}')`, + message: `Would you like to install '${green(packageName)}' package? (That will run '${green(commandToBeRun)}')`, initial: 'Y', stdout: process.stderr, }, diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index b4ede2b8d62..3a7f744ee81 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -29,8 +29,8 @@ class WebpackCLI { this.utils = { toKebabCase, getPkg, promptInstallation }; } - makeCommand(commandOptions, optionsForCommand = [], action) { - const command = program.command(commandOptions.name, { + async makeCommand(commandOptions, options, action) { + const command = this.program.command(commandOptions.name, { noHelp: commandOptions.noHelp, hidden: commandOptions.hidden, isDefault: commandOptions.isDefault, @@ -56,8 +56,50 @@ class WebpackCLI { command.pkg = 'webpack-cli'; } - if (optionsForCommand.length > 0) { - optionsForCommand.forEach((optionForCommand) => { + const { forHelp } = this.program; + + let allDependenciesInstalled = true; + + if (commandOptions.dependencies && commandOptions.dependencies.length > 0) { + for (const dependency of commandOptions.dependencies) { + const isPkgExist = getPkg(dependency); + + if (isPkgExist) { + continue; + } else if (!isPkgExist && forHelp) { + allDependenciesInstalled = false; + continue; + } + + try { + await promptInstallation(dependency, () => { + logger.error( + `For using '${green(commandOptions.name)}' command you need to install: '${green(dependency)}' package`, + ); + }); + } catch (error) { + logger.error("Action Interrupted, use 'webpack-cli help' to see possible commands."); + logger.error(error); + process.exit(2); + } + } + } + + if (options) { + if (typeof options === 'function') { + if (forHelp && !allDependenciesInstalled) { + command.description( + `${commandOptions.description} To see all available options you need to install ${commandOptions.dependencies + .map((dependency) => `'${dependency}'`) + .join(',')}.`, + ); + options = []; + } else { + options = options(); + } + } + + options.forEach((optionForCommand) => { this.makeOption(command, optionForCommand); }); } @@ -271,29 +313,11 @@ class WebpackCLI { await this.bundleCommand(options); }); } else if (commandName === helpCommandOptions.name || commandName === helpCommandOptions.alias) { - this.makeCommand( - { - name: 'help [command]', - alias: 'h', - description: 'Display help for commands and options', - usage: '[command]', - }, - [], - // Stub for the `help` command - () => {}, - ); + // Stub for the `help` command + this.makeCommand(helpCommandOptions, [], () => {}); } else if (commandName === versionCommandOptions.name || commandName === helpCommandOptions.alias) { - this.makeCommand( - { - name: 'version [commands...]', - alias: 'v', - description: "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands", - usage: '[commands...]', - }, - [], - // Stub for the `help` command - () => {}, - ); + // Stub for the `help` command + this.makeCommand(versionCommandOptions, [], () => {}); } else { const builtInExternalCommandInfo = externalBuiltInCommandsInfo.find( (externalBuiltInCommandInfo) => @@ -310,11 +334,7 @@ class WebpackCLI { if (pkg !== 'webpack-cli' && !getPkg(pkg)) { if (!allowToInstall) { - const isOptions = commandName.startsWith('-'); - - logger.error(`Unknown ${isOptions ? 'option' : 'command'} '${commandName}'`); - logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); + return; } try { @@ -464,6 +484,12 @@ class WebpackCLI { (command) => command.name() === possibleCommandName || command.alias() === possibleCommandName, ); + if (!foundCommand) { + logger.error(`Unknown command '${possibleCommandName}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + try { const { name, version } = require(`${foundCommand.pkg}/package.json`); @@ -481,7 +507,7 @@ class WebpackCLI { logger.raw(`webpack-cli ${pkgJSON.version}`); if (getPkg('webpack-dev-server')) { - // eslint-disable-next-line node/no-extraneous-require + // eslint-disable-next-line const { version } = require('webpack-dev-server/package.json'); logger.raw(`webpack-dev-server ${version}`); @@ -547,6 +573,12 @@ class WebpackCLI { } else { const [name, ...optionsWithoutCommandName] = options; + if (name.startsWith('-')) { + logger.error(`Unknown option '${name}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + optionsWithoutCommandName.forEach((option) => { logger.error(`Unknown option '${option}'`); logger.error("Run 'webpack --help' to see available commands and options"); @@ -636,6 +668,8 @@ class WebpackCLI { } } + this.program.forHelp = true; + const optionsForHelp = [].concat(opts.help && !isDefault ? [commandName] : []).concat(options); await outputHelp(optionsForHelp, isVerbose, program); diff --git a/test/help/help.test.js b/test/help/help.test.js index 35c4c568acb..d446a20947c 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -219,7 +219,7 @@ describe('help', () => { const { exitCode, stderr, stdout } = run(__dirname, ['help', 'myCommand'], false); expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown command 'myCommand'"); + expect(stderr).toContain("Can't find and load command 'myCommand'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -228,7 +228,7 @@ describe('help', () => { const { exitCode, stderr, stdout } = run(__dirname, ['help', 'verbose'], false); expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown command 'verbose'"); + expect(stderr).toContain("Can't find and load command 'verbose'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); diff --git a/test/optimization/optimization.test.js b/test/optimization/optimization.test.js deleted file mode 100644 index ea28769da3a..00000000000 --- a/test/optimization/optimization.test.js +++ /dev/null @@ -1,18 +0,0 @@ -const { run, isWebpack5 } = require('../utils/test-utils'); - -describe('optimization option in config', () => { - it('should work with mangleExports disabled', () => { - const { exitCode, stderr, stdout } = run(__dirname, [], false); - - // Should throw when webpack is less than 5 - if (isWebpack5) { - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('mangleExports: false'); - } else { - expect(exitCode).toBe(2); - expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'"); - expect(stdout).toBeFalsy(); - } - }); -}); diff --git a/test/optimization/src/index.js b/test/optimization/src/index.js deleted file mode 100644 index c56f17c89e9..00000000000 --- a/test/optimization/src/index.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Bokuto") diff --git a/test/optimization/webpack.config.js b/test/optimization/webpack.config.js deleted file mode 100644 index c5ddd675368..00000000000 --- a/test/optimization/webpack.config.js +++ /dev/null @@ -1,8 +0,0 @@ -const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin'); - -module.exports = { - plugins: [new WebpackCLITestPlugin()], - optimization: { - mangleExports: false, - }, -}; diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 52d4af7bf56..8515dbced2b 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -8,12 +8,22 @@ const { Writable } = require('readable-stream'); const concat = require('concat-stream'); const { version } = require('webpack'); const stripAnsi = require('strip-ansi'); -const { version: devServerVersion } = require('webpack-dev-server/package.json'); + +const isWebpack5 = version.startsWith('5'); + +let devServerVersion; + +try { + // eslint-disable-next-line + devServerVersion = require('webpack-dev-server/package.json').version; +} catch (error) { + // Nothing +} + +const isDevServer4 = devServerVersion && devServerVersion.startsWith('4'); const WEBPACK_PATH = path.resolve(__dirname, '../../packages/webpack-cli/bin/cli.js'); const ENABLE_LOG_COMPILATION = process.env.ENABLE_PIPE || false; -const isWebpack5 = version.startsWith('5'); -const isDevServer4 = devServerVersion.startsWith('4'); const isWindows = process.platform === 'win32'; const hyphenToUpperCase = (name) => { diff --git a/test/version/version.test.js b/test/version/version.test.js index b9a953703d4..ac2b3deb1ca 100644 --- a/test/version/version.test.js +++ b/test/version/version.test.js @@ -171,13 +171,13 @@ describe('single version flag', () => { expect(stdout).toBeFalsy(); }); - it('should log error when command using command syntax with multi commands', () => { + it('should log version for known command and log error for unknown command using command syntax with multi commands', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'unknown'], false); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); }); it('should work for multiple commands', () => { @@ -214,22 +214,22 @@ describe('single version flag', () => { expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); }); - it('should log error when unknown command used with --version flag', () => { + it('should log version for known command and log error for unknown command using the "--version" option', () => { const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '--version'], false); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/init ${initPkgJSON.version}`); }); - it('should log error when unknown command used with -v alias', () => { + it('should log version for known command and log error for unknown command using the "-v" option', () => { const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '-v'], false); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toBeFalsy(); + expect(stdout).toContain(`@webpack-cli/init ${initPkgJSON.version}`); }); it('should not output version with help dashed', () => { From bb16d4481414a5f3c0cbeb18af690084b2ae4215 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Mon, 28 Dec 2020 21:45:20 +0300 Subject: [PATCH 196/581] fix: do not apply HotModuleReplacement plugin twice (#2269) --- packages/serve/src/index.ts | 29 +++++----- test/serve/basic/serve-basic.test.js | 64 +++++++++++------------ test/serve/basic/webpack.config.js | 2 +- test/utils/cli-plugin-test/plugin.test.js | 2 +- test/utils/webpack-cli-test-plugin.js | 17 +++++- 5 files changed, 63 insertions(+), 51 deletions(-) diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 240031b69dc..5108eb93924 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -49,26 +49,23 @@ class ServeCommand { const processors: Array<(opts: Record) => void> = []; for (const optionName in options) { - if (optionName === 'hot') { - devServerOptions[optionName] = options[optionName]; + const kebabedOption = cli.utils.toKebabCase(optionName); + // `webpack-dev-server` has own logic for the `--hot` option + const isBuiltInOption = + kebabedOption !== 'hot' && builtInOptions.find((builtInOption) => builtInOption.name === kebabedOption); + + if (isBuiltInOption) { webpackOptions[optionName] = options[optionName]; } else { - const kebabedOption = cli.utils.toKebabCase(optionName); - const isBuiltInOption = builtInOptions.find((builtInOption) => builtInOption.name === kebabedOption); - - if (isBuiltInOption) { - webpackOptions[optionName] = options[optionName]; - } else { - const needToProcess = devServerFlags.find( - (devServerOption) => devServerOption.name === kebabedOption && devServerOption.processor, - ); + const needToProcess = devServerFlags.find( + (devServerOption) => devServerOption.name === kebabedOption && devServerOption.processor, + ); - if (needToProcess) { - processors.push(needToProcess.processor); - } - - devServerOptions[optionName] = options[optionName]; + if (needToProcess) { + processors.push(needToProcess.processor); } + + devServerOptions[optionName] = options[optionName]; } } diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 923dea3fff2..7efedca684f 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -27,11 +27,11 @@ describe('basic serve usage', () => { } it('should work', async () => { - const { stderr, stdout } = await runServe(['--no-hot'], __dirname); + const { stderr, stdout } = await runServe([''], __dirname); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); it('should work with the "--mode" option', async () => { @@ -40,7 +40,7 @@ describe('basic serve usage', () => { expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); it('should work with the "--mode" option #2', async () => { @@ -49,16 +49,16 @@ describe('basic serve usage', () => { expect(stderr).toBeFalsy(); expect(stdout).toContain('production'); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('should work with the "--mode" option #2', async () => { + it('should work with the "--mode" option #3', async () => { const { stderr, stdout } = await runServe(['--mode', 'development'], __dirname); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); it('should work with the "--progress" option', async () => { @@ -66,7 +66,7 @@ describe('basic serve usage', () => { expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); it('should work with the "--progress" option using the "profile" value', async () => { @@ -74,18 +74,10 @@ describe('basic serve usage', () => { expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('should work with flags', async () => { - const { stderr, stdout } = await runServe(['--hot'], __dirname); - - expect(stderr).toBeFalsy(); - expect(stdout).toContain('main.js'); - expect(stdout).toContain('HotModuleReplacementPlugin'); - }); - - it('should respect the --no-color flag', async () => { + it('should log help information and respect the "--no-color" option', async () => { const { stdout, stderr } = await runServe(['--help', '--no-color'], __dirname); expect(stderr).toBeFalsy(); @@ -93,55 +85,63 @@ describe('basic serve usage', () => { expect(stdout).toContain(descriptionText); }); - it('should not invoke info subcommand', async () => { + it('should work with the "--client-log-level" option', async () => { const { stdout, stderr } = await runServe(['--client-log-level', 'info'], testPath); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('compiles without flags', async () => { + it('should work with the "--port" option', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('uses hot flag to alter bundle', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); + it('should work with the "--hot" option', async () => { + const { stderr, stdout } = await runServe(['--hot'], __dirname); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stdout).toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1); }); - it('uses hot-only flag to alter bundle', async () => { + it('should work with the "--no-hot" option', async () => { + const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should work with the "--hot" option using the "only" value', async () => { const { stdout, stderr } = await runServe(['--port', port, isDevServer4 ? '--hot only' : '--hot-only'], testPath); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stdout).toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1); }); - it('uses no-hot flag', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + it('should work with "--hot" and "--port" options', async () => { + const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stdout).not.toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1); }); - it('uses hot flag and progress flag', async () => { + it('should work with the "--hot" and "--progress" options', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot', '--progress'], testPath); expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); - expect(stdout).toContain('HotModuleReplacementPlugin'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1); }); - it('throws error on unknown flag', async () => { + it('should log and error on unknown flag', async () => { const { exitCode, stdout, stderr } = await runServe(['--port', port, '--unknown-flag'], testPath); expect(exitCode).toBe(2); diff --git a/test/serve/basic/webpack.config.js b/test/serve/basic/webpack.config.js index 98b22edfdc9..cef4d803dc3 100644 --- a/test/serve/basic/webpack.config.js +++ b/test/serve/basic/webpack.config.js @@ -3,5 +3,5 @@ const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); module.exports = { mode: 'development', devtool: false, - plugins: [new WebpackCLITestPlugin(['mode', 'plugins'], false)], + plugins: [new WebpackCLITestPlugin(['mode'], false, 'hooks.compilation.taps')], }; diff --git a/test/utils/cli-plugin-test/plugin.test.js b/test/utils/cli-plugin-test/plugin.test.js index 77b4a6e8d09..f4add985907 100644 --- a/test/utils/cli-plugin-test/plugin.test.js +++ b/test/utils/cli-plugin-test/plugin.test.js @@ -14,6 +14,6 @@ describe('webpack-cli-test-plugin Test', () => { expect(stdout).toContain(`alias: { alias: [ 'alias1', 'alias2' ] }`); } - expect(stdout).toContain(` WebpackCLITestPlugin { opts: [Array], showAll: true }`); + expect(stdout).toContain('WebpackCLITestPlugin'); }); }); diff --git a/test/utils/webpack-cli-test-plugin.js b/test/utils/webpack-cli-test-plugin.js index b04869a16e4..510b5889bea 100644 --- a/test/utils/webpack-cli-test-plugin.js +++ b/test/utils/webpack-cli-test-plugin.js @@ -1,17 +1,32 @@ class WebpackCLITestPlugin { - constructor(options, showAll = true) { + constructor(options, showAll = true, showHooks) { this.opts = options; this.showAll = showAll; + this.showHooks = showHooks; } apply(compiler) { compiler.hooks.done.tap('webpack-cli Test Plugin', () => { + if (this.showHooks) { + const identifiers = this.showHooks.split('.'); + + let shown = compiler; + + identifiers.forEach((identifier) => { + shown = shown[identifier]; + }); + + console.log(shown); + } + if (this.showAll) { console.log(compiler.options); } + if (this.opts) { this.opts.map((e) => { const config = Object.getOwnPropertyDescriptor(compiler.options, e); + console.log(config.value); }); } From 92826d621df7454fd12b949ed926c236004439a0 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 29 Dec 2020 20:41:59 +0300 Subject: [PATCH 197/581] tests: open and serve (#2275) --- package.json | 6 +- packages/utils/package.json | 2 +- packages/webpack-cli/package.json | 2 +- test/serve/basic/serve-basic.test.js | 8 + yarn.lock | 215 ++++++++++++++------------- 5 files changed, 123 insertions(+), 110 deletions(-) diff --git a/package.json b/package.json index 7ddcd2bc6fb..08bbfd4a276 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "eslint-config-prettier": "^6.15.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.1.4", - "execa": "^4.1.0", + "execa": "^5.0.0", "get-port": "^5.1.1", "git-cz": "^4.7.1", "husky": "^4.3.0", @@ -91,8 +91,8 @@ "ts-jest": "^26.4.3", "typescript": "^3.9.7", "webpack": "^5.11.0", - "webpack-bundle-analyzer": "^3.9.0", - "webpack-dev-server": "^3.11.0", + "webpack-bundle-analyzer": "^4.3.0", + "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" } } diff --git a/packages/utils/package.json b/packages/utils/package.json index 7ef4459979d..2f763950450 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -13,7 +13,7 @@ ], "dependencies": { "colorette": "^1.2.1", - "execa": "^4.1.0", + "execa": "^5.0.0", "findup-sync": "^4.0.0", "global-modules": "^2.0.0", "got": "^11.8.0", diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 84e827d69f3..b0efd6392e1 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -33,7 +33,7 @@ "colorette": "^1.2.1", "commander": "^6.2.0", "enquirer": "^2.3.6", - "execa": "^4.1.0", + "execa": "^5.0.0", "fastest-levenshtein": "^1.0.12", "import-local": "^3.0.2", "interpret": "^2.2.0", diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 7efedca684f..e6754e52658 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -141,6 +141,14 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1); }); + it.only('should work with the "--open" option', async () => { + const { stdout, stderr } = await runServe(['--open', '--port', port], testPath); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + it('should log and error on unknown flag', async () => { const { exitCode, stdout, stderr } = await runServe(['--port', port, '--unknown-flag'], testPath); diff --git a/yarn.lock b/yarn.lock index 5eb31c139ca..b7143c47de9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2193,6 +2193,11 @@ dependencies: "@types/node" ">= 8" +"@polka/url@^1.0.0-next.9": + version "1.0.0-next.11" + resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.11.tgz#aeb16f50649a91af79dbe36574b66d0f9e4d9f71" + integrity sha512-3NsZsJIA/22P3QUyrEDNA2D133H4j224twJrdipXN38dpnIOzAbUDtOwkcJ5pXmn75w7LSQDjA4tO9dm1XlqlA== + "@samverschueren/stream-to-observable@^0.3.0": version "0.3.1" resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz#a21117b19ee9be70c379ec1877537ef2e1c63301" @@ -2808,6 +2813,11 @@ acorn-walk@^7.1.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== +acorn-walk@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.0.0.tgz#56ae4c0f434a45fff4a125e7ea95fa9c98f67a16" + integrity sha512-oZRad/3SMOI/pxbbmqyurIx7jHw1wZDcR9G44L8pUVFEomX/0dH89SrM1KaDXuv1NpzAXz6Op/Xu/Qd5XXzdEA== + acorn@^7.1.1, acorn@^7.4.0: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" @@ -3280,16 +3290,6 @@ before-after-hook@^2.0.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== -bfj@^6.1.1: - version "6.1.2" - resolved "https://registry.yarnpkg.com/bfj/-/bfj-6.1.2.tgz#325c861a822bcb358a41c78a33b8e6e2086dde7f" - integrity sha512-BmBJa4Lip6BPRINSZ0BPEIfB1wUY/9rwbwvIHQA1KjX9om29B6id0wnWXq7m3bn5JrUVjeOTnVuhPT1FiHwPGw== - dependencies: - bluebird "^3.5.5" - check-types "^8.0.3" - hoopy "^0.1.4" - tryer "^1.0.1" - binary-extensions@^1.0.0: version "1.13.1" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65" @@ -3640,11 +3640,6 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== -check-types@^8.0.3: - version "8.0.3" - resolved "https://registry.yarnpkg.com/check-types/-/check-types-8.0.3.tgz#3356cca19c889544f2d7a95ed49ce508a0ecf552" - integrity sha512-YpeKZngUmG65rLudJ4taU7VLkOCTMhNl/u4ctNC56LQS/zJTyNH0Lrtwm1tfTsbLlwvlfsA2d1c8vCf/Kh2KwQ== - chokidar@^2.1.8: version "2.1.8" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917" @@ -3888,7 +3883,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@^2.18.0, commander@^2.20.0: +commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -4185,7 +4180,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.2: +cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -4299,7 +4294,7 @@ debug@^3.1.0, debug@^3.1.1: dependencies: ms "^2.1.1" -debug@^3.2.5: +debug@^3.2.6: version "3.2.7" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== @@ -4623,7 +4618,7 @@ duplexer3@^0.1.4: resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= -duplexer@^0.1.1: +duplexer@^0.1.1, duplexer@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== @@ -5074,6 +5069,21 @@ execa@^4.0.0, execa@^4.1.0: signal-exit "^3.0.2" strip-final-newline "^2.0.0" +execa@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.0.0.tgz#4029b0007998a841fbd1032e5f4de86a3c1e3376" + integrity sha512-ov6w/2LCiuyO4RLYGdpFGjkcs0wMTgGE8PrkTHikeUy5iJekXyPIKUjifk5CsE0pt7sMCrMZ3YNqoCj6idQOnQ== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" + exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -5111,7 +5121,7 @@ expect@^26.6.2: jest-message-util "^26.6.2" jest-regex-util "^26.0.0" -express@^4.16.3, express@^4.17.1: +express@^4.17.1: version "4.17.1" resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g== @@ -5256,14 +5266,7 @@ fastq@^1.6.0: dependencies: reusify "^1.0.4" -faye-websocket@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" - integrity sha1-TkkvjQTftviQA1B/btvy1QHnxvQ= - dependencies: - websocket-driver ">=0.5.1" - -faye-websocket@~0.11.1: +faye-websocket@^0.11.3: version "0.11.3" resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.3.tgz#5c0e9a8968e8912c286639fde977a8b209f2508e" integrity sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA== @@ -5323,11 +5326,6 @@ filelist@^1.0.1: dependencies: minimatch "^3.0.4" -filesize@^3.6.1: - version "3.6.1" - resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.6.1.tgz#090bb3ee01b6f801a8a8be99d31710b3422bb317" - integrity sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg== - fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -5707,6 +5705,11 @@ get-stream@^5.0.0, get-stream@^5.1.0: dependencies: pump "^3.0.0" +get-stream@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.0.tgz#3e0012cb6827319da2706e601a1583e8629a6718" + integrity sha512-A1B3Bh1UmL0bidM/YX2NsCOTnGJePL9rO/M+Mw3m9f2gUpfokS0hi5Eah0WSUEWZdZhIZtMjkIYS7mDfOqNHbg== + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -5994,13 +5997,12 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= -gzip-size@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-5.1.1.tgz#cb9bee692f87c0612b232840a873904e4c135274" - integrity sha512-FNHi6mmoHvs1mxZAds4PpdCS6QG8B4C1krxJsMutgxl5t3+GlRTzzI3NEkifXx2pVsOvJdOGSmIgDhQ55FwdPA== +gzip-size@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462" + integrity sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q== dependencies: - duplexer "^0.1.1" - pify "^4.0.1" + duplexer "^0.1.2" handle-thing@^2.0.0: version "2.0.1" @@ -6124,11 +6126,6 @@ homedir-polyfill@^1.0.1: dependencies: parse-passwd "^1.0.0" -hoopy@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d" - integrity sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ== - hosted-git-info@^2.1.4, hosted-git-info@^2.7.1: version "2.8.8" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" @@ -6270,6 +6267,11 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== + humanize-ms@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" @@ -7509,7 +7511,7 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= -json3@^3.3.2: +json3@^3.3.3: version "3.3.3" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81" integrity sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA== @@ -8216,7 +8218,7 @@ mime@1.6.0: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== -mime@^2.4.4: +mime@^2.3.1, mime@^2.4.4: version "2.4.7" resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.7.tgz#962aed9be0ed19c91fd7dc2ece5d7f4e89a90d74" integrity sha512-dhNd1uA2u397uQk3Nv5LM4lm93WYDUXFn3Fu291FJerns4jyTudqhIWe4W04YLy7Uk1tm1Ore04NpjRvQp/NPA== @@ -8671,7 +8673,7 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -npm-run-path@^4.0.0: +npm-run-path@^4.0.0, npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== @@ -8836,7 +8838,7 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -onetime@^5.1.0: +onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== @@ -8848,7 +8850,7 @@ opencollective-postinstall@^2.0.2: resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259" integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q== -opener@^1.5.1: +opener@^1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598" integrity sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A== @@ -10129,7 +10131,7 @@ select-hose@^2.0.0: resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo= -selfsigned@^1.10.7: +selfsigned@^1.10.8: version "1.10.8" resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.8.tgz#0d17208b7d12c33f8eac85c41835f27fc3d81a30" integrity sha512-2P4PtieJeEwVgTU9QEcwIRDQ/mXJLX8/+I3ur+Pg16nS8oNbrGxEso9NyYWy8NAmXiNl4dlAp5MwoNeCWzON4w== @@ -10299,7 +10301,7 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -signal-exit@^3.0.0, signal-exit@^3.0.2: +signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== @@ -10317,6 +10319,15 @@ sinon@^9.0.1: nise "^4.0.4" supports-color "^7.1.0" +sirv@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/sirv/-/sirv-1.0.10.tgz#3e591f5a9ae2520f50d5830f5fae38d97e7be194" + integrity sha512-H5EZCoZaggEUQy8ocKsF7WAToGuZhjJlLvM3XOef46CbdIgbNeQ1p32N1PCuCjkVYwrAVOSMacN6CXXgIzuspg== + dependencies: + "@polka/url" "^1.0.0-next.9" + mime "^2.3.1" + totalist "^1.0.0" + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -10400,26 +10411,26 @@ snapdragon@^0.8.1: source-map-resolve "^0.5.0" use "^3.1.0" -sockjs-client@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.4.0.tgz#c9f2568e19c8fd8173b4997ea3420e0bb306c7d5" - integrity sha512-5zaLyO8/nri5cua0VtOrFXBPK1jbL4+1cebT/mmKA1E1ZXOvJrII75bPu0l0k843G/+iAbhEqzyKr0w/eCCj7g== +sockjs-client@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.5.0.tgz#2f8ff5d4b659e0d092f7aba0b7c386bd2aa20add" + integrity sha512-8Dt3BDi4FYNrCFGTL/HtwVzkARrENdwOUf1ZoW/9p3M8lZdFT35jVdrHza+qgxuG9H3/shR4cuX/X9umUrjP8Q== dependencies: - debug "^3.2.5" + debug "^3.2.6" eventsource "^1.0.7" - faye-websocket "~0.11.1" - inherits "^2.0.3" - json3 "^3.3.2" - url-parse "^1.4.3" + faye-websocket "^0.11.3" + inherits "^2.0.4" + json3 "^3.3.3" + url-parse "^1.4.7" -sockjs@0.3.20: - version "0.3.20" - resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.20.tgz#b26a283ec562ef8b2687b44033a4eeceac75d855" - integrity sha512-SpmVOVpdq0DJc0qArhF3E5xsxvaiqGNb73XfgBpK1y3UD5gs8DSo8aCTsuT5pX8rssdc2NDIzANwP9eCAiSdTA== +sockjs@^0.3.21: + version "0.3.21" + resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.21.tgz#b34ffb98e796930b60a0cfa11904d6a339a7d417" + integrity sha512-DhbPFGpxjc6Z3I+uX07Id5ZO2XwYsWOrYjaSeieES78cq+JaJvVe5q/m1uvjIQhXinhIeCFRH6JgXe+mvVMyXw== dependencies: - faye-websocket "^0.10.0" + faye-websocket "^0.11.3" uuid "^3.4.0" - websocket-driver "0.6.5" + websocket-driver "^0.7.4" socks-proxy-agent@^4.0.0: version "4.0.2" @@ -11091,6 +11102,11 @@ toidentifier@1.0.0: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== +totalist@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/totalist/-/totalist-1.1.0.tgz#a4d65a3e546517701e3e5c37a47a70ac97fe56df" + integrity sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g== + tough-cookie@^2.3.3, tough-cookie@~2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" @@ -11142,11 +11158,6 @@ trim-off-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= -tryer@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" - integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== - ts-jest@^26.4.3: version "26.4.4" resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.4.tgz#61f13fb21ab400853c532270e52cc0ed7e502c49" @@ -11393,7 +11404,7 @@ url-parse-lax@^1.0.0: dependencies: prepend-http "^1.0.1" -url-parse@^1.4.3: +url-parse@^1.4.3, url-parse@^1.4.7: version "1.4.7" resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.7.tgz#a8a83535e8c00a316e403a5db4ac1b9b853ae278" integrity sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg== @@ -11572,24 +11583,20 @@ webidl-conversions@^6.1.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514" integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w== -webpack-bundle-analyzer@^3.9.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.9.0.tgz#f6f94db108fb574e415ad313de41a2707d33ef3c" - integrity sha512-Ob8amZfCm3rMB1ScjQVlbYYUEJyEjdEtQ92jqiFUYt5VkEeO2v5UMbv49P/gnmCZm3A6yaFQzCBvpZqN4MUsdA== +webpack-bundle-analyzer@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.3.0.tgz#2f3c0ca9041d5ee47fa418693cf56b4a518b578b" + integrity sha512-J3TPm54bPARx6QG8z4cKBszahnUglcv70+N+8gUqv2I5KOFHJbzBiLx+pAp606so0X004fxM7hqRu10MLjJifA== dependencies: - acorn "^7.1.1" - acorn-walk "^7.1.1" - bfj "^6.1.1" - chalk "^2.4.1" - commander "^2.18.0" - ejs "^2.6.1" - express "^4.16.3" - filesize "^3.6.1" - gzip-size "^5.0.0" - lodash "^4.17.19" - mkdirp "^0.5.1" - opener "^1.5.1" - ws "^6.0.0" + acorn "^8.0.4" + acorn-walk "^8.0.0" + chalk "^4.1.0" + commander "^6.2.0" + gzip-size "^6.0.0" + lodash "^4.17.20" + opener "^1.5.2" + sirv "^1.0.7" + ws "^7.3.1" webpack-dev-middleware@^3.7.2: version "3.7.3" @@ -11602,10 +11609,10 @@ webpack-dev-middleware@^3.7.2: range-parser "^1.2.1" webpack-log "^2.0.0" -webpack-dev-server@^3.11.0: - version "3.11.0" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.11.0.tgz#8f154a3bce1bcfd1cc618ef4e703278855e7ff8c" - integrity sha512-PUxZ+oSTxogFQgkTtFndEtJIPNmml7ExwufBZ9L2/Xyyd5PnOL5UreWe5ZT7IU25DSdykL9p1MLQzmLh2ljSeg== +webpack-dev-server@^3.11.1: + version "3.11.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.11.1.tgz#c74028bf5ba8885aaf230e48a20e8936ab8511f0" + integrity sha512-u4R3mRzZkbxQVa+MBWi2uVpB5W59H3ekZAJsQlKUTdl7Elcah2EhygTPLmeFXybQkf9i2+L0kn7ik9SnXa6ihQ== dependencies: ansi-html "0.0.7" bonjour "^3.5.0" @@ -11627,11 +11634,11 @@ webpack-dev-server@^3.11.0: p-retry "^3.0.1" portfinder "^1.0.26" schema-utils "^1.0.0" - selfsigned "^1.10.7" + selfsigned "^1.10.8" semver "^6.3.0" serve-index "^1.9.1" - sockjs "0.3.20" - sockjs-client "1.4.0" + sockjs "^0.3.21" + sockjs-client "^1.5.0" spdy "^4.0.2" strip-ansi "^3.0.1" supports-color "^6.1.0" @@ -11694,14 +11701,7 @@ webpack@^5.11.0: watchpack "^2.0.0" webpack-sources "^2.1.1" -websocket-driver@0.6.5: - version "0.6.5" - resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.6.5.tgz#5cb2556ceb85f4373c6d8238aa691c8454e13a36" - integrity sha1-XLJVbOuF9Dc8bYI4qmkchFThOjY= - dependencies: - websocket-extensions ">=0.1.1" - -websocket-driver@>=0.5.1: +websocket-driver@>=0.5.1, websocket-driver@^0.7.4: version "0.7.4" resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== @@ -11884,7 +11884,7 @@ write-pkg@^3.1.0: sort-keys "^2.0.0" write-json-file "^2.2.0" -ws@^6.0.0, ws@^6.2.1: +ws@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb" integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA== @@ -11896,6 +11896,11 @@ ws@^7.2.3: resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== +ws@^7.3.1: + version "7.4.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.1.tgz#a333be02696bd0e54cea0434e21dcc8a9ac294bb" + integrity sha512-pTsP8UAfhy3sk1lSk/O/s4tjD0CRwvMnzvwr4OKGX7ZvqZtUyx4KIJB5JWbkykPoc55tixMGgTNoh3k4FkNGFQ== + xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" From 818fc1cbdf3c5b756b8ade6a2e7e032616aa520b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 30 Dec 2020 15:14:29 +0300 Subject: [PATCH 198/581] chore(deps-dev): bump webpack from 5.11.0 to 5.11.1 (#2270) Bumps [webpack](https://github.com/webpack/webpack) from 5.11.0 to 5.11.1. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.11.0...v5.11.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b7143c47de9..c442a38f70b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11672,9 +11672,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.11.0: - version "5.11.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.11.0.tgz#1647abc060441d86d01d8835b8f0fc1dae2fe76f" - integrity sha512-ubWv7iP54RqAC/VjixgpnLLogCFbAfSOREcSWnnOlZEU8GICC5eKmJSu6YEnph2N2amKqY9rvxSwgyHxVqpaRw== + version "5.11.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.11.1.tgz#39b2b9daeb5c6c620e03b7556ec674eaed4016b4" + integrity sha512-tNUIdAmYJv+nupRs/U/gqmADm6fgrf5xE+rSlSsf2PgsGO7j2WG7ccU6AWNlOJlHFl+HnmXlBmHIkiLf+XA9mQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From 05956030cbb1491a2e9313732470bcd4ebe5a36d Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 30 Dec 2020 16:38:27 +0300 Subject: [PATCH 199/581] fix: the `--progress` option is working with `--json` (#2276) --- packages/webpack-cli/lib/plugins/CLIPlugin.js | 6 +- packages/webpack-cli/lib/webpack-cli.js | 5 +- test/build-errors/errors.test.js | 4 +- test/build-warnings/warnings.test.js | 5 +- test/json/json.test.js | 98 +++++++++++++++---- test/json/logging.config.js | 5 + 6 files changed, 96 insertions(+), 27 deletions(-) create mode 100644 test/json/logging.config.js diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js index 643088643e5..584d6e21a07 100644 --- a/packages/webpack-cli/lib/plugins/CLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -79,7 +79,7 @@ class CLIPlugin { apply(compiler) { this.logger = compiler.getInfrastructureLogger('webpack-cli'); - if (this.options.progress && this.options.helpfulOutput) { + if (this.options.progress) { this.setupProgressPlugin(compiler); } @@ -95,9 +95,7 @@ class CLIPlugin { this.setupBundleAnalyzerPlugin(compiler); } - if (this.options.helpfulOutput) { - this.setupHelpfulOutput(compiler); - } + this.setupHelpfulOutput(compiler); } } diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 3a7f744ee81..67201852276 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1234,7 +1234,10 @@ class WebpackCLI { .on('error', handleWriteError) .pipe(createWriteStream(options.json)) .on('error', handleWriteError) - .on('close', () => logger.success(`stats are successfully stored as json to ${options.json}`)); + // Use stderr to logging + .on('close', () => + process.stderr.write(`[webpack-cli] ${green(`stats are successfully stored as json to ${options.json}`)}\n`), + ); } } else { const printedStats = stats.toString(foundStats); diff --git a/test/build-errors/errors.test.js b/test/build-errors/errors.test.js index 50a397ebffa..30fac63060d 100644 --- a/test/build-errors/errors.test.js +++ b/test/build-errors/errors.test.js @@ -32,8 +32,8 @@ describe('errors', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); expect(exitCode).toBe(1); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('stats are successfully stored as json to stats.json'); + expect(stderr).toContain('stats are successfully stored as json to stats.json'); + expect(stdout).toBeFalsy(); readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { expect(error).toBe(null); diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index 27422faf42e..8bf676da732 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -33,9 +33,8 @@ describe('warnings', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('stats are successfully stored as json to stats.json'); - + expect(stderr).toContain('stats are successfully stored as json to stats.json'); + expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { diff --git a/test/json/json.test.js b/test/json/json.test.js index 9fd1ef88964..64441e4504a 100644 --- a/test/json/json.test.js +++ b/test/json/json.test.js @@ -5,20 +5,24 @@ const { resolve } = require('path'); const successMessage = 'stats are successfully stored as json to stats.json'; -describe('json flag', () => { - it('should return valid json', () => { - const { stdout, exitCode } = run(__dirname, ['--json']); - expect(() => JSON.parse(stdout)).not.toThrow(); +describe('json', () => { + it('should work and output json stats', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json']); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(() => JSON.parse(stdout)).not.toThrow(); expect(JSON.parse(stdout)['hash']).toBeDefined(); }); - it('should store json to a file', (done) => { - const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json']); + it('should work and store json to a file', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); - expect(stdout).toContain(successMessage); expect(exitCode).toBe(0); + expect(stderr).toContain(successMessage); + expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(JSON.parse(data)['hash']).toBeTruthy(); @@ -29,12 +33,31 @@ describe('json flag', () => { }); }); - it('should store json to a file and respect --color flag', (done) => { - const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json', '--color']); + it('should work and store json to a file and respect --color flag', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--color']); - expect(stdout).toContain(`\u001b[32m${successMessage}`); expect(exitCode).toBe(0); + expect(stderr).toContain(`\u001b[32m${successMessage}`); + expect(stdout).toBeFalsy(); + expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { + expect(err).toBe(null); + expect(JSON.parse(data)['hash']).toBeTruthy(); + expect(JSON.parse(data)['version']).toBeTruthy(); + expect(JSON.parse(data)['time']).toBeTruthy(); + expect(() => JSON.parse(data)).not.toThrow(); + done(); + }); + }); + + it('should work and store json to a file and respect --no-color', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--no-color']); + + expect(exitCode).toBe(0); + expect(stderr).not.toContain(`\u001b[32m${successMessage}`); + expect(stderr).toContain(`${successMessage}`); + expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { @@ -47,13 +70,31 @@ describe('json flag', () => { }); }); - it('should store json to a file and respect --no-color', (done) => { - const { stdout, exitCode } = run(__dirname, ['--json', 'stats.json', '--no-color']); + it('should work using the "-j" option (alias)', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-j']); - expect(stdout).not.toContain(`\u001b[32m${successMessage}`); - expect(stdout).toContain(`${successMessage}`); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(() => JSON.parse(stdout)).not.toThrow(); + expect(JSON.parse(stdout)['hash']).toBeDefined(); + }); + + it('should work and output json stats with the "--progress" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json', '--progress']); + expect(exitCode).toBe(0); + expect(stderr).toContain('webpack.Progress'); + expect(() => JSON.parse(stdout)).not.toThrow(); + expect(JSON.parse(stdout)['hash']).toBeDefined(); + }); + + it('should work and store json to a file with the "--progress" option', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--progress']); + + expect(exitCode).toBe(0); + expect(stderr).toContain('webpack.Progress'); + expect(stderr).toContain(successMessage); + expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { @@ -66,10 +107,33 @@ describe('json flag', () => { }); }); - it('should return valid json with -j alias', () => { - const { stdout, exitCode } = run(__dirname, ['-j']); - expect(() => JSON.parse(stdout)).not.toThrow(); + it('should work and output json stats with cli logs', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json', '--config', 'logging.config.js']); + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting'); + expect(stderr).toContain('Compilation finished'); + expect(() => JSON.parse(stdout)).not.toThrow(); expect(JSON.parse(stdout)['hash']).toBeDefined(); }); + + it('should work and store json to a file with cli logs', (done) => { + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--config', 'logging.config.js']); + + expect(exitCode).toBe(0); + expect(stderr).toContain('Compilation starting'); + expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain(successMessage); + expect(stdout).toBeFalsy(); + expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); + + readFile(resolve(__dirname, 'stats.json'), 'utf-8', (err, data) => { + expect(err).toBe(null); + expect(JSON.parse(data)['hash']).toBeTruthy(); + expect(JSON.parse(data)['version']).toBeTruthy(); + expect(JSON.parse(data)['time']).toBeTruthy(); + expect(() => JSON.parse(data)).not.toThrow(); + done(); + }); + }); }); diff --git a/test/json/logging.config.js b/test/json/logging.config.js new file mode 100644 index 00000000000..481fe38bff4 --- /dev/null +++ b/test/json/logging.config.js @@ -0,0 +1,5 @@ +module.exports = { + infrastructureLogging: { + level: 'log', + }, +}; From a3092ef2b51ece30221f7dd7b30a686626c1fd7a Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 30 Dec 2020 17:28:03 +0300 Subject: [PATCH 200/581] fix: respect the `output.publicPath` option for the `serve`command (#2271) --- .../__snapshots__/startDevServer.test.ts.snap | 5 + packages/serve/src/startDevServer.ts | 73 ++++++++------ packages/serve/src/types.ts | 1 + .../dev-server-output-public-path.config.js | 13 +++ ...ti-dev-server-output-public-path.config.js | 26 +++++ test/serve/basic/multi-dev-server.config.js | 32 +++++++ .../basic/multi-output-public-path.config.js | 23 +++++ test/serve/basic/multi.config.js | 25 +++++ .../serve/basic/multiple-dev-server.config.js | 29 ++++++ test/serve/basic/output-public-path.config.js | 10 ++ test/serve/basic/serve-basic.test.js | 96 ++++++++++++++++++- test/serve/basic/src/other.js | 1 + 12 files changed, 302 insertions(+), 32 deletions(-) create mode 100644 test/serve/basic/dev-server-output-public-path.config.js create mode 100644 test/serve/basic/multi-dev-server-output-public-path.config.js create mode 100644 test/serve/basic/multi-dev-server.config.js create mode 100644 test/serve/basic/multi-output-public-path.config.js create mode 100644 test/serve/basic/multi.config.js create mode 100644 test/serve/basic/multiple-dev-server.config.js create mode 100644 test/serve/basic/output-public-path.config.js create mode 100644 test/serve/basic/src/other.js diff --git a/packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap b/packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap index e6fdcbe3b3d..ad76801f1da 100644 --- a/packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap +++ b/packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap @@ -4,6 +4,7 @@ exports[`startDevServer should set default port and host if not provided 1`] = ` Object { "host": "localhost", "port": 8080, + "publicPath": "/", } `; @@ -22,6 +23,7 @@ Object { "hot": true, "port": 9000, "progress": true, + "publicPath": "/", } `; @@ -40,6 +42,7 @@ Object { "hot": true, "port": 9000, "progress": true, + "publicPath": "/", } `; @@ -56,6 +59,7 @@ Object { "host": "localhost", "port": 9000, "progress": true, + "publicPath": "/", } `; @@ -64,6 +68,7 @@ Object { "host": "localhost", "port": 9001, "progress": true, + "publicPath": "/", } `; diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index 08a9478cc76..dd5065248ca 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -11,10 +11,7 @@ import { devServerOptionsType } from './types'; * @returns {Object[]} array of resulting servers */ export default async function startDevServer(compiler, cliOptions, logger): Promise { - let isDevServer4 = false, - devServerVersion, - Server, - findPort; + let devServerVersion, Server, findPort; try { // eslint-disable-next-line node/no-extraneous-require @@ -28,24 +25,6 @@ export default async function startDevServer(compiler, cliOptions, logger): Prom process.exit(2); } - isDevServer4 = devServerVersion.startsWith('4'); - - const defaultOpts = {}; - const devServerOptions = []; - const compilers = compiler.compilers || [compiler]; - - compilers.forEach((compiler) => { - if (compiler.options.devServer) { - devServerOptions.push(compiler.options.devServer); - } - }); - - if (devServerOptions.length === 0) { - devServerOptions.push(defaultOpts); - } - - const servers = []; - const usedPorts: number[] = []; const mergeOptions = (cliOptions: devServerOptionsType, devServerOptions: devServerOptionsType): devServerOptionsType => { // CLI options should take precedence over devServer options, // and CLI options should have no default values included @@ -60,35 +39,69 @@ export default async function startDevServer(compiler, cliOptions, logger): Prom return options; }; - for (const devServerOpts of devServerOptions) { - const options = mergeOptions(cliOptions, devServerOpts); + const isMultiCompiler = Boolean(compiler.compilers); + + let compilersWithDevServerOption; + + if (isMultiCompiler) { + compilersWithDevServerOption = compiler.compilers.filter((compiler) => compiler.options.devServer); + + // No compilers found with the `devServer` option, let's use first compiler + if (compilersWithDevServerOption.length === 0) { + compilersWithDevServerOption = [compiler.compilers[0]]; + } + } else { + compilersWithDevServerOption = [compiler]; + } + + const isDevServer4 = devServerVersion.startsWith('4'); + const usedPorts = []; + const devServersOptions = []; + + for (const compilerWithDevServerOption of compilersWithDevServerOption) { + const options = mergeOptions(cliOptions, compilerWithDevServerOption.options.devServer || {}); if (isDevServer4) { options.port = await findPort(options.port); options.client = options.client || {}; options.client.port = options.client.port || options.port; } else { + if (!options.publicPath) { + options.publicPath = + typeof compilerWithDevServerOption.options.output.publicPath === 'undefined' || + compilerWithDevServerOption.options.output.publicPath === 'auto' + ? '/' + : compilerWithDevServerOption.options.output.publicPath; + } + options.host = options.host || 'localhost'; options.port = options.port || 8080; } if (options.port) { - const portNum = +options.port; + const portNumber = Number(options.port); - if (usedPorts.find((port) => portNum === port)) { + if (usedPorts.find((port) => portNumber === port)) { throw new Error( 'Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.', ); } - usedPorts.push(portNum); + usedPorts.push(portNumber); } + devServersOptions.push({ compiler, options }); + } + + const servers = []; + + for (const devServerOptions of devServersOptions) { + const { compiler, options } = devServerOptions; const server = new Server(compiler, options); - server.listen(options.port, options.host, (err): void => { - if (err) { - throw err; + server.listen(options.port, options.host, (error): void => { + if (error) { + throw error; } }); diff --git a/packages/serve/src/types.ts b/packages/serve/src/types.ts index 61c59c5543a..f4a1b276fd0 100644 --- a/packages/serve/src/types.ts +++ b/packages/serve/src/types.ts @@ -27,6 +27,7 @@ export type devServerOptionsType = { static?: boolean | string | object | (string | object)[]; transportMode?: object | string; useLocalIp?: boolean; + publicPath?: undefined; }; type devServerClientOptions = { diff --git a/test/serve/basic/dev-server-output-public-path.config.js b/test/serve/basic/dev-server-output-public-path.config.js new file mode 100644 index 00000000000..e84e9137dd6 --- /dev/null +++ b/test/serve/basic/dev-server-output-public-path.config.js @@ -0,0 +1,13 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = { + mode: 'development', + devtool: false, + output: { + publicPath: '/my-public-path/', + }, + devServer: { + publicPath: '/dev-server-my-public-path/', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')], +}; diff --git a/test/serve/basic/multi-dev-server-output-public-path.config.js b/test/serve/basic/multi-dev-server-output-public-path.config.js new file mode 100644 index 00000000000..56409276d4e --- /dev/null +++ b/test/serve/basic/multi-dev-server-output-public-path.config.js @@ -0,0 +1,26 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = [ + { + name: 'one', + mode: 'development', + devtool: false, + entry: './src/other.js', + output: { + filename: 'first-output/[name].js', + }, + }, + { + name: 'two', + mode: 'development', + devtool: false, + output: { + publicPath: '/my-public-path/', + filename: 'second-output/[name].js', + }, + devServer: { + publicPath: '/dev-server-my-public-path/', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')], + }, +]; diff --git a/test/serve/basic/multi-dev-server.config.js b/test/serve/basic/multi-dev-server.config.js new file mode 100644 index 00000000000..59bb8f16133 --- /dev/null +++ b/test/serve/basic/multi-dev-server.config.js @@ -0,0 +1,32 @@ +const getPort = require('get-port'); + +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = async () => [ + { + name: 'one', + mode: 'development', + devtool: false, + output: { + filename: 'first-output/[name].js', + }, + devServer: { + port: await getPort(), + publicPath: '/one-dev-server-my-public-path/', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')], + }, + { + name: 'two', + mode: 'development', + devtool: false, + entry: './src/other.js', + output: { + filename: 'second-output/[name].js', + }, + devServer: { + port: await getPort(), + publicPath: '/two-dev-server-my-public-path/', + }, + }, +]; diff --git a/test/serve/basic/multi-output-public-path.config.js b/test/serve/basic/multi-output-public-path.config.js new file mode 100644 index 00000000000..64286a1c2ef --- /dev/null +++ b/test/serve/basic/multi-output-public-path.config.js @@ -0,0 +1,23 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = [ + { + name: 'one', + mode: 'development', + devtool: false, + output: { + publicPath: '/my-public-path/', + filename: 'first-output/[name].js', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')], + }, + { + name: 'two', + mode: 'development', + devtool: false, + entry: './src/other.js', + output: { + filename: 'second-output/[name].js', + }, + }, +]; diff --git a/test/serve/basic/multi.config.js b/test/serve/basic/multi.config.js new file mode 100644 index 00000000000..e344db6c72b --- /dev/null +++ b/test/serve/basic/multi.config.js @@ -0,0 +1,25 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = [ + { + name: 'one', + mode: 'development', + devtool: false, + output: { + filename: 'first-output/[name].js', + }, + devServer: { + publicPath: '/dev-server-my-public-path/', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')], + }, + { + name: 'two', + mode: 'development', + devtool: false, + entry: './src/other.js', + output: { + filename: 'second-output/[name].js', + }, + }, +]; diff --git a/test/serve/basic/multiple-dev-server.config.js b/test/serve/basic/multiple-dev-server.config.js new file mode 100644 index 00000000000..154a03b2012 --- /dev/null +++ b/test/serve/basic/multiple-dev-server.config.js @@ -0,0 +1,29 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = [ + { + name: 'one', + mode: 'development', + devtool: false, + output: { + filename: 'first-output/[name].js', + }, + devServer: { + publicPath: '/dev-server-my-public-path/', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false)], + }, + { + name: 'two', + mode: 'development', + devtool: false, + entry: './src/other.js', + output: { + filename: 'first-output/[name].js', + }, + devServer: { + publicPath: '/dev-server-my-public-path/', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false)], + }, +]; diff --git a/test/serve/basic/output-public-path.config.js b/test/serve/basic/output-public-path.config.js new file mode 100644 index 00000000000..0b9f7f04547 --- /dev/null +++ b/test/serve/basic/output-public-path.config.js @@ -0,0 +1,10 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = { + mode: 'development', + devtool: false, + output: { + publicPath: '/my-public-path/', + }, + plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')], +}; diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index e6754e52658..f9f68736d73 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -2,7 +2,7 @@ const path = require('path'); const getPort = require('get-port'); -const { runServe, isDevServer4 } = require('../../utils/test-utils'); +const { runServe, isWebpack5, isDevServer4 } = require('../../utils/test-utils'); const testPath = path.resolve(__dirname); @@ -34,6 +34,29 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); + it('should work in multi compiler mode', async () => { + const { stderr, stdout } = await runServe(['serve', '--config', 'multi.config.js', '--port', port], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('one'); + expect(stdout).toContain('first-output/main.js'); + expect(stdout).toContain('two'); + expect(stdout).toContain('second-output/main.js'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + // TODO need fix in future, edge case + it.skip('should work in multi compiler mode with multiple dev servers', async () => { + const { stderr, stdout } = await runServe(['serve', '--config', 'multi-dev-server.config.js'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('one'); + expect(stdout).toContain('first-output/main.js'); + expect(stdout).toContain('two'); + expect(stdout).toContain('second-output/main.js'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + it('should work with the "--mode" option', async () => { const { stderr, stdout } = await runServe([], __dirname); @@ -141,7 +164,60 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1); }); - it.only('should work with the "--open" option', async () => { + it('should work with the default "publicPath" option', async () => { + const { stderr, stdout } = await runServe(['serve'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout).toContain('from /'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should work with the "--output-public-path" option', async () => { + const { stderr, stdout } = await runServe(['serve', '--output-public-path', '/my-public-path/'], __dirname); + + if (isWebpack5) { + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout).toContain('/my-public-path/'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + } else { + expect(stderr).toContain("unknown option '--output-public-path'"); + expect(stdout).toBeFalsy(); + } + }); + + it('should respect the "publicPath" option from configuration', async () => { + const { stderr, stdout } = await runServe(['serve', '--config', 'output-public-path.config.js'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout).toContain('/my-public-path/'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should respect the "publicPath" option from configuration using multi compiler mode', async () => { + const { stderr, stdout } = await runServe(['serve', '--config', 'multi-output-public-path.config.js', '--port', port], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('one'); + expect(stdout).toContain('first-output/main.js'); + expect(stdout).toContain('two'); + expect(stdout).toContain('second-output/main.js'); + expect(stdout).toContain('/my-public-path/'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should respect the "publicPath" option from configuration (from the "devServer" options)', async () => { + const { stderr, stdout } = await runServe(['serve', '--config', 'dev-server-output-public-path.config.js'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('main.js'); + expect(stdout).toContain('/dev-server-my-public-path/'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should work with the "--open" option', async () => { const { stdout, stderr } = await runServe(['--open', '--port', port], testPath); expect(stderr).toBeFalsy(); @@ -149,6 +225,22 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); + it('should respect the "publicPath" option from configuration using multi compiler mode (from the "devServer" options)', async () => { + const { stderr, stdout } = await runServe( + ['serve', '--config', 'multi-dev-server-output-public-path.config.js', '--port', port], + __dirname, + ); + + expect(stderr).toBeFalsy(); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('one'); + expect(stdout).toContain('first-output/main.js'); + expect(stdout).toContain('two'); + expect(stdout).toContain('second-output/main.js'); + expect(stdout).toContain('/dev-server-my-public-path/'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + it('should log and error on unknown flag', async () => { const { exitCode, stdout, stderr } = await runServe(['--port', port, '--unknown-flag'], testPath); diff --git a/test/serve/basic/src/other.js b/test/serve/basic/src/other.js new file mode 100644 index 00000000000..2457f618e17 --- /dev/null +++ b/test/serve/basic/src/other.js @@ -0,0 +1 @@ +console.log('HERE'); From 2b5874e7da98d5439be6e30b6b9ffb0aa19f0b03 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 31 Dec 2020 18:43:01 +0300 Subject: [PATCH 201/581] refactor: code (#2280) --- packages/webpack-cli/__tests__/CLI.test.js | 1228 +++++++++++++++++ .../webpack-cli/__tests__/arg-parser.test.js | 472 ------- packages/webpack-cli/lib/utils/cli-flags.js | 28 +- packages/webpack-cli/lib/webpack-cli.js | 154 ++- .../function-with-env.test.js | 2 +- 5 files changed, 1335 insertions(+), 549 deletions(-) create mode 100644 packages/webpack-cli/__tests__/CLI.test.js delete mode 100644 packages/webpack-cli/__tests__/arg-parser.test.js diff --git a/packages/webpack-cli/__tests__/CLI.test.js b/packages/webpack-cli/__tests__/CLI.test.js new file mode 100644 index 00000000000..cf64bbf55b0 --- /dev/null +++ b/packages/webpack-cli/__tests__/CLI.test.js @@ -0,0 +1,1228 @@ +const CLI = require('../lib/webpack-cli'); + +describe('CLI API', () => { + let cli; + + beforeEach(() => { + cli = new CLI(); + }); + + describe('makeCommand', () => { + it('should make command', async (done) => { + const command = await cli.makeCommand({ name: 'command' }, [], (program) => { + expect(program.opts()).toEqual({}); + + done(); + }); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with Boolean option by default', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean', + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ boolean: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean'], { from: 'user' }); + }); + + it('should make command with Boolean option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean', + type: Boolean, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ boolean: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean'], { from: 'user' }); + }); + + it('should make command with Boolean option and negative value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean', + type: Boolean, + description: 'description', + negative: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ boolean: false }); + + done(); + }, + ); + + command.parseAsync(['--no-boolean'], { from: 'user' }); + }); + + it('should make command with Boolean option and negative value #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean', + type: Boolean, + description: 'description', + negative: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ boolean: false }); + + done(); + }, + ); + + command.parseAsync(['--boolean', '--no-boolean'], { from: 'user' }); + }); + + it('should make command with Boolean option and negative value #3', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean', + type: Boolean, + description: 'description', + negative: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ boolean: true }); + + done(); + }, + ); + + command.parseAsync(['--no-boolean', '--boolean'], { from: 'user' }); + }); + + it('should make command with Boolean option with default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean', + type: Boolean, + description: 'description', + defaultValue: false, + }, + ], + (program) => { + expect(program.opts()).toEqual({ boolean: false }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with String option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + type: String, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: 'bar' }); + + done(); + }, + ); + + command.parseAsync(['--string', 'bar'], { from: 'user' }); + }); + + it('should make command with String option with alias', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + alias: 's', + type: String, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: 'foo' }); + + done(); + }, + ); + + command.parseAsync(['-s', 'foo'], { from: 'user' }); + }); + + it('should make command with String option with default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + type: String, + description: 'description', + defaultValue: 'default-value', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: 'default-value' }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with String option with default value #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + type: String, + description: 'description', + defaultValue: 'default-value', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: 'foo' }); + + done(); + }, + ); + + command.parseAsync(['--string', 'foo'], { from: 'user' }); + }); + + it('should make command with String option using "=" syntax', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + type: String, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: 'bar' }); + + done(); + }, + ); + + command.parseAsync(['--string=bar'], { from: 'user' }); + }); + + it('should make command with multiple String option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + multiple: true, + type: String, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: ['foo', 'bar'] }); + + done(); + }, + ); + + command.parseAsync(['--string', 'foo', 'bar'], { from: 'user' }); + }); + + it('should make command with multiple String option with default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + multiple: true, + type: String, + description: 'description', + defaultValue: 'string', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: 'string' }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with multiple String option with default value #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + multiple: true, + type: String, + description: 'description', + defaultValue: 'string', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: ['foo', 'bar'] }); + + done(); + }, + ); + + command.parseAsync(['--string', 'foo', '--string', 'bar'], { from: 'user' }); + }); + + it('should make command with multiple String option #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'string', + multiple: true, + type: String, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ string: ['foo', 'bar'] }); + + done(); + }, + ); + + command.parseAsync(['--string', 'foo', '--string', 'bar'], { from: 'user' }); + }); + + it('should make command with Number option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'number', + type: Number, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ number: 12 }); + + done(); + }, + ); + + command.parseAsync(['--number', '12'], { from: 'user' }); + }); + + it('should make command with Number option with default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'number', + type: Number, + description: 'description', + defaultValue: 20, + }, + ], + (program) => { + expect(program.opts()).toEqual({ number: 20 }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with multiple Number option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'number', + multiple: true, + type: Number, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ number: [1, 2] }); + + done(); + }, + ); + + command.parseAsync(['--number', '1', '--number', '2'], { from: 'user' }); + }); + + it('should make command with multiple Number option and default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'number', + multiple: true, + type: Number, + description: 'description', + defaultValue: 50, + }, + ], + (program) => { + expect(program.opts()).toEqual({ number: [1, 2] }); + + done(); + }, + ); + + command.parseAsync(['--number', '1', '--number', '2'], { from: 'user' }); + }); + + it('should make command with multiple Number option and default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'number', + multiple: true, + type: Number, + description: 'description', + defaultValue: 50, + }, + ], + (program) => { + expect(program.opts()).toEqual({ number: 50 }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with custom function type', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'custom', + type: () => { + return 'function'; + }, + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ custom: 'function' }); + + done(); + }, + ); + + command.parseAsync(['--custom', 'value'], { from: 'user' }); + }); + + it('should make command with custom function type and default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'custom', + type: () => { + return 'function'; + }, + description: 'description', + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ custom: 'default' }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with multiple custom function type', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'custom', + type: (value, previous = []) => { + return previous.concat([value]); + }, + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ custom: ['value', 'other'] }); + + done(); + }, + ); + + command.parseAsync(['--custom', 'value', '--custom', 'other'], { from: 'user' }); + }); + + it('should make command with multiple custom function type and default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'custom', + type: (value, previous = []) => { + return previous.concat([value]); + }, + description: 'description', + multiple: true, + defaultValue: 50, + }, + ], + (program) => { + expect(program.opts()).toEqual({ custom: 50 }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with multiple custom function type and default value #2', async (done) => { + let skipDefault = true; + + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'custom', + type: (value, previous = []) => { + if (skipDefault) { + previous = []; + skipDefault = false; + } + + return [].concat(previous).concat([value]); + }, + description: 'description', + multiple: true, + defaultValue: 50, + }, + ], + (program) => { + expect(program.opts()).toEqual({ custom: ['foo'] }); + + done(); + }, + ); + + command.parseAsync(['--custom', 'foo'], { from: 'user' }); + }); + + it('should make command with Boolean and String option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-string', + type: [Boolean, String], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndString: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-string'], { from: 'user' }); + }); + + it('should make command with Boolean and String option #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-string', + type: [Boolean, String], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndString: 'value' }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-string', 'value'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and String option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-string', + type: [Boolean, String], + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndString: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-string'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and String option #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-string', + type: [Boolean, String], + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndString: ['bar', 'baz'] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-string', 'bar', '--boolean-and-string', 'baz'], { from: 'user' }); + }); + + it('should make command with Boolean and String option and negative', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-string', + type: [Boolean, String], + description: 'description', + negative: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndString: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-string'], { from: 'user' }); + }); + + it('should make command with Boolean and String option and negative #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-string', + type: [Boolean, String], + description: 'description', + negative: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndString: 'foo' }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-string', 'foo'], { from: 'user' }); + }); + + it('should make command with Boolean and String option and negative #3', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-string', + type: [Boolean, String], + description: 'description', + negative: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndString: false }); + + done(); + }, + ); + + command.parseAsync(['--no-boolean-and-string'], { from: 'user' }); + }); + + it('should make command with Boolean and Number option', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number', + type: [Boolean, Number], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumber: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number'], { from: 'user' }); + }); + + it('should make command with Boolean and Number option #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number', + type: [Boolean, Number], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumber: 12 }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number', '12'], { from: 'user' }); + }); + + it('should make command with array Boolean type', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean', + type: [Boolean], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ boolean: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean'], { from: 'user' }); + }); + + it('should make command with Boolean and Number and String type', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string'], { from: 'user' }); + }); + + it('should make command with Boolean and Number and String type #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: 12 }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', '12'], { from: 'user' }); + }); + + it('should make command with Boolean and Number and String type #3', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: 'bar' }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', 'bar'], { from: 'user' }); + }); + + it('should make command with Boolean and Number and String type and default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: 'default' }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with Boolean and Number and String type and default value #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: 'foo' }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', 'foo'], { from: 'user' }); + }); + + it('should make command with Boolean and Number and String type and default value #3', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: 12 }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', '12'], { from: 'user' }); + }); + + it('should make command with Boolean and Number and String type and default value #4', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: 'default' }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String type', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: true }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String type #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo'] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', 'foo'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String type #3', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: [12] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', '12'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String type #4', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo', 'bar'] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', 'foo', '--boolean-and-number-and-string', 'bar'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String type #5', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo', 12] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', 'foo', '--boolean-and-number-and-string', '12'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String and default value', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: 'default' }); + + done(); + }, + ); + + command.parseAsync([], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String and default value #2', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo'] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', 'foo'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String and default value #3', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: [12] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', '12'], { from: 'user' }); + }); + + it('should make command with multiple Boolean and Number and String and default value #4', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'boolean-and-number-and-string', + type: [Boolean, Number, String], + description: 'description', + multiple: true, + defaultValue: 'default', + }, + ], + (program) => { + expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo', 12] }); + + done(); + }, + ); + + command.parseAsync(['--boolean-and-number-and-string', 'foo', '--boolean-and-number-and-string', '12'], { from: 'user' }); + }); + + it('should make command with array of unknown types', async (done) => { + const command = await cli.makeCommand( + { + name: 'command', + }, + [ + { + name: 'unknown', + type: [Boolean, Symbol], + description: 'description', + }, + ], + (program) => { + expect(program.opts()).toEqual({ unknown: 'foo' }); + + done(); + }, + ); + + command.parseAsync(['--unknown', 'foo'], { from: 'user' }); + }); + }); +}); diff --git a/packages/webpack-cli/__tests__/arg-parser.test.js b/packages/webpack-cli/__tests__/arg-parser.test.js deleted file mode 100644 index 55956e85d88..00000000000 --- a/packages/webpack-cli/__tests__/arg-parser.test.js +++ /dev/null @@ -1,472 +0,0 @@ -const warnMock = jest.fn(); -const rawMock = jest.fn(); -jest.mock('../lib/utils/logger', () => { - return { - warn: warnMock, - raw: rawMock, - }; -}); - -const processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {}); -const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); - -const argParser = () => {}; -const { flags } = require('../lib/utils/cli-flags'); - -const basicOptions = [ - { - name: 'bool-flag', - alias: 'b', - usage: '--bool-flag', - type: Boolean, - description: 'boolean flag', - }, - { - name: 'num-flag', - usage: '--num-flag ', - type: Number, - description: 'number flag', - }, - { - name: 'neg-flag', - alias: 'n', - usage: '--neg-flag', - type: Boolean, - negative: true, - description: 'boolean flag', - }, - { - name: 'string-flag', - alias: 's', - usage: '--string-flag ', - type: String, - description: 'string flag', - }, - { - name: 'string-flag-with-default', - usage: '--string-flag-with-default ', - type: String, - description: 'string flag', - defaultValue: 'default-value', - }, - { - name: 'multi-type', - alias: 'm', - usage: '--multi-type | --multi-type ', - type: [String, Boolean], - negative: true, - description: 'flag with multiple types', - }, - { - name: 'multi-type-different-order', - usage: '--multi-type-different-order | --multi-type-different-order ', - // duplicates and a different ordering should be handled correctly - type: [Boolean, String, Boolean], - description: 'flag with multiple types in different order', - }, - { - name: 'multi-type-empty', - usage: '--multi-type-empty', - // should default to Boolean type - type: [], - description: 'flag with empty multi type array', - }, - { - name: 'multi-type-number', - usage: '--multi-type-number', - // should use only Number type (the first in the array), - // because Number and Boolean together are not supported - type: [Number, Boolean], - description: 'flag with number multi type', - }, - { - name: 'custom-type-flag', - usage: '--custom-type-flag ', - type: (val) => { - return val.split(','); - }, - description: 'custom type flag', - }, - { - name: 'multi-flag', - usage: '--multi-flag ', - type: String, - multiple: true, - description: 'multi flag', - }, - { - name: 'processor-flag', - usage: '--processor-flag', - type: Boolean, - description: 'flag with processor', - processor(opts) { - opts.processed = opts.processorFlag; - delete opts.processorFlag; - }, - }, - { - name: 'env', - usage: '--env', - type: String, - multipleType: true, - description: 'Environment passed to the configuration when it is a function', - }, -]; - -const helpAndVersionOptions = basicOptions.slice(0); -helpAndVersionOptions.push( - { - name: 'help', - usage: '--help', - type: Boolean, - description: 'help', - }, - { - name: 'version', - alias: 'v', - usage: '--version', - type: Boolean, - description: 'version', - }, -); - -describe.skip('arg-parser', () => { - beforeEach(() => { - warnMock.mockClear(); - processExitSpy.mockClear(); - consoleErrorSpy.mockClear(); - }); - - it('parses no flags', () => { - const res = argParser(basicOptions, [], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses basic flags', () => { - const res = argParser(basicOptions, ['--bool-flag', '--string-flag', 'val', '--num-flag', '100'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - boolFlag: true, - numFlag: 100, - stringFlag: 'val', - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses number flags', () => { - const res = argParser(basicOptions, ['--num-flag', '100'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - numFlag: 100, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses number flags with = sign', () => { - const res = argParser(basicOptions, ['--num-flag=10'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - numFlag: 10, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('should not parse negated boolean flags which are not specified', () => { - const res = argParser(basicOptions, ['--no-bool-flag'], true); - expect(res.unknownArgs.includes('--no-bool-flag')).toBeTruthy(); - }); - - it('parses boolean flag alias', () => { - const res = argParser(basicOptions, ['-b'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - boolFlag: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses string flag alias', () => { - const res = argParser(basicOptions, ['-s', 'string-value'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - stringFlag: 'string-value', - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multi type flag as Boolean', () => { - const res = argParser(basicOptions, ['--multi-type'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiType: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multi type flag as String', () => { - const res = argParser(basicOptions, ['--multi-type', 'value'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiType: 'value', - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multi type flag alias as Boolean', () => { - const res = argParser(basicOptions, ['-m'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiType: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multi type flag alias as String', () => { - const res = argParser(basicOptions, ['-m', 'value'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiType: 'value', - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses negated multi type flag as Boolean', () => { - const res = argParser(basicOptions, ['--no-multi-type'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiType: false, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multi type flag with different ordering as Boolean', () => { - const res = argParser(basicOptions, ['--multi-type-different-order'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiTypeDifferentOrder: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multi type flag with different ordering as String', () => { - const res = argParser(basicOptions, ['--multi-type-different-order', 'value'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiTypeDifferentOrder: 'value', - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses empty multi type flag array as Boolean', () => { - const res = argParser(basicOptions, ['--multi-type-empty'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiTypeEmpty: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multi type flag (Number, Boolean) as Number', () => { - const res = argParser(basicOptions, ['--multi-type-number', '1.1'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiTypeNumber: 1.1, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parsing multi type flag (Number, Boolean) as Boolean fails', () => { - // this should fail because a multi type of Number and Boolean is - // not supported - argParser(basicOptions, ['--multi-type-number'], true); - expect(warnMock.mock.calls.length).toEqual(0); - - // by default, commander handles the error with a process.exit(1) - // along with an error message - expect(processExitSpy.mock.calls.length).toEqual(1); - expect(processExitSpy.mock.calls[0]).toEqual([1]); - - expect(consoleErrorSpy.mock.calls.length).toEqual(1); - expect(consoleErrorSpy.mock.calls[0][0]).toContain("option '--multi-type-number ' argument missing"); - }); - - it('warns on usage of both flag alias and same negated flag, setting it to true', () => { - const res = argParser(basicOptions, ['--no-neg-flag', '-n'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - negFlag: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(1); - expect(warnMock.mock.calls[0][0]).toContain('You provided both -n and --no-neg-flag'); - }); - - it('parses string flag using equals sign', () => { - const res = argParser(basicOptions, ['--string-flag=val'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - stringFlag: 'val', - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('handles multiple same args', () => { - const res = argParser(basicOptions, ['--multi-flag', 'a.js', '--multi-flag', 'b.js'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - multiFlag: ['a.js', 'b.js'], - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('handles additional node args from argv', () => { - const res = argParser(basicOptions, ['node', 'index.js', '--bool-flag', '--string-flag', 'val'], false); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - boolFlag: true, - stringFlag: 'val', - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('handles unknown args', () => { - const res = argParser(basicOptions, ['--unknown-arg', '-b', 'no-leading-dashes'], true); - expect(res.unknownArgs).toEqual(['--unknown-arg', 'no-leading-dashes']); - expect(res.opts).toEqual({ - boolFlag: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('handles custom type args', () => { - const res = argParser(basicOptions, ['--custom-type-flag', 'val1,val2,val3'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - customTypeFlag: ['val1', 'val2', 'val3'], - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses webpack args', () => { - const res = argParser(flags, ['--entry', 'test.js', '--hot', '-o', './dist/', '--stats'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts.entry).toEqual(['test.js']); - expect(res.opts.hot).toBeTruthy(); - expect(res.opts.outputPath).toEqual('./dist/'); - expect(res.opts.stats).toEqual(true); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses --neg-flag', () => { - const res = argParser(basicOptions, ['--neg-flag'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - negFlag: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses --no-neg-flag', () => { - const res = argParser(basicOptions, ['--no-neg-flag'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - negFlag: false, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('warns on usage of both --neg and --no-neg flag, setting it to false', () => { - const res = argParser(basicOptions, ['--neg-flag', '--no-neg-flag'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - negFlag: false, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(1); - expect(warnMock.mock.calls[0][0]).toContain('You provided both --neg-flag and --no-neg-flag'); - }); - - it('warns on usage of both flag and same negated flag, setting it to true', () => { - const res = argParser(basicOptions, ['--no-neg-flag', '--neg-flag'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts).toEqual({ - negFlag: true, - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(1); - expect(warnMock.mock.calls[0][0]).toContain('You provided both --neg-flag and --no-neg-flag'); - }); - - it('handles unknown flag', () => { - const res = argParser(basicOptions, ['--unknown-flag'], true); - expect(res.unknownArgs).toEqual(['--unknown-flag']); - expect(res.opts).toEqual({ - stringFlagWithDefault: 'default-value', - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses multiType flag', () => { - const res = argParser(basicOptions, ['--env', 'production', '--env', 'platform=staging'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts.env).toEqual({ - platform: 'staging', - production: true, - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses nested multiType flag', () => { - const res = argParser(basicOptions, ['--env', 'a.b=d', '--env', 'a.b.c=d'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts.env).toEqual({ - a: { - b: { - c: 'd', - }, - }, - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); - - it('parses nested multiType flag with diff keys', () => { - const res = argParser(basicOptions, ['--env', 'a.b=c', '--env', 'd.e.f=g'], true); - expect(res.unknownArgs.length).toEqual(0); - expect(res.opts.env).toEqual({ - a: { - b: 'c', - }, - d: { - e: { - f: 'g', - }, - }, - }); - expect(warnMock.mock.calls.length).toEqual(0); - }); -}); diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 49272981835..b24410f2c84 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -47,8 +47,32 @@ const builtInFlags = [ { name: 'env', usage: '--env | --env --env ', - type: String, - multipleType: true, + type: (value, previous = {}) => { + // This ensures we're only splitting by the first `=` + const [allKeys, val] = value.split(/=(.+)/, 2); + const splitKeys = allKeys.split(/\.(?!$)/); + + let prevRef = previous; + + splitKeys.forEach((someKey, index) => { + if (!prevRef[someKey]) { + prevRef[someKey] = {}; + } + + if (typeof prevRef[someKey] === 'string') { + prevRef[someKey] = {}; + } + + if (index === splitKeys.length - 1) { + prevRef[someKey] = val || true; + } + + prevRef = prevRef[someKey]; + }); + + return previous; + }, + multiple: true, description: 'Environment passed to the configuration when it is a function.', }, diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 67201852276..c3b91fc554e 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -109,96 +109,102 @@ class WebpackCLI { return command; } - // TODO refactor this terrible stuff makeOption(command, option) { - let optionType = option.type; - let isStringOrBool = false; - - if (Array.isArray(optionType)) { - // filter out duplicate types - optionType = optionType.filter((type, index) => { - return optionType.indexOf(type) === index; - }); - - // the only multi type currently supported is String and Boolean, - // if there is a case where a different multi type is needed it - // must be added here - if (optionType.length === 0) { - // if no type is provided in the array fall back to Boolean - optionType = Boolean; - } else if (optionType.length === 1 || optionType.length > 2) { - // treat arrays with 1 or > 2 args as a single type - optionType = optionType[0]; + let type = option.type; + let isMultipleTypes = Array.isArray(type); + let isOptional = false; + + if (isMultipleTypes) { + if (type.length === 1) { + type = type[0]; + isMultipleTypes = false; } else { - // only String and Boolean multi type is supported - if (optionType.includes(Boolean) && optionType.includes(String)) { - isStringOrBool = true; - } else { - optionType = optionType[0]; - } + isOptional = type.includes(Boolean); } } - const flags = option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`; + const isMultiple = option.multiple; + const isRequired = type !== Boolean && typeof type !== 'undefined'; - let flagsWithType = flags; + let flags = option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`; - if (isStringOrBool) { - // commander recognizes [value] as an optional placeholder, - // making this flag work either as a string or a boolean - flagsWithType = `${flags} [value]`; - } else if (optionType !== Boolean) { + if (isOptional) { + // `commander.js` recognizes [value] as an optional placeholder, making this flag work either as a string or a boolean + flags = `${flags} [value${isMultiple ? '...' : ''}]`; + } else if (isRequired) { // is a required placeholder for any non-Boolean types - flagsWithType = `${flags} `; + flags = `${flags} `; } - if (isStringOrBool || optionType === Boolean || optionType === String) { - if (option.multiple) { - // a multiple argument parsing function - const multiArg = (value, previous = []) => previous.concat([value]); - - command.option(flagsWithType, option.description, multiArg, option.defaultValue); - } else if (option.multipleType) { - // for options which accept multiple types like env - // so you can do `--env platform=staging --env production` - // { platform: "staging", production: true } - const multiArg = (value, previous = {}) => { - // this ensures we're only splitting by the first `=` - const [allKeys, val] = value.split(/=(.+)/, 2); - const splitKeys = allKeys.split(/\.(?!$)/); - - let prevRef = previous; - - splitKeys.forEach((someKey, index) => { - if (!prevRef[someKey]) { - prevRef[someKey] = {}; - } + // TODO need to fix on webpack-dev-server side + // `describe` used by `webpack-dev-server` + const description = option.description || option.describe || ''; + const defaultValue = option.defaultValue; + + if (type === Boolean) { + command.option(flags, description, defaultValue); + } else if (type === Number) { + let skipDefault = true; + + command.option( + flags, + description, + (value, prev = []) => { + if (defaultValue && isMultiple && skipDefault) { + prev = []; + skipDefault = false; + } - if (typeof prevRef[someKey] === 'string') { - prevRef[someKey] = {}; - } + return isMultiple ? [].concat(prev).concat(Number(value)) : Number(value); + }, + defaultValue, + ); + } else if (type === String) { + let skipDefault = true; + + command.option( + flags, + description, + (value, prev = []) => { + if (defaultValue && isMultiple && skipDefault) { + prev = []; + skipDefault = false; + } - if (index === splitKeys.length - 1) { - prevRef[someKey] = val || true; - } + return isMultiple ? [].concat(prev).concat(value) : value; + }, + defaultValue, + ); + } else if (isMultipleTypes) { + let skipDefault = true; + + command.option( + flags, + description, + (value, prev = []) => { + if (defaultValue && isMultiple && skipDefault) { + prev = []; + skipDefault = false; + } - prevRef = prevRef[someKey]; - }); + if (type.includes(Number)) { + const numberValue = Number(value); - return previous; - }; + if (!isNaN(numberValue)) { + return isMultiple ? [].concat(prev).concat(numberValue) : numberValue; + } + } - command.option(flagsWithType, option.description, multiArg, option.defaultValue); - } else { - // Prevent default behavior for standalone options - command.option(flagsWithType, option.description, option.defaultValue); - } - } else if (optionType === Number) { - // this will parse the flag as a number - command.option(flagsWithType, option.description, Number, option.defaultValue); + if (type.includes(String)) { + return isMultiple ? [].concat(prev).concat(value) : value; + } + + return value; + }, + defaultValue, + ); } else { - // in this case the type is a parsing function - command.option(flagsWithType, option.description, optionType, option.defaultValue); + command.option(flags, description, type, defaultValue); } if (option.negative) { diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index d498a5d582a..c3a0275e460 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -8,7 +8,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`option '--env ' argument missing`); + expect(stderr).toContain(`option '--env ' argument missing`); expect(stdout).toBeFalsy(); }); From d885426671ead56168e1f008dbfd6fe19fb57edd Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 31 Dec 2020 18:43:33 +0300 Subject: [PATCH 202/581] chore(deps-dev): bump @types/node from 14.14.16 to 14.14.17 (#2279) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.16 to 14.14.17. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c442a38f70b..83f0a538aae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2457,9 +2457,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.16" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.16.tgz#3cc351f8d48101deadfed4c9e4f116048d437b4b" - integrity sha512-naXYePhweTi+BMv11TgioE2/FXU4fSl29HAH1ffxVciNsH3rYXjNP2yM8wqmSm7jS20gM8TIklKiTen+1iVncw== + version "14.14.17" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.17.tgz#29fab92f3986c0e379968ad3c2043683d8020dbb" + integrity sha512-G0lD1/7qD60TJ/mZmhog76k7NcpLWkPVGgzkRy3CTlnFu4LUQh5v2Wa661z6vnXmD8EQrnALUyf0VRtrACYztw== "@types/normalize-package-data@^2.4.0": version "2.4.0" From d6380bb6c6756d2a00ac20f2ffc454481d97e4d3 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 31 Dec 2020 19:47:43 +0300 Subject: [PATCH 203/581] fix: provide useful error on unknown command --- packages/webpack-cli/lib/webpack-cli.js | 18 +++++++++++++++++- test/unknown/unknown.test.js | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index c3b91fc554e..2f85a0c85ee 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -273,6 +273,9 @@ class WebpackCLI { }, ]; + const knownCommands = [bundleCommandOptions, versionCommandOptions, helpCommandOptions, ...externalBuiltInCommandsInfo]; + const isKnownCommand = (name) => knownCommands.find((command) => command.name === name || command.alias === name); + const getCommandNameAndOptions = (args) => { let commandName; const options = []; @@ -687,7 +690,20 @@ class WebpackCLI { await outputVersion(optionsForVersion, program); } - await loadCommandByName(commandName, true); + if (isKnownCommand(commandName)) { + await loadCommandByName(commandName, true); + } else { + logger.error(`Unknown command '${commandName}'`); + + const found = knownCommands.find((commandOptions) => distance(commandName, commandOptions.name) < 3); + + if (found) { + logger.error(`Did you mean '${found.name}' (alias '${found.alias}')?`); + } + + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } await this.program.parseAsync([commandName, ...options], { from: 'user' }); }); diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index bb8ba841b06..78258b22580 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -184,12 +184,22 @@ describe('unknown behaviour', () => { expect(stdout).toBeFalsy(); }); - it('should ask to install command if an unknown command passed', () => { + it('should log error if an unknown command passed', () => { const { exitCode, stderr, stdout } = run(__dirname, ['qqq'], true, [], { TERM_PROGRAM: false }); - expect(exitCode).toBe(0); - expect(stripAnsi(stderr)).toContain("For using this command you need to install: 'qqq' package"); - expect(stripAnsi(stderr)).toContain("Would you like to install 'qqq' package? (That will run 'npm install -D qqq')"); + expect(exitCode).toBe(2); + expect(stripAnsi(stderr)).toContain("Unknown command 'qqq'"); + expect(stripAnsi(stderr)).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error and provide suggestion if an unknown command passed', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['server'], true, [], { TERM_PROGRAM: false }); + + expect(exitCode).toBe(2); + expect(stripAnsi(stderr)).toContain("Unknown command 'server'"); + expect(stripAnsi(stderr)).toContain("Did you mean 'serve' (alias 's')?"); + expect(stripAnsi(stderr)).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); }); From 29eaa8e843510e020ac4b57a13622df40713fe27 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 31 Dec 2020 20:22:32 +0300 Subject: [PATCH 204/581] fix: error message on not installed module loaders for configuration (#2282) --- packages/webpack-cli/lib/webpack-cli.js | 18 +++++++++++++++++- test/config-format/failure/failure.test.js | 19 +++++++++++++++++++ .../failure/webpack.config.coffee | 10 ++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test/config-format/failure/failure.test.js create mode 100644 test/config-format/failure/webpack.config.coffee diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 2f85a0c85ee..df8649fba1a 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -717,7 +717,23 @@ class WebpackCLI { const interpreted = Object.keys(jsVariants).find((variant) => variant === ext); if (interpreted) { - rechoir.prepare(extensions, configPath); + try { + rechoir.prepare(extensions, configPath); + } catch (error) { + if (error.failures) { + logger.error(`Unable load '${configPath}'`); + logger.error(error.message); + + error.failures.forEach((failure) => { + logger.error(failure.error.message); + }); + logger.error('Please install one of them'); + process.exit(2); + } + + logger.error(error); + process.exit(2); + } } const { pathToFileURL } = require('url'); diff --git a/test/config-format/failure/failure.test.js b/test/config-format/failure/failure.test.js new file mode 100644 index 00000000000..125c94e31bf --- /dev/null +++ b/test/config-format/failure/failure.test.js @@ -0,0 +1,19 @@ +const path = require('path'); + +const { run } = require('../../utils/test-utils'); + +describe('webpack cli', () => { + it('should support mjs config format', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee']); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`Unable load '${path.resolve(__dirname, './webpack.config.coffee')}'`); + expect(stderr).toContain('Unable to use specified module loaders for ".coffee".'); + expect(stderr).toContain("Cannot find module 'coffeescript/register'"); + expect(stderr).toContain("Cannot find module 'coffee-script/register'"); + expect(stderr).toContain("Cannot find module 'coffeescript'"); + expect(stderr).toContain("Cannot find module 'coffee-script'"); + expect(stderr).toContain('Please install one of them'); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/config-format/failure/webpack.config.coffee b/test/config-format/failure/webpack.config.coffee new file mode 100644 index 00000000000..15e1934891b --- /dev/null +++ b/test/config-format/failure/webpack.config.coffee @@ -0,0 +1,10 @@ +path = require 'path' + +config = + mode: 'production' + entry: './main.js' + output: + path: path.resolve(__dirname, 'dist') + filename: 'foo.bundle.js' + +module.exports = config; From 083f2a069d6dc0a3b9492eb3f205474ba843acfd Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 31 Dec 2020 20:27:03 +0300 Subject: [PATCH 205/581] fix: peer dependencies (#2284) --- packages/webpack-cli/package.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index b0efd6392e1..66515dec846 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -45,13 +45,10 @@ "webpack": "4.x.x || 5.x.x" }, "peerDependenciesMeta": { - "@webpack-cli/init": { - "optional": true - }, - "@webpack-cli/generate-loader": { + "@webpack-cli/generators": { "optional": true }, - "@webpack-cli/generate-plugin": { + "@webpack-cli/init": { "optional": true }, "@webpack-cli/migrate": { From a5171999177925529a1c54f242afc2bd9c9e4fe3 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 31 Dec 2020 20:27:47 +0300 Subject: [PATCH 206/581] chore(release): publish new version - @webpack-cli/generators@1.2.1 - @webpack-cli/info@1.2.1 - @webpack-cli/init@1.1.1 - @webpack-cli/migrate@1.1.2 - @webpack-cli/serve@1.2.1 - @webpack-cli/utils@1.2.1 - webpack-cli@4.3.1 --- packages/generators/CHANGELOG.md | 6 ++++++ packages/generators/package.json | 4 ++-- packages/info/CHANGELOG.md | 6 ++++++ packages/info/package.json | 2 +- packages/init/CHANGELOG.md | 6 ++++++ packages/init/package.json | 6 +++--- packages/migrate/CHANGELOG.md | 6 ++++++ packages/migrate/package.json | 4 ++-- packages/serve/CHANGELOG.md | 9 +++++++++ packages/serve/package.json | 2 +- packages/utils/CHANGELOG.md | 4 ++++ packages/utils/package.json | 2 +- packages/webpack-cli/CHANGELOG.md | 10 ++++++++++ packages/webpack-cli/package.json | 6 +++--- 14 files changed, 60 insertions(+), 13 deletions(-) diff --git a/packages/generators/CHANGELOG.md b/packages/generators/CHANGELOG.md index 34b698e7486..d0ad83af03e 100644 --- a/packages/generators/CHANGELOG.md +++ b/packages/generators/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.2.0...@webpack-cli/generators@1.2.1) (2020-12-31) + +### Bug Fixes + +- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) + # [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.1.0...@webpack-cli/generators@1.2.0) (2020-12-25) ### Bug Fixes diff --git a/packages/generators/package.json b/packages/generators/package.json index 95463bc867c..c8fd91dd020 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generators", - "version": "1.2.0", + "version": "1.2.1", "description": "Webpack-CLI generators", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -14,7 +14,7 @@ "templates" ], "dependencies": { - "@webpack-cli/utils": "^1.2.0", + "@webpack-cli/utils": "^1.2.1", "colorette": "^1.2.1", "log-symbols": "^4.0.0", "yeoman-environment": "^2.10.3", diff --git a/packages/info/CHANGELOG.md b/packages/info/CHANGELOG.md index ba92309543f..32c830bbc58 100644 --- a/packages/info/CHANGELOG.md +++ b/packages/info/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.0...@webpack-cli/info@1.2.1) (2020-12-31) + +### Bug Fixes + +- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) + # [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.1.0...@webpack-cli/info@1.2.0) (2020-12-25) ### Features diff --git a/packages/info/package.json b/packages/info/package.json index 44a6eb34749..dbb837959a5 100644 --- a/packages/info/package.json +++ b/packages/info/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/info", - "version": "1.2.0", + "version": "1.2.1", "description": "Outputs info about system and webpack config", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/init/CHANGELOG.md b/packages/init/CHANGELOG.md index 97e89695a3f..93e6f1b35a2 100644 --- a/packages/init/CHANGELOG.md +++ b/packages/init/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.0...@webpack-cli/init@1.1.1) (2020-12-31) + +### Bug Fixes + +- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) + # [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.3...@webpack-cli/init@1.1.0) (2020-12-25) ### Features diff --git a/packages/init/package.json b/packages/init/package.json index 8cd6773dd3d..0898105ef64 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/init", - "version": "1.1.0", + "version": "1.1.1", "description": "init command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,8 +12,8 @@ "lib" ], "dependencies": { - "@webpack-cli/generators": "^1.2.0", - "@webpack-cli/utils": "^1.2.0" + "@webpack-cli/generators": "^1.2.1", + "@webpack-cli/utils": "^1.2.1" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", diff --git a/packages/migrate/CHANGELOG.md b/packages/migrate/CHANGELOG.md index cd4609fd11f..7415e2633a7 100644 --- a/packages/migrate/CHANGELOG.md +++ b/packages/migrate/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.1.1...@webpack-cli/migrate@1.1.2) (2020-12-31) + +### Bug Fixes + +- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) + ## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.1.0...@webpack-cli/migrate@1.1.1) (2020-12-25) **Note:** Version bump only for package @webpack-cli/migrate diff --git a/packages/migrate/package.json b/packages/migrate/package.json index b5d55622eda..e4e74bc21ac 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/migrate", - "version": "1.1.1", + "version": "1.1.2", "description": "Migrate command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,7 +12,7 @@ "lib" ], "dependencies": { - "@webpack-cli/utils": "^1.2.0", + "@webpack-cli/utils": "^1.2.1", "colorette": "^1.2.1", "diff": "^4.0.2", "inquirer": "^7.3.3", diff --git a/packages/serve/CHANGELOG.md b/packages/serve/CHANGELOG.md index 6d717309c1d..0e8cb3a23b2 100644 --- a/packages/serve/CHANGELOG.md +++ b/packages/serve/CHANGELOG.md @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.0...@webpack-cli/serve@1.2.1) (2020-12-31) + +### Bug Fixes + +- do not apply HotModuleReplacement plugin twice ([#2269](https://github.com/webpack/webpack-cli/issues/2269)) ([bb16d44](https://github.com/webpack/webpack-cli/commit/bb16d4481414a5f3c0cbeb18af690084b2ae4215)) +- respect the `output.publicPath` option for the `serve`command ([#2271](https://github.com/webpack/webpack-cli/issues/2271)) ([a3092ef](https://github.com/webpack/webpack-cli/commit/a3092ef2b51ece30221f7dd7b30a686626c1fd7a)) +- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) +- the `--progress` option with the `serve` command ([#2265](https://github.com/webpack/webpack-cli/issues/2265)) ([952a188](https://github.com/webpack/webpack-cli/commit/952a1883b1a18c4fb38e8eb7bbbdb2aefc7942f4)) + # [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.1.0...@webpack-cli/serve@1.2.0) (2020-12-25) ### Bug Fixes diff --git a/packages/serve/package.json b/packages/serve/package.json index 8494acaeafc..4099c82ec35 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/serve", - "version": "1.2.0", + "version": "1.2.1", "description": "", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 8772374651c..caca2302e41 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.2.0...@webpack-cli/utils@1.2.1) (2020-12-31) + +**Note:** Version bump only for package @webpack-cli/utils + # [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.1.0...@webpack-cli/utils@1.2.0) (2020-12-25) ### Bug Fixes diff --git a/packages/utils/package.json b/packages/utils/package.json index 2f763950450..8f96970b4d4 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/utils", - "version": "1.2.0", + "version": "1.2.1", "description": "webpack-cli utility files", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/webpack-cli/CHANGELOG.md b/packages/webpack-cli/CHANGELOG.md index aca420758ac..609b60d1d6e 100644 --- a/packages/webpack-cli/CHANGELOG.md +++ b/packages/webpack-cli/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.3.1](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.0...webpack-cli@4.3.1) (2020-12-31) + +### Bug Fixes + +- error message on not installed module loaders for configuration ([#2282](https://github.com/webpack/webpack-cli/issues/2282)) ([29eaa8e](https://github.com/webpack/webpack-cli/commit/29eaa8e843510e020ac4b57a13622df40713fe27)) +- peer dependencies ([#2284](https://github.com/webpack/webpack-cli/issues/2284)) ([083f2a0](https://github.com/webpack/webpack-cli/commit/083f2a069d6dc0a3b9492eb3f205474ba843acfd)) +- provide useful error on unknown command ([d6380bb](https://github.com/webpack/webpack-cli/commit/d6380bb6c6756d2a00ac20f2ffc454481d97e4d3)) +- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) +- the `--progress` option is working with `--json` ([#2276](https://github.com/webpack/webpack-cli/issues/2276)) ([0595603](https://github.com/webpack/webpack-cli/commit/05956030cbb1491a2e9313732470bcd4ebe5a36d)) + # [4.3.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.2.0...webpack-cli@4.3.0) (2020-12-25) ### Bug Fixes diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 66515dec846..d03d1ab2d84 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -1,6 +1,6 @@ { "name": "webpack-cli", - "version": "4.3.0", + "version": "4.3.1", "description": "CLI for webpack & friends", "license": "MIT", "repository": { @@ -28,8 +28,8 @@ ], "dependencies": { "@discoveryjs/json-ext": "^0.5.0", - "@webpack-cli/info": "^1.2.0", - "@webpack-cli/serve": "^1.2.0", + "@webpack-cli/info": "^1.2.1", + "@webpack-cli/serve": "^1.2.1", "colorette": "^1.2.1", "commander": "^6.2.0", "enquirer": "^2.3.6", From beea425221aecba1c5f174805df87a20b35a18a1 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Thu, 31 Dec 2020 20:28:19 +0300 Subject: [PATCH 207/581] docs: update changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2296eaf03c3..60d30584744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [4.3.1](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.0...webpack-cli@4.3.1) (2020-12-31) + +### Bug Fixes + +- error message on not installed module loaders for configuration ([#2282](https://github.com/webpack/webpack-cli/issues/2282)) ([29eaa8e](https://github.com/webpack/webpack-cli/commit/29eaa8e843510e020ac4b57a13622df40713fe27)) +- peer dependencies ([#2284](https://github.com/webpack/webpack-cli/issues/2284)) ([083f2a0](https://github.com/webpack/webpack-cli/commit/083f2a069d6dc0a3b9492eb3f205474ba843acfd)) +- provide useful error on unknown command ([d6380bb](https://github.com/webpack/webpack-cli/commit/d6380bb6c6756d2a00ac20f2ffc454481d97e4d3)) +- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) +- the `--progress` option is working with `--json` ([#2276](https://github.com/webpack/webpack-cli/issues/2276)) ([0595603](https://github.com/webpack/webpack-cli/commit/05956030cbb1491a2e9313732470bcd4ebe5a36d)) + # [4.3.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.2.0...webpack-cli@4.3.0) (2020-12-25) ### Bug Fixes From 4dc1a05046aeaf5a17de878a9e595697852bcd32 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 1 Jan 2021 09:40:23 +0300 Subject: [PATCH 208/581] chore: fix ci coverage (#2283) --- .github/workflows/nodejs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index efa797aa162..c5787566709 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -61,6 +61,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Using Node v${{ matrix.node-version }} uses: actions/setup-node@v1 From caf034837347d6b6854c64b5af2dc5b4f1891ea7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 3 Jan 2021 16:13:43 +0300 Subject: [PATCH 209/581] chore(deps-dev): bump @types/node from 14.14.17 to 14.14.19 (#2292) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.17 to 14.14.19. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 83f0a538aae..8cb36d9367d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2457,9 +2457,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.17" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.17.tgz#29fab92f3986c0e379968ad3c2043683d8020dbb" - integrity sha512-G0lD1/7qD60TJ/mZmhog76k7NcpLWkPVGgzkRy3CTlnFu4LUQh5v2Wa661z6vnXmD8EQrnALUyf0VRtrACYztw== + version "14.14.19" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.19.tgz#5135176a8330b88ece4e9ab1fdcfc0a545b4bab4" + integrity sha512-4nhBPStMK04rruRVtVc6cDqhu7S9GZai0fpXgPXrFpcPX6Xul8xnrjSdGB4KPBVYG/R5+fXWdCM8qBoiULWGPQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 087a61c4eebe82a3b727ae3b7eb75f29cd167f7a Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 3 Jan 2021 18:48:34 +0530 Subject: [PATCH 210/581] docs: fix typo (#2295) --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f68cbd3e629..3ce9cf3263f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -6,7 +6,7 @@ You arrived at this template because you felt none of the other options matched the kind of issue you'd like to report. Please use this opportunity to - tell us about your particular type of issue so we can try to accomodate + tell us about your particular type of issue so we can try to accommodate similar issues in the future. PLEASE do note, if you're using this to report an issue already covered by the From 70b26324a86aabfa025b5d384c5206c1731e5f17 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 3 Jan 2021 16:23:16 +0300 Subject: [PATCH 211/581] chore(deps-dev): bump eslint from 7.16.0 to 7.17.0 (#2293) Bumps [eslint](https://github.com/eslint/eslint) from 7.16.0 to 7.17.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.16.0...v7.17.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8cb36d9367d..557b1cce8d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4287,14 +4287,7 @@ debug@3.1.0, debug@=3.1.0: dependencies: ms "2.0.0" -debug@^3.1.0, debug@^3.1.1: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" - -debug@^3.2.6: +debug@^3.1.0, debug@^3.1.1, debug@^3.2.6: version "3.2.7" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== @@ -4924,9 +4917,9 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.16.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.16.0.tgz#a761605bf9a7b32d24bb7cde59aeb0fd76f06092" - integrity sha512-iVWPS785RuDA4dWuhhgXTNrGxHHK3a8HLSMBgbbU59ruJDubUraXN8N5rn7kb8tG6sjg74eE0RA3YWT51eusEw== + version "7.17.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.17.0.tgz#4ccda5bf12572ad3bf760e6f195886f50569adb0" + integrity sha512-zJk08MiBgwuGoxes5sSQhOtibZ75pz0J35XTRlZOk9xMffhpA9BTbQZxoXZzOl5zMbleShbGwtw+1kGferfFwQ== dependencies: "@babel/code-frame" "^7.0.0" "@eslint/eslintrc" "^0.2.2" From 4ee8665e01e8dce16448e0a4d3dd2293731695ab Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 3 Jan 2021 18:57:44 +0530 Subject: [PATCH 212/581] fix: better description for --no-watch-options-stdin (#2288) --- packages/webpack-cli/lib/utils/cli-flags.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index b24410f2c84..7a3476a64a3 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -182,6 +182,7 @@ const builtInFlags = [ type: Boolean, negative: true, description: 'Stop watching when stdin stream has ended.', + negatedDescription: 'Do not stop watching when stdin stream has ended.', }, ]; From afc922e0846b3d0e014765ce2562bf173f4f551a Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 3 Jan 2021 19:04:22 +0530 Subject: [PATCH 213/581] chore: create script to update docs (#2286) --- OPTIONS.md | 578 +++++++++++++++++++++++++++ package.json | 3 +- packages/webpack-cli/README.md | 699 +-------------------------------- scripts/updateDocs.js | 21 + 4 files changed, 602 insertions(+), 699 deletions(-) create mode 100644 OPTIONS.md create mode 100644 scripts/updateDocs.js diff --git a/OPTIONS.md b/OPTIONS.md new file mode 100644 index 00000000000..b7bc2513aeb --- /dev/null +++ b/OPTIONS.md @@ -0,0 +1,578 @@ +``` +Usage: webpack [options] +Alternative usage: webpack bundle [options] +Alternative usage: webpack --config [options] +Alternative usage: webpack bundle --config [options] + +The build tool for modern web applications. + +Options: + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + -h, --hot Enables Hot Module Replacement + --no-hot Disables Hot Module Replacement. + --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. + --progress [value] Print compilation progress during build. + --prefetch Prefetch this request. + -j, --json [value] Prints result as JSON or store it in a file. + --amd You can pass `false` to disable AMD support. + --no-amd Negative 'amd' option. + --bail Report the first error as a hard error instead of tolerating it. + --no-bail Negative 'bail' option. + --cache Enable in memory caching. Disable caching. + --no-cache Negative 'cache' option. + --cache-type In memory caching. Filesystem caching. + --cache-cache-directory Base directory for the cache (defaults to node_modules/.cache/webpack). + --cache-cache-location Locations for the cache (defaults to cacheDirectory / name). + --cache-hash-algorithm Algorithm used for generation the hash (see node.js crypto package). + --cache-idle-timeout Time in ms after which idle period the cache storing should happen (only for store: 'pack' or 'idle'). + --cache-idle-timeout-for-initial-store Time in ms after which idle period the initial cache storing should happen (only for store: 'pack' or 'idle'). + --cache-immutable-paths A path to a immutable directory (usually a package manager cache directory). + --cache-immutable-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable. + --cache-managed-paths A path to a managed directory (usually a node_modules directory). + --cache-managed-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and can be trusted to not be modified otherwise. + --cache-name Name for the cache. Different names will lead to different coexisting caches. + --cache-store When to store data to the filesystem. (pack: Store data when compiler is idle in a single file). + --cache-version Version of the cache data. Different versions won't allow to reuse the cache and override existing content. Update the version when config changed in a way which doesn't allow to reuse cache. This will invalidate the cache. + --context The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory. + --dependencies References to another configuration to depend on. + --dependencies-reset Clear all items provided in configuration. References to other configurations to depend on. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --entry The entry point(s) of your application e.g. ./src/main.js. + --entry-reset Clear all items provided in configuration. All modules are loaded upon startup. The last one is exported. + --experiments-asset Allow module type 'asset' to generate assets. + --no-experiments-asset Negative 'experiments-asset' option. + --experiments-async-web-assembly Support WebAssembly as asynchronous EcmaScript Module. + --no-experiments-async-web-assembly Negative 'experiments-async-web-assembly' option. + --experiments-output-module Allow output javascript files as module source type. + --no-experiments-output-module Negative 'experiments-output-module' option. + --experiments-sync-web-assembly Support WebAssembly as synchronous EcmaScript Module (outdated). + --no-experiments-sync-web-assembly Negative 'experiments-sync-web-assembly' option. + --experiments-top-level-await Allow using top-level-await in EcmaScript Modules. + --no-experiments-top-level-await Negative 'experiments-top-level-await' option. + --externals Every matched dependency becomes external. An exact matched dependency becomes external. The same string is used as external dependency. + --externals-reset Clear all items provided in configuration. Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`. + --externals-presets-electron Treat common electron built-in modules in main and preload context like 'electron', 'ipc' or 'shell' as external and load them via require() when used. + --no-externals-presets-electron Negative 'externals-presets-electron' option. + --externals-presets-electron-main Treat electron built-in modules in the main context like 'app', 'ipc-main' or 'shell' as external and load them via require() when used. + --no-externals-presets-electron-main Negative 'externals-presets-electron-main' option. + --externals-presets-electron-preload Treat electron built-in modules in the preload context like 'web-frame', 'ipc-renderer' or 'shell' as external and load them via require() when used. + --no-externals-presets-electron-preload Negative 'externals-presets-electron-preload' option. + --externals-presets-electron-renderer Treat electron built-in modules in the renderer context like 'web-frame', 'ipc-renderer' or 'shell' as external and load them via require() when used. + --no-externals-presets-electron-renderer Negative 'externals-presets-electron-renderer' option. + --externals-presets-node Treat node.js built-in modules like fs, path or vm as external and load them via require() when used. + --no-externals-presets-node Negative 'externals-presets-node' option. + --externals-presets-nwjs Treat NW.js legacy nw.gui module as external and load it via require() when used. + --no-externals-presets-nwjs Negative 'externals-presets-nwjs' option. + --externals-presets-web Treat references to 'http(s)://...' and 'std:...' as external and load them via import when used (Note that this changes execution order as externals are executed before any other code in the chunk). + --no-externals-presets-web Negative 'externals-presets-web' option. + --externals-presets-web-async Treat references to 'http(s)://...' and 'std:...' as external and load them via async import() when used (Note that this external type is an async module, which has various effects on the execution). + --no-externals-presets-web-async Negative 'externals-presets-web-async' option. + --externals-type Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value). + --ignore-warnings A RegExp to select the warning message. + --ignore-warnings-file A RegExp to select the origin file for the warning. + --ignore-warnings-message A RegExp to select the warning message. + --ignore-warnings-module A RegExp to select the origin module for the warning. + --ignore-warnings-reset Clear all items provided in configuration. Ignore specific warnings. + --infrastructure-logging-debug Enable/Disable debug logging for all loggers. Enable debug logging for specific loggers. + --infrastructure-logging-debug-reset Clear all items provided in configuration. Enable debug logging for specific loggers. + --infrastructure-logging-level Log level. + --mode Defines the mode to pass to webpack. + --module-expr-context-critical Enable warnings for full dynamic dependencies. + --no-module-expr-context-critical Negative 'module-expr-context-critical' option. + --module-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. + --no-module-expr-context-recursive Negative 'module-expr-context-recursive' option. + --module-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. + --module-expr-context-request Set the default request for full dynamic dependencies. + --module-no-parse A regular expression, when matched the module is not parsed. An absolute path, when the module starts with this path it is not parsed. + --module-no-parse-reset Clear all items provided in configuration. Don't parse files matching. It's matched against the full resolved request. + --module-rules-compiler Match the child compiler name. + --module-rules-dependency Match dependency type. + --module-rules-enforce Enforce this rule as pre or post step. + --module-rules-exclude Shortcut for resource.exclude. + --module-rules-include Shortcut for resource.include. + --module-rules-issuer Match the issuer of the module (The module pointing to this module). + --module-rules-loader A loader request. + --module-rules-mimetype Match module mimetype when load from Data URI. + --module-rules-real-resource Match the real resource path of the module. + --module-rules-resource Match the resource path of the module. + --module-rules-resource-fragment Match the resource fragment of the module. + --module-rules-resource-query Match the resource query of the module. + --module-rules-side-effects Flags a module as with or without side effects. + --no-module-rules-side-effects Negative 'module-rules-side-effects' option. + --module-rules-test Shortcut for resource.test. + --module-rules-type Module type to use for the module. + --module-rules-use-ident Unique loader options identifier. + --module-rules-use-loader A loader request. + --module-rules-use-options Options passed to a loader. + --module-rules-use A loader request. + --module-rules-reset Clear all items provided in configuration. A list of rules. + --module-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported module. + --no-module-strict-export-presence Negative 'module-strict-export-presence' option. + --module-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace objects. + --no-module-strict-this-context-on-imports Negative 'module-strict-this-context-on-imports' option. + --module-unknown-context-critical Enable warnings when using the require function in a not statically analyse-able way. + --no-module-unknown-context-critical Negative 'module-unknown-context-critical' option. + --module-unknown-context-recursive Enable recursive directory lookup when using the require function in a not statically analyse-able way. + --no-module-unknown-context-recursive Negative 'module-unknown-context-recursive' option. + --module-unknown-context-reg-exp Sets the regular expression when using the require function in a not statically analyse-able way. + --module-unknown-context-request Sets the request when using the require function in a not statically analyse-able way. + --module-unsafe-cache Cache the resolving of module requests. + --no-module-unsafe-cache Negative 'module-unsafe-cache' option. + --module-wrapped-context-critical Enable warnings for partial dynamic dependencies. + --no-module-wrapped-context-critical Negative 'module-wrapped-context-critical' option. + --module-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. + --no-module-wrapped-context-recursive Negative 'module-wrapped-context-recursive' option. + --module-wrapped-context-reg-exp Set the inner regular expression for partial dynamic dependencies. + --name Name of the configuration. Used when loading multiple configurations. + --node Include polyfills or mocks for various node stuff. + --no-node Negative 'node' option. + --node-dirname Include a polyfill for the '__dirname' variable. + --node-filename Include a polyfill for the '__filename' variable. + --node-global Include a polyfill for the 'global' variable. + --no-node-global Negative 'node-global' option. + --optimization-check-wasm-types Check for incompatible wasm types when importing/exporting from/to ESM. + --no-optimization-check-wasm-types Negative 'optimization-check-wasm-types' option. + --optimization-chunk-ids Define the algorithm to choose chunk ids (named: readable ids for better debugging, deterministic: numeric hash ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin). + --optimization-concatenate-modules Concatenate modules when possible to generate less modules, more efficient code and enable more optimizations by the minimizer. + --no-optimization-concatenate-modules Negative 'optimization-concatenate-modules' option. + --optimization-emit-on-errors Emit assets even when errors occur. Critical errors are emitted into the generated code and will cause errors at runtime. + --no-optimization-emit-on-errors Negative 'optimization-emit-on-errors' option. + --optimization-flag-included-chunks Also flag chunks as loaded which contain a subset of the modules. + --no-optimization-flag-included-chunks Negative 'optimization-flag-included-chunks' option. + --optimization-inner-graph Creates a module-internal dependency graph for top level symbols, exports and imports, to improve unused exports detection. + --no-optimization-inner-graph Negative 'optimization-inner-graph' option. + --optimization-mangle-exports Rename exports when possible to generate shorter code (depends on optimization.usedExports and optimization.providedExports, true/"deterministic": generate short deterministic names optimized for caching, "size": generate the shortest possible names). + --optimization-mangle-wasm-imports Reduce size of WASM by changing imports to shorter strings. + --no-optimization-mangle-wasm-imports Negative 'optimization-mangle-wasm-imports' option. + --optimization-merge-duplicate-chunks Merge chunks which contain the same modules. + --no-optimization-merge-duplicate-chunks Negative 'optimization-merge-duplicate-chunks' option. + --optimization-minimize Enable minimizing the output. Uses optimization.minimizer. + --no-optimization-minimize Negative 'optimization-minimize' option. + --optimization-module-ids Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: (deprecated) short hashes as ids for better long term caching, deterministic: numeric hash ids for better long term caching, size: numeric ids focused on minimal initial download size, false: no algorithm used, as custom one can be provided via plugin). + --optimization-node-env Set process.env.NODE_ENV to a specific value. + --optimization-portable-records Generate records with relative paths to be able to move the context folder. + --no-optimization-portable-records Negative 'optimization-portable-records' option. + --optimization-provided-exports Figure out which exports are provided by modules to generate more efficient code. + --no-optimization-provided-exports Negative 'optimization-provided-exports' option. + --optimization-real-content-hash Use real [contenthash] based on final content of the assets. + --no-optimization-real-content-hash Negative 'optimization-real-content-hash' option. + --optimization-remove-available-modules Removes modules from chunks when these modules are already included in all parents. + --no-optimization-remove-available-modules Negative 'optimization-remove-available-modules' option. + --optimization-remove-empty-chunks Remove chunks which are empty. + --no-optimization-remove-empty-chunks Negative 'optimization-remove-empty-chunks' option. + --optimization-runtime-chunk Create an additional chunk which contains only the webpack runtime and chunk hash maps. + --optimization-runtime-chunk-name The name or name factory for the runtime chunks. + --optimization-side-effects Skip over modules which contain no side effects when exports are not used (false: disabled, 'flag': only use manually placed side effects flag, true: also analyse source code for side effects). + --optimization-split-chunks Optimize duplication and caching by splitting chunks by shared modules and cache group. + --no-optimization-split-chunks Negative 'optimization-split-chunks' option. + --optimization-split-chunks-automatic-name-delimiter Sets the name delimiter for created chunks. + --optimization-split-chunks-chunks Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML). + --optimization-split-chunks-default-size-types Size type, like 'javascript', 'webassembly'. + --optimization-split-chunks-default-size-types-reset Clear all items provided in configuration. Sets the size types which are used when a number is used for sizes. + --optimization-split-chunks-enforce-size-threshold Size of the javascript part of the chunk. + --optimization-split-chunks-fallback-cache-group-automatic-name-delimiter Sets the name delimiter for created chunks. + --optimization-split-chunks-fallback-cache-group-max-async-size Size of the javascript part of the chunk. + --optimization-split-chunks-fallback-cache-group-max-initial-size Size of the javascript part of the chunk. + --optimization-split-chunks-fallback-cache-group-max-size Size of the javascript part of the chunk. + --optimization-split-chunks-fallback-cache-group-min-size Size of the javascript part of the chunk. + --optimization-split-chunks-filename Sets the template for the filename for created chunks. + --optimization-split-chunks-hide-path-info Prevents exposing path info when creating names for parts splitted by maxSize. + --no-optimization-split-chunks-hide-path-info Negative 'optimization-split-chunks-hide-path-info' option. + --optimization-split-chunks-max-async-requests Maximum number of requests which are accepted for on-demand loading. + --optimization-split-chunks-max-async-size Size of the javascript part of the chunk. + --optimization-split-chunks-max-initial-requests Maximum number of initial chunks which are accepted for an entry point. + --optimization-split-chunks-max-initial-size Size of the javascript part of the chunk. + --optimization-split-chunks-max-size Size of the javascript part of the chunk. + --optimization-split-chunks-min-chunks Minimum number of times a module has to be duplicated until it's considered for splitting. + --optimization-split-chunks-min-remaining-size Size of the javascript part of the chunk. + --optimization-split-chunks-min-size Size of the javascript part of the chunk. + --optimization-split-chunks-name Give chunks created a name (chunks with equal name are merged). + --optimization-split-chunks-used-exports Compare used exports when checking common modules. Modules will only be put in the same chunk when exports are equal. + --no-optimization-split-chunks-used-exports Negative 'optimization-split-chunks-used-exports' option. + --optimization-used-exports Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code (true: analyse used exports for each runtime, "global": analyse exports globally for all runtimes combined). + --output-asset-module-filename The filename of asset modules as relative path inside the `output.path` directory. + --output-charset Add charset attribute for script tag. + --no-output-charset Negative 'output-charset' option. + --output-chunk-filename The filename of non-initial chunks as relative path inside the `output.path` directory. + --output-chunk-format The format of chunks (formats included by default are 'array-push' (web/WebWorker), 'commonjs' (node.js), but others might be added by plugins). + --output-chunk-load-timeout Number of milliseconds before chunk request expires. + --output-chunk-loading The method of loading chunks (methods included by default are 'jsonp' (web), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins). + --output-chunk-loading-global The global variable used by webpack for loading of chunks. + --output-compare-before-emit Check if to be emitted file already exists and have the same content before writing to output filesystem. + --no-output-compare-before-emit Negative 'output-compare-before-emit' option. + --output-cross-origin-loading This option enables cross-origin loading of chunks. + --output-devtool-fallback-module-filename-template Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers. + --output-devtool-module-filename-template Filename template string of function for the sources array in a generated SourceMap. + --output-devtool-namespace Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries. + --output-enabled-chunk-loading-types The method of loading chunks (methods included by default are 'jsonp' (web), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins). + --output-enabled-chunk-loading-types-reset Clear all items provided in configuration. List of chunk loading types enabled for use by entry points. + --output-enabled-library-types Type of library (types included by default are 'var', 'module', 'assign', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins). + --output-enabled-library-types-reset Clear all items provided in configuration. List of library types enabled for use by entry points. + --output-enabled-wasm-loading-types The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins). + --output-enabled-wasm-loading-types-reset Clear all items provided in configuration. List of wasm loading types enabled for use by entry points. + --output-environment-arrow-function The environment supports arrow functions ('() => { ... }'). + --no-output-environment-arrow-function Negative 'output-environment-arrow-function' option. + --output-environment-big-int-literal The environment supports BigInt as literal (123n). + --no-output-environment-big-int-literal Negative 'output-environment-big-int-literal' option. + --output-environment-const The environment supports const and let for variable declarations. + --no-output-environment-const Negative 'output-environment-const' option. + --output-environment-destructuring The environment supports destructuring ('{ a, b } = obj'). + --no-output-environment-destructuring Negative 'output-environment-destructuring' option. + --output-environment-dynamic-import The environment supports an async import() function to import EcmaScript modules. + --no-output-environment-dynamic-import Negative 'output-environment-dynamic-import' option. + --output-environment-for-of The environment supports 'for of' iteration ('for (const x of array) { ... }'). + --no-output-environment-for-of Negative 'output-environment-for-of' option. + --output-environment-module The environment supports EcmaScript Module syntax to import EcmaScript modules (import ... from '...'). + --no-output-environment-module Negative 'output-environment-module' option. + --output-filename Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files. + --output-global-object An expression which is used to address the global object/scope in runtime code. + --output-hash-digest Digest type used for the hash. + --output-hash-digest-length Number of chars which are used for the hash. + --output-hash-function Algorithm used for generation the hash (see node.js crypto package). + --output-hash-salt Any string which is added to the hash to salt it. + --output-hot-update-chunk-filename The filename of the Hot Update Chunks. They are inside the output.path directory. + --output-hot-update-global The global variable used by webpack for loading of hot update chunks. + --output-hot-update-main-filename The filename of the Hot Update Main File. It is inside the `output.path` directory. + --output-iife Wrap javascript code into IIFE's to avoid leaking into global scope. + --no-output-iife Negative 'output-iife' option. + --output-import-function-name The name of the native import() function (can be exchanged for a polyfill). + --output-import-meta-name The name of the native import.meta object (can be exchanged for a polyfill). + --output-library A part of the library name. + --output-library-reset Clear all items provided in configuration. The name of the library (some types allow unnamed libraries too). + --output-library-amd Name of the exposed AMD library in the UMD. + --output-library-commonjs Name of the exposed commonjs export in the UMD. + --output-library-root Part of the name of the property exposed globally by a UMD library. + --output-library-root-reset Clear all items provided in configuration. Name of the property exposed globally by a UMD library. + --output-library-auxiliary-comment Append the same comment above each import style. + --output-library-auxiliary-comment-amd Set comment for `amd` section in UMD. + --output-library-auxiliary-comment-commonjs Set comment for `commonjs` (exports) section in UMD. + --output-library-auxiliary-comment-commonjs2 Set comment for `commonjs2` (module.exports) section in UMD. + --output-library-auxiliary-comment-root Set comment for `root` (global variable) section in UMD. + --output-library-export Part of the export that should be exposed as library. + --output-library-export-reset Clear all items provided in configuration. Specify which export should be exposed as library. + --output-library-name A part of the library name. + --output-library-name-reset Clear all items provided in configuration. The name of the library (some types allow unnamed libraries too). + --output-library-name-amd Name of the exposed AMD library in the UMD. + --output-library-name-commonjs Name of the exposed commonjs export in the UMD. + --output-library-name-root Part of the name of the property exposed globally by a UMD library. + --output-library-name-root-reset Clear all items provided in configuration. Name of the property exposed globally by a UMD library. + --output-library-type Type of library (types included by default are 'var', 'module', 'assign', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins). + --output-library-umd-named-define If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module. + --no-output-library-umd-named-define Negative 'output-library-umd-named-define' option. + --output-module Output javascript files as module source type. + --no-output-module Negative 'output-module' option. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + --output-pathinfo Include comments with information about the modules. + --no-output-pathinfo Negative 'output-pathinfo' option. + --output-public-path The `publicPath` specifies the public URL address of the output files when referenced in a browser. + --output-script-type This option enables loading async chunks via a custom script type, such as script type="module". + --output-source-map-filename The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory. + --output-source-prefix Prefixes every line of the source in the bundle with this string. + --output-strict-module-exception-handling Handles exceptions in module loading correctly at a performance cost. + --no-output-strict-module-exception-handling Negative 'output-strict-module-exception-handling' option. + --output-unique-name A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. + --output-wasm-loading The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins). + --output-webassembly-module-filename The filename of WebAssembly modules as relative path inside the `output.path` directory. + --output-worker-chunk-loading The method of loading chunks (methods included by default are 'jsonp' (web), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins). + --output-worker-wasm-loading The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins). + --parallelism The number of parallel processed modules in the compilation. + --performance Configuration for web performance recommendations. + --no-performance Negative 'performance' option. + --performance-hints Sets the format of the hints: warnings, errors or nothing at all. + --performance-max-asset-size File size limit (in bytes) when exceeded, that webpack will provide performance hints. + --performance-max-entrypoint-size Total size of an entry point (in bytes). + --profile Capture timing information for each module. + --no-profile Negative 'profile' option. + --records-input-path Store compiler state to a json file. + --records-output-path Load compiler state from a json file. + --records-path Store/Load compiler state from/to a json file. This will result in persistent ids of modules and chunks. An absolute path is expected. `recordsPath` is used for `recordsInputPath` and `recordsOutputPath` if they left undefined. + --resolve-alias-alias Ignore request (replace with empty module). New request. + --resolve-alias-name Request to be redirected. + --resolve-alias-only-module Redirect only exact matching request. + --no-resolve-alias-only-module Negative 'resolve-alias-only-module' option. + --resolve-alias-reset Clear all items provided in configuration. Redirect module requests. + --resolve-alias-fields Field in the description file (usually package.json) which are used to redirect requests inside the module. + --resolve-alias-fields-reset Clear all items provided in configuration. Fields in the description file (usually package.json) which are used to redirect requests inside the module. + --resolve-cache Enable caching of successfully resolved requests (cache entries are revalidated). + --no-resolve-cache Negative 'resolve-cache' option. + --resolve-cache-with-context Include the context information in the cache identifier when caching. + --no-resolve-cache-with-context Negative 'resolve-cache-with-context' option. + --resolve-condition-names Condition names for exports field entry point. + --resolve-condition-names-reset Clear all items provided in configuration. Condition names for exports field entry point. + --resolve-description-files Filename used to find a description file (like a package.json). + --resolve-description-files-reset Clear all items provided in configuration. Filenames used to find a description file (like a package.json). + --resolve-enforce-extension Enforce the resolver to use one of the extensions from the extensions option (User must specify requests without extension). + --no-resolve-enforce-extension Negative 'resolve-enforce-extension' option. + --resolve-exports-fields Field name from the description file (usually package.json) which is used to provide entry points of a package. + --resolve-exports-fields-reset Clear all items provided in configuration. Field names from the description file (usually package.json) which are used to provide entry points of a package. + --resolve-extensions Extension added to the request when trying to find the file. + --resolve-extensions-reset Clear all items provided in configuration. Extensions added to the request when trying to find the file. + --resolve-fallback-alias Ignore request (replace with empty module). New request. + --resolve-fallback-name Request to be redirected. + --resolve-fallback-only-module Redirect only exact matching request. + --no-resolve-fallback-only-module Negative 'resolve-fallback-only-module' option. + --resolve-fallback-reset Clear all items provided in configuration. Redirect module requests. + --resolve-fully-specified Treats the request specified by the user as fully specified, meaning no extensions are added and the mainFiles in directories are not resolved (This doesn't affect requests from mainFields, aliasFields or aliases). + --no-resolve-fully-specified Negative 'resolve-fully-specified' option. + --resolve-imports-fields Field name from the description file (usually package.json) which is used to provide internal request of a package (requests starting with # are considered as internal). + --resolve-imports-fields-reset Clear all items provided in configuration. Field names from the description file (usually package.json) which are used to provide internal request of a package (requests starting with # are considered as internal). + --resolve-main-fields Field name from the description file (package.json) which are used to find the default entry point. + --resolve-main-fields-reset Clear all items provided in configuration. Field names from the description file (package.json) which are used to find the default entry point. + --resolve-main-files Filename used to find the default entry point if there is no description file or main field. + --resolve-main-files-reset Clear all items provided in configuration. Filenames used to find the default entry point if there is no description file or main field. + --resolve-modules Folder name or directory path where to find modules. + --resolve-modules-reset Clear all items provided in configuration. Folder names or directory paths where to find modules. + --resolve-prefer-relative Prefer to resolve module requests as relative request and fallback to resolving as module. + --no-resolve-prefer-relative Negative 'resolve-prefer-relative' option. + --resolve-restrictions Resolve restriction. Resolve result must fulfill this restriction. + --resolve-restrictions-reset Clear all items provided in configuration. A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. + --resolve-roots Directory in which requests that are server-relative URLs (starting with '/') are resolved. + --resolve-roots-reset Clear all items provided in configuration. A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. + --resolve-symlinks Enable resolving symlinks to the original location. + --no-resolve-symlinks Negative 'resolve-symlinks' option. + --resolve-unsafe-cache Enable caching of successfully resolved requests (cache entries are not revalidated). + --no-resolve-unsafe-cache Negative 'resolve-unsafe-cache' option. + --resolve-use-sync-file-system-calls Use synchronous filesystem calls for the resolver. + --no-resolve-use-sync-file-system-calls Negative 'resolve-use-sync-file-system-calls' option. + --resolve-loader-alias-alias Ignore request (replace with empty module). New request. + --resolve-loader-alias-name Request to be redirected. + --resolve-loader-alias-only-module Redirect only exact matching request. + --no-resolve-loader-alias-only-module Negative 'resolve-loader-alias-only-module' option. + --resolve-loader-alias-reset Clear all items provided in configuration. Redirect module requests. + --resolve-loader-alias-fields Field in the description file (usually package.json) which are used to redirect requests inside the module. + --resolve-loader-alias-fields-reset Clear all items provided in configuration. Fields in the description file (usually package.json) which are used to redirect requests inside the module. + --resolve-loader-cache Enable caching of successfully resolved requests (cache entries are revalidated). + --no-resolve-loader-cache Negative 'resolve-loader-cache' option. + --resolve-loader-cache-with-context Include the context information in the cache identifier when caching. + --no-resolve-loader-cache-with-context Negative 'resolve-loader-cache-with-context' option. + --resolve-loader-condition-names Condition names for exports field entry point. + --resolve-loader-condition-names-reset Clear all items provided in configuration. Condition names for exports field entry point. + --resolve-loader-description-files Filename used to find a description file (like a package.json). + --resolve-loader-description-files-reset Clear all items provided in configuration. Filenames used to find a description file (like a package.json). + --resolve-loader-enforce-extension Enforce the resolver to use one of the extensions from the extensions option (User must specify requests without extension). + --no-resolve-loader-enforce-extension Negative 'resolve-loader-enforce-extension' option. + --resolve-loader-exports-fields Field name from the description file (usually package.json) which is used to provide entry points of a package. + --resolve-loader-exports-fields-reset Clear all items provided in configuration. Field names from the description file (usually package.json) which are used to provide entry points of a package. + --resolve-loader-extensions Extension added to the request when trying to find the file. + --resolve-loader-extensions-reset Clear all items provided in configuration. Extensions added to the request when trying to find the file. + --resolve-loader-fallback-alias Ignore request (replace with empty module). New request. + --resolve-loader-fallback-name Request to be redirected. + --resolve-loader-fallback-only-module Redirect only exact matching request. + --no-resolve-loader-fallback-only-module Negative 'resolve-loader-fallback-only-module' option. + --resolve-loader-fallback-reset Clear all items provided in configuration. Redirect module requests. + --resolve-loader-fully-specified Treats the request specified by the user as fully specified, meaning no extensions are added and the mainFiles in directories are not resolved (This doesn't affect requests from mainFields, aliasFields or aliases). + --no-resolve-loader-fully-specified Negative 'resolve-loader-fully-specified' option. + --resolve-loader-imports-fields Field name from the description file (usually package.json) which is used to provide internal request of a package (requests starting with # are considered as internal). + --resolve-loader-imports-fields-reset Clear all items provided in configuration. Field names from the description file (usually package.json) which are used to provide internal request of a package (requests starting with # are considered as internal). + --resolve-loader-main-fields Field name from the description file (package.json) which are used to find the default entry point. + --resolve-loader-main-fields-reset Clear all items provided in configuration. Field names from the description file (package.json) which are used to find the default entry point. + --resolve-loader-main-files Filename used to find the default entry point if there is no description file or main field. + --resolve-loader-main-files-reset Clear all items provided in configuration. Filenames used to find the default entry point if there is no description file or main field. + --resolve-loader-modules Folder name or directory path where to find modules. + --resolve-loader-modules-reset Clear all items provided in configuration. Folder names or directory paths where to find modules. + --resolve-loader-prefer-relative Prefer to resolve module requests as relative request and fallback to resolving as module. + --no-resolve-loader-prefer-relative Negative 'resolve-loader-prefer-relative' option. + --resolve-loader-restrictions Resolve restriction. Resolve result must fulfill this restriction. + --resolve-loader-restrictions-reset Clear all items provided in configuration. A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. + --resolve-loader-roots Directory in which requests that are server-relative URLs (starting with '/') are resolved. + --resolve-loader-roots-reset Clear all items provided in configuration. A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. + --resolve-loader-symlinks Enable resolving symlinks to the original location. + --no-resolve-loader-symlinks Negative 'resolve-loader-symlinks' option. + --resolve-loader-unsafe-cache Enable caching of successfully resolved requests (cache entries are not revalidated). + --no-resolve-loader-unsafe-cache Negative 'resolve-loader-unsafe-cache' option. + --resolve-loader-use-sync-file-system-calls Use synchronous filesystem calls for the resolver. + --no-resolve-loader-use-sync-file-system-calls Negative 'resolve-loader-use-sync-file-system-calls' option. + --snapshot-build-dependencies-hash Use hashes of the content of the files/directories to determine invalidation. + --no-snapshot-build-dependencies-hash Negative 'snapshot-build-dependencies-hash' option. + --snapshot-build-dependencies-timestamp Use timestamps of the files/directories to determine invalidation. + --no-snapshot-build-dependencies-timestamp Negative 'snapshot-build-dependencies-timestamp' option. + --snapshot-immutable-paths A path to a immutable directory (usually a package manager cache directory). + --snapshot-immutable-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable. + --snapshot-managed-paths A path to a managed directory (usually a node_modules directory). + --snapshot-managed-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and can be trusted to not be modified otherwise. + --snapshot-module-hash Use hashes of the content of the files/directories to determine invalidation. + --no-snapshot-module-hash Negative 'snapshot-module-hash' option. + --snapshot-module-timestamp Use timestamps of the files/directories to determine invalidation. + --no-snapshot-module-timestamp Negative 'snapshot-module-timestamp' option. + --snapshot-resolve-hash Use hashes of the content of the files/directories to determine invalidation. + --no-snapshot-resolve-hash Negative 'snapshot-resolve-hash' option. + --snapshot-resolve-timestamp Use timestamps of the files/directories to determine invalidation. + --no-snapshot-resolve-timestamp Negative 'snapshot-resolve-timestamp' option. + --snapshot-resolve-build-dependencies-hash Use hashes of the content of the files/directories to determine invalidation. + --no-snapshot-resolve-build-dependencies-hash Negative 'snapshot-resolve-build-dependencies-hash' option. + --snapshot-resolve-build-dependencies-timestamp Use timestamps of the files/directories to determine invalidation. + --no-snapshot-resolve-build-dependencies-timestamp Negative 'snapshot-resolve-build-dependencies-timestamp' option. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + --stats-all Fallback value for stats options when an option is not defined (has precedence over local webpack defaults). + --no-stats-all Negative 'stats-all' option. + --stats-assets Add assets information. + --no-stats-assets Negative 'stats-assets' option. + --stats-assets-sort Sort the assets by that field. + --stats-assets-space Space to display assets (groups will be collapsed to fit this space). + --stats-built-at Add built at time information. + --no-stats-built-at Negative 'stats-built-at' option. + --stats-cached Add information about cached (not built) modules. + --no-stats-cached Negative 'stats-cached' option. + --stats-cached-assets Show cached assets (setting this to `false` only shows emitted files). + --no-stats-cached-assets Negative 'stats-cached-assets' option. + --stats-cached-modules Add information about cached (not built) modules. + --no-stats-cached-modules Negative 'stats-cached-modules' option. + --stats-children Add children information. + --no-stats-children Negative 'stats-children' option. + --stats-chunk-group-auxiliary Display auxiliary assets in chunk groups. + --no-stats-chunk-group-auxiliary Negative 'stats-chunk-group-auxiliary' option. + --stats-chunk-group-children Display children of chunk groups. + --no-stats-chunk-group-children Negative 'stats-chunk-group-children' option. + --stats-chunk-group-max-assets Limit of assets displayed in chunk groups. + --stats-chunk-groups Display all chunk groups with the corresponding bundles. + --no-stats-chunk-groups Negative 'stats-chunk-groups' option. + --stats-chunk-modules Add built modules information to chunk information. + --no-stats-chunk-modules Negative 'stats-chunk-modules' option. + --stats-chunk-origins Add the origins of chunks and chunk merging info. + --no-stats-chunk-origins Negative 'stats-chunk-origins' option. + --stats-chunk-relations Add information about parent, children and sibling chunks to chunk information. + --no-stats-chunk-relations Negative 'stats-chunk-relations' option. + --stats-chunks Add chunk information. + --no-stats-chunks Negative 'stats-chunks' option. + --stats-chunks-sort Sort the chunks by that field. + --stats-colors Enables/Disables colorful output. + --no-stats-colors Negative 'stats-colors' option. + --stats-colors-bold Custom color for bold text. + --stats-colors-cyan Custom color for cyan text. + --stats-colors-green Custom color for green text. + --stats-colors-magenta Custom color for magenta text. + --stats-colors-red Custom color for red text. + --stats-colors-yellow Custom color for yellow text. + --stats-context Context directory for request shortening. + --stats-dependent-modules Show chunk modules that are dependencies of other modules of the chunk. + --no-stats-dependent-modules Negative 'stats-dependent-modules' option. + --stats-depth Add module depth in module graph. + --no-stats-depth Negative 'stats-depth' option. + --stats-entrypoints Display the entry points with the corresponding bundles. + --stats-env Add --env information. + --no-stats-env Negative 'stats-env' option. + --stats-error-details Add details to errors (like resolving log). + --no-stats-error-details Negative 'stats-error-details' option. + --stats-error-stack Add internal stack trace to errors. + --no-stats-error-stack Negative 'stats-error-stack' option. + --stats-errors Add errors. + --no-stats-errors Negative 'stats-errors' option. + --stats-errors-count Add errors count. + --no-stats-errors-count Negative 'stats-errors-count' option. + --stats-exclude-assets Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions. + --stats-exclude-assets-reset Clear all items provided in configuration. Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions. + --stats-exclude-modules Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions. + --stats-exclude-modules-reset Clear all items provided in configuration. Suppress modules that match the specified filters. Filters can be Strings, RegExps, Booleans or Functions. + --stats-group-assets-by-chunk Group assets by how their are related to chunks. + --no-stats-group-assets-by-chunk Negative 'stats-group-assets-by-chunk' option. + --stats-group-assets-by-emit-status Group assets by their status (emitted, compared for emit or cached). + --no-stats-group-assets-by-emit-status Negative 'stats-group-assets-by-emit-status' option. + --stats-group-assets-by-extension Group assets by their extension. + --no-stats-group-assets-by-extension Negative 'stats-group-assets-by-extension' option. + --stats-group-assets-by-info Group assets by their asset info (immutable, development, hotModuleReplacement, etc). + --no-stats-group-assets-by-info Negative 'stats-group-assets-by-info' option. + --stats-group-assets-by-path Group assets by their path. + --no-stats-group-assets-by-path Negative 'stats-group-assets-by-path' option. + --stats-group-modules-by-attributes Group modules by their attributes (errors, warnings, assets, optional, orphan, or dependent). + --no-stats-group-modules-by-attributes Negative 'stats-group-modules-by-attributes' option. + --stats-group-modules-by-cache-status Group modules by their status (cached or built and cacheable). + --no-stats-group-modules-by-cache-status Negative 'stats-group-modules-by-cache-status' option. + --stats-group-modules-by-extension Group modules by their extension. + --no-stats-group-modules-by-extension Negative 'stats-group-modules-by-extension' option. + --stats-group-modules-by-path Group modules by their path. + --no-stats-group-modules-by-path Negative 'stats-group-modules-by-path' option. + --stats-hash Add the hash of the compilation. + --no-stats-hash Negative 'stats-hash' option. + --stats-ids Add ids. + --no-stats-ids Negative 'stats-ids' option. + --stats-logging Specify log level of logging output. Enable/disable logging output (`true`: shows normal logging output, loglevel: log). + --stats-logging-debug Enable/Disable debug logging for all loggers. Include debug logging of specified loggers (i. e. for plugins or loaders). Filters can be Strings, RegExps or Functions. + --stats-logging-debug-reset Clear all items provided in configuration. Include debug logging of specified loggers (i. e. for plugins or loaders). Filters can be Strings, RegExps or Functions. + --stats-logging-trace Add stack traces to logging output. + --no-stats-logging-trace Negative 'stats-logging-trace' option. + --stats-module-assets Add information about assets inside modules. + --no-stats-module-assets Negative 'stats-module-assets' option. + --stats-module-trace Add dependencies and origin of warnings/errors. + --no-stats-module-trace Negative 'stats-module-trace' option. + --stats-modules Add built modules information. + --no-stats-modules Negative 'stats-modules' option. + --stats-modules-sort Sort the modules by that field. + --stats-modules-space Space to display modules (groups will be collapsed to fit this space, values is in number of modules/groups). + --stats-nested-modules Add information about modules nested in other modules (like with module concatenation). + --no-stats-nested-modules Negative 'stats-nested-modules' option. + --stats-optimization-bailout Show reasons why optimization bailed out for modules. + --no-stats-optimization-bailout Negative 'stats-optimization-bailout' option. + --stats-orphan-modules Add information about orphan modules. + --no-stats-orphan-modules Negative 'stats-orphan-modules' option. + --stats-output-path Add output path information. + --no-stats-output-path Negative 'stats-output-path' option. + --stats-performance Add performance hint flags. + --no-stats-performance Negative 'stats-performance' option. + --stats-preset Preset for the default values. + --stats-provided-exports Show exports provided by modules. + --no-stats-provided-exports Negative 'stats-provided-exports' option. + --stats-public-path Add public path information. + --no-stats-public-path Negative 'stats-public-path' option. + --stats-reasons Add information about the reasons why modules are included. + --no-stats-reasons Negative 'stats-reasons' option. + --stats-related-assets Add information about assets that are related to other assets (like SourceMaps for assets). + --no-stats-related-assets Negative 'stats-related-assets' option. + --stats-runtime-modules Add information about runtime modules. + --no-stats-runtime-modules Negative 'stats-runtime-modules' option. + --stats-source Add the source code of modules. + --no-stats-source Negative 'stats-source' option. + --stats-timings Add timing information. + --no-stats-timings Negative 'stats-timings' option. + --stats-used-exports Show exports used by modules. + --no-stats-used-exports Negative 'stats-used-exports' option. + --stats-version Add webpack version information. + --no-stats-version Negative 'stats-version' option. + --stats-warnings Add warnings. + --no-stats-warnings Negative 'stats-warnings' option. + --stats-warnings-count Add warnings count. + --no-stats-warnings-count Negative 'stats-warnings-count' option. + --stats-warnings-filter Suppress listing warnings that match the specified filters (they will still be counted). Filters can be Strings, RegExps or Functions. + --stats-warnings-filter-reset Clear all items provided in configuration. Suppress listing warnings that match the specified filters (they will still be counted). Filters can be Strings, RegExps or Functions. + -t, --target Sets the build target e.g. node. + --target-reset Clear all items provided in configuration. Environment to build for. An array of environments to build for all of them when possible. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-aggregate-timeout Delay the rebuilt after the first change. Value is a time in ms. + --watch-options-follow-symlinks Resolve symlinks and watch symlink and real file. This is usually not needed as webpack already resolves symlinks ('resolve.symlinks'). + --no-watch-options-follow-symlinks Negative 'watch-options-follow-symlinks' option. + --watch-options-ignored A glob pattern for files that should be ignored from watching. Ignore some files from watching (glob pattern or regexp). + --watch-options-ignored-reset Clear all items provided in configuration. Ignore some files from watching (glob pattern or regexp). + --watch-options-poll `number`: use polling with specified interval. `true`: use polling. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Negative 'watch-options-stdin' option. + +Global options: + --color Enable colors on console. + --no-color Disable colors on console. + -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + -h, --help [verbose] Display help for commands and options. + +Commands: + bundle|b [options] Run webpack (default command, can be omitted). + help|h Display help for commands and options. + version|v Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + serve|s [options] Run the webpack dev server. + info|i [options] Outputs information about your system. + init|c [options] [scaffold...] Initialize a new webpack configuration. + loader|l [output-path] Scaffold a loader. + plugin|p [output-path] Scaffold a plugin. + loader|l [output-path] Scaffold a loader. + plugin|p [output-path] Scaffold a plugin. + migrate|m [new-config-path] Migrate a configuration to a new version. + +To see list of all supported commands and options run 'webpack --help=verbose'. + +Webpack documentation: https://webpack.js.org/. +CLI documentation: https://webpack.js.org/api/cli/. +Made with ♥ by the webpack team. +``` diff --git a/package.json b/package.json index 08bbfd4a276..74a2a8cc20f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "test:packages": "jest packages/ --reporters=default --forceExit", "test:ci": "yarn test:cli && yarn test:packages", "test:watch": "jest test/ packages/ --watch", - "publish:monorepo": "yarn build && lerna version && lerna publish from-git" + "publish:monorepo": "yarn build && lerna version && lerna publish from-git", + "update:docs": "node ./scripts/updateDocs" }, "config": { "commitizen": { diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 9c9312ad353..e46b75f0e7e 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -93,701 +93,4 @@ npx webpack-cli --help verbose ### webpack 5 -``` - --amd You can pass `false` to disable AMD support. - --bail Report the first error as a hard error instead of tolerating it. - --cache Enable in memory caching. Disable caching. - --cache-immutable-paths string[] A path to a immutable directory (usually a package manager cache directory). - --cache-immutable-paths-reset Clear all items provided in configuration. List of paths that are managed by - a package manager and contain a version or hash in its path so all files are - immutable. - --cache-type string In memory caching. Filesystem caching. - --cache-cache-directory string Base directory for the cache (defaults to node_modules/.cache/webpack). - --cache-cache-location string Locations for the cache (defaults to cacheDirectory / name). - --cache-hash-algorithm string Algorithm used for generation the hash (see node.js crypto package). - --cache-idle-timeout number Time in ms after which idle period the cache storing should happen (only for - store: 'pack' or 'idle'). - --cache-idle-timeout-for-initial-store number Time in ms after which idle period the initial cache storing should happen - (only for store: 'pack' or 'idle'). - --cache-name string Name for the cache. Different names will lead to different coexisting caches. - --cache-store string When to store data to the filesystem. (pack: Store data when compiler is idle - in a single file). - --cache-version string Version of the cache data. Different versions won't allow to reuse the cache - and override existing content. Update the version when config changed in a - way which doesn't allow to reuse cache. This will invalidate the cache. - --context string The base directory (absolute path!) for resolving the `entry` option. If - `output.pathinfo` is set, the included pathinfo is shortened to this - directory. - --dependencies string[] References to another configuration to depend on. - --dependencies-reset Clear all items provided in configuration. References to other configurations - to depend on. - --devtool string A developer tool to enhance debugging (false | eval | - [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --entry-reset Clear all items provided in configuration. All modules are loaded upon - startup. The last one is exported. - --experiments-asset Allow module type 'asset' to generate assets. - --experiments-async-web-assembly Support WebAssembly as asynchronous EcmaScript Module. - --experiments-import-async Allow 'import/export' syntax to import async modules. - --experiments-import-await Allow 'import/export await' syntax to import async modules. - --experiments-mjs Support .mjs files as way to define strict ESM file (node.js). - --experiments-output-module Allow output javascript files as module source type. - --experiments-sync-web-assembly Support WebAssembly as synchronous EcmaScript Module (outdated). - --experiments-top-level-await Allow using top-level-await in EcmaScript Modules. - --externals string[] Every matched dependency becomes external. An exact matched dependency - becomes external. The same string is used as external dependency. - --externals-presets-electron Treat common electron built-in modules in main and preload context like 'electron', - 'ipc' or 'shell' as external and load them via require() when used. - --externals-presets-electron-main Treat electron built-in modules in the main context like 'app', 'ipc-main' or - 'shell' as external and load them via require() when used. - --externals-presets-electron-preload Treat electron built-in modules in the preload context like 'web-frame', - 'ipc-renderer' or 'shell' as external and load them via require() when used. - --externals-presets-electron-renderer Treat electron built-in modules in the renderer context like 'web-frame', - 'ipc-renderer' or 'shell' as external and load them via require() when used. - --externals-presets-node Treat node.js built-in modules like fs, path or vm as external and load them via - require() when used. - --externals-presets-nwjs Treat NW.js legacy nw.gui module as external and load it via require() when used. - --externals-presets-web Treat references to 'http(s)://...' and 'std:...' as external and load them via import - when used (Note that this changes execution order as externals are executed before - any other code in the chunk). - --externals-presets-web-async Treat references to 'http(s)://...' and 'std:...' as external and load them via async - import() when used (Note that this external type is an async module, which has various - effects on the execution). - --externals-reset Clear all items provided in configuration. Specify dependencies that - shouldn't be resolved by webpack, but should become dependencies of the - resulting bundle. The kind of the dependency depends on - `output.libraryTarget`. - --externals-type string Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' - depend on output.libraryTarget set to the same value). - --ignore-warnings string[] A RegExp to select the warning message. - --ignore-warnings-file string[] A RegExp to select the origin file for the warning. - --ignore-warnings-message string[] A RegExp to select the warning message. - --ignore-warnings-module string[] A RegExp to select the origin module for the warning. - --ignore-warnings-reset Clear all items provided in configuration. Ignore specific warnings. - --infrastructure-logging-debug string[] Enable/Disable debug logging for all loggers. Enable debug logging for - specific loggers. - --infrastructure-logging-debug-reset Clear all items provided in configuration. Enable debug logging for specific - loggers. - --infrastructure-logging-level string Log level. - --module-expr-context-critical Enable warnings for full dynamic dependencies. - --module-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. - --module-expr-context-reg-exp string Sets the default regular expression for full dynamic dependencies. - --module-expr-context-request string Set the default request for full dynamic dependencies. - --module-no-parse string[] A regular expression, when matched the module is not parsed. An absolute - path, when the module starts with this path it is not parsed. - --module-no-parse-reset Clear all items provided in configuration. Don't parse files matching. It's - matched against the full resolved request. - --module-rules-compiler string[] Match the child compiler name. - --module-rules-enforce string[] Enforce this rule as pre or post step. - --module-rules-exclude string[] Shortcut for resource.exclude. - --module-rules-include string[] Shortcut for resource.include. - --module-rules-issuer string[] Match the issuer of the module (The module pointing to this module). - --module-rules-loader string[] A loader request. - --module-rules-mimetype string[] Match module mimetype when load from Data URI. - --module-rules-options string[] Options passed to a loader. - --module-rules-real-resource string[] Match the real resource path of the module. - --module-rules-resource string[] Match the resource path of the module. - --module-rules-resource-fragment string[] Match the resource fragment of the module. - --module-rules-resource-query string[] Match the resource query of the module. - --module-rules-side-effects Flags a module as with or without side effects. - --module-rules-test string[] Shortcut for resource.test. - --module-rules-type string[] Module type to use for the module. - --module-rules-use-ident string[] Unique loader options identifier. - --module-rules-use-loader string[] A loader request. - --module-rules-use-options string[] Options passed to a loader. - --module-rules-use string[] A loader request. - --module-rules-reset Clear all items provided in configuration. A list of rules. - --module-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported - module. - --module-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace - objects. - --module-unknown-context-critical Enable warnings when using the require function in a not statically analyse- - able way. - --module-unknown-context-recursive Enable recursive directory lookup when using the require function in a not - statically analyse-able way. - --module-unknown-context-reg-exp string Sets the regular expression when using the require function in a not - statically analyse-able way. - --module-unknown-context-request string Sets the request when using the require function in a not statically analyse- - able way. - --module-unsafe-cache Cache the resolving of module requests. - --module-wrapped-context-critical Enable warnings for partial dynamic dependencies. - --module-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. - --module-wrapped-context-reg-exp string Set the inner regular expression for partial dynamic dependencies. - --name string Name of the configuration. Used when loading multiple configurations. - --node Include polyfills or mocks for various node stuff. - --node-dirname string Include a polyfill for the '__dirname' variable. - --node-filename string Include a polyfill for the '__filename' variable. - --node-global Include a polyfill for the 'global' variable. - --optimization-check-wasm-types Check for incompatible wasm types when importing/exporting from/to ESM. - --optimization-chunk-ids string Define the algorithm to choose chunk ids (named: readable ids for better - debugging, deterministic: numeric hash ids for better long term caching, - size: numeric ids focused on minimal initial download size, total-size: - numeric ids focused on minimal total download size, false: no algorithm used, - as custom one can be provided via plugin). - --optimization-concatenate-modules Concatenate modules when possible to generate less modules, more efficient - code and enable more optimizations by the minimizer. - --optimization-emit-on-errors Emit assets even when errors occur. Critical errors are emitted into the - generated code and will case errors at runtime. - --optimization-flag-included-chunks Also flag chunks as loaded which contain a subset of the modules. - --optimization-inner-graph Creates a module-internal dependency graph for top level symbols, exports and - imports, to improve unused exports detection. - --optimization-mangle-exports Rename exports when possible to generate shorter code (depends on - optimization.usedExports and optimization.providedExports). - --optimization-mangle-wasm-imports Reduce size of WASM by changing imports to shorter strings. - --optimization-merge-duplicate-chunks Merge chunks which contain the same modules. - --optimization-minimize Enable minimizing the output. Uses optimization.minimizer. - --optimization-module-ids string Define the algorithm to choose module ids (natural: numeric ids in order of - usage, named: readable ids for better debugging, hashed: (deprecated) short - hashes as ids for better long term caching, deterministic: numeric hash ids - for better long term caching, size: numeric ids focused on minimal initial - download size, false: no algorithm used, as custom one can be provided via - plugin). - --optimization-node-env string Set process.env.NODE_ENV to a specific value. - --optimization-portable-records Generate records with relative paths to be able to move the context folder. - --optimization-provided-exports Figure out which exports are provided by modules to generate more efficient - code. - --optimization-remove-available-modules Removes modules from chunks when these modules are already included in all - parents. - --optimization-remove-empty-chunks Remove chunks which are empty. - --optimization-runtime-chunk string Create an additional chunk which contains only the webpack runtime and chunk - hash maps. - --optimization-runtime-chunk-name string The name or name factory for the runtime chunks. - --optimization-side-effects Skip over modules which are flagged to contain no side effects when exports - are not used. - --optimization-split-chunks Optimize duplication and caching by splitting chunks by shared modules and - cache group. - --optimization-split-chunks-chunks string Select chunks for determining shared modules (defaults to "async", "initial" - and "all" requires adding these chunks to the HTML). - --optimization-split-chunks-default-size-types string Size type, like 'javascript', 'webassembly'. - --optimization-split-chunks-default-size-types-reset Clear all items provided in configuration. Sets the size types which are used when a - number is used for sizes. - - --optimization-split-chunks-enforce-size-threshold string Size of the javascript part of the chunk. - --optimization-split-chunks-fallback-cache-group-automatic-name-delimiter string Sets the name delimiter for created chunks - --optimization-split-chunks-fallback-cache-group-max-async-size number Size of the javascript part of the chunk - --optimization-split-chunks-fallback-cache-group-max-initial-size number Size of the javascript part of the chunk. - --optimization-split-chunks-fallback-cache-group-max-size number Size of the javascript part of the chunk. - --optimization-split-chunks-fallback-cache-group-min-size number Size of the javascript part of the chunk. - - --optimization-split-chunks-automatic-name-delimiter string Sets the name delimiter for created chunks - --optimization-split-chunks-filename string Sets the template for the filename for created chunks. - --optimization-split-chunks-hide-path-info Prevents exposing path info when creating names for parts splitted by - maxSize. - --optimization-split-chunks-max-async-requests number Maximum number of requests which are accepted for on-demand loading. - --optimization-split-chunks-max-async-size number Size of the javascript part of the chunk. - --optimization-split-chunks-max-initial-requests number Maximum number of initial chunks which are accepted for an entry point. - --optimization-split-chunks-max-initial-size number Size of the javascript part of the chunk. - --optimization-split-chunks-max-size number Size of the javascript part of the chunk. - --optimization-split-chunks-min-chunks number Minimum number of times a module has to be duplicated until it's considered - for splitting. - --optimization-split-chunks-min-remaining-size number Size of the javascript part of the chunk. - --optimization-split-chunks-min-size number Size of the javascript part of the chunk. - --optimization-split-chunks-name string Give chunks created a name (chunks with equal name are merged). - --optimization-used-exports Figure out which exports are used by modules to mangle export names, omit - unused exports and generate more efficient code. - --output-asset-module-filename string The filename of asset modules as relative path inside the `output.path` - directory. - --output-charset Add charset attribute for script tag. - --output-chunk-filename string The filename of non-initial chunks as relative path inside the `output.path` - directory. - --output-chunk-format string The format of chunks (formats included by default are 'array-push' - (web/WebWorker), 'commonjs' (node.js), but others might be added by plugins). - --output-chunk-load-timeout number Number of milliseconds before chunk request expires. - --output-chunk-loading string The method of loading chunks (methods included by default are 'jsonp' (web), - 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async - node.js), but others might be added by plugins). - --output-chunk-loading-global string The global variable used by webpack for loading of chunks. - --output-compare-before-emit Check if to be emitted file already exists and have the same content before - writing to output filesystem. - --output-cross-origin-loading string This option enables cross-origin loading of chunks. - --output-devtool-fallback-module-filename-template string Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of - duplicate module identifiers. - --output-devtool-module-filename-template string Filename template string of function for the sources array in a generated - SourceMap. - --output-devtool-namespace string Module namespace to use when interpolating filename template string for the - sources array in a generated SourceMap. Defaults to `output.library` if not - set. It's useful for avoiding runtime collisions in sourcemaps from multiple - webpack projects built as libraries. - --output-enabled-chunk-loading-types string[] The method of loading chunks (methods included by default are 'jsonp' (web), - 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async - node.js), but others might be added by plugins). - --output-enabled-chunk-loading-types-reset Clear all items provided in configuration. List of chunk loading types - enabled for use by entry points. - --output-enabled-library-types string[] Type of library (types included by default are 'var', 'module', 'assign', - 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs- - module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others - might be added by plugins). - --output-enabled-library-types-reset Clear all items provided in configuration. List of library types enabled for - use by entry points. - --output-enabled-wasm-loading-types string[] The method of loading WebAssembly Modules (methods included by default are - 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by - plugins). - --output-enabled-wasm-loading-types-reset Clear all items provided in configuration. List of wasm loading types enabled - for use by entry points. - --output-environment-arrow-function The environment supports arrow functions ('() => { ... }'). - --output-environment-big-int-literal The environment supports BigInt as literal (123n). - --output-environment-const The environment supports const and let for variable declarations. - --output-environment-destructuring The environment supports destructuring ('{ a, b } = obj'). - --output-environment-dynamic-import The environment supports an async import() function to import EcmaScript - modules. - --output-environment-for-of The environment supports 'for of' iteration ('for (const x of array) { ... - }'). - --output-environment-module The environment supports EcmaScript Module syntax to import EcmaScript - modules (import ... from '...'). - --output-filename string Specifies the name of each output file on disk. You must **not** specify an - absolute path here! The `output.path` option determines the location on disk - the files are written to, filename is used solely for naming the individual - files. - --output-global-object string An expression which is used to address the global object/scope in runtime - code. - --output-hash-digest string Digest type used for the hash. - --output-hash-digest-length number Number of chars which are used for the hash. - --output-hash-function string Algorithm used for generation the hash (see node.js crypto package). - --output-hash-salt string Any string which is added to the hash to salt it. - --output-hot-update-chunk-filename string The filename of the Hot Update Chunks. They are inside the output.path - directory. - --output-hot-update-global string The global variable used by webpack for loading of hot update chunks. - --output-hot-update-main-filename string The filename of the Hot Update Main File. It is inside the `output.path` - directory. - --output-iife Wrap javascript code into IIFE's to avoid leaking into global scope. - --output-import-function-name string The name of the native import() function (can be exchanged for a polyfill). - --output-import-meta-name string The name of the native import.meta object (can be exchanged for a polyfill). - --output-library string[] A part of the library name. - --output-library-reset Clear all items provided in configuration. The name of the library (some - types allow unnamed libraries too). - --output-library-amd string Name of the exposed AMD library in the UMD. - --output-library-commonjs string Name of the exposed commonjs export in the UMD. - --output-library-root string[] Part of the name of the property exposed globally by a UMD library. - --output-library-root-reset Clear all items provided in configuration. Name of the property exposed - globally by a UMD library. - --output-library-auxiliary-comment string Append the same comment above each import style. - --output-library-auxiliary-comment-amd string Set comment for `amd` section in UMD. - --output-library-auxiliary-comment-commonjs string Set comment for `commonjs` (exports) section in UMD. - --output-library-auxiliary-comment-commonjs2 string Set comment for `commonjs2` (module.exports) section in UMD. - --output-library-auxiliary-comment-root string Set comment for `root` (global variable) section in UMD. - --output-library-export string[] Part of the export that should be exposed as library. - --output-library-export-reset Clear all items provided in configuration. Specify which export should be - exposed as library. - --output-library-name string[] A part of the library name. - --output-library-name-reset Clear all items provided in configuration. The name of the library (some - types allow unnamed libraries too). - --output-library-name-amd string Name of the exposed AMD library in the UMD. - --output-library-name-commonjs string Name of the exposed commonjs export in the UMD. - --output-library-name-root string[] Part of the name of the property exposed globally by a UMD library. - --output-library-name-root-reset Clear all items provided in configuration. Name of the property exposed - globally by a UMD library. - --output-library-type string Type of library (types included by default are 'var', 'module', 'assign', - 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs- - module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others - might be added by plugins). - --output-library-umd-named-define If `output.libraryTarget` is set to umd and `output.library` is set, setting - this to true will name the AMD module. - --output-module Output javascript files as module source type. - -o, --output-path string Output location of the file generated by webpack e.g. ./dist/ - --output-pathinfo Include comments with information about the modules. - --output-public-path string The `publicPath` specifies the public URL address of the output files when - referenced in a browser. - --output-script-type string This option enables loading async chunks via a custom script type, such as - script type="module". - --output-source-map-filename string The filename of the SourceMaps for the JavaScript files. They are inside the - `output.path` directory. - --output-source-prefix string Prefixes every line of the source in the bundle with this string. - --output-strict-module-exception-handling Handles exceptions in module loading correctly at a performance cost. - --output-unique-name string A unique name of the webpack build to avoid multiple webpack runtimes to - conflict when using globals. - --output-wasm-loading string The method of loading WebAssembly Modules (methods included by default are - 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by - plugins). - --output-webassembly-module-filename string The filename of WebAssembly modules as relative path inside the `output.path` - directory. - --output-worker-chunk-loading string The method of loading chunks (methods included by default are 'jsonp' (web), - 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async - node.js), but others might be added by plugins). - --output-worker-wasm-loading string The method of loading WebAssembly Modules (methods included by default are - 'fetch' (web/WebWorker), 'async-node' (node.js), but others migby - plugins). - --parallelism number The number of parallel processed modules in the compilation. - --performance Configuration for web performance recommendations. - --performance-hints string Sets the format of the hints: warnings, errors or nothing at all. - --performance-max-asset-size number File size limit (in bytes) when exceeded, that webpack will provide - performance hints. - --performance-max-entrypoint-size number Total size of an entry point (in bytes). - --profile Capture timing information for each module. - --records-input-path string Store compiler state to a json file. - --records-output-path string Load compiler state from a json file. - --records-path string Store/Load compiler state from/to a json file. This will result in persistent - ids of modules and chunks. An absolute path is expected. `recordsPath` is - used for `recordsInputPath` and `recordsOutputPath` if they left undefined. - --resolve-alias-alias string[] Ignore request (replace with empty module). New request. - --resolve-alias-name string[] Request to be redirected. - --resolve-alias-only-module Redirect only exact matching request. - --resolve-alias-reset Clear all items provided in configuration. Redirect module requests. - --resolve-alias-fields string[] Field in the description file (usually package.json) which are used to - redirect requests inside the module. - --resolve-alias-fields-reset Clear all items provided in configuration. Fields in the description file - (usually package.json) which are used to redirect requests inside the module. - --resolve-cache Enable caching of successfully resolved requests (cache entries are - revalidated). - --resolve-cache-with-context Include the context information in the cache identifier when caching. - --resolve-condition-names string[] Condition names for exports field entry point. - --resolve-condition-names-reset Clear all items provided in configuration. Condition names for exports field - entry point. - --resolve-description-files string[] Filename used to find a description file (like a package.json). - --resolve-description-files-reset Clear all items provided in configuration. Filenames used to find a - description file (like a package.json). - --resolve-enforce-extension Enforce the resolver to use one of the extensions from the extensions option - (User must specify requests without extension). - --resolve-exports-fields string[] Field name from the description file (usually package.json) which is used to - provide entry points of a package. - --resolve-exports-fields-reset Clear all items provided in configuration. Field names from the description - file (usually package.json) which are used to provide entry points of a - package. - --resolve-extensions string[] Extension added to the request when trying to find the file. - --resolve-extensions-reset Clear all items provided in configuration. Extensions added to the request - when trying to find the file. - --resolve-fallback-alias string[] Ignore request (replace with empty module). New request. - --resolve-fallback-name string[] Request to be redirected. - --resolve-fallback-only-module Redirect only exact matching request. - --resolve-fallback-reset Clear all items provided in configuration. Redirect module requests. - --resolve-fully-specified Treats the request specified by the user as fully specified, meaning no - extensions are added and the mainFiles in directories are not resolved (This - doesn't affect requests from mainFields, aliasFields or aliases). - --resolve-main-fields string[] Field name from the description file (package.json) which are used to find - the default entry point. - --resolve-main-fields-reset Clear all items provided in configuration. Field names from the description - file (package.json) which are used to find the default entry point. - --resolve-main-files string[] Filename used to find the default entry point if there is no description file - or main field. - --resolve-main-files-reset Clear all items provided in configuration. Filenames used to find the default - entry point if there is no description file or main field. - --resolve-modules string[] Folder name or directory path where to find modules. - --resolve-modules-reset Clear all items provided in configuration. Folder names or directory paths - where to find modules. - --resolve-restrictions string[] Resolve restriction. Resolve result must fulfill this restriction. - --resolve-restrictions-reset Clear all items provided in configuration. A list of resolve restrictions. - Resolve results must fulfill all of these restrictions to resolve - successfully. Other resolve paths are taken when restrictions are not met. - --resolve-roots string[] Directory in which requests that are server-relative URLs (starting with '/') - are resolved. - --resolve-roots-reset Clear all items provided in configuration. A list of directories in which - requests that are server-relative URLs (starting with '/') are resolved. On - non-windows system these requests are tried to resolve as absolute path - first. - --resolve-symlinks Enable resolving symlinks to the original location. - --resolve-unsafe-cache Enable caching of successfully resolved requests (cache entries are not - revalidated). - --resolve-use-sync-file-system-calls Use synchronous filesystem calls for the resolver. - --resolve-loader-alias-alias string[] Ignore request (replace with empty module). New request. - --resolve-loader-alias-name string[] Request to be redirected. - --resolve-loader-alias-only-module Redirect only exact matching request. - --resolve-loader-alias-reset Clear all items provided in configuration. Redirect module requests. - --resolve-loader-alias-fields string[] Field in the description file (usually package.json) which are used to - redirect requests inside the module. - --resolve-loader-alias-fields-reset Clear all items provided in configuration. Fields in the description file - (usually package.json) which are used to redirect requests inside the module. - --resolve-loader-cache Enable caching of successfully resolved requests (cache entries are - revalidated). - --resolve-loader-cache-with-context Include the context information in the cache identifier when caching. - --resolve-loader-condition-names string[] Condition names for exports field entry point. - --resolve-loader-condition-names-reset Clear all items provided in configuration. Condition names for exports field - entry point. - --resolve-loader-description-files string[] Filename used to find a description file (like a package.json). - --resolve-loader-description-files-reset Clear all items provided in configuration. Filenames used to find a - description file (like a package.json). - --resolve-loader-enforce-extension Enforce the resolver to use one of the extensions from the extensions option - (User must specify requests without extension). - --resolve-loader-exports-fields string[] Field name from the description file (usually package.json) which is used to - provide entry points of a package. - --resolve-loader-exports-fields-reset Clear all items provided in configuration. Field names from the description - file (usually package.json) which are used to provide entry points of a - package. - --resolve-loader-extensions string[] Extension added to the request when trying to find the file. - --resolve-loader-extensions-reset Clear all items provided in configuration. Extensions added to the request - when trying to find the file. - --resolve-loader-fully-specified Treats the request specified by the user as fully specified, meaning no - extensions are added and the mainFiles in directories are not resolved (This - doesn't affect requests from mainFields, aliasFields or aliases). - --resolve-loader-main-fields string[] Field name from the description file (package.json) which are used to find - the default entry point. - --resolve-loader-main-fields-reset Clear all items provided in configuration. Field names from the description - file (package.json) which are used to find the default entry point. - --resolve-loader-main-files string[] Filename used to find the default entry point if there is no description file - or main field. - --resolve-loader-main-files-reset Clear all items provided in configuration. Filenames used to find the default - entry point if there is no description file or main field. - --resolve-loader-modules string[] Folder name or directory path where to find modules. - --resolve-loader-modules-reset Clear all items provided in configuration. Folder names or directory paths - where to find modules. - --resolve-loader-restrictions string[] Resolve restriction. Resolve result must fulfill this restriction. - --resolve-loader-restrictions-reset Clear all items provided in configuration. A list of resolve restrictions. - Resolve results must fulfill all of these restrictions to resolve - successfully. Other resolve paths are taken when restrictions are not met. - --resolve-loader-roots string[] Directory in which requests that are server-relative URLs (starting with '/') - are resolved. - --resolve-loader-roots-reset Clear all items provided in configuration. A list of directories in which - requests that are server-relative URLs (starting with '/') are resolved. On - non-windows system these requests are tried to resolve as absolute path - first. - --resolve-loader-symlinks Enable resolving symlinks to the original location. - --resolve-loader-unsafe-cache Enable caching of successfully resolved requests (cache entries are not - revalidated). - --resolve-loader-use-sync-file-system-calls Use synchronous filesystem calls for the resolver. - --stats-all Fallback value for stats options when an option is not defined (has - precedence over local webpack defaults). - --snapshot-build-dependencies-hash Use hashes of the content of the files/directories to determine invalidation. - --snapshot-build-dependencies-timestamp Use timestamps of the files/directories to determine invalidation. - --snapshot-immutable-paths string[] A path to a immutable directory (usually a package manager cache directory). - --snapshot-immutable-paths-reset Clear all items provided in configuration. List of paths that are managed by - a package manager and contain a version or hash in its path so all files are - immutable. - --snapshot-managed-paths string[] A path to a managed directory (usually a node_modules directory). - --snapshot-managed-paths-reset Clear all items provided in configuration. List of paths that are managed by - a package manager and can be trusted to not be modified otherwise. - --snapshot-module-hash Use hashes of the content of the files/directories to determine invalidation. - --snapshot-module-timestamp Use timestamps of the files/directories to determine invalidation. - --snapshot-resolve-hash Use hashes of the content of the files/directories to determine invalidation. - --snapshot-resolve-timestamp Use timestamps of the files/directories to determine invalidation. - --snapshot-resolve-build-dependencies-hash Use hashes of the content of the files/directories to determine invalidation. - --snapshot-resolve-build-dependencies-timestamp Use timestamps of the files/directories to determine invalidation. - --stats-all Fallback value for stats options when an option is not defined (has - precedence over local webpack defaults). - --stats-assets Add assets information. - --stats-assets-sort string Sort the assets by that field. - --stats-assets-space number Space to display assets (groups will be collapsed to fit this space). - --stats-built-at Add built at time information. - --stats-cached Add information about cached (not built) modules. - --stats-cached-assets Show cached assets (setting this to `false` only shows emitted files). - --stats-cached-modules Add information about cached (not built) modules. - --stats-children Add children information. - --stats-chunk-group-auxiliary Display auxiliary assets in chunk groups. - --stats-chunk-group-children Display children of chunk groups. - --stats-chunk-group-max-assets number Limit of assets displayed in chunk groups. - --stats-chunk-groups Display all chunk groups with the corresponding bundles. - --stats-chunk-modules Add built modules information to chunk information. - --stats-chunk-origins Add the origins of chunks and chunk merging info. - --stats-chunk-relations Add information about parent, children and sibling chunks to chunk - information. - --stats-chunks Add chunk information. - --stats-chunks-sort string Sort the chunks by that field. - --stats-colors Enables/Disables colorful output. - --stats-colors-bold string Custom color for bold text. - --stats-colors-cyan string Custom color for cyan text. - --stats-colors-green string Custom color for green text. - --stats-colors-magenta string Custom color for magenta text. - --stats-colors-red string Custom color for red text. - --stats-colors-yellow string Custom color for yellow text. - --stats-context string Context directory for request shortening. - --stats-dependent-modules Show chunk modules that are dependencies of other modules of the chunk. - --stats-depth Add module depth in module graph. - --stats-entrypoints string Display the entry points with the corresponding bundles. - --stats-env Add --env information. - --stats-error-details Add details to errors (like resolving log). - --stats-error-stack Add internal stack trace to errors. - --stats-errors Add errors. - --stats-errors-count Add errors count. - --stats-exclude-assets string[] Suppress assets that match the specified filters. Filters can be Strings, - RegExps or Functions. - --stats-exclude-assets-reset Clear all items provided in configuration. Suppress assets that match the - specified filters. Filters can be Strings, RegExps or Functions. - --stats-exclude-modules string[] Suppress modules that match the specified filters. Filters can be Strings, - RegExps, Booleans or Functions. - --stats-exclude-modules-reset Clear all items provided in configuration. Suppress modules that match the - specified filters. Filters can be Strings, RegExps, Booleans or Functions. - --stats-group-assets-by-chunk Group assets by how their are related to chunks. - --stats-group-assets-by-emit-status Group assets by their status (emitted, compared for emit or cached). - --stats-group-assets-by-extension Group assets by their extension. - --stats-group-assets-by-info Group assets by their asset info (immutable, development, - hotModuleReplacement, etc). - --stats-group-assets-by-path Group assets by their path. - --stats-group-modules-by-attributes Group modules by their attributes (errors, warnings, assets, optional, - orphan, or dependent). - --stats-group-modules-by-cache-status Group modules by their status (cached or built and cacheable). - --stats-group-modules-by-extension Group modules by their extension. - --stats-group-modules-by-path Group modules by their path. - --stats-hash Add the hash of the compilation. - --stats-ids Add ids. - --stats-logging string Specify log level of logging output. Enable/disable logging output (`true`: - shows normal logging output, loglevel: log). - --stats-logging-debug string[] Enable/Disable debug logging for all loggers. Include debug logging of - specified loggers (i. e. for plugins or loaders). Filters can be Strings, - RegExps or Functions. - --stats-logging-debug-reset Clear all items provided in configuration. Include debug logging of specified - loggers (i. e. for plugins or loaders). Filters can be Strings, RegExps or - Functions. - --stats-logging-trace Add stack traces to logging output. - --stats-module-assets Add information about assets inside modules. - --stats-module-trace Add dependencies and origin of warnings/errors. - --stats-modules Add built modules information. - --stats-modules-sort string Sort the modules by that field. - --stats-modules-space number Space to display modules (groups will be collapsed to fit this space, values - is in number of modules/groups). - --stats-nested-modules Add information about modules nested in other modules (like with module - concatenation). - --stats-optimization-bailout Show reasons why optimization bailed out for modules. - --stats-orphan-modules Add information about orphan modules. - --stats-output-path Add output path information. - --stats-performance Add performance hint flags. - --stats-preset string Preset for the default values. - --stats-provided-exports Show exports provided by modules. - --stats-public-path Add public path information. - --stats-reasons Add information about the reasons why modules are included. - --stats-related-assets Add information about assets that are related to other assets (like - SourceMaps for assets). - --stats-runtime-modules Add information about runtime modules. - --stats-timings Add timing information. - --stats-source Add the source code of modules. - --stats-version Add webpack version information. - --stats-used-exports Show exports used by modules. - --stats-warnings-count Add warnings count. - --stats-warnings Add warnings. - --stats-warnings-filter string[] Suppress listing warnings that match the specified filters (they will still - be counted). Filters can be Strings, RegExps or Functions. - --stats-warnings-filter-reset Clear all items provided in configuration. Suppress listing warnings that - match the specified filters (they will still be counted). Filters can be - Strings, RegExps or Functions. - --watch-options-aggregate-timeout number Delay the rebuilt after the first change. Value is a time in ms. - --watch-options-ignored string[] A glob pattern for files that should be ignored from watching. - --watch-options-ignored-reset Clear all items provided in configuration. Ignore some files from watching - (glob pattern). - --watch-options-poll string `number`: use polling with specified interval. `true`: use polling. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-hot Negates hot - --no-stats Negates stats - --no-amd Negates amd - --no-bail Negates bail - --no-cache Negates cache - --no-experiments-asset Negates experiments-asset - --no-experiments-async-web-assembly Negates experiments-async-web-assembly - --no-experiments-import-async Negates experiments-import-async - --no-experiments-import-await Negates experiments-import-await - --no-experiments-mjs Negates experiments-mjs - --no-experiments-output-module Negates experiments-output-module - --no-experiments-sync-web-assembly Negates experiments-sync-web-assembly - --no-experiments-top-level-await Negates experiments-top-level-await - --no-externals-presets-electron Negates externals-presets-electron - --no-externals-presets-electron-main Negates externals-presets-electron-main - --no-externals-presets-electron-preload Negates externals-presets-electron-preload - --no-externals-presets-electron-renderer Negates externals-presets-electron-renderer - --no-externals-presets-node Negates externals-presets-node - --no-externals-presets-nwjs Negates externals-presets-nwjs - --no-externals-presets-web Negates externals-presets-web - --no-externals-presets-web-async Negates externals-presets-web-async - --no-module-expr-context-critical Negates module-expr-context-critical - --no-module-expr-context-recursive Negates module-expr-context-recursive - --no-module-rules-side-effects Negates module-rules-side-effects - --no-module-strict-export-presence Negates module-strict-export-presence - --no-module-strict-this-context-on-imports Negates module-strict-this-context-on-imports - --no-module-unknown-context-critical Negates module-unknown-context-critical - --no-module-unknown-context-recursive Negates module-unknown-context-recursive - --no-module-unsafe-cache Negates module-unsafe-cache - --no-module-wrapped-context-critical Negates module-wrapped-context-critical - --no-module-wrapped-context-recursive Negates module-wrapped-context-recursive - --no-node Negates node - --no-node-global Negates node-global - --no-optimization-check-wasm-types Negates optimization-check-wasm-types - --no-optimization-concatenate-modules Negates optimization-concatenate-modules - --no-optimization-emit-on-errors Negates optimization-emit-on-errors - --no-optimization-flag-included-chunks Negates optimization-flag-included-chunks - --no-optimization-inner-graph Negates optimization-inner-graph - --no-optimization-mangle-exports Negates optimization-mangle-exports - --no-optimization-mangle-wasm-imports Negates optimization-mangle-wasm-imports - --no-optimization-merge-duplicate-chunks Negates optimization-merge-duplicate-chunks - --no-optimization-minimize Negates optimization-minimize - --no-optimization-portable-records Negates optimization-portable-records - --no-optimization-provided-exports Negates optimization-provided-exports - --no-optimization-remove-available-modules Negates optimization-remove-available-modules - --no-optimization-remove-empty-chunks Negates optimization-remove-empty-chunks - --no-optimization-side-effects Negates optimization-side-effects - --no-optimization-split-chunks Negates optimization-split-chunks - --no-optimization-split-chunks-hide-path-info Negates optimization-split-chunks-hide-path-info - --no-optimization-used-exports Negates optimization-used-exports - --no-output-charset Negates output-charset - --no-output-compare-before-emit Negates output-compare-before-emit - --no-output-environment-arrow-function Negates output-environment-arrow-function - --no-output-environment-big-int-literal Negates output-environment-big-int-literal - --no-output-environment-const Negates output-environment-const - --no-output-environment-destructuring Negates output-environment-destructuring - --no-output-environment-dynamic-import Negates output-environment-dynamic-import - --no-output-environment-for-of Negates output-environment-for-of - --no-output-environment-module Negates output-environment-module - --no-output-iife Negates output-iife - --no-output-library-umd-named-define Negates output-library-umd-named-define - --no-output-module Negates output-module - --no-output-pathinfo Negates output-pathinfo - --no-output-strict-module-exception-handling Negates output-strict-module-exception-handling - --no-performance Negates performance - --no-profile Negates profile - --no-resolve-alias-only-module Negates resolve-alias-only-module - --no-resolve-cache Negates resolve-cache - --no-resolve-cache-with-context Negates resolve-cache-with-context - --no-resolve-symlinks Negates resolve-symlinks - --no-resolve-unsafe-cache Negates resolve-unsafe-cache - --no-resolve-use-sync-file-system-calls Negates resolve-use-sync-file-system-calls - --no-resolve-loader-alias-only-module Negates resolve-loader-alias-only-module - --no-resolve-loader-cache Negates resolve-loader-cache - --no-resolve-loader-cache-with-context Negates resolve-loader-cache-with-context - --no-resolve-loader-symlinks Negates resolve-loader-symlinks - --no-resolve-loader-unsafe-cache Negates resolve-loader-unsafe-cache - --no-resolve-loader-use-sync-file-system-calls Negates resolve-loader-use-sync-file-system-calls - --no-snapshot-build-dependencies-hash Negates snapshot-build-dependencies-hash - --no-snapshot-build-dependencies-timestamp Negates snapshot-build-dependencies-timestamp - --no-snapshot-module-hash Negates snapshot-module-hash - --no-snapshot-module-timestamp Negates snapshot-module-timestamp - --no-snapshot-resolve-hash Negates snapshot-resolve-hash - --no-snapshot-resolve-timestamp Negates snapshot-resolve-timestamp - --no-snapshot-resolve-build-dependencies-hash Negates snapshot-resolve-build-dependencies-hash - --no-snapshot-resolve-build-dependencies-timestamp Negates snapshot-resolve-build-dependencies-timestamp - --no-stats-all Negates stats-all - --no-stats-assets Negates stats-assets - --no-stats-built-at Negates stats-built-at - --no-stats-cached Negates stats-cached - --no-stats-cached-assets Negates stats-cached-assets - --no-stats-cached-modules Negates stats-cached-modules - --no-stats-children Negates stats-children - --no-stats-chunk-group-auxiliary Negates stats-chunk-group-auxiliary - --no-stats-chunk-group-children Negates stats-chunk-group-children - --no-stats-chunk-groups Negates stats-chunk-groups - --no-stats-chunk-modules Negates stats-chunk-modules - --no-stats-chunk-origins Negates stats-chunk-origins - --no-stats-chunk-relations Negates stats-chunk-relations - --no-stats-chunks Negates stats-chunks - --no-stats-colors Negates stats-colors - --no-stats-dependent-modules Negates stats-dependent-modules - --no-stats-depth Negates stats-depth - --no-stats-env Negates stats-env - --no-stats-error-details Negates stats-error-details - --no-stats-error-stack Negates stats-error-stack - --no-stats-errors Negates stats-errors - --no-stats-errors-count Negates stats-errors-count - --no-stats-group-assets-by-chunk Negates stats-group-assets-by-chunk - --no-stats-group-assets-by-emit-status Negates stats-group-assets-by-emit-status - --no-stats-group-assets-by-extension Negates stats-group-assets-by-extension - --no-stats-group-assets-by-info Negates stats-group-assets-by-info - --no-stats-group-assets-by-path Negates stats-group-assets-by-path - --no-stats-group-modules-by-attributes Negates stats-group-modules-by-attributes - --no-stats-group-modules-by-cache-status Negates stats-group-modules-by-cache-status - --no-stats-group-modules-by-extension Negates stats-group-modules-by-extension - --no-stats-group-modules-by-path Negates stats-group-modules-by-path - --no-stats-hash Negates stats-hash - --no-stats-ids Negates stats-ids - --no-stats-logging-trace Negates stats-logging-trace - --no-stats-module-assets Negates stats-module-assets - --no-stats-module-trace Negates stats-module-trace - --no-stats-modules Negates stats-modules - --no-stats-nested-modules Negates stats-nested-modules - --no-stats-optimization-bailout Negates stats-optimization-bailout - --no-stats-orphan-modules Negates stats-orphan-modules - --no-stats-output-path Negates stats-output-path - --no-stats-performance Negates stats-performance - --no-stats-provided-exports Negates stats-provided-exports - --no-stats-public-path Negates stats-public-path - --no-stats-reasons Negates stats-reasons - --no-stats-related-assets Negates stats-related-assets - --no-stats-runtime-modules Negates stats-runtime-modules - --no-stats-source Negates stats-source - --no-stats-timings Negates stats-timings - --no-stats-used-exports Negates stats-used-exports - --no-stats-version Negates stats-version - --no-stats-warnings Negates stats-warnings - --no-stats-warnings-count Negates stats-warnings-count - --no-watch-options-stdin Negates watch-options-stdin -``` +Checkout [`OPTIONS.md`](../../OPTIONS.md) to see list of all available options. diff --git a/scripts/updateDocs.js b/scripts/updateDocs.js new file mode 100644 index 00000000000..285df23d280 --- /dev/null +++ b/scripts/updateDocs.js @@ -0,0 +1,21 @@ +//eslint-disable-next-line node/no-unpublished-require +const { sync } = require('execa'); +const { resolve } = require('path'); +const { writeFileSync } = require('fs'); + +try { + const { stdout } = sync(resolve(__dirname, '../packages/webpack-cli/bin/cli.js'), ['--help=verbose'], { + cwd: __dirname, + reject: false, + }); + + // format output for markdown + const mdContent = ['```\n', stdout, '\n```'].join(''); + + // create OPTIONS.md + writeFileSync('OPTIONS.md', mdContent); + + console.log('All options all successfully stored in "OPTIONS.md"'); +} catch (err) { + console.error(err); +} From fd4fb41c2b7486097f99fce242abe819d114c906 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sun, 3 Jan 2021 19:05:16 +0530 Subject: [PATCH 214/581] docs: usage and internal commands (#2285) --- packages/webpack-cli/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index e46b75f0e7e..e0193dbd4d9 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -30,6 +30,16 @@ yarn add webpack-cli --dev ## Supported arguments and commands +### Usage + +All interactions with webpack-cli are of the form + +```bash +npx webpack-cli [command] [options] +``` + +If no command is specified then `bundle` command is used by default + ### Help Usage You display basic commands and arguments - @@ -53,6 +63,9 @@ npx webpack-cli --help verbose ### Available Commands ``` + bundle | b Run webpack + help | h Display help for commands and options + version | v Output version number of the 'webpack', 'webpack-cli' and other related packages init | c Initialize a new webpack configuration migrate | m Migrate a configuration to a new version loader | l Scaffold a loader repository From 764036b030c48964f2803926004b049aa8f82776 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 3 Jan 2021 19:18:37 +0530 Subject: [PATCH 215/581] tests: add test cases for --ignore-warnings (#2294) --- .../ignore-warnings-flag.test.js | 32 +++++++++++++++++++ .../ignore-warnings/my-warning-loader.js | 5 +++ test/core-flags/ignore-warnings/src/main.js | 1 + .../ignore-warnings/webpack.config.js | 24 ++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 test/core-flags/ignore-warnings/ignore-warnings-flag.test.js create mode 100644 test/core-flags/ignore-warnings/my-warning-loader.js create mode 100644 test/core-flags/ignore-warnings/src/main.js create mode 100644 test/core-flags/ignore-warnings/webpack.config.js diff --git a/test/core-flags/ignore-warnings/ignore-warnings-flag.test.js b/test/core-flags/ignore-warnings/ignore-warnings-flag.test.js new file mode 100644 index 00000000000..520a2e0f98a --- /dev/null +++ b/test/core-flags/ignore-warnings/ignore-warnings-flag.test.js @@ -0,0 +1,32 @@ +'use strict'; + +const { run } = require('../../utils/test-utils'); + +describe('ignore-warnings', () => { + it('should ignore the warning emitted', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--ignore-warnings', /Generated Warning/]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).not.toContain('Module Warning (from ./my-warning-loader.js):'); + expect(stdout).not.toContain('Generated Warning'); + }); + + it('should reset options.ignoreWarnings', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--ignore-warnings', /Generated Warning/, '--ignore-warnings-reset']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Module Warning (from ./my-warning-loader.js):'); + expect(stdout).toContain('Generated Warning'); + }); + + it('should throw error for an invalid value', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--ignore-warnings', 'abc']); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`Invalid value 'abc' for the '--ignore-warnings' option`); + expect(stderr).toContain(`Expected: 'regular expression (example: /ab?c*/)'`); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/core-flags/ignore-warnings/my-warning-loader.js b/test/core-flags/ignore-warnings/my-warning-loader.js new file mode 100644 index 00000000000..dcf7db3737d --- /dev/null +++ b/test/core-flags/ignore-warnings/my-warning-loader.js @@ -0,0 +1,5 @@ +module.exports = function loader(source) { + const { emitWarning } = this; + emitWarning('Generated Warning'); + return source; +}; diff --git a/test/core-flags/ignore-warnings/src/main.js b/test/core-flags/ignore-warnings/src/main.js new file mode 100644 index 00000000000..a136806e8f1 --- /dev/null +++ b/test/core-flags/ignore-warnings/src/main.js @@ -0,0 +1 @@ +console.log('Entry'); diff --git a/test/core-flags/ignore-warnings/webpack.config.js b/test/core-flags/ignore-warnings/webpack.config.js new file mode 100644 index 00000000000..521581d4a12 --- /dev/null +++ b/test/core-flags/ignore-warnings/webpack.config.js @@ -0,0 +1,24 @@ +const path = require('path'); + +module.exports = { + mode: 'development', + entry: './src/main.js', + module: { + rules: [ + { + test: /.(js|jsx)?$/, + loader: 'my-warning-loader', + include: [path.resolve(__dirname, 'src')], + exclude: [/node_modules/], + }, + ], + }, + resolveLoader: { + alias: { + 'my-warning-loader': require.resolve('./my-warning-loader'), + }, + }, + performance: { + hints: 'warning', + }, +}; From 0191ebc7a4c5e17d098908119c67f22aea86e328 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sun, 3 Jan 2021 20:08:01 +0530 Subject: [PATCH 216/581] feat: add support for dev containers (#2287) * chore: add support for dev containers * docs: update contribution guide --- .devcontainer/Dockerfile | 4 ++++ .devcontainer/devcontainer.json | 10 ++++++++++ .github/CONTRIBUTING.md | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..2af70d687af --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +FROM node:12 + +# Add global instances of prettier and eslint for vscode +RUN npm install -g eslint prettier \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..264b218cf9b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,10 @@ +{ + "name": "webpack-cli", + "dockerFile": "Dockerfile", + "runArgs": ["-u", "node"], + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "postCreateCommand": "yarn install && yarn bootstrap && yarn build", + "extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] +} diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6b6fb20f151..c32b815ef98 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -80,6 +80,8 @@ In case you are suggesting a new feature, we will match your idea with our curre yarn build ``` +> If you are a Docker and Visual Studio Code user, you can quickstart development using [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) Extension + ## Running Tests ### Using yarn From 41c391bbe4a35a57b5a0322bdb5e9813ddd24cd0 Mon Sep 17 00:00:00 2001 From: James George Date: Sun, 3 Jan 2021 21:55:59 +0530 Subject: [PATCH 217/581] chore: prevent unnecessary writes to stdin (#2297) --- test/init/force/init-force.test.js | 2 +- test/init/generator/init-inquirer.test.js | 2 +- test/init/multipleEntries/init-multipleEntries.test.js | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/test/init/force/init-force.test.js b/test/init/force/init-force.test.js index 98f7aea1fbe..141de8021e6 100644 --- a/test/init/force/init-force.test.js +++ b/test/init/force/init-force.test.js @@ -19,7 +19,7 @@ describe('init force flag', () => { }); it('should scaffold webpack config', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init', '--force'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init', '--force'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index edd95a1f230..c66304516d6 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -19,7 +19,7 @@ describe('init', () => { }); it('should scaffold when given answers', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index f7c1d9abc2b..4ac276aa06c 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -16,11 +16,7 @@ describe('init with multiple entries', () => { }); it('should scaffold with multiple entries', async () => { - const { stdout } = await runPromptWithAnswers( - genPath, - ['init'], - [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER], - ); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); From efe81e986a6dca5cc9b72a5c9312dc21409f65b1 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Sun, 3 Jan 2021 21:24:44 +0300 Subject: [PATCH 218/581] fix: double commands output in help (#2298) --- packages/webpack-cli/__tests__/CLI.test.js | 106 +++++++++++++++++++++ packages/webpack-cli/lib/webpack-cli.js | 22 +++-- test/help/help.test.js | 18 ++++ 3 files changed, 137 insertions(+), 9 deletions(-) diff --git a/packages/webpack-cli/__tests__/CLI.test.js b/packages/webpack-cli/__tests__/CLI.test.js index cf64bbf55b0..99cae68b35e 100644 --- a/packages/webpack-cli/__tests__/CLI.test.js +++ b/packages/webpack-cli/__tests__/CLI.test.js @@ -9,6 +9,8 @@ describe('CLI API', () => { describe('makeCommand', () => { it('should make command', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand({ name: 'command' }, [], (program) => { expect(program.opts()).toEqual({}); @@ -19,6 +21,8 @@ describe('CLI API', () => { }); it('should make command with Boolean option by default', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -40,6 +44,8 @@ describe('CLI API', () => { }); it('should make command with Boolean option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -62,6 +68,8 @@ describe('CLI API', () => { }); it('should make command with Boolean option and negative value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -85,6 +93,8 @@ describe('CLI API', () => { }); it('should make command with Boolean option and negative value #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -108,6 +118,8 @@ describe('CLI API', () => { }); it('should make command with Boolean option and negative value #3', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -131,6 +143,8 @@ describe('CLI API', () => { }); it('should make command with Boolean option with default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -154,6 +168,8 @@ describe('CLI API', () => { }); it('should make command with String option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -176,6 +192,8 @@ describe('CLI API', () => { }); it('should make command with String option with alias', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -199,6 +217,8 @@ describe('CLI API', () => { }); it('should make command with String option with default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -222,6 +242,8 @@ describe('CLI API', () => { }); it('should make command with String option with default value #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -245,6 +267,8 @@ describe('CLI API', () => { }); it('should make command with String option using "=" syntax', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -267,6 +291,8 @@ describe('CLI API', () => { }); it('should make command with multiple String option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -290,6 +316,8 @@ describe('CLI API', () => { }); it('should make command with multiple String option with default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -314,6 +342,8 @@ describe('CLI API', () => { }); it('should make command with multiple String option with default value #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -338,6 +368,8 @@ describe('CLI API', () => { }); it('should make command with multiple String option #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -361,6 +393,8 @@ describe('CLI API', () => { }); it('should make command with Number option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -383,6 +417,8 @@ describe('CLI API', () => { }); it('should make command with Number option with default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -406,6 +442,8 @@ describe('CLI API', () => { }); it('should make command with multiple Number option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -429,6 +467,8 @@ describe('CLI API', () => { }); it('should make command with multiple Number option and default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -453,6 +493,8 @@ describe('CLI API', () => { }); it('should make command with multiple Number option and default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -477,6 +519,8 @@ describe('CLI API', () => { }); it('should make command with custom function type', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -501,6 +545,8 @@ describe('CLI API', () => { }); it('should make command with custom function type and default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -526,6 +572,8 @@ describe('CLI API', () => { }); it('should make command with multiple custom function type', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -551,6 +599,8 @@ describe('CLI API', () => { }); it('should make command with multiple custom function type and default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -577,6 +627,8 @@ describe('CLI API', () => { }); it('should make command with multiple custom function type and default value #2', async (done) => { + cli.program.commands = []; + let skipDefault = true; const command = await cli.makeCommand( @@ -610,6 +662,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and String option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -632,6 +686,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and String option #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -654,6 +710,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and String option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -677,6 +735,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and String option #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -700,6 +760,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and String option and negative', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -723,6 +785,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and String option and negative #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -746,6 +810,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and String option and negative #3', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -769,6 +835,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number option', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -791,6 +859,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number option #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -813,6 +883,8 @@ describe('CLI API', () => { }); it('should make command with array Boolean type', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -835,6 +907,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number and String type', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -857,6 +931,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number and String type #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -879,6 +955,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number and String type #3', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -901,6 +979,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number and String type and default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -924,6 +1004,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number and String type and default value #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -947,6 +1029,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number and String type and default value #3', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -970,6 +1054,8 @@ describe('CLI API', () => { }); it('should make command with Boolean and Number and String type and default value #4', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -993,6 +1079,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String type', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1016,6 +1104,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String type #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1039,6 +1129,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String type #3', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1062,6 +1154,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String type #4', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1085,6 +1179,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String type #5', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1108,6 +1204,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String and default value', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1132,6 +1230,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String and default value #2', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1156,6 +1256,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String and default value #3', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1180,6 +1282,8 @@ describe('CLI API', () => { }); it('should make command with multiple Boolean and Number and String and default value #4', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', @@ -1204,6 +1308,8 @@ describe('CLI API', () => { }); it('should make command with array of unknown types', async (done) => { + cli.program.commands = []; + const command = await cli.makeCommand( { name: 'command', diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index df8649fba1a..34e6f406c6e 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -30,6 +30,14 @@ class WebpackCLI { } async makeCommand(commandOptions, options, action) { + const alreadyLoaded = this.program.commands.find( + (command) => command.name() === commandOptions.name || command.alias() === commandOptions.alias, + ); + + if (alreadyLoaded) { + return; + } + const command = this.program.command(commandOptions.name, { noHelp: commandOptions.noHelp, hidden: commandOptions.hidden, @@ -551,15 +559,11 @@ class WebpackCLI { }; if (isGlobal) { - const commandsToLoad = [] - .concat(bundleCommandOptions) - .concat(helpCommandOptions) - .concat(versionCommandOptions) - .concat(externalBuiltInCommandsInfo); - - for (const commandToLoad of commandsToLoad) { - await loadCommandByName(commandToLoad.name); - } + await Promise.all( + knownCommands.map((knownCommand) => { + return loadCommandByName(knownCommand.name); + }), + ); const bundleCommand = this.program.commands.find( (command) => command.name() === bundleCommandOptions.name || command.alias() === bundleCommandOptions.alias, diff --git a/test/help/help.test.js b/test/help/help.test.js index d446a20947c..15126bb04bc 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -19,6 +19,15 @@ describe('help', () => { expect(stdout).not.toContain('--cache-type'); // verbose expect(stdout).toContain('Global options:'); expect(stdout).toContain('Commands:'); + expect(stdout.match(/bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/version\|v/g)).toHaveLength(1); + expect(stdout.match(/help\|h/g)).toHaveLength(1); + expect(stdout.match(/serve\|s/g)).toHaveLength(1); + expect(stdout.match(/info\|i/g)).toHaveLength(1); + expect(stdout.match(/init\|c/g)).toHaveLength(1); + expect(stdout.match(/loader\|l/g)).toHaveLength(1); + expect(stdout.match(/migrate\|m/g)).toHaveLength(1); + expect(stdout.match(/plugin\|p/g)).toHaveLength(1); expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); // TODO buggy on windows @@ -41,6 +50,15 @@ describe('help', () => { expect(stdout).toContain('Global options:'); expect(stdout).toContain('Commands:'); + expect(stdout.match(/bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/version\|v/g)).toHaveLength(1); + expect(stdout.match(/help\|h/g)).toHaveLength(1); + expect(stdout.match(/serve\|s/g)).toHaveLength(1); + expect(stdout.match(/info\|i/g)).toHaveLength(1); + expect(stdout.match(/init\|c/g)).toHaveLength(1); + expect(stdout.match(/loader\|l/g)).toHaveLength(1); + expect(stdout.match(/migrate\|m/g)).toHaveLength(1); + expect(stdout.match(/plugin\|p/g)).toHaveLength(1); expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); From 2af08013852a95c6f6462c56a9994a4ee28c6ea1 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Sun, 3 Jan 2021 21:26:34 +0300 Subject: [PATCH 219/581] feat: allow to pass parseOption to CLI class (#2299) --- packages/webpack-cli/lib/index.js | 12 +++--------- packages/webpack-cli/lib/webpack-cli.js | 4 ++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/webpack-cli/lib/index.js b/packages/webpack-cli/lib/index.js index f284f9074db..fa7a933054f 100644 --- a/packages/webpack-cli/lib/index.js +++ b/packages/webpack-cli/lib/index.js @@ -1,13 +1,7 @@ -const WebpackCLI = require('./webpack-cli'); -const { commands } = require('./utils/cli-flags'); +const CLI = require('./webpack-cli'); const logger = require('./utils/logger'); const getPackageManager = require('./utils/get-package-manager'); -module.exports = WebpackCLI; - +module.exports = CLI; // export additional utils used by other packages -module.exports.utils = { - logger, - commands, - getPackageManager, -}; +module.exports.utils = { logger, getPackageManager }; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 34e6f406c6e..1401bafca9a 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -227,7 +227,7 @@ class WebpackCLI { return flags; } - async run(args) { + async run(args, parseOptions) { // Built-in internal commands const bundleCommandOptions = { name: 'bundle', @@ -712,7 +712,7 @@ class WebpackCLI { await this.program.parseAsync([commandName, ...options], { from: 'user' }); }); - await this.program.parseAsync(args); + await this.program.parseAsync(args, parseOptions); } async resolveConfig(options) { From d34dfb7eea7c694574cd40e83539aeab55b5c381 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 4 Jan 2021 06:29:36 +0530 Subject: [PATCH 220/581] docs: remove redundant command entries (#2301) --- OPTIONS.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index b7bc2513aeb..bf4cd0ba68f 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -566,8 +566,6 @@ Commands: init|c [options] [scaffold...] Initialize a new webpack configuration. loader|l [output-path] Scaffold a loader. plugin|p [output-path] Scaffold a plugin. - loader|l [output-path] Scaffold a loader. - plugin|p [output-path] Scaffold a plugin. migrate|m [new-config-path] Migrate a configuration to a new version. To see list of all supported commands and options run 'webpack --help=verbose'. From 3016370ec0feab93711150fd66b0d7104e0be086 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 4 Jan 2021 19:12:06 +0530 Subject: [PATCH 221/581] chore: ignore build files from lint (#2304) --- .eslintignore | 9 +-------- .prettierignore | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.eslintignore b/.eslintignore index 7593c797b4a..ec220a0fdec 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,14 +1,7 @@ __testfixtures__ coverage node_modules -packages/generate-loader/lib -packages/generate-plugin/lib -packages/generators/lib -packages/info/lib -packages/init/lib -packages/migrate/lib -packages/serve/lib -packages/utils/lib +packages/**/lib test/**/dist/ test/**/bin/ test/**/binary/ diff --git a/.prettierignore b/.prettierignore index b9e12bb5f96..7b3b7544c17 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,3 +8,4 @@ test/config/error-commonjs/syntax-error.js test/config/error-mjs/syntax-error.mjs packages/webpack-cli/__tests__/test-assets/.yo-rc.json test/build-errors/stats.json +packages/**/lib From 4ea0cb473fd715e1a0465b2e3ae83d2fd6abb6fe Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 4 Jan 2021 21:07:56 +0530 Subject: [PATCH 222/581] tests(init): assert for webpack config file content (#2300) * tests: assert for webpack config file content * fix: update matching condition regex --- .../__tests__/utils/styleSupport.test.ts | 4 +-- packages/generators/src/utils/styleSupport.ts | 2 +- test/init/auto/init-auto.test.js | 6 +++- test/init/force/init-force.test.js | 4 +++ .../init-generation-path.test.js | 8 +++++ test/init/generator/init-inquirer.test.js | 6 +++- .../language/css/init-language-css.test.js | 33 ++++++++++++++++++- .../init/language/js/init-language-js.test.js | 12 +++++++ .../init-multipleEntries.test.js | 29 +++++++++++++--- 9 files changed, 93 insertions(+), 11 deletions(-) diff --git a/packages/generators/__tests__/utils/styleSupport.test.ts b/packages/generators/__tests__/utils/styleSupport.test.ts index 4864771e554..1bf0009b6d9 100644 --- a/packages/generators/__tests__/utils/styleSupport.test.ts +++ b/packages/generators/__tests__/utils/styleSupport.test.ts @@ -34,7 +34,7 @@ describe('styleSupport', () => { it('generates SASS configuration', () => { const gen = getMockGenerator(); const { ExtractUseProps, regExpForStyles } = style(gen, StylingType.SASS); - expect(regExpForStyles).toEqual('/.(scss|css)$/'); + expect(regExpForStyles).toEqual('/.(sa|sc|c)ss$/'); expect(gen.dependencies).toEqual(['node-sass', 'sass-loader', 'css-loader', 'style-loader']); expect(ExtractUseProps.length).toEqual(3); }); @@ -43,7 +43,7 @@ describe('styleSupport', () => { const gen = getMockGenerator(); gen.isProd = true; const { ExtractUseProps, regExpForStyles } = style(gen, StylingType.SASS); - expect(regExpForStyles).toEqual('/.(scss|css)$/'); + expect(regExpForStyles).toEqual('/.(sa|sc|c)ss$/'); expect(gen.dependencies).toEqual(['node-sass', 'sass-loader', 'css-loader']); expect(ExtractUseProps.length).toEqual(2); }); diff --git a/packages/generators/src/utils/styleSupport.ts b/packages/generators/src/utils/styleSupport.ts index 24ad636a546..2ba0d5219c7 100644 --- a/packages/generators/src/utils/styleSupport.ts +++ b/packages/generators/src/utils/styleSupport.ts @@ -18,7 +18,7 @@ export enum LoaderName { export enum StyleRegex { CSS = '/.css$/', - SASS = '/.(scss|css)$/', + SASS = '/.(sa|sc|c)ss$/', LESS = '/.(less|css)$/', PostCSS = '/.css$/', } diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index c6dae9e4316..b6a9504a8e6 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -35,12 +35,16 @@ describe('init auto flag', () => { } // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js']; + const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + const webpackConfig = require(join(genPath, 'webpack.config.js')); + + expect(webpackConfig.modules.rules).toEqual([]); + // Check package json is correctly configured const pkgJsonTests = () => { const pkgJson = require(join(genPath, './package.json')); diff --git a/test/init/force/init-force.test.js b/test/init/force/init-force.test.js index 141de8021e6..81be3543f84 100644 --- a/test/init/force/init-force.test.js +++ b/test/init/force/init-force.test.js @@ -36,6 +36,10 @@ describe('init force flag', () => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + const webpackConfig = require(join(genPath, 'webpack.config.js')); + + expect(webpackConfig.modules.rules).toEqual([]); + // Check package json is correctly configured const pkgJsonTests = () => { const pkgJson = require(join(genPath, './package.json')); diff --git a/test/init/generation-path/init-generation-path.test.js b/test/init/generation-path/init-generation-path.test.js index 87c0734e50e..596457e6c2d 100644 --- a/test/init/generation-path/init-generation-path.test.js +++ b/test/init/generation-path/init-generation-path.test.js @@ -32,6 +32,10 @@ describe('init generate-path flag', () => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + const webpackConfig = require(join(genPath, 'webpack.config.js')); + + expect(webpackConfig.modules.rules).toEqual([]); + // Check package json is correctly configured const pkgJsonTests = () => { const pkgJson = require(join(genPath, './package.json')); @@ -64,6 +68,10 @@ describe('init generate-path flag', () => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + const webpackConfig = require(join(genPath, 'webpack.config.js')); + + expect(webpackConfig.modules.rules).toEqual([]); + // Check package json is correctly configured const pkgJsonTests = () => { const pkgJson = require(join(genPath, './package.json')); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index c66304516d6..352dfd8ff99 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -30,12 +30,16 @@ describe('init', () => { } // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js']; + const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + const webpackConfig = require(join(genPath, 'webpack.config.js')); + + expect(webpackConfig.modules.rules).toEqual([]); + // Check package json is correctly configured const pkgJsonTests = () => { const pkgJson = require(join(genPath, './package.json')); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 7e28f3ff3bf..43242b8b81a 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -32,12 +32,43 @@ describe('init with SCSS', () => { } // Test regressively files are scaffolded - const files = ['./package.json', './.yo-rc.json', './src/index.js', 'webpack.config.js']; + const files = ['./package.json', './.yo-rc.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + const webpackConfig = require(join(genPath, './webpack.config.js')); + + expect(webpackConfig.module.rules).toEqual([ + { + test: /.(sa|sc|c)ss$/, + + use: [ + { + loader: MiniCssExtractPlugin.loader, // eslint-disable-line + }, + { + loader: 'style-loader', + }, + { + loader: 'css-loader', + + options: { + sourceMap: true, + }, + }, + { + loader: 'sass-loader', + + options: { + sourceMap: true, + }, + }, + ], + }, + ]); + // Check if package.json is correctly configured const pkgJsonTests = () => { const pkgJson = require(join(genPath, './package.json')); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 1400f8861a5..aed626f6ad3 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -34,6 +34,18 @@ describe('init with Typescript', () => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + const webpackConfig = require(join(genPath, 'webpack.config.js')); + + expect(webpackConfig.module.rules).toEqual([ + { + test: /\.(ts|tsx)$/, + loader: 'ts-loader', + include: [path.resolve(__dirname, 'src')], // eslint-disable-line + exclude: [/node_modules/], + }, + ]); + expect(webpackConfig.resolve.extensions).toEqual(['.tsx', '.ts', '.js']); + // Check package json is correctly configured const pkgJsonTests = () => { const pkgJson = require(join(genPath, './package.json')); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 4ac276aa06c..512934fee34 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -1,13 +1,13 @@ 'use strict'; const fs = require('fs'); -const path = require('path'); +const { join, resolve } = require('path'); const rimraf = require('rimraf'); const { runPromptWithAnswers } = require('../../utils/test-utils'); const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; -const genPath = path.join(__dirname, 'test-assets'); +const genPath = join(__dirname, 'test-assets'); describe('init with multiple entries', () => { beforeAll(() => { @@ -22,15 +22,34 @@ describe('init with multiple entries', () => { expect(stdout).toContain(firstPrompt); // Skip test in case installation fails - if (!fs.existsSync(path.resolve(genPath, './yarn.lock'))) { + if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { return; } // Test regressively files are scaffolded - const files = ['./package.json', './src/a.js', './src/b.js', './.yo-rc.json']; + const files = ['./package.json', './src/a.js', './src/b.js', './.yo-rc.json', './webpack.config.js']; files.forEach((file) => { - expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy(); + expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); }); + + const webpackConfig = require(join(genPath, 'webpack.config.js')); + + expect(webpackConfig.entry).toEqual({ + a: './src/a.js', + b: './src/b.js', + }); + expect(webpackConfig.module.rules).toEqual([]); + + // Check if package.json is correctly configured + const pkgJsonTests = () => { + const pkgJson = require(join(genPath, './package.json')); + expect(pkgJson).toBeTruthy(); + expect(pkgJson['devDependencies']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['terser-webpack-plugin']).toBeTruthy(); + expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + }; + expect(pkgJsonTests).not.toThrow(); }); }); From 9084eabd6d3c99c4c716341df7ebc4dec6507a51 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 5 Jan 2021 15:06:17 +0300 Subject: [PATCH 223/581] chore(deps-dev): bump @types/node from 14.14.19 to 14.14.20 (#2306) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.19 to 14.14.20. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 557b1cce8d8..a0a59f705ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2457,9 +2457,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.19" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.19.tgz#5135176a8330b88ece4e9ab1fdcfc0a545b4bab4" - integrity sha512-4nhBPStMK04rruRVtVc6cDqhu7S9GZai0fpXgPXrFpcPX6Xul8xnrjSdGB4KPBVYG/R5+fXWdCM8qBoiULWGPQ== + version "14.14.20" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.20.tgz#f7974863edd21d1f8a494a73e8e2b3658615c340" + integrity sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 19a25cf83dc2f680a5028f4b449d7f79895231f0 Mon Sep 17 00:00:00 2001 From: James George Date: Tue, 5 Jan 2021 17:41:19 +0530 Subject: [PATCH 224/581] fix: remove style-loader from the loader chain (#2309) --- .../__tests__/__snapshots__/init-generator.test.ts.snap | 3 --- packages/generators/__tests__/init-generator.test.ts | 5 ++--- packages/generators/src/init-generator.ts | 3 +++ test/init/language/css/init-language-css.test.js | 3 --- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index 115d8c266cd..52462b2163d 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -111,9 +111,6 @@ Object { Object { "loader": "MiniCssExtractPlugin.loader", }, - Object { - "loader": "\\"style-loader\\"", - }, Object { "loader": "\\"css-loader\\"", "options": Object { diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index d363740ecf9..6c4465281e6 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -113,10 +113,9 @@ describe('init generator', () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const config = (Object.entries(output)[0][1] as any).configuration.config.webpackOptions; expect(config.module.rules[0].test).toEqual('/.css$/'); - expect(config.module.rules[0].use.length).toEqual(3); + expect(config.module.rules[0].use.length).toEqual(2); expect(config.module.rules[0].use[0].loader).toEqual('MiniCssExtractPlugin.loader'); - expect(config.module.rules[0].use[1].loader).toEqual('"style-loader"'); - expect(config.module.rules[0].use[2].loader).toEqual('"css-loader"'); + expect(config.module.rules[0].use[1].loader).toEqual('"css-loader"'); //match config snapshot expect(config).toMatchSnapshot(); }); diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index b6e3f47e0c8..fd7cadef59e 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -187,6 +187,9 @@ export default class InitGenerator extends CustomGenerator { ); } + // Remove style-loader from the loader chain + ExtractUseProps.shift(); + ExtractUseProps.unshift({ loader: 'MiniCssExtractPlugin.loader', }); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 43242b8b81a..43ed62fd16c 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -48,9 +48,6 @@ describe('init with SCSS', () => { { loader: MiniCssExtractPlugin.loader, // eslint-disable-line }, - { - loader: 'style-loader', - }, { loader: 'css-loader', From a276354e399eb3b49d7296ce43ae5748f79ae7c2 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 5 Jan 2021 18:24:10 +0300 Subject: [PATCH 225/581] chore(deps-dev): bump eslint-plugin-prettier from 3.3.0 to 3.3.1 (#2305) Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases) - [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-plugin-prettier/compare/v3.3.0...v3.3.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index a0a59f705ee..3c3af9ca1da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4885,9 +4885,9 @@ eslint-plugin-node@^11.1.0: semver "^6.1.0" eslint-plugin-prettier@^3.1.4: - version "3.3.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.0.tgz#61e295349a65688ffac0b7808ef0a8244bdd8d40" - integrity sha512-tMTwO8iUWlSRZIwS9k7/E4vrTsfvsrcM5p1eftyuqWH25nKsz/o6/54I7jwQ/3zobISyC7wMy9ZsFwgTxOcOpQ== + version "3.3.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz#7079cfa2497078905011e6f82e8dd8453d1371b7" + integrity sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ== dependencies: prettier-linter-helpers "^1.0.0" From e44e855c7e302932a828fcedf7abfe205b47c716 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 5 Jan 2021 21:43:21 +0530 Subject: [PATCH 226/581] fix: remove splitchunks (#2310) --- .../__snapshots__/init-generator.test.ts.snap | 110 ------------------ packages/generators/src/init-generator.ts | 26 +---- 2 files changed, 1 insertion(+), 135 deletions(-) diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index 52462b2163d..d9036b1abe2 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -14,23 +14,6 @@ Object { }, ], }, - "optimization": Object { - "minimizer": Array [ - "new TerserPlugin()", - ], - "splitChunks": Object { - "cacheGroups": Object { - "vendors": Object { - "priority": -10, - "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", - }, - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": false, - }, - }, "plugins": Array [ "new webpack.ProgressPlugin()", ], @@ -55,23 +38,6 @@ Object { }, ], }, - "optimization": Object { - "minimizer": Array [ - "new TerserPlugin()", - ], - "splitChunks": Object { - "cacheGroups": Object { - "vendors": Object { - "priority": -10, - "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", - }, - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": false, - }, - }, "plugins": Array [ "new webpack.ProgressPlugin()", ], @@ -121,23 +87,6 @@ Object { }, ], }, - "optimization": Object { - "minimizer": Array [ - "new TerserPlugin()", - ], - "splitChunks": Object { - "cacheGroups": Object { - "vendors": Object { - "priority": -10, - "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", - }, - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": false, - }, - }, "plugins": Array [ "new webpack.ProgressPlugin()", "new MiniCssExtractPlugin({ filename:'main.[contenthash].css' })", @@ -166,23 +115,6 @@ Object { }, ], }, - "optimization": Object { - "minimizer": Array [ - "new TerserPlugin()", - ], - "splitChunks": Object { - "cacheGroups": Object { - "vendors": Object { - "priority": -10, - "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", - }, - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": false, - }, - }, "plugins": Array [ "new webpack.ProgressPlugin()", ], @@ -196,23 +128,6 @@ Object { "module": Object { "rules": Array [], }, - "optimization": Object { - "minimizer": Array [ - "new TerserPlugin()", - ], - "splitChunks": Object { - "cacheGroups": Object { - "vendors": Object { - "priority": -10, - "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", - }, - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": false, - }, - }, "output": Object { "path": "path.resolve(__dirname, 'dist2')", }, @@ -231,14 +146,6 @@ Object { "module": Object { "rules": Array [], }, - "optimization": Object { - "minimizer": Array [ - "new TerserPlugin()", - ], - "splitChunks": Object { - "chunks": "'all'", - }, - }, "plugins": Array [ "new webpack.ProgressPlugin()", "new HtmlWebpackPlugin({ @@ -263,23 +170,6 @@ Object { "module": Object { "rules": Array [], }, - "optimization": Object { - "minimizer": Array [ - "new TerserPlugin()", - ], - "splitChunks": Object { - "cacheGroups": Object { - "vendors": Object { - "priority": -10, - "test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", - }, - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": false, - }, - }, "plugins": Array [ "new webpack.ProgressPlugin()", ], diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index fd7cadef59e..79aaddaa6de 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -4,16 +4,7 @@ import logSymbols from 'log-symbols'; import path from 'path'; import { Confirm, Input, List } from './utils/scaffold-utils'; -import { - getDefaultOptimization, - LangType, - langQuestionHandler, - tooltip, - generatePluginName, - StylingType, - styleQuestionHandler, - entryQuestions, -} from './utils'; +import { LangType, langQuestionHandler, tooltip, generatePluginName, StylingType, styleQuestionHandler, entryQuestions } from './utils'; import { CustomGenerator } from './types'; const { logger, getPackageManager } = utils; @@ -60,15 +51,6 @@ export default class InitGenerator extends CustomGenerator { this.entryOption = './src/index.js'; - // add splitChunks options for transparency - // defaults coming from: https://webpack.js.org/plugins/split-chunks-plugin/#optimization-splitchunks - this.configuration.config.topScope.push( - "const path = require('path');", - "const webpack = require('webpack');", - '\n', - tooltip.splitChunks(), - ); - (this.configuration.config.webpackOptions.plugins as string[]).push('new webpack.ProgressPlugin()'); } @@ -231,12 +213,6 @@ export default class InitGenerator extends CustomGenerator { })`); } - // TerserPlugin - this.dependencies.push('terser-webpack-plugin'); - this.configuration.config.topScope.push(tooltip.terser(), "const TerserPlugin = require('terser-webpack-plugin');", '\n'); - - // Chunksplitting - this.configuration.config.webpackOptions.optimization = getDefaultOptimization(this.usingDefaults); this.configuration.config.webpackOptions.mode = this.usingDefaults ? "'production'" : "'development'"; } From 70cae0053028d49496fd63bddb7796cd91af0d83 Mon Sep 17 00:00:00 2001 From: James George Date: Wed, 6 Jan 2021 18:17:10 +0530 Subject: [PATCH 227/581] docs: fix broken references (#2315) --- README.md | 4 ++-- packages/README.md | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b663b3f5956..f4b7691cbca 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ Thus, webpack CLI provides different commands for many common tasks. - [`webpack-cli init`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration. - [`webpack-cli info`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment. - [`webpack-cli migrate`](./packages/migrate/README.md#webpack-cli-migrate) - Migrate project from one version to another. -- [`webpack-cli plugin`](./packages/generate-plugin/README.md#webpack-cli-generate-plugin) - Initiate new plugin project. -- [`webpack-cli loader`](./packages/generate-loader/README.md#webpack-cli-generate-loader) - Initiate new loader project. +- [`webpack-cli plugin`](./packages/generators#generators) - Initiate new plugin project. +- [`webpack-cli loader`](./packages/generators#generators) - Initiate new loader project. - [`webpack-cli serve`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading. ### Utilities diff --git a/packages/README.md b/packages/README.md index c9fee58bc04..450fcb1b56e 100644 --- a/packages/README.md +++ b/packages/README.md @@ -13,15 +13,13 @@ This folder is the collection of those packages. ## Packages -1. [generate-loader](https://github.com/webpack/webpack-cli/tree/master/packages/generate-loader) -2. [generate-plugin](https://github.com/webpack/webpack-cli/tree/master/packages/generate-plugin) -3. [generators](https://github.com/webpack/webpack-cli/tree/master/packages/generators) -4. [info](https://github.com/webpack/webpack-cli/tree/master/packages/info) -5. [init](https://github.com/webpack/webpack-cli/tree/master/packages/init) -6. [migrate](https://github.com/webpack/webpack-cli/tree/master/packages/migrate) -7. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) -8. [utils](https://github.com/webpack/webpack-cli/tree/master/packages/utils) -9. [webpack-cli](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli) +1. [generators](https://github.com/webpack/webpack-cli/tree/master/packages/generators) +2. [info](https://github.com/webpack/webpack-cli/tree/master/packages/info) +3. [init](https://github.com/webpack/webpack-cli/tree/master/packages/init) +4. [migrate](https://github.com/webpack/webpack-cli/tree/master/packages/migrate) +5. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) +6. [utils](https://github.com/webpack/webpack-cli/tree/master/packages/utils) +7. [webpack-cli](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli) ## Generic Installation From 3659c5e529fe1319251ef1c713d6cc758f7f5353 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 6 Jan 2021 18:29:38 +0530 Subject: [PATCH 228/581] fix: webpack installation prompt message (#2316) --- packages/webpack-cli/bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index dde3da09046..d309c0a985f 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -21,7 +21,7 @@ process.title = 'webpack'; if (packageExists('webpack')) { runCLI(process.argv); } else { - promptInstallation('webpack -W', () => { + promptInstallation('webpack', () => { error(`It looks like ${yellow('webpack')} is not installed.`); }) .then(() => { From 4e2105345bc3f5c3bf6e4cfb658c6b90d3725822 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 6 Jan 2021 19:54:52 +0530 Subject: [PATCH 229/581] chore: remove duplicate build script (#2318) --- .github/workflows/nodejs.yml | 2 +- package.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index c5787566709..1b35592abc6 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -88,7 +88,7 @@ jobs: run: yarn add -W webpack@${{ matrix.webpack-version }} - name: Build - run: yarn build:ci + run: yarn build - name: Test and Generate Coverage run: | diff --git a/package.json b/package.json index 74a2a8cc20f..e890c28c1d7 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "prebuild": "yarn clean", "prebuild:ci": "yarn clean && node ./scripts/setupBuild.js", "build": "tsc --build", - "build:ci": "tsc --build", "watch": "tsc --build --watch", "commit": "git-cz", "lint:prettier": "prettier --list-different . \"!**/*.{js,ts}\" ", From 73d3feced18b4e3708f958707326a6642a594cf2 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 6 Jan 2021 18:06:11 +0300 Subject: [PATCH 230/581] =?UTF-8?q?fix:=20respect=20`--stats`,=20`--color`?= =?UTF-8?q?=20and=20`--no-color`=20option=20for=20serve=20c=E2=80=A6=20(#2?= =?UTF-8?q?312)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- .../__snapshots__/startDevServer.test.ts.snap | 89 --------- .../serve/__tests__/startDevServer.test.ts | 173 ------------------ packages/serve/src/index.ts | 2 +- packages/serve/src/startDevServer.ts | 54 ++++-- packages/serve/src/types.ts | 5 +- .../webpack-cli/__tests__/resolveArgs.test.js | 21 --- packages/webpack-cli/lib/webpack-cli.js | 124 +++++++------ test/core-flags/stats-flags.test.js | 16 +- test/serve/basic/serve-basic.test.js | 19 +- .../config-no/no-stats-with-config.test.js | 17 +- test/stats/config/index.js | 5 +- test/stats/config/package.json | 8 - test/stats/config/stats.test.js | 43 ++++- test/stats/config/webpack.config.js | 2 +- test/stats/flags/index.js | 5 +- test/stats/flags/package.json | 8 - test/stats/flags/stats.test.js | 42 ++++- yarn.lock | 13 +- 19 files changed, 234 insertions(+), 414 deletions(-) delete mode 100644 packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap delete mode 100644 packages/serve/__tests__/startDevServer.test.ts delete mode 100644 test/stats/config/package.json delete mode 100644 test/stats/flags/package.json diff --git a/package.json b/package.json index e890c28c1d7..2da9bb158d7 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", "typescript": "^3.9.7", - "webpack": "^5.11.0", + "webpack": "^5.11.1", "webpack-bundle-analyzer": "^4.3.0", "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" diff --git a/packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap b/packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap deleted file mode 100644 index ad76801f1da..00000000000 --- a/packages/serve/__tests__/__snapshots__/startDevServer.test.ts.snap +++ /dev/null @@ -1,89 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`startDevServer should set default port and host if not provided 1`] = ` -Object { - "host": "localhost", - "port": 8080, - "publicPath": "/", -} -`; - -exports[`startDevServer should set default port and host if not provided 2`] = ` -Array [ - 8080, - "localhost", - [Function], -] -`; - -exports[`startDevServer should start dev server correctly for multi compiler with 1 devServer config 1`] = ` -Object { - "bonjour": true, - "host": "my.host", - "hot": true, - "port": 9000, - "progress": true, - "publicPath": "/", -} -`; - -exports[`startDevServer should start dev server correctly for multi compiler with 1 devServer config 2`] = ` -Array [ - 9000, - "my.host", - [Function], -] -`; - -exports[`startDevServer should start dev server correctly for single compiler 1`] = ` -Object { - "bonjour": true, - "host": "my.host", - "hot": true, - "port": 9000, - "progress": true, - "publicPath": "/", -} -`; - -exports[`startDevServer should start dev server correctly for single compiler 2`] = ` -Array [ - 9000, - "my.host", - [Function], -] -`; - -exports[`startDevServer should start dev servers correctly for multi compiler with 2 devServer configs 1`] = ` -Object { - "host": "localhost", - "port": 9000, - "progress": true, - "publicPath": "/", -} -`; - -exports[`startDevServer should start dev servers correctly for multi compiler with 2 devServer configs 2`] = ` -Object { - "host": "localhost", - "port": 9001, - "progress": true, - "publicPath": "/", -} -`; - -exports[`startDevServer should start dev servers correctly for multi compiler with 2 devServer configs 3`] = ` -Array [ - 9000, - "localhost", - [Function], -] -`; - -exports[`startDevServer should start dev servers correctly for multi compiler with 2 devServer configs 4`] = ` -Array [ - 9001, - "localhost", - [Function], -] -`; diff --git a/packages/serve/__tests__/startDevServer.test.ts b/packages/serve/__tests__/startDevServer.test.ts deleted file mode 100644 index e6377ca2ec1..00000000000 --- a/packages/serve/__tests__/startDevServer.test.ts +++ /dev/null @@ -1,173 +0,0 @@ -'use strict'; - -import startDevServer from '../src/startDevServer'; - -jest.mock('webpack-dev-server/lib/Server'); - -describe('startDevServer', () => { - // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-extraneous-require - const webpack = require('webpack'); - // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-extraneous-require - const DevServer = require('webpack-dev-server/lib/Server'); - - beforeEach(() => { - DevServer.mockClear(); - }); - - it('should start dev server correctly for single compiler', async () => { - const config = { - devServer: { - port: 9000, - hot: false, - bonjour: true, - }, - }; - const compiler = webpack(config); - - const servers = await startDevServer( - compiler, - { - host: 'my.host', - hot: true, - progress: true, - }, - console, - ); - - expect(servers.length).toEqual(1); - expect(servers).toEqual(DevServer.mock.instances); - - // this is the constructor - expect(DevServer.mock.calls.length).toEqual(1); - // the 2nd argument is the options - expect(DevServer.mock.calls[0][1]).toMatchSnapshot(); - - // the server should listen on correct host and port - expect(DevServer.mock.instances[0].listen.mock.calls.length).toEqual(1); - expect(DevServer.mock.instances[0].listen.mock.calls[0]).toMatchSnapshot(); - }); - - it('should set default port and host if not provided', async () => { - const config = { - devServer: {}, - }; - const compiler = webpack(config); - - const servers = await startDevServer(compiler, {}, console); - - expect(servers.length).toEqual(1); - expect(servers).toEqual(DevServer.mock.instances); - - // this is the constructor - expect(DevServer.mock.calls.length).toEqual(1); - // the 2nd argument is the options - expect(DevServer.mock.calls[0][1]).toMatchSnapshot(); - - // the server should listen on correct host and port - expect(DevServer.mock.instances[0].listen.mock.calls.length).toEqual(1); - expect(DevServer.mock.instances[0].listen.mock.calls[0]).toMatchSnapshot(); - }); - - it('should start dev server correctly for multi compiler with 1 devServer config', async () => { - const config = [ - { - devServer: { - port: 9000, - hot: false, - bonjour: true, - }, - }, - {}, - ]; - const compiler = webpack(config); - - const servers = await startDevServer( - compiler, - { - host: 'my.host', - hot: true, - progress: true, - }, - console, - ); - - expect(servers.length).toEqual(1); - expect(servers).toEqual(DevServer.mock.instances); - - // this is the constructor - expect(DevServer.mock.calls.length).toEqual(1); - // the 2nd argument is the options - expect(DevServer.mock.calls[0][1]).toMatchSnapshot(); - - // the server should listen on correct host and port - expect(DevServer.mock.instances[0].listen.mock.calls.length).toEqual(1); - expect(DevServer.mock.instances[0].listen.mock.calls[0]).toMatchSnapshot(); - }); - - it('should start dev servers correctly for multi compiler with 2 devServer configs', async () => { - const config = [ - { - devServer: { - port: 9000, - // here to show that it will be overridden - progress: false, - }, - }, - { - devServer: { - port: 9001, - }, - }, - ]; - const compiler = webpack(config); - - const servers = await startDevServer( - compiler, - { - // this progress CLI flag should override progress: false above - progress: true, - }, - console, - ); - - // there are 2 devServer configs, so both are run - expect(servers.length).toEqual(2); - expect(servers).toEqual(DevServer.mock.instances); - - // this is the constructor - expect(DevServer.mock.calls.length).toEqual(2); - // the 2nd argument is the options - expect(DevServer.mock.calls[0][1]).toMatchSnapshot(); - expect(DevServer.mock.calls[1][1]).toMatchSnapshot(); - - // both servers should listen on correct host and port - - expect(DevServer.mock.instances[0].listen.mock.calls.length).toEqual(1); - expect(DevServer.mock.instances[0].listen.mock.calls[0]).toMatchSnapshot(); - - expect(DevServer.mock.instances[1].listen.mock.calls.length).toEqual(1); - expect(DevServer.mock.instances[1].listen.mock.calls[0]).toMatchSnapshot(); - }); - - it('should handle 2 multi compiler devServer configs with conflicting ports', async () => { - await expect(async () => { - const config = [ - { - devServer: { - port: 9000, - }, - }, - { - devServer: { - port: 9000, - }, - }, - ]; - const compiler = webpack(config); - - await startDevServer(compiler, {}, console); - }).rejects.toThrow( - 'Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.', - ); - }); -}); diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 5108eb93924..2c9e0186bb3 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -108,7 +108,7 @@ class ServeCommand { } try { - servers = await startDevServer(compiler, devServerOptions, logger); + servers = await startDevServer(compiler, devServerOptions, options, logger); } catch (error) { if (error.name === 'ValidationError') { logger.error(error.message); diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index dd5065248ca..f6a825654df 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -5,12 +5,13 @@ import { devServerOptionsType } from './types'; * Starts the devServer * * @param {Object} compiler - a webpack compiler - * @param {Object} cliOptions - devServer args + * @param {Object} devServerCliOptions - dev server CLI options + * @param {Object} cliOptions - CLI options * @param {Object} logger - logger * * @returns {Object[]} array of resulting servers */ -export default async function startDevServer(compiler, cliOptions, logger): Promise { +export default async function startDevServer(compiler, devServerCliOptions, cliOptions, logger): Promise { let devServerVersion, Server, findPort; try { @@ -25,15 +26,15 @@ export default async function startDevServer(compiler, cliOptions, logger): Prom process.exit(2); } - const mergeOptions = (cliOptions: devServerOptionsType, devServerOptions: devServerOptionsType): devServerOptionsType => { + const mergeOptions = (devServerOptions: devServerOptionsType, devServerCliOptions: devServerOptionsType): devServerOptionsType => { // CLI options should take precedence over devServer options, // and CLI options should have no default values included - const options = { ...devServerOptions, ...cliOptions }; + const options = { ...devServerOptions, ...devServerCliOptions }; - if (devServerOptions.client && cliOptions.client) { + if (devServerOptions.client && devServerCliOptions.client) { // the user could set some client options in their devServer config, // then also specify client options on the CLI - options.client = { ...devServerOptions.client, ...cliOptions.client }; + options.client = { ...devServerOptions.client, ...devServerCliOptions.client }; } return options; @@ -59,23 +60,48 @@ export default async function startDevServer(compiler, cliOptions, logger): Prom const devServersOptions = []; for (const compilerWithDevServerOption of compilersWithDevServerOption) { - const options = mergeOptions(cliOptions, compilerWithDevServerOption.options.devServer || {}); + const options = mergeOptions(compilerWithDevServerOption.options.devServer || {}, devServerCliOptions); if (isDevServer4) { options.port = await findPort(options.port); options.client = options.client || {}; options.client.port = options.client.port || options.port; } else { - if (!options.publicPath) { - options.publicPath = - typeof compilerWithDevServerOption.options.output.publicPath === 'undefined' || - compilerWithDevServerOption.options.output.publicPath === 'auto' - ? '/' - : compilerWithDevServerOption.options.output.publicPath; - } + const getPublicPathOption = () => { + const normalizePublicPath = (publicPath) => (typeof publicPath === 'undefined' || publicPath === 'auto' ? '/' : publicPath); + + if (cliOptions.outputPublicPath) { + return normalizePublicPath(compilerWithDevServerOption.options.output.publicPath); + } + + // webpack-dev-server@3 + if (options.publicPath) { + return normalizePublicPath(options.publicPath); + } + + // webpack-dev-server@4 + if (options.dev && options.dev.publicPath) { + return normalizePublicPath(options.dev.publicPath); + } + + return normalizePublicPath(compilerWithDevServerOption.options.output.publicPath); + }; + const getStatsOption = () => { + if (cliOptions.stats) { + return compilerWithDevServerOption.options.stats; + } + + if (options.stats) { + return options.stats; + } + + return compilerWithDevServerOption.options.stats; + }; options.host = options.host || 'localhost'; options.port = options.port || 8080; + options.stats = getStatsOption(); + options.publicPath = getPublicPathOption(); } if (options.port) { diff --git a/packages/serve/src/types.ts b/packages/serve/src/types.ts index f4a1b276fd0..1876f21a990 100644 --- a/packages/serve/src/types.ts +++ b/packages/serve/src/types.ts @@ -2,7 +2,8 @@ export type devServerOptionsType = { bonjour?: boolean; client?: devServerClientOptions; compress?: boolean; - dev?: object; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + dev?: Record; firewall?: boolean | string[]; headers?: object; historyApiFallback?: boolean | object; @@ -28,6 +29,8 @@ export type devServerOptionsType = { transportMode?: object | string; useLocalIp?: boolean; publicPath?: undefined; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + stats?: any; }; type devServerClientOptions = { diff --git a/packages/webpack-cli/__tests__/resolveArgs.test.js b/packages/webpack-cli/__tests__/resolveArgs.test.js index c57bc89589d..67a1a0feeb1 100644 --- a/packages/webpack-cli/__tests__/resolveArgs.test.js +++ b/packages/webpack-cli/__tests__/resolveArgs.test.js @@ -1,14 +1,7 @@ const { resolve } = require('path'); -const { version } = require('webpack'); const webpackCLI = require('../lib/webpack-cli'); const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; -const statsPresets = ['normal', 'detailed', 'errors-only', 'errors-warnings', 'minimal', 'verbose', 'none']; - -if (version.startsWith('5')) { - statsPresets.push('summary'); -} - const applyOptions = new webpackCLI().applyOptions; describe('BasicResolver', () => { @@ -76,12 +69,6 @@ describe('BasicResolver', () => { expect(result.options).toMatchObject({ mode: 'development' }); }); - it('should assign stats correctly', async () => { - const result = await applyOptions({ options: {} }, { stats: 'errors-warnings' }); - - expect(result.options.stats).toEqual('errors-warnings'); - }); - targetValues.map((option) => { it(`should handle ${option} option`, async () => { const result = await applyOptions({ options: {} }, { target: option }); @@ -89,12 +76,4 @@ describe('BasicResolver', () => { expect(result.options.target).toEqual(option); }); }); - - statsPresets.map((preset) => { - it(`should handle ${preset} preset`, async () => { - const result = await applyOptions({ options: {} }, { stats: preset }); - - expect(result.options.stats).toEqual(preset); - }); - }); }); diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 1401bafca9a..e8e83ca8128 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -314,10 +314,6 @@ class WebpackCLI { this.makeCommand(bundleCommandOptions, this.getBuiltInOptions(), async (program) => { const options = program.opts(); - if (typeof colorFromArguments !== 'undefined') { - options.color = colorFromArguments; - } - if (program.args.length > 0) { const possibleCommands = [].concat([bundleCommandOptions.name]).concat(program.args); @@ -449,21 +445,18 @@ class WebpackCLI { }); // Default `--color` and `--no-color` options - // TODO doesn't work with `webpack serve` (never work, need fix), `--stats` doesn't work too, other options are fine - let colorFromArguments; - this.program.option('--color', 'Enable colors on console.'); this.program.on('option:color', function () { const { color } = this.opts(); - colorFromArguments = color; + coloretteOptions.changed = true; coloretteOptions.enabled = color; }); this.program.option('--no-color', 'Disable colors on console.'); this.program.on('option:no-color', function () { const { color } = this.opts(); - colorFromArguments = color; + coloretteOptions.changed = true; coloretteOptions.enabled = color; }); @@ -1111,6 +1104,63 @@ class WebpackCLI { ? config.options.map((options) => processLegacyArguments(options)) : processLegacyArguments(config.options); + // Apply `stats` and `stats.colors` options + const applyStatsColors = (configOptions) => { + // TODO remove after drop webpack@4 + const statsForWebpack4 = webpack.Stats && webpack.Stats.presetToOptions; + + if (statsForWebpack4) { + if (typeof configOptions.stats === 'undefined') { + configOptions.stats = {}; + } else if (typeof configOptions.stats === 'boolean' || typeof configOptions.stats === 'string') { + if ( + typeof configOptions.stats === 'string' && + configOptions.stats !== 'none' && + configOptions.stats !== 'verbose' && + configOptions.stats !== 'detailed' && + configOptions.stats !== 'minimal' && + configOptions.stats !== 'errors-only' && + configOptions.stats !== 'errors-warnings' + ) { + return configOptions; + } + + configOptions.stats = webpack.Stats.presetToOptions(configOptions.stats); + } + } else { + if (typeof configOptions.stats === 'undefined') { + configOptions.stats = { preset: 'normal' }; + } else if (typeof configOptions.stats === 'boolean') { + configOptions.stats = configOptions.stats ? { preset: 'normal' } : { preset: 'none' }; + } else if (typeof configOptions.stats === 'string') { + configOptions.stats = { preset: configOptions.stats }; + } + } + + let colors; + + // From arguments + if (typeof coloretteOptions.changed !== 'undefined') { + colors = Boolean(coloretteOptions.enabled); + } + // From stats + else if (typeof configOptions.stats.colors !== 'undefined') { + colors = configOptions.stats.colors; + } + // Default + else { + colors = Boolean(coloretteOptions.enabled); + } + + configOptions.stats.colors = colors; + + return configOptions; + }; + + config.options = Array.isArray(config.options) + ? config.options.map((options) => applyStatsColors(options)) + : applyStatsColors(config.options); + return config; } @@ -1210,53 +1260,19 @@ class WebpackCLI { process.exitCode = 1; } - // TODO remove after drop webpack@4 - const statsForWebpack4 = webpack.Stats && webpack.Stats.presetToOptions; - - const getStatsOptions = (stats) => { - if (statsForWebpack4) { - if (!stats) { - stats = {}; - } else if (typeof stats === 'boolean' || typeof stats === 'string') { - stats = webpack.Stats.presetToOptions(stats); - } - } - - let colors; - - // From arguments - if (typeof options.color !== 'undefined') { - colors = options.color; - } - // From stats - else if (typeof stats.colors !== 'undefined') { - colors = stats.colors; - } - // Default - else { - colors = coloretteOptions.enabled; - } - - stats.colors = colors; - - return stats; - }; - if (!compiler) { return; } - const foundStats = compiler.compilers - ? { - children: compiler.compilers.map((compiler) => - getStatsOptions(compiler.options ? compiler.options.stats : undefined), - ), - } - : getStatsOptions(compiler.options ? compiler.options.stats : undefined); + const statsOptions = compiler.compilers + ? { children: compiler.compilers.map((compiler) => (compiler.options ? compiler.options.stats : undefined)) } + : compiler.options + ? compiler.options.stats + : undefined; // TODO webpack@4 doesn't support `{ children: [{ colors: true }, { colors: true }] }` for stats - if (statsForWebpack4 && compiler.compilers) { - foundStats.colors = foundStats.children.some((child) => child.colors); + if (compiler.compilers && !compiler.compilers.find(oneOfCompiler => oneOfCompiler.webpack)) { + statsOptions.colors = statsOptions.children.some((child) => child.colors); } if (options.json) { @@ -1266,13 +1282,13 @@ class WebpackCLI { }; if (options.json === true) { - createJsonStringifyStream(stats.toJson(foundStats)) + createJsonStringifyStream(stats.toJson(statsOptions)) .on('error', handleWriteError) .pipe(process.stdout) .on('error', handleWriteError) .on('close', () => process.stdout.write('\n')); } else { - createJsonStringifyStream(stats.toJson(foundStats)) + createJsonStringifyStream(stats.toJson(statsOptions)) .on('error', handleWriteError) .pipe(createWriteStream(options.json)) .on('error', handleWriteError) @@ -1282,11 +1298,11 @@ class WebpackCLI { ); } } else { - const printedStats = stats.toString(foundStats); + const printedStats = stats.toString(statsOptions); // Avoid extra empty line when `stats: 'none'` if (printedStats) { - logger.raw(`${stats.toString(foundStats)}`); + logger.raw(printedStats); } } }; diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index 904e5f774da..3dccbbea5b5 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -20,9 +20,9 @@ describe('stats config related flag', () => { if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; - expect(stdout).toContain(`stats: { ${option}: [] }`); + expect(stdout).toContain(`${option}: []`); } else { - expect(stdout).toContain(`stats: { ${propName}: true }`); + expect(stdout).toContain(`${propName}: true`); } }); @@ -32,7 +32,7 @@ describe('stats config related flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`stats: { ${propName}: false }`); + expect(stdout).toContain(`${propName}: false`); }); } } @@ -43,7 +43,7 @@ describe('stats config related flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`stats: { ${propName}: 10 }`); + expect(stdout).toContain(`${propName}: 10`); }); } @@ -57,13 +57,13 @@ describe('stats config related flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`stats: { colors: { ${option}: 'u001b[32m' } }`); + expect(stdout).toContain(`colors: { ${option}: 'u001b[32m' }`); } else if (acceptsSingleValue.includes(propName)) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`stats: { ${propName}: 'log' }`); + expect(stdout).toContain(`${propName}: 'log'`); } else if (flag.name === 'stats-context') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); @@ -75,13 +75,13 @@ describe('stats config related flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`stats: { ${propName}: 'auto' }`); + expect(stdout).toContain(`${propName}: 'auto'`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`stats: { ${propName}: [ 'log' ] }`); + expect(stdout).toContain(`${propName}: [ 'log' ]`); } }); } diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index f9f68736d73..5a05c90fa80 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -1,5 +1,6 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); const path = require('path'); const getPort = require('get-port'); const { runServe, isWebpack5, isDevServer4 } = require('../../utils/test-utils'); @@ -66,6 +67,22 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); + it('should work with the "--stats" option', async () => { + const { stderr, stdout } = await runServe(['--stats'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stripAnsi(stdout)).toContain(isWebpack5 ? 'compiled successfully' : 'Version: webpack'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should work with the "--stats detailed" option', async () => { + const { stderr, stdout } = await runServe(['--stats', 'verbose'], __dirname); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain(isWebpack5 ? 'from webpack.Compiler' : 'webpack.buildChunkGraph.visitModules'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + it('should work with the "--mode" option #2', async () => { const { stderr, stdout } = await runServe(['--mode', 'production'], __dirname); @@ -169,7 +186,7 @@ describe('basic serve usage', () => { expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stdout).toContain('from /'); + expect(stripAnsi(stdout)).toContain('from /'); expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); diff --git a/test/stats/config-no/no-stats-with-config.test.js b/test/stats/config-no/no-stats-with-config.test.js index 1c4ab3da1a0..862fdfbac1d 100644 --- a/test/stats/config-no/no-stats-with-config.test.js +++ b/test/stats/config-no/no-stats-with-config.test.js @@ -1,7 +1,6 @@ 'use strict'; -const { run } = require('../../utils/test-utils'); -const { version } = require('webpack'); +const { run, isWebpack5 } = require('../../utils/test-utils'); describe('stats flag', () => { it(`should use stats 'detailed' as defined in webpack config`, () => { @@ -10,10 +9,12 @@ describe('stats flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - if (version.startsWith('5')) { - expect(stdout).toContain(`stats: { preset: 'detailed' }`); + if (isWebpack5) { + expect(stdout).toContain("preset: 'detailed'"); } else { - expect(stdout).toContain(`stats: 'detailed'`); + expect(stdout).toContain('entrypoints: true'); + expect(stdout).toContain('logging: true'); + expect(stdout).toContain('maxModules: Infinity'); } }); @@ -23,10 +24,10 @@ describe('stats flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - if (version.startsWith('5')) { - expect(stdout).toContain(`stats: { preset: 'none' }`); + if (isWebpack5) { + expect(stdout).toContain("preset: 'none'"); } else { - expect(stdout).toContain(`stats: false`); + expect(stdout).toContain('all: false'); } }); }); diff --git a/test/stats/config/index.js b/test/stats/config/index.js index cb15d2ae8df..2457f618e17 100644 --- a/test/stats/config/index.js +++ b/test/stats/config/index.js @@ -1,4 +1 @@ -require('react'); -require('react-dom'); -require('redux'); -require('react-redux'); +console.log('HERE'); diff --git a/test/stats/config/package.json b/test/stats/config/package.json deleted file mode 100644 index e04e6b3419c..00000000000 --- a/test/stats/config/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "dependencies": { - "react": "^16.13.0", - "react-dom": "^16.13.0", - "redux": "^4.0.5", - "react-redux": "^7.2.0" - } -} diff --git a/test/stats/config/stats.test.js b/test/stats/config/stats.test.js index 6d4510b5224..288e4a44249 100644 --- a/test/stats/config/stats.test.js +++ b/test/stats/config/stats.test.js @@ -1,8 +1,6 @@ -/* eslint-disable node/no-extraneous-require */ 'use strict'; -// eslint-disable-next-line node/no-unpublished-require + const { run, isWebpack5 } = require('../../utils/test-utils'); -const { version } = require('webpack'); // 'normal' is used in webpack.config.js const statsPresets = ['detailed', 'errors-only', 'errors-warnings', 'minimal', 'verbose', 'none']; @@ -18,10 +16,10 @@ describe('stats flag with config', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - if (version.startsWith('5')) { - expect(stdout).toContain(`stats: { preset: 'normal' }`); + if (isWebpack5) { + expect(stdout).toContain("preset: 'normal'"); } else { - expect(stdout).toContain(`stats: 'normal'`); + expect(stdout).toContain("stats: 'normal'"); } }); @@ -33,9 +31,38 @@ describe('stats flag with config', () => { expect(stderr).toBeFalsy(); if (isWebpack5) { - expect(stdout).toContain(`stats: { preset: '${preset}' }`); + expect(stdout).toContain(`preset: '${preset}'`); } else { - expect(stdout).toContain(`stats: '${preset}'`); + switch (preset) { + case 'normal': + expect(stdout).toContain('stats:'); + break; + case 'detailed': + expect(stdout).toContain('entrypoints: true'); + expect(stdout).toContain('errorDetails: true'); + break; + case 'errors-only': + expect(stdout).toContain('all: false'); + expect(stdout).toContain('errors: true'); + break; + case 'errors-warnings': + expect(stdout).toContain('all: false'); + expect(stdout).toContain('errors: true'); + expect(stdout).toContain('warnings: true'); + break; + case 'minimal': + expect(stdout).toContain('modules: true'); + expect(stdout).toContain('maxModules: 0'); + break; + case 'verbose': + expect(stdout).toContain("logging: 'verbose'"); + break; + case 'none': + expect(stdout).toContain('all: false'); + break; + default: + expect(stdout).toContain(`preset: '${preset}'`); + } } }); } diff --git a/test/stats/config/webpack.config.js b/test/stats/config/webpack.config.js index 30fb429bbc1..eb8d44f4507 100644 --- a/test/stats/config/webpack.config.js +++ b/test/stats/config/webpack.config.js @@ -1,5 +1,5 @@ -/* eslint-disable node/no-unpublished-require */ const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + module.exports = { mode: 'development', entry: './index.js', diff --git a/test/stats/flags/index.js b/test/stats/flags/index.js index fb8848faae4..2457f618e17 100644 --- a/test/stats/flags/index.js +++ b/test/stats/flags/index.js @@ -1,4 +1 @@ -require('../config/node_modules/react'); -require('../config/node_modules/react-dom'); -require('../config/node_modules/redux'); -require('../config/node_modules/react-redux'); +console.log('HERE'); diff --git a/test/stats/flags/package.json b/test/stats/flags/package.json deleted file mode 100644 index e04e6b3419c..00000000000 --- a/test/stats/flags/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "dependencies": { - "react": "^16.13.0", - "react-dom": "^16.13.0", - "redux": "^4.0.5", - "react-redux": "^7.2.0" - } -} diff --git a/test/stats/flags/stats.test.js b/test/stats/flags/stats.test.js index 0f37921c315..407c237f9f7 100644 --- a/test/stats/flags/stats.test.js +++ b/test/stats/flags/stats.test.js @@ -1,4 +1,3 @@ -/* eslint-disable node/no-unpublished-require */ 'use strict'; const { run, isWebpack5 } = require('../../utils/test-utils'); @@ -18,9 +17,38 @@ describe('stats flag', () => { expect(stderr).toBeFalsy(); if (isWebpack5) { - expect(stdout).toContain(`stats: { preset: '${preset}' }`); + expect(stdout).toContain(`preset: '${preset}'`); } else { - expect(stdout).toContain(`stats: '${preset}'`); + switch (preset) { + case 'normal': + expect(stdout).toContain('stats:'); + break; + case 'detailed': + expect(stdout).toContain('entrypoints: true'); + expect(stdout).toContain('errorDetails: true'); + break; + case 'errors-only': + expect(stdout).toContain('all: false'); + expect(stdout).toContain('errors: true'); + break; + case 'errors-warnings': + expect(stdout).toContain('all: false'); + expect(stdout).toContain('errors: true'); + expect(stdout).toContain('warnings: true'); + break; + case 'minimal': + expect(stdout).toContain('modules: true'); + expect(stdout).toContain('maxModules: 0'); + break; + case 'verbose': + expect(stdout).toContain("logging: 'verbose'"); + break; + case 'none': + expect(stdout).toContain('all: false'); + break; + default: + expect(stdout).toContain(`preset: '${preset}'`); + } } }); } @@ -32,9 +60,9 @@ describe('stats flag', () => { expect(stderr).toBeFalsy(); if (isWebpack5) { - expect(stdout).toContain(`stats: { preset: 'normal' }`); + expect(stdout).toContain("preset: 'normal'"); } else { - expect(stdout).toContain('stats: true'); + expect(stdout).toContain('stats:'); } }); @@ -45,9 +73,9 @@ describe('stats flag', () => { expect(stderr).toBeFalsy(); if (isWebpack5) { - expect(stdout).toContain(`stats: { preset: 'none' }`); + expect(stdout).toContain("preset: 'none'"); } else { - expect(stdout).toContain('stats: false'); + expect(stdout).toContain('all: false'); } }); diff --git a/yarn.lock b/yarn.lock index 3c3af9ca1da..255c7875a6c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8194,18 +8194,25 @@ mime-db@1.44.0: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== -"mime-db@>= 1.43.0 < 2": +mime-db@1.45.0, "mime-db@>= 1.43.0 < 2": version "1.45.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.45.0.tgz#cceeda21ccd7c3a745eba2decd55d4b73e7879ea" integrity sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w== -mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24: +mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24: version "2.1.27" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== dependencies: mime-db "1.44.0" +mime-types@^2.1.27: + version "2.1.28" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.28.tgz#1160c4757eab2c5363888e005273ecf79d2a0ecd" + integrity sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ== + dependencies: + mime-db "1.45.0" + mime@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" @@ -11664,7 +11671,7 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.11.0: +webpack@^5.11.1: version "5.11.1" resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.11.1.tgz#39b2b9daeb5c6c620e03b7556ec674eaed4016b4" integrity sha512-tNUIdAmYJv+nupRs/U/gqmADm6fgrf5xE+rSlSsf2PgsGO7j2WG7ccU6AWNlOJlHFl+HnmXlBmHIkiLf+XA9mQ== From eb7b18937d045261a5b20ca8356e8b4ae4dfcaad Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 6 Jan 2021 22:24:42 +0530 Subject: [PATCH 231/581] feat: new `configtest` command (#2303) --- .eslintignore | 1 + .prettierignore | 1 + OPTIONS.md | 7 ++-- packages/configtest/package.json | 18 ++++++++ packages/configtest/src/index.ts | 54 ++++++++++++++++++++++++ packages/configtest/tsconfig.json | 8 ++++ packages/webpack-cli/README.md | 19 +++++---- packages/webpack-cli/lib/webpack-cli.js | 5 +++ packages/webpack-cli/package.json | 3 ++ test/configtest/configtest.test.js | 55 +++++++++++++++++++++++++ test/configtest/error.config.js | 5 +++ test/configtest/src/index.js | 1 + test/configtest/syntax-error.config.js | 5 +++ test/configtest/webpack.config.js | 5 +++ test/help/help.test.js | 1 + tsconfig.json | 27 +++++++++--- 16 files changed, 197 insertions(+), 18 deletions(-) create mode 100644 packages/configtest/package.json create mode 100644 packages/configtest/src/index.ts create mode 100644 packages/configtest/tsconfig.json create mode 100644 test/configtest/configtest.test.js create mode 100644 test/configtest/error.config.js create mode 100644 test/configtest/src/index.js create mode 100644 test/configtest/syntax-error.config.js create mode 100644 test/configtest/webpack.config.js diff --git a/.eslintignore b/.eslintignore index ec220a0fdec..97edf222a8a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,3 +10,4 @@ test/typescript/webpack.config.ts test/config/error-commonjs/syntax-error.js test/config/error-mjs/syntax-error.mjs test/config/error-array/webpack.config.js +test/configtest/syntax-error.config.js diff --git a/.prettierignore b/.prettierignore index 7b3b7544c17..8f68c1e421c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,3 +9,4 @@ test/config/error-mjs/syntax-error.mjs packages/webpack-cli/__tests__/test-assets/.yo-rc.json test/build-errors/stats.json packages/**/lib +test/configtest/syntax-error.config.js diff --git a/OPTIONS.md b/OPTIONS.md index bf4cd0ba68f..c8b1025d4a8 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -549,7 +549,7 @@ Options: --watch-options-ignored-reset Clear all items provided in configuration. Ignore some files from watching (glob pattern or regexp). --watch-options-poll `number`: use polling with specified interval. `true`: use polling. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. Global options: --color Enable colors on console. @@ -559,14 +559,15 @@ Global options: Commands: bundle|b [options] Run webpack (default command, can be omitted). - help|h Display help for commands and options. version|v Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + help|h Display help for commands and options. serve|s [options] Run the webpack dev server. info|i [options] Outputs information about your system. init|c [options] [scaffold...] Initialize a new webpack configuration. loader|l [output-path] Scaffold a loader. - plugin|p [output-path] Scaffold a plugin. migrate|m [new-config-path] Migrate a configuration to a new version. + configtest|t Tests webpack configuration against validation errors. + plugin|p [output-path] Scaffold a plugin. To see list of all supported commands and options run 'webpack --help=verbose'. diff --git a/packages/configtest/package.json b/packages/configtest/package.json new file mode 100644 index 00000000000..6b0857083b0 --- /dev/null +++ b/packages/configtest/package.json @@ -0,0 +1,18 @@ +{ + "name": "@webpack-cli/configtest", + "version": "1.0.0", + "description": "Tests webpack configuration against validation errors.", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "files": [ + "lib" + ], + "peerDependencies": { + "webpack": "4.x.x || 5.x.x", + "webpack-cli": "4.x.x" + } +} diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts new file mode 100644 index 00000000000..45cd643aacb --- /dev/null +++ b/packages/configtest/src/index.ts @@ -0,0 +1,54 @@ +import webpack from 'webpack'; + +class ConfigTestCommand { + async apply(cli): Promise { + const { logger } = cli; + + await cli.makeCommand( + { + name: 'configtest ', + alias: 't', + description: 'Tests webpack configuration against validation errors.', + usage: '', + pkg: '@webpack-cli/configtest', + }, + [], + async (configPath: string): Promise => { + const config = await cli.resolveConfig({ config: [configPath] }); + + try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const error: any = webpack.validate(config.options); + + // TODO remove this after drop webpack@4 + if (error && error.length > 0) { + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // @ts-ignore + throw new webpack.WebpackOptionsValidationError(error); + } + } catch (error) { + const isValidationError = (error) => { + // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 + // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const ValidationError = (webpack.ValidationError || webpack.WebpackOptionsValidationError) as any; + + return error instanceof ValidationError; + }; + + if (isValidationError(error)) { + logger.error(error.message); + } else { + logger.error(error); + } + + process.exit(2); + } + + logger.success('There are no validation errors in the given webpack configuration.'); + }, + ); + } +} + +export default ConfigTestCommand; diff --git a/packages/configtest/tsconfig.json b/packages/configtest/tsconfig.json new file mode 100644 index 00000000000..279b3e923cc --- /dev/null +++ b/packages/configtest/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib", + "rootDir": "./src" + }, + "include": ["./src"] +} diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index e0193dbd4d9..788802545db 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -63,15 +63,16 @@ npx webpack-cli --help verbose ### Available Commands ``` - bundle | b Run webpack - help | h Display help for commands and options - version | v Output version number of the 'webpack', 'webpack-cli' and other related packages - init | c Initialize a new webpack configuration - migrate | m Migrate a configuration to a new version - loader | l Scaffold a loader repository - plugin | p Scaffold a plugin repository - info | i Outputs information about your system and dependencies - serve | s Run the webpack Dev Server + bundle | b Run webpack + help | h Display help for commands and options + version | v Output version number of the 'webpack', 'webpack-cli' and other related packages + init | c Initialize a new webpack configuration + migrate | m Migrate a configuration to a new version + loader | l Scaffold a loader repository + plugin | p Scaffold a plugin repository + info | i Outputs information about your system and dependencies + serve | s Run the webpack Dev Server + configtest | t Tests webpack configuration against validation errors. ``` ### webpack 4 diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index e8e83ca8128..78e8d07cdab 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -279,6 +279,11 @@ class WebpackCLI { alias: 'm', pkg: '@webpack-cli/migrate', }, + { + name: 'configtest', + alias: 't', + pkg: '@webpack-cli/configtest', + }, ]; const knownCommands = [bundleCommandOptions, versionCommandOptions, helpCommandOptions, ...externalBuiltInCommandsInfo]; diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index d03d1ab2d84..148ac8df7bb 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -54,6 +54,9 @@ "@webpack-cli/migrate": { "optional": true }, + "@webpack-cli/configtest": { + "optional": true + }, "webpack-bundle-analyzer": { "optional": true }, diff --git a/test/configtest/configtest.test.js b/test/configtest/configtest.test.js new file mode 100644 index 00000000000..8d88f8e62dc --- /dev/null +++ b/test/configtest/configtest.test.js @@ -0,0 +1,55 @@ +'use strict'; + +const { run } = require('../utils/test-utils'); + +describe('basic info usage', () => { + it('should validate webpack config successfully', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './webpack.config.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('There are no validation errors in the given webpack configuration.'); + }); + + it('should throw validation error', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './error.config.js'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Invalid configuration object.'); + expect(stderr).toContain('configuration.mode should be one of these:'); + expect(stdout).toBeFalsy(); + }); + + it('should throw syntax error', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './syntax-error.config.js'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`SyntaxError: Unexpected token ';'`); + expect(stdout).toBeFalsy(); + }); + + it(`should validate the config with alias 't'`, () => { + const { exitCode, stderr, stdout } = run(__dirname, ['t', './error.config.js'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Invalid configuration object.'); + expect(stderr).toContain('configuration.mode should be one of these:'); + expect(stdout).toBeFalsy(); + }); + + it('should throw error if configuration does not exist', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './a.js'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`The specified config file doesn't exist`); + expect(stdout).toBeFalsy(); + }); + + it('should throw error if no configuration was provided', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain(`error: missing required argument 'config-path'`); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/configtest/error.config.js b/test/configtest/error.config.js new file mode 100644 index 00000000000..8e614cbed23 --- /dev/null +++ b/test/configtest/error.config.js @@ -0,0 +1,5 @@ +module.exports = { + mode: 'dev', // error + target: 'node', + stats: 'normal', +}; diff --git a/test/configtest/src/index.js b/test/configtest/src/index.js new file mode 100644 index 00000000000..95ef2d52163 --- /dev/null +++ b/test/configtest/src/index.js @@ -0,0 +1 @@ +console.log('configtest command'); diff --git a/test/configtest/syntax-error.config.js b/test/configtest/syntax-error.config.js new file mode 100644 index 00000000000..96fc2e63b73 --- /dev/null +++ b/test/configtest/syntax-error.config.js @@ -0,0 +1,5 @@ +module.exports = { + name: 'config-error', + mode: 'development', + target: 'node'; //SyntaxError: Unexpected token ';' +}; diff --git a/test/configtest/webpack.config.js b/test/configtest/webpack.config.js new file mode 100644 index 00000000000..bdaebdb6f26 --- /dev/null +++ b/test/configtest/webpack.config.js @@ -0,0 +1,5 @@ +module.exports = { + mode: 'development', + target: 'node', + stats: 'verbose', +}; diff --git a/test/help/help.test.js b/test/help/help.test.js index 15126bb04bc..41be8093ff5 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -28,6 +28,7 @@ describe('help', () => { expect(stdout.match(/loader\|l/g)).toHaveLength(1); expect(stdout.match(/migrate\|m/g)).toHaveLength(1); expect(stdout.match(/plugin\|p/g)).toHaveLength(1); + expect(stdout.match(/configtest\|t/g)).toHaveLength(1); expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); // TODO buggy on windows diff --git a/tsconfig.json b/tsconfig.json index 2a8277f0cfb..9062547bfb5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,11 +20,26 @@ "declaration": true }, "references": [ - { "path": "packages/generators" }, - { "path": "packages/info" }, - { "path": "packages/init" }, - { "path": "packages/migrate" }, - { "path": "packages/serve" }, - { "path": "packages/utils" } + { + "path": "packages/generators" + }, + { + "path": "packages/info" + }, + { + "path": "packages/init" + }, + { + "path": "packages/migrate" + }, + { + "path": "packages/serve" + }, + { + "path": "packages/utils" + }, + { + "path": "packages/configtest" + } ] } From 9a74ad08b984325a63d953c685496e48700a2caf Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Wed, 6 Jan 2021 22:45:26 +0530 Subject: [PATCH 232/581] feat: flexible init scaffolding (#2311) * feat: flexible init scaffolding --- INIT.md | 14 ++++++++ .../__snapshots__/init-generator.test.ts.snap | 33 ++++++++++++++----- packages/generators/src/init-generator.ts | 31 ++++++++++++----- test/init/force/init-force.test.js | 6 +++- test/init/generator/init-inquirer.test.js | 2 +- .../language/css/init-language-css.test.js | 2 +- .../init/language/js/init-language-js.test.js | 6 +++- .../init-multipleEntries.test.js | 6 +++- 8 files changed, 79 insertions(+), 21 deletions(-) diff --git a/INIT.md b/INIT.md index 8cf285c332b..fed6af945fd 100644 --- a/INIT.md +++ b/INIT.md @@ -135,3 +135,17 @@ If you use any sort of style in your project, such as [`.less`](http://lesscss.o 6. `If you want to bundle your CSS files, what will you name the bundle? (press enter to skip)` If you indicate based on previous questions that you are using production, this will be enabled. The default value for your generated CSS file is `style.[contentHash].css`, which will collect all your `.less`, `.scss` or `.css` into one file. This will make your build faster in production. + +7. `Do you want to use webpack-dev-server?` + +> _Property/key resolved: [module.rules](https://webpack.js.org/configuration/dev-server/)_ + +Adds a development server to serve webpack bundles and hence make development faster. + +8. `Do you want to simplify the creation of HTML files for your bundle?` + +Adds `html-webpack-plugin` that simplifies creation of HTML files to serve your bundles. + +9. `Do you want to add PWA support?` + +Adds `workbox-webpack-plugin` which generates a complete service worker for you and one that generates a list of assets to precache that is injected into a service worker file. diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index d9036b1abe2..153e10c18aa 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -2,6 +2,10 @@ exports[`init generator generates a webpack config that uses ES6 1`] = ` Object { + "devServer": Object { + "host": "localhost", + "open": true, + }, "mode": "'development'", "module": Object { "rules": Array [ @@ -22,6 +26,10 @@ Object { exports[`init generator generates a webpack config that uses Typescript 1`] = ` Object { + "devServer": Object { + "host": "localhost", + "open": true, + }, "entry": "'./src/index.ts'", "mode": "'development'", "module": Object { @@ -68,6 +76,10 @@ Object { exports[`init generator generates a webpack config using CSS with mini-css-extract-plugin 1`] = ` Object { + "devServer": Object { + "host": "localhost", + "open": true, + }, "mode": "'development'", "module": Object { "rules": Array [ @@ -96,6 +108,10 @@ Object { exports[`init generator generates a webpack config using CSS without mini-css-extract-plugin 1`] = ` Object { + "devServer": Object { + "host": "localhost", + "open": true, + }, "mode": "'development'", "module": Object { "rules": Array [ @@ -123,6 +139,10 @@ Object { exports[`init generator generates a webpack config with custom entry and output 1`] = ` Object { + "devServer": Object { + "host": "localhost", + "open": true, + }, "entry": "'./src/index2.js'", "mode": "'development'", "module": Object { @@ -140,6 +160,7 @@ Object { exports[`init generator generates a webpack config with default options 1`] = ` Object { "devServer": Object { + "host": "localhost", "open": true, }, "mode": "'production'", @@ -148,20 +169,16 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new HtmlWebpackPlugin({ - template: 'index.html' - })", - "new workboxPlugin.GenerateSW({ - swDest: 'sw.js', - clientsClaim: true, - skipWaiting: false, - })", ], } `; exports[`init generator generates a webpack config with multiple entries 1`] = ` Object { + "devServer": Object { + "host": "localhost", + "open": true, + }, "entry": Object { "test1": "'./dir1/test1.js'", "test2": "'./dir2/test2.js'", diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 79aaddaa6de..0c5af323f75 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -183,7 +183,25 @@ export default class InitGenerator extends CustomGenerator { use: ExtractUseProps, }); } - if (this.usingDefaults) { + + // webpack Dev Server + const { useDevServer } = await Confirm(self, 'useDevServer', 'Do you want to use webpack-dev-server?', true, this.usingDefaults); + if (useDevServer) { + this.dependencies.push('webpack-dev-server'); + this.configuration.config.webpackOptions.devServer = { + open: true, + host: 'localhost', + }; + } + + const { useHTMLPlugin } = await Confirm( + self, + 'useHTMLPlugin', + 'Do you want to simplify the creation of HTML files for your bundle?', + false, + this.usingDefaults, + ); + if (useHTMLPlugin) { // Html webpack Plugin this.dependencies.push('html-webpack-plugin'); const htmlWebpackDependency = 'html-webpack-plugin'; @@ -196,14 +214,11 @@ export default class InitGenerator extends CustomGenerator { (this.configuration.config.webpackOptions.plugins as string[]).push(`new ${htmlwebpackPlugin}({ template: 'index.html' })`); + } - // webpack Dev Server - this.dependencies.push('webpack-dev-server'); - this.configuration.config.webpackOptions.devServer = { - open: true, - }; - - // PWA + offline support + const { useWorkboxPlugin } = await Confirm(self, 'useDevServer', 'Do you want to add PWA support?', true, this.usingDefaults); + // webpack Dev Server + if (useWorkboxPlugin) { this.configuration.config.topScope.push("const workboxPlugin = require('workbox-webpack-plugin');", '\n'); this.dependencies.push('workbox-webpack-plugin'); (this.configuration.config.webpackOptions.plugins as string[]).push(`new workboxPlugin.GenerateSW({ diff --git a/test/init/force/init-force.test.js b/test/init/force/init-force.test.js index 81be3543f84..263110d005c 100644 --- a/test/init/force/init-force.test.js +++ b/test/init/force/init-force.test.js @@ -19,7 +19,11 @@ describe('init force flag', () => { }); it('should scaffold webpack config', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init', '--force'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers( + genPath, + ['init', '--force'], + [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER], + ); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 352dfd8ff99..69cf728ddab 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -19,7 +19,7 @@ describe('init', () => { }); it('should scaffold when given answers', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER]); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index 43ed62fd16c..c36648b7aa2 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -20,7 +20,7 @@ describe('init with SCSS', () => { const { stdout } = await runPromptWithAnswers( genPath, ['init'], - [`N${ENTER}`, ENTER, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, `Y${ENTER}`, `apple${ENTER}`], + [`N${ENTER}`, ENTER, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, `Y${ENTER}`, `apple${ENTER}`, ENTER, ENTER, ENTER], ); expect(stdout).toBeTruthy(); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index aed626f6ad3..17094f65a87 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -17,7 +17,11 @@ describe('init with Typescript', () => { }); it('should use typescript', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, ENTER]); + const { stdout } = await runPromptWithAnswers( + genPath, + ['init'], + [`N${ENTER}`, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, ENTER, ENTER, ENTER, ENTER], + ); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 512934fee34..6f1db08984a 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -16,7 +16,11 @@ describe('init with multiple entries', () => { }); it('should scaffold with multiple entries', async () => { - const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]); + const { stdout } = await runPromptWithAnswers( + genPath, + ['init'], + [`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER], + ); expect(stdout).toBeTruthy(); expect(stdout).toContain(firstPrompt); From 50bbe56c0ae9d72301c4ac51fdc2b04df7b66451 Mon Sep 17 00:00:00 2001 From: James George Date: Fri, 8 Jan 2021 08:00:52 +0530 Subject: [PATCH 233/581] fix: regression with webpack config (#2319) --- .../__snapshots__/init-generator.test.ts.snap | 49 ++++++++++++++++--- packages/generators/src/init-generator.ts | 6 ++- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index 153e10c18aa..6e4bf0722ca 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -3,7 +3,7 @@ exports[`init generator generates a webpack config that uses ES6 1`] = ` Object { "devServer": Object { - "host": "localhost", + "host": "'localhost'", "open": true, }, "mode": "'development'", @@ -20,6 +20,11 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", ], } `; @@ -27,7 +32,7 @@ Object { exports[`init generator generates a webpack config that uses Typescript 1`] = ` Object { "devServer": Object { - "host": "localhost", + "host": "'localhost'", "open": true, }, "entry": "'./src/index.ts'", @@ -48,6 +53,11 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", ], "resolve": Object { "extensions": Array [ @@ -77,7 +87,7 @@ Object { exports[`init generator generates a webpack config using CSS with mini-css-extract-plugin 1`] = ` Object { "devServer": Object { - "host": "localhost", + "host": "'localhost'", "open": true, }, "mode": "'development'", @@ -102,6 +112,11 @@ Object { "plugins": Array [ "new webpack.ProgressPlugin()", "new MiniCssExtractPlugin({ filename:'main.[contenthash].css' })", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", ], } `; @@ -109,7 +124,7 @@ Object { exports[`init generator generates a webpack config using CSS without mini-css-extract-plugin 1`] = ` Object { "devServer": Object { - "host": "localhost", + "host": "'localhost'", "open": true, }, "mode": "'development'", @@ -133,6 +148,11 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", ], } `; @@ -140,7 +160,7 @@ Object { exports[`init generator generates a webpack config with custom entry and output 1`] = ` Object { "devServer": Object { - "host": "localhost", + "host": "'localhost'", "open": true, }, "entry": "'./src/index2.js'", @@ -153,6 +173,11 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", ], } `; @@ -160,7 +185,7 @@ Object { exports[`init generator generates a webpack config with default options 1`] = ` Object { "devServer": Object { - "host": "localhost", + "host": "'localhost'", "open": true, }, "mode": "'production'", @@ -169,6 +194,11 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", ], } `; @@ -176,7 +206,7 @@ Object { exports[`init generator generates a webpack config with multiple entries 1`] = ` Object { "devServer": Object { - "host": "localhost", + "host": "'localhost'", "open": true, }, "entry": Object { @@ -189,6 +219,11 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", ], } `; diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 0c5af323f75..6cefa9cecfd 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -51,6 +51,8 @@ export default class InitGenerator extends CustomGenerator { this.entryOption = './src/index.js'; + this.configuration.config.topScope.push("const path = require('path');", "const webpack = require('webpack');", '\n'); + (this.configuration.config.webpackOptions.plugins as string[]).push('new webpack.ProgressPlugin()'); } @@ -190,7 +192,7 @@ export default class InitGenerator extends CustomGenerator { this.dependencies.push('webpack-dev-server'); this.configuration.config.webpackOptions.devServer = { open: true, - host: 'localhost', + host: "'localhost'", }; } @@ -216,7 +218,7 @@ export default class InitGenerator extends CustomGenerator { })`); } - const { useWorkboxPlugin } = await Confirm(self, 'useDevServer', 'Do you want to add PWA support?', true, this.usingDefaults); + const { useWorkboxPlugin } = await Confirm(self, 'useWorkboxPlugin', 'Do you want to add PWA support?', true, this.usingDefaults); // webpack Dev Server if (useWorkboxPlugin) { this.configuration.config.topScope.push("const workboxPlugin = require('workbox-webpack-plugin');", '\n'); From 249fdd3943a8f81c043e61d1f08b266909cfaab7 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Fri, 8 Jan 2021 16:28:10 +0530 Subject: [PATCH 234/581] tests: multi compiler CLI plugin test (#2329) --- .../__tests__/applyCLIPlugin.test.js | 32 +++++++++++++++++++ packages/webpack-cli/lib/webpack-cli.js | 13 ++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/packages/webpack-cli/__tests__/applyCLIPlugin.test.js b/packages/webpack-cli/__tests__/applyCLIPlugin.test.js index f23c038108d..7c90277c5a1 100644 --- a/packages/webpack-cli/__tests__/applyCLIPlugin.test.js +++ b/packages/webpack-cli/__tests__/applyCLIPlugin.test.js @@ -16,4 +16,36 @@ describe('CLIPluginResolver', () => { analyze: undefined, }); }); + + it('should add CLI plugin to multi compiler object', async () => { + const result = await applyCLIPlugin({ options: [{}, {}] }, { hot: true, prefetch: true }); + expect(result.options[0].plugins[0] instanceof CLIPlugin).toBeTruthy(); + expect(result.options[1].plugins[0] instanceof CLIPlugin).toBeTruthy(); + expect(result.options).toEqual([ + { + plugins: [ + new CLIPlugin({ + configPath: undefined, + helpfulOutput: true, + hot: true, + progress: undefined, + prefetch: true, + analyze: undefined, + }), + ], + }, + { + plugins: [ + new CLIPlugin({ + configPath: undefined, + helpfulOutput: true, + hot: true, + progress: undefined, + prefetch: true, + analyze: undefined, + }), + ], + }, + ]); + }); }); diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 78e8d07cdab..cae401941d8 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1169,7 +1169,7 @@ class WebpackCLI { return config; } - async applyCLIPlugin(config, options) { + async applyCLIPlugin(config, cliOptions) { const addCLIPlugin = (configOptions) => { if (!configOptions.plugins) { configOptions.plugins = []; @@ -1178,17 +1178,16 @@ class WebpackCLI { configOptions.plugins.unshift( new CLIPlugin({ configPath: config.path, - helpfulOutput: !options.json, - hot: options.hot, - progress: options.progress, - prefetch: options.prefetch, - analyze: options.analyze, + helpfulOutput: !cliOptions.json, + hot: cliOptions.hot, + progress: cliOptions.progress, + prefetch: cliOptions.prefetch, + analyze: cliOptions.analyze, }), ); return configOptions; }; - config.options = Array.isArray(config.options) ? config.options.map((options) => addCLIPlugin(options)) : addCLIPlugin(config.options); From ae0c35a7cdf3409b5ecd6000574cd8ecd42ae9d8 Mon Sep 17 00:00:00 2001 From: James George Date: Fri, 8 Jan 2021 17:25:31 +0530 Subject: [PATCH 235/581] chore: remove stale helpers (#2327) --- packages/generators/src/utils/tooltip.ts | 25 ------------------------ 1 file changed, 25 deletions(-) diff --git a/packages/generators/src/utils/tooltip.ts b/packages/generators/src/utils/tooltip.ts index 39fa8289066..c888dc7d141 100644 --- a/packages/generators/src/utils/tooltip.ts +++ b/packages/generators/src/utils/tooltip.ts @@ -18,21 +18,6 @@ export default { */`; }, - splitChunks: (): string => { - return `/* - * SplitChunksPlugin is enabled by default and replaced - * deprecated CommonsChunkPlugin. It automatically identifies modules which - * should be splitted of chunk by heuristics using module duplication count and - * module category (i. e. node_modules). And splits the chunks… - * - * It is safe to remove "splitChunks" from the generated configuration - * and was added as an educational example. - * - * https://webpack.js.org/plugins/split-chunks-plugin/ - * - */`; - }, - postcss: (): string => { return `/* * We've enabled Postcss, autoprefixer and precss for you. This allows your app @@ -50,16 +35,6 @@ export default { */`; }, - terser: (): string => { - return `/* - * We've enabled TerserPlugin for you! This minifies your app - * in order to load faster and run less javascript. - * - * https://github.com/webpack-contrib/terser-webpack-plugin - * - */`; - }, - html: (): string => { return `/* * We've enabled HtmlWebpackPlugin for you! This generates a html From 346e879f40265b10052a564a399c0fe87731ef03 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 8 Jan 2021 21:25:32 +0530 Subject: [PATCH 236/581] refactor: fix typesript types and warnings (#2330) --- packages/serve/src/startDevServer.ts | 7 ++++--- packages/serve/src/types.ts | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index f6a825654df..ccdd113c970 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -67,8 +67,9 @@ export default async function startDevServer(compiler, devServerCliOptions, cliO options.client = options.client || {}; options.client.port = options.client.port || options.port; } else { - const getPublicPathOption = () => { - const normalizePublicPath = (publicPath) => (typeof publicPath === 'undefined' || publicPath === 'auto' ? '/' : publicPath); + const getPublicPathOption = (): string => { + const normalizePublicPath = (publicPath): string => + typeof publicPath === 'undefined' || publicPath === 'auto' ? '/' : publicPath; if (cliOptions.outputPublicPath) { return normalizePublicPath(compilerWithDevServerOption.options.output.publicPath); @@ -86,7 +87,7 @@ export default async function startDevServer(compiler, devServerCliOptions, cliO return normalizePublicPath(compilerWithDevServerOption.options.output.publicPath); }; - const getStatsOption = () => { + const getStatsOption = (): string | boolean => { if (cliOptions.stats) { return compilerWithDevServerOption.options.stats; } diff --git a/packages/serve/src/types.ts b/packages/serve/src/types.ts index 1876f21a990..1f573e2364d 100644 --- a/packages/serve/src/types.ts +++ b/packages/serve/src/types.ts @@ -28,9 +28,8 @@ export type devServerOptionsType = { static?: boolean | string | object | (string | object)[]; transportMode?: object | string; useLocalIp?: boolean; - publicPath?: undefined; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - stats?: any; + publicPath?: string | Function; + stats?: string | boolean; }; type devServerClientOptions = { From a4765ab98008023c980b5c6c36135f1561d1702f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 8 Jan 2021 19:03:59 +0300 Subject: [PATCH 237/581] chore(deps-dev): bump @types/jest from 26.0.19 to 26.0.20 (#2323) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.19 to 26.0.20. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 255c7875a6c..4304ab16717 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2399,9 +2399,9 @@ "@types/istanbul-lib-report" "*" "@types/jest@26.x", "@types/jest@^26.0.15": - version "26.0.19" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.19.tgz#e6fa1e3def5842ec85045bd5210e9bb8289de790" - integrity sha512-jqHoirTG61fee6v6rwbnEuKhpSKih0tuhqeFbCmMmErhtu3BYlOZaXWjffgOstMM4S/3iQD31lI5bGLTrs97yQ== + version "26.0.20" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.20.tgz#cd2f2702ecf69e86b586e1f5223a60e454056307" + integrity sha512-9zi2Y+5USJRxd0FsahERhBwlcvFh6D2GLQnY2FH2BzK8J9s9omvNHIbvABwIluXa0fD8XVKMLTO0aOEuUfACAA== dependencies: jest-diff "^26.0.0" pretty-format "^26.0.0" From d1e499c0d508c2e61fdb3fdf10f4ed8efb2606e8 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Fri, 8 Jan 2021 21:47:07 +0530 Subject: [PATCH 238/581] fix: create sourcemaps on ci (#2321) --- .github/workflows/nodejs.yml | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 1b35592abc6..c5787566709 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -88,7 +88,7 @@ jobs: run: yarn add -W webpack@${{ matrix.webpack-version }} - name: Build - run: yarn build + run: yarn build:ci - name: Test and Generate Coverage run: | diff --git a/package.json b/package.json index 2da9bb158d7..36bbcddaf28 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "prebuild": "yarn clean", "prebuild:ci": "yarn clean && node ./scripts/setupBuild.js", "build": "tsc --build", + "build:ci": "tsc --build", "watch": "tsc --build --watch", "commit": "git-cz", "lint:prettier": "prettier --list-different . \"!**/*.{js,ts}\" ", From 5266657a6bb4cff8688fd1632378b67d29f6ac65 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Fri, 8 Jan 2021 21:55:34 +0530 Subject: [PATCH 239/581] chore: remove legacy tooling (#2326) --- .babelrc | 12 - package.json | 2 - yarn.lock | 633 ++------------------------------------------------- 3 files changed, 19 insertions(+), 628 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 72009cef1f8..00000000000 --- a/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "node": "current" - } - } - ] - ] -} diff --git a/package.json b/package.json index 36bbcddaf28..ff220211e8a 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,6 @@ "webpack": "4.x.x || 5.x.x" }, "devDependencies": { - "@babel/core": "^7.12.3", - "@babel/preset-env": "^7.12.1", "@commitlint/cli": "^11.0.0", "@commitlint/config-lerna-scopes": "^11.0.0", "@types/jest": "^26.0.15", diff --git a/yarn.lock b/yarn.lock index 4304ab16717..24e3a00612c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9,12 +9,7 @@ dependencies: "@babel/highlight" "^7.10.4" -"@babel/compat-data@^7.12.5", "@babel/compat-data@^7.12.7": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.7.tgz#9329b4782a7d6bbd7eef57e11addf91ee3ef1e41" - integrity sha512-YaxPMGs/XIWtYqrdEOZOCPsVWfEoriXopnsz3/i7apYPXQ3698UFhS6dVT1KN5qOsWmVgw/FOrmQgpRaZayGsw== - -"@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.12.3", "@babel/core@^7.7.5": +"@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.7.5": version "7.12.10" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.10.tgz#b79a2e1b9f70ed3d84bbfb6d8c4ef825f606bccd" integrity sha512-eTAlQKq65zHfkHZV0sIVODCPGVgoo1HdBlbSLi9CqOzuZanMv2ihzY+4paiKr1mH+XmYESMAmJ/dpZ68eN6d8w== @@ -44,31 +39,6 @@ jsesc "^2.5.1" source-map "^0.5.0" -"@babel/helper-annotate-as-pure@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz#5bf0d495a3f757ac3bda48b5bf3b3ba309c72ba3" - integrity sha512-XQlqKQP4vXFB7BN8fEEerrmYvHp3fK/rBkRFz9jaJbzK0B1DSfej9Kc7ZzE8Z/OnId1jpJdNAZ3BFQjWG68rcA== - dependencies: - "@babel/types" "^7.10.4" - -"@babel/helper-builder-binary-assignment-operator-visitor@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.10.4.tgz#bb0b75f31bf98cbf9ff143c1ae578b87274ae1a3" - integrity sha512-L0zGlFrGWZK4PbT8AszSfLTM5sDU1+Az/En9VrdT8/LmEiJt4zXt+Jve9DCAnQcbqDhCI+29y/L93mrDzddCcg== - dependencies: - "@babel/helper-explode-assignable-expression" "^7.10.4" - "@babel/types" "^7.10.4" - -"@babel/helper-compilation-targets@^7.12.5": - version "7.12.5" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.12.5.tgz#cb470c76198db6a24e9dbc8987275631e5d29831" - integrity sha512-+qH6NrscMolUlzOYngSBMIOQpKUGPPsc61Bu5W10mg84LxZ7cmvnBHzARKbDoFxVvqqAbj6Tg6N7bSrWSPXMyw== - dependencies: - "@babel/compat-data" "^7.12.5" - "@babel/helper-validator-option" "^7.12.1" - browserslist "^4.14.5" - semver "^5.5.0" - "@babel/helper-create-class-features-plugin@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.1.tgz#3c45998f431edd4a9214c5f1d3ad1448a6137f6e" @@ -80,31 +50,6 @@ "@babel/helper-replace-supers" "^7.12.1" "@babel/helper-split-export-declaration" "^7.10.4" -"@babel/helper-create-regexp-features-plugin@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.12.1.tgz#18b1302d4677f9dc4740fe8c9ed96680e29d37e8" - integrity sha512-rsZ4LGvFTZnzdNZR5HZdmJVuXK8834R5QkF3WvcnBhrlVtF0HSIUC6zbreL9MgjTywhKokn8RIYRiq99+DLAxA== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-regex" "^7.10.4" - regexpu-core "^4.7.1" - -"@babel/helper-define-map@^7.10.4": - version "7.10.5" - resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.10.5.tgz#b53c10db78a640800152692b13393147acb9bb30" - integrity sha512-fMw4kgFB720aQFXSVaXr79pjjcW5puTCM16+rECJ/plGS+zByelE8l9nCpV1GibxTnFVmUuYG9U8wYfQHdzOEQ== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/types" "^7.10.5" - lodash "^4.17.19" - -"@babel/helper-explode-assignable-expression@^7.10.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.12.1.tgz#8006a466695c4ad86a2a5f2fb15b5f2c31ad5633" - integrity sha512-dmUwH8XmlrUpVqgtZ737tK88v07l840z9j3OEhCLwKTkjlvKpfqXVIZ0wpK3aeOxspwGrf/5AP5qLx4rO3w5rA== - dependencies: - "@babel/types" "^7.12.1" - "@babel/helper-function-name@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz#d2d3b20c59ad8c47112fa7d2a94bc09d5ef82f1a" @@ -121,13 +66,6 @@ dependencies: "@babel/types" "^7.10.4" -"@babel/helper-hoist-variables@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.10.4.tgz#d49b001d1d5a68ca5e6604dda01a6297f7c9381e" - integrity sha512-wljroF5PgCk2juF69kanHVs6vrLwIPNp6DLD+Lrl3hoQ3PpPPikaDRNFA+0t81NOoMt2DL6WW/mdU8k4k6ZzuA== - dependencies: - "@babel/types" "^7.10.4" - "@babel/helper-member-expression-to-functions@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.1.tgz#fba0f2fcff3fba00e6ecb664bb5e6e26e2d6165c" @@ -135,7 +73,7 @@ dependencies: "@babel/types" "^7.12.1" -"@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.12.5": +"@babel/helper-module-imports@^7.12.1": version "7.12.5" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.5.tgz#1bfc0229f794988f76ed0a4d4e90860850b54dfb" integrity sha512-SR713Ogqg6++uexFRORf/+nPXMmWIn80TALu0uaFb+iQIUoR7bOC7zBWyzBs5b3tBBJXuyD0cRu1F15GyzjOWA== @@ -164,27 +102,11 @@ dependencies: "@babel/types" "^7.10.4" -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.8.0": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375" integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg== -"@babel/helper-regex@^7.10.4": - version "7.10.5" - resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.10.5.tgz#32dfbb79899073c415557053a19bd055aae50ae0" - integrity sha512-68kdUAzDrljqBrio7DYAEgCoJHxppJOERHOgOrDN7WjOzP0ZQ1LsSDRXcemzVZaLvjaJsJEESb6qt+znNuENDg== - dependencies: - lodash "^4.17.19" - -"@babel/helper-remap-async-to-generator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.12.1.tgz#8c4dbbf916314f6047dc05e6a2217074238347fd" - integrity sha512-9d0KQCRM8clMPcDwo8SevNs+/9a8yWVVmaE80FGJcEP8N1qToREmWEGnBn8BUlJhYRFz6fqxeRL1sl5Ogsed7A== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-wrap-function" "^7.10.4" - "@babel/types" "^7.12.1" - "@babel/helper-replace-supers@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.12.1.tgz#f15c9cc897439281891e11d5ce12562ac0cf3fa9" @@ -226,21 +148,6 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed" integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw== -"@babel/helper-validator-option@^7.12.1", "@babel/helper-validator-option@^7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.12.11.tgz#d66cb8b7a3e7fe4c6962b32020a131ecf0847f4f" - integrity sha512-TBFCyj939mFSdeX7U7DDj32WtzYY7fDcalgq8v3fBZMNOJQNn7nOYzMaUCiPxPYfCup69mtIpqlKgMZLvQ8Xhw== - -"@babel/helper-wrap-function@^7.10.4": - version "7.12.3" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.12.3.tgz#3332339fc4d1fbbf1c27d7958c27d34708e990d9" - integrity sha512-Cvb8IuJDln3rs6tzjW3Y8UeelAOdnpB8xtQ4sme2MSZ9wOxrbThporC0y/EtE16VAtoyEfLM404Xr1e0OOp+ow== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/template" "^7.10.4" - "@babel/traverse" "^7.10.4" - "@babel/types" "^7.10.4" - "@babel/helpers@^7.12.5": version "7.12.5" resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.12.5.tgz#1a1ba4a768d9b58310eda516c449913fe647116e" @@ -264,16 +171,7 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.10.tgz#824600d59e96aea26a5a2af5a9d812af05c3ae81" integrity sha512-PJdRPwyoOqFAWfLytxrWwGrAxghCgh/yTNCYciOz8QgjflA7aZhECPZAa2VUedKg2+QMWkI0L9lynh2SNmNEgA== -"@babel/plugin-proposal-async-generator-functions@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.12.1.tgz#dc6c1170e27d8aca99ff65f4925bd06b1c90550e" - integrity sha512-d+/o30tJxFxrA1lhzJqiUcEJdI6jKlNregCv5bASeGf2Q4MXmnwH7viDo7nhx1/ohf09oaH8j1GVYG/e3Yqk6A== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-remap-async-to-generator" "^7.12.1" - "@babel/plugin-syntax-async-generators" "^7.8.0" - -"@babel/plugin-proposal-class-properties@^7.1.0", "@babel/plugin-proposal-class-properties@^7.12.1": +"@babel/plugin-proposal-class-properties@^7.1.0": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de" integrity sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w== @@ -281,39 +179,7 @@ "@babel/helper-create-class-features-plugin" "^7.12.1" "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-proposal-dynamic-import@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.12.1.tgz#43eb5c2a3487ecd98c5c8ea8b5fdb69a2749b2dc" - integrity sha512-a4rhUSZFuq5W8/OO8H7BL5zspjnc1FLd9hlOxIK/f7qG4a0qsqk8uvF/ywgBA8/OmjsapjpvaEOYItfGG1qIvQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-dynamic-import" "^7.8.0" - -"@babel/plugin-proposal-export-namespace-from@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.12.1.tgz#8b9b8f376b2d88f5dd774e4d24a5cc2e3679b6d4" - integrity sha512-6CThGf0irEkzujYS5LQcjBx8j/4aQGiVv7J9+2f7pGfxqyKh3WnmVJYW3hdrQjyksErMGBPQrCnHfOtna+WLbw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - -"@babel/plugin-proposal-json-strings@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.12.1.tgz#d45423b517714eedd5621a9dfdc03fa9f4eb241c" - integrity sha512-GoLDUi6U9ZLzlSda2Df++VSqDJg3CG+dR0+iWsv6XRw1rEq+zwt4DirM9yrxW6XWaTpmai1cWJLMfM8qQJf+yw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-json-strings" "^7.8.0" - -"@babel/plugin-proposal-logical-assignment-operators@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.12.1.tgz#f2c490d36e1b3c9659241034a5d2cd50263a2751" - integrity sha512-k8ZmVv0JU+4gcUGeCDZOGd0lCIamU/sMtIiX3UWnUc5yzgq6YUGyEolNYD+MLYKfSzgECPcqetVcJP9Afe/aCA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - -"@babel/plugin-proposal-nullish-coalescing-operator@^7.1.0", "@babel/plugin-proposal-nullish-coalescing-operator@^7.12.1": +"@babel/plugin-proposal-nullish-coalescing-operator@^7.1.0": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.12.1.tgz#3ed4fff31c015e7f3f1467f190dbe545cd7b046c" integrity sha512-nZY0ESiaQDI1y96+jk6VxMOaL4LPo/QDHBqL+SF3/vl6dHkTwHlOI8L4ZwuRBHgakRBw5zsVylel7QPbbGuYgg== @@ -321,32 +187,7 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.0" -"@babel/plugin-proposal-numeric-separator@^7.12.7": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.12.7.tgz#8bf253de8139099fea193b297d23a9d406ef056b" - integrity sha512-8c+uy0qmnRTeukiGsjLGy6uVs/TFjJchGXUeBqlG4VWYOdJWkhhVPdQ3uHwbmalfJwv2JsV0qffXP4asRfL2SQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - -"@babel/plugin-proposal-object-rest-spread@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.12.1.tgz#def9bd03cea0f9b72283dac0ec22d289c7691069" - integrity sha512-s6SowJIjzlhx8o7lsFx5zmY4At6CTtDvgNQDdPzkBQucle58A6b/TTeEBYtyDgmcXjUTM+vE8YOGHZzzbc/ioA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.0" - "@babel/plugin-transform-parameters" "^7.12.1" - -"@babel/plugin-proposal-optional-catch-binding@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.12.1.tgz#ccc2421af64d3aae50b558a71cede929a5ab2942" - integrity sha512-hFvIjgprh9mMw5v42sJWLI1lzU5L2sznP805zeT6rySVRA0Y18StRhDqhSxlap0oVgItRsB6WSROp4YnJTJz0g== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.0" - -"@babel/plugin-proposal-optional-chaining@^7.1.0", "@babel/plugin-proposal-optional-chaining@^7.12.7": +"@babel/plugin-proposal-optional-chaining@^7.1.0": version "7.12.7" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.12.7.tgz#e02f0ea1b5dc59d401ec16fb824679f683d3303c" integrity sha512-4ovylXZ0PWmwoOvhU2vhnzVNnm88/Sm9nx7V8BPgMvAzn5zDou3/Awy0EjglyubVHasJj+XCEkr/r1X3P5elCA== @@ -355,23 +196,7 @@ "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" "@babel/plugin-syntax-optional-chaining" "^7.8.0" -"@babel/plugin-proposal-private-methods@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.12.1.tgz#86814f6e7a21374c980c10d38b4493e703f4a389" - integrity sha512-mwZ1phvH7/NHK6Kf8LP7MYDogGV+DKB1mryFOEwx5EBNQrosvIczzZFTUmWaeujd5xT6G1ELYWUz3CutMhjE1w== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-proposal-unicode-property-regex@^7.12.1", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.12.1.tgz#2a183958d417765b9eae334f47758e5d6a82e072" - integrity sha512-MYq+l+PvHuw/rKUz1at/vb6nCnQ2gmJBNaM62z0OgH7B2W1D9pvkpYtlti9bGtizNIU1K3zm4bZF9F91efVY0w== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-async-generators@^7.8.0", "@babel/plugin-syntax-async-generators@^7.8.4": +"@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== @@ -385,27 +210,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-class-properties@^7.12.1", "@babel/plugin-syntax-class-properties@^7.8.3": +"@babel/plugin-syntax-class-properties@^7.8.3": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.1.tgz#bcb297c5366e79bebadef509549cd93b04f19978" integrity sha512-U40A76x5gTwmESz+qiqssqmeEsKvcSyvtgktrm0uzcARAmM9I1jR221f6Oq+GmHrcD+LvZDag1UTOTe2fL3TeA== dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-syntax-dynamic-import@^7.8.0": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" - integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-export-namespace-from@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz#028964a9ba80dbc094c915c487ad7c4e7a66465a" - integrity sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - "@babel/plugin-syntax-flow@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.12.1.tgz#a77670d9abe6d63e8acadf4c31bb1eb5a506bbdd" @@ -420,14 +231,14 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-syntax-json-strings@^7.8.0", "@babel/plugin-syntax-json-strings@^7.8.3": +"@babel/plugin-syntax-json-strings@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-logical-assignment-operators@^7.10.4", "@babel/plugin-syntax-logical-assignment-operators@^7.8.3": +"@babel/plugin-syntax-logical-assignment-operators@^7.8.3": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== @@ -441,21 +252,21 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-numeric-separator@^7.10.4", "@babel/plugin-syntax-numeric-separator@^7.8.3": +"@babel/plugin-syntax-numeric-separator@^7.8.3": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-syntax-object-rest-spread@^7.8.0", "@babel/plugin-syntax-object-rest-spread@^7.8.3": +"@babel/plugin-syntax-object-rest-spread@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-optional-catch-binding@^7.8.0", "@babel/plugin-syntax-optional-catch-binding@^7.8.3": +"@babel/plugin-syntax-optional-catch-binding@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== @@ -469,7 +280,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" -"@babel/plugin-syntax-top-level-await@^7.12.1", "@babel/plugin-syntax-top-level-await@^7.8.3": +"@babel/plugin-syntax-top-level-await@^7.8.3": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.12.1.tgz#dd6c0b357ac1bb142d98537450a319625d13d2a0" integrity sha512-i7ooMZFS+a/Om0crxZodrTzNEPJHZrlMVGMTEpFAj6rYY/bKCddB0Dk/YxfPuYXOopuhKk/e1jV6h+WUU9XN3A== @@ -483,87 +294,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-arrow-functions@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.12.1.tgz#8083ffc86ac8e777fbe24b5967c4b2521f3cb2b3" - integrity sha512-5QB50qyN44fzzz4/qxDPQMBCTHgxg3n0xRBLJUmBlLoU/sFvxVWGZF/ZUfMVDQuJUKXaBhbupxIzIfZ6Fwk/0A== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-async-to-generator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.12.1.tgz#3849a49cc2a22e9743cbd6b52926d30337229af1" - integrity sha512-SDtqoEcarK1DFlRJ1hHRY5HvJUj5kX4qmtpMAm2QnhOlyuMC4TMdCRgW6WXpv93rZeYNeLP22y8Aq2dbcDRM1A== - dependencies: - "@babel/helper-module-imports" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-remap-async-to-generator" "^7.12.1" - -"@babel/plugin-transform-block-scoped-functions@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.12.1.tgz#f2a1a365bde2b7112e0a6ded9067fdd7c07905d9" - integrity sha512-5OpxfuYnSgPalRpo8EWGPzIYf0lHBWORCkj5M0oLBwHdlux9Ri36QqGW3/LR13RSVOAoUUMzoPI/jpE4ABcHoA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-block-scoping@^7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.12.11.tgz#83ae92a104dbb93a7d6c6dd1844f351083c46b4f" - integrity sha512-atR1Rxc3hM+VPg/NvNvfYw0npQEAcHuJ+MGZnFn6h3bo+1U3BWXMdFMlvVRApBTWKQMX7SOwRJZA5FBF/JQbvA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-classes@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.12.1.tgz#65e650fcaddd3d88ddce67c0f834a3d436a32db6" - integrity sha512-/74xkA7bVdzQTBeSUhLLJgYIcxw/dpEpCdRDiHgPJ3Mv6uC11UhjpOhl72CgqbBCmt1qtssCyB2xnJm1+PFjog== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-define-map" "^7.10.4" - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-optimise-call-expression" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-replace-supers" "^7.12.1" - "@babel/helper-split-export-declaration" "^7.10.4" - globals "^11.1.0" - -"@babel/plugin-transform-computed-properties@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.12.1.tgz#d68cf6c9b7f838a8a4144badbe97541ea0904852" - integrity sha512-vVUOYpPWB7BkgUWPo4C44mUQHpTZXakEqFjbv8rQMg7TC6S6ZhGZ3otQcRH6u7+adSlE5i0sp63eMC/XGffrzg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-destructuring@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.12.1.tgz#b9a570fe0d0a8d460116413cb4f97e8e08b2f847" - integrity sha512-fRMYFKuzi/rSiYb2uRLiUENJOKq4Gnl+6qOv5f8z0TZXg3llUwUhsNNwrwaT/6dUhJTzNpBr+CUvEWBtfNY1cw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-dotall-regex@^7.12.1", "@babel/plugin-transform-dotall-regex@^7.4.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.12.1.tgz#a1d16c14862817b6409c0a678d6f9373ca9cd975" - integrity sha512-B2pXeRKoLszfEW7J4Hg9LoFaWEbr/kzo3teWHmtFCszjRNa/b40f9mfeqZsIDLLt/FjwQ6pz/Gdlwy85xNckBA== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-duplicate-keys@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.12.1.tgz#745661baba295ac06e686822797a69fbaa2ca228" - integrity sha512-iRght0T0HztAb/CazveUpUQrZY+aGKKaWXMJ4uf9YJtqxSUe09j3wteztCUDRHs+SRAL7yMuFqUsLoAKKzgXjw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-exponentiation-operator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.12.1.tgz#b0f2ed356ba1be1428ecaf128ff8a24f02830ae0" - integrity sha512-7tqwy2bv48q+c1EHbXK0Zx3KXd2RVQp6OC7PbwFNt/dPTAV3Lu5sWtWuAj8owr5wqtWnqHfl2/mJlUmqkChKug== - dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-transform-flow-strip-types@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.12.1.tgz#8430decfa7eb2aea5414ed4a3fa6e1652b7d77c4" @@ -572,45 +302,7 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-flow" "^7.12.1" -"@babel/plugin-transform-for-of@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.12.1.tgz#07640f28867ed16f9511c99c888291f560921cfa" - integrity sha512-Zaeq10naAsuHo7heQvyV0ptj4dlZJwZgNAtBYBnu5nNKJoW62m0zKcIEyVECrUKErkUkg6ajMy4ZfnVZciSBhg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-function-name@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.12.1.tgz#2ec76258c70fe08c6d7da154003a480620eba667" - integrity sha512-JF3UgJUILoFrFMEnOJLJkRHSk6LUSXLmEFsA23aR2O5CSLUxbeUX1IZ1YQ7Sn0aXb601Ncwjx73a+FVqgcljVw== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.12.1.tgz#d73b803a26b37017ddf9d3bb8f4dc58bfb806f57" - integrity sha512-+PxVGA+2Ag6uGgL0A5f+9rklOnnMccwEBzwYFL3EUaKuiyVnUipyXncFcfjSkbimLrODoqki1U9XxZzTvfN7IQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-member-expression-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.12.1.tgz#496038602daf1514a64d43d8e17cbb2755e0c3ad" - integrity sha512-1sxePl6z9ad0gFMB9KqmYofk34flq62aqMt9NqliS/7hPEpURUCMbyHXrMPlo282iY7nAvUB1aQd5mg79UD9Jg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-modules-amd@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.12.1.tgz#3154300b026185666eebb0c0ed7f8415fefcf6f9" - integrity sha512-tDW8hMkzad5oDtzsB70HIQQRBiTKrhfgwC/KkJeGsaNFTdWhKNt/BiE8c5yj19XiGyrxpbkOfH87qkNg1YGlOQ== - dependencies: - "@babel/helper-module-transforms" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-commonjs@^7.1.0", "@babel/plugin-transform-modules-commonjs@^7.12.1": +"@babel/plugin-transform-modules-commonjs@^7.1.0": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.12.1.tgz#fa403124542636c786cf9b460a0ffbb48a86e648" integrity sha512-dY789wq6l0uLY8py9c1B48V8mVL5gZh/+PQ5ZPrylPYsnAvnEMjqsUXkuoDVPeVK+0VyGar+D08107LzDQ6pag== @@ -620,111 +312,6 @@ "@babel/helper-simple-access" "^7.12.1" babel-plugin-dynamic-import-node "^2.3.3" -"@babel/plugin-transform-modules-systemjs@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.12.1.tgz#663fea620d593c93f214a464cd399bf6dc683086" - integrity sha512-Hn7cVvOavVh8yvW6fLwveFqSnd7rbQN3zJvoPNyNaQSvgfKmDBO9U1YL9+PCXGRlZD9tNdWTy5ACKqMuzyn32Q== - dependencies: - "@babel/helper-hoist-variables" "^7.10.4" - "@babel/helper-module-transforms" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-validator-identifier" "^7.10.4" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-umd@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.12.1.tgz#eb5a218d6b1c68f3d6217b8fa2cc82fec6547902" - integrity sha512-aEIubCS0KHKM0zUos5fIoQm+AZUMt1ZvMpqz0/H5qAQ7vWylr9+PLYurT+Ic7ID/bKLd4q8hDovaG3Zch2uz5Q== - dependencies: - "@babel/helper-module-transforms" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-named-capturing-groups-regex@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.12.1.tgz#b407f5c96be0d9f5f88467497fa82b30ac3e8753" - integrity sha512-tB43uQ62RHcoDp9v2Nsf+dSM8sbNodbEicbQNA53zHz8pWUhsgHSJCGpt7daXxRydjb0KnfmB+ChXOv3oADp1Q== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - -"@babel/plugin-transform-new-target@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.12.1.tgz#80073f02ee1bb2d365c3416490e085c95759dec0" - integrity sha512-+eW/VLcUL5L9IvJH7rT1sT0CzkdUTvPrXC2PXTn/7z7tXLBuKvezYbGdxD5WMRoyvyaujOq2fWoKl869heKjhw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-object-super@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.12.1.tgz#4ea08696b8d2e65841d0c7706482b048bed1066e" - integrity sha512-AvypiGJH9hsquNUn+RXVcBdeE3KHPZexWRdimhuV59cSoOt5kFBmqlByorAeUlGG2CJWd0U+4ZtNKga/TB0cAw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-replace-supers" "^7.12.1" - -"@babel/plugin-transform-parameters@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.12.1.tgz#d2e963b038771650c922eff593799c96d853255d" - integrity sha512-xq9C5EQhdPK23ZeCdMxl8bbRnAgHFrw5EOC3KJUsSylZqdkCaFEXxGSBuTSObOpiiHHNyb82es8M1QYgfQGfNg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-property-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.12.1.tgz#41bc81200d730abb4456ab8b3fbd5537b59adecd" - integrity sha512-6MTCR/mZ1MQS+AwZLplX4cEySjCpnIF26ToWo942nqn8hXSm7McaHQNeGx/pt7suI1TWOWMfa/NgBhiqSnX0cQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-regenerator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.12.1.tgz#5f0a28d842f6462281f06a964e88ba8d7ab49753" - integrity sha512-gYrHqs5itw6i4PflFX3OdBPMQdPbF4bj2REIUxlMRUFk0/ZOAIpDFuViuxPjUL7YC8UPnf+XG7/utJvqXdPKng== - dependencies: - regenerator-transform "^0.14.2" - -"@babel/plugin-transform-reserved-words@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.12.1.tgz#6fdfc8cc7edcc42b36a7c12188c6787c873adcd8" - integrity sha512-pOnUfhyPKvZpVyBHhSBoX8vfA09b7r00Pmm1sH+29ae2hMTKVmSp4Ztsr8KBKjLjx17H0eJqaRC3bR2iThM54A== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-shorthand-properties@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.12.1.tgz#0bf9cac5550fce0cfdf043420f661d645fdc75e3" - integrity sha512-GFZS3c/MhX1OusqB1MZ1ct2xRzX5ppQh2JU1h2Pnfk88HtFTM+TWQqJNfwkmxtPQtb/s1tk87oENfXJlx7rSDw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-spread@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.12.1.tgz#527f9f311be4ec7fdc2b79bb89f7bf884b3e1e1e" - integrity sha512-vuLp8CP0BE18zVYjsEBZ5xoCecMK6LBMMxYzJnh01rxQRvhNhH1csMMmBfNo5tGpGO+NhdSNW2mzIvBu3K1fng== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" - -"@babel/plugin-transform-sticky-regex@^7.12.7": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.12.7.tgz#560224613ab23987453948ed21d0b0b193fa7fad" - integrity sha512-VEiqZL5N/QvDbdjfYQBhruN0HYjSPjC4XkeqW4ny/jNtH9gcbgaqBIXYEZCNnESMAGs0/K/R7oFGMhOyu/eIxg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-template-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.12.1.tgz#b43ece6ed9a79c0c71119f576d299ef09d942843" - integrity sha512-b4Zx3KHi+taXB1dVRBhVJtEPi9h1THCeKmae2qP0YdUHIFhVjtpqqNfxeVAa1xeHVhAy4SbHxEwx5cltAu5apw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-typeof-symbol@^7.12.10": - version "7.12.10" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.12.10.tgz#de01c4c8f96580bd00f183072b0d0ecdcf0dec4b" - integrity sha512-JQ6H8Rnsogh//ijxspCjc21YPd3VLVoYtAwv3zQmqAt8YGYUtdo5usNhdl4b9/Vir2kPFZl6n1h0PfUz4hJhaA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-transform-typescript@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.1.tgz#d92cc0af504d510e26a754a7dbc2e5c8cd9c7ab4" @@ -734,93 +321,6 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-typescript" "^7.12.1" -"@babel/plugin-transform-unicode-escapes@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.12.1.tgz#5232b9f81ccb07070b7c3c36c67a1b78f1845709" - integrity sha512-I8gNHJLIc7GdApm7wkVnStWssPNbSRMPtgHdmH3sRM1zopz09UWPS4x5V4n1yz/MIWTVnJ9sp6IkuXdWM4w+2Q== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-unicode-regex@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.12.1.tgz#cc9661f61390db5c65e3febaccefd5c6ac3faecb" - integrity sha512-SqH4ClNngh/zGwHZOOQMTD+e8FGWexILV+ePMyiDJttAWRh5dhDL8rcl5lSgU3Huiq6Zn6pWTMvdPAb21Dwdyg== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/preset-env@^7.12.1": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.11.tgz#55d5f7981487365c93dbbc84507b1c7215e857f9" - integrity sha512-j8Tb+KKIXKYlDBQyIOy4BLxzv1NUOwlHfZ74rvW+Z0Gp4/cI2IMDPBWAgWceGcE7aep9oL/0K9mlzlMGxA8yNw== - dependencies: - "@babel/compat-data" "^7.12.7" - "@babel/helper-compilation-targets" "^7.12.5" - "@babel/helper-module-imports" "^7.12.5" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-validator-option" "^7.12.11" - "@babel/plugin-proposal-async-generator-functions" "^7.12.1" - "@babel/plugin-proposal-class-properties" "^7.12.1" - "@babel/plugin-proposal-dynamic-import" "^7.12.1" - "@babel/plugin-proposal-export-namespace-from" "^7.12.1" - "@babel/plugin-proposal-json-strings" "^7.12.1" - "@babel/plugin-proposal-logical-assignment-operators" "^7.12.1" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.12.1" - "@babel/plugin-proposal-numeric-separator" "^7.12.7" - "@babel/plugin-proposal-object-rest-spread" "^7.12.1" - "@babel/plugin-proposal-optional-catch-binding" "^7.12.1" - "@babel/plugin-proposal-optional-chaining" "^7.12.7" - "@babel/plugin-proposal-private-methods" "^7.12.1" - "@babel/plugin-proposal-unicode-property-regex" "^7.12.1" - "@babel/plugin-syntax-async-generators" "^7.8.0" - "@babel/plugin-syntax-class-properties" "^7.12.1" - "@babel/plugin-syntax-dynamic-import" "^7.8.0" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-json-strings" "^7.8.0" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.0" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.0" - "@babel/plugin-syntax-optional-chaining" "^7.8.0" - "@babel/plugin-syntax-top-level-await" "^7.12.1" - "@babel/plugin-transform-arrow-functions" "^7.12.1" - "@babel/plugin-transform-async-to-generator" "^7.12.1" - "@babel/plugin-transform-block-scoped-functions" "^7.12.1" - "@babel/plugin-transform-block-scoping" "^7.12.11" - "@babel/plugin-transform-classes" "^7.12.1" - "@babel/plugin-transform-computed-properties" "^7.12.1" - "@babel/plugin-transform-destructuring" "^7.12.1" - "@babel/plugin-transform-dotall-regex" "^7.12.1" - "@babel/plugin-transform-duplicate-keys" "^7.12.1" - "@babel/plugin-transform-exponentiation-operator" "^7.12.1" - "@babel/plugin-transform-for-of" "^7.12.1" - "@babel/plugin-transform-function-name" "^7.12.1" - "@babel/plugin-transform-literals" "^7.12.1" - "@babel/plugin-transform-member-expression-literals" "^7.12.1" - "@babel/plugin-transform-modules-amd" "^7.12.1" - "@babel/plugin-transform-modules-commonjs" "^7.12.1" - "@babel/plugin-transform-modules-systemjs" "^7.12.1" - "@babel/plugin-transform-modules-umd" "^7.12.1" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.12.1" - "@babel/plugin-transform-new-target" "^7.12.1" - "@babel/plugin-transform-object-super" "^7.12.1" - "@babel/plugin-transform-parameters" "^7.12.1" - "@babel/plugin-transform-property-literals" "^7.12.1" - "@babel/plugin-transform-regenerator" "^7.12.1" - "@babel/plugin-transform-reserved-words" "^7.12.1" - "@babel/plugin-transform-shorthand-properties" "^7.12.1" - "@babel/plugin-transform-spread" "^7.12.1" - "@babel/plugin-transform-sticky-regex" "^7.12.7" - "@babel/plugin-transform-template-literals" "^7.12.1" - "@babel/plugin-transform-typeof-symbol" "^7.12.10" - "@babel/plugin-transform-unicode-escapes" "^7.12.1" - "@babel/plugin-transform-unicode-regex" "^7.12.1" - "@babel/preset-modules" "^0.1.3" - "@babel/types" "^7.12.11" - core-js-compat "^3.8.0" - semver "^5.5.0" - "@babel/preset-flow@^7.0.0": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.12.1.tgz#1a81d376c5a9549e75352a3888f8c273455ae940" @@ -829,17 +329,6 @@ "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-transform-flow-strip-types" "^7.12.1" -"@babel/preset-modules@^0.1.3": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.4.tgz#362f2b68c662842970fdb5e254ffc8fc1c2e415e" - integrity sha512-J36NhwnfdzpmH41M1DrnkkgAqhZaqr/NBdPfQ677mLzlaXo+oDiv1deyCDtgAhz8p328otdob0Du7+xgHGZbKg== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" - "@babel/plugin-transform-dotall-regex" "^7.4.4" - "@babel/types" "^7.4.4" - esutils "^2.0.2" - "@babel/preset-typescript@^7.1.0": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.12.1.tgz#86480b483bb97f75036e8864fe404cc782cc311b" @@ -859,7 +348,7 @@ pirates "^4.0.0" source-map-support "^0.5.16" -"@babel/runtime@^7.11.2", "@babel/runtime@^7.8.4": +"@babel/runtime@^7.11.2": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.1.tgz#b4116a6b6711d010b2dad3b7b6e43bf1b9954740" integrity sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA== @@ -875,7 +364,7 @@ "@babel/parser" "^7.12.7" "@babel/types" "^7.12.7" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.10", "@babel/traverse@^7.12.5": +"@babel/traverse@^7.1.0", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.10", "@babel/traverse@^7.12.5": version "7.12.10" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.10.tgz#2d1f4041e8bf42ea099e5b2dc48d6a594c00017a" integrity sha512-6aEtf0IeRgbYWzta29lePeYSk+YAFIC3kyqESeft8o5CkFlYIMX+EQDDWEiAQ9LHOA3d0oHdgrSsID/CKqXJlg== @@ -890,7 +379,7 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.11", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": +"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3": version "7.12.11" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.11.tgz#a86e4d71e30a9b6ee102590446c98662589283ce" integrity sha512-ukA9SQtKThINm++CX1CwmliMrE54J6nIYB5XTwL5f/CLFW9owfls+YSU8tVW15RQ2w+a3fSbPjC6HdQNtWZkiA== @@ -3376,7 +2865,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browserslist@^4.14.5, browserslist@^4.15.0: +browserslist@^4.14.5: version "4.15.0" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.15.0.tgz#3d48bbca6a3f378e86102ffd017d9a03f122bdb0" integrity sha512-IJ1iysdMkGmjjYeRlDU8PQejVwxvVO5QOfXH7ylW31GO6LwNRSmm/SgRXtNsEXqMLl2e+2H5eEJ7sfynF8TCaQ== @@ -4123,14 +3612,6 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= -core-js-compat@^3.8.0: - version "3.8.1" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.8.1.tgz#8d1ddd341d660ba6194cbe0ce60f4c794c87a36e" - integrity sha512-a16TLmy9NVD1rkjUGbwuyWkiDoN0FDpAwrfLONvHFQx0D9k7J9y0srwMT8QP/Z6HE3MIFaVynEeYwZwPX1o5RQ== - dependencies: - browserslist "^4.15.0" - semver "7.0.0" - core-js@^3.6.1: version "3.6.5" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.6.5.tgz#7395dc273af37fb2e50e9bd3d9fe841285231d1a" @@ -7464,11 +6945,6 @@ jsesc@^2.5.1: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= - json-buffer@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" @@ -9737,30 +9213,11 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" -regenerate-unicode-properties@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" - integrity sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA== - dependencies: - regenerate "^1.4.0" - -regenerate@^1.4.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.1.tgz#cad92ad8e6b591773485fbe05a485caf4f457e6f" - integrity sha512-j2+C8+NtXQgEKWk49MMP5P/u2GhnahTtVkRIHr5R5lVRlbKvmQ+oS+A5aLKWp2ma5VkT8sh6v+v4hbH0YHR66A== - regenerator-runtime@^0.13.4: version "0.13.7" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== -regenerator-transform@^0.14.2: - version "0.14.5" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4" - integrity sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw== - dependencies: - "@babel/runtime" "^7.8.4" - regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" @@ -9782,30 +9239,6 @@ regexpp@^3.0.0, regexpp@^3.1.0: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== -regexpu-core@^4.7.1: - version "4.7.1" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.1.tgz#2dea5a9a07233298fbf0db91fa9abc4c6e0f8ad6" - integrity sha512-ywH2VUraA44DZQuRKzARmw6S66mr48pQVva4LBeRhcOltJ6hExvWly5ZjFLYo67xbIxb6W1q4bAGtgfEl20zfQ== - dependencies: - regenerate "^1.4.0" - regenerate-unicode-properties "^8.2.0" - regjsgen "^0.5.1" - regjsparser "^0.6.4" - unicode-match-property-ecmascript "^1.0.4" - unicode-match-property-value-ecmascript "^1.2.0" - -regjsgen@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.2.tgz#92ff295fb1deecbf6ecdab2543d207e91aa33733" - integrity sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A== - -regjsparser@^0.6.4: - version "0.6.4" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.4.tgz#a769f8684308401a66e9b529d2436ff4d0666272" - integrity sha512-64O87/dPDgfk8/RQqC4gkZoGyyWFIEUTTh80CU6CWuK5vkCGyekIx+oKcEIYtP/RAxSQltCZHCNu/mdd7fqlJw== - dependencies: - jsesc "~0.5.0" - release-zalgo@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/release-zalgo/-/release-zalgo-1.0.0.tgz#09700b7e5074329739330e535c5a90fb67851730" @@ -10153,11 +9586,6 @@ semver-regex@^2.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - semver@7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" @@ -11288,29 +10716,6 @@ umask@^1.1.0: resolved "https://registry.yarnpkg.com/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d" integrity sha1-8pzr8B31F5ErtY/5xOUP3o4zMg0= -unicode-canonical-property-names-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" - integrity sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ== - -unicode-match-property-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz#8ed2a32569961bce9227d09cd3ffbb8fed5f020c" - integrity sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg== - dependencies: - unicode-canonical-property-names-ecmascript "^1.0.4" - unicode-property-aliases-ecmascript "^1.0.4" - -unicode-match-property-value-ecmascript@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz#0d91f600eeeb3096aa962b1d6fc88876e64ea531" - integrity sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ== - -unicode-property-aliases-ecmascript@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz#dd57a99f6207bedff4628abefb94c50db941c8f4" - integrity sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg== - union-value@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" From 016bb348d7cc9cb299555ec8edd373130fb1b77c Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Fri, 8 Jan 2021 21:56:32 +0530 Subject: [PATCH 240/581] fix: init generator (#2324) --- .../__snapshots__/init-generator.test.ts.snap | 2 +- .../__tests__/init-generator.test.ts | 3 +- packages/generators/src/init-generator.ts | 48 ++++++++----------- test/init/auto/init-auto.test.js | 2 +- test/init/force/init-force.test.js | 2 +- .../init-generation-path.test.js | 4 +- test/init/generator/init-inquirer.test.js | 2 +- 7 files changed, 28 insertions(+), 35 deletions(-) diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index 6e4bf0722ca..9c510fc01d8 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -188,7 +188,7 @@ Object { "host": "'localhost'", "open": true, }, - "mode": "'production'", + "mode": "'development'", "module": Object { "rules": Array [], }, diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index 6c4465281e6..7e42e4c9a94 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -13,14 +13,13 @@ describe('init generator', () => { }); // Check that all the project files are generated with the correct name - const filePaths = ['package.json', 'README.md', 'src/index.js', 'sw.js']; + const filePaths = ['package.json', 'README.md', 'src/index.js']; assert.file(filePaths.map((file) => join(outputDir, file))); // Check generated file contents assert.fileContent(join(outputDir, 'package.json'), '"name": "my-webpack-project"'); assert.fileContent(join(outputDir, 'README.md'), 'Welcome to your new awesome project!'); assert.fileContent(join(outputDir, 'src', 'index.js'), "console.log('Hello World from your main file!');"); - assert.fileContent(join(outputDir, 'sw.js'), "self.addEventListener('install'"); // eslint-disable-next-line @typescript-eslint/no-var-requires const output = require(join(outputDir, '.yo-rc.json')); diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 6cefa9cecfd..75d92774f4c 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -19,7 +19,6 @@ const { logger, getPackageManager } = utils; * */ export default class InitGenerator extends CustomGenerator { - public usingDefaults: boolean; public autoGenerateConfig: boolean; public generationPath: string; private langType: string; @@ -27,7 +26,6 @@ export default class InitGenerator extends CustomGenerator { public constructor(args, opts) { super(args, opts); - this.usingDefaults = true; this.autoGenerateConfig = opts.autoSetDefaults ? true : false; this.generationPath = opts.generationPath; @@ -60,8 +58,6 @@ export default class InitGenerator extends CustomGenerator { // eslint-disable-next-line @typescript-eslint/no-this-alias const self: this = this; - this.usingDefaults = true; - logger.log( `\n${logSymbols.info}${blue(' INFO ')} ` + 'For more information and a detailed description of each question, have a look at: ' + @@ -80,14 +76,12 @@ export default class InitGenerator extends CustomGenerator { const entryOption: string | object = await entryQuestions(self, multiEntries, this.autoGenerateConfig); if (typeof entryOption === 'string') { - // single entry + // single entry apply when default is not used if (entryOption.length > 0 && entryOption !== "'./src/index.js'") { - this.usingDefaults = false; this.configuration.config.webpackOptions.entry = entryOption; } } else if (typeof entryOption === 'object') { // multiple entries - this.usingDefaults = false; this.configuration.config.webpackOptions.entry = entryOption; } @@ -101,10 +95,8 @@ export default class InitGenerator extends CustomGenerator { this.autoGenerateConfig, ); - const defaultOutputDir = !outputDir || outputDir === 'dist'; - - if (!defaultOutputDir) { - this.usingDefaults = false; + // only apply when output dir is not default + if (outputDir !== 'dist') { this.configuration.config.webpackOptions.output = { path: `path.resolve(__dirname, '${outputDir}')`, }; @@ -121,9 +113,6 @@ export default class InitGenerator extends CustomGenerator { langQuestionHandler(this, langType); this.langType = langType; - if (this.langType !== 'No') { - this.usingDefaults = false; - } const { stylingType } = await List( self, @@ -134,9 +123,6 @@ export default class InitGenerator extends CustomGenerator { this.autoGenerateConfig, ); const { ExtractUseProps, regExpForStyles } = styleQuestionHandler(self, stylingType); - if (stylingType !== 'No') { - this.usingDefaults = false; - } if (regExpForStyles) { // Ask if the user wants to use extractPlugin @@ -187,7 +173,13 @@ export default class InitGenerator extends CustomGenerator { } // webpack Dev Server - const { useDevServer } = await Confirm(self, 'useDevServer', 'Do you want to use webpack-dev-server?', true, this.usingDefaults); + const { useDevServer } = await Confirm( + self, + 'useDevServer', + 'Do you want to use webpack-dev-server?', + true, + this.autoGenerateConfig, + ); if (useDevServer) { this.dependencies.push('webpack-dev-server'); this.configuration.config.webpackOptions.devServer = { @@ -201,7 +193,7 @@ export default class InitGenerator extends CustomGenerator { 'useHTMLPlugin', 'Do you want to simplify the creation of HTML files for your bundle?', false, - this.usingDefaults, + this.autoGenerateConfig, ); if (useHTMLPlugin) { // Html webpack Plugin @@ -218,7 +210,13 @@ export default class InitGenerator extends CustomGenerator { })`); } - const { useWorkboxPlugin } = await Confirm(self, 'useWorkboxPlugin', 'Do you want to add PWA support?', true, this.usingDefaults); + const { useWorkboxPlugin } = await Confirm( + self, + 'useWorkboxPlugin', + 'Do you want to add PWA support?', + true, + this.autoGenerateConfig, + ); // webpack Dev Server if (useWorkboxPlugin) { this.configuration.config.topScope.push("const workboxPlugin = require('workbox-webpack-plugin');", '\n'); @@ -230,7 +228,7 @@ export default class InitGenerator extends CustomGenerator { })`); } - this.configuration.config.webpackOptions.mode = this.usingDefaults ? "'production'" : "'development'"; + this.configuration.config.webpackOptions.mode = this.autoGenerateConfig ? "'production'" : "'development'"; } public installPlugins(): void { @@ -244,12 +242,11 @@ export default class InitGenerator extends CustomGenerator { } public writing(): void { - this.configuration.usingDefaults = this.usingDefaults; this.config.set('configuration', this.configuration); const packageJsonTemplatePath = '../templates/package.json.js'; // eslint-disable-next-line @typescript-eslint/no-var-requires - this.fs.extendJSON(this.destinationPath('package.json'), require(packageJsonTemplatePath)(this.usingDefaults)); + this.fs.extendJSON(this.destinationPath('package.json'), require(packageJsonTemplatePath)(this.autoGenerateConfig)); const generateEntryFile = (entryPath: string, name: string): void => { entryPath = entryPath.replace(/'/g, ''); @@ -268,10 +265,7 @@ export default class InitGenerator extends CustomGenerator { this.fs.copyTpl(path.resolve(__dirname, '../templates/README.md'), this.destinationPath('README.md'), {}); // Generate HTML template file, copy the default service worker - if (this.usingDefaults) { - this.fs.copyTpl(path.resolve(__dirname, '../templates/template.html'), this.destinationPath('index.html'), {}); - this.fs.copyTpl(path.resolve(__dirname, '../templates/sw.js'), this.destinationPath('sw.js'), {}); - } + this.fs.copyTpl(path.resolve(__dirname, '../templates/template.html'), this.destinationPath('index.html'), {}); if (this.langType === LangType.ES6) { this.fs.copyTpl(path.resolve(__dirname, '../templates/.babelrc'), this.destinationPath('.babelrc'), {}); diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index b6a9504a8e6..05a58085830 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -35,7 +35,7 @@ describe('init auto flag', () => { } // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; + const files = ['./package.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); diff --git a/test/init/force/init-force.test.js b/test/init/force/init-force.test.js index 263110d005c..bbcf9bdd36a 100644 --- a/test/init/force/init-force.test.js +++ b/test/init/force/init-force.test.js @@ -34,7 +34,7 @@ describe('init force flag', () => { } // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; + const files = ['./package.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); diff --git a/test/init/generation-path/init-generation-path.test.js b/test/init/generation-path/init-generation-path.test.js index 596457e6c2d..e4211b18732 100644 --- a/test/init/generation-path/init-generation-path.test.js +++ b/test/init/generation-path/init-generation-path.test.js @@ -26,7 +26,7 @@ describe('init generate-path flag', () => { } // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; + const files = ['./package.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); @@ -62,7 +62,7 @@ describe('init generate-path flag', () => { } // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; + const files = ['./package.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 69cf728ddab..9cb3f794761 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -30,7 +30,7 @@ describe('init', () => { } // Test regressively files are scaffolded - const files = ['./sw.js', './package.json', './src/index.js', './webpack.config.js']; + const files = ['./package.json', './src/index.js', './webpack.config.js']; files.forEach((file) => { expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); From e536fbb5616946fd2a676e318135b17678c2a489 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Fri, 8 Jan 2021 23:42:47 +0530 Subject: [PATCH 241/581] tests: refactor (#2209) --- test/cache/cache.test.js | 126 +++++++++--------- test/config-format/coffee/coffee.test.js | 4 +- test/config-format/mjs/mjs.test.js | 2 +- .../mjs-config/default-mjs-config.test.js | 2 +- test/config/error-mjs/config-error.test.js | 4 +- .../config/function/functional-config.test.js | 6 +- .../function-with-env.test.js | 18 +-- test/core-flags/webpack.test.config.js | 1 + test/devtool/object/source-map-object.test.js | 2 +- test/entry/flag-entry/entry-with-flag.test.js | 4 +- .../multiple-entries/multi-entries.test.js | 4 +- test/env/array/array-env.test.js | 4 +- test/env/object/object-env.test.js | 2 +- test/hot/hot-flag.test.js | 4 +- test/loader/error-test/loader-error.test.js | 2 +- .../mode-single-arg/mode-single-arg.test.js | 2 +- .../mode-with-config/mode-with-config.test.js | 30 +++-- test/node/node.test.js | 13 +- test/serve/basic/serve-basic.test.js | 57 ++++---- test/serve/serve-variable/serve-basic.test.js | 2 +- .../serve-custom-config.test.js | 8 +- test/utils/test-utils.js | 14 +- test/utils/test-utils.test.js | 2 - 23 files changed, 159 insertions(+), 154 deletions(-) create mode 100644 test/core-flags/webpack.test.config.js diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index 7247ead765c..179ba00addd 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -8,7 +8,7 @@ describe('cache', () => { it('should work', () => { rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-default-development')); - let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); + let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js']); expect(exitCode).toEqual(0); @@ -19,7 +19,7 @@ describe('cache', () => { expect(stdout).toBeTruthy(); } - ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false)); + ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'])); expect(exitCode).toEqual(0); @@ -36,7 +36,7 @@ describe('cache', () => { rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-first-development')); rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-second-development')); - let { exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'], false); + let { exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js']); expect(exitCode).toEqual(0); @@ -48,7 +48,7 @@ describe('cache', () => { expect(stdout).toBeTruthy(); } - ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'], false)); + ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'])); expect(exitCode).toEqual(0); @@ -64,11 +64,14 @@ describe('cache', () => { it('should work in multi compiler mode with the `--config-name` argument', () => { rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-third-development')); - let { exitCode, stderr, stdout } = run( - __dirname, - ['-c', './multi.config.js', '--config-name', 'cache-test-first', '--name', 'cache-test-third'], - false, - ); + let { exitCode, stderr, stdout } = run(__dirname, [ + '-c', + './multi.config.js', + '--config-name', + 'cache-test-first', + '--name', + 'cache-test-third', + ]); expect(exitCode).toEqual(0); @@ -79,11 +82,14 @@ describe('cache', () => { expect(stdout).toBeTruthy(); } - ({ exitCode, stderr, stdout } = run( - __dirname, - ['-c', './multi.config.js', '--config-name', 'cache-test-first', '--name', 'cache-test-third'], - false, - )); + ({ exitCode, stderr, stdout } = run(__dirname, [ + '-c', + './multi.config.js', + '--config-name', + 'cache-test-first', + '--name', + 'cache-test-third', + ])); expect(exitCode).toEqual(0); @@ -99,11 +105,15 @@ describe('cache', () => { it('should work with the `--merge` argument', () => { rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-fourth-development')); - let { exitCode, stderr, stdout } = run( - __dirname, - ['-c', './multi.config.js', '-c', './webpack.config.js', '--merge', '--name', 'cache-test-fourth'], - false, - ); + let { exitCode, stderr, stdout } = run(__dirname, [ + '-c', + './multi.config.js', + '-c', + './webpack.config.js', + '--merge', + '--name', + 'cache-test-fourth', + ]); expect(exitCode).toEqual(0); @@ -114,11 +124,15 @@ describe('cache', () => { expect(stdout).toBeTruthy(); } - ({ exitCode, stderr, stdout } = run( - __dirname, - ['-c', './multi.config.js', '-c', './webpack.config.js', '--merge', '--name', 'cache-test-fourth'], - false, - )); + ({ exitCode, stderr, stdout } = run(__dirname, [ + '-c', + './multi.config.js', + '-c', + './webpack.config.js', + '--merge', + '--name', + 'cache-test-fourth', + ])); expect(exitCode).toEqual(0); @@ -134,23 +148,19 @@ describe('cache', () => { it('should work with the `--config-name` and `--merge` argument', () => { rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-fifth-development')); - let { exitCode, stderr, stdout } = run( - __dirname, - [ - '-c', - './multi.config.js', - '-c', - './webpack.config.js', - '--merge', - '--config-name', - 'cache-test-first', - '--config-name', - 'cache-test-second', - '--name', - 'cache-test-fifth', - ], - false, - ); + let { exitCode, stderr, stdout } = run(__dirname, [ + '-c', + './multi.config.js', + '-c', + './webpack.config.js', + '--merge', + '--config-name', + 'cache-test-first', + '--config-name', + 'cache-test-second', + '--name', + 'cache-test-fifth', + ]); expect(exitCode).toEqual(0); @@ -161,23 +171,19 @@ describe('cache', () => { expect(stdout).toBeTruthy(); } - ({ exitCode, stderr, stdout } = run( - __dirname, - [ - '-c', - './multi.config.js', - '-c', - './webpack.config.js', - '--merge', - '--config-name', - 'cache-test-first', - '--config-name', - 'cache-test-second', - '--name', - 'cache-test-fifth', - ], - false, - )); + ({ exitCode, stderr, stdout } = run(__dirname, [ + '-c', + './multi.config.js', + '-c', + './webpack.config.js', + '--merge', + '--config-name', + 'cache-test-first', + '--config-name', + 'cache-test-second', + '--name', + 'cache-test-fifth', + ])); expect(exitCode).toEqual(0); @@ -193,7 +199,7 @@ describe('cache', () => { it('should work with autoloading configuration', () => { rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-autoloading-development')); - let { exitCode, stderr, stdout } = run(__dirname, ['--name', 'cache-test-autoloading'], false); + let { exitCode, stderr, stdout } = run(__dirname, ['--name', 'cache-test-autoloading']); expect(exitCode).toEqual(0); @@ -204,7 +210,7 @@ describe('cache', () => { expect(stdout).toBeTruthy(); } - ({ exitCode, stderr, stdout } = run(__dirname, ['--name', 'cache-test-autoloading'], false)); + ({ exitCode, stderr, stdout } = run(__dirname, ['--name', 'cache-test-autoloading'])); expect(exitCode).toEqual(0); diff --git a/test/config-format/coffee/coffee.test.js b/test/config-format/coffee/coffee.test.js index ac853526f7d..84f6ada8f75 100644 --- a/test/config-format/coffee/coffee.test.js +++ b/test/config-format/coffee/coffee.test.js @@ -3,7 +3,7 @@ const { run } = require('../../utils/test-utils'); describe('webpack cli', () => { it('should support coffeescript file as flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -11,7 +11,7 @@ describe('webpack cli', () => { }); it('should load coffeescript file by default', () => { - const { exitCode, stderr, stdout } = run(__dirname, [], false); + const { exitCode, stderr, stdout } = run(__dirname, []); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); diff --git a/test/config-format/mjs/mjs.test.js b/test/config-format/mjs/mjs.test.js index 5da18d95c16..e8ada298f2a 100644 --- a/test/config-format/mjs/mjs.test.js +++ b/test/config-format/mjs/mjs.test.js @@ -2,7 +2,7 @@ const { run } = require('../../utils/test-utils'); describe('webpack cli', () => { it('should support mjs config format', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.mjs'], false, [], { DISABLE_V8_COMPILE_CACHE: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.mjs'], [], { DISABLE_V8_COMPILE_CACHE: true }); if (exitCode === 0) { expect(exitCode).toBe(0); diff --git a/test/config/defaults/mjs-config/default-mjs-config.test.js b/test/config/defaults/mjs-config/default-mjs-config.test.js index 434de374fd8..b2fe3551bdc 100644 --- a/test/config/defaults/mjs-config/default-mjs-config.test.js +++ b/test/config/defaults/mjs-config/default-mjs-config.test.js @@ -4,7 +4,7 @@ const { run, isWebpack5 } = require('../../../utils/test-utils'); describe('Default Config:', () => { it('Should be able to pick mjs config by default', () => { - const { exitCode, stderr, stdout } = run(__dirname, [], false, [], { DISABLE_V8_COMPILE_CACHE: true }); + const { exitCode, stderr, stdout } = run(__dirname, [], [], { DISABLE_V8_COMPILE_CACHE: true }); if (exitCode === 0) { expect(exitCode).toEqual(0); diff --git a/test/config/error-mjs/config-error.test.js b/test/config/error-mjs/config-error.test.js index 3493cd2d472..4abbe2e5b48 100644 --- a/test/config/error-mjs/config-error.test.js +++ b/test/config/error-mjs/config-error.test.js @@ -4,7 +4,7 @@ const { run } = require('../../utils/test-utils'); describe('config error', () => { it('should throw error with invalid configuration', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.mjs')], false, [], { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.mjs')], [], { DISABLE_V8_COMPILE_CACHE: true, }); @@ -14,7 +14,7 @@ describe('config error', () => { }); it('should throw syntax error and exit with non-zero exit code', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.mjs')], false, [], { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.mjs')], [], { DISABLE_V8_COMPILE_CACHE: true, }); diff --git a/test/config/function/functional-config.test.js b/test/config/function/functional-config.test.js index 3f8f2eabc11..c1c34c8ff88 100644 --- a/test/config/function/functional-config.test.js +++ b/test/config/function/functional-config.test.js @@ -11,7 +11,7 @@ describe('functional config', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('./src/index.js'); - expect(existsSync(resolve(__dirname, './bin/dist-single.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dist-single.js'))).toBeTruthy(); }); it('should work as expected in case of multiple config', () => { @@ -21,7 +21,7 @@ describe('functional config', () => { expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).toContain('second'); - expect(existsSync(resolve(__dirname, './bin/dist-first.js'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/dist-second.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dist-first.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dist-second.js'))).toBeTruthy(); }); }); diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index c3a0275e460..870cac23548 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -5,7 +5,7 @@ const { run } = require('../../../utils/test-utils'); describe('function configuration', () => { it('should throw when env is not supplied', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--env'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--env']); expect(exitCode).toBe(2); expect(stderr).toContain(`option '--env ' argument missing`); @@ -19,7 +19,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/prod.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/prod.js'))).toBeTruthy(); }); it('is able to understand a configuration file as a function', () => { @@ -29,7 +29,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/dev.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/dev.js'))).toBeTruthy(); }); it('Supports passing string in env', () => { @@ -46,7 +46,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/Luffy.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/Luffy.js'))).toBeTruthy(); }); it('Supports long nested values in env', () => { @@ -63,7 +63,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/Atsumu.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/Atsumu.js'))).toBeTruthy(); }); it('Supports multiple equal in a string', () => { @@ -80,7 +80,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/name=is=Eren.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/name=is=Eren.js'))).toBeTruthy(); }); it('Supports dot at the end', () => { @@ -97,7 +97,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/Hisoka.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/Hisoka.js'))).toBeTruthy(); }); it('Supports dot at the end', () => { @@ -107,7 +107,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/true.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/true.js'))).toBeTruthy(); }); it('is able to understand multiple env flags', (done) => { @@ -120,7 +120,7 @@ describe('function configuration', () => { expect(stdout).toContain('LOG from webpack'); // check if the values from DefinePlugin make it to the compiled code - readFile(resolve(__dirname, './bin/dev.js'), 'utf-8', (err, data) => { + readFile(resolve(__dirname, './dist/dev.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('env message present'); done(); diff --git a/test/core-flags/webpack.test.config.js b/test/core-flags/webpack.test.config.js new file mode 100644 index 00000000000..cd24476ff4c --- /dev/null +++ b/test/core-flags/webpack.test.config.js @@ -0,0 +1 @@ +module.exports = { mode: 'development' }; diff --git a/test/devtool/object/source-map-object.test.js b/test/devtool/object/source-map-object.test.js index 4237b08d520..d1050018a54 100644 --- a/test/devtool/object/source-map-object.test.js +++ b/test/devtool/object/source-map-object.test.js @@ -11,7 +11,7 @@ describe('source-map object', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - readdir(resolve(__dirname, 'bin'), (err, files) => { + readdir(resolve(__dirname, 'dist'), (err, files) => { expect(files.length).toBeGreaterThanOrEqual(1); expect(err).toBe(null); done(); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index 22d0ff09f95..6f3445111a3 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -6,7 +6,7 @@ const { resolve } = require('path'); describe('entry flag', () => { it('should resolve the path to src/index.cjs', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -34,7 +34,7 @@ describe('entry flag', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { + readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('Hello from a.js'); done(); diff --git a/test/entry/multiple-entries/multi-entries.test.js b/test/entry/multiple-entries/multi-entries.test.js index 6d236139a38..958d4ab56f6 100644 --- a/test/entry/multiple-entries/multi-entries.test.js +++ b/test/entry/multiple-entries/multi-entries.test.js @@ -11,9 +11,9 @@ describe(' multiple entries', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { + readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('Hello from a.js'); expect(data).toContain('Hello from b.js'); diff --git a/test/env/array/array-env.test.js b/test/env/array/array-env.test.js index 83e75c74fb6..e279174a1a4 100644 --- a/test/env/array/array-env.test.js +++ b/test/env/array/array-env.test.js @@ -6,8 +6,8 @@ const execa = require('execa'); const { sync: spawnSync } = execa; const { run, isWebpack5 } = require('../../utils/test-utils'); -const devFile = path.join(__dirname, './bin/dev.js'); -const prodFile = path.join(__dirname, './bin/prod.js'); +const devFile = path.join(__dirname, './dist/dev.js'); +const prodFile = path.join(__dirname, './dist/prod.js'); describe('env array', () => { it('is able to set two different environments for an array configuration', () => { diff --git a/test/env/object/object-env.test.js b/test/env/object/object-env.test.js index d886da0eaf8..c7fa2b369cb 100644 --- a/test/env/object/object-env.test.js +++ b/test/env/object/object-env.test.js @@ -15,7 +15,7 @@ describe('env object', () => { expect(stdout).toBeTruthy(); if (isWebpack5) { - const executable = path.join(__dirname, './bin/main.js'); + const executable = path.join(__dirname, './dist/main.js'); const bundledScript = spawnSync('node', [executable]); expect(bundledScript.stdout).toBe('environment is development'); } diff --git a/test/hot/hot-flag.test.js b/test/hot/hot-flag.test.js index d029a66fff0..2557252dc1e 100644 --- a/test/hot/hot-flag.test.js +++ b/test/hot/hot-flag.test.js @@ -10,7 +10,7 @@ describe('--hot flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); + expect(readFileSync(resolve(__dirname, './dist/main.js')).toString()).toContain('webpackHotUpdate'); }); it('should be successful when --no-hot is passed', () => { @@ -19,6 +19,6 @@ describe('--hot flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).not.toContain('webpackHotUpdate'); + expect(readFileSync(resolve(__dirname, './dist/main.js')).toString()).not.toContain('webpackHotUpdate'); }); }); diff --git a/test/loader/error-test/loader-error.test.js b/test/loader/error-test/loader-error.test.js index 38d0ab29eef..359d2bfb3f0 100644 --- a/test/loader/error-test/loader-error.test.js +++ b/test/loader/error-test/loader-error.test.js @@ -7,7 +7,7 @@ describe('loader error regression test for #1581', () => { it(`should not ignore loader's error produce a failing build`, () => { // Ignoring assertion on stderr because ts-loader is producing depreciation warnings // with webpack@v5.0.0-beta.24 -> https://github.com/TypeStrong/ts-loader/issues/1169 - const { stdout, exitCode } = run(__dirname, [], false); + const { stdout, exitCode } = run(__dirname, []); expect(exitCode).not.toEqual(0); expect(stdout).toContain('[1 error]'); expect(stdout).toContain(`Cannot assign to 'foobar' because it is a constant`); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 63dae85005e..7816271878f 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -37,7 +37,7 @@ describe('mode flags', () => { }); it('should pick mode form NODE_ENV', () => { - const { exitCode, stderr, stdout } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); + const { exitCode, stderr, stdout } = run(__dirname, [], { env: { NODE_ENV: 'development' } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); diff --git a/test/mode/mode-with-config/mode-with-config.test.js b/test/mode/mode-with-config/mode-with-config.test.js index c158d1b4d61..0a2e6ae9a53 100644 --- a/test/mode/mode-with-config/mode-with-config.test.js +++ b/test/mode/mode-with-config/mode-with-config.test.js @@ -13,11 +13,11 @@ describe('mode flags with config', () => { expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js.map'))).toBeFalsy(); + expect(existsSync(resolve(__dirname, './dist/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js.map'))).toBeFalsy(); // Correct mode should be propagated to the compiler - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { + readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('"production mode"'); done(); @@ -32,12 +32,12 @@ describe('mode flags with config', () => { expect(stdout).toBeTruthy(); // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js.map'))).toBeFalsy(); + expect(existsSync(resolve(__dirname, './dist/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js.map'))).toBeFalsy(); // Correct mode should be propagated to the compiler - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { + readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('development mode'); done(); @@ -53,12 +53,12 @@ describe('mode flags with config', () => { // Should generate the appropriate files // Should generate the appropriate files - expect(existsSync(resolve(__dirname, './bin/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js.map'))).toBeFalsy(); + expect(existsSync(resolve(__dirname, './dist/main.js.OTHER.LICENSE.txt'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js.map'))).toBeFalsy(); // Correct mode should be propagated to the compiler - readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { + readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); expect(data).toContain('none mode'); done(); @@ -110,8 +110,10 @@ describe('mode flags with config', () => { }); it('only config where mode is absent pick up from NODE_ENV', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config3.js', '-c', './webpack.config2.js'], false, [], { - NODE_ENV: 'production', + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config3.js', '-c', './webpack.config2.js'], { + env: { + NODE_ENV: 'production', + }, }); expect(exitCode).toEqual(0); diff --git a/test/node/node.test.js b/test/node/node.test.js index 79c143d1e2e..134bc3ee6bf 100644 --- a/test/node/node.test.js +++ b/test/node/node.test.js @@ -7,10 +7,9 @@ const { run } = require('../utils/test-utils'); // throws different error from what we manually see describe('node flags', () => { it('is able to pass the options flags to node js', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ['--output-path', './bin'], false, [ - `--require=${resolve(__dirname, 'bootstrap.js')}`, - `--require=${resolve(__dirname, 'bootstrap2.js')}`, - ]); + const { exitCode, stderr, stdout } = await run(__dirname, ['--output-path', './bin'], { + nodeOptions: [`--require=${resolve(__dirname, 'bootstrap.js')}`, `--require=${resolve(__dirname, 'bootstrap2.js')}`], + }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -19,7 +18,7 @@ describe('node flags', () => { }); it('throws an error on supplying unknown flags', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--unknown']); + const { exitCode, stderr, stdout } = await run(__dirname, [], { nodeOptions: ['--unknown'] }); expect(exitCode).not.toBe(0); expect(stderr).toContain('bad option'); @@ -27,7 +26,7 @@ describe('node flags', () => { }); it('throws an error if no values were supplied with --max-old-space-size', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--max-old-space-size']); + const { exitCode, stderr, stdout } = await run(__dirname, [], { nodeOptions: ['--max-old-space-size'] }); expect(exitCode).not.toBe(0); expect(stderr).toContain('value for flag --max-old-space-size'); @@ -35,7 +34,7 @@ describe('node flags', () => { }); it('throws an error if an illegal value was supplied with --max-old-space-size', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [], true, ['--max_old_space_size=1024a']); + const { exitCode, stderr, stdout } = await run(__dirname, [], { nodeOptions: ['--max_old_space_size=1024a'] }); expect(exitCode).not.toBe(0); expect(stderr).toContain('Error: illegal value for flag --max_old_space_size=1024a of type size_t'); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 5a05c90fa80..a188e557730 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -28,7 +28,7 @@ describe('basic serve usage', () => { } it('should work', async () => { - const { stderr, stdout } = await runServe([''], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -36,7 +36,7 @@ describe('basic serve usage', () => { }); it('should work in multi compiler mode', async () => { - const { stderr, stdout } = await runServe(['serve', '--config', 'multi.config.js', '--port', port], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'multi.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -48,7 +48,7 @@ describe('basic serve usage', () => { // TODO need fix in future, edge case it.skip('should work in multi compiler mode with multiple dev servers', async () => { - const { stderr, stdout } = await runServe(['serve', '--config', 'multi-dev-server.config.js'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'multi-dev-server.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -59,7 +59,7 @@ describe('basic serve usage', () => { }); it('should work with the "--mode" option', async () => { - const { stderr, stdout } = await runServe([], __dirname); + const { stderr, stdout } = await runServe(__dirname, []); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); @@ -84,7 +84,7 @@ describe('basic serve usage', () => { }); it('should work with the "--mode" option #2', async () => { - const { stderr, stdout } = await runServe(['--mode', 'production'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['--mode', 'production']); expect(stderr).toBeFalsy(); expect(stdout).toContain('production'); @@ -93,7 +93,7 @@ describe('basic serve usage', () => { }); it('should work with the "--mode" option #3', async () => { - const { stderr, stdout } = await runServe(['--mode', 'development'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['--mode', 'development']); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); @@ -102,7 +102,7 @@ describe('basic serve usage', () => { }); it('should work with the "--progress" option', async () => { - const { stderr, stdout } = await runServe(['--progress'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['--progress']); expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); @@ -110,7 +110,7 @@ describe('basic serve usage', () => { }); it('should work with the "--progress" option using the "profile" value', async () => { - const { stderr, stdout } = await runServe(['--progress', 'profile'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['--progress', 'profile']); expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); @@ -118,7 +118,7 @@ describe('basic serve usage', () => { }); it('should log help information and respect the "--no-color" option', async () => { - const { stdout, stderr } = await runServe(['--help', '--no-color'], __dirname); + const { stdout, stderr } = await runServe(__dirname, ['--help', '--no-color']); expect(stderr).toBeFalsy(); expect(stdout).toContain(usageText); @@ -126,7 +126,7 @@ describe('basic serve usage', () => { }); it('should work with the "--client-log-level" option', async () => { - const { stdout, stderr } = await runServe(['--client-log-level', 'info'], testPath); + const { stdout, stderr } = await runServe(testPath, ['--client-log-level', 'info']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -134,7 +134,7 @@ describe('basic serve usage', () => { }); it('should work with the "--port" option', async () => { - const { stdout, stderr } = await runServe(['--port', port], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -142,7 +142,7 @@ describe('basic serve usage', () => { }); it('should work with the "--hot" option', async () => { - const { stderr, stdout } = await runServe(['--hot'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['--hot']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -150,7 +150,7 @@ describe('basic serve usage', () => { }); it('should work with the "--no-hot" option', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port, '--no-hot']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -158,7 +158,7 @@ describe('basic serve usage', () => { }); it('should work with the "--hot" option using the "only" value', async () => { - const { stdout, stderr } = await runServe(['--port', port, isDevServer4 ? '--hot only' : '--hot-only'], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port, isDevServer4 ? '--hot only' : '--hot-only']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -166,7 +166,7 @@ describe('basic serve usage', () => { }); it('should work with "--hot" and "--port" options', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port, '--hot']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -174,7 +174,7 @@ describe('basic serve usage', () => { }); it('should work with the "--hot" and "--progress" options', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--hot', '--progress'], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port, '--hot', '--progress']); expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); @@ -182,7 +182,7 @@ describe('basic serve usage', () => { }); it('should work with the default "publicPath" option', async () => { - const { stderr, stdout } = await runServe(['serve'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['serve']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -191,7 +191,7 @@ describe('basic serve usage', () => { }); it('should work with the "--output-public-path" option', async () => { - const { stderr, stdout } = await runServe(['serve', '--output-public-path', '/my-public-path/'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['serve', '--output-public-path', '/my-public-path/']); if (isWebpack5) { expect(stderr).toBeFalsy(); @@ -205,7 +205,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration', async () => { - const { stderr, stdout } = await runServe(['serve', '--config', 'output-public-path.config.js'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'output-public-path.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -214,7 +214,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration using multi compiler mode', async () => { - const { stderr, stdout } = await runServe(['serve', '--config', 'multi-output-public-path.config.js', '--port', port], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'multi-output-public-path.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -226,7 +226,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration (from the "devServer" options)', async () => { - const { stderr, stdout } = await runServe(['serve', '--config', 'dev-server-output-public-path.config.js'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'dev-server-output-public-path.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -235,7 +235,7 @@ describe('basic serve usage', () => { }); it('should work with the "--open" option', async () => { - const { stdout, stderr } = await runServe(['--open', '--port', port], testPath); + const { stdout, stderr } = await runServe(testPath, ['--open', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -243,10 +243,13 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration using multi compiler mode (from the "devServer" options)', async () => { - const { stderr, stdout } = await runServe( - ['serve', '--config', 'multi-dev-server-output-public-path.config.js', '--port', port], - __dirname, - ); + const { stderr, stdout } = await runServe(__dirname, [ + 'serve', + '--config', + 'multi-dev-server-output-public-path.config.js', + '--port', + port, + ]); expect(stderr).toBeFalsy(); expect(stderr).toBeFalsy(); @@ -259,7 +262,7 @@ describe('basic serve usage', () => { }); it('should log and error on unknown flag', async () => { - const { exitCode, stdout, stderr } = await runServe(['--port', port, '--unknown-flag'], testPath); + const { exitCode, stdout, stderr } = await runServe(testPath, ['--port', port, '--unknown-flag']); expect(exitCode).toBe(2); expect(stderr).toContain("unknown option '--unknown-flag'"); diff --git a/test/serve/serve-variable/serve-basic.test.js b/test/serve/serve-variable/serve-basic.test.js index ee4b3b93c62..065f471d17b 100644 --- a/test/serve/serve-variable/serve-basic.test.js +++ b/test/serve/serve-variable/serve-basic.test.js @@ -24,7 +24,7 @@ describe('serve variable', () => { } it('compiles without flags and export variable', async () => { - const { stdout, stderr } = await runServe(['--port', port], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); diff --git a/test/serve/with-custom-port/serve-custom-config.test.js b/test/serve/with-custom-port/serve-custom-config.test.js index 4903e7ea7eb..ded0f9aef99 100644 --- a/test/serve/with-custom-port/serve-custom-config.test.js +++ b/test/serve/with-custom-port/serve-custom-config.test.js @@ -24,7 +24,7 @@ describe('serve with devServer in config', () => { } it('Should pick up the host and port from config', async () => { - const { stdout, stderr } = await runServe([], testPath); + const { stdout, stderr } = await runServe(testPath, []); expect(stderr).toBeFalsy(); // Should output the correct bundle file @@ -35,7 +35,7 @@ describe('serve with devServer in config', () => { }); it('Port flag should override the config port', async () => { - const { stdout, stderr } = await runServe(['--port', port], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port]); expect(stderr).toBeFalsy(); // Should output the correct bundle file @@ -46,7 +46,7 @@ describe('serve with devServer in config', () => { }); it('Passing hot flag works alongside other server config', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port, '--hot']); expect(stderr).toBeFalsy(); // Should output the correct bundle file @@ -58,7 +58,7 @@ describe('serve with devServer in config', () => { }); it('works fine when no-hot flag is passed alongside other server config', async () => { - const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + const { stdout, stderr } = await runServe(testPath, ['--port', port, '--no-hot']); expect(stderr).toBeFalsy(); // Should output the correct bundle file diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 8515dbced2b..f78f155d558 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -40,24 +40,20 @@ const hyphenToUpperCase = (name) => { * * @param {String} testCase The path to folder that contains the webpack.config.js * @param {Array} args Array of arguments to pass to webpack - * @param {Boolean} setOutput Boolean that decides if a default output path will be set or not * @param {Array} nodeOptions Boolean that decides if a default output path will be set or not * @param {Record} env Boolean that decides if a default output path will be set or not * @returns {Object} The webpack output or Promise when nodeOptions are present */ -const run = (testCase, args = [], setOutput = true, nodeOptions = [], env) => { +const run = (testCase, args = [], options = {}) => { const cwd = path.resolve(testCase); - - const outputPath = path.resolve(testCase, 'bin'); + const { nodeOptions = [] } = options; const processExecutor = nodeOptions.length ? execaNode : spawnSync; - const argsWithOutput = setOutput ? args.concat('--output-path', outputPath) : args; - const result = processExecutor(WEBPACK_PATH, argsWithOutput, { + const result = processExecutor(WEBPACK_PATH, args, { cwd, reject: false, - nodeOptions: nodeOptions, - env, stdio: ENABLE_LOG_COMPILATION ? 'inherit' : 'pipe', maxBuffer: Infinity, + ...options, }); return result; @@ -252,7 +248,7 @@ const runInstall = async (cwd) => { }); }; -const runServe = (args, testPath) => { +const runServe = (testPath, args) => { return runWatch(testPath, ['serve'].concat(args), false); }; diff --git a/test/utils/test-utils.test.js b/test/utils/test-utils.test.js index 0e4d3aeafb6..360d2bc999e 100644 --- a/test/utils/test-utils.test.js +++ b/test/utils/test-utils.test.js @@ -41,8 +41,6 @@ describe('run function', () => { expect(stderr).toBeFalsy(); // Executes the correct command expect(command).toContain('cli.js'); - // Should use apply a default output dir - expect(command).toContain('--output-path'); expect(command).toContain('bin'); expect(stdout).toBeTruthy(); }); From 5a52cdf5ff518972dbe01f154747ef979a86578c Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 9 Jan 2021 18:09:23 +0530 Subject: [PATCH 242/581] chore: update webpack to 5.12.2 (#2334) --- OPTIONS.md | 155 ++++++++++++++++-- package.json | 2 +- test/core-flags/module-flags.test.js | 36 +++- test/entry/flag-entry/entry-with-flag.test.js | 27 ++- test/serve/basic/serve-basic.test.js | 6 +- yarn.lock | 18 +- 6 files changed, 202 insertions(+), 42 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index c8b1025d4a8..24b6d9e094b 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -47,6 +47,8 @@ Options: --no-experiments-asset Negative 'experiments-asset' option. --experiments-async-web-assembly Support WebAssembly as asynchronous EcmaScript Module. --no-experiments-async-web-assembly Negative 'experiments-async-web-assembly' option. + --experiments-layers Enable module and chunk layers. + --no-experiments-layers Negative 'experiments-layers' option. --experiments-output-module Allow output javascript files as module source type. --no-experiments-output-module Negative 'experiments-output-module' option. --experiments-sync-web-assembly Support WebAssembly as synchronous EcmaScript Module (outdated). @@ -87,14 +89,143 @@ Options: --no-module-expr-context-recursive Negative 'module-expr-context-recursive' option. --module-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. --module-expr-context-request Set the default request for full dynamic dependencies. + --module-generator-asset-data-url-encoding Asset encoding (defaults to base64). + --module-generator-asset-data-url-mimetype Asset mimetype (getting from file extension by default). + --module-generator-asset-filename Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk. + --module-generator-asset-inline-data-url-encoding Asset encoding (defaults to base64). + --module-generator-asset-inline-data-url-mimetype Asset mimetype (getting from file extension by default). + --module-generator-asset-resource-filename Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk. --module-no-parse A regular expression, when matched the module is not parsed. An absolute path, when the module starts with this path it is not parsed. --module-no-parse-reset Clear all items provided in configuration. Don't parse files matching. It's matched against the full resolved request. + --module-parser-asset-data-url-condition-max-size Maximum size of asset that should be inline as modules. Default: 8kb. + --module-parser-javascript-amd You can pass `false` to disable AMD support. + --no-module-parser-javascript-amd Negative 'module-parser-javascript-amd' option. + --module-parser-javascript-browserify Enable/disable special handling for browserify bundles. + --no-module-parser-javascript-browserify Negative 'module-parser-javascript-browserify' option. + --module-parser-javascript-commonjs Enable/disable parsing of CommonJs syntax. + --no-module-parser-javascript-commonjs Negative 'module-parser-javascript-commonjs' option. + --module-parser-javascript-harmony Enable/disable parsing of EcmaScript Modules syntax. + --no-module-parser-javascript-harmony Negative 'module-parser-javascript-harmony' option. + --module-parser-javascript-import Enable/disable parsing of import() syntax. + --no-module-parser-javascript-import Negative 'module-parser-javascript-import' option. + --module-parser-javascript-node Include polyfills or mocks for various node stuff. + --no-module-parser-javascript-node Negative 'module-parser-javascript-node' option. + --module-parser-javascript-node-dirname Include a polyfill for the '__dirname' variable. + --module-parser-javascript-node-filename Include a polyfill for the '__filename' variable. + --module-parser-javascript-node-global Include a polyfill for the 'global' variable. + --no-module-parser-javascript-node-global Negative 'module-parser-javascript-node-global' option. + --module-parser-javascript-require-context Enable/disable parsing of require.context syntax. + --no-module-parser-javascript-require-context Negative 'module-parser-javascript-require-context' option. + --module-parser-javascript-require-ensure Enable/disable parsing of require.ensure syntax. + --no-module-parser-javascript-require-ensure Negative 'module-parser-javascript-require-ensure' option. + --module-parser-javascript-require-include Enable/disable parsing of require.include syntax. + --no-module-parser-javascript-require-include Negative 'module-parser-javascript-require-include' option. + --module-parser-javascript-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. + --no-module-parser-javascript-require-js Negative 'module-parser-javascript-require-js' option. + --module-parser-javascript-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. + --no-module-parser-javascript-system Negative 'module-parser-javascript-system' option. + --module-parser-javascript-url Enable/disable parsing of new URL() syntax. + --no-module-parser-javascript-url Negative 'module-parser-javascript-url' option. + --module-parser-javascript-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-auto-amd You can pass `false` to disable AMD support. + --no-module-parser-javascript-auto-amd Negative 'module-parser-javascript-auto-amd' option. + --module-parser-javascript-auto-browserify Enable/disable special handling for browserify bundles. + --no-module-parser-javascript-auto-browserify Negative 'module-parser-javascript-auto-browserify' option. + --module-parser-javascript-auto-commonjs Enable/disable parsing of CommonJs syntax. + --no-module-parser-javascript-auto-commonjs Negative 'module-parser-javascript-auto-commonjs' option. + --module-parser-javascript-auto-harmony Enable/disable parsing of EcmaScript Modules syntax. + --no-module-parser-javascript-auto-harmony Negative 'module-parser-javascript-auto-harmony' option. + --module-parser-javascript-auto-import Enable/disable parsing of import() syntax. + --no-module-parser-javascript-auto-import Negative 'module-parser-javascript-auto-import' option. + --module-parser-javascript-auto-node Include polyfills or mocks for various node stuff. + --no-module-parser-javascript-auto-node Negative 'module-parser-javascript-auto-node' option. + --module-parser-javascript-auto-node-dirname Include a polyfill for the '__dirname' variable. + --module-parser-javascript-auto-node-filename Include a polyfill for the '__filename' variable. + --module-parser-javascript-auto-node-global Include a polyfill for the 'global' variable. + --no-module-parser-javascript-auto-node-global Negative 'module-parser-javascript-auto-node-global' option. + --module-parser-javascript-auto-require-context Enable/disable parsing of require.context syntax. + --no-module-parser-javascript-auto-require-context Negative 'module-parser-javascript-auto-require-context' option. + --module-parser-javascript-auto-require-ensure Enable/disable parsing of require.ensure syntax. + --no-module-parser-javascript-auto-require-ensure Negative 'module-parser-javascript-auto-require-ensure' option. + --module-parser-javascript-auto-require-include Enable/disable parsing of require.include syntax. + --no-module-parser-javascript-auto-require-include Negative 'module-parser-javascript-auto-require-include' option. + --module-parser-javascript-auto-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. + --no-module-parser-javascript-auto-require-js Negative 'module-parser-javascript-auto-require-js' option. + --module-parser-javascript-auto-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. + --no-module-parser-javascript-auto-system Negative 'module-parser-javascript-auto-system' option. + --module-parser-javascript-auto-url Enable/disable parsing of new URL() syntax. + --no-module-parser-javascript-auto-url Negative 'module-parser-javascript-auto-url' option. + --module-parser-javascript-auto-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-auto-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-dynamic-amd You can pass `false` to disable AMD support. + --no-module-parser-javascript-dynamic-amd Negative 'module-parser-javascript-dynamic-amd' option. + --module-parser-javascript-dynamic-browserify Enable/disable special handling for browserify bundles. + --no-module-parser-javascript-dynamic-browserify Negative 'module-parser-javascript-dynamic-browserify' option. + --module-parser-javascript-dynamic-commonjs Enable/disable parsing of CommonJs syntax. + --no-module-parser-javascript-dynamic-commonjs Negative 'module-parser-javascript-dynamic-commonjs' option. + --module-parser-javascript-dynamic-harmony Enable/disable parsing of EcmaScript Modules syntax. + --no-module-parser-javascript-dynamic-harmony Negative 'module-parser-javascript-dynamic-harmony' option. + --module-parser-javascript-dynamic-import Enable/disable parsing of import() syntax. + --no-module-parser-javascript-dynamic-import Negative 'module-parser-javascript-dynamic-import' option. + --module-parser-javascript-dynamic-node Include polyfills or mocks for various node stuff. + --no-module-parser-javascript-dynamic-node Negative 'module-parser-javascript-dynamic-node' option. + --module-parser-javascript-dynamic-node-dirname Include a polyfill for the '__dirname' variable. + --module-parser-javascript-dynamic-node-filename Include a polyfill for the '__filename' variable. + --module-parser-javascript-dynamic-node-global Include a polyfill for the 'global' variable. + --no-module-parser-javascript-dynamic-node-global Negative 'module-parser-javascript-dynamic-node-global' option. + --module-parser-javascript-dynamic-require-context Enable/disable parsing of require.context syntax. + --no-module-parser-javascript-dynamic-require-context Negative 'module-parser-javascript-dynamic-require-context' option. + --module-parser-javascript-dynamic-require-ensure Enable/disable parsing of require.ensure syntax. + --no-module-parser-javascript-dynamic-require-ensure Negative 'module-parser-javascript-dynamic-require-ensure' option. + --module-parser-javascript-dynamic-require-include Enable/disable parsing of require.include syntax. + --no-module-parser-javascript-dynamic-require-include Negative 'module-parser-javascript-dynamic-require-include' option. + --module-parser-javascript-dynamic-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. + --no-module-parser-javascript-dynamic-require-js Negative 'module-parser-javascript-dynamic-require-js' option. + --module-parser-javascript-dynamic-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. + --no-module-parser-javascript-dynamic-system Negative 'module-parser-javascript-dynamic-system' option. + --module-parser-javascript-dynamic-url Enable/disable parsing of new URL() syntax. + --no-module-parser-javascript-dynamic-url Negative 'module-parser-javascript-dynamic-url' option. + --module-parser-javascript-dynamic-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-dynamic-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-esm-amd You can pass `false` to disable AMD support. + --no-module-parser-javascript-esm-amd Negative 'module-parser-javascript-esm-amd' option. + --module-parser-javascript-esm-browserify Enable/disable special handling for browserify bundles. + --no-module-parser-javascript-esm-browserify Negative 'module-parser-javascript-esm-browserify' option. + --module-parser-javascript-esm-commonjs Enable/disable parsing of CommonJs syntax. + --no-module-parser-javascript-esm-commonjs Negative 'module-parser-javascript-esm-commonjs' option. + --module-parser-javascript-esm-harmony Enable/disable parsing of EcmaScript Modules syntax. + --no-module-parser-javascript-esm-harmony Negative 'module-parser-javascript-esm-harmony' option. + --module-parser-javascript-esm-import Enable/disable parsing of import() syntax. + --no-module-parser-javascript-esm-import Negative 'module-parser-javascript-esm-import' option. + --module-parser-javascript-esm-node Include polyfills or mocks for various node stuff. + --no-module-parser-javascript-esm-node Negative 'module-parser-javascript-esm-node' option. + --module-parser-javascript-esm-node-dirname Include a polyfill for the '__dirname' variable. + --module-parser-javascript-esm-node-filename Include a polyfill for the '__filename' variable. + --module-parser-javascript-esm-node-global Include a polyfill for the 'global' variable. + --no-module-parser-javascript-esm-node-global Negative 'module-parser-javascript-esm-node-global' option. + --module-parser-javascript-esm-require-context Enable/disable parsing of require.context syntax. + --no-module-parser-javascript-esm-require-context Negative 'module-parser-javascript-esm-require-context' option. + --module-parser-javascript-esm-require-ensure Enable/disable parsing of require.ensure syntax. + --no-module-parser-javascript-esm-require-ensure Negative 'module-parser-javascript-esm-require-ensure' option. + --module-parser-javascript-esm-require-include Enable/disable parsing of require.include syntax. + --no-module-parser-javascript-esm-require-include Negative 'module-parser-javascript-esm-require-include' option. + --module-parser-javascript-esm-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. + --no-module-parser-javascript-esm-require-js Negative 'module-parser-javascript-esm-require-js' option. + --module-parser-javascript-esm-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. + --no-module-parser-javascript-esm-system Negative 'module-parser-javascript-esm-system' option. + --module-parser-javascript-esm-url Enable/disable parsing of new URL() syntax. + --no-module-parser-javascript-esm-url Negative 'module-parser-javascript-esm-url' option. + --module-parser-javascript-esm-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-esm-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). --module-rules-compiler Match the child compiler name. --module-rules-dependency Match dependency type. --module-rules-enforce Enforce this rule as pre or post step. --module-rules-exclude Shortcut for resource.exclude. --module-rules-include Shortcut for resource.include. --module-rules-issuer Match the issuer of the module (The module pointing to this module). + --module-rules-issuer-layer Match layer of the issuer of this module (The module pointing to this module). + --module-rules-layer Specifies the layer in which the module should be placed in. --module-rules-loader A loader request. --module-rules-mimetype Match module mimetype when load from Data URI. --module-rules-real-resource Match the real resource path of the module. @@ -194,10 +325,10 @@ Options: --optimization-split-chunks-used-exports Compare used exports when checking common modules. Modules will only be put in the same chunk when exports are equal. --no-optimization-split-chunks-used-exports Negative 'optimization-split-chunks-used-exports' option. --optimization-used-exports Figure out which exports are used by modules to mangle export names, omit unused exports and generate more efficient code (true: analyse used exports for each runtime, "global": analyse exports globally for all runtimes combined). - --output-asset-module-filename The filename of asset modules as relative path inside the `output.path` directory. + --output-asset-module-filename The filename of asset modules as relative path inside the 'output.path' directory. --output-charset Add charset attribute for script tag. --no-output-charset Negative 'output-charset' option. - --output-chunk-filename The filename of non-initial chunks as relative path inside the `output.path` directory. + --output-chunk-filename Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk. --output-chunk-format The format of chunks (formats included by default are 'array-push' (web/WebWorker), 'commonjs' (node.js), but others might be added by plugins). --output-chunk-load-timeout Number of milliseconds before chunk request expires. --output-chunk-loading The method of loading chunks (methods included by default are 'jsonp' (web), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins). @@ -228,7 +359,7 @@ Options: --no-output-environment-for-of Negative 'output-environment-for-of' option. --output-environment-module The environment supports EcmaScript Module syntax to import EcmaScript modules (import ... from '...'). --no-output-environment-module Negative 'output-environment-module' option. - --output-filename Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files. + --output-filename Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk. --output-global-object An expression which is used to address the global object/scope in runtime code. --output-hash-digest Digest type used for the hash. --output-hash-digest-length Number of chars which are used for the hash. @@ -236,7 +367,7 @@ Options: --output-hash-salt Any string which is added to the hash to salt it. --output-hot-update-chunk-filename The filename of the Hot Update Chunks. They are inside the output.path directory. --output-hot-update-global The global variable used by webpack for loading of hot update chunks. - --output-hot-update-main-filename The filename of the Hot Update Main File. It is inside the `output.path` directory. + --output-hot-update-main-filename The filename of the Hot Update Main File. It is inside the 'output.path' directory. --output-iife Wrap javascript code into IIFE's to avoid leaking into global scope. --no-output-iife Negative 'output-iife' option. --output-import-function-name The name of the native import() function (can be exchanged for a polyfill). @@ -266,17 +397,16 @@ Options: --output-module Output javascript files as module source type. --no-output-module Negative 'output-module' option. -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - --output-pathinfo Include comments with information about the modules. - --no-output-pathinfo Negative 'output-pathinfo' option. + --output-pathinfo Include comments with information about the modules. --output-public-path The `publicPath` specifies the public URL address of the output files when referenced in a browser. --output-script-type This option enables loading async chunks via a custom script type, such as script type="module". - --output-source-map-filename The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory. + --output-source-map-filename The filename of the SourceMaps for the JavaScript files. They are inside the 'output.path' directory. --output-source-prefix Prefixes every line of the source in the bundle with this string. --output-strict-module-exception-handling Handles exceptions in module loading correctly at a performance cost. --no-output-strict-module-exception-handling Negative 'output-strict-module-exception-handling' option. --output-unique-name A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. --output-wasm-loading The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins). - --output-webassembly-module-filename The filename of WebAssembly modules as relative path inside the `output.path` directory. + --output-webassembly-module-filename The filename of WebAssembly modules as relative path inside the 'output.path' directory. --output-worker-chunk-loading The method of loading chunks (methods included by default are 'jsonp' (web), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins). --output-worker-wasm-loading The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins). --parallelism The number of parallel processed modules in the compilation. @@ -416,7 +546,7 @@ Options: --stats-assets-space Space to display assets (groups will be collapsed to fit this space). --stats-built-at Add built at time information. --no-stats-built-at Negative 'stats-built-at' option. - --stats-cached Add information about cached (not built) modules. + --stats-cached Add information about cached (not built) modules (deprecated: use 'cachedModules' instead). --no-stats-cached Negative 'stats-cached' option. --stats-cached-assets Show cached assets (setting this to `false` only shows emitted files). --no-stats-cached-assets Negative 'stats-cached-assets' option. @@ -484,6 +614,8 @@ Options: --no-stats-group-modules-by-cache-status Negative 'stats-group-modules-by-cache-status' option. --stats-group-modules-by-extension Group modules by their extension. --no-stats-group-modules-by-extension Negative 'stats-group-modules-by-extension' option. + --stats-group-modules-by-layer Group modules by their layer. + --no-stats-group-modules-by-layer Negative 'stats-group-modules-by-layer' option. --stats-group-modules-by-path Group modules by their path. --no-stats-group-modules-by-path Negative 'stats-group-modules-by-path' option. --stats-hash Add the hash of the compilation. @@ -502,9 +634,10 @@ Options: --stats-modules Add built modules information. --no-stats-modules Negative 'stats-modules' option. --stats-modules-sort Sort the modules by that field. - --stats-modules-space Space to display modules (groups will be collapsed to fit this space, values is in number of modules/groups). + --stats-modules-space Space to display modules (groups will be collapsed to fit this space, value is in number of modules/groups). --stats-nested-modules Add information about modules nested in other modules (like with module concatenation). --no-stats-nested-modules Negative 'stats-nested-modules' option. + --stats-nested-modules-space Space to display modules nested within other modules (groups will be collapsed to fit this space, value is in number of modules/group). --stats-optimization-bailout Show reasons why optimization bailed out for modules. --no-stats-optimization-bailout Negative 'stats-optimization-bailout' option. --stats-orphan-modules Add information about orphan modules. @@ -522,6 +655,8 @@ Options: --no-stats-reasons Negative 'stats-reasons' option. --stats-related-assets Add information about assets that are related to other assets (like SourceMaps for assets). --no-stats-related-assets Negative 'stats-related-assets' option. + --stats-runtime Add information about runtime modules (deprecated: use 'runtimeModules' instead). + --no-stats-runtime Negative 'stats-runtime' option. --stats-runtime-modules Add information about runtime modules. --no-stats-runtime-modules Negative 'stats-runtime-modules' option. --stats-source Add the source code of modules. diff --git a/package.json b/package.json index ff220211e8a..c7c117f6011 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", "typescript": "^3.9.7", - "webpack": "^5.11.1", + "webpack": "^5.12.2", "webpack-bundle-analyzer": "^4.3.0", "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index b166f248c63..bc7ccd1faa6 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -16,7 +16,7 @@ describe('module config related flag', () => { const propName = hyphenToUpperCase(property); - if (flag.type === Boolean && !flag.name.includes('module-no-parse')) { + if (flag.type === Boolean && !flag.name.includes('module-no-parse') && !flag.name.includes('module-parser-')) { it(`should config --${flag.name} correctly`, () => { if (flag.name.includes('-reset')) { const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); @@ -55,7 +55,7 @@ describe('module config related flag', () => { } } - if (flag.type === String) { + if (flag.type === String && !(flag.name.includes('module-parser-') || flag.name.startsWith('module-generator'))) { it(`should config --${flag.name} correctly`, () => { if (flag.name === 'module-no-parse') { let { stderr, stdout, exitCode } = run(__dirname, [`--${flag.name}`, 'value']); @@ -94,4 +94,36 @@ describe('module config related flag', () => { }); } }); + + it('should config module.generator flags coorectly', () => { + const { exitCode, stderr, stdout } = run(__dirname, [ + '--module-generator-asset-data-url-encoding', + 'base64', + '--module-generator-asset-data-url-mimetype', + 'application/node', + ]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`generator: { asset: { dataUrl: [Object] } }`); + }); + + it('should config module.parser flags coorectly', () => { + const { exitCode, stderr, stdout } = run(__dirname, [ + '--module-parser-javascript-browserify', + '--module-parser-javascript-commonjs', + '--module-parser-javascript-harmony', + '--module-parser-javascript-import', + '--no-module-parser-javascript-node', + '--module-parser-javascript-require-include', + ]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('browserify: true'); + expect(stdout).toContain('commonjs: true'); + expect(stdout).toContain('harmony: true'); + expect(stdout).toContain('import: true'); + expect(stdout).toContain('node: false'); + }); }); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index 6f3445111a3..03475c99ae3 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { run, isWebpack5 } = require('../../utils/test-utils'); +const { run } = require('../../utils/test-utils'); const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); @@ -21,25 +21,18 @@ describe('entry flag', () => { expect(stdout).toBeTruthy(); }); - it('should resolve the path to /src/a.js as ./src/a.js for webpack-5 only', (done) => { + it('should resolve the path to /src/a.js as ./src/a.js', (done) => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', '/src/a.js']); - if (!isWebpack5) { - expect(exitCode).toBe(1); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(`Module not found: Error: Can't resolve`); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); + readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { + expect(err).toBe(null); + expect(data).toContain('Hello from a.js'); done(); - } else { - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); - readFile(resolve(__dirname, './dist/main.js'), 'utf-8', (err, data) => { - expect(err).toBe(null); - expect(data).toContain('Hello from a.js'); - done(); - }); - } + }); }); it('should throw error for invalid entry file', () => { diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index a188e557730..0c5b1c55236 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -68,15 +68,15 @@ describe('basic serve usage', () => { }); it('should work with the "--stats" option', async () => { - const { stderr, stdout } = await runServe(['--stats'], __dirname); + const { stderr, stdout } = await runServe(__dirname, ['--stats']); expect(stderr).toBeFalsy(); expect(stripAnsi(stdout)).toContain(isWebpack5 ? 'compiled successfully' : 'Version: webpack'); expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('should work with the "--stats detailed" option', async () => { - const { stderr, stdout } = await runServe(['--stats', 'verbose'], __dirname); + it('should work with the "--stats verbose" option', async () => { + const { stderr, stdout } = await runServe(__dirname, ['--stats', 'verbose']); expect(stderr).toBeFalsy(); expect(stdout).toContain(isWebpack5 ? 'from webpack.Compiler' : 'webpack.buildChunkGraph.visitModules'); diff --git a/yarn.lock b/yarn.lock index 24e3a00612c..099ec6300a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7237,10 +7237,10 @@ load-json-file@^5.3.0: strip-bom "^3.0.0" type-fest "^0.3.0" -loader-runner@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.1.0.tgz#f70bc0c29edbabdf2043e7ee73ccc3fe1c96b42d" - integrity sha512-oR4lB4WvwFoC70ocraKhn5nkKSs23t57h9udUgw8o0iH8hMXeEoRuUgfcvgUwAJ1ZpRqBvcou4N2SMvM1DwMrA== +loader-runner@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.2.0.tgz#d7022380d66d14c5fb1d496b89864ebcfd478384" + integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== locate-path@^2.0.0: version "2.0.0" @@ -11076,10 +11076,10 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.11.1: - version "5.11.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.11.1.tgz#39b2b9daeb5c6c620e03b7556ec674eaed4016b4" - integrity sha512-tNUIdAmYJv+nupRs/U/gqmADm6fgrf5xE+rSlSsf2PgsGO7j2WG7ccU6AWNlOJlHFl+HnmXlBmHIkiLf+XA9mQ== +webpack@^5.12.2: + version "5.12.2" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.12.2.tgz#f79574cdb7a4ef711c5f47f3d189e045a14217e5" + integrity sha512-HiTXBGLFQiRecP5Fwrh21aaxlEUqQdDeUaninKVKX0Dtqaf+WjKCsNcv+UVftfYXrY0bnRQHnouw1x+CPqQKFQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" @@ -11096,7 +11096,7 @@ webpack@^5.11.1: glob-to-regexp "^0.4.1" graceful-fs "^4.2.4" json-parse-better-errors "^1.0.2" - loader-runner "^4.1.0" + loader-runner "^4.2.0" mime-types "^2.1.27" neo-async "^2.6.2" pkg-dir "^5.0.0" From 8e7fbefd7b7964804142a54a8c14588a87508060 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 9 Jan 2021 15:41:19 +0300 Subject: [PATCH 243/581] chore(deps-dev): bump husky from 4.3.6 to 4.3.7 (#2320) Bumps [husky](https://github.com/typicode/husky) from 4.3.6 to 4.3.7. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](https://github.com/typicode/husky/compare/v4.3.6...v4.3.7) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 099ec6300a5..1e74bbb5f56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4893,12 +4893,12 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" -find-versions@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/find-versions/-/find-versions-3.2.0.tgz#10297f98030a786829681690545ef659ed1d254e" - integrity sha512-P8WRou2S+oe222TOCHitLy8zj+SIsVJh52VP4lvXkaFVnOFFdoWv1H1Jjvel1aI6NCFOAaeAVm8qrI0odiLcww== +find-versions@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/find-versions/-/find-versions-4.0.0.tgz#3c57e573bf97769b8cb8df16934b627915da4965" + integrity sha512-wgpWy002tA+wgmO27buH/9KzyEOQnKsG/R0yrcjPT9BOFm0zRBVQbZ95nRGXWMywS8YR5knRbpohio0bcJABxQ== dependencies: - semver-regex "^2.0.0" + semver-regex "^3.1.2" findup-sync@^4.0.0: version "4.0.0" @@ -5754,17 +5754,17 @@ humanize-ms@^1.2.1: ms "^2.0.0" husky@^4.3.0: - version "4.3.6" - resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.6.tgz#ebd9dd8b9324aa851f1587318db4cccb7665a13c" - integrity sha512-o6UjVI8xtlWRL5395iWq9LKDyp/9TE7XMOTvIpEVzW638UcGxTmV5cfel6fsk/jbZSTlvfGVJf2svFtybcIZag== + version "4.3.7" + resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.7.tgz#ca47bbe6213c1aa8b16bbd504530d9600de91e88" + integrity sha512-0fQlcCDq/xypoyYSJvEuzbDPHFf8ZF9IXKJxlrnvxABTSzK1VPT2RKYQKrcgJ+YD39swgoB6sbzywUqFxUiqjw== dependencies: chalk "^4.0.0" ci-info "^2.0.0" compare-versions "^3.6.0" cosmiconfig "^7.0.0" - find-versions "^3.2.0" + find-versions "^4.0.0" opencollective-postinstall "^2.0.2" - pkg-dir "^4.2.0" + pkg-dir "^5.0.0" please-upgrade-node "^3.2.0" slash "^3.0.0" which-pm-runs "^1.0.0" @@ -9576,10 +9576,10 @@ semver-compare@^1.0.0: resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w= -semver-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-2.0.0.tgz#a93c2c5844539a770233379107b38c7b4ac9d338" - integrity sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw== +semver-regex@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.2.tgz#34b4c0d361eef262e07199dbef316d0f2ab11807" + integrity sha512-bXWyL6EAKOJa81XG1OZ/Yyuq+oT0b2YLlxx7c+mrdYPaPbnj6WgVULXhinMIeZGufuUBu/eVRqXEhiv4imfwxA== "semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0, semver@^5.7.1: version "5.7.1" From 62e6cc4311b1f3dcc453e9c89ab37d4cfa066c86 Mon Sep 17 00:00:00 2001 From: James George Date: Sat, 9 Jan 2021 18:57:10 +0530 Subject: [PATCH 244/581] tests: increase coverage (#2335) --- .../__snapshots__/init-generator.test.ts.snap | 24 ++++++++ .../__tests__/init-generator.test.ts | 57 ++++++++++++++++--- packages/generators/src/init-generator.ts | 2 +- 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index 9c510fc01d8..e6646d18f0e 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -227,3 +227,27 @@ Object { ], } `; + +exports[`init generator generates a webpack config with optional dependencies 1`] = ` +Object { + "devServer": Object { + "host": "'localhost'", + "open": true, + }, + "mode": "'development'", + "module": Object { + "rules": Array [], + }, + "plugins": Array [ + "new webpack.ProgressPlugin()", + "new HtmlWebpackPlugin({ + template: 'index.html' + })", + "new workboxPlugin.GenerateSW({ + swDest: 'sw.js', + clientsClaim: true, + skipWaiting: false, + })", + ], +} +`; diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index 7e42e4c9a94..78f5fa9c45b 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -31,6 +31,15 @@ describe('init generator', () => { expect(config.output).toEqual(undefined); // there are no special loaders, so rules should be empty expect(config.module.rules).toEqual([]); + + // WDS and Workbox webpack plugin gets configured by default + expect(config.devServer).toEqual({ + host: "'localhost'", + open: true, + }); + expect(config.plugins.length).toBe(2); + expect(config.plugins[1]).toContain('workboxPlugin'); + // match config snapshot expect(config).toMatchSnapshot(); }); @@ -48,9 +57,6 @@ describe('init generator', () => { const filePaths = ['package.json', 'README.md', 'src/index2.js']; assert.file(filePaths.map((file) => join(outputDir, file))); - // this file is only added if the default options are used - assert.noFile(join(outputDir, 'sw.js')); - // Check generated file contents assert.fileContent(join(outputDir, 'src', 'index2.js'), "console.log('Hello World from your main file!');"); @@ -62,7 +68,7 @@ describe('init generator', () => { expect(config.output.path).toEqual("path.resolve(__dirname, 'dist2')"); // there are no special loaders, so rules should be empty expect(config.module.rules).toEqual([]); - //match config snapshot + // match config snapshot expect(config).toMatchSnapshot(); }); @@ -88,7 +94,7 @@ describe('init generator', () => { expect(config.module.rules[0].use.length).toEqual(2); expect(config.module.rules[0].use[0].loader).toEqual('"style-loader"'); expect(config.module.rules[0].use[1].loader).toEqual('"css-loader"'); - //match config snapshot + // match config snapshot expect(config).toMatchSnapshot(); }); @@ -115,7 +121,7 @@ describe('init generator', () => { expect(config.module.rules[0].use.length).toEqual(2); expect(config.module.rules[0].use[0].loader).toEqual('MiniCssExtractPlugin.loader'); expect(config.module.rules[0].use[1].loader).toEqual('"css-loader"'); - //match config snapshot + // match config snapshot expect(config).toMatchSnapshot(); }); @@ -146,7 +152,7 @@ describe('init generator', () => { test1: "'./dir1/test1.js'", test2: "'./dir2/test2.js'", }); - //match config snapshot + // match config snapshot expect(config).toMatchSnapshot(); }); @@ -174,7 +180,7 @@ describe('init generator', () => { loader: "'babel-loader'", }, ]); - //match config snapshot + // match config snapshot expect(config).toMatchSnapshot(); }); @@ -203,11 +209,44 @@ describe('init generator', () => { exclude: ['/node_modules/'], }, ]); - //match config snapshot + // match config snapshot expect(config).toMatchSnapshot(); // eslint-disable-next-line @typescript-eslint/no-var-requires const tsconfigContents = require(join(outputDir, 'tsconfig.json')); expect(tsconfigContents).toMatchSnapshot(); }); + + it('generates a webpack config with optional dependencies', async () => { + const outputDir = await run(join(__dirname, '../src/init-generator.ts')).withPrompts({ + multiEntries: false, + singularEntry: 'src/index', + outputDir: 'dist', + langType: 'No', + stylingType: 'No', + useDevServer: true, + useHTMLPlugin: true, + useWorkboxPlugin: true, + }); + + // Check that all the project files are generated with the correct name + const filePaths = ['package.json', 'README.md', 'src/index.js']; + assert.file(filePaths.map((file) => join(outputDir, file))); + + // eslint-disable-next-line @typescript-eslint/no-var-requires + const output = require(join(outputDir, '.yo-rc.json')); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const config = (Object.entries(output)[0][1] as any).configuration.config.webpackOptions; + + expect(config.devServer).toEqual({ + host: "'localhost'", + open: true, + }); + expect(config.plugins.length).toBe(3); + expect(config.plugins[1]).toContain('HtmlWebpackPlugin'); + expect(config.plugins[2]).toContain('workboxPlugin'); + + // match config snapshot + expect(config).toMatchSnapshot(); + }); }); diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 75d92774f4c..f26e71ef985 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -26,7 +26,7 @@ export default class InitGenerator extends CustomGenerator { public constructor(args, opts) { super(args, opts); - this.autoGenerateConfig = opts.autoSetDefaults ? true : false; + this.autoGenerateConfig = opts.autoSetDefaults; this.generationPath = opts.generationPath; this.dependencies = ['webpack', 'webpack-cli', 'babel-plugin-syntax-dynamic-import']; From c0086f3372ccfc218395b38d667678cf6c924bbd Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Sat, 9 Jan 2021 19:43:26 +0530 Subject: [PATCH 245/581] tests: serve help (#2317) * tests: serve help * fix: tests * fix: tests --- test/entry/flag-entry/entry-with-flag.test.js | 1 - test/serve/help/serve-help.test.js | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/serve/help/serve-help.test.js diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index 03475c99ae3..90e465042ad 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -23,7 +23,6 @@ describe('entry flag', () => { it('should resolve the path to /src/a.js as ./src/a.js', (done) => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', '/src/a.js']); - expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); diff --git a/test/serve/help/serve-help.test.js b/test/serve/help/serve-help.test.js new file mode 100644 index 00000000000..c1f4cc840c2 --- /dev/null +++ b/test/serve/help/serve-help.test.js @@ -0,0 +1,32 @@ +const { runServe, isWebpack5 } = require('../../utils/test-utils'); + +const usageText = 'webpack serve|s [options]'; +const descriptionText = 'Run the webpack dev server'; + +describe('serve help', () => { + it('should output serve help', async () => { + const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stdout).toContain(descriptionText); + expect(stdout).toContain(usageText); + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Options:'); + // Serve flags are rendered + expect(stdout).toContain('--liveReload'); + expect(stdout).toContain('--https'); + expect(stdout).toContain('--open [value]'); + }); + + it('should output all flags when verbose help is set', async () => { + const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help', 'verbose']); + expect(stderr).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stdout).toContain(descriptionText); + expect(stdout).toContain(usageText); + expect(stdout).toContain('Options:'); + if (isWebpack5) { + expect(stdout).toContain('--cache-type'); + } + }); +}); From b6884fa681533239fedf53138f17e6123b9d2870 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Sat, 9 Jan 2021 19:46:14 +0530 Subject: [PATCH 246/581] feat: deprecate migrate package (#2313) --- .cz-config.js | 2 +- MIGRATE.md | 207 ---------- README.md | 2 +- package.json | 1 + packages/README.md | 2 +- packages/migrate/CHANGELOG.md | 57 --- packages/migrate/README.md | 35 -- packages/migrate/__testfixtures__/failing.js | 79 ---- .../__snapshots__/migrate.test.ts.snap | 158 -------- .../__snapshots__/bannerPlugin.test.ts.snap | 32 -- .../__testfixtures__/bannerPlugin-0.input.js | 5 - .../__testfixtures__/bannerPlugin-1.input.js | 4 - .../__testfixtures__/bannerPlugin-2.input.js | 6 - .../bannerPlugin/bannerPlugin.test.ts | 12 - .../commonsChunkPlugin.test.ts.snap | 302 --------------- .../commonsChunkPlugin-0.input.js | 12 - .../commonsChunkPlugin-1.input.js | 11 - .../commonsChunkPlugin-2.input.js | 11 - .../commonsChunkPlugin-3.input.js | 8 - .../commonsChunkPlugin-4.input.js | 13 - .../commonsChunkPlugin-5.input.js | 11 - .../commonsChunkPlugin-6a.input.js | 12 - .../commonsChunkPlugin-6b.input.js | 15 - .../commonsChunkPlugin-6c.input.js | 15 - .../commonsChunkPlugin-6d.input.js | 18 - .../commonsChunkPlugin-7.input.js | 12 - .../commonsChunkPlugin.test.ts | 19 - .../extractTextPlugin.test.ts.snap | 21 -- .../extractTextPlugin.input.js | 13 - .../extractTextPlugin.test.ts | 10 - .../loaderOptionsPlugin.test.ts.snap | 59 --- .../loaderOptionsPlugin-0.input.js | 6 - .../loaderOptionsPlugin-1.input.js | 9 - .../loaderOptionsPlugin-2.input.js | 9 - .../loaderOptionsPlugin-3.input.js | 17 - .../loaderOptionsPlugin.test.ts | 12 - .../__snapshots__/loaders.test.ts.snap | 289 -------------- .../__testfixtures__/loaders-0.input.js | 94 ----- .../__testfixtures__/loaders-1.input.js | 10 - .../__testfixtures__/loaders-2.input.js | 20 - .../__testfixtures__/loaders-3.input.js | 10 - .../__testfixtures__/loaders-4.input.js | 10 - .../__testfixtures__/loaders-5.input.js | 17 - .../__testfixtures__/loaders-6.input.js | 16 - .../__testfixtures__/loaders-7.input.js | 14 - .../__testfixtures__/loaders-8.input.js | 11 - .../__testfixtures__/loaders-9.input.js | 14 - .../migrate/__tests__/loaders/loaders.test.ts | 18 - packages/migrate/__tests__/migrate.test.ts | 63 ---- .../moduleConcatenationPlugin.test.ts.snap | 31 -- .../moduleConcatenationPlugin-0.input.js | 3 - .../moduleConcatenationPlugin-1.input.js | 6 - .../moduleConcatenationPlugin-2.input.js | 6 - .../moduleConcatenationPlugin.test.ts | 12 - .../namedModulesPlugin.test.ts.snap | 31 -- .../namedModulesPlugin-0.input.js | 5 - .../namedModulesPlugin-1.input.js | 9 - .../namedModulesPlugin-2.input.js | 9 - .../namedModulesPlugin.test.ts | 12 - .../noEmitOnErrorsPlugin.test.ts.snap | 31 -- .../noEmitOnErrorsPlugin-0.input.js | 3 - .../noEmitOnErrorsPlugin-1.input.js | 6 - .../noEmitOnErrorsPlugin-2.input.js | 6 - .../noEmitOnErrorsPlugin.test.ts | 12 - .../__snapshots__/outputPath.test.ts.snap | 28 -- .../__testfixtures__/outputPath-0.input.js | 5 - .../__testfixtures__/outputPath-1.input.js | 5 - .../__testfixtures__/outputPath-2.input.js | 5 - .../__tests__/outputPath/outputPath.test.ts | 12 - .../removeDeprecatedPlugins.test.ts.snap | 42 --- .../removeDeprecatedPlugins-0.input.js | 3 - .../removeDeprecatedPlugins-1.input.js | 3 - .../removeDeprecatedPlugins-2.input.js | 3 - .../removeDeprecatedPlugins-3.input.js | 8 - .../removeDeprecatedPlugins-4.input.js | 8 - .../removeDeprecatedPlugins.test.ts | 14 - .../removeJsonLoader.test.ts.snap | 53 --- .../removeJsonLoader-0.input.js | 20 - .../removeJsonLoader-1.input.js | 17 - .../removeJsonLoader-2.input.js | 10 - .../removeJsonLoader-3.input.js | 14 - .../removeJsonLoader/removeJsonLoader.test.ts | 13 - .../__snapshots__/resolve.test.ts.snap | 29 -- .../resolve/__testfixtures__/resolve.input.js | 25 -- .../migrate/__tests__/resolve/resolve.test.ts | 10 - .../__snapshots__/uglifyJsPlugin.test.ts.snap | 119 ------ .../uglifyJsPlugin-0.input.js | 7 - .../uglifyJsPlugin-1.input.js | 10 - .../uglifyJsPlugin-2.input.js | 10 - .../uglifyJsPlugin-3.input.js | 26 -- .../uglifyJsPlugin-4.input.js | 28 -- .../uglifyJsPlugin/uglifyJsPlugin.test.ts | 14 - packages/migrate/package.json | 34 -- .../migrate/src/bannerPlugin/bannerPlugin.ts | 28 -- .../commonsChunkPlugin/commonsChunkPlugin.ts | 235 ------------ .../extractTextPlugin/extractTextPlugin.ts | 56 --- packages/migrate/src/index.ts | 200 ---------- .../loaderOptionsPlugin.ts | 47 --- packages/migrate/src/loaders/loaders.ts | 354 ------------------ packages/migrate/src/migrate.ts | 123 ------ .../moduleConcatenationPlugin.ts | 24 -- .../namedModulesPlugin/namedModulesPlugin.ts | 24 -- .../noEmitOnErrorsPlugin.ts | 23 -- packages/migrate/src/outputPath/outputPath.ts | 64 ---- .../removeDeprecatedPlugins.ts | 46 --- .../src/removeJsonLoader/removeJsonLoader.ts | 73 ---- packages/migrate/src/resolve/resolve.ts | 74 ---- packages/migrate/src/types/NodePath.ts | 95 ----- .../src/uglifyJsPlugin/uglifyJsPlugin.ts | 98 ----- packages/migrate/tsconfig.json | 9 - test/help/help.test.js | 6 +- test/migrate/config/bad-webpack.config.js | 5 - test/migrate/config/migrate-config.test.js | 83 ---- test/migrate/config/webpack.config.js | 32 -- test/version/version.test.js | 4 +- tsconfig.json | 3 - yarn.lock | 28 +- 117 files changed, 25 insertions(+), 4269 deletions(-) delete mode 100644 MIGRATE.md delete mode 100644 packages/migrate/CHANGELOG.md delete mode 100644 packages/migrate/README.md delete mode 100644 packages/migrate/__testfixtures__/failing.js delete mode 100644 packages/migrate/__tests__/__snapshots__/migrate.test.ts.snap delete mode 100644 packages/migrate/__tests__/bannerPlugin/__snapshots__/bannerPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-0.input.js delete mode 100644 packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-1.input.js delete mode 100644 packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-2.input.js delete mode 100644 packages/migrate/__tests__/bannerPlugin/bannerPlugin.test.ts delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__snapshots__/commonsChunkPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-0.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-1.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-2.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-3.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-4.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-5.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6a.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6b.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6c.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6d.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-7.input.js delete mode 100644 packages/migrate/__tests__/commonsChunkPlugin/commonsChunkPlugin.test.ts delete mode 100644 packages/migrate/__tests__/extractTextPlugin/__snapshots__/extractTextPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/extractTextPlugin/__testfixtures__/extractTextPlugin.input.js delete mode 100644 packages/migrate/__tests__/extractTextPlugin/extractTextPlugin.test.ts delete mode 100644 packages/migrate/__tests__/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-0.input.js delete mode 100644 packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-1.input.js delete mode 100644 packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-2.input.js delete mode 100644 packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-3.input.js delete mode 100644 packages/migrate/__tests__/loaderOptionsPlugin/loaderOptionsPlugin.test.ts delete mode 100644 packages/migrate/__tests__/loaders/__snapshots__/loaders.test.ts.snap delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-0.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-1.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-2.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-3.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-4.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-5.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-6.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-7.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-8.input.js delete mode 100644 packages/migrate/__tests__/loaders/__testfixtures__/loaders-9.input.js delete mode 100644 packages/migrate/__tests__/loaders/loaders.test.ts delete mode 100644 packages/migrate/__tests__/migrate.test.ts delete mode 100644 packages/migrate/__tests__/moduleConcatenationPlugin/__snapshots__/moduleConcatenationPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-0.input.js delete mode 100644 packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-1.input.js delete mode 100644 packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-2.input.js delete mode 100644 packages/migrate/__tests__/moduleConcatenationPlugin/moduleConcatenationPlugin.test.ts delete mode 100644 packages/migrate/__tests__/namedModulesPlugin/__snapshots__/namedModulesPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-0.input.js delete mode 100644 packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-1.input.js delete mode 100644 packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-2.input.js delete mode 100644 packages/migrate/__tests__/namedModulesPlugin/namedModulesPlugin.test.ts delete mode 100644 packages/migrate/__tests__/noEmitOnErrorsPlugin/__snapshots__/noEmitOnErrorsPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-0.input.js delete mode 100644 packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-1.input.js delete mode 100644 packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-2.input.js delete mode 100644 packages/migrate/__tests__/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.test.ts delete mode 100644 packages/migrate/__tests__/outputPath/__snapshots__/outputPath.test.ts.snap delete mode 100644 packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-0.input.js delete mode 100644 packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-1.input.js delete mode 100644 packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-2.input.js delete mode 100644 packages/migrate/__tests__/outputPath/outputPath.test.ts delete mode 100644 packages/migrate/__tests__/removeDeprecatedPlugins/__snapshots__/removeDeprecatedPlugins.test.ts.snap delete mode 100644 packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-0.input.js delete mode 100644 packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-1.input.js delete mode 100644 packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-2.input.js delete mode 100644 packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-3.input.js delete mode 100644 packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-4.input.js delete mode 100644 packages/migrate/__tests__/removeDeprecatedPlugins/removeDeprecatedPlugins.test.ts delete mode 100644 packages/migrate/__tests__/removeJsonLoader/__snapshots__/removeJsonLoader.test.ts.snap delete mode 100644 packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-0.input.js delete mode 100644 packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-1.input.js delete mode 100644 packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-2.input.js delete mode 100644 packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-3.input.js delete mode 100644 packages/migrate/__tests__/removeJsonLoader/removeJsonLoader.test.ts delete mode 100644 packages/migrate/__tests__/resolve/__snapshots__/resolve.test.ts.snap delete mode 100644 packages/migrate/__tests__/resolve/__testfixtures__/resolve.input.js delete mode 100644 packages/migrate/__tests__/resolve/resolve.test.ts delete mode 100644 packages/migrate/__tests__/uglifyJsPlugin/__snapshots__/uglifyJsPlugin.test.ts.snap delete mode 100644 packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-0.input.js delete mode 100644 packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-1.input.js delete mode 100644 packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-2.input.js delete mode 100644 packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-3.input.js delete mode 100644 packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-4.input.js delete mode 100644 packages/migrate/__tests__/uglifyJsPlugin/uglifyJsPlugin.test.ts delete mode 100644 packages/migrate/package.json delete mode 100644 packages/migrate/src/bannerPlugin/bannerPlugin.ts delete mode 100644 packages/migrate/src/commonsChunkPlugin/commonsChunkPlugin.ts delete mode 100644 packages/migrate/src/extractTextPlugin/extractTextPlugin.ts delete mode 100644 packages/migrate/src/index.ts delete mode 100644 packages/migrate/src/loaderOptionsPlugin/loaderOptionsPlugin.ts delete mode 100644 packages/migrate/src/loaders/loaders.ts delete mode 100644 packages/migrate/src/migrate.ts delete mode 100644 packages/migrate/src/moduleConcatenationPlugin/moduleConcatenationPlugin.ts delete mode 100644 packages/migrate/src/namedModulesPlugin/namedModulesPlugin.ts delete mode 100644 packages/migrate/src/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.ts delete mode 100644 packages/migrate/src/outputPath/outputPath.ts delete mode 100644 packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts delete mode 100644 packages/migrate/src/removeJsonLoader/removeJsonLoader.ts delete mode 100644 packages/migrate/src/resolve/resolve.ts delete mode 100644 packages/migrate/src/types/NodePath.ts delete mode 100644 packages/migrate/src/uglifyJsPlugin/uglifyJsPlugin.ts delete mode 100644 packages/migrate/tsconfig.json delete mode 100644 test/migrate/config/bad-webpack.config.js delete mode 100644 test/migrate/config/migrate-config.test.js delete mode 100644 test/migrate/config/webpack.config.js diff --git a/.cz-config.js b/.cz-config.js index 36c25512e7c..11703d0b2a1 100644 --- a/.cz-config.js +++ b/.cz-config.js @@ -18,7 +18,7 @@ module.exports = { scopes: [], // sort type values in asc types: [ - { value: 'ast', name: 'ast: init, migrate, add, etc' }, + { value: 'ast', name: 'ast: init, add, etc' }, { value: 'break', name: 'break: Changes that break the behaviour of the cli' }, { value: 'chore', name: 'chore: Updating deps, docs, linting, etc' }, { value: 'cli', name: 'cli: Core CLI things' }, diff --git a/MIGRATE.md b/MIGRATE.md deleted file mode 100644 index 150418dfc62..00000000000 --- a/MIGRATE.md +++ /dev/null @@ -1,207 +0,0 @@ -# webpack-cli migrate - -The `webpack-cli migrate` feature eases the transition from: - -- `version 1` to `version 2` -- `version 2` to `version 4` - -`webpack-cli migrate` also allows users to switch to the new version of webpack without having to do it extensively. - -## Table of Contents - -- [Installation](#installation) - - [Local Setup](#local-setup) - - [Global Setup](#global-setup) -- [Usage](#usage) - - [Local Setup](#local-setup) - - [Global Setup](#global-setup) - - [Usage Example](#usage-example) -- [Changes reflected after migration](#changes-reflected-after-migration) - -## Installation - -> Requires installation of `webpack` and `webpack-cli` - -### A. Local Setup - -```shell -$ npm install --save-dev @webpack-cli/migrate -``` - -### B. Global Setup - -```shell -$ npm install -g @webpack-cli/migrate -``` - -## Usage - -To use `webpack-cli migrate`, run the following command, with the value of `` being a path to an existing webpack configuration file. `` can be `webpack.config.js` , `webpack.prod.js` or any webpack configuration. - -### A. Local Setup - -```bash -$ npx webpack-cli migrate -``` - -### B. Global Setup - -```bash -$ webpack-cli migrate -``` - -### Usage Example - -Given a basic configuration file like so: - -```javascript -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const path = require('path'); -const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); -const webpack = require('webpack'); - -module.exports = { - entry: { - index: './src/index.js', - vendor: './src/vendor.js', - }, - - output: { - filename: '[name].[chunkhash].js', - chunkFilename: '[name].[chunkhash].js', - path: path.resolve(__dirname, 'dist'), - }, - - module: { - loaders: [ - { - test: /\.js$/, - exclude: /node_modules/, - loader: 'babel', - query: { - presets: ['@babel/preset-env'], - }, - }, - { - test: /\.(scss|css)$/, - loader: ExtractTextPlugin.extract('style', 'css!sass'), - }, - ], - }, - - plugins: [ - new UglifyJSPlugin(), - - new ExtractTextPlugin('styles-[contentHash].css'), - - new webpack.optimize.CommonsChunkPlugin({ - name: 'common', - filename: 'common-[hash].min.js', - }), - - new HtmlWebpackPlugin(), - ], -}; -``` - -The `migrate` command, when run, will show the proposed changes to the config file in the terminal, prompting the user to -accept the changes or not: - -```diff -$ webpack-cli migrate ./webpack.config.js - ✔ Reading webpack config - ✔ Migrating config from v1 to v2 -- loaders: [ -+ rules: [ -- loader: 'babel', -- query: { -+ use: [{ -+ loader: 'babel-loader' -+ }], -+ options: { -- loader: ExtractTextPlugin.extract('style', 'css!sass') -+ use: ExtractTextPlugin.extract({ -+ fallback: 'style', -+ use: 'css!sass' -+ }) -? Are you sure these changes are fine? Yes - - ✔︎ New webpack v2 config file is at /Users/obuckley/Workspace/github/repos/webpack-migrate-sandbox/webpack.config.js -``` - -After it has run, we have our new webpack config file! - -```javascript -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const path = require('path'); -const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); -const webpack = require('webpack'); - -module.exports = { - entry: { - index: './src/index.js', - vendor: './src/vendor.js', - }, - - output: { - filename: '[name].[chunkhash].js', - chunkFilename: '[name].[chunkhash].js', - path: path.resolve(__dirname, 'dist'), - }, - - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - use: [ - { - loader: 'babel-loader', - }, - ], - options: { - presets: ['@babel/preset-env'], - }, - }, - { - test: /\.(scss|css)$/, - use: ExtractTextPlugin.extract({ - fallback: 'style', - use: 'css!sass', - }), - }, - ], - }, - - plugins: [ - new UglifyJSPlugin(), - - new ExtractTextPlugin('styles-[contentHash].css'), - - new webpack.optimize.CommonsChunkPlugin({ - name: 'common', - filename: 'common-[hash].min.js', - }), - - new HtmlWebpackPlugin(), - ], -}; -``` - -## Changes reflected after migration - -We can see the following changes after migration: - -1. The webpack schema for using loaders has changed - - `loaders` is now `module.rules` - - `query` is now `options` -2. All loaders now have to have the _loader_ suffix, e.g. `babel` -> `babel-loader` -3. `NamedModulesPlugin` migrated to `optimizations.namedModules` -4. `NoEmitOnErrorsPlugin` migrated to `optimizations.noEmitOnErrors` -5. `ModuleConcatenationPlugin` migrated to `optimizations.concatenateModules` - ---- - -**Note: This command does NOT handle updating dependencies in _package.json_, it is only a migration tool for the config file itself. Users are expected to manage dependencies themselves.** diff --git a/README.md b/README.md index f4b7691cbca..bdf33ce0f0f 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Thus, webpack CLI provides different commands for many common tasks. - [`webpack-cli init`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration. - [`webpack-cli info`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment. -- [`webpack-cli migrate`](./packages/migrate/README.md#webpack-cli-migrate) - Migrate project from one version to another. +- [`webpack-cli migrate`](https://www.npmjs.com/package/@webpack-cli/migrate) - Migrate project from one version to another. - [`webpack-cli plugin`](./packages/generators#generators) - Initiate new plugin project. - [`webpack-cli loader`](./packages/generators#generators) - Initiate new loader project. - [`webpack-cli serve`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading. diff --git a/package.json b/package.json index c7c117f6011..e972121ad46 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "@types/node": "^14.14.6", "@typescript-eslint/eslint-plugin": "^2.34.0", "@typescript-eslint/parser": "^2.34.0", + "@webpack-cli/migrate": "^1.1.2", "colorette": "^1.2.1", "commitlint": "^11.0.0", "commitlint-config-cz": "^0.13.2", diff --git a/packages/README.md b/packages/README.md index 450fcb1b56e..2791329cf10 100644 --- a/packages/README.md +++ b/packages/README.md @@ -16,7 +16,7 @@ This folder is the collection of those packages. 1. [generators](https://github.com/webpack/webpack-cli/tree/master/packages/generators) 2. [info](https://github.com/webpack/webpack-cli/tree/master/packages/info) 3. [init](https://github.com/webpack/webpack-cli/tree/master/packages/init) -4. [migrate](https://github.com/webpack/webpack-cli/tree/master/packages/migrate) +4. [migrate](https://www.npmjs.com/package/@webpack-cli/migrate) 5. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) 6. [utils](https://github.com/webpack/webpack-cli/tree/master/packages/utils) 7. [webpack-cli](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli) diff --git a/packages/migrate/CHANGELOG.md b/packages/migrate/CHANGELOG.md deleted file mode 100644 index 7415e2633a7..00000000000 --- a/packages/migrate/CHANGELOG.md +++ /dev/null @@ -1,57 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [1.1.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.1.1...@webpack-cli/migrate@1.1.2) (2020-12-31) - -### Bug Fixes - -- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) - -## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.1.0...@webpack-cli/migrate@1.1.1) (2020-12-25) - -**Note:** Version bump only for package @webpack-cli/migrate - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.2...@webpack-cli/migrate@1.1.0) (2020-11-04) - -### Features - -- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.1...@webpack-cli/migrate@1.0.2) (2020-10-19) - -**Note:** Version bump only for package @webpack-cli/migrate - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.1-rc.1...@webpack-cli/migrate@1.0.1) (2020-10-10) - -**Note:** Version bump only for package @webpack-cli/migrate - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.1-alpha.5...@webpack-cli/migrate@1.0.1-rc.1) (2020-10-06) - -### Bug Fixes - -- **packages:** make packages have correct main paths to index ([#1366](https://github.com/webpack/webpack-cli/issues/1366)) ([5dd7bd6](https://github.com/webpack/webpack-cli/commit/5dd7bd62046568481996e48328b15a335557f8ae)) -- regression with migrate command ([7ebcbb8](https://github.com/webpack/webpack-cli/commit/7ebcbb8030b9111df797abdd67e504178b18aeac)) - -## [1.0.1-alpha.5](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/migrate@1.0.1-alpha.4...@webpack-cli/migrate@1.0.1-alpha.5) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/migrate - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/migrate@1.0.1-alpha.3...@webpack-cli/migrate@1.0.1-alpha.4) (2020-02-29) - -**Note:** Version bump only for package @webpack-cli/migrate - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/migrate@1.0.1-alpha.2...@webpack-cli/migrate@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/migrate - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.1-alpha.1...@webpack-cli/migrate@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/migrate - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/migrate@1.0.1-alpha.0...@webpack-cli/migrate@1.0.1-alpha.1) (2020-02-23) - -### Bug Fixes - -- **init:** fix webpack config scaffold ([#1231](https://github.com/webpack/webpack-cli/issues/1231)) ([2dc495a](https://github.com/webpack/webpack-cli/commit/2dc495a8d050d28478c6c2533d7839e9ff78d76c)), closes [#1230](https://github.com/webpack/webpack-cli/issues/1230) diff --git a/packages/migrate/README.md b/packages/migrate/README.md deleted file mode 100644 index 0919ec3db8f..00000000000 --- a/packages/migrate/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# webpack-cli migrate - -[![npm][downloads]][downloads-url] - -## Description - -This package contains the logic to migrate a project from one version to the other. - -## Installation - -```bash -npm i -D webpack-cli @webpack-cli/migrate -``` - -## Usage - -To run the package programmatically, install it as a dependency. When using the package programmatically, one does not have to install webpack-cli. - -### Node - -```js -const migrate = require('@webpack-cli/migrate').default; - -// add null to mock process.env -migrate(null, null, inputPath, outputPath); -``` - -### CLI (via `webpack-cli`) - -```bash -npx webpack-cli migrate -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/migrate.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/migrate diff --git a/packages/migrate/__testfixtures__/failing.js b/packages/migrate/__testfixtures__/failing.js deleted file mode 100644 index aed54036dea..00000000000 --- a/packages/migrate/__testfixtures__/failing.js +++ /dev/null @@ -1,79 +0,0 @@ -const webpack = require('webpack'); -const nodeEnvironment = process.env.NODE_ENV; - -const config = { - entry: { - lib: "./app/index.js", - email: "./app/email.js" - }, - plugins: [ - new webpack.DefinePlugin({ - INCLUDE_ALL_MODULES: function includeAllModulesGlobalFn(modulesArray, application) { - modulesArray.forEach(function executeModuleIncludesFn(moduleFn) { - moduleFn(application); - }); - }, - ENVIRONMENT: JSON.stringify(nodeEnvironment) - }) - ], - output: { - path: __dirname + "/app", - filename: "bundle.js" - }, - resolve: { - root: __dirname + "/app" - }, - module: { - // preLoaders: [ - // { test: /\.js?$/, loader: 'eslint', exclude: /node_modules/ } - // ], - loaders: [ - { test: /\.js$/, exclude: /(node_modules)/, loader: "babel" }, - { test: /\.html/, exclude: [/(node_modules)/, /src\/index\.html/], loader: "html-loader" }, - { test: /\.s?css$/, loader: "style!css!sass" }, - { test: /\.(png|jpg)$/, loader: "url-loader?mimetype=image/png" } - ] - }, - // extra configuration options. - // eslint: { - // configFile: '.eslintrc.js' - // } -}; - -switch (nodeEnvironment) { - case "production": - config.plugins.push(new webpack.optimize.UglifyJsPlugin()); - case "preproduction": - config.output.path = __dirname + "/dist"; - config.plugins.push(new webpack.optimize.DedupePlugin()); - config.plugins.push(new webpack.optimize.OccurenceOrderPlugin()); - - config.output.filename = "[name].js"; - - config.entry = { - lib: ["./app/index.js", "angular", "lodash"], - email: ["./app/email.js", "angular"] - }; - - config.devtool = "source-map"; - config.output.libraryTarget = "commonjs2"; - break; - - case "test": - config.entry = "./index.js"; - break; - - case "development": - config.entry = { - lib: ["./app/index.js", "webpack/hot/dev-server"], - email: ["./app/email.js", "webpack/hot/dev-server"] - }; - config.output.filename = "[name].js"; - config.devtool = "source-map"; - break; - - default: - console.warn("Unknown or Undefined Node Environment. Please refer to package.json for available build commands."); -} - -module.exports = config; diff --git a/packages/migrate/__tests__/__snapshots__/migrate.test.ts.snap b/packages/migrate/__tests__/__snapshots__/migrate.test.ts.snap deleted file mode 100644 index 7da8c9cc8a4..00000000000 --- a/packages/migrate/__tests__/__snapshots__/migrate.test.ts.snap +++ /dev/null @@ -1,158 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`transform should not transform if no transformations defined: -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - loaders: [{ - test: /.js$/, - loaders: ['babel'], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin(), - new webpack.optimize.OccurrenceOrderPlugin() - ], - debug: true -}; - 1`] = ` -" -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - loaders: [{ - test: /.js$/, - loaders: ['babel'], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin(), - new webpack.optimize.OccurrenceOrderPlugin() - ], - debug: true -}; -" -`; - -exports[`transform should respect recast options 1`] = ` -" -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - rules: [{ - test: /.js$/, - use: [{ - loader: \\"babel-loader\\", - }], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - modules: ['node_modules', path.resolve('/src')], - }, - plugins: [new webpack.LoaderOptionsPlugin({ - debug: true, - })], - optimization: { - minimize: true, - } -}; -" -`; - -exports[`transform should transform only using specified transformations 1`] = ` -" -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - rules: [{ - test: /.js$/, - use: [{ - loader: 'babel-loader' - }], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin(), - new webpack.optimize.OccurrenceOrderPlugin() - ], - debug: true -}; -" -`; - -exports[`transform should transform using all transformations 1`] = ` -" -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - rules: [{ - test: /.js$/, - use: [{ - loader: 'babel-loader' - }], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - modules: ['node_modules', path.resolve('/src')] - }, - plugins: [new webpack.LoaderOptionsPlugin({ - debug: true - })], - optimization: { - minimize: true - } -}; -" -`; diff --git a/packages/migrate/__tests__/bannerPlugin/__snapshots__/bannerPlugin.test.ts.snap b/packages/migrate/__tests__/bannerPlugin/__snapshots__/bannerPlugin.test.ts.snap deleted file mode 100644 index 30d5fa15421..00000000000 --- a/packages/migrate/__tests__/bannerPlugin/__snapshots__/bannerPlugin.test.ts.snap +++ /dev/null @@ -1,32 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`banner plugin bannerPlugin transforms correctly using "bannerPlugin-0" data 1`] = ` -"module.exports = { - plugins: [ - new webpack.BannerPlugin({ - raw: true, - entryOnly: true, - banner: 'Banner' - }) - ] -} -" -`; - -exports[`banner plugin bannerPlugin transforms correctly using "bannerPlugin-1" data 1`] = ` -"// Should do nothing if there is no banner plugin -module.exports = { - plugins: [] -} -" -`; - -exports[`banner plugin bannerPlugin transforms correctly using "bannerPlugin-2" data 1`] = ` -"// Only transform if it uses the old format -module.exports = { - plugins: [ - new webpack.BannerPlugin({}) - ] -} -" -`; diff --git a/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-0.input.js b/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-0.input.js deleted file mode 100644 index 56c89e72d84..00000000000 --- a/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-0.input.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - plugins: [ - new webpack.BannerPlugin('Banner', { raw: true, entryOnly: true }) - ] -} diff --git a/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-1.input.js b/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-1.input.js deleted file mode 100644 index 0d66b9de1ac..00000000000 --- a/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-1.input.js +++ /dev/null @@ -1,4 +0,0 @@ -// Should do nothing if there is no banner plugin -module.exports = { - plugins: [] -} diff --git a/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-2.input.js b/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-2.input.js deleted file mode 100644 index 90ecde8f0de..00000000000 --- a/packages/migrate/__tests__/bannerPlugin/__testfixtures__/bannerPlugin-2.input.js +++ /dev/null @@ -1,6 +0,0 @@ -// Only transform if it uses the old format -module.exports = { - plugins: [ - new webpack.BannerPlugin({}) - ] -} diff --git a/packages/migrate/__tests__/bannerPlugin/bannerPlugin.test.ts b/packages/migrate/__tests__/bannerPlugin/bannerPlugin.test.ts deleted file mode 100644 index b29851c5280..00000000000 --- a/packages/migrate/__tests__/bannerPlugin/bannerPlugin.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('banner plugin', function () { - { - defineTest(dirName, 'bannerPlugin', 'bannerPlugin-0'); - defineTest(dirName, 'bannerPlugin', 'bannerPlugin-1'); - defineTest(dirName, 'bannerPlugin', 'bannerPlugin-2'); - } -}); diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__snapshots__/commonsChunkPlugin.test.ts.snap b/packages/migrate/__tests__/commonsChunkPlugin/__snapshots__/commonsChunkPlugin.test.ts.snap deleted file mode 100644 index 593db1cc8cd..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__snapshots__/commonsChunkPlugin.test.ts.snap +++ /dev/null @@ -1,302 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-0" data 1`] = ` -"module.exports = { - entry: { - app: './src/app.js', - vendor: './src/vendors.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - app: { - name: 'app', - chunks: 'initial', - enforce: true, - test: 'app' - }, - - vendor: { - name: 'vendor', - chunks: 'initial', - enforce: true, - test: 'vendor' - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-1" data 1`] = ` -"module.exports = { - entry: { - vendor: './src/vendors.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - common: { - name: 'common', - chunks: 'initial', - enforce: true - }, - - vendor: { - name: 'vendor', - chunks: 'initial', - enforce: true, - test: 'vendor' - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-2" data 1`] = ` -"module.exports = { - entry: { - vendor: './src/vendors.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - vendor: { - name: 'vendor', - chunks: 'initial', - enforce: true, - test: 'vendor' - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-3" data 1`] = ` -"module.exports = { - optimizations: { - splitChunks: { - cacheGroups: { - commons: { - name: 'commons', - chunks: 'initial', - enforce: true, - filename: 'commons.js' - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-4" data 1`] = ` -"module.exports = { - entry: { - main: './src/index.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - main: { - name: 'main', - enforce: true, - test: 'main', - chunks: 'async', - minSize: 2000 - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-5" data 1`] = ` -"module.exports = { - entry: { - main: './src/index.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - main: { - name: 'main', - chunks: 'initial', - enforce: true, - test: 'main' - } - } - }, - - runtimeChunk: { - name: 'runtime' - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6a" data 1`] = ` -"module.exports = { - entry: { - main: './src/index.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - main: { - name: 'main', - chunks: 'initial', - enforce: true, - - test: module => { - if (module.getChunks().some(chunk => chunk.name === 'main')) - return true; - - const fn = ({ resource }) => /node_modules/.test(resource); - return fn(module); - } - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6b" data 1`] = ` -"module.exports = { - entry: { - main: './src/index.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - main: { - name: 'main', - chunks: 'initial', - enforce: true, - - test: module => { - if (module.getChunks().some(chunk => chunk.name === 'main')) - return true; - - const fn = ({ resource }) => { - // some code - return /node_modules/.test(resource); - }; - - return fn(module); - } - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6c" data 1`] = ` -"module.exports = { - entry: { - main: './src/index.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - main: { - name: 'main', - chunks: 'initial', - enforce: true, - - test: module => { - if (module.getChunks().some(chunk => chunk.name === 'main')) - return true; - - const fn = function ({ resource }) { - // some code - return /node_modules/.test(resource); - }; - - return fn(module); - } - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-6d" data 1`] = ` -"module.exports = { - entry: { - main: './src/index.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - main: { - name: 'main', - chunks: 'initial', - enforce: true, - - test: module => { - if (module.getChunks().some(chunk => chunk.name === 'main')) - return true; - - const fn = function ({ resource }) { - if (foo) { - return /node_modulesfoo/.test(resource); - } else { - return /node_modulesbaz/.test(resource); - } - }; - - return fn(module); - } - } - } - } - } -} -" -`; - -exports[`commons chunk plugin commonsChunkPlugin transforms correctly using "commonsChunkPlugin-7" data 1`] = ` -"module.exports = { - entry: { - main: './src/index.js', - }, - - optimizations: { - splitChunks: { - cacheGroups: { - main: { - name: 'main', - chunks: 'initial', - enforce: true, - test: 'main', - minSize: 3000 - } - } - } - } -} -" -`; diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-0.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-0.input.js deleted file mode 100644 index 5174a051ee1..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-0.input.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - entry: { - app: './src/app.js', - vendor: './src/vendors.js', - }, - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - names: ["app", "vendor"], - minChunks: 2 - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-1.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-1.input.js deleted file mode 100644 index 278b2581639..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-1.input.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - entry: { - vendor: './src/vendors.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - names: ["common", "vendor"] - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-2.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-2.input.js deleted file mode 100644 index 83a4fb6d3c5..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-2.input.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - entry: { - vendor: './src/vendors.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - names: ["vendor"] - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-3.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-3.input.js deleted file mode 100644 index 0c4289d6290..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-3.input.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: "commons", - filename: "commons.js", - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-4.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-4.input.js deleted file mode 100644 index 973867a9866..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-4.input.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - entry: { - main: './src/index.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: "main", - async: true, - minSize: 2000, - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-5.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-5.input.js deleted file mode 100644 index c7b2dc1c53d..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-5.input.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - entry: { - main: './src/index.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - names: ["main", "runtime"], - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6a.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6a.input.js deleted file mode 100644 index 641965277fa..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6a.input.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - entry: { - main: './src/index.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: "main", - minChunks: ({ resource }) => /node_modules/.test(resource), - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6b.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6b.input.js deleted file mode 100644 index fd48b62e34c..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6b.input.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - entry: { - main: './src/index.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: "main", - minChunks: ({ resource }) => { - // some code - return /node_modules/.test(resource); - }, - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6c.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6c.input.js deleted file mode 100644 index 9fe78cbc0fa..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6c.input.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - entry: { - main: './src/index.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: "main", - minChunks: function ({ resource }) { - // some code - return /node_modules/.test(resource); - }, - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6d.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6d.input.js deleted file mode 100644 index bab003418a4..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-6d.input.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - entry: { - main: './src/index.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: "main", - minChunks: function ({ resource }) { - if (foo) { - return /node_modulesfoo/.test(resource); - } else { - return /node_modulesbaz/.test(resource); - } - } - }) - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-7.input.js b/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-7.input.js deleted file mode 100644 index 9999d11bd64..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/__testfixtures__/commonsChunkPlugin-7.input.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - entry: { - main: './src/index.js', - }, - - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: "main", - minSize: 3000, - }), - ] -} diff --git a/packages/migrate/__tests__/commonsChunkPlugin/commonsChunkPlugin.test.ts b/packages/migrate/__tests__/commonsChunkPlugin/commonsChunkPlugin.test.ts deleted file mode 100644 index 3e97a576042..00000000000 --- a/packages/migrate/__tests__/commonsChunkPlugin/commonsChunkPlugin.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; -const dirName: string = join(__dirname); - -describe('commons chunk plugin', function () { - { - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-0'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-1'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-2'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-3'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-4'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-5'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-6a'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-6b'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-6c'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-6d'); - defineTest(dirName, 'commonsChunkPlugin', 'commonsChunkPlugin-7'); - } -}); diff --git a/packages/migrate/__tests__/extractTextPlugin/__snapshots__/extractTextPlugin.test.ts.snap b/packages/migrate/__tests__/extractTextPlugin/__snapshots__/extractTextPlugin.test.ts.snap deleted file mode 100644 index 4e2ee40db6c..00000000000 --- a/packages/migrate/__tests__/extractTextPlugin/__snapshots__/extractTextPlugin.test.ts.snap +++ /dev/null @@ -1,21 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`extractTextPlugin extractTextPlugin transforms correctly 1`] = ` -"const ExtractTextPlugin = require(\\"extract-text-webpack-plugin\\"); - -module.exports = { - module: { - rules: [ - { - test: /\\\\.css$/, - use: ExtractTextPlugin.extract({ - fallback: 'style-loader', - use: 'css-loader' - }) - } - ] - }, - plugins: [new ExtractTextPlugin(\\"styles.css\\")] -}; -" -`; diff --git a/packages/migrate/__tests__/extractTextPlugin/__testfixtures__/extractTextPlugin.input.js b/packages/migrate/__tests__/extractTextPlugin/__testfixtures__/extractTextPlugin.input.js deleted file mode 100644 index 07d46e38cc0..00000000000 --- a/packages/migrate/__tests__/extractTextPlugin/__testfixtures__/extractTextPlugin.input.js +++ /dev/null @@ -1,13 +0,0 @@ -const ExtractTextPlugin = require("extract-text-webpack-plugin"); - -module.exports = { - module: { - rules: [ - { - test: /\.css$/, - use: ExtractTextPlugin.extract("style-loader", "css-loader") - } - ] - }, - plugins: [new ExtractTextPlugin("styles.css")] -}; diff --git a/packages/migrate/__tests__/extractTextPlugin/extractTextPlugin.test.ts b/packages/migrate/__tests__/extractTextPlugin/extractTextPlugin.test.ts deleted file mode 100644 index 71d9f3d2e14..00000000000 --- a/packages/migrate/__tests__/extractTextPlugin/extractTextPlugin.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('extractTextPlugin', function () { - { - defineTest(dirName, 'extractTextPlugin'); - } -}); diff --git a/packages/migrate/__tests__/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.ts.snap b/packages/migrate/__tests__/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.ts.snap deleted file mode 100644 index 6d0877f5f11..00000000000 --- a/packages/migrate/__tests__/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.ts.snap +++ /dev/null @@ -1,59 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`loaderOptionsPlugin loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-0" data 1`] = ` -"// Do not create LoaderOptionsPlugin is not necessary -module.exports = { - plugins: [ - new SomePlugin() - ] -} -" -`; - -exports[`loaderOptionsPlugin loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-1" data 1`] = ` -"module.exports = { - plugins: [ - new webpack.optimize.UglifyJsPlugin(), - new webpack.LoaderOptionsPlugin({ - foo: 'bar', - debug: true, - minimize: true - }) - ] -} -" -`; - -exports[`loaderOptionsPlugin loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-2" data 1`] = ` -"// Don't modify LoaderOptionsPlugin -module.exports = { - plugins: [ - new SomePlugin(), - new webpack.LoaderOptionsPlugin({ - foo: 'bar' - }) - ] -} -" -`; - -exports[`loaderOptionsPlugin loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-3" data 1`] = ` -"// Don't modify LoaderOptionsPlugin - -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -module.exports = { - entry: ['./index.js'], - output: { - filename: 'bundle.js' - }, - module: { - rules: [{ - test: /\\\\.css$/, - use: ExtractTextPlugin.extract([ - 'css-loader' - ]) - }] - }, -} -" -`; diff --git a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-0.input.js b/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-0.input.js deleted file mode 100644 index e809d6a36a9..00000000000 --- a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-0.input.js +++ /dev/null @@ -1,6 +0,0 @@ -// Do not create LoaderOptionsPlugin is not necessary -module.exports = { - plugins: [ - new SomePlugin() - ] -} diff --git a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-1.input.js b/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-1.input.js deleted file mode 100644 index 3b8ac854d12..00000000000 --- a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-1.input.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - debug: true, - plugins: [ - new webpack.optimize.UglifyJsPlugin(), - new webpack.LoaderOptionsPlugin({ - foo: 'bar' - }) - ] -} diff --git a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-2.input.js b/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-2.input.js deleted file mode 100644 index eea1c515164..00000000000 --- a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-2.input.js +++ /dev/null @@ -1,9 +0,0 @@ -// Don't modify LoaderOptionsPlugin -module.exports = { - plugins: [ - new SomePlugin(), - new webpack.LoaderOptionsPlugin({ - foo: 'bar' - }) - ] -} diff --git a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-3.input.js b/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-3.input.js deleted file mode 100644 index 2a3baa56d23..00000000000 --- a/packages/migrate/__tests__/loaderOptionsPlugin/__testfixtures__/loaderOptionsPlugin-3.input.js +++ /dev/null @@ -1,17 +0,0 @@ -// Don't modify LoaderOptionsPlugin - -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -module.exports = { - entry: ['./index.js'], - output: { - filename: 'bundle.js' - }, - module: { - rules: [{ - test: /\.css$/, - use: ExtractTextPlugin.extract([ - 'css-loader' - ]) - }] - }, -} diff --git a/packages/migrate/__tests__/loaderOptionsPlugin/loaderOptionsPlugin.test.ts b/packages/migrate/__tests__/loaderOptionsPlugin/loaderOptionsPlugin.test.ts deleted file mode 100644 index 0d16e54022b..00000000000 --- a/packages/migrate/__tests__/loaderOptionsPlugin/loaderOptionsPlugin.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); -describe('loaderOptionsPlugin', function () { - { - defineTest(dirName, 'loaderOptionsPlugin', 'loaderOptionsPlugin-0'); - defineTest(dirName, 'loaderOptionsPlugin', 'loaderOptionsPlugin-1'); - defineTest(dirName, 'loaderOptionsPlugin', 'loaderOptionsPlugin-2'); - defineTest(dirName, 'loaderOptionsPlugin', 'loaderOptionsPlugin-3'); - } -}); diff --git a/packages/migrate/__tests__/loaders/__snapshots__/loaders.test.ts.snap b/packages/migrate/__tests__/loaders/__snapshots__/loaders.test.ts.snap deleted file mode 100644 index 5fb72ae39e0..00000000000 --- a/packages/migrate/__tests__/loaders/__snapshots__/loaders.test.ts.snap +++ /dev/null @@ -1,289 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`loaders loaders transforms correctly using "loaders-0" data 1`] = ` -"module.exports = [ - { - module: { - rules: [ - { - use: [{ - loader: 'babel-loader' - }], - test: /\\\\.js$/, - }, - ], - }, - }, - { - module: { - rules: [ - { - use: [{ - loader: 'style-loader' - }, { - loader: 'css-loader', - - options: { - modules: true, - importLoaders: 1, - string: 'test123' - } - }], - test: /\\\\.css$/, - }, - ], - }, - }, - { - module: { - rules: [ - { - use: [{ - loader: 'style-loader', - }, { - loader: 'css-loader', - options: { - modules: true, - }, - }], - test: /\\\\.css$/, - }, - ], - }, - }, - { - module: { - rules: [ - { - use: [{ - loader: 'eslint-loader' - }], - - test: /\\\\.js$/, - enforce: 'pre' - }, - ], - }, - }, - { - module: { - rules: [ - { - use: [{ - loader: 'my-post-loader' - }], - - test: /\\\\.js$/, - enforce: 'post' - }, - ], - }, - }, - { - module: { - rules: [{ - use: [{ - loader: 'babel-loader' - }], - test: /\\\\.js$/, - }, { - use: [{ - loader: 'eslint-loader' - }], - - test: /\\\\.js$/, - enforce: 'pre' - }] - }, - }, - { - module: { - rules: [{ - use: [{ - loader: 'babel-loader' - }], - test: /\\\\.js$/, - }, { - use: [{ - loader: 'my-post-loader' - }], - - test: /\\\\.js$/, - enforce: 'post' - }] - }, - }, -]; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-1" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - use: [{ - loader: 'style-loader' - }, { - loader: 'css-loader', - - options: { - modules: true, - importLoaders: 1, - string: 'test123' - } - }], - test: /\\\\.css$/, - }, - ], - }, -}; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-2" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - use: [{ - loader: 'style-loader', - }, { - loader: 'css-loader', - options: { - modules: true, - }, - }], - test: /\\\\.css$/, - }, - ], - }, -}; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-3" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - use: [{ - loader: 'eslint-loader' - }], - - test: /\\\\.js$/, - enforce: 'pre' - }, - ], - }, -}; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-4" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - use: [{ - loader: 'my-post-loader' - }], - - test: /\\\\.js$/, - enforce: 'post' - }, - ], - }, -}; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-5" data 1`] = ` -"module.exports = { - module: { - rules: [{ - use: [{ - loader: 'babel-loader' - }], - test: /\\\\.js$/, - }, { - use: [{ - loader: 'eslint-loader' - }], - - test: /\\\\.js$/, - enforce: 'pre' - }] - }, -}; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-6" data 1`] = ` -"module.exports = { - module: { - rules: [{ - use: [{ - loader: 'babel-loader' - }], - test: /\\\\.js$/, - }, { - use: [{ - loader: 'my-post-loader' - }], - - test: /\\\\.js$/, - enforce: 'post' - }] - }, -}; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-7" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - exclude: /(node_modules)/, - - use: [{ - loader: 'babel-loader', - - options: { - presets: [\\"@babel/preset-env\\"], - } - }], - - test: /\\\\.js$/ - }, - ], - }, -}; -" -`; - -exports[`loaders loaders transforms correctly using "loaders-8" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - include: path.join(__dirname, \\"src\\"), - use: [{ - loader: 'style-loader' - }, { - loader: 'css-loader', - - options: { - modules: true, - importLoaders: 1, - string: 'test123' - } - }], - test: /\\\\.js$/ - } - ] - } -}; -" -`; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-0.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-0.input.js deleted file mode 100644 index e58bb6f88ef..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-0.input.js +++ /dev/null @@ -1,94 +0,0 @@ -module.exports = [ - { - module: { - loaders: [ - { - loader: "babel", - test: /\.js$/, - }, - ], - }, - }, - { - module: { - loaders: [ - { - loader: "style!css?modules&importLoaders=1&string=test123", - test: /\.css$/, - }, - ], - }, - }, - { - module: { - loaders: [ - { - loaders: [ - { - loader: "style", - }, - { - loader: "css", - query: { - modules: true, - }, - }, - ], - test: /\.css$/, - }, - ], - }, - }, - { - module: { - preLoaders: [ - { - loader: "eslint", - test: /\.js$/, - }, - ], - }, - }, - { - module: { - postLoaders: [ - { - loader: "my-post", - test: /\.js$/, - }, - ], - }, - }, - { - module: { - loaders: [ - { - loader: "babel-loader", - test: /\.js$/, - }, - ], - preLoaders: [ - { - loader: "eslint-loader", - test: /\.js$/, - }, - ], - }, - }, - { - module: { - loaders: [ - { - loader: "babel-loader", - test: /\.js$/, - }, - ], - postLoaders: [ - { - loader: "my-post-loader", - test: /\.js$/, - }, - ], - }, - }, -]; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-1.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-1.input.js deleted file mode 100644 index 0662abea05e..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-1.input.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - module: { - loaders: [ - { - loader: "style!css?modules&importLoaders=1&string=test123", - test: /\.css$/, - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-2.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-2.input.js deleted file mode 100644 index 388182d1d9e..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-2.input.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - module: { - loaders: [ - { - loaders: [ - { - loader: "style", - }, - { - loader: "css", - query: { - modules: true, - }, - }, - ], - test: /\.css$/, - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-3.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-3.input.js deleted file mode 100644 index cef7c100bb7..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-3.input.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - module: { - preLoaders: [ - { - loader: "eslint", - test: /\.js$/, - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-4.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-4.input.js deleted file mode 100644 index 863f7acb499..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-4.input.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - module: { - postLoaders: [ - { - loader: "my-post", - test: /\.js$/, - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-5.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-5.input.js deleted file mode 100644 index 63758597dcf..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-5.input.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - module: { - loaders: [ - { - loader: "babel-loader", - test: /\.js$/, - }, - ], - - preLoaders: [ - { - loader: "eslint-loader", - test: /\.js$/, - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-6.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-6.input.js deleted file mode 100644 index 405e508e2d7..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-6.input.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - module: { - loaders: [ - { - loader: "babel-loader", - test: /\.js$/, - }, - ], - postLoaders: [ - { - loader: "my-post-loader", - test: /\.js$/, - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-7.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-7.input.js deleted file mode 100644 index 40c46492632..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-7.input.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - module: { - loaders: [ - { - exclude: /(node_modules)/, - loader: "babel-loader", - query: { - presets: ["@babel/preset-env"], - }, - test: /\.js$/, - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-8.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-8.input.js deleted file mode 100644 index 1be3161d4b7..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-8.input.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - module: { - loaders: [ - { - include: path.join(__dirname, "src"), - loaders: ["style", "css?modules&importLoaders=1&string=test123"], - test: /\.js$/ - } - ] - } -}; diff --git a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-9.input.js b/packages/migrate/__tests__/loaders/__testfixtures__/loaders-9.input.js deleted file mode 100644 index d100038d9a6..00000000000 --- a/packages/migrate/__tests__/loaders/__testfixtures__/loaders-9.input.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - module: { - loaders: [ - { - loader: "url-loader", - options: { - limit: 10000, - name: "static/media/[name].[hash:8].[ext]", - }, - test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], - }, - ], - }, -}; diff --git a/packages/migrate/__tests__/loaders/loaders.test.ts b/packages/migrate/__tests__/loaders/loaders.test.ts deleted file mode 100644 index ad94c6dcbea..00000000000 --- a/packages/migrate/__tests__/loaders/loaders.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('loaders', function () { - { - defineTest(dirName, 'loaders', 'loaders-0'); - defineTest(dirName, 'loaders', 'loaders-1'); - defineTest(dirName, 'loaders', 'loaders-2'); - defineTest(dirName, 'loaders', 'loaders-3'); - defineTest(dirName, 'loaders', 'loaders-4'); - defineTest(dirName, 'loaders', 'loaders-5'); - defineTest(dirName, 'loaders', 'loaders-6'); - defineTest(dirName, 'loaders', 'loaders-7'); - defineTest(dirName, 'loaders', 'loaders-8'); - } -}); diff --git a/packages/migrate/__tests__/migrate.test.ts b/packages/migrate/__tests__/migrate.test.ts deleted file mode 100644 index 4ac4c12bd64..00000000000 --- a/packages/migrate/__tests__/migrate.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { transform, transformations } from '../src/migrate'; - -const input = ` -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - loaders: [{ - test: /.js$/, - loaders: ['babel'], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin(), - new webpack.optimize.OccurrenceOrderPlugin() - ], - debug: true -}; -`; - -describe('transform', () => { - it('should not transform if no transformations defined', (done) => { - transform(input, []).then((output) => { - expect(output).toMatchSnapshot(input); - done(); - }); - }); - - it('should transform using all transformations', (done) => { - transform(input).then((output) => { - expect(output).toMatchSnapshot(); - done(); - }); - }); - - it('should transform only using specified transformations', (done) => { - transform(input, [transformations.loadersTransform]).then((output) => { - expect(output).toMatchSnapshot(); - done(); - }); - }); - - it('should respect recast options', (done) => { - transform(input, undefined, { - quote: 'double', - trailingComma: true, - }).then((output) => { - expect(output).toMatchSnapshot(); - done(); - }); - }); -}); diff --git a/packages/migrate/__tests__/moduleConcatenationPlugin/__snapshots__/moduleConcatenationPlugin.test.ts.snap b/packages/migrate/__tests__/moduleConcatenationPlugin/__snapshots__/moduleConcatenationPlugin.test.ts.snap deleted file mode 100644 index 76320d16f65..00000000000 --- a/packages/migrate/__tests__/moduleConcatenationPlugin/__snapshots__/moduleConcatenationPlugin.test.ts.snap +++ /dev/null @@ -1,31 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`moduleConcatenationPlugin moduleConcatenationPlugin transforms correctly using "moduleConcatenationPlugin-0" data 1`] = ` -"module.exports = { - optimizations: { - concatenateModules: true - } -}; -" -`; - -exports[`moduleConcatenationPlugin moduleConcatenationPlugin transforms correctly using "moduleConcatenationPlugin-1" data 1`] = ` -"module.exports = { - optimizations: { - splitChunks: false, - concatenateModules: true - }, - plugins: [new Foo()] -}; -" -`; - -exports[`moduleConcatenationPlugin moduleConcatenationPlugin transforms correctly using "moduleConcatenationPlugin-2" data 1`] = ` -"module.exports = { - optimizations: { - concatenateModules: true - }, - plugins: [new Foo()] -}; -" -`; diff --git a/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-0.input.js b/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-0.input.js deleted file mode 100644 index cd8dd6c0e65..00000000000 --- a/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-0.input.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - plugins: [new webpack.optimize.ModuleConcatenationPlugin()] -}; diff --git a/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-1.input.js b/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-1.input.js deleted file mode 100644 index 4681fe01cb8..00000000000 --- a/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-1.input.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - optimizations: { - splitChunks: false - }, - plugins: [new Foo(), new webpack.optimize.ModuleConcatenationPlugin()] -}; diff --git a/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-2.input.js b/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-2.input.js deleted file mode 100644 index 1cae8402ad0..00000000000 --- a/packages/migrate/__tests__/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-2.input.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - optimizations: { - concatenateModules: false - }, - plugins: [new Foo(), new webpack.optimize.ModuleConcatenationPlugin()] -}; diff --git a/packages/migrate/__tests__/moduleConcatenationPlugin/moduleConcatenationPlugin.test.ts b/packages/migrate/__tests__/moduleConcatenationPlugin/moduleConcatenationPlugin.test.ts deleted file mode 100644 index 39d4aff5197..00000000000 --- a/packages/migrate/__tests__/moduleConcatenationPlugin/moduleConcatenationPlugin.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('moduleConcatenationPlugin', function () { - { - defineTest(dirName, 'moduleConcatenationPlugin', 'moduleConcatenationPlugin-0'); - defineTest(dirName, 'moduleConcatenationPlugin', 'moduleConcatenationPlugin-1'); - defineTest(dirName, 'moduleConcatenationPlugin', 'moduleConcatenationPlugin-2'); - } -}); diff --git a/packages/migrate/__tests__/namedModulesPlugin/__snapshots__/namedModulesPlugin.test.ts.snap b/packages/migrate/__tests__/namedModulesPlugin/__snapshots__/namedModulesPlugin.test.ts.snap deleted file mode 100644 index 5aea9ec1444..00000000000 --- a/packages/migrate/__tests__/namedModulesPlugin/__snapshots__/namedModulesPlugin.test.ts.snap +++ /dev/null @@ -1,31 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`namedModulesPlugin namedModulesPlugin transforms correctly using "namedModulesPlugin-0" data 1`] = ` -"module.export = { - optimizations: { - namedModules: true - } -} -" -`; - -exports[`namedModulesPlugin namedModulesPlugin transforms correctly using "namedModulesPlugin-1" data 1`] = ` -"module.export = { - optimizations: { - splitChunks: false, - namedModules: true - }, - plugins: [new Foo()] -} -" -`; - -exports[`namedModulesPlugin namedModulesPlugin transforms correctly using "namedModulesPlugin-2" data 1`] = ` -"module.export = { - optimizations: { - namedModules: true - }, - plugins: [new Foo()] -} -" -`; diff --git a/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-0.input.js b/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-0.input.js deleted file mode 100644 index 0f1dc70d1a2..00000000000 --- a/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-0.input.js +++ /dev/null @@ -1,5 +0,0 @@ -module.export = { - plugins: [ - new webpack.NamedModulesPlugin() - ] -} diff --git a/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-1.input.js b/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-1.input.js deleted file mode 100644 index 834cb39181a..00000000000 --- a/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-1.input.js +++ /dev/null @@ -1,9 +0,0 @@ -module.export = { - optimizations: { - splitChunks: false - }, - plugins: [ - new Foo(), - new webpack.NamedModulesPlugin() - ] -} diff --git a/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-2.input.js b/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-2.input.js deleted file mode 100644 index d5f3facf0f4..00000000000 --- a/packages/migrate/__tests__/namedModulesPlugin/__testfixtures__/namedModulesPlugin-2.input.js +++ /dev/null @@ -1,9 +0,0 @@ -module.export = { - optimizations: { - namedModules: false - }, - plugins: [ - new Foo(), - new webpack.NamedModulesPlugin() - ] -} diff --git a/packages/migrate/__tests__/namedModulesPlugin/namedModulesPlugin.test.ts b/packages/migrate/__tests__/namedModulesPlugin/namedModulesPlugin.test.ts deleted file mode 100644 index 73b6321a87f..00000000000 --- a/packages/migrate/__tests__/namedModulesPlugin/namedModulesPlugin.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('namedModulesPlugin', function () { - { - defineTest(dirName, 'namedModulesPlugin', 'namedModulesPlugin-0'); - defineTest(dirName, 'namedModulesPlugin', 'namedModulesPlugin-1'); - defineTest(dirName, 'namedModulesPlugin', 'namedModulesPlugin-2'); - } -}); diff --git a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__snapshots__/noEmitOnErrorsPlugin.test.ts.snap b/packages/migrate/__tests__/noEmitOnErrorsPlugin/__snapshots__/noEmitOnErrorsPlugin.test.ts.snap deleted file mode 100644 index c5f215b09da..00000000000 --- a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__snapshots__/noEmitOnErrorsPlugin.test.ts.snap +++ /dev/null @@ -1,31 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`noEmitOnErrorsPlugin noEmitOnErrorsPlugin transforms correctly using "noEmitOnErrorsPlugin-0" data 1`] = ` -"module.exports = { - optimizations: { - noEmitOnErrors: true - } -}; -" -`; - -exports[`noEmitOnErrorsPlugin noEmitOnErrorsPlugin transforms correctly using "noEmitOnErrorsPlugin-1" data 1`] = ` -"module.exports = { - optimizations: { - splitChunks: false, - noEmitOnErrors: true - }, - plugins: [new Foo()] -}; -" -`; - -exports[`noEmitOnErrorsPlugin noEmitOnErrorsPlugin transforms correctly using "noEmitOnErrorsPlugin-2" data 1`] = ` -"module.exports = { - optimizations: { - noEmitOnErrors: true - }, - plugins: [new Foo()] -}; -" -`; diff --git a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-0.input.js b/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-0.input.js deleted file mode 100644 index 7eb2fa30679..00000000000 --- a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-0.input.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - plugins: [new webpack.NoEmitOnErrorsPlugin()] -}; diff --git a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-1.input.js b/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-1.input.js deleted file mode 100644 index 9d409eb31d0..00000000000 --- a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-1.input.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - optimizations: { - splitChunks: false - }, - plugins: [new Foo(), new webpack.NoEmitOnErrorsPlugin()] -}; diff --git a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-2.input.js b/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-2.input.js deleted file mode 100644 index b30145bcc85..00000000000 --- a/packages/migrate/__tests__/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-2.input.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - optimizations: { - noEmitOnErrors: false - }, - plugins: [new Foo(), new webpack.NoEmitOnErrorsPlugin()] -}; diff --git a/packages/migrate/__tests__/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.test.ts b/packages/migrate/__tests__/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.test.ts deleted file mode 100644 index 5866d0d4b75..00000000000 --- a/packages/migrate/__tests__/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('noEmitOnErrorsPlugin', function () { - { - defineTest(dirName, 'noEmitOnErrorsPlugin', 'noEmitOnErrorsPlugin-0'); - defineTest(dirName, 'noEmitOnErrorsPlugin', 'noEmitOnErrorsPlugin-1'); - defineTest(dirName, 'noEmitOnErrorsPlugin', 'noEmitOnErrorsPlugin-2'); - } -}); diff --git a/packages/migrate/__tests__/outputPath/__snapshots__/outputPath.test.ts.snap b/packages/migrate/__tests__/outputPath/__snapshots__/outputPath.test.ts.snap deleted file mode 100644 index ceb019922fc..00000000000 --- a/packages/migrate/__tests__/outputPath/__snapshots__/outputPath.test.ts.snap +++ /dev/null @@ -1,28 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`outputPath outputPath transforms correctly using "outputPath-0" data 1`] = ` -"module.exports = { - output: { - path: path.join(__dirname, \\"dist\\"), - }, -}; -" -`; - -exports[`outputPath outputPath transforms correctly using "outputPath-1" data 1`] = ` -"module.exports = { - output: { - path: path.join(__dirname, \\"dist\\") - } -}; -" -`; - -exports[`outputPath outputPath transforms correctly using "outputPath-2" data 1`] = ` -"module.exports = { - output: { - path: path.join(__dirname, \\"dist\\") - } -}; -" -`; diff --git a/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-0.input.js b/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-0.input.js deleted file mode 100644 index e111b266b50..00000000000 --- a/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-0.input.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - output: { - path: "dist", - }, -}; diff --git a/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-1.input.js b/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-1.input.js deleted file mode 100644 index 18e3d927d8f..00000000000 --- a/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-1.input.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - output: { - path: path.join(__dirname, "dist") - } -}; diff --git a/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-2.input.js b/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-2.input.js deleted file mode 100644 index 9f9c30a0420..00000000000 --- a/packages/migrate/__tests__/outputPath/__testfixtures__/outputPath-2.input.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - output: { - path: "dist" - } -}; diff --git a/packages/migrate/__tests__/outputPath/outputPath.test.ts b/packages/migrate/__tests__/outputPath/outputPath.test.ts deleted file mode 100644 index 7f0f266b761..00000000000 --- a/packages/migrate/__tests__/outputPath/outputPath.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('outputPath', function () { - { - defineTest(dirName, 'outputPath', 'outputPath-0'); - defineTest(dirName, 'outputPath', 'outputPath-1'); - defineTest(dirName, 'outputPath', 'outputPath-2'); - } -}); diff --git a/packages/migrate/__tests__/removeDeprecatedPlugins/__snapshots__/removeDeprecatedPlugins.test.ts.snap b/packages/migrate/__tests__/removeDeprecatedPlugins/__snapshots__/removeDeprecatedPlugins.test.ts.snap deleted file mode 100644 index 5955bd27226..00000000000 --- a/packages/migrate/__tests__/removeDeprecatedPlugins/__snapshots__/removeDeprecatedPlugins.test.ts.snap +++ /dev/null @@ -1,42 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`remove deprecated plugin removeDeprecatedPlugins transforms correctly using "removeDeprecatedPlugins-0" data 1`] = ` -"module.exports = {}; -" -`; - -exports[`remove deprecated plugin removeDeprecatedPlugins transforms correctly using "removeDeprecatedPlugins-1" data 1`] = ` -"module.exports = {}; -" -`; - -exports[`remove deprecated plugin removeDeprecatedPlugins transforms correctly using "removeDeprecatedPlugins-2" data 1`] = ` -"module.exports = { - plugins: [new webpack.optimize.UglifyJsPlugin()] -}; -" -`; - -exports[`remove deprecated plugin removeDeprecatedPlugins transforms correctly using "removeDeprecatedPlugins-3" data 1`] = ` -"// This should throw - -module.exports = config => { - config.plugins.push(new webpack.optimize.UglifyJsPlugin()); - config.plugins.push(new webpack.optimize.DedupePlugin()); - config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin()); - return config; -}; -" -`; - -exports[`remove deprecated plugin removeDeprecatedPlugins transforms correctly using "removeDeprecatedPlugins-4" data 1`] = ` -"// This should throw -const webpack = require(\\"webpack\\"); - -const inst = new webpack.optimize.OccurrenceOrderPlugin(); -module.exports = config => { - config.plugins = [inst]; - return config; -}; -" -`; diff --git a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-0.input.js b/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-0.input.js deleted file mode 100644 index 5171ac6d172..00000000000 --- a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-0.input.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - plugins: [new webpack.optimize.OccurrenceOrderPlugin()] -}; diff --git a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-1.input.js b/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-1.input.js deleted file mode 100644 index 73c1c9554fd..00000000000 --- a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-1.input.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - plugins: [new webpack.optimize.DedupePlugin()] -}; diff --git a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-2.input.js b/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-2.input.js deleted file mode 100644 index 93c058b3fff..00000000000 --- a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-2.input.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - plugins: [new webpack.optimize.OccurrenceOrderPlugin(), new webpack.optimize.UglifyJsPlugin(), new webpack.optimize.DedupePlugin()] -}; diff --git a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-3.input.js b/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-3.input.js deleted file mode 100644 index abdd8a4599b..00000000000 --- a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-3.input.js +++ /dev/null @@ -1,8 +0,0 @@ -// This should throw - -module.exports = config => { - config.plugins.push(new webpack.optimize.UglifyJsPlugin()); - config.plugins.push(new webpack.optimize.DedupePlugin()); - config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin()); - return config; -}; diff --git a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-4.input.js b/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-4.input.js deleted file mode 100644 index b436cbdb8ad..00000000000 --- a/packages/migrate/__tests__/removeDeprecatedPlugins/__testfixtures__/removeDeprecatedPlugins-4.input.js +++ /dev/null @@ -1,8 +0,0 @@ -// This should throw -const webpack = require("webpack"); - -const inst = new webpack.optimize.OccurrenceOrderPlugin(); -module.exports = config => { - config.plugins = [inst]; - return config; -}; diff --git a/packages/migrate/__tests__/removeDeprecatedPlugins/removeDeprecatedPlugins.test.ts b/packages/migrate/__tests__/removeDeprecatedPlugins/removeDeprecatedPlugins.test.ts deleted file mode 100644 index 130fd973c03..00000000000 --- a/packages/migrate/__tests__/removeDeprecatedPlugins/removeDeprecatedPlugins.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('remove deprecated plugin', function () { - { - defineTest(dirName, 'removeDeprecatedPlugins', 'removeDeprecatedPlugins-0'); - defineTest(dirName, 'removeDeprecatedPlugins', 'removeDeprecatedPlugins-1'); - defineTest(dirName, 'removeDeprecatedPlugins', 'removeDeprecatedPlugins-2'); - defineTest(dirName, 'removeDeprecatedPlugins', 'removeDeprecatedPlugins-3'); - defineTest(dirName, 'removeDeprecatedPlugins', 'removeDeprecatedPlugins-4'); - } -}); diff --git a/packages/migrate/__tests__/removeJsonLoader/__snapshots__/removeJsonLoader.test.ts.snap b/packages/migrate/__tests__/removeJsonLoader/__snapshots__/removeJsonLoader.test.ts.snap deleted file mode 100644 index fbdf946613a..00000000000 --- a/packages/migrate/__tests__/removeJsonLoader/__snapshots__/removeJsonLoader.test.ts.snap +++ /dev/null @@ -1,53 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`removeJsonLoader removeJsonLoader transforms correctly using "removeJsonLoader-0" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - test: /\\\\.yml/, - use: [{ - loader: \\"another-loader\\" - }, { - loader: \\"yml-loader\\" - }] - } - ] - } -}; -" -`; - -exports[`removeJsonLoader removeJsonLoader transforms correctly using "removeJsonLoader-1" data 1`] = ` -"module.exports = { - module: { - rules: [ - { - test: /\\\\.yml/, - use: [{ - loader: \\"yml-loader\\" - }] - } - ] - } -}; -" -`; - -exports[`removeJsonLoader removeJsonLoader transforms correctly using "removeJsonLoader-2" data 1`] = ` -"module.exports = { - module: { - rules: [] - } -}; -" -`; - -exports[`removeJsonLoader removeJsonLoader transforms correctly using "removeJsonLoader-3" data 1`] = ` -"module.exports = { - module: { - rules: [] - } -}; -" -`; diff --git a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-0.input.js b/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-0.input.js deleted file mode 100644 index a492d057aec..00000000000 --- a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-0.input.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - module: { - rules: [ - { - test: /\.yml/, - use: [ - { - loader: "json-loader" - }, - { - loader: "another-loader" - }, - { - loader: "yml-loader" - } - ] - } - ] - } -}; diff --git a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-1.input.js b/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-1.input.js deleted file mode 100644 index cf3e50853c4..00000000000 --- a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-1.input.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - module: { - rules: [ - { - test: /\.yml/, - use: [ - { - loader: "json-loader" - }, - { - loader: "yml-loader" - } - ] - } - ] - } -}; diff --git a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-2.input.js b/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-2.input.js deleted file mode 100644 index 5a8709cb4b4..00000000000 --- a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-2.input.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - module: { - rules: [ - { - loader: "json-loader", - test: /\.json/ - } - ] - } -}; diff --git a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-3.input.js b/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-3.input.js deleted file mode 100644 index c4050edc398..00000000000 --- a/packages/migrate/__tests__/removeJsonLoader/__testfixtures__/removeJsonLoader-3.input.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - module: { - rules: [ - { - test: /\.json/, - use: [ - { - loader: "json-loader" - } - ] - } - ] - } -}; diff --git a/packages/migrate/__tests__/removeJsonLoader/removeJsonLoader.test.ts b/packages/migrate/__tests__/removeJsonLoader/removeJsonLoader.test.ts deleted file mode 100644 index 621b531a70a..00000000000 --- a/packages/migrate/__tests__/removeJsonLoader/removeJsonLoader.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('removeJsonLoader', function () { - { - defineTest(dirName, 'removeJsonLoader', 'removeJsonLoader-0'); - defineTest(dirName, 'removeJsonLoader', 'removeJsonLoader-1'); - defineTest(dirName, 'removeJsonLoader', 'removeJsonLoader-2'); - defineTest(dirName, 'removeJsonLoader', 'removeJsonLoader-3'); - } -}); diff --git a/packages/migrate/__tests__/resolve/__snapshots__/resolve.test.ts.snap b/packages/migrate/__tests__/resolve/__snapshots__/resolve.test.ts.snap deleted file mode 100644 index 8c95bc6fa11..00000000000 --- a/packages/migrate/__tests__/resolve/__snapshots__/resolve.test.ts.snap +++ /dev/null @@ -1,29 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`resolve resolve transforms correctly 1`] = ` -"const path = require(\\"path\\"); -const rootPath = path.resolve(\\"/src\\"); -module.exports = [ - { - resolve: { - modules: [rootPath] - } - }, - { - resolve: { - modules: [rootPath] - } - }, - { - resolve: { - modules: [rootPath, \\"node_modules\\"] - } - }, - { - resolve: { - modules: [\\"node_modules\\", rootPath] - } - } -]; -" -`; diff --git a/packages/migrate/__tests__/resolve/__testfixtures__/resolve.input.js b/packages/migrate/__tests__/resolve/__testfixtures__/resolve.input.js deleted file mode 100644 index f90803ff3d0..00000000000 --- a/packages/migrate/__tests__/resolve/__testfixtures__/resolve.input.js +++ /dev/null @@ -1,25 +0,0 @@ -const path = require("path"); -const rootPath = path.resolve("/src"); -module.exports = [ - { - resolve: { - root: rootPath - } - }, - { - resolve: { - root: [rootPath] - } - }, - { - resolve: { - root: [rootPath, "node_modules"] - } - }, - { - resolve: { - modules: ["node_modules"], - root: rootPath - } - } -]; diff --git a/packages/migrate/__tests__/resolve/resolve.test.ts b/packages/migrate/__tests__/resolve/resolve.test.ts deleted file mode 100644 index 295b1df5e78..00000000000 --- a/packages/migrate/__tests__/resolve/resolve.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('resolve', function () { - { - defineTest(dirName, 'resolve'); - } -}); diff --git a/packages/migrate/__tests__/uglifyJsPlugin/__snapshots__/uglifyJsPlugin.test.ts.snap b/packages/migrate/__tests__/uglifyJsPlugin/__snapshots__/uglifyJsPlugin.test.ts.snap deleted file mode 100644 index 5f584a014f8..00000000000 --- a/packages/migrate/__tests__/uglifyJsPlugin/__snapshots__/uglifyJsPlugin.test.ts.snap +++ /dev/null @@ -1,119 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`uglifyJsPluginu uglifyJsPlugin transforms correctly using "uglifyJsPlugin-0" data 1`] = ` -"module.exports = { - optimization: { - minimize: true - } -} -" -`; - -exports[`uglifyJsPluginu uglifyJsPlugin transforms correctly using "uglifyJsPlugin-1" data 1`] = ` -"const TerserPlugin = require('terser-webpack-plugin'); -module.exports = { - devtool: \\"source-map\\", - optimization: { - minimize: true, - - minimizer: [new TerserPlugin({ - sourceMap: true, - compress: {} - })] - } -} -" -`; - -exports[`uglifyJsPluginu uglifyJsPlugin transforms correctly using "uglifyJsPlugin-2" data 1`] = ` -"const TerserPlugin = require('terser-webpack-plugin'); -module.exports = { - devtool: \\"source-map\\", - optimization: { - minimize: true, - - minimizer: [new TerserPlugin({ - sourceMap: true, - compress: {} - })] - } -} -" -`; - -exports[`uglifyJsPluginu uglifyJsPlugin transforms correctly using "uglifyJsPlugin-3" data 1`] = ` -"module.exports = { - devtool: 'eval', - - entry: [ - './src/index' - ], - - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - - module: { - loaders: [{ - test: /.js$/, - loaders: ['babel'], - include: path.join(__dirname, 'src') - }] - }, - - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - - plugins: [new webpack.optimize.OccurrenceOrderPlugin()], - debug: true, - - optimization: { - minimize: true - } -}; -" -`; - -exports[`uglifyJsPluginu uglifyJsPlugin transforms correctly using "uglifyJsPlugin-4" data 1`] = ` -"const TerserPlugin = require('terser-webpack-plugin'); -module.exports = { - devtool: 'eval', - - entry: [ - './src/index' - ], - - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - - module: { - loaders: [{ - test: /.js$/, - loaders: ['babel'], - include: path.join(__dirname, 'src') - }] - }, - - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - - plugins: [new webpack.optimize.OccurrenceOrderPlugin()], - debug: true, - - optimization: { - minimize: true, - - minimizer: [new TerserPlugin({ - sourceMap: true - })] - } -}; -" -`; diff --git a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-0.input.js b/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-0.input.js deleted file mode 100644 index a577b5143a6..00000000000 --- a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-0.input.js +++ /dev/null @@ -1,7 +0,0 @@ -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); - -module.exports = { - plugins: [ - new UglifyJsPlugin() - ] -} diff --git a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-1.input.js b/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-1.input.js deleted file mode 100644 index 1b8d983f3bd..00000000000 --- a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-1.input.js +++ /dev/null @@ -1,10 +0,0 @@ -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); -module.exports = { - devtool: "source-map", - plugins: [ - new UglifyJsPlugin({ - sourceMap: true, - compress: {} - }) - ] -} diff --git a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-2.input.js b/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-2.input.js deleted file mode 100644 index db172f05e29..00000000000 --- a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-2.input.js +++ /dev/null @@ -1,10 +0,0 @@ -const Uglify = require('uglifyjs-webpack-plugin'); -module.exports = { - devtool: "source-map", - plugins: [ - new Uglify({ - sourceMap: true, - compress: {} - }) - ] -} diff --git a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-3.input.js b/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-3.input.js deleted file mode 100644 index 4f104918915..00000000000 --- a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-3.input.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - loaders: [{ - test: /.js$/, - loaders: ['babel'], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin(), - new webpack.optimize.OccurrenceOrderPlugin() - ], - debug: true -}; diff --git a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-4.input.js b/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-4.input.js deleted file mode 100644 index 707400c20bd..00000000000 --- a/packages/migrate/__tests__/uglifyJsPlugin/__testfixtures__/uglifyJsPlugin-4.input.js +++ /dev/null @@ -1,28 +0,0 @@ -module.exports = { - devtool: 'eval', - entry: [ - './src/index' - ], - output: { - path: path.join(__dirname, 'dist'), - filename: 'index.js' - }, - module: { - loaders: [{ - test: /.js$/, - loaders: ['babel'], - include: path.join(__dirname, 'src') - }] - }, - resolve: { - root: path.resolve('/src'), - modules: ['node_modules'] - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin({ - sourceMap: true - }), - new webpack.optimize.OccurrenceOrderPlugin() - ], - debug: true -}; diff --git a/packages/migrate/__tests__/uglifyJsPlugin/uglifyJsPlugin.test.ts b/packages/migrate/__tests__/uglifyJsPlugin/uglifyJsPlugin.test.ts deleted file mode 100644 index 3d075bd0fe0..00000000000 --- a/packages/migrate/__tests__/uglifyJsPlugin/uglifyJsPlugin.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import defineTest from '../../../utils/__tests__/defineTest'; -import { join } from 'path'; - -const dirName: string = join(__dirname); - -describe('uglifyJsPluginu', function () { - { - defineTest(dirName, 'uglifyJsPlugin', 'uglifyJsPlugin-0'); - defineTest(dirName, 'uglifyJsPlugin', 'uglifyJsPlugin-1'); - defineTest(dirName, 'uglifyJsPlugin', 'uglifyJsPlugin-2'); - defineTest(dirName, 'uglifyJsPlugin', 'uglifyJsPlugin-3'); - defineTest(dirName, 'uglifyJsPlugin', 'uglifyJsPlugin-4'); - } -}); diff --git a/packages/migrate/package.json b/packages/migrate/package.json deleted file mode 100644 index e4e74bc21ac..00000000000 --- a/packages/migrate/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@webpack-cli/migrate", - "version": "1.1.2", - "description": "Migrate command for webpack-cli", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "files": [ - "lib" - ], - "dependencies": { - "@webpack-cli/utils": "^1.2.1", - "colorette": "^1.2.1", - "diff": "^4.0.2", - "inquirer": "^7.3.3", - "jscodeshift": "^0.11.0", - "listr": "^0.14.3", - "p-each-series": "^2.1.0", - "p-lazy": "^3.0.0" - }, - "peerDependencies": { - "webpack": "4.x.x || 5.x.x", - "webpack-cli": "4.x.x" - }, - "devDependencies": { - "@types/diff": "^4.0.2", - "@types/inquirer": "^7.3.1", - "@types/listr": "^0.14.2" - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/migrate/src/bannerPlugin/bannerPlugin.ts b/packages/migrate/src/bannerPlugin/bannerPlugin.ts deleted file mode 100644 index e8277e82bc1..00000000000 --- a/packages/migrate/src/bannerPlugin/bannerPlugin.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { createOrUpdatePluginByName, findPluginsByName } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Transform for BannerPlugin arguments. Consolidates first and second argument (if - * both are present) into single options object. - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -export default function (j: JSCodeshift, ast: Node): Node { - return findPluginsByName(j, ast, ['webpack.BannerPlugin']).forEach((path: Node): void => { - const args: Node[] = (path.value as Node).arguments; // any node - // If the first argument is a literal replace it with object notation - // See https://webpack.js.org/guides/migrating/#bannerplugin-breaking-change - if (args && args.length > 1 && args[0].type === j.Literal.name) { - // and remove the first argument - (path.value as Node).arguments = [(path.value as Node).arguments[1]]; - createOrUpdatePluginByName(j, path.parent, 'webpack.BannerPlugin', { - banner: args[0].value, - }); - } - }); -} diff --git a/packages/migrate/src/commonsChunkPlugin/commonsChunkPlugin.ts b/packages/migrate/src/commonsChunkPlugin/commonsChunkPlugin.ts deleted file mode 100644 index 4bc15bbda2f..00000000000 --- a/packages/migrate/src/commonsChunkPlugin/commonsChunkPlugin.ts +++ /dev/null @@ -1,235 +0,0 @@ -import { - addOrUpdateConfigObject, - createIdentifierOrLiteral, - createProperty, - findAndRemovePluginByName, - findPluginsByName, - findRootNodesByName, -} from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -// merge test entry prop and function expression. case 6[x] -// TODO: set the proper type once moved to @types/jscodeshift -// eslint-disable-next-line -const mergeTestPropArrowFunction = (j, chunkKey, testFunc): any => { - return j.property( - 'init', - createIdentifierOrLiteral(j, 'test'), - j.arrowFunctionExpression( - [j.identifier('module')], - j.blockStatement([ - j.ifStatement( - j.callExpression( - j.memberExpression( - j.callExpression(j.memberExpression(j.identifier('module'), j.identifier('getChunks')), []), - j.identifier('some'), - false, - ), - [ - j.arrowFunctionExpression( - [j.identifier('chunk')], - j.binaryExpression( - '===', - j.memberExpression(j.identifier('chunk'), j.identifier('name')), - j.literal(chunkKey), - ), - ), - ], - ), - j.returnStatement(j.literal(true)), - ), - j.variableDeclaration('const', [j.variableDeclarator(j.identifier('fn'), testFunc)]), - j.returnStatement(j.callExpression(j.identifier('fn'), [j.identifier('module')])), - ]), - ), - ); -}; - -/** - * - * Transform for CommonsChunkPlugin. If found, removes the - * plugin and sets optimizations.namedModules to true - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ -export default function (j: JSCodeshift, ast: Node): Node { - const splitChunksProps: Node[] = []; - const cacheGroupsProps: Node[] = []; - const optimizationProps: object = {}; - - let commonCacheGroupsProps: Node[] = [createProperty(j, 'chunks', 'initial'), createProperty(j, 'enforce', true)]; - - // find old options - const CommonsChunkPlugin: Node = findPluginsByName(j, ast, ['webpack.optimize.CommonsChunkPlugin']); - - if (!CommonsChunkPlugin.size()) { - return ast; - } - - // cache group options based on keys - let cacheGroup: object = {}; - let cacheGroups: Node[] = []; - - // iterate each CommonsChunkPlugin instance - CommonsChunkPlugin.forEach((path: Node): void => { - const CCPProps: Node[] = (path.value as Node).arguments[0].properties; - - // reset chunks from old props - cacheGroup = {}; - cacheGroups = []; - - commonCacheGroupsProps = [createProperty(j, 'chunks', 'initial'), createProperty(j, 'enforce', true)]; - - let chunkKey: string; - let chunkCount = 0; - - // iterate CCP props and map SCP props - CCPProps.forEach((p: Node): void => { - const propKey: string = p.key.name; - - switch (propKey) { - case 'names': - (p.value as Node).elements.forEach(({ value: chunkValue }): void => { - if (chunkValue === 'runtime') { - optimizationProps['runtimeChunk'] = j.objectExpression([createProperty(j, 'name', chunkValue)]); - } else { - if (!Array.isArray(cacheGroup[chunkValue as string])) { - cacheGroup[chunkValue as string] = []; - } - - findRootNodesByName(j, ast, 'entry').forEach(({ value }): void => { - const { properties: entries } = (value as Node).value as Node; - chunkCount = entries.length; - entries.forEach(({ key: { name: entryName } }): void => { - if (entryName === chunkValue) { - cacheGroup[chunkValue as string].push(createProperty(j, 'test', entryName)); - } - }); - }); - } - }); - break; - - case 'name': { - const nameKey = (p.value as Node).value as string; - - if (nameKey === 'runtime') { - optimizationProps['runtimeChunk'] = j.objectExpression([createProperty(j, 'name', nameKey)]); - } else { - chunkKey = nameKey; - - if (!Array.isArray(cacheGroup[nameKey])) { - cacheGroup[nameKey] = []; - } - - findRootNodesByName(j, ast, 'entry').forEach(({ value }): void => { - const { properties: entries } = (value as Node).value as Node; - chunkCount = entries.length; - entries.forEach(({ key: { name: entryName } }): void => { - if (entryName === nameKey) { - cacheGroup[nameKey].push(createProperty(j, 'test', entryName)); - } - }); - }); - } - break; - } - - case 'filename': - if (chunkKey) { - if (!Array.isArray(cacheGroup[chunkKey])) { - cacheGroup[chunkKey] = []; - } - cacheGroup[chunkKey].push(createProperty(j, propKey, (p.value as Node).value as string)); - } - break; - - case 'async': - if (!Array.isArray(cacheGroup[chunkKey])) { - cacheGroup[chunkKey] = []; - } - cacheGroup[chunkKey].push(createProperty(j, 'chunks', 'async')); - break; - - case 'minSize': - if (!Array.isArray(cacheGroup[chunkKey])) { - cacheGroup[chunkKey] = []; - } - cacheGroup[chunkKey].push(j.property('init', createIdentifierOrLiteral(j, propKey), p.value as Node)); - break; - - case 'minChunks': { - const { value: pathValue }: Node = p; - - // minChunk is a function - if ((pathValue as Node).type === 'ArrowFunctionExpression' || (pathValue as Node).type === 'FunctionExpression') { - if (!Array.isArray(cacheGroup[chunkKey])) { - cacheGroup[chunkKey] = []; - } - - cacheGroup[chunkKey] = cacheGroup[chunkKey].map((prop): string | void => - prop.key.name === 'test' ? mergeTestPropArrowFunction(j, chunkKey, pathValue) : prop, - ); - } - break; - } - } - }); - - Object.keys(cacheGroup).forEach((chunkName: string): void => { - let chunkProps: Node[] = [createProperty(j, 'name', chunkName)]; - - const chunkPropsToAdd = cacheGroup[chunkName]; - const chunkPropsKeys = chunkPropsToAdd.map((prop): string => prop.key.name); - - commonCacheGroupsProps = commonCacheGroupsProps.filter((commonProp): boolean => !chunkPropsKeys.includes(commonProp.key.name)); - - chunkProps.push(...commonCacheGroupsProps); - - if (chunkCount > 1) { - chunkProps.push(j.property('init', createIdentifierOrLiteral(j, 'minChunks'), createIdentifierOrLiteral(j, chunkCount))); - } - - const chunkPropsContainTest = chunkPropsToAdd.some( - (prop): boolean => prop.key.name === 'test' && prop.value.type === 'Literal', - ); - - if (chunkPropsContainTest) { - chunkProps = chunkProps.filter((prop): boolean => prop.key.name !== 'minChunks'); - } - - if (chunkPropsToAdd && Array.isArray(chunkPropsToAdd) && chunkPropsToAdd.length > 0) { - chunkProps.push(...chunkPropsToAdd); - } - - cacheGroups.push(j.property('init', createIdentifierOrLiteral(j, chunkName), j.objectExpression([...chunkProps]))); - }); - - if (cacheGroups.length > 0) { - cacheGroupsProps.push(...cacheGroups); - } - }); - - // Remove old plugin - const root: Node = findAndRemovePluginByName(j, ast, 'webpack.optimize.CommonsChunkPlugin'); - - const rootProps: Node[] = [...splitChunksProps]; - - if (cacheGroupsProps.length > 0) { - rootProps.push(j.property('init', createIdentifierOrLiteral(j, 'cacheGroups'), j.objectExpression([...cacheGroupsProps]))); - } - - // Add new optimizations splitChunks option - if (root) { - addOrUpdateConfigObject(j, root, 'optimizations', 'splitChunks', j.objectExpression([...rootProps])); - - Object.keys(optimizationProps).forEach((key: string): void => { - addOrUpdateConfigObject(j, root, 'optimizations', key, optimizationProps[key]); - }); - } - - return ast; -} diff --git a/packages/migrate/src/extractTextPlugin/extractTextPlugin.ts b/packages/migrate/src/extractTextPlugin/extractTextPlugin.ts deleted file mode 100644 index 1569271cadd..00000000000 --- a/packages/migrate/src/extractTextPlugin/extractTextPlugin.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { createProperty, findVariableToPlugin, isType } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Check whether `node` is the invocation of the plugin denoted by `pluginName` - * - * @param {Object} j - jscodeshift top-level import - * @param {Path} node - ast node to check - * @param {String} pluginName - name of the plugin - * @returns {Boolean} isPluginInvocation - whether `node` is the invocation of the plugin denoted by `pluginName` - */ - -function findInvocation(j: JSCodeshift, path: Node, pluginName: string): boolean { - let found = false; - found = - j(path) - .find(j.MemberExpression) - .filter((p: Node): boolean => (p.get('object').value as Node).name === pluginName) - .size() > 0; - return found; -} - -/** - * - * Transform for ExtractTextPlugin arguments. Consolidates arguments into single options object. - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -export default function (j: JSCodeshift, ast: Node): void | Node { - const changeArguments = (path: Node): Node => { - const args: Node[] = (path.value as Node).arguments; - - const literalArgs: Node[] = args.filter((p: Node): boolean => isType(p, 'Literal')); - if (literalArgs && literalArgs.length > 1) { - const newArgs: object = j.objectExpression( - literalArgs.map((p: Node, index: number): Node => createProperty(j, index === 0 ? 'fallback' : 'use', p.value as Node)), - ); - (path.value as Node).arguments = [newArgs]; - } - return path; - }; - const name: string = findVariableToPlugin(j, ast, 'extract-text-webpack-plugin'); - if (!name) { - return ast; - } - - return ast - .find(j.CallExpression) - .filter((p: Node): boolean => findInvocation(j, p, name)) - .forEach(changeArguments); -} diff --git a/packages/migrate/src/index.ts b/packages/migrate/src/index.ts deleted file mode 100644 index 3e7789a5e6c..00000000000 --- a/packages/migrate/src/index.ts +++ /dev/null @@ -1,200 +0,0 @@ -import { green, red } from 'colorette'; -import { Change, diffLines } from 'diff'; -import fs from 'fs'; -import inquirer from 'inquirer'; -import Listr from 'listr'; -import pLazy = require('p-lazy'); -import path from 'path'; -import { validate, WebpackOptionsValidationError } from 'webpack'; -import { runPrettier } from '@webpack-cli/utils'; -import { transformations } from './migrate'; -import { Node } from './types/NodePath'; -import jscodeshift from 'jscodeshift'; - -declare let process: { - cwd: Function; - webpackModule: { - validate: Function; - WebpackOptionsValidationError: { - new: ( - errors: string[], - ) => { - message: string; - }; - }; - }; - stdout: { - write: Function; - }; - exitCode: number; -}; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function runMigration(currentConfigPath: string, outputConfigPath: string, logger: any): Promise | void { - const recastOptions: object = { - quote: 'single', - }; - - const tasks: Listr = new Listr([ - { - task: (ctx: Node): string | void | Listr | Promise<{}> => - new pLazy((resolve: (value?: object) => void, reject: (reason?: string | object, err?: object) => void): void => { - fs.readFile(currentConfigPath, 'utf8', (err: object, content: string): void => { - if (err) { - reject(err); - } - try { - ctx.source = content; - ctx.ast = jscodeshift(content); - resolve(); - } catch (err) { - reject('Error generating AST', err); - } - }); - }), - title: 'Reading webpack config', - }, - { - task: (ctx: Node): string | void | Listr | Promise<{}> => { - return new Listr( - Object.keys(transformations).map((key: string): { - task: () => string; - title: string; - } => { - const transform: Function = transformations[key]; - return { - task: (): string => transform(ctx.ast, ctx.source), - title: key, - }; - }), - ); - }, - title: 'Migrating config to newest version', - }, - ]); - - return tasks - .run() - .then((ctx: Node): void | Promise => { - const result: string = ctx.ast.toSource(recastOptions); - const diffOutput: Change[] = diffLines(ctx.source, result); - - diffOutput.forEach((diffLine: Change): void => { - if (diffLine.added) { - process.stdout.write(green(`+ ${diffLine.value}`)); - } else if (diffLine.removed) { - process.stdout.write(red(`- ${diffLine.value}`)); - } - }); - - return inquirer - .prompt([ - { - default: 'Y', - message: 'Are you sure these changes are fine?', - name: 'confirmMigration', - type: 'confirm', - }, - ]) - .then( - (answers: { confirmMigration: boolean }): Promise<{}> => { - if (answers.confirmMigration) { - return inquirer.prompt([ - { - default: 'Y', - message: - 'Do you want to validate your configuration? ' + - "(If you're using webpack merge, validation isn't useful)", - name: 'confirmValidation', - type: 'confirm', - }, - ]); - } else { - logger.error('✖ Migration aborted'); - } - }, - ) - .then( - async (answer: { confirmValidation: boolean }): Promise => { - if (!answer) { - return; - } - - runPrettier(outputConfigPath, result); - - if (answer.confirmValidation) { - const outputConfig = (await import(outputConfigPath)).default; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const webpackOptionsValidationErrors: any = validate(outputConfig); - if (webpackOptionsValidationErrors && webpackOptionsValidationErrors.length) { - logger.error("\n✖ Your configuration validation wasn't successful\n"); - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore - // @ts-ignore - logger.error(new WebpackOptionsValidationError(webpackOptionsValidationErrors)); - } - } - - logger.success(`\n✔︎ New webpack config file is at ${outputConfigPath}.`); - logger.success('✔︎ Heads up! Updating to the latest version could contain breaking changes.'); - - logger.success('✔︎ Plugin and loader dependencies may need to be updated.'); - }, - ); - }) - .catch((err: object): void => { - logger.error('\n ✖ ︎Migration aborted due to some errors:\n'); - logger.error(err); - process.exitCode = 1; - }); -} - -class MigrationCommand { - async apply(cli): Promise { - const { logger } = cli; - - await cli.makeCommand( - { - name: 'migrate [new-config-path]', - alias: 'm', - description: 'Migrate a configuration to a new version.', - pkg: '@webpack-cli/migrate', - }, - [], - async (configPath: string, newConfigPath: string | undefined) => { - const currentConfigPath = path.resolve(configPath); - let outputConfigPath: string; - - if (!newConfigPath) { - try { - const { confirmPath } = await inquirer.prompt([ - { - default: 'Y', - message: 'Migration output path not specified. Do you want to use your existing webpack configuration?', - name: 'confirmPath', - type: 'confirm', - }, - ]); - if (!confirmPath) { - logger.error('︎Migration aborted due to no output path'); - return; - } - outputConfigPath = path.resolve(configPath); - - await runMigration(currentConfigPath, outputConfigPath, logger); - } catch (err) { - logger.error(err); - return; - } - - return; - } - - outputConfigPath = path.resolve(newConfigPath); - - await runMigration(currentConfigPath, outputConfigPath, logger); - }, - ); - } -} - -export default MigrationCommand; diff --git a/packages/migrate/src/loaderOptionsPlugin/loaderOptionsPlugin.ts b/packages/migrate/src/loaderOptionsPlugin/loaderOptionsPlugin.ts deleted file mode 100644 index 9df7f512070..00000000000 --- a/packages/migrate/src/loaderOptionsPlugin/loaderOptionsPlugin.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { createOrUpdatePluginByName, findPluginsByName, safeTraverse } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -interface LoaderOptions { - debug?: boolean; - minimize?: boolean; -} - -const isEmpty = (obj: LoaderOptions): boolean => Object.keys(obj).length === 0; - -/** - * - * Transform which adds context information for old loaders by injecting a `LoaderOptionsPlugin` - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - * - */ - -export default function (j: JSCodeshift, ast: Node): Node { - const loaderOptions: LoaderOptions = {}; - - // If there is debug: true, set debug: true in the plugin - if (ast.find(j.Identifier, { name: 'debug' }).size()) { - loaderOptions.debug = true; - - ast.find(j.Identifier, { name: 'debug' }).forEach((p: Node): void => { - p.parent.prune(); - }); - } - - // If there is UglifyJsPlugin, set minimize: true - if (findPluginsByName(j, ast, ['webpack.optimize.UglifyJsPlugin']).size()) { - loaderOptions.minimize = true; - } - - return ast - .find(j.ArrayExpression) - .filter((path: Node): boolean => safeTraverse(path, ['parent', 'value', 'key', 'name']) === 'plugins') - .forEach((path: Node): void => { - if (!isEmpty(loaderOptions)) { - createOrUpdatePluginByName(j, path, 'webpack.LoaderOptionsPlugin', loaderOptions); - } - }); -} diff --git a/packages/migrate/src/loaders/loaders.ts b/packages/migrate/src/loaders/loaders.ts deleted file mode 100644 index 0e3c85e4189..00000000000 --- a/packages/migrate/src/loaders/loaders.ts +++ /dev/null @@ -1,354 +0,0 @@ -import { createLiteral, createProperty, findObjWithOneOfKeys, safeTraverse } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Transform for loaders. Transforms pre- and postLoaders into enforce options, - * moves loader configuration into rules array, transforms query strings and - * props into loader options, and adds -loader suffix to loader names. - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -export default function (j: JSCodeshift, ast: Node): Node { - /** - * Creates an Array expression out of loaders string - * - * - * For syntaxes like - * - * { - * loader: 'style!css` - * } - * - * or - * - * { - * loaders: ['style', 'css'] - * } - * - * or - * - * loaders: [{ - * loader: 'style' - * }, - * { - * loader: 'css', - * }] - * - * it should generate - * - * { - * use: [{ - * loader: 'style' - * }, - * { - * loader: 'css' - * }] - * } - * - * @param {Node} path - object expression ast - * @returns {Node} path - object expression ast with array expression instead of loaders string - */ - - const createArrayExpressionFromArray = (path: Node): Node => { - const value: Node = path.value as Node; - // Find paths with `loaders` keys in the given Object - const paths: Node[] = value.properties.filter((prop: Node): boolean => prop.key.name.startsWith('loader')); - // For each pair of key and value - paths.forEach((pair: Node): void => { - // Replace 'loaders' Identifier with 'use' - pair.key.name = 'use'; - // If the value is an Array - if ((pair.value as Node).type === j.ArrayExpression.name) { - // replace its elements - const pairValue = pair.value as Node; - pair.value = j.arrayExpression( - pairValue.elements.map( - (arrElement: Node): Node => { - // If items of the array are Strings - if (arrElement.type === j.Literal.name) { - // Replace with `{ loader: LOADER }` Object - return j.objectExpression([createProperty(j, 'loader', arrElement.value as Node)]); - } - // otherwise keep the existing element - return arrElement; - }, - ), - ); - // If the value is String of loaders like 'style!css' - } else if ((pair.value as Node).type === j.Literal.name) { - // Replace it with Array expression of loaders - const literalValue = pair.value as Node; - pair.value = j.arrayExpression( - (literalValue.value as string).split('!').map( - (loader: string): Node => { - return j.objectExpression([createProperty(j, 'loader', loader)]); - }, - ), - ); - } - }); - return path; - }; - - /** - * - * Puts query parameters from loader value into options object - * - * @param {Node} p - object expression ast for loader object - * @returns {Node} objectExpression - an new object expression ast containing the query parameters - */ - - const createLoaderWithQuery = (p: Node): Node => { - const properties: Node[] = (p.value as Node).properties; - const loaderValue: string = properties.reduce( - (val: string, prop: Node): string => (prop.key.name === 'loader' ? ((prop.value as Node).value as string) : val), - '', - ); - const loader: string = loaderValue.split('?')[0]; - const query: string = loaderValue.split('?')[1]; - const options: Node[] = query.split('&').map( - (option: string): Node => { - const param: string[] = option.split('='); - const key: string = param[0]; - const val: string | boolean = param[1] || true; // No value in query string means it is truthy value - return j.objectProperty(j.identifier(key), createLiteral(j, val)); - }, - ); - const loaderProp: Node = createProperty(j, 'loader', loader); - const queryProp: Node = j.property('init', j.identifier('options'), j.objectExpression(options)); - return j.objectExpression([loaderProp, queryProp]); - }; - - /** - * - * Determine whether a loader has a query string - * - * @param {Node} p - object expression ast for loader object - * @returns {Boolean} hasLoaderQueryString - whether the loader object contains a query string - */ - - const findLoaderWithQueryString = (p: Node): boolean => { - return (p.value as Node).properties.reduce((predicate: boolean, prop: Node): boolean => { - return ( - (safeTraverse(prop, ['value', 'value', 'indexOf']) && ((prop.value as Node).value as string).indexOf('?') > -1) || predicate - ); - }, false); - }; - - /** - * Check if the identifier is the `loaders` prop in the `module` object. - * If the path value is `loaders` and it’s located in `module` object - * we assume it’s the loader's section. - * - * @param {Node} path - identifier ast - * @returns {Boolean} isLoadersProp - whether the identifier is the `loaders` prop in the `module` object - */ - - const checkForLoader = (path: Node): boolean => - (path.value as Node).name === 'loaders' && safeTraverse(path, ['parent', 'parent', 'parent', 'node', 'key', 'name']) === 'module'; - - /** - * Puts pre- or postLoader into `loaders` object and adds the appropriate `enforce` property - * - * @param {Node} p - object expression ast that has a key for either 'preLoaders' or 'postLoaders' - * @returns {Node} p - object expression with a `loaders` object and appropriate `enforce` properties - */ - - const fitIntoLoaders = (p: Node): Node => { - let loaders: Node = null; - (p.value as Node).properties.map((prop: Node): void => { - const keyName = prop.key.name; - if (keyName === 'loaders') { - loaders = prop.value as Node; - } - }); - (p.value as Node).properties.map((prop: Node): void => { - const keyName = prop.key.name; - if (keyName !== 'loaders') { - const enforceVal: string = keyName === 'preLoaders' ? 'pre' : 'post'; - (prop.value as Node).elements.map((elem: Node): void => { - elem.properties.push(createProperty(j, 'enforce', enforceVal)); - if (loaders && loaders.type === 'ArrayExpression') { - loaders.elements.push(elem); - } else { - prop.key.name = 'loaders'; - } - }); - } - }); - if (loaders) { - (p.value as Node).properties = (p.value as Node).properties.filter((prop: Node): boolean => prop.key.name === 'loaders'); - } - return p; - }; - - /** - * Find pre and postLoaders in the ast and put them into the `loaders` array - * - * @returns {Node} ast - jscodeshift ast - */ - - const prepostLoaders = (): Node => - ast - .find(j.ObjectExpression) - .filter((p: Node): boolean => findObjWithOneOfKeys(p, ['preLoaders', 'postLoaders'])) - .forEach(fitIntoLoaders); - - /** - * Convert top level `loaders` to `rules` - * - * @returns {Node} ast - jscodeshift ast - */ - - const loadersToRules = (): Node => - ast - .find(j.Identifier) - .filter(checkForLoader) - .forEach((p: Node): string => ((p.value as Node).name = 'rules')); - - /** - * Convert `loader` and `loaders` to Array of {Rule.Use} - * - * @returns {Node} ast - jscodeshift ast - */ - - const loadersToArrayExpression = (): Node | void => - ast - .find(j.ObjectExpression) - .filter((path: Node): boolean => findObjWithOneOfKeys(path, ['loader', 'loaders'])) - .filter((path: Node): boolean => safeTraverse(path, ['parent', 'parent', 'node', 'key', 'name']) === 'rules') - .forEach(createArrayExpressionFromArray); - - /** - * Find loaders with options encoded as a query string and replace the string with an options object - * - * i.e. for loader like - * - * { - * loader: 'css?modules&importLoaders=1&string=test123' - * } - * - * it should generate - * { - * loader: 'css-loader', - * options: { - * modules: true, - * importLoaders: 1, - * string: 'test123' - * } - * } - * - * @returns {Node} ast - jscodeshift ast - */ - - const loaderWithQueryParam = (): Node => - ast - .find(j.ObjectExpression) - .filter((p: Node): boolean => findObjWithOneOfKeys(p, ['loader'])) - .filter(findLoaderWithQueryString) - .replaceWith(createLoaderWithQuery); - - /** - * Find nodes with a `query` key and replace it with `options` - * - * i.e. for - * { - * query: { ... } - * } - * - * it should generate - * - * { - * options: { ... } - * } - * - * @returns {Node} ast - jscodeshift ast - */ - - const loaderWithQueryProp = (): Node => - ast - .find(j.Identifier) - .filter((p: Node): boolean => (p.value as Node).name === 'query') - .replaceWith(j.identifier('options')); - - /** - * Add required `-loader` suffix to a loader with missing suffix - * e.g. for `babel` it should generate `babel-loader` - * - * @returns {Node} ast - jscodeshift ast - */ - - const addLoaderSuffix = (): Node => - ast.find(j.ObjectExpression).forEach((path: Node): void => { - (path.value as Node).properties.forEach((prop: Node): void => { - if ( - prop.key.name === 'loader' && - safeTraverse(prop, ['value', 'value']) && - !((prop.value as Node).value as string).endsWith('-loader') - ) { - prop.value = j.literal(((prop.value as Node).value as string) + '-loader'); - } - }); - }); - - /** - * - * Puts options object outside use object into use object - * - * @param {Node} p - object expression ast that has a key for either 'options' or 'use' - * @returns {Node} objectExpression - an use object expression ast containing the options and loader - */ - - const fitOptionsToUse = (p: Node): Node => { - let options: Node = null; - (p.value as Node).properties.forEach((prop: Node): void => { - const keyName: string = prop.key.name; - if (keyName === 'options') { - options = prop; - } - }); - - if (options) { - (p.value as Node).properties = (p.value as Node).properties.filter((prop: Node): boolean => prop.key.name !== 'options'); - - (p.value as Node).properties.forEach((prop: Node): void => { - const keyName = prop.key.name; - if (keyName === 'use') { - (prop.value as Node).elements[0].properties.push(options); - } - }); - } - - return p; - }; - - /** - * Move `options` inside the Array of {Rule.Use} - * - * @returns {Node} ast - jscodeshift ast - */ - - const moveOptionsToUse = (): Node => - ast - .find(j.ObjectExpression) - .filter((p: Node): boolean => findObjWithOneOfKeys(p, ['use'])) - .forEach(fitOptionsToUse); - - const transforms = [ - prepostLoaders, - loadersToRules, - loadersToArrayExpression, - loaderWithQueryParam, - loaderWithQueryProp, - addLoaderSuffix, - moveOptionsToUse, - ]; - transforms.forEach((t: Function): void => t()); - - return ast; -} diff --git a/packages/migrate/src/migrate.ts b/packages/migrate/src/migrate.ts deleted file mode 100644 index fc771a777ba..00000000000 --- a/packages/migrate/src/migrate.ts +++ /dev/null @@ -1,123 +0,0 @@ -import jscodeshift from 'jscodeshift'; -import pEachSeries = require('p-each-series'); -import pLazy = require('p-lazy'); -import bannerPluginTransform from './bannerPlugin/bannerPlugin'; -import commonsChunkPluginTransform from './commonsChunkPlugin/commonsChunkPlugin'; -import extractTextPluginTransform from './extractTextPlugin/extractTextPlugin'; -import loaderOptionsPluginTransform from './loaderOptionsPlugin/loaderOptionsPlugin'; -import loadersTransform from './loaders/loaders'; -import noEmitOnErrorsPluginTransform from './noEmitOnErrorsPlugin/noEmitOnErrorsPlugin'; -import removeDeprecatedPluginsTransform from './removeDeprecatedPlugins/removeDeprecatedPlugins'; -import removeJsonLoaderTransform from './removeJsonLoader/removeJsonLoader'; -import resolveTransform from './resolve/resolve'; -import uglifyJsPluginTransform from './uglifyJsPlugin/uglifyJsPlugin'; - -interface TransformsObject { - bannerPluginTransform: object; - commonsChunkPluginTransform?: object; - extractTextPluginTransform: object; - loaderOptionsPluginTransform: object; - loadersTransform: object; - noEmitOnErrorsPluginTransform: object; - removeDeprecatedPluginsTransform: object; - removeJsonLoaderTransform: object; - resolveTransform: object; - uglifyJsPluginTransform: object; -} - -const transformsObject: TransformsObject = { - loadersTransform, - resolveTransform, - removeJsonLoaderTransform, - uglifyJsPluginTransform, - loaderOptionsPluginTransform, - bannerPluginTransform, - extractTextPluginTransform, - noEmitOnErrorsPluginTransform, - removeDeprecatedPluginsTransform, - commonsChunkPluginTransform, -}; - -interface LazyTransformObject { - loadersTransform?: (ast: object, source: string) => pLazy<{}>; - resolveTransform?: (ast: object, source: string) => pLazy<{}>; - removeJsonLoaderTransform?: (ast: object, source: string) => pLazy<{}>; - uglifyJsPluginTransform?: (ast: object, source: string) => pLazy<{}>; - loaderOptionsPluginTransform?: (ast: object, source: string) => pLazy<{}>; - bannerPluginTransform?: (ast: object, source: string) => pLazy<{}>; - extractTextPluginTransform?: (ast: object, source: string) => pLazy<{}>; - noEmitOnErrorsPluginTransform?: (ast: object, source: string) => pLazy<{}>; - removeDeprecatedPluginsTransform?: (ast: object, source: string) => pLazy<{}>; - commonsChunkPluginTransform?: (ast: object, source: string) => pLazy<{}>; -} - -/** - * - * Transforms single AST based on given transform function - * and returns back a promise with resolved transformation - * - * @param {Object} ast - AST object - * @param {String} source - source string - * @param {Function} transformFunction - Transformation function with source object - * @returns {Object} pLazy promise with resolved transform function - */ - -export const transformSingleAST = ( - ast: object, - source: string, - transformFunction: (jscodeshift: object, ast: object, source: string) => object, -): pLazy<{}> => { - return new pLazy((resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: object) => void): void => { - setTimeout((): void => { - try { - resolve(transformFunction(jscodeshift, ast, source)); - } catch (err) { - reject(err); - } - }, 0); - }); -}; - -export const transformations: LazyTransformObject = Object.keys(transformsObject).reduce( - (res: object, key: string): LazyTransformObject => { - res[key] = (ast: object, source: string): object => transformSingleAST(ast, source, transformsObject[key]); - return res; - }, - {}, -); - -/** - * - * Transforms a given piece of source code by applying selected transformations to the AST. - * By default, transforms a webpack version 1 configuration file into a webpack version 2 - * configuration file. - * - * @param {String} source - source file contents - * @param {Function[]} [transforms] - List of transformation functions, defined in the - * order to apply them in. By default, all defined transformations. - * @param {Object} [options] - recast formatting options - * @returns {Promise} promise functions for series - */ - -export const transform = ( - source: string, - transforms?: Iterable>, - options?: object, -): Promise => { - const ast = jscodeshift(source); - const recastOptions: object = Object.assign( - { - quote: 'single', - }, - options, - ); - transforms = transforms || Object.keys(transformations).map((k: string): Function => transformations[k]); - - return pEachSeries(transforms, (f: Function): void => f(ast, source)) - .then((): string | PromiseLike => { - return ast.toSource(recastOptions); - }) - .catch((err: object): void => { - console.error(err); - }); -}; diff --git a/packages/migrate/src/moduleConcatenationPlugin/moduleConcatenationPlugin.ts b/packages/migrate/src/moduleConcatenationPlugin/moduleConcatenationPlugin.ts deleted file mode 100644 index d3d5fcc3b70..00000000000 --- a/packages/migrate/src/moduleConcatenationPlugin/moduleConcatenationPlugin.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { addOrUpdateConfigObject, findAndRemovePluginByName } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Transform for NamedModulesPlugin. If found, removes the - * plugin and sets optimizations.namedModules to true - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ -export default function (j: JSCodeshift, ast: Node): Node { - // Remove old plugin - const root: Node = findAndRemovePluginByName(j, ast, 'webpack.optimize.ModuleConcatenationPlugin'); - - // Add new optimizations option - if (root) { - addOrUpdateConfigObject(j, root, 'optimizations', 'concatenateModules', j.booleanLiteral(true)); - } - - return ast; -} diff --git a/packages/migrate/src/namedModulesPlugin/namedModulesPlugin.ts b/packages/migrate/src/namedModulesPlugin/namedModulesPlugin.ts deleted file mode 100644 index a4fe8dfc043..00000000000 --- a/packages/migrate/src/namedModulesPlugin/namedModulesPlugin.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { addOrUpdateConfigObject, findAndRemovePluginByName } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Transform for NamedModulesPlugin. If found, removes the - * plugin and sets optimizations.namedModules to true - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ -export default function (j: JSCodeshift, ast: Node): Node { - // Remove old plugin - const root: Node = findAndRemovePluginByName(j, ast, 'webpack.NamedModulesPlugin'); - - // Add new optimizations option - if (root) { - addOrUpdateConfigObject(j, root, 'optimizations', 'namedModules', j.booleanLiteral(true)); - } - - return ast; -} diff --git a/packages/migrate/src/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.ts b/packages/migrate/src/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.ts deleted file mode 100644 index c2611c3a0ba..00000000000 --- a/packages/migrate/src/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { addOrUpdateConfigObject, findAndRemovePluginByName } from '@webpack-cli/utils'; -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Transform for NoEmitOnErrorsPlugin. If found, removes the - * plugin and sets optimizations.noEmitOnErrors to true - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ -export default function (j: JSCodeshift, ast: Node): Node { - // Remove old plugin - const root: Node = findAndRemovePluginByName(j, ast, 'webpack.NoEmitOnErrorsPlugin'); - - // Add new optimizations option - if (root) { - addOrUpdateConfigObject(j, root, 'optimizations', 'noEmitOnErrors', j.booleanLiteral(true)); - } - - return ast; -} diff --git a/packages/migrate/src/outputPath/outputPath.ts b/packages/migrate/src/outputPath/outputPath.ts deleted file mode 100644 index 14ac10bb082..00000000000 --- a/packages/migrate/src/outputPath/outputPath.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { getRequire, safeTraverse } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -function replaceWithPath(j: JSCodeshift, p: Node, pathVarName: string): Node { - const convertedPath: Node = j.callExpression(j.memberExpression(j.identifier(pathVarName), j.identifier('join'), false), [ - j.identifier('__dirname'), - p.value as Node, - ]); - - return convertedPath; -} - -/** - * - * Transform which adds `path.join` call to `output.path` literals - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ -export default function (j: JSCodeshift, ast: Node): Node | void { - const literalOutputPath: Node = ast - .find(j.ObjectExpression) - .filter((p: Node): boolean => safeTraverse(p, ['parentPath', 'value', 'key', 'name']) === 'output') - .find(j.Property) - .filter( - (p: Node): boolean => - safeTraverse(p, ['value', 'key', 'name']) === 'path' && safeTraverse(p, ['value', 'value', 'type']) === 'Literal', - ); - - if (literalOutputPath) { - let pathVarName = 'path'; - let isPathPresent = false; - const pathDeclaration: Node = ast - .find(j.VariableDeclarator) - .filter((p: Node): boolean => safeTraverse(p, ['value', 'init', 'callee', 'name']) === 'require') - .filter( - (p: Node): boolean => - safeTraverse(p, ['value', 'init', 'arguments']) && - // TODO: to fix when we have proper typing (@types/jscodeshift) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (p.value as any).init.arguments.reduce((isPresent: boolean, a: Node): boolean => { - return (a.type === 'Literal' && a.value === 'path') || isPresent; - }, false), - ); - - if (pathDeclaration) { - isPathPresent = true; - pathDeclaration.forEach((p: Node): void => { - pathVarName = safeTraverse(p, ['value', 'id', 'name']) as string; - }); - } - const finalPathName = pathVarName; - literalOutputPath.find(j.Literal).replaceWith((p: Node): Node => replaceWithPath(j, p, finalPathName)); - - if (!isPathPresent) { - const pathRequire: Node = getRequire(j, 'path', 'path'); - return ast.find(j.Program).replaceWith((p: Node): Node => j.program([].concat(pathRequire).concat((p.value as Node).body))); - } - } - - return ast; -} diff --git a/packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts b/packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts deleted file mode 100644 index 12d270e48e8..00000000000 --- a/packages/migrate/src/removeDeprecatedPlugins/removeDeprecatedPlugins.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { red, underline } from 'colorette'; - -import { findPluginsByName, isType, safeTraverse } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -import { utils } from 'webpack-cli'; - -const { logger } = utils; - -/** - * - * Find deprecated plugins and remove them from the `plugins` array, if possible. - * Otherwise, warn the user about removing deprecated plugins manually. - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -export default function (j: JSCodeshift, ast: Node): Node { - // List of deprecated plugins to remove - // each item refers to webpack.optimize.[NAME] construct - const deprecatedPlugingsList: string[] = ['webpack.optimize.OccurrenceOrderPlugin', 'webpack.optimize.DedupePlugin']; - - return findPluginsByName(j, ast, deprecatedPlugingsList).forEach((path: Node): void => { - // For now we only support the case where plugins are defined in an Array - const arrayPath = safeTraverse(path, ['parent', 'value']) as Node; - - if (arrayPath && isType(arrayPath, 'ArrayExpression')) { - // Check how many plugins are defined and - // if there is only last plugin left remove `plugins: []` node - // - const arrayElementsPath = safeTraverse(arrayPath, ['elements']) as Node[]; - if (arrayElementsPath && arrayElementsPath.length === 1) { - j(path.parent.parent).remove(); - } else { - j(path).remove(); - } - } else { - logger.log(` -${red('Please remove deprecated plugins manually. ')} -See ${underline('https://webpack.js.org/guides/migrating/')} for more information.`); - } - }); -} diff --git a/packages/migrate/src/removeJsonLoader/removeJsonLoader.ts b/packages/migrate/src/removeJsonLoader/removeJsonLoader.ts deleted file mode 100644 index 9f8a884400e..00000000000 --- a/packages/migrate/src/removeJsonLoader/removeJsonLoader.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { safeTraverse } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -type TransformCallback = (astNode: Node) => void; - -/** - * - * Transform which removes the json loader from all possible declarations - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -export default function (j: JSCodeshift, ast: Node): Node { - /** - * - * Remove the loader with name `name` from the given NodePath - * - * @param {Node} path - ast to remove the loader from - * @param {String} name - the name of the loader to remove - * @returns {void} - */ - - function removeLoaderByName(path: Node, name: string): void { - const loadersNode = (path.value as Node).value as Node; - - switch (loadersNode.type) { - case j.ArrayExpression.name: { - const loaders: Node[] = loadersNode.elements.map( - (p: Node): Node => { - return safeTraverse(p, ['properties', '0', 'value', 'value']) as Node; - }, - ); - - const loaderIndex: number = loaders.indexOf(name); - if (loaders.length && loaderIndex > -1) { - // Remove loader from the array - loaders.splice(loaderIndex, 1); - // and from AST - loadersNode.elements.splice(loaderIndex, 1); - } - - // If there are no loaders left, remove the whole Rule object - if (loaders.length === 0) { - j(path.parent).remove(); - } - break; - } - case j.Literal.name: { - // If only the loader with the matching name was used - // we can remove the whole Property node completely - if (loadersNode.value === name) { - j(path.parent).remove(); - } - break; - } - } - } - - function removeLoaders(astNode: Node): void { - astNode.find(j.Property, { key: { name: 'use' } }).forEach((path: Node): void => removeLoaderByName(path, 'json-loader')); - - astNode.find(j.Property, { key: { name: 'loader' } }).forEach((path: Node): void => removeLoaderByName(path, 'json-loader')); - } - - const transforms: TransformCallback[] = [removeLoaders]; - - transforms.forEach((t: TransformCallback): void => t(ast)); - - return ast; -} diff --git a/packages/migrate/src/resolve/resolve.ts b/packages/migrate/src/resolve/resolve.ts deleted file mode 100644 index 01cc27eade8..00000000000 --- a/packages/migrate/src/resolve/resolve.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Transform which consolidates the `resolve.root` configuration option into the `resolve.modules` array - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -export default function transformer(j: JSCodeshift, ast: Node): Node { - const getRootVal = (p: Node): Node => { - return (p.node.value as Node).properties.filter((prop: Node): boolean => prop.key.name === 'root')[0]; - }; - - const getRootIndex = (p: Node): number => { - return (p.node.value as Node).properties.reduce((rootIndex: number, prop: Node, index: number): number => { - return prop.key.name === 'root' ? index : rootIndex; - }, -1); - }; - - const isModulePresent = (p: Node): Node | false => { - const modules: Node[] = (p.node.value as Node).properties.filter((prop: Node): boolean => prop.key.name === 'modules'); - - return modules.length > 0 && modules[0]; - }; - - /** - * - * Add a `modules` property to the `resolve` object or update the existing one - * based on what is already in `resolve.root` - * - * @param {Node} p - ast node that represents the `resolve` property - * @returns {Node} ast - ast node - */ - - const createModuleArray = (p: Node): Node => { - const rootVal: Node = getRootVal(p); - - let modulesVal: Node[] = null; - - if ((rootVal.value as Node).type === 'ArrayExpression') { - modulesVal = (rootVal.value as Node).elements; - } else { - modulesVal = [rootVal.value as Node]; - } - - let module: Node | false = isModulePresent(p); - - if (!module) { - module = j.property('init', j.identifier('modules'), j.arrayExpression(modulesVal)); - (p.node.value as Node).properties = (p.node.value as Node).properties.concat([module]); - } else { - (module.value as Node).elements = (module.value as Node).elements.concat(modulesVal); - } - - const rootIndex: number = getRootIndex(p); - - (p.node.value as Node).properties.splice(rootIndex, 1); - - return p; - }; - - return ast - .find(j.Property) - .filter((p: Node): boolean => { - return ( - p.node.key.name === 'resolve' && - (p.node.value as Node).properties.filter((prop: Node): boolean => prop.key.name === 'root').length === 1 - ); - }) - .forEach(createModuleArray); -} diff --git a/packages/migrate/src/types/NodePath.ts b/packages/migrate/src/types/NodePath.ts deleted file mode 100644 index fb2a3877348..00000000000 --- a/packages/migrate/src/types/NodePath.ts +++ /dev/null @@ -1,95 +0,0 @@ -export interface Node extends Object { - id?: { - name: string; - }; - arguments?: Node[]; - body?: Node[]; - elements?: Node[]; - expression?: { - left: { - computed: boolean; - object: Node; - property: Node; - type: string; - }; - operator: string; - right: Node; - type: string; - value?: string; - }; - filter?: (p: (p: Node) => boolean) => Node; - find?: (objectExpression: object, filterExpression?: object) => Node; - forEach?: (p: (p: Node) => void) => Node; - get?: (property: string) => Node; - remove?: () => void; - nodes?: () => Node[]; - pop?: () => Node; - key?: { - name: string; - value: Node | string; - }; - node?: Node; - name?: string; - object?: object; - parent?: Node; - properties?: Node[]; - property?: Node; - prune?: Function; - replaceWith?: (objectExpression: object) => Node; - size?: () => number; - type?: string; - value?: Node | string | Node[]; - toSource?: (object: { quote?: string }) => string; - source?: string; - ast?: Node; - rules?: ModuleRule[]; - - declarations?: Node[]; - - __paths?: Node[]; -} - -interface ModuleRule { - loader?: string; -} - -interface ExpressionObject { - name?: string; -} - -export interface JSCodeshift extends Object { - (source?: Node | string): Node; - withParser?: (parser: string) => JSCodeshift; - identifier?: (key: string) => Node; - literal?: (key: valueType) => Node; - memberExpression?: (node1: Node, node2: Node, bool?: boolean) => Node; - objectProperty?: (key: Node, property: valueType) => Node; - objectExpression?: (properties: Node[]) => Node; - newExpression?: (expression: Node, args: Node[]) => Node; - callExpression?: (expression: Node, args: Node[]) => Node; - variableDeclarator?: (key: Node, args: Node) => Node; - variableDeclaration?: (key: string, args: Node[]) => Node; - arrayExpression?: (args?: Node[]) => Node; - property?: (type: string, key: Node, value: Node) => Node; - program?: (nodes: Node[]) => Node; - booleanLiteral?: (bool: boolean) => Node; - Property?: ExpressionObject; - NewExpression?: ExpressionObject; - CallExpression?: ExpressionObject; - VariableDeclarator?: ExpressionObject; - Identifier?: ExpressionObject; - Literal?: ExpressionObject; - ArrayExpression?: ExpressionObject; - MemberExpression?: ExpressionObject; - FunctionExpression?: ExpressionObject; - ObjectExpression?: ExpressionObject; - BlockStatement?: ExpressionObject; - Program?: ExpressionObject; - filters?: { - VariableDeclarator: { - requiresModule: Function; - }; - }; -} - -export type valueType = string | number | boolean | Node | null; diff --git a/packages/migrate/src/uglifyJsPlugin/uglifyJsPlugin.ts b/packages/migrate/src/uglifyJsPlugin/uglifyJsPlugin.ts deleted file mode 100644 index 8d297a54791..00000000000 --- a/packages/migrate/src/uglifyJsPlugin/uglifyJsPlugin.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { createProperty, findPluginsArrayAndRemoveIfEmpty, findPluginsByName, getRequire, safeTraverse } from '@webpack-cli/utils'; - -import { JSCodeshift, Node } from '../types/NodePath'; - -/** - * - * Transform which: - * Removes UglifyWebpackPlugin from plugins array, if no options is passed to the plugin. - * and adds `optimization.minimize: true` to config - * - * If any configuration is passed to UglifyWebpackPlugin - * UglifyWebpackPlugin is replaced with TerserPlugin - * and plugin instantiation is moved to `optimization.minimizer`. - * - * @param {Object} j - jscodeshift top-level import - * @param {Node} ast - jscodeshift ast to transform - * @returns {Node} ast - jscodeshift ast - */ - -export default function (j: JSCodeshift, ast: Node): Node { - let pluginVariableAssignment: string = null; - - const searchForRequirePlugin: Node = ast - .find(j.VariableDeclarator) - .filter(j.filters.VariableDeclarator.requiresModule('uglifyjs-webpack-plugin')); - - /** - * Look for a variable declaration which requires uglifyjs-webpack-plugin - * saves the name of this variable. - */ - searchForRequirePlugin.forEach((node: Node): void => { - pluginVariableAssignment = (node.value as Node).id.name; - }); - - pluginVariableAssignment = !pluginVariableAssignment ? 'webpack.optimize.UglifyJsPlugin' : pluginVariableAssignment; - - findPluginsByName(j, ast, [pluginVariableAssignment]).forEach((node: Node): void => { - let expressionContent: object = null; - - const configBody = safeTraverse(node, ['parent', 'parent', 'parent']); - - // options passed to plugin - const pluginOptions: Node[] = (node.value as Node).arguments; - - /** - * check if there are any options passed to UglifyWebpackPlugin - * If so, they are moved to optimization.minimizer. - * Otherwise, rely on default options - */ - if (pluginOptions.length) { - /* - * If user is using UglifyJsPlugin directly from webpack - * transformation must: - * - remove it - * - add require for terser-webpack-plugin - * - add to minimizer - */ - if (pluginVariableAssignment) { - // remove require for uglify-webpack-plugin - searchForRequirePlugin.remove(); - - // create require for terser-webpack-plugin - const pathRequire: Node = getRequire(j, 'TerserPlugin', 'terser-webpack-plugin'); - // prepend to source code. - ast.find(j.Program).replaceWith((p: Node): Node => j.program([].concat(pathRequire).concat((p.value as Node).body))); - - expressionContent = j.property( - 'init', - j.identifier('minimizer'), - j.arrayExpression([j.newExpression(j.identifier('TerserPlugin'), [pluginOptions[0]])]), - ); - } else { - expressionContent = j.property('init', j.identifier('minimizer'), j.arrayExpression([node.value as Node])); - } - } else { - searchForRequirePlugin.forEach((n: Node): void => j(n).remove()); - } - - const minimizeProperty = createProperty(j, 'minimize', 'true'); - // creates optimization property at the body of the config. - if (expressionContent) { - ((configBody as Node).value as Node).properties.push( - j.property('init', j.identifier('optimization'), j.objectExpression([minimizeProperty, expressionContent])), - ); - } else { - ((configBody as Node).value as Node).properties.push( - j.property('init', j.identifier('optimization'), j.objectExpression([minimizeProperty])), - ); - } - - // remove the old Uglify plugin from Plugins array. - j(node).remove(); - }); - - findPluginsArrayAndRemoveIfEmpty(j, ast); - - return ast; -} diff --git a/packages/migrate/tsconfig.json b/packages/migrate/tsconfig.json deleted file mode 100644 index c06b88a4409..00000000000 --- a/packages/migrate/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [{ "path": "../utils" }] -} diff --git a/test/help/help.test.js b/test/help/help.test.js index 41be8093ff5..56e863512f1 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -26,8 +26,8 @@ describe('help', () => { expect(stdout.match(/info\|i/g)).toHaveLength(1); expect(stdout.match(/init\|c/g)).toHaveLength(1); expect(stdout.match(/loader\|l/g)).toHaveLength(1); - expect(stdout.match(/migrate\|m/g)).toHaveLength(1); expect(stdout.match(/plugin\|p/g)).toHaveLength(1); + expect(stdout.match(/migrate\|m/g)).toHaveLength(1); expect(stdout.match(/configtest\|t/g)).toHaveLength(1); expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); @@ -58,8 +58,8 @@ describe('help', () => { expect(stdout.match(/info\|i/g)).toHaveLength(1); expect(stdout.match(/init\|c/g)).toHaveLength(1); expect(stdout.match(/loader\|l/g)).toHaveLength(1); - expect(stdout.match(/migrate\|m/g)).toHaveLength(1); expect(stdout.match(/plugin\|p/g)).toHaveLength(1); + expect(stdout.match(/migrate\|m/g)).toHaveLength(1); expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); @@ -155,7 +155,7 @@ describe('help', () => { expect(stdout).toContain('Made with ♥ by the webpack team'); }); - const commands = ['bundle', 'loader', 'plugin', 'info', 'init', 'migrate', 'serve']; + const commands = ['bundle', 'loader', 'plugin', 'info', 'init', 'serve', 'migrate']; commands.forEach((command) => { it(`should show help information for '${command}' command using the "--help" option`, () => { diff --git a/test/migrate/config/bad-webpack.config.js b/test/migrate/config/bad-webpack.config.js deleted file mode 100644 index ff6b82b575e..00000000000 --- a/test/migrate/config/bad-webpack.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - output: { - badOption: true, - }, -}; diff --git a/test/migrate/config/migrate-config.test.js b/test/migrate/config/migrate-config.test.js deleted file mode 100644 index 35dcb6000b9..00000000000 --- a/test/migrate/config/migrate-config.test.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const rimraf = require('rimraf'); -const stripAnsi = require('strip-ansi'); -const { run, runAndGetWatchProc, runPromptWithAnswers } = require('../../utils/test-utils'); - -const ENTER = '\x0D'; -const outputDir = 'test-assets'; -const outputPath = path.join(__dirname, outputDir); -const outputFile = `${outputDir}/updated-webpack.config.js`; -const outputFilePath = path.join(__dirname, outputFile); - -describe('migrate command', () => { - beforeEach(() => { - rimraf.sync(outputPath); - fs.mkdirSync(outputPath); - }); - - it('should warn if the source config file is not specified', () => { - const { stderr } = run(__dirname, ['migrate'], false); - expect(stderr).toContain("missing required argument 'config-path'"); - }); - - it('should prompt accordingly if an output path is not specified', () => { - const { stdout } = run(__dirname, ['migrate', 'webpack.config.js'], false); - expect(stripAnsi(stdout)).toContain('? Migration output path not specified'); - }); - - it('should throw an error if the user refused to overwrite the source file and no output path is provided', async () => { - const { stderr } = await runAndGetWatchProc(__dirname, ['migrate', 'webpack.config.js'], false, 'n'); - expect(stderr).toContain('︎Migration aborted due to no output path'); - }); - - it('should prompt for config validation when an output path is provided', async () => { - const { stdout } = await runAndGetWatchProc(__dirname, ['migrate', 'webpack.config.js', outputFile], false, 'y'); - // should show the diff of the config file - expect(stdout).toContain('rules: ['); - expect(stripAnsi(stdout)).toContain('? Do you want to validate your configuration?'); - }); - - it('should generate an updated config file when an output path is provided', async () => { - const { stdout, stderr } = await runPromptWithAnswers( - __dirname, - ['migrate', 'webpack.config.js', outputFile], - [ENTER, ENTER], - true, - ); - expect(stripAnsi(stdout)).toContain('? Do you want to validate your configuration?'); - // should show the diff of the config file - expect(stdout).toContain('rules: ['); - expect(stderr).toBeFalsy(); - - expect(fs.existsSync(outputFilePath)).toBeTruthy(); - // the output file should be a valid config file - const config = require(outputFilePath); - expect(config.module.rules).toEqual([ - { - test: /\.js$/, - exclude: /node_modules/, - - use: [ - { - loader: 'babel-loader', - - options: { - presets: ['@babel/preset-env'], - }, - }, - ], - }, - ]); - }); - - it('should generate an updated config file and warn of an invalid webpack config', async () => { - const { stdout, stderr } = await runPromptWithAnswers(__dirname, ['migrate', 'bad-webpack.config.js', outputFile], [ENTER, ENTER]); - expect(stripAnsi(stdout)).toContain('? Do you want to validate your configuration?'); - expect(stderr).toContain("configuration.output has an unknown property 'badOption'"); - - expect(fs.existsSync(outputFilePath)).toBeTruthy(); - }); -}); diff --git a/test/migrate/config/webpack.config.js b/test/migrate/config/webpack.config.js deleted file mode 100644 index b55e44c03e6..00000000000 --- a/test/migrate/config/webpack.config.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-disable */ -const path = require('path'); - -module.exports = { - entry: { - index: './src/index.js', - vendor: './src/vendor.js', - }, - - output: { - filename: '[name].[chunkhash].js', - chunkFilename: '[name].[chunkhash].js', - path: path.resolve(__dirname, 'dist'), - }, - - optimization: { - minimize: true - }, - - module: { - loaders: [ - { - test: /\.js$/, - exclude: /node_modules/, - loader: 'babel', - query: { - presets: ['@babel/preset-env'], - }, - }, - ], - }, -}; diff --git a/test/version/version.test.js b/test/version/version.test.js index ac2b3deb1ca..42749637dbc 100644 --- a/test/version/version.test.js +++ b/test/version/version.test.js @@ -6,7 +6,6 @@ const { run } = require('../utils/test-utils'); const pkgJSON = require('../../packages/webpack-cli/package.json'); const initPkgJSON = require('../../packages/init/package.json'); const servePkgJSON = require('../../packages/serve/package.json'); -const migratePkgJSON = require('../../packages/migrate/package.json'); const infoPkgJSON = require('../../packages/info/package.json'); const generatorsPkgJSON = require('../../packages/generators/package.json'); const webpackDevServerPkgJSON = require('webpack-dev-server/package.json'); @@ -142,11 +141,10 @@ describe('single version flag', () => { it('outputs version with migrate', () => { const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version'], false); - expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`@webpack-cli/migrate ${migratePkgJSON.version}`); expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`@webpack-cli/migrate`); expect(stdout).toContain(`webpack ${webpack.version}`); expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); }); diff --git a/tsconfig.json b/tsconfig.json index 9062547bfb5..ea484876822 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,9 +29,6 @@ { "path": "packages/init" }, - { - "path": "packages/migrate" - }, { "path": "packages/serve" }, diff --git a/yarn.lock b/yarn.lock index 1e74bbb5f56..1eb88b51162 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1790,7 +1790,7 @@ resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd" integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ== -"@types/diff@*", "@types/diff@^4.0.2": +"@types/diff@*": version "4.0.2" resolved "https://registry.yarnpkg.com/@types/diff/-/diff-4.0.2.tgz#2e9bb89f9acc3ab0108f0f3dc4dbdcf2fff8a99c" integrity sha512-mIenTfsIe586/yzsyfql69KRnA75S8SVXQbTLpDejRrjH0QSJcpu3AUOi/Vjnt9IOsXKxPhJfGpQUNMueIU1fQ== @@ -1860,7 +1860,7 @@ resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a" integrity sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A== -"@types/inquirer@*", "@types/inquirer@^7.3.1": +"@types/inquirer@*": version "7.3.1" resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-7.3.1.tgz#1f231224e7df11ccfaf4cf9acbcc3b935fea292d" integrity sha512-osD38QVIfcdgsPCT0V3lD7eH0OFurX71Jft18bZrsVQWVRt6TuxRzlr0GJLrxoHZR2V5ph7/qP8se/dcnI7o0g== @@ -1907,14 +1907,6 @@ dependencies: "@types/node" "*" -"@types/listr@^0.14.2": - version "0.14.2" - resolved "https://registry.yarnpkg.com/@types/listr/-/listr-0.14.2.tgz#2e5f80fbc3ca8dceb9940ce9bf8e3113ab452545" - integrity sha512-wCipMbQr3t2UHTm90LldVp+oTBj1TX6zvpkCJcWS4o8nn6kS8SN93oUvKJAgueIRZ5M36yOlFmScqBxYH8Ajig== - dependencies: - "@types/node" "*" - rxjs "^6.5.1" - "@types/mem-fs-editor@*": version "7.0.0" resolved "https://registry.yarnpkg.com/@types/mem-fs-editor/-/mem-fs-editor-7.0.0.tgz#e6576e0f66e20055481b2cdbf193457f1a2c4e65" @@ -2239,6 +2231,20 @@ "@webassemblyjs/wast-parser" "1.9.1" "@xtuc/long" "4.2.2" +"@webpack-cli/migrate@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@webpack-cli/migrate/-/migrate-1.1.2.tgz#7bac28243c63a99f6fc809cff4585a5aa9c9b907" + integrity sha512-wbIaaL88LXAcExzp9iG09Pp3sf+FPPQb/g7qCLJAVYAkN8P5L3Km7dLix9K2VQpDfGvEBE0tbEK//ot86F35ZQ== + dependencies: + "@webpack-cli/utils" "^1.2.1" + colorette "^1.2.1" + diff "^4.0.2" + inquirer "^7.3.3" + jscodeshift "^0.11.0" + listr "^0.14.3" + p-each-series "^2.1.0" + p-lazy "^3.0.0" + "@xtuc/ieee754@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" @@ -9485,7 +9491,7 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.5.1, rxjs@^6.6.0, rxjs@^6.6.3: +rxjs@>=6.4.0, rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.6.0, rxjs@^6.6.3: version "6.6.3" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552" integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ== From 7506f0758d6b73af576825c4adebd1e9d72c17df Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 9 Jan 2021 19:53:11 +0530 Subject: [PATCH 247/581] refactor: generators (#2328) --- packages/configtest/src/index.ts | 3 ++- .../package.json.js} | 0 .../generators/{templates => init-template}/.babelrc | 0 .../{templates => init-template}/README.md | 0 .../generators/{templates => init-template}/index.js | 0 .../{templates => init-template}/package.json.js | 0 .../generators/{templates => init-template}/sw.js | 0 .../{templates => init-template}/template.html | 0 .../{templates => init-template}/tsconfig.json.js | 0 packages/generators/package.json | 5 ++++- packages/generators/src/addon-generator.ts | 2 +- packages/generators/src/init-generator.ts | 12 ++++++------ packages/generators/src/types/index.ts | 1 + 13 files changed, 14 insertions(+), 9 deletions(-) rename packages/generators/{templates/addon-package.json.js => addon-template/package.json.js} (100%) rename packages/generators/{templates => init-template}/.babelrc (100%) rename packages/generators/{templates => init-template}/README.md (100%) rename packages/generators/{templates => init-template}/index.js (100%) rename packages/generators/{templates => init-template}/package.json.js (100%) rename packages/generators/{templates => init-template}/sw.js (100%) rename packages/generators/{templates => init-template}/template.html (100%) rename packages/generators/{templates => init-template}/tsconfig.json.js (100%) diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts index 45cd643aacb..367404a0868 100644 --- a/packages/configtest/src/index.ts +++ b/packages/configtest/src/index.ts @@ -27,7 +27,8 @@ class ConfigTestCommand { throw new webpack.WebpackOptionsValidationError(error); } } catch (error) { - const isValidationError = (error) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const isValidationError = (error: any): boolean => { // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/generators/templates/addon-package.json.js b/packages/generators/addon-template/package.json.js similarity index 100% rename from packages/generators/templates/addon-package.json.js rename to packages/generators/addon-template/package.json.js diff --git a/packages/generators/templates/.babelrc b/packages/generators/init-template/.babelrc similarity index 100% rename from packages/generators/templates/.babelrc rename to packages/generators/init-template/.babelrc diff --git a/packages/generators/templates/README.md b/packages/generators/init-template/README.md similarity index 100% rename from packages/generators/templates/README.md rename to packages/generators/init-template/README.md diff --git a/packages/generators/templates/index.js b/packages/generators/init-template/index.js similarity index 100% rename from packages/generators/templates/index.js rename to packages/generators/init-template/index.js diff --git a/packages/generators/templates/package.json.js b/packages/generators/init-template/package.json.js similarity index 100% rename from packages/generators/templates/package.json.js rename to packages/generators/init-template/package.json.js diff --git a/packages/generators/templates/sw.js b/packages/generators/init-template/sw.js similarity index 100% rename from packages/generators/templates/sw.js rename to packages/generators/init-template/sw.js diff --git a/packages/generators/templates/template.html b/packages/generators/init-template/template.html similarity index 100% rename from packages/generators/templates/template.html rename to packages/generators/init-template/template.html diff --git a/packages/generators/templates/tsconfig.json.js b/packages/generators/init-template/tsconfig.json.js similarity index 100% rename from packages/generators/templates/tsconfig.json.js rename to packages/generators/init-template/tsconfig.json.js diff --git a/packages/generators/package.json b/packages/generators/package.json index c8fd91dd020..73f23e85c62 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -11,7 +11,10 @@ }, "files": [ "lib", - "templates" + "addon-template", + "init-template", + "loader-template", + "plugin-template" ], "dependencies": { "@webpack-cli/utils": "^1.2.1", diff --git a/packages/generators/src/addon-generator.ts b/packages/generators/src/addon-generator.ts index 37e99297852..bcd1be0f5cb 100644 --- a/packages/generators/src/addon-generator.ts +++ b/packages/generators/src/addon-generator.ts @@ -65,7 +65,7 @@ const addonGenerator = ( } public writing(): void { - const packageJsonTemplatePath = '../templates/addon-package.json.js'; + const packageJsonTemplatePath = '../addon-template/package.json.js'; // eslint-disable-next-line @typescript-eslint/no-var-requires this.fs.extendJSON(this.destinationPath('package.json'), require(packageJsonTemplatePath)(this.props.name)); diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index f26e71ef985..26c31c3589d 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -244,13 +244,13 @@ export default class InitGenerator extends CustomGenerator { public writing(): void { this.config.set('configuration', this.configuration); - const packageJsonTemplatePath = '../templates/package.json.js'; + const packageJsonTemplatePath = '../init-template/package.json.js'; // eslint-disable-next-line @typescript-eslint/no-var-requires this.fs.extendJSON(this.destinationPath('package.json'), require(packageJsonTemplatePath)(this.autoGenerateConfig)); const generateEntryFile = (entryPath: string, name: string): void => { entryPath = entryPath.replace(/'/g, ''); - this.fs.copyTpl(path.resolve(__dirname, '../templates/index.js'), this.destinationPath(entryPath), { name }); + this.fs.copyTpl(path.resolve(__dirname, '../init-template/index.js'), this.destinationPath(entryPath), { name }); }; // Generate entry file/files @@ -262,16 +262,16 @@ export default class InitGenerator extends CustomGenerator { } // Generate README - this.fs.copyTpl(path.resolve(__dirname, '../templates/README.md'), this.destinationPath('README.md'), {}); + this.fs.copyTpl(path.resolve(__dirname, '../init-template/README.md'), this.destinationPath('README.md'), {}); // Generate HTML template file, copy the default service worker - this.fs.copyTpl(path.resolve(__dirname, '../templates/template.html'), this.destinationPath('index.html'), {}); + this.fs.copyTpl(path.resolve(__dirname, '../init-template/template.html'), this.destinationPath('index.html'), {}); if (this.langType === LangType.ES6) { - this.fs.copyTpl(path.resolve(__dirname, '../templates/.babelrc'), this.destinationPath('.babelrc'), {}); + this.fs.copyTpl(path.resolve(__dirname, '../init-template/.babelrc'), this.destinationPath('.babelrc'), {}); } else if (this.langType === LangType.Typescript) { // Generate tsconfig - const tsConfigTemplatePath = '../templates/tsconfig.json.js'; + const tsConfigTemplatePath = '../init-template/tsconfig.json.js'; // eslint-disable-next-line @typescript-eslint/no-var-requires this.fs.extendJSON(this.destinationPath('tsconfig.json'), require(tsConfigTemplatePath)); } diff --git a/packages/generators/src/types/index.ts b/packages/generators/src/types/index.ts index 0d920cb4dcf..bcd09727b2f 100644 --- a/packages/generators/src/types/index.ts +++ b/packages/generators/src/types/index.ts @@ -247,4 +247,5 @@ export class CustomGenerator extends Generator { }; public isProd: boolean; public dependencies: string[]; + public getTemplatePath: (template: string) => string; } From caa3348a825dfc5e0c6320304a28ce49630052ef Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Sat, 9 Jan 2021 18:17:01 +0300 Subject: [PATCH 248/581] refactor: `configtest` is the part of webpack-cli (#2336) --- packages/webpack-cli/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 148ac8df7bb..94d55ab3062 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -28,6 +28,7 @@ ], "dependencies": { "@discoveryjs/json-ext": "^0.5.0", + "@webpack-cli/configtest": "^1.0.0", "@webpack-cli/info": "^1.2.1", "@webpack-cli/serve": "^1.2.1", "colorette": "^1.2.1", @@ -54,9 +55,6 @@ "@webpack-cli/migrate": { "optional": true }, - "@webpack-cli/configtest": { - "optional": true - }, "webpack-bundle-analyzer": { "optional": true }, From ff2b2b375ecf7bc53be78b7b99c8a7c5245ffedc Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 9 Jan 2021 21:09:20 +0530 Subject: [PATCH 249/581] tests: add test for missing packages (#2296) --- .github/workflows/nodejs.yml | 10 ++- package.json | 1 + smoketests/index.js | 20 +++++ .../webpack-dev-server.test.js | 75 +++++++++++++++++++ smoketests/missing-packages/webpack.test.js | 74 ++++++++++++++++++ 5 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 smoketests/index.js create mode 100644 smoketests/missing-packages/webpack-dev-server.test.js create mode 100644 smoketests/missing-packages/webpack.test.js diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index c5787566709..04847d08649 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -87,12 +87,16 @@ jobs: - name: Install webpack ${{ matrix.webpack-version }} run: yarn add -W webpack@${{ matrix.webpack-version }} - - name: Build - run: yarn build:ci + - name: Build and Bootstrap + run: | + yarn build:ci + yarn run lerna bootstrap + + - name: Run Smoketests + run: yarn test:smoketests - name: Test and Generate Coverage run: | - yarn run lerna bootstrap yarn prepsuite yarn test:coverage diff --git a/package.json b/package.json index e972121ad46..f92b5600a14 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "prepsuite": "node scripts/prepareSuite.js", "pretest": "yarn build && yarn lint && yarn prepsuite", "test": "jest --reporters=default", + "test:smoketests": "nyc node smoketests", "test:coverage": "nyc jest --forceExit", "test:cli": "jest test --reporters=default --forceExit", "test:packages": "jest packages/ --reporters=default --forceExit", diff --git a/smoketests/index.js b/smoketests/index.js new file mode 100644 index 00000000000..98343c69df4 --- /dev/null +++ b/smoketests/index.js @@ -0,0 +1,20 @@ +/* eslint-disable node/no-unpublished-require */ +const tests = [require('./missing-packages/webpack-dev-server.test.js'), require('./missing-packages/webpack.test.js')]; + +(async () => { + let isAllPassed = true; + for await (const test of tests) { + console.log(`\nRUN ${test.name}`); + const isPass = await test.run(); + if (!isPass) { + console.log(`FAIL ${test.name}`); + isAllPassed = false; + } else { + console.log(`PASS ${test.name}`); + } + } + if (!isAllPassed) { + process.exit(2); + } + process.exit(0); +})(); diff --git a/smoketests/missing-packages/webpack-dev-server.test.js b/smoketests/missing-packages/webpack-dev-server.test.js new file mode 100644 index 00000000000..dd575e33491 --- /dev/null +++ b/smoketests/missing-packages/webpack-dev-server.test.js @@ -0,0 +1,75 @@ +const path = require('path'); +const execa = require('execa'); +const { renameSync } = require('fs'); +const stripAnsi = require('strip-ansi'); + +const ROOT = process.env.GITHUB_WORKSPACE ? process.env.GITHUB_WORKSPACE : path.resolve(__dirname, '../../'); +const CLI_ENTRY_PATH = path.resolve(ROOT, './packages/webpack-cli/bin/cli.js'); + +const getPkgPath = (pkg) => { + return path.resolve(ROOT, `./node_modules/${pkg}`); +}; + +const swapPkgName = (current, next) => { + console.log(` swapping ${current} with ${next}`); + renameSync(getPkgPath(current), getPkgPath(next)); +}; + +const runTest = () => { + // Simulate package missing + swapPkgName('webpack-dev-server', '.webpack-dev-server'); + + const proc = execa(CLI_ENTRY_PATH, ['serve'], { + cwd: __dirname, + }); + + proc.stdin.setDefaultEncoding('utf-8'); + + proc.stdout.on('data', (chunk) => { + console.log(` stdout: ${chunk.toString()}`); + }); + + return new Promise((resolve) => { + setTimeout(() => { + console.log(' timeout: killing process'); + proc.kill(); + }, 5000); + + const logMessage = "For using 'serve' command you need to install: 'webpack-dev-server' package"; + const prompt = 'Would you like to install'; + let hasLogMessage = false, + hasPrompt = false, + hasPassed = false; + + proc.stderr.on('data', (chunk) => { + let data = stripAnsi(chunk.toString()); + console.log(` stderr: ${data}`); + + if (data.includes(logMessage)) { + hasLogMessage = true; + } + + if (data.includes(prompt)) { + hasPrompt = true; + } + + if (hasLogMessage && hasPrompt) { + hasPassed = true; + proc.kill(); + } + }); + + proc.on('exit', () => { + swapPkgName('.webpack-dev-server', 'webpack-dev-server'); + resolve(hasPassed); + }); + + proc.on('error', () => { + swapPkgName('.webpack-dev-server', 'webpack-dev-server'); + resolve(false); + }); + }); +}; + +module.exports.run = runTest; +module.exports.name = 'Missing webpack-dev-server'; diff --git a/smoketests/missing-packages/webpack.test.js b/smoketests/missing-packages/webpack.test.js new file mode 100644 index 00000000000..14774cf6457 --- /dev/null +++ b/smoketests/missing-packages/webpack.test.js @@ -0,0 +1,74 @@ +const path = require('path'); +const execa = require('execa'); +const { renameSync } = require('fs'); +const stripAnsi = require('strip-ansi'); + +const ROOT = process.env.GITHUB_WORKSPACE ? process.env.GITHUB_WORKSPACE : path.resolve(__dirname, '../../'); +const CLI_ENTRY_PATH = path.resolve(ROOT, './packages/webpack-cli/bin/cli.js'); + +const getPkgPath = (pkg) => { + return path.resolve(ROOT, `./node_modules/${pkg}`); +}; + +const swapPkgName = (current, next) => { + console.log(` swapping ${current} with ${next}`); + renameSync(getPkgPath(current), getPkgPath(next)); +}; + +const runTest = () => { + // Simulate package missing + swapPkgName('webpack', '.webpack'); + + const proc = execa(CLI_ENTRY_PATH, [], { + cwd: __dirname, + }); + + proc.stdin.setDefaultEncoding('utf-8'); + + proc.stdout.on('data', (chunk) => { + console.log(` stdout: ${chunk.toString()}`); + }); + + return new Promise((resolve) => { + setTimeout(() => { + proc.kill(); + }, 5000); + + const logMessage = 'It looks like webpack is not installed.'; + const prompt = 'Would you like to install'; + let hasLogMessage = false, + hasPrompt = false, + hasPassed = false; + + proc.stderr.on('data', (chunk) => { + let data = stripAnsi(chunk.toString()); + console.log(` stderr: ${data}`); + + if (data.includes(logMessage)) { + hasLogMessage = true; + } + + if (data.includes(prompt)) { + hasPrompt = true; + } + + if (hasLogMessage && hasPrompt) { + hasPassed = true; + proc.kill(); + } + }); + + proc.on('exit', () => { + swapPkgName('.webpack', 'webpack'); + resolve(hasPassed); + }); + + proc.on('error', () => { + swapPkgName('.webpack', 'webpack'); + resolve(false); + }); + }); +}; + +module.exports.run = runTest; +module.exports.name = 'Missing webpack'; From 767fe6b4b4d4980b5b5cf8fd5dafb0aa84465625 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Sat, 9 Jan 2021 21:26:44 +0530 Subject: [PATCH 250/581] chore: remove stale code (#2337) --- packages/generators/src/utils/index.ts | 2 -- .../generators/src/utils/webpackConfig.ts | 30 ------------------- 2 files changed, 32 deletions(-) delete mode 100644 packages/generators/src/utils/webpackConfig.ts diff --git a/packages/generators/src/utils/index.ts b/packages/generators/src/utils/index.ts index bf086d13c8e..99f132a1377 100644 --- a/packages/generators/src/utils/index.ts +++ b/packages/generators/src/utils/index.ts @@ -4,7 +4,6 @@ import plugins, { replaceAt, generatePluginName } from './plugins'; import styleQuestionHandler, { StylingType, LoaderName, StyleRegex, Loader } from './styleSupport'; import tooltip from './tooltip'; import validate from './validate'; -import { getDefaultOptimization } from './webpackConfig'; export { entryQuestions, @@ -22,5 +21,4 @@ export { Loader, tooltip, validate, - getDefaultOptimization, }; diff --git a/packages/generators/src/utils/webpackConfig.ts b/packages/generators/src/utils/webpackConfig.ts deleted file mode 100644 index b849bd3745e..00000000000 --- a/packages/generators/src/utils/webpackConfig.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { WebpackOptions } from '../types'; - -export function getDefaultOptimization(usingDefaults: boolean): WebpackOptions['optimization'] { - let optimizationOptions; - if (!usingDefaults) { - optimizationOptions = { - minimizer: ['new TerserPlugin()'], - splitChunks: { - cacheGroups: { - vendors: { - priority: -10, - test: '/[\\\\/]node_modules[\\\\/]/', - }, - }, - chunks: "'async'", - minChunks: 1, - minSize: 30000, - name: false, - }, - }; - } else { - optimizationOptions = { - minimizer: ['new TerserPlugin()'], - splitChunks: { - chunks: "'all'", - }, - }; - } - return optimizationOptions; -} From ffc93e556d784e2d4409cb0d3a92d737850996f4 Mon Sep 17 00:00:00 2001 From: James George Date: Sun, 10 Jan 2021 15:32:53 +0530 Subject: [PATCH 251/581] fix: show exact package name while prompting for installation (#2338) --- packages/webpack-cli/lib/webpack-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index cae401941d8..e18f4a5bdb7 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -357,7 +357,7 @@ class WebpackCLI { try { pkg = await promptInstallation(pkg, () => { - logger.error(`For using this command you need to install: '${green(commandName)}' package`); + logger.error(`For using this command you need to install: '${green(pkg)}' package`); }); } catch (error) { logger.error(`Action Interrupted, use '${cyan('webpack-cli help')}' to see possible commands`); From 91fc1669f6398c53a4dda2096a3975c2e3fbf580 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Mon, 11 Jan 2021 17:03:29 +0530 Subject: [PATCH 252/581] chore: remove redundant action (#2339) --- packages/init/src/index.ts | 2 +- packages/utils/src/modify-config-helper.ts | 1 - packages/utils/src/resolve-packages.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index e0ddd3b209b..8c12b5dd98b 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -37,7 +37,7 @@ class InitCommand { return; } - modifyHelperUtil('init', initGenerator, null, null, options.auto, options.force, options.generationPath); + modifyHelperUtil(initGenerator, null, null, options.auto, options.force, options.generationPath); }, ); } diff --git a/packages/utils/src/modify-config-helper.ts b/packages/utils/src/modify-config-helper.ts index b08dcfc4995..e2dc8e71326 100644 --- a/packages/utils/src/modify-config-helper.ts +++ b/packages/utils/src/modify-config-helper.ts @@ -35,7 +35,6 @@ export interface WebpackScaffoldObject extends Object { const DEFAULT_WEBPACK_CONFIG_FILENAME = 'webpack.config.js'; export function modifyHelperUtil( - action: string, generator: Generator.GeneratorConstructor, configFile: string = DEFAULT_WEBPACK_CONFIG_FILENAME, packages?: string[], diff --git a/packages/utils/src/resolve-packages.ts b/packages/utils/src/resolve-packages.ts index ce5eddae437..cd5a8aa3c57 100644 --- a/packages/utils/src/resolve-packages.ts +++ b/packages/utils/src/resolve-packages.ts @@ -47,7 +47,7 @@ export function resolvePackages(pkg: string[]): Function | void { function invokeGeneratorIfReady(): void { if (packageLocations.length === pkg.length) { - modifyHelperUtil('init', null, null, packageLocations); + modifyHelperUtil(null, null, packageLocations); } } From 9100137bc4e7d77915407aec554da25f0ae9e55c Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 11 Jan 2021 17:09:54 +0530 Subject: [PATCH 253/581] fix: use worker from plugin and remove default (#2340) --- packages/generators/init-template/sw.js | 8 -------- packages/generators/src/init-generator.ts | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 packages/generators/init-template/sw.js diff --git a/packages/generators/init-template/sw.js b/packages/generators/init-template/sw.js deleted file mode 100644 index e4a57a33024..00000000000 --- a/packages/generators/init-template/sw.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-env browser */ -self.addEventListener('install', (event) => { - event.waitUntil( - caches.open('v1').then((cache) => { - return cache.addAll(['./index.html', './src/index.js']); - }), - ); -}); diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 26c31c3589d..914676afa9b 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -264,7 +264,7 @@ export default class InitGenerator extends CustomGenerator { // Generate README this.fs.copyTpl(path.resolve(__dirname, '../init-template/README.md'), this.destinationPath('README.md'), {}); - // Generate HTML template file, copy the default service worker + // Generate HTML template file this.fs.copyTpl(path.resolve(__dirname, '../init-template/template.html'), this.destinationPath('index.html'), {}); if (this.langType === LangType.ES6) { From debb8579e0df7a5670b1c8ca40dcd6cd6890631f Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 12 Jan 2021 17:51:35 +0530 Subject: [PATCH 254/581] refactor: union utils and generators (#2343) --- .eslintrc.js | 2 +- .../__tests__/addon-generator.test.ts | 64 ++++++++++++++--- .../__tests__/utils/languageSupport.test.ts | 4 +- .../__tests__/utils/plugins.test.ts | 2 +- .../__tests__/utils/styleSupport.test.ts | 4 +- packages/generators/package.json | 18 ++++- packages/generators/src/addon-generator.ts | 2 +- packages/generators/src/index.ts | 13 ++++ packages/generators/src/loader-generator.ts | 2 + .../__snapshots__/ast-utils.test.ts.snap | 0 .../src}/utils/__tests__/ast-utils.test.ts | 4 +- .../__tests__/find-project-root/package.json | 0 .../project/find-project-root.test.ts | 2 +- .../__tests__/global-packages-path.test.ts | 2 +- .../utils/__tests__/is-local-path.test.ts | 2 +- .../src}/utils/__tests__/npm-exists.test.ts | 2 +- .../__tests__/npm-packages-exists.test.ts | 8 +-- .../recursive-parser.test.ts.snap | 8 +-- .../__testfixtures__/fixture-0.input.js | 0 .../__testfixtures__/fixture-1.input.js | 0 .../__testfixtures__/fixture-2.input.js | 0 .../__testfixtures__/fixture-3.input.js | 2 +- .../recursive-parser/recursive-parser.test.ts | 2 +- .../utils/__tests__/resolve-packages.test.ts | 0 .../src}/utils/__tests__/run-prettier.test.ts | 2 +- .../__tests__/validate-identifier.test.ts | 2 +- .../src => generators/src/utils}/ast-utils.ts | 0 .../src/utils}/copy-utils.ts | 0 .../src/utils}/defineTest.ts | 6 +- .../src/utils}/global-packages-path.ts | 0 .../src/utils}/isWebpack5.ts | 0 .../src/utils}/modify-config-helper.ts | 0 .../src/utils}/npm-exists.ts | 0 .../src/utils}/npm-packages-exists.ts | 0 .../src/utils}/path-utils.ts | 0 .../src/utils}/prop-types.ts | 0 .../src/utils}/recursive-parser.ts | 0 .../src/utils}/resolve-packages.ts | 0 .../src/utils}/run-prettier.ts | 0 .../src => generators/src/utils}/scaffold.ts | 0 .../src/utils}/spawn-child.ts | 0 .../src/utils}/types/Config.ts | 0 .../src/utils}/types/Error.ts | 0 .../src/utils}/types/NodePath.ts | 0 .../src/utils}/types/index.ts | 0 .../src/utils}/validate-identifier.ts | 0 packages/generators/tsconfig.json | 4 +- packages/init/package.json | 3 +- packages/init/src/index.ts | 3 +- packages/init/tsconfig.json | 2 +- packages/utils/CHANGELOG.md | 69 ------------------- packages/utils/README.md | 35 ---------- packages/utils/package.json | 40 ----------- packages/utils/src/index.ts | 12 ---- packages/utils/tsconfig.json | 8 --- scripts/utils.js | 15 +++- tsconfig.json | 3 - 57 files changed, 130 insertions(+), 217 deletions(-) rename packages/{ => generators/src}/utils/__tests__/__snapshots__/ast-utils.test.ts.snap (100%) rename packages/{ => generators/src}/utils/__tests__/ast-utils.test.ts (99%) rename packages/{ => generators/src}/utils/__tests__/find-project-root/package.json (100%) rename packages/{ => generators/src}/utils/__tests__/find-project-root/project/find-project-root.test.ts (94%) rename packages/{ => generators/src}/utils/__tests__/global-packages-path.test.ts (93%) rename packages/{ => generators/src}/utils/__tests__/is-local-path.test.ts (93%) rename packages/{ => generators/src}/utils/__tests__/npm-exists.test.ts (90%) rename packages/{ => generators/src}/utils/__tests__/npm-packages-exists.test.ts (76%) rename packages/{ => generators/src}/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap (98%) rename packages/{ => generators/src}/utils/__tests__/recursive-parser/__testfixtures__/fixture-0.input.js (100%) rename packages/{ => generators/src}/utils/__tests__/recursive-parser/__testfixtures__/fixture-1.input.js (100%) rename packages/{ => generators/src}/utils/__tests__/recursive-parser/__testfixtures__/fixture-2.input.js (100%) rename packages/{ => generators/src}/utils/__tests__/recursive-parser/__testfixtures__/fixture-3.input.js (97%) rename packages/{ => generators/src}/utils/__tests__/recursive-parser/recursive-parser.test.ts (97%) rename packages/{ => generators/src}/utils/__tests__/resolve-packages.test.ts (100%) rename packages/{ => generators/src}/utils/__tests__/run-prettier.test.ts (96%) rename packages/{ => generators/src}/utils/__tests__/validate-identifier.test.ts (97%) rename packages/{utils/src => generators/src/utils}/ast-utils.ts (100%) rename packages/{utils/src => generators/src/utils}/copy-utils.ts (100%) rename packages/{utils/__tests__ => generators/src/utils}/defineTest.ts (95%) rename packages/{utils/src => generators/src/utils}/global-packages-path.ts (100%) rename packages/{utils/src => generators/src/utils}/isWebpack5.ts (100%) rename packages/{utils/src => generators/src/utils}/modify-config-helper.ts (100%) rename packages/{utils/src => generators/src/utils}/npm-exists.ts (100%) rename packages/{utils/src => generators/src/utils}/npm-packages-exists.ts (100%) rename packages/{utils/src => generators/src/utils}/path-utils.ts (100%) rename packages/{utils/src => generators/src/utils}/prop-types.ts (100%) rename packages/{utils/src => generators/src/utils}/recursive-parser.ts (100%) rename packages/{utils/src => generators/src/utils}/resolve-packages.ts (100%) rename packages/{utils/src => generators/src/utils}/run-prettier.ts (100%) rename packages/{utils/src => generators/src/utils}/scaffold.ts (100%) rename packages/{utils/src => generators/src/utils}/spawn-child.ts (100%) rename packages/{utils/src => generators/src/utils}/types/Config.ts (100%) rename packages/{utils/src => generators/src/utils}/types/Error.ts (100%) rename packages/{utils/src => generators/src/utils}/types/NodePath.ts (100%) rename packages/{utils/src => generators/src/utils}/types/index.ts (100%) rename packages/{utils/src => generators/src/utils}/validate-identifier.ts (100%) delete mode 100644 packages/utils/CHANGELOG.md delete mode 100644 packages/utils/README.md delete mode 100644 packages/utils/package.json delete mode 100644 packages/utils/src/index.ts delete mode 100644 packages/utils/tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js index 6d5203bcfb2..fa66f1777f4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,7 +6,7 @@ module.exports = { plugins: ['node'], settings: { node: { - allowModules: ['@webpack-cli/generators', '@webpack-cli/utils'], + allowModules: ['@webpack-cli/generators'], }, }, env: { diff --git a/packages/generators/__tests__/addon-generator.test.ts b/packages/generators/__tests__/addon-generator.test.ts index 92f108e6fc4..5d6bc2f9d0f 100644 --- a/packages/generators/__tests__/addon-generator.test.ts +++ b/packages/generators/__tests__/addon-generator.test.ts @@ -18,15 +18,6 @@ describe('addon generator', () => { // we call this unwanted path doubleGenPath const doubleGenPath = path.join(genPath, genName); - beforeAll(() => { - rimraf.sync(testAssetsPath); - fs.mkdirSync(genPath, { recursive: true }); - // set the working directory to here so that the addon directory is - // generated in ./test-assets/test-addon - process.chdir(genPath); - packageMock = getPackageManager as jest.Mock; - }); - afterAll(() => { rimraf.sync(testAssetsPath); }); @@ -34,6 +25,7 @@ describe('addon generator', () => { beforeEach(() => { // eslint-disable-next-line @typescript-eslint/no-empty-function const Gen = addonGenerator([], '', [], [], () => {}); + gen = new Gen(null, null); gen.props = { name: genName, @@ -43,9 +35,20 @@ describe('addon generator', () => { }); it('schedules install using npm', () => { + const defaultCwd = process.cwd(); + + rimraf.sync(testAssetsPath); + fs.mkdirSync(genPath, { recursive: true }); + + // set the working directory to here so that the addon directory is + // generated in ./test-assets/test-addon + process.chdir(genPath); + + packageMock = getPackageManager as jest.Mock; packageMock.mockReturnValue('npm'); gen.install(); + expect(installMock.mock.calls.length).toEqual(1); expect(installMock.mock.calls[0]).toEqual([ 'npm', @@ -54,12 +57,24 @@ describe('addon generator', () => { 'save-dev': true, }, ]); + + process.chdir(defaultCwd); }); it('schedules install using yarn', () => { + const defaultCwd = process.cwd(); + + rimraf.sync(testAssetsPath); + fs.mkdirSync(genPath, { recursive: true }); + // set the working directory to here so that the addon directory is + // generated in ./test-assets/test-addon + process.chdir(genPath); + + packageMock = getPackageManager as jest.Mock; packageMock.mockReturnValue('yarn'); gen.install(); + expect(installMock.mock.calls.length).toEqual(1); expect(installMock.mock.calls[0]).toEqual([ 'yarn', @@ -68,11 +83,26 @@ describe('addon generator', () => { dev: true, }, ]); + + process.chdir(defaultCwd); }); it('does not create new directory when current directory matches addon name', () => { + const defaultCwd = process.cwd(); + + rimraf.sync(testAssetsPath); + fs.mkdirSync(genPath, { recursive: true }); + + // set the working directory to here so that the addon directory is + // generated in ./test-assets/test-addon + process.chdir(genPath); + + packageMock = getPackageManager as jest.Mock; + expect(fs.existsSync(genPath)).toBeTruthy(); + gen.default(); + expect(fs.existsSync(genPath)).toBeTruthy(); expect(fs.existsSync(doubleGenPath)).toBeFalsy(); @@ -81,14 +111,26 @@ describe('addon generator', () => { // generator above // this is switching the working directory as follows: // ./test-assets/test-addon -> ./test-assets - process.chdir(testAssetsPath); rimraf.sync(genPath); + + process.chdir(defaultCwd); }); it('creates a new directory for the generated addon', () => { - expect(fs.existsSync(genPath)).toBeFalsy(); + const defaultCwd = process.cwd(); + + rimraf.sync(testAssetsPath); + fs.mkdirSync(genPath, { recursive: true }); + + // set the working directory to here so that the addon directory is + // generated in ./test-assets/test-addon + process.chdir(genPath); + gen.default(); + expect(fs.existsSync(genPath)).toBeTruthy(); expect(fs.existsSync(doubleGenPath)).toBeFalsy(); + + process.chdir(defaultCwd); }); }); diff --git a/packages/generators/__tests__/utils/languageSupport.test.ts b/packages/generators/__tests__/utils/languageSupport.test.ts index a70a7c5b611..ffb518f808e 100644 --- a/packages/generators/__tests__/utils/languageSupport.test.ts +++ b/packages/generators/__tests__/utils/languageSupport.test.ts @@ -1,5 +1,5 @@ -import language, { LangType, getBabelLoader, getTypescriptLoader } from '../../lib/utils/languageSupport'; -import { CustomGenerator } from '../../lib/types'; +import language, { LangType, getBabelLoader, getTypescriptLoader } from '../../src/utils/languageSupport'; +import { CustomGenerator } from '../../src/types'; describe('languageSupport', () => { const getMockGenerator = (): CustomGenerator => { diff --git a/packages/generators/__tests__/utils/plugins.test.ts b/packages/generators/__tests__/utils/plugins.test.ts index 35c7fe8ecc2..bfe3311f9c1 100644 --- a/packages/generators/__tests__/utils/plugins.test.ts +++ b/packages/generators/__tests__/utils/plugins.test.ts @@ -1,4 +1,4 @@ -import { replaceAt, generatePluginName } from '../../lib/utils/plugins'; +import { replaceAt, generatePluginName } from '../../src/utils/plugins'; describe('generate plugin name', () => { it('should return webpack Standard Plugin Name for Name : extract-text-webpack-plugin', () => { diff --git a/packages/generators/__tests__/utils/styleSupport.test.ts b/packages/generators/__tests__/utils/styleSupport.test.ts index 1bf0009b6d9..8ecf3815961 100644 --- a/packages/generators/__tests__/utils/styleSupport.test.ts +++ b/packages/generators/__tests__/utils/styleSupport.test.ts @@ -1,5 +1,5 @@ -import style, { StylingType } from '../../lib/utils/styleSupport'; -import { CustomGenerator } from '../../lib/types'; +import style, { StylingType } from '../../src/utils/styleSupport'; +import { CustomGenerator } from '../../src/types'; describe('styleSupport', () => { const getMockGenerator = (): CustomGenerator => { diff --git a/packages/generators/package.json b/packages/generators/package.json index 73f23e85c62..c4c069a8204 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -17,11 +17,16 @@ "plugin-template" ], "dependencies": { - "@webpack-cli/utils": "^1.2.1", "colorette": "^1.2.1", "log-symbols": "^4.0.0", "yeoman-environment": "^2.10.3", - "yeoman-generator": "^4.12.0" + "yeoman-generator": "^4.12.0", + "execa": "^4.1.0", + "findup-sync": "^4.0.0", + "global-modules": "^2.0.0", + "got": "^11.8.0", + "jscodeshift": "^0.11.0", + "p-each-series": "^2.1.0" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", @@ -33,7 +38,14 @@ "@types/yeoman-test": "^2.0.5", "rimraf": "^3.0.2", "yeoman-assert": "^3.1.1", - "yeoman-test": "^2.3.0" + "yeoman-test": "^2.3.0", + "@types/got": "^9.6.11", + "@types/prettier": "^2.1.5" + }, + "peerDependenciesMeta": { + "prettier": { + "optional": true + } }, "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" } diff --git a/packages/generators/src/addon-generator.ts b/packages/generators/src/addon-generator.ts index bcd1be0f5cb..fcc7ebfa9ba 100644 --- a/packages/generators/src/addon-generator.ts +++ b/packages/generators/src/addon-generator.ts @@ -1,7 +1,7 @@ import fs from 'fs'; import path from 'path'; import Generator from 'yeoman-generator'; -import { generatorCopy, generatorCopyTpl } from '@webpack-cli/utils'; +import { generatorCopy, generatorCopyTpl } from './utils/copy-utils'; import { utils } from 'webpack-cli'; diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index d4f0a93d18a..bea8e6577ba 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -54,3 +54,16 @@ class GeneratorsCommand { export default GeneratorsCommand; export { addonGenerator, initGenerator }; + +export * from './utils/ast-utils'; +export * from './utils/copy-utils'; +export * from './utils/modify-config-helper'; +export * from './utils/npm-exists'; +export * from './utils/npm-packages-exists'; +export * from './utils/recursive-parser'; +export * from './utils/resolve-packages'; +export * from './utils/run-prettier'; +export * from './utils/scaffold'; +export * from './utils/validate-identifier'; +export * from './utils/prop-types'; +export * from './utils/global-packages-path'; diff --git a/packages/generators/src/loader-generator.ts b/packages/generators/src/loader-generator.ts index e1b0c1ce33f..474ebe84cdf 100644 --- a/packages/generators/src/loader-generator.ts +++ b/packages/generators/src/loader-generator.ts @@ -11,9 +11,11 @@ import { toKebabCase } from './utils/helpers'; */ export function makeLoaderName(name: string): string { name = toKebabCase(name); + if (!/loader$/.test(name)) { name += '-loader'; } + return name; } diff --git a/packages/utils/__tests__/__snapshots__/ast-utils.test.ts.snap b/packages/generators/src/utils/__tests__/__snapshots__/ast-utils.test.ts.snap similarity index 100% rename from packages/utils/__tests__/__snapshots__/ast-utils.test.ts.snap rename to packages/generators/src/utils/__tests__/__snapshots__/ast-utils.test.ts.snap diff --git a/packages/utils/__tests__/ast-utils.test.ts b/packages/generators/src/utils/__tests__/ast-utils.test.ts similarity index 99% rename from packages/utils/__tests__/ast-utils.test.ts rename to packages/generators/src/utils/__tests__/ast-utils.test.ts index fa06295e3cc..a27f546fc9a 100644 --- a/packages/utils/__tests__/ast-utils.test.ts +++ b/packages/generators/src/utils/__tests__/ast-utils.test.ts @@ -15,8 +15,8 @@ import { getRequire, safeTraverse, safeTraverseAndGetType, -} from '../src/ast-utils'; -import { Node } from '../src/types/NodePath'; +} from '../ast-utils'; +import { Node } from '../types/NodePath'; describe('utils', () => { describe('createProperty', () => { diff --git a/packages/utils/__tests__/find-project-root/package.json b/packages/generators/src/utils/__tests__/find-project-root/package.json similarity index 100% rename from packages/utils/__tests__/find-project-root/package.json rename to packages/generators/src/utils/__tests__/find-project-root/package.json diff --git a/packages/utils/__tests__/find-project-root/project/find-project-root.test.ts b/packages/generators/src/utils/__tests__/find-project-root/project/find-project-root.test.ts similarity index 94% rename from packages/utils/__tests__/find-project-root/project/find-project-root.test.ts rename to packages/generators/src/utils/__tests__/find-project-root/project/find-project-root.test.ts index 83100a33386..6319a0d40ac 100644 --- a/packages/utils/__tests__/find-project-root/project/find-project-root.test.ts +++ b/packages/generators/src/utils/__tests__/find-project-root/project/find-project-root.test.ts @@ -1,5 +1,5 @@ // eslint-disable-next-line node/no-unpublished-import -import { findProjectRoot } from '../../../src/path-utils'; +import { findProjectRoot } from '../../../path-utils'; import { join } from 'path'; beforeAll(() => { diff --git a/packages/utils/__tests__/global-packages-path.test.ts b/packages/generators/src/utils/__tests__/global-packages-path.test.ts similarity index 93% rename from packages/utils/__tests__/global-packages-path.test.ts rename to packages/generators/src/utils/__tests__/global-packages-path.test.ts index e70441e974e..3fbcd785fd8 100644 --- a/packages/utils/__tests__/global-packages-path.test.ts +++ b/packages/generators/src/utils/__tests__/global-packages-path.test.ts @@ -1,7 +1,7 @@ 'use strict'; jest.setMock('webpack-cli/lib/utils/get-package-manager', jest.fn()); -import { getPathToGlobalPackages } from '../lib/global-packages-path'; +import { getPathToGlobalPackages } from '../global-packages-path'; import { utils } from 'webpack-cli'; const { getPackageManager } = utils; diff --git a/packages/utils/__tests__/is-local-path.test.ts b/packages/generators/src/utils/__tests__/is-local-path.test.ts similarity index 93% rename from packages/utils/__tests__/is-local-path.test.ts rename to packages/generators/src/utils/__tests__/is-local-path.test.ts index 4a8150f9467..2790aae28e3 100644 --- a/packages/utils/__tests__/is-local-path.test.ts +++ b/packages/generators/src/utils/__tests__/is-local-path.test.ts @@ -1,7 +1,7 @@ 'use strict'; import path from 'path'; -import { isLocalPath } from '../src/path-utils'; +import { isLocalPath } from '../path-utils'; describe('is-local-path', () => { it('returns true for paths beginning in the current directory', () => { diff --git a/packages/utils/__tests__/npm-exists.test.ts b/packages/generators/src/utils/__tests__/npm-exists.test.ts similarity index 90% rename from packages/utils/__tests__/npm-exists.test.ts rename to packages/generators/src/utils/__tests__/npm-exists.test.ts index 88297b3dbee..5e79cf24351 100644 --- a/packages/utils/__tests__/npm-exists.test.ts +++ b/packages/generators/src/utils/__tests__/npm-exists.test.ts @@ -1,5 +1,5 @@ 'use strict'; -import { npmExists } from '../src/npm-exists'; +import { npmExists } from '../npm-exists'; describe('npm-exists', () => { it('should successfully existence of a published module', () => { diff --git a/packages/utils/__tests__/npm-packages-exists.test.ts b/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts similarity index 76% rename from packages/utils/__tests__/npm-packages-exists.test.ts rename to packages/generators/src/utils/__tests__/npm-packages-exists.test.ts index 0e7762f9720..831e3955c2a 100644 --- a/packages/utils/__tests__/npm-packages-exists.test.ts +++ b/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts @@ -1,8 +1,8 @@ -import { npmPackagesExists } from '../src/npm-packages-exists'; -import { resolvePackages } from '../src/resolve-packages'; +import { npmPackagesExists } from '../npm-packages-exists'; +import { resolvePackages } from '../resolve-packages'; -jest.mock('../src/npm-exists'); -jest.mock('../src/resolve-packages'); +jest.mock('../npm-exists'); +jest.mock('../resolve-packages'); // TS is not aware that jest changes the type of resolvePackages const mockResolvePackages = resolvePackages as jest.Mock; diff --git a/packages/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap b/packages/generators/src/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap similarity index 98% rename from packages/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap rename to packages/generators/src/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap index 3aa5786cc6e..592b7f56e58 100644 --- a/packages/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap +++ b/packages/generators/src/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap @@ -105,7 +105,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 1`] symlinks: true }, module: { - noParse: function(content) { + noParse: function (content) { return /jquery|lodash/.test(content); }, rules: [ @@ -167,7 +167,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 2`] symlinks: true, }, module: { - noParse: function(content) { + noParse: function (content) { return /jquery|lodash/.test(content); }, rules: [ @@ -287,7 +287,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 4`] symlinks: true, }, module: { - noParse: function(content) { + noParse: function (content) { return /jquery|lodash/.test(content); }, rules: [ @@ -349,7 +349,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 5`] symlinks: true, }, module: { - noParse: function(content) { + noParse: function (content) { return /jquery|lodash/.test(content); }, rules: [{ diff --git a/packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-0.input.js b/packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-0.input.js similarity index 100% rename from packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-0.input.js rename to packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-0.input.js diff --git a/packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-1.input.js b/packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-1.input.js similarity index 100% rename from packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-1.input.js rename to packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-1.input.js diff --git a/packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-2.input.js b/packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-2.input.js similarity index 100% rename from packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-2.input.js rename to packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-2.input.js diff --git a/packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-3.input.js b/packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-3.input.js similarity index 97% rename from packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-3.input.js rename to packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-3.input.js index 2f5a73e568b..3d6046eabdd 100644 --- a/packages/utils/__tests__/recursive-parser/__testfixtures__/fixture-3.input.js +++ b/packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__/fixture-3.input.js @@ -35,7 +35,7 @@ module.exports = { symlinks: true, }, module: { - noParse: function(content) { + noParse: function (content) { return /jquery|lodash/.test(content); }, rules: [ diff --git a/packages/utils/__tests__/recursive-parser/recursive-parser.test.ts b/packages/generators/src/utils/__tests__/recursive-parser/recursive-parser.test.ts similarity index 97% rename from packages/utils/__tests__/recursive-parser/recursive-parser.test.ts rename to packages/generators/src/utils/__tests__/recursive-parser/recursive-parser.test.ts index 364ec6bc84b..2f7148f8768 100644 --- a/packages/utils/__tests__/recursive-parser/recursive-parser.test.ts +++ b/packages/generators/src/utils/__tests__/recursive-parser/recursive-parser.test.ts @@ -1,7 +1,7 @@ 'use strict'; import { join } from 'path'; -import defineTest from '../defineTest'; +import defineTest from '../../defineTest'; describe('recursive parser', () => { { diff --git a/packages/utils/__tests__/resolve-packages.test.ts b/packages/generators/src/utils/__tests__/resolve-packages.test.ts similarity index 100% rename from packages/utils/__tests__/resolve-packages.test.ts rename to packages/generators/src/utils/__tests__/resolve-packages.test.ts diff --git a/packages/utils/__tests__/run-prettier.test.ts b/packages/generators/src/utils/__tests__/run-prettier.test.ts similarity index 96% rename from packages/utils/__tests__/run-prettier.test.ts rename to packages/generators/src/utils/__tests__/run-prettier.test.ts index 8a04fa6ab3a..d07e03a63ee 100644 --- a/packages/utils/__tests__/run-prettier.test.ts +++ b/packages/generators/src/utils/__tests__/run-prettier.test.ts @@ -4,7 +4,7 @@ import fs from 'fs'; import path from 'path'; //eslint-disable-next-line node/no-extraneous-import import rimraf from 'rimraf'; -import { runPrettier } from '../src/run-prettier'; +import { runPrettier } from '../run-prettier'; const outputPath = path.join(__dirname, 'test-assets'); const outputFile = path.join(outputPath, 'test.js'); diff --git a/packages/utils/__tests__/validate-identifier.test.ts b/packages/generators/src/utils/__tests__/validate-identifier.test.ts similarity index 97% rename from packages/utils/__tests__/validate-identifier.test.ts rename to packages/generators/src/utils/__tests__/validate-identifier.test.ts index 4f5f4b6a718..dcebfa6f8a1 100644 --- a/packages/utils/__tests__/validate-identifier.test.ts +++ b/packages/generators/src/utils/__tests__/validate-identifier.test.ts @@ -1,6 +1,6 @@ 'use strict'; -import { isKeyword, isIdentifierChar, isIdentifierStart } from '../src/validate-identifier'; +import { isKeyword, isIdentifierChar, isIdentifierStart } from '../validate-identifier'; describe('validate-identifier', () => { it('should return true for reserved keyword', () => { diff --git a/packages/utils/src/ast-utils.ts b/packages/generators/src/utils/ast-utils.ts similarity index 100% rename from packages/utils/src/ast-utils.ts rename to packages/generators/src/utils/ast-utils.ts diff --git a/packages/utils/src/copy-utils.ts b/packages/generators/src/utils/copy-utils.ts similarity index 100% rename from packages/utils/src/copy-utils.ts rename to packages/generators/src/utils/copy-utils.ts diff --git a/packages/utils/__tests__/defineTest.ts b/packages/generators/src/utils/defineTest.ts similarity index 95% rename from packages/utils/__tests__/defineTest.ts rename to packages/generators/src/utils/defineTest.ts index 6f5a51bac9c..ada2f4f1c33 100644 --- a/packages/utils/__tests__/defineTest.ts +++ b/packages/generators/src/utils/defineTest.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; -import { JSCodeshift, Node } from '../src/types/NodePath'; +import { JSCodeshift, Node } from './types/NodePath'; interface Module { (jscodeshift: JSCodeshift, ast: Node, initOptions: string | boolean | object, action: string, transformName?: string): Node; @@ -58,9 +58,9 @@ function runSingleTransform( let module: Module; // Assumes transform and test are on the same level if (action) { - module = require(path.join(dirName, '../../src', 'recursive-parser.ts')); + module = require(path.join(dirName, '../../', 'recursive-parser.ts')); } else { - module = require(path.join(dirName, '../../src', transformName, `${transformName}.ts`)); + module = require(path.join(dirName, '../../src/', transformName, `${transformName}.ts`)); } // Handle ES6 modules using default export for the transform const transform = module.default ? module.default : module; diff --git a/packages/utils/src/global-packages-path.ts b/packages/generators/src/utils/global-packages-path.ts similarity index 100% rename from packages/utils/src/global-packages-path.ts rename to packages/generators/src/utils/global-packages-path.ts diff --git a/packages/utils/src/isWebpack5.ts b/packages/generators/src/utils/isWebpack5.ts similarity index 100% rename from packages/utils/src/isWebpack5.ts rename to packages/generators/src/utils/isWebpack5.ts diff --git a/packages/utils/src/modify-config-helper.ts b/packages/generators/src/utils/modify-config-helper.ts similarity index 100% rename from packages/utils/src/modify-config-helper.ts rename to packages/generators/src/utils/modify-config-helper.ts diff --git a/packages/utils/src/npm-exists.ts b/packages/generators/src/utils/npm-exists.ts similarity index 100% rename from packages/utils/src/npm-exists.ts rename to packages/generators/src/utils/npm-exists.ts diff --git a/packages/utils/src/npm-packages-exists.ts b/packages/generators/src/utils/npm-packages-exists.ts similarity index 100% rename from packages/utils/src/npm-packages-exists.ts rename to packages/generators/src/utils/npm-packages-exists.ts diff --git a/packages/utils/src/path-utils.ts b/packages/generators/src/utils/path-utils.ts similarity index 100% rename from packages/utils/src/path-utils.ts rename to packages/generators/src/utils/path-utils.ts diff --git a/packages/utils/src/prop-types.ts b/packages/generators/src/utils/prop-types.ts similarity index 100% rename from packages/utils/src/prop-types.ts rename to packages/generators/src/utils/prop-types.ts diff --git a/packages/utils/src/recursive-parser.ts b/packages/generators/src/utils/recursive-parser.ts similarity index 100% rename from packages/utils/src/recursive-parser.ts rename to packages/generators/src/utils/recursive-parser.ts diff --git a/packages/utils/src/resolve-packages.ts b/packages/generators/src/utils/resolve-packages.ts similarity index 100% rename from packages/utils/src/resolve-packages.ts rename to packages/generators/src/utils/resolve-packages.ts diff --git a/packages/utils/src/run-prettier.ts b/packages/generators/src/utils/run-prettier.ts similarity index 100% rename from packages/utils/src/run-prettier.ts rename to packages/generators/src/utils/run-prettier.ts diff --git a/packages/utils/src/scaffold.ts b/packages/generators/src/utils/scaffold.ts similarity index 100% rename from packages/utils/src/scaffold.ts rename to packages/generators/src/utils/scaffold.ts diff --git a/packages/utils/src/spawn-child.ts b/packages/generators/src/utils/spawn-child.ts similarity index 100% rename from packages/utils/src/spawn-child.ts rename to packages/generators/src/utils/spawn-child.ts diff --git a/packages/utils/src/types/Config.ts b/packages/generators/src/utils/types/Config.ts similarity index 100% rename from packages/utils/src/types/Config.ts rename to packages/generators/src/utils/types/Config.ts diff --git a/packages/utils/src/types/Error.ts b/packages/generators/src/utils/types/Error.ts similarity index 100% rename from packages/utils/src/types/Error.ts rename to packages/generators/src/utils/types/Error.ts diff --git a/packages/utils/src/types/NodePath.ts b/packages/generators/src/utils/types/NodePath.ts similarity index 100% rename from packages/utils/src/types/NodePath.ts rename to packages/generators/src/utils/types/NodePath.ts diff --git a/packages/utils/src/types/index.ts b/packages/generators/src/utils/types/index.ts similarity index 100% rename from packages/utils/src/types/index.ts rename to packages/generators/src/utils/types/index.ts diff --git a/packages/utils/src/validate-identifier.ts b/packages/generators/src/utils/validate-identifier.ts similarity index 100% rename from packages/utils/src/validate-identifier.ts rename to packages/generators/src/utils/validate-identifier.ts diff --git a/packages/generators/tsconfig.json b/packages/generators/tsconfig.json index b5df5fb69be..173f75d3f62 100644 --- a/packages/generators/tsconfig.json +++ b/packages/generators/tsconfig.json @@ -1,9 +1,9 @@ { "extends": "../../tsconfig.json", + "exclude": ["src/utils/__tests__"], "compilerOptions": { "outDir": "lib", "rootDir": "src" }, - "include": ["src"], - "references": [{ "path": "../utils" }] + "include": ["src"] } diff --git a/packages/init/package.json b/packages/init/package.json index 0898105ef64..4cc235e3bb0 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -12,8 +12,7 @@ "lib" ], "dependencies": { - "@webpack-cli/generators": "^1.2.1", - "@webpack-cli/utils": "^1.2.1" + "@webpack-cli/generators": "^1.2.1" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index 8c12b5dd98b..3eb7b545909 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -1,5 +1,4 @@ -import { initGenerator } from '@webpack-cli/generators'; -import { modifyHelperUtil, npmPackagesExists } from '@webpack-cli/utils'; +import { initGenerator, modifyHelperUtil, npmPackagesExists } from '@webpack-cli/generators'; class InitCommand { async apply(cli): Promise { diff --git a/packages/init/tsconfig.json b/packages/init/tsconfig.json index 5d22b189fd7..ba2474fb584 100644 --- a/packages/init/tsconfig.json +++ b/packages/init/tsconfig.json @@ -5,5 +5,5 @@ "rootDir": "./src" }, "include": ["./src"], - "references": [{ "path": "../generators" }, { "path": "../utils" }] + "references": [{ "path": "../generators" }] } diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md deleted file mode 100644 index caca2302e41..00000000000 --- a/packages/utils/CHANGELOG.md +++ /dev/null @@ -1,69 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.2.0...@webpack-cli/utils@1.2.1) (2020-12-31) - -**Note:** Version bump only for package @webpack-cli/utils - -# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.1.0...@webpack-cli/utils@1.2.0) (2020-12-25) - -### Bug Fixes - -- remove duplicate log ([#2079](https://github.com/webpack/webpack-cli/issues/2079)) ([112068d](https://github.com/webpack/webpack-cli/commit/112068dc5b962a773c5db00e4e1140e8733ea9ec)) - -### Features - -- **init:** add --generation-path flag ([#2050](https://github.com/webpack/webpack-cli/issues/2050)) ([413eb8c](https://github.com/webpack/webpack-cli/commit/413eb8cf2add4978763a4c9ee6b983582685768b)) - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.2...@webpack-cli/utils@1.1.0) (2020-11-04) - -### Features - -- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.1...@webpack-cli/utils@1.0.2) (2020-10-19) - -**Note:** Version bump only for package @webpack-cli/utils - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.1-rc.1...@webpack-cli/utils@1.0.1) (2020-10-10) - -### Bug Fixes - -- cleanup `package-utils` package ([#1822](https://github.com/webpack/webpack-cli/issues/1822)) ([fd5b92b](https://github.com/webpack/webpack-cli/commit/fd5b92b3cd40361daec5bf4486e455a41f4c9738)) -- upgrade lock file ([#1885](https://github.com/webpack/webpack-cli/issues/1885)) ([8df291e](https://github.com/webpack/webpack-cli/commit/8df291eef0fad7c91d912b158b3c2915cddfacd1)) - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.1-alpha.5...@webpack-cli/utils@1.0.1-rc.1) (2020-10-06) - -### Bug Fixes - -- add necessary peerDependencies ([#1825](https://github.com/webpack/webpack-cli/issues/1825)) ([0f13ab5](https://github.com/webpack/webpack-cli/commit/0f13ab5ddd9e28e5e7095721d086a58aebaf98a5)) -- regression with migrate command ([7ebcbb8](https://github.com/webpack/webpack-cli/commit/7ebcbb8030b9111df797abdd67e504178b18aeac)) -- use appropriate exit codes ([#1755](https://github.com/webpack/webpack-cli/issues/1755)) ([83f73b0](https://github.com/webpack/webpack-cli/commit/83f73b056e224301b871bee5e9b7254e64e84e95)) - -### Features - -- add flag to force config ([f61e7e0](https://github.com/webpack/webpack-cli/commit/f61e7e0d1b03284d7333c4f0f38294460209a25d)) - -## [1.0.1-alpha.5](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/utils@1.0.1-alpha.4...@webpack-cli/utils@1.0.1-alpha.5) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/utils - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/utils@1.0.1-alpha.3...@webpack-cli/utils@1.0.1-alpha.4) (2020-02-29) - -**Note:** Version bump only for package @webpack-cli/utils - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/utils@1.0.1-alpha.2...@webpack-cli/utils@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/utils - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.1-alpha.1...@webpack-cli/utils@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/utils - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/utils@1.0.1-alpha.0...@webpack-cli/utils@1.0.1-alpha.1) (2020-02-23) - -### Bug Fixes - -- **init:** fix webpack config scaffold ([#1231](https://github.com/webpack/webpack-cli/issues/1231)) ([2dc495a](https://github.com/webpack/webpack-cli/commit/2dc495a8d050d28478c6c2533d7839e9ff78d76c)), closes [#1230](https://github.com/webpack/webpack-cli/issues/1230) diff --git a/packages/utils/README.md b/packages/utils/README.md deleted file mode 100644 index 4863dd276db..00000000000 --- a/packages/utils/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# webpack-cli utils (WIP, not yet published) - -[![NPM Downloads][downloads]][downloads-url] - -## Description - -This package contains the utilities used across the webpack-cli repositories. - -## Installation - -```bash -npm i -D webpack-cli @webpack-cli/utils -``` - -## Contents - -- AST transformations -- Checking NPM registry -- A Recursive AST parser -- Checking Local Configurations -- Yeoman Generator Adapter -- Package Resolver -- Test Utilities for Jest - -## Usage - -### Node - -```js -const utils = require('@webpack-cli/utils'); -// API yet to be exposed -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/utils.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/utils diff --git a/packages/utils/package.json b/packages/utils/package.json deleted file mode 100644 index 8f96970b4d4..00000000000 --- a/packages/utils/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@webpack-cli/utils", - "version": "1.2.1", - "description": "webpack-cli utility files", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "publishConfig": { - "access": "public" - }, - "license": "MIT", - "files": [ - "lib" - ], - "dependencies": { - "colorette": "^1.2.1", - "execa": "^5.0.0", - "findup-sync": "^4.0.0", - "global-modules": "^2.0.0", - "got": "^11.8.0", - "jscodeshift": "^0.11.0", - "p-each-series": "^2.1.0", - "yeoman-environment": "^2.10.3", - "yeoman-generator": "^4.12.0" - }, - "peerDependencies": { - "webpack": "4.x.x || 5.x.x", - "webpack-cli": "4.x.x" - }, - "devDependencies": { - "@types/got": "^9.6.11", - "@types/prettier": "^2.1.5", - "@types/yeoman-generator": "^4.11.3" - }, - "peerDependenciesMeta": { - "prettier": { - "optional": true - } - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts deleted file mode 100644 index 68fef1ebafe..00000000000 --- a/packages/utils/src/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export * from './ast-utils'; -export * from './copy-utils'; -export * from './modify-config-helper'; -export * from './npm-exists'; -export * from './npm-packages-exists'; -export * from './recursive-parser'; -export * from './resolve-packages'; -export * from './run-prettier'; -export * from './scaffold'; -export * from './validate-identifier'; -export * from './prop-types'; -export * from './global-packages-path'; diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json deleted file mode 100644 index 279b3e923cc..00000000000 --- a/packages/utils/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"] -} diff --git a/scripts/utils.js b/scripts/utils.js index d3af3935606..966ce05f90d 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -10,13 +10,26 @@ function collectTestFolders(strategy) { } function extractFolder(folderToRead, folders = [], folderStrategy) { - const files = fs.readdirSync(folderToRead); + let files; + + try { + files = fs.readdirSync(folderToRead); + } catch (error) { + return []; + } + + if (!files) { + return []; + } + files.forEach((file) => { const filePath = path.resolve(path.join(folderToRead, file)); const stats = fs.statSync(filePath); + if (folderStrategy(stats, file)) { folders.push(folderToRead); } + if (stats.isDirectory() && file !== 'node_modules') { extractFolder(filePath, folders, folderStrategy); } diff --git a/tsconfig.json b/tsconfig.json index ea484876822..ad41a0d6d32 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,9 +32,6 @@ { "path": "packages/serve" }, - { - "path": "packages/utils" - }, { "path": "packages/configtest" } From 5070b9bcbd5bdac00088d0c21486ad181a4df000 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 13 Jan 2021 13:47:39 +0300 Subject: [PATCH 255/581] fix: pass all `argv` to configurations when `serve` command used (#2345) --- .github/workflows/nodejs.yml | 4 +- packages/serve/src/index.ts | 2 +- .../resolveConfig/resolveConfig.test.js | 2 +- packages/webpack-cli/lib/webpack-cli.js | 14 +++--- .../function-with-argv.test.js | 1 + test/serve/basic/function-with-argv.config.js | 11 +++++ test/serve/basic/function-with-env.config.js | 11 +++++ test/serve/basic/serve-basic.test.js | 46 +++++++++++++++++++ yarn.lock | 15 ++++++ 9 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 test/serve/basic/function-with-argv.config.js create mode 100644 test/serve/basic/function-with-env.config.js diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 04847d08649..7424fe6c6a0 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -92,8 +92,8 @@ jobs: yarn build:ci yarn run lerna bootstrap - - name: Run Smoketests - run: yarn test:smoketests + # - name: Run Smoketests + # run: yarn test:smoketests - name: Test and Generate Coverage run: | diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 2c9e0186bb3..c70b9ced2c2 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -73,7 +73,7 @@ class ServeCommand { processor(devServerOptions); } - webpackOptions.env = { WEBPACK_SERVE: true, ...options.env }; + webpackOptions.argv = { ...options, env: { WEBPACK_SERVE: true, ...options.env } }; const compiler = await cli.createCompiler(webpackOptions); diff --git a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js index 674e357444c..4522bfc3f2c 100644 --- a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js +++ b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js @@ -60,7 +60,7 @@ describe('resolveConfig', function () { it('should handle different env formats', async () => { const result = await resolveConfig({ - env: { test: true, name: 'Hisoka' }, + argv: { env: { test: true, name: 'Hisoka' } }, config: [resolve(__dirname, './env.webpack.config.cjs')], }); const expectedOptions = { mode: 'staging', name: 'Hisoka' }; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index e18f4a5bdb7..640c9808e33 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -778,7 +778,7 @@ class WebpackCLI { return { options, path: configPath }; }; - const evaluateConfig = async (loadedConfig, args) => { + const evaluateConfig = async (loadedConfig, argv) => { const isMultiCompiler = Array.isArray(loadedConfig.options); const config = isMultiCompiler ? loadedConfig.options : [loadedConfig.options]; @@ -791,7 +791,7 @@ class WebpackCLI { // `Promise` may return `Function` if (typeof rawConfig === 'function') { // when config is a function, pass the env from args to the config function - rawConfig = await rawConfig(args.env, args); + rawConfig = await rawConfig(argv.env, argv); } return rawConfig; @@ -824,7 +824,7 @@ class WebpackCLI { const loadedConfig = await loadConfig(configPath); - return evaluateConfig(loadedConfig, options); + return evaluateConfig(loadedConfig, options.argv || {}); }), ); @@ -867,7 +867,7 @@ class WebpackCLI { if (foundDefaultConfigFile) { const loadedConfig = await loadConfig(foundDefaultConfigFile.path); - const evaluatedConfig = await evaluateConfig(loadedConfig, options); + const evaluatedConfig = await evaluateConfig(loadedConfig, options.argv || {}); config.options = evaluatedConfig.options; @@ -1275,7 +1275,9 @@ class WebpackCLI { : undefined; // TODO webpack@4 doesn't support `{ children: [{ colors: true }, { colors: true }] }` for stats - if (compiler.compilers && !compiler.compilers.find(oneOfCompiler => oneOfCompiler.webpack)) { + const statsForWebpack4 = webpack.Stats && webpack.Stats.presetToOptions; + + if (compiler.compilers && statsForWebpack4) { statsOptions.colors = statsOptions.children.some((child) => child.colors); } @@ -1311,7 +1313,7 @@ class WebpackCLI { } }; - options.env = { WEBPACK_BUNDLE: true, ...options.env }; + options.argv = { ...options, env: { WEBPACK_BUNDLE: true, ...options.env } }; compiler = await this.createCompiler(options, callback); diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index c4ee065e975..c1d212164d5 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -11,6 +11,7 @@ describe('function configuration', () => { expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(stdout).toContain("{ argv: { mode: 'development', env: { WEBPACK_BUNDLE: true } } }"); + expect(stdout).toContain("mode: 'development'"); expect(existsSync(resolve(__dirname, './dist/dev.js'))); }); }); diff --git a/test/serve/basic/function-with-argv.config.js b/test/serve/basic/function-with-argv.config.js new file mode 100644 index 00000000000..d5e597ff3ec --- /dev/null +++ b/test/serve/basic/function-with-argv.config.js @@ -0,0 +1,11 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = (env, argv) => { + console.log(argv); + + return { + mode: 'development', + devtool: false, + plugins: [new WebpackCLITestPlugin(['mode'], false, 'hooks.compilation.taps')], + }; +}; diff --git a/test/serve/basic/function-with-env.config.js b/test/serve/basic/function-with-env.config.js new file mode 100644 index 00000000000..7aae1e7f0fe --- /dev/null +++ b/test/serve/basic/function-with-env.config.js @@ -0,0 +1,11 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = (env) => { + console.log(env); + + return { + mode: 'development', + devtool: false, + plugins: [new WebpackCLITestPlugin(['mode'], false, 'hooks.compilation.taps')], + }; +}; diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 0c5b1c55236..ff5a20998c2 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -35,6 +35,52 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); + it('should work with the "--config" option', async () => { + const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'webpack.config.js', '--port', port]); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('development'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should work with the "--config" and "--env" options', async () => { + const { stderr, stdout } = await runServe(__dirname, [ + 'serve', + '--config', + 'function-with-env.config.js', + '--env', + 'foo=bar', + '--port', + port, + ]); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('WEBPACK_SERVE: true'); + expect(stdout).toContain("foo: 'bar'"); + expect(stdout).toContain('development'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it('should work with the "--config" and "--env" options and expose dev server options', async () => { + const { stderr, stdout } = await runServe(__dirname, [ + 'serve', + '--config', + 'function-with-argv.config.js', + '--env', + 'foo=bar', + '--hot', + '--port', + port, + ]); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('hot: true'); + expect(stdout).toContain('WEBPACK_SERVE: true'); + expect(stdout).toContain("foo: 'bar'"); + expect(stdout).toContain('development'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1); + }); + it('should work in multi compiler mode', async () => { const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'multi.config.js', '--port', port]); diff --git a/yarn.lock b/yarn.lock index 1eb88b51162..41acf788531 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2245,6 +2245,21 @@ p-each-series "^2.1.0" p-lazy "^3.0.0" +"@webpack-cli/utils@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@webpack-cli/utils/-/utils-1.2.1.tgz#b3a847fc803e0ff661833b147b02f9f886a54d87" + integrity sha512-Q28u+uBYqmRGRhRNhBfi5jnlUBIEtvSsIhSIS81BCvc/nADNdNlYrqKn3FLJ2KgE7ZmEhKf0cvarcwLvy1BCOQ== + dependencies: + colorette "^1.2.1" + execa "^5.0.0" + findup-sync "^4.0.0" + global-modules "^2.0.0" + got "^11.8.0" + jscodeshift "^0.11.0" + p-each-series "^2.1.0" + yeoman-environment "^2.10.3" + yeoman-generator "^4.12.0" + "@xtuc/ieee754@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" From 9b39f1ec9a60d2ee9d7bb0bcd5197e035d4c0b41 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 13 Jan 2021 17:14:50 +0300 Subject: [PATCH 256/581] chore: update deps (#2346) --- .github/workflows/nodejs.yml | 8 +- .prettierignore | 1 + OPTIONS.md | 8 +- package.json | 9 +- .../__tests__/init-generator.test.ts | 1 + .../__tests__/loader-generator.test.ts | 1 + .../__tests__/plugin-generator.test.ts | 1 + .../__tests__/utils/scaffold-utils.test.ts | 22 +- packages/generators/package.json | 4 +- packages/serve/src/index.ts | 2 +- .../webpack-dev-server.test.js | 2 +- smoketests/missing-packages/webpack.test.js | 2 +- yarn.lock | 324 ++++++++---------- 13 files changed, 190 insertions(+), 195 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 7424fe6c6a0..d2c0262b783 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -92,8 +92,8 @@ jobs: yarn build:ci yarn run lerna bootstrap - # - name: Run Smoketests - # run: yarn test:smoketests + - name: Run Smoketests + run: yarn test:smoketests - name: Test and Generate Coverage run: | @@ -110,11 +110,15 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 + - uses: actions/setup-node@v1 with: node-version: '12.x' + - run: npm install + - name: conventional-changelog-lint-config-cz # $GITHUB_WORKSPACE is the path to your repository run: echo "NODE_PATH=$GITHUB_WORKSPACE/node_modules" >> $GITHUB_ENV + - uses: wagoid/commitlint-github-action@v2 diff --git a/.prettierignore b/.prettierignore index 8f68c1e421c..86be5e4bc4f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ coverage +.nyc_output node_modules test/**/dist/ test/**/bin/ diff --git a/OPTIONS.md b/OPTIONS.md index 24b6d9e094b..374b7cc3141 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -456,12 +456,14 @@ Options: --resolve-main-files-reset Clear all items provided in configuration. Filenames used to find the default entry point if there is no description file or main field. --resolve-modules Folder name or directory path where to find modules. --resolve-modules-reset Clear all items provided in configuration. Folder names or directory paths where to find modules. + --resolve-prefer-absolute Prefer to resolve server-relative URLs (starting with '/') as absolute paths before falling back to resolve in 'resolve.roots'. + --no-resolve-prefer-absolute Negative 'resolve-prefer-absolute' option. --resolve-prefer-relative Prefer to resolve module requests as relative request and fallback to resolving as module. --no-resolve-prefer-relative Negative 'resolve-prefer-relative' option. --resolve-restrictions Resolve restriction. Resolve result must fulfill this restriction. --resolve-restrictions-reset Clear all items provided in configuration. A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. --resolve-roots Directory in which requests that are server-relative URLs (starting with '/') are resolved. - --resolve-roots-reset Clear all items provided in configuration. A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. + --resolve-roots-reset Clear all items provided in configuration. A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. --resolve-symlinks Enable resolving symlinks to the original location. --no-resolve-symlinks Negative 'resolve-symlinks' option. --resolve-unsafe-cache Enable caching of successfully resolved requests (cache entries are not revalidated). @@ -504,12 +506,14 @@ Options: --resolve-loader-main-files-reset Clear all items provided in configuration. Filenames used to find the default entry point if there is no description file or main field. --resolve-loader-modules Folder name or directory path where to find modules. --resolve-loader-modules-reset Clear all items provided in configuration. Folder names or directory paths where to find modules. + --resolve-loader-prefer-absolute Prefer to resolve server-relative URLs (starting with '/') as absolute paths before falling back to resolve in 'resolve.roots'. + --no-resolve-loader-prefer-absolute Negative 'resolve-loader-prefer-absolute' option. --resolve-loader-prefer-relative Prefer to resolve module requests as relative request and fallback to resolving as module. --no-resolve-loader-prefer-relative Negative 'resolve-loader-prefer-relative' option. --resolve-loader-restrictions Resolve restriction. Resolve result must fulfill this restriction. --resolve-loader-restrictions-reset Clear all items provided in configuration. A list of resolve restrictions. Resolve results must fulfill all of these restrictions to resolve successfully. Other resolve paths are taken when restrictions are not met. --resolve-loader-roots Directory in which requests that are server-relative URLs (starting with '/') are resolved. - --resolve-loader-roots-reset Clear all items provided in configuration. A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first. + --resolve-loader-roots-reset Clear all items provided in configuration. A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. --resolve-loader-symlinks Enable resolving symlinks to the original location. --no-resolve-loader-symlinks Negative 'resolve-loader-symlinks' option. --resolve-loader-unsafe-cache Enable caching of successfully resolved requests (cache entries are not revalidated). diff --git a/package.json b/package.json index f92b5600a14..c6592c46c13 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "cz-customizable": "^6.3.0", "del-cli": "^3.0.1", "eslint": "^7.12.1", - "eslint-config-prettier": "^6.15.0", + "eslint-config-prettier": "^7.1.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.1.4", "execa": "^5.0.0", @@ -90,10 +90,13 @@ "rimraf": "^3.0.2", "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", - "typescript": "^3.9.7", - "webpack": "^5.12.2", + "typescript": "^4.1.3", + "webpack": "^5.13.0", "webpack-bundle-analyzer": "^4.3.0", "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" + }, + "dependencies": { + "@types/yeoman-test": "^2.0.5" } } diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index 78f5fa9c45b..92ce3f6c42a 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -1,4 +1,5 @@ import * as assert from 'yeoman-assert'; +// eslint-disable-next-line node/no-extraneous-import import { run } from 'yeoman-test'; import { join } from 'path'; diff --git a/packages/generators/__tests__/loader-generator.test.ts b/packages/generators/__tests__/loader-generator.test.ts index 4b6d7f38605..cf3be1e86eb 100644 --- a/packages/generators/__tests__/loader-generator.test.ts +++ b/packages/generators/__tests__/loader-generator.test.ts @@ -1,4 +1,5 @@ import { join } from 'path'; +// eslint-disable-next-line node/no-extraneous-import import { run } from 'yeoman-test'; import * as assert from 'yeoman-assert'; diff --git a/packages/generators/__tests__/plugin-generator.test.ts b/packages/generators/__tests__/plugin-generator.test.ts index b92f65d2d46..baecf51c450 100644 --- a/packages/generators/__tests__/plugin-generator.test.ts +++ b/packages/generators/__tests__/plugin-generator.test.ts @@ -1,4 +1,5 @@ import { join } from 'path'; +// eslint-disable-next-line node/no-extraneous-import import { run } from 'yeoman-test'; import * as assert from 'yeoman-assert'; diff --git a/packages/generators/__tests__/utils/scaffold-utils.test.ts b/packages/generators/__tests__/utils/scaffold-utils.test.ts index 6508e3dfdf5..2fd303e5dd1 100755 --- a/packages/generators/__tests__/utils/scaffold-utils.test.ts +++ b/packages/generators/__tests__/utils/scaffold-utils.test.ts @@ -1,8 +1,10 @@ import { Confirm, List, InputValidate, Input } from '../../src/utils/scaffold-utils'; describe('utils', () => { + let mockSelf; + beforeEach(() => { - this.mockSelf = { + mockSelf = { // eslint-disable-next-line @typescript-eslint/explicit-function-return-type prompt: (arg) => { return arg[0]; @@ -11,7 +13,7 @@ describe('utils', () => { }); describe('Inquirer', () => { it('should emulate a prompt for List', () => { - expect(List(this.mockSelf, 'entry', 'does it work?', ['Yes', 'Maybe'], 'Yes')).toEqual({ + expect(List(mockSelf, 'entry', 'does it work?', ['Yes', 'Maybe'], 'Yes')).toEqual({ choices: ['Yes', 'Maybe'], type: 'list', name: 'entry', @@ -21,12 +23,12 @@ describe('utils', () => { }); it('should make default value for a List', () => { - expect(List(this.mockSelf, 'entry', 'does it work?', ['Yes', 'Maybe'], 'Yes', true)).toEqual({ + expect(List(mockSelf, 'entry', 'does it work?', ['Yes', 'Maybe'], 'Yes', true)).toEqual({ entry: 'Yes', }); }); it('should emulate a prompt for list input', () => { - expect(Input(this.mockSelf, 'plugins', 'what is your plugin?', 'openJSF')).toEqual({ + expect(Input(mockSelf, 'plugins', 'what is your plugin?', 'openJSF')).toEqual({ type: 'input', name: 'plugins', message: 'what is your plugin?', @@ -34,12 +36,12 @@ describe('utils', () => { }); }); it('should return a default Input object value', () => { - expect(Input(this.mockSelf, 'plugins', 'what is your plugin?', 'my-plugin', true)).toEqual({ + expect(Input(mockSelf, 'plugins', 'what is your plugin?', 'my-plugin', true)).toEqual({ plugins: 'my-plugin', }); }); it('should emulate a prompt for confirm', () => { - expect(Confirm(this.mockSelf, 'context', 'what is your context?')).toEqual({ + expect(Confirm(mockSelf, 'context', 'what is your context?')).toEqual({ name: 'context', default: true, message: 'what is your context?', @@ -47,18 +49,18 @@ describe('utils', () => { }); }); it('should make a Confirm object with yes as default', () => { - expect(Confirm(this.mockSelf, 'context', 'what is your context?', true, true)).toEqual({ + expect(Confirm(mockSelf, 'context', 'what is your context?', true, true)).toEqual({ context: true, }); }); it('should make an Input object with validation', () => { - expect(InputValidate(this.mockSelf, 'plugins', 'what is your plugin?', () => true)).toMatchSnapshot(); + expect(InputValidate(mockSelf, 'plugins', 'what is your plugin?', () => true)).toMatchSnapshot(); }); it('should make an Input object with validation and default value', () => { - expect(InputValidate(this.mockSelf, 'plugins', 'what is your plugin?', () => true, 'my-plugin')).toMatchSnapshot(); + expect(InputValidate(mockSelf, 'plugins', 'what is your plugin?', () => true, 'my-plugin')).toMatchSnapshot(); }); it('should return a default Input object with validation and default value', () => { - expect(InputValidate(this.mockSelf, 'plugins', 'what is your plugin?', () => true, 'my-plugin', true)).toEqual({ + expect(InputValidate(mockSelf, 'plugins', 'what is your plugin?', () => true, 'my-plugin', true)).toEqual({ plugins: 'my-plugin', }); }); diff --git a/packages/generators/package.json b/packages/generators/package.json index c4c069a8204..694bc4ee50e 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -21,7 +21,7 @@ "log-symbols": "^4.0.0", "yeoman-environment": "^2.10.3", "yeoman-generator": "^4.12.0", - "execa": "^4.1.0", + "execa": "^5.0.0", "findup-sync": "^4.0.0", "global-modules": "^2.0.0", "got": "^11.8.0", @@ -35,10 +35,8 @@ "devDependencies": { "@types/yeoman-assert": "^3.1.1", "@types/yeoman-generator": "^4.11.3", - "@types/yeoman-test": "^2.0.5", "rimraf": "^3.0.2", "yeoman-assert": "^3.1.1", - "yeoman-test": "^2.3.0", "@types/got": "^9.6.11", "@types/prettier": "^2.1.5" }, diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index c70b9ced2c2..ce3c4ebe781 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -94,7 +94,7 @@ class ServeCommand { process.stdin.on('end', () => { Promise.all( servers.map((server) => { - return new Promise((resolve) => { + return new Promise((resolve) => { server.close(() => { resolve(); }); diff --git a/smoketests/missing-packages/webpack-dev-server.test.js b/smoketests/missing-packages/webpack-dev-server.test.js index dd575e33491..b0ae710b83d 100644 --- a/smoketests/missing-packages/webpack-dev-server.test.js +++ b/smoketests/missing-packages/webpack-dev-server.test.js @@ -33,7 +33,7 @@ const runTest = () => { setTimeout(() => { console.log(' timeout: killing process'); proc.kill(); - }, 5000); + }, 30000); const logMessage = "For using 'serve' command you need to install: 'webpack-dev-server' package"; const prompt = 'Would you like to install'; diff --git a/smoketests/missing-packages/webpack.test.js b/smoketests/missing-packages/webpack.test.js index 14774cf6457..31a500ae380 100644 --- a/smoketests/missing-packages/webpack.test.js +++ b/smoketests/missing-packages/webpack.test.js @@ -32,7 +32,7 @@ const runTest = () => { return new Promise((resolve) => { setTimeout(() => { proc.kill(); - }, 5000); + }, 30000); const logMessage = 'It looks like webpack is not installed.'; const prompt = 'Would you like to install'; diff --git a/yarn.lock b/yarn.lock index 41acf788531..cf6d0d6786a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2086,149 +2086,125 @@ semver "^7.3.2" tsutils "^3.17.1" -"@webassemblyjs/ast@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.1.tgz#76c6937716d68bf1484c15139f5ed30b9abc8bb4" - integrity sha512-uMu1nCWn2Wxyy126LlGqRVlhdTOsO/bsBRI4dNq3+6SiSuRKRQX6ejjKgh82LoGAPSq72lDUiQ4FWVaf0PecYw== - dependencies: - "@webassemblyjs/helper-module-context" "1.9.1" - "@webassemblyjs/helper-wasm-bytecode" "1.9.1" - "@webassemblyjs/wast-parser" "1.9.1" - -"@webassemblyjs/floating-point-hex-parser@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.1.tgz#9eb0ff90a1cdeef51f36ba533ed9f06b5cdadd09" - integrity sha512-5VEKu024RySmLKTTBl9q1eO/2K5jk9ZS+2HXDBLA9s9p5IjkaXxWiDb/+b7wSQp6FRdLaH1IVGIfOex58Na2pg== - -"@webassemblyjs/helper-api-error@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.1.tgz#ad89015c4246cd7f5ed0556700237f8b9c2c752f" - integrity sha512-y1lGmfm38djrScwpeL37rRR9f1D6sM8RhMpvM7CYLzOlHVboouZokXK/G88BpzW0NQBSvCCOnW5BFhten4FPfA== - -"@webassemblyjs/helper-buffer@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.9.1.tgz#186e67ac25f9546ea7939759413987f157524133" - integrity sha512-uS6VSgieHbk/m4GSkMU5cqe/5TekdCzQso4revCIEQ3vpGZgqSSExi4jWpTWwDpAHOIAb1Jfrs0gUB9AA4n71w== - -"@webassemblyjs/helper-code-frame@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.9.1.tgz#aab177b7cc87a318a8f8664ad68e2c3828ebc42b" - integrity sha512-ZQ2ZT6Evk4DPIfD+92AraGYaFIqGm4U20e7FpXwl7WUo2Pn1mZ1v8VGH8i+Y++IQpxPbQo/UyG0Khs7eInskzA== - dependencies: - "@webassemblyjs/wast-printer" "1.9.1" - -"@webassemblyjs/helper-fsm@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.9.1.tgz#527e91628e84d13d3573884b3dc4c53a81dcb911" - integrity sha512-J32HGpveEqqcKFS0YbgicB0zAlpfIxJa5MjxDxhu3i5ltPcVfY5EPvKQ1suRguFPehxiUs+/hfkwPEXom/l0lw== - -"@webassemblyjs/helper-module-context@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.9.1.tgz#778670b3d471f7cf093d1e7c0dde431b54310e16" - integrity sha512-IEH2cMmEQKt7fqelLWB5e/cMdZXf2rST1JIrzWmf4XBt3QTxGdnnLvV4DYoN8pJjOx0VYXsWg+yF16MmJtolZg== - dependencies: - "@webassemblyjs/ast" "1.9.1" - -"@webassemblyjs/helper-wasm-bytecode@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.1.tgz#563f59bcf409ccf469edde168b9426961ffbf6df" - integrity sha512-i2rGTBqFUcSXxyjt2K4vm/3kkHwyzG6o427iCjcIKjOqpWH8SEem+xe82jUk1iydJO250/CvE5o7hzNAMZf0dQ== - -"@webassemblyjs/helper-wasm-section@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.9.1.tgz#f7988f94c12b01b99a16120cb01dc099b00e4798" - integrity sha512-FetqzjtXZr2d57IECK+aId3D0IcGweeM0CbAnJHkYJkcRTHP+YcMb7Wmc0j21h5UWBpwYGb9dSkK/93SRCTrGg== - dependencies: - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/helper-buffer" "1.9.1" - "@webassemblyjs/helper-wasm-bytecode" "1.9.1" - "@webassemblyjs/wasm-gen" "1.9.1" - -"@webassemblyjs/ieee754@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.9.1.tgz#3b715871ca7d75784717cf9ceca9d7b81374b8af" - integrity sha512-EvTG9M78zP1MmkBpUjGQHZc26DzPGZSLIPxYHCjQsBMo60Qy2W34qf8z0exRDtxBbRIoiKa5dFyWer/7r1aaSQ== - dependencies: - "@xtuc/ieee754" "^1.2.0" - -"@webassemblyjs/leb128@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.9.1.tgz#b2ecaa39f9e8277cc9c707c1ca8b2aa7b27d0b72" - integrity sha512-Oc04ub0vFfLnF+2/+ki3AE+anmW4sv9uNBqb+79fgTaPv6xJsOT0dhphNfL3FrME84CbX/D1T9XT8tjFo0IIiw== - dependencies: +"@webassemblyjs/ast@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" + integrity sha512-kX2W49LWsbthrmIRMbQZuQDhGtjyqXfEmmHyEi4XWnSZtPmxY0+3anPIzsnRb45VH/J55zlOfWvZuY47aJZTJg== + dependencies: + "@webassemblyjs/helper-numbers" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + +"@webassemblyjs/floating-point-hex-parser@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.0.tgz#34d62052f453cd43101d72eab4966a022587947c" + integrity sha512-Q/aVYs/VnPDVYvsCBL/gSgwmfjeCb4LW8+TMrO3cSzJImgv8lxxEPM2JA5jMrivE7LSz3V+PFqtMbls3m1exDA== + +"@webassemblyjs/helper-api-error@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.0.tgz#aaea8fb3b923f4aaa9b512ff541b013ffb68d2d4" + integrity sha512-baT/va95eXiXb2QflSx95QGT5ClzWpGaa8L7JnJbgzoYeaA27FCvuBXU758l+KXWRndEmUXjP0Q5fibhavIn8w== + +"@webassemblyjs/helper-buffer@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.0.tgz#d026c25d175e388a7dbda9694e91e743cbe9b642" + integrity sha512-u9HPBEl4DS+vA8qLQdEQ6N/eJQ7gT7aNvMIo8AAWvAl/xMrcOSiI2M0MAnMCy3jIFke7bEee/JwdX1nUpCtdyA== + +"@webassemblyjs/helper-numbers@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.0.tgz#7ab04172d54e312cc6ea4286d7d9fa27c88cd4f9" + integrity sha512-DhRQKelIj01s5IgdsOJMKLppI+4zpmcMQ3XboFPLwCpSNH6Hqo1ritgHgD0nqHeSYqofA6aBN/NmXuGjM1jEfQ== + dependencies: + "@webassemblyjs/floating-point-hex-parser" "1.11.0" + "@webassemblyjs/helper-api-error" "1.11.0" "@xtuc/long" "4.2.2" -"@webassemblyjs/utf8@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.9.1.tgz#d02d9daab85cda3211e43caf31dca74c260a73b0" - integrity sha512-llkYtppagjCodFjo0alWOUhAkfOiQPQDIc5oA6C9sFAXz7vC9QhZf/f8ijQIX+A9ToM3c9Pq85X0EX7nx9gVhg== +"@webassemblyjs/helper-wasm-bytecode@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.0.tgz#85fdcda4129902fe86f81abf7e7236953ec5a4e1" + integrity sha512-MbmhvxXExm542tWREgSFnOVo07fDpsBJg3sIl6fSp9xuu75eGz5lz31q7wTLffwL3Za7XNRCMZy210+tnsUSEA== -"@webassemblyjs/wasm-edit@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.9.1.tgz#e27a6bdbf78e5c72fa812a2fc3cbaad7c3e37578" - integrity sha512-S2IaD6+x9B2Xi8BCT0eGsrXXd8UxAh2LVJpg1ZMtHXnrDcsTtIX2bDjHi40Hio6Lc62dWHmKdvksI+MClCYbbw== - dependencies: - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/helper-buffer" "1.9.1" - "@webassemblyjs/helper-wasm-bytecode" "1.9.1" - "@webassemblyjs/helper-wasm-section" "1.9.1" - "@webassemblyjs/wasm-gen" "1.9.1" - "@webassemblyjs/wasm-opt" "1.9.1" - "@webassemblyjs/wasm-parser" "1.9.1" - "@webassemblyjs/wast-printer" "1.9.1" - -"@webassemblyjs/wasm-gen@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.9.1.tgz#56a0787d1fa7994fdc7bea59004e5bec7189c5fc" - integrity sha512-bqWI0S4lBQsEN5FTZ35vYzfKUJvtjNnBobB1agCALH30xNk1LToZ7Z8eiaR/Z5iVECTlBndoRQV3F6mbEqE/fg== +"@webassemblyjs/helper-wasm-section@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.0.tgz#9ce2cc89300262509c801b4af113d1ca25c1a75b" + integrity sha512-3Eb88hcbfY/FCukrg6i3EH8H2UsD7x8Vy47iVJrP967A9JGqgBVL9aH71SETPx1JrGsOUVLo0c7vMCN22ytJew== dependencies: - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/helper-wasm-bytecode" "1.9.1" - "@webassemblyjs/ieee754" "1.9.1" - "@webassemblyjs/leb128" "1.9.1" - "@webassemblyjs/utf8" "1.9.1" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-buffer" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/wasm-gen" "1.11.0" -"@webassemblyjs/wasm-opt@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.1.tgz#fbdf8943a825e6dcc4cd69c3e092289fa4aec96c" - integrity sha512-gSf7I7YWVXZ5c6XqTEqkZjVs8K1kc1k57vsB6KBQscSagDNbAdxt6MwuJoMjsE1yWY1tsuL+pga268A6u+Fdkg== +"@webassemblyjs/ieee754@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.0.tgz#46975d583f9828f5d094ac210e219441c4e6f5cf" + integrity sha512-KXzOqpcYQwAfeQ6WbF6HXo+0udBNmw0iXDmEK5sFlmQdmND+tr773Ti8/5T/M6Tl/413ArSJErATd8In3B+WBA== dependencies: - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/helper-buffer" "1.9.1" - "@webassemblyjs/wasm-gen" "1.9.1" - "@webassemblyjs/wasm-parser" "1.9.1" + "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/wasm-parser@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.9.1.tgz#5e8352a246d3f605312c8e414f7990de55aaedfa" - integrity sha512-ImM4N2T1MEIond0MyE3rXvStVxEmivQrDKf/ggfh5pP6EHu3lL/YTAoSrR7shrbKNPpeKpGesW1LIK/L4kqduw== +"@webassemblyjs/leb128@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.0.tgz#f7353de1df38aa201cba9fb88b43f41f75ff403b" + integrity sha512-aqbsHa1mSQAbeeNcl38un6qVY++hh8OpCOzxhixSYgbRfNWcxJNJQwe2rezK9XEcssJbbWIkblaJRwGMS9zp+g== dependencies: - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/helper-api-error" "1.9.1" - "@webassemblyjs/helper-wasm-bytecode" "1.9.1" - "@webassemblyjs/ieee754" "1.9.1" - "@webassemblyjs/leb128" "1.9.1" - "@webassemblyjs/utf8" "1.9.1" - -"@webassemblyjs/wast-parser@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.9.1.tgz#e25ef13585c060073c1db0d6bd94340fdeee7596" - integrity sha512-2xVxejXSvj3ls/o2TR/zI6p28qsGupjHhnHL6URULQRcXmryn3w7G83jQMcT7PHqUfyle65fZtWLukfdLdE7qw== - dependencies: - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/floating-point-hex-parser" "1.9.1" - "@webassemblyjs/helper-api-error" "1.9.1" - "@webassemblyjs/helper-code-frame" "1.9.1" - "@webassemblyjs/helper-fsm" "1.9.1" "@xtuc/long" "4.2.2" -"@webassemblyjs/wast-printer@1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.9.1.tgz#b9f38e93652037d4f3f9c91584635af4191ed7c1" - integrity sha512-tDV8V15wm7mmbAH6XvQRU1X+oPGmeOzYsd6h7hlRLz6QpV4Ec/KKxM8OpLtFmQPLCreGxTp+HuxtH4pRIZyL9w== - dependencies: - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/wast-parser" "1.9.1" +"@webassemblyjs/utf8@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.0.tgz#86e48f959cf49e0e5091f069a709b862f5a2cadf" + integrity sha512-A/lclGxH6SpSLSyFowMzO/+aDEPU4hvEiooCMXQPcQFPPJaYcPQNKGOCLUySJsYJ4trbpr+Fs08n4jelkVTGVw== + +"@webassemblyjs/wasm-edit@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.0.tgz#ee4a5c9f677046a210542ae63897094c2027cb78" + integrity sha512-JHQ0damXy0G6J9ucyKVXO2j08JVJ2ntkdJlq1UTiUrIgfGMmA7Ik5VdC/L8hBK46kVJgujkBIoMtT8yVr+yVOQ== + dependencies: + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-buffer" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/helper-wasm-section" "1.11.0" + "@webassemblyjs/wasm-gen" "1.11.0" + "@webassemblyjs/wasm-opt" "1.11.0" + "@webassemblyjs/wasm-parser" "1.11.0" + "@webassemblyjs/wast-printer" "1.11.0" + +"@webassemblyjs/wasm-gen@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.0.tgz#3cdb35e70082d42a35166988dda64f24ceb97abe" + integrity sha512-BEUv1aj0WptCZ9kIS30th5ILASUnAPEvE3tVMTrItnZRT9tXCLW2LEXT8ezLw59rqPP9klh9LPmpU+WmRQmCPQ== + dependencies: + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/ieee754" "1.11.0" + "@webassemblyjs/leb128" "1.11.0" + "@webassemblyjs/utf8" "1.11.0" + +"@webassemblyjs/wasm-opt@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.0.tgz#1638ae188137f4bb031f568a413cd24d32f92978" + integrity sha512-tHUSP5F4ywyh3hZ0+fDQuWxKx3mJiPeFufg+9gwTpYp324mPCQgnuVKwzLTZVqj0duRDovnPaZqDwoyhIO8kYg== + dependencies: + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-buffer" "1.11.0" + "@webassemblyjs/wasm-gen" "1.11.0" + "@webassemblyjs/wasm-parser" "1.11.0" + +"@webassemblyjs/wasm-parser@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.0.tgz#3e680b8830d5b13d1ec86cc42f38f3d4a7700754" + integrity sha512-6L285Sgu9gphrcpDXINvm0M9BskznnzJTE7gYkjDbxET28shDqp27wpruyx3C2S/dvEwiigBwLA1cz7lNUi0kw== + dependencies: + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/helper-api-error" "1.11.0" + "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/ieee754" "1.11.0" + "@webassemblyjs/leb128" "1.11.0" + "@webassemblyjs/utf8" "1.11.0" + +"@webassemblyjs/wast-printer@1.11.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.0.tgz#680d1f6a5365d6d401974a8e949e05474e1fab7e" + integrity sha512-Fg5OX46pRdTgB7rKIUojkh9vXaVN6sGYCnEiJN1GYkb0RPwShZXp6KTDqmoMdQPKhcroOXh3fEzmkWmCYaKYhQ== + dependencies: + "@webassemblyjs/ast" "1.11.0" "@xtuc/long" "4.2.2" "@webpack-cli/migrate@^1.1.2": @@ -4210,10 +4186,10 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" -enhanced-resolve@^5.3.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.4.1.tgz#c89b0c34f17f931902ef2913a125d4b825b49b6f" - integrity sha512-4GbyIMzYktTFoRSmkbgZ1LU+RXwf4AQ8Z+rSuuh1dC8plp0PPeaWvx6+G4hh4KnUJ48VoxKbNyA1QQQIUpXjYA== +enhanced-resolve@^5.6.0: + version "5.6.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.6.0.tgz#ad19a1665f230a6e384724a30acf3f7332b2b3f0" + integrity sha512-C3GGDfFZmqUa21o10YRKbZN60DPl0HyXKXxoEnQMWso9u7KMU23L7CBHfr/rVxORddY/8YQZaU2MZ1ewTS8Pcw== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -4359,12 +4335,10 @@ escodegen@^1.14.1: optionalDependencies: source-map "~0.6.1" -eslint-config-prettier@^6.15.0: - version "6.15.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.15.0.tgz#7f93f6cb7d45a92f1537a70ecc06366e1ac6fed9" - integrity sha512-a1+kOYLR8wMGustcgAjdydMsQ2A/2ipRPwRKUmfYaSxc9ZPcrku080Ctl6zrZzZNs/U82MjSv+qKREkoq3bJaw== - dependencies: - get-stdin "^6.0.0" +eslint-config-prettier@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-7.1.0.tgz#5402eb559aa94b894effd6bddfa0b1ca051c858f" + integrity sha512-9sm5/PxaFG7qNJvJzTROMM1Bk1ozXVTKI0buKOyb0Bsr1hrwi0H/TzxF/COtf1uxikIK8SwhX7K6zg78jAzbeA== eslint-plugin-es@^3.0.0: version "3.0.1" @@ -5176,11 +5150,6 @@ get-stdin@^4.0.1: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= -get-stdin@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" - integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== - get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -6868,7 +6837,7 @@ jest-watcher@^26.6.2: jest-util "^26.6.2" string-length "^4.0.1" -jest-worker@^26.6.1, jest-worker@^26.6.2: +jest-worker@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ== @@ -8457,6 +8426,13 @@ p-limit@^3.0.2: dependencies: p-try "^2.0.0" +p-limit@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + p-locate@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" @@ -10402,19 +10378,19 @@ terminal-link@^2.0.0: ansi-escapes "^4.2.1" supports-hyperlinks "^2.0.0" -terser-webpack-plugin@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.0.3.tgz#ec60542db2421f45735c719d2e17dabfbb2e3e42" - integrity sha512-zFdGk8Lh9ZJGPxxPE6jwysOlATWB8GMW8HcfGULWA/nPal+3VdATflQvSBSLQJRCmYZnfFJl6vkRTiwJGNgPiQ== +terser-webpack-plugin@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.1.1.tgz#7effadee06f7ecfa093dbbd3e9ab23f5f3ed8673" + integrity sha512-5XNNXZiR8YO6X6KhSGXfY0QrGrCRlSwAEjIIrlRQR4W8nP69TaJUlh3bkuac6zzgspiGPfKEHcY295MMVExl5Q== dependencies: - jest-worker "^26.6.1" - p-limit "^3.0.2" + jest-worker "^26.6.2" + p-limit "^3.1.0" schema-utils "^3.0.0" serialize-javascript "^5.0.1" source-map "^0.6.1" - terser "^5.3.8" + terser "^5.5.1" -terser@^5.3.8: +terser@^5.5.1: version "5.5.1" resolved "https://registry.yarnpkg.com/terser/-/terser-5.5.1.tgz#540caa25139d6f496fdea056e414284886fb2289" integrity sha512-6VGWZNVP2KTUcltUQJ25TtNjx/XgdDsBDKGt8nN0MpydU36LmbPPcMBd2kmtZNNGVVDLg44k7GKeHHj+4zPIBQ== @@ -10717,10 +10693,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.9.7: - version "3.9.7" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" - integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== +typescript@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7" + integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg== uglify-js@^3.1.4: version "3.11.4" @@ -11097,21 +11073,20 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.12.2: - version "5.12.2" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.12.2.tgz#f79574cdb7a4ef711c5f47f3d189e045a14217e5" - integrity sha512-HiTXBGLFQiRecP5Fwrh21aaxlEUqQdDeUaninKVKX0Dtqaf+WjKCsNcv+UVftfYXrY0bnRQHnouw1x+CPqQKFQ== +webpack@^5.13.0: + version "5.13.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.13.0.tgz#275351b043bd212562f4390e903619d07d5a2fcf" + integrity sha512-NPhMEtfhSVegp1FNPkCM1MPygDm0GHwpreG10dh//0Gr0epfB0br9nlgEfxSghxJqrQ7j9XzgO91CGGLWZiHeA== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" - "@webassemblyjs/ast" "1.9.1" - "@webassemblyjs/helper-module-context" "1.9.1" - "@webassemblyjs/wasm-edit" "1.9.1" - "@webassemblyjs/wasm-parser" "1.9.1" + "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/wasm-edit" "1.11.0" + "@webassemblyjs/wasm-parser" "1.11.0" acorn "^8.0.4" browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.3.1" + enhanced-resolve "^5.6.0" eslint-scope "^5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" @@ -11123,7 +11098,7 @@ webpack@^5.12.2: pkg-dir "^5.0.0" schema-utils "^3.0.0" tapable "^2.1.1" - terser-webpack-plugin "^5.0.3" + terser-webpack-plugin "^5.1.1" watchpack "^2.0.0" webpack-sources "^2.1.1" @@ -11505,7 +11480,7 @@ yeoman-generator@^4.10.0, yeoman-generator@^4.12.0, yeoman-generator@^4.8.2: grouped-queue "^1.1.0" yeoman-environment "^2.9.5" -yeoman-test@^2.3.0, yeoman-test@^2.7.0: +yeoman-test@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/yeoman-test/-/yeoman-test-2.7.0.tgz#c7521b11d95c61d2d756dc14f985d31d1b596e9d" integrity sha512-NNH3XYaeiYO9gWdQ2B02kZuLZnbYZhGqcqrUjyS5VW/r1xOuJ9t6FIzw7uE35/yCx+U9R0kzeTbxkQ6Iwsv3DA== @@ -11519,3 +11494,8 @@ yeoman-test@^2.3.0, yeoman-test@^2.7.0: sinon "^9.0.1" yeoman-environment "^2.10.0" yeoman-generator "^4.10.0" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From cbf2e456e676f85d84b918be52cc35384de4fc46 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 13 Jan 2021 19:26:18 +0300 Subject: [PATCH 257/581] chore(deps-dev): bump webpack-dev-server from 3.11.1 to 3.11.2 (#2347) Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 3.11.1 to 3.11.2. - [Release notes](https://github.com/webpack/webpack-dev-server/releases) - [Changelog](https://github.com/webpack/webpack-dev-server/blob/v3.11.2/CHANGELOG.md) - [Commits](https://github.com/webpack/webpack-dev-server/compare/v3.11.1...v3.11.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index cf6d0d6786a..e398cda2396 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11012,9 +11012,9 @@ webpack-dev-middleware@^3.7.2: webpack-log "^2.0.0" webpack-dev-server@^3.11.1: - version "3.11.1" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.11.1.tgz#c74028bf5ba8885aaf230e48a20e8936ab8511f0" - integrity sha512-u4R3mRzZkbxQVa+MBWi2uVpB5W59H3ekZAJsQlKUTdl7Elcah2EhygTPLmeFXybQkf9i2+L0kn7ik9SnXa6ihQ== + version "3.11.2" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-3.11.2.tgz#695ebced76a4929f0d5de7fd73fafe185fe33708" + integrity sha512-A80BkuHRQfCiNtGBS1EMf2ChTUs0x+B3wGDFmOeT4rmJOHhHTCH2naNxIHhmkr0/UillP4U3yeIyv1pNp+QDLQ== dependencies: ansi-html "0.0.7" bonjour "^3.5.0" @@ -11292,12 +11292,7 @@ ws@^6.2.1: dependencies: async-limiter "~1.0.0" -ws@^7.2.3: - version "7.3.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" - integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== - -ws@^7.3.1: +ws@^7.2.3, ws@^7.3.1: version "7.4.1" resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.1.tgz#a333be02696bd0e54cea0434e21dcc8a9ac294bb" integrity sha512-pTsP8UAfhy3sk1lSk/O/s4tjD0CRwvMnzvwr4OKGX7ZvqZtUyx4KIJB5JWbkykPoc55tixMGgTNoh3k4FkNGFQ== From 3eabbbc8e9bb9974a58ea64b9383741f0a8aeec3 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 13 Jan 2021 20:00:48 +0300 Subject: [PATCH 258/581] chore: update `webpack-merge` (#2348) --- packages/webpack-cli/lib/webpack-cli.js | 4 ++-- packages/webpack-cli/package.json | 2 +- yarn.lock | 16 +++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 640c9808e33..3d5a97e8359 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -2,7 +2,7 @@ const path = require('path'); const { program } = require('commander'); const getPkg = require('./utils/package-exists'); const webpack = getPkg('webpack') ? require('webpack') : undefined; -const webpackMerge = require('webpack-merge'); +const { merge } = require('webpack-merge'); const { extensions, jsVariants } = require('interpret'); const rechoir = require('rechoir'); const { createWriteStream, existsSync } = require('fs'); @@ -921,7 +921,7 @@ class WebpackCLI { config.options = config.options.reduce((accumulator, options) => { const configPath = config.path.get(options); - const mergedOptions = webpackMerge(accumulator, options); + const mergedOptions = merge(accumulator, options); mergedConfigPaths.push(configPath); diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 94d55ab3062..5a94d4aca07 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -40,7 +40,7 @@ "interpret": "^2.2.0", "rechoir": "^0.7.0", "v8-compile-cache": "^2.2.0", - "webpack-merge": "^4.2.2" + "webpack-merge": "^5.7.3" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x" diff --git a/yarn.lock b/yarn.lock index e398cda2396..dfc633ee78b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11058,12 +11058,13 @@ webpack-log@^2.0.0: ansi-colors "^3.0.0" uuid "^3.3.2" -webpack-merge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" - integrity sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g== +webpack-merge@^5.7.3: + version "5.7.3" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.7.3.tgz#2a0754e1877a25a8bbab3d2475ca70a052708213" + integrity sha512-6/JUQv0ELQ1igjGDzHkXbVDRxkfA57Zw7PfiupdLFJYrgFqY5ZP8xxbpp2lU3EPwYx89ht5Z/aDkD40hFCm5AA== dependencies: - lodash "^4.17.15" + clone-deep "^4.0.1" + wildcard "^2.0.0" webpack-sources@^2.1.1: version "2.2.0" @@ -11177,6 +11178,11 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" +wildcard@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" + integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== + windows-release@^3.1.0: version "3.3.3" resolved "https://registry.yarnpkg.com/windows-release/-/windows-release-3.3.3.tgz#1c10027c7225743eec6b89df160d64c2e0293999" From 7314d6ca927473da2f355a7d356a943471488606 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 13 Jan 2021 22:31:00 +0300 Subject: [PATCH 259/581] feat: show multiple suggestions on unknown options (#2349) --- packages/webpack-cli/lib/utils/cli-flags.js | 21 --------------------- packages/webpack-cli/lib/webpack-cli.js | 12 ++++++------ test/unknown/unknown.test.js | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index 7a3476a64a3..8f3256aebb9 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -23,7 +23,6 @@ const builtInFlags = [ // For configs { name: 'config', - usage: '--config | --config --config ', alias: 'c', type: String, multiple: true, @@ -31,14 +30,12 @@ const builtInFlags = [ }, { name: 'config-name', - usage: '--config-name | --config-name --config-name ', type: String, multiple: true, description: 'Name of the configuration to use.', }, { name: 'merge', - usage: '--config --config --merge', alias: 'm', type: Boolean, description: "Merge two or more configurations using 'webpack-merge'.", @@ -46,7 +43,6 @@ const builtInFlags = [ // Complex configs { name: 'env', - usage: '--env | --env --env ', type: (value, previous = {}) => { // This ensures we're only splitting by the first `=` const [allKeys, val] = value.split(/=(.+)/, 2); @@ -79,7 +75,6 @@ const builtInFlags = [ // Adding more plugins { name: 'hot', - usage: '--hot', alias: 'h', type: Boolean, negative: true, @@ -88,20 +83,17 @@ const builtInFlags = [ }, { name: 'analyze', - usage: '--analyze', type: Boolean, multiple: false, description: 'It invokes webpack-bundle-analyzer plugin to get bundle information.', }, { name: 'progress', - usage: '--progress | --progress profile', type: [Boolean, String], description: 'Print compilation progress during build.', }, { name: 'prefetch', - usage: '--prefetch ', type: String, description: 'Prefetch this request.', }, @@ -109,7 +101,6 @@ const builtInFlags = [ // Output options { name: 'json', - usage: '--json | --json ', type: [String, Boolean], alias: 'j', description: 'Prints result as JSON or store it in a file.', @@ -118,21 +109,18 @@ const builtInFlags = [ // For webpack@4 { name: 'entry', - usage: '--entry | --entry --entry ', type: String, multiple: true, description: 'The entry point(s) of your application e.g. ./src/main.js.', }, { name: 'output-path', - usage: '--output-path ', alias: 'o', type: String, description: 'Output location of the file generated by webpack e.g. ./dist/.', }, { name: 'target', - usage: '--target | --target --target ', alias: 't', type: String, multiple: cli !== undefined, @@ -140,7 +128,6 @@ const builtInFlags = [ }, { name: 'devtool', - usage: '--devtool ', type: String, negative: true, alias: 'd', @@ -149,19 +136,16 @@ const builtInFlags = [ }, { name: 'mode', - usage: '--mode ', type: String, description: 'Defines the mode to pass to webpack.', }, { name: 'name', - usage: '--name', type: String, description: 'Name of the configuration. Used when loading multiple configurations.', }, { name: 'stats', - usage: '--stats | --stats ', type: [String, Boolean], negative: true, description: 'It instructs webpack on how to treat the stats e.g. verbose.', @@ -169,7 +153,6 @@ const builtInFlags = [ }, { name: 'watch', - usage: '--watch', type: Boolean, negative: true, alias: 'w', @@ -178,7 +161,6 @@ const builtInFlags = [ }, { name: 'watch-options-stdin', - usage: '--watch-options-stdin', type: Boolean, negative: true, description: 'Stop watching when stdin stream has ended.', @@ -192,14 +174,11 @@ const coreFlags = cli ? Object.entries(cli.getArguments()).map(([flag, meta]) => { if (meta.simpleType === 'string') { meta.type = String; - meta.usage = `--${flag} `; } else if (meta.simpleType === 'number') { meta.type = Number; - meta.usage = `--${flag} `; } else { meta.type = Boolean; meta.negative = !flag.endsWith('-reset'); - meta.usage = `--${flag}`; } const inBuiltIn = builtInFlags.find((builtInFlag) => builtInFlag.name === flag); diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 3d5a97e8359..1aeaf5504dd 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -316,7 +316,7 @@ class WebpackCLI { const loadCommandByName = async (commandName, allowToInstall = false) => { if (commandName === bundleCommandOptions.name || commandName === bundleCommandOptions.alias) { // Make `bundle|b [options]` command - this.makeCommand(bundleCommandOptions, this.getBuiltInOptions(), async (program) => { + await this.makeCommand(bundleCommandOptions, this.getBuiltInOptions(), async (program) => { const options = program.opts(); if (program.args.length > 0) { @@ -430,11 +430,11 @@ class WebpackCLI { process.exit(2); } - const found = command.options.find((option) => distance(name, option.long.slice(2)) < 3); - - if (found) { - logger.error(`Did you mean '--${found.name()}'?`); - } + command.options.forEach((option) => { + if (distance(name, option.long.slice(2)) < 3) { + logger.error(`Did you mean '--${option.name()}'?`); + } + }); } } } diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index 78258b22580..8f643d63186 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -144,6 +144,21 @@ describe('unknown behaviour', () => { expect(stdout).toBeFalsy(); }); + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag #3', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--output-library-auxiliary-comment-commnjs']); + + expect(exitCode).toBe(2); + expect(stderr).toContain("unknown option '--output-library-auxiliary-comment-commnjs'"); + + if (isWebpack5) { + expect(stderr).toContain("Did you mean '--output-library-auxiliary-comment-commonjs'?"); + expect(stderr).toContain("Did you mean '--output-library-auxiliary-comment-commonjs2'?"); + } + + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + it('should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "bundle" command', () => { const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--entyr', './a.js']); From 56569a762076cb2ff76f4fa3ddcc4dfc4addc17d Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 13 Jan 2021 23:42:10 +0300 Subject: [PATCH 260/581] refactor: generators (#2350) --- .../__snapshots__/init-generator.test.ts.snap | 16 ++--- .../__tests__/init-generator.test.ts | 4 +- .../__tests__/utils/plugins.test.ts | 30 ---------- packages/generators/src/index.ts | 1 - packages/generators/src/init-generator.ts | 14 ++--- .../src/utils/__tests__/npm-exists.test.ts | 16 ----- .../__tests__/npm-packages-exists.test.ts | 2 +- .../src/utils/__tests__/run-prettier.test.ts | 9 ++- packages/generators/src/utils/copy-utils.ts | 6 ++ packages/generators/src/utils/entry.ts | 10 +++- .../src/utils/global-packages-path.ts | 2 + packages/generators/src/utils/index.ts | 4 -- packages/generators/src/utils/isWebpack5.ts | 3 - .../generators/src/utils/languageSupport.ts | 31 ++++++---- .../src/utils/modify-config-helper.ts | 3 + packages/generators/src/utils/npm-exists.ts | 26 -------- .../src/utils/npm-packages-exists.ts | 28 ++++++++- packages/generators/src/utils/path-utils.ts | 1 + packages/generators/src/utils/plugins.ts | 49 --------------- packages/generators/src/utils/prop-types.ts | 5 +- packages/generators/src/utils/run-prettier.ts | 21 +++---- .../generators/src/utils/scaffold-utils.ts | 59 ++++++++----------- packages/generators/src/utils/scaffold.ts | 20 ++++--- packages/generators/src/utils/styleSupport.ts | 8 +++ packages/generators/src/utils/types/Error.ts | 4 -- packages/generators/src/utils/types/index.ts | 3 +- 26 files changed, 144 insertions(+), 231 deletions(-) delete mode 100644 packages/generators/__tests__/utils/plugins.test.ts delete mode 100644 packages/generators/src/utils/__tests__/npm-exists.test.ts delete mode 100644 packages/generators/src/utils/isWebpack5.ts delete mode 100644 packages/generators/src/utils/npm-exists.ts delete mode 100644 packages/generators/src/utils/plugins.ts delete mode 100644 packages/generators/src/utils/types/Error.ts diff --git a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap index e6646d18f0e..9a2690002dd 100644 --- a/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap +++ b/packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap @@ -20,7 +20,7 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, @@ -53,7 +53,7 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, @@ -112,7 +112,7 @@ Object { "plugins": Array [ "new webpack.ProgressPlugin()", "new MiniCssExtractPlugin({ filename:'main.[contenthash].css' })", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, @@ -148,7 +148,7 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, @@ -173,7 +173,7 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, @@ -194,7 +194,7 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, @@ -219,7 +219,7 @@ Object { }, "plugins": Array [ "new webpack.ProgressPlugin()", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, @@ -243,7 +243,7 @@ Object { "new HtmlWebpackPlugin({ template: 'index.html' })", - "new workboxPlugin.GenerateSW({ + "new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index 92ce3f6c42a..0d7ddb04d93 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -39,7 +39,7 @@ describe('init generator', () => { open: true, }); expect(config.plugins.length).toBe(2); - expect(config.plugins[1]).toContain('workboxPlugin'); + expect(config.plugins[1]).toContain('WorkboxWebpackPlugin'); // match config snapshot expect(config).toMatchSnapshot(); @@ -245,7 +245,7 @@ describe('init generator', () => { }); expect(config.plugins.length).toBe(3); expect(config.plugins[1]).toContain('HtmlWebpackPlugin'); - expect(config.plugins[2]).toContain('workboxPlugin'); + expect(config.plugins[2]).toContain('WorkboxWebpackPlugin'); // match config snapshot expect(config).toMatchSnapshot(); diff --git a/packages/generators/__tests__/utils/plugins.test.ts b/packages/generators/__tests__/utils/plugins.test.ts deleted file mode 100644 index bfe3311f9c1..00000000000 --- a/packages/generators/__tests__/utils/plugins.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { replaceAt, generatePluginName } from '../../src/utils/plugins'; - -describe('generate plugin name', () => { - it('should return webpack Standard Plugin Name for Name : extract-text-webpack-plugin', () => { - const pluginName = generatePluginName('extract-text-webpack-plugin'); - expect(pluginName).toEqual('ExtractTextWebpackPlugin'); - }); - - it('should return webpack Standard Plugin Name for Name : webpack.DefinePlugin', () => { - const pluginName = generatePluginName('webpack.DefinePlugin'); - expect(pluginName).toEqual('webpack.DefinePlugin'); - }); - - it('should return webpack Standard Plugin Name for Name : my-plugin-name-1', () => { - const pluginName = generatePluginName('my-plugin-name-1'); - expect(pluginName).toEqual('MyPluginName1'); - }); - - it('replaceAt capitalizes first letter', () => { - expect(replaceAt('mystring', 0, 'M')).toEqual('Mystring'); - }); - - it('replaceAt replaces within string', () => { - expect(replaceAt('mystring', 2, '-inserted-')).toEqual('my-inserted-tring'); - }); - - it('replaceAt replaces at end of string', () => { - expect(replaceAt('mystring', 7, '-inserted-')).toEqual('mystrin-inserted-'); - }); -}); diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index bea8e6577ba..8850c361123 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -58,7 +58,6 @@ export { addonGenerator, initGenerator }; export * from './utils/ast-utils'; export * from './utils/copy-utils'; export * from './utils/modify-config-helper'; -export * from './utils/npm-exists'; export * from './utils/npm-packages-exists'; export * from './utils/recursive-parser'; export * from './utils/resolve-packages'; diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 914676afa9b..40bb3b5db41 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -4,7 +4,7 @@ import logSymbols from 'log-symbols'; import path from 'path'; import { Confirm, Input, List } from './utils/scaffold-utils'; -import { LangType, langQuestionHandler, tooltip, generatePluginName, StylingType, styleQuestionHandler, entryQuestions } from './utils'; +import { LangType, langQuestionHandler, tooltip, StylingType, styleQuestionHandler, entryQuestions } from './utils'; import { CustomGenerator } from './types'; const { logger, getPackageManager } = utils; @@ -59,7 +59,7 @@ export default class InitGenerator extends CustomGenerator { const self: this = this; logger.log( - `\n${logSymbols.info}${blue(' INFO ')} ` + + `${logSymbols.info}${blue(' INFO ')} ` + 'For more information and a detailed description of each question, have a look at: ' + `${bold(green('https://github.com/webpack/webpack-cli/blob/master/INIT.md'))}`, ); @@ -195,17 +195,17 @@ export default class InitGenerator extends CustomGenerator { false, this.autoGenerateConfig, ); + if (useHTMLPlugin) { // Html webpack Plugin this.dependencies.push('html-webpack-plugin'); const htmlWebpackDependency = 'html-webpack-plugin'; - const htmlwebpackPlugin = generatePluginName(htmlWebpackDependency); (this.configuration.config.topScope as string[]).push( - `const ${htmlwebpackPlugin} = require('${htmlWebpackDependency}')`, + `const HtmlWebpackPlugin = require('${htmlWebpackDependency}')`, '\n', tooltip.html(), ); - (this.configuration.config.webpackOptions.plugins as string[]).push(`new ${htmlwebpackPlugin}({ + (this.configuration.config.webpackOptions.plugins as string[]).push(`new HtmlWebpackPlugin({ template: 'index.html' })`); } @@ -219,9 +219,9 @@ export default class InitGenerator extends CustomGenerator { ); // webpack Dev Server if (useWorkboxPlugin) { - this.configuration.config.topScope.push("const workboxPlugin = require('workbox-webpack-plugin');", '\n'); + this.configuration.config.topScope.push("const WorkboxWebpackPlugin = require('workbox-webpack-plugin');", '\n'); this.dependencies.push('workbox-webpack-plugin'); - (this.configuration.config.webpackOptions.plugins as string[]).push(`new workboxPlugin.GenerateSW({ + (this.configuration.config.webpackOptions.plugins as string[]).push(`new WorkboxWebpackPlugin.GenerateSW({ swDest: 'sw.js', clientsClaim: true, skipWaiting: false, diff --git a/packages/generators/src/utils/__tests__/npm-exists.test.ts b/packages/generators/src/utils/__tests__/npm-exists.test.ts deleted file mode 100644 index 5e79cf24351..00000000000 --- a/packages/generators/src/utils/__tests__/npm-exists.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; -import { npmExists } from '../npm-exists'; - -describe('npm-exists', () => { - it('should successfully existence of a published module', () => { - npmExists('webpack-scaffold-demo').then((status) => { - expect(status).toBe(true); - }); - }); - - it('should return false for the existence of a fake module', () => { - npmExists('webpack-scaffold-noop').then((status) => { - expect(status).toBe(false); - }); - }); -}); diff --git a/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts b/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts index 831e3955c2a..90a89bdf05e 100644 --- a/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts +++ b/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts @@ -1,7 +1,6 @@ import { npmPackagesExists } from '../npm-packages-exists'; import { resolvePackages } from '../resolve-packages'; -jest.mock('../npm-exists'); jest.mock('../resolve-packages'); // TS is not aware that jest changes the type of resolvePackages @@ -10,6 +9,7 @@ const mockResolvePackages = resolvePackages as jest.Mock describe('npmPackagesExists', () => { test('resolves packages when they are available on the local filesystem', () => { npmPackagesExists(['./testpkg']); + expect(mockResolvePackages.mock.calls[mockResolvePackages.mock.calls.length - 1][0]).toEqual(['./testpkg']); }); diff --git a/packages/generators/src/utils/__tests__/run-prettier.test.ts b/packages/generators/src/utils/__tests__/run-prettier.test.ts index d07e03a63ee..2f579917a79 100644 --- a/packages/generators/src/utils/__tests__/run-prettier.test.ts +++ b/packages/generators/src/utils/__tests__/run-prettier.test.ts @@ -2,7 +2,6 @@ import fs from 'fs'; import path from 'path'; -//eslint-disable-next-line node/no-extraneous-import import rimraf from 'rimraf'; import { runPrettier } from '../run-prettier'; @@ -22,19 +21,23 @@ describe('runPrettier', () => { it('should run prettier on JS string and write file', () => { runPrettier(outputFile, 'console.log("1");console.log("2");'); + expect(fs.existsSync(outputFile)).toBeTruthy(); + const data = fs.readFileSync(outputFile, 'utf8'); - expect(data).toContain("console.log('1');\n"); + expect(data).toContain('console.log("1");'); expect(consoleSpy).toHaveBeenCalledTimes(0); }); it('prettier should fail on invalid JS, with file still written', () => { runPrettier(outputFile, '"'); + expect(fs.existsSync(outputFile)).toBeTruthy(); + const data = fs.readFileSync(outputFile, 'utf8'); - expect(data).toContain('"'); + expect(data).toContain('"'); expect(consoleSpy).toHaveBeenCalledTimes(1); expect(consoleSpy.mock.calls[0][0]).toContain('WARNING: Could not apply prettier'); }); diff --git a/packages/generators/src/utils/copy-utils.ts b/packages/generators/src/utils/copy-utils.ts index 7a74374fb1b..bb582e9d0d8 100644 --- a/packages/generators/src/utils/copy-utils.ts +++ b/packages/generators/src/utils/copy-utils.ts @@ -10,8 +10,11 @@ import path from 'path'; */ export const generatorCopy = (generator, templateDir: string): ((filePath: string) => void) => (filePath: string): void => { const sourceParts = templateDir.split(path.delimiter); + sourceParts.push(...filePath.split('/')); + const targetParts = path.dirname(filePath).split('/'); + targetParts.push(path.basename(filePath, '.tpl')); generator.fs.copy(path.join(...sourceParts), generator.destinationPath(path.join.apply(null, targetParts))); @@ -32,8 +35,11 @@ export const generatorCopyTpl = (generator, templateDir: string, templateData: o filePath: string, ): void => { const sourceParts = templateDir.split(path.delimiter); + sourceParts.push(...filePath.split('/')); + const targetParts = path.dirname(filePath).split('/'); + targetParts.push(path.basename(filePath, '.tpl').slice(1)); generator.fs.copyTpl(path.join(...sourceParts), generator.destinationPath(path.join.apply(null, targetParts)), templateData); diff --git a/packages/generators/src/utils/entry.ts b/packages/generators/src/utils/entry.ts index 19bf41ac195..e8f6fe333b7 100644 --- a/packages/generators/src/utils/entry.ts +++ b/packages/generators/src/utils/entry.ts @@ -15,19 +15,22 @@ import validate from './validate'; export default async function entry(self: Generator, multiEntries: boolean, autoGenerateDefaults = false): Promise { const fixEntry = (entry: string): string => { entry = entry.trim().replace(/"|'/g, ''); + if (!entry.startsWith('./')) { entry = `./${entry}`; } + if (!entry.endsWith('.js')) { entry = entry.concat('.js'); } + entry = `'${entry}'`; + return entry; }; if (multiEntries) { const webpackEntryPoint: object = {}; - const multipleEntriesAnswer = await InputValidate( self, 'multipleEntries', @@ -36,7 +39,6 @@ export default async function entry(self: Generator, multiEntries: boolean, auto 'pageOne, pageTwo', autoGenerateDefaults, ); - const entryIdentifiers: string[] = multipleEntriesAnswer.multipleEntries.split(','); for (let i = 0; i < entryIdentifiers.length; i++) { @@ -50,11 +52,13 @@ export default async function entry(self: Generator, multiEntries: boolean, auto autoGenerateDefaults, ); const entry = fixEntry(entryResult[entryProp]); + webpackEntryPoint[entryProp] = entry; } return webpackEntryPoint; } + const singleEntryResult = await Input( self, 'singularEntry', @@ -63,8 +67,10 @@ export default async function entry(self: Generator, multiEntries: boolean, auto autoGenerateDefaults, ); let { singularEntry } = singleEntryResult; + if (singularEntry.length > 0) { singularEntry = fixEntry(singularEntry); } + return singularEntry; } diff --git a/packages/generators/src/utils/global-packages-path.ts b/packages/generators/src/utils/global-packages-path.ts index 8dde1dd5354..9b95113eb29 100644 --- a/packages/generators/src/utils/global-packages-path.ts +++ b/packages/generators/src/utils/global-packages-path.ts @@ -14,9 +14,11 @@ const { getPackageManager } = utils; */ export function getPathToGlobalPackages(): string { const manager: string = getPackageManager(); + if (manager === 'yarn') { try { const yarnDir = sync('yarn', ['global', 'dir']).stdout; + return path.join(yarnDir, 'node_modules'); } catch (e) { // Default to the global npm path below diff --git a/packages/generators/src/utils/index.ts b/packages/generators/src/utils/index.ts index 99f132a1377..17f74a181e9 100644 --- a/packages/generators/src/utils/index.ts +++ b/packages/generators/src/utils/index.ts @@ -1,6 +1,5 @@ import entryQuestions from './entry'; import langQuestionHandler, { LangType, getBabelLoader, getTypescriptLoader } from './languageSupport'; -import plugins, { replaceAt, generatePluginName } from './plugins'; import styleQuestionHandler, { StylingType, LoaderName, StyleRegex, Loader } from './styleSupport'; import tooltip from './tooltip'; import validate from './validate'; @@ -11,9 +10,6 @@ export { LangType, getBabelLoader, getTypescriptLoader, - plugins, - replaceAt, - generatePluginName, styleQuestionHandler, StylingType, LoaderName, diff --git a/packages/generators/src/utils/isWebpack5.ts b/packages/generators/src/utils/isWebpack5.ts deleted file mode 100644 index 54a92f32543..00000000000 --- a/packages/generators/src/utils/isWebpack5.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { version } from 'webpack'; - -export const isWebpack5 = (): boolean => version.startsWith('5'); diff --git a/packages/generators/src/utils/languageSupport.ts b/packages/generators/src/utils/languageSupport.ts index 38e922d012b..79daea59a53 100644 --- a/packages/generators/src/utils/languageSupport.ts +++ b/packages/generators/src/utils/languageSupport.ts @@ -9,7 +9,9 @@ const replaceExt = (path: string, ext: string): string => path.substr(0, path.la function updateEntryExt(self: CustomGenerator, newExt: string): void { const jsEntryOption = self.entryOption; + let tsEntryOption = {}; + if (typeof jsEntryOption === 'string') { tsEntryOption = replaceExt(jsEntryOption, newExt); } else if (typeof jsEntryOption === 'object') { @@ -17,6 +19,7 @@ function updateEntryExt(self: CustomGenerator, newExt: string): void { tsEntryOption[entry] = replaceExt(jsEntryOption[entry], newExt); }); } + self.configuration.config.webpackOptions.entry = tsEntryOption; } @@ -25,15 +28,23 @@ const getFolder = (path: string): string => path.replace("'./", '').split('/').s function getEntryFolders(self: CustomGenerator): string[] { const entryOption = self.entryOption; const entryFolders = {}; + if (typeof entryOption === 'string') { const folder = getFolder(entryOption); - if (folder.length > 0) entryFolders[folder] = true; + + if (folder.length > 0) { + entryFolders[folder] = true; + } } else if (typeof entryOption === 'object') { Object.keys(entryOption).forEach((entry: string): void => { const folder = getFolder(entryOption[entry]); - if (folder.length > 0) entryFolders[folder] = true; + + if (folder.length > 0) { + entryFolders[folder] = true; + } }); } + return Object.keys(entryFolders); } @@ -45,11 +56,8 @@ function getEntryFolders(self: CustomGenerator): string[] { */ export function getBabelLoader(includeFolders: string[]): Rule { const include = includeFolders.map((folder: string): string => `path.resolve(__dirname, '${folder}')`); - return { - test: '/\\.(js|jsx)$/', - include, - loader: "'babel-loader'", - }; + + return { test: '/\\.(js|jsx)$/', include, loader: "'babel-loader'" }; } /** @@ -60,16 +68,13 @@ 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)$/', - loader: "'ts-loader'", - include, - exclude: ['/node_modules/'], - }; + + return { test: '/\\.(ts|tsx)$/', loader: "'ts-loader'", include, exclude: ['/node_modules/'] }; } export default function language(self: CustomGenerator, langType: string): void { const entryFolders = getEntryFolders(self); + switch (langType) { case LangType.ES6: self.dependencies.push('babel-loader', '@babel/core', '@babel/preset-env'); diff --git a/packages/generators/src/utils/modify-config-helper.ts b/packages/generators/src/utils/modify-config-helper.ts index e2dc8e71326..09f9d23f8b4 100644 --- a/packages/generators/src/utils/modify-config-helper.ts +++ b/packages/generators/src/utils/modify-config-helper.ts @@ -93,8 +93,10 @@ export function modifyHelperUtil( let finalConfig: WebpackScaffoldObject = { config: {}, }; + try { const confPath = path.resolve(generationPath, '.yo-rc.json'); + configModule = require(confPath); } catch (err) { logger.error('Could not find a yeoman configuration file (.yo-rc.json).'); @@ -104,6 +106,7 @@ export function modifyHelperUtil( Error.stackTraceLimit = 0; process.exitCode = 2; } + try { // the configuration stored in .yo-rc.json should already be in the correct // WebpackScaffoldObject format diff --git a/packages/generators/src/utils/npm-exists.ts b/packages/generators/src/utils/npm-exists.ts deleted file mode 100644 index ab1a482c8a9..00000000000 --- a/packages/generators/src/utils/npm-exists.ts +++ /dev/null @@ -1,26 +0,0 @@ -import got from 'got'; - -// TODO: to understand the type -// eslint-disable-next-line -const constant = (value: boolean) => (res): boolean | PromiseLike => value; - -/** - * - * Checks if the given dependency/module is registered on npm - * - * @param {String} moduleName - The dependency to be checked - * @returns {Promise} constant - Returns either true or false, - * based on if it exists or not - */ - -// TODO: figure out the correct type here -// eslint-disable-next-line -export function npmExists(moduleName: string): Promise { - const hostname = 'https://www.npmjs.org'; - const pkgUrl = `${hostname}/package/${moduleName}`; - return got(pkgUrl, { - method: 'HEAD', - }) - .then(constant(true)) - .catch(constant(false)); -} diff --git a/packages/generators/src/utils/npm-packages-exists.ts b/packages/generators/src/utils/npm-packages-exists.ts index 2098d3e0108..bc79ea156de 100644 --- a/packages/generators/src/utils/npm-packages-exists.ts +++ b/packages/generators/src/utils/npm-packages-exists.ts @@ -1,12 +1,38 @@ import { resolve } from 'path'; import { existsSync } from 'fs'; import { red, bold } from 'colorette'; -import { npmExists } from './npm-exists'; import { isLocalPath } from './path-utils'; import { resolvePackages } from './resolve-packages'; import { getPathToGlobalPackages } from './global-packages-path'; const WEBPACK_SCAFFOLD_PREFIX = 'webpack-scaffold'; +import got from 'got'; + +// TODO: to understand the type +// eslint-disable-next-line +const constant = (value: boolean) => (res): boolean | PromiseLike => value; + +/** + * + * Checks if the given dependency/module is registered on npm + * + * @param {String} moduleName - The dependency to be checked + * @returns {Promise} constant - Returns either true or false, + * based on if it exists or not + */ + +// TODO: figure out the correct type here +// eslint-disable-next-line +export function npmExists(moduleName: string): Promise { + const hostname = 'https://www.npmjs.org'; + const pkgUrl = `${hostname}/package/${moduleName}`; + return got(pkgUrl, { + method: 'HEAD', + }) + .then(constant(true)) + .catch(constant(false)); +} + /** * * Loops through an array and checks if a package is registered diff --git a/packages/generators/src/utils/path-utils.ts b/packages/generators/src/utils/path-utils.ts index 73e8d4aa207..4e4fa6913fb 100644 --- a/packages/generators/src/utils/path-utils.ts +++ b/packages/generators/src/utils/path-utils.ts @@ -26,5 +26,6 @@ export function isLocalPath(str: string): boolean { export function findProjectRoot(cwd = process.cwd()): string { const rootFilePath = findup('package.json', { cwd }); const projectRoot = path.dirname(rootFilePath); + return projectRoot; } diff --git a/packages/generators/src/utils/plugins.ts b/packages/generators/src/utils/plugins.ts deleted file mode 100644 index 4ca6d0c1030..00000000000 --- a/packages/generators/src/utils/plugins.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * Callable function with the initial plugins - * - * @returns {Function} An function that returns an array - * that consists of terser-webpack-plugin - */ - -export default function (): string[] { - return ['new TerserPlugin()']; -} - -/** - * - * Replaces the string with a substring at the given index - * https://gist.github.com/efenacigiray/9367920 - * - * @param {String} str - string to be modified - * @param {Number} index - index to replace from - * @param {String} replace - string to replace starting from index - * - * @returns {String} string - The newly mutated string - * - */ - -export const replaceAt = (str: string, index: number, replace: string): string => { - return str.substring(0, index) + replace + str.substring(index + 1); -}; - -/** - * - * Generate a webpack standard webpack plugin name from the plugin name from the Answer - * - * @param {String} rawPluginName - plugin name from answer - * - * @returns {String} string - the webpack standard plugin name - * - */ - -export const generatePluginName = (rawPluginName: string): string => { - const myPluginNameArray = rawPluginName.split('-'); - const pluginArrLength: number = myPluginNameArray.length; - // ignore plugin names without hyphens to allow for cases - // such as webpack.DefinePlugin, which should not be capitalized - for (let i = 0; i < pluginArrLength && pluginArrLength > 1; i++) { - myPluginNameArray[i] = replaceAt(myPluginNameArray[i], 0, myPluginNameArray[i].charAt(0).toUpperCase()); - } - return myPluginNameArray.join(''); -}; diff --git a/packages/generators/src/utils/prop-types.ts b/packages/generators/src/utils/prop-types.ts index ac0a8005f25..03452b76394 100644 --- a/packages/generators/src/utils/prop-types.ts +++ b/packages/generators/src/utils/prop-types.ts @@ -1,8 +1,7 @@ -import { isWebpack5 } from './isWebpack5'; -import { config } from 'webpack'; +import { config, version } from 'webpack'; let configKeys; -if (isWebpack5()) { +if (version.startsWith('5')) { configKeys = Object.keys(config.getNormalizedWebpackOptions({})); } else { configKeys = [ diff --git a/packages/generators/src/utils/run-prettier.ts b/packages/generators/src/utils/run-prettier.ts index d2612d04849..a4c8b06b0fd 100644 --- a/packages/generators/src/utils/run-prettier.ts +++ b/packages/generators/src/utils/run-prettier.ts @@ -7,15 +7,16 @@ const { logger } = utils; * * Runs prettier and later prints the output configuration * - * @param {String} outputPath - Path to write the config to - * @param {Node} source - AST to write at the given path - * @returns {Void} Writes a file at given location + * @param {string} outputPath - Path to write the config to + * @param {string} source - AST to write at the given path + * @returns {void} Writes a file at given location */ export function runPrettier(outputPath: string, source: string): void { let prettySource: string = source; let prettier; + try { // eslint-disable-next-line node/no-extraneous-require prettier = require('prettier'); @@ -23,20 +24,16 @@ export function runPrettier(outputPath: string, source: string): void { logger.warn( "File is not properly formatted because you don't have prettier installed, you can either install it or format it manually", ); + return fs.writeFileSync(outputPath, source, 'utf8'); } try { - prettySource = prettier.format(source, { - filepath: outputPath, - parser: 'babel', - singleQuote: true, - tabWidth: 1, - useTabs: true, - }); - } catch (err) { + prettySource = prettier.format(source, { filepath: outputPath, parser: 'babel' }); + } catch (error) { logger.warn(`\nWARNING: Could not apply prettier to ${outputPath} due to validation error, but the file has been created`); prettySource = source; } - return fs.writeFileSync(outputPath, prettySource, 'utf8'); + + fs.writeFileSync(outputPath, prettySource, 'utf8'); } diff --git a/packages/generators/src/utils/scaffold-utils.ts b/packages/generators/src/utils/scaffold-utils.ts index e4611ec066b..f8a153909f5 100644 --- a/packages/generators/src/utils/scaffold-utils.ts +++ b/packages/generators/src/utils/scaffold-utils.ts @@ -13,29 +13,19 @@ export function List( defaultChoice?: string, skip = false, ): CustomGeneratorStringPrompt { - if (skip) return { [name]: defaultChoice }; + if (skip) { + return { [name]: defaultChoice }; + } - return self.prompt([ - { - choices, - message, - name, - type: 'list', - default: defaultChoice, - }, - ]); + return self.prompt([{ choices, message, name, type: 'list', default: defaultChoice }]); } export function Input(self: Generator, name: string, message: string, defaultChoice?: string, skip = false): CustomGeneratorStringPrompt { - if (skip) return { [name]: defaultChoice }; - return self.prompt([ - { - default: defaultChoice, - message, - name, - type: 'input', - }, - ]); + if (skip) { + return { [name]: defaultChoice }; + } + + return self.prompt([{ default: defaultChoice, message, name, type: 'input' }]); } export function InputValidate( @@ -46,26 +36,23 @@ export function InputValidate( defaultChoice?: string, skip = false, ): object | any { - if (skip) return { [name]: defaultChoice }; - const input: Generator.Question = { - message, - name, - type: 'input', - validate: cb, - }; - if (defaultChoice) input.default = defaultChoice; + if (skip) { + return { [name]: defaultChoice }; + } + + const input: Generator.Question = { message, name, type: 'input', validate: cb }; + + if (defaultChoice) { + input.default = defaultChoice; + } + return self.prompt([input]); } export function Confirm(self: Generator, name: string, message: string, defaultChoice = true, skip = false): CustomGeneratorBoolPrompt { - if (skip) return { [name]: defaultChoice }; + if (skip) { + return { [name]: defaultChoice }; + } - return self.prompt([ - { - default: defaultChoice, - message, - name, - type: 'confirm', - }, - ]); + return self.prompt([{ default: defaultChoice, message, name, type: 'confirm' }]); } diff --git a/packages/generators/src/utils/scaffold.ts b/packages/generators/src/utils/scaffold.ts index ebeb3b2a0d9..f7fed7cc34d 100644 --- a/packages/generators/src/utils/scaffold.ts +++ b/packages/generators/src/utils/scaffold.ts @@ -1,9 +1,8 @@ import { green } from 'colorette'; -import j from 'jscodeshift'; +import j, { Collection } from 'jscodeshift'; import pEachSeries = require('p-each-series'); import path from 'path'; import { findProjectRoot } from './path-utils'; -import { Error } from './types'; import { Config, TransformConfig } from './types'; import { PROP_TYPES } from './prop-types'; import { recursiveTransform } from './recursive-parser'; @@ -23,7 +22,10 @@ const { logger, getPackageManager } = utils; */ function mapOptionsToTransform(config: Config): string[] { - if (!config.webpackOptions) return []; + if (!config.webpackOptions) { + return []; + } + return Object.keys(config.webpackOptions).filter((k: string): boolean => PROP_TYPES.has(k)); } @@ -43,9 +45,10 @@ export function runTransform(transformConfig: TransformConfig, action: string, g if (p == 'usingDefaults') { return generateConfig; } + return p !== 'configFile' && p !== 'configPath'; }); - const initActionNotDefined = action && action !== 'init' ? true : false; + const initActionNotDefined = action && action !== 'init'; webpackConfig.forEach( (scaffoldPiece: string): Promise => { @@ -61,8 +64,8 @@ export function runTransform(transformConfig: TransformConfig, action: string, g transformations.push('merge'); } - const ast: Node = j(initActionNotDefined ? transformConfig.configFile : 'module.exports = {}'); - + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const ast: Collection = j(initActionNotDefined ? transformConfig.configFile : 'module.exports = {}'); const transformAction: string = action || null; return pEachSeries(transformations, (f: string): boolean | Node => { @@ -99,10 +102,11 @@ export function runTransform(transformConfig: TransformConfig, action: string, g let successMessage: string = green('Congratulations! Your new webpack configuration file has been created!\n\n') + - `You can now run ${green(runCommand)} to bundle your application!\n\n`; + `You can now run '${green(runCommand)}' to bundle your application!\n`; if (initActionNotDefined && transformConfig.config.item) { successMessage = green(`Congratulations! ${transformConfig.config.item} has been ${action}ed!\n`); } - logger.log(`\n${successMessage}`); + + logger.log(`${successMessage}`); } diff --git a/packages/generators/src/utils/styleSupport.ts b/packages/generators/src/utils/styleSupport.ts index 2ba0d5219c7..0e4219b8dc0 100644 --- a/packages/generators/src/utils/styleSupport.ts +++ b/packages/generators/src/utils/styleSupport.ts @@ -47,12 +47,14 @@ export default function style( regExpForStyles = StyleRegex.CSS; self.dependencies.push(LoaderName.CSS); + if (!self.isProd) { self.dependencies.push(LoaderName.STYLE); ExtractUseProps.push({ loader: `"${LoaderName.STYLE}"`, }); } + ExtractUseProps.push({ loader: `"${LoaderName.CSS}"`, options: { @@ -65,12 +67,14 @@ export default function style( regExpForStyles = StyleRegex.SASS; self.dependencies.push('node-sass', LoaderName.SASS, LoaderName.CSS); + if (!self.isProd) { self.dependencies.push(LoaderName.STYLE); ExtractUseProps.push({ loader: `"${LoaderName.STYLE}"`, }); } + ExtractUseProps.push( { loader: `"${LoaderName.CSS}"`, @@ -91,12 +95,14 @@ export default function style( regExpForStyles = StyleRegex.LESS; self.dependencies.push('less', LoaderName.LESS, LoaderName.CSS); + if (!self.isProd) { self.dependencies.push(LoaderName.STYLE); ExtractUseProps.push({ loader: `"${LoaderName.STYLE}"`, }); } + ExtractUseProps.push( { loader: `"${LoaderName.CSS}"`, @@ -124,12 +130,14 @@ export default function style( ); self.dependencies.push('precss', 'autoprefixer', LoaderName.CSS, LoaderName.POSTCSS); + if (!self.isProd) { self.dependencies.push(LoaderName.STYLE); ExtractUseProps.push({ loader: `"${LoaderName.STYLE}"`, }); } + ExtractUseProps.push( { loader: `"${LoaderName.CSS}"`, diff --git a/packages/generators/src/utils/types/Error.ts b/packages/generators/src/utils/types/Error.ts deleted file mode 100644 index d888e07886e..00000000000 --- a/packages/generators/src/utils/types/Error.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Error { - stack?: string; - message: string; -} diff --git a/packages/generators/src/utils/types/index.ts b/packages/generators/src/utils/types/index.ts index 11023920c9e..f4dff9e0fc3 100644 --- a/packages/generators/src/utils/types/index.ts +++ b/packages/generators/src/utils/types/index.ts @@ -1,5 +1,4 @@ -import { Error } from './Error'; import { Config, TransformConfig } from './Config'; import { Node, JSCodeshift, valueType } from './NodePath'; -export { Error, Config, Node, TransformConfig, JSCodeshift, valueType }; +export { Config, Node, TransformConfig, JSCodeshift, valueType }; From 87b51c31ce61dfd79f9168811ed291d8feffe516 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:26:53 +0300 Subject: [PATCH 261/581] chore(deps-dev): bump webpack from 5.13.0 to 5.14.0 (#2352) Bumps [webpack](https://github.com/webpack/webpack) from 5.13.0 to 5.14.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.13.0...v5.14.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/yarn.lock b/yarn.lock index dfc633ee78b..6ceacf1fb93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4186,10 +4186,10 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" -enhanced-resolve@^5.6.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.6.0.tgz#ad19a1665f230a6e384724a30acf3f7332b2b3f0" - integrity sha512-C3GGDfFZmqUa21o10YRKbZN60DPl0HyXKXxoEnQMWso9u7KMU23L7CBHfr/rVxORddY/8YQZaU2MZ1ewTS8Pcw== +enhanced-resolve@^5.7.0: + version "5.7.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.7.0.tgz#525c5d856680fbd5052de453ac83e32049958b5c" + integrity sha512-6njwt/NsZFUKhM6j9U8hzVyD4E4r0x7NQzhTCbcWOJ0IQjNSAoalWmb0AE51Wn+fwan5qVESWi7t2ToBxs9vrw== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -4277,6 +4277,11 @@ es-abstract@^1.18.0-next.0, es-abstract@^1.18.0-next.1: string.prototype.trimend "^1.0.1" string.prototype.trimstart "^1.0.1" +es-module-lexer@^0.3.26: + version "0.3.26" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.3.26.tgz#7b507044e97d5b03b01d4392c74ffeb9c177a83b" + integrity sha512-Va0Q/xqtrss45hWzP8CZJwzGSZJjDM5/MJRE3IXXnUCcVLElR9BRaE9F62BopysASyc4nM3uwhSW7FFB9nlWAA== + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -7655,24 +7660,12 @@ micromatch@^4.0.2: braces "^3.0.1" picomatch "^2.0.5" -mime-db@1.44.0: - version "1.44.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" - integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== - mime-db@1.45.0, "mime-db@>= 1.43.0 < 2": version "1.45.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.45.0.tgz#cceeda21ccd7c3a745eba2decd55d4b73e7879ea" integrity sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w== -mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24: - version "2.1.27" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" - integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== - dependencies: - mime-db "1.44.0" - -mime-types@^2.1.27: +mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24: version "2.1.28" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.28.tgz#1160c4757eab2c5363888e005273ecf79d2a0ecd" integrity sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ== @@ -11075,9 +11068,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.13.0: - version "5.13.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.13.0.tgz#275351b043bd212562f4390e903619d07d5a2fcf" - integrity sha512-NPhMEtfhSVegp1FNPkCM1MPygDm0GHwpreG10dh//0Gr0epfB0br9nlgEfxSghxJqrQ7j9XzgO91CGGLWZiHeA== + version "5.14.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.14.0.tgz#cdfe9286d14ddc2bb348afabc1d910d166f3c47f" + integrity sha512-PFtfqXIKT6EG+k4L7d9whUPacN2XvxlUMc8NAQvN+sF9G8xPQqrCDGDiXbAdyGNz+/OP6ioxnUKybBBZ1kp/2A== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" @@ -11087,7 +11080,8 @@ webpack@^5.13.0: acorn "^8.0.4" browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.6.0" + enhanced-resolve "^5.7.0" + es-module-lexer "^0.3.26" eslint-scope "^5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" From 7590f66663ce701d52d9276c3adf9dbdfd1a0fa4 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 14 Jan 2021 14:27:49 +0300 Subject: [PATCH 262/581] feat: added `build` command (aliases - 'bundle' and 'b') --- OPTIONS.md | 8 +- packages/webpack-cli/lib/webpack-cli.js | 103 ++++++++++-------- test/{bundle => build}/basic/basic.test.js | 16 ++- test/{bundle => build}/basic/src/index.js | 0 .../build-variable/build-variable.test.js} | 0 .../build-variable}/src/index.js | 0 test/build/build-variable/webpack.config.js | 24 ++++ .../bundle-variable/bundle-variable.test.js | 13 +++ test/build/bundle-variable/src/index.js | 1 + .../bundle-variable/webpack.config.js | 0 .../function-with-argv.test.js | 3 +- test/help/help.test.js | 10 +- test/version/version.test.js | 10 ++ 13 files changed, 131 insertions(+), 57 deletions(-) rename test/{bundle => build}/basic/basic.test.js (75%) rename test/{bundle => build}/basic/src/index.js (100%) rename test/{bundle/bundle-variable/bundle-variable.test.js => build/build-variable/build-variable.test.js} (100%) rename test/{bundle/bundle-variable => build/build-variable}/src/index.js (100%) create mode 100644 test/build/build-variable/webpack.config.js create mode 100644 test/build/bundle-variable/bundle-variable.test.js create mode 100644 test/build/bundle-variable/src/index.js rename test/{bundle => build}/bundle-variable/webpack.config.js (100%) diff --git a/OPTIONS.md b/OPTIONS.md index 374b7cc3141..cfdd161bd68 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -1,8 +1,10 @@ ``` Usage: webpack [options] -Alternative usage: webpack bundle [options] Alternative usage: webpack --config [options] -Alternative usage: webpack bundle --config [options] +Alternative usage: webpack build [options] +Alternative usage: webpack bundle [options] +Alternative usage: webpack b [options] +Alternative usage: webpack build --config [options] The build tool for modern web applications. @@ -697,7 +699,7 @@ Global options: -h, --help [verbose] Display help for commands and options. Commands: - bundle|b [options] Run webpack (default command, can be omitted). + build|bundle|b [options] Run webpack (default command, can be omitted). version|v Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. help|h Display help for commands and options. serve|s [options] Run the webpack dev server. diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 1aeaf5504dd..605311f7c7d 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -31,7 +31,7 @@ class WebpackCLI { async makeCommand(commandOptions, options, action) { const alreadyLoaded = this.program.commands.find( - (command) => command.name() === commandOptions.name || command.alias() === commandOptions.alias, + (command) => command.name() === commandOptions.name || command.aliases().includes(commandOptions.alias), ); if (alreadyLoaded) { @@ -229,9 +229,9 @@ class WebpackCLI { async run(args, parseOptions) { // Built-in internal commands - const bundleCommandOptions = { - name: 'bundle', - alias: 'b', + const buildCommandOptions = { + name: 'build', + alias: ['bundle', 'b'], description: 'Run webpack (default command, can be omitted).', usage: '[options]', }; @@ -286,8 +286,25 @@ class WebpackCLI { }, ]; - const knownCommands = [bundleCommandOptions, versionCommandOptions, helpCommandOptions, ...externalBuiltInCommandsInfo]; - const isKnownCommand = (name) => knownCommands.find((command) => command.name === name || command.alias === name); + const knownCommands = [buildCommandOptions, versionCommandOptions, helpCommandOptions, ...externalBuiltInCommandsInfo]; + const isKnownCommand = (name) => + knownCommands.find( + (command) => + command.name === name || (Array.isArray(command.alias) ? command.alias.includes(name) : command.alias === name), + ); + const isBuildCommand = (name) => + buildCommandOptions.name === name || + (Array.isArray(buildCommandOptions.alias) ? buildCommandOptions.alias.includes(name) : buildCommandOptions.alias === name); + const isHelpCommand = (name) => + helpCommandOptions.name === name || + (Array.isArray(helpCommandOptions.alias) ? helpCommandOptions.alias.includes(name) : helpCommandOptions.alias === name); + const isVersionCommand = (name) => + versionCommandOptions.name === name || + (Array.isArray(versionCommandOptions.alias) + ? versionCommandOptions.alias.includes(name) + : versionCommandOptions.alias === name); + const findCommandByName = (name) => + this.program.commands.find((command) => name === command.name() || command.alias().includes(name)); const getCommandNameAndOptions = (args) => { let commandName; @@ -311,16 +328,15 @@ class WebpackCLI { const isDefault = typeof commandName === 'undefined'; - return { commandName: isDefault ? bundleCommandOptions.name : commandName, options, isDefault }; + return { commandName: isDefault ? buildCommandOptions.name : commandName, options, isDefault }; }; const loadCommandByName = async (commandName, allowToInstall = false) => { - if (commandName === bundleCommandOptions.name || commandName === bundleCommandOptions.alias) { - // Make `bundle|b [options]` command - await this.makeCommand(bundleCommandOptions, this.getBuiltInOptions(), async (program) => { + if (isBuildCommand(commandName)) { + await this.makeCommand(buildCommandOptions, this.getBuiltInOptions(), async (program) => { const options = program.opts(); if (program.args.length > 0) { - const possibleCommands = [].concat([bundleCommandOptions.name]).concat(program.args); + const possibleCommands = [].concat([buildCommandOptions.name]).concat(program.args); logger.error('Running multiple commands at the same time is not possible'); logger.error(`Found commands: ${possibleCommands.map((item) => `'${item}'`).join(', ')}`); @@ -330,16 +346,19 @@ class WebpackCLI { await this.bundleCommand(options); }); - } else if (commandName === helpCommandOptions.name || commandName === helpCommandOptions.alias) { + } else if (isHelpCommand(commandName)) { // Stub for the `help` command this.makeCommand(helpCommandOptions, [], () => {}); - } else if (commandName === versionCommandOptions.name || commandName === helpCommandOptions.alias) { + } else if (isVersionCommand(commandName)) { // Stub for the `help` command this.makeCommand(versionCommandOptions, [], () => {}); } else { const builtInExternalCommandInfo = externalBuiltInCommandsInfo.find( (externalBuiltInCommandInfo) => - externalBuiltInCommandInfo.name === commandName || externalBuiltInCommandInfo.alias === commandName, + externalBuiltInCommandInfo.name === commandName || + (typeof Array.isArray(externalBuiltInCommandInfo.alias) + ? externalBuiltInCommandInfo.alias.includes(commandName) + : externalBuiltInCommandInfo.alias === commandName), ); let pkg; @@ -420,9 +439,7 @@ class WebpackCLI { const { commandName } = getCommandNameAndOptions(this.program.args); if (commandName) { - const command = this.program.commands.find( - (command) => command.name() === commandName || command.alias() === commandName, - ); + const command = findCommandByName(commandName); if (!command) { logger.error(`Can't find and load command '${commandName}'`); @@ -470,13 +487,7 @@ class WebpackCLI { const outputVersion = async (options) => { // Filter `bundle`, `version` and `help` commands const possibleCommandNames = options.filter( - (options) => - options !== bundleCommandOptions.name && - options !== bundleCommandOptions.alias && - options !== versionCommandOptions.name && - options !== versionCommandOptions.alias && - options !== helpCommandOptions.name && - options !== helpCommandOptions.alias, + (option) => !isBuildCommand(option) && !isVersionCommand(option) && !isHelpCommand(option), ); possibleCommandNames.forEach((possibleCommandName) => { @@ -495,9 +506,7 @@ class WebpackCLI { await Promise.all(possibleCommandNames.map((possibleCommand) => loadCommandByName(possibleCommand))); for (const possibleCommandName of possibleCommandNames) { - const foundCommand = this.program.commands.find( - (command) => command.name() === possibleCommandName || command.alias() === possibleCommandName, - ); + const foundCommand = findCommandByName(possibleCommandName); if (!foundCommand) { logger.error(`Unknown command '${possibleCommandName}'`); @@ -563,9 +572,7 @@ class WebpackCLI { }), ); - const bundleCommand = this.program.commands.find( - (command) => command.name() === bundleCommandOptions.name || command.alias() === bundleCommandOptions.alias, - ); + const bundleCommand = findCommandByName(buildCommandOptions.name); if (!isVerbose) { hideVerboseOptions(bundleCommand); @@ -574,10 +581,10 @@ class WebpackCLI { let helpInformation = bundleCommand .helpInformation() .trimRight() - .replace(bundleCommandOptions.description, 'The build tool for modern web applications.') + .replace(buildCommandOptions.description, 'The build tool for modern web applications.') .replace( /Usage:.+/, - 'Usage: webpack [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack bundle --config [options]', + 'Usage: webpack [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack build [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack b [options]\nAlternative usage: webpack build --config [options]', ); logger.raw(helpInformation); @@ -598,7 +605,7 @@ class WebpackCLI { await loadCommandByName(name); - const command = this.program.commands.find((command) => command.name() === name || command.alias() === name); + const command = findCommandByName(name); if (!command) { logger.error(`Can't find and load command '${name}'`); @@ -612,30 +619,36 @@ class WebpackCLI { let helpInformation = command.helpInformation().trimRight(); - if (name === bundleCommandOptions.name || name === bundleCommandOptions.alias) { + if (isBuildCommand(name)) { helpInformation = helpInformation - .replace(bundleCommandOptions.description, 'The build tool for modern web applications.') + .replace(buildCommandOptions.description, 'The build tool for modern web applications.') .replace( /Usage:.+/, - 'Usage: webpack [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack bundle --config [options]', + 'Usage: webpack [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack build [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack b [options]\nAlternative usage: webpack build --config [options]', ); } logger.raw(helpInformation); } - const globalOptions = program.helpInformation().match(/Options:\n(?.+)\nCommands:\n/s); + const programHelpInformation = program.helpInformation(); + const globalOptions = programHelpInformation.match(/Options:\n(?.+)\nCommands:\n/s); if (globalOptions && globalOptions.groups.globalOptions) { logger.raw('\nGlobal options:'); logger.raw(globalOptions.groups.globalOptions.trimRight()); } - if (isGlobal) { - const globalCommands = program.helpInformation().match(/Commands:\n(?.+)/s); + const globalCommands = programHelpInformation.match(/Commands:\n(?.+)/s); + if (isGlobal && globalCommands.groups.globalCommands) { logger.raw('\nCommands:'); - logger.raw(globalCommands.groups.globalCommands.trimRight()); + logger.raw( + globalCommands.groups.globalCommands + .trimRight() + // `commander` doesn't support multiple alias in help + .replace('build|bundle [options] ', 'build|bundle|b [options]'), + ); } logger.raw("\nTo see list of all supported commands and options run 'webpack --help=verbose'.\n"); @@ -665,7 +678,7 @@ class WebpackCLI { const opts = program.opts(); - if (opts.help || commandName === helpCommandOptions.name || commandName === helpCommandOptions.alias) { + if (opts.help || isHelpCommand(commandName)) { let isVerbose = false; if (opts.help) { @@ -686,7 +699,7 @@ class WebpackCLI { await outputHelp(optionsForHelp, isVerbose, program); } - if (opts.version || commandName === versionCommandOptions.name || commandName === versionCommandOptions.alias) { + if (opts.version || isVersionCommand(commandName)) { const optionsForVersion = [].concat(opts.version ? [commandName] : []).concat(options); await outputVersion(optionsForVersion, program); @@ -700,7 +713,9 @@ class WebpackCLI { const found = knownCommands.find((commandOptions) => distance(commandName, commandOptions.name) < 3); if (found) { - logger.error(`Did you mean '${found.name}' (alias '${found.alias}')?`); + logger.error( + `Did you mean '${found.name}' (alias '${Array.isArray(found.alias) ? found.alias.join(', ') : found.alias}')?`, + ); } logger.error("Run 'webpack --help' to see available commands and options"); @@ -1313,7 +1328,7 @@ class WebpackCLI { } }; - options.argv = { ...options, env: { WEBPACK_BUNDLE: true, ...options.env } }; + options.argv = { ...options, env: { WEBPACK_BUNDLE: true, WEBPACK_BUILD: true, ...options.env } }; compiler = await this.createCompiler(options, callback); diff --git a/test/bundle/basic/basic.test.js b/test/build/basic/basic.test.js similarity index 75% rename from test/bundle/basic/basic.test.js rename to test/build/basic/basic.test.js index 595d09863f8..cd5a3137ed1 100644 --- a/test/bundle/basic/basic.test.js +++ b/test/build/basic/basic.test.js @@ -4,14 +4,14 @@ const { run } = require('../../utils/test-utils'); describe('bundle command', () => { it('should work', async () => { - const { exitCode, stderr, stdout } = run(__dirname, ['bundle'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['build'], false); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); - it('should work with alias', async () => { + it('should work with the "b" alias', async () => { const { exitCode, stderr, stdout } = run(__dirname, ['b'], false); expect(exitCode).toBe(0); @@ -19,12 +19,20 @@ describe('bundle command', () => { expect(stdout).toBeTruthy(); }); + it('should work with "bundle" alias', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + it('should log error with multi commands', async () => { const { exitCode, stderr, stdout } = run(__dirname, ['bundle', 'info'], false); expect(exitCode).toBe(2); expect(stderr).toContain('Running multiple commands at the same time is not possible'); - expect(stderr).toContain("Found commands: 'bundle', 'info'"); + expect(stderr).toContain("Found commands: 'build', 'info'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -34,7 +42,7 @@ describe('bundle command', () => { expect(exitCode).toBe(2); expect(stderr).toContain('Running multiple commands at the same time is not possible'); - expect(stderr).toContain("Found commands: 'bundle', 'i'"); + expect(stderr).toContain("Found commands: 'build', 'i'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); diff --git a/test/bundle/basic/src/index.js b/test/build/basic/src/index.js similarity index 100% rename from test/bundle/basic/src/index.js rename to test/build/basic/src/index.js diff --git a/test/bundle/bundle-variable/bundle-variable.test.js b/test/build/build-variable/build-variable.test.js similarity index 100% rename from test/bundle/bundle-variable/bundle-variable.test.js rename to test/build/build-variable/build-variable.test.js diff --git a/test/bundle/bundle-variable/src/index.js b/test/build/build-variable/src/index.js similarity index 100% rename from test/bundle/bundle-variable/src/index.js rename to test/build/build-variable/src/index.js diff --git a/test/build/build-variable/webpack.config.js b/test/build/build-variable/webpack.config.js new file mode 100644 index 00000000000..a0ed78dbfb5 --- /dev/null +++ b/test/build/build-variable/webpack.config.js @@ -0,0 +1,24 @@ +const isInProcess = process.env.WEBPACK_BUNDLE; + +class CustomTestPlugin { + constructor(isInEnvironment) { + this.isInEnvironment = isInEnvironment; + } + apply(compiler) { + compiler.hooks.done.tap('testPlugin', () => { + if (!isInProcess && this.isInEnvironment) { + console.log('PASS'); + } else { + console.log('FAIL'); + } + }); + } +} + +module.exports = (env) => { + return { + mode: 'development', + devtool: false, + plugins: [new CustomTestPlugin(env.WEBPACK_BUILD)], + }; +}; diff --git a/test/build/bundle-variable/bundle-variable.test.js b/test/build/bundle-variable/bundle-variable.test.js new file mode 100644 index 00000000000..8458e95e483 --- /dev/null +++ b/test/build/bundle-variable/bundle-variable.test.js @@ -0,0 +1,13 @@ +'use strict'; + +const { run } = require('../../utils/test-utils'); + +describe('bundle variable', () => { + it('compiles without flags and export variable', async () => { + const { exitCode, stderr, stdout } = run(__dirname, [], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('PASS'); + }); +}); diff --git a/test/build/bundle-variable/src/index.js b/test/build/bundle-variable/src/index.js new file mode 100644 index 00000000000..6be02374db1 --- /dev/null +++ b/test/build/bundle-variable/src/index.js @@ -0,0 +1 @@ +console.log('hello world'); diff --git a/test/bundle/bundle-variable/webpack.config.js b/test/build/bundle-variable/webpack.config.js similarity index 100% rename from test/bundle/bundle-variable/webpack.config.js rename to test/build/bundle-variable/webpack.config.js diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index c1d212164d5..5df5a5abcb8 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -10,7 +10,8 @@ describe('function configuration', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(stdout).toContain("{ argv: { mode: 'development', env: { WEBPACK_BUNDLE: true } } }"); + expect(stdout).toContain('WEBPACK_BUNDLE: true'); + expect(stdout).toContain('WEBPACK_BUILD: true'); expect(stdout).toContain("mode: 'development'"); expect(existsSync(resolve(__dirname, './dist/dev.js'))); }); diff --git a/test/help/help.test.js b/test/help/help.test.js index 56e863512f1..2e14e2bab9c 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -155,7 +155,7 @@ describe('help', () => { expect(stdout).toContain('Made with ♥ by the webpack team'); }); - const commands = ['bundle', 'loader', 'plugin', 'info', 'init', 'serve', 'migrate']; + const commands = ['build', 'bundle', 'loader', 'plugin', 'info', 'init', 'serve', 'migrate']; commands.forEach((command) => { it(`should show help information for '${command}' command using the "--help" option`, () => { @@ -163,7 +163,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); }); it(`should show help information for '${command}' command using command syntax`, () => { @@ -171,7 +171,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); }); it('should show help information and respect the "--color" flag using the "--help" option', () => { @@ -179,7 +179,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); expect(stdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); }); @@ -188,7 +188,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); // TODO bug in tests // expect(stdout).not.toContain(bold('Made with ♥ by the webpack team')); expect(stdout).toContain('Made with ♥ by the webpack team'); diff --git a/test/version/version.test.js b/test/version/version.test.js index 42749637dbc..5a3cc96d2d2 100644 --- a/test/version/version.test.js +++ b/test/version/version.test.js @@ -85,6 +85,16 @@ describe('single version flag', () => { expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); }); + it('outputs version with build', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['build', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + it('outputs version with bundle', () => { const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--version'], false); From 15eb411237dcdcf0db7a501c103fe53f9b82903f Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 15 Jan 2021 16:03:19 +0300 Subject: [PATCH 263/581] feat: allow to use `help` command to show option information (#2353) --- OPTIONS.md | 4 +- packages/webpack-cli/lib/webpack-cli.js | 178 +++++++++++++------ test/build/basic/basic.test.js | 10 ++ test/help/help.test.js | 220 +++++++++++++++++++++++- 4 files changed, 355 insertions(+), 57 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index cfdd161bd68..797fe3b1ce6 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -700,8 +700,8 @@ Global options: Commands: build|bundle|b [options] Run webpack (default command, can be omitted). - version|v Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - help|h Display help for commands and options. + version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + help|h [command] [option] Display help for commands and options. serve|s [options] Run the webpack dev server. info|i [options] Outputs information about your system. init|c [options] [scaffold...] Initialize a new webpack configuration. diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 605311f7c7d..e3b1edb7ebe 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -144,8 +144,7 @@ class WebpackCLI { flags = `${flags} `; } - // TODO need to fix on webpack-dev-server side - // `describe` used by `webpack-dev-server` + // TODO `describe` used by `webpack-dev-server@3` const description = option.description || option.describe || ''; const defaultValue = option.defaultValue; @@ -236,16 +235,14 @@ class WebpackCLI { usage: '[options]', }; const versionCommandOptions = { - name: 'version', + name: 'version [commands...]', alias: 'v', description: "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", - usage: '[commands...]', }; const helpCommandOptions = { - name: 'help', + name: 'help [command] [option]', alias: 'h', description: 'Display help for commands and options.', - usage: '[command]', }; // Built-in external commands const externalBuiltInCommandsInfo = [ @@ -287,24 +284,34 @@ class WebpackCLI { ]; const knownCommands = [buildCommandOptions, versionCommandOptions, helpCommandOptions, ...externalBuiltInCommandsInfo]; + const getCommandName = (name) => name.split(' ')[0]; const isKnownCommand = (name) => knownCommands.find( (command) => - command.name === name || (Array.isArray(command.alias) ? command.alias.includes(name) : command.alias === name), + getCommandName(command.name) === name || + (Array.isArray(command.alias) ? command.alias.includes(name) : command.alias === name), ); const isBuildCommand = (name) => - buildCommandOptions.name === name || + getCommandName(buildCommandOptions.name) === name || (Array.isArray(buildCommandOptions.alias) ? buildCommandOptions.alias.includes(name) : buildCommandOptions.alias === name); const isHelpCommand = (name) => - helpCommandOptions.name === name || + getCommandName(helpCommandOptions.name) === name || (Array.isArray(helpCommandOptions.alias) ? helpCommandOptions.alias.includes(name) : helpCommandOptions.alias === name); const isVersionCommand = (name) => - versionCommandOptions.name === name || + getCommandName(versionCommandOptions.name) === name || (Array.isArray(versionCommandOptions.alias) ? versionCommandOptions.alias.includes(name) : versionCommandOptions.alias === name); const findCommandByName = (name) => this.program.commands.find((command) => name === command.name() || command.alias().includes(name)); + const isOption = (value) => value.startsWith('-'); + const isGlobalOption = (value) => + value === '--color' || + value === '--no-color' || + value === '-v' || + value === '--version' || + value === '-h' || + value === '--help'; const getCommandNameAndOptions = (args) => { let commandName; @@ -313,7 +320,7 @@ class WebpackCLI { let allowToSearchCommand = true; args.forEach((arg) => { - if (!arg.startsWith('-') && allowToSearchCommand) { + if (!isOption(arg) && allowToSearchCommand) { commandName = arg; allowToSearchCommand = false; @@ -491,9 +498,7 @@ class WebpackCLI { ); possibleCommandNames.forEach((possibleCommandName) => { - const isOption = possibleCommandName.startsWith('-'); - - if (!isOption) { + if (!isOption(possibleCommandName)) { return; } @@ -544,9 +549,7 @@ class WebpackCLI { "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", ); - // Default global `help` command - const outputHelp = async (options, isVerbose, program) => { - const isGlobal = options.length === 0; + const outputHelp = async (options, isVerbose, isHelpCommandSyntax, program) => { const hideVerboseOptions = (command) => { command.options = command.options.filter((option) => { const foundOption = flags.find((flag) => { @@ -564,11 +567,40 @@ class WebpackCLI { return true; }); }; + const outputGlobalOptions = () => { + const programHelpInformation = program.helpInformation(); + const globalOptions = programHelpInformation.match(/Options:\n(?.+)\nCommands:\n/s); + + if (globalOptions && globalOptions.groups.globalOptions) { + logger.raw('\nGlobal options:'); + logger.raw(globalOptions.groups.globalOptions.trimRight()); + } + }; + const outputGlobalCommands = () => { + const programHelpInformation = program.helpInformation(); + const globalCommands = programHelpInformation.match(/Commands:\n(?.+)/s); + + if (globalCommands.groups.globalCommands) { + logger.raw('\nCommands:'); + logger.raw( + globalCommands.groups.globalCommands + .trimRight() + // `commander` doesn't support multiple alias in help + .replace('build|bundle [options] ', 'build|bundle|b [options]'), + ); + } + }; + const outputIncorrectUsageOfHelp = () => { + logger.error('Incorrect use of help'); + logger.error("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + }; - if (isGlobal) { + if (options.length === 0) { await Promise.all( knownCommands.map((knownCommand) => { - return loadCommandByName(knownCommand.name); + return loadCommandByName(getCommandName(knownCommand.name)); }), ); @@ -588,20 +620,11 @@ class WebpackCLI { ); logger.raw(helpInformation); - } else { - const [name, ...optionsWithoutCommandName] = options; - if (name.startsWith('-')) { - logger.error(`Unknown option '${name}'`); - logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - } - - optionsWithoutCommandName.forEach((option) => { - logger.error(`Unknown option '${option}'`); - logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - }); + outputGlobalOptions(); + outputGlobalCommands(); + } else if (options.length === 1 && !isOption(options[0])) { + const name = options[0]; await loadCommandByName(name); @@ -629,26 +652,71 @@ class WebpackCLI { } logger.raw(helpInformation); - } - const programHelpInformation = program.helpInformation(); - const globalOptions = programHelpInformation.match(/Options:\n(?.+)\nCommands:\n/s); + outputGlobalOptions(); + } else if (isHelpCommandSyntax) { + let commandName; + let optionName; - if (globalOptions && globalOptions.groups.globalOptions) { - logger.raw('\nGlobal options:'); - logger.raw(globalOptions.groups.globalOptions.trimRight()); - } + if (options.length === 1) { + commandName = buildCommandOptions.name; + optionName = options[0]; + } else if (options.length === 2) { + commandName = options[0]; + optionName = options[1]; + + if (isOption(commandName)) { + outputIncorrectUsageOfHelp(); + } + } else { + outputIncorrectUsageOfHelp(); + } + + await loadCommandByName(commandName); + + const command = isGlobalOption(optionName) ? this.program : findCommandByName(commandName); + + if (!command) { + logger.error(`Can't find and load command '${commandName}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + const option = command.options.find((option) => option.short === optionName || option.long === optionName); - const globalCommands = programHelpInformation.match(/Commands:\n(?.+)/s); + if (!option) { + logger.error(`Unknown option '${optionName}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + const nameOutput = + option.flags.replace(/^.+[[<]/, '').replace(/(\.\.\.)?[\]>].*$/, '') + (option.variadic === true ? '...' : ''); + const value = option.required ? '<' + nameOutput + '>' : option.optional ? '[' + nameOutput + ']' : ''; - if (isGlobal && globalCommands.groups.globalCommands) { - logger.raw('\nCommands:'); logger.raw( - globalCommands.groups.globalCommands - .trimRight() - // `commander` doesn't support multiple alias in help - .replace('build|bundle [options] ', 'build|bundle|b [options]'), + `Usage: webpack${isBuildCommand(commandName) ? '' : ` ${commandName}`} ${option.long}${value ? ` ${value}` : ''}`, ); + + if (option.short) { + logger.raw( + `Short: webpack${isBuildCommand(commandName) ? '' : ` ${commandName}`} ${option.short}${value ? ` ${value}` : ''}`, + ); + } + + if (option.description) { + logger.raw(`Description: ${option.description}`); + } + + if (!option.negate && options.defaultValue) { + logger.raw(`Default value: ${JSON.stringify(option.defaultValue)}`); + } + + // TODO implement this after refactor cli arguments + // logger.raw('Possible values: foo | bar'); + // logger.raw('Documentation: https://webpack.js.org/option/name/'); + } else { + outputIncorrectUsageOfHelp(); } logger.raw("\nTo see list of all supported commands and options run 'webpack --help=verbose'.\n"); @@ -678,7 +746,9 @@ class WebpackCLI { const opts = program.opts(); - if (opts.help || isHelpCommand(commandName)) { + const isHelpCommandSyntax = isHelpCommand(commandName); + + if (opts.help || isHelpCommandSyntax) { let isVerbose = false; if (opts.help) { @@ -694,9 +764,13 @@ class WebpackCLI { this.program.forHelp = true; - const optionsForHelp = [].concat(opts.help && !isDefault ? [commandName] : []).concat(options); + const optionsForHelp = [] + .concat(opts.help && !isDefault ? [commandName] : []) + .concat(options) + .concat(isHelpCommandSyntax && typeof opts.color !== 'undefined' ? [opts.color ? '--color' : '--no-color'] : []) + .concat(isHelpCommandSyntax && typeof opts.version !== 'undefined' ? ['--version'] : []); - await outputHelp(optionsForHelp, isVerbose, program); + await outputHelp(optionsForHelp, isVerbose, isHelpCommandSyntax, program); } if (opts.version || isVersionCommand(commandName)) { @@ -710,11 +784,13 @@ class WebpackCLI { } else { logger.error(`Unknown command '${commandName}'`); - const found = knownCommands.find((commandOptions) => distance(commandName, commandOptions.name) < 3); + const found = knownCommands.find((commandOptions) => distance(commandName, getCommandName(commandOptions.name)) < 3); if (found) { logger.error( - `Did you mean '${found.name}' (alias '${Array.isArray(found.alias) ? found.alias.join(', ') : found.alias}')?`, + `Did you mean '${getCommandName(found.name)}' (alias '${ + Array.isArray(found.alias) ? found.alias.join(', ') : found.alias + }')?`, ); } diff --git a/test/build/basic/basic.test.js b/test/build/basic/basic.test.js index cd5a3137ed1..a758c3b523c 100644 --- a/test/build/basic/basic.test.js +++ b/test/build/basic/basic.test.js @@ -27,6 +27,16 @@ describe('bundle command', () => { expect(stdout).toBeTruthy(); }); + it('should log error and suggest right name on the "buil" command', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['buil'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown command 'buil'"); + expect(stderr).toContain("Did you mean 'build' (alias 'bundle, b')?"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + it('should log error with multi commands', async () => { const { exitCode, stderr, stdout } = run(__dirname, ['bundle', 'info'], false); diff --git a/test/help/help.test.js b/test/help/help.test.js index 2e14e2bab9c..ad3a1089c4c 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -208,7 +208,7 @@ describe('help', () => { expect(stdout).toContain('Made with ♥ by the webpack team'); }); - it('should show help information and taking precedence when "--help" and "--verison" option using together', () => { + it('should show help information and taking precedence when "--help" and "--version" option using together', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--version'], false); expect(exitCode).toBe(0); @@ -226,6 +226,150 @@ describe('help', () => { // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); }); + it('should show help information using the "help --mode" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --mode '); + expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help --target" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--target'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + + if (isWebpack5) { + expect(stdout).toContain('Usage: webpack --target '); + expect(stdout).toContain('Short: webpack -t '); + } else { + expect(stdout).toContain('Usage: webpack --target '); + expect(stdout).toContain('Short: webpack -t '); + } + + expect(stdout).toContain('Description: Sets the build target e.g. node.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help --stats" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--stats'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --stats [value]'); + expect(stdout).toContain('Description: It instructs webpack on how to treat the stats e.g. verbose.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help --no-stats" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-stats'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --no-stats'); + expect(stdout).toContain('Description: Disable stats output.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help --mode" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --mode '); + expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help serve --mode" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--mode'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack serve --mode '); + expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help --color" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --color'); + expect(stdout).toContain('Description: Enable colors on console.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help --no-color" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --no-color'); + expect(stdout).toContain('Description: Disable colors on console.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help serve --color" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack serve --color'); + expect(stdout).toContain('Description: Enable colors on console.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help serve --no-color" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--no-color'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack serve --no-color'); + expect(stdout).toContain('Description: Disable colors on console.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help --version" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --version'); + expect(stdout).toContain('Short: webpack -v'); + expect(stdout).toContain( + "Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", + ); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + + it('should show help information using the "help -v" option', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '-v'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('Usage: webpack --version'); + expect(stdout).toContain('Short: webpack -v'); + expect(stdout).toContain( + "Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", + ); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + }); + it('should log error for invalid command using the "--help" option', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'myCommand'], false); @@ -234,7 +378,27 @@ describe('help', () => { expect(stdout).toBeFalsy(); }); - it('should log error for invalid command using command syntax', () => { + it('should log error for invalid command using the "--help" option #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--flag', '--help'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Incorrect use of help'); + expect(stderr).toContain("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for invalid command using the "--help" option #3', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--flag', '--help'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Incorrect use of help'); + expect(stderr).toContain("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for unknown command using command syntax', () => { const { exitCode, stderr, stdout } = run(__dirname, ['help', 'myCommand'], false); expect(exitCode).toBe(2); @@ -243,7 +407,7 @@ describe('help', () => { expect(stdout).toBeFalsy(); }); - it('should log error for invalid command using command syntax #2', () => { + it('should log error for unknown command using command syntax #2', () => { const { exitCode, stderr, stdout } = run(__dirname, ['help', 'verbose'], false); expect(exitCode).toBe(2); @@ -252,11 +416,59 @@ describe('help', () => { expect(stdout).toBeFalsy(); }); + it('should log error for unknown option using command syntax #2', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--made'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown option '--made'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for unknown option using command syntax #3', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--made'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Unknown option '--made'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for unknown option using command syntax #4', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'bui', '--mode'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Can't find and load command 'bui'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for invalid command using command syntax #3', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode', 'serve'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Incorrect use of help'); + expect(stderr).toContain("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log error for invalid command using command syntax #4', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--mode', '--mode'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Incorrect use of help'); + expect(stderr).toContain("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + it('should log error for invalid flag with the "--help" option', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--my-flag'], false); expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown option '--my-flag'"); + expect(stderr).toContain('Incorrect use of help'); + expect(stderr).toContain("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); From 38869d20075fc2fd0a5a65cc88f855bcb5928e21 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 15 Jan 2021 16:05:12 +0300 Subject: [PATCH 264/581] chore(deps-dev): bump @types/node from 14.14.20 to 14.14.21 (#2355) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.20 to 14.14.21. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6ceacf1fb93..fe373a566c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1938,9 +1938,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.20" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.20.tgz#f7974863edd21d1f8a494a73e8e2b3658615c340" - integrity sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A== + version "14.14.21" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.21.tgz#d934aacc22424fe9622ebf6857370c052eae464e" + integrity sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 487691abc8d817f5b3c1ab87743d7235ff15d956 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 15 Jan 2021 17:17:54 +0300 Subject: [PATCH 265/581] feat: `configtest` validate default configuration (#2354) --- .eslintignore | 2 +- .prettierignore | 2 +- packages/configtest/src/index.ts | 27 ++++++++++++++++--- packages/webpack-cli/lib/webpack-cli.js | 4 +-- .../basic.config.js} | 0 .../{ => with-config-path}/error.config.js | 0 .../{ => with-config-path}/src/index.js | 0 .../syntax-error.config.js | 0 .../with-config-path.test.js} | 21 ++++++--------- .../webpack.config.json | 5 ++++ .../without-config-path.test.js | 16 +++++++++++ .../webpack.config.js | 5 ++++ .../without-config-path-error.test.js | 16 +++++++++++ .../webpack.config.js | 12 +++++++++ ...ut-config-path-multi-compiler-mode.test.js | 16 +++++++++++ ...thout-config-path-no-configuration.test.js | 13 +++++++++ .../without-config-path/webpack.config.js | 5 ++++ .../without-config-path.test.js | 16 +++++++++++ 18 files changed, 139 insertions(+), 21 deletions(-) rename test/configtest/{webpack.config.js => with-config-path/basic.config.js} (100%) rename test/configtest/{ => with-config-path}/error.config.js (100%) rename test/configtest/{ => with-config-path}/src/index.js (100%) rename test/configtest/{ => with-config-path}/syntax-error.config.js (100%) rename test/configtest/{configtest.test.js => with-config-path/with-config-path.test.js} (76%) create mode 100644 test/configtest/without-config-path-custom-extension/webpack.config.json create mode 100644 test/configtest/without-config-path-custom-extension/without-config-path.test.js create mode 100644 test/configtest/without-config-path-error/webpack.config.js create mode 100644 test/configtest/without-config-path-error/without-config-path-error.test.js create mode 100644 test/configtest/without-config-path-multi-compiler-mode/webpack.config.js create mode 100644 test/configtest/without-config-path-multi-compiler-mode/without-config-path-multi-compiler-mode.test.js create mode 100644 test/configtest/without-config-path-no-configuration/without-config-path-no-configuration.test.js create mode 100644 test/configtest/without-config-path/webpack.config.js create mode 100644 test/configtest/without-config-path/without-config-path.test.js diff --git a/.eslintignore b/.eslintignore index 97edf222a8a..acb5f4123c7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,4 +10,4 @@ test/typescript/webpack.config.ts test/config/error-commonjs/syntax-error.js test/config/error-mjs/syntax-error.mjs test/config/error-array/webpack.config.js -test/configtest/syntax-error.config.js +test/configtest/with-config-path/syntax-error.config.js diff --git a/.prettierignore b/.prettierignore index 86be5e4bc4f..c45e6482b38 100644 --- a/.prettierignore +++ b/.prettierignore @@ -10,4 +10,4 @@ test/config/error-mjs/syntax-error.mjs packages/webpack-cli/__tests__/test-assets/.yo-rc.json test/build-errors/stats.json packages/**/lib -test/configtest/syntax-error.config.js +test/configtest/with-config-path/syntax-error.config.js diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts index 367404a0868..2a03fad1683 100644 --- a/packages/configtest/src/index.ts +++ b/packages/configtest/src/index.ts @@ -6,15 +6,34 @@ class ConfigTestCommand { await cli.makeCommand( { - name: 'configtest ', + name: 'configtest [config-path]', alias: 't', description: 'Tests webpack configuration against validation errors.', - usage: '', pkg: '@webpack-cli/configtest', }, [], - async (configPath: string): Promise => { - const config = await cli.resolveConfig({ config: [configPath] }); + async (configPath: string | undefined): Promise => { + const config = await cli.resolveConfig(configPath ? { config: [configPath] } : {}); + const configPaths = new Set(); + + if (Array.isArray(config.options)) { + config.options.forEach((options) => { + if (config.path.get(options)) { + configPaths.add(config.path.get(options)); + } + }); + } else { + if (config.path.get(config.options)) { + configPaths.add(config.path.get(config.options)); + } + } + + if (configPaths.size === 0) { + logger.error('No configuration found.'); + process.exit(2); + } + + logger.info(`Validate '${Array.from(configPaths).join(' ,')}'.`); try { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index e3b1edb7ebe..e640f1ca053 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -277,7 +277,7 @@ class WebpackCLI { pkg: '@webpack-cli/migrate', }, { - name: 'configtest', + name: 'configtest [config-path]', alias: 't', pkg: '@webpack-cli/configtest', }, @@ -362,7 +362,7 @@ class WebpackCLI { } else { const builtInExternalCommandInfo = externalBuiltInCommandsInfo.find( (externalBuiltInCommandInfo) => - externalBuiltInCommandInfo.name === commandName || + getCommandName(externalBuiltInCommandInfo.name) === commandName || (typeof Array.isArray(externalBuiltInCommandInfo.alias) ? externalBuiltInCommandInfo.alias.includes(commandName) : externalBuiltInCommandInfo.alias === commandName), diff --git a/test/configtest/webpack.config.js b/test/configtest/with-config-path/basic.config.js similarity index 100% rename from test/configtest/webpack.config.js rename to test/configtest/with-config-path/basic.config.js diff --git a/test/configtest/error.config.js b/test/configtest/with-config-path/error.config.js similarity index 100% rename from test/configtest/error.config.js rename to test/configtest/with-config-path/error.config.js diff --git a/test/configtest/src/index.js b/test/configtest/with-config-path/src/index.js similarity index 100% rename from test/configtest/src/index.js rename to test/configtest/with-config-path/src/index.js diff --git a/test/configtest/syntax-error.config.js b/test/configtest/with-config-path/syntax-error.config.js similarity index 100% rename from test/configtest/syntax-error.config.js rename to test/configtest/with-config-path/syntax-error.config.js diff --git a/test/configtest/configtest.test.js b/test/configtest/with-config-path/with-config-path.test.js similarity index 76% rename from test/configtest/configtest.test.js rename to test/configtest/with-config-path/with-config-path.test.js index 8d88f8e62dc..2e4775868c0 100644 --- a/test/configtest/configtest.test.js +++ b/test/configtest/with-config-path/with-config-path.test.js @@ -1,13 +1,16 @@ 'use strict'; -const { run } = require('../utils/test-utils'); +const path = require('path'); -describe('basic info usage', () => { +const { run } = require('../../utils/test-utils'); + +describe("'configtest' command with the configuration path option", () => { it('should validate webpack config successfully', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './webpack.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './basic.config.js'], false); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + expect(stdout).toContain(`Validate '${path.resolve(__dirname, 'basic.config.js')}'.`); expect(stdout).toContain('There are no validation errors in the given webpack configuration.'); }); @@ -17,7 +20,7 @@ describe('basic info usage', () => { expect(exitCode).toBe(2); expect(stderr).toContain('Invalid configuration object.'); expect(stderr).toContain('configuration.mode should be one of these:'); - expect(stdout).toBeFalsy(); + expect(stdout).toContain(`Validate '${path.resolve(__dirname, 'error.config.js')}'.`); }); it('should throw syntax error', () => { @@ -34,7 +37,7 @@ describe('basic info usage', () => { expect(exitCode).toBe(2); expect(stderr).toContain('Invalid configuration object.'); expect(stderr).toContain('configuration.mode should be one of these:'); - expect(stdout).toBeFalsy(); + expect(stdout).toContain(`Validate '${path.resolve(__dirname, 'error.config.js')}'.`); }); it('should throw error if configuration does not exist', () => { @@ -44,12 +47,4 @@ describe('basic info usage', () => { expect(stderr).toContain(`The specified config file doesn't exist`); expect(stdout).toBeFalsy(); }); - - it('should throw error if no configuration was provided', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`error: missing required argument 'config-path'`); - expect(stdout).toBeFalsy(); - }); }); diff --git a/test/configtest/without-config-path-custom-extension/webpack.config.json b/test/configtest/without-config-path-custom-extension/webpack.config.json new file mode 100644 index 00000000000..821a4a55f7c --- /dev/null +++ b/test/configtest/without-config-path-custom-extension/webpack.config.json @@ -0,0 +1,5 @@ +{ + "mode": "development", + "target": "node", + "stats": "verbose" +} diff --git a/test/configtest/without-config-path-custom-extension/without-config-path.test.js b/test/configtest/without-config-path-custom-extension/without-config-path.test.js new file mode 100644 index 00000000000..f4c5218d134 --- /dev/null +++ b/test/configtest/without-config-path-custom-extension/without-config-path.test.js @@ -0,0 +1,16 @@ +'use strict'; + +const path = require('path'); + +const { run } = require('../../utils/test-utils'); + +describe("'configtest' command without the configuration path option", () => { + it.only('should validate default configuration', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`Validate '${path.resolve(__dirname, 'webpack.config.json')}'.`); + expect(stdout).toContain('There are no validation errors in the given webpack configuration.'); + }); +}); diff --git a/test/configtest/without-config-path-error/webpack.config.js b/test/configtest/without-config-path-error/webpack.config.js new file mode 100644 index 00000000000..5dbbd664f31 --- /dev/null +++ b/test/configtest/without-config-path-error/webpack.config.js @@ -0,0 +1,5 @@ +module.exports = { + mode: 'invalid', + target: 'node', + stats: 'verbose', +}; diff --git a/test/configtest/without-config-path-error/without-config-path-error.test.js b/test/configtest/without-config-path-error/without-config-path-error.test.js new file mode 100644 index 00000000000..1ddb9c1a3d4 --- /dev/null +++ b/test/configtest/without-config-path-error/without-config-path-error.test.js @@ -0,0 +1,16 @@ +'use strict'; + +const path = require('path'); + +const { run } = require('../../utils/test-utils'); + +describe("'configtest' command without the configuration path option", () => { + it.only('should validate default configuration', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('Invalid configuration object.'); + expect(stderr).toContain('configuration.mode should be one of these:'); + expect(stdout).toContain(`Validate '${path.resolve(__dirname, 'webpack.config.js')}'.`); + }); +}); diff --git a/test/configtest/without-config-path-multi-compiler-mode/webpack.config.js b/test/configtest/without-config-path-multi-compiler-mode/webpack.config.js new file mode 100644 index 00000000000..e198b8625cb --- /dev/null +++ b/test/configtest/without-config-path-multi-compiler-mode/webpack.config.js @@ -0,0 +1,12 @@ +module.exports = [ + { + mode: 'development', + target: 'node', + stats: 'verbose', + }, + { + mode: 'development', + target: 'node', + stats: 'verbose', + }, +]; diff --git a/test/configtest/without-config-path-multi-compiler-mode/without-config-path-multi-compiler-mode.test.js b/test/configtest/without-config-path-multi-compiler-mode/without-config-path-multi-compiler-mode.test.js new file mode 100644 index 00000000000..9a96a77506a --- /dev/null +++ b/test/configtest/without-config-path-multi-compiler-mode/without-config-path-multi-compiler-mode.test.js @@ -0,0 +1,16 @@ +'use strict'; + +const path = require('path'); + +const { run } = require('../../utils/test-utils'); + +describe("'configtest' command without the configuration path option", () => { + it.only('should validate default configuration', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`Validate '${path.resolve(__dirname, 'webpack.config.js')}'.`); + expect(stdout).toContain('There are no validation errors in the given webpack configuration.'); + }); +}); diff --git a/test/configtest/without-config-path-no-configuration/without-config-path-no-configuration.test.js b/test/configtest/without-config-path-no-configuration/without-config-path-no-configuration.test.js new file mode 100644 index 00000000000..167da4490fe --- /dev/null +++ b/test/configtest/without-config-path-no-configuration/without-config-path-no-configuration.test.js @@ -0,0 +1,13 @@ +'use strict'; + +const { run } = require('../../utils/test-utils'); + +describe("'configtest' command without the configuration path option", () => { + it.only('should validate default configuration', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false); + + expect(exitCode).toBe(2); + expect(stderr).toContain('No configuration found.'); + expect(stdout).toBeFalsy(); + }); +}); diff --git a/test/configtest/without-config-path/webpack.config.js b/test/configtest/without-config-path/webpack.config.js new file mode 100644 index 00000000000..bdaebdb6f26 --- /dev/null +++ b/test/configtest/without-config-path/webpack.config.js @@ -0,0 +1,5 @@ +module.exports = { + mode: 'development', + target: 'node', + stats: 'verbose', +}; diff --git a/test/configtest/without-config-path/without-config-path.test.js b/test/configtest/without-config-path/without-config-path.test.js new file mode 100644 index 00000000000..9a96a77506a --- /dev/null +++ b/test/configtest/without-config-path/without-config-path.test.js @@ -0,0 +1,16 @@ +'use strict'; + +const path = require('path'); + +const { run } = require('../../utils/test-utils'); + +describe("'configtest' command without the configuration path option", () => { + it.only('should validate default configuration', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`Validate '${path.resolve(__dirname, 'webpack.config.js')}'.`); + expect(stdout).toContain('There are no validation errors in the given webpack configuration.'); + }); +}); From 8aeca45aaafdddcae4adabc414c43e8486850772 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 18 Jan 2021 14:10:29 +0300 Subject: [PATCH 266/581] chore(deps-dev): bump webpack from 5.14.0 to 5.15.0 (#2358) Bumps [webpack](https://github.com/webpack/webpack) from 5.14.0 to 5.15.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.14.0...v5.15.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index fe373a566c6..d87aad59a3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11068,9 +11068,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.13.0: - version "5.14.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.14.0.tgz#cdfe9286d14ddc2bb348afabc1d910d166f3c47f" - integrity sha512-PFtfqXIKT6EG+k4L7d9whUPacN2XvxlUMc8NAQvN+sF9G8xPQqrCDGDiXbAdyGNz+/OP6ioxnUKybBBZ1kp/2A== + version "5.15.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.15.0.tgz#63d7b6228a4e15ee8c89899c2cfdd993e809bdd2" + integrity sha512-y/xG+ONDz78yn3VvP6gAvGr1/gkxOgitvHSXBmquyN8KDtrGEyE3K9WkXOPB7QmfcOBCpO4ELXwNcCYQnEmexA== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From 451b904393c9d0b92e49d8c7706a847ab1b2dc8b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 18 Jan 2021 14:13:36 +0300 Subject: [PATCH 267/581] chore(deps-dev): bump husky from 4.3.7 to 4.3.8 (#2360) Bumps [husky](https://github.com/typicode/husky) from 4.3.7 to 4.3.8. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](https://github.com/typicode/husky/compare/v4.3.7...v4.3.8) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d87aad59a3d..9c4846b5717 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5749,9 +5749,9 @@ humanize-ms@^1.2.1: ms "^2.0.0" husky@^4.3.0: - version "4.3.7" - resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.7.tgz#ca47bbe6213c1aa8b16bbd504530d9600de91e88" - integrity sha512-0fQlcCDq/xypoyYSJvEuzbDPHFf8ZF9IXKJxlrnvxABTSzK1VPT2RKYQKrcgJ+YD39swgoB6sbzywUqFxUiqjw== + version "4.3.8" + resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.8.tgz#31144060be963fd6850e5cc8f019a1dfe194296d" + integrity sha512-LCqqsB0PzJQ/AlCgfrfzRe3e3+NvmefAdKQhRYpxS4u6clblBoDdzzvHi8fmxKRzvMxPY/1WZWzomPZww0Anow== dependencies: chalk "^4.0.0" ci-info "^2.0.0" From 9693f7d9543a8fce610c4ef903ccca0d12d229a1 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Mon, 18 Jan 2021 16:31:50 +0300 Subject: [PATCH 268/581] feat: added the `watch` command (#2357) --- OPTIONS.md | 5 +- packages/configtest/src/index.ts | 4 +- packages/webpack-cli/lib/webpack-cli.js | 102 ++++++----- test/help/help.test.js | 36 +++- test/version/version.test.js | 30 ++++ test/watch/basic/basic.test.js | 169 +++++++++++++++++++ test/watch/{simple => basic}/src/index.js | 0 test/watch/{simple => basic}/watch.config.js | 0 test/watch/simple/watch.test.js | 52 ------ test/watch/stdin/stdin.test.js | 20 ++- 10 files changed, 315 insertions(+), 103 deletions(-) create mode 100644 test/watch/basic/basic.test.js rename test/watch/{simple => basic}/src/index.js (100%) rename test/watch/{simple => basic}/watch.config.js (100%) delete mode 100644 test/watch/simple/watch.test.js diff --git a/OPTIONS.md b/OPTIONS.md index 797fe3b1ce6..3fbe2a31dd4 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -5,6 +5,8 @@ Alternative usage: webpack build [options] Alternative usage: webpack bundle [options] Alternative usage: webpack b [options] Alternative usage: webpack build --config [options] +Alternative usage: webpack bundle --config [options] +Alternative usage: webpack b --config [options] The build tool for modern web applications. @@ -700,6 +702,7 @@ Global options: Commands: build|bundle|b [options] Run webpack (default command, can be omitted). + watch|w [options] Run webpack and watch for files changes. version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. help|h [command] [option] Display help for commands and options. serve|s [options] Run the webpack dev server. @@ -707,7 +710,7 @@ Commands: init|c [options] [scaffold...] Initialize a new webpack configuration. loader|l [output-path] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. - configtest|t Tests webpack configuration against validation errors. + configtest|t [config-path] Tests webpack configuration against validation errors. plugin|p [output-path] Scaffold a plugin. To see list of all supported commands and options run 'webpack --help=verbose'. diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts index 2a03fad1683..f9b5b92304a 100644 --- a/packages/configtest/src/index.ts +++ b/packages/configtest/src/index.ts @@ -1,8 +1,6 @@ -import webpack from 'webpack'; - class ConfigTestCommand { async apply(cli): Promise { - const { logger } = cli; + const { logger, webpack } = cli; await cli.makeCommand( { diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index e640f1ca053..3e7427e2658 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1,31 +1,28 @@ -const path = require('path'); const { program } = require('commander'); const getPkg = require('./utils/package-exists'); const webpack = getPkg('webpack') ? require('webpack') : undefined; +const path = require('path'); const { merge } = require('webpack-merge'); const { extensions, jsVariants } = require('interpret'); const rechoir = require('rechoir'); const { createWriteStream, existsSync } = require('fs'); const { distance } = require('fastest-levenshtein'); const { options: coloretteOptions, yellow, cyan, green, bold } = require('colorette'); -const { stringifyStream: createJsonStringifyStream } = require('@discoveryjs/json-ext'); const logger = require('./utils/logger'); const { cli, flags } = require('./utils/cli-flags'); const CLIPlugin = require('./plugins/CLIPlugin'); const promptInstallation = require('./utils/prompt-installation'); - const toKebabCase = require('./utils/to-kebab-case'); -const { resolve, extname } = path; - class WebpackCLI { constructor() { - this.logger = logger; // Initialize program this.program = program; this.program.name('webpack'); this.program.storeOptionsAsProperties(false); + this.webpack = webpack; + this.logger = logger; this.utils = { toKebabCase, getPkg, promptInstallation }; } @@ -234,6 +231,12 @@ class WebpackCLI { description: 'Run webpack (default command, can be omitted).', usage: '[options]', }; + const watchCommandOptions = { + name: 'watch', + alias: 'w', + description: 'Run webpack and watch for files changes.', + usage: '[options]', + }; const versionCommandOptions = { name: 'version [commands...]', alias: 'v', @@ -283,7 +286,13 @@ class WebpackCLI { }, ]; - const knownCommands = [buildCommandOptions, versionCommandOptions, helpCommandOptions, ...externalBuiltInCommandsInfo]; + const knownCommands = [ + buildCommandOptions, + watchCommandOptions, + versionCommandOptions, + helpCommandOptions, + ...externalBuiltInCommandsInfo, + ]; const getCommandName = (name) => name.split(' ')[0]; const isKnownCommand = (name) => knownCommands.find( @@ -294,6 +303,9 @@ class WebpackCLI { const isBuildCommand = (name) => getCommandName(buildCommandOptions.name) === name || (Array.isArray(buildCommandOptions.alias) ? buildCommandOptions.alias.includes(name) : buildCommandOptions.alias === name); + const isWatchCommand = (name) => + getCommandName(watchCommandOptions.name) === name || + (Array.isArray(watchCommandOptions.alias) ? watchCommandOptions.alias.includes(name) : watchCommandOptions.alias === name); const isHelpCommand = (name) => getCommandName(helpCommandOptions.name) === name || (Array.isArray(helpCommandOptions.alias) ? helpCommandOptions.alias.includes(name) : helpCommandOptions.alias === name); @@ -338,21 +350,40 @@ class WebpackCLI { return { commandName: isDefault ? buildCommandOptions.name : commandName, options, isDefault }; }; const loadCommandByName = async (commandName, allowToInstall = false) => { - if (isBuildCommand(commandName)) { - await this.makeCommand(buildCommandOptions, this.getBuiltInOptions(), async (program) => { - const options = program.opts(); + const isBuildCommandUsed = isBuildCommand(commandName); + const isWatchCommandUsed = isWatchCommand(commandName); - if (program.args.length > 0) { - const possibleCommands = [].concat([buildCommandOptions.name]).concat(program.args); + if (isBuildCommandUsed || isWatchCommandUsed) { + await this.makeCommand( + isBuildCommandUsed ? buildCommandOptions : watchCommandOptions, + this.getBuiltInOptions(), + async (program) => { + const options = program.opts(); - logger.error('Running multiple commands at the same time is not possible'); - logger.error(`Found commands: ${possibleCommands.map((item) => `'${item}'`).join(', ')}`); - logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - } + if (program.args.length > 0) { + const possibleCommands = [].concat([buildCommandOptions.name]).concat(program.args); - await this.bundleCommand(options); - }); + logger.error('Running multiple commands at the same time is not possible'); + logger.error(`Found commands: ${possibleCommands.map((item) => `'${item}'`).join(', ')}`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + if (isWatchCommandUsed) { + if (typeof options.watch !== 'undefined') { + logger.warn( + `No need to use the ${ + options.watch ? "'--watch, -w'" : "'--no-watch'" + } option together with the 'watch' command, it does not make sense`, + ); + } + + options.watch = true; + } + + await this.bundleCommand(options); + }, + ); } else if (isHelpCommand(commandName)) { // Stub for the `help` command this.makeCommand(helpCommandOptions, [], () => {}); @@ -492,9 +523,9 @@ class WebpackCLI { // Make `-v, --version` options // Make `version|v [commands...]` command const outputVersion = async (options) => { - // Filter `bundle`, `version` and `help` commands + // Filter `bundle`, `watch`, `version` and `help` commands const possibleCommandNames = options.filter( - (option) => !isBuildCommand(option) && !isVersionCommand(option) && !isHelpCommand(option), + (option) => !isBuildCommand(option) && !isWatchCommand(option) && !isVersionCommand(option) && !isHelpCommand(option), ); possibleCommandNames.forEach((possibleCommandName) => { @@ -616,7 +647,7 @@ class WebpackCLI { .replace(buildCommandOptions.description, 'The build tool for modern web applications.') .replace( /Usage:.+/, - 'Usage: webpack [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack build [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack b [options]\nAlternative usage: webpack build --config [options]', + 'Usage: webpack [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack build [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack b [options]\nAlternative usage: webpack build --config [options]\nAlternative usage: webpack bundle --config [options]\nAlternative usage: webpack b --config [options]', ); logger.raw(helpInformation); @@ -643,25 +674,21 @@ class WebpackCLI { let helpInformation = command.helpInformation().trimRight(); if (isBuildCommand(name)) { - helpInformation = helpInformation - .replace(buildCommandOptions.description, 'The build tool for modern web applications.') - .replace( - /Usage:.+/, - 'Usage: webpack [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack build [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack b [options]\nAlternative usage: webpack build --config [options]', - ); + helpInformation = helpInformation.replace('build|bundle', 'build|bundle|b'); } logger.raw(helpInformation); outputGlobalOptions(); } else if (isHelpCommandSyntax) { - let commandName; + let isCommandSpecified = false; + let commandName = buildCommandOptions.name; let optionName; if (options.length === 1) { - commandName = buildCommandOptions.name; optionName = options[0]; } else if (options.length === 2) { + isCommandSpecified = true; commandName = options[0]; optionName = options[1]; @@ -694,14 +721,10 @@ class WebpackCLI { option.flags.replace(/^.+[[<]/, '').replace(/(\.\.\.)?[\]>].*$/, '') + (option.variadic === true ? '...' : ''); const value = option.required ? '<' + nameOutput + '>' : option.optional ? '[' + nameOutput + ']' : ''; - logger.raw( - `Usage: webpack${isBuildCommand(commandName) ? '' : ` ${commandName}`} ${option.long}${value ? ` ${value}` : ''}`, - ); + logger.raw(`Usage: webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.long}${value ? ` ${value}` : ''}`); if (option.short) { - logger.raw( - `Short: webpack${isBuildCommand(commandName) ? '' : ` ${commandName}`} ${option.short}${value ? ` ${value}` : ''}`, - ); + logger.raw(`Short: webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.short}${value ? ` ${value}` : ''}`); } if (option.description) { @@ -806,7 +829,7 @@ class WebpackCLI { async resolveConfig(options) { const loadConfig = async (configPath) => { - const ext = extname(configPath); + const ext = path.extname(configPath); const interpreted = Object.keys(jsVariants).find((variant) => variant === ext); if (interpreted) { @@ -906,7 +929,7 @@ class WebpackCLI { if (options.config && options.config.length > 0) { const evaluatedConfigs = await Promise.all( options.config.map(async (value) => { - const configPath = resolve(value); + const configPath = path.resolve(value); if (!existsSync(configPath)) { logger.error(`The specified config file doesn't exist in '${configPath}'`); @@ -940,7 +963,7 @@ class WebpackCLI { .map((filename) => // Since .cjs is not available on interpret side add it manually to default config extension list [...Object.keys(extensions), '.cjs'].map((ext) => ({ - path: resolve(filename + ext), + path: path.resolve(filename + ext), ext: ext, module: extensions[ext], })), @@ -1373,6 +1396,7 @@ class WebpackCLI { } if (options.json) { + const { stringifyStream: createJsonStringifyStream } = require('@discoveryjs/json-ext'); const handleWriteError = (error) => { logger.error(error); process.exit(2); diff --git a/test/help/help.test.js b/test/help/help.test.js index ad3a1089c4c..9b40070f5ab 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -19,7 +19,8 @@ describe('help', () => { expect(stdout).not.toContain('--cache-type'); // verbose expect(stdout).toContain('Global options:'); expect(stdout).toContain('Commands:'); - expect(stdout.match(/bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/build\|bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/watch\|w/g)).toHaveLength(1); expect(stdout.match(/version\|v/g)).toHaveLength(1); expect(stdout.match(/help\|h/g)).toHaveLength(1); expect(stdout.match(/serve\|s/g)).toHaveLength(1); @@ -51,7 +52,8 @@ describe('help', () => { expect(stdout).toContain('Global options:'); expect(stdout).toContain('Commands:'); - expect(stdout.match(/bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/build\|bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/watch\|w/g)).toHaveLength(1); expect(stdout.match(/version\|v/g)).toHaveLength(1); expect(stdout.match(/help\|h/g)).toHaveLength(1); expect(stdout.match(/serve\|s/g)).toHaveLength(1); @@ -155,7 +157,27 @@ describe('help', () => { expect(stdout).toContain('Made with ♥ by the webpack team'); }); - const commands = ['build', 'bundle', 'loader', 'plugin', 'info', 'init', 'serve', 'migrate']; + const commands = [ + 'build', + 'bundle', + 'b', + 'watch', + 'w', + 'serve', + 's', + 'info', + 'i', + 'init', + 'c', + 'loader', + 'l', + 'plugin', + 'p', + 'configtest', + 't', + 'migrate', + 'm', + ]; commands.forEach((command) => { it(`should show help information for '${command}' command using the "--help" option`, () => { @@ -163,7 +185,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); }); it(`should show help information for '${command}' command using command syntax`, () => { @@ -171,7 +193,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); }); it('should show help information and respect the "--color" flag using the "--help" option', () => { @@ -179,7 +201,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); expect(stdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); }); @@ -188,7 +210,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' ? '' : command}`); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); // TODO bug in tests // expect(stdout).not.toContain(bold('Made with ♥ by the webpack team')); expect(stdout).toContain('Made with ♥ by the webpack team'); diff --git a/test/version/version.test.js b/test/version/version.test.js index 5a3cc96d2d2..1cc9fb69ce5 100644 --- a/test/version/version.test.js +++ b/test/version/version.test.js @@ -105,6 +105,36 @@ describe('single version flag', () => { expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); }); + it('outputs version with b', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['b', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with watch', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['watch', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + + it('outputs version with w', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['w', '--version'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); + expect(stdout).toContain(`webpack ${webpack.version}`); + expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); + }); + it('outputs version with plugin', () => { const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version'], false); diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js new file mode 100644 index 00000000000..34fee148278 --- /dev/null +++ b/test/watch/basic/basic.test.js @@ -0,0 +1,169 @@ +'use strict'; + +const stripAnsi = require('strip-ansi'); +const { run, runAndGetWatchProc, isWebpack5 } = require('../../utils/test-utils'); +const { writeFileSync } = require('fs'); +const { resolve } = require('path'); + +const wordsInStatsv4 = ['Hash', 'Version', 'Time', 'Built at:', 'main.js']; +const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; + +describe('basic', () => { + it('should work with negative value', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './watch.config.js', '--no-watch']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should recompile upon file change using the `--watch` option', (done) => { + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); + + let modified = false; + + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + if (data.includes('index.js')) { + if (isWebpack5) { + for (const word of wordsInStatsv5) { + expect(data).toContain(word); + } + } else { + for (const word of wordsInStatsv4) { + expect(data).toContain(word); + } + } + + if (!modified) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } + } + }); + }); + + it('should recompile upon file change using the `watch` command', (done) => { + const proc = runAndGetWatchProc(__dirname, ['watch', '--mode', 'development'], false, '', true); + + let modified = false; + + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + if (data.includes('index.js')) { + if (isWebpack5) { + for (const word of wordsInStatsv5) { + expect(data).toContain(word); + } + } else { + for (const word of wordsInStatsv4) { + expect(data).toContain(word); + } + } + + if (!modified) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } + } + }); + }); + + it('should recompile upon file change using the `command` option and the `--watch` option and log warning', (done) => { + const proc = runAndGetWatchProc(__dirname, ['watch', '--watch', '--mode', 'development'], false, '', true); + + let modified = false; + let hasWarning = false; + + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + if (data.includes('index.js')) { + if (isWebpack5) { + for (const word of wordsInStatsv5) { + expect(data).toContain(word); + } + } else { + for (const word of wordsInStatsv4) { + expect(data).toContain(word); + } + } + + if (!modified && !hasWarning) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } + } + }); + + proc.stderr.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + hasWarning = true; + + expect(data).toContain("No need to use the '--watch, -w' option together with the 'watch' command, it does not make sense"); + }); + }); + + it('should recompile upon file change using the `command` option and the `--no-watch` option and log warning', (done) => { + const proc = runAndGetWatchProc(__dirname, ['watch', '--no-watch', '--mode', 'development'], false, '', true); + + let modified = false; + let hasWarning = false; + + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + if (data.includes('index.js')) { + if (isWebpack5) { + for (const word of wordsInStatsv5) { + expect(data).toContain(word); + } + } else { + for (const word of wordsInStatsv4) { + expect(data).toContain(word); + } + } + + if (!modified && !hasWarning) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } + } + }); + + proc.stderr.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + hasWarning = true; + + expect(data).toContain("No need to use the '--no-watch' option together with the 'watch' command, it does not make sense"); + }); + }); +}); diff --git a/test/watch/simple/src/index.js b/test/watch/basic/src/index.js similarity index 100% rename from test/watch/simple/src/index.js rename to test/watch/basic/src/index.js diff --git a/test/watch/simple/watch.config.js b/test/watch/basic/watch.config.js similarity index 100% rename from test/watch/simple/watch.config.js rename to test/watch/basic/watch.config.js diff --git a/test/watch/simple/watch.test.js b/test/watch/simple/watch.test.js deleted file mode 100644 index 4ddf7386acb..00000000000 --- a/test/watch/simple/watch.test.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -const stripAnsi = require('strip-ansi'); -const { run, runAndGetWatchProc, isWebpack5 } = require('../../utils/test-utils'); -const { writeFileSync } = require('fs'); -const { resolve } = require('path'); - -const wordsInStatsv4 = ['Hash', 'Version', 'Time', 'Built at:', 'main.js']; -const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; - -describe('--watch flag', () => { - it('should work with negative value', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './watch.config.js', '--no-watch']); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); - }); - - it('should recompile upon file change', (done) => { - const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); - - let modified = false; - - proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); - - if (data.includes('index.js')) { - if (isWebpack5) { - for (const word of wordsInStatsv5) { - expect(data).toContain(word); - } - } else { - for (const word of wordsInStatsv4) { - expect(data).toContain(word); - } - } - - if (!modified) { - process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); - }); - - modified = true; - } else { - proc.kill(); - done(); - } - } - }); - }); -}); diff --git a/test/watch/stdin/stdin.test.js b/test/watch/stdin/stdin.test.js index 06d285d53ab..e7d3be46210 100644 --- a/test/watch/stdin/stdin.test.js +++ b/test/watch/stdin/stdin.test.js @@ -1,7 +1,7 @@ const { runAndGetWatchProc } = require('../../utils/test-utils'); describe('--watch-options-stdin', () => { - it.only('should stop the process when stdin ends using "--watch" and "--watch-options-stdin" options', (done) => { + it('should stop the process when stdin ends using "--watch" and "--watch-options-stdin" options', (done) => { const proc = runAndGetWatchProc(__dirname, ['--watch', '--watch-options-stdin'], false, '', true); let semaphore = false; @@ -19,6 +19,24 @@ describe('--watch-options-stdin', () => { }); }); + it('should stop the process when stdin ends using the "watch" command and the "--watch-options-stdin" option', (done) => { + const proc = runAndGetWatchProc(__dirname, ['watch', '--watch-options-stdin'], false, '', true); + + let semaphore = false; + + proc.on('exit', () => { + expect(semaphore).toBe(true); + + proc.kill(); + + done(); + }); + + proc.stdin.end(() => { + semaphore = true; + }); + }); + it('should stop the process when stdin ends using the config file', (done) => { const proc = runAndGetWatchProc(__dirname, ['--config', './watch.config.js'], false, '', true); From 366521e8d820a498ea2d95e8e41c218b019fe7d0 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 18 Jan 2021 17:35:59 +0300 Subject: [PATCH 269/581] chore(deps-dev): bump eslint from 7.17.0 to 7.18.0 (#2359) Bumps [eslint](https://github.com/eslint/eslint) from 7.17.0 to 7.18.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.17.0...v7.18.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9c4846b5717..520a96a6d98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -544,10 +544,10 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz#8f03a22a04de437254e8ce8cc84ba39689288752" integrity sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg== -"@eslint/eslintrc@^0.2.2": - version "0.2.2" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.2.tgz#d01fc791e2fc33e88a29d6f3dc7e93d0cd784b76" - integrity sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ== +"@eslint/eslintrc@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.3.0.tgz#d736d6963d7003b6514e6324bec9c602ac340318" + integrity sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg== dependencies: ajv "^6.12.4" debug "^4.1.1" @@ -556,7 +556,7 @@ ignore "^4.0.6" import-fresh "^3.2.1" js-yaml "^3.13.1" - lodash "^4.17.19" + lodash "^4.17.20" minimatch "^3.0.4" strip-json-comments "^3.1.1" @@ -4398,12 +4398,12 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.17.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.17.0.tgz#4ccda5bf12572ad3bf760e6f195886f50569adb0" - integrity sha512-zJk08MiBgwuGoxes5sSQhOtibZ75pz0J35XTRlZOk9xMffhpA9BTbQZxoXZzOl5zMbleShbGwtw+1kGferfFwQ== + version "7.18.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.18.0.tgz#7fdcd2f3715a41fe6295a16234bd69aed2c75e67" + integrity sha512-fbgTiE8BfUJZuBeq2Yi7J3RB3WGUQ9PNuNbmgi6jt9Iv8qrkxfy19Ds3OpL1Pm7zg3BtTVhvcUZbIRQ0wmSjAQ== dependencies: "@babel/code-frame" "^7.0.0" - "@eslint/eslintrc" "^0.2.2" + "@eslint/eslintrc" "^0.3.0" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -4427,7 +4427,7 @@ eslint@^7.12.1: js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" - lodash "^4.17.19" + lodash "^4.17.20" minimatch "^3.0.4" natural-compare "^1.4.0" optionator "^0.9.1" From 586d228d40608e10ee99b99e146561854835fb26 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 19 Jan 2021 13:30:33 +0300 Subject: [PATCH 270/581] chore(deps-dev): bump eslint-config-prettier from 7.1.0 to 7.2.0 (#2364) Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 7.1.0 to 7.2.0. - [Release notes](https://github.com/prettier/eslint-config-prettier/releases) - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v7.1.0...v7.2.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 520a96a6d98..ca371037d66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4341,9 +4341,9 @@ escodegen@^1.14.1: source-map "~0.6.1" eslint-config-prettier@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-7.1.0.tgz#5402eb559aa94b894effd6bddfa0b1ca051c858f" - integrity sha512-9sm5/PxaFG7qNJvJzTROMM1Bk1ozXVTKI0buKOyb0Bsr1hrwi0H/TzxF/COtf1uxikIK8SwhX7K6zg78jAzbeA== + version "7.2.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-7.2.0.tgz#f4a4bd2832e810e8cc7c1411ec85b3e85c0c53f9" + integrity sha512-rV4Qu0C3nfJKPOAhFujFxB7RMP+URFyQqqOZW9DMRD7ZDTFyjaIlETU3xzHELt++4ugC0+Jm084HQYkkJe+Ivg== eslint-plugin-es@^3.0.0: version "3.0.1" From f55d44d243d6e101f7e7c88ddf0e7c567e33bd08 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 19 Jan 2021 14:27:05 +0300 Subject: [PATCH 271/581] chore(release): publish new version - @webpack-cli/configtest@1.0.0 - @webpack-cli/generators@1.3.0 - @webpack-cli/init@1.1.2 - @webpack-cli/serve@1.2.2 - webpack-cli@4.4.0 --- packages/configtest/CHANGELOG.md | 12 ++++++++++++ packages/generators/CHANGELOG.md | 14 ++++++++++++++ packages/generators/package.json | 16 ++++++++-------- packages/init/CHANGELOG.md | 4 ++++ packages/init/package.json | 4 ++-- packages/serve/CHANGELOG.md | 7 +++++++ packages/serve/package.json | 2 +- packages/webpack-cli/CHANGELOG.md | 21 +++++++++++++++++++++ packages/webpack-cli/package.json | 4 ++-- 9 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 packages/configtest/CHANGELOG.md diff --git a/packages/configtest/CHANGELOG.md b/packages/configtest/CHANGELOG.md new file mode 100644 index 00000000000..5b94c2f2ba8 --- /dev/null +++ b/packages/configtest/CHANGELOG.md @@ -0,0 +1,12 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# 1.0.0 (2021-01-19) + +### Features + +- `configtest` validate default configuration ([#2354](https://github.com/webpack/webpack-cli/issues/2354)) ([487691a](https://github.com/webpack/webpack-cli/commit/487691abc8d817f5b3c1ab87743d7235ff15d956)) +- added the `watch` command ([#2357](https://github.com/webpack/webpack-cli/issues/2357)) ([9693f7d](https://github.com/webpack/webpack-cli/commit/9693f7d9543a8fce610c4ef903ccca0d12d229a1)) +- new `configtest` command ([#2303](https://github.com/webpack/webpack-cli/issues/2303)) ([eb7b189](https://github.com/webpack/webpack-cli/commit/eb7b18937d045261a5b20ca8356e8b4ae4dfcaad)) diff --git a/packages/generators/CHANGELOG.md b/packages/generators/CHANGELOG.md index d0ad83af03e..c273131aa0c 100644 --- a/packages/generators/CHANGELOG.md +++ b/packages/generators/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.2.1...@webpack-cli/generators@1.3.0) (2021-01-19) + +### Bug Fixes + +- init generator ([#2324](https://github.com/webpack/webpack-cli/issues/2324)) ([016bb34](https://github.com/webpack/webpack-cli/commit/016bb348d7cc9cb299555ec8edd373130fb1b77c)) +- regression with webpack config ([#2319](https://github.com/webpack/webpack-cli/issues/2319)) ([50bbe56](https://github.com/webpack/webpack-cli/commit/50bbe56c0ae9d72301c4ac51fdc2b04df7b66451)) +- remove splitchunks ([#2310](https://github.com/webpack/webpack-cli/issues/2310)) ([e44e855](https://github.com/webpack/webpack-cli/commit/e44e855c7e302932a828fcedf7abfe205b47c716)) +- remove style-loader from the loader chain ([#2309](https://github.com/webpack/webpack-cli/issues/2309)) ([19a25cf](https://github.com/webpack/webpack-cli/commit/19a25cf83dc2f680a5028f4b449d7f79895231f0)) +- use worker from plugin and remove default ([#2340](https://github.com/webpack/webpack-cli/issues/2340)) ([9100137](https://github.com/webpack/webpack-cli/commit/9100137bc4e7d77915407aec554da25f0ae9e55c)) + +### Features + +- flexible init scaffolding ([#2311](https://github.com/webpack/webpack-cli/issues/2311)) ([9a74ad0](https://github.com/webpack/webpack-cli/commit/9a74ad08b984325a63d953c685496e48700a2caf)) + ## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.2.0...@webpack-cli/generators@1.2.1) (2020-12-31) ### Bug Fixes diff --git a/packages/generators/package.json b/packages/generators/package.json index 694bc4ee50e..518d16009c6 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generators", - "version": "1.2.1", + "version": "1.3.0", "description": "Webpack-CLI generators", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -18,27 +18,27 @@ ], "dependencies": { "colorette": "^1.2.1", - "log-symbols": "^4.0.0", - "yeoman-environment": "^2.10.3", - "yeoman-generator": "^4.12.0", "execa": "^5.0.0", "findup-sync": "^4.0.0", "global-modules": "^2.0.0", "got": "^11.8.0", "jscodeshift": "^0.11.0", - "p-each-series": "^2.1.0" + "log-symbols": "^4.0.0", + "p-each-series": "^2.1.0", + "yeoman-environment": "^2.10.3", + "yeoman-generator": "^4.12.0" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", "webpack-cli": "4.x.x" }, "devDependencies": { + "@types/got": "^9.6.11", + "@types/prettier": "^2.1.5", "@types/yeoman-assert": "^3.1.1", "@types/yeoman-generator": "^4.11.3", "rimraf": "^3.0.2", - "yeoman-assert": "^3.1.1", - "@types/got": "^9.6.11", - "@types/prettier": "^2.1.5" + "yeoman-assert": "^3.1.1" }, "peerDependenciesMeta": { "prettier": { diff --git a/packages/init/CHANGELOG.md b/packages/init/CHANGELOG.md index 93e6f1b35a2..71ce0af5f2a 100644 --- a/packages/init/CHANGELOG.md +++ b/packages/init/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.1...@webpack-cli/init@1.1.2) (2021-01-19) + +**Note:** Version bump only for package @webpack-cli/init + ## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.0...@webpack-cli/init@1.1.1) (2020-12-31) ### Bug Fixes diff --git a/packages/init/package.json b/packages/init/package.json index 4cc235e3bb0..9f4261998c6 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/init", - "version": "1.1.1", + "version": "1.1.2", "description": "init command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,7 +12,7 @@ "lib" ], "dependencies": { - "@webpack-cli/generators": "^1.2.1" + "@webpack-cli/generators": "^1.3.0" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", diff --git a/packages/serve/CHANGELOG.md b/packages/serve/CHANGELOG.md index 0e8cb3a23b2..6df9f1652e1 100644 --- a/packages/serve/CHANGELOG.md +++ b/packages/serve/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.2.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.1...@webpack-cli/serve@1.2.2) (2021-01-19) + +### Bug Fixes + +- pass all `argv` to configurations when `serve` command used ([#2345](https://github.com/webpack/webpack-cli/issues/2345)) ([5070b9b](https://github.com/webpack/webpack-cli/commit/5070b9bcbd5bdac00088d0c21486ad181a4df000)) +- respect `--stats`, `--color` and `--no-color` option for serve c… ([#2312](https://github.com/webpack/webpack-cli/issues/2312)) ([73d3fec](https://github.com/webpack/webpack-cli/commit/73d3feced18b4e3708f958707326a6642a594cf2)) + ## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.0...@webpack-cli/serve@1.2.1) (2020-12-31) ### Bug Fixes diff --git a/packages/serve/package.json b/packages/serve/package.json index 4099c82ec35..55426cbfbe7 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/serve", - "version": "1.2.1", + "version": "1.2.2", "description": "", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/webpack-cli/CHANGELOG.md b/packages/webpack-cli/CHANGELOG.md index 609b60d1d6e..7ae81a01387 100644 --- a/packages/webpack-cli/CHANGELOG.md +++ b/packages/webpack-cli/CHANGELOG.md @@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.4.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.1...webpack-cli@4.4.0) (2021-01-19) + +### Bug Fixes + +- better description for --no-watch-options-stdin ([#2288](https://github.com/webpack/webpack-cli/issues/2288)) ([4ee8665](https://github.com/webpack/webpack-cli/commit/4ee8665e01e8dce16448e0a4d3dd2293731695ab)) +- double commands output in help ([#2298](https://github.com/webpack/webpack-cli/issues/2298)) ([efe81e9](https://github.com/webpack/webpack-cli/commit/efe81e986a6dca5cc9b72a5c9312dc21409f65b1)) +- pass all `argv` to configurations when `serve` command used ([#2345](https://github.com/webpack/webpack-cli/issues/2345)) ([5070b9b](https://github.com/webpack/webpack-cli/commit/5070b9bcbd5bdac00088d0c21486ad181a4df000)) +- respect `--stats`, `--color` and `--no-color` option for serve c… ([#2312](https://github.com/webpack/webpack-cli/issues/2312)) ([73d3fec](https://github.com/webpack/webpack-cli/commit/73d3feced18b4e3708f958707326a6642a594cf2)) +- show exact package name while prompting for installation ([#2338](https://github.com/webpack/webpack-cli/issues/2338)) ([ffc93e5](https://github.com/webpack/webpack-cli/commit/ffc93e556d784e2d4409cb0d3a92d737850996f4)) +- webpack installation prompt message ([#2316](https://github.com/webpack/webpack-cli/issues/2316)) ([3659c5e](https://github.com/webpack/webpack-cli/commit/3659c5e529fe1319251ef1c713d6cc758f7f5353)) + +### Features + +- `configtest` validate default configuration ([#2354](https://github.com/webpack/webpack-cli/issues/2354)) ([487691a](https://github.com/webpack/webpack-cli/commit/487691abc8d817f5b3c1ab87743d7235ff15d956)) +- added `build` command (aliases - 'bundle' and 'b') ([7590f66](https://github.com/webpack/webpack-cli/commit/7590f66663ce701d52d9276c3adf9dbdfd1a0fa4)) +- added the `watch` command ([#2357](https://github.com/webpack/webpack-cli/issues/2357)) ([9693f7d](https://github.com/webpack/webpack-cli/commit/9693f7d9543a8fce610c4ef903ccca0d12d229a1)) +- allow to pass parseOption to CLI class ([#2299](https://github.com/webpack/webpack-cli/issues/2299)) ([2af0801](https://github.com/webpack/webpack-cli/commit/2af08013852a95c6f6462c56a9994a4ee28c6ea1)) +- allow to use `help` command to show option information ([#2353](https://github.com/webpack/webpack-cli/issues/2353)) ([15eb411](https://github.com/webpack/webpack-cli/commit/15eb411237dcdcf0db7a501c103fe53f9b82903f)) +- new `configtest` command ([#2303](https://github.com/webpack/webpack-cli/issues/2303)) ([eb7b189](https://github.com/webpack/webpack-cli/commit/eb7b18937d045261a5b20ca8356e8b4ae4dfcaad)) +- show multiple suggestions on unknown options ([#2349](https://github.com/webpack/webpack-cli/issues/2349)) ([7314d6c](https://github.com/webpack/webpack-cli/commit/7314d6ca927473da2f355a7d356a943471488606)) + ## [4.3.1](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.0...webpack-cli@4.3.1) (2020-12-31) ### Bug Fixes diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 5a94d4aca07..1e9767a48ca 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -1,6 +1,6 @@ { "name": "webpack-cli", - "version": "4.3.1", + "version": "4.4.0", "description": "CLI for webpack & friends", "license": "MIT", "repository": { @@ -30,7 +30,7 @@ "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^1.0.0", "@webpack-cli/info": "^1.2.1", - "@webpack-cli/serve": "^1.2.1", + "@webpack-cli/serve": "^1.2.2", "colorette": "^1.2.1", "commander": "^6.2.0", "enquirer": "^2.3.6", From 34a2e3b4f55612d8de893857af4152a44295ac56 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 19 Jan 2021 14:30:14 +0300 Subject: [PATCH 272/581] docs: changelog --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60d30584744..92155dfb12a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +# [4.4.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.1...webpack-cli@4.4.0) (2021-01-19) + +### Bug Fixes + +- better description for `--no-watch-options-stdin` ([#2288](https://github.com/webpack/webpack-cli/issues/2288)) ([4ee8665](https://github.com/webpack/webpack-cli/commit/4ee8665e01e8dce16448e0a4d3dd2293731695ab)) +- double commands output in help ([#2298](https://github.com/webpack/webpack-cli/issues/2298)) ([efe81e9](https://github.com/webpack/webpack-cli/commit/efe81e986a6dca5cc9b72a5c9312dc21409f65b1)) +- pass all `argv` to configurations when `serve` command used ([#2345](https://github.com/webpack/webpack-cli/issues/2345)) ([5070b9b](https://github.com/webpack/webpack-cli/commit/5070b9bcbd5bdac00088d0c21486ad181a4df000)) +- respect `--stats`, `--color` and `--no-color` option for `serve` command ([#2312](https://github.com/webpack/webpack-cli/issues/2312)) ([73d3fec](https://github.com/webpack/webpack-cli/commit/73d3feced18b4e3708f958707326a6642a594cf2)) +- show exact package name while prompting for installation ([#2338](https://github.com/webpack/webpack-cli/issues/2338)) ([ffc93e5](https://github.com/webpack/webpack-cli/commit/ffc93e556d784e2d4409cb0d3a92d737850996f4)) +- webpack installation prompt message ([#2316](https://github.com/webpack/webpack-cli/issues/2316)) ([3659c5e](https://github.com/webpack/webpack-cli/commit/3659c5e529fe1319251ef1c713d6cc758f7f5353)) + +### Features + +- added the `configtest` command ([#2303](https://github.com/webpack/webpack-cli/issues/2303)) ([eb7b189](https://github.com/webpack/webpack-cli/commit/eb7b18937d045261a5b20ca8356e8b4ae4dfcaad)) +- added the `build` command (aliases - `bundle` and `b`) ([7590f66](https://github.com/webpack/webpack-cli/commit/7590f66663ce701d52d9276c3adf9dbdfd1a0fa4)) +- added the `watch` command ([#2357](https://github.com/webpack/webpack-cli/issues/2357)) ([9693f7d](https://github.com/webpack/webpack-cli/commit/9693f7d9543a8fce610c4ef903ccca0d12d229a1)) +- allow to pass parseOption to CLI class ([#2299](https://github.com/webpack/webpack-cli/issues/2299)) ([2af0801](https://github.com/webpack/webpack-cli/commit/2af08013852a95c6f6462c56a9994a4ee28c6ea1)) +- allow to use `help` command to show option information ([#2353](https://github.com/webpack/webpack-cli/issues/2353)) ([15eb411](https://github.com/webpack/webpack-cli/commit/15eb411237dcdcf0db7a501c103fe53f9b82903f)) +- show multiple suggestions on unknown options ([#2349](https://github.com/webpack/webpack-cli/issues/2349)) ([7314d6c](https://github.com/webpack/webpack-cli/commit/7314d6ca927473da2f355a7d356a943471488606)) + ## [4.3.1](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.0...webpack-cli@4.3.1) (2020-12-31) ### Bug Fixes From 78074cac284e8230823c32dc43d928324d000847 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 19 Jan 2021 16:38:46 +0300 Subject: [PATCH 273/581] chore: update `commander` (#2365) --- packages/info/src/index.ts | 7 +- packages/init/src/index.ts | 4 +- packages/serve/src/index.ts | 3 +- packages/webpack-cli/__tests__/CLI.test.js | 212 +++++++++--------- .../lib/utils/capitalize-first-letter.js | 9 + packages/webpack-cli/lib/webpack-cli.js | 20 +- packages/webpack-cli/package.json | 2 +- .../function-with-env.test.js | 2 +- test/defaults/output-defaults.test.js | 2 +- test/info/info-unknown.test.js | 2 +- test/output/output-named-bundles.test.js | 2 +- test/prefetch/prefetch.test.js | 2 +- test/serve/basic/serve-basic.test.js | 4 +- test/target/flag-test/target-flag.test.js | 2 +- test/unknown/unknown.test.js | 40 ++-- yarn.lock | 5 + 16 files changed, 167 insertions(+), 151 deletions(-) create mode 100644 packages/webpack-cli/lib/utils/capitalize-first-letter.js diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index 83b3884d7c1..3cc41ec587f 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -31,6 +31,8 @@ const DEFAULT_DETAILS: Information = { class InfoCommand { async apply(cli): Promise { + const { logger } = cli; + await cli.makeCommand( { name: 'info', @@ -46,10 +48,9 @@ class InfoCommand { description: 'To get the output in specified format ( accept json or markdown )', }, ], - async (program) => { - let { output } = program.opts(); + async (options) => { + let { output } = options; - const { logger } = cli; const envinfoConfig = {}; if (output) { diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index 3eb7b545909..077e673053c 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -27,9 +27,7 @@ class InitCommand { description: 'To scaffold in a specified path', }, ], - async (scaffold, program) => { - const options = program.opts(); - + async (scaffold, options) => { if (scaffold && scaffold.length > 0) { await npmPackagesExists(scaffold); diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index ce3c4ebe781..3448af21808 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -28,7 +28,7 @@ class ServeCommand { return [...builtInOptions, ...devServerFlags]; }, - async (program) => { + async (options) => { const builtInOptions = cli.getBuiltInOptions(); let devServerFlags = []; @@ -43,7 +43,6 @@ class ServeCommand { const webpackOptions: Record = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any const devServerOptions: Record = {}; - const options = program.opts(); // eslint-disable-next-line @typescript-eslint/no-explicit-any const processors: Array<(opts: Record) => void> = []; diff --git a/packages/webpack-cli/__tests__/CLI.test.js b/packages/webpack-cli/__tests__/CLI.test.js index 99cae68b35e..348e081893a 100644 --- a/packages/webpack-cli/__tests__/CLI.test.js +++ b/packages/webpack-cli/__tests__/CLI.test.js @@ -11,8 +11,8 @@ describe('CLI API', () => { it('should make command', async (done) => { cli.program.commands = []; - const command = await cli.makeCommand({ name: 'command' }, [], (program) => { - expect(program.opts()).toEqual({}); + const command = await cli.makeCommand({ name: 'command' }, [], (options) => { + expect(options).toEqual({}); done(); }); @@ -33,8 +33,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ boolean: true }); + (options) => { + expect(options).toEqual({ boolean: true }); done(); }, @@ -57,8 +57,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ boolean: true }); + (options) => { + expect(options).toEqual({ boolean: true }); done(); }, @@ -82,8 +82,8 @@ describe('CLI API', () => { negative: true, }, ], - (program) => { - expect(program.opts()).toEqual({ boolean: false }); + (options) => { + expect(options).toEqual({ boolean: false }); done(); }, @@ -107,8 +107,8 @@ describe('CLI API', () => { negative: true, }, ], - (program) => { - expect(program.opts()).toEqual({ boolean: false }); + (options) => { + expect(options).toEqual({ boolean: false }); done(); }, @@ -132,8 +132,8 @@ describe('CLI API', () => { negative: true, }, ], - (program) => { - expect(program.opts()).toEqual({ boolean: true }); + (options) => { + expect(options).toEqual({ boolean: true }); done(); }, @@ -157,8 +157,8 @@ describe('CLI API', () => { defaultValue: false, }, ], - (program) => { - expect(program.opts()).toEqual({ boolean: false }); + (options) => { + expect(options).toEqual({ boolean: false }); done(); }, @@ -181,8 +181,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ string: 'bar' }); + (options) => { + expect(options).toEqual({ string: 'bar' }); done(); }, @@ -206,8 +206,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ string: 'foo' }); + (options) => { + expect(options).toEqual({ string: 'foo' }); done(); }, @@ -231,8 +231,8 @@ describe('CLI API', () => { defaultValue: 'default-value', }, ], - (program) => { - expect(program.opts()).toEqual({ string: 'default-value' }); + (options) => { + expect(options).toEqual({ string: 'default-value' }); done(); }, @@ -256,8 +256,8 @@ describe('CLI API', () => { defaultValue: 'default-value', }, ], - (program) => { - expect(program.opts()).toEqual({ string: 'foo' }); + (options) => { + expect(options).toEqual({ string: 'foo' }); done(); }, @@ -280,8 +280,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ string: 'bar' }); + (options) => { + expect(options).toEqual({ string: 'bar' }); done(); }, @@ -305,8 +305,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ string: ['foo', 'bar'] }); + (options) => { + expect(options).toEqual({ string: ['foo', 'bar'] }); done(); }, @@ -331,8 +331,8 @@ describe('CLI API', () => { defaultValue: 'string', }, ], - (program) => { - expect(program.opts()).toEqual({ string: 'string' }); + (options) => { + expect(options).toEqual({ string: 'string' }); done(); }, @@ -357,8 +357,8 @@ describe('CLI API', () => { defaultValue: 'string', }, ], - (program) => { - expect(program.opts()).toEqual({ string: ['foo', 'bar'] }); + (options) => { + expect(options).toEqual({ string: ['foo', 'bar'] }); done(); }, @@ -382,8 +382,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ string: ['foo', 'bar'] }); + (options) => { + expect(options).toEqual({ string: ['foo', 'bar'] }); done(); }, @@ -406,8 +406,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ number: 12 }); + (options) => { + expect(options).toEqual({ number: 12 }); done(); }, @@ -431,8 +431,8 @@ describe('CLI API', () => { defaultValue: 20, }, ], - (program) => { - expect(program.opts()).toEqual({ number: 20 }); + (options) => { + expect(options).toEqual({ number: 20 }); done(); }, @@ -456,8 +456,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ number: [1, 2] }); + (options) => { + expect(options).toEqual({ number: [1, 2] }); done(); }, @@ -482,8 +482,8 @@ describe('CLI API', () => { defaultValue: 50, }, ], - (program) => { - expect(program.opts()).toEqual({ number: [1, 2] }); + (options) => { + expect(options).toEqual({ number: [1, 2] }); done(); }, @@ -508,8 +508,8 @@ describe('CLI API', () => { defaultValue: 50, }, ], - (program) => { - expect(program.opts()).toEqual({ number: 50 }); + (options) => { + expect(options).toEqual({ number: 50 }); done(); }, @@ -534,8 +534,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ custom: 'function' }); + (options) => { + expect(options).toEqual({ custom: 'function' }); done(); }, @@ -561,8 +561,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ custom: 'default' }); + (options) => { + expect(options).toEqual({ custom: 'default' }); done(); }, @@ -588,8 +588,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ custom: ['value', 'other'] }); + (options) => { + expect(options).toEqual({ custom: ['value', 'other'] }); done(); }, @@ -616,8 +616,8 @@ describe('CLI API', () => { defaultValue: 50, }, ], - (program) => { - expect(program.opts()).toEqual({ custom: 50 }); + (options) => { + expect(options).toEqual({ custom: 50 }); done(); }, @@ -651,8 +651,8 @@ describe('CLI API', () => { defaultValue: 50, }, ], - (program) => { - expect(program.opts()).toEqual({ custom: ['foo'] }); + (options) => { + expect(options).toEqual({ custom: ['foo'] }); done(); }, @@ -675,8 +675,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndString: true }); + (options) => { + expect(options).toEqual({ booleanAndString: true }); done(); }, @@ -699,8 +699,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndString: 'value' }); + (options) => { + expect(options).toEqual({ booleanAndString: 'value' }); done(); }, @@ -724,8 +724,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndString: true }); + (options) => { + expect(options).toEqual({ booleanAndString: true }); done(); }, @@ -749,8 +749,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndString: ['bar', 'baz'] }); + (options) => { + expect(options).toEqual({ booleanAndString: ['bar', 'baz'] }); done(); }, @@ -774,8 +774,8 @@ describe('CLI API', () => { negative: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndString: true }); + (options) => { + expect(options).toEqual({ booleanAndString: true }); done(); }, @@ -799,8 +799,8 @@ describe('CLI API', () => { negative: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndString: 'foo' }); + (options) => { + expect(options).toEqual({ booleanAndString: 'foo' }); done(); }, @@ -824,8 +824,8 @@ describe('CLI API', () => { negative: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndString: false }); + (options) => { + expect(options).toEqual({ booleanAndString: false }); done(); }, @@ -848,8 +848,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumber: true }); + (options) => { + expect(options).toEqual({ booleanAndNumber: true }); done(); }, @@ -872,8 +872,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumber: 12 }); + (options) => { + expect(options).toEqual({ booleanAndNumber: 12 }); done(); }, @@ -896,8 +896,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ boolean: true }); + (options) => { + expect(options).toEqual({ boolean: true }); done(); }, @@ -920,8 +920,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: true }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: true }); done(); }, @@ -944,8 +944,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: 12 }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: 12 }); done(); }, @@ -968,8 +968,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: 'bar' }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: 'bar' }); done(); }, @@ -993,8 +993,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: 'default' }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: 'default' }); done(); }, @@ -1018,8 +1018,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: 'foo' }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: 'foo' }); done(); }, @@ -1043,8 +1043,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: 12 }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: 12 }); done(); }, @@ -1068,8 +1068,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: 'default' }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: 'default' }); done(); }, @@ -1093,8 +1093,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: true }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: true }); done(); }, @@ -1118,8 +1118,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo'] }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: ['foo'] }); done(); }, @@ -1143,8 +1143,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: [12] }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: [12] }); done(); }, @@ -1168,8 +1168,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo', 'bar'] }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: ['foo', 'bar'] }); done(); }, @@ -1193,8 +1193,8 @@ describe('CLI API', () => { multiple: true, }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo', 12] }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: ['foo', 12] }); done(); }, @@ -1219,8 +1219,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: 'default' }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: 'default' }); done(); }, @@ -1245,8 +1245,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo'] }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: ['foo'] }); done(); }, @@ -1271,8 +1271,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: [12] }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: [12] }); done(); }, @@ -1297,8 +1297,8 @@ describe('CLI API', () => { defaultValue: 'default', }, ], - (program) => { - expect(program.opts()).toEqual({ booleanAndNumberAndString: ['foo', 12] }); + (options) => { + expect(options).toEqual({ booleanAndNumberAndString: ['foo', 12] }); done(); }, @@ -1321,8 +1321,8 @@ describe('CLI API', () => { description: 'description', }, ], - (program) => { - expect(program.opts()).toEqual({ unknown: 'foo' }); + (options) => { + expect(options).toEqual({ unknown: 'foo' }); done(); }, diff --git a/packages/webpack-cli/lib/utils/capitalize-first-letter.js b/packages/webpack-cli/lib/utils/capitalize-first-letter.js new file mode 100644 index 00000000000..3ddf802630a --- /dev/null +++ b/packages/webpack-cli/lib/utils/capitalize-first-letter.js @@ -0,0 +1,9 @@ +const capitalizeFirstLetter = (string) => { + if (typeof string !== 'string') { + return ''; + } + + return string.charAt(0).toUpperCase() + string.slice(1); +}; + +module.exports = capitalizeFirstLetter; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 3e7427e2658..2de8f796d2e 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -10,6 +10,7 @@ const { distance } = require('fastest-levenshtein'); const { options: coloretteOptions, yellow, cyan, green, bold } = require('colorette'); const logger = require('./utils/logger'); +const capitalizeFirstLetter = require('./utils/capitalize-first-letter'); const { cli, flags } = require('./utils/cli-flags'); const CLIPlugin = require('./plugins/CLIPlugin'); const promptInstallation = require('./utils/prompt-installation'); @@ -17,13 +18,18 @@ const toKebabCase = require('./utils/to-kebab-case'); class WebpackCLI { constructor() { - // Initialize program - this.program = program; - this.program.name('webpack'); - this.program.storeOptionsAsProperties(false); + // Global this.webpack = webpack; this.logger = logger; this.utils = { toKebabCase, getPkg, promptInstallation }; + + // Initialize program + this.program = program; + this.program.name('webpack'); + this.program.configureOutput({ + writeErr: logger.error, + outputError: (str, write) => write(`Error: ${capitalizeFirstLetter(str.replace(/^error:/, '').trim())}`), + }); } async makeCommand(commandOptions, options, action) { @@ -357,9 +363,7 @@ class WebpackCLI { await this.makeCommand( isBuildCommandUsed ? buildCommandOptions : watchCommandOptions, this.getBuiltInOptions(), - async (program) => { - const options = program.opts(); - + async (options, program) => { if (program.args.length > 0) { const possibleCommands = [].concat([buildCommandOptions.name]).concat(program.args); @@ -757,7 +761,7 @@ class WebpackCLI { // Default action this.program.usage('[options]'); this.program.allowUnknownOption(true); - this.program.action(async (program) => { + this.program.action(async (_, program) => { if (!isInternalActionCalled) { isInternalActionCalled = true; } else { diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 1e9767a48ca..bbeea374eba 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -32,7 +32,7 @@ "@webpack-cli/info": "^1.2.1", "@webpack-cli/serve": "^1.2.2", "colorette": "^1.2.1", - "commander": "^6.2.0", + "commander": "^7.0.0", "enquirer": "^2.3.6", "execa": "^5.0.0", "fastest-levenshtein": "^1.0.12", diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index 870cac23548..12a783e31d3 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -8,7 +8,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env']); expect(exitCode).toBe(2); - expect(stderr).toContain(`option '--env ' argument missing`); + expect(stderr).toContain("Error: Option '--env ' argument missing"); expect(stdout).toBeFalsy(); }); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index 71f83302c7e..bd4b4213a91 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -28,7 +28,7 @@ describe('output flag defaults', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js', '--output-path'], false); expect(exitCode).toBe(2); - expect(stderr).toContain("error: option '-o, --output-path ' argument missing"); + expect(stderr).toContain("Error: Option '-o, --output-path ' argument missing"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/info/info-unknown.test.js b/test/info/info-unknown.test.js index 545e4d71a55..4846b8f9d7a 100644 --- a/test/info/info-unknown.test.js +++ b/test/info/info-unknown.test.js @@ -5,7 +5,7 @@ describe('should handle unknown args', () => { const { exitCode, stderr, stdout } = run(__dirname, ['info', '--unknown'], false); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/output/output-named-bundles.test.js b/test/output/output-named-bundles.test.js index e93e0fe70d5..343dd26ae5c 100644 --- a/test/output/output-named-bundles.test.js +++ b/test/output/output-named-bundles.test.js @@ -52,7 +52,7 @@ describe('output flag named bundles', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-path'], false); expect(exitCode).toEqual(2); - expect(stderr).toContain("option '-o, --output-path ' argument missing"); + expect(stderr).toContain("Error: Option '-o, --output-path ' argument missing"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index a9404a5a110..1e1a85ab8f7 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -33,7 +33,7 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`error: option '--prefetch ' argument missing`); + expect(stderr).toContain(`Error: Option '--prefetch ' argument missing`); expect(stdout).toBeFalsy(); }); }); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index ff5a20998c2..3ad7aa8def4 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -245,7 +245,7 @@ describe('basic serve usage', () => { expect(stdout).toContain('/my-public-path/'); expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); } else { - expect(stderr).toContain("unknown option '--output-public-path'"); + expect(stderr).toContain("Error: Unknown option '--output-public-path'"); expect(stdout).toBeFalsy(); } }); @@ -311,7 +311,7 @@ describe('basic serve usage', () => { const { exitCode, stdout, stderr } = await runServe(testPath, ['--port', port, '--unknown-flag']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown-flag'"); + expect(stderr).toContain("Error: Unknown option '--unknown-flag'"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index 0705a117cee..0996e9185be 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -59,7 +59,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target', 'node', '--target', 'invalid']); expect(exitCode).toBe(2); - expect(stderr).toContain(`Error: Unknown target 'invalid'`); + expect(stderr).toContain("Error: Unknown target 'invalid'"); expect(stdout).toBeFalsy(); }); diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index 8f643d63186..ad3b6c97ec3 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -6,7 +6,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -15,7 +15,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-u']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Error: Unknown option '-u'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -24,7 +24,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-u', '--unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Error: Unknown option '-u'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -33,7 +33,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-u', '-u']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Error: Unknown option '-u'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -42,7 +42,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-u', 'foo']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '-u'"); + expect(stderr).toContain("Error: Unknown option '-u'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -51,7 +51,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -60,7 +60,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['b', '--unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -69,7 +69,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', 'bundle']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -78,7 +78,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['info', '--unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -87,7 +87,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['i', '--unknown']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -96,7 +96,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', 'i']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -105,7 +105,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--color']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--unknown'"); + expect(stderr).toContain("Error: Unknown option '--unknown'"); expect(stderr).toContain("\u001b[31mRun 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -114,7 +114,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--no-color']); expect(exitCode).toBe(2); - expect(stderr).not.toContain(`\u001b[31munknown option '--unknown'`); + expect(stderr).not.toContain(`\u001b[31mError: Unknown option '--unknown'`); expect(stderr).not.toContain("\u001b[31mRun 'webpack --help' to see available commands and options"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); @@ -124,7 +124,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entyr', './a.js']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--entyr'"); + expect(stderr).toContain("Error: Unknown option '--entyr'"); expect(stderr).toContain("Did you mean '--entry'?"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); @@ -134,7 +134,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-fileneme', '[name].js']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--output-fileneme'"); + expect(stderr).toContain("Error: Unknown option '--output-fileneme'"); if (isWebpack5) { expect(stderr).toContain("Did you mean '--output-filename'?"); @@ -148,7 +148,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-library-auxiliary-comment-commnjs']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--output-library-auxiliary-comment-commnjs'"); + expect(stderr).toContain("Error: Unknown option '--output-library-auxiliary-comment-commnjs'"); if (isWebpack5) { expect(stderr).toContain("Did you mean '--output-library-auxiliary-comment-commonjs'?"); @@ -163,7 +163,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--entyr', './a.js']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--entyr'"); + expect(stderr).toContain("Error: Unknown option '--entyr'"); expect(stderr).toContain("Did you mean '--entry'?"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); @@ -173,7 +173,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['b', '--entyr', './a.js']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--entyr'"); + expect(stderr).toContain("Error: Unknown option '--entyr'"); expect(stderr).toContain("Did you mean '--entry'?"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); @@ -183,7 +183,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['info', '--outpyt']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--outpyt'"); + expect(stderr).toContain("Error: Unknown option '--outpyt'"); expect(stderr).toContain("Did you mean '--output'?"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); @@ -193,7 +193,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['i', '--outpyt']); expect(exitCode).toBe(2); - expect(stderr).toContain("unknown option '--outpyt'"); + expect(stderr).toContain("Error: Unknown option '--outpyt'"); expect(stderr).toContain("Did you mean '--output'?"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); diff --git a/yarn.lock b/yarn.lock index ca371037d66..ad2dcac08c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3379,6 +3379,11 @@ commander@^6.2.0: resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== +commander@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-7.0.0.tgz#3e2bbfd8bb6724760980988fb5b22b7ee6b71ab2" + integrity sha512-ovx/7NkTrnPuIV8sqk/GjUIIM1+iUQeqA3ye2VNpq9sVoiZsooObWlQy+OPWGI17GDaEoybuAGJm6U8yC077BA== + commitlint-config-cz@^0.13.2: version "0.13.2" resolved "https://registry.yarnpkg.com/commitlint-config-cz/-/commitlint-config-cz-0.13.2.tgz#83f98a1217fb9e1e7cedd6d1d4fdb2d1492a867e" From 7600caba420f785b9a841fca6cccfc577e555367 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 20 Jan 2021 14:07:11 +0300 Subject: [PATCH 274/581] chore(deps-dev): bump @types/node from 14.14.21 to 14.14.22 (#2368) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.21 to 14.14.22. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ad2dcac08c5..788b7ec3f93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1938,9 +1938,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.21" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.21.tgz#d934aacc22424fe9622ebf6857370c052eae464e" - integrity sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A== + version "14.14.22" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18" + integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 23ed6c86b86acbcea85e64e0dbf3da52e0a9f56f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 20 Jan 2021 14:20:03 +0300 Subject: [PATCH 275/581] chore(deps-dev): bump webpack from 5.15.0 to 5.16.0 (#2367) Bumps [webpack](https://github.com/webpack/webpack) from 5.15.0 to 5.16.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.15.0...v5.16.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 788b7ec3f93..d774a850ff0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11073,9 +11073,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.13.0: - version "5.15.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.15.0.tgz#63d7b6228a4e15ee8c89899c2cfdd993e809bdd2" - integrity sha512-y/xG+ONDz78yn3VvP6gAvGr1/gkxOgitvHSXBmquyN8KDtrGEyE3K9WkXOPB7QmfcOBCpO4ELXwNcCYQnEmexA== + version "5.16.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.16.0.tgz#796e093c2d92c229f013aefefde82b50c0572570" + integrity sha512-QOkctcjYfEGxcYg4AzPJafyAQ7ANc266/URkX881uFA7b2k31E0Dmpy1ExfppHOTp1kHDTsRh9sXojVUvgPF0g== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.45" From 85648dbd418deaaada11dd8df1b4469fb8b4817a Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 20 Jan 2021 15:28:32 +0300 Subject: [PATCH 276/581] refactor: code (#2366) --- packages/webpack-cli/lib/webpack-cli.js | 80 ++++++++++--------------- 1 file changed, 32 insertions(+), 48 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 2de8f796d2e..aac07d43a46 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -331,30 +331,6 @@ class WebpackCLI { value === '-h' || value === '--help'; - const getCommandNameAndOptions = (args) => { - let commandName; - const options = []; - - let allowToSearchCommand = true; - - args.forEach((arg) => { - if (!isOption(arg) && allowToSearchCommand) { - commandName = arg; - - allowToSearchCommand = false; - - return; - } - - allowToSearchCommand = false; - - options.push(arg); - }); - - const isDefault = typeof commandName === 'undefined'; - - return { commandName: isDefault ? buildCommandOptions.name : commandName, options, isDefault }; - }; const loadCommandByName = async (commandName, allowToInstall = false) => { const isBuildCommandUsed = isBuildCommand(commandName); const isWatchCommandUsed = isWatchCommand(commandName); @@ -478,13 +454,14 @@ class WebpackCLI { name = name.split('=')[0]; } - const { commandName } = getCommandNameAndOptions(this.program.args); + const { operands } = this.program.parseOptions(this.program.args); + const operand = typeof operands[0] !== 'undefined' ? operands[0] : 'build'; - if (commandName) { - const command = findCommandByName(commandName); + if (operand) { + const command = findCommandByName(operand); if (!command) { - logger.error(`Can't find and load command '${commandName}'`); + logger.error(`Can't find and load command '${operand}'`); logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); } @@ -761,7 +738,7 @@ class WebpackCLI { // Default action this.program.usage('[options]'); this.program.allowUnknownOption(true); - this.program.action(async (_, program) => { + this.program.action(async (options, program) => { if (!isInternalActionCalled) { isInternalActionCalled = true; } else { @@ -769,18 +746,19 @@ class WebpackCLI { process.exit(2); } - const { commandName, options, isDefault } = getCommandNameAndOptions(program.args); - - const opts = program.opts(); + // Command and options + const { operands, unknown } = this.program.parseOptions(program.args); + const hasOperand = typeof operands[0] !== 'undefined'; + const operand = hasOperand ? operands[0] : 'build'; - const isHelpCommandSyntax = isHelpCommand(commandName); + const isHelpCommandSyntax = isHelpCommand(operand); - if (opts.help || isHelpCommandSyntax) { + if (options.help || isHelpCommandSyntax) { let isVerbose = false; - if (opts.help) { - if (typeof opts.help === 'string') { - if (opts.help !== 'verbose') { + if (options.help) { + if (typeof options.help === 'string') { + if (options.help !== 'verbose') { logger.error("Unknown value for '--help' option, please use '--help=verbose'"); process.exit(2); } @@ -792,26 +770,32 @@ class WebpackCLI { this.program.forHelp = true; const optionsForHelp = [] - .concat(opts.help && !isDefault ? [commandName] : []) - .concat(options) - .concat(isHelpCommandSyntax && typeof opts.color !== 'undefined' ? [opts.color ? '--color' : '--no-color'] : []) - .concat(isHelpCommandSyntax && typeof opts.version !== 'undefined' ? ['--version'] : []); + .concat(options.help && hasOperand ? [operand] : []) + // Syntax `webpack help [command]` + .concat(operands.slice(1)) + // Syntax `webpack help [option]` + .concat(unknown) + .concat(isHelpCommandSyntax && typeof options.color !== 'undefined' ? [options.color ? '--color' : '--no-color'] : []) + .concat(isHelpCommandSyntax && typeof options.version !== 'undefined' ? ['--version'] : []); await outputHelp(optionsForHelp, isVerbose, isHelpCommandSyntax, program); } - if (opts.version || isVersionCommand(commandName)) { - const optionsForVersion = [].concat(opts.version ? [commandName] : []).concat(options); + if (options.version || isVersionCommand(operand)) { + const optionsForVersion = [] + .concat(options.version ? [operand] : []) + .concat(operands.slice(1)) + .concat(unknown); await outputVersion(optionsForVersion, program); } - if (isKnownCommand(commandName)) { - await loadCommandByName(commandName, true); + if (isKnownCommand(operand)) { + await loadCommandByName(operand, true); } else { - logger.error(`Unknown command '${commandName}'`); + logger.error(`Unknown command '${operand}'`); - const found = knownCommands.find((commandOptions) => distance(commandName, getCommandName(commandOptions.name)) < 3); + const found = knownCommands.find((commandOptions) => distance(operand, getCommandName(commandOptions.name)) < 3); if (found) { logger.error( @@ -825,7 +809,7 @@ class WebpackCLI { process.exit(2); } - await this.program.parseAsync([commandName, ...options], { from: 'user' }); + await this.program.parseAsync([operand, ...operands.slice(1), ...unknown], { from: 'user' }); }); await this.program.parseAsync(args, parseOptions); From 53e8a539d842681d6b3e015c57e756fc7b7a3c57 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 21 Jan 2021 17:09:30 +0300 Subject: [PATCH 277/581] chore(deps-dev): bump webpack-bundle-analyzer from 4.3.0 to 4.4.0 (#2371) Bumps [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) from 4.3.0 to 4.4.0. - [Release notes](https://github.com/webpack-contrib/webpack-bundle-analyzer/releases) - [Changelog](https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/webpack-bundle-analyzer/compare/v4.3.0...v4.4.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d774a850ff0..d98aba10c17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10984,9 +10984,9 @@ webidl-conversions@^6.1.0: integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w== webpack-bundle-analyzer@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.3.0.tgz#2f3c0ca9041d5ee47fa418693cf56b4a518b578b" - integrity sha512-J3TPm54bPARx6QG8z4cKBszahnUglcv70+N+8gUqv2I5KOFHJbzBiLx+pAp606so0X004fxM7hqRu10MLjJifA== + version "4.4.0" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.4.0.tgz#74013106e7e2b07cbd64f3a5ae847f7e814802c7" + integrity sha512-9DhNa+aXpqdHk8LkLPTBU/dMfl84Y+WE2+KnfI6rSpNRNVKa0VGLjPd2pjFubDeqnWmulFggxmWBxhfJXZnR0g== dependencies: acorn "^8.0.4" acorn-walk "^8.0.0" From 0d30eda2e0345d6e323408218e420bd6d1b090e2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 22 Jan 2021 05:50:37 -0500 Subject: [PATCH 278/581] docs: mention `-p` in the changelog (#2372) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92155dfb12a..ad016fcba6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -219,7 +219,7 @@ ## Refactor -- remove --dev and --prod flags ([#1693](https://github.com/webpack/webpack-cli/pull/1693)) +- remove --dev and --prod flags and their aliases -d and -p ([#1693](https://github.com/webpack/webpack-cli/pull/1693)) - remove duplicate invocation ([#1790](https://github.com/webpack/webpack-cli/pull/1790)) - cliExecuter consumes runCLI ([#1754](https://github.com/webpack/webpack-cli/pull/1754)) - remove --mode flag validation ([#1744](https://github.com/webpack/webpack-cli/pull/1744)) From c5a06f7b58d161f525183c73b96ab339712bb681 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 26 Jan 2021 17:09:55 +0530 Subject: [PATCH 279/581] chore: update webpack to 5.17.0 (#2376) --- OPTIONS.md | 126 ++++++++++++++++++++--- package.json | 2 +- packages/webpack-cli/README.md | 70 +++++++------ test/core-flags/experiments-flag.test.js | 45 +++++--- yarn.lock | 17 +-- 5 files changed, 194 insertions(+), 66 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index 3fbe2a31dd4..fd2ea885820 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -53,6 +53,11 @@ Options: --no-experiments-async-web-assembly Negative 'experiments-async-web-assembly' option. --experiments-layers Enable module and chunk layers. --no-experiments-layers Negative 'experiments-layers' option. + --experiments-lazy-compilation Compile entrypoints and import()s only when they are accessed. + --no-experiments-lazy-compilation Negative 'experiments-lazy-compilation' option. + --experiments-lazy-compilation-client A custom client. + --experiments-lazy-compilation-entries Enable/disable lazy compilation for entries. + --no-experiments-lazy-compilation-entries Negative 'experiments-lazy-compilation-entries' option. --experiments-output-module Allow output javascript files as module source type. --no-experiments-output-module Negative 'experiments-output-module' option. --experiments-sync-web-assembly Support WebAssembly as synchronous EcmaScript Module (outdated). @@ -89,10 +94,10 @@ Options: --mode Defines the mode to pass to webpack. --module-expr-context-critical Enable warnings for full dynamic dependencies. --no-module-expr-context-critical Negative 'module-expr-context-critical' option. - --module-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. + --module-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. Deprecated: This option has moved to 'module.parser.javascript.exprContextRecursive'. --no-module-expr-context-recursive Negative 'module-expr-context-recursive' option. - --module-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. - --module-expr-context-request Set the default request for full dynamic dependencies. + --module-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. Deprecated: This option has moved to 'module.parser.javascript.exprContextRegExp'. + --module-expr-context-request Set the default request for full dynamic dependencies. Deprecated: This option has moved to 'module.parser.javascript.exprContextRequest'. --module-generator-asset-data-url-encoding Asset encoding (defaults to base64). --module-generator-asset-data-url-mimetype Asset mimetype (getting from file extension by default). --module-generator-asset-filename Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk. @@ -108,6 +113,14 @@ Options: --no-module-parser-javascript-browserify Negative 'module-parser-javascript-browserify' option. --module-parser-javascript-commonjs Enable/disable parsing of CommonJs syntax. --no-module-parser-javascript-commonjs Negative 'module-parser-javascript-commonjs' option. + --module-parser-javascript-commonjs-magic-comments Enable/disable parsing of magic comments in CommonJs syntax. + --no-module-parser-javascript-commonjs-magic-comments Negative 'module-parser-javascript-commonjs-magic-comments' option. + --module-parser-javascript-expr-context-critical Enable warnings for full dynamic dependencies. + --no-module-parser-javascript-expr-context-critical Negative 'module-parser-javascript-expr-context-critical' option. + --module-parser-javascript-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. + --no-module-parser-javascript-expr-context-recursive Negative 'module-parser-javascript-expr-context-recursive' option. + --module-parser-javascript-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. + --module-parser-javascript-expr-context-request Set the default request for full dynamic dependencies. --module-parser-javascript-harmony Enable/disable parsing of EcmaScript Modules syntax. --no-module-parser-javascript-harmony Negative 'module-parser-javascript-harmony' option. --module-parser-javascript-import Enable/disable parsing of import() syntax. @@ -126,18 +139,41 @@ Options: --no-module-parser-javascript-require-include Negative 'module-parser-javascript-require-include' option. --module-parser-javascript-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. --no-module-parser-javascript-require-js Negative 'module-parser-javascript-require-js' option. + --module-parser-javascript-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported module. + --no-module-parser-javascript-strict-export-presence Negative 'module-parser-javascript-strict-export-presence' option. + --module-parser-javascript-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace objects. + --no-module-parser-javascript-strict-this-context-on-imports Negative 'module-parser-javascript-strict-this-context-on-imports' option. --module-parser-javascript-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. --no-module-parser-javascript-system Negative 'module-parser-javascript-system' option. + --module-parser-javascript-unknown-context-critical Enable warnings when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-unknown-context-critical Negative 'module-parser-javascript-unknown-context-critical' option. + --module-parser-javascript-unknown-context-recursive Enable recursive directory lookup when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-unknown-context-recursive Negative 'module-parser-javascript-unknown-context-recursive' option. + --module-parser-javascript-unknown-context-reg-exp Sets the regular expression when using the require function in a not statically analyse-able way. + --module-parser-javascript-unknown-context-request Sets the request when using the require function in a not statically analyse-able way. --module-parser-javascript-url Enable/disable parsing of new URL() syntax. --no-module-parser-javascript-url Negative 'module-parser-javascript-url' option. --module-parser-javascript-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). --module-parser-javascript-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-wrapped-context-critical Enable warnings for partial dynamic dependencies. + --no-module-parser-javascript-wrapped-context-critical Negative 'module-parser-javascript-wrapped-context-critical' option. + --module-parser-javascript-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. + --no-module-parser-javascript-wrapped-context-recursive Negative 'module-parser-javascript-wrapped-context-recursive' option. + --module-parser-javascript-wrapped-context-reg-exp Set the inner regular expression for partial dynamic dependencies. --module-parser-javascript-auto-amd You can pass `false` to disable AMD support. --no-module-parser-javascript-auto-amd Negative 'module-parser-javascript-auto-amd' option. --module-parser-javascript-auto-browserify Enable/disable special handling for browserify bundles. --no-module-parser-javascript-auto-browserify Negative 'module-parser-javascript-auto-browserify' option. --module-parser-javascript-auto-commonjs Enable/disable parsing of CommonJs syntax. --no-module-parser-javascript-auto-commonjs Negative 'module-parser-javascript-auto-commonjs' option. + --module-parser-javascript-auto-commonjs-magic-comments Enable/disable parsing of magic comments in CommonJs syntax. + --no-module-parser-javascript-auto-commonjs-magic-comments Negative 'module-parser-javascript-auto-commonjs-magic-comments' option. + --module-parser-javascript-auto-expr-context-critical Enable warnings for full dynamic dependencies. + --no-module-parser-javascript-auto-expr-context-critical Negative 'module-parser-javascript-auto-expr-context-critical' option. + --module-parser-javascript-auto-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. + --no-module-parser-javascript-auto-expr-context-recursive Negative 'module-parser-javascript-auto-expr-context-recursive' option. + --module-parser-javascript-auto-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. + --module-parser-javascript-auto-expr-context-request Set the default request for full dynamic dependencies. --module-parser-javascript-auto-harmony Enable/disable parsing of EcmaScript Modules syntax. --no-module-parser-javascript-auto-harmony Negative 'module-parser-javascript-auto-harmony' option. --module-parser-javascript-auto-import Enable/disable parsing of import() syntax. @@ -156,18 +192,41 @@ Options: --no-module-parser-javascript-auto-require-include Negative 'module-parser-javascript-auto-require-include' option. --module-parser-javascript-auto-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. --no-module-parser-javascript-auto-require-js Negative 'module-parser-javascript-auto-require-js' option. + --module-parser-javascript-auto-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported module. + --no-module-parser-javascript-auto-strict-export-presence Negative 'module-parser-javascript-auto-strict-export-presence' option. + --module-parser-javascript-auto-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace objects. + --no-module-parser-javascript-auto-strict-this-context-on-imports Negative 'module-parser-javascript-auto-strict-this-context-on-imports' option. --module-parser-javascript-auto-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. --no-module-parser-javascript-auto-system Negative 'module-parser-javascript-auto-system' option. + --module-parser-javascript-auto-unknown-context-critical Enable warnings when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-auto-unknown-context-critical Negative 'module-parser-javascript-auto-unknown-context-critical' option. + --module-parser-javascript-auto-unknown-context-recursive Enable recursive directory lookup when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-auto-unknown-context-recursive Negative 'module-parser-javascript-auto-unknown-context-recursive' option. + --module-parser-javascript-auto-unknown-context-reg-exp Sets the regular expression when using the require function in a not statically analyse-able way. + --module-parser-javascript-auto-unknown-context-request Sets the request when using the require function in a not statically analyse-able way. --module-parser-javascript-auto-url Enable/disable parsing of new URL() syntax. --no-module-parser-javascript-auto-url Negative 'module-parser-javascript-auto-url' option. --module-parser-javascript-auto-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). --module-parser-javascript-auto-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-auto-wrapped-context-critical Enable warnings for partial dynamic dependencies. + --no-module-parser-javascript-auto-wrapped-context-critical Negative 'module-parser-javascript-auto-wrapped-context-critical' option. + --module-parser-javascript-auto-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. + --no-module-parser-javascript-auto-wrapped-context-recursive Negative 'module-parser-javascript-auto-wrapped-context-recursive' option. + --module-parser-javascript-auto-wrapped-context-reg-exp Set the inner regular expression for partial dynamic dependencies. --module-parser-javascript-dynamic-amd You can pass `false` to disable AMD support. --no-module-parser-javascript-dynamic-amd Negative 'module-parser-javascript-dynamic-amd' option. --module-parser-javascript-dynamic-browserify Enable/disable special handling for browserify bundles. --no-module-parser-javascript-dynamic-browserify Negative 'module-parser-javascript-dynamic-browserify' option. --module-parser-javascript-dynamic-commonjs Enable/disable parsing of CommonJs syntax. --no-module-parser-javascript-dynamic-commonjs Negative 'module-parser-javascript-dynamic-commonjs' option. + --module-parser-javascript-dynamic-commonjs-magic-comments Enable/disable parsing of magic comments in CommonJs syntax. + --no-module-parser-javascript-dynamic-commonjs-magic-comments Negative 'module-parser-javascript-dynamic-commonjs-magic-comments' option. + --module-parser-javascript-dynamic-expr-context-critical Enable warnings for full dynamic dependencies. + --no-module-parser-javascript-dynamic-expr-context-critical Negative 'module-parser-javascript-dynamic-expr-context-critical' option. + --module-parser-javascript-dynamic-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. + --no-module-parser-javascript-dynamic-expr-context-recursive Negative 'module-parser-javascript-dynamic-expr-context-recursive' option. + --module-parser-javascript-dynamic-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. + --module-parser-javascript-dynamic-expr-context-request Set the default request for full dynamic dependencies. --module-parser-javascript-dynamic-harmony Enable/disable parsing of EcmaScript Modules syntax. --no-module-parser-javascript-dynamic-harmony Negative 'module-parser-javascript-dynamic-harmony' option. --module-parser-javascript-dynamic-import Enable/disable parsing of import() syntax. @@ -186,18 +245,41 @@ Options: --no-module-parser-javascript-dynamic-require-include Negative 'module-parser-javascript-dynamic-require-include' option. --module-parser-javascript-dynamic-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. --no-module-parser-javascript-dynamic-require-js Negative 'module-parser-javascript-dynamic-require-js' option. + --module-parser-javascript-dynamic-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported module. + --no-module-parser-javascript-dynamic-strict-export-presence Negative 'module-parser-javascript-dynamic-strict-export-presence' option. + --module-parser-javascript-dynamic-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace objects. + --no-module-parser-javascript-dynamic-strict-this-context-on-imports Negative 'module-parser-javascript-dynamic-strict-this-context-on-imports' option. --module-parser-javascript-dynamic-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. --no-module-parser-javascript-dynamic-system Negative 'module-parser-javascript-dynamic-system' option. + --module-parser-javascript-dynamic-unknown-context-critical Enable warnings when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-dynamic-unknown-context-critical Negative 'module-parser-javascript-dynamic-unknown-context-critical' option. + --module-parser-javascript-dynamic-unknown-context-recursive Enable recursive directory lookup when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-dynamic-unknown-context-recursive Negative 'module-parser-javascript-dynamic-unknown-context-recursive' option. + --module-parser-javascript-dynamic-unknown-context-reg-exp Sets the regular expression when using the require function in a not statically analyse-able way. + --module-parser-javascript-dynamic-unknown-context-request Sets the request when using the require function in a not statically analyse-able way. --module-parser-javascript-dynamic-url Enable/disable parsing of new URL() syntax. --no-module-parser-javascript-dynamic-url Negative 'module-parser-javascript-dynamic-url' option. --module-parser-javascript-dynamic-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). --module-parser-javascript-dynamic-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-dynamic-wrapped-context-critical Enable warnings for partial dynamic dependencies. + --no-module-parser-javascript-dynamic-wrapped-context-critical Negative 'module-parser-javascript-dynamic-wrapped-context-critical' option. + --module-parser-javascript-dynamic-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. + --no-module-parser-javascript-dynamic-wrapped-context-recursive Negative 'module-parser-javascript-dynamic-wrapped-context-recursive' option. + --module-parser-javascript-dynamic-wrapped-context-reg-exp Set the inner regular expression for partial dynamic dependencies. --module-parser-javascript-esm-amd You can pass `false` to disable AMD support. --no-module-parser-javascript-esm-amd Negative 'module-parser-javascript-esm-amd' option. --module-parser-javascript-esm-browserify Enable/disable special handling for browserify bundles. --no-module-parser-javascript-esm-browserify Negative 'module-parser-javascript-esm-browserify' option. --module-parser-javascript-esm-commonjs Enable/disable parsing of CommonJs syntax. --no-module-parser-javascript-esm-commonjs Negative 'module-parser-javascript-esm-commonjs' option. + --module-parser-javascript-esm-commonjs-magic-comments Enable/disable parsing of magic comments in CommonJs syntax. + --no-module-parser-javascript-esm-commonjs-magic-comments Negative 'module-parser-javascript-esm-commonjs-magic-comments' option. + --module-parser-javascript-esm-expr-context-critical Enable warnings for full dynamic dependencies. + --no-module-parser-javascript-esm-expr-context-critical Negative 'module-parser-javascript-esm-expr-context-critical' option. + --module-parser-javascript-esm-expr-context-recursive Enable recursive directory lookup for full dynamic dependencies. + --no-module-parser-javascript-esm-expr-context-recursive Negative 'module-parser-javascript-esm-expr-context-recursive' option. + --module-parser-javascript-esm-expr-context-reg-exp Sets the default regular expression for full dynamic dependencies. + --module-parser-javascript-esm-expr-context-request Set the default request for full dynamic dependencies. --module-parser-javascript-esm-harmony Enable/disable parsing of EcmaScript Modules syntax. --no-module-parser-javascript-esm-harmony Negative 'module-parser-javascript-esm-harmony' option. --module-parser-javascript-esm-import Enable/disable parsing of import() syntax. @@ -216,12 +298,27 @@ Options: --no-module-parser-javascript-esm-require-include Negative 'module-parser-javascript-esm-require-include' option. --module-parser-javascript-esm-require-js Enable/disable parsing of require.js special syntax like require.config, requirejs.config, require.version and requirejs.onError. --no-module-parser-javascript-esm-require-js Negative 'module-parser-javascript-esm-require-js' option. + --module-parser-javascript-esm-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported module. + --no-module-parser-javascript-esm-strict-export-presence Negative 'module-parser-javascript-esm-strict-export-presence' option. + --module-parser-javascript-esm-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace objects. + --no-module-parser-javascript-esm-strict-this-context-on-imports Negative 'module-parser-javascript-esm-strict-this-context-on-imports' option. --module-parser-javascript-esm-system Enable/disable parsing of System.js special syntax like System.import, System.get, System.set and System.register. --no-module-parser-javascript-esm-system Negative 'module-parser-javascript-esm-system' option. + --module-parser-javascript-esm-unknown-context-critical Enable warnings when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-esm-unknown-context-critical Negative 'module-parser-javascript-esm-unknown-context-critical' option. + --module-parser-javascript-esm-unknown-context-recursive Enable recursive directory lookup when using the require function in a not statically analyse-able way. + --no-module-parser-javascript-esm-unknown-context-recursive Negative 'module-parser-javascript-esm-unknown-context-recursive' option. + --module-parser-javascript-esm-unknown-context-reg-exp Sets the regular expression when using the require function in a not statically analyse-able way. + --module-parser-javascript-esm-unknown-context-request Sets the request when using the require function in a not statically analyse-able way. --module-parser-javascript-esm-url Enable/disable parsing of new URL() syntax. --no-module-parser-javascript-esm-url Negative 'module-parser-javascript-esm-url' option. --module-parser-javascript-esm-worker Specify a syntax that should be parsed as WebWorker reference. 'Abc' handles 'new Abc()', 'Abc from xyz' handles 'import { Abc } from "xyz"; new Abc()', 'abc()' handles 'abc()', and combinations are also possible. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). --module-parser-javascript-esm-worker-reset Clear all items provided in configuration. Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register(). + --module-parser-javascript-esm-wrapped-context-critical Enable warnings for partial dynamic dependencies. + --no-module-parser-javascript-esm-wrapped-context-critical Negative 'module-parser-javascript-esm-wrapped-context-critical' option. + --module-parser-javascript-esm-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. + --no-module-parser-javascript-esm-wrapped-context-recursive Negative 'module-parser-javascript-esm-wrapped-context-recursive' option. + --module-parser-javascript-esm-wrapped-context-reg-exp Set the inner regular expression for partial dynamic dependencies. --module-rules-compiler Match the child compiler name. --module-rules-dependency Match dependency type. --module-rules-enforce Enforce this rule as pre or post step. @@ -245,23 +342,23 @@ Options: --module-rules-use-options Options passed to a loader. --module-rules-use A loader request. --module-rules-reset Clear all items provided in configuration. A list of rules. - --module-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported module. + --module-strict-export-presence Emit errors instead of warnings when imported names don't exist in imported module. Deprecated: This option has moved to 'module.parser.javascript.strictExportPresence'. --no-module-strict-export-presence Negative 'module-strict-export-presence' option. - --module-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace objects. + --module-strict-this-context-on-imports Handle the this context correctly according to the spec for namespace objects. Deprecated: This option has moved to 'module.parser.javascript.strictThisContextOnImports'. --no-module-strict-this-context-on-imports Negative 'module-strict-this-context-on-imports' option. - --module-unknown-context-critical Enable warnings when using the require function in a not statically analyse-able way. + --module-unknown-context-critical Enable warnings when using the require function in a not statically analyse-able way. Deprecated: This option has moved to 'module.parser.javascript.unknownContextCritical'. --no-module-unknown-context-critical Negative 'module-unknown-context-critical' option. - --module-unknown-context-recursive Enable recursive directory lookup when using the require function in a not statically analyse-able way. + --module-unknown-context-recursive Enable recursive directory lookup when using the require function in a not statically analyse-able way. Deprecated: This option has moved to 'module.parser.javascript.unknownContextRecursive'. --no-module-unknown-context-recursive Negative 'module-unknown-context-recursive' option. - --module-unknown-context-reg-exp Sets the regular expression when using the require function in a not statically analyse-able way. - --module-unknown-context-request Sets the request when using the require function in a not statically analyse-able way. + --module-unknown-context-reg-exp Sets the regular expression when using the require function in a not statically analyse-able way. Deprecated: This option has moved to 'module.parser.javascript.unknownContextRegExp'. + --module-unknown-context-request Sets the request when using the require function in a not statically analyse-able way. Deprecated: This option has moved to 'module.parser.javascript.unknownContextRequest'. --module-unsafe-cache Cache the resolving of module requests. --no-module-unsafe-cache Negative 'module-unsafe-cache' option. - --module-wrapped-context-critical Enable warnings for partial dynamic dependencies. + --module-wrapped-context-critical Enable warnings for partial dynamic dependencies. Deprecated: This option has moved to 'module.parser.javascript.wrappedContextCritical'. --no-module-wrapped-context-critical Negative 'module-wrapped-context-critical' option. - --module-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. + --module-wrapped-context-recursive Enable recursive directory lookup for partial dynamic dependencies. Deprecated: This option has moved to 'module.parser.javascript.wrappedContextRecursive'. --no-module-wrapped-context-recursive Negative 'module-wrapped-context-recursive' option. - --module-wrapped-context-reg-exp Set the inner regular expression for partial dynamic dependencies. + --module-wrapped-context-reg-exp Set the inner regular expression for partial dynamic dependencies. Deprecated: This option has moved to 'module.parser.javascript.wrappedContextRegExp'. --name Name of the configuration. Used when loading multiple configurations. --node Include polyfills or mocks for various node stuff. --no-node Negative 'node' option. @@ -345,7 +442,7 @@ Options: --output-devtool-namespace Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries. --output-enabled-chunk-loading-types The method of loading chunks (methods included by default are 'jsonp' (web), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins). --output-enabled-chunk-loading-types-reset Clear all items provided in configuration. List of chunk loading types enabled for use by entry points. - --output-enabled-library-types Type of library (types included by default are 'var', 'module', 'assign', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins). + --output-enabled-library-types Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins). --output-enabled-library-types-reset Clear all items provided in configuration. List of library types enabled for use by entry points. --output-enabled-wasm-loading-types The method of loading WebAssembly Modules (methods included by default are 'fetch' (web/WebWorker), 'async-node' (node.js), but others might be added by plugins). --output-enabled-wasm-loading-types-reset Clear all items provided in configuration. List of wasm loading types enabled for use by entry points. @@ -395,7 +492,7 @@ Options: --output-library-name-commonjs Name of the exposed commonjs export in the UMD. --output-library-name-root Part of the name of the property exposed globally by a UMD library. --output-library-name-root-reset Clear all items provided in configuration. Name of the property exposed globally by a UMD library. - --output-library-type Type of library (types included by default are 'var', 'module', 'assign', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins). + --output-library-type Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins). --output-library-umd-named-define If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module. --no-output-library-umd-named-define Negative 'output-library-umd-named-define' option. --output-module Output javascript files as module source type. @@ -571,6 +668,7 @@ Options: --no-stats-chunk-groups Negative 'stats-chunk-groups' option. --stats-chunk-modules Add built modules information to chunk information. --no-stats-chunk-modules Negative 'stats-chunk-modules' option. + --stats-chunk-modules-space Space to display chunk modules (groups will be collapsed to fit this space, value is in number of modules/group). --stats-chunk-origins Add the origins of chunks and chunk merging info. --no-stats-chunk-origins Negative 'stats-chunk-origins' option. --stats-chunk-relations Add information about parent, children and sibling chunks to chunk information. diff --git a/package.json b/package.json index c6592c46c13..f029c615ce4 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", "typescript": "^4.1.3", - "webpack": "^5.13.0", + "webpack": "^5.17.0", "webpack-bundle-analyzer": "^4.3.0", "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 788802545db..ca7f2204b8d 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -63,46 +63,52 @@ npx webpack-cli --help verbose ### Available Commands ``` - bundle | b Run webpack - help | h Display help for commands and options - version | v Output version number of the 'webpack', 'webpack-cli' and other related packages - init | c Initialize a new webpack configuration - migrate | m Migrate a configuration to a new version - loader | l Scaffold a loader repository - plugin | p Scaffold a plugin repository - info | i Outputs information about your system and dependencies - serve | s Run the webpack Dev Server - configtest | t Tests webpack configuration against validation errors. + build|bundle|b [options] Run webpack (default command, can be omitted). + watch|w [options] Run webpack and watch for files changes. + version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + help|h [command] [option] Display help for commands and options. + serve|s [options] Run the webpack dev server. + info|i [options] Outputs information about your system. + init|c [options] [scaffold...] Initialize a new webpack configuration. + loader|l [output-path] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + configtest|t [config-path] Tests webpack configuration against validation errors. + plugin|p [output-path] Scaffold a plugin. ``` ### webpack 4 ``` + Options: --analyze It invokes webpack-bundle-analyzer plugin to get bundle information - --entry string[] The entry point(s) of your application. - -c, --config string[] Provide path to webpack configuration file(s) - --config-name string[] Name of the configuration to use - -m, --merge Merge several configurations using webpack-merge - --progress string, boolean Print compilation progress during build - --color Enables colors on console - --no-color Disable colors on console - --env string[] Environment passed to the configuration when it is a function - --name string Name of the configuration. Used when loading multiple configurations - --help Outputs list of supported flags - -o, --output-path string Output location of the generated bundle - -t, --target string[] Sets the build target - -w, --watch Watch for files changes - --no-watch Do not watch for file changes + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --entry The entry point(s) of your application e.g. ./src/main.js. -h, --hot Enables Hot Module Replacement --no-hot Disables Hot Module Replacement - -d, --devtool string Controls if and how source maps are generated. - --no-devtool Do not generate source maps - --prefetch string Prefetch this request - -j, --json string, boolean Prints result as JSON or store it in a file - --mode string Defines the mode to pass to webpack - -v, --version Get current version - --stats string, boolean It instructs webpack on how to treat the stats - --no-stats Disables stats output + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + --prefetch Prefetch this request + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -t, --target Sets the build target e.g. node. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. + +Global options: + --color Enable colors on console. + --no-color Disable colors on console. + -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + -h, --help [verbose] Display help for commands and options. ``` ### webpack 5 diff --git a/test/core-flags/experiments-flag.test.js b/test/core-flags/experiments-flag.test.js index 07704d3c825..b7554dff33e 100644 --- a/test/core-flags/experiments-flag.test.js +++ b/test/core-flags/experiments-flag.test.js @@ -8,23 +8,42 @@ const experimentsFlags = flags.filter(({ name }) => name.startsWith('experiments describe('experiments option related flag', () => { experimentsFlags.forEach((flag) => { // extract property name from flag name - const property = flag.name.split('experiments-')[1]; + let property; + + if (flag.name.includes('-lazy-compilation-')) { + property = flag.name.split('experiments-lazy-compilation-')[1]; + } else { + property = flag.name.split('experiments-')[1]; + } + const propName = hyphenToUpperCase(property); - it(`should config ${flag.name} correctly`, () => { - const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); + if (flag.type === Boolean) { + it(`should config --${flag.name} correctly`, () => { + const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + + if (flag.name.includes('-lazy-compilation-')) { + expect(stdout).toContain(`lazyCompilation: { ${propName}: true }`); + } else { + expect(stdout).toContain(`${propName}: true`); + } + }); - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(`${propName}: true`); - }); + it(`should config --no-${flag.name} correctly`, () => { + const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - it(`should config --no-${flag.name} correctly`, () => { - const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain(`${propName}: false`); - }); + if (flag.name.includes('-lazy-compilation-')) { + expect(stdout).toContain(`lazyCompilation: { ${propName}: false }`); + } else { + expect(stdout).toContain(`${propName}: false`); + } + }); + } }); }); diff --git a/yarn.lock b/yarn.lock index d98aba10c17..d401919163c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1821,11 +1821,16 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*", "@types/estree@^0.0.45": +"@types/estree@*": version "0.0.45" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884" integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g== +"@types/estree@^0.0.46": + version "0.0.46" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.46.tgz#0fb6bfbbeabd7a30880504993369c4bf1deab1fe" + integrity sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg== + "@types/expect@^1.20.4": version "1.20.4" resolved "https://registry.yarnpkg.com/@types/expect/-/expect-1.20.4.tgz#8288e51737bf7e3ab5d7c77bfa695883745264e5" @@ -11072,13 +11077,13 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.13.0: - version "5.16.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.16.0.tgz#796e093c2d92c229f013aefefde82b50c0572570" - integrity sha512-QOkctcjYfEGxcYg4AzPJafyAQ7ANc266/URkX881uFA7b2k31E0Dmpy1ExfppHOTp1kHDTsRh9sXojVUvgPF0g== +webpack@^5.17.0: + version "5.17.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.17.0.tgz#e92aebad45be25f86f788dc72fc11daacdcfd55d" + integrity sha512-R+IdNEaYcYaACpXZOt7reyc8txBK7J06lOPkX1SbgmeoAnUbyBZivJIksrDBnmMA3wlTWvPcX7DubxELyPB8rA== dependencies: "@types/eslint-scope" "^3.7.0" - "@types/estree" "^0.0.45" + "@types/estree" "^0.0.46" "@webassemblyjs/ast" "1.11.0" "@webassemblyjs/wasm-edit" "1.11.0" "@webassemblyjs/wasm-parser" "1.11.0" From 153d449386ecbf2b9b502fd9b2999bd494f8d256 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 27 Jan 2021 13:38:02 +0300 Subject: [PATCH 280/581] chore(deps-dev): bump webpack from 5.17.0 to 5.18.0 (#2378) Bumps [webpack](https://github.com/webpack/webpack) from 5.17.0 to 5.18.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.17.0...v5.18.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index d401919163c..0dbfd643050 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1821,12 +1821,7 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*": - version "0.0.45" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884" - integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g== - -"@types/estree@^0.0.46": +"@types/estree@*", "@types/estree@^0.0.46": version "0.0.46" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.46.tgz#0fb6bfbbeabd7a30880504993369c4bf1deab1fe" integrity sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg== @@ -11078,9 +11073,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.17.0: - version "5.17.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.17.0.tgz#e92aebad45be25f86f788dc72fc11daacdcfd55d" - integrity sha512-R+IdNEaYcYaACpXZOt7reyc8txBK7J06lOPkX1SbgmeoAnUbyBZivJIksrDBnmMA3wlTWvPcX7DubxELyPB8rA== + version "5.18.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.18.0.tgz#bbcf13094aa0da0534d513f27d7ee72d74e499c6" + integrity sha512-RmiP/iy6ROvVe/S+u0TrvL/oOmvP+2+Bs8MWjvBwwY/j82Q51XJyDJ75m0QAGntL1Wx6B//Xc0+4VPP/hlNHmw== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" From 6b3161479578f572f803f579c7e71073eb797184 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 27 Jan 2021 14:45:38 +0300 Subject: [PATCH 281/581] feat: entries syntax (#2369) --- OPTIONS.md | 40 +- packages/serve/src/index.ts | 10 +- .../webpack-cli/__tests__/resolveArgs.test.js | 20 +- packages/webpack-cli/lib/utils/cli-flags.js | 202 ------ packages/webpack-cli/lib/webpack-cli.js | 669 +++++++++++++----- test/build/basic/basic.test.js | 126 +++- test/build/basic/entry.config.js | 4 + test/build/basic/src/again.js | 1 + test/build/basic/src/entry.js | 1 + test/build/basic/src/other.js | 1 + test/config/absent/config-absent.test.js | 6 +- test/config/invalid-path/invalid-path.test.js | 6 +- .../with-config-path/with-config-path.test.js | 2 +- test/core-flags/experiments-flag.test.js | 5 +- test/core-flags/externals-flags.test.js | 5 +- test/core-flags/module-flags.test.js | 5 +- test/core-flags/optimization-flags.test.js | 5 +- test/core-flags/output-flags.test.js | 5 +- test/core-flags/performance-flags.test.js | 5 +- test/core-flags/resolve-flags.test.js | 5 +- test/core-flags/snapshot-flags.test.js | 5 +- test/core-flags/stats-flags.test.js | 5 +- test/core-flags/watch-flags.test.js | 5 +- test/core-flags/webpack.test.config.js | 1 - test/help/help.test.js | 428 ++++++----- .../config-absent/merge-config-absent.test.js | 4 +- test/serve/basic/serve-basic.test.js | 47 +- test/serve/basic/serve.config.js | 7 + test/serve/basic/src/entry.js | 1 + test/serve/help/serve-help.test.js | 17 +- test/unknown/unknown.test.js | 4 +- test/watch/basic/basic.test.js | 35 + test/watch/basic/src/entry.js | 1 + 33 files changed, 991 insertions(+), 692 deletions(-) delete mode 100644 packages/webpack-cli/lib/utils/cli-flags.js create mode 100644 test/build/basic/entry.config.js create mode 100644 test/build/basic/src/again.js create mode 100644 test/build/basic/src/entry.js create mode 100644 test/build/basic/src/other.js delete mode 100644 test/core-flags/webpack.test.config.js create mode 100644 test/serve/basic/serve.config.js create mode 100644 test/serve/basic/src/entry.js create mode 100644 test/watch/basic/src/entry.js diff --git a/OPTIONS.md b/OPTIONS.md index fd2ea885820..f87c5a7269e 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -1,12 +1,6 @@ ``` -Usage: webpack [options] -Alternative usage: webpack --config [options] -Alternative usage: webpack build [options] -Alternative usage: webpack bundle [options] -Alternative usage: webpack b [options] -Alternative usage: webpack build --config [options] -Alternative usage: webpack bundle --config [options] -Alternative usage: webpack b --config [options] +Usage: webpack [entries...] [options] +Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. @@ -793,23 +787,23 @@ Options: --no-watch-options-stdin Do not stop watching when stdin stream has ended. Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. + --color Enable colors on console. + --no-color Disable colors on console. + -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + -h, --help [verbose] Display help for commands and options. Commands: - build|bundle|b [options] Run webpack (default command, can be omitted). - watch|w [options] Run webpack and watch for files changes. - version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - help|h [command] [option] Display help for commands and options. - serve|s [options] Run the webpack dev server. - info|i [options] Outputs information about your system. - init|c [options] [scaffold...] Initialize a new webpack configuration. - loader|l [output-path] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - configtest|t [config-path] Tests webpack configuration against validation errors. - plugin|p [output-path] Scaffold a plugin. + build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). + configtest|t [config-path] Tests webpack configuration against validation errors. + help|h [command] [option] Display help for commands and options. + info|i [options] Outputs information about your system. + init|c [scaffold...] [options] Initialize a new webpack configuration. + loader|l [output-path] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + watch|w [entries...] [options] Run webpack and watch for files changes. To see list of all supported commands and options run 'webpack --help=verbose'. diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 3448af21808..5b72fd66a3a 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -6,10 +6,10 @@ class ServeCommand { await cli.makeCommand( { - name: 'serve', + name: 'serve [entries...]', alias: 's', description: 'Run the webpack dev server.', - usage: '[options]', + usage: '[entries...] [options]', pkg: '@webpack-cli/serve', dependencies: ['webpack-dev-server'], }, @@ -28,7 +28,7 @@ class ServeCommand { return [...builtInOptions, ...devServerFlags]; }, - async (options) => { + async (entries, options) => { const builtInOptions = cli.getBuiltInOptions(); let devServerFlags = []; @@ -72,6 +72,10 @@ class ServeCommand { processor(devServerOptions); } + if (entries.length > 0) { + webpackOptions.entry = [...entries, ...(webpackOptions.entry || [])]; + } + webpackOptions.argv = { ...options, env: { WEBPACK_SERVE: true, ...options.env } }; const compiler = await cli.createCompiler(webpackOptions); diff --git a/packages/webpack-cli/__tests__/resolveArgs.test.js b/packages/webpack-cli/__tests__/resolveArgs.test.js index 67a1a0feeb1..db8215e98d5 100644 --- a/packages/webpack-cli/__tests__/resolveArgs.test.js +++ b/packages/webpack-cli/__tests__/resolveArgs.test.js @@ -2,24 +2,24 @@ const { resolve } = require('path'); const webpackCLI = require('../lib/webpack-cli'); const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; -const applyOptions = new webpackCLI().applyOptions; +const cli = new webpackCLI(); describe('BasicResolver', () => { it('should handle the output option', async () => { - const result = await applyOptions({ options: {} }, { outputPath: './bundle' }); + const result = await cli.applyOptions({ options: {} }, { outputPath: './bundle' }); expect(result.options.output.path).toEqual(resolve('bundle')); }); it('should handle the mode option [production]', async () => { - const result = await applyOptions({ options: {} }, { mode: 'production' }); + const result = await cli.applyOptions({ options: {} }, { mode: 'production' }); expect(result.options).toMatchObject({ mode: 'production' }); expect(result.options.mode).toEqual('production'); }); it('should handle the mode option [development]', async () => { - const result = await applyOptions( + const result = await cli.applyOptions( { options: {} }, { mode: 'development', @@ -31,7 +31,7 @@ describe('BasicResolver', () => { }); it('should handle the mode option [none]', async () => { - const result = await applyOptions( + const result = await cli.applyOptions( { options: {} }, { mode: 'none', @@ -44,34 +44,34 @@ describe('BasicResolver', () => { it('should prefer supplied move flag over NODE_ENV', async () => { process.env.NODE_ENV = 'production'; - const result = await applyOptions({ options: {} }, { mode: 'development' }); + const result = await cli.applyOptions({ options: {} }, { mode: 'development' }); expect(result.options).toMatchObject({ mode: 'development' }); }); it('should prefer supplied move flag over mode from config', async () => { - const result = await applyOptions({ options: { mode: 'development' } }, { mode: 'production' }); + const result = await cli.applyOptions({ options: { mode: 'development' } }, { mode: 'production' }); expect(result.options).toMatchObject({ mode: 'production' }); }); it('should prefer mode form config over NODE_ENV', async () => { process.env.NODE_ENV = 'development'; - const result = await applyOptions({ options: {} }, { mode: 'production' }); + const result = await cli.applyOptions({ options: {} }, { mode: 'production' }); expect(result.options).toMatchObject({ mode: 'production' }); }); it('should prefer mode form flag over NODE_ENV and config', async () => { process.env.NODE_ENV = 'development'; - const result = await applyOptions({ options: {} }, {}); + const result = await cli.applyOptions({ options: {} }, {}); expect(result.options).toMatchObject({ mode: 'development' }); }); targetValues.map((option) => { it(`should handle ${option} option`, async () => { - const result = await applyOptions({ options: {} }, { target: option }); + const result = await cli.applyOptions({ options: {} }, { target: option }); expect(result.options.target).toEqual(option); }); diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js deleted file mode 100644 index 8f3256aebb9..00000000000 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ /dev/null @@ -1,202 +0,0 @@ -const packageExists = require('./package-exists'); -const cli = packageExists('webpack') ? require('webpack').cli : undefined; - -const minimumHelpFlags = [ - 'config', - 'config-name', - 'merge', - 'env', - 'mode', - 'watch', - 'watch-options-stdin', - 'stats', - 'devtool', - 'entry', - 'target', - 'progress', - 'json', - 'name', - 'output-path', -]; - -const builtInFlags = [ - // For configs - { - name: 'config', - alias: 'c', - type: String, - multiple: true, - description: 'Provide path to a webpack configuration file e.g. ./webpack.config.js.', - }, - { - name: 'config-name', - type: String, - multiple: true, - description: 'Name of the configuration to use.', - }, - { - name: 'merge', - alias: 'm', - type: Boolean, - description: "Merge two or more configurations using 'webpack-merge'.", - }, - // Complex configs - { - name: 'env', - type: (value, previous = {}) => { - // This ensures we're only splitting by the first `=` - const [allKeys, val] = value.split(/=(.+)/, 2); - const splitKeys = allKeys.split(/\.(?!$)/); - - let prevRef = previous; - - splitKeys.forEach((someKey, index) => { - if (!prevRef[someKey]) { - prevRef[someKey] = {}; - } - - if (typeof prevRef[someKey] === 'string') { - prevRef[someKey] = {}; - } - - if (index === splitKeys.length - 1) { - prevRef[someKey] = val || true; - } - - prevRef = prevRef[someKey]; - }); - - return previous; - }, - multiple: true, - description: 'Environment passed to the configuration when it is a function.', - }, - - // Adding more plugins - { - name: 'hot', - alias: 'h', - type: Boolean, - negative: true, - description: 'Enables Hot Module Replacement', - negatedDescription: 'Disables Hot Module Replacement.', - }, - { - name: 'analyze', - type: Boolean, - multiple: false, - description: 'It invokes webpack-bundle-analyzer plugin to get bundle information.', - }, - { - name: 'progress', - type: [Boolean, String], - description: 'Print compilation progress during build.', - }, - { - name: 'prefetch', - type: String, - description: 'Prefetch this request.', - }, - - // Output options - { - name: 'json', - type: [String, Boolean], - alias: 'j', - description: 'Prints result as JSON or store it in a file.', - }, - - // For webpack@4 - { - name: 'entry', - type: String, - multiple: true, - description: 'The entry point(s) of your application e.g. ./src/main.js.', - }, - { - name: 'output-path', - alias: 'o', - type: String, - description: 'Output location of the file generated by webpack e.g. ./dist/.', - }, - { - name: 'target', - alias: 't', - type: String, - multiple: cli !== undefined, - description: 'Sets the build target e.g. node.', - }, - { - name: 'devtool', - type: String, - negative: true, - alias: 'd', - description: 'Determine source maps to use.', - negatedDescription: 'Do not generate source maps.', - }, - { - name: 'mode', - type: String, - description: 'Defines the mode to pass to webpack.', - }, - { - name: 'name', - type: String, - description: 'Name of the configuration. Used when loading multiple configurations.', - }, - { - name: 'stats', - type: [String, Boolean], - negative: true, - description: 'It instructs webpack on how to treat the stats e.g. verbose.', - negatedDescription: 'Disable stats output.', - }, - { - name: 'watch', - type: Boolean, - negative: true, - alias: 'w', - description: 'Watch for files changes.', - negatedDescription: 'Do not watch for file changes.', - }, - { - name: 'watch-options-stdin', - type: Boolean, - negative: true, - description: 'Stop watching when stdin stream has ended.', - negatedDescription: 'Do not stop watching when stdin stream has ended.', - }, -]; - -// Extract all the flags being exported from core. -// A list of cli flags generated by core can be found here https://github.com/webpack/webpack/blob/master/test/__snapshots__/Cli.test.js.snap -const coreFlags = cli - ? Object.entries(cli.getArguments()).map(([flag, meta]) => { - if (meta.simpleType === 'string') { - meta.type = String; - } else if (meta.simpleType === 'number') { - meta.type = Number; - } else { - meta.type = Boolean; - meta.negative = !flag.endsWith('-reset'); - } - - const inBuiltIn = builtInFlags.find((builtInFlag) => builtInFlag.name === flag); - - if (inBuiltIn) { - return { ...meta, name: flag, group: 'core', ...inBuiltIn }; - } - - return { ...meta, name: flag, group: 'core' }; - }) - : []; -const flags = [] - .concat(builtInFlags.filter((builtInFlag) => !coreFlags.find((coreFlag) => builtInFlag.name === coreFlag.name))) - .concat(coreFlags) - .map((option) => { - option.help = minimumHelpFlags.includes(option.name) ? 'minimum' : 'verbose'; - - return option; - }); - -module.exports = { cli, flags }; diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index aac07d43a46..b945f9b189f 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1,17 +1,16 @@ +const fs = require('fs'); +const path = require('path'); + const { program } = require('commander'); const getPkg = require('./utils/package-exists'); const webpack = getPkg('webpack') ? require('webpack') : undefined; -const path = require('path'); -const { merge } = require('webpack-merge'); -const { extensions, jsVariants } = require('interpret'); +const interpret = require('interpret'); const rechoir = require('rechoir'); -const { createWriteStream, existsSync } = require('fs'); const { distance } = require('fastest-levenshtein'); const { options: coloretteOptions, yellow, cyan, green, bold } = require('colorette'); const logger = require('./utils/logger'); const capitalizeFirstLetter = require('./utils/capitalize-first-letter'); -const { cli, flags } = require('./utils/cli-flags'); const CLIPlugin = require('./plugins/CLIPlugin'); const promptInstallation = require('./utils/prompt-installation'); const toKebabCase = require('./utils/to-kebab-case'); @@ -85,7 +84,9 @@ class WebpackCLI { try { await promptInstallation(dependency, () => { logger.error( - `For using '${green(commandOptions.name)}' command you need to install: '${green(dependency)}' package`, + `For using '${green(commandOptions.name.split(' ')[0])}' command you need to install: '${green( + dependency, + )}' package`, ); }); } catch (error) { @@ -226,22 +227,219 @@ class WebpackCLI { } getBuiltInOptions() { - return flags; + const minimumHelpFlags = [ + 'config', + 'config-name', + 'merge', + 'env', + 'mode', + 'watch', + 'watch-options-stdin', + 'stats', + 'devtool', + 'entry', + 'target', + 'progress', + 'json', + 'name', + 'output-path', + ]; + + const builtInFlags = [ + // For configs + { + name: 'config', + alias: 'c', + type: String, + multiple: true, + description: 'Provide path to a webpack configuration file e.g. ./webpack.config.js.', + }, + { + name: 'config-name', + type: String, + multiple: true, + description: 'Name of the configuration to use.', + }, + { + name: 'merge', + alias: 'm', + type: Boolean, + description: "Merge two or more configurations using 'webpack-merge'.", + }, + // Complex configs + { + name: 'env', + type: (value, previous = {}) => { + // This ensures we're only splitting by the first `=` + const [allKeys, val] = value.split(/=(.+)/, 2); + const splitKeys = allKeys.split(/\.(?!$)/); + + let prevRef = previous; + + splitKeys.forEach((someKey, index) => { + if (!prevRef[someKey]) { + prevRef[someKey] = {}; + } + + if (typeof prevRef[someKey] === 'string') { + prevRef[someKey] = {}; + } + + if (index === splitKeys.length - 1) { + prevRef[someKey] = val || true; + } + + prevRef = prevRef[someKey]; + }); + + return previous; + }, + multiple: true, + description: 'Environment passed to the configuration when it is a function.', + }, + + // Adding more plugins + { + name: 'hot', + alias: 'h', + type: Boolean, + negative: true, + description: 'Enables Hot Module Replacement', + negatedDescription: 'Disables Hot Module Replacement.', + }, + { + name: 'analyze', + type: Boolean, + multiple: false, + description: 'It invokes webpack-bundle-analyzer plugin to get bundle information.', + }, + { + name: 'progress', + type: [Boolean, String], + description: 'Print compilation progress during build.', + }, + { + name: 'prefetch', + type: String, + description: 'Prefetch this request.', + }, + + // Output options + { + name: 'json', + type: [String, Boolean], + alias: 'j', + description: 'Prints result as JSON or store it in a file.', + }, + + // For webpack@4 + { + name: 'entry', + type: String, + multiple: true, + description: 'The entry point(s) of your application e.g. ./src/main.js.', + }, + { + name: 'output-path', + alias: 'o', + type: String, + description: 'Output location of the file generated by webpack e.g. ./dist/.', + }, + { + name: 'target', + alias: 't', + type: String, + multiple: this.webpack.cli !== undefined, + description: 'Sets the build target e.g. node.', + }, + { + name: 'devtool', + type: String, + negative: true, + alias: 'd', + description: 'Determine source maps to use.', + negatedDescription: 'Do not generate source maps.', + }, + { + name: 'mode', + type: String, + description: 'Defines the mode to pass to webpack.', + }, + { + name: 'name', + type: String, + description: 'Name of the configuration. Used when loading multiple configurations.', + }, + { + name: 'stats', + type: [String, Boolean], + negative: true, + description: 'It instructs webpack on how to treat the stats e.g. verbose.', + negatedDescription: 'Disable stats output.', + }, + { + name: 'watch', + type: Boolean, + negative: true, + alias: 'w', + description: 'Watch for files changes.', + negatedDescription: 'Do not watch for file changes.', + }, + { + name: 'watch-options-stdin', + type: Boolean, + negative: true, + description: 'Stop watching when stdin stream has ended.', + negatedDescription: 'Do not stop watching when stdin stream has ended.', + }, + ]; + + // Extract all the flags being exported from core. + // A list of cli flags generated by core can be found here https://github.com/webpack/webpack/blob/master/test/__snapshots__/Cli.test.js.snap + const coreFlags = this.webpack.cli + ? Object.entries(this.webpack.cli.getArguments()).map(([flag, meta]) => { + if (meta.simpleType === 'string') { + meta.type = String; + } else if (meta.simpleType === 'number') { + meta.type = Number; + } else { + meta.type = Boolean; + meta.negative = !flag.endsWith('-reset'); + } + + const inBuiltIn = builtInFlags.find((builtInFlag) => builtInFlag.name === flag); + + if (inBuiltIn) { + return { ...meta, name: flag, group: 'core', ...inBuiltIn }; + } + + return { ...meta, name: flag, group: 'core' }; + }) + : []; + + return [] + .concat(builtInFlags.filter((builtInFlag) => !coreFlags.find((coreFlag) => builtInFlag.name === coreFlag.name))) + .concat(coreFlags) + .map((option) => { + option.help = minimumHelpFlags.includes(option.name) ? 'minimum' : 'verbose'; + + return option; + }); } async run(args, parseOptions) { // Built-in internal commands const buildCommandOptions = { - name: 'build', + name: 'build [entries...]', alias: ['bundle', 'b'], description: 'Run webpack (default command, can be omitted).', - usage: '[options]', + usage: '[entries...] [options]', }; const watchCommandOptions = { - name: 'watch', + name: 'watch [entries...]', alias: 'w', description: 'Run webpack and watch for files changes.', - usage: '[options]', + usage: '[entries...] [options]', }; const versionCommandOptions = { name: 'version [commands...]', @@ -256,7 +454,7 @@ class WebpackCLI { // Built-in external commands const externalBuiltInCommandsInfo = [ { - name: 'serve', + name: 'serve [entries...]', alias: 's', pkg: '@webpack-cli/serve', }, @@ -306,20 +504,23 @@ class WebpackCLI { getCommandName(command.name) === name || (Array.isArray(command.alias) ? command.alias.includes(name) : command.alias === name), ); - const isBuildCommand = (name) => - getCommandName(buildCommandOptions.name) === name || - (Array.isArray(buildCommandOptions.alias) ? buildCommandOptions.alias.includes(name) : buildCommandOptions.alias === name); - const isWatchCommand = (name) => - getCommandName(watchCommandOptions.name) === name || - (Array.isArray(watchCommandOptions.alias) ? watchCommandOptions.alias.includes(name) : watchCommandOptions.alias === name); - const isHelpCommand = (name) => - getCommandName(helpCommandOptions.name) === name || - (Array.isArray(helpCommandOptions.alias) ? helpCommandOptions.alias.includes(name) : helpCommandOptions.alias === name); - const isVersionCommand = (name) => - getCommandName(versionCommandOptions.name) === name || - (Array.isArray(versionCommandOptions.alias) - ? versionCommandOptions.alias.includes(name) - : versionCommandOptions.alias === name); + const isCommand = (input, commandOptions) => { + const longName = getCommandName(commandOptions.name); + + if (input === longName) { + return true; + } + + if (commandOptions.alias) { + if (Array.isArray(commandOptions.alias)) { + return commandOptions.alias.includes(input); + } else { + return commandOptions.alias === input; + } + } + + return false; + }; const findCommandByName = (name) => this.program.commands.find((command) => name === command.name() || command.alias().includes(name)); const isOption = (value) => value.startsWith('-'); @@ -332,21 +533,16 @@ class WebpackCLI { value === '--help'; const loadCommandByName = async (commandName, allowToInstall = false) => { - const isBuildCommandUsed = isBuildCommand(commandName); - const isWatchCommandUsed = isWatchCommand(commandName); + const isBuildCommandUsed = isCommand(commandName, buildCommandOptions); + const isWatchCommandUsed = isCommand(commandName, watchCommandOptions); if (isBuildCommandUsed || isWatchCommandUsed) { await this.makeCommand( isBuildCommandUsed ? buildCommandOptions : watchCommandOptions, this.getBuiltInOptions(), - async (options, program) => { - if (program.args.length > 0) { - const possibleCommands = [].concat([buildCommandOptions.name]).concat(program.args); - - logger.error('Running multiple commands at the same time is not possible'); - logger.error(`Found commands: ${possibleCommands.map((item) => `'${item}'`).join(', ')}`); - logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); + async (entries, options) => { + if (entries.length > 0) { + options.entry = [...entries, ...(options.entry || [])]; } if (isWatchCommandUsed) { @@ -361,13 +557,13 @@ class WebpackCLI { options.watch = true; } - await this.bundleCommand(options); + await this.buildCommand(options); }, ); - } else if (isHelpCommand(commandName)) { + } else if (isCommand(commandName, helpCommandOptions)) { // Stub for the `help` command this.makeCommand(helpCommandOptions, [], () => {}); - } else if (isVersionCommand(commandName)) { + } else if (isCommand(commandName, versionCommandOptions)) { // Stub for the `help` command this.makeCommand(versionCommandOptions, [], () => {}); } else { @@ -455,7 +651,7 @@ class WebpackCLI { } const { operands } = this.program.parseOptions(this.program.args); - const operand = typeof operands[0] !== 'undefined' ? operands[0] : 'build'; + const operand = typeof operands[0] !== 'undefined' ? operands[0] : getCommandName(buildCommandOptions.name); if (operand) { const command = findCommandByName(operand); @@ -506,7 +702,11 @@ class WebpackCLI { const outputVersion = async (options) => { // Filter `bundle`, `watch`, `version` and `help` commands const possibleCommandNames = options.filter( - (option) => !isBuildCommand(option) && !isWatchCommand(option) && !isVersionCommand(option) && !isHelpCommand(option), + (option) => + !isCommand(option, buildCommandOptions) && + !isCommand(option, watchCommandOptions) && + !isCommand(option, versionCommandOptions) && + !isCommand(option, helpCommandOptions), ); possibleCommandNames.forEach((possibleCommandName) => { @@ -544,7 +744,7 @@ class WebpackCLI { const pkgJSON = require('../package.json'); - logger.raw(`webpack ${webpack.version}`); + logger.raw(`webpack ${this.webpack.version}`); logger.raw(`webpack-cli ${pkgJSON.version}`); if (getPkg('webpack-dev-server')) { @@ -562,46 +762,6 @@ class WebpackCLI { ); const outputHelp = async (options, isVerbose, isHelpCommandSyntax, program) => { - const hideVerboseOptions = (command) => { - command.options = command.options.filter((option) => { - const foundOption = flags.find((flag) => { - if (option.negate && flag.negative) { - return `no-${flag.name}` === option.name(); - } - - return flag.name === option.name(); - }); - - if (foundOption && foundOption.help) { - return foundOption.help === 'minimum'; - } - - return true; - }); - }; - const outputGlobalOptions = () => { - const programHelpInformation = program.helpInformation(); - const globalOptions = programHelpInformation.match(/Options:\n(?.+)\nCommands:\n/s); - - if (globalOptions && globalOptions.groups.globalOptions) { - logger.raw('\nGlobal options:'); - logger.raw(globalOptions.groups.globalOptions.trimRight()); - } - }; - const outputGlobalCommands = () => { - const programHelpInformation = program.helpInformation(); - const globalCommands = programHelpInformation.match(/Commands:\n(?.+)/s); - - if (globalCommands.groups.globalCommands) { - logger.raw('\nCommands:'); - logger.raw( - globalCommands.groups.globalCommands - .trimRight() - // `commander` doesn't support multiple alias in help - .replace('build|bundle [options] ', 'build|bundle|b [options]'), - ); - } - }; const outputIncorrectUsageOfHelp = () => { logger.error('Incorrect use of help'); logger.error("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); @@ -609,61 +769,177 @@ class WebpackCLI { process.exit(2); }; - if (options.length === 0) { - await Promise.all( - knownCommands.map((knownCommand) => { - return loadCommandByName(getCommandName(knownCommand.name)); - }), - ); + const isGlobalHelp = options.length === 0; + const isCommandHelp = options.length === 1 && !isOption(options[0]); - const bundleCommand = findCommandByName(buildCommandOptions.name); + if (isGlobalHelp || isCommandHelp) { + const cliAPI = this; - if (!isVerbose) { - hideVerboseOptions(bundleCommand); - } + program.configureHelp({ + sortSubcommands: true, + // Support multiple aliases + commandUsage: (command) => { + let parentCmdNames = ''; - let helpInformation = bundleCommand - .helpInformation() - .trimRight() - .replace(buildCommandOptions.description, 'The build tool for modern web applications.') - .replace( - /Usage:.+/, - 'Usage: webpack [options]\nAlternative usage: webpack --config [options]\nAlternative usage: webpack build [options]\nAlternative usage: webpack bundle [options]\nAlternative usage: webpack b [options]\nAlternative usage: webpack build --config [options]\nAlternative usage: webpack bundle --config [options]\nAlternative usage: webpack b --config [options]', - ); + for (let parentCmd = command.parent; parentCmd; parentCmd = parentCmd.parent) { + parentCmdNames = `${parentCmd.name()} ${parentCmdNames}`; + } - logger.raw(helpInformation); + if (isGlobalHelp) { + return `${parentCmdNames}${command.usage()}\n${bold( + 'Alternative usage to run commands:', + )} ${parentCmdNames}[command] [options]`; + } - outputGlobalOptions(); - outputGlobalCommands(); - } else if (options.length === 1 && !isOption(options[0])) { - const name = options[0]; + return `${parentCmdNames}${command.name()}|${command.aliases().join('|')} ${command.usage()}`; + }, + // Support multiple aliases + subcommandTerm: (command) => { + const humanReadableArgumentName = (argument) => { + const nameOutput = argument.name + (argument.variadic === true ? '...' : ''); + + return argument.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']'; + }; + const args = command._args.map((arg) => humanReadableArgumentName(arg)).join(' '); + + return `${command.name()}|${command.aliases().join('|')}${args ? ` ${args}` : ''}${ + command.options.length > 0 ? ' [options]' : '' + }`; + }, + visibleOptions: function visibleOptions(command) { + const options = cliAPI.getBuiltInOptions(); - await loadCommandByName(name); + return command.options.filter((option) => { + if (option.hidden) { + return false; + } - const command = findCommandByName(name); + if (!isVerbose) { + const foundOption = options.find((flag) => { + if (option.negate && flag.negative) { + return `no-${flag.name}` === option.name(); + } - if (!command) { - logger.error(`Can't find and load command '${name}'`); - logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - } + return flag.name === option.name(); + }); - if (!isVerbose) { - hideVerboseOptions(command); - } + if (foundOption) { + return foundOption.help === 'minimum'; + } - let helpInformation = command.helpInformation().trimRight(); + return true; + } - if (isBuildCommand(name)) { - helpInformation = helpInformation.replace('build|bundle', 'build|bundle|b'); - } + return true; + }); + }, + padWidth(command, helper) { + return Math.max( + helper.longestArgumentTermLength(command, helper), + helper.longestOptionTermLength(command, helper), + // For global options + helper.longestOptionTermLength(program, helper), + helper.longestSubcommandTermLength(isGlobalHelp ? program : command, helper), + ); + }, + formatHelp: (command, helper) => { + const termWidth = helper.padWidth(command, helper); + const helpWidth = helper.helpWidth || 80; + const itemIndentWidth = 2; + const itemSeparatorWidth = 2; // between term and description + + const formatItem = (term, description) => { + if (description) { + const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`; + + return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth); + } + + return term; + }; + + const formatList = (textArray) => textArray.join('\n').replace(/^/gm, ' '.repeat(itemIndentWidth)); + + // Usage + let output = [`${bold('Usage:')} ${helper.commandUsage(command)}`, '']; + + // Description + const commandDescription = isGlobalHelp + ? 'The build tool for modern web applications.' + : helper.commandDescription(command); + + if (commandDescription.length > 0) { + output = output.concat([commandDescription, '']); + } + + // Arguments + const argumentList = helper + .visibleArguments(command) + .map((argument) => formatItem(argument.term, argument.description)); + + if (argumentList.length > 0) { + output = output.concat([bold('Arguments:'), formatList(argumentList), '']); + } + + // Options + const optionList = helper + .visibleOptions(command) + .map((option) => formatItem(helper.optionTerm(option), helper.optionDescription(option))); + + if (optionList.length > 0) { + output = output.concat([bold('Options:'), formatList(optionList), '']); + } + + // Global options + const globalOptionList = program.options.map((option) => + formatItem(helper.optionTerm(option), helper.optionDescription(option)), + ); + + if (globalOptionList.length > 0) { + output = output.concat([bold('Global options:'), formatList(globalOptionList), '']); + } + + // Commands + const commandList = helper + .visibleCommands(isGlobalHelp ? program : command) + .map((command) => formatItem(helper.subcommandTerm(command), helper.subcommandDescription(command))); + + if (commandList.length > 0) { + output = output.concat([bold('Commands:'), formatList(commandList), '']); + } + + return output.join('\n'); + }, + }); + + if (isGlobalHelp) { + await Promise.all( + knownCommands.map((knownCommand) => { + return loadCommandByName(getCommandName(knownCommand.name)); + }), + ); + + const buildCommand = findCommandByName(getCommandName(buildCommandOptions.name)); + + logger.raw(buildCommand.helpInformation()); + } else { + const name = options[0]; + + await loadCommandByName(name); - logger.raw(helpInformation); + const command = findCommandByName(name); - outputGlobalOptions(); + if (!command) { + logger.error(`Can't find and load command '${name}'`); + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } + + logger.raw(command.helpInformation()); + } } else if (isHelpCommandSyntax) { let isCommandSpecified = false; - let commandName = buildCommandOptions.name; + let commandName = getCommandName(buildCommandOptions.name); let optionName; if (options.length === 1) { @@ -682,7 +958,7 @@ class WebpackCLI { await loadCommandByName(commandName); - const command = isGlobalOption(optionName) ? this.program : findCommandByName(commandName); + const command = isGlobalOption(optionName) ? program : findCommandByName(commandName); if (!command) { logger.error(`Can't find and load command '${commandName}'`); @@ -702,20 +978,28 @@ class WebpackCLI { option.flags.replace(/^.+[[<]/, '').replace(/(\.\.\.)?[\]>].*$/, '') + (option.variadic === true ? '...' : ''); const value = option.required ? '<' + nameOutput + '>' : option.optional ? '[' + nameOutput + ']' : ''; - logger.raw(`Usage: webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.long}${value ? ` ${value}` : ''}`); + logger.raw( + `${bold('Usage')}: webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.long}${value ? ` ${value}` : ''}`, + ); if (option.short) { - logger.raw(`Short: webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.short}${value ? ` ${value}` : ''}`); + logger.raw( + `${bold('Short:')} webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.short}${ + value ? ` ${value}` : '' + }`, + ); } if (option.description) { - logger.raw(`Description: ${option.description}`); + logger.raw(`${bold('Description:')} ${option.description}`); } if (!option.negate && options.defaultValue) { - logger.raw(`Default value: ${JSON.stringify(option.defaultValue)}`); + logger.raw(`${bold('Default value:')} ${JSON.stringify(option.defaultValue)}`); } + logger.raw(''); + // TODO implement this after refactor cli arguments // logger.raw('Possible values: foo | bar'); // logger.raw('Documentation: https://webpack.js.org/option/name/'); @@ -723,9 +1007,9 @@ class WebpackCLI { outputIncorrectUsageOfHelp(); } - logger.raw("\nTo see list of all supported commands and options run 'webpack --help=verbose'.\n"); - logger.raw('Webpack documentation: https://webpack.js.org/.'); - logger.raw('CLI documentation: https://webpack.js.org/api/cli/.'); + logger.raw("To see list of all supported commands and options run 'webpack --help=verbose'.\n"); + logger.raw(`${bold('Webpack documentation:')} https://webpack.js.org/.`); + logger.raw(`${bold('CLI documentation:')} https://webpack.js.org/api/cli/.`); logger.raw(`${bold('Made with ♥ by the webpack team')}.`); process.exit(0); }; @@ -748,10 +1032,11 @@ class WebpackCLI { // Command and options const { operands, unknown } = this.program.parseOptions(program.args); + const defaultCommandToRun = getCommandName(buildCommandOptions.name); const hasOperand = typeof operands[0] !== 'undefined'; - const operand = hasOperand ? operands[0] : 'build'; + const operand = hasOperand ? operands[0] : defaultCommandToRun; - const isHelpCommandSyntax = isHelpCommand(operand); + const isHelpCommandSyntax = isCommand(operand, helpCommandOptions); if (options.help || isHelpCommandSyntax) { let isVerbose = false; @@ -781,7 +1066,7 @@ class WebpackCLI { await outputHelp(optionsForHelp, isVerbose, isHelpCommandSyntax, program); } - if (options.version || isVersionCommand(operand)) { + if (options.version || isCommand(operand, versionCommandOptions)) { const optionsForVersion = [] .concat(options.version ? [operand] : []) .concat(operands.slice(1)) @@ -790,26 +1075,44 @@ class WebpackCLI { await outputVersion(optionsForVersion, program); } - if (isKnownCommand(operand)) { - await loadCommandByName(operand, true); - } else { - logger.error(`Unknown command '${operand}'`); + let commandToRun = operand; + let commandOperands = operands.slice(1); - const found = knownCommands.find((commandOptions) => distance(operand, getCommandName(commandOptions.name)) < 3); + if (isKnownCommand(commandToRun)) { + await loadCommandByName(commandToRun, true); + } else { + let isEntrySyntax = true; - if (found) { - logger.error( - `Did you mean '${getCommandName(found.name)}' (alias '${ - Array.isArray(found.alias) ? found.alias.join(', ') : found.alias - }')?`, - ); + try { + await fs.promises.access(operand, fs.constants.F_OK); + } catch (error) { + isEntrySyntax = false; } - logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); + if (isEntrySyntax) { + commandToRun = defaultCommandToRun; + commandOperands = operands; + + await loadCommandByName(commandToRun); + } else { + logger.error(`Unknown command or entry '${operand}'`); + + const found = knownCommands.find((commandOptions) => distance(operand, getCommandName(commandOptions.name)) < 3); + + if (found) { + logger.error( + `Did you mean '${getCommandName(found.name)}' (alias '${ + Array.isArray(found.alias) ? found.alias.join(', ') : found.alias + }')?`, + ); + } + + logger.error("Run 'webpack --help' to see available commands and options"); + process.exit(2); + } } - await this.program.parseAsync([operand, ...operands.slice(1), ...unknown], { from: 'user' }); + await this.program.parseAsync([commandToRun, ...commandOperands, ...unknown], { from: 'user' }); }); await this.program.parseAsync(args, parseOptions); @@ -818,11 +1121,11 @@ class WebpackCLI { async resolveConfig(options) { const loadConfig = async (configPath) => { const ext = path.extname(configPath); - const interpreted = Object.keys(jsVariants).find((variant) => variant === ext); + const interpreted = Object.keys(interpret.jsVariants).find((variant) => variant === ext); if (interpreted) { try { - rechoir.prepare(extensions, configPath); + rechoir.prepare(interpret.extensions, configPath); } catch (error) { if (error.failures) { logger.error(`Unable load '${configPath}'`); @@ -868,7 +1171,7 @@ class WebpackCLI { throw error; } } catch (error) { - logger.error(`Failed to load '${configPath}'`); + logger.error(`Failed to load '${configPath}' config`); logger.error(error); process.exit(2); } @@ -916,18 +1219,7 @@ class WebpackCLI { if (options.config && options.config.length > 0) { const evaluatedConfigs = await Promise.all( - options.config.map(async (value) => { - const configPath = path.resolve(value); - - if (!existsSync(configPath)) { - logger.error(`The specified config file doesn't exist in '${configPath}'`); - process.exit(2); - } - - const loadedConfig = await loadConfig(configPath); - - return evaluateConfig(loadedConfig, options.argv || {}); - }), + options.config.map(async (value) => evaluateConfig(await loadConfig(path.resolve(value)), options.argv || {})), ); config.options = []; @@ -950,10 +1242,10 @@ class WebpackCLI { const defaultConfigFiles = ['webpack.config', '.webpack/webpack.config', '.webpack/webpackfile'] .map((filename) => // Since .cjs is not available on interpret side add it manually to default config extension list - [...Object.keys(extensions), '.cjs'].map((ext) => ({ + [...Object.keys(interpret.extensions), '.cjs'].map((ext) => ({ path: path.resolve(filename + ext), ext: ext, - module: extensions[ext], + module: interpret.extensions[ext], })), ) .reduce((accumulator, currentValue) => accumulator.concat(currentValue), []); @@ -961,10 +1253,14 @@ class WebpackCLI { let foundDefaultConfigFile; for (const defaultConfigFile of defaultConfigFiles) { - if (existsSync(defaultConfigFile.path)) { - foundDefaultConfigFile = defaultConfigFile; - break; + try { + await fs.promises.access(defaultConfigFile.path, fs.constants.F_OK); + } catch (error) { + continue; } + + foundDefaultConfigFile = defaultConfigFile; + break; } if (foundDefaultConfigFile) { @@ -1011,6 +1307,8 @@ class WebpackCLI { } if (options.merge) { + const { merge } = require('webpack-merge'); + // we can only merge when there are multiple configurations // either by passing multiple configs by flags or passing a // single config exporting an array @@ -1057,34 +1355,33 @@ class WebpackCLI { process.exit(2); } - if (Object.keys(options).length === 0 && !process.env.NODE_ENV) { - return config; - } - - if (cli) { + if (this.webpack.cli) { const processArguments = (configOptions) => { - const coreFlagMap = flags + const args = this.getBuiltInOptions() .filter((flag) => flag.group === 'core') .reduce((accumulator, flag) => { accumulator[flag.name] = flag; return accumulator; }, {}); - const CLIoptions = Object.keys(options).reduce((accumulator, name) => { + + const values = Object.keys(options).reduce((accumulator, name) => { + if (name === 'argv') { + return accumulator; + } + const kebabName = toKebabCase(name); - if (coreFlagMap[kebabName]) { + if (args[kebabName]) { accumulator[kebabName] = options[name]; } return accumulator; }, {}); - const problems = cli.processArguments(coreFlagMap, configOptions, CLIoptions); + + const problems = this.webpack.cli.processArguments(args, configOptions, values); if (problems) { - const capitalizeFirstLetter = (string) => { - return string.charAt(0).toUpperCase() + string.slice(1); - }; const groupBy = (xs, key) => { return xs.reduce((rv, x) => { (rv[x[key]] = rv[x[key]] || []).push(x); @@ -1214,7 +1511,7 @@ class WebpackCLI { // Apply `stats` and `stats.colors` options const applyStatsColors = (configOptions) => { // TODO remove after drop webpack@4 - const statsForWebpack4 = webpack.Stats && webpack.Stats.presetToOptions; + const statsForWebpack4 = this.webpack.Stats && this.webpack.Stats.presetToOptions; if (statsForWebpack4) { if (typeof configOptions.stats === 'undefined') { @@ -1232,7 +1529,7 @@ class WebpackCLI { return configOptions; } - configOptions.stats = webpack.Stats.presetToOptions(configOptions.stats); + configOptions.stats = this.webpack.Stats.presetToOptions(configOptions.stats); } } else { if (typeof configOptions.stats === 'undefined') { @@ -1309,7 +1606,7 @@ class WebpackCLI { const isValidationError = (error) => { // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 - const ValidationError = webpack.ValidationError || webpack.WebpackOptionsValidationError; + const ValidationError = this.webpack.ValidationError || this.webpack.WebpackOptionsValidationError; return error instanceof ValidationError; }; @@ -1322,7 +1619,7 @@ class WebpackCLI { let compiler; try { - compiler = webpack( + compiler = this.webpack( config.options, callback ? (error, stats) => { @@ -1353,7 +1650,7 @@ class WebpackCLI { return compiler; } - async bundleCommand(options) { + async buildCommand(options) { let compiler; const callback = (error, stats) => { @@ -1377,7 +1674,7 @@ class WebpackCLI { : undefined; // TODO webpack@4 doesn't support `{ children: [{ colors: true }, { colors: true }] }` for stats - const statsForWebpack4 = webpack.Stats && webpack.Stats.presetToOptions; + const statsForWebpack4 = this.webpack.Stats && this.webpack.Stats.presetToOptions; if (compiler.compilers && statsForWebpack4) { statsOptions.colors = statsOptions.children.some((child) => child.colors); @@ -1399,7 +1696,7 @@ class WebpackCLI { } else { createJsonStringifyStream(stats.toJson(statsOptions)) .on('error', handleWriteError) - .pipe(createWriteStream(options.json)) + .pipe(fs.createWriteStream(options.json)) .on('error', handleWriteError) // Use stderr to logging .on('close', () => diff --git a/test/build/basic/basic.test.js b/test/build/basic/basic.test.js index a758c3b523c..01481187f45 100644 --- a/test/build/basic/basic.test.js +++ b/test/build/basic/basic.test.js @@ -3,7 +3,63 @@ const { run } = require('../../utils/test-utils'); describe('bundle command', () => { - it('should work', async () => { + it('should work without command (default command)', async () => { + const { exitCode, stderr, stdout } = run(__dirname, [], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work without command and options (default command)', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with multiple entries syntax without command (default command)', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['./src/index.js', './src/other.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with multiple entries syntax without command with options (default command)', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['./src/index.js', './src/other.js', '--mode', 'development'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with multiple entries syntax without command with options #2 (default command)', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development', './src/index.js', './src/other.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with multiple entries syntax without command with options #3 (default command)', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['./src/index.js', './src/other.js', '--entry', './src/again.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with and override entries from the configuration', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['./src/index.js', './src/other.js', '--config', './entry.config.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with the "build" alias', async () => { const { exitCode, stderr, stdout } = run(__dirname, ['build'], false); expect(exitCode).toBe(0); @@ -11,6 +67,14 @@ describe('bundle command', () => { expect(stdout).toBeTruthy(); }); + it('should work with "bundle" alias', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + it('should work with the "b" alias', async () => { const { exitCode, stderr, stdout } = run(__dirname, ['b'], false); @@ -19,40 +83,60 @@ describe('bundle command', () => { expect(stdout).toBeTruthy(); }); - it('should work with "bundle" alias', async () => { - const { exitCode, stderr, stdout } = run(__dirname, ['bundle'], false); + it('should work with entries syntax using the "build" alias', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['build', './src/index.js'], false); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); - it('should log error and suggest right name on the "buil" command', async () => { - const { exitCode, stderr, stdout } = run(__dirname, ['buil'], false); + it('should work with entries syntax using the "bundle" alias', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', './src/index.js'], false); - expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown command 'buil'"); - expect(stderr).toContain("Did you mean 'build' (alias 'bundle, b')?"); - expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); - it('should log error with multi commands', async () => { - const { exitCode, stderr, stdout } = run(__dirname, ['bundle', 'info'], false); + it('should work with entries syntax using the "b" alias', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['b', './src/index.js'], false); - expect(exitCode).toBe(2); - expect(stderr).toContain('Running multiple commands at the same time is not possible'); - expect(stderr).toContain("Found commands: 'build', 'info'"); - expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toBeFalsy(); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with multiple entries syntax using the "build" alias', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['build', './src/index.js', './src/other.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should work with multiple entries syntax using the "build" alias and options', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['build', './src/index.js', './src/other.js', '--mode', 'development'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); - it('should log error with multi commands', async () => { - const { exitCode, stderr, stdout } = run(__dirname, ['b', 'i'], false); + it('should work with multiple entries syntax using the "build" alias and options', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['build', '--mode', 'development', './src/index.js', './src/other.js'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); + + it('should log error and suggest right name on the "buil" command', async () => { + const { exitCode, stderr, stdout } = run(__dirname, ['buil'], false); expect(exitCode).toBe(2); - expect(stderr).toContain('Running multiple commands at the same time is not possible'); - expect(stderr).toContain("Found commands: 'build', 'i'"); + expect(stderr).toContain("Unknown command or entry 'buil'"); + expect(stderr).toContain("Did you mean 'build' (alias 'bundle, b')?"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); diff --git a/test/build/basic/entry.config.js b/test/build/basic/entry.config.js new file mode 100644 index 00000000000..431945f5225 --- /dev/null +++ b/test/build/basic/entry.config.js @@ -0,0 +1,4 @@ +module.exports = { + mode: 'development', + entry: './src/entry.js', +}; diff --git a/test/build/basic/src/again.js b/test/build/basic/src/again.js new file mode 100644 index 00000000000..eec159b09dc --- /dev/null +++ b/test/build/basic/src/again.js @@ -0,0 +1 @@ +console.log('again'); diff --git a/test/build/basic/src/entry.js b/test/build/basic/src/entry.js new file mode 100644 index 00000000000..6daf0ddddd1 --- /dev/null +++ b/test/build/basic/src/entry.js @@ -0,0 +1 @@ +console.log('CONFIG'); diff --git a/test/build/basic/src/other.js b/test/build/basic/src/other.js new file mode 100644 index 00000000000..6be02374db1 --- /dev/null +++ b/test/build/basic/src/other.js @@ -0,0 +1 @@ +console.log('hello world'); diff --git a/test/config/absent/config-absent.test.js b/test/config/absent/config-absent.test.js index 2a10305273c..1e22b4a67a0 100644 --- a/test/config/absent/config-absent.test.js +++ b/test/config/absent/config-absent.test.js @@ -1,16 +1,16 @@ 'use strict'; -const { resolve } = require('path'); +const path = require('path'); const { run } = require('../../utils/test-utils'); describe('Config:', () => { it('supplied config file is absent', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', path.resolve(__dirname, 'webpack.config.js')], false); // should throw with correct exit code expect(exitCode).toBe(2); // Should contain the correct error message - expect(stderr).toContain(`The specified config file doesn't exist in '${resolve(__dirname, 'webpack.config.js')}'`); + expect(stderr).toContain(`Failed to load '${path.resolve(__dirname, 'webpack.config.js')}' config`); expect(stdout).toBeFalsy(); }); }); diff --git a/test/config/invalid-path/invalid-path.test.js b/test/config/invalid-path/invalid-path.test.js index b571740a71f..fe94a8826d9 100644 --- a/test/config/invalid-path/invalid-path.test.js +++ b/test/config/invalid-path/invalid-path.test.js @@ -1,13 +1,13 @@ 'use strict'; -const { resolve } = require('path'); +const path = require('path'); const { run } = require('../../utils/test-utils'); describe('basic config file', () => { it('is able to understand and parse a very basic configuration file', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'invalid-webpack.config.js')], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', path.resolve(__dirname, 'invalid-webpack.config.js')], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`The specified config file doesn't exist in '${resolve(__dirname, 'invalid-webpack.config.js')}'`); + expect(stderr).toContain(`Failed to load '${path.resolve(__dirname, 'invalid-webpack.config.js')}' config`); expect(stdout).toBeFalsy(); }); }); diff --git a/test/configtest/with-config-path/with-config-path.test.js b/test/configtest/with-config-path/with-config-path.test.js index 2e4775868c0..ca2ae90524a 100644 --- a/test/configtest/with-config-path/with-config-path.test.js +++ b/test/configtest/with-config-path/with-config-path.test.js @@ -44,7 +44,7 @@ describe("'configtest' command with the configuration path option", () => { const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './a.js'], false); expect(exitCode).toBe(2); - expect(stderr).toContain(`The specified config file doesn't exist`); + expect(stderr).toContain(`Failed to load '${path.resolve(__dirname, './a.js')}' config`); expect(stdout).toBeFalsy(); }); }); diff --git a/test/core-flags/experiments-flag.test.js b/test/core-flags/experiments-flag.test.js index b7554dff33e..f0bf72803eb 100644 --- a/test/core-flags/experiments-flag.test.js +++ b/test/core-flags/experiments-flag.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const experimentsFlags = flags.filter(({ name }) => name.startsWith('experiments-')); +const cli = new CLI(); +const experimentsFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('experiments-')); describe('experiments option related flag', () => { experimentsFlags.forEach((flag) => { diff --git a/test/core-flags/externals-flags.test.js b/test/core-flags/externals-flags.test.js index f402a194691..66b2e549c2d 100644 --- a/test/core-flags/externals-flags.test.js +++ b/test/core-flags/externals-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const externalsPresetsFlags = flags.filter(({ name }) => name.startsWith('externals-presets-')); +const cli = new CLI(); +const externalsPresetsFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('externals-presets-')); describe('externals related flag', () => { it('should set externals properly', () => { diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index bc7ccd1faa6..5a3759573fe 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const moduleFlags = flags.filter(({ name }) => name.startsWith('module-')); +const cli = new CLI(); +const moduleFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('module-')); describe('module config related flag', () => { moduleFlags.forEach((flag) => { diff --git a/test/core-flags/optimization-flags.test.js b/test/core-flags/optimization-flags.test.js index 72cd235c357..079f95929ab 100644 --- a/test/core-flags/optimization-flags.test.js +++ b/test/core-flags/optimization-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const optimizationFlags = flags.filter(({ name }) => name.startsWith('optimization-')); +const cli = new CLI(); +const optimizationFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('optimization-')); describe('optimization config related flag', () => { optimizationFlags.forEach((flag) => { diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index fb08268a5a1..3829a5e3a21 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const outputFlags = flags.filter(({ name }) => name.startsWith('output-')); +const cli = new CLI(); +const outputFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('output-')); describe('output config related flag', () => { outputFlags.forEach((flag) => { diff --git a/test/core-flags/performance-flags.test.js b/test/core-flags/performance-flags.test.js index f13d1ca0221..9d113fc7f22 100644 --- a/test/core-flags/performance-flags.test.js +++ b/test/core-flags/performance-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const performanceFlags = flags.filter(({ name }) => name.startsWith('performance-')); +const cli = new CLI(); +const performanceFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('performance-')); describe('module config related flag', () => { it(`should config --performance option correctly`, () => { diff --git a/test/core-flags/resolve-flags.test.js b/test/core-flags/resolve-flags.test.js index e2c069ff02c..6b0318fcbf6 100644 --- a/test/core-flags/resolve-flags.test.js +++ b/test/core-flags/resolve-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const resolveFlags = flags.filter(({ name }) => name.startsWith('resolve')); +const cli = new CLI(); +const resolveFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('resolve')); describe('resolve config related flags', () => { resolveFlags.forEach((flag) => { diff --git a/test/core-flags/snapshot-flags.test.js b/test/core-flags/snapshot-flags.test.js index 5860127cb3b..9cc9077db49 100644 --- a/test/core-flags/snapshot-flags.test.js +++ b/test/core-flags/snapshot-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const snapshotFlags = flags.filter(({ name }) => name.startsWith('snapshot')); +const cli = new CLI(); +const snapshotFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('snapshot')); describe('snapshot config related flags', () => { snapshotFlags.forEach((flag) => { diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index 3dccbbea5b5..77d7ff11edd 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const statsFlags = flags.filter(({ name }) => name.startsWith('stats-')); +const cli = new CLI(); +const statsFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('stats-')); describe('stats config related flag', () => { statsFlags.forEach((flag) => { diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index ddb47635f17..34656cccf7d 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -1,9 +1,10 @@ 'use strict'; const { run, hyphenToUpperCase } = require('../utils/test-utils'); -const { flags } = require('../../packages/webpack-cli/lib/utils/cli-flags'); +const CLI = require('../../packages/webpack-cli/lib/index'); -const watchFlags = flags.filter(({ name }) => name.startsWith('watch')); +const cli = new CLI(); +const watchFlags = cli.getBuiltInOptions().filter(({ name }) => name.startsWith('watch')); describe('watch config related flag', () => { watchFlags.forEach((flag) => { diff --git a/test/core-flags/webpack.test.config.js b/test/core-flags/webpack.test.config.js deleted file mode 100644 index cd24476ff4c..00000000000 --- a/test/core-flags/webpack.test.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = { mode: 'development' }; diff --git a/test/help/help.test.js b/test/help/help.test.js index 9b40070f5ab..4f1b703ede1 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -8,111 +8,124 @@ const helpDefaultHeader = 'The build tool for modern web applications.'; describe('help', () => { it('should show help information using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack [options]'); - expect(stdout).toContain(helpDefaultHeader); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--merge'); // minimum - expect(stdout).not.toContain('--cache-type'); // verbose - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Commands:'); - expect(stdout.match(/build\|bundle\|b/g)).toHaveLength(1); - expect(stdout.match(/watch\|w/g)).toHaveLength(1); - expect(stdout.match(/version\|v/g)).toHaveLength(1); - expect(stdout.match(/help\|h/g)).toHaveLength(1); - expect(stdout.match(/serve\|s/g)).toHaveLength(1); - expect(stdout.match(/info\|i/g)).toHaveLength(1); - expect(stdout.match(/init\|c/g)).toHaveLength(1); - expect(stdout.match(/loader\|l/g)).toHaveLength(1); - expect(stdout.match(/plugin\|p/g)).toHaveLength(1); - expect(stdout.match(/migrate\|m/g)).toHaveLength(1); - expect(stdout.match(/configtest\|t/g)).toHaveLength(1); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - // TODO buggy on windows - // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack [entries...] [options]'); + expect(pureStdout).toContain('webpack [command] [options]'); + expect(pureStdout).toContain(helpDefaultHeader); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--merge'); // minimum + expect(pureStdout).not.toContain('--cache-type'); // verbose + expect(pureStdout).toContain('Global options:'); + expect(pureStdout).toContain('Commands:'); + expect(pureStdout.match(/build\|bundle\|b/g)).toHaveLength(1); + expect(pureStdout.match(/watch\|w/g)).toHaveLength(1); + expect(pureStdout.match(/version\|v/g)).toHaveLength(1); + expect(pureStdout.match(/help\|h/g)).toHaveLength(1); + expect(pureStdout.match(/serve\|s/g)).toHaveLength(1); + expect(pureStdout.match(/info\|i/g)).toHaveLength(1); + expect(pureStdout.match(/init\|c/g)).toHaveLength(1); + expect(pureStdout.match(/loader\|l/g)).toHaveLength(1); + expect(pureStdout.match(/plugin\|p/g)).toHaveLength(1); + expect(pureStdout.match(/migrate\|m/g)).toHaveLength(1); + expect(pureStdout.match(/configtest\|t/g)).toHaveLength(1); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain('Made with ♥ by the webpack team.'); }); it.skip('should show help information using the "--help" option with the "verbose" value', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'verbose'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'verbose']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack [options]'); - expect(stdout).toContain(helpDefaultHeader); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--merge'); // minimum + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack [entries...] [options]'); + expect(pureStdout).toContain('webpack [command] [options]'); + expect(pureStdout).toContain(helpDefaultHeader); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--merge'); // minimum if (isWebpack5) { - expect(stdout).toContain('--cache-type'); // verbose + expect(pureStdout).toContain('--cache-type'); // verbose } - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Commands:'); - expect(stdout.match(/build\|bundle\|b/g)).toHaveLength(1); - expect(stdout.match(/watch\|w/g)).toHaveLength(1); - expect(stdout.match(/version\|v/g)).toHaveLength(1); - expect(stdout.match(/help\|h/g)).toHaveLength(1); - expect(stdout.match(/serve\|s/g)).toHaveLength(1); - expect(stdout.match(/info\|i/g)).toHaveLength(1); - expect(stdout.match(/init\|c/g)).toHaveLength(1); - expect(stdout.match(/loader\|l/g)).toHaveLength(1); - expect(stdout.match(/plugin\|p/g)).toHaveLength(1); - expect(stdout.match(/migrate\|m/g)).toHaveLength(1); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + expect(pureStdout).toContain('Global options:'); + expect(pureStdout).toContain('Commands:'); + expect(pureStdout.match(/build\|bundle\|b/g)).toHaveLength(1); + expect(pureStdout.match(/watch\|w/g)).toHaveLength(1); + expect(pureStdout.match(/version\|v/g)).toHaveLength(1); + expect(pureStdout.match(/help\|h/g)).toHaveLength(1); + expect(pureStdout.match(/serve\|s/g)).toHaveLength(1); + expect(pureStdout.match(/info\|i/g)).toHaveLength(1); + expect(pureStdout.match(/init\|c/g)).toHaveLength(1); + expect(pureStdout.match(/loader\|l/g)).toHaveLength(1); + expect(pureStdout.match(/plugin\|p/g)).toHaveLength(1); + expect(pureStdout.match(/migrate\|m/g)).toHaveLength(1); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain('Made with ♥ by the webpack team.'); }); it.skip('should show help information using the "--help" option with the "verbose" value #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help=verbose'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help=verbose']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack [options]'); - expect(stdout).toContain(helpDefaultHeader); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--merge'); // minimum + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack [entries...] [options]'); + expect(pureStdout).toContain('webpack [command] [options]'); + expect(pureStdout).toContain(helpDefaultHeader); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--merge'); // minimum if (isWebpack5) { - expect(stdout).toContain('--cache-type'); // verbose + expect(pureStdout).toContain('--cache-type'); // verbose } - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Commands:'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain('Global options:'); + expect(pureStdout).toContain('Commands:'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack [options]'); - expect(stdout).toContain(helpDefaultHeader); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--merge'); // minimum - expect(stdout).not.toContain('--cache-type'); // verbose - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Commands:'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack [entries...] [options]'); + expect(pureStdout).toContain('webpack [command] [options]'); + expect(pureStdout).toContain(helpDefaultHeader); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--merge'); // minimum + expect(pureStdout).not.toContain('--cache-type'); // verbose + expect(pureStdout).toContain('Global options:'); + expect(pureStdout).toContain('Commands:'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); // TODO buggy on windows // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show the same information using the "--help" option and command syntax', () => { - const { exitCode: exitCodeFromOption, stderr: stderrFromOption, stdout: stdoutFromOption } = run(__dirname, ['--help'], false); - const { exitCode: exitCodeFromCommandSyntax, stderr: stderrFromCommandSyntax, stdout: stdoutFromCommandSyntax } = run( - __dirname, - ['help'], - false, - ); + const { exitCode: exitCodeFromOption, stderr: stderrFromOption, stdout: stdoutFromOption } = run(__dirname, ['--help']); + const { exitCode: exitCodeFromCommandSyntax, stderr: stderrFromCommandSyntax, stdout: stdoutFromCommandSyntax } = run(__dirname, [ + 'help', + ]); expect(exitCodeFromOption).toBe(0); expect(exitCodeFromCommandSyntax).toBe(0); @@ -122,39 +135,47 @@ describe('help', () => { }); it('should show help information and respect the "--color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack [options]'); - expect(stdout).toContain(helpDefaultHeader); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--merge'); // minimum - expect(stdout).not.toContain('--cache-type'); // verbose - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Commands:'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(stdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack [entries...] [options]'); + expect(pureStdout).toContain('webpack [command] [options]'); + expect(pureStdout).toContain(helpDefaultHeader); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--merge'); // minimum + expect(pureStdout).not.toContain('--cache-type'); // verbose + expect(pureStdout).toContain('Global options:'); + expect(pureStdout).toContain('Commands:'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); }); it('should show help information and respect the "--no-color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--no-color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack [options]'); - expect(stdout).toContain(helpDefaultHeader); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--merge'); // minimum - expect(stdout).not.toContain('--cache-type'); // verbose - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Commands:'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack [entries...] [options]'); + expect(pureStdout).toContain('webpack [command] [options]'); + expect(pureStdout).toContain(helpDefaultHeader); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--merge'); // minimum + expect(pureStdout).not.toContain('--cache-type'); // verbose + expect(pureStdout).toContain('Global options:'); + expect(pureStdout).toContain('Commands:'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); // TODO bug in tests // expect(stdout).not.toContain(bold('Made with ♥ by the webpack team')); - expect(stdout).toContain('Made with ♥ by the webpack team'); + expect(pureStdout).toContain('Made with ♥ by the webpack team'); }); const commands = [ @@ -181,7 +202,7 @@ describe('help', () => { commands.forEach((command) => { it(`should show help information for '${command}' command using the "--help" option`, () => { - const { exitCode, stderr, stdout } = run(__dirname, [command, '--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -189,7 +210,7 @@ describe('help', () => { }); it(`should show help information for '${command}' command using command syntax`, () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', command], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', command]); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -197,7 +218,7 @@ describe('help', () => { }); it('should show help information and respect the "--color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--color'], false); + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -206,7 +227,7 @@ describe('help', () => { }); it('should show help information and respect the "--no-color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--no-color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -218,145 +239,178 @@ describe('help', () => { }); it('should show help information with options for sub commands', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['info', '--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--help']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack info|i [options]'); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--output '); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(stdout).toContain('Made with ♥ by the webpack team'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack info|i [options]'); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--output '); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain('Made with ♥ by the webpack team'); }); it('should show help information and taking precedence when "--help" and "--version" option using together', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('webpack [options]'); - expect(stdout).toContain(helpDefaultHeader); - expect(stdout).toContain('Options:'); - expect(stdout).toContain('--merge'); // minimum - expect(stdout).not.toContain('--cache-type'); // verbose - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Commands:'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('webpack [entries...] [options]'); + expect(pureStdout).toContain('webpack [command] [options]'); + expect(pureStdout).toContain(helpDefaultHeader); + expect(pureStdout).toContain('Options:'); + expect(pureStdout).toContain('--merge'); // minimum + expect(pureStdout).not.toContain('--cache-type'); // verbose + expect(pureStdout).toContain('Global options:'); + expect(pureStdout).toContain('Commands:'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); // TODO buggy on windows // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help --mode" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --mode '); - expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --mode '); + expect(pureStdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help --target" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--target'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--target']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + const pureStdout = stripAnsi(stdout); + if (isWebpack5) { - expect(stdout).toContain('Usage: webpack --target '); - expect(stdout).toContain('Short: webpack -t '); + expect(pureStdout).toContain('Usage: webpack --target '); + expect(pureStdout).toContain('Short: webpack -t '); } else { - expect(stdout).toContain('Usage: webpack --target '); - expect(stdout).toContain('Short: webpack -t '); + expect(pureStdout).toContain('Usage: webpack --target '); + expect(pureStdout).toContain('Short: webpack -t '); } - expect(stdout).toContain('Description: Sets the build target e.g. node.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain('Description: Sets the build target e.g. node.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help --stats" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--stats'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--stats']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --stats [value]'); - expect(stdout).toContain('Description: It instructs webpack on how to treat the stats e.g. verbose.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --stats [value]'); + expect(pureStdout).toContain('Description: It instructs webpack on how to treat the stats e.g. verbose.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help --no-stats" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-stats'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-stats']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --no-stats'); - expect(stdout).toContain('Description: Disable stats output.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --no-stats'); + expect(pureStdout).toContain('Description: Disable stats output.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help --mode" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --mode '); - expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --mode '); + expect(pureStdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help serve --mode" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--mode'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--mode']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack serve --mode '); - expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack serve --mode '); + expect(pureStdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help --color" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --color'); - expect(stdout).toContain('Description: Enable colors on console.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --color'); + expect(pureStdout).toContain('Description: Enable colors on console.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help --no-color" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --no-color'); - expect(stdout).toContain('Description: Disable colors on console.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --no-color'); + expect(pureStdout).toContain('Description: Disable colors on console.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help serve --color" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack serve --color'); - expect(stdout).toContain('Description: Enable colors on console.'); - expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack serve --color'); + expect(pureStdout).toContain('Description: Enable colors on console.'); + expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help serve --no-color" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--no-color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -367,33 +421,39 @@ describe('help', () => { }); it('should show help information using the "help --version" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --version'); - expect(stdout).toContain('Short: webpack -v'); - expect(stdout).toContain( + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --version'); + expect(pureStdout).toContain('Short: webpack -v'); + expect(pureStdout).toContain( "Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", ); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help -v" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '-v'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '-v']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('Usage: webpack --version'); - expect(stdout).toContain('Short: webpack -v'); - expect(stdout).toContain( + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).toContain('Usage: webpack --version'); + expect(pureStdout).toContain('Short: webpack -v'); + expect(pureStdout).toContain( "Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", ); - expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should log error for invalid command using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'myCommand'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'myCommand']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown value for '--help' option, please use '--help=verbose'"); @@ -401,7 +461,7 @@ describe('help', () => { }); it('should log error for invalid command using the "--help" option #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--flag', '--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--flag', '--help']); expect(exitCode).toBe(2); expect(stderr).toContain('Incorrect use of help'); @@ -411,7 +471,7 @@ describe('help', () => { }); it('should log error for invalid command using the "--help" option #3', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--flag', '--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--flag', '--help']); expect(exitCode).toBe(2); expect(stderr).toContain('Incorrect use of help'); @@ -421,7 +481,7 @@ describe('help', () => { }); it('should log error for unknown command using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'myCommand'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'myCommand']); expect(exitCode).toBe(2); expect(stderr).toContain("Can't find and load command 'myCommand'"); @@ -430,7 +490,7 @@ describe('help', () => { }); it('should log error for unknown command using command syntax #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'verbose'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'verbose']); expect(exitCode).toBe(2); expect(stderr).toContain("Can't find and load command 'verbose'"); @@ -439,7 +499,7 @@ describe('help', () => { }); it('should log error for unknown option using command syntax #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--made'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--made']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown option '--made'"); @@ -448,7 +508,7 @@ describe('help', () => { }); it('should log error for unknown option using command syntax #3', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--made'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--made']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown option '--made'"); @@ -457,7 +517,7 @@ describe('help', () => { }); it('should log error for unknown option using command syntax #4', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'bui', '--mode'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'bui', '--mode']); expect(exitCode).toBe(2); expect(stderr).toContain("Can't find and load command 'bui'"); @@ -466,7 +526,7 @@ describe('help', () => { }); it('should log error for invalid command using command syntax #3', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode', 'serve'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--mode', 'serve']); expect(exitCode).toBe(2); expect(stderr).toContain('Incorrect use of help'); @@ -476,7 +536,7 @@ describe('help', () => { }); it('should log error for invalid command using command syntax #4', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--mode', '--mode'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--mode', '--mode']); expect(exitCode).toBe(2); expect(stderr).toContain('Incorrect use of help'); @@ -486,7 +546,7 @@ describe('help', () => { }); it('should log error for invalid flag with the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--my-flag'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--my-flag']); expect(exitCode).toBe(2); expect(stderr).toContain('Incorrect use of help'); @@ -496,7 +556,7 @@ describe('help', () => { }); it('should log error for invalid flag with the "--help" option #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'init', 'info'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', 'init', 'info']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown value for '--help' option, please use '--help=verbose'"); diff --git a/test/merge/config-absent/merge-config-absent.test.js b/test/merge/config-absent/merge-config-absent.test.js index 5c9d6e05d03..623d8259758 100644 --- a/test/merge/config-absent/merge-config-absent.test.js +++ b/test/merge/config-absent/merge-config-absent.test.js @@ -1,5 +1,7 @@ 'use strict'; +const path = require('path'); + const { run } = require('../../utils/test-utils'); describe('merge flag configuration', () => { @@ -11,6 +13,6 @@ describe('merge flag configuration', () => { // Since the process will exit, nothing on stdout expect(stdout).toBeFalsy(); // Confirm that the user is notified - expect(stderr).toContain(`The specified config file doesn't exist`); + expect(stderr).toContain(`Failed to load '${path.resolve(__dirname, './2.js')}' config`); }); }); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 3ad7aa8def4..a57308f0a00 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -7,9 +7,6 @@ const { runServe, isWebpack5, isDevServer4 } = require('../../utils/test-utils') const testPath = path.resolve(__dirname); -const usageText = 'webpack serve|s [options]'; -const descriptionText = 'Run the webpack dev server'; - describe('basic serve usage', () => { let port; @@ -28,7 +25,7 @@ describe('basic serve usage', () => { } it('should work', async () => { - const { stderr, stdout } = await runServe(__dirname, ['']); + const { stderr, stdout } = await runServe(__dirname, []); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -36,7 +33,7 @@ describe('basic serve usage', () => { }); it('should work with the "--config" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'webpack.config.js', '--port', port]); + const { stderr, stdout } = await runServe(__dirname, ['--config', 'serve.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); @@ -45,7 +42,6 @@ describe('basic serve usage', () => { it('should work with the "--config" and "--env" options', async () => { const { stderr, stdout } = await runServe(__dirname, [ - 'serve', '--config', 'function-with-env.config.js', '--env', @@ -63,7 +59,6 @@ describe('basic serve usage', () => { it('should work with the "--config" and "--env" options and expose dev server options', async () => { const { stderr, stdout } = await runServe(__dirname, [ - 'serve', '--config', 'function-with-argv.config.js', '--env', @@ -82,7 +77,7 @@ describe('basic serve usage', () => { }); it('should work in multi compiler mode', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'multi.config.js', '--port', port]); + const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -94,7 +89,7 @@ describe('basic serve usage', () => { // TODO need fix in future, edge case it.skip('should work in multi compiler mode with multiple dev servers', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'multi-dev-server.config.js']); + const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi-dev-server.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -163,14 +158,6 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('should log help information and respect the "--no-color" option', async () => { - const { stdout, stderr } = await runServe(__dirname, ['--help', '--no-color']); - - expect(stderr).toBeFalsy(); - expect(stdout).toContain(usageText); - expect(stdout).toContain(descriptionText); - }); - it('should work with the "--client-log-level" option', async () => { const { stdout, stderr } = await runServe(testPath, ['--client-log-level', 'info']); @@ -228,7 +215,7 @@ describe('basic serve usage', () => { }); it('should work with the default "publicPath" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve']); + const { stderr, stdout } = await runServe(__dirname, []); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -237,7 +224,7 @@ describe('basic serve usage', () => { }); it('should work with the "--output-public-path" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve', '--output-public-path', '/my-public-path/']); + const { stderr, stdout } = await runServe(__dirname, ['--output-public-path', '/my-public-path/']); if (isWebpack5) { expect(stderr).toBeFalsy(); @@ -251,7 +238,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'output-public-path.config.js']); + const { stderr, stdout } = await runServe(__dirname, ['--config', 'output-public-path.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -260,7 +247,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration using multi compiler mode', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'multi-output-public-path.config.js', '--port', port]); + const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi-output-public-path.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -272,7 +259,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration (from the "devServer" options)', async () => { - const { stderr, stdout } = await runServe(__dirname, ['serve', '--config', 'dev-server-output-public-path.config.js']); + const { stderr, stdout } = await runServe(__dirname, ['--config', 'dev-server-output-public-path.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -289,13 +276,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration using multi compiler mode (from the "devServer" options)', async () => { - const { stderr, stdout } = await runServe(__dirname, [ - 'serve', - '--config', - 'multi-dev-server-output-public-path.config.js', - '--port', - port, - ]); + const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi-dev-server-output-public-path.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stderr).toBeFalsy(); @@ -307,6 +288,14 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); + it('should work with entries syntax', async () => { + const { stderr, stdout } = await runServe(__dirname, ['./src/entry.js', '--port', port]); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain('development'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + it('should log and error on unknown flag', async () => { const { exitCode, stdout, stderr } = await runServe(testPath, ['--port', port, '--unknown-flag']); diff --git a/test/serve/basic/serve.config.js b/test/serve/basic/serve.config.js new file mode 100644 index 00000000000..cef4d803dc3 --- /dev/null +++ b/test/serve/basic/serve.config.js @@ -0,0 +1,7 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = { + mode: 'development', + devtool: false, + plugins: [new WebpackCLITestPlugin(['mode'], false, 'hooks.compilation.taps')], +}; diff --git a/test/serve/basic/src/entry.js b/test/serve/basic/src/entry.js new file mode 100644 index 00000000000..a136806e8f1 --- /dev/null +++ b/test/serve/basic/src/entry.js @@ -0,0 +1 @@ +console.log('Entry'); diff --git a/test/serve/help/serve-help.test.js b/test/serve/help/serve-help.test.js index c1f4cc840c2..eb8cabef807 100644 --- a/test/serve/help/serve-help.test.js +++ b/test/serve/help/serve-help.test.js @@ -1,11 +1,12 @@ const { runServe, isWebpack5 } = require('../../utils/test-utils'); -const usageText = 'webpack serve|s [options]'; +const usageText = 'webpack serve|s [entries...] [options]'; const descriptionText = 'Run the webpack dev server'; describe('serve help', () => { - it('should output serve help', async () => { + it('should log help information', async () => { const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help']); + expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); expect(stdout).toContain(descriptionText); @@ -18,15 +19,25 @@ describe('serve help', () => { expect(stdout).toContain('--open [value]'); }); - it('should output all flags when verbose help is set', async () => { + it('should log help information using "verbose"', async () => { const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help', 'verbose']); + expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); expect(stdout).toContain(descriptionText); expect(stdout).toContain(usageText); expect(stdout).toContain('Options:'); + if (isWebpack5) { expect(stdout).toContain('--cache-type'); } }); + + it('should log help information and respect the "--no-color" option', async () => { + const { stdout, stderr } = await runServe(__dirname, ['--help', '--no-color']); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain(usageText); + expect(stdout).toContain(descriptionText); + }); }); diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index ad3b6c97ec3..c87fbd5bcd2 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -203,7 +203,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['qqq'], true, [], { TERM_PROGRAM: false }); expect(exitCode).toBe(2); - expect(stripAnsi(stderr)).toContain("Unknown command 'qqq'"); + expect(stripAnsi(stderr)).toContain("Unknown command or entry 'qqq'"); expect(stripAnsi(stderr)).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -212,7 +212,7 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['server'], true, [], { TERM_PROGRAM: false }); expect(exitCode).toBe(2); - expect(stripAnsi(stderr)).toContain("Unknown command 'server'"); + expect(stripAnsi(stderr)).toContain("Unknown command or entry 'server'"); expect(stripAnsi(stderr)).toContain("Did you mean 'serve' (alias 's')?"); expect(stripAnsi(stderr)).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js index 34fee148278..0d24c6dda3a 100644 --- a/test/watch/basic/basic.test.js +++ b/test/watch/basic/basic.test.js @@ -83,6 +83,41 @@ describe('basic', () => { }); }); + it('should recompile upon file change using the `watch` command and entries syntax', (done) => { + const proc = runAndGetWatchProc(__dirname, ['watch', './src/entry.js', '--mode', 'development'], false, '', true); + + let modified = false; + + const wordsInStatsv5Entries = ['asset', 'entry.js', 'compiled successfully']; + + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + if (data.includes('entry.js')) { + if (isWebpack5) { + for (const word of wordsInStatsv5Entries) { + expect(data).toContain(word); + } + } else { + for (const word of wordsInStatsv4) { + expect(data).toContain(word); + } + } + + if (!modified) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/entry.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } + } + }); + }); + it('should recompile upon file change using the `command` option and the `--watch` option and log warning', (done) => { const proc = runAndGetWatchProc(__dirname, ['watch', '--watch', '--mode', 'development'], false, '', true); diff --git a/test/watch/basic/src/entry.js b/test/watch/basic/src/entry.js new file mode 100644 index 00000000000..1d8734ee1c8 --- /dev/null +++ b/test/watch/basic/src/entry.js @@ -0,0 +1 @@ +console.log('watch flag test'); From 311bae336d83424c800e553b6ef40242d967685c Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 28 Jan 2021 15:30:22 +0530 Subject: [PATCH 282/581] fix: improve description for 'configtest' command (#2379) --- OPTIONS.md | 2 +- packages/configtest/package.json | 2 +- packages/configtest/src/index.ts | 2 +- packages/webpack-cli/README.md | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index f87c5a7269e..9cf47d8cec7 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -794,7 +794,7 @@ Global options: Commands: build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Tests webpack configuration against validation errors. + configtest|t [config-path] Validate a webpack configuration. help|h [command] [option] Display help for commands and options. info|i [options] Outputs information about your system. init|c [scaffold...] [options] Initialize a new webpack configuration. diff --git a/packages/configtest/package.json b/packages/configtest/package.json index 6b0857083b0..b33a1bd3d15 100644 --- a/packages/configtest/package.json +++ b/packages/configtest/package.json @@ -1,7 +1,7 @@ { "name": "@webpack-cli/configtest", "version": "1.0.0", - "description": "Tests webpack configuration against validation errors.", + "description": "Validate a webpack configuration.", "main": "lib/index.js", "types": "lib/index.d.ts", "license": "MIT", diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts index f9b5b92304a..50e4a3d9205 100644 --- a/packages/configtest/src/index.ts +++ b/packages/configtest/src/index.ts @@ -6,7 +6,7 @@ class ConfigTestCommand { { name: 'configtest [config-path]', alias: 't', - description: 'Tests webpack configuration against validation errors.', + description: 'Validate a webpack configuration.', pkg: '@webpack-cli/configtest', }, [], diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index ca7f2204b8d..a7248a715c6 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -63,17 +63,17 @@ npx webpack-cli --help verbose ### Available Commands ``` - build|bundle|b [options] Run webpack (default command, can be omitted). - watch|w [options] Run webpack and watch for files changes. - version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). + configtest|t [config-path] Validate a webpack configuration. help|h [command] [option] Display help for commands and options. - serve|s [options] Run the webpack dev server. info|i [options] Outputs information about your system. - init|c [options] [scaffold...] Initialize a new webpack configuration. + init|c [scaffold...] [options] Initialize a new webpack configuration. loader|l [output-path] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. - configtest|t [config-path] Tests webpack configuration against validation errors. plugin|p [output-path] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. + watch|w [entries...] [options] Run webpack and watch for files changes. ``` ### webpack 4 From f9ce1d30b83bf0e0b4d91498d012c13c208e6e67 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Thu, 28 Jan 2021 17:03:37 +0300 Subject: [PATCH 283/581] fix: error message on invalid plugin options (#2380) --- package.json | 2 +- packages/serve/src/index.ts | 2 +- packages/webpack-cli/lib/webpack-cli.js | 26 +++--- .../invalid-schema/invalid-schema.test.js | 89 ++++++++++++++++++- ....config.mock.js => webpack.mock.config.js} | 0 .../webpack.plugin-mock.config.js | 10 +++ yarn.lock | 45 +++++----- 7 files changed, 139 insertions(+), 35 deletions(-) rename test/error/invalid-schema/{webpack.config.mock.js => webpack.mock.config.js} (100%) create mode 100644 test/error/invalid-schema/webpack.plugin-mock.config.js diff --git a/package.json b/package.json index f029c615ce4..504d74f5ff9 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", "typescript": "^4.1.3", - "webpack": "^5.17.0", + "webpack": "^5.18.0", "webpack-bundle-analyzer": "^4.3.0", "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 5b72fd66a3a..508b5cee234 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -113,7 +113,7 @@ class ServeCommand { try { servers = await startDevServer(compiler, devServerOptions, options, logger); } catch (error) { - if (error.name === 'ValidationError') { + if (cli.isValidationError(error)) { logger.error(error.message); } else { logger.error(error); diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index b945f9b189f..0baf614ee13 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1172,7 +1172,13 @@ class WebpackCLI { } } catch (error) { logger.error(`Failed to load '${configPath}' config`); - logger.error(error); + + if (this.isValidationError(error)) { + logger.error(error.message); + } else { + logger.error(error); + } + process.exit(2); } @@ -1602,15 +1608,15 @@ class WebpackCLI { return compiler.options.watchOptions && compiler.options.watchOptions.stdin; } - async createCompiler(options, callback) { - const isValidationError = (error) => { - // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 - // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 - const ValidationError = this.webpack.ValidationError || this.webpack.WebpackOptionsValidationError; + isValidationError(error) { + // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 + // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 + const ValidationError = this.webpack.ValidationError || this.webpack.WebpackOptionsValidationError; - return error instanceof ValidationError; - }; + return error instanceof ValidationError || error.name === 'ValidationError'; + } + async createCompiler(options, callback) { let config = await this.resolveConfig(options); config = await this.applyOptions(config, options); @@ -1623,7 +1629,7 @@ class WebpackCLI { config.options, callback ? (error, stats) => { - if (isValidationError(error)) { + if (error && this.isValidationError(error)) { logger.error(error.message); process.exit(2); } @@ -1633,7 +1639,7 @@ class WebpackCLI { : callback, ); } catch (error) { - if (isValidationError(error)) { + if (this.isValidationError(error)) { logger.error(error.message); } else { logger.error(error); diff --git a/test/error/invalid-schema/invalid-schema.test.js b/test/error/invalid-schema/invalid-schema.test.js index cfcb54542da..05c04c8d735 100644 --- a/test/error/invalid-schema/invalid-schema.test.js +++ b/test/error/invalid-schema/invalid-schema.test.js @@ -3,15 +3,23 @@ const { run, isWebpack5 } = require('../../utils/test-utils'); describe('invalid schema', () => { it('should log error on invalid config', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.mock.config.js']); expect(exitCode).toEqual(2); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); + it('should log error on invalid plugin options', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.plugin-mock.config.js']); + + expect(exitCode).toEqual(2); + expect(stderr).toContain(isWebpack5 ? 'Invalid options object' : 'Invalid Options'); + expect(stdout).toBeFalsy(); + }); + it('should log error on invalid config using the "bundle" command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--config', './webpack.config.mock.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--config', './webpack.mock.config.js']); expect(exitCode).toEqual(2); expect(stderr).toContain('Invalid configuration object'); @@ -19,7 +27,7 @@ describe('invalid schema', () => { }); it('should log error on invalid config using the "serve" command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--config', './webpack.config.mock.js']); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--config', './webpack.mock.config.js']); expect(exitCode).toEqual(2); expect(stderr).toContain('Invalid configuration object'); @@ -41,6 +49,21 @@ describe('invalid schema', () => { expect(stdout).toBeFalsy(); }); + it('should log error on invalid option using "build" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['build', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); + it('should log error on invalid option using "bundle" command', () => { const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--mode', 'Yukihira']); @@ -56,6 +79,51 @@ describe('invalid schema', () => { expect(stdout).toBeFalsy(); }); + it('should log error on invalid option using "b" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['b', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid option using "watch" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['watch', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid option using "w" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['w', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); + it('should log error on invalid option using "server" command', () => { const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--mode', 'Yukihira']); @@ -70,4 +138,19 @@ describe('invalid schema', () => { expect(stdout).toBeFalsy(); }); + + it('should log error on invalid option using "s" command', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['s', '--mode', 'Yukihira']); + + expect(exitCode).toEqual(2); + + if (isWebpack5) { + expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option"); + expect(stderr).toContain("Expected: 'development | production | none'"); + } else { + expect(stderr).toContain('Invalid configuration object'); + } + + expect(stdout).toBeFalsy(); + }); }); diff --git a/test/error/invalid-schema/webpack.config.mock.js b/test/error/invalid-schema/webpack.mock.config.js similarity index 100% rename from test/error/invalid-schema/webpack.config.mock.js rename to test/error/invalid-schema/webpack.mock.config.js diff --git a/test/error/invalid-schema/webpack.plugin-mock.config.js b/test/error/invalid-schema/webpack.plugin-mock.config.js new file mode 100644 index 00000000000..24a228b9d92 --- /dev/null +++ b/test/error/invalid-schema/webpack.plugin-mock.config.js @@ -0,0 +1,10 @@ +const webpack = require('webpack'); + +module.exports = { + mode: 'development', + plugins: [ + new webpack.BannerPlugin({ + unknown: 'unknown', + }), + ], +}; diff --git a/yarn.lock b/yarn.lock index 0dbfd643050..a05832ed73a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1895,11 +1895,16 @@ jest-diff "^26.0.0" pretty-format "^26.0.0" -"@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.6": +"@types/json-schema@*", "@types/json-schema@^7.0.3": version "7.0.6" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== +"@types/json-schema@^7.0.6": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad" + integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA== + "@types/keyv@*": version "3.1.1" resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.1.tgz#e45a45324fca9dab716ab1230ee249c9fb52cfa7" @@ -2863,15 +2868,15 @@ browser-process-hrtime@^1.0.0: integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== browserslist@^4.14.5: - version "4.15.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.15.0.tgz#3d48bbca6a3f378e86102ffd017d9a03f122bdb0" - integrity sha512-IJ1iysdMkGmjjYeRlDU8PQejVwxvVO5QOfXH7ylW31GO6LwNRSmm/SgRXtNsEXqMLl2e+2H5eEJ7sfynF8TCaQ== + version "4.16.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.1.tgz#bf757a2da376b3447b800a16f0f1c96358138766" + integrity sha512-UXhDrwqsNcpTYJBTZsbGATDxZbiVDsx6UjpmRUmtnP10pr8wAYr5LgFoEFw9ixriQH2mv/NX2SfGzE/o8GndLA== dependencies: - caniuse-lite "^1.0.30001164" + caniuse-lite "^1.0.30001173" colorette "^1.2.1" - electron-to-chromium "^1.3.612" + electron-to-chromium "^1.3.634" escalade "^3.1.1" - node-releases "^1.1.67" + node-releases "^1.1.69" bs-logger@0.x: version "0.2.6" @@ -3066,10 +3071,10 @@ camelcase@^6.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== -caniuse-lite@^1.0.30001164: - version "1.0.30001165" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001165.tgz#32955490d2f60290bb186bb754f2981917fa744f" - integrity sha512-8cEsSMwXfx7lWSUMA2s08z9dIgsnR5NAqjXP23stdsU3AUWkCr/rr4s4OFtHXn5XXr6+7kam3QFVoYyXNPdJPA== +caniuse-lite@^1.0.30001173: + version "1.0.30001180" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001180.tgz#67abcd6d1edf48fa5e7d1e84091d1d65ab76e33b" + integrity sha512-n8JVqXuZMVSPKiPiypjFtDTXc4jWIdjxull0f92WLo7e1MSi3uJ3NvveakSh/aCl1QKFAvIz3vIj0v+0K+FrXw== capture-exit@^2.0.0: version "2.0.0" @@ -4147,10 +4152,10 @@ ejs@^3.0.1: dependencies: jake "^10.6.1" -electron-to-chromium@^1.3.612: - version "1.3.621" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.621.tgz#0bbe2100ef0b28f88d0b1101fbdf433312f69be0" - integrity sha512-FeIuBzArONbAmKmZIsZIFGu/Gc9AVGlVeVbhCq+G2YIl6QkT0TDn2HKN/FMf1btXEB9kEmIuQf3/lBTVAbmFOg== +electron-to-chromium@^1.3.634: + version "1.3.647" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.647.tgz#8f1750ab7a5137f1a9a27f8f4ebdf550e08ae10b" + integrity sha512-Or2Nu8TjkmSywY9hk85K/Y6il28hchlonITz30fkC87qvSNupQl29O12BzDDDTnUFlo6kEIFL2QGSpkZDMxH8g== elegant-spinner@^1.0.1: version "1.0.1" @@ -8019,10 +8024,10 @@ node-preload@^0.2.1: dependencies: process-on-spawn "^1.0.0" -node-releases@^1.1.67: - version "1.1.67" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.67.tgz#28ebfcccd0baa6aad8e8d4d8fe4cbc49ae239c12" - integrity sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg== +node-releases@^1.1.69: + version "1.1.70" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.70.tgz#66e0ed0273aa65666d7fe78febe7634875426a08" + integrity sha512-Slf2s69+2/uAD79pVVQo8uSiC34+g8GWY8UH2Qtqv34ZfhYrxpYpfzs9Js9d6O0mbDmALuxaTlplnBTnSELcrw== nopt@^4.0.1: version "4.0.3" @@ -11072,7 +11077,7 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.17.0: +webpack@^5.18.0: version "5.18.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.18.0.tgz#bbcf13094aa0da0534d513f27d7ee72d74e499c6" integrity sha512-RmiP/iy6ROvVe/S+u0TrvL/oOmvP+2+Bs8MWjvBwwY/j82Q51XJyDJ75m0QAGntL1Wx6B//Xc0+4VPP/hlNHmw== From 529e9f01372a5cc6e910dd65528dc759819ac823 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 29 Jan 2021 18:38:36 +0300 Subject: [PATCH 284/581] refactor: code --- .eslintignore | 11 +- .eslintrc.js | 1 + .prettierignore | 9 +- .../resolveConfig/resolveConfig.test.js | 14 +- packages/webpack-cli/bin/cli.js | 16 +- packages/webpack-cli/lib/bootstrap.js | 6 +- packages/webpack-cli/lib/index.js | 6 +- packages/webpack-cli/lib/plugins/CLIPlugin.js | 9 +- .../lib/utils/get-package-manager.js | 5 +- packages/webpack-cli/lib/utils/index.js | 45 ++++ packages/webpack-cli/lib/utils/logger.js | 10 +- .../webpack-cli/lib/utils/package-exists.js | 4 +- .../lib/utils/prompt-installation.js | 23 +- packages/webpack-cli/lib/utils/run-command.js | 4 +- packages/webpack-cli/lib/webpack-cli.js | 244 +++++++++--------- 15 files changed, 233 insertions(+), 174 deletions(-) create mode 100644 packages/webpack-cli/lib/utils/index.js diff --git a/.eslintignore b/.eslintignore index acb5f4123c7..b6038bd2368 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,13 +1,18 @@ -__testfixtures__ coverage +.nyc_output node_modules -packages/**/lib +dist +packages/configtest/lib +packages/generators/lib +packages/info/lib +packages/init/lib +packages/serve/lib test/**/dist/ test/**/bin/ test/**/binary/ test/**/index.js -test/typescript/webpack.config.ts test/config/error-commonjs/syntax-error.js test/config/error-mjs/syntax-error.mjs test/config/error-array/webpack.config.js test/configtest/with-config-path/syntax-error.config.js +packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__ diff --git a/.eslintrc.js b/.eslintrc.js index fa66f1777f4..9e59b158b59 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,6 +21,7 @@ module.exports = { 'no-caller': 'error', 'no-extra-bind': 'error', 'no-loop-func': 'error', + 'no-undef': 'error', }, overrides: [ { diff --git a/.prettierignore b/.prettierignore index c45e6482b38..877e50a1666 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,13 +1,18 @@ coverage .nyc_output node_modules +dist +packages/configtest/lib +packages/generators/lib +packages/info/lib +packages/init/lib +packages/serve/lib test/**/dist/ test/**/bin/ test/**/binary/ test/**/index.js test/config/error-commonjs/syntax-error.js test/config/error-mjs/syntax-error.mjs +test/configtest/with-config-path/syntax-error.config.js packages/webpack-cli/__tests__/test-assets/.yo-rc.json test/build-errors/stats.json -packages/**/lib -test/configtest/with-config-path/syntax-error.config.js diff --git a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js index 4522bfc3f2c..d3002fb0225 100644 --- a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js +++ b/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js @@ -5,11 +5,11 @@ const config2 = require('./webpack.config2.cjs'); const arrayConfig = require('./webpack.config.cjs'); const promiseConfig = require('./webpack.promise.config.cjs'); -const resolveConfig = new WebpackCLI().resolveConfig; +const cli = new WebpackCLI(); describe('resolveConfig', function () { it('should handle merge properly', async () => { - const result = await resolveConfig({ + const result = await cli.resolveConfig({ merge: true, config: [resolve(__dirname, './webpack.config.cjs')], }); @@ -27,7 +27,7 @@ describe('resolveConfig', function () { }); it('should return array for multiple config', async () => { - const result = await resolveConfig({ + const result = await cli.resolveConfig({ config: [resolve(__dirname, './webpack.config1.cjs'), resolve(__dirname, './webpack.config2.cjs')], }); const expectedOptions = [config1, config2]; @@ -36,20 +36,20 @@ describe('resolveConfig', function () { }); it('should return config object for single config', async () => { - const result = await resolveConfig({ config: [resolve(__dirname, './webpack.config1.cjs')] }); + const result = await cli.resolveConfig({ config: [resolve(__dirname, './webpack.config1.cjs')] }); expect(result.options).toEqual(config1); }); it('should return resolved config object for promise config', async () => { - const result = await resolveConfig({ config: [resolve(__dirname, './webpack.promise.config.cjs')] }); + const result = await cli.resolveConfig({ config: [resolve(__dirname, './webpack.promise.config.cjs')] }); const expectedOptions = await promiseConfig(); expect(result.options).toEqual(expectedOptions); }); it('should handle configs returning different types', async () => { - const result = await resolveConfig({ + const result = await cli.resolveConfig({ config: [resolve(__dirname, './webpack.promise.config.cjs'), resolve(__dirname, './webpack.config.cjs')], }); const resolvedPromiseConfig = await promiseConfig(); @@ -59,7 +59,7 @@ describe('resolveConfig', function () { }); it('should handle different env formats', async () => { - const result = await resolveConfig({ + const result = await cli.resolveConfig({ argv: { env: { test: true, name: 'Hisoka' } }, config: [resolve(__dirname, './env.webpack.config.cjs')], }); diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index d309c0a985f..c78e0935e9f 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -1,15 +1,11 @@ #!/usr/bin/env node 'use strict'; - require('v8-compile-cache'); const importLocal = require('import-local'); const runCLI = require('../lib/bootstrap'); -const { yellow } = require('colorette'); -const { error, success } = require('../lib/utils/logger'); -const packageExists = require('../lib/utils/package-exists'); -const promptInstallation = require('../lib/utils/prompt-installation'); +const utils = require('../lib/utils'); // Prefer the local installation of `webpack-cli` if (importLocal(__filename)) { @@ -18,19 +14,21 @@ if (importLocal(__filename)) { process.title = 'webpack'; -if (packageExists('webpack')) { +if (utils.packageExists('webpack')) { runCLI(process.argv); } else { + const { promptInstallation, logger, colors } = utils; + promptInstallation('webpack', () => { - error(`It looks like ${yellow('webpack')} is not installed.`); + utils.logger.error(`It looks like ${colors.bold('webpack')} is not installed.`); }) .then(() => { - success(`${yellow('webpack')} was installed successfully.`); + logger.success(`${colors.bold('webpack')} was installed successfully.`); runCLI(process.argv); }) .catch(() => { - error(`Action Interrupted, Please try once again or install ${yellow('webpack')} manually.`); + logger.error(`Action Interrupted, Please try once again or install ${colors.bold('webpack')} manually.`); process.exit(2); }); diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index ffb65e53c08..c01ca2b7ce7 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -1,7 +1,5 @@ const WebpackCLI = require('./webpack-cli'); -const logger = require('./utils/logger'); - -process.title = 'webpack-cli'; +const utils = require('./utils'); const runCLI = async (args) => { try { @@ -10,7 +8,7 @@ const runCLI = async (args) => { await cli.run(args); } catch (error) { - logger.error(error); + utils.logger.error(error); process.exit(2); } }; diff --git a/packages/webpack-cli/lib/index.js b/packages/webpack-cli/lib/index.js index fa7a933054f..0af01e8eb7c 100644 --- a/packages/webpack-cli/lib/index.js +++ b/packages/webpack-cli/lib/index.js @@ -1,7 +1,5 @@ const CLI = require('./webpack-cli'); -const logger = require('./utils/logger'); -const getPackageManager = require('./utils/get-package-manager'); +const utils = require('./utils'); module.exports = CLI; -// export additional utils used by other packages -module.exports.utils = { logger, getPackageManager }; +module.exports.utils = utils; diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js index 584d6e21a07..350ee33e573 100644 --- a/packages/webpack-cli/lib/plugins/CLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -1,13 +1,10 @@ -const packageExists = require('../utils/package-exists'); -const webpack = packageExists('webpack') ? require('webpack') : undefined; - class CLIPlugin { constructor(options) { this.options = options; } setupHotPlugin(compiler) { - const { HotModuleReplacementPlugin } = compiler.webpack || webpack; + const { HotModuleReplacementPlugin } = compiler.webpack || require('webpack'); const hotModuleReplacementPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof HotModuleReplacementPlugin)); if (!hotModuleReplacementPlugin) { @@ -16,7 +13,7 @@ class CLIPlugin { } setupPrefetchPlugin(compiler) { - const { PrefetchPlugin } = compiler.webpack || webpack; + const { PrefetchPlugin } = compiler.webpack || require('webpack'); new PrefetchPlugin(null, this.options.prefetch).apply(compiler); } @@ -32,7 +29,7 @@ class CLIPlugin { } setupProgressPlugin(compiler) { - const { ProgressPlugin } = compiler.webpack || webpack; + const { ProgressPlugin } = compiler.webpack || require('webpack'); const progressPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin)); if (!progressPlugin) { diff --git a/packages/webpack-cli/lib/utils/get-package-manager.js b/packages/webpack-cli/lib/utils/get-package-manager.js index d25f3564778..616e64b31c2 100644 --- a/packages/webpack-cli/lib/utils/get-package-manager.js +++ b/packages/webpack-cli/lib/utils/get-package-manager.js @@ -1,8 +1,9 @@ const fs = require('fs'); const path = require('path'); -const logger = require('./logger'); const { sync } = require('execa'); +const utils = require('./index'); + /** * * Returns the name of package manager to use, @@ -56,7 +57,7 @@ function getPackageManager() { return 'pnpm'; } } catch (e) { - logger.error('No package manager found.'); + utils.logger.error('No package manager found.'); process.exit(2); } } diff --git a/packages/webpack-cli/lib/utils/index.js b/packages/webpack-cli/lib/utils/index.js new file mode 100644 index 00000000000..223e9c0cf3f --- /dev/null +++ b/packages/webpack-cli/lib/utils/index.js @@ -0,0 +1,45 @@ +module.exports = { + get colors() { + return require('colorette'); + }, + + get levenshtein() { + return require('fastest-levenshtein'); + }, + + get interpret() { + return require('interpret'); + }, + + get rechoir() { + return require('rechoir'); + }, + + get capitalizeFirstLetter() { + return require('./capitalize-first-letter'); + }, + + get getPackageManager() { + return require('./get-package-manager'); + }, + + get logger() { + return require('./logger'); + }, + + get packageExists() { + return require('./package-exists'); + }, + + get promptInstallation() { + return require('./prompt-installation'); + }, + + get runCommand() { + return require('./run-command'); + }, + + get toKebabCase() { + return require('./to-kebab-case'); + }, +}; diff --git a/packages/webpack-cli/lib/utils/logger.js b/packages/webpack-cli/lib/utils/logger.js index 3afafc1ad44..b0d37baafd8 100644 --- a/packages/webpack-cli/lib/utils/logger.js +++ b/packages/webpack-cli/lib/utils/logger.js @@ -1,11 +1,11 @@ +const utils = require('./index'); const util = require('util'); -const { red, cyan, yellow, green } = require('colorette'); module.exports = { - error: (val) => console.error(`[webpack-cli] ${red(util.format(val))}`), - warn: (val) => console.warn(`[webpack-cli] ${yellow(val)}`), - info: (val) => console.info(`[webpack-cli] ${cyan(val)}`), - success: (val) => console.log(`[webpack-cli] ${green(val)}`), + error: (val) => console.error(`[webpack-cli] ${utils.colors.red(util.format(val))}`), + warn: (val) => console.warn(`[webpack-cli] ${utils.colors.yellow(val)}`), + info: (val) => console.info(`[webpack-cli] ${utils.colors.cyan(val)}`), + success: (val) => console.log(`[webpack-cli] ${utils.colors.green(val)}`), log: (val) => console.log(`[webpack-cli] ${val}`), raw: (val) => console.log(val), }; diff --git a/packages/webpack-cli/lib/utils/package-exists.js b/packages/webpack-cli/lib/utils/package-exists.js index 48211cfb938..532b619c8b2 100644 --- a/packages/webpack-cli/lib/utils/package-exists.js +++ b/packages/webpack-cli/lib/utils/package-exists.js @@ -1,4 +1,4 @@ -function getPkg(packageName) { +function packageExists(packageName) { try { return require.resolve(packageName); } catch (error) { @@ -6,4 +6,4 @@ function getPkg(packageName) { } } -module.exports = getPkg; +module.exports = packageExists; diff --git a/packages/webpack-cli/lib/utils/prompt-installation.js b/packages/webpack-cli/lib/utils/prompt-installation.js index d025d80e6ff..d477701a03b 100644 --- a/packages/webpack-cli/lib/utils/prompt-installation.js +++ b/packages/webpack-cli/lib/utils/prompt-installation.js @@ -1,9 +1,5 @@ const { prompt } = require('enquirer'); -const { green } = require('colorette'); -const runCommand = require('./run-command'); -const getPackageManager = require('./get-package-manager'); -const packageExists = require('./package-exists'); -const logger = require('./logger'); +const utils = require('./index'); /** * @@ -11,10 +7,10 @@ const logger = require('./logger'); * @param preMessage Message to show before the question */ async function promptInstallation(packageName, preMessage) { - const packageManager = getPackageManager(); + const packageManager = utils.getPackageManager(); if (!packageManager) { - logger.error("Can't find package manager"); + utils.logger.error("Can't find package manager"); process.exit(2); } @@ -24,6 +20,7 @@ async function promptInstallation(packageName, preMessage) { // yarn uses 'add' command, rest npm and pnpm both use 'install' const commandToBeRun = `${packageManager} ${[packageManager === 'yarn' ? 'add' : 'install', '-D', packageName].join(' ')}`; + const { colors } = utils; let installConfirm; @@ -32,25 +29,27 @@ async function promptInstallation(packageName, preMessage) { { type: 'confirm', name: 'installConfirm', - message: `Would you like to install '${green(packageName)}' package? (That will run '${green(commandToBeRun)}')`, + message: `Would you like to install '${colors.green(packageName)}' package? (That will run '${colors.green( + commandToBeRun, + )}')`, initial: 'Y', stdout: process.stderr, }, ])); } catch (error) { - logger.error(error); + utils.logger.error(error); process.exit(2); } if (installConfirm) { try { - await runCommand(commandToBeRun); + await utils.runCommand(commandToBeRun); } catch (error) { - logger.error(error); + utils.logger.error(error); process.exit(2); } - return packageExists(packageName); + return utils.packageExists(packageName); } process.exit(2); diff --git a/packages/webpack-cli/lib/utils/run-command.js b/packages/webpack-cli/lib/utils/run-command.js index 4ed493f3ea3..58463661c27 100644 --- a/packages/webpack-cli/lib/utils/run-command.js +++ b/packages/webpack-cli/lib/utils/run-command.js @@ -1,11 +1,11 @@ const execa = require('execa'); -const logger = require('./logger'); +const utils = require('./index'); async function runCommand(command, args = []) { try { await execa(command, args, { stdio: 'inherit', shell: true }); } catch (error) { - logger.error(error.message); + utils.logger.error(error.message); process.exit(2); } } diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 0baf614ee13..8fb1ffdebbd 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -2,32 +2,21 @@ const fs = require('fs'); const path = require('path'); const { program } = require('commander'); -const getPkg = require('./utils/package-exists'); -const webpack = getPkg('webpack') ? require('webpack') : undefined; -const interpret = require('interpret'); -const rechoir = require('rechoir'); -const { distance } = require('fastest-levenshtein'); -const { options: coloretteOptions, yellow, cyan, green, bold } = require('colorette'); - -const logger = require('./utils/logger'); -const capitalizeFirstLetter = require('./utils/capitalize-first-letter'); -const CLIPlugin = require('./plugins/CLIPlugin'); -const promptInstallation = require('./utils/prompt-installation'); -const toKebabCase = require('./utils/to-kebab-case'); +const utils = require('./utils'); class WebpackCLI { constructor() { // Global - this.webpack = webpack; - this.logger = logger; - this.utils = { toKebabCase, getPkg, promptInstallation }; + this.webpack = require('webpack'); + this.logger = utils.logger; + this.utils = utils; // Initialize program this.program = program; this.program.name('webpack'); this.program.configureOutput({ - writeErr: logger.error, - outputError: (str, write) => write(`Error: ${capitalizeFirstLetter(str.replace(/^error:/, '').trim())}`), + writeErr: this.logger.error, + outputError: (str, write) => write(`Error: ${this.utils.capitalizeFirstLetter(str.replace(/^error:/, '').trim())}`), }); } @@ -72,7 +61,8 @@ class WebpackCLI { if (commandOptions.dependencies && commandOptions.dependencies.length > 0) { for (const dependency of commandOptions.dependencies) { - const isPkgExist = getPkg(dependency); + const { packageExists } = this.utils; + const isPkgExist = packageExists(dependency); if (isPkgExist) { continue; @@ -81,17 +71,19 @@ class WebpackCLI { continue; } + const { promptInstallation, colors } = this.utils; + try { await promptInstallation(dependency, () => { - logger.error( - `For using '${green(commandOptions.name.split(' ')[0])}' command you need to install: '${green( + this.logger.error( + `For using '${colors.green(commandOptions.name.split(' ')[0])}' command you need to install: '${colors.green( dependency, )}' package`, ); }); } catch (error) { - logger.error("Action Interrupted, use 'webpack-cli help' to see possible commands."); - logger.error(error); + this.logger.error("Action Interrupted, use 'webpack-cli help' to see possible commands."); + this.logger.error(error); process.exit(2); } } @@ -227,6 +219,10 @@ class WebpackCLI { } getBuiltInOptions() { + if (this.builtInOptionsCache) { + return this.builtInOptionsCache; + } + const minimumHelpFlags = [ 'config', 'config-name', @@ -417,7 +413,7 @@ class WebpackCLI { }) : []; - return [] + const options = [] .concat(builtInFlags.filter((builtInFlag) => !coreFlags.find((coreFlag) => builtInFlag.name === coreFlag.name))) .concat(coreFlags) .map((option) => { @@ -425,6 +421,10 @@ class WebpackCLI { return option; }); + + this.builtInOptionsCache = options; + + return options; } async run(args, parseOptions) { @@ -547,7 +547,7 @@ class WebpackCLI { if (isWatchCommandUsed) { if (typeof options.watch !== 'undefined') { - logger.warn( + this.logger.warn( `No need to use the ${ options.watch ? "'--watch, -w'" : "'--no-watch'" } option together with the 'watch' command, it does not make sense`, @@ -570,7 +570,7 @@ class WebpackCLI { const builtInExternalCommandInfo = externalBuiltInCommandsInfo.find( (externalBuiltInCommandInfo) => getCommandName(externalBuiltInCommandInfo.name) === commandName || - (typeof Array.isArray(externalBuiltInCommandInfo.alias) + (Array.isArray(externalBuiltInCommandInfo.alias) ? externalBuiltInCommandInfo.alias.includes(commandName) : externalBuiltInCommandInfo.alias === commandName), ); @@ -583,17 +583,19 @@ class WebpackCLI { pkg = commandName; } - if (pkg !== 'webpack-cli' && !getPkg(pkg)) { + if (pkg !== 'webpack-cli' && !this.utils.packageExists(pkg)) { if (!allowToInstall) { return; } + const { promptInstallation, colors } = this.utils; + try { pkg = await promptInstallation(pkg, () => { - logger.error(`For using this command you need to install: '${green(pkg)}' package`); + this.logger.error(`For using this command you need to install: '${colors.green(pkg)}' package`); }); } catch (error) { - logger.error(`Action Interrupted, use '${cyan('webpack-cli help')}' to see possible commands`); + this.logger.error(`Action Interrupted, use '${colors.cyan('webpack-cli help')}' to see possible commands`); process.exit(2); } } @@ -619,8 +621,8 @@ class WebpackCLI { await command.apply(this); } catch (error) { - logger.error(`Unable to load '${pkg}' command`); - logger.error(error); + this.logger.error(`Unable to load '${pkg}' command`); + this.logger.error(error); process.exit(2); } } @@ -657,14 +659,14 @@ class WebpackCLI { const command = findCommandByName(operand); if (!command) { - logger.error(`Can't find and load command '${operand}'`); - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error(`Can't find and load command '${operand}'`); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); } command.options.forEach((option) => { - if (distance(name, option.long.slice(2)) < 3) { - logger.error(`Did you mean '--${option.name()}'?`); + if (this.utils.levenshtein.distance(name, option.long.slice(2)) < 3) { + this.logger.error(`Did you mean '--${option.name()}'?`); } }); } @@ -677,24 +679,25 @@ class WebpackCLI { // - commander.missingMandatoryOptionValue // - commander.optionMissingArgument - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); }); // Default `--color` and `--no-color` options + const cli = this; this.program.option('--color', 'Enable colors on console.'); this.program.on('option:color', function () { const { color } = this.opts(); - coloretteOptions.changed = true; - coloretteOptions.enabled = color; + cli.utils.colors.options.changed = true; + cli.utils.colors.options.enabled = color; }); this.program.option('--no-color', 'Disable colors on console.'); this.program.on('option:no-color', function () { const { color } = this.opts(); - coloretteOptions.changed = true; - coloretteOptions.enabled = color; + cli.utils.colors.options.changed = true; + cli.utils.colors.options.enabled = color; }); // Make `-v, --version` options @@ -714,8 +717,8 @@ class WebpackCLI { return; } - logger.error(`Unknown option '${possibleCommandName}'`); - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error(`Unknown option '${possibleCommandName}'`); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); }); @@ -726,17 +729,17 @@ class WebpackCLI { const foundCommand = findCommandByName(possibleCommandName); if (!foundCommand) { - logger.error(`Unknown command '${possibleCommandName}'`); - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error(`Unknown command '${possibleCommandName}'`); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); } try { const { name, version } = require(`${foundCommand.pkg}/package.json`); - logger.raw(`${name} ${version}`); + this.logger.raw(`${name} ${version}`); } catch (e) { - logger.error(`Error: External package '${foundCommand.pkg}' not found`); + this.logger.error(`Error: External package '${foundCommand.pkg}' not found`); process.exit(2); } } @@ -744,14 +747,14 @@ class WebpackCLI { const pkgJSON = require('../package.json'); - logger.raw(`webpack ${this.webpack.version}`); - logger.raw(`webpack-cli ${pkgJSON.version}`); + this.logger.raw(`webpack ${this.webpack.version}`); + this.logger.raw(`webpack-cli ${pkgJSON.version}`); - if (getPkg('webpack-dev-server')) { + if (this.utils.packageExists('webpack-dev-server')) { // eslint-disable-next-line const { version } = require('webpack-dev-server/package.json'); - logger.raw(`webpack-dev-server ${version}`); + this.logger.raw(`webpack-dev-server ${version}`); } process.exit(0); @@ -762,10 +765,12 @@ class WebpackCLI { ); const outputHelp = async (options, isVerbose, isHelpCommandSyntax, program) => { + const { bold } = this.utils.colors; + const outputIncorrectUsageOfHelp = () => { - logger.error('Incorrect use of help'); - logger.error("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error('Incorrect use of help'); + this.logger.error("Please use: 'webpack help [command] [option]' | 'webpack [command] --help'"); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); }; @@ -786,7 +791,7 @@ class WebpackCLI { } if (isGlobalHelp) { - return `${parentCmdNames}${command.usage()}\n${bold( + return `${parentCmdNames}${command.usage()}\n${this.utils.colors.bold( 'Alternative usage to run commands:', )} ${parentCmdNames}[command] [options]`; } @@ -921,7 +926,7 @@ class WebpackCLI { const buildCommand = findCommandByName(getCommandName(buildCommandOptions.name)); - logger.raw(buildCommand.helpInformation()); + this.logger.raw(buildCommand.helpInformation()); } else { const name = options[0]; @@ -930,12 +935,12 @@ class WebpackCLI { const command = findCommandByName(name); if (!command) { - logger.error(`Can't find and load command '${name}'`); - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error(`Can't find and load command '${name}'`); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); } - logger.raw(command.helpInformation()); + this.logger.raw(command.helpInformation()); } } else if (isHelpCommandSyntax) { let isCommandSpecified = false; @@ -961,16 +966,16 @@ class WebpackCLI { const command = isGlobalOption(optionName) ? program : findCommandByName(commandName); if (!command) { - logger.error(`Can't find and load command '${commandName}'`); - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error(`Can't find and load command '${commandName}'`); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); } const option = command.options.find((option) => option.short === optionName || option.long === optionName); if (!option) { - logger.error(`Unknown option '${optionName}'`); - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error(`Unknown option '${optionName}'`); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); } @@ -978,12 +983,12 @@ class WebpackCLI { option.flags.replace(/^.+[[<]/, '').replace(/(\.\.\.)?[\]>].*$/, '') + (option.variadic === true ? '...' : ''); const value = option.required ? '<' + nameOutput + '>' : option.optional ? '[' + nameOutput + ']' : ''; - logger.raw( + this.logger.raw( `${bold('Usage')}: webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.long}${value ? ` ${value}` : ''}`, ); if (option.short) { - logger.raw( + this.logger.raw( `${bold('Short:')} webpack${isCommandSpecified ? ` ${commandName}` : ''} ${option.short}${ value ? ` ${value}` : '' }`, @@ -991,14 +996,14 @@ class WebpackCLI { } if (option.description) { - logger.raw(`${bold('Description:')} ${option.description}`); + this.logger.raw(`${bold('Description:')} ${option.description}`); } if (!option.negate && options.defaultValue) { - logger.raw(`${bold('Default value:')} ${JSON.stringify(option.defaultValue)}`); + this.logger.raw(`${bold('Default value:')} ${JSON.stringify(option.defaultValue)}`); } - logger.raw(''); + this.logger.raw(''); // TODO implement this after refactor cli arguments // logger.raw('Possible values: foo | bar'); @@ -1007,10 +1012,10 @@ class WebpackCLI { outputIncorrectUsageOfHelp(); } - logger.raw("To see list of all supported commands and options run 'webpack --help=verbose'.\n"); - logger.raw(`${bold('Webpack documentation:')} https://webpack.js.org/.`); - logger.raw(`${bold('CLI documentation:')} https://webpack.js.org/api/cli/.`); - logger.raw(`${bold('Made with ♥ by the webpack team')}.`); + this.logger.raw("To see list of all supported commands and options run 'webpack --help=verbose'.\n"); + this.logger.raw(`${bold('Webpack documentation:')} https://webpack.js.org/.`); + this.logger.raw(`${bold('CLI documentation:')} https://webpack.js.org/api/cli/.`); + this.logger.raw(`${bold('Made with ♥ by the webpack team')}.`); process.exit(0); }; this.program.helpOption(false); @@ -1026,7 +1031,7 @@ class WebpackCLI { if (!isInternalActionCalled) { isInternalActionCalled = true; } else { - logger.error('No commands found to run'); + this.logger.error('No commands found to run'); process.exit(2); } @@ -1044,7 +1049,7 @@ class WebpackCLI { if (options.help) { if (typeof options.help === 'string') { if (options.help !== 'verbose') { - logger.error("Unknown value for '--help' option, please use '--help=verbose'"); + this.logger.error("Unknown value for '--help' option, please use '--help=verbose'"); process.exit(2); } @@ -1081,13 +1086,7 @@ class WebpackCLI { if (isKnownCommand(commandToRun)) { await loadCommandByName(commandToRun, true); } else { - let isEntrySyntax = true; - - try { - await fs.promises.access(operand, fs.constants.F_OK); - } catch (error) { - isEntrySyntax = false; - } + let isEntrySyntax = fs.existsSync(operand); if (isEntrySyntax) { commandToRun = defaultCommandToRun; @@ -1095,19 +1094,21 @@ class WebpackCLI { await loadCommandByName(commandToRun); } else { - logger.error(`Unknown command or entry '${operand}'`); + this.logger.error(`Unknown command or entry '${operand}'`); - const found = knownCommands.find((commandOptions) => distance(operand, getCommandName(commandOptions.name)) < 3); + const found = knownCommands.find( + (commandOptions) => this.utils.levenshtein.distance(operand, getCommandName(commandOptions.name)) < 3, + ); if (found) { - logger.error( + this.logger.error( `Did you mean '${getCommandName(found.name)}' (alias '${ Array.isArray(found.alias) ? found.alias.join(', ') : found.alias }')?`, ); } - logger.error("Run 'webpack --help' to see available commands and options"); + this.logger.error("Run 'webpack --help' to see available commands and options"); process.exit(2); } } @@ -1120,25 +1121,28 @@ class WebpackCLI { async resolveConfig(options) { const loadConfig = async (configPath) => { + const { interpret } = this.utils; const ext = path.extname(configPath); const interpreted = Object.keys(interpret.jsVariants).find((variant) => variant === ext); if (interpreted) { + const { rechoir } = this.utils; + try { rechoir.prepare(interpret.extensions, configPath); } catch (error) { if (error.failures) { - logger.error(`Unable load '${configPath}'`); - logger.error(error.message); + this.logger.error(`Unable load '${configPath}'`); + this.logger.error(error.message); error.failures.forEach((failure) => { - logger.error(failure.error.message); + this.logger.error(failure.error.message); }); - logger.error('Please install one of them'); + this.logger.error('Please install one of them'); process.exit(2); } - logger.error(error); + this.logger.error(error); process.exit(2); } } @@ -1171,12 +1175,12 @@ class WebpackCLI { throw error; } } catch (error) { - logger.error(`Failed to load '${configPath}' config`); + this.logger.error(`Failed to load '${configPath}' config`); if (this.isValidationError(error)) { - logger.error(error.message); + this.logger.error(error.message); } else { - logger.error(error); + this.logger.error(error); } process.exit(2); @@ -1214,7 +1218,7 @@ class WebpackCLI { const isObject = (value) => typeof value === 'object' && value !== null; if (!isObject(loadedConfig.options) && !Array.isArray(loadedConfig.options)) { - logger.error(`Invalid configuration in '${loadedConfig.path}'`); + this.logger.error(`Invalid configuration in '${loadedConfig.path}'`); process.exit(2); } @@ -1244,6 +1248,8 @@ class WebpackCLI { config.options = config.options.length === 1 ? config.options[0] : config.options; } else { + const { interpret } = this.utils; + // Order defines the priority, in increasing order const defaultConfigFiles = ['webpack.config', '.webpack/webpack.config', '.webpack/webpackfile'] .map((filename) => @@ -1259,9 +1265,7 @@ class WebpackCLI { let foundDefaultConfigFile; for (const defaultConfigFile of defaultConfigFiles) { - try { - await fs.promises.access(defaultConfigFile.path, fs.constants.F_OK); - } catch (error) { + if (!fs.existsSync(defaultConfigFile.path)) { continue; } @@ -1305,7 +1309,7 @@ class WebpackCLI { }); if (notfoundConfigNames.length > 0) { - logger.error( + this.logger.error( notfoundConfigNames.map((configName) => `Configuration with the name "${configName}" was not found.`).join(' '), ); process.exit(2); @@ -1319,7 +1323,7 @@ class WebpackCLI { // either by passing multiple configs by flags or passing a // single config exporting an array if (!Array.isArray(config.options) || config.options.length <= 1) { - logger.error('At least two configurations are required for merge.'); + this.logger.error('At least two configurations are required for merge.'); process.exit(2); } @@ -1342,22 +1346,26 @@ class WebpackCLI { // TODO refactor async applyOptions(config, options) { if (options.analyze) { - if (!getPkg('webpack-bundle-analyzer')) { + if (!this.utils.packageExists('webpack-bundle-analyzer')) { + const { promptInstallation, colors } = this.utils; + try { await promptInstallation('webpack-bundle-analyzer', () => { - logger.error(`It looks like ${yellow('webpack-bundle-analyzer')} is not installed.`); + this.logger.error(`It looks like ${colors.yellow('webpack-bundle-analyzer')} is not installed.`); }); } catch (error) { - logger.error(`Action Interrupted, Please try once again or install ${yellow('webpack-bundle-analyzer')} manually.`); + this.logger.error( + `Action Interrupted, Please try once again or install ${colors.yellow('webpack-bundle-analyzer')} manually.`, + ); process.exit(2); } - logger.success(`${yellow('webpack-bundle-analyzer')} was installed successfully.`); + this.logger.success(`${colors.yellow('webpack-bundle-analyzer')} was installed successfully.`); } } if (typeof options.progress === 'string' && options.progress !== 'profile') { - logger.error(`'${options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`); + this.logger.error(`'${options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`); process.exit(2); } @@ -1376,7 +1384,7 @@ class WebpackCLI { return accumulator; } - const kebabName = toKebabCase(name); + const kebabName = this.utils.toKebabCase(name); if (args[kebabName]) { accumulator[kebabName] = options[name]; @@ -1401,14 +1409,14 @@ class WebpackCLI { const problems = problemsByPath[path]; problems.forEach((problem) => { - logger.error( - `${capitalizeFirstLetter(problem.type.replace(/-/g, ' '))}${ + this.logger.error( + `${this.utils.capitalizeFirstLetter(problem.type.replace(/-/g, ' '))}${ problem.value ? ` '${problem.value}'` : '' } for the '--${problem.argument}' option${problem.index ? ` by index '${problem.index}'` : ''}`, ); if (problem.expected) { - logger.error(`Expected: '${problem.expected}'`); + this.logger.error(`Expected: '${problem.expected}'`); } }); } @@ -1550,8 +1558,8 @@ class WebpackCLI { let colors; // From arguments - if (typeof coloretteOptions.changed !== 'undefined') { - colors = Boolean(coloretteOptions.enabled); + if (typeof this.utils.colors.options.changed !== 'undefined') { + colors = Boolean(this.utils.colors.options.enabled); } // From stats else if (typeof configOptions.stats.colors !== 'undefined') { @@ -1559,7 +1567,7 @@ class WebpackCLI { } // Default else { - colors = Boolean(coloretteOptions.enabled); + colors = Boolean(this.utils.colors.options.enabled); } configOptions.stats.colors = colors; @@ -1580,6 +1588,8 @@ class WebpackCLI { configOptions.plugins = []; } + const CLIPlugin = require('./plugins/CLIPlugin'); + configOptions.plugins.unshift( new CLIPlugin({ configPath: config.path, @@ -1630,7 +1640,7 @@ class WebpackCLI { callback ? (error, stats) => { if (error && this.isValidationError(error)) { - logger.error(error.message); + this.logger.error(error.message); process.exit(2); } @@ -1640,9 +1650,9 @@ class WebpackCLI { ); } catch (error) { if (this.isValidationError(error)) { - logger.error(error.message); + this.logger.error(error.message); } else { - logger.error(error); + this.logger.error(error); } process.exit(2); @@ -1661,7 +1671,7 @@ class WebpackCLI { const callback = (error, stats) => { if (error) { - logger.error(error); + this.logger.error(error); process.exit(2); } @@ -1689,7 +1699,7 @@ class WebpackCLI { if (options.json) { const { stringifyStream: createJsonStringifyStream } = require('@discoveryjs/json-ext'); const handleWriteError = (error) => { - logger.error(error); + this.logger.error(error); process.exit(2); }; @@ -1706,7 +1716,9 @@ class WebpackCLI { .on('error', handleWriteError) // Use stderr to logging .on('close', () => - process.stderr.write(`[webpack-cli] ${green(`stats are successfully stored as json to ${options.json}`)}\n`), + process.stderr.write( + `[webpack-cli] ${this.utils.colors.green(`stats are successfully stored as json to ${options.json}`)}\n`, + ), ); } } else { @@ -1714,7 +1726,7 @@ class WebpackCLI { // Avoid extra empty line when `stats: 'none'` if (printedStats) { - logger.raw(printedStats); + this.logger.raw(printedStats); } } }; From ed76f9b0e8db8a146adf40802a422adadd1a6c9b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 29 Jan 2021 18:39:01 +0300 Subject: [PATCH 285/581] chore(deps-dev): bump ts-jest from 26.4.4 to 26.5.0 (#2383) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.4.4 to 26.5.0. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v26.4.4...v26.5.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index a05832ed73a..b807d3bb3f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7302,11 +7302,6 @@ lodash.ismatch@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" integrity sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc= -lodash.memoize@4.x: - version "4.1.2" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" - integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= - lodash.set@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" @@ -7337,7 +7332,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4, lodash@^4.2.1: +lodash@4.x, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4, lodash@^4.2.1: version "4.17.20" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== @@ -10587,9 +10582,9 @@ trim-off-newlines@^1.0.0: integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= ts-jest@^26.4.3: - version "26.4.4" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.4.tgz#61f13fb21ab400853c532270e52cc0ed7e502c49" - integrity sha512-3lFWKbLxJm34QxyVNNCgXX1u4o/RV0myvA2y2Bxm46iGIjKlaY0own9gIckbjZJPn+WaJEnfPPJ20HHGpoq4yg== + version "26.5.0" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.0.tgz#3e3417d91bc40178a6716d7dacc5b0505835aa21" + integrity sha512-Ya4IQgvIFNa2Mgq52KaO8yBw2W8tWp61Ecl66VjF0f5JaV8u50nGoptHVILOPGoI7SDnShmEqnYQEmyHdQ+56g== dependencies: "@types/jest" "26.x" bs-logger "0.x" @@ -10597,7 +10592,7 @@ ts-jest@^26.4.3: fast-json-stable-stringify "2.x" jest-util "^26.1.0" json5 "2.x" - lodash.memoize "4.x" + lodash "4.x" make-error "1.x" mkdirp "1.x" semver "7.x" From dcb452ebb6630056611f084dfe4db07cd32d4625 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 30 Jan 2021 15:48:19 +0300 Subject: [PATCH 286/581] chore(deps-dev): bump webpack from 5.18.0 to 5.19.0 (#2384) Bumps [webpack](https://github.com/webpack/webpack) from 5.18.0 to 5.19.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.18.0...v5.19.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b807d3bb3f8..d99f9a919b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11073,9 +11073,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.18.0: - version "5.18.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.18.0.tgz#bbcf13094aa0da0534d513f27d7ee72d74e499c6" - integrity sha512-RmiP/iy6ROvVe/S+u0TrvL/oOmvP+2+Bs8MWjvBwwY/j82Q51XJyDJ75m0QAGntL1Wx6B//Xc0+4VPP/hlNHmw== + version "5.19.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.19.0.tgz#1a5fee84dd63557e68336b0774ac4a1c81aa2c73" + integrity sha512-egX19vAQ8fZ4cVYtA9Y941eqJtcZAK68mQq87MMv+GTXKZOc3TpKBBxdGX+HXUYlquPxiluNsJ1VHvwwklW7CQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" From 710e343b0a791ba94d4544bba6f5a59c1550a84d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 31 Jan 2021 17:12:16 +0300 Subject: [PATCH 287/581] chore(deps-dev): bump eslint from 7.18.0 to 7.19.0 (#2387) Bumps [eslint](https://github.com/eslint/eslint) from 7.18.0 to 7.19.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.18.0...v7.19.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d99f9a919b7..570916aea85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4408,9 +4408,9 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.18.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.18.0.tgz#7fdcd2f3715a41fe6295a16234bd69aed2c75e67" - integrity sha512-fbgTiE8BfUJZuBeq2Yi7J3RB3WGUQ9PNuNbmgi6jt9Iv8qrkxfy19Ds3OpL1Pm7zg3BtTVhvcUZbIRQ0wmSjAQ== + version "7.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.19.0.tgz#6719621b196b5fad72e43387981314e5d0dc3f41" + integrity sha512-CGlMgJY56JZ9ZSYhJuhow61lMPPjUzWmChFya71Z/jilVos7mR/jPgaEfVGgMBY5DshbKdG8Ezb8FDCHcoMEMg== dependencies: "@babel/code-frame" "^7.0.0" "@eslint/eslintrc" "^0.3.0" From 2c85b9b6a97a6c9c72b4ec74fdaafd67e2ef1627 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 31 Jan 2021 17:12:25 +0300 Subject: [PATCH 288/581] chore(deps): bump yeoman-generator from 4.12.0 to 4.13.0 (#2386) Bumps [yeoman-generator](https://github.com/yeoman/generator) from 4.12.0 to 4.13.0. - [Release notes](https://github.com/yeoman/generator/releases) - [Commits](https://github.com/yeoman/generator/compare/v4.12.0...v4.13.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index 570916aea85..c787ad26d6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9710,7 +9710,7 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -shelljs@^0.8.3: +shelljs@^0.8.4: version "0.8.4" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2" integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ== @@ -11447,9 +11447,9 @@ yeoman-environment@^2.10.0, yeoman-environment@^2.10.3, yeoman-environment@^2.9. yeoman-generator "^4.8.2" yeoman-generator@^4.10.0, yeoman-generator@^4.12.0, yeoman-generator@^4.8.2: - version "4.12.0" - resolved "https://registry.yarnpkg.com/yeoman-generator/-/yeoman-generator-4.12.0.tgz#512e783a38b004c49265e71826a09ff7f1939f4b" - integrity sha512-lozwklVQHwUXMM1o8BgxEB8F5BB7vkHW4pjAo1Zt5sJ7FOlWhd6DJ4ZxJ2OK0w+gNYkY/ocPMkUV7DTz/uqEEg== + version "4.13.0" + resolved "https://registry.yarnpkg.com/yeoman-generator/-/yeoman-generator-4.13.0.tgz#a6caeed8491fceea1f84f53e31795f25888b4672" + integrity sha512-f2/5N5IR3M2Ozm+QocvZQudlQITv2DwI6Mcxfy7R7gTTzaKgvUpgo/pQMJ+WQKm0KN0YMWCFOZpj0xFGxevc1w== dependencies: async "^2.6.2" chalk "^2.4.2" @@ -11473,7 +11473,7 @@ yeoman-generator@^4.10.0, yeoman-generator@^4.12.0, yeoman-generator@^4.8.2: rimraf "^2.6.3" run-async "^2.0.0" semver "^7.2.1" - shelljs "^0.8.3" + shelljs "^0.8.4" text-table "^0.2.0" through2 "^3.0.1" optionalDependencies: From 9d6dbda93da167a1aaad03f599105a4fe7849dc3 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 31 Jan 2021 20:04:13 +0530 Subject: [PATCH 289/581] fix: avoid deprecation message --- packages/serve/src/index.ts | 2 +- packages/webpack-cli/lib/webpack-cli.js | 56 +++++++++---- test/serve/basic/serve-basic.test.js | 28 ++++++- test/serve/basic/watch.config.js | 8 ++ test/watch/basic/basic.test.js | 65 +++++---------- test/watch/watch-variable/src/index.js | 1 + .../watch-variable/watch-variable.test.js | 81 +++++++++++++++++++ test/watch/watch-variable/webpack.config.js | 24 ++++++ 8 files changed, 202 insertions(+), 63 deletions(-) create mode 100644 test/serve/basic/watch.config.js create mode 100644 test/watch/watch-variable/src/index.js create mode 100644 test/watch/watch-variable/watch-variable.test.js create mode 100644 test/watch/watch-variable/webpack.config.js diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 508b5cee234..8b52e1568ec 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -24,7 +24,7 @@ class ServeCommand { process.exit(2); } - const builtInOptions = cli.getBuiltInOptions(); + const builtInOptions = cli.getBuiltInOptions().filter((option) => option.name !== 'watch'); return [...builtInOptions, ...devServerFlags]; }, diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 8fb1ffdebbd..04d28a9135e 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -537,27 +537,17 @@ class WebpackCLI { const isWatchCommandUsed = isCommand(commandName, watchCommandOptions); if (isBuildCommandUsed || isWatchCommandUsed) { + const options = this.getBuiltInOptions(); + await this.makeCommand( isBuildCommandUsed ? buildCommandOptions : watchCommandOptions, - this.getBuiltInOptions(), + isWatchCommandUsed ? options.filter((option) => option.name !== 'watch') : options, async (entries, options) => { if (entries.length > 0) { options.entry = [...entries, ...(options.entry || [])]; } - if (isWatchCommandUsed) { - if (typeof options.watch !== 'undefined') { - this.logger.warn( - `No need to use the ${ - options.watch ? "'--watch, -w'" : "'--no-watch'" - } option together with the 'watch' command, it does not make sense`, - ); - } - - options.watch = true; - } - - await this.buildCommand(options); + await this.buildCommand(options, isWatchCommandUsed); }, ); } else if (isCommand(commandName, helpCommandOptions)) { @@ -1369,6 +1359,31 @@ class WebpackCLI { process.exit(2); } + const outputHints = (configOptions) => { + if ( + configOptions.watch && + options.argv && + options.argv.env && + (options.argv.env['WEBPACK_WATCH'] || options.argv.env['WEBPACK_SERVE']) + ) { + this.logger.warn( + `No need to use the '${ + options.argv.env['WEBPACK_WATCH'] ? 'watch' : 'serve' + }' command together with '{ watch: true }' configuration, it does not make sense.`, + ); + + if (options.argv.env['WEBPACK_SERVE']) { + configOptions.watch = false; + } + } + + return configOptions; + }; + + config.options = Array.isArray(config.options) + ? config.options.map((options) => outputHints(options)) + : outputHints(config.options); + if (this.webpack.cli) { const processArguments = (configOptions) => { const args = this.getBuiltInOptions() @@ -1666,7 +1681,7 @@ class WebpackCLI { return compiler; } - async buildCommand(options) { + async buildCommand(options, isWatchCommand) { let compiler; const callback = (error, stats) => { @@ -1731,7 +1746,16 @@ class WebpackCLI { } }; - options.argv = { ...options, env: { WEBPACK_BUNDLE: true, WEBPACK_BUILD: true, ...options.env } }; + const env = + isWatchCommand || options.watch + ? { WEBPACK_WATCH: true, ...options.env } + : { WEBPACK_BUNDLE: true, WEBPACK_BUILD: true, ...options.env }; + + options.argv = { ...options, env }; + + if (isWatchCommand) { + options.watch = true; + } compiler = await this.createCompiler(options, callback); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index a57308f0a00..d215cea596e 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -296,7 +296,33 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('should log and error on unknown flag', async () => { + it('should work and log warning on the `watch option in a configuration', async () => { + const { stderr, stdout } = await runServe(__dirname, ['--config', './watch.config.js', '--port', port]); + + expect(stderr).toContain( + "No need to use the 'serve' command together with '{ watch: true }' configuration, it does not make sense.", + ); + expect(stdout).toContain('development'); + expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); + }); + + it("should log error on using '--watch' flag with serve", async () => { + const { stdout, stderr } = await runServe(testPath, ['--watch']); + + expect(stderr).toContain("Error: Unknown option '--watch'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it("should log error on using '-w' alias with serve", async () => { + const { stdout, stderr } = await runServe(testPath, ['-w']); + + expect(stderr).toContain("Error: Unknown option '-w'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); + + it('should log an error on unknown flag', async () => { const { exitCode, stdout, stderr } = await runServe(testPath, ['--port', port, '--unknown-flag']); expect(exitCode).toBe(2); diff --git a/test/serve/basic/watch.config.js b/test/serve/basic/watch.config.js new file mode 100644 index 00000000000..7f7eb3153b8 --- /dev/null +++ b/test/serve/basic/watch.config.js @@ -0,0 +1,8 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + +module.exports = { + mode: 'development', + devtool: false, + plugins: [new WebpackCLITestPlugin(['mode'], false, 'hooks.compilation.taps')], + watch: true, +}; diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js index 0d24c6dda3a..771e4f81344 100644 --- a/test/watch/basic/basic.test.js +++ b/test/watch/basic/basic.test.js @@ -5,7 +5,7 @@ const { run, runAndGetWatchProc, isWebpack5 } = require('../../utils/test-utils' const { writeFileSync } = require('fs'); const { resolve } = require('path'); -const wordsInStatsv4 = ['Hash', 'Version', 'Time', 'Built at:', 'main.js']; +const wordsInStatsv4 = ['Hash', 'Built at:', 'main.js']; const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; describe('basic', () => { @@ -118,11 +118,10 @@ describe('basic', () => { }); }); - it('should recompile upon file change using the `command` option and the `--watch` option and log warning', (done) => { - const proc = runAndGetWatchProc(__dirname, ['watch', '--watch', '--mode', 'development'], false, '', true); + it('should log warning about the `watch` option in the configuration and recompile upon file change using the `watch` command', (done) => { + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development', '--config', './watch.config.js'], false, '', true); let modified = false; - let hasWarning = false; proc.stdout.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); @@ -138,7 +137,7 @@ describe('basic', () => { } } - if (!modified && !hasWarning) { + if (!modified) { process.nextTick(() => { writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); }); @@ -154,51 +153,27 @@ describe('basic', () => { proc.stderr.on('data', (chunk) => { const data = stripAnsi(chunk.toString()); - hasWarning = true; - - expect(data).toContain("No need to use the '--watch, -w' option together with the 'watch' command, it does not make sense"); + expect(data).toContain( + "No need to use the 'watch' command together with '{ watch: true }' configuration, it does not make sense.", + ); }); }); - it('should recompile upon file change using the `command` option and the `--no-watch` option and log warning', (done) => { - const proc = runAndGetWatchProc(__dirname, ['watch', '--no-watch', '--mode', 'development'], false, '', true); - - let modified = false; - let hasWarning = false; - - proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); - - if (data.includes('index.js')) { - if (isWebpack5) { - for (const word of wordsInStatsv5) { - expect(data).toContain(word); - } - } else { - for (const word of wordsInStatsv4) { - expect(data).toContain(word); - } - } - - if (!modified && !hasWarning) { - process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); - }); + it('should recompile upon file change using the `command` option and the `--watch` option and log warning', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ['watch', '--watch', '--mode', 'development']); - modified = true; - } else { - proc.kill(); - done(); - } - } - }); - - proc.stderr.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + expect(exitCode).toBe(2); + expect(stderr).toContain("Error: Unknown option '--watch'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); + }); - hasWarning = true; + it('should recompile upon file change using the `command` option and the `--no-watch` option and log warning', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ['watch', '--no-watch', '--mode', 'development']); - expect(data).toContain("No need to use the '--no-watch' option together with the 'watch' command, it does not make sense"); - }); + expect(exitCode).toBe(2); + expect(stderr).toContain("Error: Unknown option '--no-watch'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/watch/watch-variable/src/index.js b/test/watch/watch-variable/src/index.js new file mode 100644 index 00000000000..efc51ca0a97 --- /dev/null +++ b/test/watch/watch-variable/src/index.js @@ -0,0 +1 @@ +console.log('watch flag test'); \ No newline at end of file diff --git a/test/watch/watch-variable/watch-variable.test.js b/test/watch/watch-variable/watch-variable.test.js new file mode 100644 index 00000000000..0f5cc994ed6 --- /dev/null +++ b/test/watch/watch-variable/watch-variable.test.js @@ -0,0 +1,81 @@ +'use strict'; + +const stripAnsi = require('strip-ansi'); +const { runAndGetWatchProc, isWebpack5 } = require('../../utils/test-utils'); +const { writeFileSync } = require('fs'); +const { resolve } = require('path'); + +const wordsInStatsv4 = ['Hash', 'Built at:', 'main.js']; +const wordsInStatsv5 = ['asset', 'index.js', 'compiled successfully']; + +describe('watch variable', () => { + it('should pass `WEBPACK_WATCH` env variable and recompile upon file change using the `watch` command', (done) => { + const proc = runAndGetWatchProc(__dirname, ['watch', '--mode', 'development'], false, '', true); + + let modified = false; + + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + expect(data).not.toContain('FAIL'); + + if (data.includes('index.js')) { + if (isWebpack5) { + for (const word of wordsInStatsv5) { + expect(data).toContain(word); + } + } else { + for (const word of wordsInStatsv4) { + expect(data).toContain(word); + } + } + + if (!modified) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } + } + }); + }); + + it('should pass `WEBPACK_WATCH` env variable and recompile upon file change using the `--watch` option', (done) => { + const proc = runAndGetWatchProc(__dirname, ['--watch', '--mode', 'development'], false, '', true); + + let modified = false; + + proc.stdout.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + expect(data).not.toContain('FAIL'); + + if (data.includes('index.js')) { + if (isWebpack5) { + for (const word of wordsInStatsv5) { + expect(data).toContain(word); + } + } else { + for (const word of wordsInStatsv4) { + expect(data).toContain(word); + } + } + + if (!modified) { + process.nextTick(() => { + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + }); + + modified = true; + } else { + proc.kill(); + done(); + } + } + }); + }); +}); diff --git a/test/watch/watch-variable/webpack.config.js b/test/watch/watch-variable/webpack.config.js new file mode 100644 index 00000000000..a177e2cf731 --- /dev/null +++ b/test/watch/watch-variable/webpack.config.js @@ -0,0 +1,24 @@ +const isInProcess = process.env.WEBPACK_WATCH; + +class CustomTestPlugin { + constructor(isInEnvironment) { + this.isInEnvironment = isInEnvironment; + } + apply(compiler) { + compiler.hooks.done.tap('testPlugin', () => { + if (!isInProcess && this.isInEnvironment) { + console.log('PASS'); + } else { + console.log('FAIL'); + } + }); + } +} + +module.exports = (env) => { + return { + mode: 'development', + devtool: false, + plugins: [new CustomTestPlugin(env.WEBPACK_WATCH)], + }; +}; From 7092a724d07462205fe3612baa2e27b0d744d7fb Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 1 Feb 2021 15:28:49 +0530 Subject: [PATCH 290/581] chore: remove git-cz (#2389) --- .github/CONTRIBUTING.md | 2 -- package.json | 2 -- yarn.lock | 5 ----- 3 files changed, 9 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index c32b815ef98..d7d77e2a22d 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -193,8 +193,6 @@ In case you've got a small change in most of the cases, your pull request would Our commit messages format follows the [angular.js commits format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits). -You can use `yarn commit` script to have an interactive way of making commits that follow our guidelines. - We don't use the scope. The template of a commit would look like this: ### Commit Message Format diff --git a/package.json b/package.json index 504d74f5ff9..a54dc077679 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "build": "tsc --build", "build:ci": "tsc --build", "watch": "tsc --build --watch", - "commit": "git-cz", "lint:prettier": "prettier --list-different . \"!**/*.{js,ts}\" ", "lint:eslint": "eslint --cache --ext .js --ext .ts .", "lint": "yarn lint:eslint && yarn lint:prettier", @@ -77,7 +76,6 @@ "eslint-plugin-prettier": "^3.1.4", "execa": "^5.0.0", "get-port": "^5.1.1", - "git-cz": "^4.7.1", "husky": "^4.3.0", "jest": "^26.6.1", "jest-serializer-ansi": "^1.0.3", diff --git a/yarn.lock b/yarn.lock index c787ad26d6f..2d97813f88f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5209,11 +5209,6 @@ gh-got@^5.0.0: got "^6.2.0" is-plain-obj "^1.1.0" -git-cz@^4.7.1: - version "4.7.6" - resolved "https://registry.yarnpkg.com/git-cz/-/git-cz-4.7.6.tgz#1250c486f01724e801a630b848fd8786f7e67e90" - integrity sha512-WtQEXqetJSi9LKPI77bMdSQWvLGjE93egVbR0zjXd1KFKrFvo/YE/UuGNcMeBDiwzxfQBhjyV7Hn0YUZ8Q0BcQ== - git-raw-commits@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-2.0.0.tgz#d92addf74440c14bcc5c83ecce3fb7f8a79118b5" From 7bd747a4815136d90c812c0fd9ae8c231556fadb Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 1 Feb 2021 16:00:20 +0530 Subject: [PATCH 291/581] chore(init): remove --force flag (#2391) --- INIT.md | 6 -- .../src/utils/modify-config-helper.ts | 3 +- packages/generators/src/utils/scaffold.ts | 6 +- packages/init/README.md | 6 -- packages/init/src/index.ts | 7 +-- test/init/force/init-force.test.js | 60 ------------------- 6 files changed, 3 insertions(+), 85 deletions(-) delete mode 100644 test/init/force/init-force.test.js diff --git a/INIT.md b/INIT.md index fed6af945fd..94769b34572 100644 --- a/INIT.md +++ b/INIT.md @@ -81,12 +81,6 @@ webpack-cli init webpack-cli init --auto ``` -**To force config generation** - -```bash -webpack-cli init --force -``` - **To scaffold in a specified path** ```bash diff --git a/packages/generators/src/utils/modify-config-helper.ts b/packages/generators/src/utils/modify-config-helper.ts index 09f9d23f8b4..8dede3af614 100644 --- a/packages/generators/src/utils/modify-config-helper.ts +++ b/packages/generators/src/utils/modify-config-helper.ts @@ -39,7 +39,6 @@ export function modifyHelperUtil( configFile: string = DEFAULT_WEBPACK_CONFIG_FILENAME, packages?: string[], autoSetDefaults = false, - generateConfig = false, generationPath = '.', ): void { const configPath: string | null = null; @@ -135,7 +134,7 @@ export function modifyHelperUtil( ) as TransformConfig; // scaffold webpack config file from using .yo-rc.json - return runTransform(transformConfig, 'init', generateConfig, generationPath); + return runTransform(transformConfig, 'init', generationPath); } catch (error) { logger.error(error); process.exitCode = 2; diff --git a/packages/generators/src/utils/scaffold.ts b/packages/generators/src/utils/scaffold.ts index f7fed7cc34d..ec38c2278bd 100644 --- a/packages/generators/src/utils/scaffold.ts +++ b/packages/generators/src/utils/scaffold.ts @@ -39,13 +39,9 @@ function mapOptionsToTransform(config: Config): string[] { * and writes the file */ -export function runTransform(transformConfig: TransformConfig, action: string, generateConfig: boolean, generationPath: string): void { +export function runTransform(transformConfig: TransformConfig, action: string, generationPath: string): void { // webpackOptions.name sent to nameTransform if match const webpackConfig = Object.keys(transformConfig).filter((p: string): boolean => { - if (p == 'usingDefaults') { - return generateConfig; - } - return p !== 'configFile' && p !== 'configPath'; }); const initActionNotDefined = action && action !== 'init'; diff --git a/packages/init/README.md b/packages/init/README.md index fc6ea999a16..a1e392533cb 100644 --- a/packages/init/README.md +++ b/packages/init/README.md @@ -28,12 +28,6 @@ npx webpack-cli init npx webpack-cli init --auto ``` -**To force config generation** - -```bash -npx webpack-cli init --force -``` - **To scaffold in a specified path** ```bash diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts index 077e673053c..e75210408ce 100644 --- a/packages/init/src/index.ts +++ b/packages/init/src/index.ts @@ -16,11 +16,6 @@ class InitCommand { type: Boolean, description: 'To generate default config', }, - { - name: 'force', - type: Boolean, - description: 'To force config generation', - }, { name: 'generation-path', type: String, @@ -34,7 +29,7 @@ class InitCommand { return; } - modifyHelperUtil(initGenerator, null, null, options.auto, options.force, options.generationPath); + modifyHelperUtil(initGenerator, null, null, options.auto, options.generationPath); }, ); } diff --git a/test/init/force/init-force.test.js b/test/init/force/init-force.test.js deleted file mode 100644 index bbcf9bdd36a..00000000000 --- a/test/init/force/init-force.test.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict'; - -const { green } = require('colorette'); -const fs = require('fs'); -const { join, resolve } = require('path'); -const rimraf = require('rimraf'); -const { runPromptWithAnswers } = require('../../utils/test-utils'); -const firstPrompt = 'Will your application have multiple bundles?'; - -const ENTER = '\x0D'; -const genPath = join(__dirname, 'test-assets'); - -const successLog = `You can now run ${green('yarn build')} to bundle your application!`; - -describe('init force flag', () => { - beforeAll(() => { - rimraf.sync(genPath); - fs.mkdirSync(genPath); - }); - - it('should scaffold webpack config', async () => { - const { stdout } = await runPromptWithAnswers( - genPath, - ['init', '--force'], - [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER], - ); - - expect(stdout).toBeTruthy(); - expect(stdout).toContain(firstPrompt); - - // Skip test in case installation fails - if (!fs.existsSync(resolve(genPath, './yarn.lock'))) { - return; - } - - // Test regressively files are scaffolded - const files = ['./package.json', './src/index.js', './webpack.config.js']; - - files.forEach((file) => { - expect(fs.existsSync(resolve(genPath, file))).toBeTruthy(); - }); - - const webpackConfig = require(join(genPath, 'webpack.config.js')); - - expect(webpackConfig.modules.rules).toEqual([]); - - // Check package json is correctly configured - const pkgJsonTests = () => { - const pkgJson = require(join(genPath, './package.json')); - expect(pkgJson).toBeTruthy(); - expect(pkgJson['devDependencies']).toBeTruthy(); - expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); - expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); - }; - expect(pkgJsonTests).not.toThrow(); - - // Check we are not logging twice - expect(stdout.split(successLog).length - 1).toBe(1); - }); -}); From d004ded913b5048f88516047cdb941e6496c4982 Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 1 Feb 2021 22:03:09 +0530 Subject: [PATCH 292/581] docs: remove references to non-existent packages (#2395) --- README.md | 1 - packages/README.md | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bdf33ce0f0f..f0eed545f74 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,6 @@ Thus, webpack CLI provides different commands for many common tasks. The project also has several utility packages which are used by other commands -- [`utils`](./packages/utils/README.md) - Several utilities used across webpack-cli. - [`generators`](./packages/generators/README.md) - Contains all webpack-cli related yeoman generators. ## Getting started diff --git a/packages/README.md b/packages/README.md index 2791329cf10..ea522074275 100644 --- a/packages/README.md +++ b/packages/README.md @@ -13,12 +13,12 @@ This folder is the collection of those packages. ## Packages -1. [generators](https://github.com/webpack/webpack-cli/tree/master/packages/generators) -2. [info](https://github.com/webpack/webpack-cli/tree/master/packages/info) -3. [init](https://github.com/webpack/webpack-cli/tree/master/packages/init) -4. [migrate](https://www.npmjs.com/package/@webpack-cli/migrate) -5. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) -6. [utils](https://github.com/webpack/webpack-cli/tree/master/packages/utils) +1. [configtest](https://github.com/webpack/webpack-cli/tree/master/packages/configtest) +2. [generators](https://github.com/webpack/webpack-cli/tree/master/packages/generators) +3. [info](https://github.com/webpack/webpack-cli/tree/master/packages/info) +4. [init](https://github.com/webpack/webpack-cli/tree/master/packages/init) +5. [migrate](https://www.npmjs.com/package/@webpack-cli/migrate) +6. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) 7. [webpack-cli](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli) ## Generic Installation From aebdbbc1f6e2761e7821cb3660bea686cce7b587 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Mon, 1 Feb 2021 22:10:23 +0300 Subject: [PATCH 293/581] feat: support ES module configuration format (#2381) --- package.json | 4 ++- packages/webpack-cli/bin/cli.js | 9 +++-- packages/webpack-cli/lib/bootstrap.js | 4 ++- .../lib/utils/dynamic-import-loader.js | 13 +++++++ packages/webpack-cli/lib/utils/index.js | 4 +++ packages/webpack-cli/lib/webpack-cli.js | 35 +++++++++++------- test/config-format/coffee/coffee.test.js | 1 - test/config-format/coffee/package.json | 5 --- .../commonjs-default/commonjs-default.test.js | 11 ++++++ test/config-format/commonjs-default/main.js | 1 + .../commonjs-default/webpack.config.cjs | 12 +++++++ test/config-format/failure/failure.test.js | 16 ++++----- ...pack.config.coffee => webpack.config.iced} | 0 test/config-format/mjs/mjs.test.js | 13 +++---- test/config-format/typescript/package.json | 7 ---- .../typescript/typescript.test.js | 22 +++++------- .../typescript/webpack.config.ts | 2 +- .../custom-name/config.webpack.mjs | 10 ++++++ .../custom-name/custom-name.test.js | 19 ++++++++-- .../mjs-config/default-mjs-config.test.js | 11 +++--- test/config/error-mjs/config-error.test.js | 21 +++++++---- test/entry/scss/package.json | 10 +++--- test/watch/basic/basic.test.js | 8 ++--- test/watch/basic/src/index.js | 2 +- yarn.lock | 36 +++++++++++++++++-- 25 files changed, 191 insertions(+), 85 deletions(-) create mode 100644 packages/webpack-cli/lib/utils/dynamic-import-loader.js delete mode 100644 test/config-format/coffee/package.json create mode 100644 test/config-format/commonjs-default/commonjs-default.test.js create mode 100644 test/config-format/commonjs-default/main.js create mode 100644 test/config-format/commonjs-default/webpack.config.cjs rename test/config-format/failure/{webpack.config.coffee => webpack.config.iced} (100%) delete mode 100644 test/config-format/typescript/package.json create mode 100644 test/config-lookup/custom-name/config.webpack.mjs diff --git a/package.json b/package.json index a54dc077679..84f62d67bd3 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "pretest": "yarn build && yarn lint && yarn prepsuite", "test": "jest --reporters=default", "test:smoketests": "nyc node smoketests", - "test:coverage": "nyc jest --forceExit", + "test:coverage": "nyc --require ts-node/register jest --forceExit", "test:cli": "jest test --reporters=default --forceExit", "test:packages": "jest packages/ --reporters=default --forceExit", "test:ci": "yarn test:cli && yarn test:packages", @@ -64,6 +64,7 @@ "@typescript-eslint/eslint-plugin": "^2.34.0", "@typescript-eslint/parser": "^2.34.0", "@webpack-cli/migrate": "^1.1.2", + "coffeescript": "^2.5.1", "colorette": "^1.2.1", "commitlint": "^11.0.0", "commitlint-config-cz": "^0.13.2", @@ -88,6 +89,7 @@ "rimraf": "^3.0.2", "strip-ansi": "^6.0.0", "ts-jest": "^26.4.3", + "ts-node": "^9.1.1", "typescript": "^4.1.3", "webpack": "^5.18.0", "webpack-bundle-analyzer": "^4.3.0", diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index c78e0935e9f..db74156aa8b 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -1,6 +1,11 @@ #!/usr/bin/env node 'use strict'; + +const Module = require('module'); + +const originalModuleCompile = Module.prototype._compile; + require('v8-compile-cache'); const importLocal = require('import-local'); @@ -15,7 +20,7 @@ if (importLocal(__filename)) { process.title = 'webpack'; if (utils.packageExists('webpack')) { - runCLI(process.argv); + runCLI(process.argv, originalModuleCompile); } else { const { promptInstallation, logger, colors } = utils; @@ -25,7 +30,7 @@ if (utils.packageExists('webpack')) { .then(() => { logger.success(`${colors.bold('webpack')} was installed successfully.`); - runCLI(process.argv); + runCLI(process.argv, originalModuleCompile); }) .catch(() => { logger.error(`Action Interrupted, Please try once again or install ${colors.bold('webpack')} manually.`); diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index c01ca2b7ce7..0a83a81c9e2 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -1,11 +1,13 @@ const WebpackCLI = require('./webpack-cli'); const utils = require('./utils'); -const runCLI = async (args) => { +const runCLI = async (args, originalModuleCompile) => { try { // Create a new instance of the CLI object const cli = new WebpackCLI(); + cli._originalModuleCompile = originalModuleCompile; + await cli.run(args); } catch (error) { utils.logger.error(error); diff --git a/packages/webpack-cli/lib/utils/dynamic-import-loader.js b/packages/webpack-cli/lib/utils/dynamic-import-loader.js new file mode 100644 index 00000000000..a9dbedc197b --- /dev/null +++ b/packages/webpack-cli/lib/utils/dynamic-import-loader.js @@ -0,0 +1,13 @@ +function dynamicImportLoader() { + let importESM; + + try { + importESM = new Function('id', 'return import(id);'); + } catch (e) { + importESM = null; + } + + return importESM; +} + +module.exports = dynamicImportLoader; diff --git a/packages/webpack-cli/lib/utils/index.js b/packages/webpack-cli/lib/utils/index.js index 223e9c0cf3f..045c98f2aab 100644 --- a/packages/webpack-cli/lib/utils/index.js +++ b/packages/webpack-cli/lib/utils/index.js @@ -19,6 +19,10 @@ module.exports = { return require('./capitalize-first-letter'); }, + get dynamicImportLoader() { + return require('./dynamic-import-loader'); + }, + get getPackageManager() { return require('./get-package-manager'); }, diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 04d28a9135e..79f7070534c 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1,5 +1,7 @@ const fs = require('fs'); const path = require('path'); +const { pathToFileURL } = require('url'); +const Module = require('module'); const { program } = require('commander'); const utils = require('./utils'); @@ -1137,26 +1139,35 @@ class WebpackCLI { } } - const { pathToFileURL } = require('url'); - - let importESM; - - try { - importESM = new Function('id', 'return import(id);'); - } catch (e) { - importESM = null; - } - let options; try { try { options = require(configPath); } catch (error) { - if (pathToFileURL && importESM && error.code === 'ERR_REQUIRE_ESM') { + let previousModuleCompile; + + // TODO Workaround https://github.com/zertosh/v8-compile-cache/issues/30 + if (this._originalModuleCompile) { + previousModuleCompile = Module.prototype._compile; + + Module.prototype._compile = this._originalModuleCompile; + } + + const dynamicImportLoader = this.utils.dynamicImportLoader(); + + if (this._originalModuleCompile) { + Module.prototype._compile = previousModuleCompile; + } + + if ( + (error.code === 'ERR_REQUIRE_ESM' || process.env.WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG) && + pathToFileURL && + dynamicImportLoader + ) { const urlForConfig = pathToFileURL(configPath); - options = await importESM(urlForConfig); + options = await dynamicImportLoader(urlForConfig); options = options.default; return { options, path: configPath }; diff --git a/test/config-format/coffee/coffee.test.js b/test/config-format/coffee/coffee.test.js index 84f6ada8f75..1a31dbd4849 100644 --- a/test/config-format/coffee/coffee.test.js +++ b/test/config-format/coffee/coffee.test.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line node/no-unpublished-require const { run } = require('../../utils/test-utils'); describe('webpack cli', () => { diff --git a/test/config-format/coffee/package.json b/test/config-format/coffee/package.json deleted file mode 100644 index 79463144cb1..00000000000 --- a/test/config-format/coffee/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "coffeescript": "^2.5.1" - } -} diff --git a/test/config-format/commonjs-default/commonjs-default.test.js b/test/config-format/commonjs-default/commonjs-default.test.js new file mode 100644 index 00000000000..b31d62a3655 --- /dev/null +++ b/test/config-format/commonjs-default/commonjs-default.test.js @@ -0,0 +1,11 @@ +const { run } = require('../../utils/test-utils'); + +describe('webpack cli', () => { + it('should support CommonJS file', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.cjs'], false); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + }); +}); diff --git a/test/config-format/commonjs-default/main.js b/test/config-format/commonjs-default/main.js new file mode 100644 index 00000000000..8ed93e41fb2 --- /dev/null +++ b/test/config-format/commonjs-default/main.js @@ -0,0 +1 @@ +console.log('Hoshiumi'); diff --git a/test/config-format/commonjs-default/webpack.config.cjs b/test/config-format/commonjs-default/webpack.config.cjs new file mode 100644 index 00000000000..415d965a247 --- /dev/null +++ b/test/config-format/commonjs-default/webpack.config.cjs @@ -0,0 +1,12 @@ +const path = require('path'); + +const config = { + mode: 'production', + entry: './main.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'foo.bundle.js', + }, +}; + +module.exports.default = config; diff --git a/test/config-format/failure/failure.test.js b/test/config-format/failure/failure.test.js index 125c94e31bf..0befcb891ca 100644 --- a/test/config-format/failure/failure.test.js +++ b/test/config-format/failure/failure.test.js @@ -2,17 +2,15 @@ const path = require('path'); const { run } = require('../../utils/test-utils'); -describe('webpack cli', () => { - it('should support mjs config format', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee']); +describe('failure', () => { + it('should log error on not installed registers', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.iced']); expect(exitCode).toBe(2); - expect(stderr).toContain(`Unable load '${path.resolve(__dirname, './webpack.config.coffee')}'`); - expect(stderr).toContain('Unable to use specified module loaders for ".coffee".'); - expect(stderr).toContain("Cannot find module 'coffeescript/register'"); - expect(stderr).toContain("Cannot find module 'coffee-script/register'"); - expect(stderr).toContain("Cannot find module 'coffeescript'"); - expect(stderr).toContain("Cannot find module 'coffee-script'"); + expect(stderr).toContain(`Unable load '${path.resolve(__dirname, './webpack.config.iced')}'`); + expect(stderr).toContain('Unable to use specified module loaders for ".iced".'); + expect(stderr).toContain("Cannot find module 'iced-coffee-script/register'"); + expect(stderr).toContain("Cannot find module 'iced-coffee-script'"); expect(stderr).toContain('Please install one of them'); expect(stdout).toBeFalsy(); }); diff --git a/test/config-format/failure/webpack.config.coffee b/test/config-format/failure/webpack.config.iced similarity index 100% rename from test/config-format/failure/webpack.config.coffee rename to test/config-format/failure/webpack.config.iced diff --git a/test/config-format/mjs/mjs.test.js b/test/config-format/mjs/mjs.test.js index e8ada298f2a..97853c18bfd 100644 --- a/test/config-format/mjs/mjs.test.js +++ b/test/config-format/mjs/mjs.test.js @@ -2,16 +2,17 @@ const { run } = require('../../utils/test-utils'); describe('webpack cli', () => { it('should support mjs config format', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.mjs'], [], { DISABLE_V8_COMPILE_CACHE: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.mjs'], { + env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true }, + }); - if (exitCode === 0) { + if (/Error: Not supported/.test(stderr)) { + expect(exitCode).toBe(2); + expect(stdout).toBeFalsy(); + } else { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - } else { - expect(exitCode).toBe(2); - expect(/Cannot use import statement outside a module/.test(stderr) || /Unexpected token/.test(stderr)).toBe(true); - expect(stdout).toBeFalsy(); } }); }); diff --git a/test/config-format/typescript/package.json b/test/config-format/typescript/package.json deleted file mode 100644 index 43237a25bed..00000000000 --- a/test/config-format/typescript/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "dependencies": { - "typescript": "^3.8.2", - "ts-node": "^8.6.2", - "tsconfig-paths": "^3.9.0" - } -} diff --git a/test/config-format/typescript/typescript.test.js b/test/config-format/typescript/typescript.test.js index 21fadb957e7..b511e69843e 100644 --- a/test/config-format/typescript/typescript.test.js +++ b/test/config-format/typescript/typescript.test.js @@ -1,20 +1,14 @@ -/* eslint-disable node/no-unpublished-require */ -const { run, runInstall } = require('../../utils/test-utils'); +const { run } = require('../../utils/test-utils'); const { existsSync } = require('fs'); const { resolve } = require('path'); describe('webpack cli', () => { - it.skip( - 'should support typescript file', - async () => { - await runInstall(__dirname); - const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); + it('should support typescript file', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); - expect(exitCode).toBe(0); - expect(existsSync(resolve(__dirname, 'bin/foo.bundle.js'))).toBeTruthy(); - }, - 1000 * 60 * 5, - ); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + expect(exitCode).toBe(0); + expect(existsSync(resolve(__dirname, 'dist/foo.bundle.js'))).toBeTruthy(); + }); }); diff --git a/test/config-format/typescript/webpack.config.ts b/test/config-format/typescript/webpack.config.ts index 4a17fa148c6..bbc70963b3b 100644 --- a/test/config-format/typescript/webpack.config.ts +++ b/test/config-format/typescript/webpack.config.ts @@ -11,4 +11,4 @@ const config = { }, }; -export default config; +export = config; diff --git a/test/config-lookup/custom-name/config.webpack.mjs b/test/config-lookup/custom-name/config.webpack.mjs new file mode 100644 index 00000000000..272b905bc1c --- /dev/null +++ b/test/config-lookup/custom-name/config.webpack.mjs @@ -0,0 +1,10 @@ +import { fileURLToPath } from 'url'; +import path from 'path'; + +export default { + entry: './a.js', + output: { + path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), 'dist'), + filename: 'a.bundle.js', + }, +}; diff --git a/test/config-lookup/custom-name/custom-name.test.js b/test/config-lookup/custom-name/custom-name.test.js index aa9bcd1c439..1f088a363e4 100644 --- a/test/config-lookup/custom-name/custom-name.test.js +++ b/test/config-lookup/custom-name/custom-name.test.js @@ -4,11 +4,26 @@ const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('custom config file', () => { - it('should work', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'config.webpack.js')], false); + it('should work with cjs format', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'config.webpack.js')]); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); + + it('should work with esm format', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'config.webpack.mjs')], { + env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true }, + }); + + if (/Error: Not supported/.test(stderr)) { + expect(exitCode).toBe(2); + expect(stdout).toBeFalsy(); + } else { + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); + } + }); }); diff --git a/test/config/defaults/mjs-config/default-mjs-config.test.js b/test/config/defaults/mjs-config/default-mjs-config.test.js index b2fe3551bdc..f5b443c9613 100644 --- a/test/config/defaults/mjs-config/default-mjs-config.test.js +++ b/test/config/defaults/mjs-config/default-mjs-config.test.js @@ -4,9 +4,12 @@ const { run, isWebpack5 } = require('../../../utils/test-utils'); describe('Default Config:', () => { it('Should be able to pick mjs config by default', () => { - const { exitCode, stderr, stdout } = run(__dirname, [], [], { DISABLE_V8_COMPILE_CACHE: true }); + const { exitCode, stderr, stdout } = run(__dirname, [], { env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true } }); - if (exitCode === 0) { + if (/Error: Not supported/.test(stderr)) { + expect(exitCode).toEqual(2); + expect(stdout).toBeFalsy(); + } else { expect(exitCode).toEqual(0); expect(stderr).toBeFalsy(); // default entry should be used @@ -23,10 +26,6 @@ describe('Default Config:', () => { // check that the output file exists expect(fs.existsSync(path.join(__dirname, '/dist/test-output.js'))).toBeTruthy(); - } else { - expect(exitCode).toEqual(2); - expect(stderr).toContain('Unexpected token'); - expect(stdout).toBeFalsy(); } }); }); diff --git a/test/config/error-mjs/config-error.test.js b/test/config/error-mjs/config-error.test.js index 4abbe2e5b48..eb90cbf1e76 100644 --- a/test/config/error-mjs/config-error.test.js +++ b/test/config/error-mjs/config-error.test.js @@ -4,22 +4,31 @@ const { run } = require('../../utils/test-utils'); describe('config error', () => { it('should throw error with invalid configuration', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.mjs')], [], { - DISABLE_V8_COMPILE_CACHE: true, + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.mjs')], { + env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true }, }); expect(exitCode).toBe(2); - expect(/Invalid configuration object/.test(stderr) || /Unexpected token/.test(stderr)).toBe(true); + + if (!/Error: Not supported/.test(stderr)) { + expect(stderr).toContain('Invalid configuration object'); + expect(stderr).toContain(`"development" | "production" | "none"`); + } + expect(stdout).toBeFalsy(); }); it('should throw syntax error and exit with non-zero exit code', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.mjs')], [], { - DISABLE_V8_COMPILE_CACHE: true, + const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.mjs')], { + env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true }, }); expect(exitCode).toBe(2); - expect(stderr).toContain('SyntaxError: Unexpected token'); + + if (!/Error: Not supported/.test(stderr)) { + expect(stderr).toContain('SyntaxError: Unexpected token'); + } + expect(stdout).toBeFalsy(); }); }); diff --git a/test/entry/scss/package.json b/test/entry/scss/package.json index 2ddfa5b1c12..11b90db6ca3 100644 --- a/test/entry/scss/package.json +++ b/test/entry/scss/package.json @@ -1,9 +1,9 @@ { "dependencies": { - "css-loader": "^3.4.2", - "style-loader": "^1.1.3", - "sass-loader": "^8.0.2", - "mini-css-extract-plugin": "^0.9.0", - "node-sass": "^4.13.1" + "css-loader": "^5.0.1", + "style-loader": "^2.0.0", + "sass-loader": "^10.1.1", + "mini-css-extract-plugin": "^1.3.5", + "node-sass": "^5.0.0" } } diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js index 771e4f81344..29013daeff3 100644 --- a/test/watch/basic/basic.test.js +++ b/test/watch/basic/basic.test.js @@ -38,7 +38,7 @@ describe('basic', () => { if (!modified) { process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');\n`); }); modified = true; @@ -71,7 +71,7 @@ describe('basic', () => { if (!modified) { process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');\n`); }); modified = true; @@ -106,7 +106,7 @@ describe('basic', () => { if (!modified) { process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/entry.js'), `console.log('watch flag test');`); + writeFileSync(resolve(__dirname, './src/entry.js'), `console.log('watch flag test');\n`); }); modified = true; @@ -139,7 +139,7 @@ describe('basic', () => { if (!modified) { process.nextTick(() => { - writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); + writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');\n`); }); modified = true; diff --git a/test/watch/basic/src/index.js b/test/watch/basic/src/index.js index efc51ca0a97..1d8734ee1c8 100644 --- a/test/watch/basic/src/index.js +++ b/test/watch/basic/src/index.js @@ -1 +1 @@ -console.log('watch flag test'); \ No newline at end of file +console.log('watch flag test'); diff --git a/yarn.lock b/yarn.lock index 2d97813f88f..7cab2c49a97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2495,6 +2495,11 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -3307,6 +3312,11 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= +coffeescript@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-2.5.1.tgz#b2442a1f2c806139669534a54adc35010559d16a" + integrity sha512-J2jRPX0eeFh5VKyVnoLrfVFgLZtnnmp96WQSLAS8OrLm2wtQLcnikYKe1gViJKDH7vucjuhHvBKKBP3rKcD1tQ== + collect-v8-coverage@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" @@ -3657,6 +3667,11 @@ create-error-class@^3.0.0: dependencies: capture-stack-trace "^1.0.0" +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + cross-spawn@^6.0.0, cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -7436,7 +7451,7 @@ make-dir@^3.0.0, make-dir@^3.0.2: dependencies: semver "^6.0.0" -make-error@1.x: +make-error@1.x, make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== @@ -9889,7 +9904,7 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.16, source-map-support@^0.5.6, source-map-support@~0.5.19: +source-map-support@^0.5.16, source-map-support@^0.5.17, source-map-support@^0.5.6, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -10593,6 +10608,18 @@ ts-jest@^26.4.3: semver "7.x" yargs-parser "20.x" +ts-node@^9.1.1: + version "9.1.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d" + integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg== + dependencies: + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -11490,6 +11517,11 @@ yeoman-test@^2.7.0: yeoman-environment "^2.10.0" yeoman-generator "^4.10.0" +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" From 9967de91c34cf36783ba7d622be06bc4ae4661f6 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 1 Feb 2021 22:10:57 +0300 Subject: [PATCH 294/581] chore(deps): bump envinfo from 7.7.3 to 7.7.4 (#2396) Bumps [envinfo](https://github.com/tabrindle/envinfo) from 7.7.3 to 7.7.4. - [Release notes](https://github.com/tabrindle/envinfo/releases) - [Commits](https://github.com/tabrindle/envinfo/compare/7.7.3...7.7.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7cab2c49a97..1eee835e480 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4232,9 +4232,9 @@ env-paths@^2.2.0: integrity sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA== envinfo@^7.3.1, envinfo@^7.7.3: - version "7.7.3" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.3.tgz#4b2d8622e3e7366afb8091b23ed95569ea0208cc" - integrity sha512-46+j5QxbPWza0PB1i15nZx0xQ4I/EfQxg9J8Had3b408SV63nEtor2e+oiY63amTo9KTuh2a3XLObNwduxYwwA== + version "7.7.4" + resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.4.tgz#c6311cdd38a0e86808c1c9343f667e4267c4a320" + integrity sha512-TQXTYFVVwwluWSFis6K2XKxgrD22jEv0FTuLCQI+OjH7rn93+iY0fSSFM5lrSxFY+H1+B0/cvvlamr3UsBivdQ== err-code@^1.0.0: version "1.1.2" From 805f9ffb3493f7bea2d1be2c6e3c8884abebe621 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 2 Feb 2021 16:27:14 +0530 Subject: [PATCH 295/581] chore: use conventional commitlint (#2394) --- .cz-config.js | 32 ----------------------------- commitlint.config.js | 20 +----------------- package.json | 11 +--------- yarn.lock | 48 +++++++++++++------------------------------- 4 files changed, 16 insertions(+), 95 deletions(-) delete mode 100644 .cz-config.js diff --git a/.cz-config.js b/.cz-config.js deleted file mode 100644 index 11703d0b2a1..00000000000 --- a/.cz-config.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license Copyright 2017 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by - * applicable law or agreed to in writing, software distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS - * OF ANY KIND, either express or implied. See the License for the specific - * language governing permissions and limitations under the License. - */ -// Based on https://github.com/GoogleChrome/lighthouse/blob/master/.cz-config.js - -'use strict'; - -module.exports = { - allowBreakingChanges: ['ast'], - allowCustomScopes: true, - scopes: [], - // sort type values in asc - types: [ - { value: 'ast', name: 'ast: init, add, etc' }, - { value: 'break', name: 'break: Changes that break the behaviour of the cli' }, - { value: 'chore', name: 'chore: Updating deps, docs, linting, etc' }, - { value: 'cli', name: 'cli: Core CLI things' }, - { value: 'docs', name: 'docs: Documentation' }, - { value: 'feat', name: 'feat: A new feature' }, - { value: 'fix', name: 'fix: Bugs, typos, etc' }, - { value: 'misc', name: 'misc: Other formats like tweaks and such' }, - { value: 'tests', name: 'tests: Tests, jest, etc' }, - { value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature' }, - ], -}; diff --git a/commitlint.config.js b/commitlint.config.js index d816fd4e9fc..2f9d1aa0e6c 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,21 +1,3 @@ -'use strict'; - module.exports = { - extends: ['cz', '@commitlint/config-lerna-scopes'], - rules: { - 'body-leading-blank': [1, 'always'], - 'footer-leading-blank': [1, 'always'], - 'header-max-length': [2, 'always', 80], - 'scope-case': [2, 'always', 'lowerCase'], - 'scope-empty': [0, 'never'], - 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], - 'subject-empty': [0, 'never'], - 'subject-full-stop': [2, 'never', '.'], - 'type-case': [2, 'always', 'lowerCase'], - // turn it on once CLI will be inside its own package, so the scope will be the name of the packaged - // part of the @commitlint/config-lerna-scopes - 'scope-enum': [0, 'never'], - 'type-empty': [2, 'never'], - 'type-enum': [2, 'always', ['ast', 'break', 'chore', 'cli', 'docs', 'feat', 'fix', 'misc', 'tests', 'refactor']], - }, + extends: ['@commitlint/config-conventional'], }; diff --git a/package.json b/package.json index 84f62d67bd3..6114c3636e1 100644 --- a/package.json +++ b/package.json @@ -45,20 +45,12 @@ "publish:monorepo": "yarn build && lerna version && lerna publish from-git", "update:docs": "node ./scripts/updateDocs" }, - "config": { - "commitizen": { - "path": "./node_modules/cz-customizable" - }, - "cz-customizable": { - "config": "./.cz-config.js" - } - }, "peerDependencies": { "webpack": "4.x.x || 5.x.x" }, "devDependencies": { "@commitlint/cli": "^11.0.0", - "@commitlint/config-lerna-scopes": "^11.0.0", + "@commitlint/config-conventional": "^11.0.0", "@types/jest": "^26.0.15", "@types/node": "^14.14.6", "@typescript-eslint/eslint-plugin": "^2.34.0", @@ -67,7 +59,6 @@ "coffeescript": "^2.5.1", "colorette": "^1.2.1", "commitlint": "^11.0.0", - "commitlint-config-cz": "^0.13.2", "concat-stream": "^2.0.0", "cz-customizable": "^6.3.0", "del-cli": "^3.0.1", diff --git a/yarn.lock b/yarn.lock index 1eee835e480..094afc705ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -419,14 +419,12 @@ resolve-global "1.0.0" yargs "^15.1.0" -"@commitlint/config-lerna-scopes@^11.0.0": +"@commitlint/config-conventional@^11.0.0": version "11.0.0" - resolved "https://registry.yarnpkg.com/@commitlint/config-lerna-scopes/-/config-lerna-scopes-11.0.0.tgz#4152287c5d13ea844160507523b2f98b015adf4a" - integrity sha512-/PjLKefMlnG+Sk27MY3MZo+T/9/PrgDcLk1YCSPVHNkXibXiS2Hb5NEMuNHzPxwts4IvJo0WIOb0YOBx5GBsdA== + resolved "https://registry.yarnpkg.com/@commitlint/config-conventional/-/config-conventional-11.0.0.tgz#3fa300a1b639273946de3c3f15e1cda518333422" + integrity sha512-SNDRsb5gLuDd2PL83yCOQX6pE7gevC79UPFx+GLbLfw6jGnnbO9/tlL76MLD8MOViqGbo7ZicjChO9Gn+7tHhA== dependencies: - import-from "3.0.0" - resolve-pkg "2.0.0" - semver "7.3.2" + conventional-changelog-conventionalcommits "^4.3.1" "@commitlint/ensure@^11.0.0": version "11.0.0" @@ -2460,11 +2458,6 @@ anymatch@^3.0.3: normalize-path "^3.0.0" picomatch "^2.0.4" -app-root-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.0.0.tgz#210b6f43873227e18a4b810a032283311555d5ad" - integrity sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw== - append-transform@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-2.0.0.tgz#99d9d29c7b38391e6f428d28ce136551f0b77e12" @@ -3399,14 +3392,6 @@ commander@^7.0.0: resolved "https://registry.yarnpkg.com/commander/-/commander-7.0.0.tgz#3e2bbfd8bb6724760980988fb5b22b7ee6b71ab2" integrity sha512-ovx/7NkTrnPuIV8sqk/GjUIIM1+iUQeqA3ye2VNpq9sVoiZsooObWlQy+OPWGI17GDaEoybuAGJm6U8yC077BA== -commitlint-config-cz@^0.13.2: - version "0.13.2" - resolved "https://registry.yarnpkg.com/commitlint-config-cz/-/commitlint-config-cz-0.13.2.tgz#83f98a1217fb9e1e7cedd6d1d4fdb2d1492a867e" - integrity sha512-2oN0pXWwDtoKaWW35Haa3xUqWU7761OqM5yu5/UqmklBiznl9WDwoEJ5JIGzHE6qzTmBjAvITToyGNVUcjT/dg== - dependencies: - app-root-path "~3.0.0" - lodash.clonedeep "~4.5.0" - commitlint@^11.0.0: version "11.0.0" resolved "https://registry.yarnpkg.com/commitlint/-/commitlint-11.0.0.tgz#a60f759b938c97c5d601c881cfe71b1d4051d219" @@ -3520,6 +3505,15 @@ conventional-changelog-angular@^5.0.0, conventional-changelog-angular@^5.0.3: compare-func "^2.0.0" q "^1.5.1" +conventional-changelog-conventionalcommits@^4.3.1: + version "4.5.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.5.0.tgz#a02e0b06d11d342fdc0f00c91d78265ed0bc0a62" + integrity sha512-buge9xDvjjOxJlyxUnar/+6i/aVEVGA7EEh4OafBCXPlLUQPGbRUBhBUveWRxzvR8TEjhKEP4BdepnpG2FSZXw== + dependencies: + compare-func "^2.0.0" + lodash "^4.17.15" + q "^1.5.1" + conventional-changelog-core@^3.1.6: version "3.2.3" resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-3.2.3.tgz#b31410856f431c847086a7dcb4d2ca184a7d88fb" @@ -5841,13 +5835,6 @@ import-fresh@^3.0.0, import-fresh@^3.2.1: parent-module "^1.0.0" resolve-from "^4.0.0" -import-from@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/import-from/-/import-from-3.0.0.tgz#055cfec38cd5a27d8057ca51376d7d3bf0891966" - integrity sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ== - dependencies: - resolve-from "^5.0.0" - import-local@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" @@ -7292,7 +7279,7 @@ lodash._reinterpolate@^3.0.0: resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= -lodash.clonedeep@^4.5.0, lodash.clonedeep@~4.5.0: +lodash.clonedeep@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= @@ -9384,13 +9371,6 @@ resolve-global@1.0.0, resolve-global@^1.0.0: dependencies: global-dirs "^0.1.1" -resolve-pkg@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-pkg/-/resolve-pkg-2.0.0.tgz#ac06991418a7623edc119084edc98b0e6bf05a41" - integrity sha512-+1lzwXehGCXSeryaISr6WujZzowloigEofRB+dj75y9RRa/obVcYgbHJd53tdYw8pvZj8GojXaaENws8Ktw/hQ== - dependencies: - resolve-from "^5.0.0" - resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" From ad1a6b83dfa83737f561180384a7968d90472e70 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 2 Feb 2021 15:28:21 +0300 Subject: [PATCH 296/581] docs: update (#2398) --- .github/CONTRIBUTING.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d7d77e2a22d..c394cda8e83 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -211,16 +211,17 @@ format that includes a **type** and a **subject**: This is the list of _type_ of commits that we accept: -- **ast** : Init, migrate, etc. -- **break** : Changes that break the behaviour of the cli. +- **build** : Changes that affect the build system or external dependencies (example scopes: typescript, webpack, npm). - **chore** : Updating deps, docs, linting, etc. -- **cli** : Changes related to core CLI things. +- **ci** : Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) - **docs** : Documentation only changes. - **feat** : A new feature. -- **fix** : A bug fix, typos, etc. -- **misc** : Other formats like tweaks and such. -- **tests** : Adding missing or correcting existing tests. +- **fix** : A bug fix. +- **perf** : A code change that improves performance. - **refactor** : A code change that neither fixes a bug nor adds a feature. +- **revert** : Reverts the previous commit. +- **style** : Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc). +- **test** : Adding missing tests or correcting existing tests. The **header** is mandatory. From b50d71b0bb6ad679a00b06a9dab6ceb49ed99c33 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 2 Feb 2021 19:23:59 +0530 Subject: [PATCH 297/581] test: improve tests for --merge (#2399) --- test/merge/config/1.js | 8 ++++++-- test/merge/config/2.js | 5 +++-- test/merge/config/3.js | 6 ++++++ test/merge/config/first-entry.js | 1 + test/merge/config/merge-config.test.js | 22 +++++++++++++++++++--- test/merge/config/second-entry.js | 1 + test/merge/config/some_entry.js | 1 - test/merge/config/third-entry.js | 1 + 8 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 test/merge/config/3.js create mode 100644 test/merge/config/first-entry.js create mode 100644 test/merge/config/second-entry.js delete mode 100644 test/merge/config/some_entry.js create mode 100644 test/merge/config/third-entry.js diff --git a/test/merge/config/1.js b/test/merge/config/1.js index 5051ea4b9d9..b09ad20ba61 100644 --- a/test/merge/config/1.js +++ b/test/merge/config/1.js @@ -1,6 +1,10 @@ +const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); + module.exports = { - entry: './old_entry.js', + entry: './first-entry.js', + mode: 'development', output: { - filename: 'badfile.js', + filename: 'first-output.js', }, + plugins: [new WebpackCLITestPlugin()], }; diff --git a/test/merge/config/2.js b/test/merge/config/2.js index 2c99fa4d4b7..cdf6f428467 100644 --- a/test/merge/config/2.js +++ b/test/merge/config/2.js @@ -1,6 +1,7 @@ module.exports = { - entry: './some_entry.js', + entry: './second-entry.js', + target: 'node', output: { - filename: 'merged.js', + filename: 'second-output.js', }, }; diff --git a/test/merge/config/3.js b/test/merge/config/3.js new file mode 100644 index 00000000000..eb2a7d3a6f5 --- /dev/null +++ b/test/merge/config/3.js @@ -0,0 +1,6 @@ +module.exports = { + entry: './third-entry.js', + output: { + filename: 'third-output.js', + }, +}; diff --git a/test/merge/config/first-entry.js b/test/merge/config/first-entry.js new file mode 100644 index 00000000000..e5ba023838e --- /dev/null +++ b/test/merge/config/first-entry.js @@ -0,0 +1 @@ +console.log('first'); diff --git a/test/merge/config/merge-config.test.js b/test/merge/config/merge-config.test.js index 916eb44c750..8ac300abb4c 100644 --- a/test/merge/config/merge-config.test.js +++ b/test/merge/config/merge-config.test.js @@ -8,7 +8,22 @@ describe('merge flag configuration', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('option has not been set, webpack will fallback to'); + expect(stdout).toContain('WebpackCLITestPlugin'); // from 1.js + expect(stdout).toContain('second-output.js'); // from 2.js + }); + + it('merges more than two configurations together', () => { + const { exitCode, stderr, stdout } = run( + __dirname, + ['--config', './1.js', '--config', './2.js', '--config', './3.js', '--merge'], + false, + ); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain('WebpackCLITestPlugin'); // from 1.js + expect(stdout).toContain("target: 'node'"); // from 2.js + expect(stdout).toContain('third-output.js'); // from 3.js }); it('merges two configurations together with flag alias', () => { @@ -16,11 +31,12 @@ describe('merge flag configuration', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain('merged.js'); + expect(stdout).toContain('WebpackCLITestPlugin'); // from 1.js + expect(stdout).toContain('second-output.js'); // from 2.js }); it('fails when there are less than 2 configurations to merge', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '-m'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--merge'], false); expect(exitCode).toBe(2); expect(stderr).toContain('At least two configurations are required for merge.'); diff --git a/test/merge/config/second-entry.js b/test/merge/config/second-entry.js new file mode 100644 index 00000000000..e1595dffb00 --- /dev/null +++ b/test/merge/config/second-entry.js @@ -0,0 +1 @@ +console.log('second'); diff --git a/test/merge/config/some_entry.js b/test/merge/config/some_entry.js deleted file mode 100644 index ad5fca8a5fd..00000000000 --- a/test/merge/config/some_entry.js +++ /dev/null @@ -1 +0,0 @@ -console.log('yass'); diff --git a/test/merge/config/third-entry.js b/test/merge/config/third-entry.js new file mode 100644 index 00000000000..29134430a5e --- /dev/null +++ b/test/merge/config/third-entry.js @@ -0,0 +1 @@ +console.log('third'); From 2841cd77284678dfccc500f8c6e1eb509c9c7aff Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Tue, 2 Feb 2021 20:06:22 +0530 Subject: [PATCH 298/581] test: default loader name and plugin name (#2392) --- test/loader/loader.test.js | 28 ++++++++++++++++++++++++++++ test/plugin/plugin.test.js | 27 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/test/loader/loader.test.js b/test/loader/loader.test.js index bf1638a239d..6ee115a8853 100644 --- a/test/loader/loader.test.js +++ b/test/loader/loader.test.js @@ -10,11 +10,13 @@ const firstPrompt = '? Loader name (my-loader)'; const ENTER = '\x0D'; const loaderName = 'test-loader'; const loaderPath = join(__dirname, loaderName); +const defaultLoaderPath = join(__dirname, 'my-loader'); const genPath = join(__dirname, 'test-assets'); const customLoaderPath = join(genPath, loaderName); describe('loader command', () => { beforeEach(() => { + rimraf.sync(defaultLoaderPath); rimraf.sync(loaderPath); rimraf.sync(genPath); }); @@ -26,6 +28,32 @@ describe('loader command', () => { expect(stripAnsi(stdout)).toContain(firstPrompt); }); + it('should scaffold loader with default name if no loader name provided', async () => { + let { stdout } = await runPromptWithAnswers(__dirname, ['loader'], [`${ENTER}`]); + + expect(stripAnsi(stdout)).toContain(firstPrompt); + + // Skip test in case installation fails + if (!existsSync(resolve(defaultLoaderPath, './yarn.lock'))) { + return; + } + + // Check if the output directory exists with the appropriate loader name + expect(existsSync(defaultLoaderPath)).toBeTruthy(); + + // All test files are scaffolded + const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; + + files.forEach((file) => { + expect(existsSync(defaultLoaderPath, file)).toBeTruthy(); + }); + + // Check if the the generated loader works successfully + const path = resolve(__dirname, './my-loader/examples/simple/'); + ({ stdout } = run(path, [], false)); + expect(stdout).toContain('my-loader'); + }); + it('should scaffold loader template with a given name', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['loader'], [`${loaderName}${ENTER}`]); diff --git a/test/plugin/plugin.test.js b/test/plugin/plugin.test.js index ac41d218dd6..bad234e7a83 100644 --- a/test/plugin/plugin.test.js +++ b/test/plugin/plugin.test.js @@ -10,11 +10,13 @@ const firstPrompt = '? Plugin name'; const pluginName = 'test-plugin'; const pluginPath = join(__dirname, pluginName); +const defaultPluginPath = join(__dirname, 'my-webpack-plugin'); const genPath = join(__dirname, 'test-assets'); const customPluginPath = join(genPath, pluginName); describe('plugin command', () => { beforeEach(() => { + rimraf.sync(defaultPluginPath); rimraf.sync(pluginPath); rimraf.sync(genPath); }); @@ -26,6 +28,31 @@ describe('plugin command', () => { expect(stripAnsi(stdout)).toContain(firstPrompt); }); + it('should scaffold plugin with default name if no plugin name provided', async () => { + let { stdout } = await runPromptWithAnswers(__dirname, ['plugin'], [`${ENTER}`]); + + expect(stripAnsi(stdout)).toContain(firstPrompt); + + // Check if the output directory exists with the appropriate plugin name + expect(existsSync(defaultPluginPath)).toBeTruthy(); + + // Skip test in case installation fails + if (!existsSync(resolve(defaultPluginPath, './yarn.lock'))) { + return; + } + + // Test regressively files are scaffolded + const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js']; + + files.forEach((file) => { + expect(existsSync(join(defaultPluginPath, file))).toBeTruthy(); + }); + + // Check if the the generated plugin works successfully + stdout = run(__dirname, ['--config', './my-webpack-plugin/examples/simple/webpack.config.js'], false).stdout; + expect(stdout).toContain('Hello World!'); + }); + it('should scaffold plugin template with a given name', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['plugin'], [`${pluginName}${ENTER}`]); From e5126f10b6622437c0541c25be2a610a82c1df04 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 2 Feb 2021 20:59:51 +0530 Subject: [PATCH 299/581] feat: add the `--node-env` flag (#2388) --- packages/webpack-cli/lib/webpack-cli.js | 16 +++++++- test/node-env/auto-mode.config.js | 5 +++ test/node-env/node-env.test.js | 53 +++++++++++++++++++++++++ test/node-env/src/index.js | 1 + test/node-env/webpack.config.js | 6 +++ 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 test/node-env/auto-mode.config.js create mode 100644 test/node-env/node-env.test.js create mode 100644 test/node-env/src/index.js create mode 100644 test/node-env/webpack.config.js diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 79f7070534c..15be68263dc 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -295,6 +295,12 @@ class WebpackCLI { multiple: true, description: 'Environment passed to the configuration when it is a function.', }, + { + name: 'node-env', + type: String, + multiple: false, + description: 'Sets process.env.NODE_ENV to the specified value', + }, // Adding more plugins { @@ -429,6 +435,12 @@ class WebpackCLI { return options; } + applyNodeEnv(options) { + if (typeof options.nodeEnv === 'string') { + process.env.NODE_ENV = options.nodeEnv; + } + } + async run(args, parseOptions) { // Built-in internal commands const buildCommandOptions = { @@ -1517,7 +1529,7 @@ class WebpackCLI { !configOptions.mode && process.env && process.env.NODE_ENV && - (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'node') + (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'none') ) { configOptions.mode = process.env.NODE_ENV; } @@ -1653,6 +1665,8 @@ class WebpackCLI { } async createCompiler(options, callback) { + this.applyNodeEnv(options); + let config = await this.resolveConfig(options); config = await this.applyOptions(config, options); diff --git a/test/node-env/auto-mode.config.js b/test/node-env/auto-mode.config.js new file mode 100644 index 00000000000..385cb2ac035 --- /dev/null +++ b/test/node-env/auto-mode.config.js @@ -0,0 +1,5 @@ +const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin'); + +module.exports = { + plugins: [new WebpackCLITestPlugin()], +}; diff --git a/test/node-env/node-env.test.js b/test/node-env/node-env.test.js new file mode 100644 index 00000000000..4d8bda5d328 --- /dev/null +++ b/test/node-env/node-env.test.js @@ -0,0 +1,53 @@ +'use strict'; + +const { run } = require('../utils/test-utils'); + +describe('--node-env flag', () => { + it('should set "process.env.NODE_ENV" to "development"', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--node-env', 'development']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'development'"); + }); + + it('should set "process.env.NODE_ENV" to "production"', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--node-env', 'production']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'production'"); + }); + + it('should set "process.env.NODE_ENV" to "none"', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--node-env', 'none']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'none'"); + }); + + it('should set "process.env.NODE_ENV" and the "mode" option to "development"', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--node-env', 'development', '--config', './auto-mode.config.js']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'development'"); + }); + + it('should set "process.env.NODE_ENV" and the "mode" option to "production"', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--node-env', 'production', '--config', './auto-mode.config.js']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'production'"); + }); + + it('should set "process.env.NODE_ENV" and the "mode" option to "none"', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--node-env', 'none', '--config', './auto-mode.config.js']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'none'"); + }); +}); diff --git a/test/node-env/src/index.js b/test/node-env/src/index.js new file mode 100644 index 00000000000..c70a2899e94 --- /dev/null +++ b/test/node-env/src/index.js @@ -0,0 +1 @@ +console.log('--node-env test'); \ No newline at end of file diff --git a/test/node-env/webpack.config.js b/test/node-env/webpack.config.js new file mode 100644 index 00000000000..ca74229899d --- /dev/null +++ b/test/node-env/webpack.config.js @@ -0,0 +1,6 @@ +const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin'); + +module.exports = { + mode: process.env.NODE_ENV, + plugins: [new WebpackCLITestPlugin()], +}; From 3bbda71e9637b7d20f3f49f9e080e27d8d8ae929 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 2 Feb 2021 20:03:06 +0300 Subject: [PATCH 300/581] chore(release): publish new version - @webpack-cli/configtest@1.0.1 - @webpack-cli/generators@1.3.1 - @webpack-cli/info@1.2.2 - @webpack-cli/init@1.1.3 - @webpack-cli/serve@1.3.0 - webpack-cli@4.5.0 --- packages/configtest/CHANGELOG.md | 6 ++++++ packages/configtest/package.json | 2 +- packages/generators/CHANGELOG.md | 4 ++++ packages/generators/package.json | 2 +- packages/info/CHANGELOG.md | 4 ++++ packages/info/package.json | 2 +- packages/init/CHANGELOG.md | 4 ++++ packages/init/package.json | 4 ++-- packages/serve/CHANGELOG.md | 11 +++++++++++ packages/serve/package.json | 2 +- packages/webpack-cli/CHANGELOG.md | 14 ++++++++++++++ packages/webpack-cli/package.json | 8 ++++---- 12 files changed, 53 insertions(+), 10 deletions(-) diff --git a/packages/configtest/CHANGELOG.md b/packages/configtest/CHANGELOG.md index 5b94c2f2ba8..5591b28d520 100644 --- a/packages/configtest/CHANGELOG.md +++ b/packages/configtest/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.0...@webpack-cli/configtest@1.0.1) (2021-02-02) + +### Bug Fixes + +- improve description for 'configtest' command ([#2379](https://github.com/webpack/webpack-cli/issues/2379)) ([311bae3](https://github.com/webpack/webpack-cli/commit/311bae336d83424c800e553b6ef40242d967685c)) + # 1.0.0 (2021-01-19) ### Features diff --git a/packages/configtest/package.json b/packages/configtest/package.json index b33a1bd3d15..e1edb626ad1 100644 --- a/packages/configtest/package.json +++ b/packages/configtest/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/configtest", - "version": "1.0.0", + "version": "1.0.1", "description": "Validate a webpack configuration.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/generators/CHANGELOG.md b/packages/generators/CHANGELOG.md index c273131aa0c..21a61d8b8b7 100644 --- a/packages/generators/CHANGELOG.md +++ b/packages/generators/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.3.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.3.0...@webpack-cli/generators@1.3.1) (2021-02-02) + +**Note:** Version bump only for package @webpack-cli/generators + # [1.3.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@1.2.1...@webpack-cli/generators@1.3.0) (2021-01-19) ### Bug Fixes diff --git a/packages/generators/package.json b/packages/generators/package.json index 518d16009c6..8984a335af8 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generators", - "version": "1.3.0", + "version": "1.3.1", "description": "Webpack-CLI generators", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/info/CHANGELOG.md b/packages/info/CHANGELOG.md index 32c830bbc58..6d94a300ed5 100644 --- a/packages/info/CHANGELOG.md +++ b/packages/info/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.2.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.1...@webpack-cli/info@1.2.2) (2021-02-02) + +**Note:** Version bump only for package @webpack-cli/info + ## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.0...@webpack-cli/info@1.2.1) (2020-12-31) ### Bug Fixes diff --git a/packages/info/package.json b/packages/info/package.json index dbb837959a5..e46b874587d 100644 --- a/packages/info/package.json +++ b/packages/info/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/info", - "version": "1.2.1", + "version": "1.2.2", "description": "Outputs info about system and webpack config", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/init/CHANGELOG.md b/packages/init/CHANGELOG.md index 71ce0af5f2a..890c797cfe5 100644 --- a/packages/init/CHANGELOG.md +++ b/packages/init/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.2...@webpack-cli/init@1.1.3) (2021-02-02) + +**Note:** Version bump only for package @webpack-cli/init + ## [1.1.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.1...@webpack-cli/init@1.1.2) (2021-01-19) **Note:** Version bump only for package @webpack-cli/init diff --git a/packages/init/package.json b/packages/init/package.json index 9f4261998c6..92ce11d2b7d 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/init", - "version": "1.1.2", + "version": "1.1.3", "description": "init command for webpack-cli", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -12,7 +12,7 @@ "lib" ], "dependencies": { - "@webpack-cli/generators": "^1.3.0" + "@webpack-cli/generators": "^1.3.1" }, "peerDependencies": { "webpack": "4.x.x || 5.x.x", diff --git a/packages/serve/CHANGELOG.md b/packages/serve/CHANGELOG.md index 6df9f1652e1..1410db8f934 100644 --- a/packages/serve/CHANGELOG.md +++ b/packages/serve/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.3.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.2...@webpack-cli/serve@1.3.0) (2021-02-02) + +### Bug Fixes + +- avoid deprecation message ([9d6dbda](https://github.com/webpack/webpack-cli/commit/9d6dbda93da167a1aaad03f599105a4fe7849dc3)) +- error message on invalid plugin options ([#2380](https://github.com/webpack/webpack-cli/issues/2380)) ([f9ce1d3](https://github.com/webpack/webpack-cli/commit/f9ce1d30b83bf0e0b4d91498d012c13c208e6e67)) + +### Features + +- entries syntax ([#2369](https://github.com/webpack/webpack-cli/issues/2369)) ([6b31614](https://github.com/webpack/webpack-cli/commit/6b3161479578f572f803f579c7e71073eb797184)) + ## [1.2.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.1...@webpack-cli/serve@1.2.2) (2021-01-19) ### Bug Fixes diff --git a/packages/serve/package.json b/packages/serve/package.json index 55426cbfbe7..de003324058 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/serve", - "version": "1.2.2", + "version": "1.3.0", "description": "", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/webpack-cli/CHANGELOG.md b/packages/webpack-cli/CHANGELOG.md index 7ae81a01387..cd541473b01 100644 --- a/packages/webpack-cli/CHANGELOG.md +++ b/packages/webpack-cli/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.5.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.4.0...webpack-cli@4.5.0) (2021-02-02) + +### Bug Fixes + +- avoid deprecation message ([9d6dbda](https://github.com/webpack/webpack-cli/commit/9d6dbda93da167a1aaad03f599105a4fe7849dc3)) +- error message on invalid plugin options ([#2380](https://github.com/webpack/webpack-cli/issues/2380)) ([f9ce1d3](https://github.com/webpack/webpack-cli/commit/f9ce1d30b83bf0e0b4d91498d012c13c208e6e67)) +- improve description for 'configtest' command ([#2379](https://github.com/webpack/webpack-cli/issues/2379)) ([311bae3](https://github.com/webpack/webpack-cli/commit/311bae336d83424c800e553b6ef40242d967685c)) + +### Features + +- add the `--node-env` flag ([#2388](https://github.com/webpack/webpack-cli/issues/2388)) ([e5126f1](https://github.com/webpack/webpack-cli/commit/e5126f10b6622437c0541c25be2a610a82c1df04)) +- entries syntax ([#2369](https://github.com/webpack/webpack-cli/issues/2369)) ([6b31614](https://github.com/webpack/webpack-cli/commit/6b3161479578f572f803f579c7e71073eb797184)) +- support ES module configuration format ([#2381](https://github.com/webpack/webpack-cli/issues/2381)) ([aebdbbc](https://github.com/webpack/webpack-cli/commit/aebdbbc1f6e2761e7821cb3660bea686cce7b587)) + # [4.4.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.1...webpack-cli@4.4.0) (2021-01-19) ### Bug Fixes diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index bbeea374eba..a81232c5aa6 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -1,6 +1,6 @@ { "name": "webpack-cli", - "version": "4.4.0", + "version": "4.5.0", "description": "CLI for webpack & friends", "license": "MIT", "repository": { @@ -28,9 +28,9 @@ ], "dependencies": { "@discoveryjs/json-ext": "^0.5.0", - "@webpack-cli/configtest": "^1.0.0", - "@webpack-cli/info": "^1.2.1", - "@webpack-cli/serve": "^1.2.2", + "@webpack-cli/configtest": "^1.0.1", + "@webpack-cli/info": "^1.2.2", + "@webpack-cli/serve": "^1.3.0", "colorette": "^1.2.1", "commander": "^7.0.0", "enquirer": "^2.3.6", From 1adc5aae08a561b97cff84f14fb4421409bfd4b6 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 2 Feb 2021 20:22:31 +0300 Subject: [PATCH 301/581] docs: update changelog --- CHANGELOG.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad016fcba6a..8f1b80d7b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,44 @@ +# [4.5.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.4.0...webpack-cli@4.5.0) (2021-02-02) + +### Notes + +- now you can use `webpack.config.mjs` and `webpack.config.js` with `{ "type": "module" }` in `package.json` +- you can avoid using the `cross-env` package: + +Before: + +```json +{ + "scripts": { + "build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js" + } +} +``` + +Now (you can remove the `cross-env` if you don't use it somewhere else): + +```json +{ + "scripts": { + "build": "webpack --node-env=production --config build/webpack.config.js" + } +} +``` + +- the `mode` option respect the `--node-env` option if you don't set the `mode` option explicit using CLI options or in configuration(s), i.e. `--node-env production` set `process.env.NODE_ENV` and `mode` to `production` + +### Bug Fixes + +- avoid deprecation message ([9d6dbda](https://github.com/webpack/webpack-cli/commit/9d6dbda93da167a1aaad03f599105a4fe7849dc3)) +- error message on invalid plugin options ([#2380](https://github.com/webpack/webpack-cli/issues/2380)) ([f9ce1d3](https://github.com/webpack/webpack-cli/commit/f9ce1d30b83bf0e0b4d91498d012c13c208e6e67)) +- improve description for 'configtest' command ([#2379](https://github.com/webpack/webpack-cli/issues/2379)) ([311bae3](https://github.com/webpack/webpack-cli/commit/311bae336d83424c800e553b6ef40242d967685c)) + +### Features + +- add the `--node-env` flag ([#2388](https://github.com/webpack/webpack-cli/issues/2388)) ([e5126f1](https://github.com/webpack/webpack-cli/commit/e5126f10b6622437c0541c25be2a610a82c1df04)) +- entries syntax ([#2369](https://github.com/webpack/webpack-cli/issues/2369)) ([6b31614](https://github.com/webpack/webpack-cli/commit/6b3161479578f572f803f579c7e71073eb797184)) +- support ES module configuration format ([#2381](https://github.com/webpack/webpack-cli/issues/2381)) ([aebdbbc](https://github.com/webpack/webpack-cli/commit/aebdbbc1f6e2761e7821cb3660bea686cce7b587)) + # [4.4.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.3.1...webpack-cli@4.4.0) (2021-01-19) ### Bug Fixes From f9dadef1577ec0df9ac89f6308ff8b4da19892e0 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 6 Feb 2021 19:43:39 +0530 Subject: [PATCH 302/581] chore: update webpack (#2416) --- OPTIONS.md | 12 +++++-- package.json | 2 +- test/build-errors/errors.test.js | 4 ++- test/build-warnings/warnings.test.js | 4 ++- test/colors/colors.test.js | 36 +++++++++---------- test/core-flags/context-flag.test.js | 3 +- test/core-flags/output-flags.test.js | 2 ++ test/core-flags/stats-flags.test.js | 2 +- test/defaults/output-defaults.test.js | 4 ++- .../defaults-empty/entry-single-arg.test.js | 3 +- test/entry/flag-entry/entry-with-flag.test.js | 3 +- .../mode-single-arg/mode-single-arg.test.js | 8 +++-- test/prefetch/prefetch.test.js | 5 ++- .../entry-absent/zero-config.test.js | 5 ++- yarn.lock | 9 +++-- 15 files changed, 64 insertions(+), 38 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index 9cf47d8cec7..06a04206bfb 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -9,6 +9,7 @@ Options: --config-name Name of the configuration to use. -m, --merge Merge two or more configurations using 'webpack-merge'. --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value -h, --hot Enables Hot Module Replacement --no-hot Disables Hot Module Replacement. --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. @@ -52,6 +53,9 @@ Options: --experiments-lazy-compilation-client A custom client. --experiments-lazy-compilation-entries Enable/disable lazy compilation for entries. --no-experiments-lazy-compilation-entries Negative 'experiments-lazy-compilation-entries' option. + --experiments-lazy-compilation-imports Enable/disable lazy compilation for import() modules. + --no-experiments-lazy-compilation-imports Negative 'experiments-lazy-compilation-imports' option. + --experiments-lazy-compilation-test Specify which entrypoints or import()ed modules should be lazily compiled. This is matched with the imported module and not the entrypoint name. --experiments-output-module Allow output javascript files as module source type. --no-experiments-output-module Negative 'experiments-output-module' option. --experiments-sync-web-assembly Support WebAssembly as synchronous EcmaScript Module (outdated). @@ -428,6 +432,11 @@ Options: --output-chunk-load-timeout Number of milliseconds before chunk request expires. --output-chunk-loading The method of loading chunks (methods included by default are 'jsonp' (web), 'importScripts' (WebWorker), 'require' (sync node.js), 'async-node' (async node.js), but others might be added by plugins). --output-chunk-loading-global The global variable used by webpack for loading of chunks. + --output-clean Clean the output directory before emit. + --no-output-clean Negative 'output-clean' option. + --output-clean-dry Log the assets that should be removed instead of deleting them. + --no-output-clean-dry Negative 'output-clean-dry' option. + --output-clean-keep Keep these assets. --output-compare-before-emit Check if to be emitted file already exists and have the same content before writing to output filesystem. --no-output-compare-before-emit Negative 'output-compare-before-emit' option. --output-cross-origin-loading This option enables cross-origin loading of chunks. @@ -686,8 +695,7 @@ Options: --stats-entrypoints Display the entry points with the corresponding bundles. --stats-env Add --env information. --no-stats-env Negative 'stats-env' option. - --stats-error-details Add details to errors (like resolving log). - --no-stats-error-details Negative 'stats-error-details' option. + --stats-error-details Add details to errors (like resolving log). --stats-error-stack Add internal stack trace to errors. --no-stats-error-stack Negative 'stats-error-stack' option. --stats-errors Add errors. diff --git a/package.json b/package.json index 6114c3636e1..64039a18326 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "ts-jest": "^26.4.3", "ts-node": "^9.1.1", "typescript": "^4.1.3", - "webpack": "^5.18.0", + "webpack": "^5.21.1", "webpack-bundle-analyzer": "^4.3.0", "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" diff --git a/test/build-errors/errors.test.js b/test/build-errors/errors.test.js index 30fac63060d..3147000a8b3 100644 --- a/test/build-errors/errors.test.js +++ b/test/build-errors/errors.test.js @@ -1,4 +1,6 @@ 'use strict'; + +const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const { readFile } = require('fs'); const { resolve } = require('path'); @@ -10,7 +12,7 @@ describe('errors', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); expect(stdout).toMatch(/ERROR/); - expect(stdout).toMatch(/Error: Can't resolve/); + expect(stripAnsi(stdout)).toMatch(/Error: Can't resolve/); }); it('should output JSON with the "json" flag', () => { diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index 8bf676da732..c58d9b9fab8 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -1,4 +1,6 @@ 'use strict'; + +const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); @@ -10,7 +12,7 @@ describe('warnings', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toMatch(/WARNING/); - expect(stdout).toMatch(/Error: Can't resolve/); + expect(stripAnsi(stdout)).toMatch(/Error: Can't resolve/); }); it('should output JSON with the "json" flag', () => { diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 52d842821b5..8e7348f8480 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -1,51 +1,49 @@ 'use strict'; + const { run, isWebpack5 } = require('../utils/test-utils'); const { resolve } = require('path'); -const { options: coloretteOptions } = require('colorette'); describe('colors related tests', () => { it('should output by default', () => { - const { exitCode, stderr, stdout } = run(__dirname, [], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, [], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should work with the "stats" option from flags', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should work with the "stats" option from flags and from configuration', () => { const { exitCode, stderr, stdout } = run( __dirname, ['--stats=verbose', `--config=${resolve(__dirname, './no-stats.webpack.config.js')}`], - true, - [], - { FORCE_COLOR: true }, + { env: { FORCE_COLOR: true } }, ); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should work with the "stats" option from flags and from configuration #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js'], true, [], { - FORCE_COLOR: true, + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--config=stats-string.webpack.config.js'], { + env: { FORCE_COLOR: true }, }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should disable colored output with --no-color', () => { @@ -68,30 +66,30 @@ describe('colors related tests', () => { }); it('should work with the "stats" option from the configuration', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-string.webpack.config.js'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-string.webpack.config.js'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should work with the "stats" option from the configuration #1', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-boolean.webpack.config.js'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-boolean.webpack.config.js'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should work with the "stats" option from the configuration #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--config=no-stats.webpack.config.js'], true, [], { FORCE_COLOR: true }); + const { exitCode, stderr, stdout } = run(__dirname, ['--config=no-stats.webpack.config.js'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should work with the "stats" option from the configuration #3', () => { @@ -100,7 +98,7 @@ describe('colors related tests', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); it('should work with the "stats" option from the configuration #4', () => { diff --git a/test/core-flags/context-flag.test.js b/test/core-flags/context-flag.test.js index df4050e94a7..20b4072f84e 100644 --- a/test/core-flags/context-flag.test.js +++ b/test/core-flags/context-flag.test.js @@ -1,5 +1,6 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); const { resolve } = require('path'); const { run, isWindows } = require('../utils/test-utils'); @@ -23,6 +24,6 @@ describe('--context flag', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`Module not found: Error: Can't resolve './src/main.js'`); + expect(stripAnsi(stdout)).toContain(`Module not found: Error: Can't resolve './src/main.js'`); }); }); diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index 3829a5e3a21..bd725deb68f 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -13,6 +13,8 @@ describe('output config related flag', () => { if (property.includes('environment-')) { property = property.split('environment-')[1]; + } else if (property.includes('clean-')) { + property = property.split('clean-')[1]; } const propName = hyphenToUpperCase(property); diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index 77d7ff11edd..d8c92acd093 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -71,7 +71,7 @@ describe('stats config related flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('log'); - } else if (flag.name === 'stats-entrypoints') { + } else if (flag.name === 'stats-entrypoints' || flag.name === 'stats-error-details') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'auto']); expect(exitCode).toBe(0); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index bd4b4213a91..910419745a9 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -1,4 +1,6 @@ 'use strict'; + +const stripAnsi = require('strip-ansi'); const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../utils/test-utils'); @@ -10,7 +12,7 @@ describe('output flag defaults', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); // Should print warning about config fallback - expect(stdout).toContain('option has not been set, webpack will fallback to'); + expect(stripAnsi(stdout)).toContain('option has not been set, webpack will fallback to'); expect(existsSync(resolve(__dirname, './binary/main.js'))).toBeTruthy(); }); diff --git a/test/entry/defaults-empty/entry-single-arg.test.js b/test/entry/defaults-empty/entry-single-arg.test.js index d6274bf2e8f..b4d6cf07f86 100644 --- a/test/entry/defaults-empty/entry-single-arg.test.js +++ b/test/entry/defaults-empty/entry-single-arg.test.js @@ -1,5 +1,6 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); const { run } = require('../../utils/test-utils'); describe('single entry flag empty project', () => { @@ -8,6 +9,6 @@ describe('single entry flag empty project', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`not found: Error: Can't resolve`); + expect(stripAnsi(stdout)).toContain(`not found: Error: Can't resolve`); }); }); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index 90e465042ad..b2d02f9f3fd 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -1,5 +1,6 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); const { run } = require('../../utils/test-utils'); const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); @@ -39,6 +40,6 @@ describe('entry flag', () => { expect(exitCode).toEqual(1); expect(stderr).toBeFalsy(); - expect(stdout).toContain("Module not found: Error: Can't resolve"); + expect(stripAnsi(stdout)).toContain("Module not found: Error: Can't resolve"); }); }); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 7816271878f..3d18ddb14e6 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -1,5 +1,6 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); const { run, isWebpack5 } = require('../../utils/test-utils'); describe('mode flags', () => { @@ -8,8 +9,11 @@ describe('mode flags', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).not.toContain(`mode: 'production'`); - expect(stdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); + + const pureStdout = stripAnsi(stdout); + + expect(pureStdout).not.toContain(`mode: 'production'`); + expect(pureStdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); }); it('should load a development config when --mode=development is passed', () => { diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index 1e1a85ab8f7..cf7c60fe638 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -1,5 +1,8 @@ +'use strict'; + const fs = require('fs'); const { join } = require('path'); +const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const rimraf = require('rimraf'); @@ -26,7 +29,7 @@ describe('prefetch', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); // Should contain the error message - expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); + expect(stripAnsi(stdout)).toContain(`Error: Can't resolve './src/somefile.js'`); }); it('should log error when flag value is not supplied', () => { diff --git a/test/zero-config/entry-absent/zero-config.test.js b/test/zero-config/entry-absent/zero-config.test.js index c55f05e049a..0ebba445d1a 100644 --- a/test/zero-config/entry-absent/zero-config.test.js +++ b/test/zero-config/entry-absent/zero-config.test.js @@ -1,3 +1,6 @@ +'use strict'; + +const stripAnsi = require('strip-ansi'); const { run } = require('../../utils/test-utils'); describe('Zero Config tests', () => { @@ -7,6 +10,6 @@ describe('Zero Config tests', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); // Entry file is absent, should log the Error from the compiler - expect(stdout).toContain("Error: Can't resolve './src'"); + expect(stripAnsi(stdout)).toContain("Error: Can't resolve './src'"); }); }); diff --git a/yarn.lock b/yarn.lock index 094afc705ea..5417978a1ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11074,10 +11074,10 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.18.0: - version "5.19.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.19.0.tgz#1a5fee84dd63557e68336b0774ac4a1c81aa2c73" - integrity sha512-egX19vAQ8fZ4cVYtA9Y941eqJtcZAK68mQq87MMv+GTXKZOc3TpKBBxdGX+HXUYlquPxiluNsJ1VHvwwklW7CQ== +webpack@^5.21.1: + version "5.21.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.21.1.tgz#a5a13965187deeaa674a0ecea219b61060a2c38f" + integrity sha512-H/fjQiDETEZDKoZm/LhvDBxOIKf9rfOdqb2pKTHRvBFMIRtwAwYlPCgBd0gc5xiDG5DqkxAiFZgAF/4H41wMuQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" @@ -11097,7 +11097,6 @@ webpack@^5.18.0: loader-runner "^4.2.0" mime-types "^2.1.27" neo-async "^2.6.2" - pkg-dir "^5.0.0" schema-utils "^3.0.0" tapable "^2.1.1" terser-webpack-plugin "^5.1.1" From e0b208d3cd7d22e64c88a9fa2fd3adf59219d94d Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 6 Feb 2021 19:45:32 +0530 Subject: [PATCH 303/581] build: do not install webpack 5 again (#2417) --- .github/workflows/nodejs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index d2c0262b783..351cdbadfa1 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -85,6 +85,7 @@ jobs: yarn bootstrap - name: Install webpack ${{ matrix.webpack-version }} + if: matrix.webpack-version == 'webpack-4' run: yarn add -W webpack@${{ matrix.webpack-version }} - name: Build and Bootstrap From 2c2eacf6890111897e48001bcac09707fd99eaf3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 6 Feb 2021 19:18:23 +0300 Subject: [PATCH 304/581] chore(deps-dev): bump @types/prettier Bumps [@types/prettier](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/prettier) from 2.1.6 to 2.2.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/prettier) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5417978a1ac..5d06ceee46e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1956,9 +1956,9 @@ integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== "@types/prettier@^2.0.0", "@types/prettier@^2.1.5": - version "2.1.6" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.6.tgz#f4b1efa784e8db479cdb8b14403e2144b1e9ff03" - integrity sha512-6gOkRe7OIioWAXfnO/2lFiv+SJichKVSys1mSsgyrYHSEjk8Ctv4tSR/Odvnu+HWlH2C8j53dahU03XmQdd5fA== + version "2.2.0" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.0.tgz#a4e8205a4955690eef712a6d0394a1d2e121e721" + integrity sha512-O3SQC6+6AySHwrspYn2UvC6tjo6jCTMMmylxZUFhE1CulVu5l3AxU6ca9lrJDTQDVllF62LIxVSx5fuYL6LiZg== "@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" From 5a4e792d76baf860b27338e05f5c42b2b9ec614f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 6 Feb 2021 20:12:07 +0300 Subject: [PATCH 305/581] chore(deps-dev): bump lint-staged from 10.5.3 to 10.5.4 (#2413) Bumps [lint-staged](https://github.com/okonet/lint-staged) from 10.5.3 to 10.5.4. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v10.5.3...v10.5.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5d06ceee46e..db877f81c5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7129,9 +7129,9 @@ lines-and-columns@^1.1.6: integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= lint-staged@^10.5.0: - version "10.5.3" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.3.tgz#c682838b3eadd4c864d1022da05daa0912fb1da5" - integrity sha512-TanwFfuqUBLufxCc3RUtFEkFraSPNR3WzWcGF39R3f2J7S9+iF9W0KTVLfSy09lYGmZS5NDCxjNvhGMSJyFCWg== + version "10.5.4" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.5.4.tgz#cd153b5f0987d2371fc1d2847a409a2fe705b665" + integrity sha512-EechC3DdFic/TdOPgj/RB3FicqE6932LTHCUm0Y2fsD9KGlLB+RwJl2q1IYBIvEsKzDOgn0D4gll+YxG5RsrKg== dependencies: chalk "^4.1.0" cli-truncate "^2.1.0" From 75eae34dbd2cd791df1e03b8a4d93ec412e1f337 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 6 Feb 2021 20:12:24 +0300 Subject: [PATCH 306/581] chore(deps-dev): bump @types/node Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.22 to 14.14.25. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index db877f81c5d..16425d5b928 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1941,9 +1941,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.22" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18" - integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw== + version "14.14.25" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.25.tgz#15967a7b577ff81383f9b888aa6705d43fbbae93" + integrity sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 62ef2e3902cf4c6da12538971b214ffb11ec565c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 8 Feb 2021 13:16:40 +0300 Subject: [PATCH 307/581] chore(deps-dev): bump webpack from 5.21.1 to 5.21.2 (#2421) Bumps [webpack](https://github.com/webpack/webpack) from 5.21.1 to 5.21.2. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.21.1...v5.21.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 16425d5b928..4a634ff34ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11075,9 +11075,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.21.1: - version "5.21.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.21.1.tgz#a5a13965187deeaa674a0ecea219b61060a2c38f" - integrity sha512-H/fjQiDETEZDKoZm/LhvDBxOIKf9rfOdqb2pKTHRvBFMIRtwAwYlPCgBd0gc5xiDG5DqkxAiFZgAF/4H41wMuQ== + version "5.21.2" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.21.2.tgz#647507e50d3637695be28af58a6a8246050394e7" + integrity sha512-xHflCenx+AM4uWKX71SWHhxml5aMXdy2tu/vdi4lClm7PADKxlyDAFFN1rEFzNV0MAoPpHtBeJnl/+K6F4QBPg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" From dd0f1632217a40c04c19af973ef3d696cc595d21 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Mon, 8 Feb 2021 15:59:48 +0530 Subject: [PATCH 308/581] refactor: move init to generators (#2393) --- .eslintignore | 1 - .prettierignore | 1 - packages/generators/src/index.ts | 36 ++++++++++++- packages/init/CHANGELOG.md | 69 ------------------------- packages/init/README.md | 52 ------------------- packages/init/package.json | 22 -------- packages/init/src/index.ts | 38 -------------- packages/init/tsconfig.json | 9 ---- packages/webpack-cli/lib/webpack-cli.js | 2 +- packages/webpack-cli/package.json | 3 -- test/version/version.test.js | 15 +++--- tsconfig.json | 3 -- 12 files changed, 43 insertions(+), 208 deletions(-) delete mode 100644 packages/init/CHANGELOG.md delete mode 100644 packages/init/README.md delete mode 100644 packages/init/package.json delete mode 100644 packages/init/src/index.ts delete mode 100644 packages/init/tsconfig.json diff --git a/.eslintignore b/.eslintignore index b6038bd2368..671d7209437 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,7 +5,6 @@ dist packages/configtest/lib packages/generators/lib packages/info/lib -packages/init/lib packages/serve/lib test/**/dist/ test/**/bin/ diff --git a/.prettierignore b/.prettierignore index 877e50a1666..12de069ebb5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,7 +5,6 @@ dist packages/configtest/lib packages/generators/lib packages/info/lib -packages/init/lib packages/serve/lib test/**/dist/ test/**/bin/ diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index 8850c361123..8826052aa1d 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -4,10 +4,44 @@ import pluginGenerator from './plugin-generator'; import addonGenerator from './addon-generator'; import initGenerator from './init-generator'; +import { modifyHelperUtil } from './utils/modify-config-helper'; +import { npmPackagesExists } from './utils/npm-packages-exists'; + class GeneratorsCommand { async apply(cli): Promise { const { logger } = cli; + await cli.makeCommand( + { + name: 'init [scaffold...]', + alias: 'c', + description: 'Initialize a new webpack configuration.', + usage: '[scaffold...] [options]', + pkg: '@webpack-cli/generators', + }, + [ + { + name: 'auto', + type: Boolean, + description: 'To generate default config', + }, + { + name: 'generation-path', + type: String, + description: 'To scaffold in a specified path', + }, + ], + async (scaffold, options) => { + if (scaffold && scaffold.length > 0) { + await npmPackagesExists(scaffold); + + return; + } + + modifyHelperUtil(initGenerator, null, null, options.auto, options.generationPath); + }, + ); + await cli.makeCommand( { name: 'loader [output-path]', @@ -29,7 +63,7 @@ class GeneratorsCommand { }, ); - cli.makeCommand( + await cli.makeCommand( { name: 'plugin [output-path]', alias: 'p', diff --git a/packages/init/CHANGELOG.md b/packages/init/CHANGELOG.md deleted file mode 100644 index 890c797cfe5..00000000000 --- a/packages/init/CHANGELOG.md +++ /dev/null @@ -1,69 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [1.1.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.2...@webpack-cli/init@1.1.3) (2021-02-02) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.1.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.1...@webpack-cli/init@1.1.2) (2021-01-19) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.1.0...@webpack-cli/init@1.1.1) (2020-12-31) - -### Bug Fixes - -- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.3...@webpack-cli/init@1.1.0) (2020-12-25) - -### Features - -- add `--generation-path` option ([#2050](https://github.com/webpack/webpack-cli/issues/2050)) ([413eb8c](https://github.com/webpack/webpack-cli/commit/413eb8cf2add4978763a4c9ee6b983582685768b)) - -## [1.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.2...@webpack-cli/init@1.0.3) (2020-11-04) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.1...@webpack-cli/init@1.0.2) (2020-10-19) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.1-rc.1...@webpack-cli/init@1.0.1) (2020-10-10) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.1-alpha.5...@webpack-cli/init@1.0.1-rc.1) (2020-10-06) - -### Bug Fixes - -- **packages:** make packages have correct main paths to index ([#1366](https://github.com/webpack/webpack-cli/issues/1366)) ([5dd7bd6](https://github.com/webpack/webpack-cli/commit/5dd7bd62046568481996e48328b15a335557f8ae)) -- add necessary peerDependencies ([#1825](https://github.com/webpack/webpack-cli/issues/1825)) ([0f13ab5](https://github.com/webpack/webpack-cli/commit/0f13ab5ddd9e28e5e7095721d086a58aebaf98a5)) - -### Features - -- add flag to force config ([f61e7e0](https://github.com/webpack/webpack-cli/commit/f61e7e0d1b03284d7333c4f0f38294460209a25d)) - -## [1.0.1-alpha.5](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/init@1.0.1-alpha.4...@webpack-cli/init@1.0.1-alpha.5) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/init@1.0.1-alpha.3...@webpack-cli/init@1.0.1-alpha.4) (2020-02-29) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/init@1.0.1-alpha.2...@webpack-cli/init@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.1-alpha.1...@webpack-cli/init@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/init - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/init@1.0.1-alpha.0...@webpack-cli/init@1.0.1-alpha.1) (2020-02-23) - -### Bug Fixes - -- **init:** fix webpack config scaffold ([#1231](https://github.com/webpack/webpack-cli/issues/1231)) ([2dc495a](https://github.com/webpack/webpack-cli/commit/2dc495a8d050d28478c6c2533d7839e9ff78d76c)), closes [#1230](https://github.com/webpack/webpack-cli/issues/1230) diff --git a/packages/init/README.md b/packages/init/README.md deleted file mode 100644 index a1e392533cb..00000000000 --- a/packages/init/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# webpack-cli init - -[![NPM Downloads][downloads]][downloads-url] - -## Description - -This package contains the logic to create a new webpack configuration. - -## Installation - -```bash -npm i -D webpack-cli @webpack-cli/init -``` - -## Usage - -### CLI (via `webpack-cli`) - -**Via defaults** - -```bash -npx webpack-cli init -``` - -**To generate default configs** - -```bash -npx webpack-cli init --auto -``` - -**To scaffold in a specified path** - -```bash -npx webpack-cli init --generation-path [path] -``` - -**Via custom scaffold** - -1. Using package on `npm` - -```bash -npx webpack-cli init webpack-scaffold-[name] -``` - -2. Using path to a local directory - -```bash -npx webpack-cli init [path] -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/init.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/init diff --git a/packages/init/package.json b/packages/init/package.json deleted file mode 100644 index 92ce11d2b7d..00000000000 --- a/packages/init/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "@webpack-cli/init", - "version": "1.1.3", - "description": "init command for webpack-cli", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "files": [ - "lib" - ], - "dependencies": { - "@webpack-cli/generators": "^1.3.1" - }, - "peerDependencies": { - "webpack": "4.x.x || 5.x.x", - "webpack-cli": "4.x.x" - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/init/src/index.ts b/packages/init/src/index.ts deleted file mode 100644 index e75210408ce..00000000000 --- a/packages/init/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { initGenerator, modifyHelperUtil, npmPackagesExists } from '@webpack-cli/generators'; - -class InitCommand { - async apply(cli): Promise { - await cli.makeCommand( - { - name: 'init [scaffold...]', - alias: 'c', - description: 'Initialize a new webpack configuration.', - usage: '[scaffold...] [options]', - pkg: '@webpack-cli/init', - }, - [ - { - name: 'auto', - type: Boolean, - description: 'To generate default config', - }, - { - name: 'generation-path', - type: String, - description: 'To scaffold in a specified path', - }, - ], - async (scaffold, options) => { - if (scaffold && scaffold.length > 0) { - await npmPackagesExists(scaffold); - - return; - } - - modifyHelperUtil(initGenerator, null, null, options.auto, options.generationPath); - }, - ); - } -} - -export default InitCommand; diff --git a/packages/init/tsconfig.json b/packages/init/tsconfig.json deleted file mode 100644 index ba2474fb584..00000000000 --- a/packages/init/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [{ "path": "../generators" }] -} diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 15be68263dc..a95c28eebe1 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -480,7 +480,7 @@ class WebpackCLI { { name: 'init', alias: 'c', - pkg: '@webpack-cli/init', + pkg: '@webpack-cli/generators', }, { name: 'loader', diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index a81232c5aa6..ffa31882c8a 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -49,9 +49,6 @@ "@webpack-cli/generators": { "optional": true }, - "@webpack-cli/init": { - "optional": true - }, "@webpack-cli/migrate": { "optional": true }, diff --git a/test/version/version.test.js b/test/version/version.test.js index 1cc9fb69ce5..b0c7df26b81 100644 --- a/test/version/version.test.js +++ b/test/version/version.test.js @@ -4,7 +4,6 @@ const webpack = require('webpack'); const { run } = require('../utils/test-utils'); const pkgJSON = require('../../packages/webpack-cli/package.json'); -const initPkgJSON = require('../../packages/init/package.json'); const servePkgJSON = require('../../packages/serve/package.json'); const infoPkgJSON = require('../../packages/info/package.json'); const generatorsPkgJSON = require('../../packages/generators/package.json'); @@ -162,7 +161,7 @@ describe('single version flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`@webpack-cli/init ${initPkgJSON.version}`); + expect(stdout).toContain(`@webpack-cli/generators ${generatorsPkgJSON.version}`); expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); expect(stdout).toContain(`webpack ${webpack.version}`); expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); @@ -190,11 +189,11 @@ describe('single version flag', () => { }); it('outputs version with the alias c for init', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['i', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['c', '--version'], false); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stdout).toContain(`@webpack-cli/info ${infoPkgJSON.version}`); + expect(stdout).toContain(`@webpack-cli/generators ${generatorsPkgJSON.version}`); expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); expect(stdout).toContain(`webpack ${webpack.version}`); expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); @@ -253,21 +252,21 @@ describe('single version flag', () => { }); it('should log version for known command and log error for unknown command using the "--version" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'abc', '--version'], false); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toContain(`@webpack-cli/init ${initPkgJSON.version}`); + expect(stdout).toContain(`@webpack-cli/serve ${servePkgJSON.version}`); }); it('should log version for known command and log error for unknown command using the "-v" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', 'abc', '-v'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'abc', '-v'], false); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toContain(`@webpack-cli/init ${initPkgJSON.version}`); + expect(stdout).toContain(`@webpack-cli/serve ${servePkgJSON.version}`); }); it('should not output version with help dashed', () => { diff --git a/tsconfig.json b/tsconfig.json index ad41a0d6d32..d5d1c44c8f5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,9 +26,6 @@ { "path": "packages/info" }, - { - "path": "packages/init" - }, { "path": "packages/serve" }, From 78e2fa7036e123beefe2010e0a6cc10697d14c4d Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 8 Feb 2021 18:00:46 +0530 Subject: [PATCH 309/581] fix: add serve script if opted for WDS with init (#2424) * fix: add start script if opted for WDS * chore: rename to serve --- packages/generators/init-template/package.json.js | 6 +++--- packages/generators/src/init-generator.ts | 8 ++++++-- test/init/auto/init-auto.test.js | 2 ++ test/init/generation-path/init-generation-path.test.js | 4 ++++ test/init/generator/init-inquirer.test.js | 2 ++ test/init/language/css/init-language-css.test.js | 2 ++ test/init/language/js/init-language-js.test.js | 2 ++ test/init/multipleEntries/init-multipleEntries.test.js | 2 ++ 8 files changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/generators/init-template/package.json.js b/packages/generators/init-template/package.json.js index effe0ca439d..b5c6ee60ebb 100644 --- a/packages/generators/init-template/package.json.js +++ b/packages/generators/init-template/package.json.js @@ -1,9 +1,9 @@ -module.exports = (usingDefaults) => { +module.exports = (isUsingDevServer) => { const scripts = { build: 'webpack', }; - if (usingDefaults) { - scripts.start = 'webpack-dev-server'; + if (isUsingDevServer) { + scripts.serve = 'webpack serve'; } return { diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 40bb3b5db41..022768b9596 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -244,9 +244,13 @@ export default class InitGenerator extends CustomGenerator { public writing(): void { this.config.set('configuration', this.configuration); + const isUsingDevServer = this.dependencies.includes('webpack-dev-server'); const packageJsonTemplatePath = '../init-template/package.json.js'; - // eslint-disable-next-line @typescript-eslint/no-var-requires - this.fs.extendJSON(this.destinationPath('package.json'), require(packageJsonTemplatePath)(this.autoGenerateConfig)); + this.fs.extendJSON( + this.destinationPath('package.json'), + // eslint-disable-next-line @typescript-eslint/no-var-requires + require(packageJsonTemplatePath)(isUsingDevServer), + ); const generateEntryFile = (entryPath: string, name: string): void => { entryPath = entryPath.replace(/'/g, ''); diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index 05a58085830..c29df7cf5c1 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -51,7 +51,9 @@ describe('init auto flag', () => { expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] == 'webpack serve').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); diff --git a/test/init/generation-path/init-generation-path.test.js b/test/init/generation-path/init-generation-path.test.js index e4211b18732..b4b614536da 100644 --- a/test/init/generation-path/init-generation-path.test.js +++ b/test/init/generation-path/init-generation-path.test.js @@ -42,7 +42,9 @@ describe('init generate-path flag', () => { expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] == 'webpack serve').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); }); @@ -78,7 +80,9 @@ describe('init generate-path flag', () => { expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] == 'webpack serve').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); }); diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 9cb3f794761..677535adf9f 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -46,7 +46,9 @@ describe('init', () => { expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] == 'webpack serve').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); diff --git a/test/init/language/css/init-language-css.test.js b/test/init/language/css/init-language-css.test.js index c36648b7aa2..5a4cb27b925 100644 --- a/test/init/language/css/init-language-css.test.js +++ b/test/init/language/css/init-language-css.test.js @@ -72,9 +72,11 @@ describe('init with SCSS', () => { expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); expect(pkgJson['devDependencies']['node-sass']).toBeTruthy(); expect(pkgJson['devDependencies']['mini-css-extract-plugin']).toBeTruthy(); expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] == 'webpack serve').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); }); diff --git a/test/init/language/js/init-language-js.test.js b/test/init/language/js/init-language-js.test.js index 17094f65a87..bbb76d132e5 100644 --- a/test/init/language/js/init-language-js.test.js +++ b/test/init/language/js/init-language-js.test.js @@ -56,9 +56,11 @@ describe('init with Typescript', () => { expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); expect(pkgJson['devDependencies']['typescript']).toBeTruthy(); expect(pkgJson['devDependencies']['ts-loader']).toBeTruthy(); expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] == 'webpack serve').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); }); diff --git a/test/init/multipleEntries/init-multipleEntries.test.js b/test/init/multipleEntries/init-multipleEntries.test.js index 6f1db08984a..518003a1799 100644 --- a/test/init/multipleEntries/init-multipleEntries.test.js +++ b/test/init/multipleEntries/init-multipleEntries.test.js @@ -51,8 +51,10 @@ describe('init with multiple entries', () => { expect(pkgJson).toBeTruthy(); expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); + expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); expect(pkgJson['devDependencies']['terser-webpack-plugin']).toBeTruthy(); expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] == 'webpack-dev-server').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); }); From f5fc3023121f4d952a166879a46b2653c20b6349 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 8 Feb 2021 18:57:29 +0530 Subject: [PATCH 310/581] fix: show '--node-env' in minimum help output (#2411) --- OPTIONS.md | 2 +- packages/webpack-cli/README.md | 1 + packages/webpack-cli/lib/webpack-cli.js | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index 06a04206bfb..ad5e4473f34 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -9,7 +9,7 @@ Options: --config-name Name of the configuration to use. -m, --merge Merge two or more configurations using 'webpack-merge'. --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value + --node-env Sets process.env.NODE_ENV to the specified value. -h, --hot Enables Hot Module Replacement --no-hot Disables Hot Module Replacement. --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index a7248a715c6..86941f9f47a 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -85,6 +85,7 @@ npx webpack-cli --help verbose --config-name Name of the configuration to use. -m, --merge Merge two or more configurations using 'webpack-merge'. --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. -d, --devtool Determine source maps to use. diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index a95c28eebe1..6e049c5b19d 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -241,6 +241,7 @@ class WebpackCLI { 'json', 'name', 'output-path', + 'node-env', ]; const builtInFlags = [ @@ -299,7 +300,7 @@ class WebpackCLI { name: 'node-env', type: String, multiple: false, - description: 'Sets process.env.NODE_ENV to the specified value', + description: 'Sets process.env.NODE_ENV to the specified value.', }, // Adding more plugins From 217012c96f8f3586b58a9be0c52686f6fd361f1e Mon Sep 17 00:00:00 2001 From: James George Date: Mon, 8 Feb 2021 19:39:43 +0530 Subject: [PATCH 311/581] chore: update types (#2425) --- packages/generators/src/types/index.ts | 1 - packages/generators/src/utils/modify-config-helper.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/generators/src/types/index.ts b/packages/generators/src/types/index.ts index bcd09727b2f..00cc32f4ea8 100644 --- a/packages/generators/src/types/index.ts +++ b/packages/generators/src/types/index.ts @@ -243,7 +243,6 @@ export class CustomGenerator extends Generator { topScope?: string[]; webpackOptions?: WebpackOptions; }; - usingDefaults?: boolean; }; public isProd: boolean; public dependencies: string[]; diff --git a/packages/generators/src/utils/modify-config-helper.ts b/packages/generators/src/utils/modify-config-helper.ts index 8dede3af614..3357e7cccee 100644 --- a/packages/generators/src/utils/modify-config-helper.ts +++ b/packages/generators/src/utils/modify-config-helper.ts @@ -29,7 +29,6 @@ export interface WebpackScaffoldObject extends Object { topScope?: string[]; webpackOptions?: object; }; - usingDefaults?: boolean; } const DEFAULT_WEBPACK_CONFIG_FILENAME = 'webpack.config.js'; From 81a9c60a94dcc3125a3f60a43ce0d73cc0abddee Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 8 Feb 2021 20:14:53 +0530 Subject: [PATCH 312/581] docs: update commands (#2402) --- README.md | 17 +++++++++++------ packages/configtest/README.md | 27 +++++++++++++++++++++++++++ packages/info/README.md | 2 +- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 packages/configtest/README.md diff --git a/README.md b/README.md index f0eed545f74..365a6b4f262 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,17 @@ We organize webpack CLI as a multi-package repository using [lerna](https://gith Supporting developers is an important task for webpack CLI. Thus, webpack CLI provides different commands for many common tasks. -- [`webpack-cli init`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration. -- [`webpack-cli info`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment. -- [`webpack-cli migrate`](https://www.npmjs.com/package/@webpack-cli/migrate) - Migrate project from one version to another. -- [`webpack-cli plugin`](./packages/generators#generators) - Initiate new plugin project. -- [`webpack-cli loader`](./packages/generators#generators) - Initiate new loader project. -- [`webpack-cli serve`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading. +- `build|bundle|b [entries...] [options]` - Run webpack (default command, can be omitted). +- [`configtest|t [config-path]`](./packages/configtest/README.md#webpack-cli-configtest) - Validate a webpack configuration. +- `help|h [command] [option]` - Display help for commands and options. +- [`init|c [scaffold...] [options]`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration. +- [`info|i [options]`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment. +- [`migrate|m [new-config-path]`](https://www.npmjs.com/package/@webpack-cli/migrate) - Migrate project from one version to another. +- [`plugin|p [output-path]`](./packages/generators#generators) - Initiate new plugin project. +- [`loader|l [output-path]`](./packages/generators#generators) - Initiate new loader project. +- [`serve|s [entries...] [options]`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading. +- `version|v [commands...]` - Output the version number of `webpack`, `webpack-cli`, `webpack-dev-server`, and commands +- `watch|w [entries...] [options]` - Run webpack and watch for files changes. ### Utilities diff --git a/packages/configtest/README.md b/packages/configtest/README.md new file mode 100644 index 00000000000..07f991f33df --- /dev/null +++ b/packages/configtest/README.md @@ -0,0 +1,27 @@ +# webpack-cli configtest + +[![NPM Downloads][downloads]][downloads-url] + +## Description + +This package validates a webpack configuration. + +## Installation + +```bash +#npm +npm i -D @webpack-cli/configtest + +#yarn +yarn add -D @webpack-cli/configtest + +``` + +## Usage + +```bash +npx webpack configtest [config-path] +``` + +[downloads]: https://img.shields.io/npm/dm/@webpack-cli/configtest.svg +[downloads-url]: https://www.npmjs.com/package/@webpack-cli/configtest diff --git a/packages/info/README.md b/packages/info/README.md index ed1603fc691..4c77be70812 100644 --- a/packages/info/README.md +++ b/packages/info/README.md @@ -13,7 +13,7 @@ This package returns a set of information related to the local environment. npm i -D @webpack-cli/info #yarn -yarn add @webpack-cli/info -D +yarn add -D @webpack-cli/info ``` From 6ae73ec7fb230a31efb70604101267d261da15ad Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 8 Feb 2021 21:00:14 +0530 Subject: [PATCH 313/581] refactor: use error validation from cli (#2423) --- packages/configtest/src/index.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts index 50e4a3d9205..15161d85f79 100644 --- a/packages/configtest/src/index.ts +++ b/packages/configtest/src/index.ts @@ -44,17 +44,7 @@ class ConfigTestCommand { throw new webpack.WebpackOptionsValidationError(error); } } catch (error) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const isValidationError = (error: any): boolean => { - // https://github.com/webpack/webpack/blob/master/lib/index.js#L267 - // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90 - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const ValidationError = (webpack.ValidationError || webpack.WebpackOptionsValidationError) as any; - - return error instanceof ValidationError; - }; - - if (isValidationError(error)) { + if (cli.isValidationError(error)) { logger.error(error.message); } else { logger.error(error); From 21a1a30c687cd800396a1c13abefc57bf42886f3 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Mon, 8 Feb 2021 23:10:30 +0530 Subject: [PATCH 314/581] fix: improve prettier message (#2419) --- .../generators/src/utils/__tests__/run-prettier.test.ts | 4 ++-- packages/generators/src/utils/run-prettier.ts | 6 ++---- packages/generators/src/utils/scaffold.ts | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/generators/src/utils/__tests__/run-prettier.test.ts b/packages/generators/src/utils/__tests__/run-prettier.test.ts index 2f579917a79..e8508520e74 100644 --- a/packages/generators/src/utils/__tests__/run-prettier.test.ts +++ b/packages/generators/src/utils/__tests__/run-prettier.test.ts @@ -20,7 +20,7 @@ describe('runPrettier', () => { }); it('should run prettier on JS string and write file', () => { - runPrettier(outputFile, 'console.log("1");console.log("2");'); + runPrettier(outputFile, 'console.log("1");console.log("2");', 'webpack.config.js'); expect(fs.existsSync(outputFile)).toBeTruthy(); @@ -31,7 +31,7 @@ describe('runPrettier', () => { }); it('prettier should fail on invalid JS, with file still written', () => { - runPrettier(outputFile, '"'); + runPrettier(outputFile, '"', 'webpack.config.js'); expect(fs.existsSync(outputFile)).toBeTruthy(); diff --git a/packages/generators/src/utils/run-prettier.ts b/packages/generators/src/utils/run-prettier.ts index a4c8b06b0fd..734f37f5d40 100644 --- a/packages/generators/src/utils/run-prettier.ts +++ b/packages/generators/src/utils/run-prettier.ts @@ -12,7 +12,7 @@ const { logger } = utils; * @returns {void} Writes a file at given location */ -export function runPrettier(outputPath: string, source: string): void { +export function runPrettier(outputPath: string, source: string, fileName: string): void { let prettySource: string = source; let prettier; @@ -21,9 +21,7 @@ export function runPrettier(outputPath: string, source: string): void { // eslint-disable-next-line node/no-extraneous-require prettier = require('prettier'); } catch (err) { - logger.warn( - "File is not properly formatted because you don't have prettier installed, you can either install it or format it manually", - ); + logger.warn(`${fileName} is not formatted because prettier is not installed locally.`); return fs.writeFileSync(outputPath, source, 'utf8'); } diff --git a/packages/generators/src/utils/scaffold.ts b/packages/generators/src/utils/scaffold.ts index ec38c2278bd..b078eacb2d6 100644 --- a/packages/generators/src/utils/scaffold.ts +++ b/packages/generators/src/utils/scaffold.ts @@ -86,7 +86,7 @@ export function runTransform(transformConfig: TransformConfig, action: string, g const source: string = ast.toSource({ quote: 'single', }); - runPrettier(outputPath, source); + runPrettier(outputPath, source, configurationName); }) .catch((err: Error): void => { logger.error(err); From b8deb52f903cd758d0222ad378e71364aeead994 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 9 Feb 2021 16:20:59 +0300 Subject: [PATCH 315/581] chore(deps-dev): bump ts-jest from 26.5.0 to 26.5.1 (#2427) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.0 to 26.5.1. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v26.5.0...v26.5.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4a634ff34ad..92e8c7d967c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10572,9 +10572,9 @@ trim-off-newlines@^1.0.0: integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= ts-jest@^26.4.3: - version "26.5.0" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.0.tgz#3e3417d91bc40178a6716d7dacc5b0505835aa21" - integrity sha512-Ya4IQgvIFNa2Mgq52KaO8yBw2W8tWp61Ecl66VjF0f5JaV8u50nGoptHVILOPGoI7SDnShmEqnYQEmyHdQ+56g== + version "26.5.1" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.1.tgz#4d53ee4481552f57c1624f0bd3425c8b17996150" + integrity sha512-G7Rmo3OJMvlqE79amJX8VJKDiRcd7/r61wh9fnvvG8cAjhA9edklGw/dCxRSQmfZ/z8NDums5srSVgwZos1qfg== dependencies: "@types/jest" "26.x" bs-logger "0.x" From f5c9b6b5d3485301cbba199beaa5d3595301ee6a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 10 Feb 2021 00:44:32 +0300 Subject: [PATCH 316/581] chore(deps-dev): bump typescript from 4.1.3 to 4.1.4 (#2428) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.1.3 to 4.1.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.1.3...v4.1.4) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 92e8c7d967c..49586cd4c36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10694,9 +10694,9 @@ typedarray@^0.0.6: integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= typescript@^4.1.3: - version "4.1.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7" - integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg== + version "4.1.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.4.tgz#f058636e2f4f83f94ddaae07b20fd5e14598432f" + integrity sha512-+Uru0t8qIRgjuCpiSPpfGuhHecMllk5Zsazj5LZvVsEStEjmIRRBZe+jHjGQvsgS7M1wONy2PQXd67EMyV6acg== uglify-js@^3.1.4: version "3.11.4" From 4f559fe69bd7d44c607fb35ce87a46812da7b697 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 11 Feb 2021 14:12:01 +0300 Subject: [PATCH 317/581] chore(deps-dev): bump typescript from 4.1.4 to 4.1.5 (#2433) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.1.4 to 4.1.5. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.1.4...v4.1.5) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 49586cd4c36..d7e27007095 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10694,9 +10694,9 @@ typedarray@^0.0.6: integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= typescript@^4.1.3: - version "4.1.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.4.tgz#f058636e2f4f83f94ddaae07b20fd5e14598432f" - integrity sha512-+Uru0t8qIRgjuCpiSPpfGuhHecMllk5Zsazj5LZvVsEStEjmIRRBZe+jHjGQvsgS7M1wONy2PQXd67EMyV6acg== + version "4.1.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.5.tgz#123a3b214aaff3be32926f0d8f1f6e704eb89a72" + integrity sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA== uglify-js@^3.1.4: version "3.11.4" From f8406e1c5253849fad741eb45f1ece23a7c603f4 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Thu, 11 Feb 2021 22:04:15 +0530 Subject: [PATCH 318/581] feat: display used config path when logging level=log (#2431) --- .github/workflows/nodejs.yml | 30 +++++++------------ package.json | 1 - .../__tests__/applyCLIPlugin.test.js | 4 +-- packages/webpack-cli/lib/plugins/CLIPlugin.js | 26 ++++++++++++---- packages/webpack-cli/lib/webpack-cli.js | 2 +- test/build/basic/basic.test.js | 16 ++++++++++ test/build/basic/log.config.js | 6 ++++ .../core-flags/infrastructure-logging.test.js | 4 +-- test/json/json.test.js | 15 ++++++---- test/serve/basic/log.config.js | 6 ++++ test/serve/basic/serve-basic.test.js | 10 +++++++ test/watch/basic/basic.test.js | 22 ++++++++++++++ test/watch/basic/log.config.js | 6 ++++ 13 files changed, 113 insertions(+), 35 deletions(-) create mode 100644 test/build/basic/log.config.js create mode 100644 test/serve/basic/log.config.js create mode 100644 test/watch/basic/log.config.js diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 351cdbadfa1..837f99b1ac1 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -35,12 +35,7 @@ jobs: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: | - yarn - yarn bootstrap - - - name: Install webpack ${{ matrix.webpack-version }} - run: yarn add -W webpack@${{ matrix.webpack-version }} + run: yarn - name: Build run: yarn build @@ -57,7 +52,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] node-version: [10.x, 12.x, 14.x] - webpack-version: [webpack-4, latest] + webpack-version: [4, latest] steps: - uses: actions/checkout@v2 @@ -76,27 +71,24 @@ jobs: path: | node_modules */*/node_modules - key: ${{ runner.os }}-${{ matrix.webpack-version }}-${{ hashFiles('**/yarn.lock', './yarn.lock') }} + key: ${{ runner.os }}-${{ matrix.webpack-version }}-yarn-${{ hashFiles('**/yarn.lock', './yarn.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.webpack-version }}-yarn- - name: Install dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: | - yarn - yarn bootstrap + run: yarn - name: Install webpack ${{ matrix.webpack-version }} - if: matrix.webpack-version == 'webpack-4' + if: matrix.webpack-version == '4' run: yarn add -W webpack@${{ matrix.webpack-version }} - - name: Build and Bootstrap - run: | - yarn build:ci - yarn run lerna bootstrap + - name: Prepare environment for tests + run: yarn build:ci - - name: Run Smoketests + - name: Run smoketests run: yarn test:smoketests - - name: Test and Generate Coverage + - name: Run tests and generate coverage run: | yarn prepsuite yarn test:coverage diff --git a/package.json b/package.json index 64039a18326..368f125a321 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "./packages/*" ], "scripts": { - "bootstrap": "lerna bootstrap", "clean": "del-cli \"*.tsbuildinfo\" \"packages/**/*.tsbuildinfo\" \"packages/!(webpack-cli)/lib/!(*.tpl)\" \"**/.yo-rc.json\"", "prebuild": "yarn clean", "prebuild:ci": "yarn clean && node ./scripts/setupBuild.js", diff --git a/packages/webpack-cli/__tests__/applyCLIPlugin.test.js b/packages/webpack-cli/__tests__/applyCLIPlugin.test.js index 7c90277c5a1..7889a7af624 100644 --- a/packages/webpack-cli/__tests__/applyCLIPlugin.test.js +++ b/packages/webpack-cli/__tests__/applyCLIPlugin.test.js @@ -5,7 +5,7 @@ const applyCLIPlugin = new webpackCLI().applyCLIPlugin; describe('CLIPluginResolver', () => { it('should add CLI plugin to single compiler object', async () => { - const result = await applyCLIPlugin({ options: {} }, { hot: true, prefetch: true }); + const result = await applyCLIPlugin({ options: {}, path: new WeakMap() }, { hot: true, prefetch: true }); expect(result.options.plugins[0] instanceof CLIPlugin).toBeTruthy(); expect(result.options.plugins[0].options).toEqual({ configPath: undefined, @@ -18,7 +18,7 @@ describe('CLIPluginResolver', () => { }); it('should add CLI plugin to multi compiler object', async () => { - const result = await applyCLIPlugin({ options: [{}, {}] }, { hot: true, prefetch: true }); + const result = await applyCLIPlugin({ options: [{}, {}], path: new WeakMap() }, { hot: true, prefetch: true }); expect(result.options[0].plugins[0] instanceof CLIPlugin).toBeTruthy(); expect(result.options[1].plugins[0] instanceof CLIPlugin).toBeTruthy(); expect(result.options).toEqual([ diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js index 350ee33e573..363221e3fd6 100644 --- a/packages/webpack-cli/lib/plugins/CLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -39,10 +39,18 @@ class CLIPlugin { setupHelpfulOutput(compiler) { const pluginName = 'webpack-cli'; - const getCompilationName = () => (compiler.name ? ` '${compiler.name}'` : ''); + const getCompilationName = () => (compiler.name ? `'${compiler.name}'` : ''); + + const { configPath } = this.options; compiler.hooks.run.tap(pluginName, () => { - this.logger.log(`Compilation${getCompilationName()} starting...`); + const name = getCompilationName(); + + this.logger.log(`Compiler${name ? ` ${name}` : ''} starting...`); + + if (configPath) { + this.logger.log(`Compiler${name ? ` ${name}` : ''} is using config: '${configPath}'`); + } }); compiler.hooks.watchRun.tap(pluginName, (compiler) => { @@ -52,7 +60,13 @@ class CLIPlugin { this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); } - this.logger.log(`Compilation${getCompilationName()} starting...`); + const name = getCompilationName(); + + this.logger.log(`Compiler${name ? ` ${name}` : ''} starting...`); + + if (configPath) { + this.logger.log(`Compiler${name ? ` ${name}` : ''} is using config: '${configPath}'`); + } }); compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => { @@ -63,11 +77,13 @@ class CLIPlugin { }); (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => { - this.logger.log(`Compilation${getCompilationName()} finished`); + const name = getCompilationName(); + + this.logger.log(`Compiler${name ? ` ${name}` : ''} finished`); process.nextTick(() => { if (compiler.watchMode) { - this.logger.log(`Compiler${getCompilationName()} is watching files for updates...`); + this.logger.log(`Compiler${name ? `${name}` : ''} is watching files for updates...`); } }); }); diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 6e049c5b19d..4ce7ad3254f 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -1631,7 +1631,7 @@ class WebpackCLI { configOptions.plugins.unshift( new CLIPlugin({ - configPath: config.path, + configPath: config.path.get(configOptions), helpfulOutput: !cliOptions.json, hot: cliOptions.hot, progress: cliOptions.progress, diff --git a/test/build/basic/basic.test.js b/test/build/basic/basic.test.js index 01481187f45..1b559e77599 100644 --- a/test/build/basic/basic.test.js +++ b/test/build/basic/basic.test.js @@ -1,5 +1,7 @@ 'use strict'; +const stripAnsi = require('strip-ansi'); +const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); describe('bundle command', () => { @@ -140,4 +142,18 @@ describe('bundle command', () => { expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); + + it('should log supplied config when logging level is log', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--config', './log.config.js']); + const configPath = resolve(__dirname, './log.config.js'); + + expect(exitCode).toBe(0); + + const pureStderr = stripAnsi(stderr); + + expect(pureStderr).toContain('Compiler starting...'); + expect(pureStderr).toContain(`Compiler is using config: '${configPath}'`); + expect(pureStderr).toContain('Compiler finished'); + expect(stdout).toBeTruthy(); + }); }); diff --git a/test/build/basic/log.config.js b/test/build/basic/log.config.js new file mode 100644 index 00000000000..70619a29563 --- /dev/null +++ b/test/build/basic/log.config.js @@ -0,0 +1,6 @@ +module.exports = { + mode: 'development', + infrastructureLogging: { + level: 'log', + }, +}; diff --git a/test/core-flags/infrastructure-logging.test.js b/test/core-flags/infrastructure-logging.test.js index 9e408f2d46b..8c2f8645169 100644 --- a/test/core-flags/infrastructure-logging.test.js +++ b/test/core-flags/infrastructure-logging.test.js @@ -23,8 +23,8 @@ describe('infrastructure logging related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-level', 'log']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toContain("Compiler 'compiler' starting..."); + expect(stderr).toContain("Compiler 'compiler' finished"); expect(stdout).toContain(`level: 'log'`); }); }); diff --git a/test/json/json.test.js b/test/json/json.test.js index 64441e4504a..49022409705 100644 --- a/test/json/json.test.js +++ b/test/json/json.test.js @@ -1,4 +1,6 @@ 'use strict'; + +const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); @@ -111,8 +113,8 @@ describe('json', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', '--config', 'logging.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toContain('Compiler starting...'); + expect(stderr).toContain('Compiler finished'); expect(() => JSON.parse(stdout)).not.toThrow(); expect(JSON.parse(stdout)['hash']).toBeDefined(); }); @@ -121,9 +123,12 @@ describe('json', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--config', 'logging.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain(successMessage); + + const pureStderr = stripAnsi(stderr); + + expect(stderr).toContain('Compiler starting...'); + expect(pureStderr).toContain('Compiler finished'); + expect(pureStderr).toContain(successMessage); expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); diff --git a/test/serve/basic/log.config.js b/test/serve/basic/log.config.js new file mode 100644 index 00000000000..70619a29563 --- /dev/null +++ b/test/serve/basic/log.config.js @@ -0,0 +1,6 @@ +module.exports = { + mode: 'development', + infrastructureLogging: { + level: 'log', + }, +}; diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index d215cea596e..e5b1335bb60 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -306,6 +306,16 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); + it('should log used supplied config with serve', async () => { + const { stderr, stdout } = await runServe(__dirname, ['--config', 'log.config.js', '--port', port]); + const configPath = path.resolve(__dirname, './log.config.js'); + + expect(stderr).toContain('Compiler starting...'); + expect(stderr).toContain(`Compiler is using config: '${configPath}'`); + expect(stderr).toContain('Compiler finished'); + expect(stdout).toBeTruthy(); + }); + it("should log error on using '--watch' flag with serve", async () => { const { stdout, stderr } = await runServe(testPath, ['--watch']); diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js index 29013daeff3..bced22c1988 100644 --- a/test/watch/basic/basic.test.js +++ b/test/watch/basic/basic.test.js @@ -159,6 +159,28 @@ describe('basic', () => { }); }); + it('should log supplied config with watch', (done) => { + const proc = runAndGetWatchProc(__dirname, ['watch', '--config', 'log.config.js']); + const configPath = resolve(__dirname, './log.config.js'); + + let stderr = ''; + + proc.stderr.on('data', (chunk) => { + const data = stripAnsi(chunk.toString()); + + stderr += stripAnsi(data); + + if (/Compiler finished/.test(data)) { + expect(stderr).toContain('Compiler starting...'); + expect(stderr).toContain(`Compiler is using config: '${configPath}'`); + expect(stderr).toContain('Compiler finished'); + + proc.kill(); + done(); + } + }); + }); + it('should recompile upon file change using the `command` option and the `--watch` option and log warning', async () => { const { exitCode, stderr, stdout } = await run(__dirname, ['watch', '--watch', '--mode', 'development']); diff --git a/test/watch/basic/log.config.js b/test/watch/basic/log.config.js new file mode 100644 index 00000000000..70619a29563 --- /dev/null +++ b/test/watch/basic/log.config.js @@ -0,0 +1,6 @@ +module.exports = { + mode: 'development', + infrastructureLogging: { + level: 'log', + }, +}; From 4fd643207bee9219613c58685f5217f128430c2c Mon Sep 17 00:00:00 2001 From: James George Date: Fri, 12 Feb 2021 16:11:41 +0530 Subject: [PATCH 319/581] docs: remove reference to init package (#2432) --- README.md | 2 +- packages/README.md | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 365a6b4f262..5c3717d8a69 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Thus, webpack CLI provides different commands for many common tasks. - `build|bundle|b [entries...] [options]` - Run webpack (default command, can be omitted). - [`configtest|t [config-path]`](./packages/configtest/README.md#webpack-cli-configtest) - Validate a webpack configuration. - `help|h [command] [option]` - Display help for commands and options. -- [`init|c [scaffold...] [options]`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration. +- [`init|c [scaffold...] [options]`](./INIT.md#webpack-cli-init) - Create a new webpack configuration. - [`info|i [options]`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment. - [`migrate|m [new-config-path]`](https://www.npmjs.com/package/@webpack-cli/migrate) - Migrate project from one version to another. - [`plugin|p [output-path]`](./packages/generators#generators) - Initiate new plugin project. diff --git a/packages/README.md b/packages/README.md index ea522074275..680f46c8ff0 100644 --- a/packages/README.md +++ b/packages/README.md @@ -16,10 +16,9 @@ This folder is the collection of those packages. 1. [configtest](https://github.com/webpack/webpack-cli/tree/master/packages/configtest) 2. [generators](https://github.com/webpack/webpack-cli/tree/master/packages/generators) 3. [info](https://github.com/webpack/webpack-cli/tree/master/packages/info) -4. [init](https://github.com/webpack/webpack-cli/tree/master/packages/init) -5. [migrate](https://www.npmjs.com/package/@webpack-cli/migrate) -6. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) -7. [webpack-cli](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli) +4. [migrate](https://www.npmjs.com/package/@webpack-cli/migrate) +5. [serve](https://github.com/webpack/webpack-cli/tree/master/packages/serve) +6. [webpack-cli](https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli) ## Generic Installation From 2968b491d8f350dfee618f2645495e1438275f53 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 13 Feb 2021 18:40:26 +0300 Subject: [PATCH 320/581] chore(deps-dev): bump eslint from 7.19.0 to 7.20.0 (#2436) Bumps [eslint](https://github.com/eslint/eslint) from 7.19.0 to 7.20.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.19.0...v7.20.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/yarn.lock b/yarn.lock index d7e27007095..048cbaf4ff9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" - integrity sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== +"@babel/code-frame@7.12.11", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" + integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw== dependencies: "@babel/highlight" "^7.10.4" @@ -4417,11 +4417,11 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.19.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.19.0.tgz#6719621b196b5fad72e43387981314e5d0dc3f41" - integrity sha512-CGlMgJY56JZ9ZSYhJuhow61lMPPjUzWmChFya71Z/jilVos7mR/jPgaEfVGgMBY5DshbKdG8Ezb8FDCHcoMEMg== + version "7.20.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.20.0.tgz#db07c4ca4eda2e2316e7aa57ac7fc91ec550bdc7" + integrity sha512-qGi0CTcOGP2OtCQBgWZlQjcTuP0XkIpYFj25XtRTQSHC+umNnp7UMshr2G8SLsRFYDdAPFeHOsiteadmMH02Yw== dependencies: - "@babel/code-frame" "^7.0.0" + "@babel/code-frame" "7.12.11" "@eslint/eslintrc" "^0.3.0" ajv "^6.10.0" chalk "^4.0.0" @@ -4433,7 +4433,7 @@ eslint@^7.12.1: eslint-utils "^2.1.0" eslint-visitor-keys "^2.0.0" espree "^7.3.1" - esquery "^1.2.0" + esquery "^1.4.0" esutils "^2.0.2" file-entry-cache "^6.0.0" functional-red-black-tree "^1.0.1" @@ -4473,10 +4473,10 @@ esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" - integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== +esquery@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" + integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== dependencies: estraverse "^5.1.0" From 2f9383619f12142ecd99dd3a8ff2eb2c550aea9e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 13 Feb 2021 18:40:42 +0300 Subject: [PATCH 321/581] chore(deps-dev): bump @types/prettier Bumps [@types/prettier](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/prettier) from 2.2.0 to 2.2.1. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/prettier) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 048cbaf4ff9..d78cce28f4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1956,9 +1956,9 @@ integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== "@types/prettier@^2.0.0", "@types/prettier@^2.1.5": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.0.tgz#a4e8205a4955690eef712a6d0394a1d2e121e721" - integrity sha512-O3SQC6+6AySHwrspYn2UvC6tjo6jCTMMmylxZUFhE1CulVu5l3AxU6ca9lrJDTQDVllF62LIxVSx5fuYL6LiZg== + version "2.2.1" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.1.tgz#374e31645d58cb18a07b3ecd8e9dede4deb2cccd" + integrity sha512-DxZZbyMAM9GWEzXL+BMZROWz9oo6A9EilwwOMET2UVu2uZTqMWS5S69KVtuVKaRjCUpcrOXRalet86/OpG4kqw== "@types/responselike@*", "@types/responselike@^1.0.0": version "1.0.0" From 27201fb7a5701b0c8658bcf55b9ae542a4b69632 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 14 Feb 2021 17:45:06 +0300 Subject: [PATCH 322/581] chore(deps-dev): bump @types/node Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.25 to 14.14.27. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index d78cce28f4d..38acf71dd3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1941,9 +1941,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.25" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.25.tgz#15967a7b577ff81383f9b888aa6705d43fbbae93" - integrity sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ== + version "14.14.27" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.27.tgz#c7127f8da0498993e13b1a42faf1303d3110d2f2" + integrity sha512-Ecfmo4YDQPwuqTCl1yBxLV5ihKfRlkBmzUEDcfIRvDxOTGQEeikr317Ln7Gcv0tjA8dVgKI3rniqW2G1OyKDng== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 09bb615eba303dd4a3b371c7e33948532e9f5678 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:06:20 +0300 Subject: [PATCH 323/581] chore(deps): bump commander from 7.0.0 to 7.1.0 (#2440) Bumps [commander](https://github.com/tj/commander.js) from 7.0.0 to 7.1.0. - [Release notes](https://github.com/tj/commander.js/releases) - [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/tj/commander.js/compare/v7.0.0...v7.1.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 38acf71dd3c..cf6a0971a4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3388,9 +3388,9 @@ commander@^6.2.0: integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== commander@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.0.0.tgz#3e2bbfd8bb6724760980988fb5b22b7ee6b71ab2" - integrity sha512-ovx/7NkTrnPuIV8sqk/GjUIIM1+iUQeqA3ye2VNpq9sVoiZsooObWlQy+OPWGI17GDaEoybuAGJm6U8yC077BA== + version "7.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-7.1.0.tgz#f2eaecf131f10e36e07d894698226e36ae0eb5ff" + integrity sha512-pRxBna3MJe6HKnBGsDyMv8ETbptw3axEdYHoqNh7gu5oDcew8fs0xnivZGm06Ogk8zGAJ9VX+OPEr2GXEQK4dg== commitlint@^11.0.0: version "11.0.0" From 358391101f5a463f1c0528b7e132e66d936e1f4a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:11:03 +0300 Subject: [PATCH 324/581] chore(deps-dev): bump @types/node Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.27 to 14.14.28. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index cf6a0971a4b..f1278f110ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1941,9 +1941,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.27" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.27.tgz#c7127f8da0498993e13b1a42faf1303d3110d2f2" - integrity sha512-Ecfmo4YDQPwuqTCl1yBxLV5ihKfRlkBmzUEDcfIRvDxOTGQEeikr317Ln7Gcv0tjA8dVgKI3rniqW2G1OyKDng== + version "14.14.28" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.28.tgz#cade4b64f8438f588951a6b35843ce536853f25b" + integrity sha512-lg55ArB+ZiHHbBBttLpzD07akz0QPrZgUODNakeC09i62dnrywr9mFErHuaPlB6I7z+sEbK+IYmplahvplCj2g== "@types/normalize-package-data@^2.4.0": version "2.4.0" From ff3dcda254216eff182e6d48629c2db8240eabb3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 15 Feb 2021 16:08:33 +0300 Subject: [PATCH 325/581] chore(deps-dev): bump webpack from 5.21.2 to 5.22.0 (#2441) Bumps [webpack](https://github.com/webpack/webpack) from 5.21.2 to 5.22.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.21.2...v5.22.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f1278f110ee..8a1422527ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11075,9 +11075,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.21.1: - version "5.21.2" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.21.2.tgz#647507e50d3637695be28af58a6a8246050394e7" - integrity sha512-xHflCenx+AM4uWKX71SWHhxml5aMXdy2tu/vdi4lClm7PADKxlyDAFFN1rEFzNV0MAoPpHtBeJnl/+K6F4QBPg== + version "5.22.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.22.0.tgz#8505158bc52dcbbdb01ac94796a8aed61badf11a" + integrity sha512-xqlb6r9RUXda/d9iA6P7YRTP1ChWeP50TEESKMMNIg0u8/Rb66zN9YJJO7oYgJTRyFyYi43NVC5feG45FSO1vQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" From 4c786e39f342414948c9620f128f67f8b1e821e2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 15 Feb 2021 21:56:05 +0530 Subject: [PATCH 326/581] test: disable colors on CI by default (#2404) --- setupTest.js | 6 + .../webpack-dev-server.test.js | 2 + smoketests/missing-packages/webpack.test.js | 2 + test/analyze/analyze-flag.test.js | 5 +- test/build-errors/errors.test.js | 3 +- test/build-warnings/warnings.test.js | 3 +- test/build/basic/basic.test.js | 10 +- test/colors/colors.test.js | 18 +- test/config/multiple/multiple-config.test.js | 8 +- test/core-flags/context-flag.test.js | 3 +- test/defaults/output-defaults.test.js | 3 +- .../defaults-empty/entry-single-arg.test.js | 3 +- test/entry/flag-entry/entry-with-flag.test.js | 3 +- test/help/help.test.js | 357 ++++++++---------- test/init/auto/init-auto.test.js | 3 +- test/init/generator/init-inquirer.test.js | 7 +- test/json/json.test.js | 10 +- test/loader/loader.test.js | 11 +- .../mode-single-arg/mode-single-arg.test.js | 8 +- test/plugin/plugin.test.js | 11 +- test/prefetch/prefetch.test.js | 3 +- test/serve/basic/serve-basic.test.js | 5 +- test/serve/help/serve-help.test.js | 43 --- test/stats/watch/stats-and-watch.test.js | 6 +- test/unknown/unknown.test.js | 17 +- test/utils/test-utils.js | 6 +- test/version/version.test.js | 86 ++--- test/watch/basic/basic.test.js | 15 +- .../watch-variable/watch-variable.test.js | 5 +- .../entry-absent/zero-config.test.js | 3 +- 30 files changed, 287 insertions(+), 378 deletions(-) delete mode 100644 test/serve/help/serve-help.test.js diff --git a/setupTest.js b/setupTest.js index 43e2888a655..6234cd7fd26 100644 --- a/setupTest.js +++ b/setupTest.js @@ -1 +1,7 @@ +/*global jasmine*/ + jest.setTimeout(240000); + +if (!jasmine.testPath.includes('colors.test.js')) { + process.env.NO_COLOR = true; +} diff --git a/smoketests/missing-packages/webpack-dev-server.test.js b/smoketests/missing-packages/webpack-dev-server.test.js index b0ae710b83d..b5ec3f57a53 100644 --- a/smoketests/missing-packages/webpack-dev-server.test.js +++ b/smoketests/missing-packages/webpack-dev-server.test.js @@ -1,3 +1,5 @@ +'use strict'; + const path = require('path'); const execa = require('execa'); const { renameSync } = require('fs'); diff --git a/smoketests/missing-packages/webpack.test.js b/smoketests/missing-packages/webpack.test.js index 31a500ae380..0be70358b7f 100644 --- a/smoketests/missing-packages/webpack.test.js +++ b/smoketests/missing-packages/webpack.test.js @@ -1,3 +1,5 @@ +'use strict'; + const path = require('path'); const execa = require('execa'); const { renameSync } = require('fs'); diff --git a/test/analyze/analyze-flag.test.js b/test/analyze/analyze-flag.test.js index 9f86a3dc3c8..972a00223eb 100644 --- a/test/analyze/analyze-flag.test.js +++ b/test/analyze/analyze-flag.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run, runAndGetWatchProc } = require('../utils/test-utils'); describe('--analyze flag', () => { @@ -24,7 +23,7 @@ describe('--analyze flag', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - expect(stripAnsi(stdout)).toContain('Webpack Bundle Analyzer saved report to'); - expect(stripAnsi(stdout).match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); + expect(stdout).toContain('Webpack Bundle Analyzer saved report to'); + expect(stdout.match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); }); }); diff --git a/test/build-errors/errors.test.js b/test/build-errors/errors.test.js index 3147000a8b3..c64b439e2f8 100644 --- a/test/build-errors/errors.test.js +++ b/test/build-errors/errors.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const { readFile } = require('fs'); const { resolve } = require('path'); @@ -12,7 +11,7 @@ describe('errors', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); expect(stdout).toMatch(/ERROR/); - expect(stripAnsi(stdout)).toMatch(/Error: Can't resolve/); + expect(stdout).toMatch(/Error: Can't resolve/); }); it('should output JSON with the "json" flag', () => { diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index c58d9b9fab8..65971088470 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); @@ -12,7 +11,7 @@ describe('warnings', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toMatch(/WARNING/); - expect(stripAnsi(stdout)).toMatch(/Error: Can't resolve/); + expect(stdout).toMatch(/Error: Can't resolve/); }); it('should output JSON with the "json" flag', () => { diff --git a/test/build/basic/basic.test.js b/test/build/basic/basic.test.js index 1b559e77599..11b49da017d 100644 --- a/test/build/basic/basic.test.js +++ b/test/build/basic/basic.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { resolve } = require('path'); const { run } = require('../../utils/test-utils'); @@ -148,12 +147,9 @@ describe('bundle command', () => { const configPath = resolve(__dirname, './log.config.js'); expect(exitCode).toBe(0); - - const pureStderr = stripAnsi(stderr); - - expect(pureStderr).toContain('Compiler starting...'); - expect(pureStderr).toContain(`Compiler is using config: '${configPath}'`); - expect(pureStderr).toContain('Compiler finished'); + expect(stderr).toContain('Compiler starting...'); + expect(stderr).toContain(`Compiler is using config: '${configPath}'`); + expect(stderr).toContain('Compiler finished'); expect(stdout).toBeTruthy(); }); }); diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 8e7348f8480..af302374c93 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -3,7 +3,7 @@ const { run, isWebpack5 } = require('../utils/test-utils'); const { resolve } = require('path'); -describe('colors related tests', () => { +describe('colors', () => { it('should output by default', () => { const { exitCode, stderr, stdout } = run(__dirname, [], { env: { FORCE_COLOR: true } }); @@ -46,23 +46,23 @@ describe('colors related tests', () => { expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); - it('should disable colored output with --no-color', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--no-color']); + it('should work with the "stats" option and --color flags', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); - expect(stdout).toContain(output); + expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); - it('should work with the "stats" option and --color flags', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--color']); + it('should disable colored output with --no-color', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--no-color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; - expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); + expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); + expect(stdout).toContain(output); }); it('should work with the "stats" option from the configuration', () => { @@ -120,7 +120,7 @@ describe('colors related tests', () => { expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); }); - it('should prioratize --no-color over colors in config', () => { + it('should prioritize --no-color over colors in config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-true.webpack.config.js', '--no-color']); expect(exitCode).toBe(0); diff --git a/test/config/multiple/multiple-config.test.js b/test/config/multiple/multiple-config.test.js index feee98f7bda..ea36be69ad9 100644 --- a/test/config/multiple/multiple-config.test.js +++ b/test/config/multiple/multiple-config.test.js @@ -1,16 +1,16 @@ -const stripAnsi = require('strip-ansi'); +'use strict'; const { run } = require('../../utils/test-utils'); describe('Multiple config flag: ', () => { it('spawns multiple compilers for multiple configs', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack1.config.js', '-c', 'webpack2.config.js'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'webpack1.config.js', '--config', 'webpack2.config.js'], false); // Should contain the correct exit code expect(exitCode).toEqual(0); expect(stderr).toBeFalsy(); // Should spawn multiple compilers - expect(stripAnsi(stdout)).toContain('amd:'); - expect(stripAnsi(stdout)).toContain('commonjs:'); + expect(stdout).toContain('amd:'); + expect(stdout).toContain('commonjs:'); }); }); diff --git a/test/core-flags/context-flag.test.js b/test/core-flags/context-flag.test.js index 20b4072f84e..df4050e94a7 100644 --- a/test/core-flags/context-flag.test.js +++ b/test/core-flags/context-flag.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { resolve } = require('path'); const { run, isWindows } = require('../utils/test-utils'); @@ -24,6 +23,6 @@ describe('--context flag', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); - expect(stripAnsi(stdout)).toContain(`Module not found: Error: Can't resolve './src/main.js'`); + expect(stdout).toContain(`Module not found: Error: Can't resolve './src/main.js'`); }); }); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index 910419745a9..70c73359f7b 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { existsSync } = require('fs'); const { resolve } = require('path'); const { run } = require('../utils/test-utils'); @@ -12,7 +11,7 @@ describe('output flag defaults', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); // Should print warning about config fallback - expect(stripAnsi(stdout)).toContain('option has not been set, webpack will fallback to'); + expect(stdout).toContain('option has not been set, webpack will fallback to'); expect(existsSync(resolve(__dirname, './binary/main.js'))).toBeTruthy(); }); diff --git a/test/entry/defaults-empty/entry-single-arg.test.js b/test/entry/defaults-empty/entry-single-arg.test.js index b4d6cf07f86..d6274bf2e8f 100644 --- a/test/entry/defaults-empty/entry-single-arg.test.js +++ b/test/entry/defaults-empty/entry-single-arg.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run } = require('../../utils/test-utils'); describe('single entry flag empty project', () => { @@ -9,6 +8,6 @@ describe('single entry flag empty project', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); - expect(stripAnsi(stdout)).toContain(`not found: Error: Can't resolve`); + expect(stdout).toContain(`not found: Error: Can't resolve`); }); }); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index b2d02f9f3fd..90e465042ad 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run } = require('../../utils/test-utils'); const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); @@ -40,6 +39,6 @@ describe('entry flag', () => { expect(exitCode).toEqual(1); expect(stderr).toBeFalsy(); - expect(stripAnsi(stdout)).toContain("Module not found: Error: Can't resolve"); + expect(stdout).toContain("Module not found: Error: Can't resolve"); }); }); diff --git a/test/help/help.test.js b/test/help/help.test.js index 4f1b703ede1..c99062b81d0 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -1,7 +1,6 @@ 'use strict'; const stripAnsi = require('strip-ansi'); -const { bold, enabled: coloretteEnabled } = require('colorette'); const { run, isWebpack5 } = require('../utils/test-utils'); const helpDefaultHeader = 'The build tool for modern web applications.'; @@ -13,30 +12,28 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('webpack [entries...] [options]'); - expect(pureStdout).toContain('webpack [command] [options]'); - expect(pureStdout).toContain(helpDefaultHeader); - expect(pureStdout).toContain('Options:'); - expect(pureStdout).toContain('--merge'); // minimum - expect(pureStdout).not.toContain('--cache-type'); // verbose - expect(pureStdout).toContain('Global options:'); - expect(pureStdout).toContain('Commands:'); - expect(pureStdout.match(/build\|bundle\|b/g)).toHaveLength(1); - expect(pureStdout.match(/watch\|w/g)).toHaveLength(1); - expect(pureStdout.match(/version\|v/g)).toHaveLength(1); - expect(pureStdout.match(/help\|h/g)).toHaveLength(1); - expect(pureStdout.match(/serve\|s/g)).toHaveLength(1); - expect(pureStdout.match(/info\|i/g)).toHaveLength(1); - expect(pureStdout.match(/init\|c/g)).toHaveLength(1); - expect(pureStdout.match(/loader\|l/g)).toHaveLength(1); - expect(pureStdout.match(/plugin\|p/g)).toHaveLength(1); - expect(pureStdout.match(/migrate\|m/g)).toHaveLength(1); - expect(pureStdout.match(/configtest\|t/g)).toHaveLength(1); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(pureStdout).toContain('Made with ♥ by the webpack team.'); + expect(stdout).toContain('webpack [entries...] [options]'); + expect(stdout).toContain('webpack [command] [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout.match(/build\|bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/watch\|w/g)).toHaveLength(1); + expect(stdout.match(/version\|v/g)).toHaveLength(1); + expect(stdout.match(/help\|h/g)).toHaveLength(1); + expect(stdout.match(/serve\|s/g)).toHaveLength(1); + expect(stdout.match(/info\|i/g)).toHaveLength(1); + expect(stdout.match(/init\|c/g)).toHaveLength(1); + expect(stdout.match(/loader\|l/g)).toHaveLength(1); + expect(stdout.match(/plugin\|p/g)).toHaveLength(1); + expect(stdout.match(/migrate\|m/g)).toHaveLength(1); + expect(stdout.match(/configtest\|t/g)).toHaveLength(1); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it.skip('should show help information using the "--help" option with the "verbose" value', () => { @@ -44,34 +41,31 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('webpack [entries...] [options]'); - expect(pureStdout).toContain('webpack [command] [options]'); - expect(pureStdout).toContain(helpDefaultHeader); - expect(pureStdout).toContain('Options:'); - expect(pureStdout).toContain('--merge'); // minimum + expect(stdout).toContain('webpack [entries...] [options]'); + expect(stdout).toContain('webpack [command] [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum if (isWebpack5) { - expect(pureStdout).toContain('--cache-type'); // verbose + expect(stdout).toContain('--cache-type'); // verbose } - expect(pureStdout).toContain('Global options:'); - expect(pureStdout).toContain('Commands:'); - expect(pureStdout.match(/build\|bundle\|b/g)).toHaveLength(1); - expect(pureStdout.match(/watch\|w/g)).toHaveLength(1); - expect(pureStdout.match(/version\|v/g)).toHaveLength(1); - expect(pureStdout.match(/help\|h/g)).toHaveLength(1); - expect(pureStdout.match(/serve\|s/g)).toHaveLength(1); - expect(pureStdout.match(/info\|i/g)).toHaveLength(1); - expect(pureStdout.match(/init\|c/g)).toHaveLength(1); - expect(pureStdout.match(/loader\|l/g)).toHaveLength(1); - expect(pureStdout.match(/plugin\|p/g)).toHaveLength(1); - expect(pureStdout.match(/migrate\|m/g)).toHaveLength(1); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(pureStdout).toContain('Made with ♥ by the webpack team.'); + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout.match(/build\|bundle\|b/g)).toHaveLength(1); + expect(stdout.match(/watch\|w/g)).toHaveLength(1); + expect(stdout.match(/version\|v/g)).toHaveLength(1); + expect(stdout.match(/help\|h/g)).toHaveLength(1); + expect(stdout.match(/serve\|s/g)).toHaveLength(1); + expect(stdout.match(/info\|i/g)).toHaveLength(1); + expect(stdout.match(/init\|c/g)).toHaveLength(1); + expect(stdout.match(/loader\|l/g)).toHaveLength(1); + expect(stdout.match(/plugin\|p/g)).toHaveLength(1); + expect(stdout.match(/migrate\|m/g)).toHaveLength(1); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it.skip('should show help information using the "--help" option with the "verbose" value #2', () => { @@ -79,24 +73,21 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('webpack [entries...] [options]'); - expect(pureStdout).toContain('webpack [command] [options]'); - expect(pureStdout).toContain(helpDefaultHeader); - expect(pureStdout).toContain('Options:'); - expect(pureStdout).toContain('--merge'); // minimum + expect(stdout).toContain('webpack [entries...] [options]'); + expect(stdout).toContain('webpack [command] [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum if (isWebpack5) { - expect(pureStdout).toContain('--cache-type'); // verbose + expect(stdout).toContain('--cache-type'); // verbose } - expect(pureStdout).toContain('Global options:'); - expect(pureStdout).toContain('Commands:'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using command syntax', () => { @@ -104,21 +95,17 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('webpack [entries...] [options]'); - expect(pureStdout).toContain('webpack [command] [options]'); - expect(pureStdout).toContain(helpDefaultHeader); - expect(pureStdout).toContain('Options:'); - expect(pureStdout).toContain('--merge'); // minimum - expect(pureStdout).not.toContain('--cache-type'); // verbose - expect(pureStdout).toContain('Global options:'); - expect(pureStdout).toContain('Commands:'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - // TODO buggy on windows - // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + expect(stdout).toContain('webpack [entries...] [options]'); + expect(stdout).toContain('webpack [command] [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show the same information using the "--help" option and command syntax', () => { @@ -135,10 +122,11 @@ describe('help', () => { }); it('should show help information and respect the "--color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + expect(stdout).toContain('\x1b[1m'); const pureStdout = stripAnsi(stdout); @@ -152,30 +140,26 @@ describe('help', () => { expect(pureStdout).toContain('Commands:'); expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(pureStdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); + expect(pureStdout).toContain('Made with ♥ by the webpack team'); }); it('should show help information and respect the "--no-color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--no-color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--help', '--no-color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('webpack [entries...] [options]'); - expect(pureStdout).toContain('webpack [command] [options]'); - expect(pureStdout).toContain(helpDefaultHeader); - expect(pureStdout).toContain('Options:'); - expect(pureStdout).toContain('--merge'); // minimum - expect(pureStdout).not.toContain('--cache-type'); // verbose - expect(pureStdout).toContain('Global options:'); - expect(pureStdout).toContain('Commands:'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - // TODO bug in tests - // expect(stdout).not.toContain(bold('Made with ♥ by the webpack team')); - expect(pureStdout).toContain('Made with ♥ by the webpack team'); + expect(stdout).not.toContain('\x1b[1m'); + expect(stdout).toContain('webpack [entries...] [options]'); + expect(stdout).toContain('webpack [command] [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team'); }); const commands = [ @@ -209,6 +193,14 @@ describe('help', () => { expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); }); + it(`should show help information for '${command}' command using the "--help verbose" option`, () => { + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', 'verbose']); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); + }); + it(`should show help information for '${command}' command using command syntax`, () => { const { exitCode, stderr, stdout } = run(__dirname, ['help', command]); @@ -218,22 +210,22 @@ describe('help', () => { }); it('should show help information and respect the "--color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + expect(stdout).toContain('\x1b[1m'); expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); - expect(stdout).toContain(coloretteEnabled ? bold('Made with ♥ by the webpack team') : 'Made with ♥ by the webpack team'); + expect(stdout).toContain('Made with ♥ by the webpack team'); }); it('should show help information and respect the "--no-color" flag using the "--help" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--no-color']); + const { exitCode, stderr, stdout } = run(__dirname, [command, '--help', '--no-color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + expect(stdout).not.toContain('\x1b[1m'); expect(stdout).toContain(`webpack ${command === 'build' || command === 'bundle' || command === 'b' ? '' : command}`); - // TODO bug in tests - // expect(stdout).not.toContain(bold('Made with ♥ by the webpack team')); expect(stdout).toContain('Made with ♥ by the webpack team'); }); }); @@ -243,15 +235,12 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('webpack info|i [options]'); - expect(pureStdout).toContain('Options:'); - expect(pureStdout).toContain('--output '); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - expect(pureStdout).toContain('Made with ♥ by the webpack team'); + expect(stdout).toContain('webpack info|i [options]'); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--output '); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team'); }); it('should show help information and taking precedence when "--help" and "--version" option using together', () => { @@ -259,21 +248,17 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('webpack [entries...] [options]'); - expect(pureStdout).toContain('webpack [command] [options]'); - expect(pureStdout).toContain(helpDefaultHeader); - expect(pureStdout).toContain('Options:'); - expect(pureStdout).toContain('--merge'); // minimum - expect(pureStdout).not.toContain('--cache-type'); // verbose - expect(pureStdout).toContain('Global options:'); - expect(pureStdout).toContain('Commands:'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); - // TODO buggy on windows - // expect(coloretteEnabled ? stripAnsi(stdout) : stdout).toContain('Made with ♥ by the webpack team.'); + expect(stdout).toContain('webpack [entries...] [options]'); + expect(stdout).toContain('webpack [command] [options]'); + expect(stdout).toContain(helpDefaultHeader); + expect(stdout).toContain('Options:'); + expect(stdout).toContain('--merge'); // minimum + expect(stdout).not.toContain('--cache-type'); // verbose + expect(stdout).toContain('Global options:'); + expect(stdout).toContain('Commands:'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help --mode" option', () => { @@ -281,13 +266,11 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack --mode '); - expect(pureStdout).toContain('Description: Defines the mode to pass to webpack.'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Usage: webpack --mode '); + expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help --target" option', () => { @@ -296,19 +279,18 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - const pureStdout = stripAnsi(stdout); - if (isWebpack5) { - expect(pureStdout).toContain('Usage: webpack --target '); - expect(pureStdout).toContain('Short: webpack -t '); + expect(stdout).toContain('Usage: webpack --target '); + expect(stdout).toContain('Short: webpack -t '); } else { - expect(pureStdout).toContain('Usage: webpack --target '); - expect(pureStdout).toContain('Short: webpack -t '); + expect(stdout).toContain('Usage: webpack --target '); + expect(stdout).toContain('Short: webpack -t '); } - expect(pureStdout).toContain('Description: Sets the build target e.g. node.'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Description: Sets the build target e.g. node.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help --stats" option', () => { @@ -316,13 +298,11 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack --stats [value]'); - expect(pureStdout).toContain('Description: It instructs webpack on how to treat the stats e.g. verbose.'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Usage: webpack --stats [value]'); + expect(stdout).toContain('Description: It instructs webpack on how to treat the stats e.g. verbose.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help --no-stats" option', () => { @@ -330,13 +310,11 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack --no-stats'); - expect(pureStdout).toContain('Description: Disable stats output.'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Usage: webpack --no-stats'); + expect(stdout).toContain('Description: Disable stats output.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help --mode" option', () => { @@ -344,13 +322,11 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack --mode '); - expect(pureStdout).toContain('Description: Defines the mode to pass to webpack.'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Usage: webpack --mode '); + expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help serve --mode" option', () => { @@ -358,20 +334,19 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack serve --mode '); - expect(pureStdout).toContain('Description: Defines the mode to pass to webpack.'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Usage: webpack serve --mode '); + expect(stdout).toContain('Description: Defines the mode to pass to webpack.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('Made with ♥ by the webpack team.'); }); it('should show help information using the "help --color" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + expect(stdout).toContain('\x1b[1m'); const pureStdout = stripAnsi(stdout); @@ -382,24 +357,23 @@ describe('help', () => { }); it('should show help information using the "help --no-color" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-color']); + const { exitCode, stderr, stdout } = run(__dirname, ['help', '--no-color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack --no-color'); - expect(pureStdout).toContain('Description: Disable colors on console.'); - expect(pureStdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).not.toContain('\x1b[1m'); + expect(stdout).toContain('Usage: webpack --no-color'); + expect(stdout).toContain('Description: Disable colors on console.'); + expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help serve --color" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['help', 'serve', '--color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + expect(stdout).toContain('\x1b[1m'); const pureStdout = stripAnsi(stdout); @@ -414,6 +388,7 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); + expect(stdout).not.toContain('\x1b[1m'); expect(stdout).toContain('Usage: webpack serve --no-color'); expect(stdout).toContain('Description: Disable colors on console.'); expect(stdout).toContain("To see list of all supported commands and options run 'webpack --help=verbose'."); @@ -425,15 +400,12 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack --version'); - expect(pureStdout).toContain('Short: webpack -v'); - expect(pureStdout).toContain( + expect(stdout).toContain('Usage: webpack --version'); + expect(stdout).toContain('Short: webpack -v'); + expect(stdout).toContain( "Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", ); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should show help information using the "help -v" option', () => { @@ -441,15 +413,12 @@ describe('help', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).toContain('Usage: webpack --version'); - expect(pureStdout).toContain('Short: webpack -v'); - expect(pureStdout).toContain( + expect(stdout).toContain('Usage: webpack --version'); + expect(stdout).toContain('Short: webpack -v'); + expect(stdout).toContain( "Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", ); - expect(pureStdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); + expect(stdout).toContain('CLI documentation: https://webpack.js.org/api/cli/.'); }); it('should log error for invalid command using the "--help" option', () => { diff --git a/test/init/auto/init-auto.test.js b/test/init/auto/init-auto.test.js index c29df7cf5c1..a5e15e8912f 100644 --- a/test/init/auto/init-auto.test.js +++ b/test/init/auto/init-auto.test.js @@ -1,4 +1,3 @@ -const { green } = require('colorette'); const fs = require('fs'); const path = require('path'); const rimraf = require('rimraf'); @@ -8,7 +7,7 @@ const { run } = require('../../utils/test-utils'); const genPath = path.resolve(__dirname, './test-assets'); const firstPrompt = 'Will your application have multiple bundles?'; -const successLog = `You can now run ${green('yarn build')} to bundle your application!`; +const successLog = `You can now run 'yarn build' to bundle your application!`; describe('init auto flag', () => { beforeAll(() => { diff --git a/test/init/generator/init-inquirer.test.js b/test/init/generator/init-inquirer.test.js index 677535adf9f..2d4932530e0 100644 --- a/test/init/generator/init-inquirer.test.js +++ b/test/init/generator/init-inquirer.test.js @@ -1,6 +1,5 @@ 'use strict'; -const { green } = require('colorette'); const fs = require('fs'); const { join, resolve } = require('path'); const rimraf = require('rimraf'); @@ -10,7 +9,7 @@ const firstPrompt = 'Will your application have multiple bundles?'; const ENTER = '\x0D'; const genPath = join(__dirname, 'test-assets'); -const successLog = `You can now run ${green('yarn build')} to bundle your application!`; +const successLog = `You can now run 'yarn build' to bundle your application!`; describe('init', () => { beforeAll(() => { @@ -47,8 +46,8 @@ describe('init', () => { expect(pkgJson['devDependencies']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack']).toBeTruthy(); expect(pkgJson['devDependencies']['webpack-dev-server']).toBeTruthy(); - expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy(); - expect(pkgJson['scripts']['serve'] == 'webpack serve').toBeTruthy(); + expect(pkgJson['scripts']['build'] === 'webpack').toBeTruthy(); + expect(pkgJson['scripts']['serve'] === 'webpack serve').toBeTruthy(); }; expect(pkgJsonTests).not.toThrow(); diff --git a/test/json/json.test.js b/test/json/json.test.js index 49022409705..0efe8ecb27c 100644 --- a/test/json/json.test.js +++ b/test/json/json.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const { existsSync, readFile } = require('fs'); const { resolve } = require('path'); @@ -36,7 +35,7 @@ describe('json', () => { }); it('should work and store json to a file and respect --color flag', (done) => { - const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toContain(`\u001b[32m${successMessage}`); @@ -123,12 +122,9 @@ describe('json', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json', '--config', 'logging.config.js']); expect(exitCode).toBe(0); - - const pureStderr = stripAnsi(stderr); - expect(stderr).toContain('Compiler starting...'); - expect(pureStderr).toContain('Compiler finished'); - expect(pureStderr).toContain(successMessage); + expect(stderr).toContain('Compiler finished'); + expect(stderr).toContain(successMessage); expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); diff --git a/test/loader/loader.test.js b/test/loader/loader.test.js index 6ee115a8853..a1e7db13b04 100644 --- a/test/loader/loader.test.js +++ b/test/loader/loader.test.js @@ -3,7 +3,6 @@ const { existsSync, mkdirSync } = require('fs'); const { join, resolve } = require('path'); const rimraf = require('rimraf'); -const stripAnsi = require('strip-ansi'); const { run, runPromptWithAnswers } = require('../utils/test-utils'); const firstPrompt = '? Loader name (my-loader)'; @@ -25,13 +24,13 @@ describe('loader command', () => { const { stdout, stderr } = run(__dirname, ['loader'], false); expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); }); it('should scaffold loader with default name if no loader name provided', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['loader'], [`${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Skip test in case installation fails if (!existsSync(resolve(defaultLoaderPath, './yarn.lock'))) { @@ -57,7 +56,7 @@ describe('loader command', () => { it('should scaffold loader template with a given name', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['loader'], [`${loaderName}${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Skip test in case installation fails if (!existsSync(resolve(loaderPath, './yarn.lock'))) { @@ -83,7 +82,7 @@ describe('loader command', () => { it('should scaffold loader template in the specified path', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['loader', 'test-assets'], [`${loaderName}${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Skip test in case installation fails if (!existsSync(resolve(customLoaderPath, './yarn.lock'))) { @@ -112,7 +111,7 @@ describe('loader command', () => { let { stdout } = await runPromptWithAnswers(genPath, ['loader', './'], [`${loaderName}${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Skip test in case installation fails if (!existsSync(resolve(customLoaderPath, './yarn.lock'))) { diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 3d18ddb14e6..7816271878f 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run, isWebpack5 } = require('../../utils/test-utils'); describe('mode flags', () => { @@ -9,11 +8,8 @@ describe('mode flags', () => { expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); - - const pureStdout = stripAnsi(stdout); - - expect(pureStdout).not.toContain(`mode: 'production'`); - expect(pureStdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); + expect(stdout).not.toContain(`mode: 'production'`); + expect(stdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); }); it('should load a development config when --mode=development is passed', () => { diff --git a/test/plugin/plugin.test.js b/test/plugin/plugin.test.js index bad234e7a83..dc900238ae1 100644 --- a/test/plugin/plugin.test.js +++ b/test/plugin/plugin.test.js @@ -1,7 +1,6 @@ const { existsSync, mkdirSync } = require('fs'); const { join, resolve } = require('path'); const rimraf = require('rimraf'); -const stripAnsi = require('strip-ansi'); const { run, runPromptWithAnswers } = require('../utils/test-utils'); const ENTER = '\x0D'; @@ -25,13 +24,13 @@ describe('plugin command', () => { const { stdout, stderr } = run(__dirname, ['plugin'], false); expect(stdout).toBeTruthy(); expect(stderr).toBeFalsy(); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); }); it('should scaffold plugin with default name if no plugin name provided', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['plugin'], [`${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Check if the output directory exists with the appropriate plugin name expect(existsSync(defaultPluginPath)).toBeTruthy(); @@ -56,7 +55,7 @@ describe('plugin command', () => { it('should scaffold plugin template with a given name', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['plugin'], [`${pluginName}${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Check if the output directory exists with the appropriate plugin name expect(existsSync(pluginPath)).toBeTruthy(); @@ -81,7 +80,7 @@ describe('plugin command', () => { it('should scaffold plugin template in the specified path', async () => { let { stdout } = await runPromptWithAnswers(__dirname, ['plugin', 'test-assets'], [`${pluginName}${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Check if the output directory exists with the appropriate plugin name expect(existsSync(customPluginPath)).toBeTruthy(); @@ -109,7 +108,7 @@ describe('plugin command', () => { let { stdout } = await runPromptWithAnswers(genPath, ['plugin', './'], [`${pluginName}${ENTER}`]); - expect(stripAnsi(stdout)).toContain(firstPrompt); + expect(stdout).toContain(firstPrompt); // Check if the output directory exists with the appropriate plugin name expect(existsSync(customPluginPath)).toBeTruthy(); diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index cf7c60fe638..010b04769da 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -2,7 +2,6 @@ const fs = require('fs'); const { join } = require('path'); -const stripAnsi = require('strip-ansi'); const { run } = require('../utils/test-utils'); const rimraf = require('rimraf'); @@ -29,7 +28,7 @@ describe('prefetch', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); // Should contain the error message - expect(stripAnsi(stdout)).toContain(`Error: Can't resolve './src/somefile.js'`); + expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); }); it('should log error when flag value is not supplied', () => { diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index e5b1335bb60..cf508855b3d 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const path = require('path'); const getPort = require('get-port'); const { runServe, isWebpack5, isDevServer4 } = require('../../utils/test-utils'); @@ -112,7 +111,7 @@ describe('basic serve usage', () => { const { stderr, stdout } = await runServe(__dirname, ['--stats']); expect(stderr).toBeFalsy(); - expect(stripAnsi(stdout)).toContain(isWebpack5 ? 'compiled successfully' : 'Version: webpack'); + expect(stdout).toContain(isWebpack5 ? 'compiled successfully' : 'Version: webpack'); expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); @@ -219,7 +218,7 @@ describe('basic serve usage', () => { expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stripAnsi(stdout)).toContain('from /'); + expect(stdout).toContain('from /'); expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); diff --git a/test/serve/help/serve-help.test.js b/test/serve/help/serve-help.test.js deleted file mode 100644 index eb8cabef807..00000000000 --- a/test/serve/help/serve-help.test.js +++ /dev/null @@ -1,43 +0,0 @@ -const { runServe, isWebpack5 } = require('../../utils/test-utils'); - -const usageText = 'webpack serve|s [entries...] [options]'; -const descriptionText = 'Run the webpack dev server'; - -describe('serve help', () => { - it('should log help information', async () => { - const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help']); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); - expect(stdout).toContain(descriptionText); - expect(stdout).toContain(usageText); - expect(stdout).toContain('Global options:'); - expect(stdout).toContain('Options:'); - // Serve flags are rendered - expect(stdout).toContain('--liveReload'); - expect(stdout).toContain('--https'); - expect(stdout).toContain('--open [value]'); - }); - - it('should log help information using "verbose"', async () => { - const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help', 'verbose']); - - expect(stderr).toBeFalsy(); - expect(exitCode).toBe(0); - expect(stdout).toContain(descriptionText); - expect(stdout).toContain(usageText); - expect(stdout).toContain('Options:'); - - if (isWebpack5) { - expect(stdout).toContain('--cache-type'); - } - }); - - it('should log help information and respect the "--no-color" option', async () => { - const { stdout, stderr } = await runServe(__dirname, ['--help', '--no-color']); - - expect(stderr).toBeFalsy(); - expect(stdout).toContain(usageText); - expect(stdout).toContain(descriptionText); - }); -}); diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js index e180b31741e..278c69a4a62 100644 --- a/test/stats/watch/stats-and-watch.test.js +++ b/test/stats/watch/stats-and-watch.test.js @@ -4,21 +4,21 @@ const { runWatch } = require('../../utils/test-utils'); describe('stats and watch', () => { it('should not log stats with the "none" value from the configuration', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js'], true); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should not log stats with the "none" value from the configuration and multi compiler mode', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js'], true); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should log stats with the "normal" value in arguments', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal'], true); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); diff --git a/test/unknown/unknown.test.js b/test/unknown/unknown.test.js index c87fbd5bcd2..80b10c6b163 100644 --- a/test/unknown/unknown.test.js +++ b/test/unknown/unknown.test.js @@ -1,4 +1,5 @@ -const stripAnsi = require('strip-ansi'); +'use strict'; + const { run, isWebpack5 } = require('../utils/test-utils'); describe('unknown behaviour', () => { @@ -102,7 +103,7 @@ describe('unknown behaviour', () => { }); it('should log error and respect --color flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(2); expect(stderr).toContain("Error: Unknown option '--unknown'"); @@ -111,7 +112,7 @@ describe('unknown behaviour', () => { }); it('should log error for unknown flag and respect --no-color', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--no-color']); + const { exitCode, stderr, stdout } = run(__dirname, ['--unknown', '--no-color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(2); expect(stderr).not.toContain(`\u001b[31mError: Unknown option '--unknown'`); @@ -203,8 +204,8 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['qqq'], true, [], { TERM_PROGRAM: false }); expect(exitCode).toBe(2); - expect(stripAnsi(stderr)).toContain("Unknown command or entry 'qqq'"); - expect(stripAnsi(stderr)).toContain("Run 'webpack --help' to see available commands and options"); + expect(stderr).toContain("Unknown command or entry 'qqq'"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); @@ -212,9 +213,9 @@ describe('unknown behaviour', () => { const { exitCode, stderr, stdout } = run(__dirname, ['server'], true, [], { TERM_PROGRAM: false }); expect(exitCode).toBe(2); - expect(stripAnsi(stderr)).toContain("Unknown command or entry 'server'"); - expect(stripAnsi(stderr)).toContain("Did you mean 'serve' (alias 's')?"); - expect(stripAnsi(stderr)).toContain("Run 'webpack --help' to see available commands and options"); + expect(stderr).toContain("Unknown command or entry 'server'"); + expect(stderr).toContain("Did you mean 'serve' (alias 's')?"); + expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); }); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index f78f155d558..9d036a9a086 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -7,7 +7,6 @@ const { sync: spawnSync, node: execaNode } = execa; const { Writable } = require('readable-stream'); const concat = require('concat-stream'); const { version } = require('webpack'); -const stripAnsi = require('strip-ansi'); const isWebpack5 = version.startsWith('5'); @@ -59,7 +58,7 @@ const run = (testCase, args = [], options = {}) => { return result; }; -const runWatch = (testCase, args = [], setOutput = true, outputKillStr = /webpack \d+\.\d+\.\d/) => { +const runWatch = (testCase, args = [], setOutput = true, outputKillStr = /webpack \d+\.\d+\.\d/, options = {}) => { const cwd = path.resolve(testCase); const outputPath = path.resolve(testCase, 'bin'); @@ -70,12 +69,13 @@ const runWatch = (testCase, args = [], setOutput = true, outputKillStr = /webpac cwd, reject: false, stdio: 'pipe', + ...options, }); proc.stdout.pipe( new Writable({ write(chunk, encoding, callback) { - const output = stripAnsi(chunk.toString('utf8')); + const output = chunk.toString('utf8'); if (outputKillStr.test(output)) { if (isWindows) { diff --git a/test/version/version.test.js b/test/version/version.test.js index b0c7df26b81..36be704bd27 100644 --- a/test/version/version.test.js +++ b/test/version/version.test.js @@ -11,7 +11,7 @@ const webpackDevServerPkgJSON = require('webpack-dev-server/package.json'); describe('single version flag', () => { it('outputs versions with command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -21,7 +21,7 @@ describe('single version flag', () => { }); it('outputs versions with dashed syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -31,7 +31,7 @@ describe('single version flag', () => { }); it('outputs versions with alias syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-v'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-v']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -41,7 +41,7 @@ describe('single version flag', () => { }); it('outputs version with info', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['info', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -52,7 +52,7 @@ describe('single version flag', () => { }); it('outputs version with info using option alias', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['info', '-v'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['info', '-v']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -63,7 +63,7 @@ describe('single version flag', () => { }); it('outputs version with info using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -74,7 +74,7 @@ describe('single version flag', () => { }); it('outputs version with info using command alias', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['v', 'info'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['v', 'info']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -85,7 +85,7 @@ describe('single version flag', () => { }); it('outputs version with build', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['build', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['build', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -95,7 +95,7 @@ describe('single version flag', () => { }); it('outputs version with bundle', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -105,7 +105,7 @@ describe('single version flag', () => { }); it('outputs version with b', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['b', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['b', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -115,7 +115,7 @@ describe('single version flag', () => { }); it('outputs version with watch', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['watch', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['watch', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -125,7 +125,7 @@ describe('single version flag', () => { }); it('outputs version with w', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['w', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['w', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -135,7 +135,7 @@ describe('single version flag', () => { }); it('outputs version with plugin', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -146,7 +146,7 @@ describe('single version flag', () => { }); it('outputs version with loader', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['loader', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['loader', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -157,7 +157,7 @@ describe('single version flag', () => { }); it('outputs version with init', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['init', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['init', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -168,7 +168,7 @@ describe('single version flag', () => { }); it('outputs version with serve', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -179,7 +179,7 @@ describe('single version flag', () => { }); it('outputs version with migrate', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain(`webpack-cli ${pkgJSON.version}`); @@ -189,7 +189,7 @@ describe('single version flag', () => { }); it('outputs version with the alias c for init', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['c', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['c', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -200,7 +200,7 @@ describe('single version flag', () => { }); it('should log error when unknown command using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'unknown'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'unknown']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'unknown'"); @@ -209,7 +209,7 @@ describe('single version flag', () => { }); it('should log version for known command and log error for unknown command using command syntax with multi commands', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'unknown'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'unknown']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'unknown'"); @@ -218,7 +218,7 @@ describe('single version flag', () => { }); it('should work for multiple commands', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['info', 'serve', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['info', 'serve', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -230,7 +230,7 @@ describe('single version flag', () => { }); it('should output versions for multiple commands using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'serve'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'serve']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -242,7 +242,7 @@ describe('single version flag', () => { }); it('should output versions with help command using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'help']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -252,7 +252,7 @@ describe('single version flag', () => { }); it('should log version for known command and log error for unknown command using the "--version" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'abc', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'abc', '--version']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); @@ -261,7 +261,7 @@ describe('single version flag', () => { }); it('should log version for known command and log error for unknown command using the "-v" option', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'abc', '-v'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['serve', 'abc', '-v']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); @@ -270,15 +270,15 @@ describe('single version flag', () => { }); it('should not output version with help dashed', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--help'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--help']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toContain('webpack version|v [commands...]'); }); - it('outputs versions with --color using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--color'], false); + it('outputs versions with --color using option syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -287,8 +287,8 @@ describe('single version flag', () => { expect(stdout).toContain(`webpack-dev-server ${webpackDevServerPkgJSON.version}`); }); - it('outputs versions with --no-color using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--no-color'], false); + it('outputs versions with --no-color using option syntax', () => { + const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--no-color'], { env: { FORCE_COLOR: true } }); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -298,7 +298,7 @@ describe('single version flag', () => { }); it('outputs versions with --color using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -308,7 +308,7 @@ describe('single version flag', () => { }); it('outputs versions with --no-color using command syntax', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--no-color'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--no-color']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -318,7 +318,7 @@ describe('single version flag', () => { }); it('should log error when unknown command used', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'abc'], false, []); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'abc']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); @@ -327,7 +327,7 @@ describe('single version flag', () => { }); it('throws error if invalid option is passed with version command', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--abc'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--abc']); expect(exitCode).toBe(2); expect(stderr).toContain(`Unknown option '--abc`); @@ -336,7 +336,7 @@ describe('single version flag', () => { }); it('should log error when unknown command used with --version flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version', 'abc'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--version', 'abc']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); @@ -345,7 +345,7 @@ describe('single version flag', () => { }); it('throws error if invalid option is passed with --version flag', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--abc'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--abc']); expect(exitCode).toBe(2); expect(stderr).toContain(`Unknown option '--abc'`); @@ -354,7 +354,7 @@ describe('single version flag', () => { }); it('should log error when unknown command used with -v alias', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-v', 'abc'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-v', 'abc']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown command 'abc'"); @@ -363,7 +363,7 @@ describe('single version flag', () => { }); it('throws error if invalid option is passed with -v alias', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['-v', '--abc'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['-v', '--abc']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown option '--abc'"); @@ -372,7 +372,7 @@ describe('single version flag', () => { }); it('should work using command syntax with the "version" value', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -382,7 +382,7 @@ describe('single version flag', () => { }); it('should work using command syntax and the "--version" argument', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--version'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--version']); expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); @@ -392,7 +392,7 @@ describe('single version flag', () => { }); it('should log an error using command syntax with unknown argument', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', '--unknown'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', '--unknown']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown option '--unknown'"); @@ -401,7 +401,7 @@ describe('single version flag', () => { }); it('should log an error using command syntax with unknown argument #2', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', '--unknown'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', '--unknown']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown option '--unknown'"); @@ -410,7 +410,7 @@ describe('single version flag', () => { }); it('should log an error using command syntax with multiple commands with unknown argument', () => { - const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'serve', '--unknown'], false); + const { exitCode, stderr, stdout } = run(__dirname, ['version', 'info', 'serve', '--unknown']); expect(exitCode).toBe(2); expect(stderr).toContain("Unknown option '--unknown'"); diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js index bced22c1988..7fc2921e1af 100644 --- a/test/watch/basic/basic.test.js +++ b/test/watch/basic/basic.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run, runAndGetWatchProc, isWebpack5 } = require('../../utils/test-utils'); const { writeFileSync } = require('fs'); const { resolve } = require('path'); @@ -23,7 +22,7 @@ describe('basic', () => { let modified = false; proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); if (data.includes('index.js')) { if (isWebpack5) { @@ -56,7 +55,7 @@ describe('basic', () => { let modified = false; proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); if (data.includes('index.js')) { if (isWebpack5) { @@ -91,7 +90,7 @@ describe('basic', () => { const wordsInStatsv5Entries = ['asset', 'entry.js', 'compiled successfully']; proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); if (data.includes('entry.js')) { if (isWebpack5) { @@ -124,7 +123,7 @@ describe('basic', () => { let modified = false; proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); if (data.includes('index.js')) { if (isWebpack5) { @@ -151,7 +150,7 @@ describe('basic', () => { }); proc.stderr.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); expect(data).toContain( "No need to use the 'watch' command together with '{ watch: true }' configuration, it does not make sense.", @@ -166,9 +165,9 @@ describe('basic', () => { let stderr = ''; proc.stderr.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); - stderr += stripAnsi(data); + stderr += data; if (/Compiler finished/.test(data)) { expect(stderr).toContain('Compiler starting...'); diff --git a/test/watch/watch-variable/watch-variable.test.js b/test/watch/watch-variable/watch-variable.test.js index 0f5cc994ed6..0ab866c9997 100644 --- a/test/watch/watch-variable/watch-variable.test.js +++ b/test/watch/watch-variable/watch-variable.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { runAndGetWatchProc, isWebpack5 } = require('../../utils/test-utils'); const { writeFileSync } = require('fs'); const { resolve } = require('path'); @@ -15,7 +14,7 @@ describe('watch variable', () => { let modified = false; proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); expect(data).not.toContain('FAIL'); @@ -50,7 +49,7 @@ describe('watch variable', () => { let modified = false; proc.stdout.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); + const data = chunk.toString(); expect(data).not.toContain('FAIL'); diff --git a/test/zero-config/entry-absent/zero-config.test.js b/test/zero-config/entry-absent/zero-config.test.js index 0ebba445d1a..3309c19683e 100644 --- a/test/zero-config/entry-absent/zero-config.test.js +++ b/test/zero-config/entry-absent/zero-config.test.js @@ -1,6 +1,5 @@ 'use strict'; -const stripAnsi = require('strip-ansi'); const { run } = require('../../utils/test-utils'); describe('Zero Config tests', () => { @@ -10,6 +9,6 @@ describe('Zero Config tests', () => { expect(exitCode).toBe(1); expect(stderr).toBeFalsy(); // Entry file is absent, should log the Error from the compiler - expect(stripAnsi(stdout)).toContain("Error: Can't resolve './src'"); + expect(stdout).toContain("Error: Can't resolve './src'"); }); }); From 139695afa4160ce49e9847e677d247455db9ba2c Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 17 Feb 2021 15:00:34 +0300 Subject: [PATCH 327/581] test: refactor --- test/bail/bail.test.js | 2 +- test/serve/basic/serve-basic.test.js | 76 ++++++++++--------- test/serve/serve-variable/serve-basic.test.js | 4 +- .../serve-custom-config.test.js | 10 +-- test/stats/watch/stats-and-watch.test.js | 6 +- test/utils/test-utils.js | 26 ++++--- 6 files changed, 67 insertions(+), 57 deletions(-) diff --git a/test/bail/bail.test.js b/test/bail/bail.test.js index 51f0121fc40..af801b197fd 100644 --- a/test/bail/bail.test.js +++ b/test/bail/bail.test.js @@ -55,7 +55,7 @@ describe('bail and watch warning', () => { }); it('should log warning in case of multiple compilers', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js'], true); + const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js']); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index cf508855b3d..8eb1f8e6afd 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -2,7 +2,7 @@ const path = require('path'); const getPort = require('get-port'); -const { runServe, isWebpack5, isDevServer4 } = require('../../utils/test-utils'); +const { runWatch, isWebpack5, isDevServer4 } = require('../../utils/test-utils'); const testPath = path.resolve(__dirname); @@ -24,7 +24,7 @@ describe('basic serve usage', () => { } it('should work', async () => { - const { stderr, stdout } = await runServe(__dirname, []); + const { stderr, stdout } = await runWatch(__dirname, ['serve']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -32,7 +32,7 @@ describe('basic serve usage', () => { }); it('should work with the "--config" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'serve.config.js', '--port', port]); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', 'serve.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); @@ -40,7 +40,8 @@ describe('basic serve usage', () => { }); it('should work with the "--config" and "--env" options', async () => { - const { stderr, stdout } = await runServe(__dirname, [ + const { stderr, stdout } = await runWatch(__dirname, [ + 'serve', '--config', 'function-with-env.config.js', '--env', @@ -57,7 +58,8 @@ describe('basic serve usage', () => { }); it('should work with the "--config" and "--env" options and expose dev server options', async () => { - const { stderr, stdout } = await runServe(__dirname, [ + const { stderr, stdout } = await runWatch(__dirname, [ + 'serve', '--config', 'function-with-argv.config.js', '--env', @@ -76,7 +78,7 @@ describe('basic serve usage', () => { }); it('should work in multi compiler mode', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi.config.js', '--port', port]); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', 'multi.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -88,7 +90,7 @@ describe('basic serve usage', () => { // TODO need fix in future, edge case it.skip('should work in multi compiler mode with multiple dev servers', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi-dev-server.config.js']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', 'multi-dev-server.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -99,7 +101,7 @@ describe('basic serve usage', () => { }); it('should work with the "--mode" option', async () => { - const { stderr, stdout } = await runServe(__dirname, []); + const { stderr, stdout } = await runWatch(__dirname, ['serve']); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); @@ -108,7 +110,7 @@ describe('basic serve usage', () => { }); it('should work with the "--stats" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--stats']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--stats']); expect(stderr).toBeFalsy(); expect(stdout).toContain(isWebpack5 ? 'compiled successfully' : 'Version: webpack'); @@ -116,7 +118,7 @@ describe('basic serve usage', () => { }); it('should work with the "--stats verbose" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--stats', 'verbose']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--stats', 'verbose']); expect(stderr).toBeFalsy(); expect(stdout).toContain(isWebpack5 ? 'from webpack.Compiler' : 'webpack.buildChunkGraph.visitModules'); @@ -124,7 +126,7 @@ describe('basic serve usage', () => { }); it('should work with the "--mode" option #2', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--mode', 'production']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--mode', 'production']); expect(stderr).toBeFalsy(); expect(stdout).toContain('production'); @@ -133,7 +135,7 @@ describe('basic serve usage', () => { }); it('should work with the "--mode" option #3', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--mode', 'development']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--mode', 'development']); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); @@ -142,7 +144,7 @@ describe('basic serve usage', () => { }); it('should work with the "--progress" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--progress']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--progress']); expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); @@ -150,7 +152,7 @@ describe('basic serve usage', () => { }); it('should work with the "--progress" option using the "profile" value', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--progress', 'profile']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--progress', 'profile']); expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); @@ -158,7 +160,7 @@ describe('basic serve usage', () => { }); it('should work with the "--client-log-level" option', async () => { - const { stdout, stderr } = await runServe(testPath, ['--client-log-level', 'info']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--client-log-level', 'info']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -166,7 +168,7 @@ describe('basic serve usage', () => { }); it('should work with the "--port" option', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port]); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -174,7 +176,7 @@ describe('basic serve usage', () => { }); it('should work with the "--hot" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--hot']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--hot']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -182,7 +184,7 @@ describe('basic serve usage', () => { }); it('should work with the "--no-hot" option', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port, '--no-hot']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port, '--no-hot']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -190,7 +192,7 @@ describe('basic serve usage', () => { }); it('should work with the "--hot" option using the "only" value', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port, isDevServer4 ? '--hot only' : '--hot-only']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port, isDevServer4 ? '--hot only' : '--hot-only']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -198,7 +200,7 @@ describe('basic serve usage', () => { }); it('should work with "--hot" and "--port" options', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port, '--hot']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port, '--hot']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -206,7 +208,7 @@ describe('basic serve usage', () => { }); it('should work with the "--hot" and "--progress" options', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port, '--hot', '--progress']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port, '--hot', '--progress']); expect(stderr).toContain('webpack.Progress'); expect(stdout).toContain('main.js'); @@ -214,7 +216,7 @@ describe('basic serve usage', () => { }); it('should work with the default "publicPath" option', async () => { - const { stderr, stdout } = await runServe(__dirname, []); + const { stderr, stdout } = await runWatch(__dirname, ['serve']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -223,7 +225,7 @@ describe('basic serve usage', () => { }); it('should work with the "--output-public-path" option', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--output-public-path', '/my-public-path/']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--output-public-path', '/my-public-path/']); if (isWebpack5) { expect(stderr).toBeFalsy(); @@ -237,7 +239,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'output-public-path.config.js']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', 'output-public-path.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -246,7 +248,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration using multi compiler mode', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi-output-public-path.config.js', '--port', port]); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', 'multi-output-public-path.config.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('one'); @@ -258,7 +260,7 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration (from the "devServer" options)', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'dev-server-output-public-path.config.js']); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', 'dev-server-output-public-path.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -267,7 +269,7 @@ describe('basic serve usage', () => { }); it('should work with the "--open" option', async () => { - const { stdout, stderr } = await runServe(testPath, ['--open', '--port', port]); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--open', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); @@ -275,7 +277,13 @@ describe('basic serve usage', () => { }); it('should respect the "publicPath" option from configuration using multi compiler mode (from the "devServer" options)', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'multi-dev-server-output-public-path.config.js', '--port', port]); + const { stderr, stdout } = await runWatch(__dirname, [ + 'serve', + '--config', + 'multi-dev-server-output-public-path.config.js', + '--port', + port, + ]); expect(stderr).toBeFalsy(); expect(stderr).toBeFalsy(); @@ -288,7 +296,7 @@ describe('basic serve usage', () => { }); it('should work with entries syntax', async () => { - const { stderr, stdout } = await runServe(__dirname, ['./src/entry.js', '--port', port]); + const { stderr, stdout } = await runWatch(__dirname, ['serve', './src/entry.js', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('development'); @@ -296,7 +304,7 @@ describe('basic serve usage', () => { }); it('should work and log warning on the `watch option in a configuration', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', './watch.config.js', '--port', port]); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', './watch.config.js', '--port', port]); expect(stderr).toContain( "No need to use the 'serve' command together with '{ watch: true }' configuration, it does not make sense.", @@ -306,7 +314,7 @@ describe('basic serve usage', () => { }); it('should log used supplied config with serve', async () => { - const { stderr, stdout } = await runServe(__dirname, ['--config', 'log.config.js', '--port', port]); + const { stderr, stdout } = await runWatch(__dirname, ['serve', '--config', 'log.config.js', '--port', port]); const configPath = path.resolve(__dirname, './log.config.js'); expect(stderr).toContain('Compiler starting...'); @@ -316,7 +324,7 @@ describe('basic serve usage', () => { }); it("should log error on using '--watch' flag with serve", async () => { - const { stdout, stderr } = await runServe(testPath, ['--watch']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--watch']); expect(stderr).toContain("Error: Unknown option '--watch'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); @@ -324,7 +332,7 @@ describe('basic serve usage', () => { }); it("should log error on using '-w' alias with serve", async () => { - const { stdout, stderr } = await runServe(testPath, ['-w']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '-w']); expect(stderr).toContain("Error: Unknown option '-w'"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); @@ -332,7 +340,7 @@ describe('basic serve usage', () => { }); it('should log an error on unknown flag', async () => { - const { exitCode, stdout, stderr } = await runServe(testPath, ['--port', port, '--unknown-flag']); + const { exitCode, stdout, stderr } = await runWatch(testPath, ['serve', '--port', port, '--unknown-flag']); expect(exitCode).toBe(2); expect(stderr).toContain("Error: Unknown option '--unknown-flag'"); diff --git a/test/serve/serve-variable/serve-basic.test.js b/test/serve/serve-variable/serve-basic.test.js index 065f471d17b..84002d52596 100644 --- a/test/serve/serve-variable/serve-basic.test.js +++ b/test/serve/serve-variable/serve-basic.test.js @@ -2,7 +2,7 @@ const path = require('path'); const getPort = require('get-port'); -const { runServe } = require('../../utils/test-utils'); +const { runWatch } = require('../../utils/test-utils'); const testPath = path.resolve(__dirname); @@ -24,7 +24,7 @@ describe('serve variable', () => { } it('compiles without flags and export variable', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port]); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port]); expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); diff --git a/test/serve/with-custom-port/serve-custom-config.test.js b/test/serve/with-custom-port/serve-custom-config.test.js index ded0f9aef99..cad1dea9064 100644 --- a/test/serve/with-custom-port/serve-custom-config.test.js +++ b/test/serve/with-custom-port/serve-custom-config.test.js @@ -2,7 +2,7 @@ const path = require('path'); const getPort = require('get-port'); -const { runServe } = require('../../utils/test-utils'); +const { runWatch } = require('../../utils/test-utils'); const testPath = path.resolve(__dirname); @@ -24,7 +24,7 @@ describe('serve with devServer in config', () => { } it('Should pick up the host and port from config', async () => { - const { stdout, stderr } = await runServe(testPath, []); + const { stdout, stderr } = await runWatch(testPath, ['serve']); expect(stderr).toBeFalsy(); // Should output the correct bundle file @@ -35,7 +35,7 @@ describe('serve with devServer in config', () => { }); it('Port flag should override the config port', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port]); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port]); expect(stderr).toBeFalsy(); // Should output the correct bundle file @@ -46,7 +46,7 @@ describe('serve with devServer in config', () => { }); it('Passing hot flag works alongside other server config', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port, '--hot']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port, '--hot']); expect(stderr).toBeFalsy(); // Should output the correct bundle file @@ -58,7 +58,7 @@ describe('serve with devServer in config', () => { }); it('works fine when no-hot flag is passed alongside other server config', async () => { - const { stdout, stderr } = await runServe(testPath, ['--port', port, '--no-hot']); + const { stdout, stderr } = await runWatch(testPath, ['serve', '--port', port, '--no-hot']); expect(stderr).toBeFalsy(); // Should output the correct bundle file diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js index 278c69a4a62..6b34d69ef6f 100644 --- a/test/stats/watch/stats-and-watch.test.js +++ b/test/stats/watch/stats-and-watch.test.js @@ -4,21 +4,21 @@ const { runWatch } = require('../../utils/test-utils'); describe('stats and watch', () => { it('should not log stats with the "none" value from the configuration', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js'], true); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should not log stats with the "none" value from the configuration and multi compiler mode', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js'], true); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should log stats with the "normal" value in arguments', async () => { - const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal'], true); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal']); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 9d036a9a086..34b66286b89 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -39,8 +39,7 @@ const hyphenToUpperCase = (name) => { * * @param {String} testCase The path to folder that contains the webpack.config.js * @param {Array} args Array of arguments to pass to webpack - * @param {Array} nodeOptions Boolean that decides if a default output path will be set or not - * @param {Record} env Boolean that decides if a default output path will be set or not + * @param {Object} options Boolean that decides if a default output path will be set or not * @returns {Object} The webpack output or Promise when nodeOptions are present */ const run = (testCase, args = [], options = {}) => { @@ -58,14 +57,20 @@ const run = (testCase, args = [], options = {}) => { return result; }; -const runWatch = (testCase, args = [], setOutput = true, outputKillStr = /webpack \d+\.\d+\.\d/, options = {}) => { +/** + * Run the webpack CLI in watch mode for a test case. + * + * @param {String} testCase The path to folder that contains the webpack.config.js + * @param {Array} args Array of arguments to pass to webpack + * @param {Object} options Boolean that decides if a default output path will be set or not + * @param {string} outputKillStr String to kill + * @returns {Object} The webpack output or Promise when nodeOptions are present + */ +const runWatch = (testCase, args = [], options, outputKillStr = /webpack \d+\.\d+\.\d/) => { const cwd = path.resolve(testCase); - const outputPath = path.resolve(testCase, 'bin'); - const argsWithOutput = setOutput ? args.concat('--output-path', outputPath) : args; - return new Promise((resolve, reject) => { - const proc = execa(WEBPACK_PATH, argsWithOutput, { + const proc = execa(WEBPACK_PATH, args, { cwd, reject: false, stdio: 'pipe', @@ -128,10 +133,12 @@ const runAndGetWatchProc = (testCase, args = [], setOutput = true, input = '', f */ const runPromptWithAnswers = (location, args, answers, waitForOutput = true) => { const runner = runAndGetWatchProc(location, args, false, '', true); + runner.stdin.setDefaultEncoding('utf-8'); const delay = 2000; let outputTimeout; + if (waitForOutput) { let currentAnswer = 0; const writeAnswer = () => { @@ -248,14 +255,9 @@ const runInstall = async (cwd) => { }); }; -const runServe = (testPath, args) => { - return runWatch(testPath, ['serve'].concat(args), false); -}; - module.exports = { run, runWatch, - runServe, runAndGetWatchProc, runPromptWithAnswers, appendDataIfFileExists, From f2e935e8acf6c37e4ff777a80342b5991c1f7485 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Wed, 17 Feb 2021 21:08:33 +0530 Subject: [PATCH 328/581] chore: upgrade eslint plugins (#2443) --- package.json | 4 +- packages/configtest/src/index.ts | 5 +- .../__tests__/addon-generator.test.ts | 3 +- .../__tests__/utils/scaffold-utils.test.ts | 1 - packages/generators/src/addon-generator.ts | 5 +- packages/generators/src/index.ts | 3 +- packages/generators/src/init-generator.ts | 7 +- packages/generators/src/loader-generator.ts | 2 +- packages/generators/src/plugin-generator.ts | 2 +- packages/generators/src/types/index.ts | 103 ++++++++--------- .../__tests__/npm-packages-exists.test.ts | 3 +- .../recursive-parser.test.ts.snap | 2 +- .../recursive-parser/recursive-parser.test.ts | 2 +- .../utils/__tests__/resolve-packages.test.ts | 4 - packages/generators/src/utils/ast-utils.ts | 2 +- packages/generators/src/utils/copy-utils.ts | 12 +- packages/generators/src/utils/defineTest.ts | 20 ++-- packages/generators/src/utils/entry.ts | 8 +- .../src/utils/modify-config-helper.ts | 8 +- .../src/utils/npm-packages-exists.ts | 2 +- .../generators/src/utils/resolve-packages.ts | 6 +- .../generators/src/utils/scaffold-utils.ts | 2 +- packages/generators/src/utils/types/Config.ts | 2 +- .../generators/src/utils/types/NodePath.ts | 10 +- packages/info/src/index.ts | 3 +- packages/serve/src/index.ts | 3 +- packages/serve/src/startDevServer.ts | 11 +- packages/serve/src/types.ts | 28 ++--- test/entry/scss/webpack.config.js | 2 +- test/stats/flags/webpack.config.js | 1 - test/utils/test-utils.js | 1 - yarn.lock | 107 +++++++++++++----- 32 files changed, 219 insertions(+), 155 deletions(-) diff --git a/package.json b/package.json index 368f125a321..ffb7b57f470 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "@commitlint/config-conventional": "^11.0.0", "@types/jest": "^26.0.15", "@types/node": "^14.14.6", - "@typescript-eslint/eslint-plugin": "^2.34.0", - "@typescript-eslint/parser": "^2.34.0", + "@typescript-eslint/eslint-plugin": "^4.14.1", + "@typescript-eslint/parser": "^4.14.1", "@webpack-cli/migrate": "^1.1.2", "coffeescript": "^2.5.1", "colorette": "^1.2.1", diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts index 15161d85f79..caa31de3f49 100644 --- a/packages/configtest/src/index.ts +++ b/packages/configtest/src/index.ts @@ -1,5 +1,6 @@ class ConfigTestCommand { - async apply(cli): Promise { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + async apply(cli: any): Promise { const { logger, webpack } = cli; await cli.makeCommand( @@ -39,8 +40,6 @@ class ConfigTestCommand { // TODO remove this after drop webpack@4 if (error && error.length > 0) { - // eslint-disable-next-line @typescript-eslint/ban-ts-ignore - // @ts-ignore throw new webpack.WebpackOptionsValidationError(error); } } catch (error) { diff --git a/packages/generators/__tests__/addon-generator.test.ts b/packages/generators/__tests__/addon-generator.test.ts index 5d6bc2f9d0f..16322b95e99 100644 --- a/packages/generators/__tests__/addon-generator.test.ts +++ b/packages/generators/__tests__/addon-generator.test.ts @@ -23,8 +23,7 @@ describe('addon generator', () => { }); beforeEach(() => { - // eslint-disable-next-line @typescript-eslint/no-empty-function - const Gen = addonGenerator([], '', [], [], () => {}); + const Gen = addonGenerator([], '', [], [], () => ({})); gen = new Gen(null, null); gen.props = { diff --git a/packages/generators/__tests__/utils/scaffold-utils.test.ts b/packages/generators/__tests__/utils/scaffold-utils.test.ts index 2fd303e5dd1..c92e63b4143 100755 --- a/packages/generators/__tests__/utils/scaffold-utils.test.ts +++ b/packages/generators/__tests__/utils/scaffold-utils.test.ts @@ -5,7 +5,6 @@ describe('utils', () => { beforeEach(() => { mockSelf = { - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type prompt: (arg) => { return arg[0]; }, diff --git a/packages/generators/src/addon-generator.ts b/packages/generators/src/addon-generator.ts index fcc7ebfa9ba..dee481dceec 100644 --- a/packages/generators/src/addon-generator.ts +++ b/packages/generators/src/addon-generator.ts @@ -33,14 +33,15 @@ const addonGenerator = ( templateDir: string, copyFiles: string[], copyTemplateFiles: string[], - templateFn: Function, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + templateFn: (instance: any) => Record, ): Generator.GeneratorConstructor => { return class extends Generator { public props: Generator.Question; public copy: (value: string, index: number, array: string[]) => void; public copyTpl: (value: string, index: number, array: string[]) => void; - public prompting(): Promise { + public prompting(): Promise { return this.prompt(prompts).then((props: Generator.Question): void => { this.props = props; }); diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index 8826052aa1d..66ebc7926e3 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -8,7 +8,8 @@ import { modifyHelperUtil } from './utils/modify-config-helper'; import { npmPackagesExists } from './utils/npm-packages-exists'; class GeneratorsCommand { - async apply(cli): Promise { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + async apply(cli: any): Promise { const { logger } = cli; await cli.makeCommand( diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 022768b9596..4269fcda362 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -23,7 +23,8 @@ export default class InitGenerator extends CustomGenerator { public generationPath: string; private langType: string; - public constructor(args, opts) { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + public constructor(args: any, opts: any) { super(args, opts); this.autoGenerateConfig = opts.autoSetDefaults; @@ -54,7 +55,7 @@ export default class InitGenerator extends CustomGenerator { (this.configuration.config.webpackOptions.plugins as string[]).push('new webpack.ProgressPlugin()'); } - public async prompting(): Promise { + public async prompting(): Promise { // eslint-disable-next-line @typescript-eslint/no-this-alias const self: this = this; @@ -73,7 +74,7 @@ export default class InitGenerator extends CustomGenerator { this.autoGenerateConfig, ); - const entryOption: string | object = await entryQuestions(self, multiEntries, this.autoGenerateConfig); + const entryOption: string | Record = await entryQuestions(self, multiEntries, this.autoGenerateConfig); if (typeof entryOption === 'string') { // single entry apply when default is not used diff --git a/packages/generators/src/loader-generator.ts b/packages/generators/src/loader-generator.ts index 474ebe84cdf..debf22a3d2b 100644 --- a/packages/generators/src/loader-generator.ts +++ b/packages/generators/src/loader-generator.ts @@ -52,7 +52,7 @@ export const LoaderGenerator = addonGenerator( 'examples/simple/src/static-esm-module.js.tpl', ], ['src/_index.js.tpl'], - (gen): object => ({ name: gen.props.name }), + (gen): Record => ({ name: gen.props.name }), ); export default LoaderGenerator; diff --git a/packages/generators/src/plugin-generator.ts b/packages/generators/src/plugin-generator.ts index 113bdf8322e..f33298f5bad 100644 --- a/packages/generators/src/plugin-generator.ts +++ b/packages/generators/src/plugin-generator.ts @@ -31,7 +31,7 @@ export const PluginGenerator = addonGenerator( 'examples/simple/src/static-esm-module.js.tpl', ], ['src/_index.js.tpl', 'examples/simple/_webpack.config.js.tpl'], - (gen): object => ({ name: toUpperCamelCase(gen.props.name) }), + (gen): Record => ({ name: toUpperCamelCase(gen.props.name) }), ); export default PluginGenerator; diff --git a/packages/generators/src/types/index.ts b/packages/generators/src/types/index.ts index 00cc32f4ea8..398f4dbfc82 100644 --- a/packages/generators/src/types/index.ts +++ b/packages/generators/src/types/index.ts @@ -1,16 +1,17 @@ import Generator from 'yeoman-generator'; +import { Loader } from '../utils/styleSupport'; export interface SchemaProperties { additionalProperties?: boolean; - definitions?: object; - properties?: object; + definitions?: Record; + properties?: Record; type?: string; } interface WebpackResolve { - alias?: object; + alias?: Record; aliasFields?: string[]; - cachePredicate?: Function; + cachePredicate?: () => void; cacheWithContext?: boolean; descriptionFiles?: string[]; enforceExtension?: boolean; @@ -20,19 +21,19 @@ interface WebpackResolve { mainFiles?: string[]; moduleExtensions?: string[]; modules?: string[]; - plugins?: object[] | Function[]; + plugins?: Record[] | Array<() => void>; symlinks?: boolean; concord?: boolean; - unsafeCache?: boolean | object; + unsafeCache?: boolean | Record; useSyncFileSystemCalls?: boolean; } -type IRuleSetCondition = RegExp | string | Function | object; +type IRuleSetCondition = RegExp | string | (() => void) | Record | string[]; export interface WebpackOptions { amd?: string; bail?: boolean; - cache?: boolean | object; + cache?: boolean | Record; context?: string; devServer?: { hot?: boolean; @@ -45,8 +46,8 @@ export interface WebpackOptions { publicPath?: string; port?: number | string; socket?: string; - watchOptions?: object; - headers?: object; + watchOptions?: Record; + headers?: Record; logLevel?: string; clientLogLevel?: string; overlay?: @@ -65,50 +66,50 @@ export interface WebpackOptions { inline?: boolean; disableHostCheck?: boolean; public?: string; - https?: object | boolean; + https?: Record | boolean; contentBase?: false | number | string | string[]; watchContentBase?: boolean; open?: string | boolean; useLocalIp?: boolean; openPage?: string; compress?: boolean; - proxy?: object[] | Function[]; + proxy?: Record[] | Array<() => void>; historyApiFallback?: | boolean | { - rewrites?: object[]; + rewrites?: Record[]; disableDotRule?: boolean; }; - staticOptions?: object; - setup?: Function; - before?: Function; - after?: Function; - stats?: boolean | object | string; - reporter?: Function; + staticOptions?: Record; + setup?: () => void; + before?: () => void; + after?: () => void; + stats?: boolean | Record | string; + reporter?: () => void; logTime?: boolean; noInfo?: boolean; quiet?: boolean; serverSideRender?: boolean; index?: string; - log?: Function; - warn?: Function; + log?: () => void; + warn?: () => void; }; devtool?: string; - entry?: string | object | Function; - externals?: string | object | boolean | Function | RegExp; + entry?: string | Record | (() => void); + externals?: string | Record | boolean | (() => void) | RegExp; mode?: 'development' | 'production' | 'none' | string; module?: { exprContextCritical?: boolean; exprContextRecursive?: boolean; exprContextRegExp?: boolean | RegExp; exprContextRequest?: string; - noParse?: string | string[] | Function | RegExp | RegExp[]; + noParse?: string | string[] | (() => void) | RegExp | RegExp[]; rules?: Rule[]; unknownContextCritical?: boolean; unknownContextRecursive?: boolean; unknownContextRegExp?: boolean | RegExp; unknownContextRequest?: string; - unsafeCache?: boolean | Function; + unsafeCache?: boolean | (() => void); wrappedContextCritical?: boolean; wrappedContextRecursive?: boolean; wrappedContextRegExp?: RegExp; @@ -129,25 +130,25 @@ export interface WebpackOptions { setImmediate?: boolean | string; }; output?: { - auxiliaryComment?: string | object; + auxiliaryComment?: string | Record; chunkFilename?: string; chunkLoadTimeout?: number; crossOriginLoading?: boolean | string; jsonpScriptType?: string; - devtoolFallbackModuleFilenameTemplate?: string | Function; - devtoolLineToLine?: boolean | object; - devtoolModuleFilenameTemplate?: string | Function; + devtoolFallbackModuleFilenameTemplate?: string | (() => void); + devtoolLineToLine?: boolean | Record; + devtoolModuleFilenameTemplate?: string | (() => void); devtoolNamespace?: string; - filename?: string | Function; + filename?: string | (() => void); hashDigest?: 'latin1' | string; hashDigestLength?: number; - hashFunction?: string | Function; + hashFunction?: string | (() => void); hashSalt?: string; - hotUpdateChunkFilename?: string | Function; - hotUpdateFunction?: Function; - hotUpdateMainFilename?: string | Function; - jsonpFunction?: string; - library?: string | object; + hotUpdateChunkFilename?: string | (() => void); + hotUpdateFunction?: () => void; + hotUpdateMainFilename?: string | (() => void); + jsonpFunctiion?: string; + library?: string | Record; path?: string; }; optimization?: { @@ -167,7 +168,7 @@ export interface WebpackOptions { minChunks?: number; maxAsyncRequests?: number; maxInitialRequests?: number; - name?: boolean | Function | string; + name?: boolean | (() => void) | string; filename?: string; automaticNameDelimiter?: string; hidePathInfo?: boolean; @@ -176,8 +177,8 @@ export interface WebpackOptions { maxSize?: number; automaticNameDelimiter?: number; }; - cacheGroups?: number | boolean | string | Function | RegExp | object; - runtimeChunk?: boolean | string | object; + cacheGroups?: number | boolean | string | (() => void) | RegExp | Record; + runtimeChunk?: boolean | string | Record; noEmitOnErrors?: boolean; checkWasmTypes?: boolean; mangleWasmImports?: boolean; @@ -186,7 +187,7 @@ export interface WebpackOptions { namedChunks?: boolean; portableRecords?: boolean; minimize?: boolean; - minimizer?: object[] | Function[]; + minimizer?: Record[] | Array<() => void>; nodeEnv?: false | string; }; }; @@ -194,20 +195,20 @@ export interface WebpackOptions { performance?: | false | { - assetFilter?: Function; + assetFilter?: () => void; hints?: false | string; maxEntrypointSize?: number; maxAssetSize?: number; }; - plugins?: object[] | Function[] | string[] | string; + plugins?: Record[] | Array<() => void> | string[] | string; profile?: boolean; recordsInputPath?: string; recordsOutputPath?: string; recordsPath?: string; resolve?: WebpackResolve; resolveLoader?: WebpackResolve; - stats?: string | boolean | object; - target?: string | Function; + stats?: string | boolean | Record; + target?: string | (() => void); watch?: boolean; watchOptions?: { aggregateTimeout?: number; @@ -221,22 +222,22 @@ export interface Rule { exclude?: IRuleSetCondition; include?: IRuleSetCondition; issuer?: IRuleSetCondition; - loader?: string | Function | object; - loaders?: Function[] | object[]; - options?: object; - parser?: object; + loader?: string | (() => void) | Record; + loaders?: Array<() => void> | Record[]; + options?: Record; + parser?: Record; sideEffects?: boolean; type?: string; resource?: IRuleSetCondition; resourceQuery?: IRuleSetCondition; compiler?: IRuleSetCondition; - rules?: object[]; - use?: object | object[] | Function; + rules?: Record[]; + use?: Loader[] | (() => void); test?: IRuleSetCondition; } export class CustomGenerator extends Generator { - public entryOption: string | object; + public entryOption: string | Record; public configuration: { config: { configName?: string; diff --git a/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts b/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts index 90a89bdf05e..4ba4efa57ca 100644 --- a/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts +++ b/packages/generators/src/utils/__tests__/npm-packages-exists.test.ts @@ -4,7 +4,8 @@ import { resolvePackages } from '../resolve-packages'; jest.mock('../resolve-packages'); // TS is not aware that jest changes the type of resolvePackages -const mockResolvePackages = resolvePackages as jest.Mock; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const mockResolvePackages = resolvePackages as any; describe('npmPackagesExists', () => { test('resolves packages when they are available on the local filesystem', () => { diff --git a/packages/generators/src/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap b/packages/generators/src/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap index 592b7f56e58..69096cb389d 100644 --- a/packages/generators/src/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap +++ b/packages/generators/src/utils/__tests__/recursive-parser/__snapshots__/recursive-parser.test.ts.snap @@ -140,7 +140,7 @@ exports[`recursive parser remove transforms correctly using "fixture-3" data 2`] port: 9000, }, devtool: 'eval', - plugins: ['plugin1', 'plugin3'], + plugins: ['plugin1', 'plugin2', 'plugin3'], resolve: { alias: { inject: \\"{{#if_eq build 'standalone'}}\\", diff --git a/packages/generators/src/utils/__tests__/recursive-parser/recursive-parser.test.ts b/packages/generators/src/utils/__tests__/recursive-parser/recursive-parser.test.ts index 2f7148f8768..5c3a33546d9 100644 --- a/packages/generators/src/utils/__tests__/recursive-parser/recursive-parser.test.ts +++ b/packages/generators/src/utils/__tests__/recursive-parser/recursive-parser.test.ts @@ -48,7 +48,7 @@ describe('recursive parser', () => { alias: null, }); - defineTest(join(__dirname), 'remove', 'fixture-3', 'plugins', ['plugin2']); + defineTest(join(__dirname), 'remove', 'fixture-3', 'plugins', 'plugin2'); defineTest(join(__dirname), 'remove', 'fixture-3', 'module', { noParse: null, diff --git a/packages/generators/src/utils/__tests__/resolve-packages.test.ts b/packages/generators/src/utils/__tests__/resolve-packages.test.ts index 2531ba2dd3d..824fac8fa8d 100644 --- a/packages/generators/src/utils/__tests__/resolve-packages.test.ts +++ b/packages/generators/src/utils/__tests__/resolve-packages.test.ts @@ -2,11 +2,9 @@ import path from 'path'; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function mockPromise(value) { const isValueAPromise = (value || {}).then; const mockedPromise = { - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type then(callback) { return mockPromise(callback(value)); }, @@ -15,12 +13,10 @@ function mockPromise(value) { return isValueAPromise ? value : mockedPromise; } -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function spawnChild(pkg) { return pkg; } -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function getLoc(option) { const packageModule = []; option.filter((pkg) => { diff --git a/packages/generators/src/utils/ast-utils.ts b/packages/generators/src/utils/ast-utils.ts index ec529f719aa..425a5406927 100644 --- a/packages/generators/src/utils/ast-utils.ts +++ b/packages/generators/src/utils/ast-utils.ts @@ -285,7 +285,7 @@ function findAndRemovePluginByName(j: JSCodeshift, node: Node, pluginName: strin * @returns {Void} */ -function createOrUpdatePluginByName(j: JSCodeshift, rootNodePath: Node, pluginName: string, options?: object): void { +function createOrUpdatePluginByName(j: JSCodeshift, rootNodePath: Node, pluginName: string, options?: Record): void { const pluginInstancePath: Node = findPluginsByName(j, j(rootNodePath), [pluginName]); let optionsProps: Node[]; if (options) { diff --git a/packages/generators/src/utils/copy-utils.ts b/packages/generators/src/utils/copy-utils.ts index bb582e9d0d8..25dd6fda949 100644 --- a/packages/generators/src/utils/copy-utils.ts +++ b/packages/generators/src/utils/copy-utils.ts @@ -8,7 +8,8 @@ import path from 'path'; * @param {string} templateDir Absolute path to template directory * @returns {Function} A curried function that takes a file path and copies it */ -export const generatorCopy = (generator, templateDir: string): ((filePath: string) => void) => (filePath: string): void => { +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any +export const generatorCopy = (generator: any, templateDir: string): ((filePath: string) => void) => (filePath: string): void => { const sourceParts = templateDir.split(path.delimiter); sourceParts.push(...filePath.split('/')); @@ -31,9 +32,12 @@ export const generatorCopy = (generator, templateDir: string): ((filePath: strin * the template files. * @returns {Function} A curried function that takes a file path and copies it */ -export const generatorCopyTpl = (generator, templateDir: string, templateData: object): ((filePath: string) => void) => ( - filePath: string, -): void => { +export const generatorCopyTpl = ( + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + generator: any, + templateDir: string, + templateData: Record, +): ((filePath: string) => void) => (filePath: string): void => { const sourceParts = templateDir.split(path.delimiter); sourceParts.push(...filePath.split('/')); diff --git a/packages/generators/src/utils/defineTest.ts b/packages/generators/src/utils/defineTest.ts index ada2f4f1c33..f90de53f3b1 100644 --- a/packages/generators/src/utils/defineTest.ts +++ b/packages/generators/src/utils/defineTest.ts @@ -4,7 +4,13 @@ import * as path from 'path'; import { JSCodeshift, Node } from './types/NodePath'; interface Module { - (jscodeshift: JSCodeshift, ast: Node, initOptions: string | boolean | object, action: string, transformName?: string): Node; + ( + jscodeshift: JSCodeshift, + ast: Node, + initOptions: string | boolean | Record, + action: string, + transformName?: string, + ): Node; default: transformType; parser: string; } @@ -12,8 +18,8 @@ interface Module { type transformType = ( jscodeshift: JSCodeshift, ast: Node, - initOptions: string | boolean | object, - action: object | string, + initOptions: string | boolean | Record, + action: Record | string, transformName?: string, ) => Node; @@ -45,8 +51,8 @@ function runSingleTransform( dirName: string, transformName: string, testFilePrefix: string, - initOptions: object | boolean | string, - action: object | string, + initOptions: Record | boolean | string, + action: Record | string, ): string { if (!testFilePrefix) { testFilePrefix = transformName; @@ -104,8 +110,8 @@ export default function defineTest( dirName: string, transformName: string, testFilePrefix?: string, - transformObject?: object | string, - action?: object | string, + transformObject?: Record | string, + action?: Record | string, ): void { const testName: string = testFilePrefix ? `transforms correctly using "${testFilePrefix}" data` : 'transforms correctly'; describe(transformName, () => { diff --git a/packages/generators/src/utils/entry.ts b/packages/generators/src/utils/entry.ts index e8f6fe333b7..831bcac2ec9 100644 --- a/packages/generators/src/utils/entry.ts +++ b/packages/generators/src/utils/entry.ts @@ -12,7 +12,11 @@ import validate from './validate'; * @returns {Object} An Object that holds the answers given by the user, later used to scaffold */ -export default async function entry(self: Generator, multiEntries: boolean, autoGenerateDefaults = false): Promise { +export default async function entry( + self: Generator, + multiEntries: boolean, + autoGenerateDefaults = false, +): Promise> { const fixEntry = (entry: string): string => { entry = entry.trim().replace(/"|'/g, ''); @@ -30,7 +34,7 @@ export default async function entry(self: Generator, multiEntries: boolean, auto }; if (multiEntries) { - const webpackEntryPoint: object = {}; + const webpackEntryPoint: Record = {}; const multipleEntriesAnswer = await InputValidate( self, 'multipleEntries', diff --git a/packages/generators/src/utils/modify-config-helper.ts b/packages/generators/src/utils/modify-config-helper.ts index 3357e7cccee..4dbeded7f35 100644 --- a/packages/generators/src/utils/modify-config-helper.ts +++ b/packages/generators/src/utils/modify-config-helper.ts @@ -14,7 +14,7 @@ export interface Config extends Object { topScope?: string[]; configName?: string; merge: string | string[]; - webpackOptions: object; + webpackOptions: Record; } export interface TransformConfig extends Object { @@ -24,10 +24,10 @@ export interface TransformConfig extends Object { } export interface WebpackScaffoldObject extends Object { - config: { + config?: { configName?: string; topScope?: string[]; - webpackOptions?: object; + webpackOptions?: Record; }; } @@ -87,7 +87,7 @@ export function modifyHelperUtil( generationPath, }, () => { - let configModule: object; + let configModule: Record>; let finalConfig: WebpackScaffoldObject = { config: {}, }; diff --git a/packages/generators/src/utils/npm-packages-exists.ts b/packages/generators/src/utils/npm-packages-exists.ts index bc79ea156de..e22dc5e4035 100644 --- a/packages/generators/src/utils/npm-packages-exists.ts +++ b/packages/generators/src/utils/npm-packages-exists.ts @@ -45,7 +45,7 @@ export function npmExists(moduleName: string): Promise { export function npmPackagesExists(pkg: string[]): void { const acceptedPackages: string[] = []; - function resolvePackagesIfReady(): void | Function { + function resolvePackagesIfReady(): void | (() => void) { if (acceptedPackages.length === pkg.length) { return resolvePackages(acceptedPackages); } diff --git a/packages/generators/src/utils/resolve-packages.ts b/packages/generators/src/utils/resolve-packages.ts index cd5a8aa3c57..9e86529a99a 100644 --- a/packages/generators/src/utils/resolve-packages.ts +++ b/packages/generators/src/utils/resolve-packages.ts @@ -9,10 +9,6 @@ import { utils } from 'webpack-cli'; const { logger } = utils; -interface ChildProcess { - status: number; -} - /** * * Attaches a promise to the installation of the package @@ -40,7 +36,7 @@ export function processPromise(child: ExecaSyncReturnValue): Promise { * a webpack configuration through yeoman or throws an error */ -export function resolvePackages(pkg: string[]): Function | void { +export function resolvePackages(pkg: string[]): (() => void) | void { Error.stackTraceLimit = 30; const packageLocations: string[] = []; diff --git a/packages/generators/src/utils/scaffold-utils.ts b/packages/generators/src/utils/scaffold-utils.ts index f8a153909f5..c7064a02559 100644 --- a/packages/generators/src/utils/scaffold-utils.ts +++ b/packages/generators/src/utils/scaffold-utils.ts @@ -35,7 +35,7 @@ export function InputValidate( cb?: (input: string) => string | boolean, defaultChoice?: string, skip = false, -): object | any { +): Record | any { if (skip) { return { [name]: defaultChoice }; } diff --git a/packages/generators/src/utils/types/Config.ts b/packages/generators/src/utils/types/Config.ts index a511f80a0c1..89f1ff78bff 100644 --- a/packages/generators/src/utils/types/Config.ts +++ b/packages/generators/src/utils/types/Config.ts @@ -5,7 +5,7 @@ export interface Config extends Object { topScope?: string[]; configName?: string; merge: string | string[]; - webpackOptions: object; + webpackOptions: Record; } export interface TransformConfig extends Object { diff --git a/packages/generators/src/utils/types/NodePath.ts b/packages/generators/src/utils/types/NodePath.ts index dbe41aceff6..f93d2b884f0 100644 --- a/packages/generators/src/utils/types/NodePath.ts +++ b/packages/generators/src/utils/types/NodePath.ts @@ -19,7 +19,7 @@ export interface Node extends Object { value?: string; }; filter?: (p: (p: Node) => boolean) => Node; - find?: (objectExpression: object, filterExpression?: object) => Node; + find?: (objectExpression: ExpressionObject, filterExpression?: Record) => Node; forEach?: (p: (p: Node) => void) => Node; get?: (property: string) => Node; remove?: () => void; @@ -31,12 +31,12 @@ export interface Node extends Object { }; node?: Node; name?: string; - object?: object; + object?: Record; parent?: Node; properties?: Node[]; property?: Node; - prune?: Function; - replaceWith?: (objectExpression: object) => Node; + prune?: () => void; + replaceWith?: (objectExpression: Node) => Node; size?: () => number; type?: string; value?: Node | string | Node[]; @@ -88,7 +88,7 @@ export interface JSCodeshift extends Object { Program?: ExpressionObject; filters?: { VariableDeclarator: { - requiresModule: Function; + requiresModule: (p: string) => (p: Node) => boolean; }; }; } diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts index 3cc41ec587f..cbbf25657c3 100644 --- a/packages/info/src/index.ts +++ b/packages/info/src/index.ts @@ -30,7 +30,8 @@ const DEFAULT_DETAILS: Information = { }; class InfoCommand { - async apply(cli): Promise { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + async apply(cli: any): Promise { const { logger } = cli; await cli.makeCommand( diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 8b52e1568ec..0f33450562a 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -1,7 +1,8 @@ import startDevServer from './startDevServer'; class ServeCommand { - async apply(cli): Promise { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + async apply(cli: any): Promise { const { logger } = cli; await cli.makeCommand( diff --git a/packages/serve/src/startDevServer.ts b/packages/serve/src/startDevServer.ts index ccdd113c970..5549c59f1ab 100644 --- a/packages/serve/src/startDevServer.ts +++ b/packages/serve/src/startDevServer.ts @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-var-requires */ import { devServerOptionsType } from './types'; /** @@ -11,7 +14,13 @@ import { devServerOptionsType } from './types'; * * @returns {Object[]} array of resulting servers */ -export default async function startDevServer(compiler, devServerCliOptions, cliOptions, logger): Promise { + +export default async function startDevServer( + compiler: any, + devServerCliOptions: any, + cliOptions: any, + logger: any, +): Promise[]> { let devServerVersion, Server, findPort; try { diff --git a/packages/serve/src/types.ts b/packages/serve/src/types.ts index 1f573e2364d..c7fece4b5c5 100644 --- a/packages/serve/src/types.ts +++ b/packages/serve/src/types.ts @@ -5,30 +5,30 @@ export type devServerOptionsType = { // eslint-disable-next-line @typescript-eslint/no-explicit-any dev?: Record; firewall?: boolean | string[]; - headers?: object; - historyApiFallback?: boolean | object; + headers?: Record; + historyApiFallback?: boolean | Record; host?: string | null; hot?: boolean | string; http2?: boolean; - https?: boolean | object; - injectClient?: boolean | Function; - injectHot?: boolean | Function; + https?: boolean | Record; + injectClient?: boolean | (() => void); + injectHot?: boolean | (() => void); liveReload?: boolean; - onAfterSetupMiddleware?: Function; - onBeforeSetupMiddleware?: Function; - onListening?: Function; - open?: string | boolean | object; + onAfterSetupMiddleware?: () => void; + onBeforeSetupMiddleware?: () => void; + onListening?: () => void; + open?: string | boolean | Record; openPage?: string | string[]; - overlay?: boolean | object; + overlay?: boolean | Record; port?: number | string | null; profile?: boolean; progress?: boolean; - proxy?: object | (object | Function)[]; + proxy?: Record | (Record | (() => void))[]; public?: string; - static?: boolean | string | object | (string | object)[]; - transportMode?: object | string; + static?: boolean | string | Record | (string | Record)[]; + transportMode?: Record | string; useLocalIp?: boolean; - publicPath?: string | Function; + publicPath?: string | (() => void); stats?: string | boolean; }; diff --git a/test/entry/scss/webpack.config.js b/test/entry/scss/webpack.config.js index d8d1ce1a57e..a2cec076cda 100644 --- a/test/entry/scss/webpack.config.js +++ b/test/entry/scss/webpack.config.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-missing-require */ +// eslint-disable-next-line const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { diff --git a/test/stats/flags/webpack.config.js b/test/stats/flags/webpack.config.js index e8dfd7998a5..1d31a7103f5 100644 --- a/test/stats/flags/webpack.config.js +++ b/test/stats/flags/webpack.config.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line node/no-unpublished-require const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); module.exports = { diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 34b66286b89..4c587c8967a 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -13,7 +13,6 @@ const isWebpack5 = version.startsWith('5'); let devServerVersion; try { - // eslint-disable-next-line devServerVersion = require('webpack-dev-server/package.json').version; } catch (error) { // Nothing diff --git a/yarn.lock b/yarn.lock index 8a1422527ca..9f2dbf16cd4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1806,11 +1806,6 @@ "@types/eslint" "*" "@types/estree" "*" -"@types/eslint-visitor-keys@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" - integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== - "@types/eslint@*": version "7.2.6" resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.6.tgz#5e9aff555a975596c03a98b59ecd103decc70c3c" @@ -2046,49 +2041,77 @@ dependencies: "@types/yeoman-generator" "*" -"@typescript-eslint/eslint-plugin@^2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz#6f8ce8a46c7dea4a6f1d171d2bb8fbae6dac2be9" - integrity sha512-4zY3Z88rEE99+CNvTbXSyovv2z9PNOVffTWD2W8QF5s2prBQtwN2zadqERcrHpcR7O/+KMI3fcTAmUUhK/iQcQ== +"@typescript-eslint/eslint-plugin@^4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.1.tgz#22dd301ce228aaab3416b14ead10b1db3e7d3180" + integrity sha512-5JriGbYhtqMS1kRcZTQxndz1lKMwwEXKbwZbkUZNnp6MJX0+OVXnG0kOlBZP4LUAxEyzu3cs+EXd/97MJXsGfw== dependencies: - "@typescript-eslint/experimental-utils" "2.34.0" + "@typescript-eslint/experimental-utils" "4.14.1" + "@typescript-eslint/scope-manager" "4.14.1" + debug "^4.1.1" functional-red-black-tree "^1.0.1" + lodash "^4.17.15" regexpp "^3.0.0" + semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz#d3524b644cdb40eebceca67f8cf3e4cc9c8f980f" - integrity sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA== +"@typescript-eslint/experimental-utils@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.1.tgz#a5c945cb24dabb96747180e1cfc8487f8066f471" + integrity sha512-2CuHWOJwvpw0LofbyG5gvYjEyoJeSvVH2PnfUQSn0KQr4v8Dql2pr43ohmx4fdPQ/eVoTSFjTi/bsGEXl/zUUQ== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "2.34.0" + "@typescript-eslint/scope-manager" "4.14.1" + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/typescript-estree" "4.14.1" eslint-scope "^5.0.0" eslint-utils "^2.0.0" -"@typescript-eslint/parser@^2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.34.0.tgz#50252630ca319685420e9a39ca05fe185a256bc8" - integrity sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA== +"@typescript-eslint/parser@^4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.14.1.tgz#3bd6c24710cd557d8446625284bcc9c6d52817c6" + integrity sha512-mL3+gU18g9JPsHZuKMZ8Z0Ss9YP1S5xYZ7n68Z98GnPq02pYNQuRXL85b9GYhl6jpdvUc45Km7hAl71vybjUmw== dependencies: - "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "2.34.0" - "@typescript-eslint/typescript-estree" "2.34.0" - eslint-visitor-keys "^1.1.0" + "@typescript-eslint/scope-manager" "4.14.1" + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/typescript-estree" "4.14.1" + debug "^4.1.1" -"@typescript-eslint/typescript-estree@2.34.0": - version "2.34.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5" - integrity sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg== +"@typescript-eslint/scope-manager@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.14.1.tgz#8444534254c6f370e9aa974f035ced7fe713ce02" + integrity sha512-F4bjJcSqXqHnC9JGUlnqSa3fC2YH5zTtmACS1Hk+WX/nFB0guuynVK5ev35D4XZbdKjulXBAQMyRr216kmxghw== dependencies: + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/visitor-keys" "4.14.1" + +"@typescript-eslint/types@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.14.1.tgz#b3d2eb91dafd0fd8b3fce7c61512ac66bd0364aa" + integrity sha512-SkhzHdI/AllAgQSxXM89XwS1Tkic7csPdndUuTKabEwRcEfR8uQ/iPA3Dgio1rqsV3jtqZhY0QQni8rLswJM2w== + +"@typescript-eslint/typescript-estree@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.1.tgz#20d3b8c8e3cdc8f764bdd5e5b0606dd83da6075b" + integrity sha512-M8+7MbzKC1PvJIA8kR2sSBnex8bsR5auatLCnVlNTJczmJgqRn8M+sAlQfkEq7M4IY3WmaNJ+LJjPVRrREVSHQ== + dependencies: + "@typescript-eslint/types" "4.14.1" + "@typescript-eslint/visitor-keys" "4.14.1" debug "^4.1.1" - eslint-visitor-keys "^1.1.0" - glob "^7.1.6" + globby "^11.0.1" is-glob "^4.0.1" lodash "^4.17.15" semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/visitor-keys@4.14.1": + version "4.14.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.1.tgz#e93c2ff27f47ee477a929b970ca89d60a117da91" + integrity sha512-TAblbDXOI7bd0C/9PE1G+AFo7R5uc+ty1ArDoxmrC1ah61Hn6shURKy7gLdRb1qKJmjHkqu5Oq+e4Kt0jwf1IA== + dependencies: + "@typescript-eslint/types" "4.14.1" + eslint-visitor-keys "^2.0.0" + "@webassemblyjs/ast@1.11.0": version "1.11.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" @@ -4737,6 +4760,18 @@ fast-glob@^3.0.3: micromatch "^4.0.2" picomatch "^2.2.1" +fast-glob@^3.1.1: + version "3.2.5" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661" + integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.0" + merge2 "^1.3.0" + micromatch "^4.0.2" + picomatch "^2.2.1" + fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -5391,6 +5426,18 @@ globby@^10.0.1: merge2 "^1.2.3" slash "^3.0.0" +globby@^11.0.1: + version "11.0.2" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.2.tgz#1af538b766a3b540ebfb58a32b2e2d5897321d83" + integrity sha512-2ZThXDvvV8fYFRVIxnrMQBipZQDr7MxKAmQK1vujaj9/7eF0efG7BPUKJ7jP7G5SLF37xKDXvO4S/KKLj/Z0og== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.1.1" + ignore "^5.1.4" + merge2 "^1.3.0" + slash "^3.0.0" + globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -5814,7 +5861,7 @@ ignore@^4.0.3, ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.1.1: +ignore@^5.1.1, ignore@^5.1.4: version "5.1.8" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== From cd5ba144c8b195f81e123d28c25c5b7c6cb1820d Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 18 Feb 2021 17:48:56 +0530 Subject: [PATCH 329/581] chore: skip flaky tests for windows (#2445) --- test/config-format/mjs/mjs.test.js | 7 ++++++- test/config-lookup/custom-name/custom-name.test.js | 7 ++++++- .../defaults/mjs-config/default-mjs-config.test.js | 7 ++++++- test/config/error-mjs/config-error.test.js | 10 +++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/test/config-format/mjs/mjs.test.js b/test/config-format/mjs/mjs.test.js index 97853c18bfd..f0c547a6995 100644 --- a/test/config-format/mjs/mjs.test.js +++ b/test/config-format/mjs/mjs.test.js @@ -1,4 +1,4 @@ -const { run } = require('../../utils/test-utils'); +const { run, isWindows } = require('../../utils/test-utils'); describe('webpack cli', () => { it('should support mjs config format', () => { @@ -10,6 +10,11 @@ describe('webpack cli', () => { expect(exitCode).toBe(2); expect(stdout).toBeFalsy(); } else { + // TODO: fix for windows + if (isWindows) { + expect(true).toBe(true); + return; + } expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); diff --git a/test/config-lookup/custom-name/custom-name.test.js b/test/config-lookup/custom-name/custom-name.test.js index 1f088a363e4..1e9e0cbd002 100644 --- a/test/config-lookup/custom-name/custom-name.test.js +++ b/test/config-lookup/custom-name/custom-name.test.js @@ -1,7 +1,7 @@ 'use strict'; const { resolve } = require('path'); -const { run } = require('../../utils/test-utils'); +const { run, isWindows } = require('../../utils/test-utils'); describe('custom config file', () => { it('should work with cjs format', () => { @@ -21,6 +21,11 @@ describe('custom config file', () => { expect(exitCode).toBe(2); expect(stdout).toBeFalsy(); } else { + // TODO: fix for windows + if (isWindows) { + expect(true).toBe(true); + return; + } expect(exitCode).toBe(0); expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); diff --git a/test/config/defaults/mjs-config/default-mjs-config.test.js b/test/config/defaults/mjs-config/default-mjs-config.test.js index f5b443c9613..3873d528028 100644 --- a/test/config/defaults/mjs-config/default-mjs-config.test.js +++ b/test/config/defaults/mjs-config/default-mjs-config.test.js @@ -1,6 +1,6 @@ const fs = require('fs'); const path = require('path'); -const { run, isWebpack5 } = require('../../../utils/test-utils'); +const { run, isWebpack5, isWindows } = require('../../../utils/test-utils'); describe('Default Config:', () => { it('Should be able to pick mjs config by default', () => { @@ -10,6 +10,11 @@ describe('Default Config:', () => { expect(exitCode).toEqual(2); expect(stdout).toBeFalsy(); } else { + // TODO: fix for windows + if (isWindows) { + expect(true).toBe(true); + return; + } expect(exitCode).toEqual(0); expect(stderr).toBeFalsy(); // default entry should be used diff --git a/test/config/error-mjs/config-error.test.js b/test/config/error-mjs/config-error.test.js index eb90cbf1e76..0bdf082b9b0 100644 --- a/test/config/error-mjs/config-error.test.js +++ b/test/config/error-mjs/config-error.test.js @@ -1,8 +1,16 @@ 'use strict'; const { resolve } = require('path'); -const { run } = require('../../utils/test-utils'); +const { run, isWindows } = require('../../utils/test-utils'); describe('config error', () => { + // TODO fix on windows + if (isWindows) { + it('TODO: ix on windows', () => { + expect(true).toBe(true); + }); + return; + } + it('should throw error with invalid configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.mjs')], { env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true }, From 6edc0e18527ecd91c2f5494b100ad9aab82a37a7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 18 Feb 2021 17:09:11 +0300 Subject: [PATCH 330/581] chore(deps-dev): bump @typescript-eslint Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.14.1 to 4.15.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.1/packages/eslint-plugin) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 58 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9f2dbf16cd4..5ac34f05b68 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2042,12 +2042,12 @@ "@types/yeoman-generator" "*" "@typescript-eslint/eslint-plugin@^4.14.1": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.1.tgz#22dd301ce228aaab3416b14ead10b1db3e7d3180" - integrity sha512-5JriGbYhtqMS1kRcZTQxndz1lKMwwEXKbwZbkUZNnp6MJX0+OVXnG0kOlBZP4LUAxEyzu3cs+EXd/97MJXsGfw== + version "4.15.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.1.tgz#835f64aa0a403e5e9e64c10ceaf8d05c3f015180" + integrity sha512-yW2epMYZSpNJXZy22Biu+fLdTG8Mn6b22kR3TqblVk50HGNV8Zya15WAXuQCr8tKw4Qf1BL4QtI6kv6PCkLoJw== dependencies: - "@typescript-eslint/experimental-utils" "4.14.1" - "@typescript-eslint/scope-manager" "4.14.1" + "@typescript-eslint/experimental-utils" "4.15.1" + "@typescript-eslint/scope-manager" "4.15.1" debug "^4.1.1" functional-red-black-tree "^1.0.1" lodash "^4.17.15" @@ -2055,15 +2055,15 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@4.14.1": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.1.tgz#a5c945cb24dabb96747180e1cfc8487f8066f471" - integrity sha512-2CuHWOJwvpw0LofbyG5gvYjEyoJeSvVH2PnfUQSn0KQr4v8Dql2pr43ohmx4fdPQ/eVoTSFjTi/bsGEXl/zUUQ== +"@typescript-eslint/experimental-utils@4.15.1": + version "4.15.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.1.tgz#d744d1ac40570a84b447f7aa1b526368afd17eec" + integrity sha512-9LQRmOzBRI1iOdJorr4jEnQhadxK4c9R2aEAsm7WE/7dq8wkKD1suaV0S/JucTL8QlYUPU1y2yjqg+aGC0IQBQ== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/scope-manager" "4.14.1" - "@typescript-eslint/types" "4.14.1" - "@typescript-eslint/typescript-estree" "4.14.1" + "@typescript-eslint/scope-manager" "4.15.1" + "@typescript-eslint/types" "4.15.1" + "@typescript-eslint/typescript-estree" "4.15.1" eslint-scope "^5.0.0" eslint-utils "^2.0.0" @@ -2085,11 +2085,24 @@ "@typescript-eslint/types" "4.14.1" "@typescript-eslint/visitor-keys" "4.14.1" +"@typescript-eslint/scope-manager@4.15.1": + version "4.15.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.15.1.tgz#f6511eb38def2a8a6be600c530c243bbb56ac135" + integrity sha512-ibQrTFcAm7yG4C1iwpIYK7vDnFg+fKaZVfvyOm3sNsGAerKfwPVFtYft5EbjzByDJ4dj1WD8/34REJfw/9wdVA== + dependencies: + "@typescript-eslint/types" "4.15.1" + "@typescript-eslint/visitor-keys" "4.15.1" + "@typescript-eslint/types@4.14.1": version "4.14.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.14.1.tgz#b3d2eb91dafd0fd8b3fce7c61512ac66bd0364aa" integrity sha512-SkhzHdI/AllAgQSxXM89XwS1Tkic7csPdndUuTKabEwRcEfR8uQ/iPA3Dgio1rqsV3jtqZhY0QQni8rLswJM2w== +"@typescript-eslint/types@4.15.1": + version "4.15.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.1.tgz#da702f544ef1afae4bc98da699eaecd49cf31c8c" + integrity sha512-iGsaUyWFyLz0mHfXhX4zO6P7O3sExQpBJ2dgXB0G5g/8PRVfBBsmQIc3r83ranEQTALLR3Vko/fnCIVqmH+mPw== + "@typescript-eslint/typescript-estree@4.14.1": version "4.14.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.1.tgz#20d3b8c8e3cdc8f764bdd5e5b0606dd83da6075b" @@ -2104,6 +2117,19 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@4.15.1": + version "4.15.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.1.tgz#fa9a9ff88b4a04d901ddbe5b248bc0a00cd610be" + integrity sha512-z8MN3CicTEumrWAEB2e2CcoZa3KP9+SMYLIA2aM49XW3cWIaiVSOAGq30ffR5XHxRirqE90fgLw3e6WmNx5uNw== + dependencies: + "@typescript-eslint/types" "4.15.1" + "@typescript-eslint/visitor-keys" "4.15.1" + debug "^4.1.1" + globby "^11.0.1" + is-glob "^4.0.1" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/visitor-keys@4.14.1": version "4.14.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.1.tgz#e93c2ff27f47ee477a929b970ca89d60a117da91" @@ -2112,6 +2138,14 @@ "@typescript-eslint/types" "4.14.1" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@4.15.1": + version "4.15.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.1.tgz#c76abbf2a3be8a70ed760f0e5756bf62de5865dd" + integrity sha512-tYzaTP9plooRJY8eNlpAewTOqtWW/4ff/5wBjNVaJ0S0wC4Gpq/zDVRTJa5bq2v1pCNQ08xxMCndcvR+h7lMww== + dependencies: + "@typescript-eslint/types" "4.15.1" + eslint-visitor-keys "^2.0.0" + "@webassemblyjs/ast@1.11.0": version "1.11.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" From cdd983a1eac5928d19c34de2636e3abf54d0a98d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 18 Feb 2021 20:21:47 +0300 Subject: [PATCH 331/581] chore(deps-dev): bump @typescript-eslint/parser Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.14.1 to 4.15.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.1/packages/parser) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5ac34f05b68..c68fde36863 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2068,13 +2068,13 @@ eslint-utils "^2.0.0" "@typescript-eslint/parser@^4.14.1": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.14.1.tgz#3bd6c24710cd557d8446625284bcc9c6d52817c6" - integrity sha512-mL3+gU18g9JPsHZuKMZ8Z0Ss9YP1S5xYZ7n68Z98GnPq02pYNQuRXL85b9GYhl6jpdvUc45Km7hAl71vybjUmw== + version "4.15.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.15.1.tgz#4c91a0602733db63507e1dbf13187d6c71a153c4" + integrity sha512-V8eXYxNJ9QmXi5ETDguB7O9diAXlIyS+e3xzLoP/oVE4WCAjssxLIa0mqCLsCGXulYJUfT+GV70Jv1vHsdKwtA== dependencies: - "@typescript-eslint/scope-manager" "4.14.1" - "@typescript-eslint/types" "4.14.1" - "@typescript-eslint/typescript-estree" "4.14.1" + "@typescript-eslint/scope-manager" "4.15.1" + "@typescript-eslint/types" "4.15.1" + "@typescript-eslint/typescript-estree" "4.15.1" debug "^4.1.1" "@typescript-eslint/scope-manager@4.14.1": From fbc53aeadd47fb15f09d3469e224e2107c9e43a6 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 18 Feb 2021 22:52:13 +0530 Subject: [PATCH 332/581] docs: remove migrate references (#2450) --- .github/CONTRIBUTING.md | 66 ----------------------------------------- 1 file changed, 66 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index c394cda8e83..21debd0edf9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -23,10 +23,6 @@ Table of Contents - [Submitting a good Pull Request](#submitting-a-good-pull-request) - [Commit message](#commit-message) - [Commit Message Format](#commit-message-format) -- [Migrate with the CLI](#migrate-with-the-cli) - - [How it's being done](#how-its-being-done) - - [Structure of a transform](#structure-of-a-transform) - - [Further Work](#further-work) - [Contributor License Agreement](#contributor-license-agreement) - [Documentation](#documentation) - [Releasing](#releasing) @@ -239,68 +235,6 @@ feat(webpack-cli): allow multiple values for --stats docs: update README.md ``` -## Migrate with the CLI - -```sh -webpack migrate -``` - -The expected result of the above command is to take the mentioned `webpack` configuration and create a new configuration file which is compatible with webpack 2. -It should be a valid new config and should keep intact all the features from the original config. -The new config will be as readable as possible (may add some comments). - -With [#40](https://github.com/webpack/webpack-cli/pull/40), we have been able to add basic scaffolding and do many of the conversions recommended in the [docs](https://webpack.js.org/migrate). - -### How it's being done - -We use [`jscodeshift`](https://github.com/facebook/jscodeshift) transforms called `codemods` to accomplish this. -We have written a bunch of transformations under [/lib/transformations](https://github.com/webpack/webpack-cli/tree/master/lib/transformations),divided logically. -We convert the existing webpack config to [AST](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API). We then parse this tree for the specific features and modify it to conform to webpack v2. - -#### Structure of a transform - -The directory structure of a transform looks as follows - - -```sh -│ -├──__snapshots__ -├──__testfixtures__ -│ │ -│ └───transform-name.input.js -│ -├──transform-name.js -├──transform-name.test.js -``` - -`transform-name.js` - -This file contains the actual transformation codemod. It applies specific transformation and parsing logic to accomplish its job. -There are utilities available under `/lib/utils.js` which can help you with this. - -`transform-name.test.js` - -This is where you declare a new test case for your transformation. -Each test will refer to an input webpack config snippet. -Conventionally we write them in `\_\_testfixtures\_\_`. - -```js -const defineTest = require('../defineTest'); - -defineTest(__dirname, 'transform-name.input1.js'); -defineTest(__dirname, 'transform-name.input2.js'); -``` - -`defineTest` is a helper test method which helps us to run tests on all the transforms uniformly. -It takes the input file given as parameter and uses jest to create a snapshot of the output. This effectively tests the correctness of our transformation. - -### Further Work - -This is still in a very raw form. We'd like to take this as close to a truly useful tool as possible. -We will still need to - -- Support all kinds of webpack configuration(made using merge tools) -- Test these transforms against real-world configurations. - ## Contributor License Agreement When submitting your contribution, a CLA (Contributor License Agreement) bot will come by to verify that you signed the CLA. If you are submitting a PR for the first time, it will link you to the right place to sign it. If you have committed your contributions using an email that is not the same as your email used on GitHub, the CLA bot can't accept your contribution. From 74ed07b0d27aad0ee873b039b644ea68470b3e87 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 18 Feb 2021 21:40:23 +0300 Subject: [PATCH 333/581] chore(deps-dev): bump webpack from 5.22.0 to 5.23.0 (#2451) Bumps [webpack](https://github.com/webpack/webpack) from 5.22.0 to 5.23.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.22.0...v5.23.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c68fde36863..fa022fa1bed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11156,9 +11156,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.21.1: - version "5.22.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.22.0.tgz#8505158bc52dcbbdb01ac94796a8aed61badf11a" - integrity sha512-xqlb6r9RUXda/d9iA6P7YRTP1ChWeP50TEESKMMNIg0u8/Rb66zN9YJJO7oYgJTRyFyYi43NVC5feG45FSO1vQ== + version "5.23.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.23.0.tgz#9ed57e9a54b267b3549899271ad780cddc6ee316" + integrity sha512-RC6dwDuRxiU75F8XC4H08NtzUrMfufw5LDnO8dTtaKU2+fszEdySCgZhNwSBBn516iNaJbQI7T7OPHIgCwcJmg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" From 97ab92ac75324ff9598857a971c211e4a8de067e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 14:35:13 +0300 Subject: [PATCH 334/581] chore(deps-dev): bump @types/node from 14.14.28 to 14.14.30 (#2453) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.28 to 14.14.30. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/yarn.lock b/yarn.lock index fa022fa1bed..cf087344fe2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1936,9 +1936,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.28" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.28.tgz#cade4b64f8438f588951a6b35843ce536853f25b" - integrity sha512-lg55ArB+ZiHHbBBttLpzD07akz0QPrZgUODNakeC09i62dnrywr9mFErHuaPlB6I7z+sEbK+IYmplahvplCj2g== + version "14.14.30" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.30.tgz#7d5162eec085ba34f8cb9011e9ba12119f76f961" + integrity sha512-gUWhy8s45fQp4PqqKecsnOkdW0kt1IaKjgOIR3HPokkzTmQj9ji2wWFID5THu1MKrtO+d4s2lVrlEhXUsPXSvg== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -2077,14 +2077,6 @@ "@typescript-eslint/typescript-estree" "4.15.1" debug "^4.1.1" -"@typescript-eslint/scope-manager@4.14.1": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.14.1.tgz#8444534254c6f370e9aa974f035ced7fe713ce02" - integrity sha512-F4bjJcSqXqHnC9JGUlnqSa3fC2YH5zTtmACS1Hk+WX/nFB0guuynVK5ev35D4XZbdKjulXBAQMyRr216kmxghw== - dependencies: - "@typescript-eslint/types" "4.14.1" - "@typescript-eslint/visitor-keys" "4.14.1" - "@typescript-eslint/scope-manager@4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.15.1.tgz#f6511eb38def2a8a6be600c530c243bbb56ac135" @@ -2093,30 +2085,11 @@ "@typescript-eslint/types" "4.15.1" "@typescript-eslint/visitor-keys" "4.15.1" -"@typescript-eslint/types@4.14.1": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.14.1.tgz#b3d2eb91dafd0fd8b3fce7c61512ac66bd0364aa" - integrity sha512-SkhzHdI/AllAgQSxXM89XwS1Tkic7csPdndUuTKabEwRcEfR8uQ/iPA3Dgio1rqsV3jtqZhY0QQni8rLswJM2w== - "@typescript-eslint/types@4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.1.tgz#da702f544ef1afae4bc98da699eaecd49cf31c8c" integrity sha512-iGsaUyWFyLz0mHfXhX4zO6P7O3sExQpBJ2dgXB0G5g/8PRVfBBsmQIc3r83ranEQTALLR3Vko/fnCIVqmH+mPw== -"@typescript-eslint/typescript-estree@4.14.1": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.1.tgz#20d3b8c8e3cdc8f764bdd5e5b0606dd83da6075b" - integrity sha512-M8+7MbzKC1PvJIA8kR2sSBnex8bsR5auatLCnVlNTJczmJgqRn8M+sAlQfkEq7M4IY3WmaNJ+LJjPVRrREVSHQ== - dependencies: - "@typescript-eslint/types" "4.14.1" - "@typescript-eslint/visitor-keys" "4.14.1" - debug "^4.1.1" - globby "^11.0.1" - is-glob "^4.0.1" - lodash "^4.17.15" - semver "^7.3.2" - tsutils "^3.17.1" - "@typescript-eslint/typescript-estree@4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.1.tgz#fa9a9ff88b4a04d901ddbe5b248bc0a00cd610be" @@ -2130,14 +2103,6 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/visitor-keys@4.14.1": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.1.tgz#e93c2ff27f47ee477a929b970ca89d60a117da91" - integrity sha512-TAblbDXOI7bd0C/9PE1G+AFo7R5uc+ty1ArDoxmrC1ah61Hn6shURKy7gLdRb1qKJmjHkqu5Oq+e4Kt0jwf1IA== - dependencies: - "@typescript-eslint/types" "4.14.1" - eslint-visitor-keys "^2.0.0" - "@typescript-eslint/visitor-keys@4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.1.tgz#c76abbf2a3be8a70ed760f0e5756bf62de5865dd" From fb22376b0440f81261e89f0b2025199f945454c3 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 19 Feb 2021 17:10:13 +0530 Subject: [PATCH 335/581] test: refactor (#2454) --- .../__tests__/applyCLIPlugin.test.js | 51 ------------ .../webpack-cli/__tests__/resolveArgs.test.js | 79 ------------------- .../__tests__ => test/api}/CLI.test.js | 2 +- .../api}/resolveConfig/env.webpack.config.cjs | 0 .../api}/resolveConfig/resolveConfig.test.js | 2 +- .../api}/resolveConfig/webpack.config.cjs | 0 .../api}/resolveConfig/webpack.config1.cjs | 0 .../api}/resolveConfig/webpack.config2.cjs | 0 .../resolveConfig/webpack.promise.config.cjs | 0 9 files changed, 2 insertions(+), 132 deletions(-) delete mode 100644 packages/webpack-cli/__tests__/applyCLIPlugin.test.js delete mode 100644 packages/webpack-cli/__tests__/resolveArgs.test.js rename {packages/webpack-cli/__tests__ => test/api}/CLI.test.js (99%) rename {packages/webpack-cli/__tests__ => test/api}/resolveConfig/env.webpack.config.cjs (100%) rename {packages/webpack-cli/__tests__ => test/api}/resolveConfig/resolveConfig.test.js (97%) rename {packages/webpack-cli/__tests__ => test/api}/resolveConfig/webpack.config.cjs (100%) rename {packages/webpack-cli/__tests__ => test/api}/resolveConfig/webpack.config1.cjs (100%) rename {packages/webpack-cli/__tests__ => test/api}/resolveConfig/webpack.config2.cjs (100%) rename {packages/webpack-cli/__tests__ => test/api}/resolveConfig/webpack.promise.config.cjs (100%) diff --git a/packages/webpack-cli/__tests__/applyCLIPlugin.test.js b/packages/webpack-cli/__tests__/applyCLIPlugin.test.js deleted file mode 100644 index 7889a7af624..00000000000 --- a/packages/webpack-cli/__tests__/applyCLIPlugin.test.js +++ /dev/null @@ -1,51 +0,0 @@ -const webpackCLI = require('../lib/webpack-cli'); -const CLIPlugin = require('../lib/plugins/CLIPlugin'); - -const applyCLIPlugin = new webpackCLI().applyCLIPlugin; - -describe('CLIPluginResolver', () => { - it('should add CLI plugin to single compiler object', async () => { - const result = await applyCLIPlugin({ options: {}, path: new WeakMap() }, { hot: true, prefetch: true }); - expect(result.options.plugins[0] instanceof CLIPlugin).toBeTruthy(); - expect(result.options.plugins[0].options).toEqual({ - configPath: undefined, - helpfulOutput: true, - hot: true, - progress: undefined, - prefetch: true, - analyze: undefined, - }); - }); - - it('should add CLI plugin to multi compiler object', async () => { - const result = await applyCLIPlugin({ options: [{}, {}], path: new WeakMap() }, { hot: true, prefetch: true }); - expect(result.options[0].plugins[0] instanceof CLIPlugin).toBeTruthy(); - expect(result.options[1].plugins[0] instanceof CLIPlugin).toBeTruthy(); - expect(result.options).toEqual([ - { - plugins: [ - new CLIPlugin({ - configPath: undefined, - helpfulOutput: true, - hot: true, - progress: undefined, - prefetch: true, - analyze: undefined, - }), - ], - }, - { - plugins: [ - new CLIPlugin({ - configPath: undefined, - helpfulOutput: true, - hot: true, - progress: undefined, - prefetch: true, - analyze: undefined, - }), - ], - }, - ]); - }); -}); diff --git a/packages/webpack-cli/__tests__/resolveArgs.test.js b/packages/webpack-cli/__tests__/resolveArgs.test.js deleted file mode 100644 index db8215e98d5..00000000000 --- a/packages/webpack-cli/__tests__/resolveArgs.test.js +++ /dev/null @@ -1,79 +0,0 @@ -const { resolve } = require('path'); -const webpackCLI = require('../lib/webpack-cli'); - -const targetValues = ['web', 'webworker', 'node', 'async-node', 'node-webkit', 'electron-main', 'electron-renderer', 'electron-preload']; -const cli = new webpackCLI(); - -describe('BasicResolver', () => { - it('should handle the output option', async () => { - const result = await cli.applyOptions({ options: {} }, { outputPath: './bundle' }); - - expect(result.options.output.path).toEqual(resolve('bundle')); - }); - - it('should handle the mode option [production]', async () => { - const result = await cli.applyOptions({ options: {} }, { mode: 'production' }); - - expect(result.options).toMatchObject({ mode: 'production' }); - expect(result.options.mode).toEqual('production'); - }); - - it('should handle the mode option [development]', async () => { - const result = await cli.applyOptions( - { options: {} }, - { - mode: 'development', - }, - ); - - expect(result.options).toMatchObject({ mode: 'development' }); - expect(result.options.mode).toEqual('development'); - }); - - it('should handle the mode option [none]', async () => { - const result = await cli.applyOptions( - { options: {} }, - { - mode: 'none', - }, - ); - - expect(result.options).toMatchObject({ mode: 'none' }); - expect(result.options.mode).toEqual('none'); - }); - - it('should prefer supplied move flag over NODE_ENV', async () => { - process.env.NODE_ENV = 'production'; - const result = await cli.applyOptions({ options: {} }, { mode: 'development' }); - - expect(result.options).toMatchObject({ mode: 'development' }); - }); - - it('should prefer supplied move flag over mode from config', async () => { - const result = await cli.applyOptions({ options: { mode: 'development' } }, { mode: 'production' }); - - expect(result.options).toMatchObject({ mode: 'production' }); - }); - - it('should prefer mode form config over NODE_ENV', async () => { - process.env.NODE_ENV = 'development'; - const result = await cli.applyOptions({ options: {} }, { mode: 'production' }); - - expect(result.options).toMatchObject({ mode: 'production' }); - }); - - it('should prefer mode form flag over NODE_ENV and config', async () => { - process.env.NODE_ENV = 'development'; - const result = await cli.applyOptions({ options: {} }, {}); - - expect(result.options).toMatchObject({ mode: 'development' }); - }); - - targetValues.map((option) => { - it(`should handle ${option} option`, async () => { - const result = await cli.applyOptions({ options: {} }, { target: option }); - - expect(result.options.target).toEqual(option); - }); - }); -}); diff --git a/packages/webpack-cli/__tests__/CLI.test.js b/test/api/CLI.test.js similarity index 99% rename from packages/webpack-cli/__tests__/CLI.test.js rename to test/api/CLI.test.js index 348e081893a..a56e71c8769 100644 --- a/packages/webpack-cli/__tests__/CLI.test.js +++ b/test/api/CLI.test.js @@ -1,4 +1,4 @@ -const CLI = require('../lib/webpack-cli'); +const CLI = require('../../packages/webpack-cli/lib/webpack-cli'); describe('CLI API', () => { let cli; diff --git a/packages/webpack-cli/__tests__/resolveConfig/env.webpack.config.cjs b/test/api/resolveConfig/env.webpack.config.cjs similarity index 100% rename from packages/webpack-cli/__tests__/resolveConfig/env.webpack.config.cjs rename to test/api/resolveConfig/env.webpack.config.cjs diff --git a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js b/test/api/resolveConfig/resolveConfig.test.js similarity index 97% rename from packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js rename to test/api/resolveConfig/resolveConfig.test.js index d3002fb0225..cff857beb18 100644 --- a/packages/webpack-cli/__tests__/resolveConfig/resolveConfig.test.js +++ b/test/api/resolveConfig/resolveConfig.test.js @@ -1,5 +1,5 @@ const { resolve } = require('path'); -const WebpackCLI = require('../../lib/webpack-cli'); +const WebpackCLI = require('../../../packages/webpack-cli/lib/webpack-cli'); const config1 = require('./webpack.config1.cjs'); const config2 = require('./webpack.config2.cjs'); const arrayConfig = require('./webpack.config.cjs'); diff --git a/packages/webpack-cli/__tests__/resolveConfig/webpack.config.cjs b/test/api/resolveConfig/webpack.config.cjs similarity index 100% rename from packages/webpack-cli/__tests__/resolveConfig/webpack.config.cjs rename to test/api/resolveConfig/webpack.config.cjs diff --git a/packages/webpack-cli/__tests__/resolveConfig/webpack.config1.cjs b/test/api/resolveConfig/webpack.config1.cjs similarity index 100% rename from packages/webpack-cli/__tests__/resolveConfig/webpack.config1.cjs rename to test/api/resolveConfig/webpack.config1.cjs diff --git a/packages/webpack-cli/__tests__/resolveConfig/webpack.config2.cjs b/test/api/resolveConfig/webpack.config2.cjs similarity index 100% rename from packages/webpack-cli/__tests__/resolveConfig/webpack.config2.cjs rename to test/api/resolveConfig/webpack.config2.cjs diff --git a/packages/webpack-cli/__tests__/resolveConfig/webpack.promise.config.cjs b/test/api/resolveConfig/webpack.promise.config.cjs similarity index 100% rename from packages/webpack-cli/__tests__/resolveConfig/webpack.promise.config.cjs rename to test/api/resolveConfig/webpack.promise.config.cjs From b121039f5dca04de7b495dd08176d0615164a2cb Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 20 Feb 2021 15:46:43 +0300 Subject: [PATCH 336/581] chore(deps-dev): bump @types/node Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.30 to 14.14.31. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index cf087344fe2..edab1d93118 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1936,9 +1936,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.6": - version "14.14.30" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.30.tgz#7d5162eec085ba34f8cb9011e9ba12119f76f961" - integrity sha512-gUWhy8s45fQp4PqqKecsnOkdW0kt1IaKjgOIR3HPokkzTmQj9ji2wWFID5THu1MKrtO+d4s2lVrlEhXUsPXSvg== + version "14.14.31" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.31.tgz#72286bd33d137aa0d152d47ec7c1762563d34055" + integrity sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 66ac9eb5989fa1ec6136d5463291b231a5684fa6 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 24 Feb 2021 14:21:05 +0300 Subject: [PATCH 337/581] chore(deps-dev): bump typescript from 4.1.5 to 4.2.2 (#2463) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.1.5 to 4.2.2. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/commits) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index edab1d93118..c10875d581c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10740,9 +10740,9 @@ typedarray@^0.0.6: integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= typescript@^4.1.3: - version "4.1.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.5.tgz#123a3b214aaff3be32926f0d8f1f6e704eb89a72" - integrity sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA== + version "4.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.2.tgz#1450f020618f872db0ea17317d16d8da8ddb8c4c" + integrity sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ== uglify-js@^3.1.4: version "3.11.4" From c1462a44f7e954b947d0f9b34dfb9483a1010052 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 24 Feb 2021 14:21:23 +0300 Subject: [PATCH 338/581] chore(deps-dev): bump ts-jest from 26.5.1 to 26.5.2 (#2465) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.1 to 26.5.2. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v26.5.1...v26.5.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c10875d581c..7f565e676b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10618,9 +10618,9 @@ trim-off-newlines@^1.0.0: integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= ts-jest@^26.4.3: - version "26.5.1" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.1.tgz#4d53ee4481552f57c1624f0bd3425c8b17996150" - integrity sha512-G7Rmo3OJMvlqE79amJX8VJKDiRcd7/r61wh9fnvvG8cAjhA9edklGw/dCxRSQmfZ/z8NDums5srSVgwZos1qfg== + version "26.5.2" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.2.tgz#5281d6b44c2f94f71205728a389edc3d7995b0c4" + integrity sha512-bwyJ2zJieSugf7RB+o8fgkMeoMVMM2KPDE0UklRLuACxjwJsOrZNo6chrcScmK33YavPSwhARffy8dZx5LJdUQ== dependencies: "@types/jest" "26.x" bs-logger "0.x" From 06431900d2fb97a2d033003374d81721e84bebc6 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 24 Feb 2021 14:21:30 +0300 Subject: [PATCH 339/581] chore(deps-dev): bump webpack from 5.23.0 to 5.24.1 (#2464) Bumps [webpack](https://github.com/webpack/webpack) from 5.23.0 to 5.24.1. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.23.0...v5.24.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7f565e676b7..cdf9bc38989 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4318,10 +4318,10 @@ es-abstract@^1.18.0-next.0, es-abstract@^1.18.0-next.1: string.prototype.trimend "^1.0.1" string.prototype.trimstart "^1.0.1" -es-module-lexer@^0.3.26: - version "0.3.26" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.3.26.tgz#7b507044e97d5b03b01d4392c74ffeb9c177a83b" - integrity sha512-Va0Q/xqtrss45hWzP8CZJwzGSZJjDM5/MJRE3IXXnUCcVLElR9BRaE9F62BopysASyc4nM3uwhSW7FFB9nlWAA== +es-module-lexer@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.4.0.tgz#21f4181cc8b7eee06855f1c59e6087c7bc4f77b0" + integrity sha512-iuEGihqqhKWFgh72Q/Jtch7V2t/ft8w8IPP2aEN8ArYKO+IWyo6hsi96hCdgyeEDQIV3InhYQ9BlwUFPGXrbEQ== es-to-primitive@^1.2.1: version "1.2.1" @@ -11121,9 +11121,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.21.1: - version "5.23.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.23.0.tgz#9ed57e9a54b267b3549899271ad780cddc6ee316" - integrity sha512-RC6dwDuRxiU75F8XC4H08NtzUrMfufw5LDnO8dTtaKU2+fszEdySCgZhNwSBBn516iNaJbQI7T7OPHIgCwcJmg== + version "5.24.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.24.1.tgz#6b7730bfba1ee94b05d05ef7c32743a35105a744" + integrity sha512-eg+6OIt6npUSwbhRQY6XffAixEUSARBf+WAWOxrZwOB4jRbbpMXlridFy/Yt7N0U20Ry1vp/nnDbtN7l1rUdIA== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" @@ -11134,7 +11134,7 @@ webpack@^5.21.1: browserslist "^4.14.5" chrome-trace-event "^1.0.2" enhanced-resolve "^5.7.0" - es-module-lexer "^0.3.26" + es-module-lexer "^0.4.0" eslint-scope "^5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" From 4777381bfad4935ac90bdc58f02cd347f203222a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 24 Feb 2021 14:47:05 +0300 Subject: [PATCH 340/581] chore(deps-dev): bump @typescript-eslint/parser Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.15.1 to 4.15.2. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.2/packages/parser) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index cdf9bc38989..46775103eb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2068,13 +2068,13 @@ eslint-utils "^2.0.0" "@typescript-eslint/parser@^4.14.1": - version "4.15.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.15.1.tgz#4c91a0602733db63507e1dbf13187d6c71a153c4" - integrity sha512-V8eXYxNJ9QmXi5ETDguB7O9diAXlIyS+e3xzLoP/oVE4WCAjssxLIa0mqCLsCGXulYJUfT+GV70Jv1vHsdKwtA== + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.15.2.tgz#c804474321ef76a3955aec03664808f0d6e7872e" + integrity sha512-SHeF8xbsC6z2FKXsaTb1tBCf0QZsjJ94H6Bo51Y1aVEZ4XAefaw5ZAilMoDPlGghe+qtq7XdTiDlGfVTOmvA+Q== dependencies: - "@typescript-eslint/scope-manager" "4.15.1" - "@typescript-eslint/types" "4.15.1" - "@typescript-eslint/typescript-estree" "4.15.1" + "@typescript-eslint/scope-manager" "4.15.2" + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/typescript-estree" "4.15.2" debug "^4.1.1" "@typescript-eslint/scope-manager@4.15.1": @@ -2085,11 +2085,24 @@ "@typescript-eslint/types" "4.15.1" "@typescript-eslint/visitor-keys" "4.15.1" +"@typescript-eslint/scope-manager@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.15.2.tgz#5725bda656995960ae1d004bfd1cd70320f37f4f" + integrity sha512-Zm0tf/MSKuX6aeJmuXexgdVyxT9/oJJhaCkijv0DvJVT3ui4zY6XYd6iwIo/8GEZGy43cd7w1rFMiCLHbRzAPQ== + dependencies: + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/visitor-keys" "4.15.2" + "@typescript-eslint/types@4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.1.tgz#da702f544ef1afae4bc98da699eaecd49cf31c8c" integrity sha512-iGsaUyWFyLz0mHfXhX4zO6P7O3sExQpBJ2dgXB0G5g/8PRVfBBsmQIc3r83ranEQTALLR3Vko/fnCIVqmH+mPw== +"@typescript-eslint/types@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.2.tgz#04acf3a2dc8001a88985291744241e732ef22c60" + integrity sha512-r7lW7HFkAarfUylJ2tKndyO9njwSyoy6cpfDKWPX6/ctZA+QyaYscAHXVAfJqtnY6aaTwDYrOhp+ginlbc7HfQ== + "@typescript-eslint/typescript-estree@4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.1.tgz#fa9a9ff88b4a04d901ddbe5b248bc0a00cd610be" @@ -2103,6 +2116,19 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.2.tgz#c2f7a1e94f3428d229d5ecff3ead6581ee9b62fa" + integrity sha512-cGR8C2g5SPtHTQvAymEODeqx90pJHadWsgTtx6GbnTWKqsg7yp6Eaya9nFzUd4KrKhxdYTTFBiYeTPQaz/l8bw== + dependencies: + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/visitor-keys" "4.15.2" + debug "^4.1.1" + globby "^11.0.1" + is-glob "^4.0.1" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/visitor-keys@4.15.1": version "4.15.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.1.tgz#c76abbf2a3be8a70ed760f0e5756bf62de5865dd" @@ -2111,6 +2137,14 @@ "@typescript-eslint/types" "4.15.1" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.2.tgz#3d1c7979ce75bf6acf9691109bd0d6b5706192b9" + integrity sha512-TME1VgSb7wTwgENN5KVj4Nqg25hP8DisXxNBojM4Nn31rYaNDIocNm5cmjOFfh42n7NVERxWrDFoETO/76ePyg== + dependencies: + "@typescript-eslint/types" "4.15.2" + eslint-visitor-keys "^2.0.0" + "@webassemblyjs/ast@1.11.0": version "1.11.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" From 8222de9faa1f0469fa4430d6c504b0d723d05891 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 24 Feb 2021 14:47:17 +0300 Subject: [PATCH 341/581] chore(deps-dev): bump @typescript-eslint/eslint-plugin Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.15.1 to 4.15.2. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.15.2/packages/eslint-plugin) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/yarn.lock b/yarn.lock index 46775103eb2..7ac4460752b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2042,12 +2042,12 @@ "@types/yeoman-generator" "*" "@typescript-eslint/eslint-plugin@^4.14.1": - version "4.15.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.1.tgz#835f64aa0a403e5e9e64c10ceaf8d05c3f015180" - integrity sha512-yW2epMYZSpNJXZy22Biu+fLdTG8Mn6b22kR3TqblVk50HGNV8Zya15WAXuQCr8tKw4Qf1BL4QtI6kv6PCkLoJw== + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.2.tgz#981b26b4076c62a5a55873fbef3fe98f83360c61" + integrity sha512-uiQQeu9tWl3f1+oK0yoAv9lt/KXO24iafxgQTkIYO/kitruILGx3uH+QtIAHqxFV+yIsdnJH+alel9KuE3J15Q== dependencies: - "@typescript-eslint/experimental-utils" "4.15.1" - "@typescript-eslint/scope-manager" "4.15.1" + "@typescript-eslint/experimental-utils" "4.15.2" + "@typescript-eslint/scope-manager" "4.15.2" debug "^4.1.1" functional-red-black-tree "^1.0.1" lodash "^4.17.15" @@ -2055,15 +2055,15 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@4.15.1": - version "4.15.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.1.tgz#d744d1ac40570a84b447f7aa1b526368afd17eec" - integrity sha512-9LQRmOzBRI1iOdJorr4jEnQhadxK4c9R2aEAsm7WE/7dq8wkKD1suaV0S/JucTL8QlYUPU1y2yjqg+aGC0IQBQ== +"@typescript-eslint/experimental-utils@4.15.2": + version "4.15.2" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.2.tgz#5efd12355bd5b535e1831282e6cf465b9a71cf36" + integrity sha512-Fxoshw8+R5X3/Vmqwsjc8nRO/7iTysRtDqx6rlfLZ7HbT8TZhPeQqbPjTyk2RheH3L8afumecTQnUc9EeXxohQ== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/scope-manager" "4.15.1" - "@typescript-eslint/types" "4.15.1" - "@typescript-eslint/typescript-estree" "4.15.1" + "@typescript-eslint/scope-manager" "4.15.2" + "@typescript-eslint/types" "4.15.2" + "@typescript-eslint/typescript-estree" "4.15.2" eslint-scope "^5.0.0" eslint-utils "^2.0.0" From 9d3ece045aea2f95cff03da58707c343d960d64f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 25 Feb 2021 14:24:31 +0300 Subject: [PATCH 342/581] chore(deps-dev): bump webpack from 5.24.1 to 5.24.2 (#2466) Bumps [webpack](https://github.com/webpack/webpack) from 5.24.1 to 5.24.2. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.24.1...v5.24.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 40 +++------------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7ac4460752b..8571a0b521c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2077,14 +2077,6 @@ "@typescript-eslint/typescript-estree" "4.15.2" debug "^4.1.1" -"@typescript-eslint/scope-manager@4.15.1": - version "4.15.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.15.1.tgz#f6511eb38def2a8a6be600c530c243bbb56ac135" - integrity sha512-ibQrTFcAm7yG4C1iwpIYK7vDnFg+fKaZVfvyOm3sNsGAerKfwPVFtYft5EbjzByDJ4dj1WD8/34REJfw/9wdVA== - dependencies: - "@typescript-eslint/types" "4.15.1" - "@typescript-eslint/visitor-keys" "4.15.1" - "@typescript-eslint/scope-manager@4.15.2": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.15.2.tgz#5725bda656995960ae1d004bfd1cd70320f37f4f" @@ -2093,29 +2085,11 @@ "@typescript-eslint/types" "4.15.2" "@typescript-eslint/visitor-keys" "4.15.2" -"@typescript-eslint/types@4.15.1": - version "4.15.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.1.tgz#da702f544ef1afae4bc98da699eaecd49cf31c8c" - integrity sha512-iGsaUyWFyLz0mHfXhX4zO6P7O3sExQpBJ2dgXB0G5g/8PRVfBBsmQIc3r83ranEQTALLR3Vko/fnCIVqmH+mPw== - "@typescript-eslint/types@4.15.2": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.2.tgz#04acf3a2dc8001a88985291744241e732ef22c60" integrity sha512-r7lW7HFkAarfUylJ2tKndyO9njwSyoy6cpfDKWPX6/ctZA+QyaYscAHXVAfJqtnY6aaTwDYrOhp+ginlbc7HfQ== -"@typescript-eslint/typescript-estree@4.15.1": - version "4.15.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.1.tgz#fa9a9ff88b4a04d901ddbe5b248bc0a00cd610be" - integrity sha512-z8MN3CicTEumrWAEB2e2CcoZa3KP9+SMYLIA2aM49XW3cWIaiVSOAGq30ffR5XHxRirqE90fgLw3e6WmNx5uNw== - dependencies: - "@typescript-eslint/types" "4.15.1" - "@typescript-eslint/visitor-keys" "4.15.1" - debug "^4.1.1" - globby "^11.0.1" - is-glob "^4.0.1" - semver "^7.3.2" - tsutils "^3.17.1" - "@typescript-eslint/typescript-estree@4.15.2": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.2.tgz#c2f7a1e94f3428d229d5ecff3ead6581ee9b62fa" @@ -2129,14 +2103,6 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/visitor-keys@4.15.1": - version "4.15.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.1.tgz#c76abbf2a3be8a70ed760f0e5756bf62de5865dd" - integrity sha512-tYzaTP9plooRJY8eNlpAewTOqtWW/4ff/5wBjNVaJ0S0wC4Gpq/zDVRTJa5bq2v1pCNQ08xxMCndcvR+h7lMww== - dependencies: - "@typescript-eslint/types" "4.15.1" - eslint-visitor-keys "^2.0.0" - "@typescript-eslint/visitor-keys@4.15.2": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.2.tgz#3d1c7979ce75bf6acf9691109bd0d6b5706192b9" @@ -11155,9 +11121,9 @@ webpack-sources@^2.1.1: source-map "^0.6.1" webpack@^5.21.1: - version "5.24.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.24.1.tgz#6b7730bfba1ee94b05d05ef7c32743a35105a744" - integrity sha512-eg+6OIt6npUSwbhRQY6XffAixEUSARBf+WAWOxrZwOB4jRbbpMXlridFy/Yt7N0U20Ry1vp/nnDbtN7l1rUdIA== + version "5.24.2" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.24.2.tgz#33790dad631e8b639f4246d762e257720875fe54" + integrity sha512-uxxKYEY4kMNjP+D2Y+8aw5Vd7ar4pMuKCNemxV26ysr1nk0YDiQTylg9U3VZIdkmI0YHa0uC8ABxL+uGxGWWJg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46" From b1c035fae6771325781f71533fa90f2c9e4c4863 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 25 Feb 2021 18:57:56 +0300 Subject: [PATCH 343/581] chore(deps): bump colorette from 1.2.1 to 1.2.2 (#2467) Bumps [colorette](https://github.com/jorgebucaran/colorette) from 1.2.1 to 1.2.2. - [Release notes](https://github.com/jorgebucaran/colorette/releases) - [Commits](https://github.com/jorgebucaran/colorette/compare/1.2.1...1.2.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8571a0b521c..9ee6575eb42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3370,9 +3370,9 @@ color-name@~1.1.4: integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== colorette@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b" - integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw== + version "1.2.2" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" + integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== colors@1.0.3: version "1.0.3" From 3772148fda2b52d6498ad9d4f43e2dae0eb8f3a2 Mon Sep 17 00:00:00 2001 From: Sumukha Hegde Date: Sun, 28 Feb 2021 13:33:46 +0530 Subject: [PATCH 344/581] docs: grammatical error in webpack-cli commands and arguments usage (#2469) --- packages/webpack-cli/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index 86941f9f47a..bbd61977060 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -42,7 +42,7 @@ If no command is specified then `bundle` command is used by default ### Help Usage -You display basic commands and arguments - +To display basic commands and arguments - ```bash npx webpack-cli --help From a1809892047088b9039b2454934eba034ac9c42e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 15:28:56 +0300 Subject: [PATCH 345/581] chore(deps-dev): bump eslint from 7.20.0 to 7.21.0 (#2471) Bumps [eslint](https://github.com/eslint/eslint) from 7.20.0 to 7.21.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.20.0...v7.21.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9ee6575eb42..e33b1d478a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -542,10 +542,10 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz#8f03a22a04de437254e8ce8cc84ba39689288752" integrity sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg== -"@eslint/eslintrc@^0.3.0": - version "0.3.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.3.0.tgz#d736d6963d7003b6514e6324bec9c602ac340318" - integrity sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg== +"@eslint/eslintrc@^0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.0.tgz#99cc0a0584d72f1df38b900fb062ba995f395547" + integrity sha512-2ZPCc+uNbjV5ERJr+aKSPRwZgKd2z11x0EgLvb1PURmUrn9QNRXFqje0Ldq454PfAVyaJYyrDvvIKSFP4NnBog== dependencies: ajv "^6.12.4" debug "^4.1.1" @@ -554,7 +554,6 @@ ignore "^4.0.6" import-fresh "^3.2.1" js-yaml "^3.13.1" - lodash "^4.17.20" minimatch "^3.0.4" strip-json-comments "^3.1.1" @@ -4439,12 +4438,12 @@ eslint-visitor-keys@^2.0.0: integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== eslint@^7.12.1: - version "7.20.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.20.0.tgz#db07c4ca4eda2e2316e7aa57ac7fc91ec550bdc7" - integrity sha512-qGi0CTcOGP2OtCQBgWZlQjcTuP0XkIpYFj25XtRTQSHC+umNnp7UMshr2G8SLsRFYDdAPFeHOsiteadmMH02Yw== + version "7.21.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.21.0.tgz#4ecd5b8c5b44f5dedc9b8a110b01bbfeb15d1c83" + integrity sha512-W2aJbXpMNofUp0ztQaF40fveSsJBjlSCSWpy//gzfTvwC+USs/nceBrKmlJOiM8r1bLwP2EuYkCqArn/6QTIgg== dependencies: "@babel/code-frame" "7.12.11" - "@eslint/eslintrc" "^0.3.0" + "@eslint/eslintrc" "^0.4.0" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -4457,7 +4456,7 @@ eslint@^7.12.1: espree "^7.3.1" esquery "^1.4.0" esutils "^2.0.2" - file-entry-cache "^6.0.0" + file-entry-cache "^6.0.1" functional-red-black-tree "^1.0.1" glob-parent "^5.0.0" globals "^12.1.0" @@ -4834,10 +4833,10 @@ figures@^3.0.0, figures@^3.2.0: dependencies: escape-string-regexp "^1.0.5" -file-entry-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.0.tgz#7921a89c391c6d93efec2169ac6bf300c527ea0a" - integrity sha512-fqoO76jZ3ZnYrXLDRxBR1YvOvc0k844kcOg40bgsPrE25LAb/PDqTY+ho64Xh2c8ZXgIKldchCFHczG2UVRcWA== +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== dependencies: flat-cache "^3.0.4" From 375e2f5b209a8992f89877fe35c441e1d0e9407e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 2 Mar 2021 12:50:45 +0300 Subject: [PATCH 346/581] chore(deps-dev): bump @typescript-eslint/eslint-plugin Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.15.2 to 4.16.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.16.1/packages/eslint-plugin) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 58 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/yarn.lock b/yarn.lock index e33b1d478a9..ad66ddaeeca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2041,12 +2041,12 @@ "@types/yeoman-generator" "*" "@typescript-eslint/eslint-plugin@^4.14.1": - version "4.15.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.2.tgz#981b26b4076c62a5a55873fbef3fe98f83360c61" - integrity sha512-uiQQeu9tWl3f1+oK0yoAv9lt/KXO24iafxgQTkIYO/kitruILGx3uH+QtIAHqxFV+yIsdnJH+alel9KuE3J15Q== + version "4.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.16.1.tgz#2caf6a79dd19c3853b8d39769a27fccb24e4e651" + integrity sha512-SK777klBdlkUZpZLC1mPvyOWk9yAFCWmug13eAjVQ4/Q1LATE/NbcQL1xDHkptQkZOLnPmLUA1Y54m8dqYwnoQ== dependencies: - "@typescript-eslint/experimental-utils" "4.15.2" - "@typescript-eslint/scope-manager" "4.15.2" + "@typescript-eslint/experimental-utils" "4.16.1" + "@typescript-eslint/scope-manager" "4.16.1" debug "^4.1.1" functional-red-black-tree "^1.0.1" lodash "^4.17.15" @@ -2054,15 +2054,15 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@4.15.2": - version "4.15.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.2.tgz#5efd12355bd5b535e1831282e6cf465b9a71cf36" - integrity sha512-Fxoshw8+R5X3/Vmqwsjc8nRO/7iTysRtDqx6rlfLZ7HbT8TZhPeQqbPjTyk2RheH3L8afumecTQnUc9EeXxohQ== +"@typescript-eslint/experimental-utils@4.16.1": + version "4.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.16.1.tgz#da7a396dc7d0e01922acf102b76efff17320b328" + integrity sha512-0Hm3LSlMYFK17jO4iY3un1Ve9x1zLNn4EM50Lia+0EV99NdbK+cn0er7HC7IvBA23mBg3P+8dUkMXy4leL33UQ== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/scope-manager" "4.15.2" - "@typescript-eslint/types" "4.15.2" - "@typescript-eslint/typescript-estree" "4.15.2" + "@typescript-eslint/scope-manager" "4.16.1" + "@typescript-eslint/types" "4.16.1" + "@typescript-eslint/typescript-estree" "4.16.1" eslint-scope "^5.0.0" eslint-utils "^2.0.0" @@ -2084,11 +2084,24 @@ "@typescript-eslint/types" "4.15.2" "@typescript-eslint/visitor-keys" "4.15.2" +"@typescript-eslint/scope-manager@4.16.1": + version "4.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.16.1.tgz#244e2006bc60cfe46987e9987f4ff49c9e3f00d5" + integrity sha512-6IlZv9JaurqV0jkEg923cV49aAn8V6+1H1DRfhRcvZUrptQ+UtSKHb5kwTayzOYTJJ/RsYZdcvhOEKiBLyc0Cw== + dependencies: + "@typescript-eslint/types" "4.16.1" + "@typescript-eslint/visitor-keys" "4.16.1" + "@typescript-eslint/types@4.15.2": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.15.2.tgz#04acf3a2dc8001a88985291744241e732ef22c60" integrity sha512-r7lW7HFkAarfUylJ2tKndyO9njwSyoy6cpfDKWPX6/ctZA+QyaYscAHXVAfJqtnY6aaTwDYrOhp+ginlbc7HfQ== +"@typescript-eslint/types@4.16.1": + version "4.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.16.1.tgz#5ba2d3e38b1a67420d2487519e193163054d9c15" + integrity sha512-nnKqBwMgRlhzmJQF8tnFDZWfunXmJyuXj55xc8Kbfup4PbkzdoDXZvzN8//EiKR27J6vUSU8j4t37yUuYPiLqA== + "@typescript-eslint/typescript-estree@4.15.2": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.2.tgz#c2f7a1e94f3428d229d5ecff3ead6581ee9b62fa" @@ -2102,6 +2115,19 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@4.16.1": + version "4.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.16.1.tgz#c2fc46b05a48fbf8bbe8b66a63f0a9ba04b356f1" + integrity sha512-m8I/DKHa8YbeHt31T+UGd/l8Kwr0XCTCZL3H4HMvvLCT7HU9V7yYdinTOv1gf/zfqNeDcCgaFH2BMsS8x6NvJg== + dependencies: + "@typescript-eslint/types" "4.16.1" + "@typescript-eslint/visitor-keys" "4.16.1" + debug "^4.1.1" + globby "^11.0.1" + is-glob "^4.0.1" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/visitor-keys@4.15.2": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.2.tgz#3d1c7979ce75bf6acf9691109bd0d6b5706192b9" @@ -2110,6 +2136,14 @@ "@typescript-eslint/types" "4.15.2" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@4.16.1": + version "4.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.16.1.tgz#d7571fb580749fae621520deeb134370bbfc7293" + integrity sha512-s/aIP1XcMkEqCNcPQtl60ogUYjSM8FU2mq1O7y5cFf3Xcob1z1iXWNB6cC43Op+NGRTFgGolri6s8z/efA9i1w== + dependencies: + "@typescript-eslint/types" "4.16.1" + eslint-visitor-keys "^2.0.0" + "@webassemblyjs/ast@1.11.0": version "1.11.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" From 609767aff9f9658e998457f09e05f4cc3280d3cc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 2 Mar 2021 12:53:45 +0300 Subject: [PATCH 347/581] chore(deps-dev): bump @typescript-eslint/parser Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.15.2 to 4.16.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.16.1/packages/parser) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index ad66ddaeeca..b99d691b698 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2067,13 +2067,13 @@ eslint-utils "^2.0.0" "@typescript-eslint/parser@^4.14.1": - version "4.15.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.15.2.tgz#c804474321ef76a3955aec03664808f0d6e7872e" - integrity sha512-SHeF8xbsC6z2FKXsaTb1tBCf0QZsjJ94H6Bo51Y1aVEZ4XAefaw5ZAilMoDPlGghe+qtq7XdTiDlGfVTOmvA+Q== + version "4.16.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.16.1.tgz#3bbd3234dd3c5b882b2bcd9899bc30e1e1586d2a" + integrity sha512-/c0LEZcDL5y8RyI1zLcmZMvJrsR6SM1uetskFkoh3dvqDKVXPsXI+wFB/CbVw7WkEyyTKobC1mUNp/5y6gRvXg== dependencies: - "@typescript-eslint/scope-manager" "4.15.2" - "@typescript-eslint/types" "4.15.2" - "@typescript-eslint/typescript-estree" "4.15.2" + "@typescript-eslint/scope-manager" "4.16.1" + "@typescript-eslint/types" "4.16.1" + "@typescript-eslint/typescript-estree" "4.16.1" debug "^4.1.1" "@typescript-eslint/scope-manager@4.15.2": From 4cd3796023c498c6aaa92f26138701ad1c46dac9 Mon Sep 17 00:00:00 2001 From: Sumukha Hegde Date: Tue, 2 Mar 2021 15:46:56 +0530 Subject: [PATCH 348/581] docs: fix a typo at contrbuting readme file (#2470) Removed an extra line space in commit message format --- .github/CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 21debd0edf9..5a8214cbd5c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -196,10 +196,9 @@ We don't use the scope. The template of a commit would look like this: Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type** and a **subject**: -```md +``` : -