-
Notifications
You must be signed in to change notification settings - Fork 0
/
volofile
109 lines (94 loc) · 3.5 KB
/
volofile
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var FS = require('fs');
module.exports = {
onCreate: function(d, v, namedArgs, projectName) {
var date = new Date(),
day = date.getDate(),
month = date.getMonth() + 1,
year = date.getFullYear(),
projectUpper = projectName.toUpperCase();
// Add leading zero to month
if (String(month).length < 2) month = '0' + month;
var dateStr = day + '.' + month + '.' + year;
v.prompt('Github host [github.com]:')
.then(function(ghHost) {
return [
ghHost || 'github.com',
v.prompt('Github login:')
];
})
.spread(function(ghHost, login) {
return [
ghHost,
login,
v.prompt('Author name:')
];
})
.spread(function(ghHost, login, name) {
return [
ghHost,
login,
name,
v.prompt('Author email:')
];
})
.spread(function(ghHost, login, name, email) {
return [
ghHost,
login,
name,
email,
v.prompt('Github path (in organization/repo format):')
];
})
.spread(function(ghHost, login, name, email, ghPath) {
var ghUrl = ghHost + '/' + ghPath;
// Update the files that reference this project by name
[
'package.json',
'index.js',
'GNUmakefile',
'ChangeLog.md',
'README.md.in',
'LICENSE',
'bin/app.in'
].forEach(function(file) {
var res = v.template(v.read(file), {
app: projectName,
APP: projectUpper,
APP_ENV: projectUpper.replace(/-/g, '_'),
authorName: name,
authorEmail: email,
githubHost: ghHost,
githubUrl: ghUrl,
githubPath: ghPath,
githubLogin: login,
year: year,
date: dateStr
});
if (file === 'package.json') {
res = res.replace('"app"', '"' + projectName + '"');
}
v.write(file, res);
});
// Rename bin/app.in to bin/{app} and make it executable
var from = 'bin/app.in',
to = 'bin/' + projectName;
v.mv(from, to);
FS.chmodSync(to, '0755');
// Rename README.md.in to README.md
v.mv('README.md.in', 'README.md');
// Remove this volofile
v.rm('volofile');
console.log([
'Project directory is ready!',
'',
'Do not forget to',
'- run `npm init` to initialize npm package',
'- run `git init` to create git repository',
'- review CONTRIBUTING.md',
'- commit your project'
].join('\n'));
d.resolve();
});
}
};