{ | ||
"name": "nw", | ||
"version": "0.88.0", | ||
"version": "0.89.0-sdk", | ||
"description": "An installer for nw.js", | ||
@@ -17,2 +17,3 @@ "repository": { | ||
"test": "vitest run", | ||
"test:cov": "vitest --coverage.enabled true", | ||
"demo": "nw ./test/app --log-level=verbose" | ||
@@ -37,6 +38,6 @@ }, | ||
"dependencies": { | ||
"axios": "^1.7.1", | ||
"axios": "^1.7.2", | ||
"commander": "^12.1.0", | ||
"semver": "^7.6.2", | ||
"tar": "^7.1.0", | ||
"tar": "^7.4.0", | ||
"yauzl-promise": "^4.0.0" | ||
@@ -57,5 +58,6 @@ }, | ||
"devDependencies": { | ||
"selenium-webdriver": "^4.21.0", | ||
"@vitest/coverage-v8": "^1.6.0", | ||
"selenium-webdriver": "^4.22.0", | ||
"vitest": "^1.6.0" | ||
} | ||
} | ||
} |
@@ -93,3 +93,3 @@ # nw | ||
import { findpath } from 'nw'; | ||
var path = findpath(); | ||
let path = await findpath(); | ||
``` | ||
@@ -101,3 +101,3 @@ | ||
import { findpath } from 'nw'; | ||
var path = findpath('chromedriver'); | ||
let path = await findpath('chromedriver', { flavor: 'sdk' }); | ||
``` | ||
@@ -104,0 +104,0 @@ |
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import process from "node:process"; | ||
import { beforeAll, describe, it } from "vitest"; | ||
import { afterAll, beforeAll, describe, expect, it } from "vitest"; | ||
import * as nw from "../src/index.js"; | ||
import decompress from "./decompress.js"; | ||
import request from "./request.js"; | ||
import util from './util.js'; | ||
describe("get/decompress", function () { | ||
describe("get/decompress", async function () { | ||
let tarUrl = "https://dl.nwjs.io/v0.83.0/nwjs-sdk-v0.83.0-linux-x64.tar.gz"; | ||
let zipUrl = "https://dl.nwjs.io/v0.83.0/nwjs-sdk-v0.83.0-osx-x64.zip"; | ||
let nwFilePath = ''; | ||
let nwDirPath = ''; | ||
let nwOutPath = "./test/fixture/cache"; | ||
afterAll(async function () { | ||
await fs.promises.rm(nwOutPath, { recursive: true, force: true }); | ||
}); | ||
beforeAll(async function () { | ||
await fs.promises.mkdir("./test/fixture/cache", {recursive: true}); | ||
nwDirPath = await nw.findpath('all', { flavor: 'sdk' }); | ||
await request(tarUrl, "./test/fixture/cache/nw.tar.gz"); | ||
await request(zipUrl, "./test/fixture/cache/nw.zip"); | ||
}, Infinity); | ||
const cacheExists = await util.fileExists(nwOutPath) | ||
if (!cacheExists) { | ||
await fs.promises.mkdir(nwOutPath); | ||
} | ||
it("decompresses a Linux tarball", async function () { | ||
await decompress("./test/fixture/cache/nw.tar.gz", "./test/fixture/cache"); | ||
if (process.platform === 'linux') { | ||
nwFilePath = nwDirPath + '.tar.gz'; | ||
} else { | ||
nwFilePath = nwDirPath + '.zip'; | ||
} | ||
}); | ||
it("decompresses a NW.js binary", async function () { | ||
await decompress(nwFilePath, nwOutPath); | ||
}, Infinity); | ||
it("decompresses a MacOS zip", async function () { | ||
await decompress("./test/fixture/cache/nw.zip", "./test/fixture/cache"); | ||
}, Infinity); | ||
}); | ||
it.runIf(process.platform === 'darwin')("preserves symlinks on macos", async function () { | ||
const frameworksPath = path.resolve(process.cwd(), nwOutPath, nwDirPath, "nwjs.app", "Contents", "Frameworks", "nwjs Framework.framework"); | ||
const symlinks = [ | ||
path.join(frameworksPath, "Helpers"), | ||
path.join(frameworksPath, "Libraries"), | ||
path.join(frameworksPath, "nwjs Framework"), | ||
path.join(frameworksPath, "Resources"), | ||
path.join(frameworksPath, "Versions", "Current"), | ||
]; | ||
for (const symlink of symlinks) { | ||
const stats = await fs.promises.lstat(symlink); | ||
expect(stats.isSymbolicLink()).toEqual(true); | ||
} | ||
}); | ||
}); |
@@ -27,4 +27,4 @@ import fs from 'node:fs'; | ||
* Parse options. | ||
* | ||
* @param {ParseOptions} options | ||
* | ||
* @param {ParseOptions} options | ||
* @return {Promise<ParseOptions>} | ||
@@ -49,23 +49,6 @@ */ | ||
].join('.'); | ||
options.flavor = options.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); | ||
} | ||
options.version = [options.version, ...prerelease].join('-'); | ||
} | ||
/* Check build flavor and slice that off the `version`. */ | ||
if (options.version.endsWith('-sdk')) { | ||
options.version = options.version.slice(0, -4); | ||
if (String(parsedVersion?.prerelease[0]).endsWith('sdk')) { | ||
options.flavor = 'sdk'; | ||
} else if (options.version.endsWith('sdk')) { | ||
options.version = version.slice(0, -3); | ||
options.flavor = 'sdk'; | ||
} | ||
options.platform = options.platform || util.PLATFORM_KV[process.env.npm_config_nwjs_platform || process.env.NWJS_PLATFORM || process.platform]; | ||
@@ -72,0 +55,0 @@ options.arch = options.arch || util.ARCH_KV[process.env.npm_config_nwjs_process_arch || process.env.NWJS_ARCH || process.arch]; |
@@ -48,3 +48,3 @@ import fs from 'node:fs'; | ||
/* Check build flavor and slice that off the `version`. */ | ||
if (prerelease.endsWith('-sdk')) { | ||
if (prerelease.endsWith('sdk')) { | ||
flavor = 'sdk'; | ||
@@ -51,0 +51,0 @@ } |
@@ -11,3 +11,3 @@ import fs from "node:fs"; | ||
* @function | ||
* | ||
* | ||
* @param {string} url - Download server | ||
@@ -14,0 +14,0 @@ * @param {string} filePath - file path of downloaded content |
@@ -1,25 +0,15 @@ | ||
import fs from "node:fs"; | ||
import { describe, expect, it } from "vitest"; | ||
import { afterEach, beforeAll, describe, expect, it } from "vitest"; | ||
import request from "./request.js"; | ||
import util from "./util.js"; | ||
describe("get/request", function () { | ||
describe.skip("get/request", function () { | ||
let url = "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json" | ||
const filePath = "./test/fixture/request.test.json"; | ||
const filePath = "./test/fixture/cache/request.test.json"; | ||
afterEach(async function () { | ||
await fs.promises.rm(filePath, { force: true }); | ||
}); | ||
beforeAll(async function () { | ||
await fs.promises.mkdir('./test/fixture', { recursive: true }); | ||
}); | ||
it("downloads from specific url", async function () { | ||
await request(url, filePath); | ||
expect(util.fileExists(filePath)).resolves.toBe(true); | ||
}, Infinity); | ||
}); | ||
}); | ||
}, Infinity); |
@@ -54,3 +54,3 @@ import child_process from "node:child_process"; | ||
[srcDir, ...args], | ||
{ detached: true, stdio: "ignore" }, | ||
{ stdio: "inherit" }, | ||
); | ||
@@ -57,0 +57,0 @@ |
@@ -46,4 +46,4 @@ import fs from 'node:fs'; | ||
* Get the platform dependant path of the NW.js or ChromeDriver binary. | ||
* | ||
* @param {'nwjs' | 'chromedriver'} executable Path to NW.js or Chromedriver executable. | ||
* | ||
* @param {'nwjs' | 'chromedriver' | 'all'} Path to NW.js or Chromedriver executable. | ||
* @return {Promise<string>} | ||
@@ -54,6 +54,6 @@ */ | ||
const nwDir = path.resolve(__dirname, '..', `nwjs${options.flavor === "sdk" ? "-sdk" : ""}-v${options.version}-${options.platform}-${options.arch}`); | ||
/** | ||
* File path to executable. | ||
* | ||
* | ||
* @type {string} | ||
@@ -64,2 +64,9 @@ */ | ||
/** | ||
* Get the platform dependant path of the NW.js directory containing everything. | ||
*/ | ||
function findDir() { | ||
binPath = nwDir; | ||
} | ||
/** | ||
* Get the platform dependant path of the NW.js binary. | ||
@@ -82,2 +89,4 @@ */ | ||
findChromeDriver(); | ||
} else if (executable === 'all') { | ||
findDir(); | ||
} else { | ||
@@ -84,0 +93,0 @@ console.error(`[ ERROR ] Expected nwjs or chromedriver, got ${executable}.`); |
35730
0.79%847
1.68%3
50%