From c9ee947618c06447bc1f949e4d401e63f737f38d Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 16 Apr 2021 16:45:40 +0530 Subject: [PATCH] feat: add `server` alias for `serve` command (#2631) --- OPTIONS.md | 2 +- README.md | 2 +- SERVE-OPTIONS.md | 2 +- packages/serve/src/index.ts | 2 +- packages/webpack-cli/README.md | 2 +- packages/webpack-cli/lib/webpack-cli.js | 2 +- test/build/unknown/unknown.test.js | 6 +++--- test/help/__snapshots__/help.test.js.snap.webpack4 | 12 ++++++------ test/help/__snapshots__/help.test.js.snap.webpack5 | 12 ++++++------ test/help/help.test.js | 4 ++-- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index 7af5a89d1d0..88515e0f378 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -873,7 +873,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. diff --git a/README.md b/README.md index e950f468e08..e47e40ab364 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Thus, webpack CLI provides different commands for many common tasks. - [`migrate|m [new-config-path]`](https://www.npmjs.com/package/@webpack-cli/migrate) - Migrate project from one version to another. - [`plugin|p [output-path] [options]`](./packages/generators#generators) - Initiate new plugin project. - [`loader|l [output-path] [options]`](./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. +- [`serve|server|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. diff --git a/SERVE-OPTIONS.md b/SERVE-OPTIONS.md index 808b6966c4a..efb5b9e51ab 100644 --- a/SERVE-OPTIONS.md +++ b/SERVE-OPTIONS.md @@ -1,5 +1,5 @@ ``` -Usage: webpack serve|s [entries...] [options] +Usage: webpack serve|server|s [entries...] [options] Run the webpack dev server. diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 0f33450562a..a66f02d248a 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -8,7 +8,7 @@ class ServeCommand { await cli.makeCommand( { name: 'serve [entries...]', - alias: 's', + alias: ['server', 's'], description: 'Run the webpack dev server.', usage: '[entries...] [options]', pkg: '@webpack-cli/serve', diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index da57269ae2a..8104a38c73b 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -71,7 +71,7 @@ npx webpack-cli --help verbose loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. ``` diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index c31e7ae5d7b..c5ba9ff9e15 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -644,7 +644,7 @@ class WebpackCLI { const externalBuiltInCommandsInfo = [ { name: 'serve [entries...]', - alias: 's', + alias: ['server', 's'], pkg: '@webpack-cli/serve', }, { diff --git a/test/build/unknown/unknown.test.js b/test/build/unknown/unknown.test.js index b30d8d7fa2f..0ed9c264465 100644 --- a/test/build/unknown/unknown.test.js +++ b/test/build/unknown/unknown.test.js @@ -219,11 +219,11 @@ describe('unknown behaviour', () => { }); it('should log error and provide suggestion if an unknown command passed', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ['server'], true, [], { TERM_PROGRAM: false }); + const { exitCode, stderr, stdout } = await run(__dirname, ['serverr'], true, [], { TERM_PROGRAM: false }); expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown command or entry 'server'"); - expect(stderr).toContain("Did you mean 'serve' (alias 's')?"); + expect(stderr).toContain("Unknown command or entry 'serverr'"); + expect(stderr).toContain("Did you mean 'serve' (alias 'server, s')?"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); diff --git a/test/help/__snapshots__/help.test.js.snap.webpack4 b/test/help/__snapshots__/help.test.js.snap.webpack4 index 62ee96ce206..a17dfec40c0 100644 --- a/test/help/__snapshots__/help.test.js.snap.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.webpack4 @@ -102,7 +102,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -156,7 +156,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -210,7 +210,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -400,7 +400,7 @@ Made with ♥ by the webpack team." `; exports[`help should show help information for 'serve' command using the "--help" option 1`] = ` -"Usage: webpack serve|s [entries...] [options] +"Usage: webpack serve|server|s [entries...] [options] Run the webpack dev server. @@ -572,7 +572,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -626,7 +626,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. diff --git a/test/help/__snapshots__/help.test.js.snap.webpack5 b/test/help/__snapshots__/help.test.js.snap.webpack5 index 5e758f10da4..7297f62c0f0 100644 --- a/test/help/__snapshots__/help.test.js.snap.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.webpack5 @@ -103,7 +103,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -158,7 +158,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -213,7 +213,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -404,7 +404,7 @@ Made with ♥ by the webpack team." `; exports[`help should show help information for 'serve' command using the "--help" option 1`] = ` -"Usage: webpack serve|s [entries...] [options] +"Usage: webpack serve|server|s [entries...] [options] Run the webpack dev server. @@ -579,7 +579,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. @@ -634,7 +634,7 @@ Commands: loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. + serve|server|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. diff --git a/test/help/help.test.js b/test/help/help.test.js index 91e4aeab84d..189fcf095d7 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -108,8 +108,8 @@ describe('help', () => { }, { name: 'serve', - alias: 's', - usage: 'webpack serve|s [entries...] [options]', + alias: ['server', 's'], + usage: 'webpack serve|server|s [entries...] [options]', }, { name: 'build',