nobj-build-nw
A tool to build applications for the NW platform. Features:
- Installable as devDependencies with just one line
- Joins + Obfuscates closures for NodeJS context
- Joins + Obfuscates code, css, assets for Local Webapps
- Compiles 100% of NodeJS context to bytecode using ByteNode (arch dependent)
- Compiles 100% of local webapps to bytecode using NWJC (arch / plaf dependent)
- Builds distribution packages for OSX and Windows
Installing
1 - Install the tool
- Declare the dependency in ```devDependencies````
npm install nobj-build-nw@53.1.37 --save-dev
You will get the package inserted into devDependencies
"devDependencies": {
"nobj-build-nw": "^53.1.37"
}
- NW.JS version are the first two numbers: 53.1 means NWJS 0.53.1
- Minor is the tool revision for the NWJS Version
- Your package.json has to match this version number or compiled binaries will not work.
2 - Add scripts to package.json
You can declare the following scripts in the parent project for ease of use:
"scripts": {
"build": "nobj-nw-build",
"build:osx-x64": "nobj-nw-build-plaf osx x64",
"build:win-x64": "nobj-nw-build-plaf win x64",
"dist:osx-x64": "nobj-nw-dist osx x64",
"dist:win-x64": "nobj-nw-dist win x64",
"sign:osx": "nobj-nw-sign-osx dist/$npm_package_name-$npm_package_version-mac-x64/Holopoke.app",
"proto:osx": "nobj-nw-proto-osx dist/$npm_package_name-$npm_package_version-mac-x64/Holopoke.app"
}
3 - Setup deployment in package.json
- The tool uses
nw-builder-phoenix
internally, so check out the documentation to configure the deployment. Use this as an example:
"build": {
"appId": "my.cool.application",
"nwVersion": "0.53.1",
"nwFlavor": "normal",
"output": "./dist/",
"packed": false,
"targets": [
"nsis"
],
"files": [
"bin/**",
"app/**"
],
"ffmpegIntegration": false,
"mac": {
"name": "MyApp",
"displayName": "MyApp",
"copyright": "Copyright (C) Disaster Might Happen",
"icon": "dist.src/osx/icon-1024.icns"
},
"win": {
"productName": "MyApp",
"companyName": "NDisaster Might Happen",
"copyright": "Copyright (C) Disaster Might Happen",
"icon": "dist.src/win/icon.ico"
},
"nsis": {
"icon": "dist.src/win/icon.ico",
"solid": true
}
}
4. Create the manifest
Manifest is in .template
file. This file is parsed by nobj-build-tools, that are used internally
to buld the different modules.
export TEMPLATE=default
# Closure Compiler Mode
export CCMODE="--language_out=ECMASCRIPT_2018 --language_in=ECMASCRIPT_2018"
# Apple Certificate
export APPLECF_NAME="xxxxxxx"
export APPLECF_ID="xxxxxxxx"
# NW Version
export NW_VERSION=0.53.1
# Local Apps to build
export BUILD_APPS="\
git@bitbucket.org:user/repo-app-1 app-1
git@bitbucket.org:user/repo-app-2 app-2
git@bitbucket.org:user/repo-lib-1 lib-1
.
.
"
- Each entry in BUILD_APPS will download that application, and build it using
nobj-build-tools
. - Later steps compile each application into bytecode.
Invoking the scripts
After the .template
file is created, you can run the scripts.
npm run build
- Builds the non-arch-dependent part of the applications
npm run build:osx-x64 / npm run build:win-x64
Builds the arch-dependent part of the applications
- Compiles the source code into Bytecode.
- Run after
npm run build
- CROSS-COMPILING IS NOT SUPPORTED, due to the fact that NWJC does not support cross-compilation: You can only generate bytecode for the current platform.
npm run dist:osx-x64 / npm run dist:win-x64
- Creates the distribution packages under dist/
- Will also prepare and sign the application
npm run sign:osx
- Signs the OSX application with credentials supplied in .template
- Called automatically by
dist
npm run proto:osx
- Adds functionality to the application manifest such as Custom Protocol Mappings
- Called automatically by
dist
Dependencies
- To sign OSX applications, you need
XCODE
pre-installed, as it uses codesign
. - To run under windows, you need CygWin pre-installed. Also suggested is to use a decent terminal other than the one included with Windows.
Work in progress
This is a work in progress and several features still don´t work, but will do soon:
- Code Signing for Windows.
- Code Signing for mac works barebones. Probably there are more files to sign, or refine the codesign parameters.
- Add the Custom Protocol for Windows.
- Windows NSIS target does not boot. Seems a packaging issue as the uncompressed target does work)
Copyright
(C) 2018-2021 Nebular Streams.
License: CC 4.0 Attribution Sharealike