GithubHelp home page GithubHelp logo

nwjs-builder-phoenix's Introduction

nwjs-builder-phoenix npm version Standard Version

A possible solution to build and package a ready for distribution NW.js app for Windows, macOS and Linux.

Why Bother?

We already had nw-builder, but it has made little progress on the way, and nwjs-builder has been hard to continue due to personal and historic reasons.

electron-builder inspired me when I became an Electron user later, loose files excluding, various target formats, auto updater, artifacts publishing and code signing, amazing!

Although NW.js has much lesser popularity than Electron, and is really troubled by historic headaches, let's have something modern.

Features

  • Building for Windows, macOS and Linux
    • Common: zip, 7z
    • Windows: nsis, nsis7z
    • macOS: TODO
    • Linux: TODO
  • Building for different platforms concurrently
  • Configurable executable fields and icons for Windows and macOS
  • Exclusion of loose files from node_modules
  • Chrome App support
  • nwjs-ffmpeg-prebuilt integration
  • Auto Updater
  • TODO Rebuilding native modules
  • TODO Code signing
  • Ideas appreciated :)

Getting Started

  • Make sure your NW.js project has a valid package.json (e.g. generated by npm init), and have basic fields like name, description and version filled.

  • For apps destined for Mac, providing a product_string in the package.json will allow the Helper app to be renamed for you.

  • Install nwjs-builder-phoenix as a devDependencies of your NW.js project as follows:

# Optional wine for building for Windows on other platforms.
# The command may differ in different Linux distributions.
#sudo apt-get install wine
npm install nwjs-builder-phoenix --save-dev

By installing it locally, build and run commands will be available in npm scripts. You can access option lists via ./node_modules/.bin/{ build, run } --help.

DO NOT install it globally, as the command names are just too common.

  • Add build properties at the root of the package.json, for example:
// package.json
{
    "build": {
        "nwVersion": "0.14.7"
    }
}

This will specify the NW.js version we are using. See more in the following Options section.

  • Add some helper npm scripts, for example:
// package.json
{
    "scripts": {
        // Deprecated. "dist": "build --win --mac --linux --x86 --x64 --mirror https://dl.nwjs.io/ .",
        "dist": "build --tasks win-x86,win-x64,linux-x86,linux-x64,mac-x64 --mirror https://dl.nwjs.io/ .",
        "start": "run --x86 --mirror https://dl.nwjs.io/ ."
    }
}

The above code snippet enables npm run dist and npm run start/npm start. The former builds for all major platforms and both x86 and x64 arch, and the latter runs the project with x86 binaries, both with the specified version of NW.js and use specified mirror to accelerate the download.

  • Well done.

This should be the common use case, read the following Options section and FAQs if something is missing.

See also sample project and test cases for reference.

Options

Passing and managing commandline arguments can be painful. In nwjs-builder-phoenix, we configure via the build property of the package.json of your NW.js project.

Also see all available options here.

Differences to nwjs-builder

  • nwjs-builder-phoenix queries versions.json only when a symbol like lts, stable or latest is used to specify a version.
  • nwjs-builder-phoenix uses rcedit instead of node-resourcehacker, thus it's up to you to create proper .ico files with different sizes.
  • nwjs-builder-phoenix supports node.js 4.x and later versions only.
  • nwjs-builder-phoenix writes with TypeScript and benefits from strong typing and async/await functions.

Development

git clone https://github.com/evshiron/nwjs-builder-phoenix
cd nwjs-builder-phoenix
npm install

npm test

By the way, I use some custom strings in NSIS scripts which might not be fully translated, if anyone is interested in translating them into languages that aren't available, feel free to fork and send PRs.

Available Mirrors

If you have difficulties connecting to the official download source, you can specify a mirror via --mirror argument of both build and run, or by setting NWJS_MIRROR environment variable. Environment variables like HTTP_PROXY, HTTPS_PROXY and ALL_PROXY should be useful too.

License

MIT.

nwjs-builder-phoenix's People

Contributors

alexkirsz avatar ernanielyjr avatar evshiron avatar fprijate avatar kierans avatar spadarshut avatar wangzhengbo 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nwjs-builder-phoenix's Issues

Why?

Hi there,

