@k3000/s1 0.1.8 → 0.2.1

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/bin.mjs CHANGED
@@ -65,7 +65,7 @@ function init(override) {
65
65
  myCopyFn('谨慎打开', '谨慎打开', override)
66
66
  myCopyFn('build.mjs', 'build.mjs', override)
67
67
  myCopyFn('index.mjs', 'index.mjs', override)
68
- myCopyFn('package.json', 'package.json', override)
68
+ myCopyFn('files/package.json', 'package.json', override)
69
69
 
70
70
  // pm2.del(uiService)
71
71
  // pm2.add(uiService, './backstage/index.mjs')
package/build.mjs CHANGED
@@ -1,25 +1,17 @@
1
- /*import {build} from '@k3000/build'
1
+ import {build} from '@k3000/build'
2
+ import {copyDir} from "./common/tools.mjs";
3
+ import {existsSync, mkdirSync} from 'node:fs'
2
4
 
3
- // build('admin', 'index', 'admin') // 打包
4
- // build('jwt', 'index', 'jwt') // 打包
5
- // build('proxy', 'index', 'proxy') // 打包
6
- build('test', {
7
- target: 'index2.mjs',
8
- except: ['test/a']
9
- }) // 打包*/
10
-
11
- // import './test/index.mjs'
12
- import './index2.mjs'
13
-
14
- /*import {build} from '@k3000/build'
15
-
16
- // build('admin', 'index', 'admin') // 打包
17
- // build('jwt', 'index', 'jwt') // 打包
18
- // build('proxy', 'index', 'proxy') // 打包
5
+ build('admin', 'bin/admin') // 打包
6
+ build('jwt', 'bin/jwt') // 打包
7
+ build('proxy', 'bin/proxy') // 打包
19
8
  build('store1', {
20
- target: 'store1/index2.mjs',
9
+ target: 'bin/store1',
21
10
  except: ['store1/store']
22
- }) // 打包*/
11
+ }) // 打包
12
+
13
+ if (!existsSync('bin')) mkdirSync('bin')
23
14
 
24
- // import './store1/index.mjs'
25
- // import './store1/index2.mjs'
15
+ copyDir('common', 'bin/common')
16
+ copyDir('static', 'bin/static')
17
+ copyDir('package.json', 'bin')
package/common/tools.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import {Cipher} from "@k3000/tools";
2
- import {jwtLifetime, jwtSalt} from "./config.mjs";
3
- import {readdirSync, statSync} from "node:fs";
2
+ import {jwtLifetime, jwtSalt, staticDir} from "./config.mjs";
3
+ import {existsSync, mkdirSync, readdirSync, statSync, readFileSync, appendFileSync} from "node:fs";
4
+ import {basename} from "node:path";
4
5
 
