@gjsify/cli 0.64.49-next.348 → 0.64.50
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/dist/cli.gjs.mjs +255 -255
- package/lib/commands/webext/subcommands.d.ts +1 -0
- package/lib/commands/webext/subcommands.js +8 -2
- package/lib/utils/webext/stores/amo.d.ts +9 -0
- package/lib/utils/webext/stores/amo.js +233 -0
- package/lib/utils/webext/stores/index.d.ts +6 -5
- package/lib/utils/webext/stores/index.js +17 -15
- package/lib/utils/webext/submit.d.ts +2 -0
- package/lib/utils/webext/submit.js +18 -7
- package/package.json +21 -22
|
@@ -280,10 +280,10 @@ export const webextListingCommand = {
|
|
|
280
280
|
};
|
|
281
281
|
export const webextSubmitCommand = {
|
|
282
282
|
command: 'submit',
|
|
283
|
-
description: 'Upload the built zip to the Chrome Web Store
|
|
283
|
+
description: 'Upload the built zip to the Chrome Web Store, Edge Add-ons or Firefox AMO; --submit also asks for review (tags only).',
|
|
284
284
|
builder: (yargs) => yargs
|
|
285
285
|
.option('store', {
|
|
286
|
-
description: 'Which store (amo
|
|
286
|
+
description: 'Which store (amo = addons.mozilla.org, an existing listed add-on).',
|
|
287
287
|
type: 'string',
|
|
288
288
|
choices: ['chrome', 'edge', 'amo'],
|
|
289
289
|
demandOption: true,
|
|
@@ -305,6 +305,10 @@ export const webextSubmitCommand = {
|
|
|
305
305
|
.option('timeout', {
|
|
306
306
|
description: 'Seconds to wait for the store to resolve an upload or submission (default: 600).',
|
|
307
307
|
type: 'number',
|
|
308
|
+
})
|
|
309
|
+
.option('source', {
|
|
310
|
+
description: 'AMO only: source archive for reviewers (needed when the zip is bundled or minified); attached with --submit.',
|
|
311
|
+
type: 'string',
|
|
308
312
|
})
|
|
309
313
|
.option('listing-dir', {
|
|
310
314
|
description: 'Where `webext listing` wrote store.json (default: dist/listing).',
|
|
@@ -312,6 +316,7 @@ export const webextSubmitCommand = {
|
|
|
312
316
|
})
|
|
313
317
|
.epilog('Credentials come from the environment only (see ADR 0077 § Amendment 1). Exit codes: 0 done or nothing to do, ' +
|
|
314
318
|
'1 rejected or failed, 3 accepted but unresolved (run again), 4 unverifiable. ' +
|
|
319
|
+
'AMO: without --submit the zip is only uploaded and validated (no version, no review); --submit creates the version, which enters review at once. ' +
|
|
315
320
|
'A submission stuck in review is cancelled in the Chrome dashboard (:cancelSubmission); this command never does.'),
|
|
316
321
|
handler: async (args) => {
|
|
317
322
|
const cwd = process.cwd();
|
|
@@ -322,6 +327,7 @@ export const webextSubmitCommand = {
|
|
|
322
327
|
submit: args.submit,
|
|
323
328
|
timeoutSeconds: args.timeout,
|
|
324
329
|
listingDir: args.listingDir,
|
|
330
|
+
sourceZip: args.source ? resolve(cwd, args.source) : undefined,
|
|
325
331
|
project: loadSubmitProject(cwd),
|
|
326
332
|
env: process.env,
|
|
327
333
|
out: (line) => console.log(line),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type StoreBackendFactory } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* An HS256 JWT as auth.html describes it: `iss` = API key, `jti` unique per token, `iat` now (UTC
|
|
4
|
+
* seconds), `exp` ≤ iat + 5 min. Exported for the spec, which verifies the signature itself.
|
|
5
|
+
*/
|
|
6
|
+
export declare function signJwt(key: string, secret: string, nowMs: number): string;
|
|
7
|
+
/** The error lines of a `validation` blob, whatever its exact shape. */
|
|
8
|
+
export declare function validationLines(validation: unknown): string[];
|
|
9
|
+
export declare const createAmoBackend: StoreBackendFactory;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// The addons.mozilla.org (AMO) backend: addons-server API v5, "Submission API".
|
|
2
|
+
//
|
|
3
|
+
// DOCUMENTED against https://mozilla.github.io/addons-server/topics/api/ — `auth.html`
|
|
4
|
+
// (JWT) and `addons.html` (Upload Create/Detail, Version Create/Detail, Version Sources,
|
|
5
|
+
// Add-on Detail), plus https://extensionworkshop.com/documentation/publish/source-code-submission/,
|
|
6
|
+
// read 2026-11-19. Nothing here has been sent to Mozilla yet.
|
|
7
|
+
//
|
|
8
|
+
// THE FLOW FOR AN ALREADY-EXISTING LISTED ADD-ON, and how it maps onto the three verbs:
|
|
9
|
+
//
|
|
10
|
+
// upload() POST /upload/ (multipart: upload=<zip>, channel=listed) → a uuid. The package is
|
|
11
|
+
// then VALIDATED asynchronously; {@link StoreBackend.operation} reads
|
|
12
|
+
// GET /upload/<uuid>/ until `processed` and checks `valid`. This creates NO version
|
|
13
|
+
// and enters NO review: an upload is a validated, unused package. That is the honest
|
|
14
|
+
// equivalent of Chrome's/Edge's "draft" (ADR 0148).
|
|
15
|
+
// publish() POST /addons/addon/<id>/versions/ {upload: uuid, approval_notes?}. For a LISTED
|
|
16
|
+
// channel this is what puts the version into review, which is why `submit` never
|
|
17
|
+
// calls it without `--submit`. If a source archive is given it is attached by a
|
|
18
|
+
// second request (PATCH multipart `source`), because the docs say a multipart body
|
|
19
|
+
// cannot carry the complex fields and only name `source`/`upload`/`license` there.
|
|
20
|
+
//
|
|
21
|
+
// WHAT IS NOT DOCUMENTED and is therefore a guess named as one:
|
|
22
|
+
// - the shape of `validation` ("the validation results JSON blob"): {@link validationLines}
|
|
23
|
+
// reads `messages[].message` defensively and falls back to the raw type counts;
|
|
24
|
+
// - how long an unused upload stays valid;
|
|
25
|
+
// - that GET .../versions/v<number>/ answers 404 for an unknown number (the docs give no status
|
|
26
|
+
// for it; 404 is the usual DRF reply), used for the "already there" check. The `v` prefix is
|
|
27
|
+
// DOCUMENTED: a number without a dot is otherwise read as a version id, and forces a number lookup.
|
|
28
|
+
import { createHmac, randomBytes } from 'node:crypto';
|
|
29
|
+
import { readFileSync } from 'node:fs';
|
|
30
|
+
import { basename } from 'node:path';
|
|
31
|
+
import { redactHeaders, redactSecrets, secretValuesOf, StoreApiError, StoreVersionAlreadyThereError, } from './index.js';
|
|
32
|
+
const STORE = 'amo';
|
|
33
|
+
const API_ROOT = 'https://addons.mozilla.org/api/v5';
|
|
34
|
+
/** Longest slice of vendor text a message carries. */
|
|
35
|
+
const MAX_VENDOR_TEXT = 400;
|
|
36
|
+
/** AMO accepts a JWT for at most five minutes (auth.html); a minute is plenty for one request. */
|
|
37
|
+
const JWT_LIFETIME_S = 60;
|
|
38
|
+
const AUTH_HINT = 'the JWT was rejected — check AMO_WEB_EXT_API_KEY / AMO_WEB_EXT_API_SECRET (addons.mozilla.org → Developer Hub → ' +
|
|
39
|
+
"Manage API Keys) and that this machine's clock is correct; AMO refuses a JWT whose iat/exp are off.";
|
|
40
|
+
const b64url = (input) => Buffer.from(input).toString('base64url');
|
|
41
|
+
/**
|
|
42
|
+
* An HS256 JWT as auth.html describes it: `iss` = API key, `jti` unique per token, `iat` now (UTC
|
|
43
|
+
* seconds), `exp` ≤ iat + 5 min. Exported for the spec, which verifies the signature itself.
|
|
44
|
+
*/
|
|
45
|
+
export function signJwt(key, secret, nowMs) {
|
|
46
|
+
const iat = Math.floor(nowMs / 1000);
|
|
47
|
+
const header = b64url(JSON.stringify({ alg: 'HS256', typ: 'JWT' }));
|
|
48
|
+
const payload = b64url(JSON.stringify({ iss: key, jti: randomBytes(16).toString('hex'), iat, exp: iat + JWT_LIFETIME_S }));
|
|
49
|
+
const signature = createHmac('sha256', secret).update(`${header}.${payload}`).digest();
|
|
50
|
+
return `${header}.${payload}.${b64url(signature)}`;
|
|
51
|
+
}
|
|
52
|
+
/** The error lines of a `validation` blob, whatever its exact shape. */
|
|
53
|
+
export function validationLines(validation) {
|
|
54
|
+
if (typeof validation !== 'object' || validation === null)
|
|
55
|
+
return [];
|
|
56
|
+
const messages = validation.messages;
|
|
57
|
+
if (!Array.isArray(messages))
|
|
58
|
+
return [];
|
|
59
|
+
const lines = [];
|
|
60
|
+
for (const item of messages) {
|
|
61
|
+
if (typeof item !== 'object' || item === null)
|
|
62
|
+
continue;
|
|
63
|
+
const m = item;
|
|
64
|
+
if (m.type !== undefined && m.type !== 'error')
|
|
65
|
+
continue;
|
|
66
|
+
if (typeof m.message === 'string')
|
|
67
|
+
lines.push(m.message);
|
|
68
|
+
else if (typeof m.description === 'string')
|
|
69
|
+
lines.push(m.description);
|
|
70
|
+
}
|
|
71
|
+
return lines;
|
|
72
|
+
}
|
|
73
|
+
export const createAmoBackend = (credentials, options = {}) => {
|
|
74
|
+
const addonId = credentials['AMO_ADDON_ID'];
|
|
75
|
+
const apiKey = credentials['AMO_WEB_EXT_API_KEY'];
|
|
76
|
+
const apiSecret = credentials['AMO_WEB_EXT_API_SECRET'];
|
|
77
|
+
const secrets = secretValuesOf(STORE, credentials);
|
|
78
|
+
const now = options.now ?? (() => Date.now());
|
|
79
|
+
const addon = `${API_ROOT}/addons/addon/${encodeURIComponent(addonId)}`;
|
|
80
|
+
const clean = (text) => redactSecrets(text, secrets).slice(0, MAX_VENDOR_TEXT);
|
|
81
|
+
/** State carried from `upload()` to `publish()` and `status()` within one run. */
|
|
82
|
+
let lastUpload = null;
|
|
83
|
+
async function send(method, url, extra = {}, acceptable = []) {
|
|
84
|
+
const headers = { Authorization: `JWT ${signJwt(apiKey, apiSecret, now())}` };
|
|
85
|
+
let body;
|
|
86
|
+
if (extra.json !== undefined) {
|
|
87
|
+
headers['Content-Type'] = 'application/json';
|
|
88
|
+
body = JSON.stringify(extra.json);
|
|
89
|
+
}
|
|
90
|
+
else if (extra.form !== undefined) {
|
|
91
|
+
// No Content-Type: fetch sets the multipart boundary itself.
|
|
92
|
+
body = extra.form;
|
|
93
|
+
}
|
|
94
|
+
options.log?.(`${method} ${url} ${JSON.stringify(redactHeaders(headers))}`);
|
|
95
|
+
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
96
|
+
let response;
|
|
97
|
+
try {
|
|
98
|
+
response = await fetchImpl(url, { method, headers, body });
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
throw new StoreApiError(STORE, undefined, clean(error instanceof Error ? error.message : String(error)));
|
|
102
|
+
}
|
|
103
|
+
options.log?.(` → HTTP ${response.status}`);
|
|
104
|
+
if ((response.status >= 200 && response.status < 300) || acceptable.includes(response.status))
|
|
105
|
+
return response;
|
|
106
|
+
const text = await response.text().catch(() => '');
|
|
107
|
+
throw new StoreApiError(STORE, response.status, failureDetail(response.status, text));
|
|
108
|
+
}
|
|
109
|
+
function failureDetail(status, text) {
|
|
110
|
+
const body = clean(text.trim());
|
|
111
|
+
const said = body === '' ? '' : ` Store said: ${body}`;
|
|
112
|
+
if (status === 401)
|
|
113
|
+
return AUTH_HINT + said;
|
|
114
|
+
if (status === 403)
|
|
115
|
+
return `the account is not an author of ${clean(addonId)}, or lacks permission.${said}`;
|
|
116
|
+
if (status === 404)
|
|
117
|
+
return `unknown add-on or version — check AMO_ADDON_ID (slug, numeric id or GUID).${said}`;
|
|
118
|
+
if (status === 429)
|
|
119
|
+
return 'throttled — too many requests; retry later.';
|
|
120
|
+
return body === '' ? 'the store gave no reason.' : body;
|
|
121
|
+
}
|
|
122
|
+
async function json(response, what) {
|
|
123
|
+
try {
|
|
124
|
+
return JSON.parse(await response.text());
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
throw new StoreApiError(STORE, response.status, `${what} answered something that is not JSON.`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function versionExists(version) {
|
|
131
|
+
const response = await send('GET', `${addon}/versions/v${encodeURIComponent(version)}/`, {}, [404]);
|
|
132
|
+
return response.status !== 404;
|
|
133
|
+
}
|
|
134
|
+
/** Classifies a finished validation: throws for a refusal, returns for a valid package. */
|
|
135
|
+
function judge(body, version) {
|
|
136
|
+
if (body.valid === true)
|
|
137
|
+
return;
|
|
138
|
+
const lines = validationLines(body.validation).map(clean);
|
|
139
|
+
if (lines.some((line) => /already exists/i.test(line)))
|
|
140
|
+
throw new StoreVersionAlreadyThereError(STORE, version);
|
|
141
|
+
throw new StoreApiError(STORE, 200, lines.length === 0
|
|
142
|
+
? 'AMO validation rejected the package and gave no message.'
|
|
143
|
+
: `AMO validation rejected the package: ${lines.join(' | ')}`);
|
|
144
|
+
}
|
|
145
|
+
async function upload(input) {
|
|
146
|
+
if (await versionExists(input.version))
|
|
147
|
+
throw new StoreVersionAlreadyThereError(STORE, input.version);
|
|
148
|
+
const form = new FormData();
|
|
149
|
+
form.append('upload', new Blob([new Uint8Array(readFileSync(input.zipPath))]), basename(input.zipPath));
|
|
150
|
+
form.append('channel', 'listed');
|
|
151
|
+
const response = await send('POST', `${API_ROOT}/addons/upload/`, { form });
|
|
152
|
+
const body = await json(response, 'the upload');
|
|
153
|
+
if (typeof body.uuid !== 'string' || body.uuid === '') {
|
|
154
|
+
throw new StoreApiError(STORE, response.status, 'the upload answered without a uuid.');
|
|
155
|
+
}
|
|
156
|
+
lastUpload = { uuid: body.uuid, version: input.version };
|
|
157
|
+
if (body.processed === true) {
|
|
158
|
+
judge(body, input.version);
|
|
159
|
+
return {
|
|
160
|
+
operationId: body.uuid,
|
|
161
|
+
ingested: true,
|
|
162
|
+
detail: `upload ${body.uuid} validated; no version created.`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
operationId: body.uuid,
|
|
167
|
+
ingested: false,
|
|
168
|
+
detail: `HTTP ${response.status} — upload ${body.uuid} is being validated.`,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async function operation(kind, operationId, version) {
|
|
172
|
+
if (kind !== 'upload') {
|
|
173
|
+
throw new StoreApiError(STORE, undefined, 'AMO has no publish operation to read; a version create answers directly.');
|
|
174
|
+
}
|
|
175
|
+
const response = await send('GET', `${API_ROOT}/addons/upload/${encodeURIComponent(operationId)}/`);
|
|
176
|
+
const body = await json(response, 'the upload detail');
|
|
177
|
+
if (body.processed !== true) {
|
|
178
|
+
return { state: 'in-progress', detail: `upload ${operationId} is still being validated.` };
|
|
179
|
+
}
|
|
180
|
+
judge(body, version ?? body.version ?? 'in the upload');
|
|
181
|
+
return { state: 'succeeded', detail: `upload ${operationId} passed validation; no version created yet.` };
|
|
182
|
+
}
|
|
183
|
+
async function publish(input) {
|
|
184
|
+
if (lastUpload === null) {
|
|
185
|
+
throw new StoreApiError(STORE, undefined, 'publish needs an upload from this run; none was made.');
|
|
186
|
+
}
|
|
187
|
+
const created = await send('POST', `${addon}/versions/`, {
|
|
188
|
+
json: {
|
|
189
|
+
upload: lastUpload.uuid,
|
|
190
|
+
...(input.notes === undefined || input.notes === '' ? {} : { approval_notes: input.notes }),
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
const version = await json(created, 'the version create');
|
|
194
|
+
const ref = version.id ?? input.version;
|
|
195
|
+
if (input.sourceZip !== undefined) {
|
|
196
|
+
const form = new FormData();
|
|
197
|
+
form.append('source', new Blob([new Uint8Array(readFileSync(input.sourceZip))]), basename(input.sourceZip));
|
|
198
|
+
await send('PATCH', `${addon}/versions/${encodeURIComponent(String(ref))}/`, { form });
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
state: 'in-review',
|
|
202
|
+
detail: `HTTP ${created.status} — version ${input.version} created from upload ${lastUpload.uuid}, which puts it into review` +
|
|
203
|
+
(input.sourceZip === undefined ? ' (no source archive attached).' : '; source archive attached.'),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
async function status() {
|
|
207
|
+
if (lastUpload === null) {
|
|
208
|
+
const response = await send('GET', `${addon}/`);
|
|
209
|
+
const body = await json(response, 'the add-on detail');
|
|
210
|
+
return {
|
|
211
|
+
state: 'unknown',
|
|
212
|
+
version: body.current_version?.version,
|
|
213
|
+
detail: `AMO reports ${body.current_version?.version ?? 'no public version'} as the current version.`,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const { version } = lastUpload;
|
|
217
|
+
const response = await send('GET', `${addon}/versions/v${encodeURIComponent(version)}/`, {}, [404]);
|
|
218
|
+
if (response.status === 404) {
|
|
219
|
+
return { state: 'draft', version, detail: `AMO has no version ${version}; only a validated upload.` };
|
|
220
|
+
}
|
|
221
|
+
const body = await json(response, 'the version detail');
|
|
222
|
+
const fileStatus = body.file?.status;
|
|
223
|
+
return {
|
|
224
|
+
state: fileStatus === 'public' ? 'published' : 'in-review',
|
|
225
|
+
version,
|
|
226
|
+
detail: `AMO has version ${version} with file status ${clean(String(fileStatus))}.`,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
async function verifyCredentials() {
|
|
230
|
+
await send('GET', `${addon}/`);
|
|
231
|
+
}
|
|
232
|
+
return { store: STORE, upload, publish, status, operation, verifyCredentials };
|
|
233
|
+
};
|
|
@@ -92,7 +92,7 @@ export declare class StoreCredentialsMissingError extends Error {
|
|
|
92
92
|
readonly missing: readonly StoreCredentialField[];
|
|
93
93
|
constructor(store: StoreId, missing: readonly StoreCredentialField[]);
|
|
94
94
|
}
|
|
95
|
-
/** A store with a row and no backend —
|
|
95
|
+
/** A store with a row and no backend — a store declared before its file exists. */
|
|
96
96
|
export declare class StoreUnsupportedError extends Error {
|
|
97
97
|
readonly store: StoreId;
|
|
98
98
|
constructor(store: StoreId, detail: string);
|
|
@@ -198,8 +198,10 @@ export interface StorePublishInput {
|
|
|
198
198
|
readonly version: string;
|
|
199
199
|
/** What Chrome calls a staged rollout; a backend whose store has none refuses a value below 100. */
|
|
200
200
|
readonly deployPercentage?: number;
|
|
201
|
-
/** Edge's
|
|
201
|
+
/** Edge's certification `notes`, AMO's `approval_notes` for the reviewers. Stores that take no note ignore it. */
|
|
202
202
|
readonly notes?: string;
|
|
203
|
+
/** AMO only: a source archive attached to the version, for bundled or minified code. Absolute path. */
|
|
204
|
+
readonly sourceZip?: string;
|
|
203
205
|
}
|
|
204
206
|
/**
|
|
205
207
|
* What every store backend answers to. Three verbs, because that is what both
|
|
@@ -231,7 +233,7 @@ export interface StoreBackendOptions {
|
|
|
231
233
|
/** A store's backend factory, registered in {@link STORE_BACKENDS}. */
|
|
232
234
|
export type StoreBackendFactory = (credentials: StoreCredentials, options?: StoreBackendOptions) => StoreBackend;
|
|
233
235
|
/**
|
|
234
|
-
* Backend per store.
|
|
236
|
+
* Backend per store. Registered here rather than as an import side
|
|
235
237
|
* effect of each backend file, so a backend is never silently missing.
|
|
236
238
|
*/
|
|
237
239
|
export declare const STORE_BACKENDS: Partial<Record<StoreId, StoreBackendFactory>>;
|
|
@@ -239,7 +241,6 @@ export declare const STORE_BACKENDS: Partial<Record<StoreId, StoreBackendFactory
|
|
|
239
241
|
* The backend for a store, with its credentials resolved from `env`.
|
|
240
242
|
*
|
|
241
243
|
* The order matters: a store with no backend is refused BEFORE credentials are
|
|
242
|
-
* read, so
|
|
243
|
-
* variables it would not use.
|
|
244
|
+
* read, so it says "not implemented" rather than asking for variables it would not use.
|
|
244
245
|
*/
|
|
245
246
|
export declare function createStoreBackend(store: StoreId, env: EnvLike, options?: StoreBackendOptions): StoreBackend;
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
// {@link redactSecrets} first. `publish-readback.ts`'s rule carries over
|
|
26
26
|
// unchanged: never claim what was not established.
|
|
27
27
|
// The import cycle with `edge.ts` is safe: it uses this file's exports only inside functions.
|
|
28
|
+
import { createAmoBackend } from './amo.js';
|
|
28
29
|
import { createChromeBackend } from './chrome.js';
|
|
29
30
|
import { createEdgeBackend } from './edge.js';
|
|
30
31
|
export const STORE_IDS = ['chrome', 'edge', 'amo'];
|
|
@@ -58,21 +59,24 @@ export const STORE_CREDENTIALS = {
|
|
|
58
59
|
{ env: 'EDGE_ADDONS_API_KEY', secret: true, what: 'the API key sent as `Authorization: ApiKey …`' },
|
|
59
60
|
],
|
|
60
61
|
/**
|
|
61
|
-
* AMO
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* keeps calling `web-ext`, which reads these two itself — they are listed so
|
|
65
|
-
* nobody adds a second spelling later.
|
|
62
|
+
* AMO's Submission API signs a JWT with an API key and secret (addons-server `auth.html`).
|
|
63
|
+
* `web-ext` reads `WEB_EXT_API_KEY`/`WEB_EXT_API_SECRET` for the same pair; the `AMO_` prefix
|
|
64
|
+
* keeps this table's one-prefix-per-store convention and lets a CI map either name onto it.
|
|
66
65
|
*/
|
|
67
66
|
amo: [
|
|
68
|
-
{ env: '
|
|
69
|
-
{
|
|
67
|
+
{ env: 'AMO_ADDON_ID', secret: false, what: 'the add-on slug, numeric id or GUID of the existing listing' },
|
|
68
|
+
{
|
|
69
|
+
env: 'AMO_WEB_EXT_API_KEY',
|
|
70
|
+
secret: false,
|
|
71
|
+
what: 'the AMO JWT issuer (API key, `user:…`) — also in every token payload',
|
|
72
|
+
},
|
|
73
|
+
{ env: 'AMO_WEB_EXT_API_SECRET', secret: true, what: 'the AMO JWT secret' },
|
|
70
74
|
],
|
|
71
75
|
};
|
|
72
76
|
export const STORES = {
|
|
73
77
|
chrome: { id: 'chrome', label: 'Chrome Web Store', implemented: true, createsListings: false },
|
|
74
78
|
edge: { id: 'edge', label: 'Edge Add-ons', implemented: true, createsListings: false },
|
|
75
|
-
amo: { id: 'amo', label: 'addons.mozilla.org', implemented:
|
|
79
|
+
amo: { id: 'amo', label: 'addons.mozilla.org', implemented: true, createsListings: false },
|
|
76
80
|
};
|
|
77
81
|
/** `id` as a {@link StoreId}, or null — the caller owns the message, same contract as `parseWebextTarget`'s callers. */
|
|
78
82
|
export function asStoreId(id) {
|
|
@@ -168,7 +172,7 @@ export class StoreCredentialsMissingError extends Error {
|
|
|
168
172
|
this.name = 'StoreCredentialsMissingError';
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
|
-
/** A store with a row and no backend —
|
|
175
|
+
/** A store with a row and no backend — a store declared before its file exists. */
|
|
172
176
|
export class StoreUnsupportedError extends Error {
|
|
173
177
|
store;
|
|
174
178
|
constructor(store, detail) {
|
|
@@ -232,26 +236,24 @@ export function isIdempotentSkip(error) {
|
|
|
232
236
|
return error instanceof StoreVersionAlreadyThereError || error instanceof StoreInReviewError;
|
|
233
237
|
}
|
|
234
238
|
/**
|
|
235
|
-
* Backend per store.
|
|
239
|
+
* Backend per store. Registered here rather than as an import side
|
|
236
240
|
* effect of each backend file, so a backend is never silently missing.
|
|
237
241
|
*/
|
|
238
242
|
export const STORE_BACKENDS = {
|
|
239
243
|
chrome: createChromeBackend,
|
|
240
244
|
edge: createEdgeBackend,
|
|
245
|
+
amo: createAmoBackend,
|
|
241
246
|
};
|
|
242
247
|
/**
|
|
243
248
|
* The backend for a store, with its credentials resolved from `env`.
|
|
244
249
|
*
|
|
245
250
|
* The order matters: a store with no backend is refused BEFORE credentials are
|
|
246
|
-
* read, so
|
|
247
|
-
* variables it would not use.
|
|
251
|
+
* read, so it says "not implemented" rather than asking for variables it would not use.
|
|
248
252
|
*/
|
|
249
253
|
export function createStoreBackend(store, env, options) {
|
|
250
254
|
const factory = STORE_BACKENDS[store];
|
|
251
255
|
if (factory === undefined) {
|
|
252
|
-
throw new StoreUnsupportedError(store,
|
|
253
|
-
? 'use `gjsify webext sign` for AMO; this slice ships the Chrome and Edge backends only (ADR 0077 § Amendment 1)'
|
|
254
|
-
: 'no backend is registered for it');
|
|
256
|
+
throw new StoreUnsupportedError(store, 'no backend is registered for it');
|
|
255
257
|
}
|
|
256
258
|
return factory(resolveStoreCredentials(store, env), options);
|
|
257
259
|
}
|
|
@@ -17,6 +17,8 @@ export interface SubmitCommandInput {
|
|
|
17
17
|
readonly timeoutSeconds?: number;
|
|
18
18
|
/** Where `webext listing` wrote its output (default `dist/listing` under the project root). */
|
|
19
19
|
readonly listingDir?: string;
|
|
20
|
+
/** AMO only: a source archive for the reviewers, attached when a version is created (`--submit`). */
|
|
21
|
+
readonly sourceZip?: string;
|
|
20
22
|
readonly project: SubmitProject;
|
|
21
23
|
readonly env: EnvLike;
|
|
22
24
|
readonly createBackend?: (store: StoreId, env: EnvLike, options?: StoreBackendOptions) => StoreBackend;
|
|
@@ -16,16 +16,17 @@ import { join, resolve } from 'node:path';
|
|
|
16
16
|
import { asStoreId, createStoreBackend, redactSecrets, STORE_CREDENTIALS, StoreUnsupportedError, STORES, } from './stores/index.js';
|
|
17
17
|
import { driveSubmission, SUBMIT_EXIT_CODES } from './stores/poll.js';
|
|
18
18
|
/** `webext listing` names the Chrome store `cws`. */
|
|
19
|
-
const LISTING_STORE = { chrome: 'cws', edge: 'edge' };
|
|
19
|
+
const LISTING_STORE = { chrome: 'cws', edge: 'edge', amo: 'amo' };
|
|
20
20
|
export function isTagRef(ref) {
|
|
21
21
|
return ref !== undefined && ref.startsWith('refs/tags/') && ref.length > 'refs/tags/'.length;
|
|
22
22
|
}
|
|
23
23
|
/** The zip `webext zip` writes for this store's target (see `buildWebext`). */
|
|
24
24
|
export function defaultZipPath(project, store) {
|
|
25
|
-
const
|
|
25
|
+
const browser = store === 'amo' ? 'firefox' : store;
|
|
26
|
+
const target = project.targets.find((t) => t.browser === browser);
|
|
26
27
|
if (target === undefined) {
|
|
27
|
-
throw new Error(`gjsify webext submit: gjsify.webext.targets has no ${
|
|
28
|
-
`Add ${
|
|
28
|
+
throw new Error(`gjsify webext submit: gjsify.webext.targets has no ${browser} target, so there is no zip to derive. ` +
|
|
29
|
+
`Add ${browser}-mv3 or pass --zip.`);
|
|
29
30
|
}
|
|
30
31
|
return join(project.outDir, `${project.name}-${project.version}-${target.id}.zip`);
|
|
31
32
|
}
|
|
@@ -88,11 +89,11 @@ export async function runSubmit(input) {
|
|
|
88
89
|
throw new Error(`gjsify webext submit: unknown store "${input.store}".`);
|
|
89
90
|
const descriptor = STORES[store];
|
|
90
91
|
if (!descriptor.implemented) {
|
|
91
|
-
throw new StoreUnsupportedError(store, '
|
|
92
|
+
throw new StoreUnsupportedError(store, 'no backend is registered for it');
|
|
92
93
|
}
|
|
93
94
|
if (input.submit && !isTagRef(env['GITHUB_REF'])) {
|
|
94
95
|
throw new Error('gjsify webext submit: --submit asks the store for review and runs only on a tag ' +
|
|
95
|
-
'($GITHUB_REF must start with refs/tags/). Without --submit the zip is uploaded
|
|
96
|
+
'($GITHUB_REF must start with refs/tags/). Without --submit the zip is uploaded (AMO: validated, no version created).');
|
|
96
97
|
}
|
|
97
98
|
let timeoutMs;
|
|
98
99
|
if (input.timeoutSeconds !== undefined) {
|
|
@@ -114,6 +115,16 @@ export async function runSubmit(input) {
|
|
|
114
115
|
if (pre.manual.length > 0)
|
|
115
116
|
out(` by hand in the dashboard: ${pre.manual.join(', ')}`);
|
|
116
117
|
const zipPath = resolve(input.zip ?? defaultZipPath(project, store));
|
|
118
|
+
const sourceZip = input.sourceZip === undefined ? undefined : resolve(input.sourceZip);
|
|
119
|
+
if (sourceZip !== undefined && store !== 'amo') {
|
|
120
|
+
throw new Error('gjsify webext submit: --source applies to AMO only; Chrome and Edge take no source archive.');
|
|
121
|
+
}
|
|
122
|
+
if (sourceZip !== undefined && !input.submit) {
|
|
123
|
+
throw new Error('gjsify webext submit: --source is attached to the version, which only --submit creates; add --submit or drop --source.');
|
|
124
|
+
}
|
|
125
|
+
if (sourceZip !== undefined && !input.dryRun && !existsSync(sourceZip)) {
|
|
126
|
+
throw new Error(`gjsify webext submit: the source archive ${sourceZip} does not exist.`);
|
|
127
|
+
}
|
|
117
128
|
if (!input.dryRun && !existsSync(zipPath)) {
|
|
118
129
|
throw new Error(`gjsify webext submit: ${zipPath} does not exist. Run \`gjsify webext zip\` first or pass --zip.`);
|
|
119
130
|
}
|
|
@@ -132,7 +143,7 @@ export async function runSubmit(input) {
|
|
|
132
143
|
const result = await driveSubmission({
|
|
133
144
|
backend,
|
|
134
145
|
upload: { zipPath, version: project.version },
|
|
135
|
-
publish: input.submit ? { version: project.version } : undefined,
|
|
146
|
+
publish: input.submit ? { version: project.version, sourceZip } : undefined,
|
|
136
147
|
}, { timeoutMs, sleep: input.sleep, now: input.now, log, secrets });
|
|
137
148
|
const write = result.exitCode === 0 ? out : err;
|
|
138
149
|
for (const line of describeResult(result, descriptor.label))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/cli",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.50",
|
|
4
4
|
"description": "CLI for Gjsify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -142,22 +142,22 @@
|
|
|
142
142
|
"cli"
|
|
143
143
|
],
|
|
144
144
|
"dependencies": {
|
|
145
|
-
"@gjsify/blueprint": "0.64.
|
|
146
|
-
"@gjsify/buffer": "0.64.
|
|
147
|
-
"@gjsify/create-app": "0.64.
|
|
148
|
-
"@gjsify/node-globals": "0.64.
|
|
149
|
-
"@gjsify/node-polyfills": "0.64.
|
|
150
|
-
"@gjsify/npm-registry": "0.64.
|
|
151
|
-
"@gjsify/resolve-npm": "0.64.
|
|
152
|
-
"@gjsify/rolldown-plugin-gjsify": "0.64.
|
|
153
|
-
"@gjsify/vite-plugin-blueprint": "0.64.
|
|
154
|
-
"@gjsify/rolldown-plugin-pnp": "0.64.
|
|
155
|
-
"@gjsify/semver": "0.64.
|
|
156
|
-
"@gjsify/tar": "0.64.
|
|
157
|
-
"@gjsify/tsc": "0.64.
|
|
158
|
-
"@gjsify/utils": "0.64.
|
|
159
|
-
"@gjsify/web-polyfills": "0.64.
|
|
160
|
-
"@gjsify/workspace": "0.64.
|
|
145
|
+
"@gjsify/blueprint": "0.64.50",
|
|
146
|
+
"@gjsify/buffer": "0.64.50",
|
|
147
|
+
"@gjsify/create-app": "0.64.50",
|
|
148
|
+
"@gjsify/node-globals": "0.64.50",
|
|
149
|
+
"@gjsify/node-polyfills": "0.64.50",
|
|
150
|
+
"@gjsify/npm-registry": "0.64.50",
|
|
151
|
+
"@gjsify/resolve-npm": "0.64.50",
|
|
152
|
+
"@gjsify/rolldown-plugin-gjsify": "0.64.50",
|
|
153
|
+
"@gjsify/vite-plugin-blueprint": "0.64.50",
|
|
154
|
+
"@gjsify/rolldown-plugin-pnp": "0.64.50",
|
|
155
|
+
"@gjsify/semver": "0.64.50",
|
|
156
|
+
"@gjsify/tar": "0.64.50",
|
|
157
|
+
"@gjsify/tsc": "0.64.50",
|
|
158
|
+
"@gjsify/utils": "0.64.50",
|
|
159
|
+
"@gjsify/web-polyfills": "0.64.50",
|
|
160
|
+
"@gjsify/workspace": "0.64.50",
|
|
161
161
|
"acorn": "^8.17.0",
|
|
162
162
|
"cosmiconfig": "^9.0.2",
|
|
163
163
|
"get-tsconfig": "^4.14.0",
|
|
@@ -166,13 +166,13 @@
|
|
|
166
166
|
"yargs": "^18.0.0"
|
|
167
167
|
},
|
|
168
168
|
"devDependencies": {
|
|
169
|
-
"@gjsify/unit": "0.64.
|
|
169
|
+
"@gjsify/unit": "0.64.50",
|
|
170
170
|
"@types/yargs": "^17.0.35",
|
|
171
171
|
"typescript": "^6.0.3"
|
|
172
172
|
},
|
|
173
173
|
"peerDependencies": {
|
|
174
|
-
"@gjsify/oxfmt-native": "0.64.
|
|
175
|
-
"@gjsify/rolldown-native": "0.64.
|
|
174
|
+
"@gjsify/oxfmt-native": "0.64.50",
|
|
175
|
+
"@gjsify/rolldown-native": "0.64.50"
|
|
176
176
|
},
|
|
177
177
|
"peerDependenciesMeta": {
|
|
178
178
|
"@gjsify/oxfmt-native": {
|
|
@@ -191,6 +191,5 @@
|
|
|
191
191
|
"bugs": {
|
|
192
192
|
"url": "https://github.com/gjsify/gjsify/issues"
|
|
193
193
|
},
|
|
194
|
-
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/infra/cli#readme"
|
|
195
|
-
"gitHead": "c61ed1ad2d0c4bacbd6a1652663d5bfbf2fca47b"
|
|
194
|
+
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/infra/cli#readme"
|
|
196
195
|
}
|