-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkickstarter.js
72 lines (52 loc) · 1.95 KB
/
kickstarter.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
const inquirer = require('inquirer');
const ui = new inquirer.ui.BottomBar();
const fs = require('fs');
const rimraf = require('rimraf');
const packageJson = require('./package.json');
async function kickstart() {
const questions = await inquirer.prompt([
{
type: 'input',
name: 'projectName',
message: `What's the name of your project? (kebab-cased)`,
default: 'awesome-project'
},
{
type: 'input',
name: 'projectAuthor',
message: `Who's the author?`,
default: 'John Doe'
}
]);
const {projectName, projectAuthor} = questions;
ui.log.write('Removing /docs directory');
rimraf.sync('./docs');
ui.log.write('Updating package.json name');
packageJson.name = projectName;
ui.log.write('Updating package.json author');
packageJson.author = projectAuthor;
packageJson.description = '';
ui.log.write('Removing package.json git repository');
packageJson.keywords = [];
packageJson.repository.url = '';
ui.log.write('Removing .git directory');
rimraf.sync('.git');
ui.log.write('Removing package.json kickstart dependencies');
packageJson.kickstartDependencies.forEach((kickstartDependency) => {
delete packageJson.devDependencies[kickstartDependency];
rimraf.sync(`./node-modules/${kickstartDependency}`);
});
delete packageJson.kickstartDependencies;
packageJson.homepage = '';
packageJson.bugs.url = '';
ui.log.write('Removing package.json kickstart script');
delete packageJson.scripts.kickstart;
ui.log.write('Writing new package.json');
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 4));
ui.log.write('Removing package-lock.json');
fs.unlinkSync('./package-lock.json');
ui.log.write('Removing kickstarter script');
fs.unlinkSync('./kickstarter.js');
ui.log.write('All done!');
}
kickstart();