@mobify/generator
Advanced tools
Comparing version
@@ -28,5 +28,8 @@ 'use strict'; | ||
var CliSession = function () { | ||
function CliSession() { | ||
function CliSession(dryRun) { | ||
_classCallCheck(this, CliSession); | ||
this.defaultFeatures = ['web', 'native']; | ||
this.dryRun = dryRun; | ||
this.apiClient = new _api2.default(); | ||
@@ -48,5 +51,19 @@ } | ||
value: function askQuestions() { | ||
_inquirer2.default.prompt(this.questions).then(function (answers) { | ||
console.log(JSON.stringify(answers, null, ' ')); | ||
console.log('TODO: actually call API to create a new project'); | ||
var _this2 = this; | ||
return _inquirer2.default.prompt(this.questions).then(function (answers) { | ||
if (_this2.dryRun) { | ||
return JSON.stringify(answers, null, ' '); | ||
} else { | ||
console.log('Generating...'); | ||
return _this2.apiClient.generateProject({ | ||
project_id: answers['project-id'], | ||
project_url: answers['project-url'], | ||
mobify_id: answers['mobify-id'], | ||
features: _this2.defaultFeatures, | ||
bundle_identifier: answers['apps-bundle-id'] | ||
}).then(function (response) { | ||
return 'That\'s it, your project has been created!\nGo to this URL to explore and clone the project: ' + response.url.underline; | ||
}); | ||
} | ||
}); | ||
@@ -57,3 +74,3 @@ } | ||
value: function prompt() { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -90,5 +107,7 @@ /* eslint-disable prefer-template */ | ||
this.apiClient.getQuestions().then(function (questions) { | ||
return _this2.transformQuestions(questions); | ||
return _this3.transformQuestions(questions); | ||
}).then(function () { | ||
return _this2.askQuestions(); | ||
return _this3.askQuestions(); | ||
}).then(function (message) { | ||
return console.log(message); | ||
}).catch(function (error) { | ||
@@ -95,0 +114,0 @@ console.error('Generator failed :-( Please try again later'); |
@@ -14,5 +14,6 @@ 'use strict'; | ||
/* eslint-disable no-undef */ | ||
_commander2.default.option('--dry-run', 'ask questions and print results, but do not generate the project'); | ||
_commander2.default.command('create').description('Generate new Mobify Platform project').action(function () { | ||
var session = new _cli2.default(); | ||
var session = new _cli2.default(_commander2.default.dryRun); | ||
session.prompt(); | ||
@@ -19,0 +20,0 @@ }); |
{ | ||
"name": "@mobify/generator", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Mobify Platform Generator", | ||
@@ -5,0 +5,0 @@ "main": "./lib/mobify.js", |
20086
5.17%341
5.57%