Skip to content

Commit d90d573

Browse files
authored
test: add test should shim asars with different unpacked dirs (#125)
1 parent 7c0ad6c commit d90d573

3 files changed

Lines changed: 211 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
test:
1616
name: Test
1717
strategy:
18+
fail-fast: false
1819
matrix:
1920
node-version:
2021
- '20.5'

test/__snapshots__/index.spec.ts.snap

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,180 @@ exports[`makeUniversalApp asar mode should not inject ElectronAsarIntegrity into
273273
}
274274
`;
275275

276+
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 1`] = `
277+
{
278+
"files": {
279+
"index.js": {
280+
"integrity": {
281+
"algorithm": "SHA256",
282+
"blockSize": 4194304,
283+
"blocks": [
284+
"0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
285+
],
286+
"hash": "0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
287+
},
288+
"size": 66,
289+
},
290+
"package.json": {
291+
"integrity": {
292+
"algorithm": "SHA256",
293+
"blockSize": 4194304,
294+
"blocks": [
295+
"d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
296+
],
297+
"hash": "d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
298+
},
299+
"size": 41,
300+
},
301+
"private": {
302+
"files": {
303+
"var": {
304+
"files": {
305+
"app": {
306+
"files": {
307+
"file.txt": {
308+
"link": "private/var/file.txt",
309+
},
310+
},
311+
},
312+
"file.txt": {
313+
"integrity": {
314+
"algorithm": "SHA256",
315+
"blockSize": 4194304,
316+
"blocks": [
317+
"b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
318+
],
319+
"hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
320+
},
321+
"size": 11,
322+
"unpacked": true,
323+
},
324+
},
325+
},
326+
},
327+
},
328+
"var": {
329+
"link": "private/var",
330+
},
331+
},
332+
}
333+
`;
334+
335+
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 2`] = `
336+
{
337+
"files": {
338+
"index.js": {
339+
"integrity": {
340+
"algorithm": "SHA256",
341+
"blockSize": 4194304,
342+
"blocks": [
343+
"0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
344+
],
345+
"hash": "0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
346+
},
347+
"size": 66,
348+
},
349+
"package.json": {
350+
"integrity": {
351+
"algorithm": "SHA256",
352+
"blockSize": 4194304,
353+
"blocks": [
354+
"d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
355+
],
356+
"hash": "d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
357+
},
358+
"size": 41,
359+
},
360+
"private": {
361+
"files": {
362+
"var": {
363+
"files": {
364+
"app": {
365+
"files": {
366+
"file.txt": {
367+
"link": "private/var/file.txt",
368+
},
369+
},
370+
},
371+
"file.txt": {
372+
"integrity": {
373+
"algorithm": "SHA256",
374+
"blockSize": 4194304,
375+
"blocks": [
376+
"b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
377+
],
378+
"hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
379+
},
380+
"size": 11,
381+
},
382+
},
383+
},
384+
},
385+
},
386+
"var": {
387+
"link": "private/var",
388+
},
389+
},
390+
}
391+
`;
392+
393+
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 3`] = `
394+
{
395+
"files": {
396+
"index.js": {
397+
"integrity": {
398+
"algorithm": "SHA256",
399+
"blockSize": 4194304,
400+
"blocks": [
401+
"b7e5f58d3c0fddc1a57d1279a7f19a34a01784f4036920d4b60a1e33f6d1635b",
402+
],
403+
"hash": "b7e5f58d3c0fddc1a57d1279a7f19a34a01784f4036920d4b60a1e33f6d1635b",
404+
},
405+
"size": 1068,
406+
},
407+
"package.json": {
408+
"integrity": {
409+
"algorithm": "SHA256",
410+
"blockSize": 4194304,
411+
"blocks": [
412+
"2873266521e41d58d02e7acfbbbdb046edfa04b6ce262b8987de8e8548671fc7",
413+
],
414+
"hash": "2873266521e41d58d02e7acfbbbdb046edfa04b6ce262b8987de8e8548671fc7",
415+
},
416+
"size": 33,
417+
},
418+
},
419+
}
420+
`;
421+
422+
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 4`] = `
423+
[
424+
{
425+
"content": "hello world",
426+
"name": "private/var/file.txt",
427+
},
428+
]
429+
`;
430+
431+
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 5`] = `
432+
{
433+
"Contents/Info.plist": {
434+
"Resources/app-arm64.asar": {
435+
"algorithm": "SHA256",
436+
"hash": "c7563e17e768e508045ffb888935d50dbf785bbba3ffb0068e5472fda4f6c199",
437+
},
438+
"Resources/app-x64.asar": {
439+
"algorithm": "SHA256",
440+
"hash": "7e6af4d00f4cc737eff922e2b386128a269f80887b79a011022f1276bdbe7832",
441+
},
442+
"Resources/app.asar": {
443+
"algorithm": "SHA256",
444+
"hash": "b62aaaed07ff72dc33da1720d900e0443c060285ef374ce1bdaef1d4f28b5fe4",
445+
},
446+
},
447+
}
448+
`;
449+
276450
exports[`makeUniversalApp force packages successfully if \`out\` bundle already exists and \`force\` is \`true\` 1`] = `
277451
{
278452
"files": {

test/index.spec.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33

44
import { makeUniversalApp } from '../dist/cjs/index';
55
import { createTestApp, templateApp, VERIFY_APP_TIMEOUT, verifyApp } from './util';
6-
import { createPackage } from '@electron/asar';
6+
import { createPackage, createPackageWithOptions } from '@electron/asar';
77

88
const appsPath = path.resolve(__dirname, 'fixtures', 'apps');
99
const appsOutPath = path.resolve(__dirname, 'fixtures', 'apps', 'out');
@@ -156,6 +156,41 @@ describe('makeUniversalApp', () => {
156156
},
157157
VERIFY_APP_TIMEOUT,
158158
);
159+
160+
it(
161+
'should shim asars with different unpacked dirs',
162+
async () => {
163+
const arm64AppPath = await templateApp('UnpackedArm64.app', 'arm64', async (appPath) => {
164+
const { testPath } = await createTestApp('UnpackedAppArm64');
165+
await createPackageWithOptions(
166+
testPath,
167+
path.resolve(appPath, 'Contents', 'Resources', 'app.asar'),
168+
{
169+
unpackDir: 'var',
170+
unpack: '*.txt',
171+
},
172+
);
173+
});
174+
175+
const x64AppPath = await templateApp('UnpackedX64.app', 'x64', async (appPath) => {
176+
const { testPath } = await createTestApp('UnpackedAppX64');
177+
await createPackageWithOptions(
178+
testPath,
179+
path.resolve(appPath, 'Contents', 'Resources', 'app.asar'),
180+
{},
181+
);
182+
});
183+
184+
const outAppPath = path.resolve(appsOutPath, 'UnpackedDir.app');
185+
await makeUniversalApp({
186+
x64AppPath,
187+
arm64AppPath,
188+
outAppPath,
189+
});
190+
await verifyApp(outAppPath);
191+
},
192+
VERIFY_APP_TIMEOUT,
193+
);
159194
});
160195

161196
describe('no asar mode', () => {

0 commit comments

Comments
 (0)