-
Notifications
You must be signed in to change notification settings - Fork 0
/
npm-init
72 lines (56 loc) · 1.87 KB
/
npm-init
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
// ln -s $DOTFILES/npm-init ~/.npm-init.js
// npm config set init-module ~/.npm-init.js
const cp = require('child_process');
const USER = process.env.GITHUB_USERNAME || 'dkunin';
let priv;
module.exports = {
name: prompt('name', basename),
version: '0.0.1',
private: prompt('private', 'false', function(val) {
return (priv = typeof val === 'boolean'
? val
: Boolean(val.match('true')));
}),
create: prompt('create github repo', 'no', function(val) {
if (val.indexOf('y') !== -1) {
cp.execSync('git init');
// eslint-disable-next-line
console.log('enter github password:');
cp.execSync(
`curl -u "${USER}" https://api.github.com/user/repos -d '{"name": "${basename}", "private": "${priv ? true : false}"}'`
);
cp.execSync(
`git remote add origin https://github.com/${USER}/${basename}.git`
);
}
return undefined;
}),
scaffold: prompt('Add scaffold files', 'no', function(val) {
if (val.indexOf('y') !== -1) {
cp.execSync(
'get-config eslintrc && getreadme && echo node_modules >> .gitignore && :> .npmrc'
);
}
return undefined;
}),
main: prompt('entry point', 'index.js'),
repository: {
type: 'git',
url: 'git://github.com/' + USER + '/' + basename + '.git'
},
bugs: { url: 'https://github.com/' + USER + '/' + basename + '/issues' },
scripts: {
test: 'echo test',
start: 'node ./',
dev: 'node ./',
build: 'NODE_ENV=production node ./'
},
homepage: 'https://github.com/' + USER + '/' + basename,
keywords: prompt(function(s) {
return s.split(/\s+/);
}),
license: 'MIT',
cleanup: function(cb) {
cb(null, undefined);
}
};