Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
work on #341: integrated appmobi in generator/app
Browse files Browse the repository at this point in the history
  • Loading branch information
gruppjo committed Mar 16, 2016
1 parent 8c48af4 commit a8d8f9c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 14 deletions.
56 changes: 43 additions & 13 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,20 @@ module.exports = yeoman.Base.extend({
}
// save appModule in answers
this.answers.appModule = utils.moduleName(this.answers.appName);

// store answers in .yo-rc.json
this.config.set('answers', this.answers);
},

writing: {
subgenerators: function () {
// create main module
this.composeWith('m-ionic:module', {
arguments: config.DEFAULT_MODULE,
options: {
mainModule: true,
ionicCss: this.answers.ionicCss,
'skip-prompts': this.options['skip-prompts']
}
});
},

cordova: function () {
if (this.update) {
Expand Down Expand Up @@ -242,16 +250,38 @@ module.exports = yeoman.Base.extend({
this.write(this.destinationRoot() + '/README.md', readme);
},

subgenerators: function () {
// create main module
this.composeWith('m-ionic:module', {
arguments: config.DEFAULT_MODULE,
options: {
mainModule: true,
ionicCss: this.answers.ionicCss,
'skip-prompts': this.options['skip-prompts']
}
});
ecosystemPrompts: function () {
if (!this.options['skip-prompts']) {
// ecosystem prompts
var done = this.async();
this.prompt([{
type: 'checkbox',
name: 'ecosystems',
message: 'integrate into the following ecosystems: (can still be done later)',
choices: [{
name: 'appmobi - have your APP_NAME, PROJECT_ID & CONFIG_URL ready',
value: 'appmobi'
}]
}], function (answers) { // prompt
this.answers.ecosystems = answers.ecosystems;
done();
}.bind(this));
}
},

ecosystemIntegration: function () {
// store answers in .yo-rc.json, all questions now asked
this.config.set('answers', this.answers);

if (this.answers.ecosystems.indexOf('appmobi') > -1) {
this.composeWith('generator-appmobi', {
options: {
'skip-sdk': this.options['skip-sdk']
}
}, {
local: require.resolve('generator-appmobi/generators/app/index.js')
});
}
}
},

Expand Down
9 changes: 8 additions & 1 deletion generators/app/sources/sample-answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = {
'cordova-plugin-dialogs',
'ionic-plugin-keyboard'
],
template: 'tabs'
template: 'tabs',
ecosystems: []
},

/**
Expand Down Expand Up @@ -55,6 +56,12 @@ module.exports = {
});
standardCopy.bowerPackages = bowerPackages;
}
if (options && options.appmobi) {
standardCopy.ecosystems.push('appmobi');
standardCopy['APP_NAME'] = '0f50dcbf-5c79-41ee-b038-330de3ee07a5.Test';
standardCopy['PROJECT_ID'] = '5buk7ayx';
standardCopy['CONFIG_URL'] = 'https://cloud.appmobi.com';
}
return standardCopy;
},

Expand Down
23 changes: 23 additions & 0 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,29 @@ describe('m', function () {
});
});

describe('appmobi', function () {
var answers = sampleAnswers.getStandard({appmobi: true});

before(function (done) {
helpers.run(path.join(__dirname, '../generators/app'))
.withGenerators([ // configure path to subgenerators
path.join(__dirname, '../generators/appmobi'),
path.join(__dirname, '../generators/module'),
path.join(__dirname, '../generators/constant'),
path.join(__dirname, '../generators/controller'),
path.join(__dirname, '../generators/template'),
path.join(__dirname, '../generators/service')
])
.withOptions({ 'skip-install': true, 'skip-sdk': true }) // execute with options
.withPrompts(answers) // answer prompts
.on('end', done);
});

it('runs', function () {
assert(true);
});
});

describe('--app-name=tradecore', function () {
var answers = sampleAnswers.getForAppNameOption();

Expand Down

0 comments on commit a8d8f9c

Please sign in to comment.