fix: install deps for new project via Yarn properly (#5490)

This commit is contained in:
Alexey Pyltsyn 2021-09-22 11:13:01 +03:00 committed by GitHub
parent 29e06d0677
commit ebf81b6ef6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

4
packages/docusaurus-init/package.json Normal file → Executable file
View file

@ -29,9 +29,13 @@
"prompts": "^2.4.1", "prompts": "^2.4.1",
"semver": "^7.3.4", "semver": "^7.3.4",
"shelljs": "^0.8.4", "shelljs": "^0.8.4",
"supports-color": "^8.1.1",
"tslib": "^2.2.0" "tslib": "^2.2.0"
}, },
"engines": { "engines": {
"node": ">=12.13.0" "node": ">=12.13.0"
},
"devDependencies": {
"@types/supports-color": "^8.1.1"
} }
} }

13
packages/docusaurus-init/src/index.ts Normal file → Executable file
View file

@ -12,6 +12,7 @@ import prompts, {Choice} from 'prompts';
import path from 'path'; import path from 'path';
import shell from 'shelljs'; import shell from 'shelljs';
import {kebabCase, sortBy} from 'lodash'; import {kebabCase, sortBy} from 'lodash';
import supportsColor from 'supports-color';
const RecommendedTemplate = 'classic'; const RecommendedTemplate = 'classic';
const TypeScriptTemplateSuffix = '-typescript'; const TypeScriptTemplateSuffix = '-typescript';
@ -239,11 +240,15 @@ ${chalk.cyan('Creating new Docusaurus project...')}
console.log(`Installing dependencies with ${chalk.cyan(pkgManager)}...`); console.log(`Installing dependencies with ${chalk.cyan(pkgManager)}...`);
try { try {
// Use force coloring the output, since the command is invoked by shelljs, which is not the interactive shell
shell.exec( shell.exec(
`cd "${name}" && ${ `cd "${name}" && ${useYarn ? 'yarn' : 'npm install --color always'}`,
// Force coloring the output, because the command is invoked by shelljs, not in the interative shell {
useYarn ? 'FORCE_COLOR=true yarn' : 'npm install --color always' env: {
}`, ...process.env,
...(supportsColor.stdout ? {FORCE_COLOR: '1'} : {}),
},
},
); );
} catch (err) { } catch (err) {
console.log(chalk.red('Installation failed.')); console.log(chalk.red('Installation failed.'));

View file

@ -4486,6 +4486,11 @@
resolved "https://registry.yarnpkg.com/@types/stringify-object/-/stringify-object-3.3.1.tgz#9ee394931e63468de0412a8e19c9f021a7d1d24d" resolved "https://registry.yarnpkg.com/@types/stringify-object/-/stringify-object-3.3.1.tgz#9ee394931e63468de0412a8e19c9f021a7d1d24d"
integrity sha512-bpCBW0O+QrMLNFBY/+rkZtGzcYRmc2aTD8qYHOMNUmednqETfEZtFcGEA11l9xqbIeiT1PgXG0eq3zqayVzZSQ== integrity sha512-bpCBW0O+QrMLNFBY/+rkZtGzcYRmc2aTD8qYHOMNUmednqETfEZtFcGEA11l9xqbIeiT1PgXG0eq3zqayVzZSQ==
"@types/supports-color@^8.1.1":
version "8.1.1"
resolved "https://registry.yarnpkg.com/@types/supports-color/-/supports-color-8.1.1.tgz#1b44b1b096479273adf7f93c75fc4ecc40a61ee4"
integrity sha512-dPWnWsf+kzIG140B8z2w3fr5D03TLWbOAFQl45xUpI3vcizeXriNR5VYkWZ+WTMsUHqZ9Xlt3hrxGNANFyNQfw==
"@types/tapable@^1": "@types/tapable@^1":
version "1.0.7" version "1.0.7"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.7.tgz#545158342f949e8fd3bfd813224971ecddc3fac4" resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.7.tgz#545158342f949e8fd3bfd813224971ecddc3fac4"
@ -18787,7 +18792,7 @@ supports-color@^7.0.0, supports-color@^7.1.0:
dependencies: dependencies:
has-flag "^4.0.0" has-flag "^4.0.0"
supports-color@^8.0.0: supports-color@^8.0.0, supports-color@^8.1.1:
version "8.1.1" version "8.1.1"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==