-
Notifications
You must be signed in to change notification settings - Fork 3
fix: exit successfully when submitting a listed add-on #91
Changes from all commits
00b2fe9
ddd6b91
61f0ad6
9bd6cf4
474c188
9cecb0e
5ff6ad7
c288c1c
8f4f88e
e92f265
8288fba
f168ec0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ const path = require('path') | |
const webExt = require('web-ext').default | ||
const defaultAddonSigner = require('sign-addon') | ||
|
||
const { allowedChannels } = require('./constants') | ||
const { verifyOptions } = require('./utils') | ||
|
||
const publish = async options => { | ||
|
@@ -24,18 +25,25 @@ const publish = async options => { | |
|
||
const { FIREFOX_API_KEY, FIREFOX_SECRET_KEY } = process.env | ||
|
||
let unsignedXpiPath | ||
const signAddon = async params => { | ||
unsignedXpiPath = params.xpiPath | ||
const unsignedXpiFile = `unsigned-${targetXpi}` | ||
fs.writeFileSync( | ||
path.join(artifactsDir, unsignedXpiFile), | ||
fs.readFileSync(params.xpiPath), | ||
) | ||
const result = await defaultAddonSigner(params) | ||
if (!result.success && result.errorCode === 'ADDON_NOT_AUTO_SIGNED') { | ||
if ( | ||
channel === allowedChannels.LISTED && | ||
!result.success && | ||
result.errorCode === 'ADDON_NOT_AUTO_SIGNED' | ||
) { | ||
result.success = true | ||
result.downloadedFiles = result.downloadedFiles || [] | ||
result.downloadedFiles = result.downloadedFiles || [unsignedXpiFile] | ||
} | ||
return result | ||
} | ||
|
||
const { success, downloadedFiles } = await webExt.cmd.sign( | ||
const { downloadedFiles } = await webExt.cmd.sign( | ||
{ | ||
apiKey: FIREFOX_API_KEY, | ||
apiSecret: FIREFOX_SECRET_KEY, | ||
|
@@ -46,14 +54,9 @@ const publish = async options => { | |
}, | ||
{ signAddon }, | ||
) | ||
if (!success) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
throw new Error( | ||
'Signing the extension failed. See the console output from web-ext sign for the validation link', | ||
) | ||
} | ||
const [xpiFile] = downloadedFiles | ||
fs.renameSync( | ||
xpiFile ? path.join(artifactsDir, xpiFile) : unsignedXpiPath, | ||
path.join(artifactsDir, xpiFile), | ||
path.join(artifactsDir, targetXpi), | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
const { fs } = require('memfs') | ||
const path = jest.requireActual('path') | ||
const fs = jest.requireActual('fs') | ||
const { vol } = require('memfs') | ||
const { ufs } = require('unionfs') | ||
|
||
module.exports = fs | ||
const { createWriteStream } = ufs | ||
ufs.createWriteStream = (...args) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addresses streamich/unionfs/issues/428 |
||
for (const _fs of ufs.fss) { | ||
try { | ||
if (_fs.existsSync(path.dirname(`${args[0]}`))) { | ||
return _fs.createWriteStream(args[0]) | ||
} | ||
} catch (e) { | ||
continue | ||
} | ||
} | ||
return createWriteStream(...args) | ||
} | ||
|
||
module.exports = ufs.use(vol).use(fs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Combining |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = jest.fn() |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
jest.mock('fs') | ||
jest.mock('web-ext') | ||
jest.mock('sign-addon') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not use
fs.copyFileSync
as it did not play well withunionfs
. See streamich/unionfs/issues/429There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's necessary to copy the file as the
defaultAddonSigner
uses a temporary folder that gets cleaned up on success or failure.