From 898462db462b501f6779c4de014b6b7890daaf80 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 29 Aug 2018 17:37:41 +0300 Subject: [PATCH 1/3] refactor: remove `webpack-command` from CLIs --- bin/webpack.js | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/bin/webpack.js b/bin/webpack.js index 977fe5c93ea..f0573a68983 100755 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -103,9 +103,7 @@ if (installedClis.length === 0) { )}".` ); - let question = `Which one do you like to install (${CLIs.map( - item => item.name - ).join("/")}):\n`; + let question = `Do you want to install 'webpack-cli' (yes/no): `; const questionInterface = readLine.createInterface({ input: process.stdin, @@ -114,35 +112,22 @@ if (installedClis.length === 0) { questionInterface.question(question, answer => { questionInterface.close(); - const normalizedAnswer = answer.toLowerCase(); - const selectedPackage = CLIs.find(item => { - return item.name === normalizedAnswer || item.alias === normalizedAnswer; - }); + const normalizedAnswer = answer.toLowerCase().startsWith("y"); if (!normalizedAnswer) { console.error( - "One CLI needs to be installed alongside webpack to use the CLI." - ); - process.exitCode = 1; - - return; - } else if (!selectedPackage) { - console.error( - "No matching choice.\n" + - "One CLI needs to be installed alongside webpack to use the CLI.\n" + - "Try to installing your CLI of choice manually." + "You need to install 'webpack-cli' for using webpack via CLI.\n" + + "Also you can installing CLI manually." ); process.exitCode = 1; return; } - const packageName = selectedPackage.package; + const packageName = "webpack-cli"; console.log( - `Installing '${ - selectedPackage.name - }' (running '${packageManager} ${installOptions.join( + `Installing '${packageName}' (running '${packageManager} ${installOptions.join( " " )} ${packageName}')...` ); From 691cc94e0f4851ef9f9d3156d45f023f2dfe3217 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 5 Sep 2018 14:01:44 +0200 Subject: [PATCH 2/3] Spelling --- bin/webpack.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/webpack.js b/bin/webpack.js index f0573a68983..0bf012cbe34 100755 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -116,8 +116,8 @@ if (installedClis.length === 0) { if (!normalizedAnswer) { console.error( - "You need to install 'webpack-cli' for using webpack via CLI.\n" + - "Also you can installing CLI manually." + "You need to install 'webpack-cli' to use webpack via CLI.\n" + + "You can also install the CLI manually." ); process.exitCode = 1; From b717aadf491a784ae1c72d797a626a6778bd8b53 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 10 Sep 2018 14:53:54 +0200 Subject: [PATCH 3/3] Show only webpack-cli in the list --- bin/webpack.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/webpack.js b/bin/webpack.js index 0bf012cbe34..3fb260c01e0 100755 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -50,6 +50,7 @@ const isInstalled = packageName => { * @property {string} binName name of the executable file * @property {string} alias shortcut for choice * @property {boolean} installed currently installed? + * @property {boolean} recommended is recommended * @property {string} url homepage * @property {string} description description */ @@ -62,6 +63,7 @@ const CLIs = [ binName: "webpack-cli", alias: "cli", installed: isInstalled("webpack-cli"), + recommended: true, url: "https://github.com/webpack/webpack-cli", description: "The original webpack full-featured CLI." }, @@ -71,6 +73,7 @@ const CLIs = [ binName: "webpack-command", alias: "command", installed: isInstalled("webpack-command"), + recommended: false, url: "https://github.com/webpack-contrib/webpack-command", description: "A lightweight, opinionated webpack CLI." } @@ -87,7 +90,9 @@ if (installedClis.length === 0) { "One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:"; for (const item of CLIs) { - notify += `\n - ${item.name} (${item.url})\n ${item.description}`; + if (item.recommended) { + notify += `\n - ${item.name} (${item.url})\n ${item.description}`; + } } console.error(notify);