deeke-script-app 1.7.1 → 1.7.2
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/.vscode/settings.json +1 -0
- package/deekeScript.json +1 -0
- package/deekeScript.schema.json +492 -0
- package/package.json +3 -2
- package/test.json +67 -0
- package/update-types.js +118 -0
package/.vscode/settings.json
CHANGED
package/deekeScript.json
CHANGED
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "DeekeScript 配置文件",
|
|
4
|
+
"description": "DeekeScript Android 项目配置文件,用于动态渲染页面",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["name", "versionCode", "versionName", "icon", "host", "switchSetting", "groups", "bottomMenus", "settingLists", "apis"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "App安装成功之后,在手机上的名称"
|
|
11
|
+
},
|
|
12
|
+
"versionCode": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "版本号(软件自动升级凭证,当前版本号大于或者等于后台上传的版本号,则无法升级)"
|
|
15
|
+
},
|
|
16
|
+
"versionName": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "版本名称,尽量和版本号统一(版本号100,则配置为1.0.0)"
|
|
19
|
+
},
|
|
20
|
+
"icon": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "图标建议采用200*200像素的,清晰度大的"
|
|
23
|
+
},
|
|
24
|
+
"head": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "App中用户设置页面的头像,无设置页可以不填"
|
|
27
|
+
},
|
|
28
|
+
"settingTopBg": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "设置页面顶部背景图"
|
|
31
|
+
},
|
|
32
|
+
"debug": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "默认为true(不需要激活码也可以启动脚本),如果需要激活才能使用APP,请设置为false",
|
|
35
|
+
"default": true
|
|
36
|
+
},
|
|
37
|
+
"host": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "接口请求域名",
|
|
40
|
+
"format": "uri"
|
|
41
|
+
},
|
|
42
|
+
"switchSetting": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"description": "功能开关设置",
|
|
45
|
+
"required": ["alipay"],
|
|
46
|
+
"properties": {
|
|
47
|
+
"alipay": {
|
|
48
|
+
"type": "boolean",
|
|
49
|
+
"description": "支持支付宝支付"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"groups": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"description": "主界面的功能组,每组都会包含若干个功能",
|
|
56
|
+
"items": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"required": ["title", "methods"],
|
|
59
|
+
"properties": {
|
|
60
|
+
"title": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "App主界面的功能名称"
|
|
63
|
+
},
|
|
64
|
+
"titleHidden": {
|
|
65
|
+
"type": "boolean",
|
|
66
|
+
"description": "App主界面功能组标题是否隐藏,默认不隐藏",
|
|
67
|
+
"default": false
|
|
68
|
+
},
|
|
69
|
+
"hidden": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"description": "是否隐藏当前功能组,默认不隐藏",
|
|
72
|
+
"default": false
|
|
73
|
+
},
|
|
74
|
+
"methods": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"description": "当前功能组下的功能列表",
|
|
77
|
+
"items": {
|
|
78
|
+
"$ref": "#/definitions/method"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"bottomMenus": {
|
|
85
|
+
"type": "array",
|
|
86
|
+
"description": "App中底部菜单,可以使用系统内置的,也可以自定义",
|
|
87
|
+
"items": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"required": ["title", "icon", "type"],
|
|
90
|
+
"properties": {
|
|
91
|
+
"title": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"description": "菜单标题,可使用 {NAME} 占位符"
|
|
94
|
+
},
|
|
95
|
+
"icon": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"description": "菜单图标路径"
|
|
98
|
+
},
|
|
99
|
+
"banner": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"description": "横幅图片路径"
|
|
102
|
+
},
|
|
103
|
+
"type": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"description": "菜单类型",
|
|
106
|
+
"enum": ["home", "speech", "setting"]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"settingLists": {
|
|
112
|
+
"type": "array",
|
|
113
|
+
"description": "App中设置页的列表项,可以使用系统内置的,也可以自定义",
|
|
114
|
+
"items": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"required": ["title", "icon", "type"],
|
|
117
|
+
"properties": {
|
|
118
|
+
"title": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"description": "设置项标题"
|
|
121
|
+
},
|
|
122
|
+
"icon": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"description": "设置项图标路径"
|
|
125
|
+
},
|
|
126
|
+
"type": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"description": "设置项类型",
|
|
129
|
+
"enum": ["customerService", "notice", "settingService", "statistics", "uploadLog", "updateApp", "clear", "qiwei"]
|
|
130
|
+
},
|
|
131
|
+
"description": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"description": "设置项描述"
|
|
134
|
+
},
|
|
135
|
+
"file": {
|
|
136
|
+
"type": "string",
|
|
137
|
+
"description": "文件路径(用于 notice 类型)"
|
|
138
|
+
},
|
|
139
|
+
"url": {
|
|
140
|
+
"type": "string",
|
|
141
|
+
"description": "接口URL"
|
|
142
|
+
},
|
|
143
|
+
"jsFile": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"description": "JavaScript文件路径"
|
|
146
|
+
},
|
|
147
|
+
"hidden": {
|
|
148
|
+
"type": "boolean",
|
|
149
|
+
"description": "是否隐藏",
|
|
150
|
+
"default": false
|
|
151
|
+
},
|
|
152
|
+
"settingPage": {
|
|
153
|
+
"$ref": "#/definitions/settingPage"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"apis": {
|
|
159
|
+
"type": "array",
|
|
160
|
+
"description": "设置相关api,比如激活码api,验证激活码是否有效api等",
|
|
161
|
+
"items": {
|
|
162
|
+
"type": "object",
|
|
163
|
+
"required": ["type", "url"],
|
|
164
|
+
"properties": {
|
|
165
|
+
"type": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"description": "API类型",
|
|
168
|
+
"enum": ["bind", "checkBind", "aiSpeechToken", "config", "getToken", "createOrder"]
|
|
169
|
+
},
|
|
170
|
+
"url": {
|
|
171
|
+
"type": "string",
|
|
172
|
+
"description": "API接口路径"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"definitions": {
|
|
179
|
+
"method": {
|
|
180
|
+
"type": "object",
|
|
181
|
+
"required": ["title", "icon"],
|
|
182
|
+
"properties": {
|
|
183
|
+
"title": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"description": "App主界面的功能名称"
|
|
186
|
+
},
|
|
187
|
+
"icon": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"description": "App主界面的功能图标"
|
|
190
|
+
},
|
|
191
|
+
"jsFile": {
|
|
192
|
+
"type": "string",
|
|
193
|
+
"description": "功能实际执行的代码所在文件"
|
|
194
|
+
},
|
|
195
|
+
"settingPage": {
|
|
196
|
+
"$ref": "#/definitions/settingPage"
|
|
197
|
+
},
|
|
198
|
+
"hidden": {
|
|
199
|
+
"type": "boolean",
|
|
200
|
+
"description": "属性值,当为true的时候,则界面上不再显示此功能模块",
|
|
201
|
+
"default": false
|
|
202
|
+
},
|
|
203
|
+
"runType": {
|
|
204
|
+
"type": "string",
|
|
205
|
+
"description": "如果为floatSwitch则需要手动点击右侧悬浮窗执行",
|
|
206
|
+
"enum": ["floatSwitch"]
|
|
207
|
+
},
|
|
208
|
+
"packageName": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"description": "包名,和runType配合使用"
|
|
211
|
+
},
|
|
212
|
+
"columns": {
|
|
213
|
+
"type": "number",
|
|
214
|
+
"description": "每行被等分为24,8则表示当前groups一行放3个功能图标"
|
|
215
|
+
},
|
|
216
|
+
"autoOpen": {
|
|
217
|
+
"type": "boolean",
|
|
218
|
+
"description": "是否自动打开界面(需要和packageName配合使用)"
|
|
219
|
+
},
|
|
220
|
+
"activity": {
|
|
221
|
+
"type": "object",
|
|
222
|
+
"description": "活动配置",
|
|
223
|
+
"properties": {
|
|
224
|
+
"notice": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"description": "活动提示"
|
|
227
|
+
},
|
|
228
|
+
"title": {
|
|
229
|
+
"type": "string",
|
|
230
|
+
"description": "活动标题"
|
|
231
|
+
},
|
|
232
|
+
"minVersion": {
|
|
233
|
+
"type": "number",
|
|
234
|
+
"description": "最小版本号"
|
|
235
|
+
},
|
|
236
|
+
"groups": {
|
|
237
|
+
"type": "array",
|
|
238
|
+
"description": "活动功能组",
|
|
239
|
+
"items": {
|
|
240
|
+
"type": "object",
|
|
241
|
+
"properties": {
|
|
242
|
+
"title": {
|
|
243
|
+
"type": "string"
|
|
244
|
+
},
|
|
245
|
+
"titleHidden": {
|
|
246
|
+
"type": "boolean"
|
|
247
|
+
},
|
|
248
|
+
"methods": {
|
|
249
|
+
"type": "array",
|
|
250
|
+
"items": {
|
|
251
|
+
"$ref": "#/definitions/method"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"settingPage": {
|
|
262
|
+
"type": "object",
|
|
263
|
+
"required": ["params"],
|
|
264
|
+
"properties": {
|
|
265
|
+
"params": {
|
|
266
|
+
"type": "array",
|
|
267
|
+
"description": "需要用户设置的参数",
|
|
268
|
+
"items": {
|
|
269
|
+
"$ref": "#/definitions/param"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
"param": {
|
|
275
|
+
"type": "object",
|
|
276
|
+
"required": ["type"],
|
|
277
|
+
"properties": {
|
|
278
|
+
"type": {
|
|
279
|
+
"type": "string",
|
|
280
|
+
"description": "参数类型",
|
|
281
|
+
"enum": [
|
|
282
|
+
"text",
|
|
283
|
+
"number",
|
|
284
|
+
"numberRange",
|
|
285
|
+
"textArea",
|
|
286
|
+
"switch",
|
|
287
|
+
"radio",
|
|
288
|
+
"checkbox",
|
|
289
|
+
"checkboxGroup",
|
|
290
|
+
"select",
|
|
291
|
+
"date",
|
|
292
|
+
"time",
|
|
293
|
+
"datetime",
|
|
294
|
+
"color",
|
|
295
|
+
"file",
|
|
296
|
+
"image",
|
|
297
|
+
"notice"
|
|
298
|
+
]
|
|
299
|
+
},
|
|
300
|
+
"label": {
|
|
301
|
+
"type": "string",
|
|
302
|
+
"description": "标签文本"
|
|
303
|
+
},
|
|
304
|
+
"name": {
|
|
305
|
+
"type": "string",
|
|
306
|
+
"description": "参数名称(用于存储和获取值)"
|
|
307
|
+
},
|
|
308
|
+
"value": {
|
|
309
|
+
"description": "默认值(类型根据type而定)"
|
|
310
|
+
},
|
|
311
|
+
"hint": {
|
|
312
|
+
"type": "string",
|
|
313
|
+
"description": "提示文本"
|
|
314
|
+
},
|
|
315
|
+
"notice": {
|
|
316
|
+
"type": "string",
|
|
317
|
+
"description": "通知文本"
|
|
318
|
+
},
|
|
319
|
+
"title": {
|
|
320
|
+
"type": "string",
|
|
321
|
+
"description": "标题(用于notice类型)"
|
|
322
|
+
},
|
|
323
|
+
"min": {
|
|
324
|
+
"type": "number",
|
|
325
|
+
"description": "最小值(用于numberRange类型)"
|
|
326
|
+
},
|
|
327
|
+
"max": {
|
|
328
|
+
"type": "number",
|
|
329
|
+
"description": "最大值(用于numberRange类型)"
|
|
330
|
+
},
|
|
331
|
+
"step": {
|
|
332
|
+
"type": "number",
|
|
333
|
+
"description": "步长(用于numberRange类型)"
|
|
334
|
+
},
|
|
335
|
+
"options": {
|
|
336
|
+
"type": "array",
|
|
337
|
+
"description": "选项列表(用于radio、select类型)",
|
|
338
|
+
"items": {
|
|
339
|
+
"type": "object",
|
|
340
|
+
"properties": {
|
|
341
|
+
"label": {
|
|
342
|
+
"type": "string"
|
|
343
|
+
},
|
|
344
|
+
"value": {
|
|
345
|
+
"type": "string"
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
"dataFrom": {
|
|
351
|
+
"type": "string",
|
|
352
|
+
"description": "数据来源(如:role)"
|
|
353
|
+
},
|
|
354
|
+
"children": {
|
|
355
|
+
"type": "array",
|
|
356
|
+
"description": "子选项(用于checkboxGroup类型)",
|
|
357
|
+
"items": {
|
|
358
|
+
"type": "string"
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
"values": {
|
|
362
|
+
"type": "array",
|
|
363
|
+
"description": "值列表(用于checkboxGroup类型)",
|
|
364
|
+
"items": {
|
|
365
|
+
"type": "string"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"columnCount": {
|
|
369
|
+
"type": "number",
|
|
370
|
+
"description": "列数(用于checkboxGroup类型)"
|
|
371
|
+
},
|
|
372
|
+
"lines": {
|
|
373
|
+
"type": "number",
|
|
374
|
+
"description": "行数(用于textArea类型)"
|
|
375
|
+
},
|
|
376
|
+
"textColor": {
|
|
377
|
+
"type": "string",
|
|
378
|
+
"description": "文本颜色(用于notice类型)",
|
|
379
|
+
"pattern": "^#[0-9A-Fa-f]{6}$"
|
|
380
|
+
},
|
|
381
|
+
"textSize": {
|
|
382
|
+
"type": "number",
|
|
383
|
+
"description": "文本大小(用于notice类型)"
|
|
384
|
+
},
|
|
385
|
+
"hidden": {
|
|
386
|
+
"type": "boolean",
|
|
387
|
+
"description": "是否隐藏",
|
|
388
|
+
"default": false
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
"allOf": [
|
|
392
|
+
{
|
|
393
|
+
"if": {
|
|
394
|
+
"properties": {
|
|
395
|
+
"type": {
|
|
396
|
+
"const": "numberRange"
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
"then": {
|
|
401
|
+
"required": ["label", "name", "min", "max", "value"]
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"if": {
|
|
406
|
+
"properties": {
|
|
407
|
+
"type": {
|
|
408
|
+
"const": "textArea"
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
"then": {
|
|
413
|
+
"required": ["label", "name"]
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"if": {
|
|
418
|
+
"properties": {
|
|
419
|
+
"type": {
|
|
420
|
+
"const": "checkboxGroup"
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
"then": {
|
|
425
|
+
"required": ["label", "name", "children", "values"]
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"if": {
|
|
430
|
+
"properties": {
|
|
431
|
+
"type": {
|
|
432
|
+
"const": "switch"
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
"then": {
|
|
437
|
+
"required": ["label", "name"]
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"if": {
|
|
442
|
+
"properties": {
|
|
443
|
+
"type": {
|
|
444
|
+
"const": "radio"
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
"then": {
|
|
449
|
+
"required": ["label", "name"]
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"if": {
|
|
454
|
+
"properties": {
|
|
455
|
+
"type": {
|
|
456
|
+
"const": "text"
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
"then": {
|
|
461
|
+
"required": ["label", "name"]
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"if": {
|
|
466
|
+
"properties": {
|
|
467
|
+
"type": {
|
|
468
|
+
"const": "number"
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
"then": {
|
|
473
|
+
"required": ["label", "name"]
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"if": {
|
|
478
|
+
"properties": {
|
|
479
|
+
"type": {
|
|
480
|
+
"const": "notice"
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
"then": {
|
|
485
|
+
"required": ["title"]
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
]
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deeke-script-app",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "DeekeScript应用",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"build-zip": "rimraf script && cpx \"src/**/*\" script && ts-node --esm ./deekeScriptZipBuild",
|
|
9
9
|
"build-obfuscator": "rimraf script && cpx \"src/**/*\" script && ts-node --esm ./gulpfile",
|
|
10
10
|
"build-obfuscator-zip": "rimraf script && cpx \"src/**/*\" script && ts-node --esm ./gulpfile && ts-node --esm ./deekeScriptZipBuild",
|
|
11
|
-
"postinstall": "ts-node --esm init"
|
|
11
|
+
"postinstall": "ts-node --esm init",
|
|
12
|
+
"update-types": "node update-types.js"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
package/test.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./deekeScript.schema.json",
|
|
3
|
+
"name": "test",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "test",
|
|
6
|
+
"versionCode": "100",
|
|
7
|
+
"versionName": "名称",
|
|
8
|
+
"debug": true,
|
|
9
|
+
"icon": "icon.png",
|
|
10
|
+
"head": "head.png",
|
|
11
|
+
"host": "http://127.0.0.1:8080",
|
|
12
|
+
"switchSetting": {
|
|
13
|
+
"alipay": false
|
|
14
|
+
},
|
|
15
|
+
"settingTopBg": "top.png",
|
|
16
|
+
"groups": [
|
|
17
|
+
{
|
|
18
|
+
"title": "测试",
|
|
19
|
+
"methods": [
|
|
20
|
+
{
|
|
21
|
+
"icon": "icon.png",
|
|
22
|
+
"title": "测试",
|
|
23
|
+
"jsFile": "test.js",
|
|
24
|
+
"settingPage": {
|
|
25
|
+
"params": [
|
|
26
|
+
{
|
|
27
|
+
"label": "标题",
|
|
28
|
+
"name": "title",
|
|
29
|
+
"type": "number"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"apis": [
|
|
38
|
+
{
|
|
39
|
+
"type": "aiSpeechToken",
|
|
40
|
+
"url": "http://127.0.0.1:8080/api/aiSpeechToken"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"bottomMenus": [
|
|
44
|
+
{
|
|
45
|
+
"banner": "banner.png",
|
|
46
|
+
"icon": "icon.png",
|
|
47
|
+
"title": "标题",
|
|
48
|
+
"type": "home"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"settingLists": [
|
|
52
|
+
{
|
|
53
|
+
"title": "设置",
|
|
54
|
+
"icon": "icon.png",
|
|
55
|
+
"type": "clear",
|
|
56
|
+
"settingPage": {
|
|
57
|
+
"params": [
|
|
58
|
+
{
|
|
59
|
+
"label": "标题",
|
|
60
|
+
"name": "title",
|
|
61
|
+
"type": "number"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
package/update-types.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const PROJECT_ROOT = __dirname;
|
|
6
|
+
const TYPES_FOLDER = path.join(PROJECT_ROOT, '@deekeScript');
|
|
7
|
+
const TEMP_DIR = path.join(PROJECT_ROOT, '.temp-update');
|
|
8
|
+
const PACKAGE_NAME = 'deeke-script-app';
|
|
9
|
+
|
|
10
|
+
// 颜色输出
|
|
11
|
+
const colors = {
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
green: '\x1b[32m',
|
|
14
|
+
yellow: '\x1b[33m',
|
|
15
|
+
red: '\x1b[31m',
|
|
16
|
+
blue: '\x1b[34m',
|
|
17
|
+
cyan: '\x1b[36m'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function log(message, color = 'reset') {
|
|
21
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 清理临时目录
|
|
25
|
+
function cleanup() {
|
|
26
|
+
if (fs.existsSync(TEMP_DIR)) {
|
|
27
|
+
fs.rmSync(TEMP_DIR, { recursive: true, force: true });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 从npm更新
|
|
32
|
+
async function updateFromNpm() {
|
|
33
|
+
log('\n📦 从npm更新类型定义文件...', 'cyan');
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// 检查npm包是否存在
|
|
37
|
+
log('检查npm包版本...', 'blue');
|
|
38
|
+
const latestVersion = execSync(`npm view ${PACKAGE_NAME} version`, { encoding: 'utf-8' }).trim();
|
|
39
|
+
log(`最新版本: ${latestVersion}`, 'green');
|
|
40
|
+
|
|
41
|
+
// 创建临时目录
|
|
42
|
+
if (!fs.existsSync(TEMP_DIR)) {
|
|
43
|
+
fs.mkdirSync(TEMP_DIR, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const tempPackageDir = path.join(TEMP_DIR, 'node_modules', PACKAGE_NAME);
|
|
47
|
+
|
|
48
|
+
// 在临时目录安装npm包
|
|
49
|
+
log('下载并安装npm包...', 'blue');
|
|
50
|
+
const packageJsonPath = path.join(TEMP_DIR, 'package.json');
|
|
51
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify({
|
|
52
|
+
name: 'temp-update',
|
|
53
|
+
version: '1.0.0',
|
|
54
|
+
dependencies: {
|
|
55
|
+
[PACKAGE_NAME]: 'latest'
|
|
56
|
+
}
|
|
57
|
+
}, null, 2));
|
|
58
|
+
|
|
59
|
+
execSync('npm install', {
|
|
60
|
+
cwd: TEMP_DIR,
|
|
61
|
+
stdio: 'pipe',
|
|
62
|
+
env: { ...process.env, npm_config_progress: 'false' }
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// 检查@deekeScript文件夹是否存在
|
|
66
|
+
const sourceTypesFolder = path.join(tempPackageDir, '@deekeScript');
|
|
67
|
+
if (!fs.existsSync(sourceTypesFolder)) {
|
|
68
|
+
throw new Error('npm包中未找到@deekeScript文件夹');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 备份现有文件夹
|
|
72
|
+
if (fs.existsSync(TYPES_FOLDER)) {
|
|
73
|
+
log('备份现有类型定义文件...', 'yellow');
|
|
74
|
+
const backupFolder = path.join(PROJECT_ROOT, '@deekeScript.backup');
|
|
75
|
+
if (fs.existsSync(backupFolder)) {
|
|
76
|
+
fs.rmSync(backupFolder, { recursive: true, force: true });
|
|
77
|
+
}
|
|
78
|
+
fs.cpSync(TYPES_FOLDER, backupFolder, { recursive: true });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 删除旧文件夹并复制新文件夹
|
|
82
|
+
if (fs.existsSync(TYPES_FOLDER)) {
|
|
83
|
+
fs.rmSync(TYPES_FOLDER, { recursive: true, force: true });
|
|
84
|
+
}
|
|
85
|
+
fs.cpSync(sourceTypesFolder, TYPES_FOLDER, { recursive: true });
|
|
86
|
+
|
|
87
|
+
log('✅ 类型定义文件更新成功!', 'green');
|
|
88
|
+
log(`已更新到版本: ${latestVersion}`, 'green');
|
|
89
|
+
|
|
90
|
+
} catch (error) {
|
|
91
|
+
log(`❌ 从npm更新失败: ${error.message}`, 'red');
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 主函数
|
|
97
|
+
async function main() {
|
|
98
|
+
log('🚀 开始更新@deekeScript类型定义文件...', 'cyan');
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
// 确保在项目根目录
|
|
102
|
+
if (!fs.existsSync(path.join(PROJECT_ROOT, 'package.json'))) {
|
|
103
|
+
throw new Error('请在项目根目录运行此脚本');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
await updateFromNpm();
|
|
107
|
+
|
|
108
|
+
} catch (error) {
|
|
109
|
+
log(`\n❌ 更新失败: ${error.message}`, 'red');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
} finally {
|
|
112
|
+
// 清理临时文件
|
|
113
|
+
cleanup();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 运行主函数
|
|
118
|
+
main();
|