I'm currently building a NW.js scaffolding CLI and planned on using nwjs-builder as the build tool for it. I'm actually just about to publish this package to npm/github and am now unsure whether to use nwjs-builder or this repo. I chose nwjs-builder over nw-builder as it seemed more actively maintained and had more configuration options.

I'm not entirely sure why you were not able to release a new version of nwjs-builder with the features described in this package... wouldn't it be better to have one package?

Also I'm not sure why you made the decision to not submit this as an npm package?

Are you going to drop support for nwjs-builder now?

Thanks in advance!

Builder Doesn't Work with Symlinks

{ Error: EISDIR: illegal operation on a directory, read
  cause: { Error: EISDIR: illegal operation on a directory, read errno: -21, code: 'EISDIR', syscall: 'read' },
  isOperational: true,
  errno: -21,
  code: 'EISDIR',
  syscall: 'read' }

No call stacks, when I was using lerna to link packages in the project.

nwjs cache location?

How can I find and change nwjs download directory location? nwjs-builder has an option called cache for this.

There are several problems

1、Can you pack the MAC installation package on windows?
2、packed parameter configuration error!
3、nsis parameter configuration error!

How to build Mac x64 and both x86 and x64 linux?

Thanks for all your help in the past. I would like to try to build three packages in one command, how do I get to build just one Mac OSX version (as x86 is no longer available) and both x86 and x64 versions of Linux? Is there a chance to support ignoring a 404 failure for a missing NWJS package if others exist and complete the other builds?

Currently I get a failure to build any of the above or I need to build Mac in a separate command from Linux if I want all three builds.

Unable to run tsc

When running an npm run build I get the following error:

> [email protected] build /Users/kieran/Projects/nwjs-builder-phoenix/nwjs-builder-phoenix
> tsc

src/lib/common/DownloaderBase.ts(111,53): error TS2345: Argument of type 'string | string[]' is not assignable to parameter of type 'string'.
  Type 'string[]' is not assignable to type 'string'.

npm ERR! Darwin 14.5.0
npm ERR! argv "/opt/local/bin/node" "/opt/local/bin/npm" "run" "build"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] build script 'tsc'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the nwjs-builder-phoenix package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs nwjs-builder-phoenix
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls nwjs-builder-phoenix
npm ERR! There is likely additional logging output above.

npm installed [email protected]

mac icon file ignored

I added first "icon":"app.icns" and later "icon":"app" in the mac object in the package.json file and neither of these worked, with the resulting build always keeping the default nw icon. I tried putting the app.icns file in both the app root folder and in the src/ sub folder and in both. None of these worked.

Also I cannot seem to get the dist folder to appear under the root app folder. I tried specifying output as "dist/" and ./dist/"

But I am pleased in one regard because I have a normal flavour build for the first time whereas nw-builder always gives me an sdk build whatever I do.

Enhancement to Mac pList options

nw-builder allowed more general plist options in its build process, and since switching to this project, I have a need to customize the LSUIPresentationMode key with a non-default integer value in my app, but cannot do so without manually doing it after the built is completed.

Is there any way you can add a generic default options object with just key: value combinations?

Enable GCM Flag isn't passed to nwjs when installing/running chrome app

In order for the chrome.gcm API to work with nwjs when running a chrome app, the --enable-gcm flag needs to be passed as a command line argument to the nwjs executable. Is there any way to configure the installer to pass this command line argument to nwjs when a user runs the installed executable? It would be ideal if it only passed the flag if the chrome app manifest.json file included the GCM permission, but at this point I'd settle for an option I can set manually during the build of the installer. I know I can have users create a shortcut that has the command line argument, but that is not an ideal situation. Any thoughts on how to achieve this?

Using packed: true doesn't unpack and run properly

Running the EXE on Windows extracts the packed exe, but doesn't seem to know where it was extracted to when launching, and expects it to have been extracted to its local folder, which it shouldn't be.

I only know this as after I built, after running and encountering a stalled launch, I killed the process and copied my extracted source to the local folder and once I reran it, it launched.

NSIS Bad Encoding and Unicode

Today someone told me NSIS might complain about "Bad Encoding" if Chinese characters are used in description and so on. I couldn't reproduce it but providing NSIS Unicode support might help.

