Skip to content

Commit 2a48305

Browse files
author
Guillaume Chau
committed
chore: merge dev
2 parents 4cbca94 + 69ebd80 commit 2a48305

Some content is hidden

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

62 files changed

+599
-545
lines changed

.circleci/config.yml

+64-18
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,75 @@
11
version: 2
2-
jobs:
3-
build:
4-
docker:
5-
# specify the version you desire here
6-
- image: vuejs/ci
72

8-
working_directory: ~/repo
3+
defaults: &defaults
4+
working_directory: ~/project/vue
5+
docker:
6+
- image: vuejs/ci
97

8+
jobs:
9+
install:
10+
<<: *defaults
1011
steps:
1112
- checkout
12-
13-
# Download and cache dependencies
1413
- restore_cache:
1514
keys:
16-
- v1-dependencies-{{ checksum "yarn.lock" }}
17-
# fallback to using the latest cache if no exact match is found
18-
- v1-dependencies-
19-
20-
- run: yarn install
21-
15+
- v1-vue-{{ .Branch }}-{{ checksum "yarn.lock" }}
16+
- v1-vue-{{ .Branch }}-
17+
- v1-vue-
18+
- run: yarn
2219
- save_cache:
20+
key: v1-vue-{{ .Branch }}-{{ checksum "yarn.lock" }}
2321
paths:
24-
- node_modules
22+
- node_modules/
2523
- ~/.cache/yarn
26-
key: v1-dependencies-{{ checksum "yarn.lock" }}
24+
- persist_to_workspace:
25+
root: ~/project
26+
paths:
27+
- vue
28+
29+
group-1:
30+
<<: *defaults
31+
steps:
32+
- attach_workspace:
33+
at: ~/project
34+
- run: yarn test -p cli,cli-service,cli-shared-utils
35+
36+
group-2:
37+
<<: *defaults
38+
steps:
39+
- attach_workspace:
40+
at: ~/project
41+
- run: yarn test 'ts(?:\w(?!E2e))+\.spec\.js$'
42+
43+
group-3:
44+
<<: *defaults
45+
steps:
46+
- attach_workspace:
47+
at: ~/project
48+
- run: yarn lint
49+
- run: yarn test -p cli-service-global,eslint,pwa,babel,babel-preset-app
50+
51+
group-4:
52+
<<: *defaults
53+
steps:
54+
- attach_workspace:
55+
at: ~/project
56+
- run: yarn test -p unit-mocha,unit-jest,e2e-nightwatch,e2e-cypress
57+
- run: yarn test tsPluginE2e
2758

28-
# run tests!
29-
- run: yarn test
59+
workflows:
60+
version: 2
61+
test:
62+
jobs:
63+
- install
64+
- group-1:
65+
requires:
66+
- install
67+
- group-2:
68+
requires:
69+
- install
70+
- group-3:
71+
requires:
72+
- install
73+
- group-4:
74+
requires:
75+
- install

.eslintrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"jest": true
55
},
66
"rules": {
7-
"indent": ["error", 2, { "MemberExpression": "off" }],
8-
"vue-libs/no-async-functions": 2
7+
"indent": ["error", 2, { "MemberExpression": "off" }]
98
}
109
}

.github/COMMIT_CONVENTION.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Git Commit Message Convention
22

3-
> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/readme.md).
3+
> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular).
44
55
#### TL;DR:
66

docs/env.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ Loaded variables will become available to all `vue-cli-service` commands, plugin
3030
**Mode** is an important concept in Vue CLI projects. By default, there are three modes in a Vue CLI project:
3131

3232
- `development` is used by `vue-cli-service serve`
33-
- `production` is used by `vue-cli-service build`
34-
- `test` is used by `vue-cli-service test`
33+
- `production` is used by `vue-cli-service build` and `vue-cli-service test:e2e`
34+
- `test` is used by `vue-cli-service test:unit`
3535

3636
Note that a mode is different from `NODE_ENV`, as a mode can contain multiple environment variables. That said, each mode does set `NODE_ENV` to the same value by default - for example, `NODE_ENV` will be set to `"development"` in development mode.
3737

3838
You can set environment variables only available to a certain mode by postfixing the `.env` file. For example, if you create a file named `.env.development` in your project root, then the variables declared in that file will only be loaded in development mode.
3939

