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(ngx-deploy-npm): add version check to prevent duplicate publishes #667

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Romain7495
Copy link

@Romain7495 Romain7495 commented Dec 6, 2024

fixes: #666
fixes: #508

This commit adds a new optional flag checkExisting that allows users to verify if a package version already exists in the registry before publishing. When enabled, it will:

  • Check the package.json for name and version
  • Query npm registry for existing versions
  • Skip publishing if version already exists
  • Default to false to maintain backward compatibility and avoid regression
  • Add test
  • Add documentation

This helps prevent accidental republishing package and having issue (403) when trying to republish a version that is already pushed (on gitlab for example)

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)

What is the current behavior?

Issue Number: #666

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@Romain7495
Copy link
Author

Hi @dianjuar, thanks for the suggestions. I replaced the readFileSync and removed the beforeEach

Copy link
Member

@dianjuar dianjuar left a comment

Choose a reason for hiding this comment

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

@Romain7495 Thank you so much for taking the initiative to implement this feature.

It has an excellent foundation for the feature. Thank you so much for that.

Some concerns exist about the implementation and the flexibility to adapt to other workflow necessities. I started a discussion on issue #666.

@Romain7495
Copy link
Author

@dianjuar agree, I have updated the type of checkExisting and unit test, It works as welll on our nx monorepo with yarn link

@Romain7495 Romain7495 force-pushed the main branch 2 times, most recently from d52e512 to 56f81eb Compare December 9, 2024 23:24
@Romain7495
Copy link
Author

hello @dianjuar, do you think we can merge this ? do you need something else ? Do you need help to fix the sonarcloud pipeline issue (SONAR_TOKEN missing ? )

Copy link
Member

@dianjuar dianjuar left a comment

Choose a reason for hiding this comment

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

I have more suggestions about the unit test.
Thanks for your patience in waiting for my feedback.

I use this time Conventional Comments to express my feedback in a more effective way.

@dianjuar
Copy link
Member

@Romain7495 regarding that "failing" check on the CI. Don't mind it.

I'll try to fix it in the next couple of hours.

It has been a problem since its implementation. It's failing for contributors, but it works fine for repo members.

Ideally, it would trigger a static code analysis of your contribution to detect unit test coverage, code smells, and security vulnerabilities.

If I can't find a fix, I would integrate it with it failing.

@Romain7495 Romain7495 force-pushed the main branch 4 times, most recently from cc6cfe3 to e538aa1 Compare December 12, 2024 11:13
@Romain7495
Copy link
Author

@dianjuar Thanks for all the feedback! First time doing Jest tests, so I really appreciate the tips. Pretty sure I got all your suggestions covered in my latest changes 😊

@dianjuar
Copy link
Member

dianjuar commented Dec 13, 2024

@Romain7495
To give visibility on what's on my end to integrate this PR:

  • Fix some nitpicks
  • Integrate ci: fix publishment commit push #658 (this will fix a current publishment issue on the CI)
  • Update this PR
  • (optional but highly desired) Add a couple of e2e tests to verify everything is working as expected
    • The user base of this package is quite large, so it is important to ensure everything is functioning correctly to avoid introducing unintended behaviors.
  • (optional) Fix Sonar
  • Integrate
  • Deploy 🚀

renovate bot and others added 3 commits December 14, 2024 13:57
This commit adds a new optional flag `checkExisting` that allows users to
verify if a package version already exists in the registry before publishing.
When enabled, it will:
- Check the package.json for name and version
- Query npm registry for existing versions
- Skip publishing if version already exists
- Default to false to maintain backward compatibility and avoid
  regression
- Add test
- Add documentation

This helps prevent accidental republishing package and having issue (403)
when trying to republish a version that is already pushed (on gitlab
for example)

Signed-off-by: Romain LABAT <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants