Code Monkey home page Code Monkey logo

nwjs-shell-builder's Introduction

This repository is in maintainance mode. Bug fixes will be provided on a best effort basis. If you use this project, please consider contributing back.

nwjs application shell builder and packager

What's in here:

nwjs shell builder script

nwjs shell script builder for nwjs (node-webkit) applications.

This script can be easily integrated into your build process.

How it works

It will download nwjs 32/64bit for Linux, Windows and OSX and build for all 3 platforms from given source directory

How we use it

This script was made to help us automate nightly builds of Gisto

You can see example usage in the CI script in Gisto repository: drone.io script

Usage:

If you want/have to build on Windows machine, use: Babun as your shell. Tested on Windows 8 but should work on Windows 7 too. If you're missing an package (like ZIP), just install it via Babun with pact - a Babun provided package manager.

$ /path/to/nwjs-build.sh --help

Options:

Option Description
-h, --help Show help and usage
--version=PACKAGE_VERSION Set package version (defaults to 1.0.0)
--name=NAME Set package name (if not set - default will be used)
--src=/PATH/TO/DIR Set path to source dir
--target="2 3" Build for particular OS or all (default is to build for all targets)
Available targets:
- 0 - linux-ia32
- 1 - linux-x64
- 2 - win-ia32
- 3 - win-x64
- 4 - osx-ia32
- 5 - osx-x64
--nw=VERSION Set nwjs version to use (if not set - default will be used)
--output-dir=/PATH/TO/DIR Change output directory (if not set - default will be used)
--win-icon=/PATH/TO/FILE (For Windows target only) Path to .ico file (if not set - default will be used)
--osx-icon=/PATH/TO/FILE (For OSX target only) Path to .icns file (if not set - default will be used)
--CFBundleIdentifier=com.bundle.name (For OSX target only) Name of the bundle’s Identifier (if not set - default will be used)
--libudev (For Linux target only) Use if you want the script to handle the lack of libudev.so.0 (linux targets) as mentioned here
--build Start the build process (IMPORTANT! Must be the last parameter of the command)
--clean Clean and remove TMP directory

Examples

========================

The bare minimum to build:
$ ./path/to/nwjs-build.sh \
    --src=/home/projects/PACKAGE_NAME/src \
    --build
Clean working dir:
$ ./path/to/nwjs-build.sh \
    --clean
Build for all targets:
$ ./path/to/nwjs-build.sh \
    --src=/home/projects/PACKAGE_NAME/src \
    --output-dir=/path/to/output/the/builds \
    --name=PACKAGE_NAME \
    --win-icon=/home/projects/resorses/icon.ico \
    --osx-icon=/home/projects/resorses/icon.icns \
    --CFBundleIdentifier=com.bundle.name \
    --target="0 1 2 3 4 5" \
    --version="1.0.0" \
    --libudev \
    --nw=0.11.6 \
    --build
Build only for windows 64 and 32 bit targets:
$ ./path/to/nwjs-build.sh \
    --src=/home/projects/PACKAGE_NAME/src \
    --output-dir=/path/to/output/the/builds \
    --name=PACKAGE_NAME \
    --win-icon=/home/projects/resorses/icon.ico \
    --target="2 3" \
    --version="1.0.0" \
    --build
Build only for osx 32 bit target:
$ ./path/to/nwjs-build.sh \
    --src=/home/projects/PACKAGE_NAME/src \
    --output-dir=/path/to/output/the/builds \
    --name=PACKAGE_NAME \
    --osx-icon=/home/projects/resorses/icon.icns \
    --CFBundleIdentifier=com.bundle.name \
    --target="4" \
    --version="1.0.0" \
    --build
Build for all 64 bit:
$ ./path/to/nwjs-build.sh \
    --src=/home/projects/PACKAGE_NAME/src \
    --output-dir=/path/to/output/the/builds \
    --name=PACKAGE_NAME \
    --osx-icon=/home/projects/resorses/icon.icns \
    --win-icon=/home/projects/resorses/icon.ico \
    --CFBundleIdentifier=com.bundle.name \
    --target="1 3 5 " \
    --version="1.0.0" \
    --libudev \
    --build

NWJS packaging script (currently in BETA)

❗ Please note that this is currently in BETA and it is not affecting the build script. You may off course use it but beta warning applies with all consequenses, so don't expect it to work out-of-the-box.

  • install if not present zip, unzip, tar, git, NSIS, libxml2
  • rename config.json.sample to config.json and adjust correct paths or generate with ./pack.sh init or specify location of the config.json by adding --config=/path/to/config.json

Usage:

./pack.sh init - generate config.json with interactive CMD

./pack.sh --windows - to build Windows installers

./pack.sh --linux - to build Linux installers

./pack.sh --osx - to build OSX installers

./pack.sh --all - to build installers for all systems

./pack.sh --all --config=/path/to/config.json - to build installers for all systems but using config.json located in any other path than in root directory

./pack.sh --clean - removes the ./TMP working directory

./pack.sh --clean all - removes the ./TMP working directory and releases directory (with all the content)

Hooks:

Place hooks in ./hooks/ directory

  • file name before.sh will be executed before each build start
  • file name after.sh will be executed after packaging script is finished
  • file name after_build.sh will be executed after each platform build is finished

License

MIT

Thanks

Huge thanks to @SchizoDuckie for assisting with OSX build

nwjs-shell-builder's People

Contributors

digason avatar morsdyce avatar sanusart avatar schizoduckie avatar thejaredwilcurt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nwjs-shell-builder's Issues

bad substitution

I got a plist error. After the error message the build is exported, but when i tried to start the app it didn't work and shows a message that the app (app contents) are damaged and can't be opened. Do you have any fixes? Thanks a lot.

