pulsar-edit / ppm

Pulsar Package Manager
MIT License
35 stars 13 forks source link

Support the `prepublishOnly` hook #89

Open savetheclocktower opened 1 year ago

savetheclocktower commented 1 year ago

Have you checked for existing feature requests?

Summary

I wrote a TypeScript package as a way of dogfooding the IDE experience with my pulsar-ide-typescript-alpha package. By and large it's a smooth process, but the hardest part has been automatically transpiling to JavaScript before publish.

My understanding is that most NPM packages that are written in TypeScript use the prepublishOnly script hook for this task. prepublishOnly is called after the user runs npm publish, but before anything else happens.

Inspecting the artifacts of other high-profile Atom packages that were written in TypeScript implies that this might’ve worked for ppm at some point in the past, but I can’t imagine how that would be true.

My goal for my own project is (a) never to have to care about built files until publish time, and (b) never to run the risk of forgetting to transpile (and commit the transpilation) before publishing.

This is not a major priority, but I think it’s worth visiting at some point.

What benefits does this feature provide?

Feature parity with npm. Makes it much easier to do something that might be a common need for new package contributors.

Any alternatives?

I can't think of a good alternative to this. In my case, I've managed to build a system out of duct tape and twine that forces me to build code before I run ppm publish patch, but that's not a proper solution.

Other examples:

No response

confused-Techie commented 1 year ago

Since PPM, from my understanding, defers handling of scripts like this to NPM, we should support whatever is supported by version 8 on NPM. Which hasn't been bumped by us. We only bumped node-gyp within NPM, so I'd imagine it's supported. But we can always look at the source of our npm-cli to determine exactly what's supported.

And if anything is missing, hopefully cherry pick the commits adding them to upstream, to use the feature while keeping to NPM API of NPM 8

confused-Techie commented 1 year ago

Looking into this, we do not currently support the prepublishOnly hook, as well as we actually do not support a huge number of other hooks.

I only now realize how many of them were created after NPM 8. So I would really like to try and take some time to update our version of NPM to be something a bit more up to date, but we would have to do it totally custom, in order to keep the API functionality needed. So I have a feeling this may turn into a much larger project.

So it may be worth it for us to create an issue over there, and try to see what we can do to support some modern hooks and features.

savetheclocktower commented 1 year ago

It's odd because prepublishOnly was supposedly added to npm in version 4, and ppm --version insists that it's using npm version 6.14.18.