diff --git a/README.md b/README.md index ed7176750..a698cad23 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ npm install nw-builder ## Usage ```javascript -import nwbuild from "nw-builder"; +import { nwbuild } from "nw-builder"; nwbuild({ srcDir: "./nwapp", @@ -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 diff --git a/package-lock.json b/package-lock.json index 6a4b27fda..5c78335ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,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", diff --git a/package.json b/package.json index c71ff5382..5ae1888e1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/bld/osxCfg.js b/src/bld/osxCfg.js new file mode 100644 index 000000000..fb62455c0 --- /dev/null +++ b/src/bld/osxCfg.js @@ -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 }; diff --git a/src/bld/package.js b/src/bld/package.js index ed609e8e8..039ea874d 100644 --- a/src/bld/package.js +++ b/src/bld/package.js @@ -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) => { @@ -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; } diff --git a/test/demo/bld.js b/test/demo/bld.js index 6396d3a13..4fd6d7e1d 100644 --- a/test/demo/bld.js +++ b/test/demo/bld.js @@ -8,5 +8,4 @@ nwbuild({ platform: "linux", arch: "x64", outDir: "./build", - zip: true, }); diff --git a/test/demo/nwapp/package.json b/test/demo/nwapp/package.json index 997dde60e..308ab6e92 100644 --- a/test/demo/nwapp/package.json +++ b/test/demo/nwapp/package.json @@ -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