Skip to content

Commit 358651e

Browse files
chore: move cli under lerna package (#1225)
* 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>
1 parent 2dc495a commit 358651e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+299
-51986
lines changed

.github/CONTRIBUTING.md

+6-43
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,23 @@ In case you are suggesting a new feature, we will match your idea with our curre
5656
- Fork the **webpack-cli** repo at [https://github.com/webpack/webpack-cli](https://github.com/webpack/webpack-cli).
5757
- `git clone <your-clone-url> && cd webpack-cli`
5858

59-
- If you decide to use [yarn](https://yarnpkg.com/lang/en/):
59+
- We use [yarn](https://yarnpkg.com/lang/en/) workspaces, please install it:
6060
```bash
6161
npm install -g yarn
6262
```
6363

6464
> Using yarn is not a requirement, [npm](https://www.npmjs.com/) is included in node.
6565

66-
- Install the dependencies and link them:
66+
- Install the dependencies:
6767

6868
```bash
69-
#npm
70-
npm install
71-
npm link
72-
npm link webpack-cli
73-
---------------------------
74-
#yarn
75-
yarn
76-
yarn link
77-
yarn link webpack-cli
69+
yarn install
7870
```
7971

8072
- Bootstrap all the submodules before building for the first time
8173

8274
```bash
8375
#npm
84-
npm run bootstrap
85-
npm run build
86-
---------------------------
87-
#yarn
8876
yarn bootstrap
8977
yarn build
9078
```
@@ -96,30 +84,18 @@ In case you are suggesting a new feature, we will match your idea with our curre
9684
- Run all the tests with:
9785

9886
```bash
99-
#npm
100-
npm run test
101-
---------------------------
102-
#yarn
10387
yarn test
10488
```
10589

10690
- Run CLI tests with:
10791

10892
```bash
109-
#npm
110-
npm run test:cli
111-
---------------------------
112-
#yarn
11393
yarn test:cli`
11494
```
11595

11696
- Run tests of all packages:
11797

11898
```bash
119-
#npm
120-
npm run test:packages
121-
---------------------------
122-
#yarn
12399
yarn test:packages
124100
```
125101

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

130106
```bash
131-
#npm
132-
npx jest path/to/my-test.js
133-
---------------------------
134-
#yarn
135107
yarn jest path/to/my-test.js
136108
```
137109

138110
- You can also install jest globally and run tests without npx:
139111

140112
```bash
141-
#npm
142-
npm i -g jest
143-
jest path/to/my-test.js
144-
---------------------------
145-
#yarn
146113
yarn global add jest
147114
jest path/to/my-test.js
148115
```
149116

150117
- You can run the linters:
151118

152119
```bash
153-
#npm
154-
npm run lint
155-
---------------------------
156-
#yarn
157120
yarn lint
158121
```
159122

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

307270
```js
308-
const defineTest = require("../defineTest");
271+
const defineTest = require('../defineTest');
309272
310-
defineTest(__dirname, "transform-name.input1.js");
311-
defineTest(__dirname, "transform-name.input2.js");
273+
defineTest(__dirname, 'transform-name.input1.js');
274+
defineTest(__dirname, 'transform-name.input2.js');
312275
```
313276

314277
`defineTest` is a helper test method which helps us to run tests on all the transforms uniformly.

.github/workflows/nodejs.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ jobs:
2626
uses: actions/setup-node@v1
2727
with:
2828
node-version: ${{ matrix.node-version }}
29-
- name: npm install, bootstrap
29+
- name: yarn install, bootstrap
3030
run: |
31-
npm install
32-
npm run bootstrap
31+
yarn
32+
yarn bootstrap
3333
- name: Run test for webpack version ${{ matrix.webpack-version }}
3434
run: |
35-
npm install --save webpack@${{ matrix.webpack-version }}
36-
npm run build
37-
npm run test:ci
35+
yarn add -W webpack@${{ matrix.webpack-version }}
36+
yarn build
37+
yarn test:ci
3838
env:
3939
CI: true
4040
- name: smoketest
4141
run: |
42-
npm run build --if-present
43-
npm run smoketest
42+
yarn build
43+
yarn smoketest
4444
env:
4545
CI: true

.travis.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ language: node_js
55
node_js:
66
- "12"
77
- "10"
8-
cache:
9-
directories:
10-
- ~/.npm
8+
119
matrix:
1210
include:
1311
- os: linux
@@ -21,14 +19,14 @@ matrix:
2119
env: JOB_PART=integration
2220

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

2624
install:
27-
- travis_wait npm ci
25+
- travis_wait yarn
2826
- lerna bootstrap
29-
- npm install -g codecov
30-
- npm install -g eslint
27+
- yarn global add codecov
28+
- yarn global add eslint
3129
script:
32-
- npm run travis:lint
33-
- npm run test:ci
30+
- yarn travis:lint
31+
- yarn test:ci
3432

README.md

+4-37
Original file line numberDiff line numberDiff line change
@@ -51,51 +51,18 @@ When you have followed the [Getting Started](https://webpack.js.org/guides/getti
5151

5252
Otherwise `npm install --save-dev webpack-cli` or `yarn add webpack-cli --dev` will install it.
5353

54-
# Supported arguments and commands
54+
## Supported arguments and commands
5555

56-
```
57-
58-
Available Commands
59-
60-
init Initialize a new webpack configuration
61-
migrate Migrate a configuration to a new version
62-
loader Scaffold a loader repository
63-
plugin Scaffold a plugin repository
64-
info Outputs information about your system and dependencies
65-
serve Run the webpack Dev Server
66-
67-
Options
68-
69-
--entry string The entry point of your application.
70-
-c, --config string Provide path to a webpack configuration file
71-
-m, --merge string Merge a configuration file using webpack-merge
72-
--progress Print compilation progress during build
73-
--silent Disable any output that webpack makes
74-
--help Outputs list of supported flags
75-
--defaults Allow webpack to set defaults aggresively
76-
-o, --output string Output location of the file generated by webpack
77-
--plugin string Load a given plugin
78-
-g, --global string[] Declares and exposes a global variable
79-
-t, --target string Sets the build target
80-
-w, --watch Watch for files changes
81-
-h, --hot Enables Hot Module Replacement
82-
-s, --sourcemap string Determine source maps to use
83-
--prefetch string Prefetch this request
84-
-j, --json Prints result as JSON
85-
--standard Prints standard output
86-
-d, --dev Run development build
87-
-p, --prod Run production build
88-
--version Get current version
89-
--node-args string[] NodeJS flags
90-
```
56+
Get to know what are the available commands and arguments [here](./packages/cli/README.md).
9157

9258
## Packages
9359

9460
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.
9561

9662
### Commands
9763

98-
Supporting developers is an important task for webpack CLI. Thus, webpack CLI provides different commands for many common tasks.
64+
Supporting developers is an important task for webpack CLI.
65+
Thus, webpack CLI provides different commands for many common tasks.
9966

10067
- [`webpack-cli init`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration.
10168
- [`webpack-cli info`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment.

azure-pipelines-template.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ jobs:
1515
versionSpec: $(node_version)
1616
displayName: "Install Node.js"
1717
- script: |
18-
npm install -g npm@latest
18+
npm install -g yarn
1919
displayName: "Install npm"
2020
- script: |
2121
node -v
22-
npm -v
22+
yarn -v
2323
displayName: "Print version"
2424
- script: |
25-
npm ci
26-
npm run bootstrap
25+
yarn
26+
yarn bootstrap
2727
displayName: "Lerna bootstrap"
2828
- script: |
29-
npm run test
29+
yarn test:ci
3030
displayName: "Run tests"
3131
- task: PublishTestResults@2
3232
inputs:

jest.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
3+
// transformIgnorePatterns: ['<rootDir>.*(node_modules)(?!.*webpack-cli.*).*$'],
4+
testEnvironment: 'node',
5+
collectCoverage: true,
6+
coverageReporters: ['json', 'html', 'cobertura'],
7+
transform: {
8+
'^.+\\.(ts)?$': 'ts-jest',
9+
},
10+
testRegex: ['/__tests__/.*\\.(test.js|test.ts)$', '/test/.*\\.(test.js|test.ts)$'],
11+
moduleFileExtensions: ['ts', 'js', 'json'],
12+
};

lerna.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
"lerna": "3.20.2",
33
"packages": ["packages/*"],
44
"version": "independent",
5+
"npmClient": "yarn",
6+
"useWorkspaces": true,
57
"command": {
68
"version": {
7-
"message": "chore(release): publish",
9+
"message": "chore(release): publish %s",
810
"conventionalCommits": true,
11+
"allowBranch": ["master", "next/"],
912
"yes": true
1013
}
1114
}

0 commit comments

Comments
 (0)