nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.52k stars 2.34k forks source link

Restore previous NPM Registry value upon receipt of SIGINT in `local-registry` process #18921

Closed TheHaymaker closed 5 months ago

TheHaymaker commented 1 year ago

Description

By default, running the verdaccio-setup reaches in over-writes my registry in my .npmrc.

I had the impression that my old .npmrc registry value would be restored if I killed/interrupted the local-registry process -- but that isn't the case.

I wanted to propose that the original registry value -- if set -- is saved somewhere. My .npmrc registry value is updated to the verdaccio target when I spin up the local-registry command.

And upon SIGINT, SIGTERM, etc of the local-registry process (e.g. when I close it down via ctrl + c), I perform a clean up / restoration operation on my .npmrc.

I am raising this because I explicity set a custom NPM registry (inside an enterprise network). Without some clean up / restoration here, that original registry value is blown away and NPM ceases to function in a normative (or functional) way unless my proxy npm server is running.

Motivation

The proposed behavior matches my initial mental model of the verdaccio-setup and local-registry demo. Having some sort of clean up / restoration feature also reinforces good DX here (as this operation becomes a lot less destructive with a side effect that is not necessarily obvious).

Suggested Implementation

I wanted to propose that the original registry value -- if set -- is saved somewhere. My .npmrc registry value is updated to the verdaccio target when I spin up the local-registry command.

And upon SIGINT, SIGTERM, etc of the local-registry process (e.g. when I close it down via ctrl + c), I perform a clean up / restoration operation on my .npmrc.

There are projects like DEATH.js that provide a clean, cross-OS way to listen for SIGINT.

Alternate Implementations

github-actions[bot] commented 7 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

TheHaymaker commented 7 months ago

Just checking in.

Would the maintainers like me to raise a PR with the proposed fix?

AgentEnder commented 7 months ago

Hey, yeah a PR would be appreciated

AgentEnder commented 5 months ago

I can't reproduce this issue, on both windows and wsl I am seeing the registry get reset upon ctrl+c. If you can still reproduce the issue, feel free to ping me and we can investigate further.

github-actions[bot] commented 4 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.