Skip to content

Commit 78c7c12

Browse files
committed
feat: support yarn for adding inline registry
closes #2809 Yarn supports `--registry` since v1.2.0
1 parent 21256f5 commit 78c7c12

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

docs/guide/creating-a-project.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ Options:
4646
-d, --default Skip prompts and use default preset
4747
-i, --inlinePreset <json> Skip prompts and use inline JSON string as preset
4848
-m, --packageManager <command> Use specified npm client when installing dependencies
49-
-r, --registry <url> Use specified npm registry when installing dependencies (only for npm)
49+
-r, --registry <url> Use specified npm registry when installing dependencies
5050
-g, --git [message|false] Force / skip git initialization, optionally specify initial commit message
5151
-n, --no-git Skip git initialization
5252
-f, --force Overwrite target directory if it exists
5353
-c, --clone Use git clone when fetching remote preset
54-
-x, --proxy Use specified proxy when creating project
54+
-x, --proxy Use specified proxy when creating project
5555
-b, --bare Scaffold project without beginner instructions
5656
-h, --help Output usage information
5757
```

docs/ru/guide/creating-a-project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ vue create --help
4646
-d, --default Пропустить подсказки и использовать пресет настроек по умолчанию
4747
-i, --inlinePreset <json> Пропустить подсказки и использовать вставленную строку JSON в качестве пресета настроек
4848
-m, --packageManager <command> Использовать указанный npm клиент при установке зависимостей
49-
-r, --registry <url> Использовать указанный npm регистр при установке зависимостей (только для npm)
49+
-r, --registry <url> Использовать указанный npm регистр при установке зависимостей
5050
-g, --git [message|false] Форсировать / пропустить инициализацию git, опционально указать сообщение к первому коммиту
5151
-n, --no-git Пропустить инициализацию git
5252
-f, --force Перезаписать целевой каталог, если такой уже есть

docs/zh/guide/creating-a-project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ vue create --help
4646
-d, --default 忽略提示符并使用默认预设选项
4747
-i, --inlinePreset <json> 忽略提示符并使用内联的 JSON 字符串预设选项
4848
-m, --packageManager <command> 在安装依赖时使用指定的 npm 客户端
49-
-r, --registry <url> 在安装依赖时使用指定的 npm registry (仅用于 npm 客户端)
49+
-r, --registry <url> 在安装依赖时使用指定的 npm registry
5050
-g, --git [message] 强制 / 跳过 git 初始化,并可选的指定初始化提交信息
5151
-n, --no-git 跳过 git 初始化
5252
-f, --force 覆写目标目录可能存在的配置

packages/@vue/cli/lib/util/installDeps.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,9 @@ function renderProgressBar (curr, total) {
6161
}
6262

6363
async function addRegistryToArgs (command, args, cliRegistry) {
64-
if (command === 'yarn' && cliRegistry) {
65-
throw new Error(
66-
`Inline registry is not supported when using yarn. ` +
67-
`Please run \`yarn config set registry ${cliRegistry}\` before running @vue/cli.`
68-
)
69-
}
70-
7164
const altRegistry = (
7265
cliRegistry || (
73-
(command === 'npm' && await shouldUseTaobao())
66+
(await shouldUseTaobao(command))
7467
? registries.taobao
7568
: null
7669
)

packages/@vue/cli/lib/util/shouldUseTaobao.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function removeSlash (url) {
1717
let checked
1818
let result
1919

20-
module.exports = async function shouldUseTaobao () {
20+
module.exports = async function shouldUseTaobao (command = 'npm') {
2121
// ensure this only gets called once.
2222
if (checked) return result
2323
checked = true
@@ -34,8 +34,8 @@ module.exports = async function shouldUseTaobao () {
3434
return val
3535
}
3636

37-
const userCurrent = (await execa(`npm`, ['config', 'get', 'registry'])).stdout
38-
const defaultRegistry = registries.npm
37+
const userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout
38+
const defaultRegistry = registries[command]
3939

4040
if (removeSlash(userCurrent) !== removeSlash(defaultRegistry)) {
4141
// user has configured custom registry, respect that
@@ -67,7 +67,7 @@ module.exports = async function shouldUseTaobao () {
6767
name: 'useTaobaoRegistry',
6868
type: 'confirm',
6969
message: chalk.yellow(
70-
` Your connection to the default npm registry seems to be slow.\n` +
70+
` Your connection to the default ${command} registry seems to be slow.\n` +
7171
` Use ${chalk.cyan(registries.taobao)} for faster installation?`
7272
)
7373
}

0 commit comments

Comments
 (0)