8000 feat: allow omitting scope prefix for official plugins on `vue add` (… · vuejs/vue-cli@3c8a890 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c8a890

Browse files
committed
feat: allow omitting scope prefix for official plugins on vue add (#4219)
(cherry picked from commit 8b8bb99)
1 parent 4c970f9 commit 3c8a890

File tree

12 files changed

+34
-18
lines changed

12 files changed

+34
-18
lines changed

docs/guide/plugins-and-presets.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can install and manage Plugins using the GUI with the `vue ui` command.
1515
Each CLI plugin ships with a generator (which creates files) and a runtime plugin (which tweaks the core webpack config and injects commands). When you use `vue create` to create a new project, some plugins will be pre-installed for you based on your feature selection. In case you want to install a plugin into an already created project, you can do so with the `vue add` command:
1616

1717
``` bash
18-
vue add @vue/eslint
18+
vue add eslint
1919
```
2020

2121
::: tip
@@ -30,7 +30,7 @@ The command resolves `@vue/eslint` to the full package name `@vue/cli-plugin-esl
3030

3131
``` bash
3232
# these are equivalent to the previous usage
33-
vue add @vue/cli-plugin-eslint
33+
vue add cli-plugin-eslint
3434
```
3535

3636
Without the `@vue` prefix, the command will resolve to an unscoped package instead. For example, to install the 3rd party plugin `vue-cli-plugin-apollo`:
@@ -49,7 +49,7 @@ vue add @foo/bar
4949
You can pass generator options to the installed plugin (this will skip the prompts):
5050

5151
``` bash
52-
vue add @vue/eslint --config airbnb --lintOn save
52+
vue add eslint --config airbnb --lintOn save
5353
```
5454

5555
`vue-router` and `vuex` are special cases - they do not have their own plugins, but you can add them nonetheless:

docs/ru/guide/plugins-and-presets.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Каждый плагин для CLI поставляется с генератором (который создаёт файлы) и плагином для runtime (который меняет конфигурацию webpack и внедряет команды). Когда вы используете `vue create` для создания нового проекта, некоторые плагины будут уже предустановлены, в зависимости от вашего выбора необходимых возможностей. В случае, когда необходимо установить плагин в уже существующий проект, вы должны сделать это командой `vue add`:
1616

1717
``` bash
18-
vue add @vue/eslint
18+
vue add eslint
1919
```
2020

2121
::: tip Совет
@@ -30,7 +30,7 @@ vue add @vue/eslint
3030

3131
``` bash
3232
# это аналогично предыдущей команде
33-
vue add @vue/cli-plugin-eslint
33+
vue add cli-plugin-eslint
3434
```
3535

3636
Без префикса `@vue` команда будет трансформировать название к публичному пакету. Например, чтобы установить сторонний плагин `vue-cli-plugin-apollo`:
@@ -49,7 +49,7 @@ vue add @foo/bar
4949
Можно передавать опции генерации в установленный плагин (для пропуска интерактивного выбора):
5050

5151
``` bash
52-
vue add @vue/eslint --config airbnb --lintOn save
52+
vue add eslint --config airbnb --lintOn save
5353
```
5454

5555
Добавление `vue-router` и `vuex` — особый случай, у них нет собственных плагинов, но вы тем не менее можете их добавить:

docs/zh/guide/plugins-and-presets.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Vue CLI 使用了一套基于插件的架构。如果你查阅一个新创建项
1515
每个 CLI 插件都会包含一个 (用来创建文件的) 生成器和一个 (用来调整 webpack 核心配置和注入命令的) 运行时插件。当你使用 `vue create` 来创建一个新项目的时候,有些插件会根据你选择的特性被预安装好。如果你想在一个已经被创建好的项目中安装一个插件,可以使用 `vue add` 命令:
1616

1717
``` bash
18-
vue add @vue/eslint
18+
vue add eslint
1919
```
2020

2121
::: tip 提示
@@ -30,7 +30,7 @@ vue add @vue/eslint
3030

3131
``` bash
3232
# 这个和之前的用法等价
33-
vue add @vue/cli-plugin-eslint
33+
vue add cli-plugin-eslint
3434
```
3535

3636
如果不带 `@vue` 前缀,该命令会换作解析一个 unscoped 的包。例如以下命令会安装第三方插件 `vue-cli-plugin-apollo`
@@ -49,7 +49,7 @@ vue add @foo/bar
4949
你可以向被安装的插件传递生成器选项 (这样做会跳过命令提示):
5050

5151
``` bash
52-
vue add @vue/eslint --config airbnb --lintOn save
52+
vue add eslint --config airbnb --lintOn save
5353
```
5454

5555
`vue-router``vuex` 的情况比较特殊——它们并没有自己的插件,但是你仍然可以这样添加它们:

packages/@vue/cli-plugin-babel/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
## Installing in an Already Created Project
3030

3131
``` sh
32-
vue add @vue/babel
32+
vue add babel
3333
```
3434

3535
## Injected webpack-chain Rules

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Cypress offers a rich interactive interface for running E2E tests, but currently
2929

3030
- In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
3131
- In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
32-
32+
3333
Examples :
3434
- Run Cypress in headless mode for a specific file: `vue-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js`
3535

@@ -44,5 +44,5 @@ Cypress doesn't load .env files for your test files the same way as `vue-cli` do
4444
## Installing in an Already Created Project
4545

4646
``` sh
47-
vue add @vue/e2e-cypress
47+
vue add e2e-cypress
4848
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ Consult Nightwatch docs for [configuration options](http://nightwatchjs.org/gett
3333
## Installing in an Already Created Project
3434

3535
``` sh
36-
vue add @vue/e2e-nightwatch
36+
vue add e2e-nightwatch
3737
```

packages/@vue/cli-plugin-eslint/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = {
6363
## Installing in an Already Created Project
6464

6565
``` sh
66-
vue add @vue/eslint
66+
vue add eslint
6767
```
6868

6969
## Injected webpack-chain Rules

packages/@vue/cli-plugin-pwa/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module.exports = {
114114
## Installing in an Already Created Project
115115

116116
``` sh
117-
vue add @vue/pwa
117+
vue add pwa
118118
```
119119

120120
## Injected webpack-chain Rules

packages/@vue/cli-plugin-typescript/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ If opted to use [TSLint](https://palantir.github.io/tslint/) during project crea
2727
## Installing in an Already Created Project
2828

2929
``` sh
30-
vue add @vue/typescript
30+
vue add typescript
3131
```
3232

3333
## Injected webpack-chain Rules

packages/@vue/cli-plugin-unit-jest/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Jest can be configured via `jest.config.js` in your project root, or the `jest`
3636
## Installing in an Already Created Project
3737

3838
```sh
39-
vue add @vue/unit-jest
39+
vue add unit-jest
4040
```
4141

4242
## Transform dependencies from `/node_modules`

packages/@vue/cli-plugin-unit-mocha/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
## Installing in an Already Created Project
3333

3434
``` sh
35-
vue add @vue/unit-mocha
35+
vue add unit-mocha
3636
```

packages/@vue/cli-shared-utils/lib/pluginResolution.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ const pluginRE = /^(@vue\/|vue-|@[\w-]+\/vue-)cli-plugin-/
22
const scopeRE = /^@[\w-]+\//
33
const officialRE = /^@vue\//
44

5+
const officialPlugins = [
6+
'babel',
7+
'e2e-cypress',
8+
'e2e-nightwatch',
9+
'eslint',
10+
'pwa',
11+
'router',
12+
'typescript',
13+
'unit-jest',
14+
'unit-mocha',
15+
'vuex'
16+
]
17+
518
exports.isPlugin = id => pluginRE.test(id)
619

720
exports.isOfficialPlugin = id => exports.isPlugin(id) && officialRE.test(id)
@@ -14,6 +27,9 @@ exports.resolvePluginId = id => {
1427
if (pluginRE.test(id)) {
1528
return id
1629
}
30+
if (officialPlugins.includes(id)) {
31+
return `@vue/cli-plugin-${id}`
32+
}
1733
// scoped short
1834
// e.g. @vue/foo, @bar/foo
1935
if (id.charAt(0) === '@') {

0 commit comments

Comments
 (0)
0