This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1357: Add small node module to handle JX build dependency
- Loading branch information
Showing
7 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Export `findpath` function to get the platform dependant path of the `nodewebkit` binary | ||
*/ | ||
module.exports.findpath = require('./lib/findpath.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var bindir = path.resolve(__dirname, '..', 'bin'); | ||
|
||
module.exports = function() { | ||
var bin = bindir; | ||
if (process.platform === 'win32') { | ||
bin = path.join(bin, 'jx.exe'); | ||
} else { | ||
bin = path.join(bin, 'jx'); | ||
} | ||
return bin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "jxcore", | ||
"version": "0.3.1", | ||
"subpatch": "1", | ||
"description": "NPM based dependency downloader", | ||
"scripts": { | ||
"postinstall": "node scripts/install.js" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"decompress": "^2.2.1", | ||
"download": "^3.3.0", | ||
"file-exists": "^0.1.1", | ||
"merge": "^1.2.0", | ||
"multimeter": "^0.1.1", | ||
"rimraf": "^2.2.8", | ||
"semver": "^4.3.0", | ||
"chalk": "~1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env node | ||
|
||
var Download = require('download'); | ||
var rimraf = require('rimraf'); | ||
var semver = require('semver'); | ||
var createBar = require('multimeter')(process); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var merge = require('merge'); | ||
var urlModule = require('url'); | ||
var Decompress = require('decompress'); | ||
var fileExists = require('file-exists'); | ||
var chalk = require('chalk'); | ||
|
||
var v = semver.parse(require('../package.json').version); | ||
var subpatch = require('../package.json').subpatch; | ||
var version = [v.major, v.minor, v.patch, subpatch].join(''); | ||
|
||
/* | ||
* Determine package type | ||
*/ | ||
var getPkgType = function() { | ||
switch (process.platform) { | ||
case 'win32': return 'win64'; | ||
case 'darwin': return 'osx64'; | ||
case 'linux': return 'deb64'; | ||
} | ||
}; | ||
|
||
function logError(e) { | ||
console.error(chalk.bold.red((typeof e === 'string') ? e : e.message)); | ||
process.exit(1); | ||
} | ||
|
||
function cb(error) { | ||
if( error != null ) { | ||
return logError( error ) | ||
} | ||
|
||
process.nextTick(function() { | ||
process.exit(); | ||
}); | ||
} | ||
|
||
if (v.prerelease && typeof v.prerelease[0] === 'string') { | ||
var prerelease = v.prerelease[0].split('-'); | ||
if (prerelease.length > 1) { | ||
prerelease = prerelease.slice(0, -1); | ||
} | ||
version += '-' + prerelease.join('-'); | ||
} | ||
|
||
if (!getPkgType()) logError('Could not find a compatible version of nw.js to download for your platform.'); | ||
|
||
var url = [ | ||
'https://raw.githubusercontent.com/jxcore/jxcore-release/master/', | ||
version, | ||
'jx_' + getPkgType() + 'v8.zip' | ||
].join('/'); | ||
|
||
var dest = path.resolve(__dirname, '..', 'bin'); | ||
rimraf.sync(dest); | ||
|
||
var bar = createBar({ before: url + ' [' }); | ||
|
||
var total = 0; | ||
var progress = 0; | ||
|
||
var parsedUrl = urlModule.parse(url); | ||
var decompressOptions = { strip: 1, mode: '755' }; | ||
if( parsedUrl.protocol == 'file:' ) { | ||
if ( !fileExists(parsedUrl.path) ) { | ||
logError('Could not find ' + parsedUrl.path); | ||
} | ||
new Decompress() | ||
.src( parsedUrl.path ) | ||
.dest( dest ) | ||
.use( Decompress.zip(decompressOptions) ) | ||
.use( Decompress.targz(decompressOptions) ) | ||
.run( cb ); | ||
} else { | ||
new Download(merge({ extract: true }, decompressOptions)) | ||
.get( url ) | ||
.dest( dest ) | ||
.run( cb ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters