diff --git a/.babelrc b/.babelrc deleted file mode 100644 index e095cab0376..00000000000 --- a/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [[ - "@babel/preset-env", - { - "targets": { - "node": "current" - } - } - ], - "jest" - ] -} \ No newline at end of file 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/.cz-config.js b/.cz-config.js deleted file mode 100644 index b9895b88383..00000000000 --- a/.cz-config.js +++ /dev/null @@ -1,31 +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: "break", name: "break: Changes that break the behaviour of the cli" }, - { 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..2af70d687af --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +FROM node:12 + +# Add global instances of prettier and eslint for vscode +RUN npm install -g eslint prettier \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..264b218cf9b --- /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 bootstrap && yarn build", + "extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] +} diff --git a/.editorconfig b/.editorconfig index b6030406bfb..13c919daf16 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,7 @@ root = true [*] -indent_style = tab +indent_style = space indent_size = 4 charset = utf-8 trim_trailing_whitespace = true diff --git a/.eslintignore b/.eslintignore index f6c8e2019eb..d14956aa89a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,13 +1,17 @@ -**/__testfixtures__/* coverage -docs +.nyc_output node_modules -test/binCases/errors/parse/index.js -test/**/bundle.js -test/**/*.bundle.js -test/**/null.js -test/**/main.js -test/**/cliEntry.js -test/**/foo.js -test/binCases/config-location/webpack-babel-config/bin/es6.js -packages/utils/validate-identifier.ts \ No newline at end of file +dist +packages/configtest/lib +packages/generators/lib +packages/info/lib +packages/serve/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 +packages/generators/src/utils/__tests__/recursive-parser/__testfixtures__ diff --git a/.eslintrc.js b/.eslintrc.js index 1aa1b65f720..282964570ca 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,62 +1,51 @@ module.exports = { - extends: ["eslint:recommended", "plugin:prettier/recommended"], - plugins: ["prettier"], - 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", - "eol-last": ["error", "always"], - "newline-per-chained-call": "off" - } + root: true, + reportUnusedDisableDirectives: true, + extends: [ + "eslint:recommended", + "plugin:node/recommended", + "plugin:prettier/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/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9fe2bc4fa62..0b85fbb6c8c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing From opening a bug report to creating a pull request: every contribution is -appreciated and welcomed. If you're planning a new feature or changing +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. @@ -11,6 +11,7 @@ Table of Contents - [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) @@ -22,12 +23,10 @@ Table of Contents - [Submitting a good Pull Request](#submitting-a-good-pull-request) - [Commit message](#commit-message) - [Commit Message Format](#commit-message-format) -- [Migrate with the CLI](#migrate-with-the-cli) - - [How it's being done](#how-its-being-done) - - [Structure of a transform](#structure-of-a-transform) - - [Further Work](#further-work) - [Contributor License Agreement](#contributor-license-agreement) - [Documentation](#documentation) +- [Releasing](#releasing) +- [Join The Development](#join-the-development) ## Issues @@ -37,13 +36,15 @@ If you are still having difficulty after looking over your configuration careful 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 on Github.** +**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 the issue, we will have a look, and provide feedback to your ticket. +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. @@ -56,93 +57,60 @@ In case you are suggesting a new feature, we will match your idea with our curre - Fork the **webpack-cli** repo at [https://github.com/webpack/webpack-cli](https://github.com/webpack/webpack-cli). - `git clone && cd webpack-cli` -- If you decide to use [yarn](https://yarnpkg.com/lang/en/): - ```bash - npm install -g yarn - ``` +- 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 and link them: +- Install the dependencies: ```bash - #npm - npm install - npm link - npm link webpack-cli - --------------------------- - #yarn - yarn - yarn link - yarn link webpack-cli + yarn install ``` - Bootstrap all the submodules before building for the first time ```bash - #npm - npm run bootstrap - npm run build - --------------------------- - #yarn - yarn bootstrap + 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 npm +### Using yarn - Run all the tests with: ```bash - #npm - npm run test - --------------------------- - #yarn yarn test ``` - Run CLI tests with: ```bash - #npm - npm run test:cli - --------------------------- - #yarn - yarn test:cli` + yarn test:cli ``` - Run tests of all packages: ```bash - #npm - npm run test:packages - --------------------------- - #yarn yarn test:packages ``` - Test a single CLI test case: - > Must run from root of the poject + > Must run from root of the project ```bash - #npm - npx jest path/to/my-test.js - --------------------------- - #yarn yarn jest path/to/my-test.js ``` - You can also install jest globally and run tests without npx: ```bash - #npm - npm i -g jest - jest path/to/my-test.js - --------------------------- - #yarn yarn global add jest jest path/to/my-test.js ``` @@ -150,10 +118,6 @@ In case you are suggesting a new feature, we will match your idea with our curre - You can run the linters: ```bash - #npm - npm run lint - --------------------------- - #yarn yarn lint ``` @@ -165,7 +129,7 @@ The [.editorconfig](https://github.com/webpack/webpack-cli/blob/master/.editorco 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 `package-lock.json` file. +> If you are adding or updating any dependency, please commit the updated `yarn.lock` file. ## Branching Model @@ -214,15 +178,16 @@ In case you've got a small change in most of the cases, your pull request would ## Submitting a good Pull Request -- Write tests -- Follow the existing coding style +- 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/CONTRIBUTING.md#commit-message-format). - -You can use `npm run commit` script to have an interactive way of making commits that follow our guidelines. +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: @@ -231,10 +196,9 @@ We don't use the scope. The template of a commit would look like this: 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**: -```md +``` : -