The output from the shell:

/Applications/nwjs-shell-builder/nwjs-build.sh: line 358: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>${PKG_NAME^}</string>
    <key>CFBundleDocumentTypes</key>
    <array/>
    <key>CFBundleExecutable</key>
    <string>node-webkit</string>
    <key>CFBundleIconFile</key>
    <string>$(echo "${OSX_RESOURCE_ICNS}" | rev | cut -d"/" -f1 | rev)</string>
    <key>CFBundleIdentifier</key>
    <string>${CFBundleIdentifier}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PKG_NAME^}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>${PKG_VERSION}</string>
    <key>CFBundleVersion</key>
    <string>${PKG_VERSION}</string>
    <key>LSFileQuarantineEnabled</key>
    <true/>
    <key>LSMinimumSystemVersion</key>
    <string>10.6.0</string>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
    <key>NSSupportsAutomaticGraphicsSwitching</key>
    <true/>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright (c) $(date +"%Y") ${PKG_NAME^}</string>
    <key>SCMRevision</key>
    <string>175484</string>
    <key>UTExportedTypeDeclarations</key>
    <array/>
</dict>
</plist>
: bad substitution

Would you be interested in an OSX .pkg building extension that works on linux?

I just created this:

And would be more than happy to create a pull request to inject it into nwjs-shell-builder

#!/bin/bash

BUILD_DIR="/var/www/deploy/TMP/osx-ia32/latest-git"
BASE_DIR="/var/www/deploy/osx" 
VERSION="1.1.3"
IDENTIFIER="tv.duckie"
APPNAME="DuckieTV"
BACKGROUND="/var/www/DuckieTV/img/duckietv.png"

rm -rf "$BASE_DIR/darwin"
mkdir -p "$BASE_DIR/darwin/flat/Resources/en.lproj"
mkdir -p "$BASE_DIR/darwin/flat/base.pkg/"
mkdir -p "$BASE_DIR/darwin/root/Applications"
cp -R $BUILD_DIR/*.* $BASE_DIR/darwin/root/Applications
cp $BACKGROUND $BASE_DIR/darwin/flat/Resources/en.lproj/background
NUM_FILES=$(find ${BASE_DIR}/darwin/root | wc -l)
INSTALL_KB_SIZE=$(du -k -s ${BASE_DIR}/darwin/root | awk '{print $1}')

cat <<EOF > ${BASE_DIR}/darwin/flat/base.pkg/PackageInfo
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<pkg-info overwrite-permissions="true" relocatable="false" identifier="${IDENTIFIER}" postinstall-action="none" version="${VERSION}" format-version="2" generator-version="InstallCmds-502 (14B25)" auth="root">
    <payload numberOfFiles="${NUM_FILES}" installKBytes="${INSTALL_KB_SIZE}"/>
    <bundle-version>
        <bundle id="${IDENTIFIER}" CFBundleIdentifier="${IDENTIFIER}" path="./Applications/DuckieTV.app" CFBundleVersion="1.3.0"/>
    </bundle-version>
    <update-bundle/>
    <atomic-update-bundle/>
    <strict-identifier/>
    <relocate/>
    <scripts/>
</pkg-info>
EOF

cat <<EOF > ${BASE_DIR}/darwin/flat/Distribution
<?xml version="1.0" encoding="utf-8"?>
<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.3" authoringToolBuild="174">
    <title>${APPNAME} ${VERSION}</title>
    <options customize="never" allow-external-scripts="no"/>
    <background file="background" alignment="bottomleft" scaling="none"/>
    <domains enable_anywhere="true"/>
    <installation-check script="pm_install_check();"/>
    <script>function pm_install_check() {
      if(!(system.compareVersions(system.version.ProductVersion,'10.5') >= 0)) {
        my.result.title = 'Failure';
        my.result.message = 'You need at least Mac OS X 10.5 to install ${APPNAME}.';
        my.result.type = 'Fatal';
        return false;
      }
      return true;
    }
    </script>
    <choices-outline>
        <line choice="choice1"/>
    </choices-outline>
    <choice id="choice1" title="base">
        <pkg-ref id="${IDENTIFIER}.base.pkg"/>
    </choice>
    <pkg-ref id="${IDENTIFIER}.base.pkg" installKBytes="${INSTALL_KB_SIZE}" version="${VERSION}" auth="Root">#base.pkg</pkg-ref>
</installer-script>
EOF

PKG_LOCATION="/var/www/deploy/osx/${APPNAME}-${VERSION}.pkg"

( cd ${BASE_DIR}/darwin/root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > ${BASE_DIR}/darwin/flat/base.pkg/Payload
mkbom -u 0 -g 80 ${BASE_DIR}/darwin/root ${BASE_DIR}/darwin/flat/base.pkg/Bom 
( cd ${BASE_DIR}/darwin/flat/ && xar --compression none -cf "${PKG_LOCATION}" * ) 
echo "osx package has been built: ${PKG_LOCATION}"

which will deliver you a nice .pkg that looks like this:
image

I'm also planning to create a win32 installer using innosetup, which we should also be able to run directly from linux using wine.

a project with binary V8 snapshot packaging

Hi all,

Just a few words to let you know that I've published a new project based on nwjs-shell-builder : https://github.com/lgodard/nwjs-node-packager

https://github.com/lgodard/nwjs-node-packager allows to package (linux, win, osx) a nwjs app with optionally binary V8 snapshot to protect/obfuscate sources, and is well maintained 😀

Feel free to post any remark and contribution to the project!

Many thanks to nwjs-shell-builder for the inspiration!

Laurent

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.