Skip to content

Commit

Permalink
docs(cli): changed README to notify the beta version (#1223)
Browse files Browse the repository at this point in the history
* docs(cli): changed README to notify of beta version

docs(init): changed `create` to `init`

* tests(init): updated tests and snapshots
  • Loading branch information
ematipico authored Feb 12, 2020
1 parent 76d2eb3 commit 68087f1
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 14 deletions.
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
</p>
<br>

> ## This is the documentation of the beta version.
>
> We are working on reducing the number of arguments passed to the CLI,
> please leave your feedback [here](https://github.com/webpack/webpack-cli/issues/1222)
[![npm][npm]][npm-url]
[![Build Status][build-status]][build-status-url]
[![Build2 Status][build-status-azure]][build-status-azure-url]
Expand Down Expand Up @@ -46,6 +51,44 @@ When you have followed the [Getting Started](https://webpack.js.org/guides/getti

Otherwise `npm install --save-dev webpack-cli` or `yarn add webpack-cli --dev` will install it.

# Supported arguments and commands

```
Available Commands
init Initialize a new webpack configuration
migrate Migrate a configuration to a new version
loader Scaffold a loader repository
plugin Scaffold a plugin repository
info Outputs information about your system and dependencies
serve Run the webpack Dev Server
Options
--entry string The entry point of your application.
-c, --config string Provide path to a webpack configuration file
-m, --merge string Merge a configuration file using webpack-merge
--progress Print compilation progress during build
--silent Disable any output that webpack makes
--help Outputs list of supported flags
--defaults Allow webpack to set defaults aggresively
-o, --output string Output location of the file generated by webpack
--plugin string Load a given plugin
-g, --global string[] Declares and exposes a global variable
-t, --target string Sets the build target
-w, --watch Watch for files changes
-h, --hot Enables Hot Module Replacement
-s, --sourcemap string Determine source maps to use
--prefetch string Prefetch this request
-j, --json Prints result as JSON
--standard Prints standard output
-d, --dev Run development build
-p, --prod Run production build
--version Get current version
--node-args string[] NodeJS flags
```

## 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.
Expand All @@ -54,7 +97,7 @@ 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 create`](./packages/init/README.md#webpack-cli-create) - Create a new webpack configuration.
- [`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.
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module.exports = {
},
commands: [
{
name: 'create',
name: 'init',
alias: 'c',
type: String,
usage: 'create | create <scaffold>',
usage: 'init | init <scaffold>',
description: 'Initialize a new webpack configuration',
},
{
Expand Down
10 changes: 5 additions & 5 deletions packages/init/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# webpack-cli create
# webpack-cli init

[![NPM Downloads][downloads]][downloads-url]

Expand Down Expand Up @@ -33,27 +33,27 @@ init([null, null, ...myPacakges]);
**Via defaults**

```bash
npx webpack-cli create
npx webpack-cli init
```

**To generate default configs**

```bash
npx webpack-cli create --auto
npx webpack-cli init --auto
```

**Via custom scaffold**

1. Using package on `npm`

```bash
npx webpack-cli create webpack-scaffold-[name]
npx webpack-cli init webpack-scaffold-[name]
```

2. Using path to a local directory

```bash
npx webpack-cli create [path]
npx webpack-cli init [path]
```

[downloads]: https://img.shields.io/npm/dm/@webpack-cli/init.svg
Expand Down
2 changes: 1 addition & 1 deletion test/help/__snapshots__/help-single-arg.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`single help flag creates a readable snapshot 1`] = `
Available Commands
create Initialize a new webpack configuration
init Initialize a new webpack configuration
migrate Migrate a configuration to a new version
loader Scaffold a loader repository
plugin Scaffold a plugin repository
Expand Down
8 changes: 4 additions & 4 deletions test/help/help-commands.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ describe('commands help', () => {
expect(stderr).toHaveLength(0);
});
it('shows command help with valid command', () => {
const { stdout, stderr } = run(__dirname, ['--help', 'create'], false);
const { stdout, stderr } = run(__dirname, ['--help', 'init'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack create | create <scaffold>');
expect(stdout).toContain('webpack init | init <scaffold>');
expect(stderr).toHaveLength(0);
});

it('gives precedence to earlier command in case of multiple commands', () => {
const { stdout, stderr } = run(__dirname, ['--help', 'create', 'info'], false);
const { stdout, stderr } = run(__dirname, ['--help', 'init', 'info'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack create | create <scaffold>');
expect(stdout).toContain('webpack init | init <scaffold>');
expect(stderr).toHaveLength(0);
});
});
2 changes: 1 addition & 1 deletion test/help/help-multi-args.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('help flag with multiple arguments', () => {
});

it('outputs info with multiple commands and with precedence', () => {
const { stdout, stderr } = run(__dirname, ['create', 'help']);
const { stdout, stderr } = run(__dirname, ['init', 'help']);
expect(stdout).toContain(createDescription);
expect(stderr).toHaveLength(0);
});
Expand Down

0 comments on commit 68087f1

Please sign in to comment.