This repository was archived by the owner on Oct 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
112 lines (98 loc) · 2.53 KB
/
Copy pathindex.js
File metadata and controls
112 lines (98 loc) · 2.53 KB
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
110
111
112
'use strict';
const fs = require('fs');
// get the user()
// createLicense()
// createEslint()
// createGitignore();
// createTest();
var baseData = {
name: basename || package.name,
version: '0.0.1',
main: 'index.js',
author: 'Red Hat, Inc.',
license: 'Apache-2.0',
scripts: {
test: 'tape test/*.js | tap-spec',
lint: 'eslint test/*.js index.js',
prepublish: 'nsp check',
release: 'standard-version'
},
repository: {
type: 'git',
url: `git://github.com/${user}/${basename}.git`
},
files: [
'package.json',
'README.md',
'LICENSE',
'index.js'
],
bugs: {url: `https://github.com/${user}/${basename}/issues`},
homepage: `https://github.com/${user}/${basename}`,
devDependencies: {
eslint: '~3.8.1',
'eslint-config-semistandard': '~7.0.0',
'eslint-config-standard': '~6.2.0',
'eslint-plugin-promise': '~3.3.0',
'eslint-plugin-react': '~6.4.1',
'eslint-plugin-standard': '~2.0.1',
nsp: '~2.6.2',
'tap-spec': '~4.1.1',
tape: '~4.6.2',
'standard-version': '^3.0.0'
}
};
var customizedData = {};
Object.assign(customizedData, baseData);
customizedData.gitHubUser = prompt('GitHub user name', user, n => user = n);
customizedData.name = prompt('name', basename || package.name);
customizedData.description = prompt(s => s);
customizedData.main = prompt('entry point', 'index.js',
ep => !exists(ep) && fs.writeFileSync(ep, 'module.exports = exports = {};\n\n' ));
customizedData.keywords = prompt('Enter keywords separated by a space', s => s.split(/\s+/));
Object.defineProperties(customizedData, {
repository: {
get: () => {
return {
type: 'git',
url: `git://github.com/${user}/${basename}.git`
};
}
},
bugs: {
get: () => {
return {url: `https://github.com/${user}/${basename}/issues`};
}
},
homepage: {
get: () => `https://github.com/${user}/${basename}`
}
});
if (yes) {
console.log('Assuming all defaults.');
module.exports = baseData;
} else {
module.exports = customizedData;
}
function exists (name) {
try {
fs.statSync(name);
return true;
} catch (e) {
return false;
}
}
var needInstall = true;
for (var i = 0; i < process.argv.length; i++) {
if (process.argv[i] === '--no-install' || process.argv[i] === '-n') {
needInstall = false;
break;
}
}
if (needInstall) {
process.on('exit', () => {
console.log('Installing dependencies...');
let out = require('child_process').spawnSync('npm', ['install']);
console.log(out.output.toString('utf8'));
});
}