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(testing): allow custom address for local registry #29050

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

tinesoft
Copy link
Contributor

@tinesoft tinesoft commented Nov 23, 2024

… output

Current Behavior

The startLocalRegistry() always assumed that the local registry was started on localhost , which is not necessary the case, if for example user has set the listenAddress option in the underlying verdaccio executor or via the verdaccio config file

const listenAddress = options.listenAddress

As a result the startLocalregistry(), will never return as, it is waiting forever to detect the local registry URL in the process output:

if (data.toString().includes('http://localhost:')) {

This customization of verdaccio listen address is something required, namely when running within a devcontainer. In that case, the address must be set to 0.0.0.0, so that the registry can be accessed from http://localhost:4873 from host machine.

Expected Behavior

Allow customizing the listenAddress when starting the local registry, via an additional option that can be provided when calling the method. It default value will be localhost.

Related Issue(s)

Fixes #28238

@tinesoft tinesoft requested a review from a team as a code owner November 23, 2024 17:03
Copy link

vercel bot commented Nov 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Dec 4, 2024 1:32pm

@tinesoft tinesoft force-pushed the fix/jest-start-verdaccio branch from 55f9619 to 19338bc Compare November 24, 2024 07:46
tinesoft added a commit to tinesoft/nxrocks that referenced this pull request Nov 24, 2024
tinesoft added a commit to tinesoft/nxrocks that referenced this pull request Nov 27, 2024
… starting the local registry

Until nrwl/nx#29050 is merged and released
tinesoft added a commit to tinesoft/nxrocks that referenced this pull request Dec 2, 2024
… starting the local registry

Until nrwl/nx#29050 is merged and released
@xiongemi xiongemi changed the title feat(testing): improve local registry script… feat(js): allow custom listenAddress Dec 2, 2024
@xiongemi xiongemi changed the title feat(js): allow custom listenAddress feat(testing): allow custom listenAddress Dec 2, 2024
@xiongemi xiongemi force-pushed the fix/jest-start-verdaccio branch from ba68fa5 to d94bc90 Compare December 2, 2024 21:04
@xiongemi xiongemi changed the title feat(testing): allow custom listenAddress feat(testing): allow custom address used to start the local registry Dec 2, 2024
@xiongemi xiongemi force-pushed the fix/jest-start-verdaccio branch from d94bc90 to 547dc7f Compare December 2, 2024 21:37
@xiongemi xiongemi changed the title feat(testing): allow custom address used to start the local registry feat(testing): allow custom address for local registry Dec 2, 2024
@tinesoft tinesoft force-pushed the fix/jest-start-verdaccio branch 3 times, most recently from 914f980 to 4b76394 Compare December 3, 2024 15:54
tinesoft added a commit to tinesoft/nxrocks that referenced this pull request Dec 4, 2024
… starting the local registry

Until nrwl/nx#29050 is merged and released
@tinesoft tinesoft force-pushed the fix/jest-start-verdaccio branch from 4b76394 to c5d6bc2 Compare December 4, 2024 13:29
@jaysoo jaysoo merged commit cfb67cf into nrwl:master Dec 10, 2024
6 checks passed
FrozenPandaz pushed a commit that referenced this pull request Dec 10, 2024
… output<!-- Please make sure you have read the submission guidelines
before posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
The `startLocalRegistry()` always assumed that the local registry was
started on `localhost` , which is not necessary the case, if for example
user has set the `listenAddress` option in the underlying `verdaccio
executor` or via the `verdaccio config
file`https://github.com/nrwl/nx/blob/128778e7d1a8d7f2b078b2401d47270c0c15a2ce/packages/js/src/executors/verdaccio/verdaccio.impl.ts#L130

As a result the `startLocalregistry()`, will never return as, it is
waiting forever to detect the local registry URL in the process output:
https://github.com/nrwl/nx/blob/128778e7d1a8d7f2b078b2401d47270c0c15a2ce/packages/js/src/plugins/jest/start-local-registry.ts#L40

This customization of `verdaccio` listen address is something required,
namely when running within a **devcontainer**. In that case, the address
must be set to `0.0.0.0`, so that the registry can be accessed from
`http://localhost:4873` from host machine.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Allow customizing the `listenAddress` when starting the local registry,
via an additional option that can be provided when calling the method.
It default value will be `localhost`.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28238

(cherry picked from commit cfb67cf)
@tinesoft tinesoft deleted the fix/jest-start-verdaccio branch December 11, 2024 11:49
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot set up a local registry if NX project is opened in a devcontainer ( Docker Desktop )
3 participants