mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-06 06:18:38 -06:00
feat: support yarn for adding inline registry
closes #2809 Yarn supports `--registry` since v1.2.0
This commit is contained in:
@@ -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
|
||||
```
|
||||
|
||||
@@ -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 Перезаписать целевой каталог, если такой уже есть
|
||||
|
||||
@@ -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 覆写目标目录可能存在的配置
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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?`
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user