Skip to content

Commit

Permalink
feat: add server alias for serve command (#2631)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Apr 16, 2021
1 parent 7673aad commit c9ee947
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Thus, webpack CLI provides different commands for many common tasks.
- [`migrate|m <config-path> [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.

Expand Down
2 changes: 1 addition & 1 deletion SERVE-OPTIONS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```
Usage: webpack serve|s [entries...] [options]
Usage: webpack serve|server|s [entries...] [options]
Run the webpack dev server.
Expand Down
2 changes: 1 addition & 1 deletion packages/serve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ npx webpack-cli --help verbose
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.
```
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-cli/lib/webpack-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ class WebpackCLI {
const externalBuiltInCommandsInfo = [
{
name: 'serve [entries...]',
alias: 's',
alias: ['server', 's'],
pkg: '@webpack-cli/serve',
},
{
Expand Down
6 changes: 3 additions & 3 deletions test/build/unknown/unknown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
12 changes: 6 additions & 6 deletions test/help/__snapshots__/help.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -156,7 +156,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -210,7 +210,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -572,7 +572,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -626,7 +626,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down
12 changes: 6 additions & 6 deletions test/help/__snapshots__/help.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -158,7 +158,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -213,7 +213,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -579,7 +579,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down Expand Up @@ -634,7 +634,7 @@ Commands:
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [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.

Expand Down
4 changes: 2 additions & 2 deletions test/help/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit c9ee947

Please sign in to comment.