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

feat(v2): prompt user when default port is in use #3006

Merged
merged 5 commits into from
Jun 30, 2020
Merged

feat(v2): prompt user when default port is in use #3006

merged 5 commits into from
Jun 30, 2020

Conversation

taylorallen0913
Copy link
Contributor

Motivation

This PR implements what was proposed in #3005.

When a user already has a process running on the default docusaurus port, docusaurus finds the next open port and runs the client on it. Based on a simular implementation in create-react-app, this feature warns the user if something is already running on the default port, and asks them if they want to run the client on a different port.

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

Run a program on port 3000 (I ran create-react-app)

yarn start

When you try to run yarn start with another app already running on the Docusaurus default port:

docusaurus

When you select "Yes":

docusaurus2

When you select "No":

docusaurus3

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 27, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jun 27, 2020

Deploy preview for docusaurus-2 ready!

Built with commit dbf356c

https://deploy-preview-3006--docusaurus-2.netlify.app

}

// Gets package name in a directory
async function getPackageNameInDirectory(
Copy link
Collaborator

@slorber slorber Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to export it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying to remove the export default function getProcessForPort ? I am using the function in another file.

@slorber slorber linked an issue Jun 29, 2020 that may be closed by this pull request
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,

Seems to work as intended:

image

Someone on Windows could test this?

@slorber
Copy link
Collaborator

slorber commented Jun 29, 2020

@yangshun I guess it's not a problem to copy facebook code from one project to another right?

This is heavily inspired from current CRA code: https://github.com/facebook/create-react-app/blob/f5c3bdb65480f93b2d4a4c2f3214fc50753de434/packages/react-dev-utils/WebpackDevServerUtils.js#L448

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

portfinder should be removed + I think we should document it's code inspired from CRA + isolate it better in a single place. Probably does not belong to webpack utils, it's not really webpack related.

packages/docusaurus/src/commands/start.ts Show resolved Hide resolved
packages/docusaurus/src/webpack/getProcessForPort.ts Outdated Show resolved Hide resolved
packages/docusaurus/src/webpack/utils.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems nice, thanks

@slorber slorber merged commit 998e4d5 into facebook:master Jun 30, 2020
@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Jun 30, 2020
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: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v2] Prompt user when port is already being used
4 participants