cuxml 1.0.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/cxml_w.js ADDED
@@ -0,0 +1,54 @@
1
+ const fs = require('fs');
2
+ const xmlFlatten = require('./xml2json');
3
+ const checker = require('./check.js');
4
+ const chokidar = require('chokidar');
5
+ const xmljs = require('xml-js');
6
+
7
+ module.exports = (arg1, arg2, opt) => {
8
+ if (!arg1.endsWith('.xml')) throw new Error('The first argument must be a XML file');
9
+ let xmlContent;
10
+ try {
11
+ xmlContent = fs.readFileSync(arg1, 'utf-8');
12
+ } catch (e) {
13
+ throw new Error(e);
14
+ }
15
+ // 空文件不处理,且不监听的话,直接返回
16
+ if(xmlContent.trim() === ""&&!opt.watch) return;
17
+ let xml2jsonContent = xmljs.xml2js(xmlContent, { compact: false, spaces: 4 }, (err, res) => {
18
+ if (err) {
19
+ console.error(err);
20
+ } else {
21
+ return res;
22
+ }
23
+ });
24
+
25
+ let xmlFlattenRes = xmlFlatten(xml2jsonContent);
26
+
27
+ let realFile = fs.existsSync(arg2);
28
+
29
+ function doit(){
30
+ if(!realFile){
31
+ fs.writeFileSync(arg2, '');
32
+ }
33
+ xmlFlattenRes.forEach(o => {
34
+ let oItem_name = o.name;
35
+ let oItem_attributes = [];
36
+ if (Object.keys(o).includes('attributes')) {
37
+ oItem_attributes = o.attributes;
38
+ }
39
+ let iTemCheckResult = checker({ name: oItem_name, attributes: oItem_attributes, xmlpath: o.xmlpath });
40
+ if(realFile){
41
+ console.log(iTemCheckResult);
42
+ fs.writeFileSync(arg2, JSON.stringify(iTemCheckResult)+'\n',{flag:'a'});
43
+ }else{
44
+ console.log(iTemCheckResult);
45
+ }
46
+ })
47
+ };
48
+ if(opt.watch){
49
+ let wcer = chokidar.watch(arg1);
50
+ wcer.on('change', doit);
51
+ }else{
52
+ doit();
53
+ }
54
+ }
package/index.js ADDED
@@ -0,0 +1,37 @@
1
+ const Command = require('commander').Command;
2
+ const program = new Command();
3
+ const pkg = require('./package.json')
4
+
5
+
6
+ program
7
+ .name('cxml')
8
+ .description(pkg.description)
9
+ .version(pkg.version);
10
+ program.command('check')
11
+ .description('Check XML file against a schema')
12
+ .argument('<xmlFile>', 'XML file to check')
13
+ .argument('[outFile]', 'Output file')
14
+ .option('-w, --watch', 'Watch the file for changes')
15
+ .action((xmlFile, outFile, options) => {
16
+ //console.log(JSON.stringify([options, xmlFile, outFile]));
17
+ require('./cxml_w.js')(xmlFile, outFile, options)
18
+ });
19
+ program.command('callback')
20
+ .description('Add a callbackFunction to the <jsFile>')
21
+ .argument('<xmlFile>', 'XML file to load')
22
+ .argument('<jsFile>', 'JavaScript file to Append the callbackFunction')
23
+ .option('-w, --write', 'Rewrite the file <jsFile>')
24
+ .option('-a, --append', 'Append the file <jsFile>')
25
+ .option('-watch, --watch', 'Watch the <xmlFile> file for changes')
26
+ .action((xmlFile, jsFile, options) => {
27
+ //console.log(JSON.stringify([options, xmlFile, jsFile]));
28
+ if(options.watch){
29
+ let w = require('chokidar').watch(xmlFile);
30
+ w.on('change', () => {
31
+ require('./xml2cbFn.js')(xmlFile, jsFile, options);
32
+ })
33
+ }else{
34
+ require('./xml2cbFn.js')(xmlFile, jsFile, options);
35
+ }
36
+ });
37
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "cuxml",
3
+ "version": "1.0.1",
4
+ "description": "A tool to help use ribbon UI for your WPS Office Client JS add-in project.",
5
+ "keywords": [
6
+ "wps office",
7
+ "add-in",
8
+ "wps addon",
9
+ "customUI",
10
+ "ribbonUI",
11
+ "wps jsPlugin"
12
+ ],
13
+ "main": "index.js",
14
+ "bin": "./index.js",
15
+ "scripts": {
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
+ },
18
+ "author": "",
19
+ "license": "ISC",
20
+ "homepage": "https://github.com/YYago/cuxml/README.md",
21
+ "bugs": {
22
+ "url": "https://github.com/YYago/cuxml/issues"
23
+ },
24
+ "dependencies": {
25
+ "chokidar": "^3.5.3",
26
+ "commander": "^10.0.0",
27
+ "lodash": "^4.17.21",
28
+ "xml-js": "^1.6.11"
29
+ }
30
+ }
@@ -0,0 +1,514 @@
1
+ {
2
+ "tabs": [],
3
+ "ribbon": [
4
+ "startFromScratch"
5
+ ],
6
+ "box": [
7
+ "boxStyle",
8
+ "getVisible",
9
+ "visible",
10
+ "insertAfterMso",
11
+ "insertBeforeMso",
12
+ "idQ",
13
+ "insertAfterQ",
14
+ "insertBeforeQ",
15
+ "id"
16
+ ],
17
+ "button": [
18
+ "getDescription",
19
+ "getEnabled",
20
+ "enabled",
21
+ "getImage",
22
+ "getKeytip",
23
+ "getLabel",
24
+ "getScreentip",
25
+ "getShowImage",
26
+ "getShowLabel",
27
+ "getSize",
28
+ "getSupertip",
29
+ "getVisible",
30
+ "visible",
31
+ "onAction",
32
+ "idMso",
33
+ "imageMso",
34
+ "insertAfterMso",
35
+ "insertBeforeMso",
36
+ "keytip",
37
+ "description",
38
+ "idQ",
39
+ "insertAfterQ",
40
+ "insertBeforeQ",
41
+ "size",
42
+ "label",
43
+ "screentip",
44
+ "supertip",
45
+ "tag",
46
+ "id",
47
+ "image"
48
+ ],
49
+ "buttonGroup": [
50
+ "getVisible",
51
+ "visible",
52
+ "insertAfterMso",
53
+ "insertBeforeMso",
54
+ "idQ",
55
+ "insertAfterQ",
56
+ "insertBeforeQ",
57
+ "id"
58
+ ],
59
+ "checkBox": [
60
+ "getDescription",
61
+ "getEnabled",
62
+ "enabled",
63
+ "getImage",
64
+ "getKeytip",
65
+ "getLabel",
66
+ "getPressed",
67
+ "getScreentip",
68
+ "getShowImage",
69
+ "getShowLabel",
70
+ "getSupertip",
71
+ "getVisible",
72
+ "visible",
73
+ "onAction",
74
+ "idMso",
75
+ "imageMso",
76
+ "insertAfterMso",
77
+ "insertBeforeMso",
78
+ "keytip",
79
+ "description",
80
+ "idQ",
81
+ "insertAfterQ",
82
+ "insertBeforeQ",
83
+ "label",
84
+ "screentip",
85
+ "supertip",
86
+ "tag",
87
+ "id",
88
+ "image"
89
+ ],
90
+ "comboBox": [
91
+ "getEnabled",
92
+ "enabled",
93
+ "getImage",
94
+ "getItemCount",
95
+ "getItemID",
96
+ "getItemImage",
97
+ "getItemLabel",
98
+ "getItemScreentip",
99
+ "getItemSupertip",
100
+ "getKeytip",
101
+ "getLabel",
102
+ "getScreentip",
103
+ "getShowImage",
104
+ "getShowLabel",
105
+ "getSupertip",
106
+ "getText",
107
+ "getVisible",
108
+ "visible",
109
+ "onChange",
110
+ "idMso",
111
+ "imageMso",
112
+ "insertAfterMso",
113
+ "insertBeforeMso",
114
+ "keytip",
115
+ "idQ",
116
+ "insertAfterQ",
117
+ "insertBeforeQ",
118
+ "label",
119
+ "screentip",
120
+ "sizeString",
121
+ "supertip",
122
+ "tag",
123
+ "maxLength",
124
+ "id",
125
+ "image"
126
+ ],
127
+ "commands": [],
128
+ "command": [
129
+ "getEnabled",
130
+ "enabled",
131
+ "onAction",
132
+ "idMso"
133
+ ],
134
+ "control": [
135
+ "getDescription",
136
+ "getEnabled",
137
+ "enabled",
138
+ "getImage",
139
+ "getKeytip",
140
+ "getLabel",
141
+ "getScreentip",
142
+ "getShowImage",
143
+ "getShowLabel",
144
+ "getSize",
145
+ "getSupertip",
146
+ "getVisible",
147
+ "visible",
148
+ "onAction",
149
+ "id",
150
+ "idMso",
151
+ "imageMso",
152
+ "insertAfterMso",
153
+ "insertBeforeMso",
154
+ "keytip",
155
+ "description",
156
+ "idQ",
157
+ "insertAfterQ",
158
+ "insertBeforeQ",
159
+ "size",
160
+ "label",
161
+ "screentip",
162
+ "supertip",
163
+ "tag",
164
+ "image"
165
+ ],
166
+ "customUI": [
167
+ "loadImage",
168
+ "onLoad",
169
+ "xmlns"
170
+ ],
171
+ "dropDown": [
172
+ "getEnabled",
173
+ "enabled",
174
+ "getImage",
175
+ "getItemCount",
176
+ "getItemID",
177
+ "getItemImage",
178
+ "getItemLabel",
179
+ "getItemScreentip",
180
+ "getItemSupertip",
181
+ "getKeytip",
182
+ "getLabel",
183
+ "getScreentip",
184
+ "getSelectedItemID",
185
+ "getSelectedItemIndex",
186
+ "getShowImage",
187
+ "getShowLabel",
188
+ "getSupertip",
189
+ "getVisible",
190
+ "visible",
191
+ "onAction",
192
+ "idMso",
193
+ "imageMso",
194
+ "insertAfterMso",
195
+ "insertBeforeMso",
196
+ "keytip",
197
+ "idQ",
198
+ "insertAfterQ",
199
+ "insertBeforeQ",
200
+ "label",
201
+ "screentip",
202
+ "sizeString",
203
+ "supertip",
204
+ "tag",
205
+ "id",
206
+ "image"
207
+ ],
208
+ "contextualTabs": [],
209
+ "dynamicMenu": [
210
+ "getContent",
211
+ "getDescription",
212
+ "getEnabled",
213
+ "enabled",
214
+ "getImage",
215
+ "getKeytip",
216
+ "getLabel",
217
+ "getScreentip",
218
+ "getShowImage",
219
+ "getShowLabel",
220
+ "getSize",
221
+ "getSupertip",
222
+ "getVisible",
223
+ "visible",
224
+ "idMso",
225
+ "imageMso",
226
+ "insertAfterMso",
227
+ "insertBeforeMso",
228
+ "keytip",
229
+ "description",
230
+ "idQ",
231
+ "insertAfterQ",
232
+ "insertBeforeQ",
233
+ "size",
234
+ "label",
235
+ "screentip",
236
+ "supertip",
237
+ "tag",
238
+ "id",
239
+ "image"
240
+ ],
241
+ "editBox": [
242
+ "getEnabled",
243
+ "enabled",
244
+ "getImage",
245
+ "getKeytip",
246
+ "getLabel",
247
+ "getScreentip",
248
+ "getShowImage",
249
+ "getShowLabel",
250
+ "getSupertip",
251
+ "getText",
252
+ "getVisible",
253
+ "visible",
254
+ "onChange",
255
+ "idMso",
256
+ "imageMso",
257
+ "insertAfterMso",
258
+ "insertBeforeMso",
259
+ "keytip",
260
+ "idQ",
261
+ "insertAfterQ",
262
+ "insertBeforeQ",
263
+ "label",
264
+ "screentip",
265
+ "sizeString",
266
+ "supertip",
267
+ "tag",
268
+ "maxLength",
269
+ "id",
270
+ "image"
271
+ ],
272
+ "gallery": [
273
+ "getDescription",
274
+ "getEnabled",
275
+ "enabled",
276
+ "getImage",
277
+ "getItemCount",
278
+ "getItemHeight",
279
+ "getItemID",
280
+ "getItemImage",
281
+ "getItemLabel",
282
+ "getItemScreentip",
283
+ "getItemSupertip",
284
+ "getItemWidth",
285
+ "getKeytip",
286
+ "getLabel",
287
+ "getScreentip",
288
+ "getSelectedItemID",
289
+ "getSelectedItemIndex",
290
+ "getShowImage",
291
+ "getShowLabel",
292
+ "getSize",
293
+ "getSupertip",
294
+ "getVisible",
295
+ "visible",
296
+ "onAction",
297
+ "itemHeight",
298
+ "itemWidth",
299
+ "columns",
300
+ "rows",
301
+ "idMso",
302
+ "imageMso",
303
+ "insertAfterMso",
304
+ "insertBeforeMso",
305
+ "keytip",
306
+ "description",
307
+ "idQ",
308
+ "insertAfterQ",
309
+ "insertBeforeQ",
310
+ "size",
311
+ "label",
312
+ "screentip",
313
+ "sizeString",
314
+ "supertip",
315
+ "tag",
316
+ "id",
317
+ "image"
318
+ ],
319
+ "group": [
320
+ "getImage",
321
+ "getKeytip",
322
+ "getLabel",
323
+ "getScreentip",
324
+ "getSupertip",
325
+ "getVisible",
326
+ "visible",
327
+ "idMso",
328
+ "imageMso",
329
+ "insertAfterMso",
330
+ "insertBeforeMso",
331
+ "keytip",
332
+ "idQ",
333
+ "insertAfterQ",
334
+ "insertBeforeQ",
335
+ "label",
336
+ "screentip",
337
+ "supertip",
338
+ "tag",
339
+ "id",
340
+ "image"
341
+ ],
342
+ "labelControl": [
343
+ "getEnabled",
344
+ "enabled",
345
+ "getImage",
346
+ "getKeytip",
347
+ "getLabel",
348
+ "getScreentip",
349
+ "getShowImage",
350
+ "getShowLabel",
351
+ "getSupertip",
352
+ "getVisible",
353
+ "visible",
354
+ "idMso",
355
+ "imageMso",
356
+ "insertAfterMso",
357
+ "insertBeforeMso",
358
+ "keytip",
359
+ "idQ",
360
+ "insertAfterQ",
361
+ "insertBeforeQ",
362
+ "label",
363
+ "screentip",
364
+ "supertip",
365
+ "tag",
366
+ "id",
367
+ "image"
368
+ ],
369
+ "menu": [
370
+ "getDescription",
371
+ "getEnabled",
372
+ "enabled",
373
+ "getImage",
374
+ "getKeytip",
375
+ "getLabel",
376
+ "getScreentip",
377
+ "getShowImage",
378
+ "getShowLabel",
379
+ "getSize",
380
+ "getSupertip",
381
+ "getTitle",
382
+ "getVisible",
383
+ "visible",
384
+ "idMso",
385
+ "imageMso",
386
+ "insertAfterMso",
387
+ "insertBeforeMso",
388
+ "itemSize",
389
+ "keytip",
390
+ "description",
391
+ "idQ",
392
+ "insertAfterQ",
393
+ "insertBeforeQ",
394
+ "size",
395
+ "label",
396
+ "screentip",
397
+ "supertip",
398
+ "tag",
399
+ "title",
400
+ "id",
401
+ "image"
402
+ ],
403
+ "menuSeparator": [
404
+ "getTitle",
405
+ "insertAfterMso",
406
+ "insertBeforeMso",
407
+ "idQ",
408
+ "insertAfterQ",
409
+ "insertBeforeQ",
410
+ "title",
411
+ "id"
412
+ ],
413
+ "separator": [
414
+ "getVisible",
415
+ "visible",
416
+ "insertAfterMso",
417
+ "insertBeforeMso",
418
+ "idQ",
419
+ "insertAfterQ",
420
+ "insertBeforeQ",
421
+ "id"
422
+ ],
423
+ "splitButton": [
424
+ "getEnabled",
425
+ "enabled",
426
+ "getImage",
427
+ "getKeytip",
428
+ "getLabel",
429
+ "getScreentip",
430
+ "getShowImage",
431
+ "getShowLabel",
432
+ "getSize",
433
+ "getSupertip",
434
+ "getVisible",
435
+ "visible",
436
+ "idMso",
437
+ "imageMso",
438
+ "insertAfterMso",
439
+ "insertBeforeMso",
440
+ "keytip",
441
+ "idQ",
442
+ "insertAfterQ",
443
+ "insertBeforeQ",
444
+ "size",
445
+ "label",
446
+ "screentip",
447
+ "supertip",
448
+ "tag",
449
+ "id",
450
+ "image"
451
+ ],
452
+ "tab": [
453
+ "getKeytip",
454
+ "getLabel",
455
+ "getVisible",
456
+ "visible",
457
+ "idMso",
458
+ "insertAfterMso",
459
+ "insertBeforeMso",
460
+ "keytip",
461
+ "idQ",
462
+ "insertAfterQ",
463
+ "insertBeforeQ",
464
+ "label",
465
+ "tag",
466
+ "id"
467
+ ],
468
+ "tabSet": [
469
+ "getVisible",
470
+ "visible",
471
+ "idMso"
472
+ ],
473
+ "toggleButton": [
474
+ "getDescription",
475
+ "getEnabled",
476
+ "getImage",
477
+ "getKeytip",
478
+ "getLabel",
479
+ "getPressed",
480
+ "getScreentip",
481
+ "getShowImage",
482
+ "getShowLabel",
483
+ "getSize",
484
+ "getSupertip",
485
+ "getVisible",
486
+ "visible",
487
+ "onAction",
488
+ "idMso",
489
+ "imageMso",
490
+ "insertAfterMso",
491
+ "insertBeforeMso",
492
+ "keytip",
493
+ "description",
494
+ "idQ",
495
+ "insertAfterQ",
496
+ "insertBeforeQ",
497
+ "size",
498
+ "label",
499
+ "screentip",
500
+ "supertip",
501
+ "tag",
502
+ "id",
503
+ "image",
504
+ "enabled"
505
+ ],
506
+ "item": [
507
+ "imageMso",
508
+ "label",
509
+ "screentip",
510
+ "supertip",
511
+ "id",
512
+ "image"
513
+ ]
514
+ }