-
Notifications
You must be signed in to change notification settings - Fork 3
/
instructions.js
96 lines (78 loc) · 2.17 KB
/
instructions.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
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
/*
* File: instructions.js
* Project: adoscope
* Author: Paradox
*
* Copyright (c) 2019 Paradox.
*/
const fs = require('fs')
const path = require('path')
const _ = require('lodash')
async function copyConfigFile (cli) {
try {
const configFile = 'adoscope.js'
await cli.copy(
path.join(__dirname, 'config', configFile),
path.join(cli.helpers.configPath(), configFile)
)
cli.command.completed('create', `config/${configFile}`)
} catch (error) {
// ignore error
}
}
async function copyMigrationFile (cli) {
try {
const migrationFile = 'adoscope_entries_schema.js'
const outFile = `${new Date().getTime()}_${migrationFile}`
await cli.copy(
path.join(__dirname, 'dist', 'src', 'database', 'migrations', migrationFile),
path.join(cli.helpers.migrationsPath(), outFile)
)
cli.command.completed('create', `database/migrations/${outFile}`)
} catch (error) {
// ignore error
}
}
async function copyControllersDirectory (cli) {
try {
const controllersPath = 'app/Controllers/Http'
await cli.copy(
path.join(__dirname, 'dist', 'src', controllersPath),
path.join(cli.helpers.appRoot(), controllersPath, 'Adoscope')
)
cli.command.completed('create', `${controllersPath}/Adoscope`)
} catch (error) {
// ignore error
}
}
async function copyModelFile (cli) {
try {
const modelFile = 'app/Models/Entry.js'
await cli.copy(
path.join(__dirname, 'dist', 'src', modelFile),
path.join(cli.helpers.appRoot(), modelFile)
)
cli.command.completed('create', modelFile)
} catch (error) {
// ignore error
}
}
async function copyViewFile (cli) {
try {
const viewFile = 'adoscope.edge'
await cli.copy(
path.join(__dirname, 'resources', 'views', viewFile),
path.join(cli.helpers.viewsPath(), 'adoscope', viewFile)
)
cli.command.completed('create', `resources/views/adoscope/${viewFile}`)
} catch (error) {
// ignore error
}
}
module.exports = async (cli) => {
await copyConfigFile(cli)
await copyMigrationFile(cli)
//await copyModelFile(cli)
//await copyControllersDirectory(cli)
await copyViewFile(cli)
}