Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2]: Add option to skip dependency install when initializing new Docusaurus project #3450

Closed
facultymatt opened this issue Sep 14, 2020 · 6 comments
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. hacktoberfest help wanted Asking for outside help and/or contributions to this particular issue or PR.

Comments

@facultymatt
Copy link

🚀 Feature

When initializing a new Docusaurus project, a user might wish to skip the dependency install and handle it later on their own. This would be done by passing a flag such as npx @docusaurus/init@next init [name] [template] --skip-install . This is supported in other React ecosystem libraries such as Storybook, and there is an open issue on Create React App for this feature, too: facebook/create-react-app#7568

Have you read the Contributing Guidelines on issues?

Yes

Motivation

This feature would be especially useful when installing Docusarus as one of many packages in a project and wanting to install all dependencies at one time at the end to help avoid conflicts and speed up each individual install. A Lerna project or Yarn Workspace comes to mind.

Pitch

Run npx @docusaurus/init@next init [name] [template] --skip-install and get work done faster!

@facultymatt facultymatt added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. status: needs triage This issue has not been triaged by maintainers labels Sep 14, 2020
@facultymatt
Copy link
Author

facultymatt commented Sep 14, 2020

For implementation, since Docusaurus already uses commander it would be easy to support a flag. See https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-init/bin/index.js#L39-L44. The code would look like this which uses almost the exact syntax from Storybooks which the addition of defaulting to false

program
  .command('init [siteName] [template] [rootDir]')
  .option('-s --skip-install', 'Skip installing deps', false)
  .description('Initialize website')
  .action((siteName, template, rootDir = '.', cmdObj) => {
    wrapCommand(init)(path.resolve(rootDir), siteName, template, cmdObj.skipInstall);
  });

This change would wrap the following lines in a conditional based on the flag: https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-init/src/index.ts#L154-L164

if (skipInstall === false) {
  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;
  }
  console.log();
}

NOTE this change would also require updating the docs

@slorber
Copy link
Collaborator

slorber commented Sep 29, 2020

@facultymatt I'm not against, but do you actually plan to use this feature?
I wonder if it's useful to add an option if nobody feels the need for using it right now, as it seems a particularly niche usecase and our userbase is likely smaller than CRA/Storybook. Any option that we provide and is never used is cluttering the project.

If so, as you have a good idea of how to implement it, are you interested to submit a PR?

@lex111 lex111 added good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. hacktoberfest help wanted Asking for outside help and/or contributions to this particular issue or PR. labels Sep 30, 2020
@alexnaiman
Copy link

Hello! Can I try to tackle this issue for the Hacktoberfest2020? If so, can you assign it to me?

@facultymatt
Copy link
Author

facultymatt commented Oct 11, 2020 via email

@slorber
Copy link
Collaborator

slorber commented Oct 12, 2020

Thanks, waiting for your PR @facultymatt

Still interested to know: do you actually need this feature? I'm not 100% sure to understand in which case I'd use it. Do yu often init a new docusaurus project at the same time as you bootstrap a monorepo?

@facultymatt
Copy link
Author

Thanks @kumaraditya303 for the PR. Yes @slorber we do this quite frequently - we always use Docusaurus for the landing page / docs and then create react app for the application. Testing out the new flag now. Thanks again!

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. hacktoberfest help wanted Asking for outside help and/or contributions to this particular issue or PR.
Projects
None yet
Development

No branches or pull requests

5 participants