-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscaffold.config.cjs
More file actions
76 lines (73 loc) · 1.82 KB
/
scaffold.config.cjs
File metadata and controls
76 lines (73 loc) · 1.82 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
/* eslint-disable @typescript-eslint/no-require-imports */
// eslint-disable-next-line no-undef
const { format } = require('date-fns')
// eslint-disable-next-line no-undef
const fs = require('node:fs')
function getLatestMigration() {
const migrationDir = 'lib/Migration'
const files = fs.readdirSync(migrationDir)
const migrationFiles = files.sort((a, b) => a.localeCompare(b))
const latestMigration = migrationFiles[migrationFiles.length - 1]
const matches = /Version(\d+)/.exec(latestMigration)
const version = (matches ? Number(matches[1]) : 0) + 1
return version
}
// eslint-disable-next-line no-undef
module.exports = () => {
const latestMigrationVersion = getLatestMigration()
return {
component: {
templates: ['gen/component'],
output: 'src/components',
},
view: {
templates: ['gen/view'],
output: 'src/views',
subDir: false,
},
command: {
templates: ['gen/command'],
output: 'lib/Command',
subDir: false,
},
model: {
templates: ['gen/model'],
output: 'lib/Db',
subDir: false,
},
'task-queued': {
templates: ['gen/task-queued'],
output: 'lib/Cron',
subDir: false,
},
'task-timed': {
templates: ['gen/task-timed'],
output: 'lib/Cron',
subDir: false,
},
service: {
templates: ['gen/service'],
output: 'lib/Service',
subDir: false,
},
util: {
templates: ['gen/util'],
output: 'lib/Util',
subDir: false,
},
api: {
templates: ['gen/api'],
output: 'lib/Controller',
subDir: false,
},
migration: {
templates: ['gen/migration'],
output: 'lib/Migration',
name: '-',
data: {
version: latestMigrationVersion,
dt: format(new Date(), 'yyyyMMddHHmmss'),
},
},
}
}