Skip to content

Commit a5ec187

Browse files
authored
Support -codesign option for macdeployqt (#40)
1 parent d3d5fbb commit a5ec187

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Currently if you need to produce a build you need to run the packer in different
2929
`npx nodegui-packer --pack <path to dist>`
3030

3131
This command essential takes the dist folder as the input and puts it in the suitable location inside the standalone executable. Also it runs the correct deployment tool (macdeployqt incase of mac, etc) and packs in the dependencies. The output of the command is found under the build directory. You should gitignore the build directory.
32+
33+
- macOS supports signing the application:
34+
35+
`npx nodegui-packer --pack <path to dist> --sign <identity>`
36+
37+
Identity should be added to the keychain and trusted first. Its value can be copied from: `security find-identity -p codesigning`
3238

3339
# How does it work ?
3440

src/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { getPacker } from "./index";
66

77
program
88
.option("-i, --init <name>", "Creates initial deploy files")
9-
.option("-p, --pack <distPath>", "Packs the app into deployable");
9+
.option("-p, --pack <distPath>", "Packs the app into deployable")
10+
.option("-s, --sign <identity>", "Signs the app during packing using identity (macOS)");
1011

1112
program.parse(process.argv);
1213
const options = program.opts();
@@ -19,5 +20,5 @@ if (program.init) {
1920
}
2021

2122
if (program.pack) {
22-
packer.pack(options.pack);
23+
packer.pack(options.pack, options.sign);
2324
}

src/darwin/index.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ const copyAppDist = async (distPath: string, resourceDir: string) => {
1919
});
2020
};
2121

22-
const runMacDeployQt = async (appName: string, buildDir: string) => {
22+
export type macDeployQtOptions = {
23+
appName: string,
24+
buildDir: string,
25+
identity?: string,
26+
}
27+
28+
const runMacDeployQt = async ({appName, buildDir, identity}: macDeployQtOptions) => {
2329
const qtHome = process.env.QT_INSTALL_DIR || qode.qtHome;
2430
const macDeployQtBin = path.resolve(qtHome, "bin", "macdeployqt");
2531
try {
@@ -30,7 +36,12 @@ const runMacDeployQt = async (appName: string, buildDir: string) => {
3036

3137
const macDeployQt = spawn(
3238
macDeployQtBin,
33-
[`${appName}.app`, "-dmg", "-verbose=3", `-libpath ${qode.qtHome}`],
39+
[`${appName}.app`,
40+
"-dmg",
41+
"-verbose=3",
42+
`-libpath ${qode.qtHome}`,
43+
...(identity ? [`-codesign=${identity}`] : [])
44+
],
3445
{ cwd: buildDir }
3546
);
3647

@@ -65,7 +76,7 @@ export const init = async (appName: string) => {
6576
await fs.writeJSON(configFile, config);
6677
};
6778

68-
export const pack = async (distPath: string) => {
79+
export const pack = async (distPath: string, identity?: string) => {
6980
const config = await fs.readJSON(
7081
path.resolve(deployDirectory, "config.json")
7182
);
@@ -86,6 +97,6 @@ export const pack = async (distPath: string) => {
8697
console.log(`copying dist`);
8798
await copyAppDist(distPath, Resources);
8899
console.log(`running macdeployqt`);
89-
await runMacDeployQt(appName, buildDir);
100+
await runMacDeployQt({ appName, buildDir, identity });
90101
console.log(`Build successful. Find the dmg/app at ${buildDir}`);
91102
};

0 commit comments

Comments
 (0)