From beee004619903f14dfbaf7139f0167e0a0a0ff4e Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 3 Jan 2021 14:09:04 +0530 Subject: [PATCH 1/2] fix: #3450 Signed-off-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- packages/docusaurus-init/bin/index.js | 8 ++++++-- packages/docusaurus-init/src/index.ts | 16 +++++++++------- website/docs/installation.md | 6 ++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/docusaurus-init/bin/index.js b/packages/docusaurus-init/bin/index.js index 162e209cffdb..242f4c5e7fa5 100755 --- a/packages/docusaurus-init/bin/index.js +++ b/packages/docusaurus-init/bin/index.js @@ -39,9 +39,13 @@ program program .command('init [siteName] [template] [rootDir]') .option('--use-npm') + .option('--skip-install') .description('Initialize website') - .action((siteName, template, rootDir = '.', {useNpm}) => { - wrapCommand(init)(path.resolve(rootDir), siteName, template, {useNpm}); + .action((siteName, template, rootDir = '.', {useNpm, skipInstall}) => { + wrapCommand(init)(path.resolve(rootDir), siteName, template, { + useNpm, + skipInstall, + }); }); program.arguments('').action((cmd) => { diff --git a/packages/docusaurus-init/src/index.ts b/packages/docusaurus-init/src/index.ts index f600e9e09fb1..9544054c09b8 100644 --- a/packages/docusaurus-init/src/index.ts +++ b/packages/docusaurus-init/src/index.ts @@ -43,6 +43,7 @@ export default async function init( reqTemplate?: string, cliOptions: Partial<{ useNpm: boolean; + skipInstall: boolean; }> = {}, ): Promise { const useYarn = !cliOptions.useNpm ? hasYarn() : false; @@ -155,14 +156,15 @@ export default async function init( } 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 { - shell.exec(`cd "${name}" && ${useYarn ? 'yarn' : 'npm install'}`); - } catch (err) { - console.log(chalk.red('Installation failed')); - throw err; + try { + shell.exec(`cd "${name}" && ${useYarn ? 'yarn' : 'npm install'}`); + } catch (err) { + console.log(chalk.red('Installation failed')); + throw err; + } } console.log(); diff --git a/website/docs/installation.md b/website/docs/installation.md index e62b94305082..63e5d5a14c32 100644 --- a/website/docs/installation.md +++ b/website/docs/installation.md @@ -38,6 +38,12 @@ npx @docusaurus/init@latest init my-website facebook 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 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/`: From 91fadbeb5ba8cf2024542ff9331fbf464a269ba8 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 3 Jan 2021 14:39:05 +0530 Subject: [PATCH 2/2] test: fix failing test Signed-off-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- .../src/__tests__/__fixtures__/expectedSiteConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-migrate/src/__tests__/__fixtures__/expectedSiteConfig.js b/packages/docusaurus-migrate/src/__tests__/__fixtures__/expectedSiteConfig.js index 4dce50160de7..fc61cf1a5c1e 100644 --- a/packages/docusaurus-migrate/src/__tests__/__fixtures__/expectedSiteConfig.js +++ b/packages/docusaurus-migrate/src/__tests__/__fixtures__/expectedSiteConfig.js @@ -71,7 +71,7 @@ module.exports = { items: [{label: 'Twitter', to: 'https://twitter.com/docusaurus'}], }, ], - copyright: 'Copyright © 2020 Facebook Inc.', + copyright: 'Copyright © 2021 Facebook Inc.', logo: {src: 'img/docusaurus_monochrome.svg'}, }, algolia: {