diff --git a/docs/guide/creating-a-project.md b/docs/guide/creating-a-project.md index caf528989..2e0368d20 100644 --- a/docs/guide/creating-a-project.md +++ b/docs/guide/creating-a-project.md @@ -46,12 +46,12 @@ Options: -d, --default Skip prompts and use default preset -i, --inlinePreset Skip prompts and use inline JSON string as preset -m, --packageManager Use specified npm client when installing dependencies - -r, --registry Use specified npm registry when installing dependencies (only for npm) + -r, --registry 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 ``` diff --git a/docs/ru/guide/creating-a-project.md b/docs/ru/guide/creating-a-project.md index 15f1394fe..fe75cfc88 100644 --- a/docs/ru/guide/creating-a-project.md +++ b/docs/ru/guide/creating-a-project.md @@ -46,7 +46,7 @@ vue create --help -d, --default Пропустить подсказки и использовать пресет настроек по умолчанию -i, --inlinePreset Пропустить подсказки и использовать вставленную строку JSON в качестве пресета настроек -m, --packageManager Использовать указанный npm клиент при установке зависимостей - -r, --registry Использовать указанный npm регистр при установке зависимостей (только для npm) + -r, --registry Использовать указанный npm регистр при установке зависимостей -g, --git [message|false] Форсировать / пропустить инициализацию git, опционально указать сообщение к первому коммиту -n, --no-git Пропустить инициализацию git -f, --force Перезаписать целевой каталог, если такой уже есть diff --git a/docs/zh/guide/creating-a-project.md b/docs/zh/guide/creating-a-project.md index d1be073a2..2570690cd 100644 --- a/docs/zh/guide/creating-a-project.md +++ b/docs/zh/guide/creating-a-project.md @@ -46,7 +46,7 @@ vue create --help -d, --default 忽略提示符并使用默认预设选项 -i, --inlinePreset 忽略提示符并使用内联的 JSON 字符串预设选项 -m, --packageManager 在安装依赖时使用指定的 npm 客户端 - -r, --registry 在安装依赖时使用指定的 npm registry (仅用于 npm 客户端) + -r, --registry 在安装依赖时使用指定的 npm registry -g, --git [message] 强制 / 跳过 git 初始化,并可选的指定初始化提交信息 -n, --no-git 跳过 git 初始化 -f, --force 覆写目标目录可能存在的配置 diff --git a/packages/@vue/cli/lib/util/installDeps.js b/packages/@vue/cli/lib/util/installDeps.js index 1d81396fe..63cc2995d 100644 --- a/packages/@vue/cli/lib/util/installDeps.js +++ b/packages/@vue/cli/lib/util/installDeps.js @@ -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 ) diff --git a/packages/@vue/cli/lib/util/shouldUseTaobao.js b/packages/@vue/cli/lib/util/shouldUseTaobao.js index 893538f1a..1bee59aee 100644 --- a/packages/@vue/cli/lib/util/shouldUseTaobao.js +++ b/packages/@vue/cli/lib/util/shouldUseTaobao.js @@ -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?` ) }