@equicord/publish-browser-extension 4.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.
- package/LICENSE +21 -0
- package/README.md +108 -0
- package/bin/publish-extension.mjs +2 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +156 -0
- package/dist/index.d.ts +419 -0
- package/dist/index.js +3 -0
- package/dist/init-CL9ikrQH.js +4292 -0
- package/package.json +94 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Aaron Klinker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<h1 align="center">Publish Browser Extension</h1>
|
|
2
|
+
<p align="center">Publish an extension to all the extension stores in a single command!</p>
|
|
3
|
+
|
|
4
|
+
https://github.com/aklinker1/publish-browser-extension/assets/10101283/b0e856ca-4e26-4c7e-9ff8-c900e203cab5
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- Publish to the **Chrome Web Store**, **Firefox Addon Store**, and **Edge Addon Store**
|
|
9
|
+
- Helper script to generate secrets and configure options
|
|
10
|
+
- **Upload sources ZIP** to the Firefox Addon Store
|
|
11
|
+
|
|
12
|
+
> [!IMPORTANT]
|
|
13
|
+
>
|
|
14
|
+
> You are responsible for uploading and submitting an extension for the first time by hand. `publish-browser-extension` does not provide tools for creating a new extension.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm i -D publish-browser-extension
|
|
20
|
+
pnpm i -D publish-browser-extension
|
|
21
|
+
bun i -D publish-browser-extension
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## CLI Usage
|
|
25
|
+
|
|
26
|
+
To get started, run the init command. It will walk you through generating all the necessary environment variables/CLI flags, saving them to a `.env.submit` file:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
publish-extension init
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> All CLI flags can be passed as environment variables instead. For example, setting the `CHROME_CLIENT_ID` environment variable is equivalent to passing `--chrome-client-id`. Just convert the flag to UPPER_SNAKE_CASE.
|
|
33
|
+
|
|
34
|
+
Then, just run the submit command, passing the ZIP files you want to submit:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
publish-extension \
|
|
38
|
+
--chrome-zip dist/chrome.zip \
|
|
39
|
+
--firefox-zip dist/firefox.zip --firefox-sources-zip dist/sources.zip \
|
|
40
|
+
--edge-zip dist/chrome.zip
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`publish-extension` will automatically look for a `.env.submit` file and load it if it exists.
|
|
44
|
+
|
|
45
|
+
## JS Usage
|
|
46
|
+
|
|
47
|
+
<!-- prettier-ignore -->
|
|
48
|
+
```js
|
|
49
|
+
import { publishExtension } from 'publish-browser-extension';
|
|
50
|
+
|
|
51
|
+
publishExtension({
|
|
52
|
+
dryRun: true,
|
|
53
|
+
chrome: {
|
|
54
|
+
zip: 'dist/chrome.zip',
|
|
55
|
+
extensionId: '<cws-extension-id>',
|
|
56
|
+
clientId: '<gcp-client-id>',
|
|
57
|
+
clientSecret: '<gcp-client-secret>',
|
|
58
|
+
refreshToken: '<gcp-refresh-token>',
|
|
59
|
+
publishTarget: '<default|trustedTesters>',
|
|
60
|
+
skipSubmitReview: false,
|
|
61
|
+
},
|
|
62
|
+
firefox: {
|
|
63
|
+
zip: 'dist/firefox.zip',
|
|
64
|
+
sourcesZip: 'dist/sources.zip',
|
|
65
|
+
extensionId: '<addons-extension-id>',
|
|
66
|
+
jwtIssuer: '<addons-jwt-issuer>',
|
|
67
|
+
jwtSecret: '<addons-jwt-secret>',
|
|
68
|
+
channel: '<listed|unlisted>',
|
|
69
|
+
},
|
|
70
|
+
edge: {
|
|
71
|
+
zip: 'dist/chrome.zip',
|
|
72
|
+
productId: "<edge-product-id>",
|
|
73
|
+
clientId: "<edge-client-id>",
|
|
74
|
+
apiKey: "<edge-api-key>",
|
|
75
|
+
skipSubmitReview: false,
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
.then(results => console.log(results))
|
|
79
|
+
.catch(err => console.error(err));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Contributing
|
|
83
|
+
|
|
84
|
+
<a href="https://github.com/aklinker1/publish-browser-extension/graphs/contributors">
|
|
85
|
+
<img src="https://contrib.rocks/image?repo=aklinker1/publish-browser-extension" />
|
|
86
|
+
</a>
|
|
87
|
+
|
|
88
|
+
### Contributor Setup
|
|
89
|
+
|
|
90
|
+
1. Install [bun](https://bun.sh/)
|
|
91
|
+
2. Install dependencies
|
|
92
|
+
```sh
|
|
93
|
+
bun i
|
|
94
|
+
```
|
|
95
|
+
3. Run the `init` command to generate a `.env.submit` file for testing
|
|
96
|
+
```sh
|
|
97
|
+
bun publish-extension init
|
|
98
|
+
```
|
|
99
|
+
> [!WARNING]
|
|
100
|
+
>
|
|
101
|
+
> Make sure to set the Firefox channel to "unlisted", chrome's publish target to "trustedTesters", and don't submit the extension for review for Chrome or Edge. This will prevent you from accidentally releasing one of the test extensions publicly.
|
|
102
|
+
4. Run the dev commands to upload a test extension to the stores:
|
|
103
|
+
```sh
|
|
104
|
+
bun dev:all
|
|
105
|
+
bun dev:chrome
|
|
106
|
+
bun dev:firefox
|
|
107
|
+
bun dev:edge
|
|
108
|
+
```
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { d as chromeStatus, n as submit, t as init, u as chromeSetDeployPercentage } from "./init-CL9ikrQH.js";
|
|
2
|
+
import { cac } from "cac";
|
|
3
|
+
import { consola as consola$1 } from "consola";
|
|
4
|
+
import { config } from "dotenv";
|
|
5
|
+
|
|
6
|
+
//#region package.json
|
|
7
|
+
var version = "4.0.0";
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/cli.ts
|
|
11
|
+
config({
|
|
12
|
+
path: ".env.submit",
|
|
13
|
+
quiet: true
|
|
14
|
+
});
|
|
15
|
+
const cli = cac("publish-extension");
|
|
16
|
+
cli.version(version);
|
|
17
|
+
cli.help();
|
|
18
|
+
cli.option("--dry-run", "Check authentication, but don't upload the zip or submit for review");
|
|
19
|
+
cli.option("--chrome-zip [chromeZip]", "Path to extension zip to upload");
|
|
20
|
+
cli.option("--chrome-extension-id [chromeExtensionId]", "The ID of the extension to be submitted");
|
|
21
|
+
cli.option("--chrome-publisher-id [chromePublisherId]", "The publisher ID from the Chrome Web Store Developer Dashboard");
|
|
22
|
+
cli.option("--chrome-client-id [chromeClientId]", "Client ID used for authorizing requests to the Chrome Web Store");
|
|
23
|
+
cli.option("--chrome-client-secret [chromeClientSecret]", "Client secret used for authorizing requests to the Chrome Web Store");
|
|
24
|
+
cli.option("--chrome-refresh-token [chromeRefreshToken]", "Refresh token used for authorizing requests to the Chrome Web Store");
|
|
25
|
+
cli.option("--chrome-deploy-percentage [chromeDeployPercentage]", "An integer from 1-100");
|
|
26
|
+
cli.option("--chrome-skip-submit-review", "Just upload the extension zip, don't submit it for review or publish it");
|
|
27
|
+
cli.option("--chrome-cancel-pending", "Cancel any pending submission before uploading");
|
|
28
|
+
cli.option("--chrome-skip-review", "Attempt to skip review if the item qualifies");
|
|
29
|
+
cli.option("--chrome-publish-type [chromePublishType]", "Publish type: \"DEFAULT_PUBLISH\" or \"STAGED_PUBLISH\"");
|
|
30
|
+
cli.option("--firefox-zip [firefoxZip]", "Path to extension zip to upload");
|
|
31
|
+
cli.option("--firefox-sources-zip [firefoxSourcesZip]", "Path to sources zip to upload");
|
|
32
|
+
cli.option("--firefox-extension-id [firefoxExtensionId]", "The ID of the extension to be submitted");
|
|
33
|
+
cli.option("--firefox-jwt-issuer [firefoxJwtIssuer]", "Issuer used for authorizing requests to Addon Store APIs");
|
|
34
|
+
cli.option("--firefox-jwt-secret [firefoxJwtSecret]", "Secret used for authorizing requests to Addon Store APIs");
|
|
35
|
+
cli.option("--firefox-channel [firefoxChannel]", "The channel to publish to, \"listed\" or \"unlisted\"");
|
|
36
|
+
cli.option("--edge-zip [edgeZip]", "Path to extension zip to upload");
|
|
37
|
+
cli.option("--edge-product-id [edgeProductId]", "Product ID listed on the developer dashboard");
|
|
38
|
+
cli.option("--edge-client-id [edgeClientId]", "Client ID used for authorizing requests to Microsofts addon API");
|
|
39
|
+
cli.option("--edge-api-key [edgeApiKey]", "API key used for authorizing requests to Microsofts addon API v1.1");
|
|
40
|
+
cli.option("--edge-client-secret [edgeClientSecret]", "DEPRECATED: Client secret used for authorizing requests to Microsofts addon API v1.0 (no longer available)");
|
|
41
|
+
cli.option("--edge-access-token-url [edgeAccessTokenUrl]", "DEPRECATED: Access token URL used for authorizing requests to Microsofts addon API v1.0 (no longer available)");
|
|
42
|
+
cli.option("--edge-skip-submit-review", "Just upload the extension zip, don't submit it for review or publish it");
|
|
43
|
+
function configFromFlags(flags) {
|
|
44
|
+
return {
|
|
45
|
+
dryRun: flags.dryRun,
|
|
46
|
+
chrome: {
|
|
47
|
+
zip: flags.chromeZip,
|
|
48
|
+
extensionId: flags.chromeExtensionId,
|
|
49
|
+
publisherId: flags.chromePublisherId,
|
|
50
|
+
clientId: flags.chromeClientId,
|
|
51
|
+
clientSecret: flags.chromeClientSecret,
|
|
52
|
+
refreshToken: flags.chromeRefreshToken,
|
|
53
|
+
deployPercentage: flags.chromeDeployPercentage,
|
|
54
|
+
skipSubmitReview: flags.chromeSkipSubmitReview,
|
|
55
|
+
cancelPending: flags.chromeCancelPending,
|
|
56
|
+
skipReview: flags.chromeSkipReview,
|
|
57
|
+
publishType: flags.chromePublishType
|
|
58
|
+
},
|
|
59
|
+
firefox: {
|
|
60
|
+
zip: flags.firefoxZip,
|
|
61
|
+
sourcesZip: flags.firefoxSourcesZip,
|
|
62
|
+
extensionId: flags.firefoxExtensionId,
|
|
63
|
+
jwtIssuer: flags.firefoxJwtIssuer,
|
|
64
|
+
jwtSecret: flags.firefoxJwtSecret,
|
|
65
|
+
channel: flags.firefoxChannel
|
|
66
|
+
},
|
|
67
|
+
edge: {
|
|
68
|
+
zip: flags.edgeZip,
|
|
69
|
+
productId: flags.edgeProductId,
|
|
70
|
+
clientId: flags.edgeClientId,
|
|
71
|
+
apiKey: flags.edgeApiKey,
|
|
72
|
+
clientSecret: flags.edgeClientSecret,
|
|
73
|
+
accessTokenUrl: flags.edgeAccessTokenUrl,
|
|
74
|
+
skipSubmitReview: flags.edgeSkipSubmitReview
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
cli.command("", "Submit an extension to multiple stores for review").action(async (flags) => {
|
|
79
|
+
const config$1 = configFromFlags(flags);
|
|
80
|
+
try {
|
|
81
|
+
await submit(config$1);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
consola$1.error(err);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
cli.command("init", "Interactive walkthrough to initialize or update secrets and options for each store").action(async (flags) => {
|
|
88
|
+
const config$1 = configFromFlags({
|
|
89
|
+
chromeZip: "...",
|
|
90
|
+
firefoxZip: "...",
|
|
91
|
+
edgeZip: "...",
|
|
92
|
+
...flags
|
|
93
|
+
});
|
|
94
|
+
try {
|
|
95
|
+
await init(config$1);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
consola$1.error(err);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
cli.command("status", "Fetch the status of a Chrome extension").option("--chrome-extension-id [chromeExtensionId]", "The ID of the extension").option("--chrome-publisher-id [chromePublisherId]", "The publisher ID from the Chrome Web Store Developer Dashboard").option("--chrome-client-id [chromeClientId]", "Client ID used for authorizing requests").option("--chrome-client-secret [chromeClientSecret]", "Client secret used for authorizing requests").option("--chrome-refresh-token [chromeRefreshToken]", "Refresh token used for authorizing requests").action(async (flags) => {
|
|
102
|
+
const extensionId = flags.chromeExtensionId ?? process.env.CHROME_EXTENSION_ID;
|
|
103
|
+
const publisherId = flags.chromePublisherId ?? process.env.CHROME_PUBLISHER_ID;
|
|
104
|
+
const clientId = flags.chromeClientId ?? process.env.CHROME_CLIENT_ID;
|
|
105
|
+
const clientSecret = flags.chromeClientSecret ?? process.env.CHROME_CLIENT_SECRET;
|
|
106
|
+
const refreshToken = flags.chromeRefreshToken ?? process.env.CHROME_REFRESH_TOKEN;
|
|
107
|
+
if (!extensionId || !publisherId || !clientId || !clientSecret || !refreshToken) {
|
|
108
|
+
consola$1.error("Missing required options: --chrome-extension-id, --chrome-publisher-id, --chrome-client-id, --chrome-client-secret, --chrome-refresh-token");
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
await chromeStatus({
|
|
113
|
+
extensionId,
|
|
114
|
+
publisherId,
|
|
115
|
+
clientId,
|
|
116
|
+
clientSecret,
|
|
117
|
+
refreshToken
|
|
118
|
+
});
|
|
119
|
+
} catch (err) {
|
|
120
|
+
consola$1.error(err);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
cli.command("set-deploy-percentage", "Update deployment percentage for a published Chrome extension").option("--chrome-extension-id [chromeExtensionId]", "The ID of the extension").option("--chrome-publisher-id [chromePublisherId]", "The publisher ID from the Chrome Web Store Developer Dashboard").option("--chrome-client-id [chromeClientId]", "Client ID used for authorizing requests").option("--chrome-client-secret [chromeClientSecret]", "Client secret used for authorizing requests").option("--chrome-refresh-token [chromeRefreshToken]", "Refresh token used for authorizing requests").option("--chrome-deploy-percentage <chromeDeployPercentage>", "Deploy percentage (1-100)").action(async (flags) => {
|
|
125
|
+
const extensionId = flags.chromeExtensionId ?? process.env.CHROME_EXTENSION_ID;
|
|
126
|
+
const publisherId = flags.chromePublisherId ?? process.env.CHROME_PUBLISHER_ID;
|
|
127
|
+
const clientId = flags.chromeClientId ?? process.env.CHROME_CLIENT_ID;
|
|
128
|
+
const clientSecret = flags.chromeClientSecret ?? process.env.CHROME_CLIENT_SECRET;
|
|
129
|
+
const refreshToken = flags.chromeRefreshToken ?? process.env.CHROME_REFRESH_TOKEN;
|
|
130
|
+
const deployPercentage = flags.chromeDeployPercentage ? parseInt(flags.chromeDeployPercentage, 10) : void 0;
|
|
131
|
+
if (!extensionId || !publisherId || !clientId || !clientSecret || !refreshToken) {
|
|
132
|
+
consola$1.error("Missing required options: --chrome-extension-id, --chrome-publisher-id, --chrome-client-id, --chrome-client-secret, --chrome-refresh-token");
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
if (!deployPercentage || deployPercentage < 1 || deployPercentage > 100) {
|
|
136
|
+
consola$1.error("Missing or invalid --chrome-deploy-percentage (must be 1-100)");
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
await chromeSetDeployPercentage({
|
|
141
|
+
extensionId,
|
|
142
|
+
publisherId,
|
|
143
|
+
clientId,
|
|
144
|
+
clientSecret,
|
|
145
|
+
refreshToken,
|
|
146
|
+
deployPercentage
|
|
147
|
+
});
|
|
148
|
+
} catch (err) {
|
|
149
|
+
consola$1.error(err);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
cli.parse();
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
export { };
|