Repository URL to install this package:
|
Version:
1.0.3 ▾
|
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
const path = require('path');
module.exports = class extends Generator {
prompting() {
// Have Yeoman greet the user.
this.log(
yosay(
'Welcome to the astounding ' +
chalk.red('Drupal@melt Travis') +
' generator!'
)
);
const prompts = [
{
type: 'input',
name: 'projectName',
message: 'Project Name?',
default: this.destinationRoot()
.split(path.sep)
.pop()
},
{
type: 'input',
name: 'acquiaRemote',
message: 'What is the Git URL for your Acquia server?'
},
{
type: 'confirm',
name: 'slackNotification',
message: 'Include Slack notifications?',
default: true
},
{
type: 'input',
name: 'slackSecureToken',
message: 'Slack Secure Token',
when: function(answers) {
return answers.slackNotification;
}
}
];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}
writing() {
this.fs.copyTpl(
this.templatePath('travis-deploy.sh.ejs'),
this.destinationPath('travis-deploy.sh'),
{
acquiaRemote: this.props.acquiaRemote,
projectName: this.props.projectName
}
);
this.fs.copyTpl(
this.templatePath('travis.yml.ejs'),
this.destinationPath('.travis.yml'),
{
slackNotification: this.props.slackNotification,
notifcationsSlackSecure: this.props.slackSecureToken,
acquiaRemoteHost: /.*@(.*):.*/.exec(this.props.acquiaRemote)[1]
}
);
}
};