-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·68 lines (62 loc) · 1.84 KB
/
index.js
File metadata and controls
executable file
·68 lines (62 loc) · 1.84 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
#!/usr/bin/env node
const { program } = require('commander')
const {
checkIfProjectAlreadyStarted,
checkIfModuleAlreadyCreated,
} = require('./src/utils')
const { createFolderStructure, createModule } = require('./src/builders')
const setup = require('./src/setup')
const run = () => {
program
.command('start-project')
.description('Starts the project structure.')
.action(async () => {
try {
const projectAlreadyStarted = checkIfProjectAlreadyStarted()
if (projectAlreadyStarted) {
console.log('Project already built.')
process.exit()
} else {
console.log('Starting project builders...')
await createFolderStructure()
const projectName = process.cwd().split('/').pop()
await setup(projectName)
process.exit()
}
} catch (error) {
console.log(error)
} finally {
process.exit()
}
})
program
.command('add-module')
.description('Adds a new module to the project.')
.requiredOption('-n, --name <module-name>', 'Module name')
.action(async (args) => {
try {
const projectAlreadyStarted = checkIfProjectAlreadyStarted()
const moduleName = args.name
if (!projectAlreadyStarted) {
console.log('Project not started.')
process.exit()
} else {
const moduleAlreadyCreated = checkIfModuleAlreadyCreated(moduleName)
if (moduleAlreadyCreated) {
console.log('Module already created.')
process.exit()
} else {
await createModule(moduleName)
console.log(`Module ${moduleName} created.`)
process.exit()
}
}
} catch (error) {
console.log(error)
} finally {
process.exit()
}
})
program.parse(process.argv)
}
run();