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

chore: move cli under lerna package #1225

Merged
merged 18 commits into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 6 additions & 43 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,23 @@ 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 <your-clone-url> && cd webpack-cli`

- If you decide to use [yarn](https://yarnpkg.com/lang/en/):
- We use [yarn](https://yarnpkg.com/lang/en/) workspaces, please install it:
```bash
npm install -g 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 build
```
Expand All @@ -96,30 +84,18 @@ In case you are suggesting a new feature, we will match your idea with our curre
- 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`
```

- Run tests of all packages:

```bash
#npm
npm run test:packages
---------------------------
#yarn
yarn test:packages
```

Expand All @@ -128,32 +104,19 @@ In case you are suggesting a new feature, we will match your idea with our curre
> Must run from root of the poject

```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
```

- You can run the linters:

```bash
#npm
npm run lint
---------------------------
#yarn
yarn lint
```

Expand Down Expand Up @@ -305,10 +268,10 @@ Each test will refer to an input webpack config snippet.
Conventionally we write them in `\_\_testfixtures\_\_`.

```js
const defineTest = require("../defineTest");
const defineTest = require('../defineTest');

defineTest(__dirname, "transform-name.input1.js");
defineTest(__dirname, "transform-name.input2.js");
defineTest(__dirname, 'transform-name.input1.js');
defineTest(__dirname, 'transform-name.input2.js');
```

`defineTest` is a helper test method which helps us to run tests on all the transforms uniformly.
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, bootstrap
- name: yarn install, bootstrap
run: |
npm install
npm run bootstrap
yarn
yarn bootstrap
- name: Run test for webpack version ${{ matrix.webpack-version }}
run: |
npm install --save webpack@${{ matrix.webpack-version }}
npm run build
npm run test:ci
yarn add -W webpack@${{ matrix.webpack-version }}
yarn build
yarn test:ci
env:
CI: true
- name: smoketest
run: |
npm run build --if-present
npm run smoketest
yarn build
yarn smoketest
env:
CI: true
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ language: node_js
node_js:
- "12"
- "10"
cache:
directories:
- ~/.npm

matrix:
include:
- os: linux
Expand All @@ -21,14 +19,14 @@ matrix:
env: JOB_PART=integration

before_install:
- "[[ $(node -v) =~ ^v9.*$ ]] || npm install -g npm@latest" # skipped when using node 9
- npm install -g yarn@latest

install:
- travis_wait npm ci
- travis_wait yarn
- lerna bootstrap
- npm install -g codecov
- npm install -g eslint
- yarn global add codecov
- yarn global add eslint
script:
- npm run travis:lint
- npm run test:ci
- yarn travis:lint
- yarn test:ci

41 changes: 4 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,51 +51,18 @@ 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
## 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
```
Please read [here](./packages/cli/README.md) what are the available commands and arguments.
ematipico marked this conversation as resolved.
Show resolved Hide resolved

## 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.

### Commands

Supporting developers is an important task for webpack CLI. Thus, webpack CLI provides different commands for many common tasks.
Supporting developers is an important task for webpack CLI.
Thus, webpack CLI provides different commands for many common tasks.

- [`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.
Expand Down
10 changes: 5 additions & 5 deletions azure-pipelines-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ jobs:
versionSpec: $(node_version)
displayName: "Install Node.js"
- script: |
npm install -g npm@latest
npm install -g yarn
displayName: "Install npm"
- script: |
node -v
npm -v
yarn -v
displayName: "Print version"
- script: |
npm ci
npm run bootstrap
yarn
yarn bootstrap
displayName: "Lerna bootstrap"
- script: |
npm run test
yarn test:ci
displayName: "Run tests"
- task: PublishTestResults@2
inputs:
Expand Down
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
// transformIgnorePatterns: ['<rootDir>.*(node_modules)(?!.*webpack-cli.*).*$'],
testEnvironment: 'node',
collectCoverage: true,
coverageReporters: ['json', 'html', 'cobertura'],
transform: {
'^.+\\.(ts)?$': 'ts-jest',
},
testRegex: ['/__tests__/.*\\.(test.js|test.ts)$', '/test/.*\\.(test.js|test.ts)$'],
moduleFileExtensions: ['ts', 'js', 'json'],
};
5 changes: 4 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"lerna": "3.20.2",
"packages": ["packages/*"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"version": {
"message": "chore(release): publish",
"message": "chore(release): publish %s",
"conventionalCommits": true,
"allowBranch": ["master", "next/"],
"yes": true
}
}
Expand Down
Loading