diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index a883c4b1ad5..00000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,27 +0,0 @@ -clone_depth: 10 - -version: "{build}" - -environment: - fast_finish: true - matrix: - - nodejs_version: "6" - platform: x86 - -build: off - -install: - - ps: Install-Product node $env:nodejs_version $env:platform - - npm install - - npm install --global codecov - - npm install eslint-plugin-node@latest --save-dev - -test_script: - - node --version - - npm --version - - which npm - - npm run appveyor:lint - - npm run appveyor:test - -cache: - - node_modules -> appveyor.yml,package.json,package-lock.json diff --git a/.codecov.yml b/.codecov.yml index 58598d7c0e6..9f22d86e981 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,15 +1,20 @@ -comment: off +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "50...100" parsers: - javascript: - enable_partials: yes + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no -coverage: - status: - project: - default: - threshold: 4% - if_not_found: success - patch: - default: - if_not_found: success +comment: + layout: "reach,diff,flags,files,footer" + behavior: default + require_changes: no diff --git a/.cspell.json b/.cspell.json new file mode 100644 index 00000000000..ee2bee7f736 --- /dev/null +++ b/.cspell.json @@ -0,0 +1,117 @@ +{ + "version": "0.2", + "language": "en,en-gb", + "words": [ + "Atsumu", + "autoprefixer", + "barbaz", + "Cantarell", + "Chizuru", + "chuntaro", + "CLIAPI", + "cobertura", + "codecov", + "colorette", + "commitlint", + "compat", + "configjs", + "configtest", + "CRLs", + "deserialization", + "discoveryjs", + "dotfolder", + "entrypoint", + "entrypoints", + "envinfo", + "Eren", + "execa", + "Fira", + "gitter", + "Gojou", + "Hisoka", + "Hoshiumi", + "Ichigo", + "IIFE's", + "iife", + "Itadori", + "Iwaizumi", + "Jotaro", + "Kageyama", + "Kazuya", + "kebabed", + "kiryu", + "Kiyoomi", + "Kujo", + "loglevel", + "Luffy", + "mergeable", + "Miyuki", + "Mizuhara", + "multicompiler", + "multipleq", + "Naruto", + "Neue", + "Nishinoya", + "nwjs", + "Oikawa", + "pathinfo", + "pnpm", + "postcss", + "prebuild", + "prepsuite", + "rechoir", + "Rimuru", + "Roboto", + "runtimes", + "Sakusa", + "Satoru", + "Segoe", + "Shoyo", + "smoketests", + "sockjs", + "somefile", + "SPDY", + "splitted", + "Statsv", + "styl", + "Tanjiro", + "tapable", + "taskkill", + "Tensa", + "testname", + "Tobio", + "tsbuildinfo", + "typeahead", + "webassembly", + "webpackfile", + "Yukihira", + "Yukii", + "Yuuji", + "Zangetsu", + "Zenitsu", + "eslintcache", + "wagoid", + "Nitin", + "smoketest", + "dbaeumer", + "esbenp", + "msuccessfully", + "mfirst", + "msecond", + "sourcemaps" + ], + "dictionaries": ["npm", "software-terms"], + "ignorePaths": [ + "**/CHANGELOG.md", + "**/package.json", + "**/dist/**", + "**/__snapshots__/**", + "**/*.tsbuildinfo", + "**/yarn.lock", + "**/*.png.tpl", + "**/package-lock.json", + "node_modules", + "coverage", + "*.log" + ] +} diff --git a/.cz-config.js b/.cz-config.js deleted file mode 100644 index 2eb91ccdab0..00000000000 --- a/.cz-config.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license Copyright 2017 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by - * applicable law or agreed to in writing, software distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS - * OF ANY KIND, either express or implied. See the License for the specific - * language governing permissions and limitations under the License. - */ -// Based on https://github.com/GoogleChrome/lighthouse/blob/master/.cz-config.js - -'use strict'; - -module.exports = { - allowBreakingChanges: ["ast"], - allowCustomScopes: true, - scopes: [], - // sort type values in asc - types: [ - { value: "ast", name: "ast: init, migrate, add, etc" }, - { value: "chore", name: "chore: Updating deps, docs, linting, etc" }, - { value: "cli", name: "cli: Core CLI things" }, - { value: "docs", name: "docs: Documentation" }, - { value: "feat", name: "feat: A new feature" }, - { value: "fix", name: "fix: Bugs, typos, etc" }, - { value: "misc", name: "misc: Other formats like tweaks and such" }, - { value: "tests", name: "tests: Tests, jest, binTestCases, etc" } - ] -}; diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..01e6227668f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +FROM node:lts + +# Add global instances of prettier and eslint for vscode +RUN npm install -g eslint prettier diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..f8ab0aa2e13 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,10 @@ +{ + "name": "webpack-cli", + "dockerFile": "Dockerfile", + "runArgs": ["-u", "node"], + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "postCreateCommand": "yarn install && yarn build", + "extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] +} diff --git a/.editorconfig b/.editorconfig index b6030406bfb..1cd054b5315 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,26 +1,15 @@ root = true [*] -indent_style = tab -indent_size = 4 charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -max_line_length = 233 - -[*.js] -end_of_line = lf - -[*.json] indent_style = space indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true -[*.yml] -indent_style = space -indent_size = 2 +[*.md] +trim_trailing_whitespace = false [test/cases/parsing/bom/bomfile.{css,js}] charset = utf-8-bom - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore index 010eb91b941..91718ffa7a2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,13 @@ -**/__testfixtures__/* coverage -test -docs \ No newline at end of file +.nyc_output +node_modules +dist +packages/*/lib +test/**/dist/ +test/**/bin/ +test/**/binary/ +test/**/index.js +test/build/config/error-commonjs/syntax-error.js +test/build/config/error-mjs/syntax-error.mjs +test/build/config/error-array/webpack.config.js +test/configtest/with-config-path/syntax-error.config.js diff --git a/.eslintrc.js b/.eslintrc.js index 79e9725bdaa..a17e0c5be7c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,82 +1,46 @@ module.exports = { - "root": true, - "plugins": ["node"], - "extends": ["eslint:recommended", "plugin:node/recommended"], - "env": { - "node": true, - "es6": true, - "jest": true - }, - "parserOptions": { "ecmaVersion": 2017, "sourceType": "module"}, - "rules": { - "no-useless-escape": "off", - "quote-props": ["error", "as-needed"], - "no-dupe-keys": "error", - "quotes": ["error", "double"], - "no-undef": "error", - "no-extra-semi": "error", - "semi": "error", - "no-template-curly-in-string": "error", - "no-caller": "error", - "yoda": "error", - "eqeqeq": "error", - "global-require": "off", - "brace-style": "error", - "key-spacing": "error", - "space-in-parens": ["error", "never"], - "space-infix-ops": "error", - "indent": ["error", "tab", { "SwitchCase": 1 }], - "no-extra-bind": "warn", - "no-empty": "off", - "no-multiple-empty-lines": "error", - "no-multi-spaces": "error", - "no-process-exit": "off", - "no-trailing-spaces": "error", - "no-use-before-define": "off", - "no-unused-vars": ["error", { "args": "none" }], - "no-unsafe-negation": "error", - "no-loop-func": "warn", - "space-before-function-paren": ["error", "never"], - "space-before-blocks": "error", - "object-curly-spacing": ["error", "always"], - "object-curly-newline": ["error", { "consistent": true }], - "keyword-spacing": ["error", { - "after": true, - "overrides": { - "const": { "after": true }, - "try": { "after": true }, - "throw": { "after": true }, - "case": { "after": true }, - "return": { "after": true }, - "finally": { "after": true }, - "do": { "after": true } - } - }], - "no-console": "off", - "valid-jsdoc": "error", - "node/no-unsupported-features": ["error", { "version": 6 }], - "node/no-deprecated-api": "error", - "node/no-missing-import": "error", - "node/no-missing-require": [ - "error", - { - "allowModules": [ - "webpack" - ] - } - ], - "node/no-unpublished-bin": "error", - "node/no-unpublished-require": [ - "error", - { - "allowModules": [ - "webpack", - "webpack-dev-server" - ] - } - ], - "eol-last": ["error", "always"], - "newline-per-chained-call": "off", - "node/process-exit-as-throw": "error" - } + root: true, + reportUnusedDisableDirectives: true, + extends: ["eslint:recommended", "plugin:node/recommended", "prettier"], + parserOptions: { ecmaVersion: 2018, sourceType: "script" }, + plugins: ["node"], + settings: { + node: { + allowModules: ["@webpack-cli/generators"], + }, + }, + env: { + node: true, + es6: true, + jest: true, + }, + rules: { + "no-process-exit": "off", + "no-template-curly-in-string": "error", + "no-caller": "error", + "no-extra-bind": "error", + "no-loop-func": "error", + "no-undef": "error", + "prefer-const": "error", + }, + overrides: [ + { + settings: { + node: { + tryExtensions: [".ts", ".tsx", ".js", ".jsx", ".json"], + }, + }, + files: ["**/*.ts"], + extends: [ + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "prettier", + ], + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + rules: { + "node/no-unsupported-features/es-syntax": "off", + }, + }, + ], }; diff --git a/.fitcommitjsrc.json b/.fitcommitjsrc.json deleted file mode 100644 index 081d8fdf89b..00000000000 --- a/.fitcommitjsrc.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "validators": { - "lineLength": { - "enabled": true, - "maxLineLength": 100, - "subjectMaxLength": 100 - }, - "emptyLines": { - "enabled": false - }, - "tags": { - "enabled": true, - "tags": "feat, fix, docs, style, refactor, perf, test, chore, revert", - "lineOfTheTag": 1 - }, - "subjectTense": { - "enabled": true - }, - "wip": { - "enabled": true, - "branch": "master" - } - } -} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..1632a73dd4c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.js text eol=lf +*.ts text eol=lf diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000000..f8761f90d48 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,259 @@ +# Contributing + +From opening a bug report to creating a pull request: every contribution is +appreciated and welcomed. If you're planning to implement a new feature or changing +the API, please create an issue first. This way we can ensure that your precious +work is not in vain. + +Table of Contents + +- [Issues](#issues) +- [Your first Contribution](#your-first-contribution) +- [Setup](#setup) +- [Running Tests](#running-tests) + - [Using yarn](#using-yarn) +- [Editor Config](#editor-config) +- [Dependencies](#dependencies) +- [Branching Model](#branching-model) +- [Naming a branch](#naming-a-branch) + - [Features](#features) + - [Fixes](#fixes) +- [Testing](#testing) +- [Pull Requests](#pull-requests) +- [Submitting a good Pull Request](#submitting-a-good-pull-request) +- [Commit message](#commit-message) + - [Commit Message Format](#commit-message-format) +- [Contributor License Agreement](#contributor-license-agreement) +- [Documentation](#documentation) +- [Releasing](#releasing) +- [Join The Development](#join-the-development) + +## Issues + +Most of the time, when webpack does not work correctly, it might be a configuration issue. + +If you are still having difficulty after looking over your configuration carefully, please post +a question to [StackOverflow with the webpack-cli tag](http://stackoverflow.com/tags/webpack-cli). Please ensure that your questions +that include your `webpack.config.js` and relevant files. This way you help others to help you. + +**If you have discovered a bug or have a feature suggestion, feel free to create an [issue](https://github.com/webpack/webpack-cli/issues) on Github.** + +> In case you're filing a bug, make sure you add steps to reproduce it. Especially if that bug is some weird/rare one. + +## Your first Contribution + +First of all, you will need to create an issue in Github for the feature or bugfix that you want to work on. When you open a new issue, there will be a template that will be automatically added to the text of the issue, which you would need to fill in. Doing this will help us to understand better what the ticket is about. + +After you've created an issue, we will have a look, and provide feedback to your ticket. + +In case it is a bug that you want to fix, we might help you with background information about the issue, so you can make an informed fix. + +In case you are suggesting a new feature, we will match your idea with our current roadmap, and will open conversations about it. Once the discussion has been done, and the tasks cleared, then you're ready to code. + +## Setup + +- Install [Node.js](https://nodejs.org/) if you don't have it already. + _Note: Node 6 or greater would be better for "best results"._ +- Fork the **webpack-cli** repo at [https://github.com/webpack/webpack-cli](https://github.com/webpack/webpack-cli). +- `git clone && cd webpack-cli` + +- We use [yarn](https://yarnpkg.com/lang/en/) workspaces, please install it: + + Read the [Installation Guide](https://yarnpkg.com/en/docs/install) on their official website for detailed instructions on how to install Yarn. + +> Using yarn is not a requirement, [npm](https://www.npmjs.com/) is included in node. + +- Install the dependencies: + + ```bash + yarn install + ``` + +- Bootstrap all the submodules before building for the first time + + ```bash + yarn lerna bootstrap + yarn build + ``` + +> If you are a Docker and Visual Studio Code user, you can quickstart development using [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) Extension + +## Running Tests + +### Using yarn + +- Run all the tests with: + + ```bash + yarn test + ``` + +- Run CLI tests with: + + ```bash + yarn test:cli + ``` + +- Run tests of all packages: + + ```bash + yarn test:packages + ``` + +- Test a single CLI test case: + + > Must run from root of the project + + ```bash + yarn jest path/to/my-test.js + ``` + +- You can also install jest globally and run tests without npx: + + ```bash + yarn global add jest + jest path/to/my-test.js + ``` + +- You can run the linters: + + ```bash + yarn lint + ``` + +## Editor Config + +The [.editorconfig](https://github.com/webpack/webpack-cli/blob/master/.editorconfig) in the root should ensure consistent formatting. Please make sure you've [installed the plugin](http://editorconfig.org/#download) if your text editor needs one. + +## Dependencies + +This is a multi-package repository and dependencies are managed using [lerna](https://lerna.js.org/) + +> If you are adding or updating any dependency, please commit the updated `yarn.lock` file. + +## Branching Model + +We base our branching model on [git flow](http://nvie.com/posts/a-successful-git-branching-model/). Instead of working with a `develop` base branch, we use the `master` branch. We do it to ease the workflow a bit. However, we find that adding prefixes to the branches is useful. + +## Naming a branch + +Making a branch in your fork for your contribution is helpful in the following ways: + +- It allows you to submit more than one contribution in a single PR. +- It allows us to identify what your contribution is about from the branch name. + +You will want to checkout the `master` branch locally before creating your new branch. + +There are two types of branches: + +- Feature +- Bugfix + +### Features + +If your contribution is something new, like an option for the cli, you can create a branch with the following prefix: + +`feature/` + +### Fixes + +If you are fixing an existing bug, you can create a branch with the following prefix: + +`bugfix/` + +## Testing + +Every bugfix or feature that you submit, needs to be tested. Writing tests for the code is very important to prevent future bugs, and help to discover possible new bugs promptly. + +It is important that you test the logic of the code you're writing, and that your tests really go through all your lines, branches and statements. This is the only way to ensure that the code coverage is high enough to ensure the users of the cli, that they are using a solid tool. + +In case you need a hand or pointers on to how to write your tests, do not hesitate to reach out to us. We will gladly point you in the right direction. + +## Pull Requests + +After getting some feedback, push to your fork and submit a pull request. We +may suggest some changes, improvements or implementation alternatives. + +In case you've got a small change in most of the cases, your pull request would be accepted quicker. + +## Submitting a good Pull Request + +- Write tests. +- Follow the existing coding style. +- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) +- For a major bugfix/feature make sure your PR has an issue and if it doesn't, please create one. This would help discussion with the community, and polishing ideas in case of a new feature. +- Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. ([More info](https://github.com/blog/1506-closing-issues-via-pull-requests)) +- When you have lot of commits in your PR, it's good practice to squash all your commits in one single commit. ([Learn how to squash here](https://davidwalsh.name/squash-commits-git)) + +## Commit message + +Our commit messages format follows the [angular.js commits format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits). + +We don't use the scope. The template of a commit would look like this: + +### Commit Message Format + +Each commit message consists of a **header**, a **body** and a **footer**. The header has a special +format that includes a **type** and a **subject**: + +``` +: + + + +