Skip to content

Commit

Permalink
replace decompress-zip with adm-zip
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondkmp committed Jul 18, 2024
1 parent 4202527 commit d2f9a56
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 138 deletions.
112 changes: 9 additions & 103 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"builder-util-runtime": "workspace:*",
"chalk": "^4.1.2",
"ci-info": "^3.7.0",
"decompress-zip": "^0.3.3",
"adm-zip":"0.5.14",
"depcheck": "1.4.3",
"dmg-builder": "workspace:*",
"electron-builder": "workspace:*",
Expand Down
28 changes: 13 additions & 15 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { addValue, deepAssign, exec, log, spawn, getPath7x, getPath7za, copyDir, FileCopier, USE_HARD_LINKS, walk } from "builder-util"
import { CancellationToken, UpdateFileInfo } from "builder-util-runtime"
import { executeFinally } from "builder-util"
import DecompressZip from "decompress-zip"
import { Arch, ArtifactCreated, Configuration, DIR_TARGET, getArchSuffix, MacOsTargetName, Packager, PackagerOptions, Platform, Target } from "electron-builder"
import { PublishManager } from "app-builder-lib"
import { computeArchToTargetNamesMap } from "app-builder-lib/out/targets/targetFactory"
Expand Down Expand Up @@ -390,28 +389,24 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp
}

const packageFile = artifacts.find(it => it.file.endsWith("-full.nupkg"))!.file
const unZipper = new DecompressZip(packageFile)
const fileDescriptors = await unZipper.getFiles()

// we test app-update.yml separately, don't want to complicate general assert (yes, it is not good that we write app-update.yml for squirrel.windows if we build nsis and squirrel.windows in parallel, but as squirrel.windows is deprecated, it is ok)
const AdmZip = require("adm-zip")
const zip = new AdmZip(packageFile)
const zipEntries = zip.getEntries()
const files = pathSorter(
fileDescriptors
.map(it => toSystemIndependentPath(it.path))
zipEntries
.map((it: any) => toSystemIndependentPath(it.entryName))
.filter(
it =>
(it: string) =>
(!it.startsWith("lib/net45/locales/") || it === "lib/net45/locales/en-US.pak") && !it.endsWith(".psmdcp") && !it.endsWith("app-update.yml") && !it.includes("/inspector/")
)
)

expect(files).toMatchSnapshot()

if (checkOptions == null) {
await unZipper.extractFile(fileDescriptors.filter(it => it.path === "TestApp.nuspec")[0], {
path: path.dirname(packageFile),
})
const expectedSpec = (await fs.readFile(path.join(path.dirname(packageFile), "TestApp.nuspec"), "utf8")).replace(/\r\n/g, "\n")
// console.log(expectedSpec)
expect(expectedSpec).toEqual(`<?xml version="1.0"?>
for (const entry of zipEntries) {
if (entry.entryName === "TestApp.nuspec") {
const expectedSpec = entry.getData().toString("utf8").replace(/\r\n/g, "\n")
expect(expectedSpec).toEqual(`<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>TestApp</id>
Expand All @@ -426,6 +421,9 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp
<projectUrl>http://foo.example.com</projectUrl>
</metadata>
</package>`)
return
}
}
}
}

Expand Down
19 changes: 0 additions & 19 deletions test/typings/decompress-zip.d.ts

This file was deleted.

0 comments on commit d2f9a56

Please sign in to comment.