Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos support #685

Merged
merged 5 commits into from
Nov 13, 2022
Merged
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
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ npm install nw-builder
## Usage

```javascript
import nwbuild from "nw-builder";
import { nwbuild } from "nw-builder";

nwbuild({
srcDir: "./nwapp",
Expand All @@ -37,10 +37,6 @@ nwbuild({
});
```

## Team

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).

## Contributing

1. Pick and install a Node version manager
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"archiver": "^5.3.1",
"cli-progress": "^3.11.2",
"extract-zip": "^2.0.1",
"plist": "^3.0.5",
"plist": "^3.0.6",
"progress": "^2.0.3",
"rcedit": "^3.0.1",
"tar": "^6.1.11",
Expand Down
89 changes: 89 additions & 0 deletions src/bld/osxCfg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import fs from "node:fs/promises";

import plist from "plist";

const setOsxConfig = async (pkg, outDir) => {
// Rename CFBundleDisplayName in Contents/Info.plist
let contents_info_plist_path = `${outDir}/nwjs.app/Contents/Info.plist`;
let contents_info_plist_json = plist.parse(
await fs.readFile(contents_info_plist_path, "utf-8"),
);
contents_info_plist_json.CFBundleDisplayName = pkg.name;
let contents_info_plist = plist.build(contents_info_plist_json);
await fs.writeFile(contents_info_plist_path, contents_info_plist);

// Rename CFBundleDisplayName in Contents/Resources/en.lproj/InfoPlist.strings

// Rename Helper apps in Contents/Framework.framework/Versions/n.n.n.n/Helpers
let chromium_version = "107.0.5304.88";
let helper_app_path_alerts = (name = "nwjs") =>
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (Alerts).app`;
let helper_app_path_gpu = (name = "nwjs") =>
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (GPU).app`;
let helper_app_path_plugin = (name = "nwjs") =>
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (Plugin).app`;
let helper_app_path_renderer = (name = "nwjs") =>
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper (Renderer).app`;
let helper_app_path = (name = "nwjs") =>
`${outDir}/nwjs.app/Contents/Frameworks/nwjs Framework.framework/Versions/${chromium_version}/Helpers/${name} Helper.app`;
await fs.rename(helper_app_path_alerts(), helper_app_path_alerts(pkg.name));
await fs.rename(helper_app_path_gpu(), helper_app_path_gpu(pkg.name));
await fs.rename(helper_app_path_plugin(), helper_app_path_plugin(pkg.name));
await fs.rename(
helper_app_path_renderer(),
helper_app_path_renderer(pkg.name),
);
await fs.rename(helper_app_path(), helper_app_path(pkg.name));

let helper_app_alerts_plist_path = `${helper_app_path_alerts(
pkg.name,
)}/Contents/Info.plist`;
let helper_app_gpu_plist_path = `${helper_app_path_gpu(
pkg.name,
)}/Contents/Info.plist`;
let helper_app_plugin_plist_path = `${helper_app_path_plugin(
pkg.name,
)}/Contents/Info.plist`;
let helper_app_render_plist_path = `${helper_app_path_renderer(
pkg.name,
)}/Contents/Info.plist`;
let helper_app_plist_path = `${helper_app_path(
pkg.name,
)}/Contents/Info.plist`;

let helper_app_alerts_plist_json = plist.parse(
await fs.readFile(helper_app_alerts_plist_path, "utf-8"),
);
let helper_app_gpu_plist_json = plist.parse(
await fs.readFile(helper_app_gpu_plist_path, "utf-8"),
);
let helper_app_plugin_plist_json = plist.parse(
await fs.readFile(helper_app_plugin_plist_path, "utf-8"),
);
let helper_app_render_plist_json = plist.parse(
await fs.readFile(helper_app_render_plist_path, "utf-8"),
);
let helper_app_plist_json = plist.parse(
await fs.readFile(helper_app_plist_path, "utf-8"),
);

helper_app_alerts_plist_json.CFBundleDisplayName = pkg.name;
helper_app_gpu_plist_json.CFBundleDisplayName = pkg.name;
helper_app_render_plist_json.CFBundleDisplayName = pkg.name;
helper_app_plugin_plist_json.CFBundleDisplayName = pkg.name;
helper_app_plist_json.CFBundleDisplayName = pkg.name;

let helper_app_alerts_plist = plist.build(helper_app_alerts_plist_json);
let helper_app_gpu_plist = plist.build(helper_app_gpu_plist_json);
let helper_app_render_plist = plist.build(helper_app_render_plist_json);
let helper_app_plugin_plist = plist.build(helper_app_plugin_plist_json);
let helper_app_plist = plist.build(helper_app_plist_json);

await fs.writeFile(helper_app_alerts_plist_path, helper_app_alerts_plist);
await fs.writeFile(helper_app_gpu_plist_path, helper_app_gpu_plist);
await fs.writeFile(helper_app_plugin_plist_path, helper_app_plugin_plist);
await fs.writeFile(helper_app_render_plist_path, helper_app_render_plist);
await fs.writeFile(helper_app_plist_path, helper_app_plist);
};

export { setOsxConfig };
4 changes: 4 additions & 0 deletions src/bld/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from "node:fs";

import { compress } from "./compress.js";
import { setLinuxConfig } from "./linuxCfg.js";
import { setOsxConfig } from "./osxCfg.js";
import { setWinConfig } from "./winCfg.js";

const packager = async (srcDir, nwDir, outDir, platform, zip) => {
Expand Down Expand Up @@ -31,6 +32,9 @@ const packager = async (srcDir, nwDir, outDir, platform, zip) => {
case "win":
setWinConfig(pkg, outDir);
break;
case "osx":
setOsxConfig(pkg, outDir);
break;
default:
break;
}
Expand Down
1 change: 0 additions & 1 deletion test/demo/bld.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ nwbuild({
platform: "linux",
arch: "x64",
outDir: "./build",
zip: true,
});
3 changes: 2 additions & 1 deletion test/demo/nwapp/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "nwdemo",
"main": "index.html",
"product_string": "nwdemo",
"nwbuild": {
"srcDir": "./nwapp",
"version": "0.70.1",
"flavour": "sdk",
"platform": "linux",
"platform": "osx",
"arch": "x64",
"outDir": "./build",
"run": true
Expand Down