Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class Applesign {
}

addEntitlementsSync(orig: any) {
if (this.config.addEntitlements === undefined) {
if (!this.config.addEntitlements) {
return orig;
}
this.emit("message", "Adding entitlements from file");
Expand Down Expand Up @@ -480,7 +480,7 @@ class Applesign {
additionalKeychainGroups.push(this.config.customKeychainGroup);
}
const infoPlist = path.join(this.config.appdir, "Info.plist");
const plistData = plist.readFileSync(infoPlist);
const plistData = plist.readFileSync(infoPlist) as Record<string, any>;
if (this.config.bundleIdKeychainGroup) {
if (typeof this.config.bundleid === "string") {
additionalKeychainGroups.push(this.config.bundleid);
Expand Down Expand Up @@ -513,7 +513,7 @@ class Applesign {
: this.config.entitlement
? fs.readFileSync(this.config.entitlement).toString()
: plistBuild(entMacho).toString();
const ent = plist.parse(newEntitlements.trim());
const ent = plist.parse(newEntitlements.trim()) as Record<string, any>;
const shouldRenameGroups = !this.config.mobileprovision &&
!this.config.cloneEntitlements;
if (shouldRenameGroups && ent["com.apple.security.application-groups"]) {
Expand Down Expand Up @@ -876,17 +876,17 @@ class Applesign {
}
}

async unzipIPA(file: any, workdir: any): Promise<any> {
async unzipIPA(file: string, workdir: string): Promise<void> {
fchk(arguments, ["string", "string"]);
if (!file || !workdir) {
throw new Error("No output specified");
if (!file) {
throw new Error("No input file specified");
}
if (!workdir) {
throw new Error("Invalid output directory");
throw new Error("No output directory specified");
}
await this.cleanup();
this.events.emit("message", "Unzipping " + file);
return tools.unzip(file, workdir);
await tools.unzip(file, workdir);
}

/* Event Wrapper API with cb support */
Expand Down Expand Up @@ -926,7 +926,7 @@ function getExecutable(appdir: string) {
}
const plistPath = path.join(appdir, "Info.plist");
try {
const plistData = plist.readFileSync(plistPath);
const plistData = plist.readFileSync(plistPath) as Record<string, any>;
const cfBundleExecutable = plistData.CFBundleExecutable;
if (cfBundleExecutable) {
return cfBundleExecutable;
Expand Down
2 changes: 1 addition & 1 deletion lib/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ async function getMobileProvisionPlist(file: string) {
const args = ["cms", "-D", "-i", file];
res = await execProgram(getTool("security")!, args);
}
return plist.parse(res.stdout);
return plist.parse(res.stdout) as Record<string, any>;
}

async function getEntitlementsFromMobileProvision(
Expand Down
2 changes: 1 addition & 1 deletion lib/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const version = "5.0.1";
const version = "6.0.0";
export default version;
21 changes: 21 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { spawn } from "node:child_process";
import * as path from "node:path";
import * as fs from "node:fs";
import { describe, it } from "mocha";
import Applesign from "../index.js";

const mochaTimeout = 15000;
const developerCertificate = process.env.DEVCERT;
Expand All @@ -25,6 +26,26 @@ describe("API", () => {
});
*/

describe("API", () => {
describe("unzipIPA", () => {
it("should fail when the input file is missing", async () => {
const applesign = new Applesign({});
await assert.rejects(
applesign.unzipIPA("", "tmp"),
/No input file specified/,
);
});

it("should fail when the output directory is missing", async () => {
const applesign = new Applesign({});
await assert.rejects(
applesign.unzipIPA("test.ipa", ""),
/No output directory specified/,
);
});
});
});

describe("Commandline", () => {
describe("dist/bin/applesign.js", () => {
it("should fail when applesign cannot be executed", (done) => {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ts-node": {
"esm": true
},
"files": ["lib/types.d.ts"],
"include": [
// include both JS and TS sources for migration
"lib/**/*",
Expand Down
Loading