From 67a8437b3bad65e0c0938055581e4ceb53a77870 Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Sat, 22 Feb 2025 16:14:20 -0800 Subject: [PATCH] rename `createTestApp` to `createStagingAppDir` and add jsdoc to the function --- test/index.spec.ts | 16 +++++++++------- test/util.ts | 8 ++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/index.spec.ts b/test/index.spec.ts index 0f69187..f901b20 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import { makeUniversalApp } from '../dist/cjs/index'; import { - createTestApp, + createStagingAppDir, generateNativeApp, templateApp, VERIFY_APP_TIMEOUT, @@ -150,7 +150,7 @@ describe('makeUniversalApp', () => { 'should not inject ElectronAsarIntegrity into `infoPlistsToIgnore`', async () => { const arm64AppPath = await templateApp('Arm64-1.app', 'arm64', async (appPath) => { - const { testPath } = await createTestApp('Arm64-1'); + const { testPath } = await createStagingAppDir('Arm64-1'); await createPackage(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app.asar')); await templateApp('SubApp-1.app', 'arm64', async (subArm64AppPath) => { await fs.move( @@ -160,7 +160,7 @@ describe('makeUniversalApp', () => { }); }); const x64AppPath = await templateApp('X64-1.app', 'x64', async (appPath) => { - const { testPath } = await createTestApp('X64-1'); + const { testPath } = await createStagingAppDir('X64-1'); await createPackage(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app.asar')); await templateApp('SubApp-1.app', 'x64', async (subArm64AppPath) => { await fs.move( @@ -186,7 +186,7 @@ describe('makeUniversalApp', () => { 'should shim asars with different unpacked dirs', async () => { const arm64AppPath = await templateApp('UnpackedArm64.app', 'arm64', async (appPath) => { - const { testPath } = await createTestApp('UnpackedAppArm64'); + const { testPath } = await createStagingAppDir('UnpackedAppArm64'); await createPackageWithOptions( testPath, path.resolve(appPath, 'Contents', 'Resources', 'app.asar'), @@ -198,7 +198,7 @@ describe('makeUniversalApp', () => { }); const x64AppPath = await templateApp('UnpackedX64.app', 'x64', async (appPath) => { - const { testPath } = await createTestApp('UnpackedAppX64'); + const { testPath } = await createStagingAppDir('UnpackedAppX64'); await createPackageWithOptions( testPath, path.resolve(appPath, 'Contents', 'Resources', 'app.asar'), @@ -237,14 +237,16 @@ describe('makeUniversalApp', () => { 'should shim two different app folders', async () => { const arm64AppPath = await templateApp('ShimArm64.app', 'arm64', async (appPath) => { - const { testPath } = await createTestApp('shimArm64', { + const { testPath } = await createStagingAppDir('shimArm64', { 'i-aint-got-no-rhythm.bin': 'boomshakalaka', }); await fs.copy(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app')); }); const x64AppPath = await templateApp('ShimX64.app', 'x64', async (appPath) => { - const { testPath } = await createTestApp('shimX64', { 'hello-world.bin': 'Hello World' }); + const { testPath } = await createStagingAppDir('shimX64', { + 'hello-world.bin': 'Hello World', + }); await fs.copy(testPath, path.resolve(appPath, 'Contents', 'Resources', 'app')); }); diff --git a/test/util.ts b/test/util.ts index a43106d..ab7a685 100644 --- a/test/util.ts +++ b/test/util.ts @@ -116,6 +116,10 @@ export const removeUnstableProperties = (data: any) => { }; /** + * Creates an app directory at runtime for usage: + * - `testPath` can be used with `asar.createPackage`. Just set the output `.asar` path to `Test.app/Contents/Resources/.asar` + * - `testPath` can be utilized for logic paths involving `AsarMode.NO_ASAR` and copied directly to `Test.app/Contents/Resources` + * * Directory structure: * testName * ├── private @@ -127,7 +131,7 @@ export const removeUnstableProperties = (data: any) => { * ├── index.js * ├── package.json */ -export const createTestApp = async ( +export const createStagingAppDir = async ( testName: string | undefined, additionalFiles: Record = {}, ) => { @@ -202,7 +206,7 @@ export const generateNativeApp = async (options: { if (!fs.existsSync(resourcesApp)) { await fs.mkdir(resourcesApp); } - const { testPath } = await createTestApp( + const { testPath } = await createStagingAppDir( path.basename(appNameWithExtension, '.app'), additionalFiles, );