at-builder 1.1.1 → 1.1.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/.eslintrc +525 -0
- package/.plop/constants/index.js +11 -0
- package/.plop/generators/actions.js +119 -0
- package/.plop/generators/components.js +8 -0
- package/.plop/generators/prompts.js +31 -0
- package/.plop/index.js +5 -0
- package/.plop/templates/analytics.hbs +23 -0
- package/.plop/templates/build-template.hbs +7 -0
- package/.plop/templates/component.cb.hbs +34 -0
- package/.plop/templates/constants.hbs +7 -0
- package/.plop/templates/index.hbs +10 -0
- package/.plop/templates/observer.hbs +18 -0
- package/.plop/templates/style.hbs +3 -0
- package/.plop/utils/index.js +10 -0
- package/README.md +5 -14
- package/bin/constants/config.js +92 -15
- package/bin/index.js +172 -77
- package/package.json +33 -24
- package/src/constants/config.ts +94 -15
- package/src/index.ts +180 -99
- package/tsconfig.json +6 -4
- package/webpack.config.js +9 -9
- package/at-builder.zip +0 -0
package/.eslintrc
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@babel/eslint-parser",
|
|
3
|
+
"parserOptions": {
|
|
4
|
+
"ecmaVersion": "latest",
|
|
5
|
+
"sourceType": "module",
|
|
6
|
+
"es6": true
|
|
7
|
+
},
|
|
8
|
+
"env": {
|
|
9
|
+
"es2021": true,
|
|
10
|
+
"browser": true,
|
|
11
|
+
"jquery": true
|
|
12
|
+
},
|
|
13
|
+
"globals": {
|
|
14
|
+
"document": "readonly",
|
|
15
|
+
"navigator": "readonly",
|
|
16
|
+
"window": "readonly",
|
|
17
|
+
"utag_data": "readonly",
|
|
18
|
+
"utag": "readonly"
|
|
19
|
+
},
|
|
20
|
+
"ignorePatterns": [
|
|
21
|
+
"webpack.config.js",
|
|
22
|
+
"puppeteer.js",
|
|
23
|
+
"plopfile.js",
|
|
24
|
+
"build.js",
|
|
25
|
+
"babel.config.js",
|
|
26
|
+
"at-build-generator.js"
|
|
27
|
+
],
|
|
28
|
+
"rules": {
|
|
29
|
+
"no-var": "warn",
|
|
30
|
+
"accessor-pairs": [
|
|
31
|
+
"error",
|
|
32
|
+
{
|
|
33
|
+
"setWithoutGet": true,
|
|
34
|
+
"enforceForClassMembers": true
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"array-bracket-spacing": [
|
|
38
|
+
"error",
|
|
39
|
+
"never"
|
|
40
|
+
],
|
|
41
|
+
"array-callback-return": [
|
|
42
|
+
"error",
|
|
43
|
+
{
|
|
44
|
+
"allowImplicit": false,
|
|
45
|
+
"checkForEach": false
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"arrow-spacing": [
|
|
49
|
+
"error",
|
|
50
|
+
{
|
|
51
|
+
"before": true,
|
|
52
|
+
"after": true
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"block-spacing": [
|
|
56
|
+
"error",
|
|
57
|
+
"always"
|
|
58
|
+
],
|
|
59
|
+
"brace-style": [
|
|
60
|
+
"error",
|
|
61
|
+
"1tbs",
|
|
62
|
+
{
|
|
63
|
+
"allowSingleLine": true
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"camelcase": [
|
|
67
|
+
"error",
|
|
68
|
+
{
|
|
69
|
+
"allow": [
|
|
70
|
+
"^UNSAFE_"
|
|
71
|
+
],
|
|
72
|
+
"properties": "never",
|
|
73
|
+
"ignoreGlobals": true
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"comma-dangle": [
|
|
77
|
+
"error",
|
|
78
|
+
{
|
|
79
|
+
"arrays": "never",
|
|
80
|
+
"objects": "never",
|
|
81
|
+
"imports": "never",
|
|
82
|
+
"exports": "never",
|
|
83
|
+
"functions": "never"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"comma-spacing": [
|
|
87
|
+
"error",
|
|
88
|
+
{
|
|
89
|
+
"before": false,
|
|
90
|
+
"after": true
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"comma-style": [
|
|
94
|
+
"error",
|
|
95
|
+
"last"
|
|
96
|
+
],
|
|
97
|
+
"computed-property-spacing": [
|
|
98
|
+
"error",
|
|
99
|
+
"never",
|
|
100
|
+
{
|
|
101
|
+
"enforceForClassMembers": true
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"constructor-super": "error",
|
|
105
|
+
"curly": [
|
|
106
|
+
"error",
|
|
107
|
+
"multi-line"
|
|
108
|
+
],
|
|
109
|
+
"default-case-last": "error",
|
|
110
|
+
"dot-location": [
|
|
111
|
+
"error",
|
|
112
|
+
"property"
|
|
113
|
+
],
|
|
114
|
+
"dot-notation": [
|
|
115
|
+
"error",
|
|
116
|
+
{
|
|
117
|
+
"allowKeywords": true
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"eol-last": "warn",
|
|
121
|
+
"eqeqeq": [
|
|
122
|
+
"error",
|
|
123
|
+
"always",
|
|
124
|
+
{
|
|
125
|
+
"null": "ignore"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"func-call-spacing": [
|
|
129
|
+
"error",
|
|
130
|
+
"never"
|
|
131
|
+
],
|
|
132
|
+
"generator-star-spacing": [
|
|
133
|
+
"error",
|
|
134
|
+
{
|
|
135
|
+
"before": true,
|
|
136
|
+
"after": true
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"indent": [
|
|
140
|
+
"error",
|
|
141
|
+
4
|
|
142
|
+
],
|
|
143
|
+
"key-spacing": [
|
|
144
|
+
"error",
|
|
145
|
+
{
|
|
146
|
+
"beforeColon": false,
|
|
147
|
+
"afterColon": true
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"keyword-spacing": [
|
|
151
|
+
"error",
|
|
152
|
+
{
|
|
153
|
+
"before": true,
|
|
154
|
+
"after": true
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"lines-between-class-members": [
|
|
158
|
+
"error",
|
|
159
|
+
"always",
|
|
160
|
+
{
|
|
161
|
+
"exceptAfterSingleLine": true
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"multiline-ternary": [
|
|
165
|
+
"error",
|
|
166
|
+
"always-multiline"
|
|
167
|
+
],
|
|
168
|
+
"new-cap": [
|
|
169
|
+
"error",
|
|
170
|
+
{
|
|
171
|
+
"newIsCap": true,
|
|
172
|
+
"capIsNew": false,
|
|
173
|
+
"properties": true
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"new-parens": "error",
|
|
177
|
+
"no-array-constructor": "error",
|
|
178
|
+
"no-async-promise-executor": "error",
|
|
179
|
+
"no-caller": "error",
|
|
180
|
+
"no-case-declarations": "error",
|
|
181
|
+
"no-class-assign": "error",
|
|
182
|
+
"no-compare-neg-zero": "error",
|
|
183
|
+
"no-cond-assign": "error",
|
|
184
|
+
"no-const-assign": "error",
|
|
185
|
+
"no-constant-condition": [
|
|
186
|
+
"error",
|
|
187
|
+
{
|
|
188
|
+
"checkLoops": false
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"no-control-regex": "error",
|
|
192
|
+
"no-debugger": "off",
|
|
193
|
+
"no-delete-var": "error",
|
|
194
|
+
"no-dupe-args": "error",
|
|
195
|
+
"no-dupe-class-members": "error",
|
|
196
|
+
"no-dupe-keys": "error",
|
|
197
|
+
"no-duplicate-case": "error",
|
|
198
|
+
"no-useless-backreference": "error",
|
|
199
|
+
"no-empty": [
|
|
200
|
+
"error",
|
|
201
|
+
{
|
|
202
|
+
"allowEmptyCatch": true
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"no-empty-character-class": "error",
|
|
206
|
+
"no-empty-pattern": "error",
|
|
207
|
+
"no-eval": "error",
|
|
208
|
+
"no-ex-assign": "error",
|
|
209
|
+
"no-extend-native": "error",
|
|
210
|
+
"no-extra-bind": "error",
|
|
211
|
+
"no-extra-boolean-cast": "error",
|
|
212
|
+
"no-extra-parens": [
|
|
213
|
+
"error",
|
|
214
|
+
"functions"
|
|
215
|
+
],
|
|
216
|
+
"no-fallthrough": "error",
|
|
217
|
+
"no-floating-decimal": "error",
|
|
218
|
+
"no-func-assign": "error",
|
|
219
|
+
"no-global-assign": "error",
|
|
220
|
+
"no-implied-eval": "error",
|
|
221
|
+
"no-import-assign": "error",
|
|
222
|
+
"no-invalid-regexp": "error",
|
|
223
|
+
"no-irregular-whitespace": "error",
|
|
224
|
+
"no-iterator": "error",
|
|
225
|
+
"no-labels": [
|
|
226
|
+
"error",
|
|
227
|
+
{
|
|
228
|
+
"allowLoop": false,
|
|
229
|
+
"allowSwitch": false
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
"no-lone-blocks": "error",
|
|
233
|
+
"no-loss-of-precision": "error",
|
|
234
|
+
"no-misleading-character-class": "error",
|
|
235
|
+
"no-prototype-builtins": "error",
|
|
236
|
+
"no-useless-catch": "error",
|
|
237
|
+
"no-mixed-operators": [
|
|
238
|
+
"error",
|
|
239
|
+
{
|
|
240
|
+
"groups": [
|
|
241
|
+
[
|
|
242
|
+
"==",
|
|
243
|
+
"!=",
|
|
244
|
+
"===",
|
|
245
|
+
"!==",
|
|
246
|
+
">",
|
|
247
|
+
">=",
|
|
248
|
+
"<",
|
|
249
|
+
"<="
|
|
250
|
+
],
|
|
251
|
+
[
|
|
252
|
+
"&&",
|
|
253
|
+
"||"
|
|
254
|
+
],
|
|
255
|
+
[
|
|
256
|
+
"in",
|
|
257
|
+
"instanceof"
|
|
258
|
+
]
|
|
259
|
+
],
|
|
260
|
+
"allowSamePrecedence": true
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
"no-mixed-spaces-and-tabs": "error",
|
|
264
|
+
"no-multi-spaces": "error",
|
|
265
|
+
"no-multi-str": "error",
|
|
266
|
+
"no-multiple-empty-lines": [
|
|
267
|
+
"error",
|
|
268
|
+
{
|
|
269
|
+
"max": 1,
|
|
270
|
+
"maxEOF": 0
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
"no-new": "error",
|
|
274
|
+
"no-new-func": "error",
|
|
275
|
+
"no-new-object": "error",
|
|
276
|
+
"no-new-symbol": "error",
|
|
277
|
+
"no-new-wrappers": "error",
|
|
278
|
+
"no-obj-calls": "error",
|
|
279
|
+
"no-octal": "error",
|
|
280
|
+
"no-octal-escape": "error",
|
|
281
|
+
"no-proto": "error",
|
|
282
|
+
"no-redeclare": [
|
|
283
|
+
"error",
|
|
284
|
+
{
|
|
285
|
+
"builtinGlobals": false
|
|
286
|
+
}
|
|
287
|
+
],
|
|
288
|
+
"no-regex-spaces": "error",
|
|
289
|
+
"no-return-assign": [
|
|
290
|
+
"error",
|
|
291
|
+
"except-parens"
|
|
292
|
+
],
|
|
293
|
+
"no-self-assign": [
|
|
294
|
+
"error",
|
|
295
|
+
{
|
|
296
|
+
"props": true
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
"no-self-compare": "error",
|
|
300
|
+
"no-sequences": "error",
|
|
301
|
+
"no-shadow-restricted-names": "error",
|
|
302
|
+
"no-sparse-arrays": "error",
|
|
303
|
+
"no-tabs": "error",
|
|
304
|
+
"no-template-curly-in-string": "error",
|
|
305
|
+
"no-this-before-super": "error",
|
|
306
|
+
"no-throw-literal": "error",
|
|
307
|
+
"no-trailing-spaces": "error",
|
|
308
|
+
"no-undef": "error",
|
|
309
|
+
"no-undef-init": "error",
|
|
310
|
+
"no-unexpected-multiline": "error",
|
|
311
|
+
"no-unmodified-loop-condition": "error",
|
|
312
|
+
"no-unneeded-ternary": [
|
|
313
|
+
"error",
|
|
314
|
+
{
|
|
315
|
+
"defaultAssignment": false
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
"no-unreachable": "error",
|
|
319
|
+
"no-unreachable-loop": "error",
|
|
320
|
+
"no-unsafe-finally": "error",
|
|
321
|
+
"no-unsafe-negation": "error",
|
|
322
|
+
"no-unused-expressions": [
|
|
323
|
+
"error",
|
|
324
|
+
{
|
|
325
|
+
"allowShortCircuit": true,
|
|
326
|
+
"allowTernary": true,
|
|
327
|
+
"allowTaggedTemplates": true
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
"no-unused-vars": [
|
|
331
|
+
"error",
|
|
332
|
+
{
|
|
333
|
+
"args": "none",
|
|
334
|
+
"caughtErrors": "none",
|
|
335
|
+
"ignoreRestSiblings": true,
|
|
336
|
+
"vars": "all"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"no-use-before-define": [
|
|
340
|
+
"error",
|
|
341
|
+
{
|
|
342
|
+
"functions": false,
|
|
343
|
+
"classes": false,
|
|
344
|
+
"variables": false
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
"no-useless-call": "error",
|
|
348
|
+
"no-useless-computed-key": "error",
|
|
349
|
+
"no-useless-constructor": "error",
|
|
350
|
+
"no-useless-escape": "error",
|
|
351
|
+
"no-useless-rename": "error",
|
|
352
|
+
"no-useless-return": "error",
|
|
353
|
+
"no-void": "error",
|
|
354
|
+
"no-whitespace-before-property": "error",
|
|
355
|
+
"no-with": "error",
|
|
356
|
+
"object-curly-newline": [
|
|
357
|
+
"error",
|
|
358
|
+
{
|
|
359
|
+
"multiline": true,
|
|
360
|
+
"consistent": true
|
|
361
|
+
}
|
|
362
|
+
],
|
|
363
|
+
"object-curly-spacing": [
|
|
364
|
+
"error",
|
|
365
|
+
"always"
|
|
366
|
+
],
|
|
367
|
+
"object-property-newline": [
|
|
368
|
+
"error",
|
|
369
|
+
{
|
|
370
|
+
"allowMultiplePropertiesPerLine": true
|
|
371
|
+
}
|
|
372
|
+
],
|
|
373
|
+
"one-var": [
|
|
374
|
+
"error",
|
|
375
|
+
{
|
|
376
|
+
"initialized": "never"
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"operator-linebreak": [
|
|
380
|
+
"error",
|
|
381
|
+
"after",
|
|
382
|
+
{
|
|
383
|
+
"overrides": {
|
|
384
|
+
"?": "before",
|
|
385
|
+
":": "before",
|
|
386
|
+
"|>": "before"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
],
|
|
390
|
+
"padded-blocks": [
|
|
391
|
+
"error",
|
|
392
|
+
{
|
|
393
|
+
"blocks": "never",
|
|
394
|
+
"switches": "never",
|
|
395
|
+
"classes": "never"
|
|
396
|
+
}
|
|
397
|
+
],
|
|
398
|
+
"prefer-const": [
|
|
399
|
+
"error",
|
|
400
|
+
{
|
|
401
|
+
"destructuring": "all"
|
|
402
|
+
}
|
|
403
|
+
],
|
|
404
|
+
"prefer-promise-reject-errors": "error",
|
|
405
|
+
"prefer-regex-literals": [
|
|
406
|
+
"error",
|
|
407
|
+
{
|
|
408
|
+
"disallowRedundantWrapping": true
|
|
409
|
+
}
|
|
410
|
+
],
|
|
411
|
+
"quote-props": [
|
|
412
|
+
"error",
|
|
413
|
+
"as-needed"
|
|
414
|
+
],
|
|
415
|
+
"quotes": [
|
|
416
|
+
"error",
|
|
417
|
+
"single",
|
|
418
|
+
{
|
|
419
|
+
"avoidEscape": true,
|
|
420
|
+
"allowTemplateLiterals": false
|
|
421
|
+
}
|
|
422
|
+
],
|
|
423
|
+
"rest-spread-spacing": [
|
|
424
|
+
"error",
|
|
425
|
+
"never"
|
|
426
|
+
],
|
|
427
|
+
"semi-spacing": [
|
|
428
|
+
"error",
|
|
429
|
+
{
|
|
430
|
+
"before": false,
|
|
431
|
+
"after": true
|
|
432
|
+
}
|
|
433
|
+
],
|
|
434
|
+
"space-before-blocks": [
|
|
435
|
+
"off",
|
|
436
|
+
"always"
|
|
437
|
+
],
|
|
438
|
+
"space-before-function-paren": [
|
|
439
|
+
"off",
|
|
440
|
+
"always"
|
|
441
|
+
],
|
|
442
|
+
"space-in-parens": [
|
|
443
|
+
"error",
|
|
444
|
+
"never"
|
|
445
|
+
],
|
|
446
|
+
"space-infix-ops": "error",
|
|
447
|
+
"space-unary-ops": [
|
|
448
|
+
"error",
|
|
449
|
+
{
|
|
450
|
+
"words": true,
|
|
451
|
+
"nonwords": false
|
|
452
|
+
}
|
|
453
|
+
],
|
|
454
|
+
"spaced-comment": [
|
|
455
|
+
"error",
|
|
456
|
+
"always",
|
|
457
|
+
{
|
|
458
|
+
"line": {
|
|
459
|
+
"markers": [
|
|
460
|
+
"*package",
|
|
461
|
+
"!",
|
|
462
|
+
"/",
|
|
463
|
+
",",
|
|
464
|
+
"="
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
"block": {
|
|
468
|
+
"balanced": true,
|
|
469
|
+
"markers": [
|
|
470
|
+
"*package",
|
|
471
|
+
"!",
|
|
472
|
+
",",
|
|
473
|
+
":",
|
|
474
|
+
"::",
|
|
475
|
+
"flow-include"
|
|
476
|
+
],
|
|
477
|
+
"exceptions": [
|
|
478
|
+
"*"
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
],
|
|
483
|
+
"symbol-description": "error",
|
|
484
|
+
"template-curly-spacing": [
|
|
485
|
+
"error",
|
|
486
|
+
"never"
|
|
487
|
+
],
|
|
488
|
+
"template-tag-spacing": [
|
|
489
|
+
"error",
|
|
490
|
+
"never"
|
|
491
|
+
],
|
|
492
|
+
"unicode-bom": [
|
|
493
|
+
"error",
|
|
494
|
+
"never"
|
|
495
|
+
],
|
|
496
|
+
"use-isnan": [
|
|
497
|
+
"error",
|
|
498
|
+
{
|
|
499
|
+
"enforceForSwitchCase": true,
|
|
500
|
+
"enforceForIndexOf": true
|
|
501
|
+
}
|
|
502
|
+
],
|
|
503
|
+
"valid-typeof": [
|
|
504
|
+
"error",
|
|
505
|
+
{
|
|
506
|
+
"requireStringLiterals": true
|
|
507
|
+
}
|
|
508
|
+
],
|
|
509
|
+
"wrap-iife": [
|
|
510
|
+
"error",
|
|
511
|
+
"any",
|
|
512
|
+
{
|
|
513
|
+
"functionPrototypeMethods": true
|
|
514
|
+
}
|
|
515
|
+
],
|
|
516
|
+
"yield-star-spacing": [
|
|
517
|
+
"error",
|
|
518
|
+
"both"
|
|
519
|
+
],
|
|
520
|
+
"yoda": [
|
|
521
|
+
"error",
|
|
522
|
+
"never"
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
exports.path = require('path');
|
|
2
|
+
exports.PATTERN_CLASS_BASED = 'Class-Based Component';
|
|
3
|
+
exports.PATTERN_FUNCTIONAL = 'Functional Component';
|
|
4
|
+
exports.TEMPLATE_DIR = '.plop/templates';
|
|
5
|
+
exports.TEMPLATE_TYPE_SUFFIX_CLASS_BASED = 'cb';
|
|
6
|
+
exports.TEMPLATE_TYPE_SUFFIX_FUNCTIONAL = 'func';
|
|
7
|
+
exports.PROMPT_TYPE_LIST = 'list';
|
|
8
|
+
exports.PROMPT_TYPE_INPUT = 'input';
|
|
9
|
+
exports.ACTION_ADD = 'add';
|
|
10
|
+
exports.type_script = 'script';
|
|
11
|
+
exports.type_style = 'style';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const { template } = require("lodash");
|
|
2
|
+
const { ACTION_ADD, PATTERN_CLASS_BASED, PATTERN_FUNCTIONAL, TEMPLATE_DIR, TEMPLATE_TYPE_SUFFIX_CLASS_BASED, TEMPLATE_TYPE_SUFFIX_FUNCTIONAL } = require("../constants");
|
|
3
|
+
const { toCamelCase, toPascalCase } = require("../utils");
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Action handler for plop
|
|
10
|
+
* @param {Object} data - Data that contains inputs from the user
|
|
11
|
+
* @returns {Array} - Array of actions that plop needs to perform
|
|
12
|
+
*/
|
|
13
|
+
exports.actionHandler = (data) => {
|
|
14
|
+
let { executionPath } = process.env;
|
|
15
|
+
let actions = [];
|
|
16
|
+
let fileName = '';
|
|
17
|
+
let componentType = '';
|
|
18
|
+
let folderName = '';
|
|
19
|
+
let testPath = '';
|
|
20
|
+
let numberOfVariations;
|
|
21
|
+
let { trackName, testName, variationName, name } = data;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Assigns constants to the files
|
|
25
|
+
* @param {String} variation - The name of the variation
|
|
26
|
+
* @returns {Array} - Array of objects with the path and template
|
|
27
|
+
*/
|
|
28
|
+
function assignConstants(variation) {
|
|
29
|
+
return [{ 'global': false, 'path': `${folderName}/index.js`, 'templateFile': `${TEMPLATE_DIR}/index.hbs`, variation },
|
|
30
|
+
{ 'global': true, 'path': `${testPath}/Vanalytics/analytics.js`, 'templateFile': `${TEMPLATE_DIR}/analytics.hbs`, variation },
|
|
31
|
+
{ 'global': false, 'path': `${folderName}/constants/index.js`, 'templateFile': `${TEMPLATE_DIR}/constants.hbs`, variation },
|
|
32
|
+
{ 'global': false, 'path': `${folderName}/scripts/app.js`, 'templateFile': `${TEMPLATE_DIR}/component.cb.hbs`, variation },
|
|
33
|
+
{ 'global': false, 'path': `${folderName}/css/style.scss`, 'templateFile': `${TEMPLATE_DIR}/style.hbs`, variation }
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Get the track path from the environment variable
|
|
38
|
+
trackName = executionPath + "/Activities";
|
|
39
|
+
// trackName = path.join(fs.readFileSync(path.join(process.cwd(), 'sample.txt'), { flag: 'r' }).toString(), 'Activities');
|
|
40
|
+
|
|
41
|
+
// Convert the name to camel case
|
|
42
|
+
fileName = toCamelCase(name);
|
|
43
|
+
|
|
44
|
+
// Get the number of variations from the user
|
|
45
|
+
numberOfVariations = parseInt(variationName);
|
|
46
|
+
|
|
47
|
+
let constantMappingFile = null;
|
|
48
|
+
|
|
49
|
+
// If the user has provided track name and test name and variation name
|
|
50
|
+
if (trackName && testName && variationName) {
|
|
51
|
+
// Get the current year
|
|
52
|
+
let year = new Date().getFullYear();
|
|
53
|
+
// testPath = trackName + `/${year}/` + testName;
|
|
54
|
+
testPath = trackName + `/${testName}`;
|
|
55
|
+
// Get the constant mapping
|
|
56
|
+
constantMappingFile = assignConstants();
|
|
57
|
+
// Convert the name to pascal case
|
|
58
|
+
fileName = toPascalCase(name);
|
|
59
|
+
// Set the component type
|
|
60
|
+
componentType = TEMPLATE_TYPE_SUFFIX_CLASS_BASED;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Create actions for the global files
|
|
64
|
+
createActionObject(true);
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// Loop through the number of variations provided by the user
|
|
69
|
+
let i = 1;
|
|
70
|
+
|
|
71
|
+
do {
|
|
72
|
+
// Get the variation name
|
|
73
|
+
let variation = "Variation-" + i;
|
|
74
|
+
// Get the folder name
|
|
75
|
+
folderName = testPath + "/" + variation;
|
|
76
|
+
// Get the constant mapping
|
|
77
|
+
constantMappingFile = assignConstants(variation);
|
|
78
|
+
// Create actions for the variation files
|
|
79
|
+
createActionObject(false);
|
|
80
|
+
// Increment the loop counter
|
|
81
|
+
i++;
|
|
82
|
+
}
|
|
83
|
+
while (i <= numberOfVariations);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Creates an action object for plop
|
|
87
|
+
* @param {Boolean} isGlobalFile - If it is a global file or not
|
|
88
|
+
*/
|
|
89
|
+
function createActionObject(isGlobalFile) {
|
|
90
|
+
constantMappingFile.forEach(item => {
|
|
91
|
+
if ((!item.global && !isGlobalFile) || (item.global && isGlobalFile)) {
|
|
92
|
+
let actionObj = {
|
|
93
|
+
type: `${ACTION_ADD}`,
|
|
94
|
+
path: item.path,
|
|
95
|
+
data: {
|
|
96
|
+
componentName: toPascalCase(name),
|
|
97
|
+
variation: item.variation,
|
|
98
|
+
fileName: fileName,
|
|
99
|
+
windowFlagName: toPascalCase(testName)
|
|
100
|
+
},
|
|
101
|
+
skipIfExists: true,
|
|
102
|
+
abortOnFail: true
|
|
103
|
+
};
|
|
104
|
+
if (item['templateFile']) {
|
|
105
|
+
actionObj['templateFile'] = item['templateFile'];
|
|
106
|
+
} else {
|
|
107
|
+
actionObj['template'] = item['template'];
|
|
108
|
+
}
|
|
109
|
+
actions.push(actionObj);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// Return the actions
|
|
117
|
+
return actions;
|
|
118
|
+
}
|
|
119
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { PROMPT_TYPE_INPUT } = require("../constants");
|
|
2
|
+
|
|
3
|
+
function promptToChooseTrack(inquirer, answers = {}) {
|
|
4
|
+
|
|
5
|
+
const prompts = inquirer.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: PROMPT_TYPE_INPUT,
|
|
8
|
+
name: 'testName',
|
|
9
|
+
message: "Enter the test name"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: PROMPT_TYPE_INPUT,
|
|
13
|
+
name: 'variationName',
|
|
14
|
+
message: "How many variations you want?"
|
|
15
|
+
}
|
|
16
|
+
]);
|
|
17
|
+
prompts.then((newAnswers) => {
|
|
18
|
+
Object.assign(newAnswers, answers);
|
|
19
|
+
});
|
|
20
|
+
return prompts;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const prompts = function (inquirer) {
|
|
25
|
+
const basePrompt = promptToChooseTrack(inquirer);
|
|
26
|
+
return basePrompt.then((answers) => {
|
|
27
|
+
return basePrompt;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
module.exports = prompts;
|