BitBoxSwiss / bitbox-api-rs

BitBox02 client library for Rust and TypeScript
Apache License 2.0
5 stars 9 forks source link

Use separate versions for the Rust and NPM packages #41

Closed benma closed 8 months ago

benma commented 1 year ago

wasm-pack produces the NPM package from Rust, adopting the version from Cargo.toml.

Both libraries should have their own versions and changelogs, as it is likely that sometimes one is changed but not other. Already happened with v0.1.6 where a Rust type was made public that did not affect the NPM lib.

Idea for solution: add a NPM-VERSION file that contains the version for NPM, use jq to patch the package.json using this version using in make wasm.

asi345 commented 10 months ago

I worked on this issue and opened a pr #57

thisconnect commented 10 months ago

I wanted to ask to add "Why" in the commit message, but reading this issue I don't understand in which situations bitbox-api-rs should have a different versioning as the corresponding npm pkg. I assume you do manual npm publish? so in the example you gave about the Rust type, you could just decide to not publish it.

as it is likely that sometimes one is changed but not other.

also which changelogs?

benma commented 10 months ago

@thisconnect

Let's say both packages are at v1.0.0.

Then a Rust feature is added that does not affect NPM. Bump to v2.0.0, release Rust, do not release NPM.

Then a change comes that patches a bug in the NPM package. What now? Bump vp v2.0.1? But why did NPM get a major version bump when it only fixed a bug?

That is why the versions need to be separate - they are separate packages.

also which changelogs?

Don't have any yet, but once we start, both packages should have their own changelog, for the same reason - some changes do not affect both packages equally.

benma commented 10 months ago

@asi345 ^ maybe put something like the above into the commit msg - @thisconnect had a good point, the commit msg should always contain the reason for the change unless it is trivial :smile:

thisconnect commented 10 months ago

Then a Rust feature is added that does not affect NPM. Bump to v2.0.0, release Rust, do not release NPM.

In my understanding a bump to 2.x would mean major version with breaking changes, how come we would not release NPM 2.x at the same time?

I probably miss things, but isn't the NPM api supposed to be more or less 1:1 the api that the rust api provides?

Then a change comes that patches a bug in the NPM package.

then we would patch that in the last 1.x version, git checkout 1.x, fix commit publish new 1.x version, I dont understand why in this case we would want to push as NPM. ... but I am probably missing something.

thisconnect commented 10 months ago

So not every rust versions will be have a npm release. I think that is fine... but as a npm library user I would be confused if there was a npm version that didn't have a corresponding git tag in this repo.

Is it planned that every npm version will also have a rust version / git tag ?

asi345 commented 10 months ago

@asi345 ^ maybe put something like the above into the commit msg - @thisconnect had a good point, the commit msg should always contain the reason for the change unless it is trivial 😄

Okay, before merging I'm updating the commit message

thisconnect commented 10 months ago

thank you ❤️

benma commented 10 months ago

In my understanding a bump to 2.x would mean major version with breaking changes, how come we would not release NPM 2.x at the same time?

because in that scenario that breaking change would only be in Rust, not NPM.

it is similar in patch verions:

say both are at 0.1.0. Then a patch is done to Rust, e.g. export a type. bump to 0.1.1, make a tag, release Rust. Then patch a typo in a Javascript, like recently here. Then NPM goes to 0.1.2? But where is 0.1.1, it is skipped.

Any combination of major minor and patch version mismatches between the two can happen.

benma commented 10 months ago

... but as a npm library user I would be confused if there was a npm version that didn't have a corresponding git tag in this repo.

Is it planned that every npm version will also have a rust version / git tag ?

Yeah, the tags will become separate too. Think of the two packages as totally unrelated except that they happen to live in the same repo. Maybe it would be smart to split it into two repos somehow :thinking:

thisconnect commented 10 months ago

Think of the two packages as totally unrelated except that they happen to live in the same repo

Unrelated except that the NPM/TS/wasm is generated from the Rust one.. I think we should try with independent changelog/versions and see how it goes and decide later if it should be split.. or is there a reason to split already now?

benma commented 10 months ago

Unrelated except that the NPM/TS/wasm is generated from the Rust one

Fyi, the NPM package uses the Rust lib as kind of an internal library and manually exposes a TypeScript API. It is not fully automatic.

I am fine with keeping them in one repo but separate versions/tags/changelogs for the time being. Different repos would make the distinction quite clear however :shrug: maybe in the future

benma commented 8 months ago

Solved by https://github.com/digitalbitbox/bitbox-api-rs/pull/57.