Skip to content

Commit ebe1f05

Browse files
committed
fix(browser-extension): support current web-ext
1 parent 7ff84ac commit ebe1f05

2 files changed

Lines changed: 50 additions & 11 deletions

File tree

storage/framework/core/browser-extension/src/firefox-addons.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@ export interface FirefoxPublishResult {
3232
channel: 'listed' | 'unlisted'
3333
}
3434

35+
interface FirefoxSignArgsOptions {
36+
executable: string
37+
sourceDir: string
38+
artifactsDir: string
39+
channel: 'listed' | 'unlisted'
40+
timeout: number
41+
approvalTimeout: number
42+
}
43+
44+
export function firefoxSignArgs(options: FirefoxSignArgsOptions): string[] {
45+
return [
46+
options.executable,
47+
'sign',
48+
'--source-dir', options.sourceDir,
49+
'--artifacts-dir', options.artifactsDir,
50+
'--channel', options.channel,
51+
'--timeout', String(options.timeout),
52+
'--approval-timeout', String(options.approvalTimeout),
53+
'--no-input',
54+
]
55+
}
56+
3557
function resolveFirefoxAuth(options: FirefoxAddonsAuth): Required<FirefoxAddonsAuth> {
3658
const issuer = options.issuer ?? process.env.AMO_JWT_ISSUER ?? process.env.WEB_EXT_API_KEY
3759
const secret = options.secret ?? process.env.AMO_JWT_SECRET ?? process.env.WEB_EXT_API_SECRET
@@ -99,17 +121,14 @@ export async function publishFirefoxExtension(config: ExtensionConfig, options:
99121
const tempDir = await mkdtemp(join(tmpdir(), 'stacks-firefox-publish-'))
100122

101123
try {
102-
const args = [
124+
const args = firefoxSignArgs({
103125
executable,
104-
'sign',
105-
'--source-dir', sourceDir,
106-
'--artifacts-dir', artifactsDir,
107-
'--channel', store.channel ?? 'listed',
108-
'--timeout', String(options.timeout ?? 300000),
109-
'--approval-timeout', String(options.approvalTimeout ?? 0),
110-
'--no-input',
111-
'--boring',
112-
]
126+
sourceDir,
127+
artifactsDir,
128+
channel: store.channel ?? 'listed',
129+
timeout: options.timeout ?? 300000,
130+
approvalTimeout: options.approvalTimeout ?? 0,
131+
})
113132
const metadata = firefoxListingMetadata(config, store)
114133
if (metadata) {
115134
const metadataPath = join(tempDir, 'amo-metadata.json')

storage/framework/core/browser-extension/tests/store-publishing.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os'
55
import { join } from 'node:path'
66
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
77
import { ChromeWebStoreClient, chromeWebStoreServiceAccountAssertion } from '../src/chrome-web-store'
8-
import { firefoxListingMetadata, resolveWebExtExecutable } from '../src/firefox-addons'
8+
import { firefoxListingMetadata, firefoxSignArgs, resolveWebExtExecutable } from '../src/firefox-addons'
99

1010
const chromeConfig: ChromeWebStoreConfig = {
1111
publisherId: 'publisher-123',
@@ -112,4 +112,24 @@ describe('Firefox Add-ons metadata', () => {
112112
const executable = resolveWebExtExecutable(() => null)
113113
expect(executable).toEndWith('/web-ext/bin/web-ext.js')
114114
})
115+
116+
it('uses only options supported by current web-ext releases', () => {
117+
expect(firefoxSignArgs({
118+
executable: '/bin/web-ext',
119+
sourceDir: '/extension',
120+
artifactsDir: '/artifacts',
121+
channel: 'listed',
122+
timeout: 300000,
123+
approvalTimeout: 0,
124+
})).toEqual([
125+
'/bin/web-ext',
126+
'sign',
127+
'--source-dir', '/extension',
128+
'--artifacts-dir', '/artifacts',
129+
'--channel', 'listed',
130+
'--timeout', '300000',
131+
'--approval-timeout', '0',
132+
'--no-input',
133+
])
134+
})
115135
})

0 commit comments

Comments
 (0)