📦 Package Chrome extensions
Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
test
.gitattributes
.gitignore
.travis.yml
Gemfile
Gemfile.lock
LICENSE.md
README.md
Rakefile
extensionator.gemspec

README.md

Extensionator

Package Chrome extensions. Zip files or CRXs. Some convenience options. Use the command line or Ruby API.

Gem Version MIT License Gem Downloads Build Status Code Climate

Install

gem install extensionator

Identity

If you plan on generating a CRX (as opposed to just a zip file to upload somewhere), you need a private key to sign the extension with, and this is a BYOK (bring your own key) library. So first, you need a PEM file. If you have one, cool. If not, do this:

openssl genrsa -out identity.pem 2048

That's the file you'll use as identity.pem below.

Command line

extensionator -d directory/with/extension -i identity.pem -o output.crx

Useful options!

  • -e --exclude. Specify a regex of things to exclude. Matches on the whole path. -e "\.md$"

  • -f --format. "zip", "dir" or "crx". Zip is what the Chrome store has you upload, since it does its own signing. You won't need the -i option unless you do something weird with the other options. Dir is useful for using the inject_key option with.

  • --inject-key. If you have an extension in the store, you know you can't have a "key" property in your manifest file. But if you do local unpacked development and want to keep your extension ID the same, you need that property in there. This is because Google hates you and wants to make your life hard. Fortunately, Extensionator can take your pem file, generate the public key, and put it in the manifest file before writing the extension. Yay!

  • --strip-key. Alternatively, your workflow may make more sense leaving the key in your source file and stripping it out when you build your zip. Up to you!

  • --inject-version. Use this to override the "version" property in your manifest.

Here's the whole shebang:

-> extensionator
usage: /Users/isaac/.gem/ruby/2.2.4/bin/extensionator [options]
    -d, --directory    Directory containing the extension. (Default: .)
    -i, --identity     Location of the pem file to sign with.
    -o, --output       Location of the output file. (Default: 'output[.zip|.crx|]')
    -e, --exclude      Regular expression for filenames to exclude. (Default: .crx$)
    -f, --format       Type of file to produce, either 'zip', 'dir' or 'crx'. (Default: crx)
    --inject-version   Inject a version number into the manifest file. (Default: none)
    --inject-key       Inject a key parameter into the manifest file. (Default: no)
    --strip-key        Remove the key parameter from the manifest file. (Default: no)
    --skip-validation  Don't try to validate this extension. Currently just checks that the manifest is parsable.
    -v, --version      Extensionator version info.
    -h, --help         Print this message.

Programmatically

Create a CRX:

require "extensionator"
Extensionator.crx("directory/with/extension", "output_file.crx", identity: "identity.pem")

Or to create a zip:

Extensionator.zip("directory/with/extension", "output_file.zip")

Or a directory:

Extensionator.dir("directory/with/extension", "output_dir")

Options go at the end of any method call, and just look just like the CLI ones, but as Ruby symbols:

Extensionator.crx("dir", 
                  "output.crx",
                  identity: "identity.pem",
                  inject_version: "4.5.1",
                  strip_key: true,
                  inject_key: true,
                  exclude: /\.md$/)

License

Copyright 2015 Zensight. Distributed under the MIT License. See the LICENSE file for more details.

Phasers to stun