Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate manifest.json using package.json data on build? #110

Closed
lmorchard opened this issue Jan 19, 2017 · 4 comments
Closed

Generate manifest.json using package.json data on build? #110

lmorchard opened this issue Jan 19, 2017 · 4 comments
Milestone

Comments

@lmorchard
Copy link
Collaborator

So, with SDK addons, we stick the metadata in package.json. For webext, we stick metadata in manifest.json. Stubbed my brain on this difference while working on #102 and trying to bump version numbers.

Since we have a build process, it might be handy to have manifest.json be a templated & generated artifact based on data from package.json.

@pdehaan
Copy link
Collaborator

pdehaan commented Jan 19, 2017

@lmorchard What fields in manifest.json would be variable?

  • version — definitely.
  • name — maybe, but how likely are we to rename this?
  • description — maybe?
  • author — package.json is Blake, src/manifest.json is Mozilla
  • homepage => homepage_url — maybe?

@lmorchard
Copy link
Collaborator Author

lmorchard commented Jan 19, 2017

Version's definitely variable - and tracking down errors in the auto-build process & editing the wrong file is what led me to this.

As for the rest, the data is all mostly redundant between two JSON files in two different spots. Also potentially inconsistent (e.g. author). Thinking this will all also be useful example stuff for the next Test Pilot experiment.

@pdehaan
Copy link
Collaborator

pdehaan commented Jan 19, 2017

Here's a super weak attempt (./bin/sync-manifest.js) which keeps the version in sync, but should be pretty trivial to extend to other properties:

#!/usr/bin/env node

const { writeFileSync } = require('fs');

const manifestPath = require.resolve('../src/manifest.json');

const { version } = require('../package.json');
const manifest = require(manifestPath);

const data = Object.assign(manifest, { version });

writeFileSync(manifestPath, JSON.stringify(data, null, 2) + '\n');

I imagine it may be easiest to add this to a npm prebuild script hook, so the manifest.json gets automatically updated before npm run build gets called.

@bwinton
Copy link
Owner

bwinton commented Jan 19, 2017

We would also want to run it on watch, so that I use the fancy "Load Temporary Add-on" button… 🙂
In another project, I used a gulp thing to do it, and that seemed to work out pretty well!

@ckprice ckprice added this to the Next milestone Jan 24, 2017
This was referenced Feb 14, 2017
lmorchard added a commit to lmorchard/SnoozeTabs that referenced this issue Mar 3, 2017
- bin/generate-manifest.js to create dist/manifest.json based on
  package.json

- Remove original src/manifest.json

- Move pontoon-to-webext.js into bin/

- NPM script changes to use new scripts

Fixes bwinton#110.
lmorchard added a commit to lmorchard/SnoozeTabs that referenced this issue Mar 6, 2017
- Move most properties of `src/manifest.json` to `webextensionManifest`
  in `package.json`

- `bin/generate-manifest.js` to create `dist/manifest.json` based on
  `package.json`

- Remove original src/manifest.json

- Move pontoon-to-webext.js into bin/

- NPM script changes to use new scripts

Fixes bwinton#110.
bwinton added a commit that referenced this issue Mar 6, 2017
* Add `bin/generate-manifest.js` to create `dist/manifest.json` based on `package.json`.
* Remove original `src/manifest.json`.
* Move `pontoon-to-webext.js` into `bin/`.
* NPM script changes to use new scripts.

Fixes #110.
Merge pull request #235 from lmorchard/110-generate-manifest-json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants