How to pack an NW.js application on Windows

I am reading instructions on how to pack the NW.js application , and the wording is confusing and does not make sense. I highlighted conflicting words, salad parts.

Create a zip file (it is built in XP, Vista and 7) Copy all your files to a zip file , keeping the directory structure and making sure that the package.json file is in the root directory (if you make a zip file containing a folder with your material in it, then it doesn’t work ) Rename the file extension from .zip to .nw. By default, file extensions may be hidden. You need (press alt), go to the folder and uncheck "Hide extensions for known file types" to rename zip.

Is there a simple step by step set of instructions for how to do this? I looked online and could not find anyone for Windows. The goal is to create an executable file (.exe) with internal applications hidden from users.

I have done this on a Mac before but never graduated. The way official documentation is written is too confusing and everywhere for me to understand.

+4
source share
3 answers

For this purpose you can use https://github.com/nwjs/nw-builder

NW.js mac, win linux cli. , , , app.nw app.nw, .

, node -webkit-builder , :

$ npm install node-webkit-builder -g

, nwbuild :

$ nwbuild [options] [path]

- , :

-p Operating System to build ['osx32', 'osx64', 'win32', 'win64']
-v NW.js version [default: "latest"]
-r Runs NW.js project [default: false]
-o The path of the output folder [default: "./build"]
-f Force download of node-webkit [default: false]
--quiet Disables logging

:

  • ( ):

    $ nwbuild -v [version of your nw.js] -r /path/to/the/project
    
  • ( (.exe)) Win32 / Win64:

    $ nwbuild -v [version of your nw.js] -p win32,win64 /path/to/the/project
    

cmd , ,

+3

, . , , , .

XP W7.

NB: "SourceDir", "DestinDir" "ProgName" .

@echo off
title ProgName Compile & Run Script (c) 2016
cls
set FILETOZIP=C:\SourceDir\*.*
set TEMPDIR=C:\temp
: rmdir %TEMPDIR%
mkdir %TEMPDIR%
xcopy /s %FILETOZIP% %TEMPDIR%
cd C:\temp
copy /b *.* +,,
cd C:\DestinDir
echo Set objArgs = WScript.Arguments > Temp.vbs
echo InputFolder = objArgs(0) >> Temp.vbs
echo ZipFile = objArgs(1) >> Temp.vbs
echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) >> Temp.vbs
echo Set objShell = CreateObject("Shell.Application") >> Temp.vbs
echo Set source = objShell.NameSpace(InputFolder).Items >> Temp.vbs
echo objShell.NameSpace(ZipFile).CopyHere(source) >> Temp.vbs
echo wScript.Sleep 2000 >> Temp.vbs
del C:\DestinDir\ProgName.exe /f /s
CScript Temp.vbs  %TEMPDIR%  C:\DestinDir\ProgName.zip
ren C:\DestinDir\ProgName.zip ProgName.nw
copy /b nw.exe+ProgName.nw ProgName.exe
del C:\DestinDir\Temp.vbs /f /s
del C:\DestinDir\ProgName.nw /f /s
rmdir C:\temp /s /q
start ProgName.exe
+1

nw-builder NW.js ( > 0.12) 02/July/2016 , , /.

nwjs-builder, ( ffmpeg withFFmpeg), line , () gulp, - :

var gulp = require('gulp'),
    glp = require('gulp-load-plugins')(),
    del = require('del'),
    nwb = require('nwjs-builder'),
    argv = require('yargs').alias('p', 'platforms').argv,
    paths = {
        build: './build',
        src: './src',
        images: './src/images'
    },
    detectCurrentPlatform = function () {
        switch (process.platform) {
        case 'darwin':
            return process.arch === 'x64' ? 'osx64' : 'osx32';
        case 'win32':
            return (process.arch === 'x64' || process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432')) ? 'win64' : 'win32';
        case 'linux':
            return process.arch === 'x64' ? 'linux64' : 'linux32';
        }
    };

gulp.task('build', ['clean:build'], function () {
    return new Promise(function (resolve, reject) {
        nwb.commands.nwbuild(paths.src, {
            version: '0.15.4',
            platforms: argv.p ? argv.p : detectCurrentPlatform(),
            withFFmpeg: true,
            production: true,
            macIcns: paths.images + '/icon.icns',
            winIco: paths.images + '/icon.ico',
            sideBySide: false,
            //outputFormat: 'ZIP',
            outputDir: paths.build
        }, function (err) {
            if (err) {
                reject(err);
            }
            return resolve();
        });
    });
});

gulp.task('clean:build', function () {
    return gulp.src(paths.build, {
        read: false
    }).pipe(glp.clean());
});

( ):

"devDependencies": {
    "del": "^2.2.1",
    "gulp": "^3.9.1",
    "gulp-clean": "^0.3.2",
    "gulp-load-plugins": "^1.2.4",
    "nwjs-builder": "latest",
    "yargs": "^4.7.1"
}

You can get more usage documentation and args in the main GitHub repository.

0
source

All Articles