1.0.8 • Published 7 years ago
node-chrome-webstore v1.0.8
node chrome webstore
Update and publish chrome extension automatically.
Prepare
If you have refresh_token, you can visit Subsequent calls directly.
Else please follow Using the Chrome Web Store Publish API instructions and come back when you get client id, client secret and code.
Code can only be used once, mainly use refresh token later.
Installation
npm i node-chrome-webstoreUsage
First call
Save refresh token and use it in subsequent calls
const webstore = require('node-chrome-webstore');
const client_id = '';
const client_secret = '';
const code = '';
webstore.auth({
client_id,
client_secret,
code,
});
webstore.items.getRefreshToken().then((token) => {
console.log(token); // save it
});Subsequent calls
const webstore = require('node-chrome-webstore');
const client_id = '';
const client_secret = '';
const refresh_token = '';
const itemId = '';
const zipPath = '';
webstore.auth({
client_id,
client_secret,
refresh_token,
});
// update
webstore.items.update(itemId, zipPath).then(res => {
console.log(res);
});
// publish
webstore.items.publish(itemId).then(res => {
console.log(res);
});With dotenv example
dotenv can help to save auth info to .env in project root.
Strongly recommend against committing your
.envfile to version control. It should be in.gitignore.
.env
client_id=9867219971
client_secret=5d21TdajfIcK
refresh_token=1/jBtQRAjjy
code=4/lgAZRFXy
itemId=eppeghhopeo
zipPath=path/to/zipRead auth info from .env
const webstore = require('node-chrome-webstore');
require('dotenv').config();
const {
client_id,
client_secret,
refresh_token,
itemId,
zipPath,
} = process.env;
webstore.auth({
client_id,
client_secret,
refresh_token,
});
webstore.items.update(itemId, zipPath).then((res) => {
if (res.uploadState === 'SUCCESS') {
webstore.items.publish(itemId).then((res) => {
console.log(res);
});
} else {
console.log(res);
}
});Development
Test
npm test