Open pdehaan opened 8 years ago
Here was my crappy attempt at keeping package.json's version
in sync with src/manifest.json's version
field:
const manifestPath = require.resolve("../src/manifest.json");
const packageVersion = require("../package.json").version;
const manifestJson = require(manifestPath);
const fs = require("fs");
var manifestStr;
if (packageVersion !== manifestJson.version) {
manifestJson.version = packageVersion;
manifestStr = JSON.stringify(manifestJson, null, 2) + "\n";
fs.writeFileSync(manifestPath, manifestStr, "utf-8");
}
Then we can probably trigger this bin/set-manifest-version.js file using npm pre* hooks for build_unsigned
and sign
scripts:
"scripts": {
"build_unsigned": "mkdir -p build_unsigned && web-ext build --source-dir=src --artifacts-dir=build_unsigned",
"dev": "web-ext run -s=src --pre-install",
"lint": "eslint .",
"prebuild_unsigned": "npm run set_manifest_version",
"presign": "npm run set_manifest_version",
"set_manifest_version": "node bin/set-manifest-version",
"sign": "rm ./build/* || true && (export $(cat CREDENTIALS | xargs) && web-ext sign --verbose -s=src -a=build --api-key=$JWT_ISSUER --api-secret=$JWT_SECRET) && git add *.xpi",
"test": "npm run lint"
}
This way, we'll automatically update src/manifest.json [if necessary] before making any signed/unsigned builds.
shrug
Currently it looks like we have 3 places where we store a VERSION string:
"version": "1.5.3"
"version": "1.5.3"
var VERSION = "1.5.3";
Not a huge deal, but may be easy to overlook a string when bumping versions. I don't know if there's an easier way to specify a definitive version string in one place.
It may be easiest to just keep specify the definitive version number in /package.json, then have some basic script which copies the /package.json
version
property into /src/manifest.json (we could automate that as aprebuild_unsigned
andpresign
npm script hook), and then do something likechrome.runtime.getManifest().version
in the /src/scripts/background.js to grab it from the /src/manifest.json file instead of hard coding it.http://stackoverflow.com/questions/7573191/can-i-access-a-property-from-my-manifest-json-in-my-extensions-javascript-files