Coder Social home page Coder Social logo

joscha / grunt-crx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thom4parisot/grunt-crx

0.0 2.0 0.0 206 KB

Grunt task used to package private Chrome Extensions.

Home Page: https://npmjs.org/package/grunt-crx

License: MIT License

JavaScript 100.00%

grunt-crx's Introduction

grunt-crx

Build Status Dependencies Status Dev Dependencies Status

grunt-crx is a Grunt task used to package private Chrome Extensions.

In the future, this task will also help you to also package Packaged Apps, Hosted Apps, and public Chrome Extensions to publish on the Chrome Web Store.

Getting Started

Install this grunt plugin next to your project's Gruntfile.js with the following command:

npm install --save-dev grunt-crx

Then add this line to your project's Gruntfile.js:

grunt.loadNpmTasks('grunt-crx');

Dependencies

  • openssl - Used to sign your Chrome extensions
  • ssh-keygen - Used to generate new signatures
    • Linux and OS X: Should already exist
    • Windows: Comes with git, if you have <git install location>/bin in your PATH you should be set

Documentation

This task is a multi task, meaning that grunt will automatically iterate over all crx targets if a target is not specified.

There will be as many extension packaged as there are targets.

Target Properties

  • src (string, mandatory): location of a folder containing a Chrome Extension manifest.json;
  • dest (string, mandatory): location of a folder where the crx file will be available;
  • baseURL (string): folder URL where package files will be self hosted (see Autoupdating in Chrome Extension docs);
  • exclude (array): array of glob style src-relative paths which won't be included in the built package;
  • privateKey (string): location of the .pem file used to encrypt your extension;
  • options (object) – options that are directly provided to the ChromeExtension object;
  • maxBuffer (Number): amount of bytes available to package the extension (see child_process#exec)

Target Defaults

  • privateKey: key.pem — which means the task will look forward its file next to the grunt.js one;
  • filename: <%= pkg.name %>-<%= manifest.version %>.crx – which means it will automagically use your package.json name and manifest.json version to build the filename.

Configuration Examples

//Gruntfile.js
grunt.loadNpmTasks('grunt-crx');

grunt.initConfig({
  crx: {
    myPublicPackage: {
      "src": "src/",
      "dest": "dist/crx/",
    }
  }
});

Advanced Example

This example demonstrates how you can tweak your builds upon your own source architecture.

//Gruntfile.js
grunt.loadNpmTasks('grunt-crx');

grunt.initConfig({
  crx: {
    myHostedPackage: {
      "src": "src-beta/",
      "dest": "dist/crx-beta/src/my-extension.crx",
      "baseURL": "http://my.app.net/files/",
      "exclude": [ ".git", ".svn" ],
      "privateKey": "~/.ssh/chrome-apps.pem",
      "options": {
        "maxBuffer": 3000 * 1024 //build extension with a weight up to 3MB
      }
    }
  }
});

Fully Customized Example

This example demonstrates how to build separate channels of packages within a same repository location.

Pretty handy to use a Git workflow and pre-release code before deploying it in production.

//Gruntfile.js
grunt.loadNpmTasks('grunt-crx');

grunt.initConfig({
  pkg: grunt.file.readJSON('package.json'),
  manifest: grunt.file.readJSON('src/manifest.json'),
  crx: {
    staging: {
      "src": "src/",
      "dest": "dist/staging/src/<%= pkg.name %>-<%= manifest.version %>-dev.crx",
      "baseURL": "http://my.app.intranet/files/",
      "filename": "",
      "exclude": [ ".git", ".svn", "*.pem" ],
      "privateKey": "dist/key.pem",
      "options": {
        "maxBuffer": 3000 * 1024 //build extension with a weight up to 3MB
      }
    },
    production: {
      "src": "src/",
      "dest": "dist/production/src/<%= pkg.name %>-<%= manifest.version %>-dev.crx",
      "baseURL": "http://my.app.net/files/",
      "exclude": [ ".git", ".svn", "dev/**", "*.pem" ],
      "options": {
        "maxBuffer": 3000 * 1024 //build extension with a weight up to 3MB
      }
    }
  }
});

Security Notice

It is strongly recommended to store your privates keys outside the source folder of your extensions.

Otherwise we will laught at you.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.

If you don't add unit tests, someone will take care of that before shipping the module to NPM. Take any contribution as an opportunity to learn.

Credits

License

The MIT License (MIT)
Copyright © 2013 Thomas Parisot, https://oncletom.io

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

grunt-crx's People

Contributors

thom4parisot avatar ehrlich-b avatar alexeykuzmin avatar pismute avatar pwmckenna avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.