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

refactor(create): clean up logic when prompting for unspecified arguments #7374

Merged
merged 1 commit into from
May 8, 2022

Conversation

Josh-Cena
Copy link
Collaborator

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

The create-docusaurus code is super messy, and because it's highly async and imperative, it's quite hard to refactor. Therefore, this refactor probably doesn't make the code any cleaner (😅), however, it aims to make the code more correct.

We get our input from two sources: CLI args, or prompt results. What happens when part of the arguments are provided from CLI, but we are missing information and need to prompt them? (e.g. yarn create docusaurus --git-strategy shallow) This PR will standardize the behavior in this case. (Previously, we would still prompt for the template, and would even accept classic—but in this case, we should really only accept a git repo URL)

What happens when you use a local template, and the local template contains a lockfile? We should definitely use the package manager for that, instead of still using heuristics. This PR fixes that behavior.

What happens when you enter a folder name as site name, but a path already exists? Previously, the process is aborted; now, it will simply reject the input and ask you to enter another.

What happens when you cancel the current prompt? Previously it would usually give a cryptic error, now it always correctly handles this case.

Test Plan

Tested locally

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@Josh-Cena Josh-Cena added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label May 8, 2022
@Josh-Cena Josh-Cena requested review from slorber and lex111 as code owners May 8, 2022 13:02
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 8, 2022
@netlify
Copy link

netlify bot commented May 8, 2022

[V2]

Name Link
🔨 Latest commit 34503e7
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6277c8381c7a42000973afc0
😎 Deploy Preview https://deploy-preview-7374--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented May 8, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 67 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 82 🟢 99 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented May 8, 2022

Size Change: 0 B

Total Size: 811 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.3 kB
website/build/assets/css/styles.********.css 105 kB
website/build/assets/js/main.********.js 615 kB
website/build/index.html 38.8 kB

compressed-size-action

@Josh-Cena Josh-Cena force-pushed the jc/refactor-create branch from 6f3e79e to 34503e7 Compare May 8, 2022 13:40
@Josh-Cena Josh-Cena merged commit c3880cc into main May 8, 2022
@Josh-Cena Josh-Cena deleted the jc/refactor-create branch May 8, 2022 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants