Giter Club home page Giter Club logo

chrome-webstore-api's Introduction

Chrome Web Store API Client

deno version GitHub Release Release codecov Open in Visual Studio Code Open in Visual Studio Code

cwa is a simple Deno library for uploading & publishing your extensions and themes to the Chrome Web Store.

If you're looking for an easy-to-use command-line version of this, check out cwc.

This draws inspiration heavily from Andrew's fantastic chrome-webstore-upload library (originally written for Node.js) and improves on it by offering a few more API methods.

Usage

You'll need Google API client ID, client secret and a refresh token. Learn how to get them.

Once you have them, can you start using the client in your Deno project like this —

import { APIClient } from "https://deno.land/x/[email protected]/mod.ts";

const apiClient = new APIClient({
  // Note: These values are representative and don't actually work.
  id: "akjpoenbamadeeboawhkeljfvhngklfi",
  clientId:
    "618272284469-5hba9n4sc2hgommup53osq7s7f0k6bp6.apps.googleusercontent.com",
  clientSecret: "VwE91L-3_NWEcSlZfPJk6721",
  refreshToken:
    "1//0dbz-Pw36crhMCgYIPORTGB1SNwF-M2IrETpgP8ebvFCmFUuUXQRxxxIOuKiXE_ZvCLM7EbrHWah3dPOGOUfiBBuzwxjhplWISMB",
});

API

uploadNew(stream, token?)

Upload a new item to the Web Store. Use this only when you're uploading your extension or theme for the very first time.

import { readableStreamFromReader } from "https://deno.land/[email protected]/io/mod.ts";

const filePath = "/path/to/your/new/extension.zip";
const fileReader = await Deno.open(filePath, { read: true });
const fileStream = readableStreamFromReader(fileReader);
const uploadResult = await apiClient.uploadNew(fileStream);
console.log(uploadResult);

// {
//   "kind": "chromewebstore#item",
//   "id": "...",
//   "uploadState": "SUCCESS"
// }

uploadExisting(stream, token?)

Upload a new version of an existing item to the Web Store. Use this when you're uploading a newer version of an existing extension or theme.

import { readableStreamFromReader } from "https://deno.land/[email protected]/io/mod.ts";

const filePath = "/path/to/your/existing/extension.zip";
const fileReader = await Deno.open(filePath, { read: true });
const fileStream = readableStreamFromReader(fileReader);
const uploadResult = await apiClient.uploadExisting(fileStream);
console.log(uploadResult);

// {
//   "kind": "chromewebstore#item",
//   "id": "...",
//   "uploadState": "SUCCESS"
// }

publish(target, token?)

Publish the latest uploaded version of an existing item to the Web Store. By default, this publishes to everyone.

const publishResult = await apiClient.publish();
console.log(publishResult);

// {
//   "kind": "chromewebstore#item",
//   "item_id": "...",
//   "status": ["OK"],
//   "statusDetail": ["..."]
// }

If you'd like to publish only to your trusted testers, you can set the first argument to the publish() call.

const publishResult = await apiClient.publish("trustedTesters");
console.log(publishResult);

// {
//   "kind": "chromewebstore#item",
//   "item_id": "...",
//   "status": ["OK"],
//   "statusDetail": ["..."]
// }

checkUploadStatus(token?)

Find out the upload status of your item on the Chrome Store.

const uploadStatus = await apiClient.checkUploadStatus();
console.log(uploadStatus);

// {
//   "kind": "chromewebstore#item",
//   "id": "...",
//   "uploadState": "FAILURE",
//   "itemError": [{
//     "error_code": "...",
//     "error_detail": "..."
//   }]
// }

fetchToken()

Fetches an access token; you won't need it most of the time, but it is available if you need it.

const accessToken = await apiClient.fetchToken();
console.log(accessToken);

// "..."

Developer Notes

1.Useful deno shorthand scripts and Git hooks are set up with velociraptor. You can view a list of the commands using –

```
vr
```
  1. To debug this module or to get detailed logs, set the environment variable DEBUG to cwa:*. For example, if you're a *Nix user, use the command —
DEBUG=cwa:* vr run test

License

The code in this project is released under the MIT License.

FOSSA Status

chrome-webstore-api's People

Contributors

paambaati avatar

Watchers

 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.