5
6
  /**
6
7
  * 生成固定格式数据
@@ -312,3 +313,39 @@ export const rowSlice = (rows, index, size) => {
312
313
  return rows.slice((index - 1) * size, index * size)
313
314
  }
314
315
 
316
+ export const copyDir = (source, target) => {
317
+
318
+ if (!existsSync(source)) return
319
+
320
+ const stat = statSync(source)
321
+
322
+ if (stat.isDirectory()) {
323
+
324
+ if (!existsSync(target)) {
325
+
326
+ mkdirSync(target)
327
+ }
328
+
329
+ for (const name of readdirSync(source)) {
330
+
331
+ copyDir(`${source}/${name}`, `${target}/${name}`)
332
+ }
333
+
334
+ } else if (stat.isFile()) {
335
+
336
+ if (existsSync(target) && statSync(target).isDirectory()) {
337
+
338
+ if (!existsSync(target)) {
339
+
340
+ mkdirSync(target)
341
+ }
342
+
343
+ target = `${target}/${basename(source)}`
344
+ }
345
+
346
+ if (!existsSync(target)) {
347
+
348
+ appendFileSync(target, readFileSync(source))
349
+ }
350
+ }
351
+ }
@@ -4,10 +4,11 @@
4
4
  "store1": "node store1/index.mjs",
5
5
  "proxy": "node proxy/index.mjs",
6
6
  "jwt": "node jwt/index.mjs",
7
- "app": "node app/index.mjs"
7
+ "app": "node app/index.mjs",
8
+ "build": "node build.mjs"
8
9
  },
9
10
  "dependencies": {
10
- "@k3000/build": "^0.1.1",
11
+ "@k3000/build": "^0.1.2",
11
12
  "@k3000/express": "^0.1.1",
12
13
  "@k3000/info": "^0.1.0",
13
14
  "@k3000/mysql": "^0.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k3000/s1",
3
- "version": "0.1.8",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "sync": "npm link",
@@ -1,468 +0,0 @@
1
- import {jwtPort, store1Port} from "./config.mjs";
2
-
3
- export const service = {
4
- store1: {
5
- /**
6
- * @type {Function}
7
- * @return {Promise<Array<String>>}
8
- */
9
- getSetList: `localhost:${store1Port}/getSetList`,
10
- /**
11
- * 登录
12
- * @type {Function}
13
- * @param {{
14
- * userName: String,
15
- * password: String,
16
- * }} data
17
- * @return {Promise<Array<String>>}
18
- */
19
- login: `localhost:${store1Port}/login`,
20
- /**
21
- * 更新JWT
22
- * @type {Function}
23
- * @param {{
24
- * uid: Number,
25
- * jti: Number,
26
- * }} data
27
- * @return {Promise<Array<String>>}
28
- */
29
- checkJWT: `localhost:${store1Port}/checkJWT`,
30
- /**
31
- * @type {Function}
32
- * @param {Number} id
33
- * @return {Promise<Array<String>>}
34
- */
35
- getDeptNameById: `localhost:${store1Port}/getDeptNameById`,
36
- /**
37
- * @type {Function}
38
- * @param {Number} id
39
- * @return {Promise<Array<String>>}
40
- */
41
- getRouters: `localhost:${store1Port}/getRouters`,
42
- /**
43
- * @type {Function}
44
- * @param {Object} data
45
- * @return {Promise<Array<String>>}
46
- */
47
- log: `localhost:${store1Port}/log`,
48
- /**
49
- * @type {Function}
50
- * @param {Object} data
51
- * @return {Promise<Array<String>>}
52
- */
53
- log2: `localhost:${store1Port}/log2`,
54
- /**
55
- * @type {Function}
56
- * @param {Object} data
57
- * @return {Promise<Array<String>>}
58
- */
59
- getInfo: `localhost:${store1Port}/getInfo`,
60
- /**
61
- * @type {Function}
62
- * @param {{
63
- * name: String,
64
- * key: String,
65
- * value: *
66
- * }} data
67
- * @return {Promise<Array<String>>}
68
- */
69
- genericFilter: `localhost:${store1Port}/genericFilter`,
70
- /**
71
- * @type {Function}
72
- * @param {{
73
- * name: String,
74
- * key: String,
75
- * value: *
76
- * }} data
77
- * @return {Promise<Array<String>>}
78
- */
79
- genericChangeStatus: `localhost:${store1Port}/genericChangeStatus`,
80
- /**
81
- * @type {Function}
82
- * @param {{
83
- * name: String,
84
- * key: String,
85
- * value: *
86
- * }} data
87
- * @return {Promise<Array<String>>}
88
- */
89
- genericFind: `localhost:${store1Port}/genericFind`,
90
- /**
91
- * @type {Function}
92
- * @param {{
93
- * name: String,
94
- * key: String,
95
- * values: Array
96
- * }} data
97
- * @return {Promise<Array<String>>}
98
- */
99
- genericRemove: `localhost:${store1Port}/genericRemove`,
100
- /**
101
- * @type {Function}
102
- * @param {{
103
- * name: String,
104
- * key: String,
105
- * values: Array
106
- * }} data
107
- * @return {Promise<Array<String>>}
108
- */
109
- genericRemove2: `localhost:${store1Port}/genericRemove2`,
110
- /**
111
- * @type {Function}
112
- * @param {{
113
- * name: String,
114
- * body: Object
115
- * }} data
116
- * @return {Promise<Array<String>>}
117
- */
118
- genericPush: `localhost:${store1Port}/genericPush`,
119
- /**
120
- * @type {Function}
121
- * @param {{
122
- * name: String,
123
- * body: Object
124
- * }} data
125
- * @return {Promise<Array<String>>}
126
- */
127
- genericUpdate: `localhost:${store1Port}/genericUpdate`,
128
- /**
129
- * @type {Function}
130
- * @param {Number} userId
131
- * @return {Promise<Array<String>>}
132
- */
133
- getPerms: `localhost:${store1Port}/getPerms`,
134
- /**
135
- * @type {Function}
136
- * @param {String} name
137
- * @return {Promise<Array<String>>}
138
- */
139
- genericClean: `localhost:${store1Port}/genericClean`,
140
- /**
141
- * @type {Function}
142
- * @param {{
143
- * name: String,
144
- * query: Object,
145
- * timeKey: String,
146
- * all: Boolean,
147
- * }} data
148
- * @return {Promise<Array<String>>}
149
- */
150
- genericPage: `localhost:${store1Port}/genericPage`,
151
- /**
152
- * @type {Function}
153
- * @param {{
154
- * name: String,
155
- * keys: Array<String>,
156
- * }} data
157
- * @return {Promise}
158
- */
159
- genericTable: `localhost:${store1Port}/genericTable`,
160
- /**
161
- * @type {Function}
162
- * @return {Promise<Array<String>>}
163
- */
164
- buildDeptTree: `localhost:${store1Port}/buildDeptTree`,
165
- /**
166
- * @type {Function}
167
- * @param {Number} id
168
- * @return {Promise<Array<Number>>}
169
- */
170
- getDept: `localhost:${store1Port}/getDept`,
171
- /**
172
- * @type {Function}
173
- * @return {Promise<Array<Number>>}
174
- */
175
- getPostUserList: `localhost:${store1Port}/getPostUserList`,
176
- /**
177
- * @type {Function}
178
- * @param {Number} id
179
- * @return {Promise<Array<Number>>}
180
- */
181
- getUserInfoById: `localhost:${store1Port}/getUserInfoById`,
182
- /**
183
- * @type {Function}
184
- * @param {Array<Number>} ids
185
- * @return {Promise}
186
- */
187
- deleteUserByIds: `localhost:${store1Port}/deleteUserByIds`,
188
- /**
189
- * @type {Function}
190
- * @param {Object} data
191
- * @return {Promise}
192
- */
193
- addUser: `localhost:${store1Port}/addUser`,
194
- /**
195
- * @type {Function}
196
- * @param {Object} data
197
- * @return {Promise}
198
- */
199
- updateUser: `localhost:${store1Port}/updateUser`,
200
- /**
201
- * @type {Function}
202
- * @param {Object} data
203
- * @return {Promise}
204
- */
205
- changeUserStatus: `localhost:${store1Port}/changeUserStatus`,
206
- /**
207
- * @type {Function}
208
- * @param {Object} data
209
- * @return {Promise}
210
- */
211
- resetUserPwd: `localhost:${store1Port}/resetUserPwd`,
212
- /**
213
- * @type {Function}
214
- * @param {Object} data
215
- * @return {Promise}
216
- */
217
- authUserRole: `localhost:${store1Port}/authUserRole`,
218
- /**
219
- * @type {Function}
220
- * @param {Object} data
221
- * @return {Promise}
222
- */
223
- getDeptList: `localhost:${store1Port}/getDeptList`,
224
- /**
225
- * @type {Function}
226
- * @param {Number} id
227
- * @return {Promise}
228
- */
229
- getDeptListExcludeById: `localhost:${store1Port}/getDeptListExcludeById`,
230
- /**
231
- * @type {Function}
232
- * @param {Object} data
233
- * @return {Promise}
234
- */
235
- getMenuList: `localhost:${store1Port}/getMenuList`,
236
- /**
237
- * @type {Function}
238
- * @return {Promise}
239
- */
240
- getTreeSelect: `localhost:${store1Port}/getTreeSelect`,
241
- /**
242
- * @type {Function}
243
- * @param {Number} id
244
- * @return {Promise}
245
- */
246
- getRoleMenuTreeSelect: `localhost:${store1Port}/getRoleMenuTreeSelect`,
247
- /**
248
- * @type {Function}
249
- * @param {Number} id
250
- * @return {Promise}
251
- */
252
- getUserAuthRole: `localhost:${store1Port}/getUserAuthRole`,
253
- /**
254
- * @type {Function}
255
- * @param {Object} data
256
- * @return {Promise}
257
- */
258
- addRole: `localhost:${store1Port}/addRole`,
259
- /**
260
- * @type {Function}
261
- * @param {Object} data
262
- * @return {Promise}
263
- */
264
- updateRole: `localhost:${store1Port}/updateRole`,
265
- /**
266
- * @type {Function}
267
- * @param {Array} list
268
- * @return {Promise}
269
- */
270
- deleteRole: `localhost:${store1Port}/deleteRole`,
271
- /**
272
- * @type {Function}
273
- * @param {Object} data
274
- * @return {Promise}
275
- */
276
- changeRoleStatus: `localhost:${store1Port}/changeRoleStatus`,
277
- /**
278
- * @type {Function}
279
- * @param {Object} data
280
- * @return {Promise}
281
- */
282
- getRoleDataScope: `localhost:${store1Port}/getRoleDataScope`,
283
- /**
284
- * @type {Function}
285
- * @param {Object} data
286
- * @return {Promise}
287
- */
288
- roleAuthUserAllocatedList: `localhost:${store1Port}/roleAuthUserAllocatedList`,
289
- /**
290
- * @type {Function}
291
- * @param {Object} data
292
- * @return {Promise}
293
- */
294
- roleAuthUserUnallocatedList: `localhost:${store1Port}/roleAuthUserUnallocatedList`,
295
- /**
296
- * @type {Function}
297
- * @param {Object} data
298
- * @return {Promise}
299
- */
300
- roleAuthUserSelectAll: `localhost:${store1Port}/roleAuthUserSelectAll`,
301
- /**
302
- * @type {Function}
303
- * @param {Object} data
304
- * @return {Promise}
305
- */
306
- roleAuthUserCancel: `localhost:${store1Port}/roleAuthUserCancel`,
307
- /**
308
- * @type {Function}
309
- * @param {Number} id
310
- * @return {Promise}
311
- */
312
- getRoleDeptTree: `localhost:${store1Port}/getRoleDeptTree`,
313
- /**
314
- * @type {Function}
315
- * @param {String} usn
316
- * @return {Promise}
317
- */
318
- LogininforUnlock: `localhost:${store1Port}/LogininforUnlock`,
319
- /**
320
- * @type {Function}
321
- * @param {Object} data
322
- * @return {Promise}
323
- */
324
- updateGenTable: `localhost:${store1Port}/updateGenTable`,
325
- /**
326
- * @type {Function}
327
- * @param {Object} data
328
- * @return {Promise}
329
- */
330
- genTableImportTable: `localhost:${store1Port}/genTableImportTable`,
331
- /**
332
- * @type {Function}
333
- * @param {Object} data
334
- * @return {Promise}
335
- */
336
- genTableImportTable2: `localhost:${store1Port}/genTableImportTable2`,
337
- /**
338
- * @type {Function}
339
- * @param {Object} data
340
- * @return {Promise}
341
- */
342
- batchGenCode: `localhost:${store1Port}/batchGenCode`,
343
- /**
344
- * @type {Function}
345
- * @param {Object} data
346
- * @return {Promise}
347
- */
348
- toolGenDbList: `localhost:${store1Port}/toolGenDbList`,
349
- /**
350
- * @type {Function}
351
- * @param {Object} data
352
- * @return {Promise}
353
- */
354
- toolGenDbList2: `localhost:${store1Port}/toolGenDbList2`,
355
- /**
356
- * @type {Function}
357
- * @param {Number} id
358
- * @return {Promise}
359
- */
360
- genPreview: `localhost:${store1Port}/genPreview`,
361
- /**
362
- * @type {Function}
363
- * @param {Object} data
364
- * @return {Promise}
365
- */
366
- toolPm2List: `localhost:${store1Port}/toolPm2List`,
367
- /**
368
- * @type {Function}
369
- * @param {Object} data
370
- * @return {Promise}
371
- */
372
- toolPm2AddService: `localhost:${store1Port}/toolPm2AddService`,
373
- /**
374
- * @type {Function}
375
- * @param {String} name
376
- * @return {Promise}
377
- */
378
- toolPm2RemoveService: `localhost:${store1Port}/toolPm2RemoveService`,
379
- /**
380
- * @type {Function}
381
- * @param {Object} data
382
- * @return {Promise}
383
- */
384
- toolPm2ChangeStatus: `localhost:${store1Port}/toolPm2ChangeStatus`,
385
- /**
386
- * @type {Function}
387
- * @param {Object} data
388
- * @return {Promise}
389
- */
390
- toolPm2Data: `localhost:${store1Port}/toolPm2Data`,
391
- /**
392
- * @type {Function}
393
- * @param {Object} data
394
- * @return {Promise}
395
- */
396
- toolPm2DataList: `localhost:${store1Port}/toolPm2DataList`,
397
- /**
398
- * @type {Function}
399
- * @param {String} ids
400
- * @return {Promise}
401
- */
402
- toolPm2RemoveData: `localhost:${store1Port}/toolPm2RemoveData`,
403
- /**
404
- * @type {Function}
405
- * @return {Promise}
406
- */
407
- toolPm2Export: `localhost:${store1Port}/toolPm2Export`,
408
- /**
409
- * @type {Function}
410
- * @return {Promise}
411
- */
412
- getStruct: `localhost:${store1Port}/getStruct`,
413
- /**
414
- * @type {Function}
415
- * @param {Object} data
416
- * @return {Promise}
417
- */
418
- toolPm2StoreList: `localhost:${store1Port}/toolPm2StoreList`,
419
- /**
420
- * @type {Function}
421
- * @param {Object} data
422
- * @return {Promise}
423
- */
424
- toolPm2StoreDataUpdate: `localhost:${store1Port}/toolPm2StoreDataUpdate`,
425
- /**
426
- * @type {Function}
427
- * @param {Object} data
428
- * @return {Promise}
429
- */
430
- toolPm2RemoveStoreData: `localhost:${store1Port}/toolPm2RemoveStoreData`,
431
- },
432
- jwt: {
433
- /**
434
- * 登录
435
- * @type {Function}
436
- * @param {{
437
- * uid: String,
438
- * pwd: String,
439
- * }} data
440
- * @return {Promise<Array<String>>}
441
- */
442
- login: `localhost:${jwtPort}/login`,
443
- /**
444
- * 安全退出
445
- * @type {Function}
446
- * @param {String} token
447
- * @return {Promise<Array<String>>}
448
- */
449
- logout: `localhost:${jwtPort}/logout`,
450
- /**
451
- * 校验并获取登录信息
452
- * @type {Function}
453
- * @param {String} token
454
- * @return {Promise<Array<String>>}
455
- */
456
- check: `localhost:${jwtPort}/check`,
457
- /**
458
- * 刷新token
459
- * @type {Function}
460
- * @param {String} token
461
- * @return {Promise<Array<String>>}
462
- */
463
- /**
464
- * @type {import('./type').Service}
465
- */
466
- update: `localhost:${jwtPort}/update`,
467
- }
468
- }