Automatically upload new versions of Chrome Extensions or Apps to the Chrome Webstore - integrated in your node project!
npm install webstore-uploadnpm install --save webstore-upload
js
// Promise api
var webstore_upload = require('webstore-upload');
webstore_upload(uploadOptions, loggerFn)
.then(function(result) {
console.log(result);
// do somethings nice
return 'yay';
})
.catch(function(err) {
console.error(err);
});
// Deprecated callback api - meanwhile it's here for compatability and whoever is already depend on it.
var webstore_upload = require('webstore-upload/deprecated');
webstore_upload(uploadOptions, function(result) {
console.log('complete!');
console.log(result);
});
`
`js
var uploadOptions = {
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: true,
appID: 'jcbeonnlikcefedeaijjln',
zip: 'test/files/test2.zip',
publishTarget: 'trustedTesters'
}
},
uploadExtensions : ['extension2']
};
`
$3
Test cases:
* All should work with existing refresh_token
* All should work with creating new token from web
* All should work with creating new token from cmd
* Fail on bad existing refresh_token
* Fail on Non developer account
* Fail on incorrect publishTarget value
$3
Can be 'default', 'quiet' or your logger function (winston and similar):
`js
// info, log, warn, err
logger('log', 'message');
`
$3
If you want the cli option, you can use the original grunt project
$3
| Name | Type | Required | Default | Description | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- |
| accounts | Object | Yes | | List of the accounts (see Accounts section for details). | |
| extensions | Object | Yes | | List of the extension (see Extensions section for details). | |
| onComplete | Function | No | | Function that will be executed when all extensions uploaded. | See result example below |
#### onComplete / Promise result
Array of released extensions passed as argument:
`js
[{
fileName : zip,
extensionName : options.name,
extensionId : options.appID,
published : true
}..]
`
#### 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.
| Name | Type | Required | Default | Description | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- |
| publish | Boolean | No | false | Make item available at Chrome Webstore or not. | |
| client_id | String | Yes | | Client ID to access to Chrome Console API. | How to get it |
| client_secret | String | Yes | | Client Secret to access to Chrome Console API. | How to get it |
| refresh_token | String | No | | Refresh token for the Chrome Console API. | How to get it |
#### Extensions
It is object with arbitrary meaningful extensions names as a keys (see example above).
| Name | Type | Required | Default | Description | Notes |
| :-- | :-- | :-- | :-- | :-- | :-- |
| appID | String | Yes | | Extension id or Application id at Chrome Webstore | |
| zip | String | Yes | | Path to zip file. Upload most recent zip file in case of path is directory | |
| zip | String | Yes | | | |
| publish | Boolean | No | false | Make item available at Chrome Webstore or not. This option under extensions will rewrite publish under related account section. | |
| publishTarget | String | No | default | Make item available at Chrome Webstore. Can be trustedTesters or default | Publish |
| account | String | No | default | Name of the account, that we should use to upload extension. | |
$3
Read more about Chrome Web Store Publish API and how to get Client ID and Client secret
+ require the module with the configuration (see examples)
+ call the module
+ 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