Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(help): display error message if no option provided on startup #254

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5a040ba
bugfix - display error message if no option provided on startup
sumit-gupta91 Jan 26, 2018
d43ab9f
added test for no-options
sumit-gupta91 Feb 1, 2018
37cb6d8
Merge remote-tracking branch 'upstream/master' into bugfix/error-msg-…
sumit-gupta91 Feb 26, 2018
580395a
refactor- intercept webpack error and transform to show no options error
sumit-gupta91 Mar 4, 2018
ec6cc38
chore(monorepo): move to lerna
sendilkumarn Mar 18, 2018
bdafce0
chore(monorepo): use commands as normal instead of package
sendilkumarn Mar 18, 2018
3dd244b
fix(revert): packagejson
sendilkumarn Mar 18, 2018
059d6f9
chore(monorepo): prune files and update eslint rules
sendilkumarn Mar 18, 2018
8ef1804
chore(monorepo): fix the no-missing-require error
sendilkumarn Mar 18, 2018
a1d5406
chore(monorepo): fix typo
sendilkumarn Mar 18, 2018
a6a2715
chore(monorepo): fix typo
sendilkumarn Mar 18, 2018
e9bc6eb
Merge branch 'master' into lerna-workspace
sendilkumarn Mar 20, 2018
64cfef7
chore(monorepo): prune package json
sendilkumarn Mar 20, 2018
2738a1e
Merge branch 'next' into lerna-workspace
sendilkumarn Apr 4, 2018
d4c7c5d
chore(monorepo): merge package lock json
sendilkumarn Apr 4, 2018
ff6c371
chore(monorepo): updated package.json
sendilkumarn Apr 4, 2018
3c822cf
chore(monorepo): fix plugin package.json
sendilkumarn Apr 4, 2018
bdf7e5a
Merge pull request #353 from sendilkumarn/lerna-workspace
sendilkumarn Apr 15, 2018
2d58452
Merge remote-tracking branch 'upstream/master' into bugfix/error-msg-…
sumit-gupta91 May 8, 2018
a01a0c5
fixed test cases
sumit-gupta91 May 8, 2018
8a02f35
remove unwanted console
sumit-gupta91 May 8, 2018
fa452a0
chore(cli): move to lerna and scoped packages (#434)
evenstensberg May 14, 2018
b1a8398
chore(rebase): merge master branch
evenstensberg May 14, 2018
1db677e
chore(linting): resolve linter errors
evenstensberg May 14, 2018
a76c46f
chore(linting): fix linting errors
evenstensberg May 14, 2018
8f6f1db
chore(linting): resolve linting
evenstensberg May 14, 2018
80c9e9a
chore(linting): resolve linting
evenstensberg May 14, 2018
b2a7470
chore(scaffold): move addons to scaffold
evenstensberg May 14, 2018
df8287d
chore(scaffold): fix linting errors
evenstensberg May 14, 2018
f8a71c0
cli(prompt): initial comment for prompt file
evenstensberg May 14, 2018
5f357c9
cli(prompt): wip
evenstensberg May 14, 2018
74fb759
fix(monorepo): fix lint errors
sendilkumarn May 15, 2018
0fcc5b3
fix(monorepo): fix cross spawn versions
sendilkumarn May 15, 2018
ca8f5c1
fix(monorepo): update lock files
sendilkumarn May 15, 2018
2b3035c
fix(monorepo): fix versions in pacakges
sendilkumarn May 15, 2018
b02070d
chore(rebase): refactor stuff
evenstensberg May 17, 2018
b2c2bbd
cli(pkgs): re-add entries
evenstensberg May 17, 2018
ab38a3a
chore(v): revise pkg
evenstensberg May 17, 2018
faae7aa
v0.0.1
evenstensberg May 17, 2018
c36f3e8
chore(v): revise some deps
evenstensberg May 17, 2018
91be3fd
v0.0.2
evenstensberg May 17, 2018
b51e66d
v0.0.3
evenstensberg May 17, 2018
3ed29c6
chore(v): back to v1
evenstensberg May 17, 2018
6489b10
v0.0.2
evenstensberg May 17, 2018
01cef3f
v0.0.3
evenstensberg May 17, 2018
e29a173
v0.0.4
evenstensberg May 17, 2018
58a437d
chore(deps): update deps
evenstensberg May 17, 2018
bccc56e
chore(prompt): revise prompt cmd
evenstensberg May 17, 2018
062fa28
v0.0.5
evenstensberg May 17, 2018
7fca948
cli(path): resolve better
evenstensberg May 17, 2018
f544578
v0.0.6
evenstensberg May 17, 2018
ebe5c6b
chore(v.6): update init
evenstensberg May 17, 2018
3a82b7d
chore(pkg): v.6 on next
evenstensberg May 17, 2018
17c2c88
chore(monorepo): add bootstrap to run
sendilkumarn May 17, 2018
42468d3
chore(monorepo): fix appveyor build
sendilkumarn May 17, 2018
a08b899
chore(monorepo): fix appveyor build
sendilkumarn May 18, 2018
ae55183
chore(monorepo): add eslint-plugin-prettier
sendilkumarn May 18, 2018
206749b
chore(monorepo): fix appveyor build
sendilkumarn May 17, 2018
7de58ea
chore(monorepo): fix versions and use clean bootstrap
sendilkumarn May 18, 2018
7c0e245
chore(monorepo): add rimraf globally
sendilkumarn May 18, 2018
2be0bce
Merge branch 'next' of https://github.com/webpack/webpack-cli into next
evenstensberg May 19, 2018
8c58d24
chore(monorepo): fix windows build
sendilkumarn May 19, 2018
e87fd7d
cli(color): don't use color on non-tty (#452)
evenstensberg May 20, 2018
0989b1d
Added yarn lock file to gitignore (#455)
nveenjain May 20, 2018
77cbf01
fix(254) - addressed PR comments
sumit-gupta91 May 21, 2018
76416ff
fix(254) - added requested changes at right place
sumit-gupta91 May 21, 2018
78b48a6
chore(next): dev version bump
evenstensberg May 21, 2018
0310fd3
chore(monorepo): fix windows build
sendilkumarn May 21, 2018
217670f
cli(symlinks): Fix paths (#453)
evenstensberg May 21, 2018
8e48e37
cli(init): Better defaults (#451)
evenstensberg May 22, 2018
6be1af0
fix(254) - exit after error
sumit-gupta91 May 22, 2018
92816e1
fix(vulnerabilities): vulnerabilities patch for v3 (#460)
dhruvdutt May 24, 2018
422191c
Merge remote-tracking branch 'upstream/next' into bugfix/error-msg-fo…
sumit-gupta91 May 26, 2018
b305327
merge from master
sumit-gupta91 May 26, 2018
610ec1e
Merge remote-tracking branch 'upstream/master' into bugfix/error-msg-…
sumit-gupta91 May 26, 2018
eec7a3c
merge from master
sumit-gupta91 May 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 30 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ module.exports = {
"node/no-missing-require": [
"error",
{
"resolvePaths": ["./packages"],
"allowModules": [
"webpack"
"webpack",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
Expand All @@ -71,7 +79,27 @@ module.exports = {
{
"allowModules": [
"webpack",
"webpack-dev-server"
"webpack-dev-server",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
"node/no-extraneous-require": [
"error",
{
"allowModules": [
"@webpack-cli/migrate",
"@webpack-cli/generators",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ yarn-error.log
# Test Compilation
test/js/*

# lerna log
lerna-debug.log

# Yeoman file
.yo-rc.json
.yo-rc.json

# Yarn lock file
yarn.lock
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ install:
- npm install -g codecov
- npm install -g eslint
- npm install -g greenkeeper-lockfile@1
- lerna bootstrap

before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
Expand Down
10 changes: 1 addition & 9 deletions INIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ What we are meaning here, is if you want to provide your bundle a single or mult

This answers to the output directory of your application. The output directory is where servers or your `index.html` will read the generated bundle from.

3. `Are you going to use this in production? (Y/n)`

If you answer `Yes` to this, we add [`MinCssExtractPlugin`](https://github.com/webpack-contrib/mini-css-extract-plugin) to your project. This means that your style files will be separated in production from the bundles where they are used. If you answer `No`, we will not use the plugin, and `Question 6` will be ignored by default.

4. `Will you be using ES2015? (Y/n)`

If you answer `Yes` to this question, we will add [`ES2015`](https://babeljs.io/learn-es2015/) to your webpack configuration, which will allow you to use modern JavaScript in your project.
Expand All @@ -29,8 +25,4 @@ If you use any sort of style in your project, such as [`.less`](http://lesscss.o
6. `If you want to bundle your CSS files, what will you name the bundle? (press
enter to skip)`

If you answered `Yes` to `Question 3`, this will be enabled. The default value for your generated CSS file is `style.[contentHash].css`, which will collect all your `.less`, `.scss` or `.css` into one file. This will make your build faster in production.

7. `Name your 'webpack.[name].js?' [default: 'prod/config']`

If you answered `Yes` to `Question 3`, the default name of your configuration will be `webpack.prod.js`, otherwise it will be `webpack.config.js` if you don't answer. Other good options to answer to this question is: `dev`, `base`, `production` or `development`.
If you indicate based on previous questions that you are using production, this will be enabled. The default value for your generated CSS file is `style.[contentHash].css`, which will collect all your `.less`, `.scss` or `.css` into one file. This will make your build faster in production.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The `migrate` feature eases the transition from [version 1](http://webpack.githu

The `init` feature allows users to get started with webpack, fast. Through scaffolding, people can create their own configuration in order to faster initialize new projects for various of use cases.

`webpack-cli init webpack-addons-<package>`
`webpack-cli init webpack-scaffold-<package>`

[Read more about scaffolding](SCAFFOLDING.md)

Expand Down
12 changes: 6 additions & 6 deletions SCAFFOLDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Before writing a `webpack-cli` scaffold, think about what you're trying to achie

`webpack-cli` offers an experience that is interactive and you can prompt users for questions (like, "What is your entry point?") to help customize the output accordingly.

## webpack-addons
## webpack-scaffold

[`webpack-addons`](https://github.com/webpack-contrib/webpack-addons) is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself.
`webpack-scaffold` is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself.

## webpack-addons-yourpackage
## webpack-scaffold-yourpackage

In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `addon`, please read [How do I compose a
webpack-addon?](https://github.com/ev1stensberg/webpack-addons-demo).
In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `scaffold`, please read [How do I compose a
webpack-addon?](https://github.com/ev1stensberg/webpack-scaffold-demo).

If the package is on npm, its name must have a prefix of `webpack-addons`.
If the package is on npm, its name must have a prefix of `webpack-scaffold`.

If the package is on your local filesystem, it can be named whatever you want. Pass the path to the package.

Expand Down
46 changes: 38 additions & 8 deletions bin/webpack.js → bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
const chalk = require("chalk");

(function() {
// wrap in IIFE to be able to use return
Expand All @@ -15,6 +16,17 @@
}

require("v8-compile-cache");

// try local module, fallback to global
try {
require.resolve("webpack");
process.webpackModule = require("webpack");
} catch (err) {
const globalPathToWebpack = require("global-modules-path").getPath(
"webpack"
);
process.webpackModule = require(globalPathToWebpack);
}
const ErrorHelpers = require("./errorHelpers");

const NON_COMPILATION_ARGS = [
Expand All @@ -41,9 +53,7 @@
});

if (NON_COMPILATION_CMD) {
// eslint-disable-next-line
require("../lib/index")(NON_COMPILATION_CMD, process.argv);
return;
return require("./prompt-command")(NON_COMPILATION_CMD, ...process.argv);
}

const yargs = require("yargs").usage(`webpack-cli ${
Expand Down Expand Up @@ -81,7 +91,9 @@ For more information, see https://webpack.js.org/api/cli/.`);
type: "boolean",
alias: "colors",
default: function supportsColor() {
return require("supports-color").supportsColor;
if (process.stdout.isTTY === true) {
return require("supports-color").supportsColor;
}
},
group: DISPLAY_GROUP,
describe: "Enables/Disables colors on the console"
Expand Down Expand Up @@ -287,7 +299,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
}

const firstOptions = [].concat(options)[0];
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
const statsPresetToOptions = process.webpackModule.Stats.presetToOptions;

let outputOptions = options.stats;
if (
Expand Down Expand Up @@ -323,7 +335,10 @@ For more information, see https://webpack.js.org/api/cli/.`);
}
});

if (typeof outputOptions.colors === "undefined")
if (
typeof outputOptions.colors === "undefined" &&
process.stdout.isTTY === true
)
outputOptions.colors = require("supports-color").stdout;

ifArg("sort-modules-by", function(value) {
Expand Down Expand Up @@ -429,7 +444,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
outputOptions.buildDelimiter = value;
});

const webpack = require("webpack");
const webpack = process.webpackModule;

let lastHash = null;
let compiler;
Expand All @@ -450,7 +465,7 @@ For more information, see https://webpack.js.org/api/cli/.`);
}

if (argv.progress) {
const ProgressPlugin = require("webpack").ProgressPlugin;
const ProgressPlugin = process.webpackModule.ProgressPlugin;
new ProgressPlugin({
profile: argv.profile
}).apply(compiler);
Expand Down Expand Up @@ -482,6 +497,21 @@ For more information, see https://webpack.js.org/api/cli/.`);
);
} else if (stats.hash !== lastHash) {
lastHash = stats.hash;
if (stats.compilation && stats.compilation.errors.length !== 0) {
const errors = stats.compilation.errors;
if (errors[0].name === "EntryModuleNotFoundError") {
stdout.write("\n" + chalk.red(errors[0].error.toString()) + "\n");
stdout.write(
"\n" + chalk.blue(" ERROR ") + "Insufficient number of arguments provided " +
"\n" + chalk.blue(" INFO ") + "Alternatively, run `webpack(-cli) --help` for usage info." +
"\n\n"
);
process.exit(0);
}
} else {
const statsString = stats.toString(outputOptions);
if (statsString) stdout.write(statsString + "\n");
}
const statsString = stats.toString(outputOptions);
const delimiter = outputOptions.buildDelimiter
? `${outputOptions.buildDelimiter}\n`
Expand Down
2 changes: 1 addition & 1 deletion bin/config-yargs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const optionsSchema = require("webpack/schemas/WebpackOptions.json");
const optionsSchema = require("./optionsSchema.json");
const CONFIG_GROUP = "Config options:";
const BASIC_GROUP = "Basic options:";
const MODULE_GROUP = "Module options:";
Expand Down
29 changes: 15 additions & 14 deletions bin/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const fs = require("fs");
fs.existsSync = fs.existsSync || path.existsSync;
const interpret = require("interpret");
const prepareOptions = require("./prepareOptions");
const webpackConfigurationSchema = require("../schemas/webpackConfigurationSchema.json");
const validateSchema = require("webpack").validateSchema;
const WebpackOptionsValidationError = require("webpack")
.WebpackOptionsValidationError;
const webpackConfigurationSchema = require("./webpackConfigurationSchema.json");
const validateSchema = process.webpackModule.validateSchema;
const WebpackOptionsValidationError =
process.webpackModule.WebpackOptionsValidationError;

module.exports = function(...args) {
const argv = args[1] || args[0];
Expand Down Expand Up @@ -398,7 +398,7 @@ module.exports = function(...args) {
defineObject = {};
},
function() {
const DefinePlugin = require("webpack").DefinePlugin;
const DefinePlugin = process.webpackModule.DefinePlugin;
addPlugin(options, new DefinePlugin(defineObject));
}
);
Expand Down Expand Up @@ -468,13 +468,13 @@ module.exports = function(...args) {
mapArgToBoolean("cache");

ifBooleanArg("hot", function() {
const HotModuleReplacementPlugin = require("webpack")
.HotModuleReplacementPlugin;
const HotModuleReplacementPlugin =
process.webpackModule.HotModuleReplacementPlugin;
addPlugin(options, new HotModuleReplacementPlugin());
});

ifBooleanArg("debug", function() {
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
addPlugin(
options,
new LoaderOptionsPlugin({
Expand Down Expand Up @@ -510,8 +510,8 @@ module.exports = function(...args) {
});

ifArg("optimize-max-chunks", function(value) {
const LimitChunkCountPlugin = require("webpack").optimize
.LimitChunkCountPlugin;
const LimitChunkCountPlugin =
process.webpackModule.optimize.LimitChunkCountPlugin;
addPlugin(
options,
new LimitChunkCountPlugin({
Expand All @@ -521,7 +521,8 @@ module.exports = function(...args) {
});

ifArg("optimize-min-chunk-size", function(value) {
const MinChunkSizePlugin = require("webpack").optimize.MinChunkSizePlugin;
const MinChunkSizePlugin =
process.webpackModule.optimize.MinChunkSizePlugin;
addPlugin(
options,
new MinChunkSizePlugin({
Expand All @@ -531,7 +532,7 @@ module.exports = function(...args) {
});

ifBooleanArg("optimize-minimize", function() {
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
const LoaderOptionsPlugin = process.webpackModule.LoaderOptionsPlugin;
addPlugin(
options,
new LoaderOptionsPlugin({
Expand All @@ -541,7 +542,7 @@ module.exports = function(...args) {
});

ifArg("prefetch", function(request) {
const PrefetchPlugin = require("webpack").PrefetchPlugin;
const PrefetchPlugin = process.webpackModule.PrefetchPlugin;
addPlugin(options, new PrefetchPlugin(request));
});

Expand All @@ -554,7 +555,7 @@ module.exports = function(...args) {
} else {
name = value;
}
const ProvidePlugin = require("webpack").ProvidePlugin;
const ProvidePlugin = process.webpackModule.ProvidePlugin;
addPlugin(options, new ProvidePlugin(name, value));
});

Expand Down
Loading