-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.es6
67 lines (53 loc) · 1.82 KB
/
index.es6
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
import { Base } from 'yeoman-generator';
import yosay from 'yosay';
class GitGenerator extends Base {
constructor(...args) {
super(...args);
this.option('debug', {
type: String,
defaults: false,
alias: 'd',
desc: 'GitHubAPI Debug'
});
this.argument('generators', {
type: Array,
defaults: ['authenticate', 'orgs','create','readme','gitinit','gitpush'],
required: false,
desc: 'List of generators to use. Ex: yo github-create orgs create readme'
});
}
initializing() {
this.log(yosay('Welcome to the github repository generator!'));
if(this.generators.indexOf('authenticate') !== -1) {
this.composeWith('github-create:authenticate', {
options: {
debug: this.options.debug
}
});
}
}
default() {
if(this.generators.indexOf('create') !== -1) {
this.composeWith('github-create:create', {
options: {
org: this.config.get('orgs') ? this.config.get('orgs').org : undefined,
user: this.config.get('authenticate') ? this.config.get('authenticate').user : undefined,
}
});
}
}
writing() {
let config = this.config.get('app');
if(this.generators.indexOf('readme') !== -1) {
this.composeWith('github-create:readme', {
options: {
profile: this.config.get('orgs') ? this.config.get('orgs').org : undefined || this.config.get('authenticate') ? this.config.get('authenticate').user : undefined,
repository: this.config.get('create') ? this.config.get('create').name : undefined,
title: this.config.get('create') ? this.config.get('create').name : undefined,
description: this.config.get('create') ? this.config.get('create').description : undefined,
}
});
}
}
}
module.exports = GitGenerator;