v-transform 2.1.0 → 2.2.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/.trunk/trunk.yaml +5 -0
- package/dist/blindDate/dimension.json +138 -0
- package/dist/lifeRestart/en-us/achievement.json +1487 -0
- package/dist/lifeRestart/en-us/age.json +71820 -0
- package/dist/lifeRestart/en-us/character.json +1594 -0
- package/dist/lifeRestart/en-us/events.json +13164 -0
- package/dist/lifeRestart/en-us/talents.json +1817 -0
- package/dist/lifeRestart/specialthanks.json +4591 -0
- package/dist/lifeRestart/zh-cn/achievement.json +1487 -0
- package/dist/lifeRestart/zh-cn/age.json +71820 -0
- package/dist/lifeRestart/zh-cn/character.json +1594 -0
- package/dist/lifeRestart/zh-cn/events.json +13164 -0
- package/dist/lifeRestart/zh-cn/talents.json +1817 -0
- package/dist/motleycrowd/achievement.json +1513 -0
- package/dist/motleycrowd/badge.json +1587 -0
- package/dist/motleycrowd/card.json +22 -0
- package/dist/motleycrowd/reward.json +884 -0
- package/dist/question/question.json +1306 -0
- package/dist/question/result.json +260 -0
- package/package.json +26 -26
- package/src/dump.js +34 -31
- package/src/index.js +25 -25
- package/src/loader.js +49 -49
- package/src/parser.js +117 -134
- package/src/prepare.js +16 -19
- package/src/transform.js +61 -59
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
{
|
|
2
|
+
"101": {
|
|
3
|
+
"id": 101,
|
|
4
|
+
"result": {
|
|
5
|
+
"description": "情商爆表的"
|
|
6
|
+
},
|
|
7
|
+
"condition": "EQ>=18"
|
|
8
|
+
},
|
|
9
|
+
"102": {
|
|
10
|
+
"id": 102,
|
|
11
|
+
"result": {
|
|
12
|
+
"description": "情商很高的"
|
|
13
|
+
},
|
|
14
|
+
"condition": "(EQ>=10)&(EQ<18)"
|
|
15
|
+
},
|
|
16
|
+
"103": {
|
|
17
|
+
"id": 103,
|
|
18
|
+
"result": {
|
|
19
|
+
"description": "情商较高的"
|
|
20
|
+
},
|
|
21
|
+
"condition": "(EQ>=1)&(EQ<10)"
|
|
22
|
+
},
|
|
23
|
+
"104": {
|
|
24
|
+
"id": 104,
|
|
25
|
+
"result": {
|
|
26
|
+
"description": "情商进步空间较大的"
|
|
27
|
+
},
|
|
28
|
+
"condition": "(EQ>=-6)&(EQ<1)"
|
|
29
|
+
},
|
|
30
|
+
"105": {
|
|
31
|
+
"id": 105,
|
|
32
|
+
"result": {
|
|
33
|
+
"description": "情商进步空间很大的"
|
|
34
|
+
},
|
|
35
|
+
"condition": "(EQ>=-12)&(EQ<-6)"
|
|
36
|
+
},
|
|
37
|
+
"106": {
|
|
38
|
+
"id": 106,
|
|
39
|
+
"result": {
|
|
40
|
+
"description": "情商进步空间爆表的"
|
|
41
|
+
},
|
|
42
|
+
"condition": "EQ<-12"
|
|
43
|
+
},
|
|
44
|
+
"201": {
|
|
45
|
+
"id": 201,
|
|
46
|
+
"result": {
|
|
47
|
+
"description": "哲学家型的",
|
|
48
|
+
"addition": "INFP",
|
|
49
|
+
"types": "内向 直觉 情感 感知"
|
|
50
|
+
},
|
|
51
|
+
"condition": "(EI<=0)&(SN<=0)&(TF<=0)&(JP<=0)"
|
|
52
|
+
},
|
|
53
|
+
"202": {
|
|
54
|
+
"id": 202,
|
|
55
|
+
"result": {
|
|
56
|
+
"description": "学者型的",
|
|
57
|
+
"addition": "INTP",
|
|
58
|
+
"types": "内向 直觉 逻辑 感知"
|
|
59
|
+
},
|
|
60
|
+
"condition": "(EI<=0)&(SN<=0)&(TF>0)&(JP<=0)"
|
|
61
|
+
},
|
|
62
|
+
"203": {
|
|
63
|
+
"id": 203,
|
|
64
|
+
"result": {
|
|
65
|
+
"description": "作家型的",
|
|
66
|
+
"addition": "INFJ",
|
|
67
|
+
"types": "内向 直觉 情感 判断"
|
|
68
|
+
},
|
|
69
|
+
"condition": "(EI<=0)&(SN<=0)&(TF<=0)&(JP>0)"
|
|
70
|
+
},
|
|
71
|
+
"204": {
|
|
72
|
+
"id": 204,
|
|
73
|
+
"result": {
|
|
74
|
+
"description": "专家型的",
|
|
75
|
+
"addition": "INTJ",
|
|
76
|
+
"types": "内向 直觉 逻辑 判断"
|
|
77
|
+
},
|
|
78
|
+
"condition": "(EI<=0)&(SN<=0)&(TF>0)&(JP>0)"
|
|
79
|
+
},
|
|
80
|
+
"205": {
|
|
81
|
+
"id": 205,
|
|
82
|
+
"result": {
|
|
83
|
+
"description": "艺术家型的",
|
|
84
|
+
"addition": "ISFP",
|
|
85
|
+
"types": "内向 经验 情感 感知"
|
|
86
|
+
},
|
|
87
|
+
"condition": "(EI<=0)&(SN>0)&(TF<=0)&(JP<=0)"
|
|
88
|
+
},
|
|
89
|
+
"206": {
|
|
90
|
+
"id": 206,
|
|
91
|
+
"result": {
|
|
92
|
+
"description": "匠人型的",
|
|
93
|
+
"addition": "ISTP",
|
|
94
|
+
"types": "内向 经验 逻辑 感知"
|
|
95
|
+
},
|
|
96
|
+
"condition": "(EI<=0)&(SN>0)&(TF>0)&(JP<=0)"
|
|
97
|
+
},
|
|
98
|
+
"207": {
|
|
99
|
+
"id": 207,
|
|
100
|
+
"result": {
|
|
101
|
+
"description": "保护者型的",
|
|
102
|
+
"addition": "ISFJ",
|
|
103
|
+
"types": "内向 经验 情感 判断"
|
|
104
|
+
},
|
|
105
|
+
"condition": "(EI<=0)&(SN>0)&(TF<=0)&(JP>0)"
|
|
106
|
+
},
|
|
107
|
+
"208": {
|
|
108
|
+
"id": 208,
|
|
109
|
+
"result": {
|
|
110
|
+
"description": "调查者型的",
|
|
111
|
+
"addition": "ISTJ",
|
|
112
|
+
"types": "内向 经验 逻辑 判断"
|
|
113
|
+
},
|
|
114
|
+
"condition": "(EI<=0)&(SN>0)&(TF>0)&(JP>0)"
|
|
115
|
+
},
|
|
116
|
+
"209": {
|
|
117
|
+
"id": 209,
|
|
118
|
+
"result": {
|
|
119
|
+
"description": "追梦人型的",
|
|
120
|
+
"addition": "ENFP",
|
|
121
|
+
"types": "外向 直觉 情感 感知"
|
|
122
|
+
},
|
|
123
|
+
"condition": "(EI>0)&(SN<=0)&(TF<=0)&(JP<=0)"
|
|
124
|
+
},
|
|
125
|
+
"210": {
|
|
126
|
+
"id": 210,
|
|
127
|
+
"result": {
|
|
128
|
+
"description": "发明家型的",
|
|
129
|
+
"addition": "ENTP",
|
|
130
|
+
"types": "外向 直觉 逻辑 感知"
|
|
131
|
+
},
|
|
132
|
+
"condition": "(EI>0)&(SN<=0)&(TF>0)&(JP<=0)"
|
|
133
|
+
},
|
|
134
|
+
"211": {
|
|
135
|
+
"id": 211,
|
|
136
|
+
"result": {
|
|
137
|
+
"description": "主人公型的",
|
|
138
|
+
"addition": "ENFJ",
|
|
139
|
+
"types": "外向 直觉 情感 判断"
|
|
140
|
+
},
|
|
141
|
+
"condition": "(EI>0)&(SN<=0)&(TF<=0)&(JP>0)"
|
|
142
|
+
},
|
|
143
|
+
"212": {
|
|
144
|
+
"id": 212,
|
|
145
|
+
"result": {
|
|
146
|
+
"description": "指挥官型的",
|
|
147
|
+
"addition": "ENTJ",
|
|
148
|
+
"types": "外向 直觉 逻辑 判断"
|
|
149
|
+
},
|
|
150
|
+
"condition": "(EI>0)&(SN<=0)&(TF>0)&(JP>0)"
|
|
151
|
+
},
|
|
152
|
+
"213": {
|
|
153
|
+
"id": 213,
|
|
154
|
+
"result": {
|
|
155
|
+
"description": "表演者型的",
|
|
156
|
+
"addition": "ESFP",
|
|
157
|
+
"types": "外向 经验 情感 感知"
|
|
158
|
+
},
|
|
159
|
+
"condition": "(EI>0)&(SN>0)&(TF<=0)&(JP<=0)"
|
|
160
|
+
},
|
|
161
|
+
"214": {
|
|
162
|
+
"id": 214,
|
|
163
|
+
"result": {
|
|
164
|
+
"description": "挑战者型的",
|
|
165
|
+
"addition": "ESTP",
|
|
166
|
+
"types": "外向 经验 逻辑 感知"
|
|
167
|
+
},
|
|
168
|
+
"condition": "(EI>0)&(SN>0)&(TF>0)&(JP<=0)"
|
|
169
|
+
},
|
|
170
|
+
"215": {
|
|
171
|
+
"id": 215,
|
|
172
|
+
"result": {
|
|
173
|
+
"description": "供给者型的",
|
|
174
|
+
"addition": "ESFJ",
|
|
175
|
+
"types": "外向 经验 情感 判断"
|
|
176
|
+
},
|
|
177
|
+
"condition": "(EI>0)&(SN>0)&(TF<=0)&(JP>0)"
|
|
178
|
+
},
|
|
179
|
+
"216": {
|
|
180
|
+
"id": 216,
|
|
181
|
+
"result": {
|
|
182
|
+
"description": "监管者型的",
|
|
183
|
+
"addition": "ESTJ",
|
|
184
|
+
"types": "外向 经验 逻辑 判断"
|
|
185
|
+
},
|
|
186
|
+
"condition": "(EI>0)&(SN>0)&(TF>0)&(JP>0)"
|
|
187
|
+
},
|
|
188
|
+
"301": {
|
|
189
|
+
"id": 301,
|
|
190
|
+
"result": {
|
|
191
|
+
"description": "守序善良",
|
|
192
|
+
"addition": "的"
|
|
193
|
+
},
|
|
194
|
+
"condition": "(OR>9)&(GD>8)"
|
|
195
|
+
},
|
|
196
|
+
"302": {
|
|
197
|
+
"id": 302,
|
|
198
|
+
"result": {
|
|
199
|
+
"description": "中立善良",
|
|
200
|
+
"addition": "的"
|
|
201
|
+
},
|
|
202
|
+
"condition": "(OR>-5)&(OR<=9)&(GD>8)"
|
|
203
|
+
},
|
|
204
|
+
"303": {
|
|
205
|
+
"id": 303,
|
|
206
|
+
"result": {
|
|
207
|
+
"description": "混乱善良",
|
|
208
|
+
"addition": "的"
|
|
209
|
+
},
|
|
210
|
+
"condition": "(OR<=-5)&(GD>8)"
|
|
211
|
+
},
|
|
212
|
+
"304": {
|
|
213
|
+
"id": 304,
|
|
214
|
+
"result": {
|
|
215
|
+
"description": "守序中立",
|
|
216
|
+
"addition": "的"
|
|
217
|
+
},
|
|
218
|
+
"condition": "(OR>9)&(GD>-1)&(GD<=8)"
|
|
219
|
+
},
|
|
220
|
+
"305": {
|
|
221
|
+
"id": 305,
|
|
222
|
+
"result": {
|
|
223
|
+
"description": "绝对中立",
|
|
224
|
+
"addition": "的"
|
|
225
|
+
},
|
|
226
|
+
"condition": "(OR>-5)&(OR<=9)&(GD>-1)&(GD<=8)"
|
|
227
|
+
},
|
|
228
|
+
"306": {
|
|
229
|
+
"id": 306,
|
|
230
|
+
"result": {
|
|
231
|
+
"description": "混乱中立",
|
|
232
|
+
"addition": "的"
|
|
233
|
+
},
|
|
234
|
+
"condition": "(OR<=-5)&(GD>-1)&(GD<=8)"
|
|
235
|
+
},
|
|
236
|
+
"307": {
|
|
237
|
+
"id": 307,
|
|
238
|
+
"result": {
|
|
239
|
+
"description": "守序邪恶",
|
|
240
|
+
"addition": "的"
|
|
241
|
+
},
|
|
242
|
+
"condition": "(OR>9)&(GD<=-1)"
|
|
243
|
+
},
|
|
244
|
+
"308": {
|
|
245
|
+
"id": 308,
|
|
246
|
+
"result": {
|
|
247
|
+
"description": "中立邪恶",
|
|
248
|
+
"addition": "的"
|
|
249
|
+
},
|
|
250
|
+
"condition": "(OR>-5)&(OR<=9)&(GD<=-1)"
|
|
251
|
+
},
|
|
252
|
+
"309": {
|
|
253
|
+
"id": 309,
|
|
254
|
+
"result": {
|
|
255
|
+
"description": "混乱邪恶",
|
|
256
|
+
"addition": "的"
|
|
257
|
+
},
|
|
258
|
+
"condition": "(OR<=-5)&(GD<=-1)"
|
|
259
|
+
}
|
|
260
|
+
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "v-transform",
|
|
3
|
-
"bin": {
|
|
4
|
-
"vt": "src/index.js"
|
|
5
|
-
},
|
|
6
|
-
"type": "module",
|
|
7
|
-
"version": "2.
|
|
8
|
-
"main": "index.js",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "v-transform",
|
|
3
|
+
"bin": {
|
|
4
|
+
"vt": "src/index.js"
|
|
5
|
+
},
|
|
6
|
+
"type": "module",
|
|
7
|
+
"version": "2.2.0",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/VickScarlet/vTransform.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "Vick Scarlet <scarlet_vick@outlook.com>",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"commander": "^14.0.2",
|
|
17
|
+
"glob": "^13.0.0",
|
|
18
|
+
"js-yaml": "^4.1.1",
|
|
19
|
+
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "npx rimraf test",
|
|
23
|
+
"vt": "node src/index.js",
|
|
24
|
+
"transform": "node src/index.js transform"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/dump.js
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
1
|
-
import yaml from 'js-yaml'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { writeFile, stat, mkdir } from 'fs/promises'
|
|
1
|
+
import yaml from 'js-yaml'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { writeFile, stat, mkdir } from 'node:fs/promises'
|
|
4
4
|
|
|
5
5
|
function jsonify(data, space) {
|
|
6
|
-
return JSON.stringify(data, null, space)
|
|
6
|
+
return JSON.stringify(data, null, space)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function cjsify(data, space) {
|
|
10
|
-
return `module.exports = ${jsonify(data, space)}
|
|
10
|
+
return `module.exports = ${jsonify(data, space)}`
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function esmify(data, space) {
|
|
14
|
-
return `export default ${jsonify(data, space)}
|
|
14
|
+
return `export default ${jsonify(data, space)}`
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function yamlify(data, space) {
|
|
18
18
|
return yaml.dump(data, {
|
|
19
19
|
indent: space || undefined,
|
|
20
|
-
})
|
|
20
|
+
})
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function mkdirs(dir) {
|
|
24
24
|
try {
|
|
25
|
-
await stat(dir)
|
|
26
|
-
} catch(e) {
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
await stat(dir)
|
|
26
|
+
} catch (e) {
|
|
27
|
+
if (e.code !== 'ENOENT') {
|
|
28
|
+
throw e
|
|
29
|
+
}
|
|
30
|
+
await mkdirs(path.dirname(dir))
|
|
31
|
+
await mkdir(dir)
|
|
29
32
|
}
|
|
30
|
-
}
|
|
33
|
+
}
|
|
31
34
|
|
|
32
35
|
async function write(sheet, data) {
|
|
33
|
-
console.info(`Dump ${sheet}`)
|
|
34
|
-
await mkdirs(path.dirname(sheet))
|
|
35
|
-
await writeFile(sheet, data)
|
|
36
|
+
console.info(`Dump ${sheet}`)
|
|
37
|
+
await mkdirs(path.dirname(sheet))
|
|
38
|
+
await writeFile(sheet, data)
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
export async function dump(sheet, data, type, space) {
|
|
39
|
-
let ext, ify
|
|
40
|
-
switch(type) {
|
|
42
|
+
let ext, ify
|
|
43
|
+
switch (type) {
|
|
41
44
|
case 'cjs':
|
|
42
|
-
ext = '.js'
|
|
43
|
-
ify = cjsify
|
|
44
|
-
break
|
|
45
|
+
ext = '.js'
|
|
46
|
+
ify = cjsify
|
|
47
|
+
break
|
|
45
48
|
case 'js':
|
|
46
49
|
case 'mjs':
|
|
47
50
|
case 'esm':
|
|
48
|
-
ext = '.js'
|
|
49
|
-
ify = esmify
|
|
50
|
-
break
|
|
51
|
+
ext = '.js'
|
|
52
|
+
ify = esmify
|
|
53
|
+
break
|
|
51
54
|
case 'yaml':
|
|
52
55
|
case 'yml':
|
|
53
|
-
ext = '.yaml'
|
|
54
|
-
ify = yamlify
|
|
55
|
-
break
|
|
56
|
+
ext = '.yaml'
|
|
57
|
+
ify = yamlify
|
|
58
|
+
break
|
|
56
59
|
case 'json':
|
|
57
60
|
default:
|
|
58
|
-
ext = '.json'
|
|
59
|
-
ify = jsonify
|
|
60
|
-
break
|
|
61
|
+
ext = '.json'
|
|
62
|
+
ify = jsonify
|
|
63
|
+
break
|
|
61
64
|
}
|
|
62
|
-
return write(`${sheet}${ext}`, ify(data, space))
|
|
63
|
-
}
|
|
65
|
+
return write(`${sheet}${ext}`, ify(data, space))
|
|
66
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander'
|
|
3
|
-
import { readFile } from 'fs/promises'
|
|
4
|
-
import { transform } from './transform.js'
|
|
2
|
+
import { Command } from 'commander'
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { transform } from './transform.js'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const program = new Command()
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
program.name('vt')
|
|
9
|
+
program.version(JSON.parse(await readFile('package.json')).version)
|
|
10
|
+
program
|
|
11
|
+
.command('transform [list...]')
|
|
12
|
+
.option(
|
|
13
|
+
'-t, --type <type>',
|
|
14
|
+
'type of transform, available: js, esm, cjs, json',
|
|
15
|
+
'json',
|
|
16
|
+
)
|
|
17
|
+
.option('-s, --space <space>', 'format space number', 0)
|
|
18
|
+
.option('-c, --config <config>', 'configure file', null)
|
|
19
|
+
.option('-w, --cwd <cwd>', 'current work dir', null)
|
|
20
|
+
.option('-o, --output <output>', 'output dir', null)
|
|
21
|
+
.option('-d, --dest <dest>', 'dest dir', null)
|
|
22
|
+
.option('-a, --addition', 'addition version', false)
|
|
23
|
+
.action((list, options) => {
|
|
24
|
+
if (!options.dest) options.dest = options.output
|
|
25
|
+
options.list = list
|
|
26
|
+
transform(options)
|
|
27
|
+
})
|
|
9
28
|
|
|
10
|
-
|
|
11
|
-
program.version(JSON.parse(await readFile('package.json')).version);
|
|
12
|
-
program
|
|
13
|
-
.command('transform [list...]')
|
|
14
|
-
.option('-t, --type <type>', 'type of transform, available: js, esm, cjs, json', 'json')
|
|
15
|
-
.option('-s, --space <space>', 'format space number', 0)
|
|
16
|
-
.option('-c, --config <config>', 'configure file', null)
|
|
17
|
-
.option('-w, --cwd <cwd>', 'current work dir', null)
|
|
18
|
-
.option('-o, --output <output>', 'output dir', null)
|
|
19
|
-
.option('-d, --dest <dest>', 'dest dir', null)
|
|
20
|
-
.option('-a, --addition', 'addition version', false)
|
|
21
|
-
.action((list, options) => {
|
|
22
|
-
if (!options.dest) options.dest = options.output;
|
|
23
|
-
options.list = list;
|
|
24
|
-
transform(options);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
program.parse(process.argv);
|
|
28
|
-
|
|
29
|
-
})();
|
|
29
|
+
program.parse(process.argv)
|
package/src/loader.js
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
import glob from 'glob'
|
|
2
|
-
import yaml from 'js-yaml'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import { readFile } from 'fs/promises'
|
|
1
|
+
import { glob } from 'glob'
|
|
2
|
+
import yaml from 'js-yaml'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { readFile } from 'node:fs/promises'
|
|
5
5
|
|
|
6
6
|
export async function load({ type, space, config, dest, list, cwd, addition }) {
|
|
7
|
-
const version = new Date().toISOString()
|
|
8
|
-
type = type || 'json'
|
|
9
|
-
cwd = cwd || process.cwd()
|
|
10
|
-
space = Number(space) || 0
|
|
11
|
-
dest = dest || cwd
|
|
12
|
-
const def = { cwd, type, space, dest, addition }
|
|
13
|
-
const m = (...l) => globit(Object.assign({}, ...l))
|
|
14
|
-
const cfgs = []
|
|
7
|
+
const version = new Date().toISOString()
|
|
8
|
+
type = type || 'json'
|
|
9
|
+
cwd = cwd || process.cwd()
|
|
10
|
+
space = Number(space) || 0
|
|
11
|
+
dest = dest || cwd
|
|
12
|
+
const def = { cwd, type, space, dest, addition }
|
|
13
|
+
const m = (...l) => globit(Object.assign({}, ...l))
|
|
14
|
+
const cfgs = []
|
|
15
15
|
|
|
16
|
-
if (list?.length)
|
|
17
|
-
cfgs.unshift(await m(def, { glob: list }));
|
|
16
|
+
if (list?.length) cfgs.unshift(await m(def, { glob: list }))
|
|
18
17
|
|
|
19
18
|
if (config) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const cdef = {};
|
|
23
|
-
if (c.cwd) cdef.cwd = path.resolve(dir, c.cwd);
|
|
24
|
-
if (c.type) cdef.type = c.type;
|
|
25
|
-
if (typeof c.space == 'number') cdef.space = c.space;
|
|
26
|
-
if (c.dest) cdef.dest = path.resolve(dir, c.dest);
|
|
27
|
-
for (const cfg of c.configurations) {
|
|
28
|
-
if (cfg.cwd) cfg.cwd = path.resolve(dir, cfg.cwd);
|
|
29
|
-
if (cfg.dest) cfg.dest = path.resolve(dir, cfg.dest);
|
|
30
|
-
cfgs.push(await m(def, cdef, cfg));
|
|
31
|
-
}
|
|
19
|
+
const cfgData = await loadConfigData(config, def, m)
|
|
20
|
+
cfgs.push(...cfgData)
|
|
32
21
|
}
|
|
33
22
|
|
|
34
|
-
for (const cfg of cfgs)
|
|
35
|
-
if (cfg.addition)
|
|
36
|
-
|
|
23
|
+
for (const cfg of cfgs) {
|
|
24
|
+
if (cfg.addition) cfg.addition = { version, timestamp: version }
|
|
25
|
+
}
|
|
37
26
|
|
|
38
|
-
return cfgs
|
|
27
|
+
return cfgs
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function loadConfigData(config, def, m) {
|
|
31
|
+
const c = await loadConfig(config)
|
|
32
|
+
const dir = path.dirname(config)
|
|
33
|
+
const cdef = {}
|
|
34
|
+
if (c.cwd) cdef.cwd = path.resolve(dir, c.cwd)
|
|
35
|
+
if (c.type) cdef.type = c.type
|
|
36
|
+
if (typeof c.space == 'number') cdef.space = c.space
|
|
37
|
+
if (c.dest) cdef.dest = path.resolve(dir, c.dest)
|
|
38
|
+
const cfgs = []
|
|
39
|
+
|
|
40
|
+
for (const cfg of c.configurations) {
|
|
41
|
+
if (cfg.cwd) cfg.cwd = path.resolve(dir, cfg.cwd)
|
|
42
|
+
if (cfg.dest) cfg.dest = path.resolve(dir, cfg.dest)
|
|
43
|
+
cfgs.push(await m(def, cdef, cfg))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return cfgs
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
async function loadConfig(config) {
|
|
@@ -43,30 +51,22 @@ async function loadConfig(config) {
|
|
|
43
51
|
case '.json':
|
|
44
52
|
case '.yaml':
|
|
45
53
|
case '.yml':
|
|
46
|
-
return yaml.load(
|
|
47
|
-
await readFile(config)
|
|
48
|
-
);
|
|
54
|
+
return yaml.load(await readFile(config))
|
|
49
55
|
case '.js':
|
|
50
56
|
case '.mjs':
|
|
51
|
-
return (await import(config)).default
|
|
57
|
+
return (await import(config)).default
|
|
52
58
|
default:
|
|
53
|
-
throw new Error(`Unknown config file type: ${config}`)
|
|
59
|
+
throw new Error(`Unknown config file type: ${config}`)
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
async function globit(options) {
|
|
58
|
-
const { glob: gs, cwd } = options
|
|
59
|
-
const files = []
|
|
60
|
-
const g = p =>
|
|
61
|
-
|
|
62
|
-
))
|
|
63
|
-
|
|
64
|
-
for (const p of gs)
|
|
65
|
-
files.push(...await g(p));
|
|
66
|
-
else if (typeof gs == 'string')
|
|
67
|
-
files.push(...await g(gs));
|
|
68
|
-
else
|
|
69
|
-
throw new Error(`Unknown glob type: ${gs}`);
|
|
64
|
+
const { glob: gs, cwd } = options
|
|
65
|
+
const files = []
|
|
66
|
+
const g = p => glob(p, { cwd })
|
|
67
|
+
if (Array.isArray(gs)) for (const p of gs) files.push(...(await g(p)))
|
|
68
|
+
else if (typeof gs == 'string') files.push(...(await g(gs)))
|
|
69
|
+
else throw new Error(`Unknown glob type: ${gs}`)
|
|
70
70
|
|
|
71
|
-
return
|
|
72
|
-
}
|
|
71
|
+
return { ...options, files }
|
|
72
|
+
}
|