diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64b3f83a6..d91bbad1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -278,6 +278,8 @@ jobs: run: npm run test:focused -- src/application/NibNativeHierarchy.test.ts - name: Real binary metadata and Interface Builder integration run: npm run verify:apple-dispatch && npm run verify:interface-builder + - name: Native plist CLI selection regressions + run: npm run test:focused -- tests/boundary/cli/nativePlistCli.test.ts reconstruction-readiness: name: Reconstruction readiness diff --git a/src/cli/utilityCommands.ts b/src/cli/utilityCommands.ts index d5b723d01..d0758f26e 100644 --- a/src/cli/utilityCommands.ts +++ b/src/cli/utilityCommands.ts @@ -143,7 +143,7 @@ const registerNativeCommands = (cli: CliInstance, logger: Logger): void => { runProviderAnalysis( args.path, "inspect_plist", - { relative_path: options.relativePath }, + { path: options.relativePath }, logger, ), ), diff --git a/tests/boundary/cli/nativePlistCli.test.ts b/tests/boundary/cli/nativePlistCli.test.ts new file mode 100644 index 000000000..eca99cac5 --- /dev/null +++ b/tests/boundary/cli/nativePlistCli.test.ts @@ -0,0 +1,64 @@ +import { mkdir, writeFile } from "node:fs/promises"; +import { join } from "node:path"; + +import { describe, expect } from "vitest"; + +import { thinMach } from "../../../src/domain/binaryTarget.fixture.js"; +import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; +import { cliTest } from "../../support/cli/cliFixture.js"; + +describe.skipIf(process.platform !== "darwin")( + "native plist CLI selection", + () => { + cliTest.for([ + ["default", undefined, "default"], + ["alternate", "Contents/Alternate.plist", "alternate"], + ["missing", "Contents/Missing.plist", undefined], + ] as const)( + "honors the $0 plist selection", + async ([, selected, identifier], { cli }) => { + const directory = await createTestTempDirectory("rea-plist-cli-"); + const app = join(directory, "Example.app"); + const contents = join(app, "Contents"); + await mkdir(join(contents, "MacOS"), { recursive: true }); + await writeFile( + join(contents, "MacOS/App"), + thinMach(0xfeedfacf, 0x0100000c), + ); + for (const [name, value] of [ + ["Info", "default"], + ["Alternate", "alternate"], + ]) { + await writeFile( + join(contents, `${name}.plist`), + `CFBundleExecutableAppCFBundleIdentifier${value}`, + ); + } + const result = await cli.run({ + arguments: [ + "inspect-plist", + app, + ...(selected === undefined ? [] : ["--relative-path", selected]), + "--json", + ], + environment: { + REA_LOG_LEVEL: "silent", + REA_ANALYSIS_PROVIDER: "auto", + }, + }); + if (identifier === undefined) { + expect(result.exitCode).toBe(1); + expect(result.json).toMatchObject({ error: "Analysis failed" }); + } else { + expect(result.exitCode).toBe(0); + expect(result.json).toMatchObject({ + normalized_result: { + source_path: join(app, selected ?? "Contents/Info.plist"), + value: { CFBundleIdentifier: identifier }, + }, + }); + } + }, + ); + }, +);