mozilla / tab-split

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

Add npm script to build XPI? #34

Closed pdehaan closed 6 years ago

pdehaan commented 6 years ago
diff --git a/package.json b/package.json
index fed776a..9b2241b 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
   },
   "scripts": {
     "addon": "cd addon && mkdir -p ../Profile/ && jpm run -b nightly --prefs ../.jpm-prefs.json --profile ../Profile/ --no-copy --binary-args -jsconsole",
+    "build": "jpm xpi --addon-dir addon --dest-dir=. && mv null.xpi $npm_package_name-$npm_package_version.xpi",
     "lint:css": "stylelint 'addon/**/*.css'"
   }
 }

Running npm run build will now generate a file in the root directory named "tab-split-0.1.0.xpi" (so we'd want to add *.xpi to the .gitignore file probably.

Not sure why the file is being null.xpi. Maybe we need an "addon/manifest.json" file with values copied from package.json. Currently running npx addons-linter tab-split-0.1.0.xpi returns the following:

$ npx addons-linter tab-split-0.1.0.xpi

Validation Summary:

errors          0
notices         1
warnings        0

NOTICES:

Code                    Message         Description                     File   Line   Column
TYPE_NO_MANIFEST_JSON   manifest.json   No manifest.json was found at
                        was not found   the root of the extension.
                                        The package file must be a
                                        ZIP of the extension's files
                                        themselves, not of the
                                        containing directory. See:
                                        https://mzl.la/2r2McKv for
                                        more on packaging.

$ echo $? # 0
pdehaan commented 6 years ago

We can also use the same JPM --addon-dir flag to specify the addon directory during jpm run, which would save us a cd addon &&.

"addon": "jpm run --addon-dir addon -b nightly --prefs .jpm-prefs.json --profile ./Profile --no-copy --binary-args -jsconsole",

Although we'd still need to either do the mkdir -p ./Profile && to pre-create that directory [every time somebody runs npm run addon], or else just commit an empty Profile directory into the repo and add a nested .gitignore file in it, to save constantly doing a mkdir -p on a potentially already existing directory.