cross platform js test

This commit is contained in:
Caelan
2024-10-02 12:08:42 -06:00
parent 426c647372
commit 0a46b6a52e
4 changed files with 28 additions and 47 deletions

View File

@@ -0,0 +1,15 @@
const os = require("node:os");
const fs = require("node:fs");
const path = require("node:path");
const platform = os.platform();
if (platform == "win32") {
fs.copyFileSync("../../target/debug/velopack_nodeffi.dll", "index.node");
} else if (platform == "darwin") {
fs.copyFileSync("../../target/debug/libvelopack_nodeffi.dylib", "index.node");
} else if (platform == "linux") {
fs.copyFileSync("../../target/debug/libvelopack_nodeffi.so", "index.node");
} else {
throw new Error("Unsupported platform: " + platform);
}

View File

@@ -2,43 +2,26 @@
"name": "velopack",
"version": "0.1.0",
"description": "",
"main": "./lib/index.cjs",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"scripts": {
"test": "npm run debug && cross-env VELOPACK_RESTART=true VELOPACK_DEBUG=true jest",
"debug": "tsc -p tsconfig.build.json && cargo build && neon dist -f ../../target/debug/velopack_nodeffi.dll && npm run lint",
"build": "tsc -p tsconfig.build.json && cargo build --release && neon dist -f ../../target/release/velopack_nodeffi.dll",
"clean": "cargo clean && del-cli platforms/**/index.node index.node lib",
"test": "npm run dev && cross-env VELOPACK_RESTART=true VELOPACK_DEBUG=true jest",
"dev": "cargo build && tsc -p tsconfig.build.json && node copy-lib.js && npm run lint",
"build": "tsc -p tsconfig.build.json",
"clean": "del-cli **/*.node lib",
"lint": "prettier . --write"
},
"author": "Velopack Ltd, Caelan Sayler",
"license": "MIT",
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./lib/index.d.cts",
"default": "./lib/index.cjs"
}
}
},
"engines": {
"node": ">=18.0.0 <=21.0.0"
},
"types": "./lib/index.d.cts",
"files": [
"lib/**/*.?({c,m}){t,j}s"
"lib/**/*.ts",
"lib/**/*.js",
"lib/**/*.node"
],
"neon": {
"type": "library",
"org": "@velopack",
"platforms": "common",
"load": "./src/load.cts"
},
"devDependencies": {
"@neon-rs/cli": "^0.1.73",
"@tsconfig/node20": "^20.1.4",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.16",
@@ -52,11 +35,5 @@
},
"dependencies": {
"@neon-rs/load": "^0.1.73"
},
"optionalDependencies": {
"@velopack/darwin-arm64": "0.1.0",
"@velopack/darwin-x64": "0.1.0",
"@velopack/linux-x64-gnu": "0.1.0",
"@velopack/win32-x64-msvc": "0.1.0"
}
}

View File

@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["lib", "test"]
"include": ["src"]
}

View File

@@ -23,11 +23,12 @@ pub fn default_log_location(context: LocationContext) -> PathBuf {
if let Ok(locator) = auto_locate_app_manifest(context) {
return locator.get_root_dir().join("Velopack.log");
}
warn!("Could not auto-locate app manifest, writing log to current directory.");
// If we can't locate the current app, we write to the parent directory.
// If we can't locate the current app, we write to the current directory.
let mut my_exe = std::env::current_exe().expect("Could not locate current executable");
my_exe.pop();
my_exe.pop();
return my_exe.join("Velopack.log");
}
#[cfg(target_os = "linux")]
@@ -260,18 +261,6 @@ impl VelopackLocator {
Some(self.manifest.shortcut_amuid.clone())
}
/// Returns a copy of the current VelopackLocator with the shortcut_locations
/// field set to an empty string.
pub fn clone_self_with_blank_shortcuts(&self) -> VelopackLocator
{
let mut new_manifest = self.manifest.clone();
new_manifest.shortcut_locations = "".to_string();
VelopackLocator {
paths: self.paths.clone(),
manifest: new_manifest,
}
}
/// Returns a copy of the current VelopackLocator with the manifest field set to the given manifest.
pub fn clone_self_with_new_manifest(&self, manifest: &Manifest) -> VelopackLocator
{