40-
Passing the `--mode` option flag with [build command](https://github.com/vuejs/vue-cli/blob/dev/docs/cli-service.md#build) will use that mode's environment variables in the build. For example, if you want to use development variables in the build command, add this to your package.json scripts:
40+
You can overwrite the default mode used for a command by passing the `--mode` option flag. For example, if you want to use development variables in the build command, add this to your `package.json` scripts:
4141

4242
```
4343
"dev-build": "vue-cli-service build --mode development",

docs/plugin-dev.md

+22-24
Original file line numberDiff line numberDiff line change
@@ -72,54 +72,52 @@ module.exports = (api, projectOptions) => {
7272
}
7373
```
7474

75-
#### Environment Variables in Service Plugins
75+
#### Specifying Mode for Commands
7676

77-
An important thing to note about env variables is knowing when they are resolved. Typically, a command like `vue-cli-service serve` or `vue-cli-service build` will always call `api.setMode()` as the first thing it does. However, this also means those env variables may not yet be available when a service plugin is invoked:
77+
> Note: the way plugins set modes has been changed in beta.10.
78+
79+
If a plugin-registered command needs to run in a specific default mode,
80+
the plugin needs to expose it via `module.exports.defaultModes` in the form
81+
of `{ [commandName]: mode }`:
7882

7983
``` js
8084
module.exports = api => {
81-
process.env.NODE_ENV // may not be resolved yet
82-
8385
api.registerCommand('build', () => {
84-
api.setMode('production')
86+
// ...
8587
})
8688
}
87-
```
88-
89-
Instead, it's safer to rely on env variables in `configureWebpack` or `chainWebpack` functions, which are called lazily only when `api.resolveWebpackConfig()` is finally called:
9089

91-
``` js
92-
module.exports = api => {
93-
api.configureWebpack(config => {
94-
if (process.env.NODE_ENV === 'production') {
95-
// ...
96-
}
97-
})
90+
module.exports.defaultModes = {
91+
build: 'production'
9892
}
9993
```
10094

95+
This is because the command's expected mode needs to be known before loading environment variables, which in turn needs to happen before loading user options / applying the plugins.
96+
10197
#### Resolving Webpack Config in Plugins
10298

10399
A plugin can retrieve the resolved webpack config by calling `api.resolveWebpackConfig()`. Every call generates a fresh webpack config which can be further mutated as needed:
104100

105101
``` js
106-
api.registerCommand('my-build', args => {
107-
// make sure to set mode and load env variables
108-
api.setMode('production')
102+
module.exports = api => {
103+
api.registerCommand('my-build', args => {
104+
const configA = api.resolveWebpackConfig()
105+
const configB = api.resolveWebpackConfig()
109106

110-
const configA = api.resolveWebpackConfig()
111-
const configB = api.resolveWebpackConfig()
107+
// mutate configA and configB for different purposes...
108+
})
109+
}
112110

113-
// mutate configA and configB for different purposes...
114-
})
111+
// make sure to specify the default mode for correct env variables
112+
module.exports.defaultModes = {
113+
'my-build': 'production'
114+
}
115115
```
116116

117117
Alternatively, a plugin can also obtain a fresh [chainable config](https://github.com/mozilla-neutrino/webpack-chain) by calling `api.resolveChainableWebpackConfig()`:
118118

119119
``` js
120120
api.registerCommand('my-build', args => {
121-
api.setMode('production')
122-
123121
const configA = api.resolveChainableWebpackConfig()
124122
const configB = api.resolveChainableWebpackConfig()
125123

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"puppeteer": "^1.0.0",
5656
"request": "^2.83.0",
5757
"request-promise-native": "^1.0.5",
58+
"rimraf": "^2.6.2",
5859
"yorkie": "^1.0.2"
5960
}
6061
}

packages/@vue/cli-plugin-e2e-cypress/README.md

+9-18
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,24 @@ Cypress offers a rich interactive interface for running E2E tests, but currently
88

99
## Injected Commands
1010

11-
- **`vue-cli-service e2e`**
11+
- **`vue-cli-service test:e2e`**
1212

13-
run e2e tests headlessly with `cypress run`.
13+
Run e2e tests with `cypress run`.
1414

15-
Options:
16-
17-
```
18-
--url run e2e tests against given url instead of auto-starting dev server
19-
-s, --spec runs a specific spec file. defaults to "all"
20-
```
15+
By default it launches Cypress in interactive mode with a GUI. If you want to run the tests in headless mode (e.g. for CI), you can do so with the `--headless` option.
2116

22-
Additionally, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
23-
24-
- **`vue-cli-service e2e:open`**
25-
26-
run e2e tests in interactive mode with `cypress open`.
17+
The command automatically starts a server in production mode to run the e2e tests against. If you want to run the tests multiple times without having to restart the server every time, you can start the server with `vue-cli-service serve --mode production` in one terminal, and then run e2e tests against that server using the `--url` option.
2718

2819
Options:
2920

3021
```
22+
--headless run in headless mode without GUI
23+
--mode specify the mode the dev server should run in. (default: production)
3124
--url run e2e tests against given url instead of auto-starting dev server
25+
-s, --spec (headless only) runs a specific spec file. defaults to "all"
3226
```
3327

34-
Additionally, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open).
35-
36-
Both commands automatically starts a server in production mode to run the e2e tests against. If you want to run the tests multiple times without having to restart the server every time, you can start the server with `vue-cli-service serve --mode production` in one terminal, and then run e2e tests against that server using the `--url` option.
28+
Additionally, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
3729

3830
## Configuration
3931

@@ -42,6 +34,5 @@ We've pre-configured Cypress to place most of the e2e testing related files unde
4234
## Installing in an Already Created Project
4335

4436
``` sh
45-
npm install -D @vue/cli-plugin-e2e-cypress
46-
vue invoke e2e-cypress
37+
vue add e2e-cypress
4738
```

packages/@vue/cli-plugin-e2e-cypress/__tests__/.eslintrc

-5
This file was deleted.

packages/@vue/cli-plugin-e2e-cypress/__tests__/cypressPlugin.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ test('should work', async () => {
1414
config.videoRecording = false
1515
await project.write('cypress.json', JSON.stringify(config))
1616

17-
await project.run(`vue-cli-service e2e`)
17+
await project.run(`vue-cli-service test:e2e --headless`)
1818
})

packages/@vue/cli-plugin-e2e-cypress/generator/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ module.exports = api => {
66

77
api.extendPackage({
88
scripts: {
9-
e2e: 'vue-cli-service e2e',
10-
'e2e:open': 'vue-cli-service e2e:open'
9+
'test:e2e': 'vue-cli-service test:e2e'
1110
}
1211
})
1312
}

0 commit comments

Comments
 (0)