Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deploy for partial rollout #90

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
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) => (
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions shouldn't accept more than 1 optional parameter, can you turn this into an object? {id, target, deployPercentage}

`${rootURI}/chromewebstore/v1.1/items/${id}/publish?publishTarget=${target}`
+ (deployPercentage == undefined ? '' : `&deployPercentage=${deployPercentage}`)

Check failure on line 11 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected '===' and instead saw '=='.

Check failure on line 11 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected '===' and instead saw '=='.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you alter this function to build the URL via new URL() so you can add parameters via url.searchParams.set()?

);
const getURI = (id, projection) =>
`${rootURI}/chromewebstore/v1.1/items/${id}?projection=${projection}`;

Expand Down Expand Up @@ -61,10 +63,10 @@
return response;
}

async publish(target = 'default', token = this.fetchToken()) {
async publish(target = 'default', token = this.fetchToken(), deployPercentage = undefined) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes here, this can be changed to a single object: {target, token, deployPercentage}

I'll release a breaking version after this

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),
});
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
Loading