From 136ec2347a7d34367150e78852e5dbf565bf3fac Mon Sep 17 00:00:00 2001 From: wilix-lead Date: Mon, 19 Apr 2021 11:55:53 +0300 Subject: [PATCH] + Enhancement for package.json iohook configuration. Now targets support object for define prebuild version (read the docs) + Bump electron version in examples --- build.js | 4 ++-- docs/installation.md | 1 + docs/usage.md | 20 +++++++++++++++++++ examples/electron-example/package.json | 2 +- .../electron-renderer-example/package.json | 2 +- install.js | 16 ++++++++++++--- package-lock.json | 12 +++++------ 7 files changed, 44 insertions(+), 13 deletions(-) diff --git a/build.js b/build.js index bc3aa2b8..85a6fa2c 100644 --- a/build.js +++ b/build.js @@ -93,7 +93,7 @@ function initBuild() { return uploadFiles(files) }); - + cpGyp(); } @@ -145,7 +145,7 @@ function build(runtime, version, abi) { } } - console.log('Compiling iohook for ' + runtime + ' v' + version + '>>>>'); + console.log('Building iohook for ' + runtime + ' v' + version + '>>>>'); if (process.platform === 'win32') { if (version.split('.')[0] >= 4) { process.env.msvs_toolset = 15 diff --git a/docs/installation.md b/docs/installation.md index 8eb163db..33d220e3 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -17,6 +17,7 @@ iohook currently provides prebuilt versions for the following runtimes: - 9.X.X (ABI 80) - 10.X.X (ABI 82) - 11.X.X (ABI 85) + - 12.X.X (ABI 87) - Node.js: - 8.9.X (ABI 57) diff --git a/docs/usage.md b/docs/usage.md index 424a4ead..f01f434e 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -24,6 +24,26 @@ Checkout your ABI for [node.js](https://nodejs.org/en/download/releases/) or [el } ``` +Or you can specify targets as objects: + +```json +"iohook": { + "targets": [ + { + "target": "node", + "abi": "72", + "platform": "darwin", + "arch": "x64" + }, + { + "target": "electron", + "abi": "85", + "platform": "win32", + "arch": "ia32" + }, + ], +``` + ::: tip if you use a two-package.json structure, add this to application package.json. ::: diff --git a/examples/electron-example/package.json b/examples/electron-example/package.json index a6f03778..d7c21b17 100644 --- a/examples/electron-example/package.json +++ b/examples/electron-example/package.json @@ -10,6 +10,6 @@ "author": "Aloyan Dmitry", "license": "MIT", "dependencies": { - "electron": "^11.0.0" + "electron": ">=11.1.0" } } diff --git a/examples/electron-renderer-example/package.json b/examples/electron-renderer-example/package.json index 4a579200..dbb17051 100644 --- a/examples/electron-renderer-example/package.json +++ b/examples/electron-renderer-example/package.json @@ -7,6 +7,6 @@ "start": "electron ." }, "devDependencies": { - "electron": "^11.0.0" + "electron": ">=11.1.0" } } diff --git a/install.js b/install.js index 2c471fe1..abeb9475 100644 --- a/install.js +++ b/install.js @@ -66,7 +66,7 @@ function install(runtime, abi, platform, arch, cb) { onerror(error); } else { console.error('Prebuild for current platform (' + currentPlatform + ') not found!'); - console.error('Try to compile for your platform:'); + console.error('Try to build for your platform manually:'); console.error('# cd node_modules/iohook;'); console.error('# npm run build'); console.error(''); @@ -96,10 +96,10 @@ function install(runtime, abi, platform, arch, cb) { } const options = optionsFromPackage(); + if (process.env.npm_config_targets) { options.targets = options.targets.concat(process.env.npm_config_targets.split(',')); } -options.targets = options.targets.map(targetStr => targetStr.split('-')); if (process.env.npm_config_targets === 'all') { options.targets = supportedTargets.map(arr => [arr[0], arr[2]]); options.platforms = ['win32', 'darwin', 'linux']; @@ -115,7 +115,17 @@ if (process.env.npm_config_arches) { // Choice prebuilds for install if (options.targets.length > 0) { let chain = Promise.resolve(); - options.targets.forEach(function(parts) { + options.targets.forEach(function(target) { + if (typeof target === 'object') { + chain = chain.then(function() { + return new Promise(function(resolve) { + console.log(target.runtime, target.abi, target.platform, target.arch); + install(target.runtime, target.abi, target.platform, target.arch, resolve) + }) + }); + return; + } + let parts = target.split('-'); let runtime = parts[0]; let abi = parts[1]; options.platforms.forEach(function(platform) { diff --git a/package-lock.json b/package-lock.json index 99ee8135..88f327d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19757,9 +19757,9 @@ } }, "node_modules/ssri": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", - "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.2.tgz", + "integrity": "sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==", "dev": true, "dependencies": { "figgy-pudding": "^3.5.1" @@ -40314,9 +40314,9 @@ } }, "ssri": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", - "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.2.tgz", + "integrity": "sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==", "dev": true, "requires": { "figgy-pudding": "^3.5.1"