diff --git a/packages/create-turbo/src/index.ts b/packages/create-turbo/src/index.ts index 805876713c577..b36e88bd9620c 100644 --- a/packages/create-turbo/src/index.ts +++ b/packages/create-turbo/src/index.ts @@ -2,7 +2,6 @@ import * as path from "path"; import execa from "execa"; -import fs from "fs"; import fse from "fs-extra"; import inquirer from "inquirer"; import ora from "ora"; @@ -29,7 +28,7 @@ const help = ` If is not provided up front you will be prompted for it. - Flags: + Flags: --use-npm Explicitly tell the CLI to bootstrap the app using npm --use-pnpm Explicitly tell the CLI to bootstrap the app using pnpm --no-install Explicitly do not run the package manager's install command @@ -209,10 +208,18 @@ async function run() { }, }).start(); - await execa(`${answers.packageManager}`, [`install`], { - stdio: "ignore", - cwd: projectDir, - }); + // Using the official npm registry in the installation could be very slow, + // So we use the user customized registry from default instead. + const npmRegistry = await getNpmRegistry(answers.packageManager); + + await execa( + `${answers.packageManager}`, + [`install`, `--registry=${npmRegistry}`], + { + stdio: "ignore", + cwd: projectDir, + } + ); spinner.stop(); } else { console.log(); @@ -278,6 +285,20 @@ async function run() { console.log(); } +async function getNpmRegistry(pkgManager: PackageManager): Promise { + try { + // npm/pnpm/yarn share the same CLI configuration commands + const { stdout: registry } = await execa(pkgManager, [ + "config", + "get", + "registry", + ]); + return registry; + } catch (error) { + return ""; + } +} + const update = checkForUpdate(cliPkgJson).catch(() => null); async function notifyUpdate(): Promise {