Skip to content

Commit

Permalink
test: update to test uploading a source code
Browse files Browse the repository at this point in the history
The `adm-zip` has some flaw so we cannot generate good JS files (see
cthackers/adm-zip#526). Therefore I do a
patch. We should remove the patch once the issue is fixed.
  • Loading branch information
wdzeng committed Aug 16, 2024
1 parent 5d6209a commit 857d0fa
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"overrides": {
"hasown": "npm:@nolyfill/hasown@^1",
"is-core-module": "npm:@nolyfill/is-core-module@^1"
},
"patchedDependencies": {
"adm-zip": "patches/adm-zip.patch"
}
}
}
16 changes: 16 additions & 0 deletions patches/adm-zip.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/zipFile.js b/zipFile.js
index 234f6cdbfa954c077c31000459e0d7c22c1533f4..39e23f1a9662b2ccff6eef96761bca0f93c9998e 100644
--- a/zipFile.js
+++ b/zipFile.js
@@ -294,7 +294,10 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {

mainHeader.size = 0;
mainHeader.offset = 0;
- totalEntries = 0;
+
+ // A fix of https://github.com/cthackers/adm-zip/issues/526.
+ // TODO: Drop the patch once the issue is resolved.
+ let totalEntries = 0;

for (const entry of this.entries) {
// compress data and set local and entry header accordingly. Reason why is called first
27 changes: 16 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function updateVersionAndSaveZip(zipPath: string): void {
const minute = now.getMinutes()
const seconds = now.getSeconds()
const version = `${year.toString().slice(-2)}.${month}${toTwoDigit(date)}.${hour}${toTwoDigit(minute)}.${seconds}`
core.debug(`Set version to ${version}`)

// @ts-expect-error: JSON.parse accepts buffer.
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand Down Expand Up @@ -63,7 +62,16 @@ async function main() {
const uuid = await uploadXpi(xpiPath, jwtToken, selfHosted)
const approvalNotes = 'general update'
const releaseNotes = { 'zh-TW': 'improve performance' }
await updateAddon(addonGuid, license, uuid, jwtToken, approvalNotes, releaseNotes)
await updateAddon(
addonGuid,
license,
uuid,
jwtToken,
approvalNotes,
releaseNotes,
xpiPath, // Let the source code file be the same as the xpi file in this test.
xpiPath
)
} catch (e: unknown) {
// The test will exit with non-zero code.
handleError(e)
Expand Down

0 comments on commit 857d0fa

Please sign in to comment.