But in my experiments, the provided appName remains the same weird characters (UTF-8 bytes as ANSI characters) no matter whether Unicode true is set or not.

NSIS Unicode supports UTF-8 and UTF-16LE charsets, but UTF-16LE just wouldn't parse in NSIS 3 if I was doing it in the right way, and UTF-8 was treated as ANSI.

What should I do next?

Why does "packed:true" increase the size than pacekd : false options?

Why does "packed:true" increase the size than pacekd : false options?

if i packed: false

win x64 size : 176MB

but packed: true

win x64 size : 530MB

is it okay?

my package.json

{
  "name": "tyle-v1.1",
  "version": "1.1.0",
  "main": "index.html",
  "scripts": {
    "dist": "build --win --x64 --mirror https://dl.nwjs.io/ .",
    "start": "run --x86 --mirror https://dl.nwjs.io/ ."
  },
  "author": "tyle",
  "license": "ISC",
  "description": "tyle",
  "devDependencies": {
    "nw-builder": "^3.2.0",
    "nwjs-builder-phoenix": "^1.12.1"
  },
  "chromium-args": "--allow-running-insecure-content --ignore-certificate-errors",
  "window": {
    "toolbar": true,
    "width": 1200,
    "height": 750,
    "title": "tyle",
    "icon": "./resources/icons/512x512.png"
  },
  "webkit": {
    "plugin": true
  },
  "node-remote": "*://*.tyle.io",
  "user-agent": "tyle-nw-%ver",
  "inject-js-end": "./index.js",
  "dependencies": {
    "del": "^2.2.2",
    "fs": "0.0.1-security",
    "fs-jetpack": "^0.10.2",
    "ncp": "^2.0.0",
    "os": "^0.1.1",
    "path": "^0.12.7",
    "request": "^2.79.0",
    "semver": "^5.3.0",
    "url": "^0.11.0"
  },
  "build": {
    "nwVersion": "stable",
    "output": "./build/",
    "packed": true,
    "excludes": [
      "./node_modules/nwjs-builder-phoenix/**/*",
      "./node_modules/nw-builder/**/*"
    ],
    "mac": {
      "icon": "./resources/osx/tyle_logo_electron.icns",
      "copyright": "tyle.io"
    },
    "win": {
      "icon": "./resources/windows/tyle_logo_electron.ico"
    }
  }
}

Specify arch of NW

  public static DEFAULT_OPTIONS: IDownloaderOptions = {
        platform: process.platform,
        arch: process.arch,  // <--- I need to specify the arch
        version: '0.14.7',
        flavor: 'normal',
        mirror: 'https://dl.nwjs.io/',
        useCaches: true,
        showProgress: true,
    };

Linux+packed don't work

Running the following (when packed: true)

./node_modules/.bin/build --linux --x64 .

leads to a

Starting building tasks... { tasks: [ [ 'linux', 'x64' ] ], concurrent: false }
Building for linux, x64 starts...
Fetching NW.js binary... { platform: 'linux',
  arch: 'x64',
  version: 'stable',
  flavor: 'sdk' }
Building targets...
Building directory target starts...
{ Error: EACCES: permission denied, open '$PATH/build/rogalia-0.35.0-linux-x64/nw'
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '$PATH/build/rogalia-0.35.0-linux-x64/nw' }

Option to change default directory structure

As I can see there the path to a output directory is hardcoded like this:

 const targetDir = resolve(this.dir, config.output, `${ pkg.name }-${ pkg.version }-${ platform }-${ arch }`);

Because I moved from nw-builder I have a lot of scripts which works on it's directory structure i.e.

${root}/${appname}/${platform+arch}/

which is a good for further scripting because it's not tied to a version. Sure I can make links or update my scripts to handle this, but it would be helpfull if I could just replace nw-builder without this troubles.

Thank you for your work.

Temp Files Removal

Seems like tmp module doesn't cleanup everything although I should have setGracefulCleanup and call cleanup manually.

Packed:true Build Fails for windows on Windows

