-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
92 lines (80 loc) · 2.87 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var path = require('path');
module.exports = yeoman.Base.extend({
prompting: function () {
// Have Yeoman greet the user.
this.log(yosay(
'\'Alo \'alo! Welcome to the ' + chalk.red('geb') + ' generator!\nOut of the box I come with gradlew, geb, and webdriver.'
));
var prompts = [
{
type: 'input',
name: 'projectName',
message: 'What is the name of this project?',
default: path.basename(process.cwd())
},
{
type: 'input',
name: 'basePackage',
message: 'What is the base package for this project?',
default: 'com.mycompany'
}
];
return this.prompt(prompts).then(function (props) {
this.props = props;
this.props.basePackageDirectory = props.basePackage.replace(/\./g, '/');
}.bind(this));
},
writing: function () {
var self = this;
function writeFile(file) {
self.fs.copy(
self.templatePath(file),
self.destinationPath(file)
);
}
this.fs.copy(
this.templatePath('gitignore'),
this.destinationPath('.gitignore')
);
this.fs.copy(
this.templatePath('editorconfig'),
this.destinationPath('.editorconfig')
);
writeFile('gradle/wrapper/gradle-wrapper.jar');
writeFile('gradle/wrapper/gradle-wrapper.properties');
writeFile('gradle/ci.gradle');
writeFile('gradle/idea.gradle');
writeFile('gradle/osSpecificDownloads.gradle');
writeFile('build.gradle');
writeFile('gradlew');
writeFile('gradlew.bat');
writeFile('src/test/resources/GebConfig.groovy');
this.fs.copyTpl(
this.templatePath('src/test/groovy/com/company/tests/LandingPageTest.groovy'),
this.destinationPath('src/test/groovy/{basePackage}/tests/LandingPageTest.groovy'.replace('{basePackage}', this.props.basePackageDirectory)),
this.props
);
this.fs.copyTpl(
this.templatePath('src/test/groovy/com/company/component/library/LandingPage.groovy'),
this.destinationPath('src/test/groovy/{basePackage}/component/library/LandingPage.groovy'.replace('{basePackage}', this.props.basePackageDirectory)),
this.props
);
this.fs.copyTpl(
this.templatePath('src/test/groovy/com/company/Config.groovy'),
this.destinationPath('src/test/groovy/{basePackage}/Config.groovy'.replace('{basePackage}', this.props.basePackageDirectory)),
this.props
);
this.fs.copyTpl(
this.templatePath('src/test/resources/com/company/Profiles.groovy'),
this.destinationPath('src/test/resources/{basePackage}/Profiles.groovy'.replace('{basePackage}', this.props.basePackageDirectory)),
this.props
);
},
install: function () {
this.log('\nI\'m finished!\ngive it a try:\n\n./gradlew chromeTest -Dprofile=production');
}
});