Skip to content

Commit d30754d

Browse files
macos support (#685)
1 parent dfae361 commit d30754d

File tree

7 files changed

+98
-9
lines changed

7 files changed

+98
-9
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ npm install nw-builder
1616
## Usage
1717

1818
```javascript
19-
import nwbuild from "nw-builder";
19+
import { nwbuild } from "nw-builder";
2020

2121
nwbuild({
2222
srcDir: "./nwapp",
@@ -37,10 +37,6 @@ nwbuild({
3737
});
3838
```
3939

40-
## Team
41-
42-
This project was created by [Steffen Müller](https://github.com/steffenmllr) and has been maintained by [Gabe Paez](https://github.com/gabepaez), [Andy Trevorah](https://github.com/trevorah), [Adam Lynch](https://github.com/adam-lynch) and [Rémy Boulanouar](https://github.com/DblK) in the past. This project is currently maintained by [Ayushman Chhabra](https://github.com/ayushmxn).
43-
4440
## Contributing
4541

4642
1. Pick and install a Node version manager

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"archiver": "^5.3.1",
4444
"cli-progress": "^3.11.2",
4545
"extract-zip": "^2.0.1",
46-
"plist": "^3.0.5",
46+
"plist": "^3.0.6",
4747
"progress": "^2.0.3",
4848
"rcedit": "^3.0.1",
4949
"tar": "^6.1.11",

src/bld/osxCfg.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import fs from "node:fs/promises";
2+
3+
import plist from "plist";
4+
5+
const setOsxConfig = async (pkg, outDir) => {
6+
// Rename CFBundleDisplayName in Contents/Info.plist
7+
let contents_info_plist_path = `${outDir}/nwjs.app/Contents/Info.plist`;
8+
let contents_info_plist_json = plist.parse(
9+
await fs.readFile(contents_info_plist_path, "utf-8"),
10+
);
11+
contents_info_plist_json.CFBundleDisplayName = pkg.name;
12+
let contents_info_plist = plist.build(contents_info_plist_json);
13+
await fs.writeFile(contents_info_plist_path, contents_info_plist);
14+
15+
// Rename CFBundleDisplayName in Contents/Resources/en.lproj/InfoPlist.strings
16+
17+
// Rename Helper apps in Contents/Framework.framework/Versions/n.n.n.n/Helpers
18+
let chromium_version = "107.0.5304.88";
19+
let helper_app_path_alerts = (name = "nwjs") =>
20+
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (Alerts).app`;
21+
let helper_app_path_gpu = (name = "nwjs") =>
22+
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (GPU).app`;
23+
let helper_app_path_plugin = (name = "nwjs") =>
24+
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (Plugin).app`;
25+
let helper_app_path_renderer = (name = "nwjs") =>
26+
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (Renderer).app`;
27+
let helper_app_path = (name = "nwjs") =>
28+
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper.app`;
29+
await fs.rename(helper_app_path_alerts(), helper_app_path_alerts(pkg.name));
30+
await fs.rename(helper_app_path_gpu(), helper_app_path_gpu(pkg.name));
31+
await fs.rename(helper_app_path_plugin(), helper_app_path_plugin(pkg.name));
32+
await fs.rename(
33+
helper_app_path_renderer(),
34+
helper_app_path_renderer(pkg.name),
35+
);
36+
await fs.rename(helper_app_path(), helper_app_path(pkg.name));
37+
38+
let helper_app_alerts_plist_path = `${helper_app_path_alerts(
39+
pkg.name,
40+
)}/Contents/Info.plist`;
41+
let helper_app_gpu_plist_path = `${helper_app_path_gpu(
42+
pkg.name,
43+
)}/Contents/Info.plist`;
44+
let helper_app_plugin_plist_path = `${helper_app_path_plugin(
45+
pkg.name,
46+
)}/Contents/Info.plist`;
47+
let helper_app_render_plist_path = `${helper_app_path_renderer(
48+
pkg.name,
49+
)}/Contents/Info.plist`;
50+
let helper_app_plist_path = `${helper_app_path(
51+
pkg.name,
52+
)}/Contents/Info.plist`;
53+
54+
let helper_app_alerts_plist_json = plist.parse(
55+
await fs.readFile(helper_app_alerts_plist_path, "utf-8"),
56+
);
57+
let helper_app_gpu_plist_json = plist.parse(
58+
await fs.readFile(helper_app_gpu_plist_path, "utf-8"),
59+
);
60+
let helper_app_plugin_plist_json = plist.parse(
61+
await fs.readFile(helper_app_plugin_plist_path, "utf-8"),
62+
);
63+
let helper_app_render_plist_json = plist.parse(
64+
await fs.readFile(helper_app_render_plist_path, "utf-8"),
65+
);
66+
let helper_app_plist_json = plist.parse(
67+
await fs.readFile(helper_app_plist_path, "utf-8"),
68+
);
69+
70+
helper_app_alerts_plist_json.CFBundleDisplayName = pkg.name;
71+
helper_app_gpu_plist_json.CFBundleDisplayName = pkg.name;
72+
helper_app_render_plist_json.CFBundleDisplayName = pkg.name;
73+
helper_app_plugin_plist_json.CFBundleDisplayName = pkg.name;
74+
helper_app_plist_json.CFBundleDisplayName = pkg.name;
75+
76+
let helper_app_alerts_plist = plist.build(helper_app_alerts_plist_json);
77+
let helper_app_gpu_plist = plist.build(helper_app_gpu_plist_json);
78+
let helper_app_render_plist = plist.build(helper_app_render_plist_json);
79+
let helper_app_plugin_plist = plist.build(helper_app_plugin_plist_json);
80+
let helper_app_plist = plist.build(helper_app_plist_json);
81+
82+
await fs.writeFile(helper_app_alerts_plist_path, helper_app_alerts_plist);
83+
await fs.writeFile(helper_app_gpu_plist_path, helper_app_gpu_plist);
84+
await fs.writeFile(helper_app_plugin_plist_path, helper_app_plugin_plist);
85+
await fs.writeFile(helper_app_render_plist_path, helper_app_render_plist);
86+
await fs.writeFile(helper_app_plist_path, helper_app_plist);
87+
};
88+
89+
export { setOsxConfig };

src/bld/package.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "node:fs";
22

33
import { compress } from "./compress.js";
44
import { setLinuxConfig } from "./linuxCfg.js";
5+
import { setOsxConfig } from "./osxCfg.js";
56
import { setWinConfig } from "./winCfg.js";
67

78
const packager = async (srcDir, nwDir, outDir, platform, zip) => {
@@ -31,6 +32,9 @@ const packager = async (srcDir, nwDir, outDir, platform, zip) => {
3132
case "win":
3233
setWinConfig(pkg, outDir);
3334
break;
35+
case "osx":
36+
setOsxConfig(pkg, outDir);
37+
break;
3438
default:
3539
break;
3640
}

test/demo/bld.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ nwbuild({
88
platform: "linux",
99
arch: "x64",
1010
outDir: "./build",
11-
zip: true,
1211
});

test/demo/nwapp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "nwdemo",
33
"main": "index.html",
4+
"product_string": "nwdemo",
45
"nwbuild": {
56
"srcDir": "./nwapp",
67
"version": "0.70.1",
78
"flavour": "sdk",
8-
"platform": "linux",
9+
"platform": "osx",
910
"arch": "x64",
1011
"outDir": "./build",
1112
"run": true

0 commit comments

Comments
 (0)