-
Notifications
You must be signed in to change notification settings - Fork 0
/
lavoca.ts
80 lines (56 loc) · 2.01 KB
/
lavoca.ts
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
import { Command } from 'https://cdn.depjs.com/cmd/mod.ts'
import {Route} from './.core/Router___.ts'
import { listrouter as showRoute } from './routers/router.ts'
import Conf from './config.ts'
import { Filesexist } from './.core/app___.ts'
import * as ink from 'https://deno.land/x/ink/mod.ts'
const program = new Command()
program.version('0.0.1')
program
.option('-c, --config <FILE>', 'load configuration file')
.option('-v, --verbose', 'enable verbose mode')
.option('-m, --controller <type>')
.option('-r, --router <type> ')
.option('-m, --model <type>')
program.parse(Deno.args)
if (program.router != null) {
console.log(showRoute);
}
if (program.controller != null && program.controller != '') {
const Isi = `
//controller ${program.controller} created
import View from '../core/view___.ts'
import {Controller} from '../core/controller___.ts'
export class ${program.controller} extends Controller{
}
`
const FileName =`./controller/${program.controller}.ts`
if (await Filesexist(`${Deno.cwd()}${FileName}`)) {
console.log('the controller already exists');
} else {
await Deno.writeTextFile(FileName, Isi);
console.log(ink.colorize(`<green>Controller ${program.controller} Created</green>`));
}
} else {
}
if (program.model != null && program.model != '') {
const Isi = `
import {Model,DataTypes,db} from '../.core/database___.ts'
export class ${program.model} extends Model {
static table = 'nametable'; //name table
static timestamps = true; //create_at & update_at
static fields = { // field
id: { primaryKey: true, autoIncrement: true },
};
}
db.link([${program.model}]);
`
const FileName =`./model/${program.model}.ts`
if (await Filesexist(`${Deno.cwd()}${FileName}`)) {
console.log('the controller already exists');
} else {
await Deno.writeTextFile(FileName, Isi);
console.log(ink.colorize(`<green>Controller ${program.model} Created</green>`));
}
} else {
}