chrome-webstore-upload 2.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 (2) hide show
  1. package/index.js +29 -20
  2. package/package.json +8 -7
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": "2.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": "^14.0.0"
42
- },
43
40
  "devDependencies": {
44
- "ava": "^6.0.1",
45
- "sinon": "^17.0.1",
41
+ "fetch-mock": "^9.11.0",
42
+ "node-fetch": "^2.7.0",
43
+ "vitest": "^1.0.4",
46
44
  "xo": "^0.56.0"
47
45
  },
48
46
  "engines": {
49
47
  "node": ">=18"
48
+ },
49
+ "webExt": {
50
+ "sourceDir": "live-test"
50
51
  }
51
52
  }