chrome-webstore-upload 3.0.0 → 3.0.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.
Files changed (3) hide show
  1. package/index.js +9 -0
  2. package/package.json +10 -3
  3. package/readme.md +1 -1
package/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ // API documentation:
2
+ // https://developer.chrome.com/docs/webstore/api
3
+ // https://developer.chrome.com/docs/webstore/using-api
4
+
1
5
  const rootURI = 'https://www.googleapis.com';
2
6
  export const refreshTokenURI = 'https://www.googleapis.com/oauth2/v4/token';
3
7
  const uploadExistingURI = id =>
@@ -11,6 +15,10 @@ const requiredFields = ['extensionId', 'clientId', 'refreshToken'];
11
15
 
12
16
  class APIClient {
13
17
  constructor(options) {
18
+ if (typeof fetch !== 'function') {
19
+ throw new TypeError('`chrome-webstore-upload` requires Node.js 18.0 or newer because it relies on the global `fetch` function.');
20
+ }
21
+
14
22
  for (const field of requiredFields) {
15
23
  if (!options[field]) {
16
24
  throw new Error(`Option "${field}" is required`);
@@ -34,6 +42,7 @@ class APIClient {
34
42
  const request = await fetch(uploadExistingURI(extensionId), {
35
43
  method: 'PUT',
36
44
  headers: this._headers(await token),
45
+ duplex: 'half',
37
46
  body: readStream,
38
47
  });
39
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-webstore-upload",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Upload Chrome Extensions to the Chrome Web Store",
5
5
  "keywords": [
6
6
  "chrome",
@@ -25,7 +25,12 @@
25
25
  "index.js"
26
26
  ],
27
27
  "scripts": {
28
- "test": "xo && vitest"
28
+ "test": "xo && vitest run",
29
+ "upload": "npm run bundle && npm run test:upload",
30
+ "prebundle": "dot-json test/extension/manifest.json version $(utc-version)",
31
+ "bundle": "web-ext build --filename live-test.zip --overwrite-dest",
32
+ "postbundle": "git restore test/extension/manifest.json",
33
+ "test:upload": "eval $(cat .env) node test/live-test.js"
29
34
  },
30
35
  "xo": {
31
36
  "rules": {
@@ -38,8 +43,10 @@
38
43
  "space": 4
39
44
  },
40
45
  "devDependencies": {
46
+ "dot-json": "^1.3.0",
41
47
  "fetch-mock": "^9.11.0",
42
48
  "node-fetch": "^2.7.0",
49
+ "utc-version": "^2.0.2",
43
50
  "vitest": "^1.0.4",
44
51
  "xo": "^0.56.0"
45
52
  },
@@ -47,6 +54,6 @@
47
54
  "node": ">=18"
48
55
  },
49
56
  "webExt": {
50
- "sourceDir": "live-test"
57
+ "sourceDir": "test/extension"
51
58
  }
52
59
  }
package/readme.md CHANGED
@@ -12,7 +12,7 @@ npm install --save-dev chrome-webstore-upload
12
12
 
13
13
  ## Setup
14
14
 
15
- You will need a Google API `clientId`, `clientSecret` and `refreshToken`. Read [the guide](./How%20to%20generate%20Google%20API%20keys.md).
15
+ You will need a Google API `clientId`, `clientSecret` and `refreshToken`. Use [the guide]( https://github.com/fregante/chrome-webstore-upload-keys).
16
16
 
17
17
  ## Usage
18
18