Nebulous Puffy Marshmallows

    chrome-webstore-upload

    1.0.0 • Public • Published

    chrome-webstore-upload

    A small node.js module to upload/publish extensions to the Chrome Web Store.

    If you're looking to upload/publish from the CLI, then use chrome-webstore-upload-cli.

    Install

    npm install --save-dev chrome-webstore-upload
    

    Setup

    You will need a Google API clientId and a refreshToken. Read the guide.

    Note: If you created the APIs before version 0.5.0 (September 2021), you might have to follow the guide again. Leave a comment if that happened to you.

    Usage

    All methods return an ES2015-compliant promise.

    Create a new client

    import chromeWebstoreUpload from 'chrome-webstore-upload';
    
    const store = chromeWebstoreUpload({
      extensionId: 'ecnglinljpjkbgmdpeiglonddahpbkeb',
      clientId: 'xxxxxxxxxx',
      refreshToken: 'xxxxxxxxxx',
    });

    Upload to existing extension

    import fs from 'fs';
    
    const myZipFile = fs.createReadStream('./mypackage.zip');
    const token = 'xxxx'; // optional. One will be fetched if not provided
    store.uploadExisting(myZipFile, token).then(res => {
      // Response is a Resource Representation
      // https://developer.chrome.com/webstore/webstore_api/items#resource
    });

    Publish extension

    const target = 'default'; // optional. Can also be 'trustedTesters'
    const token = 'xxxx'; // optional. One will be fetched if not provided
    store.publish(target, token).then(res => {
      // Response is documented here:
      // https://developer.chrome.com/webstore/webstore_api/items/publish
    });

    Get a Chrome Web Store item

    const projection = "DRAFT"; // optional. Can also be 'PUBLISHED' but only "DRAFT" is supported at this time.
    const token = "xxxx"; // optional. One will be fetched if not provided
    store.get(projection, token).then((res) => {
      // Response is documented here:
      // https://developer.chrome.com/docs/webstore/webstore_api/items/get
    });

    Fetch token

    store.fetchToken().then(token => {
      // Token is a string
    });

    Tips

    • If you plan to upload and publish at the same time, use the fetchToken method, and pass it to both uploadExisting and publish as the optional second parameter. This will avoid those methods making duplicate calls for new tokens.

    Related

    Install

    npm i chrome-webstore-upload

    DownloadsWeekly Downloads

    11,030

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    7.74 kB

    Total Files

    4

    Last publish

    Collaborators

    • drewml
    • fregante