adapt-migrations 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -1
- package/.eslintrc.json +14 -14
- package/.github/CONTRIBUTING.md +8 -0
- package/.github/ISSUE_TEMPLATE/config.yml +1 -0
- package/.github/ISSUE_TEMPLATE/issue_template.md +23 -0
- package/.github/ISSUE_TEMPLATE.md +17 -0
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/addtomainproject.yml +19 -0
- package/.github/workflows/releases.yml +25 -0
- package/README.md +106 -106
- package/api/commands.js +33 -33
- package/api/data.js +26 -26
- package/api/describe.js +12 -12
- package/api/errors.js +28 -28
- package/api/helpers.js +17 -17
- package/api/plugins.js +47 -47
- package/api/tests.js +56 -57
- package/api/where.js +46 -46
- package/examples/migrations.js +159 -159
- package/examples/script.js +78 -78
- package/index.js +70 -70
- package/lib/CacheManager.js +95 -95
- package/lib/Journal.js +303 -303
- package/lib/Logger.js +91 -91
- package/lib/Task.js +402 -381
- package/lib/TaskContext.js +27 -27
- package/lib/TaskTest.js +21 -19
- package/lib/lifecycle.js +50 -50
- package/package.json +55 -18
package/lib/Logger.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import fs from 'fs-extra'
|
|
4
|
-
|
|
5
|
-
function padNum2(value) {
|
|
6
|
-
return String(value).padStart(2, '0');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default class Logger {
|
|
10
|
-
constructor () {
|
|
11
|
-
this.logArr = []
|
|
12
|
-
this.config = {
|
|
13
|
-
levels: {
|
|
14
|
-
error: {
|
|
15
|
-
colour: 'red'
|
|
16
|
-
},
|
|
17
|
-
warn: {
|
|
18
|
-
colour: 'yellow'
|
|
19
|
-
},
|
|
20
|
-
info: {
|
|
21
|
-
colour: 'cyan'
|
|
22
|
-
},
|
|
23
|
-
debug: {
|
|
24
|
-
colour: 'grey'
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// getInstance used to allow import
|
|
31
|
-
static getInstance () {
|
|
32
|
-
if (Logger.instance === null) {
|
|
33
|
-
Logger.instance = new Logger()
|
|
34
|
-
}
|
|
35
|
-
return Logger.instance
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Colour level string, easier to differentiate between info/error/warn/debug
|
|
39
|
-
static colourise (str, colour) {
|
|
40
|
-
const chalkFunc = chalk[colour]
|
|
41
|
-
return chalkFunc ? chalkFunc(str) : str
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Use getDateStamp to return readable date/time string.
|
|
45
|
-
static getDateStamp () {
|
|
46
|
-
const d = new Date()
|
|
47
|
-
const date = `${d.getFullYear().toString()}/${padNum2(d.getMonth() + 1)}/${padNum2(d.getDate())}`
|
|
48
|
-
const time = `${padNum2(d.getHours())}:${padNum2(d.getMinutes())}:${padNum2(d.getSeconds())}.${padNum2(d.getMilliseconds())}`
|
|
49
|
-
const str = `${date} ${time}`
|
|
50
|
-
return str
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Add Success/Fail ?
|
|
54
|
-
info (...args) {
|
|
55
|
-
this.log('info', args)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
error (...args) {
|
|
59
|
-
this.log('error', args)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
warn (...args) {
|
|
63
|
-
this.log('warn', args)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
debug (...args) {
|
|
67
|
-
this.log('debug', args)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Colour level for easy read, store log in this.logArr as string
|
|
71
|
-
log (level, args) {
|
|
72
|
-
const colour = this?.config?.levels[level]?.colour || 'grey'
|
|
73
|
-
const logFunc = console[level] ?? console.log
|
|
74
|
-
const dateStamp = Logger.getDateStamp()
|
|
75
|
-
const argsStr = args.join(', ')
|
|
76
|
-
logFunc(`(${dateStamp}) -- ${Logger.colourise(level, colour)} -- `, ...args)
|
|
77
|
-
this.logArr.push(`[${dateStamp}] -- ${level} -- ${argsStr}`)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Output this.logArr, 2 log outputs, capture & migrate
|
|
81
|
-
output (dir, type) {
|
|
82
|
-
const logPath = path.join(dir, './logs/')
|
|
83
|
-
if (!fs.existsSync(logPath)) fs.mkdirSync(logPath)
|
|
84
|
-
|
|
85
|
-
const outputName = `${type}_log`
|
|
86
|
-
const outputFile = path.join(logPath, `${outputName}.json`)
|
|
87
|
-
fs.writeJSONSync(outputFile, this.logArr, { replacer: null, spaces: 2 })
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
Logger.instance = null
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import fs from 'fs-extra'
|
|
4
|
+
|
|
5
|
+
function padNum2(value) {
|
|
6
|
+
return String(value).padStart(2, '0');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class Logger {
|
|
10
|
+
constructor () {
|
|
11
|
+
this.logArr = []
|
|
12
|
+
this.config = {
|
|
13
|
+
levels: {
|
|
14
|
+
error: {
|
|
15
|
+
colour: 'red'
|
|
16
|
+
},
|
|
17
|
+
warn: {
|
|
18
|
+
colour: 'yellow'
|
|
19
|
+
},
|
|
20
|
+
info: {
|
|
21
|
+
colour: 'cyan'
|
|
22
|
+
},
|
|
23
|
+
debug: {
|
|
24
|
+
colour: 'grey'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// getInstance used to allow import
|
|
31
|
+
static getInstance () {
|
|
32
|
+
if (Logger.instance === null) {
|
|
33
|
+
Logger.instance = new Logger()
|
|
34
|
+
}
|
|
35
|
+
return Logger.instance
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Colour level string, easier to differentiate between info/error/warn/debug
|
|
39
|
+
static colourise (str, colour) {
|
|
40
|
+
const chalkFunc = chalk[colour]
|
|
41
|
+
return chalkFunc ? chalkFunc(str) : str
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Use getDateStamp to return readable date/time string.
|
|
45
|
+
static getDateStamp () {
|
|
46
|
+
const d = new Date()
|
|
47
|
+
const date = `${d.getFullYear().toString()}/${padNum2(d.getMonth() + 1)}/${padNum2(d.getDate())}`
|
|
48
|
+
const time = `${padNum2(d.getHours())}:${padNum2(d.getMinutes())}:${padNum2(d.getSeconds())}.${padNum2(d.getMilliseconds())}`
|
|
49
|
+
const str = `${date} ${time}`
|
|
50
|
+
return str
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Add Success/Fail ?
|
|
54
|
+
info (...args) {
|
|
55
|
+
this.log('info', args)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
error (...args) {
|
|
59
|
+
this.log('error', args)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
warn (...args) {
|
|
63
|
+
this.log('warn', args)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
debug (...args) {
|
|
67
|
+
this.log('debug', args)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Colour level for easy read, store log in this.logArr as string
|
|
71
|
+
log (level, args) {
|
|
72
|
+
const colour = this?.config?.levels[level]?.colour || 'grey'
|
|
73
|
+
const logFunc = console[level] ?? console.log
|
|
74
|
+
const dateStamp = Logger.getDateStamp()
|
|
75
|
+
const argsStr = args.join(', ')
|
|
76
|
+
logFunc(`(${dateStamp}) -- ${Logger.colourise(level, colour)} -- `, ...args)
|
|
77
|
+
this.logArr.push(`[${dateStamp}] -- ${level} -- ${argsStr}`)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Output this.logArr, 2 log outputs, capture & migrate
|
|
81
|
+
output (dir, type) {
|
|
82
|
+
const logPath = path.join(dir, './logs/')
|
|
83
|
+
if (!fs.existsSync(logPath)) fs.mkdirSync(logPath)
|
|
84
|
+
|
|
85
|
+
const outputName = `${type}_log`
|
|
86
|
+
const outputFile = path.join(logPath, `${outputName}.json`)
|
|
87
|
+
fs.writeJSONSync(outputFile, this.logArr, { replacer: null, spaces: 2 })
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Logger.instance = null
|