Skip to content

feat: allow omitting scope prefix for official plugins on vue add #4219

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

Merged
merged 4 commits into from
Jul 6, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/core-plugins/babel.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
## Installing in an Already Created Project

``` sh
vue add @vue/babel
vue add babel
```

## Injected webpack-chain Rules
Expand Down
4 changes: 2 additions & 2 deletions docs/core-plugins/e2e-cypress.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Cypress offers a rich interactive interface for running E2E tests, but currently

- In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
- In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).

Examples :
- Run Cypress in headless mode for a specific file: `vue-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js`

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

``` sh
vue add @vue/e2e-cypress
vue add e2e-cypress
```
2 changes: 1 addition & 1 deletion docs/core-plugins/e2e-nightwatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ Consult Nightwatch docs for [configuration options](http://nightwatchjs.org/gett
## Installing in an Already Created Project

``` sh
vue add @vue/e2e-nightwatch
vue add e2e-nightwatch
```
2 changes: 1 addition & 1 deletion docs/core-plugins/eslint.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = {
## Installing in an Already Created Project

``` sh
vue add @vue/eslint
vue add eslint
```

## Injected webpack-chain Rules
Expand Down
2 changes: 1 addition & 1 deletion docs/core-plugins/pwa.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports = {
## Installing in an Already Created Project

``` sh
vue add @vue/pwa
vue add pwa
```

## Injected webpack-chain Rules
Expand Down
2 changes: 1 addition & 1 deletion docs/core-plugins/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If opted to use [TSLint](https://palantir.github.io/tslint/) during project crea
## Installing in an Already Created Project

``` sh
vue add @vue/typescript
vue add typescript
```

## Injected webpack-chain Rules
Expand Down
2 changes: 1 addition & 1 deletion docs/core-plugins/unit-jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Jest can be configured via `jest.config.js` in your project root, or the `jest`
## Installing in an Already Created Project

```sh
vue add @vue/unit-jest
vue add unit-jest
```

## Transform dependencies from `/node_modules`
Expand Down
2 changes: 1 addition & 1 deletion docs/core-plugins/unit-mocha.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
## Installing in an Already Created Project

``` sh
vue add @vue/unit-mocha
vue add unit-mocha
```
6 changes: 3 additions & 3 deletions docs/guide/plugins-and-presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can install and manage Plugins using the GUI with the `vue ui` command.
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:

``` bash
vue add @vue/eslint
vue add eslint
```

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

``` bash
# these are equivalent to the previous usage
vue add @vue/cli-plugin-eslint
vue add cli-plugin-eslint
```

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`:
Expand All @@ -49,7 +49,7 @@ vue add @foo/bar
You can pass generator options to the installed plugin (this will skip the prompts):

``` bash
vue add @vue/eslint --config airbnb --lintOn save
vue add eslint --config airbnb --lintOn save
```

If a plugin is already installed, you can skip the installation and only invoke its generator with the `vue invoke` command. The command takes the same arguments as `vue add`.
Expand Down
6 changes: 3 additions & 3 deletions docs/ru/guide/plugins-and-presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Каждый плагин для CLI поставляется с генератором (который создаёт файлы) и плагином для runtime (который меняет конфигурацию webpack и внедряет команды). Когда вы используете `vue create` для создания нового проекта, некоторые плагины будут уже предустановлены, в зависимости от вашего выбора необходимых возможностей. В случае, когда необходимо установить плагин в уже существующий проект, вы должны сделать это командой `vue add`:

``` bash
vue add @vue/eslint
vue add eslint
```

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

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

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

``` bash
vue add @vue/eslint --config airbnb --lintOn save
vue add eslint --config airbnb --lintOn save
```

Если плагин уже установлен, вы можете пропустить установку и только вызвать его генератор с помощью команды `vue invoke`. Команда принимает такие же аргументы, как и `vue add`.
Expand Down
6 changes: 3 additions & 3 deletions docs/zh/guide/plugins-and-presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Vue CLI 使用了一套基于插件的架构。如果你查阅一个新创建项
每个 CLI 插件都会包含一个 (用来创建文件的) 生成器和一个 (用来调整 webpack 核心配置和注入命令的) 运行时插件。当你使用 `vue create` 来创建一个新项目的时候,有些插件会根据你选择的特性被预安装好。如果你想在一个已经被创建好的项目中安装一个插件,可以使用 `vue add` 命令:

``` bash
vue add @vue/eslint
vue add eslint
```

::: tip 提示
Expand All @@ -30,7 +30,7 @@ vue add @vue/eslint

``` bash
# 这个和之前的用法等价
vue add @vue/cli-plugin-eslint
vue add cli-plugin-eslint
```

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

``` bash
vue add @vue/eslint --config airbnb --lintOn save
vue add eslint --config airbnb --lintOn save
```

如果一个插件已经被安装,你可以使用 `vue invoke` 命令跳过安装过程,只调用它的生成器。这个命令会接受和 `vue add` 相同的参数。
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-babel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
## Installing in an Already Created Project

``` sh
vue add @vue/babel
vue add babel
```

## Injected webpack-chain Rules
Expand Down
4 changes: 2 additions & 2 deletions packages/@vue/cli-plugin-e2e-cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Cypress offers a rich interactive interface for running E2E tests, but currently

- In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
- In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).

Examples :
- Run Cypress in headless mode for a specific file: `vue-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js`

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

``` sh
vue add @vue/e2e-cypress
vue add e2e-cypress
```
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-e2e-nightwatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ Consult Nightwatch docs for [configuration options](http://nightwatchjs.org/gett
## Installing in an Already Created Project

``` sh
vue add @vue/e2e-nightwatch
vue add e2e-nightwatch
```
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = {
## Installing in an Already Created Project

``` sh
vue add @vue/eslint
vue add eslint
```

## Injected webpack-chain Rules
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-pwa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports = {
## Installing in an Already Created Project

``` sh
vue add @vue/pwa
vue add pwa
```

## Injected webpack-chain Rules
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
## Installing in an Already Created Project

``` sh
vue add @vue/router
vue add router
```
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If opted to use [TSLint](https://palantir.github.io/tslint/) during project crea
## Installing in an Already Created Project

``` sh
vue add @vue/typescript
vue add typescript
```

## Injected webpack-chain Rules
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Jest can be configured via `jest.config.js` in your project root, or the `jest`
## Installing in an Already Created Project

```sh
vue add @vue/unit-jest
vue add unit-jest
```

## Transform dependencies from `/node_modules`
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-mocha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
## Installing in an Already Created Project

``` sh
vue add @vue/unit-mocha
vue add unit-mocha
```
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-vuex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
## Installing in an Already Created Project

``` sh
vue add @vue/vuex
vue add vuex
```
16 changes: 16 additions & 0 deletions packages/@vue/cli-shared-utils/lib/pluginResolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ const pluginRE = /^(@vue\/|vue-|@[\w-]+\/vue-)cli-plugin-/
const scopeRE = /^@[\w-]+\//
const officialRE = /^@vue\//

const officialPlugins = [
'babel',
'e2e-cypress',
'e2e-nightwatch',
'eslint',
'pwa',
'router',
'typescript',
'unit-jest',
'unit-mocha',
'vuex'
]

exports.isPlugin = id => pluginRE.test(id)

exports.isOfficialPlugin = id => exports.isPlugin(id) && officialRE.test(id)
Expand All @@ -14,6 +27,9 @@ exports.resolvePluginId = id => {
if (pluginRE.test(id)) {
return id
}
if (officialPlugins.includes(id)) {
return `@vue/cli-plugin-${id}`
}
// scoped short
// e.g. @vue/foo, @bar/foo
if (id.charAt(0) === '@') {
Expand Down