New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nw

Package Overview
Dependencies
Maintainers
4
Versions
686
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nw - npm Package Compare versions

Comparing version

to
0.88.0-1-sdk

16

package.json
{
"name": "nw",
"version": "0.87.0",
"version": "0.88.0-1-sdk",
"description": "An installer for nw.js",

@@ -36,6 +36,6 @@ "repository": {

"dependencies": {
"axios": "^1.6.8",
"commander": "^12.0.0",
"semver": "^7.5.4",
"tar": "^7.0.1",
"axios": "^1.7.2",
"commander": "^12.1.0",
"semver": "^7.6.2",
"tar": "^7.2.0",
"yauzl-promise": "^4.0.0"

@@ -56,5 +56,5 @@ },

"devDependencies": {
"selenium-webdriver": "^4.18.1",
"vitest": "^1.5.0"
"selenium-webdriver": "^4.21.0",
"vitest": "^1.6.0"
}
}
}

@@ -9,2 +9,4 @@ # nw

Please go through the [CHANGELOG](https://github.com/nwjs/npm-installer/blob/main/CHANGELOG.md) carefully and choose the appropriate version. Bug fixes and feature updates are pushed to the repo periodically.
### Latest version globally

@@ -68,2 +70,6 @@

### Specify unref flag
Set `nwjs_unref` in `.npmrc` or `NWJS_UNREF` environment variable. Default to `false`. This is useful if you're using `nw` package to call the executable and want to prevent zombie processes eating up memory.
## Usage

@@ -70,0 +76,0 @@

@@ -15,9 +15,9 @@ #!/usr/bin/env node

program
.option('--version <string>')
.option('--flavor <flavor>')
.option('--platform <platform>')
.option('--arch <arch>')
.option('--cacheDir <cacheDir>')
.argument('[app]')
.allowUnknownOption()
.argument('[app]', 'File path to project', '.')
.option('--version <string>', 'NW.js version')
.option('--flavor <flavor>', 'NW.js flavor')
.option('--platform <platform>', 'Host platform')
.option('--arch <arch>', 'Host architecture')
.option('--cacheDir <cacheDir>', 'File path to cache directory')
.allowUnknownOption() // this allows chromium and node options to be passed through to the nwjs binary
.parse(process.argv);

@@ -35,4 +35,5 @@

srcDir: program.args[0],
args: program.args.slice(1),
});
}

@@ -95,2 +95,3 @@ import fs from "node:fs";

}
await zip.close();
}

@@ -0,7 +1,8 @@

import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import url from 'node:url';
import semver from 'semver';
import nodeManifest from '../package.json' assert { type: 'json' };
import util from '../src/util.js';

@@ -17,5 +18,7 @@

* @property {string} cacheDir Cache directory
* @property {string} srcDir Source directory
* @property {boolean} cache If false, remove cache and redownload.
* @property {boolean} ffmpeg If true, ffmpeg is not downloaded.
* @property {false | "gyp"} nativeAddon Rebuild native modules
* @property {false | "gyp"} nativeAddon Rebuild native modules
* @property {boolean} unref Unref the child process and unblock the caller
*/

@@ -30,2 +33,11 @@

export default async function parse(options) {
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
/**
* @type {fs.PathLike}
*/
const nodeManifestPath = path.resolve(__dirname, '..', 'package.json');
/**
* @type {object}
*/
const nodeManifest = JSON.parse(await fs.promises.readFile(nodeManifestPath, { encoding: 'utf-8' }));
options.version = options.version ?? nodeManifest.version;

@@ -62,8 +74,10 @@ const parsedVersion = semver.parse(options.version);

options.downloadUrl = options.downloadUrl || process.env.npm_config_nwjs_urlbase || process.env.NWJS_URLBASE || 'https://dl.nwjs.io';
options.cacheDir = options.npm_config_nwjs_urlbase || process.env.npm_config_nwjs_cache_dir || process.env.NWJS_CACHE_DIR || path.resolve('.', 'node_modules', 'nw');
options.cacheDir = options.npm_config_nwjs_urlbase || process.env.npm_config_nwjs_cache_dir || process.env.NWJS_CACHE_DIR || path.resolve(__dirname, '..');
options.srcDir = options.srcDir || process.cwd();
options.cache = options.cache || process.env.npm_config_nwjs_cache || process.env.NWJS_CACHE || true;
options.ffmpeg = options.ffmpeg || process.env.npm_config_nwjs_ffmpeg || process.env.NWJS_FFMPEG || false;
options.nativeAddon = options.nativeAddon || process.env.npm_config_nwjs_native_addon || process.env.NWJS_NATIVE_ADDON || false;
options.unref = options.unref || process.env.npm_config_nwjs_unref || process.env.NWJS_UNREF || false;
return { ...options };
}

@@ -0,2 +1,5 @@

import fs from 'node:fs';
import process from 'node:process';
import path from 'node:path';
import url from 'node:url';

@@ -8,4 +11,2 @@ import semver from 'semver';

import nodeManifest from '../package.json' assert { type: 'json' };
await postinstall()

@@ -15,2 +16,4 @@ .catch((error) => {

console.error('Unable to create symlink since user did not run as Administrator.');
} else {
console.error(error)
}

@@ -20,2 +23,11 @@ });

async function postinstall() {
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
/**
* @type {fs.PathLike}
*/
const nodeManifestPath = path.resolve(__dirname, '..', 'package.json');
/**
* @type {object}
*/
const nodeManifest = JSON.parse(await fs.promises.readFile(nodeManifestPath));
const parsedVersion = semver.parse(nodeManifest.version);

@@ -29,18 +41,14 @@ let version = [

let flavor = process.env.npm_config_nwjs_build_type || process.env.NWJS_BUILD_TYPE || 'normal';
/* Check if version is a prelease. */
if (typeof parsedVersion?.prerelease?.[0] === 'string') {
let prerelease = parsedVersion.prerelease[0].split('-');
if (prerelease.length > 1) {
prerelease = prerelease.slice(0, -1);
}
version = [version, ...prerelease].join('-');
}
/**
* If `parsedVersion` is `null`, then prerelease is `"null"`.
* If `parsedVersion?.prerelease` is `[]`, then prerelease is `"undefined"`.
* If `parsedVersion?.prerelease[0]` is `"N-sdk"` where N represents a build number, then prerelease is `"N-sdk"`.
*
* @type {"null" | "undefined" | "N-sdk" | ""}
*/
const prerelease = String(parsedVersion?.prerelease[0]);
/* Check build flavor and slice that off the `version`. */
if (version.endsWith('-sdk')) {
version = version.slice(0, -4);
if (prerelease.endsWith('sdk')) {
flavor = 'sdk';
} else if (version.endsWith('sdk')) {
version = version.slice(0, -3);
flavor = 'sdk';
}

@@ -47,0 +55,0 @@

@@ -16,2 +16,4 @@ import child_process from "node:child_process";

* @property {string} [cacheDir = "./cache"] Cache directory
* @property {boolean} [unref = false] Unref the child process and unblock the caller
* @property {string[]} [args = []] Command line arguments
*/

@@ -35,2 +37,4 @@

cacheDir = "./cache",
unref = false,
args = [],
}) {

@@ -51,3 +55,4 @@

path.resolve(nwDir, util.EXE_NAME[platform]),
[srcDir]
[srcDir, ...args],
{ detached: true, stdio: "ignore" },
);

@@ -59,2 +64,6 @@

nwProcess.on("message", (message) => {
console.log(message);
});
nwProcess.on("error", (error) => {

@@ -64,2 +73,6 @@ console.error(error);

});
if (unref) {
nwProcess.unref();
}
});

@@ -66,0 +79,0 @@ } catch (error) {