Giter Site home page Giter Site logo

node-chrome-webstore's Introduction

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-webstore

Usage

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 .env file 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/zip

Read 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

node-chrome-webstore's People

Contributors

dependabot[bot] avatar leafoftree avatar

Stargazers

 avatar

Watchers

 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.