mozilla / tab-split

A magical place for tabs and tabs
https://testpilot.firefox.com
Mozilla Public License 2.0
4 stars 6 forks source link

Generate install.rdf from template from package.json values? #37

Open pdehaan opened 6 years ago

pdehaan commented 6 years ago

We've used it on different projects for keeping package.json and the install.rdf in sync, and it worked fairly well.

I think we'd just need a ./install.rdf.mustache template with something like this:

<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  <Description about="urn:mozilla:install-manifest">
    <em:id>moztabsplit@mozilla.org</em:id>
    <em:name>Firefox Tab Split</em:name>
    <em:description>{{description}}</em:description>
    <em:targetApplication>
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!--Firefox-->
        <em:minVersion>57.0a1</em:minVersion>
        <em:maxVersion>*</em:maxVersion>
      </Description>
    </em:targetApplication>
    <em:type>2</em:type>
    <em:version>{{version}}</em:version>
    <em:bootstrap>true</em:bootstrap>
    <em:multiprocessCompatible>true</em:multiprocessCompatible>
  </Description>
</RDF>

And then build the ./addon/install.rdf using something like this in package.json:

"build": "mustache package.json install.rdf.mustache > addon/install.rdf"
pdehaan commented 6 years ago

Actually, now that we're a web-ext, values may be in 3 places, although I'm not clear if they need to be in sync:

https://github.com/mozilla/tab-split/blob/e6bed5a61ed3a49b2b076130b4ea37fcbdb2cecc/package.json#L2-L4

https://github.com/mozilla/tab-split/blob/e6bed5a61ed3a49b2b076130b4ea37fcbdb2cecc/webext/manifest.json#L3-L5

https://github.com/mozilla/tab-split/blob/e6bed5a61ed3a49b2b076130b4ea37fcbdb2cecc/experiment/install.rdf#L5-L11

fzzzy commented 6 years ago

Yes, let's automate setting the version number in those three places in some sort of build step.

pdehaan commented 6 years ago

I don't know how you set package.json versions currently, but if you're using npm version, we could probably just write some postversion npm script which will automatically update the version in /webext/manifest.json, and /experiment/install.rdf with the value from /package.json.

I guess even if you aren't bumping the major|minor|patch versions using the npm version CLI, you could manually run npm run postversion after you've hand crafted the package.json version number to update it in the other places.