Skip to content

Commit

Permalink
feat: support yarn for adding inline registry
Browse files Browse the repository at this point in the history
closes vuejs#2809

Yarn supports `--registry` since v1.2.0
  • Loading branch information
haoqunjiang committed Oct 28, 2018
1 parent 21256f5 commit 78c7c12
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/guide/creating-a-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Options:
-d, --default Skip prompts and use default preset
-i, --inlinePreset <json> Skip prompts and use inline JSON string as preset
-m, --packageManager <command> Use specified npm client when installing dependencies
-r, --registry <url> Use specified npm registry when installing dependencies (only for npm)
-r, --registry <url> Use specified npm registry when installing dependencies
-g, --git [message|false] Force / skip git initialization, optionally specify initial commit message
-n, --no-git Skip git initialization
-f, --force Overwrite target directory if it exists
-c, --clone Use git clone when fetching remote preset
-x, --proxy Use specified proxy when creating project
-x, --proxy Use specified proxy when creating project
-b, --bare Scaffold project without beginner instructions
-h, --help Output usage information
```
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/guide/creating-a-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ vue create --help
-d, --default Пропустить подсказки и использовать пресет настроек по умолчанию
-i, --inlinePreset <json> Пропустить подсказки и использовать вставленную строку JSON в качестве пресета настроек
-m, --packageManager <command> Использовать указанный npm клиент при установке зависимостей
-r, --registry <url> Использовать указанный npm регистр при установке зависимостей (только для npm)
-r, --registry <url> Использовать указанный npm регистр при установке зависимостей
-g, --git [message|false] Форсировать / пропустить инициализацию git, опционально указать сообщение к первому коммиту
-n, --no-git Пропустить инициализацию git
-f, --force Перезаписать целевой каталог, если такой уже есть
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/guide/creating-a-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ vue create --help
-d, --default 忽略提示符并使用默认预设选项
-i, --inlinePreset <json> 忽略提示符并使用内联的 JSON 字符串预设选项
-m, --packageManager <command> 在安装依赖时使用指定的 npm 客户端
-r, --registry <url> 在安装依赖时使用指定的 npm registry (仅用于 npm 客户端)
-r, --registry <url> 在安装依赖时使用指定的 npm registry
-g, --git [message] 强制 / 跳过 git 初始化,并可选的指定初始化提交信息
-n, --no-git 跳过 git 初始化
-f, --force 覆写目标目录可能存在的配置
Expand Down
9 changes: 1 addition & 8 deletions packages/@vue/cli/lib/util/installDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,9 @@ function renderProgressBar (curr, total) {
}

async function addRegistryToArgs (command, args, cliRegistry) {
if (command === 'yarn' && cliRegistry) {
throw new Error(
`Inline registry is not supported when using yarn. ` +
`Please run \`yarn config set registry ${cliRegistry}\` before running @vue/cli.`
)
}

const altRegistry = (
cliRegistry || (
(command === 'npm' && await shouldUseTaobao())
(await shouldUseTaobao(command))
? registries.taobao
: null
)
Expand Down
8 changes: 4 additions & 4 deletions packages/@vue/cli/lib/util/shouldUseTaobao.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function removeSlash (url) {
let checked
let result

module.exports = async function shouldUseTaobao () {
module.exports = async function shouldUseTaobao (command = 'npm') {
// ensure this only gets called once.
if (checked) return result
checked = true
Expand All @@ -34,8 +34,8 @@ module.exports = async function shouldUseTaobao () {
return val
}

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

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

0 comments on commit 78c7c12

Please sign in to comment.