mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 14:06:59 +02:00
feat(v2): skip dependency install on docusaurus init (#3986)
* fix: #3450 Signed-off-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> * test: fix failing test Signed-off-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
869e118e4f
commit
0bb5e547b1
4 changed files with 22 additions and 10 deletions
|
@ -39,9 +39,13 @@ program
|
||||||
program
|
program
|
||||||
.command('init [siteName] [template] [rootDir]')
|
.command('init [siteName] [template] [rootDir]')
|
||||||
.option('--use-npm')
|
.option('--use-npm')
|
||||||
|
.option('--skip-install')
|
||||||
.description('Initialize website')
|
.description('Initialize website')
|
||||||
.action((siteName, template, rootDir = '.', {useNpm}) => {
|
.action((siteName, template, rootDir = '.', {useNpm, skipInstall}) => {
|
||||||
wrapCommand(init)(path.resolve(rootDir), siteName, template, {useNpm});
|
wrapCommand(init)(path.resolve(rootDir), siteName, template, {
|
||||||
|
useNpm,
|
||||||
|
skipInstall,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
program.arguments('<command>').action((cmd) => {
|
program.arguments('<command>').action((cmd) => {
|
||||||
|
|
|
@ -43,6 +43,7 @@ export default async function init(
|
||||||
reqTemplate?: string,
|
reqTemplate?: string,
|
||||||
cliOptions: Partial<{
|
cliOptions: Partial<{
|
||||||
useNpm: boolean;
|
useNpm: boolean;
|
||||||
|
skipInstall: boolean;
|
||||||
}> = {},
|
}> = {},
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const useYarn = !cliOptions.useNpm ? hasYarn() : false;
|
const useYarn = !cliOptions.useNpm ? hasYarn() : false;
|
||||||
|
@ -155,7 +156,7 @@ export default async function init(
|
||||||
}
|
}
|
||||||
|
|
||||||
const pkgManager = useYarn ? 'yarn' : 'npm';
|
const pkgManager = useYarn ? 'yarn' : 'npm';
|
||||||
|
if (!cliOptions.skipInstall) {
|
||||||
console.log(`Installing dependencies with: ${chalk.cyan(pkgManager)}`);
|
console.log(`Installing dependencies with: ${chalk.cyan(pkgManager)}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -164,6 +165,7 @@ export default async function init(
|
||||||
console.log(chalk.red('Installation failed'));
|
console.log(chalk.red('Installation failed'));
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
console.log();
|
console.log();
|
||||||
|
|
||||||
// Display the most elegant way to cd.
|
// Display the most elegant way to cd.
|
||||||
|
|
|
@ -71,7 +71,7 @@ module.exports = {
|
||||||
items: [{label: 'Twitter', to: 'https://twitter.com/docusaurus'}],
|
items: [{label: 'Twitter', to: 'https://twitter.com/docusaurus'}],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
copyright: 'Copyright © 2020 Facebook Inc.',
|
copyright: 'Copyright © 2021 Facebook Inc.',
|
||||||
logo: {src: 'img/docusaurus_monochrome.svg'},
|
logo: {src: 'img/docusaurus_monochrome.svg'},
|
||||||
},
|
},
|
||||||
algolia: {
|
algolia: {
|
||||||
|
|
|
@ -38,6 +38,12 @@ npx @docusaurus/init@latest init my-website facebook
|
||||||
npx @docusaurus/init@latest init my-website bootstrap
|
npx @docusaurus/init@latest init my-website bootstrap
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to skip installing dependencies, use the `--skip-install` option, like the following:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @docusaurus/init@latest init my-website classic --skip-install
|
||||||
|
```
|
||||||
|
|
||||||
## Project structure
|
## Project structure
|
||||||
|
|
||||||
Assuming you chose the classic template and named your site `my-website`, you will see the following files generated under a new directory `my-website/`:
|
Assuming you chose the classic template and named your site `my-website`, you will see the following files generated under a new directory `my-website/`:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue