chrome-webstore-upload 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +23 -7
- package/package.json +1 -1
- package/readme.md +11 -0
package/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const uploadExistingURI = id =>
|
|
|
6
6
|
`${rootURI}/upload/chromewebstore/v1.1/items/${id}`;
|
|
7
7
|
const publishURI = (id, target) =>
|
|
8
8
|
`${rootURI}/chromewebstore/v1.1/items/${id}/publish?publishTarget=${target}`;
|
|
9
|
+
const getURI = (id, projection) =>
|
|
10
|
+
`${rootURI}/chromewebstore/v1.1/items/${id}?projection=${projection}`;
|
|
9
11
|
|
|
10
12
|
const requiredFields = ['extensionId', 'clientId', 'refreshToken'];
|
|
11
13
|
|
|
@@ -31,18 +33,32 @@ class APIClient {
|
|
|
31
33
|
|
|
32
34
|
const { extensionId } = this;
|
|
33
35
|
|
|
34
|
-
return got
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
return got
|
|
37
|
+
.put(uploadExistingURI(extensionId), {
|
|
38
|
+
headers: this._headers(await token),
|
|
39
|
+
body: readStream,
|
|
40
|
+
})
|
|
41
|
+
.json();
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
async publish(target = 'default', token = this.fetchToken()) {
|
|
41
45
|
const { extensionId } = this;
|
|
42
46
|
|
|
43
|
-
return got
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
return got
|
|
48
|
+
.post(publishURI(extensionId, target), {
|
|
49
|
+
headers: this._headers(await token),
|
|
50
|
+
})
|
|
51
|
+
.json();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async get(projection = 'DRAFT', token = this.fetchToken()) {
|
|
55
|
+
const { extensionId } = this;
|
|
56
|
+
|
|
57
|
+
return got
|
|
58
|
+
.get(getURI(extensionId, projection), {
|
|
59
|
+
headers: this._headers(await token),
|
|
60
|
+
})
|
|
61
|
+
.json();
|
|
46
62
|
}
|
|
47
63
|
|
|
48
64
|
async fetchToken() {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -56,6 +56,17 @@ store.publish(target, token).then(res => {
|
|
|
56
56
|
});
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### Get a Chrome Web Store item
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
const projection = "DRAFT"; // optional. Can also be 'PUBLISHED' but only "DRAFT" is supported at this time.
|
|
63
|
+
const token = "xxxx"; // optional. One will be fetched if not provided
|
|
64
|
+
store.get(projection, token).then((res) => {
|
|
65
|
+
// Response is documented here:
|
|
66
|
+
// https://developer.chrome.com/docs/webstore/webstore_api/items/get
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
59
70
|
### Fetch token
|
|
60
71
|
|
|
61
72
|
```javascript
|