npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-webstore-upload

v0.9.24

Published

Automate uploading process of the new versions of Chrome Extension to Chrome Webstore

Downloads

564

Readme

grunt-webstore-upload

Automate uploading process of the new versions of Chrome Extension or App to Chrome Webstore

Getting Started

This plugin requires Grunt.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-webstore-upload --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-webstore-upload');

The "webstore_upload" task

Overview

Read more about great ability to automate this task here: Chrome Web Store Publish API. In your project's Gruntfile, add a section named webstore_upload to the data object passed into grunt.initConfig().

Please note, that you have to upload your extension first time manually, and then provide appID to update ( see below ). Also please make sure, that your draft ready to be published, ie all required fields was populated

grunt.initConfig({
    webstore_upload: {
        "accounts": {
            "default": { //account under this section will be used by default
                publish: true, //publish item right after uploading. default false
                client_id: "ie204es2mninvnb.apps.googleusercontent.com",
                client_secret: "LEJDeBHfS"
            },
            "other_account": {
                publish: true, //publish item right after uploading. default false
                client_id: "ie204es2mninvnb.apps.googleusercontent.com",
                client_secret: "LEJDeBHfS",
                refresh_token: "1/eeeeeeeeeeeeeeeeeeeeeee_aaaaaaaaaaaaaaaaaaa"
            },
            "new_account": { 
                cli_auth: true, // Use server-less cli prompt go get access token. Default false
                publish: true, //publish item right after uploading. default false
                client_id: "kie204es2mninvnb.apps.googleusercontent.com",
                client_secret: "EbDeHfShcj"
            }
        },
        "extensions": {
            "extension1": {
                //required
                appID: "jcbeonnlikcefedeaijjln",
                //required, we can use dir name and upload most recent zip file
                zip: "test/files/test1.zip"      
            },
            "extension2": {
                account: "new_account",
                //will rewrite values from 'account' section
                publish: false, 
                appID: "jcbeonnlplijjln",
                zip: "test/files/test2.zip"
            }
        }
    }
})

CLI options

You can pass multiple compile targets separated with comas: grunt webstore_upload:target1:target2 -m "new super feature released"

-m

Message for release, can be used within onComplete callback

-a

upload only extensions for provided account grunt webstore_upload -a acc1 -a acc2

--group

upload only extensions for provided group grunt webstore_upload --group acc1 -group acc2

--exclude-group

exclude extensions of this group grunt webstore_upload --exclude-group group1

--exclude-single <extension_name>

exclude extension grunt webstore_upload --exclude-single extension_name

Configuration

accounts

List of the accounts (see Accounts section for details).

Type: Object

Required

extensions

List of the extension (see Extensions section for details).

Type: Object

Required

onComplete

Function that will be executed when all extension uploaded.

Array of released extensions and release message ( see -m ) passed as argument:

[{
    fileName        : zip,
    extensionName   : options.name,
    extensionId     : options.appID,
    published       : true
}..]

Type: Function

Optional

fakeUpload

Simulate success upload

Type: Boolean

Option

fakeGoodPublish

Simulate success publish

Type: Boolean

Option

fakeBadPublish

Simulate failed publish

Type: Boolean

Option

Accounts

Since Google allows only 20 extensions under one account, you can create multiple records here. It is object with arbitrary meaningful accounts names as a keys (see example above). Special account named default will be used by defaults.

publish

Make item available at Chrome Webstore or not

Type: Boolean

Default value: false

Optional

client_id

How to get it Client ID to access to Chrome Console API

Type: String

Required

client_secret

How to get it Client Secret to access to Chrome Console API

Type: String

Required

refresh_token

How to get it Refresh token for the Chrome Console API

Type: String

Optional

skipUnpublished

Skip extensions where publish is false

Type: Boolean

Default value: false

Optional

safe_global_upload

Allow global upload only with --global flag

Type: Boolean

Default value: false

Optional

retryOneMoreTime

Will be called on each uploading/publishing error. Should return true in case of one more try ( return false by default ).

Type: Function

Example

...
"retryOneMoreTime": function(response){
    var nonRetryCodes = ["PKG_INVALID_VERSION_NUMBER", "FILE_NOT_EXISTS"];
    var errorCode = _.get(response, "errors.itemError.0.error_code") ||
        _.get(response, "errors.error_code");
    if( nonRetryCodes.includes(errorCode) ){
        return false;
    }
    return true;
}
...

Optional

Extensions

It is object with arbitrary meaningful extensions names as a keys (see example above).

appID

Extension id or Application id at Chrome Webstore

Type: String

Required

zip

Path to zip file. Upload most recent zip file in case of path is directory

Type: String

Required

publish

Make item available at Chrome Webstore or not. This option under extensions will rewrite publish under related account section.

Type: Boolean

Default value: false

Optional

publishTarget

Make item available at . See https://developer.chrome.com/webstore/webstore_api/items/publish Can be trustedTesters or default

Type: String

Default value: default

Optional

account

Name of the account, that we should use to upload extension. If ommited, default account will be used.

Type: String

Default value: default

Optional

group

Name of the group, that we should use to upload extension.

Type: String

Optional

skip

skip this extension ( don't upload, etc )

Type: Bool

Default value: false

Optional

Migrating from < 0.7 versions

In order to move your existing config to new version, do following steps:

  • Create new keys in config accounts, extensions
  • Remove browser_path from options
  • Move publish, client_id, client_secret from options to default account
  • Move all exntentions to extension section.
  • Move publish, zip, appID from options of the extension to one level up
  • Ask me, if something still broken :P

Workflow

Read more about Chrome Web Store Publish API and how to get Client ID and Client secret

  • execute grunt webstore_upload or grunt webstore_upload:target in order to upload zip files
  • browser should be opened
  • confirm privileges in browser ( we have to manually do this )
  • wait until uploading will be finished

To automatically pull a new access token using a refresh token just set the refresh_token property in your configuration. If the refresh_token is present it will automatically refresh the token for you without any manual intervention.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.8.9 -m and onComplete released

0.7.0 Allowed multiple accounts. Async multiple uploading. Redo configuration style.

0.5.1 Fix problem with path

0.5.0 Initial commit

License

Copyright (c) 2014 Anton Sivolapov. Licensed under the MIT license.