NPM distribution
TheSpyder opened this issue ยท 7 comments
As a JavaScript developer, I'd like to use changie but it's not available as a peer of other JavaScript tooling through NPM. JavaScript projects generally only require npm
to be installed on the system, everything else (even binary executables) are installed through NPM packages.
Transferred from #550
Where we've landed in the discussion is I will contribute some JS scripts and initial config. The bulk of this task is adding a step to release.yml
that collects the archive binaries for distribution. To keep the size of the npm package down, I'm going to exclude the 386
builds and just ship the 6 major OS/Arch combinations:
dist/changie_darwin_arm64/changie
dist/changie_darwin_amd64_v1/changie
dist/changie_linux_arm64/changie
dist/changie_linux_amd64_v1/changie
dist/changie_windows_arm64/changie.exe
dist/changie_windows_amd64_v1/changie.exe
To achieve this, I need to do a few things.
- create a script to parse
dist/artifacts.json
and collect the required binaries (the paths above cannot be relied on) - Execute this script after the
Run GoReleaser
step in the release github action - Add a
package.json
and include it to the list of replacements in.changie.yaml
config - Use the NodeJS github action to publish changie
Let me know when you are getting close and I can sign up for the NPM Token
I haven't tested it yet but I've written the code. I'll do some sample runs to check my logic tomorrow.
main...TheSpyder:changie:561-npm-publishing
I also realised my list of 6 platforms is a bit aggressive; 32-bit windows is probably far more common than ARM windows (and ARM windows has emulation built-in). I'll adjust that tomorrow as well.
The branch is ready, I have tested it about as much as I can without having it on NPM (I've run the postinstall script with forced platform settings, but it's hard to do actual testing on other platforms from source).
Do you want me to do docs before I open the PR?
hmm, if you can just give a basic overview of docs in the PR so I can add it when I rework the site that should be fine.
I've written basic docs but I just realised my approach of minimal disruption - I put everything in an npm
subfolder instead of the project root - means the package has no readme or license file. I will think about how to tweak this before opening my PR (probably tomorrow).
I decided to double-check my scripts on a windows VM, and I'm glad I did, because they didn't work quite how I intended ๐
I was over-optimising for performance by trying to have the direct binary linked, but NodeJS makes that difficult. So I've swapped to a NodeJS wrapper that then spawns the executable - slower, but far more reliable and compatible cross-platform.