Skip to content

Commit

Permalink
chore: move cli under lerna package (#1225)
Browse files Browse the repository at this point in the history
* chore(cli): move cli under lerna package

* chore(cli): move cli under lerna package

* fix(cli): lock correct webpack version

* fix(serve): expose cmdArgs using webpack-cli API

* chore(serve): remove logs

* chore: fix lerna config file

* docs(cli): added readme file to the cli package

* chore: moved to yarn workspaces to have a better testing suite

This is done because we want to resolve internal packages during e2e without using shim code.

* docs: updated contribution file

* chore(ci): moved to yarn inside the CI

* chore(ci): install yarn

* chore(ci): fix issue inside yaml file

* tests: fix various tests

* chore(ci): fix node command

* chore(ci): skip root check on yarn

* chore(ci): skip tests because they don't work

* chore(migrate): added ignore as webpack types are incorrect

* docs:Update README.md

Co-Authored-By: James George <jamesgeorge998001@gmail.com>

Co-authored-by: James George <jamesgeorge998001@gmail.com>
  • Loading branch information
ematipico and jamesgeorge007 committed Feb 17, 2020
1 parent 2dc495a commit 358651e
Show file tree
Hide file tree
Showing 66 changed files with 299 additions and 51,986 deletions.
49 changes: 6 additions & 43 deletions .github/CONTRIBUTING.md
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
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
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
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
```
Get to know what are the available commands and arguments [here](./packages/cli/README.md).

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

0 comments on commit 358651e

Please sign in to comment.