vue-data-ui-cli 0.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/.prettierrc +7 -0
- package/LICENCE +21 -0
- package/README.md +32 -0
- package/boilerplate.js +76 -0
- package/datasets.js +1288 -0
- package/emits.js +159 -0
- package/index.js +594 -0
- package/package.json +35 -0
package/index.js
ADDED
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
5
|
+
import { resolve, join } from 'path';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import prettier from 'prettier';
|
|
8
|
+
import boilerplate from './boilerplate.js';
|
|
9
|
+
import inquirer from 'inquirer';
|
|
10
|
+
import datasets from './datasets.js';
|
|
11
|
+
import emitExamples from './emits.js'
|
|
12
|
+
|
|
13
|
+
let getVueDataUiConfig;
|
|
14
|
+
try {
|
|
15
|
+
({ getVueDataUiConfig } = await import('vue-data-ui'));
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error(
|
|
18
|
+
chalk.red('Failed to load vue-data-ui. Please ensure it is installed.')
|
|
19
|
+
);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const supportedComponents = {
|
|
24
|
+
VueUiXy: {
|
|
25
|
+
key: 'vue_ui_xy',
|
|
26
|
+
link: 'vue-ui-xy',
|
|
27
|
+
datasetType: 'VueUiXyDatasetItem',
|
|
28
|
+
configType: 'VueUiXyConfig',
|
|
29
|
+
isDatasetArray: true,
|
|
30
|
+
slots: [
|
|
31
|
+
'svg',
|
|
32
|
+
'legend',
|
|
33
|
+
'tooltip-before',
|
|
34
|
+
'tooltip-after',
|
|
35
|
+
'reset-action',
|
|
36
|
+
'time-label',
|
|
37
|
+
'watermark',
|
|
38
|
+
'source',
|
|
39
|
+
'plot-comment',
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
VueUiDonut: {
|
|
43
|
+
key: 'vue_ui_donut',
|
|
44
|
+
link: 'vue-ui-donut',
|
|
45
|
+
datasetType: 'VueUiDonutDatasetItem',
|
|
46
|
+
isDatasetArray: true,
|
|
47
|
+
configType: 'VueUiDonutConfig',
|
|
48
|
+
slots: ['source']
|
|
49
|
+
},
|
|
50
|
+
VueUiNestedDonuts: {
|
|
51
|
+
key: 'vue_ui_nested_donuts',
|
|
52
|
+
link: 'vue-ui-nested-donuts',
|
|
53
|
+
datasetType: 'VueUiNestedDonutsDatasetItem',
|
|
54
|
+
isDatasetArray: true,
|
|
55
|
+
configType: 'VueUiNestedDonutsConfig',
|
|
56
|
+
slots: ['source']
|
|
57
|
+
},
|
|
58
|
+
VueUiQuickChart: {
|
|
59
|
+
key: 'vue_ui_quick_chart',
|
|
60
|
+
link: 'vue-ui-quick-chart',
|
|
61
|
+
datasetType: 'VueUiQuickChartDataset',
|
|
62
|
+
isDatasetArray: false,
|
|
63
|
+
configType: 'VueUiQuickChartConfig',
|
|
64
|
+
slots: ['source']
|
|
65
|
+
},
|
|
66
|
+
VueUiStackbar: {
|
|
67
|
+
key: 'vue_ui_stackbar',
|
|
68
|
+
link: 'vue-ui-stackbar',
|
|
69
|
+
datasetType: 'VueUiStackbarDatasetItem',
|
|
70
|
+
isDatasetArray: true,
|
|
71
|
+
configType: 'VueUiStackbarConfig',
|
|
72
|
+
slots: ['source']
|
|
73
|
+
},
|
|
74
|
+
VueUiSparkline: {
|
|
75
|
+
key: 'vue_ui_sparkline',
|
|
76
|
+
link: 'vue-ui-sparkline',
|
|
77
|
+
datasetType: 'VueUiSparklineDatasetItem',
|
|
78
|
+
isDatasetArray: true,
|
|
79
|
+
configType: 'VueUiSparklineConfig',
|
|
80
|
+
slots: ['source']
|
|
81
|
+
},
|
|
82
|
+
VueUiSparkbar: {
|
|
83
|
+
key: 'vue_ui_sparkbar',
|
|
84
|
+
link: 'vue-ui-sparkbar',
|
|
85
|
+
datasetType: 'VueUiSparkbarDatasetItem',
|
|
86
|
+
isDatasetArray: true,
|
|
87
|
+
configType: 'VueUiSparkbarConfig',
|
|
88
|
+
slots: ['source']
|
|
89
|
+
},
|
|
90
|
+
VueUiSparkStackbar: {
|
|
91
|
+
key:'vue_ui_sparkstackbar',
|
|
92
|
+
link: 'vue-ui-sparkstackbar',
|
|
93
|
+
datasetType: 'VueUiSparkStackbarDatasetItem',
|
|
94
|
+
isDatasetArray: true,
|
|
95
|
+
configType: 'VueUiSparkStackbarConfig',
|
|
96
|
+
slots: ['source']
|
|
97
|
+
},
|
|
98
|
+
VueUiGauge: {
|
|
99
|
+
key: 'vue_ui_gauge',
|
|
100
|
+
link: 'vue-ui-gauge',
|
|
101
|
+
datasetType: 'VueUiGaugeDataset',
|
|
102
|
+
isDatasetArray: false,
|
|
103
|
+
configType: 'VueUiGaugeConfig',
|
|
104
|
+
slots: ['source']
|
|
105
|
+
},
|
|
106
|
+
VueUiSparkHistogram: {
|
|
107
|
+
key: 'vue_ui_sparkhistogram',
|
|
108
|
+
link: 'vue-ui-sparkhistogram',
|
|
109
|
+
datasetType: 'VueUiSparkHistogramDatasetItem',
|
|
110
|
+
isDatasetArray: true,
|
|
111
|
+
configType: 'VueUiSparkHistogramConfig',
|
|
112
|
+
slots: ['source']
|
|
113
|
+
},
|
|
114
|
+
VueUiSparkgauge: {
|
|
115
|
+
key: 'vue_ui_sparkgauge',
|
|
116
|
+
link: 'vue-ui-sparkgauge',
|
|
117
|
+
datasetType: 'VueUiSparkgaugeDataset',
|
|
118
|
+
isDatasetArray: false,
|
|
119
|
+
configType: 'VueUiSparkgaugeConfig',
|
|
120
|
+
slots: ['source']
|
|
121
|
+
},
|
|
122
|
+
VueUiSparkTrend: {
|
|
123
|
+
key: 'vue_ui_spark_trend',
|
|
124
|
+
link: 'vueè-ui-spark-trend',
|
|
125
|
+
datasetType: 'number',
|
|
126
|
+
isDatasetArray: true,
|
|
127
|
+
configType: 'VueUiSparkTrendConfig',
|
|
128
|
+
slots: ['source']
|
|
129
|
+
},
|
|
130
|
+
VueUiGizmo: {
|
|
131
|
+
key: 'vue_ui_gizmo',
|
|
132
|
+
link: 'vue-ui-gizmo',
|
|
133
|
+
datasetType: 'number',
|
|
134
|
+
isDatasetArray: false,
|
|
135
|
+
configType: 'VueUiGizmoConfig',
|
|
136
|
+
slots: []
|
|
137
|
+
},
|
|
138
|
+
VueUiKpi: {
|
|
139
|
+
key: 'vue_ui_kpi',
|
|
140
|
+
link: 'vue-ui-kpi',
|
|
141
|
+
datasetType: 'number',
|
|
142
|
+
isDatasetArray: false,
|
|
143
|
+
configType: 'VueUiKpiConfig',
|
|
144
|
+
slots: []
|
|
145
|
+
},
|
|
146
|
+
VueUiBullet: {
|
|
147
|
+
key: 'vue_ui_bullet',
|
|
148
|
+
link: 'vue-ui-bullet',
|
|
149
|
+
datasetType: 'VueUiBulletDataset',
|
|
150
|
+
isDatasetArray: false,
|
|
151
|
+
configType: 'VueUiBulletConfig',
|
|
152
|
+
slots: ['source']
|
|
153
|
+
},
|
|
154
|
+
VueUiXyCanvas: {
|
|
155
|
+
key: 'vue_ui_xy_canvas',
|
|
156
|
+
link: 'vue-ui-xy-canvas',
|
|
157
|
+
datasetType: 'VueUiXyCanvasDatasetItem',
|
|
158
|
+
isDatasetArray: true,
|
|
159
|
+
configType: 'VueUiXyCanvasConfig',
|
|
160
|
+
slots: ['source']
|
|
161
|
+
},
|
|
162
|
+
VueUiVerticalBar: {
|
|
163
|
+
key: 'vue_ui_vertical_bar',
|
|
164
|
+
link: 'vue-ui-vertical-bar',
|
|
165
|
+
datasetType: 'VueUiVerticalBarDatasetItem',
|
|
166
|
+
isDatasetArray: true,
|
|
167
|
+
configType: 'VueUiVerticalBarConfig',
|
|
168
|
+
slots: ['source']
|
|
169
|
+
},
|
|
170
|
+
VueUiParallelCoordinatePlot: {
|
|
171
|
+
key: 'vue_ui_parallel_coordinate_plot',
|
|
172
|
+
link: 'vue-ui-parallel-coordinate-plot',
|
|
173
|
+
datasetType: 'VueUiParallelCoordinatePlotDatasetItem',
|
|
174
|
+
isDatasetArray: true,
|
|
175
|
+
configType: 'VueUiParallelCoordinatePlotConfig',
|
|
176
|
+
slots: ['source']
|
|
177
|
+
},
|
|
178
|
+
VueUiFlow: {
|
|
179
|
+
key: 'vue_ui_flow',
|
|
180
|
+
link: 'vue-ui-flow',
|
|
181
|
+
datasetType: 'VueUiFlowDatasetItem',
|
|
182
|
+
isDatasetArray: true,
|
|
183
|
+
configType: 'VueUiFlowConfig',
|
|
184
|
+
slots: ['source']
|
|
185
|
+
},
|
|
186
|
+
VueUiCandlestick: {
|
|
187
|
+
key: 'vue_ui_candlestick',
|
|
188
|
+
link: 'vue-ui-candlestick',
|
|
189
|
+
datasetType: 'Array<Array<string | number>>',
|
|
190
|
+
isDatasetArray: false,
|
|
191
|
+
configType: 'VueUiCandlestickConfig',
|
|
192
|
+
slots: ['source']
|
|
193
|
+
},
|
|
194
|
+
VueUiAgePyramid: {
|
|
195
|
+
key: 'vue_ui_age_pyramid',
|
|
196
|
+
link: 'vue-ui-age-pyramid',
|
|
197
|
+
datasetType: 'Array<Array<string | number>>',
|
|
198
|
+
isDatasetArray: false,
|
|
199
|
+
configType: 'VueUiAgePyramidConfig',
|
|
200
|
+
slots: ['source']
|
|
201
|
+
},
|
|
202
|
+
VueUiDonutEvolution: {
|
|
203
|
+
key: 'vue_ui_donut_evolution',
|
|
204
|
+
link: 'vue-ui-donut-evolution',
|
|
205
|
+
datasetType: 'VueUiDonutEvolutionDatasetItem',
|
|
206
|
+
isDatasetArray: true,
|
|
207
|
+
configType: 'VueUiDonutEvolutionConfig',
|
|
208
|
+
slots: ['source']
|
|
209
|
+
},
|
|
210
|
+
VueUiFunnel: {
|
|
211
|
+
key: 'vue_ui_funnel',
|
|
212
|
+
link: 'vue-ui-funnel',
|
|
213
|
+
datasetType: 'VueUiFunnelDatasetItem',
|
|
214
|
+
isDatasetArray: true,
|
|
215
|
+
configType: 'VueUiFunnelConfig',
|
|
216
|
+
slots: ['source']
|
|
217
|
+
},
|
|
218
|
+
VueUiHistoryPlot: {
|
|
219
|
+
key: 'vue_ui_history_plot',
|
|
220
|
+
link: 'vue-ui-history-plot',
|
|
221
|
+
datasetType: 'VueUiHistoryPlotDatasetItem',
|
|
222
|
+
isDatasetArray: true,
|
|
223
|
+
configType: 'VueUiHistoryPlotConfig',
|
|
224
|
+
slots: ['source']
|
|
225
|
+
},
|
|
226
|
+
VueUiWaffle: {
|
|
227
|
+
key: 'vue_ui_waffle',
|
|
228
|
+
link: 'vue-ui-waffle',
|
|
229
|
+
datasetType: 'VueUiWaffleDatasetItem',
|
|
230
|
+
isDatasetArray: true,
|
|
231
|
+
configType: 'VueUiWaffleConfig',
|
|
232
|
+
slots: ['source']
|
|
233
|
+
},
|
|
234
|
+
VueUiHeatmap: {
|
|
235
|
+
key: 'vue_ui_heatmap',
|
|
236
|
+
link: 'vue-ui-heatmap',
|
|
237
|
+
datasetType: 'VueUiHeatmapDatasetItem',
|
|
238
|
+
isDatasetArray: true,
|
|
239
|
+
configType: 'VueUiHeatmapConfig',
|
|
240
|
+
slots: ['source']
|
|
241
|
+
},
|
|
242
|
+
VueUiTreemap: {
|
|
243
|
+
key: 'vue_ui_treemap',
|
|
244
|
+
link: 'vue-ui-treemap',
|
|
245
|
+
datasetType: 'VueUiTreemapDatasetItem',
|
|
246
|
+
isDatasetArray: true,
|
|
247
|
+
configType: 'VueUiTreemapConfig',
|
|
248
|
+
slots: ['source']
|
|
249
|
+
},
|
|
250
|
+
VueUiRings: {
|
|
251
|
+
key: 'vue_ui_rings',
|
|
252
|
+
link: 'vue-ui-rings',
|
|
253
|
+
datasetType: 'VueUiRingsDatasetItem',
|
|
254
|
+
isDatasetArray: true,
|
|
255
|
+
configType: 'VueUiRingsConfig',
|
|
256
|
+
slots: ['source']
|
|
257
|
+
},
|
|
258
|
+
VueUiGalaxy: {
|
|
259
|
+
key: 'vue_ui_galaxy',
|
|
260
|
+
link: 'vue-ui-galaxy',
|
|
261
|
+
datasetType: 'VueUiGalaxyDatasetItem',
|
|
262
|
+
isDatasetArray: true,
|
|
263
|
+
configType: 'VueUiGalaxyConfig',
|
|
264
|
+
slots: ['source']
|
|
265
|
+
},
|
|
266
|
+
VueUiChestnut: {
|
|
267
|
+
key: 'vue_ui_chestnut',
|
|
268
|
+
link: 'vue-ui-chestnut',
|
|
269
|
+
datasetType: 'VueUiChestnutDatasetRoot',
|
|
270
|
+
isDatasetArray: true,
|
|
271
|
+
configType: 'VueUiChestnutConfig',
|
|
272
|
+
slots: ['source']
|
|
273
|
+
},
|
|
274
|
+
VueUiOnion: {
|
|
275
|
+
key: 'vue_ui_onion',
|
|
276
|
+
link: 'vue-ui-onion',
|
|
277
|
+
datasetType: 'VueUiOnionDatasetItem',
|
|
278
|
+
isDatasetArray: true,
|
|
279
|
+
configType: 'VueUiOnionConfig',
|
|
280
|
+
slots: ['source']
|
|
281
|
+
},
|
|
282
|
+
VueUiWheel: {
|
|
283
|
+
key: 'vue_ui_wheel',
|
|
284
|
+
link: 'vue-ui-wheel',
|
|
285
|
+
datasetType: 'VueUiWheelDataset',
|
|
286
|
+
isDatasetArray: false,
|
|
287
|
+
configType: 'VueUiWheelConfig',
|
|
288
|
+
slots: ['source']
|
|
289
|
+
},
|
|
290
|
+
VueUiTiremarks: {
|
|
291
|
+
key: 'vue_ui_tiremarks',
|
|
292
|
+
link: 'vue-ui-tiremarks',
|
|
293
|
+
datasetType: 'VueUiTiremarksDataset',
|
|
294
|
+
isDatasetArray: false,
|
|
295
|
+
configType: 'VueUiTiremarksConfig',
|
|
296
|
+
slots: ['source']
|
|
297
|
+
},
|
|
298
|
+
VueUiThermometer: {
|
|
299
|
+
key: 'vue_ui_thermometer',
|
|
300
|
+
link: 'vue-ui-thermometer',
|
|
301
|
+
datasetType: 'VueUiThermometerDataset',
|
|
302
|
+
isDatasetArray: false,
|
|
303
|
+
configType: 'VueUiThermometerConfig',
|
|
304
|
+
slots: ['source']
|
|
305
|
+
},
|
|
306
|
+
VueUiWordCloud: {
|
|
307
|
+
key: 'vue_ui_word_cloud',
|
|
308
|
+
link: 'vue-ui-word-cloud',
|
|
309
|
+
datasetType: 'VueUiWordCloudDatasetItem',
|
|
310
|
+
isDatasetArray: true,
|
|
311
|
+
configType: 'VueUiWordCloudConfig',
|
|
312
|
+
slots: ['source']
|
|
313
|
+
},
|
|
314
|
+
VueUiRelationCircle: {
|
|
315
|
+
key: 'vue_ui_relation_circle',
|
|
316
|
+
link: 'vue-ui-relation-circle',
|
|
317
|
+
datasetType: 'VueUiRelationCircleDatasetItem',
|
|
318
|
+
isDatasetArray: true,
|
|
319
|
+
configType: 'VueUiRelationCircleConfig',
|
|
320
|
+
slots: ['source']
|
|
321
|
+
},
|
|
322
|
+
VueUiRadar: {
|
|
323
|
+
key: 'vue_ui_radar',
|
|
324
|
+
link: 'vue-ui-radar',
|
|
325
|
+
datasetType: 'VueUiRadarDataset',
|
|
326
|
+
isDatasetArray: false,
|
|
327
|
+
configType: 'VueUiRadarConfig',
|
|
328
|
+
slots: ['source']
|
|
329
|
+
},
|
|
330
|
+
VueUiMoodRadar: {
|
|
331
|
+
key: 'vue_ui_mood_radar',
|
|
332
|
+
link: 'vue-ui-mood-radar',
|
|
333
|
+
datasetType: 'VueUiMoodRadarDataset',
|
|
334
|
+
isDatasetArray: false,
|
|
335
|
+
configType: 'VueUiMoodRadarConfig',
|
|
336
|
+
slots: ['source']
|
|
337
|
+
},
|
|
338
|
+
VueUiQuadrant: {
|
|
339
|
+
key: 'vue_ui_quadrant',
|
|
340
|
+
link: 'vue-ui-quadrant',
|
|
341
|
+
datasetType: 'VueUiQuadrantDatasetItem',
|
|
342
|
+
isDatasetArray: true,
|
|
343
|
+
configType: 'VueUiQuadrantConfig',
|
|
344
|
+
slots: ['source']
|
|
345
|
+
},
|
|
346
|
+
VueUiScatter: {
|
|
347
|
+
key: 'vue_ui_scatter',
|
|
348
|
+
link: 'vue-ui-scatter',
|
|
349
|
+
datasetType: 'VueUiScatterDatasetItem',
|
|
350
|
+
isDatasetArray: true,
|
|
351
|
+
configType: 'VueUiScatterConfig',
|
|
352
|
+
slots: ['source']
|
|
353
|
+
},
|
|
354
|
+
VueUiMolecule: {
|
|
355
|
+
key: 'vue_ui_molecule',
|
|
356
|
+
link: 'vue-ui-molecule',
|
|
357
|
+
datasetType: 'VueUiMoleculeDatasetNode',
|
|
358
|
+
isDatasetArray: true,
|
|
359
|
+
configType: 'VueUiMoleculeConfig',
|
|
360
|
+
slots: ['source']
|
|
361
|
+
},
|
|
362
|
+
VueUiStripPlot: {
|
|
363
|
+
key: 'vue_ui_strip_plot',
|
|
364
|
+
link: 'vue-ui-strip-plot',
|
|
365
|
+
datasetType: 'VueUiStripPlotDataset',
|
|
366
|
+
isDatasetArray: true,
|
|
367
|
+
configType: 'VueUiStripPlotConfig',
|
|
368
|
+
slots: ['source']
|
|
369
|
+
},
|
|
370
|
+
VueUiDumbbell: {
|
|
371
|
+
key: 'vue_ui_dumbbell',
|
|
372
|
+
link: 'vue-ui-dumbbell',
|
|
373
|
+
datasetType: 'VueUiDumbbellDataset',
|
|
374
|
+
isDatasetArray: true,
|
|
375
|
+
configType: 'VueUiDumbbellConfig',
|
|
376
|
+
slots: ['source']
|
|
377
|
+
},
|
|
378
|
+
VueUi3dBar: {
|
|
379
|
+
key: 'vue_ui_3d_bar',
|
|
380
|
+
link: 'vue-ui-3d-bar',
|
|
381
|
+
datasetType: 'VueUi3dBarDataset',
|
|
382
|
+
isDatasetArray: false,
|
|
383
|
+
configType: 'VueUi3dBarConfig',
|
|
384
|
+
slots: ['source']
|
|
385
|
+
},
|
|
386
|
+
VueUiTableSparkline: {
|
|
387
|
+
key: 'vue_ui_table_sparkline',
|
|
388
|
+
link: 'vue-ui-table-sparkline',
|
|
389
|
+
datasetType: 'VueUiTableSparklineDatasetItem',
|
|
390
|
+
isDatasetArray: true,
|
|
391
|
+
configType: 'VueUiTableSparklineConfig',
|
|
392
|
+
slots: ['source']
|
|
393
|
+
},
|
|
394
|
+
VueUiCarouselTable: {
|
|
395
|
+
key: 'vue_ui_carousel_table',
|
|
396
|
+
link: 'vue-ui-carousel-table',
|
|
397
|
+
datasetType: 'VueUiCarouselTableDataset',
|
|
398
|
+
isDatasetArray: false,
|
|
399
|
+
configType: 'VueUiCarouselTableConfig',
|
|
400
|
+
slots: ['source']
|
|
401
|
+
},
|
|
402
|
+
VueUiRating: {
|
|
403
|
+
key: 'vue_ui_rating',
|
|
404
|
+
link: 'vue-ui-rating',
|
|
405
|
+
datasetType: 'VueUiRatingDataset',
|
|
406
|
+
isDatasetArray: false,
|
|
407
|
+
configType: 'VueUiRatingConfig',
|
|
408
|
+
slots: []
|
|
409
|
+
},
|
|
410
|
+
VueUiSmiley: {
|
|
411
|
+
key: 'vue_ui_smiley',
|
|
412
|
+
link: 'vue-ui-smiley',
|
|
413
|
+
datasetType: 'VueUiRatingDataset',
|
|
414
|
+
isDatasetArray: false,
|
|
415
|
+
configType: 'VueUiSmileyConfig',
|
|
416
|
+
slots: []
|
|
417
|
+
},
|
|
418
|
+
VueUiAccordion: {
|
|
419
|
+
key: 'vue_ui_accordion',
|
|
420
|
+
link: 'vue-ui-accordion',
|
|
421
|
+
datasetType: '',
|
|
422
|
+
isDatasetArray: false,
|
|
423
|
+
configType: 'VueUiAccordionConfig',
|
|
424
|
+
slots: ['content']
|
|
425
|
+
},
|
|
426
|
+
VueUiSkeleton: {
|
|
427
|
+
key: 'vue_ui_skeleton',
|
|
428
|
+
link: 'vue-ui-skeleton',
|
|
429
|
+
datasetType: '',
|
|
430
|
+
isDatasetArray: false,
|
|
431
|
+
configType: 'VueUiSkeletonConfig',
|
|
432
|
+
slots: []
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
program
|
|
437
|
+
.version('0.0.1')
|
|
438
|
+
.description('CLI to generate Vue Data UI component boilerplates')
|
|
439
|
+
.action(async () => {
|
|
440
|
+
const answers = await inquirer.prompt([
|
|
441
|
+
{
|
|
442
|
+
type: 'list',
|
|
443
|
+
name: 'chartComponent',
|
|
444
|
+
message: 'Select a Vue Data UI chart component:',
|
|
445
|
+
choices: Object.keys(supportedComponents),
|
|
446
|
+
validate: (input) =>
|
|
447
|
+
input ? true : 'You must select a chart component.',
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
type: 'confirm',
|
|
451
|
+
name: 'useComputedDataset',
|
|
452
|
+
message: 'Use computed for the dataset ? (Answering no will use ref)',
|
|
453
|
+
default: false,
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
type: 'confirm',
|
|
457
|
+
name: 'useComputedConfig',
|
|
458
|
+
message: 'Use computed for the config ? (Answering no will use ref)',
|
|
459
|
+
default: false,
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
type: 'confirm',
|
|
463
|
+
name: 'useTypescript',
|
|
464
|
+
message: 'Would you like to use TypeScript?',
|
|
465
|
+
default: false,
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
type: 'input',
|
|
469
|
+
name: 'componentName',
|
|
470
|
+
message: 'Enter the name of your Vue component (e.g., MyComponent):',
|
|
471
|
+
validate: (input) => (input ? true : 'Component name is required.'),
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
type: 'input',
|
|
475
|
+
name: 'directory',
|
|
476
|
+
message: 'Enter the directory to create the component in:',
|
|
477
|
+
default: './src/components/charts',
|
|
478
|
+
},
|
|
479
|
+
]);
|
|
480
|
+
|
|
481
|
+
const {
|
|
482
|
+
componentName,
|
|
483
|
+
chartComponent,
|
|
484
|
+
useTypescript,
|
|
485
|
+
directory,
|
|
486
|
+
useComputedDataset,
|
|
487
|
+
useComputedConfig,
|
|
488
|
+
} = answers;
|
|
489
|
+
|
|
490
|
+
const targetDir = resolve(directory);
|
|
491
|
+
const fileName = `${componentName}.vue`;
|
|
492
|
+
const filePath = join(targetDir, fileName);
|
|
493
|
+
|
|
494
|
+
if (!existsSync(targetDir)) {
|
|
495
|
+
mkdirSync(targetDir, { recursive: true });
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const componentKey = supportedComponents[chartComponent].key;
|
|
499
|
+
if (!componentKey) {
|
|
500
|
+
console.error(
|
|
501
|
+
chalk.red(`${chartComponent} is not a valid Vue Data UI component.`)
|
|
502
|
+
);
|
|
503
|
+
process.exit(1);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
let config;
|
|
507
|
+
try {
|
|
508
|
+
config = await getVueDataUiConfig(componentKey);
|
|
509
|
+
} catch (err) {
|
|
510
|
+
console.error(
|
|
511
|
+
chalk.red(`Failed to get configuration for ${chartComponent}.`)
|
|
512
|
+
);
|
|
513
|
+
process.exit(1);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
let dataset;
|
|
517
|
+
try {
|
|
518
|
+
dataset = datasets(chartComponent);
|
|
519
|
+
} catch (err) {
|
|
520
|
+
console.error(
|
|
521
|
+
chalk.red(`Failed to get dataset boilerplate for ${chartComponent}.`)
|
|
522
|
+
);
|
|
523
|
+
process.exit(1);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
let emits;
|
|
527
|
+
try {
|
|
528
|
+
emits = emitExamples(chartComponent);
|
|
529
|
+
} catch (err) {
|
|
530
|
+
console.error(
|
|
531
|
+
chalk.red(`Failed to get emits for ${chartComponent}.`)
|
|
532
|
+
);
|
|
533
|
+
process.exit(1);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
let rawContent;
|
|
537
|
+
try {
|
|
538
|
+
rawContent = boilerplate({
|
|
539
|
+
component: chartComponent,
|
|
540
|
+
config,
|
|
541
|
+
dataset,
|
|
542
|
+
useTypescript,
|
|
543
|
+
useComputedConfig,
|
|
544
|
+
useComputedDataset,
|
|
545
|
+
datasetType: supportedComponents[chartComponent].datasetType,
|
|
546
|
+
configType: supportedComponents[chartComponent].configType,
|
|
547
|
+
isDatasetArray: supportedComponents[chartComponent].isDatasetArray,
|
|
548
|
+
componentSlots: supportedComponents[chartComponent].slots,
|
|
549
|
+
componentLink: supportedComponents[chartComponent].link,
|
|
550
|
+
emits
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
if (typeof rawContent !== 'string') {
|
|
554
|
+
console.error(chalk.red('Boilerplate content is not a valid string.'));
|
|
555
|
+
process.exit(1);
|
|
556
|
+
}
|
|
557
|
+
} catch (err) {
|
|
558
|
+
console.error(chalk.red('Error generating boilerplate content.'));
|
|
559
|
+
process.exit(1);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// Prettier formatting
|
|
563
|
+
let formattedContent;
|
|
564
|
+
try {
|
|
565
|
+
const prettierOptions = (await prettier.resolveConfig(process.cwd())) || {
|
|
566
|
+
parser: 'vue',
|
|
567
|
+
};
|
|
568
|
+
formattedContent = await prettier.format(rawContent, prettierOptions);
|
|
569
|
+
} catch (err) {
|
|
570
|
+
console.warn(
|
|
571
|
+
chalk.yellow('Prettier formatting failed. Writing unformatted content.')
|
|
572
|
+
);
|
|
573
|
+
formattedContent = rawContent;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (typeof formattedContent !== 'string') {
|
|
577
|
+
console.error(chalk.red('Formatted content is not a valid string.'));
|
|
578
|
+
process.exit(1);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
try {
|
|
582
|
+
writeFileSync(filePath, formattedContent);
|
|
583
|
+
console.log(
|
|
584
|
+
chalk.green(
|
|
585
|
+
`Component ${fileName} created and formatted at ${filePath}`
|
|
586
|
+
)
|
|
587
|
+
);
|
|
588
|
+
} catch (err) {
|
|
589
|
+
console.error(chalk.red('Error writing to file:'), err);
|
|
590
|
+
process.exit(1);
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-data-ui-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "A CLI tool to generate Vue Data UI chart component boilerplates",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Vue Data UI",
|
|
12
|
+
"Vue",
|
|
13
|
+
"Vue 3",
|
|
14
|
+
"CLI",
|
|
15
|
+
"CLI tool",
|
|
16
|
+
"boilerplate",
|
|
17
|
+
"charts"
|
|
18
|
+
],
|
|
19
|
+
"author": "Alec Lloyd Probert",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"chalk": "^5.4.0",
|
|
23
|
+
"commander": "^12.1.0",
|
|
24
|
+
"inquirer": "^12.2.0"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"vdui-cli": "./index.js"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"prettier": "^3.4.2",
|
|
32
|
+
"vue-data-ui": "^2.4.45",
|
|
33
|
+
"vue": "^3.5.13"
|
|
34
|
+
}
|
|
35
|
+
}
|