crex
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -10,2 +10,3 @@ #!/usr/bin/env node | ||
var CrEx = require('../lib/index'); | ||
var poller = require('promise-poller'); | ||
var auth = {}; | ||
@@ -54,2 +55,3 @@ | ||
.option('-e, --env <name>', 'specify environment from auth.json') | ||
.option('-a, --activate', 'activate after install') | ||
.parse(process.argv); | ||
@@ -78,2 +80,14 @@ | ||
var checkStatus = (id) => { | ||
return new Promise((resolve, reject) => { | ||
return crex.themesCheckActivateProgress({id: id}) | ||
.then(function (res) { | ||
if (res.status !== 'DONE') { | ||
reject(id); | ||
} | ||
resolve(id); | ||
}); | ||
}); | ||
}; | ||
new Promise((resolve, reject) => { | ||
@@ -129,2 +143,3 @@ if (program.compress) { | ||
const action = program.inspect ? 'inspected' : 'installed'; | ||
const themesToActivate = []; | ||
spinner.succeed(util.format('Package %s %s on %s', chalk.green(name), action, chalk.green(crex.getAddress()))); | ||
@@ -153,4 +168,10 @@ console.log(); | ||
res.themeStatuses.forEach((theme) => { | ||
console.log(util.format(' %s %s', chalk.blue(theme.themeName + ':'),' ' + theme.themeAction.toLowerCase())); | ||
if (theme.themeAction !== 'IGNORED' && theme.themeAction !== 'UNTOUCHED') { | ||
themesToActivate.push(theme.themePath); | ||
} | ||
const color = (theme.themeAction.toLowerCase() === 'changed') ? chalk.green : chalk.grey; | ||
console.log(util.format(' %s %s', theme.themePath + ':',' ' + color(theme.themeAction.toLowerCase()))); | ||
}); | ||
reportChanges(res, 'Css'); | ||
@@ -160,4 +181,25 @@ reportChanges(res, 'Js'); | ||
console.log(); | ||
if (themesToActivate.length > 0 && program.activate && !program.inspect) { | ||
spinner = ora('Activating package...').start(); | ||
return crex.themesActivateThemes({themes: JSON.stringify(themesToActivate)}); | ||
} else { | ||
return false; | ||
} | ||
}).then((package) => { | ||
if (!package) { | ||
return false; | ||
} | ||
return poller.default({ | ||
taskFn: function () { | ||
return checkStatus(package.id) | ||
}, | ||
retries: 10000 | ||
}) | ||
}).then((res) => { | ||
if (!res) { | ||
return false; | ||
} | ||
spinner.succeed(util.format('Package %s activated', chalk.green(name))); | ||
}).catch((err) => { | ||
spinner.fail(chalk.red(err)); | ||
}); |
@@ -170,3 +170,3 @@ var request = require('./request'); | ||
* @arg {Object} args | ||
* @arg {Array.<string>} args.themes - Theme paths | ||
* @arg {Array.<string>} args.themes - Stringified list of theme paths | ||
* @returns {Promise} | ||
@@ -173,0 +173,0 @@ */ |
{ | ||
"name": "crex", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Creative Exchange SDK for Javascript", | ||
@@ -5,0 +5,0 @@ "author": "Mateusz Luczak <mateusz.luczak@outlook.com>", |
183641
4766