@@ -2,16 +2,12 @@ import * as fs from 'fs-extra';
22import * as path from 'path' ;
33
44import { makeUniversalApp } from '../dist/cjs/index' ;
5- import {
6- appsPath ,
7- appsOutPath ,
8- createTestApp ,
9- templateApp ,
10- VERIFY_APP_TIMEOUT ,
11- verifyApp ,
12- } from './util' ;
5+ import { createTestApp , templateApp , VERIFY_APP_TIMEOUT , verifyApp } from './util' ;
136import { createPackage , createPackageWithOptions } from '@electron/asar' ;
147
8+ const appsPath = path . resolve ( __dirname , 'fixtures' , 'apps' ) ;
9+ const appsOutPath = path . resolve ( __dirname , 'fixtures' , 'apps' , 'out' ) ;
10+
1511// See `jest.setup.ts` for app fixture setup process
1612describe ( 'makeUniversalApp' , ( ) => {
1713 afterEach ( async ( ) => {
@@ -160,110 +156,128 @@ describe('makeUniversalApp', () => {
160156 } ,
161157 VERIFY_APP_TIMEOUT ,
162158 ) ;
163- it ( 'should generate AsarIntegrity for all asars in the application' , async ( ) => {
164- const { testPath } = await createTestApp ( 'app-2' ) ;
165- const testAsarPath = path . resolve ( appsOutPath , 'app-2.asar' ) ;
166- await createPackage ( testPath , testAsarPath ) ;
167159
168- const arm64AppPath = await templateApp ( 'Arm64-2.app' , 'arm64' , async ( appPath ) => {
169- await fs . copyFile ( testAsarPath , path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ) ;
170- await fs . copyFile (
171- testAsarPath ,
172- path . resolve ( appPath , 'Contents' , 'Resources' , 'webapp.asar' ) ,
173- ) ;
174- } ) ;
175- const x64AppPath = await templateApp ( 'X64-2.app' , 'x64' , async ( appPath ) => {
176- await fs . copyFile ( testAsarPath , path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ) ;
177- await fs . copyFile (
178- testAsarPath ,
179- path . resolve ( appPath , 'Contents' , 'Resources' , 'webbapp.asar' ) ,
180- ) ;
181- } ) ;
182- const outAppPath = path . resolve ( appsOutPath , 'MultipleAsars.app' ) ;
160+ // TODO: Investigate if this should even be allowed.
161+ // Current logic detects all unpacked files as APP_CODE, which doesn't seem correct since it could also be a macho file requiring lipo
162+ // https://github.com/electron/universal/blob/d90d573ccf69a5b14b91aa818c8b97e0e6840399/src/file-utils.ts#L48-L49
163+ it . skip (
164+ 'should shim asars with different unpacked dirs' ,
165+ async ( ) => {
166+ const arm64AppPath = await templateApp ( 'UnpackedArm64.app' , 'arm64' , async ( appPath ) => {
167+ const { testPath } = await createTestApp ( 'UnpackedAppArm64' ) ;
168+ await createPackageWithOptions (
169+ testPath ,
170+ path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ,
171+ {
172+ unpackDir : 'var' ,
173+ unpack : '*.txt' ,
174+ } ,
175+ ) ;
176+ } ) ;
183177
184- it (
185- 'should shim asars with different unpacked dirs' ,
186- async ( ) => {
187- const arm64AppPath = await templateApp ( 'UnpackedArm64.app' , 'arm64' , async ( appPath ) => {
188- const { testPath } = await createTestApp ( 'UnpackedAppArm64' ) ;
189- await createPackageWithOptions (
190- testPath ,
191- path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ,
192- {
193- unpackDir : 'var' ,
194- unpack : '*.txt' ,
195- } ,
196- ) ;
197- } ) ;
178+ const x64AppPath = await templateApp ( 'UnpackedX64.app' , 'x64' , async ( appPath ) => {
179+ const { testPath } = await createTestApp ( 'UnpackedAppX64' ) ;
180+ await createPackageWithOptions (
181+ testPath ,
182+ path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ,
183+ { } ,
184+ ) ;
185+ } ) ;
198186
199- const x64AppPath = await templateApp ( 'UnpackedX64.app' , 'x64' , async ( appPath ) => {
200- const { testPath } = await createTestApp ( 'UnpackedAppX64' ) ;
201- await createPackageWithOptions (
202- testPath ,
203- path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ,
204- { } ,
205- ) ;
206- } ) ;
187+ const outAppPath = path . resolve ( appsOutPath , 'UnpackedDir.app' ) ;
188+ await makeUniversalApp ( {
189+ x64AppPath,
190+ arm64AppPath,
191+ outAppPath,
192+ } ) ;
193+ await verifyApp ( outAppPath ) ;
194+ } ,
195+ VERIFY_APP_TIMEOUT ,
196+ ) ;
207197
208- const outAppPath = path . resolve ( appsOutPath , 'UnpackedDir.app' ) ;
209- await makeUniversalApp ( {
210- x64AppPath,
211- arm64AppPath,
212- outAppPath,
213- mergeASARs : true ,
214- } ) ;
215- await verifyApp ( outAppPath ) ;
216- } ,
217- VERIFY_APP_TIMEOUT ,
218- ) ;
219- } ) ;
198+ it (
199+ 'should generate AsarIntegrity for all asars in the application' ,
200+ async ( ) => {
201+ const { testPath } = await createTestApp ( 'app-2' ) ;
202+ const testAsarPath = path . resolve ( appsOutPath , 'app-2.asar' ) ;
203+ await createPackage ( testPath , testAsarPath ) ;
220204
221- describe ( 'no asar mode' , ( ) => {
222- it (
223- 'should correctly merge two identical app folders' ,
224- async ( ) => {
225- const out = path . resolve ( appsOutPath , 'MergedNoAsar.app' ) ;
226- await makeUniversalApp ( {
227- x64AppPath : path . resolve ( appsPath , 'X64NoAsar.app' ) ,
228- arm64AppPath : path . resolve ( appsPath , 'Arm64NoAsar.app' ) ,
229- outAppPath : out ,
230- } ) ;
231- await verifyApp ( out ) ;
232- } ,
233- VERIFY_APP_TIMEOUT ,
234- ) ;
205+ const arm64AppPath = await templateApp ( 'Arm64-2.app' , 'arm64' , async ( appPath ) => {
206+ await fs . copyFile (
207+ testAsarPath ,
208+ path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ,
209+ ) ;
210+ await fs . copyFile (
211+ testAsarPath ,
212+ path . resolve ( appPath , 'Contents' , 'Resources' , 'webapp.asar' ) ,
213+ ) ;
214+ } ) ;
215+ const x64AppPath = await templateApp ( 'X64-2.app' , 'x64' , async ( appPath ) => {
216+ await fs . copyFile (
217+ testAsarPath ,
218+ path . resolve ( appPath , 'Contents' , 'Resources' , 'app.asar' ) ,
219+ ) ;
220+ await fs . copyFile (
221+ testAsarPath ,
222+ path . resolve ( appPath , 'Contents' , 'Resources' , 'webbapp.asar' ) ,
223+ ) ;
224+ } ) ;
225+ const outAppPath = path . resolve ( appsOutPath , 'MultipleAsars.app' ) ;
226+ await makeUniversalApp ( {
227+ x64AppPath,
228+ arm64AppPath,
229+ outAppPath,
230+ mergeASARs : true ,
231+ } ) ;
232+ await verifyApp ( outAppPath ) ;
233+ } ,
234+ VERIFY_APP_TIMEOUT ,
235+ ) ;
236+ } ) ;
235237
236- it (
237- 'should shim two different app folders' ,
238- async ( ) => {
239- const arm64AppPath = await templateApp ( 'ShimArm64.app' , 'arm64' , async ( appPath ) => {
240- const { testPath } = await createTestApp ( 'shimArm64' , {
241- 'i-aint-got-no-rhythm.bin' : 'boomshakalaka' ,
242- } ) ;
243- await fs . copy ( testPath , path . resolve ( appPath , 'Contents' , 'Resources' , 'app' ) ) ;
244- } ) ;
238+ describe ( 'no asar mode' , ( ) => {
239+ it (
240+ 'should correctly merge two identical app folders' ,
241+ async ( ) => {
242+ const out = path . resolve ( appsOutPath , 'MergedNoAsar.app' ) ;
243+ await makeUniversalApp ( {
244+ x64AppPath : path . resolve ( appsPath , 'X64NoAsar.app' ) ,
245+ arm64AppPath : path . resolve ( appsPath , 'Arm64NoAsar.app' ) ,
246+ outAppPath : out ,
247+ } ) ;
248+ await verifyApp ( out ) ;
249+ } ,
250+ VERIFY_APP_TIMEOUT ,
251+ ) ;
245252
246- const x64AppPath = await templateApp ( 'ShimX64.app' , 'x64' , async ( appPath ) => {
247- const { testPath } = await createTestApp ( 'shimX64' , {
248- 'hello-world.bin' : 'Hello World' ,
249- } ) ;
250- await fs . copy ( testPath , path . resolve ( appPath , 'Contents' , 'Resources' , 'app' ) ) ;
253+ it (
254+ 'should shim two different app folders' ,
255+ async ( ) => {
256+ const arm64AppPath = await templateApp ( 'ShimArm64.app' , 'arm64' , async ( appPath ) => {
257+ const { testPath } = await createTestApp ( 'shimArm64' , {
258+ 'i-aint-got-no-rhythm.bin' : 'boomshakalaka' ,
251259 } ) ;
260+ await fs . copy ( testPath , path . resolve ( appPath , 'Contents' , 'Resources' , 'app' ) ) ;
261+ } ) ;
252262
253- const outAppPath = path . resolve ( appsOutPath , 'ShimNoAsar.app' ) ;
254- await makeUniversalApp ( {
255- x64AppPath,
256- arm64AppPath,
257- outAppPath,
258- } ) ;
259- await verifyApp ( outAppPath ) ;
260- } ,
261- VERIFY_APP_TIMEOUT ,
262- ) ;
263- } ) ;
263+ const x64AppPath = await templateApp ( 'ShimX64.app' , 'x64' , async ( appPath ) => {
264+ const { testPath } = await createTestApp ( 'shimX64' , { 'hello-world.bin' : 'Hello World' } ) ;
265+ await fs . copy ( testPath , path . resolve ( appPath , 'Contents' , 'Resources' , 'app' ) ) ;
266+ } ) ;
264267
265- // TODO: Add tests for
266- // * different app dirs with different macho files
267- // * identical app dirs with universal macho files
268+ const outAppPath = path . resolve ( appsOutPath , 'ShimNoAsar.app' ) ;
269+ await makeUniversalApp ( {
270+ x64AppPath,
271+ arm64AppPath,
272+ outAppPath,
273+ } ) ;
274+ await verifyApp ( outAppPath ) ;
275+ } ,
276+ VERIFY_APP_TIMEOUT ,
277+ ) ;
268278 } ) ;
279+
280+ // TODO: Add tests for
281+ // * different app dirs with different macho files
282+ // * identical app dirs with universal macho files
269283} ) ;
0 commit comments