-
Notifications
You must be signed in to change notification settings - Fork 29
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
afterPublish
is called before the package is effectively published
#604
Comments
There's npm hooks that could be awaited for the next release, but I think more likely an exponential backoff which checks if it's actually published will be more reliable |
Hi @francoischalifour , https://npm.community/t/newly-published-packages-have-a-delay-before-they-are-consumable/952 Indeed, there can be a gap between publish and distribution. Ship.js is made for releasing packages to NPM, but now that it provides What if afterPublish({ exec, dir, version, waitForNpmDistribution }) {
await waitForNpmDistribution();
// Update the Autocomplete.js version in the examples
const examplePath = path.resolve(dir, 'examples/autocomplete.js');
// eslint-disable-next-line no-console
console.log('Updating Autocomplete.js dependency in examples...');
exec(
`cd ${examplePath} && yarn upgrade @francoischalifour/autocomplete.js@${version}`
);
exec('git add examples');
exec('git commit -m "chore(examples): update autocomplete.js dependency"');
exec('git push origin next');
}, What do you think? |
At second thought, it makes sense to not fully rely on npm distribution as you mentioned. Having a way that is documented would be great. |
Maybe a general "waitForDistribution" could be provided by the function which actually publishes in the previous hook? |
Describe the bug
I'm trying to upgrade my package dependency after it was published with the
afterPublish
hook. However, Ship.js doesn't wait for the publication to runafterPublish
. Therefore, the npm registry isn't updated when the function is called, resulting in an upgrade error.To Reproduce
Steps to reproduce the behavior:
afterPublish
hook that relies on the npm registryafterPublish
errors because it's called before the package is effectively published to the npm registryExpected behavior
We should somehow await before calling
runAfterPublish
so that this kind ofafterPublish
scripts is made possible.Side note
It'd be nice to have access to a
version
parameter in theafterPublish
function so that we don't need to read it frompackage.json
.The text was updated successfully, but these errors were encountered: