From 2bc836f5eaa4c0c0c47ec129a44c4f94586c0be9 Mon Sep 17 00:00:00 2001 From: Jordi Salvat i Alabart Date: Wed, 29 May 2024 19:11:18 +0200 Subject: [PATCH 1/2] feat: add support for `deployPercentage` Google recently documented this parameter to the `publish` call; this adds support for it. --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5678412..2649953 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,10 @@ const rootURI = 'https://www.googleapis.com'; export const refreshTokenURI = 'https://www.googleapis.com/oauth2/v4/token'; const uploadExistingURI = id => `${rootURI}/upload/chromewebstore/v1.1/items/${id}`; -const publishURI = (id, target) => - `${rootURI}/chromewebstore/v1.1/items/${id}/publish?publishTarget=${target}`; +const publishURI = (id, target, deployPercentage) => ( + `${rootURI}/chromewebstore/v1.1/items/${id}/publish?publishTarget=${target}` + + (deployPercentage == undefined ? '' : `&deployPercentage=${deployPercentage}`) +); const getURI = (id, projection) => `${rootURI}/chromewebstore/v1.1/items/${id}?projection=${projection}`; @@ -61,10 +63,10 @@ class APIClient { return response; } - async publish(target = 'default', token = this.fetchToken()) { + async publish(target = 'default', token = this.fetchToken(), deployPercentage = undefined) { const { extensionId } = this; - const request = await fetch(publishURI(extensionId, target), { + const request = await fetch(publishURI(extensionId, target, deployPercentage), { method: 'POST', headers: this._headers(await token), }); From df2fe2d57c98b4d574544d42ddda79a8c78bdb5d Mon Sep 17 00:00:00 2001 From: Jordi Salvat i Alabart Date: Wed, 29 May 2024 19:13:40 +0200 Subject: [PATCH 2/2] docs: added `deployPercentage` parameter to `publish` --- readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 321a80d..ceb1c5c 100644 --- a/readme.md +++ b/readme.md @@ -49,7 +49,8 @@ store.uploadExisting(myZipFile, token).then(res => { ```javascript 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 => { +const deployPercentage = 25; // optional. Rolls out to 100% if not provided. +store.publish(target, token, deployPercentage).then(res => { // Response is documented here: // https://developer.chrome.com/webstore/webstore_api/items/publish });