electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.71k stars 1.74k forks source link

Injecting version into `package.json` should start early #8678

Open cawa-93 opened 1 week ago

cawa-93 commented 1 week ago

I'm trying to inject app version on compile stage. I have a package.json with major.minor version part and compile app like so:

electron-builder build -c.extraMetadata.version=$MAJOR.$MINOR.$DYNAMICALLY_CALCULATED_PATCH

The final command may look like this:

electron-builder build --config electron-builder.mjs --publish never -c.extraMetadata.version=3.1.1731434857-vanilla-ts

But it fails with error:

Invalid version: "3.1"  failedTask=build stackTrace=Error: Invalid version: "3.1"

As I assume, version checking happens before all injections into the package.json

mmaietta commented 1 week ago

Curious, why not just set the package.json version to major.minor.0? Your c.extraMetadata.version will override it anyways later on

cawa-93 commented 1 week ago

Yeap. I can do that. But It's just not intuitive. If I inject the version, I expect it to be validated.