Skip to content

Commit

Permalink
feat(info): added the --additional-package option
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Aug 25, 2021
1 parent 603041d commit 06cd267
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 207 deletions.
7 changes: 4 additions & 3 deletions packages/info/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ webpack info [options]

#### Output format

| Flag | Description | Type |
| ----------------------------------- | --------------------------------------- | ------ |
| `-o, --output < json or markdown >` | To get the output in a specified format | string |
| Flag | Description | Type |
| ------------------------------------- | --------------------------------------- | ------ |
| `-o, --output < json or markdown >` | To get the output in a specified format | string |
| `-a, --additional-package <value...>` | Adds additional packages to the output | string |

_Not supported for config_

Expand Down
59 changes: 38 additions & 21 deletions packages/info/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ interface Information {
npmPackages?: string | string[];
}

const DEFAULT_DETAILS: Information = {
Binaries: ["Node", "Yarn", "npm"],
Browsers: [
"Brave Browser",
"Chrome",
"Chrome Canary",
"Edge",
"Firefox",
"Firefox Developer Edition",
"Firefox Nightly",
"Internet Explorer",
"Safari",
"Safari Technology Preview",
],
Monorepos: ["Yarn Workspaces", "Lerna"],
System: ["OS", "CPU", "Memory"],
npmGlobalPackages: ["webpack", "webpack-cli"],
npmPackages: "*webpack*",
};

class InfoCommand {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
async apply(cli: any): Promise<void> {
Expand All @@ -51,6 +31,13 @@ class InfoCommand {
],
description: "To get the output in a specified format ( accept json or markdown )",
},
{
name: "additional-package",
alias: "a",
configs: [{ type: "string" }],
multiple: true,
description: "Adds additional packages to the output",
},
],
async (options) => {
let { output } = options;
Expand All @@ -74,7 +61,37 @@ class InfoCommand {
}
}

let info = await envinfo.run(DEFAULT_DETAILS, envinfoConfig);
const defaultInformation: Information = {
Binaries: ["Node", "Yarn", "npm"],
Browsers: [
"Brave Browser",
"Chrome",
"Chrome Canary",
"Edge",
"Firefox",
"Firefox Developer Edition",
"Firefox Nightly",
"Internet Explorer",
"Safari",
"Safari Technology Preview",
],
Monorepos: ["Yarn Workspaces", "Lerna"],
System: ["OS", "CPU", "Memory"],
npmGlobalPackages: ["webpack", "webpack-cli", "webpack-dev-server"],
npmPackages: "{*webpack*,*loader*}",
};

let defaultPackages: string[] = ["webpack", "loader"];

if (typeof options.additionalPackage !== "undefined") {
defaultPackages = [...defaultPackages, ...options.additionalPackage];
}

defaultInformation.npmPackages = `{${defaultPackages
.map((item) => `*${item}*`)
.join(",")}}`;

let info = await envinfo.run(defaultInformation, envinfoConfig);

info = info.replace(/npmPackages/g, "Packages");
info = info.replace(/npmGlobalPackages/g, "Global Packages");
Expand Down
87 changes: 48 additions & 39 deletions test/help/__snapshots__/help.test.js.snap.devServer3.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -721,13 +721,14 @@ exports[`help should show help information for 'i' command using command syntax:
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -744,13 +745,14 @@ exports[`help should show help information for 'i' command using the "--help" op
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -767,15 +769,17 @@ exports[`help should show help information for 'info' and respect the "--color"
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json
or markdown )
-o, --output <value> To get the output in a specified format
( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -792,15 +796,17 @@ exports[`help should show help information for 'info' and respect the "--no-colo
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json
or markdown )
-o, --output <value> To get the output in a specified format
( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -817,13 +823,14 @@ exports[`help should show help information for 'info' command using command synt
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -840,13 +847,14 @@ exports[`help should show help information for 'info' command using the "--help"
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand Down Expand Up @@ -2669,13 +2677,14 @@ exports[`help should show help information with options for sub commands: stdout
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand Down
87 changes: 48 additions & 39 deletions test/help/__snapshots__/help.test.js.snap.devServer3.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,14 @@ exports[`help should show help information for 'i' command using command syntax:
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -753,13 +754,14 @@ exports[`help should show help information for 'i' command using the "--help" op
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -776,15 +778,17 @@ exports[`help should show help information for 'info' and respect the "--color"
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json
or markdown )
-o, --output <value> To get the output in a specified format
( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -801,15 +805,17 @@ exports[`help should show help information for 'info' and respect the "--no-colo
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json
or markdown )
-o, --output <value> To get the output in a specified format
( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -826,13 +832,14 @@ exports[`help should show help information for 'info' command using command synt
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand All @@ -849,13 +856,14 @@ exports[`help should show help information for 'info' command using the "--help"
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand Down Expand Up @@ -2712,13 +2720,14 @@ exports[`help should show help information with options for sub commands: stdout
Outputs information about your system.

Options:
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-o, --output <value> To get the output in a specified format ( accept json or markdown )
-a, --additional-package <value...> Adds additional packages to the output

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.

To see list of all supported commands and options run 'webpack --help=verbose'.

Expand Down
Loading

0 comments on commit 06cd267

Please sign in to comment.