chrome-webstore-upload 1.0.0 → 3.0.0

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.
Files changed (3) hide show
  1. package/index.js +29 -20
  2. package/package.json +10 -9
  3. package/readme.md +3 -4
package/index.js CHANGED
@@ -1,7 +1,5 @@
1
- import got from 'got';
2
-
3
1
  const rootURI = 'https://www.googleapis.com';
4
- const refreshTokenURI = 'https://www.googleapis.com/oauth2/v4/token';
2
+ export const refreshTokenURI = 'https://www.googleapis.com/oauth2/v4/token';
5
3
  const uploadExistingURI = id =>
6
4
  `${rootURI}/upload/chromewebstore/v1.1/items/${id}`;
7
5
  const publishURI = (id, target) =>
@@ -33,32 +31,35 @@ class APIClient {
33
31
 
34
32
  const { extensionId } = this;
35
33
 
36
- return got
37
- .put(uploadExistingURI(extensionId), {
38
- headers: this._headers(await token),
39
- body: readStream,
40
- })
41
- .json();
34
+ const request = await fetch(uploadExistingURI(extensionId), {
35
+ method: 'PUT',
36
+ headers: this._headers(await token),
37
+ body: readStream,
38
+ });
39
+
40
+ return request.json();
42
41
  }
43
42
 
44
43
  async publish(target = 'default', token = this.fetchToken()) {
45
44
  const { extensionId } = this;
46
45
 
47
- return got
48
- .post(publishURI(extensionId, target), {
49
- headers: this._headers(await token),
50
- })
51
- .json();
46
+ const request = await fetch(publishURI(extensionId, target), {
47
+ method: 'POST',
48
+ headers: this._headers(await token),
49
+ });
50
+
51
+ return request.json();
52
52
  }
53
53
 
54
54
  async get(projection = 'DRAFT', token = this.fetchToken()) {
55
55
  const { extensionId } = this;
56
56
 
57
- return got
58
- .get(getURI(extensionId, projection), {
59
- headers: this._headers(await token),
60
- })
61
- .json();
57
+ const request = await fetch(getURI(extensionId, projection), {
58
+ method: 'GET',
59
+ headers: this._headers(await token),
60
+ });
61
+
62
+ return request.json();
62
63
  }
63
64
 
64
65
  async fetchToken() {
@@ -73,7 +74,15 @@ class APIClient {
73
74
  json.client_secret = clientSecret;
74
75
  }
75
76
 
76
- const response = await got.post(refreshTokenURI, { json }).json();
77
+ const request = await fetch(refreshTokenURI, {
78
+ method: 'POST',
79
+ body: JSON.stringify(json),
80
+ headers: {
81
+ 'Content-Type': 'application/json',
82
+ },
83
+ });
84
+
85
+ const response = await request.json();
77
86
 
78
87
  return response.access_token;
79
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-webstore-upload",
3
- "version": "1.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "Upload Chrome Extensions to the Chrome Web Store",
5
5
  "keywords": [
6
6
  "chrome",
@@ -25,7 +25,7 @@
25
25
  "index.js"
26
26
  ],
27
27
  "scripts": {
28
- "test": "xo && ava"
28
+ "test": "xo && vitest"
29
29
  },
30
30
  "xo": {
31
31
  "rules": {
@@ -37,15 +37,16 @@
37
37
  },
38
38
  "space": 4
39
39
  },
40
- "dependencies": {
41
- "got": "^11.8.2"
42
- },
43
40
  "devDependencies": {
44
- "ava": "^3.15.0",
45
- "sinon": "^11.1.2",
46
- "xo": "^0.44.0"
41
+ "fetch-mock": "^9.11.0",
42
+ "node-fetch": "^2.7.0",
43
+ "vitest": "^1.0.4",
44
+ "xo": "^0.56.0"
47
45
  },
48
46
  "engines": {
49
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
47
+ "node": ">=18"
48
+ },
49
+ "webExt": {
50
+ "sourceDir": "live-test"
50
51
  }
51
52
  }
package/readme.md CHANGED
@@ -12,13 +12,11 @@ npm install --save-dev chrome-webstore-upload
12
12
 
13
13
  ## Setup
14
14
 
15
- You will need a Google API `clientId` and a `refreshToken`. Read [the guide](./How%20to%20generate%20Google%20API%20keys.md).
16
-
17
- Note: If you created the APIs before version 0.5.0 (September 2021), you might have to follow [the guide](./How%20to%20generate%20Google%20API%20keys.md) again. [Leave a comment](https://github.com/fregante/chrome-webstore-upload-cli/issues/44) if that happened to you.
15
+ You will need a Google API `clientId`, `clientSecret` and `refreshToken`. Read [the guide](./How%20to%20generate%20Google%20API%20keys.md).
18
16
 
19
17
  ## Usage
20
18
 
21
- All methods return an ES2015-compliant promise.
19
+ All methods return a promise.
22
20
 
23
21
  ### Create a new client
24
22
 
@@ -28,6 +26,7 @@ import chromeWebstoreUpload from 'chrome-webstore-upload';
28
26
  const store = chromeWebstoreUpload({
29
27
  extensionId: 'ecnglinljpjkbgmdpeiglonddahpbkeb',
30
28
  clientId: 'xxxxxxxxxx',
29
+ clientSecret: 'xxxxxxxxxx',
31
30
  refreshToken: 'xxxxxxxxxx',
32
31
  });
33
32
  ```