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

[ENHANCEMENT] automatically select a port by default with ember serve #10394

Merged
merged 1 commit into from
Nov 1, 2023
Merged

Conversation

sportshead
Copy link
Contributor

Fixes #9512

ember serve will now automatically choose a port (starting with 4200), unless a port is explicitly set with the --port flag or the $PORT env variable.

Notes:

The base port has also been changed from 7020 (which seems to have been arbitrarily chosen in 43878e2) to 4200, the current default. The old value of 7020 also doesn't seem to do anything since it's overridden by the default 4200 anyways.

The should throw error when -p PORT is taken test block has been moved out of a legacy if statement referencing appveyor.

@sportshead sportshead changed the title feat: automatically select a port by default with ember serve [ENHANCEMENT] automatically select a port by default with ember serve Oct 27, 2023
return command.validateAndRun().then(function () {
let captor = td.matchers.captor();
td.verify(tasks.Serve.prototype.run(captor.capture()), {times: 1});
expect(captor.value.port).to.be.within(4201, 65535, 'has correct port');
Copy link
Contributor

Choose a reason for hiding this comment

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

oo nice!

Copy link
Contributor

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

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

Thanks a ton for working on this! this is a massive DX win!

@sportshead
Copy link
Contributor Author

I'll also make a patch to fix the test and lint errors

@sportshead sportshead marked this pull request as draft October 27, 2023 15:13
@sportshead sportshead marked this pull request as ready for review October 27, 2023 15:42
@NullVoxPopuli
Copy link
Contributor

@sportshead this is looking good -- can you get the tests passing? <3

@sportshead
Copy link
Contributor Author

@NullVoxPopuli - all the failed tests are referring to ember help, I'll try to rebase and see if that helps.

@NullVoxPopuli
Copy link
Contributor

the help output shows the description for the flags, so since the -p description changed, the help text change -- it's a type of snapshot test, if that makes sense

Fixes #9512

The base port has also been changed from 7020 (which seems to have been arbitrarily chosen in 43878e2) to 4200, the current default.
The old value of 7020 also doesn't seem to do anything since it's overridden by the default 4200 anyways.

The `should throw error when -p PORT is taken` test block has been moved out of a legacy if statement referencing appveyor.

Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
@sportshead
Copy link
Contributor Author

@NullVoxPopuli ah, that makes sense. I've updated the PR with the new changes for the help tests.

@NullVoxPopuli NullVoxPopuli merged commit 0e983a4 into ember-cli:master Nov 1, 2023
11 checks passed
sportshead added a commit to sportshead/cli-guides that referenced this pull request Nov 1, 2023
See ember-cli/ember-cli#10394

Also fixed some of the line wrapping in other parts of the `ember serve` help text
@amk221 amk221 mentioned this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thoughts on automatically selecting a new port if there is a port conflict?
2 participants