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

chore: fix deprecated npm script & add check for version and unexpected files before publishing to npm #998

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

plainheart
Copy link
Collaborator

@plainheart plainheart commented Mar 11, 2023

Background

According to recent mistakes in publishing to npm, sometimes some files neither tracked by git nor ignored by the .npmignore file are unexpectedly published [1], and more often, the versions in different files are inconsistent [2][3], which is more serious than the former. Therefore, I've added a script build/prepublish.js that runs before really publishing distribution files to npm to reduce the possibility of this kind of mistake.

[1] 1.log was published to npm in Apache ECharts v5.4.0
[2] Published v5.4.2 but the version in lib/zrender.js is still 5.4.1
[3] Published v5.3.1 but both the version in lib/zrender.js and the version in src/zrender.ts are still 5.3.0

Changes

1. Replace the deprecated prepublish hook in favor of prepare & prepublishOnly.

2. Check the consistency of versions in different key distribution files.

- package.json
- package-lock.json
- dist/zrender.js
- dist/zrender.min.js
- lib/zrender.js
- src/zrender.ts

This will output the version in each file and the file path to help you confirm if they are all expected.
If the version in any file doesn't match the others, an error will be shown, and it will give the corresponding steps to fix it.

3. Check if there are unexpected files that probably shouldn't be published.

This will list all untracked files by git and check if they have been ignored by the .npmignore file.
If not, an error will be shown and output all unexpected files for double-check.

image

Copy link
Member

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

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

This offers great help! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants