openfin-cli
Advanced tools
Comparing version 0.1.1 to 0.2.1
@@ -25,2 +25,2 @@ #!/usr/bin/env node | ||
}); | ||
openfinCli(cli.input, cli.flags); | ||
openfinCli(cli); |
72
index.js
@@ -5,6 +5,11 @@ 'use strict'; | ||
path = require('path'), | ||
fs = require('fs'); | ||
fs = require('fs'), | ||
request = require('request'), | ||
meow; | ||
function main(str, flags) { | ||
var name = flags.n || flags.name, | ||
function main(cli) { | ||
meow = cli; | ||
var flags = cli.flags, | ||
name = flags.n || flags.name, | ||
url = flags.u || flags.url, | ||
@@ -15,16 +20,22 @@ config = flags.c || flags.config || 'app.json', | ||
if (isEmpty(flags)) { | ||
console.log('please see options: openfin --help'); | ||
console.log(cli.help); | ||
return; | ||
} | ||
writeToConfig(name, url, config, function(configObj) { | ||
if (launch) { | ||
launchOpenfin(config); | ||
} | ||
try { | ||
writeToConfig(name, url, config, function(configObj) { | ||
if (launch) { | ||
launchOpenfin(config); | ||
} | ||
fetchInstaller(flags, configObj); | ||
}); | ||
if (configObj) { | ||
fetchInstaller(flags, configObj); | ||
} | ||
}); | ||
} catch (err) { | ||
onError('Failed:', err); | ||
} | ||
} | ||
function fetchInstaller (flags, configObj){ | ||
function fetchInstaller(flags, configObj) { | ||
var installer = flags.i || flags.installer, | ||
@@ -36,3 +47,3 @@ hyperlink = flags.h || flags.hyperlink, | ||
if (destination){ | ||
if (destination) { | ||
openfinInstaller | ||
@@ -42,15 +53,18 @@ .fetchInstaller({ | ||
}) | ||
.then(function(){ | ||
console.log('Installer zip written to', destination); | ||
}, | ||
function(reason){ | ||
console.log(reason); | ||
}); | ||
.then(function() { | ||
console.log('Installer zip written to', destination); | ||
}, | ||
function(reason) { | ||
console.log(reason); | ||
}); | ||
} | ||
if (hyperlink){ | ||
console.log('\n',openfinInstaller.generateInstallUrl(name, installer), '\n'); | ||
if (hyperlink) { | ||
console.log('\n', openfinInstaller.generateInstallUrl(encodeURIComponent(name), installer), '\n'); | ||
} | ||
} | ||
function isURL(str) { | ||
return (typeof str === 'string') && str.lastIndexOf('http') >= 0; | ||
} | ||
@@ -67,9 +81,14 @@ //makeshift is object empty function | ||
function onError(message, err) { | ||
console.log(message, err); | ||
console.log(meow.help); | ||
} | ||
//will launch download the rvm and launch openfin | ||
function launchOpenfin(config) { | ||
openfinLauncher.launchOpenFin({ | ||
configPath: path.resolve(config), | ||
configPath: isURL(config) ? config : path.resolve(config), | ||
rvmGlobalCommand: 'OpenFinRVM' | ||
}).fail(function(err) { | ||
console.log('launch failed', err); | ||
onError('launch failed', err); | ||
}); | ||
@@ -80,2 +99,11 @@ } | ||
function writeToConfig(name, url, config, callback) { | ||
if (isURL(config)) { | ||
request(config, function(err, response, body) { | ||
if (!err && response.statusCode === 200) { | ||
callback(JSON.parse(body)); | ||
} | ||
}); | ||
return; | ||
} | ||
var startup_app = {}, | ||
@@ -82,0 +110,0 @@ shortcut = {}, |
{ | ||
"name": "openfin-cli", | ||
"version": "0.1.1", | ||
"version": "0.2.1", | ||
"description": "OpenFin Runtime cli tool", | ||
@@ -26,3 +26,4 @@ "homepage": "http://www.openfin.co", | ||
"openfin-installer": ">=0.1.0", | ||
"openfin-launcher": ">=0.2.0" | ||
"openfin-launcher": ">=0.2.0", | ||
"request": "^2.53.0" | ||
}, | ||
@@ -29,0 +30,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1998989
7
147
5
+ Addedrequest@^2.53.0