When I set the option 'packed' to true, I cannot get the build to work. The compress functionality appears to add '.zip' to the temporary filename during build, and when it tries to find it to copy the package, it no longer can be found. This appears to be an issue with the '7zip-bin' package. Each time I see a filename with the name given in the not found filename with '.zip' extension appended to the filename in the Temp folder.

`Starting building tasks... { tasks: [ [ 'win', 'x86' ], [ 'win', 'x64' ] ],
concurrent: false }
Building for win, x86 starts...
Fetching NW.js binary... { platform: 'win', arch: 'x86', version: '0.22.1', flavor: 'sdk' }
Building targets...
Building directory target starts...
{ Error: ENOENT: no such file or directory, open 'C:\Users\xxx\AppData\Local\Temp\tmp-26568vQHtcVPlm7C4'
at Error (native)
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\Users\xxx\AppData\Local\Temp\tmp-26568vQHtcVPlm7C4' }

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "distwin"
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] distwin: build --win --x86 --x64 --mirror https://dl.nwjs.io/ .
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the [email protected] distwin script 'build --win --x86 --x64 --mirror https://dl.nwjs.io/ .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the QuestarStudent package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! build --win --x86 --x64 --mirror https://dl.nwjs.io/ .
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs QuestarStudent
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls QuestarStudent
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\git\sec_nwjs\npm-debug.log
`

Offline Use?

Hi, thanks for the great work so far!

I want to create different packages for different targets while being offline and was wondering if and how I could use nwjs-builder-phoenix in that scenario.
If all else fails I might set up a local mirror, but I don't know which files I need and where to put them (obviously, I don't want to clone a complete mirror site, only the required versions/targets).

Thanks for your support!
Ole.

running installer on sample project on windows leads to broken shortcuts

After modifying the build script in the package.json at nwjs-builder-phoenix/assets/project/ so it works for windows in x86, running on Windows 7 points to "C:\Program Files\nwjs-builder-phoenix\Project\Project.exe", but that directory is not created during installation. Instead, it's in C:\Users\IEUser\AppData\Local\project.

Also, is there a way to modify the generated NSIS installer to be able to provide execution arguments to the executable?

It seems that package.json/build/appId is not used

If I'm not mistaken the appId option is always set to default value via the following:

this.appId = "io.github.nwjs." + pkg.name;

and value specified in package.json/build section is being ignored.

Compress Failed on Windows

Command Line Error:
Incorrect item in listfile.
Check charset encoding and -scs switch.
C:\Users\XXXX\AppData\Local\Temp\tmp-XXXXXXXXXXXXXXXX.tmp

While extract and extractTarGz works well.

NSIS Target and Updater

  • NSIS binaries
  • wine integration
  • nsis-compat-updater
  • delta updater
    • Modern UI 2
      • welcome
      • set install dir in installer
        • read install dir from registry in updater
      • create shortcuts in Desktop and Start Menu
      • finish and launch
    • /selfDestroy
    • nsis7z integration
    • remove only installed files
  • WIP custom NSIS scripts

Remove External Config Support

Currently the external config is in a package.json-like format, and BuildConfig reads properties from package.json. In rare situations we might use external configs, but it will only make things complex in daily usage.

So I consider removing it and collect some requests before re-enabling it.

Build multiple arch/platforms at once?

nw-builder has an option

platforms: ["win32", "linux64", "linux32", "osx64"],

so I can run it once and build all required targets.
How can I achieve this?

Compatibility

Hi, sorry for the non-issue posting but I have an app that communicates with a sound engine (SuperCollider) running in localhost, alongside with a Haskell compiler. They are all wrapped in a react-app with related package.json format.

I am a bit confused about the compatibility and my search led me here, which seem to be the latest updated repo of nw.js

I'd appreciate any help
cheers

NSIS Failed on Ubuntu 16.04

When running npm test ./test/nsis-gen.js on Ubuntu 16.04 with wine installed, it says:

Processing config: Z:\home\user\Documents\nwjs-builder-phoenix\assets\nsis\nsisconf.nsh
Processing script file: "\tmp\tmp-22140uwCJrcxlTRw.nsi" (ACP)
!include: could not find: "Z:\home\user\Documents\nwjs-builder-phoenix\assets\nsis\Contrib\Language files\English.nsh"
Error in macro LANGFILE_INCLUDE_WITHDEFAULT on macroline 12
Error in macro MUI_LANGUAGEEX on macroline 15
Error in macro MUI_LANGUAGE on macroline 4
Error in script "\tmp\tmp-22140uwCJrcxlTRw.nsi" on line 53 -- aborting creation process

While wine for macOS works well. Hmm, why?

Mac packed file missing package.json and doesn't run properly

I have noticed that when I build the Mac with the 'Packed' flag (I have other concurrent builds that need packed:true), I would like them all to run, but after building, the Mac version doesn't run properly. When I checked the difference in file structure, the Mac is missing the stripped package.json file.

In the packed vs unpacked code for mac is nearly identical except for one line in the unpacked code:
await this.writeStrippedManifest(resolve(appRoot, 'package.json'), pkg, config);

With this code missing, it just launches an unconfigured version of NWJS.

Starting with 0.22.0 package for macOS is more than double the size

It seems that in 0.22 NW.js changed what is included in the download for macOS, switching to symbolic links for some of the nested folders.

Before 0.22 this is what you normally would have in the nwjs package (actual folders with content).
screenshot 2017-04-24 12 46 12

In 0.22 instead of some of the folders that it used to have now it has symbolic links.
screenshot 2017-04-24 12 45 29

In the package for the app we end up having triple of original content.
screenshot 2017-04-24 12 44 38

One copy ends up in "nwjs Framework.framework", and two more copies in "nwjs Framework.framework/Versions/Current" and "nwjs Framework.framework/Versions/A" (the original content for this distro).

InfoPlist.strings files are not updated due to use of ucs2 encoding

It seems that replacements that are supposed to happen in Builder.fixMacMeta are not happening, leaving all those InfoPlist.string files with original values.

Assuming that path variable in that operation points to something like ${name}.app/Contents/Resources/en.lproj/InfoPlist.strings here is what is what would be returned from readFileAsync, which results into regexp replacements being skipped:

> require('fs-extra-promise').readFileSync(path, {encoding: 'ucs2'})
'䙃畂摮敬楄灳慬乹浡⁥‽渢橷≳਻䙃畂摮敬敇䥴普卯牴湩⁧‽渢橷⁳㠵〮㌮㈰⸹ㄸ‬潃祰楲桧⁴〲㜱吠敨䌠牨浯畩畁桴牯ⱳ丠⹗獪挠湯牴扩瑵牯ⱳ丠摯⹥獪‮汁楲桧獴爠獥牥敶⹤㬢䌊䉆湵汤乥浡⁥‽渢橷≳਻华潃瑮捡獴獕条䑥獥牣灩楴湯㴠∠敄慴汩⁳牦浯礠畯⁲潣瑮捡獴挠湡栠汥⁰潹⁵楦汬漠瑵映牯獭洠牯⁥畱捩汫⁹湩䌠牨浯畩⹭㬢上䡓浵湡敒摡扡敬潃祰楲桧⁴‽䌢灯特杩瑨㈠㄰‷桔⁥桃潲業浵䄠瑵潨獲‬坎樮⁳潣瑮楲畢潴獲‬潎敤樮⹳䄠汬爠杩瑨⁳敲敳癲摥∮਻'

Most likely simple change from ucs2 to utf-8 or something like that in calls to readFileAsync / writeFileAsync would fix the issue:

> require('fs-extra-promise').readFileSync(path, {encoding: 'utf-8'})
'CFBundleDisplayName = "nwjs";\nCFBundleGetInfoString = "nwjs 58.0.3029.81, Copyright 2017 The Chromium Authors, NW.js contributors, Node.js. All rights reserved.";\nCFBundleName = "nwjs";\nNSContactsUsageDescription = "Details from your contacts can help you fill out forms more quickly in Chromium.";\nNSHumanReadableCopyright = "Copyright 2017 The Chromium Authors, NW.js contributors, Node.js. All rights reserved.";\n'

Beautify User Interface

Currently the progress bar won't display when running in non-TTY (e.g. test runners) and when building concurrently, I have to mute the output to keep console clean. It's not a solution though.

But I couldn't find a nice library for this, so this issue will serve as backlog and it will be appreciated if anyone has suggestions for this.

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.