@pega/dx-component-builder-sdk 0.1.16 → 0.1.18

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.
Files changed (63) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +6 -0
  3. package/src/constants.js +13 -17
  4. package/src/tasks/build-all/helper.js +76 -0
  5. package/src/tasks/build-all/index.js +121 -0
  6. package/src/tasks/create/index.js +52 -60
  7. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +1 -0
  8. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +11 -6
  9. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +11 -7
  10. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +7 -7
  11. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +9 -8
  12. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +7 -7
  13. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +7 -7
  14. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +16 -10
  15. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +9 -7
  16. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +8 -8
  17. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +7 -7
  18. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +7 -7
  19. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +6 -6
  20. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +1 -1
  21. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +6 -6
  22. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -1
  23. package/src/tasks/create/templates/Constellation/Field/Text-URL/{text-url.js.mustache → text-url.jsx.mustache} +2 -1
  24. package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +10 -5
  25. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +59 -51
  26. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +64 -59
  27. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +43 -39
  28. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +46 -46
  29. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +24 -25
  30. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +7 -7
  31. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +2 -1
  32. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +1 -1
  33. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +2 -1
  34. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +6 -6
  35. package/src/tasks/create/templates/SDK-React/Field/Date/index.tsx.mustache +2 -2
  36. package/src/tasks/create/templates/SDK-React/Field/DateTime/index.tsx.mustache +2 -2
  37. package/src/tasks/create/templates/SDK-React/Field/Decimal/index.tsx.mustache +3 -3
  38. package/src/tasks/create/templates/SDK-React/Field/Decimal-Currency/index.tsx.mustache +1 -1
  39. package/src/tasks/create/templates/SDK-React/Field/Decimal-Percentage/index.tsx.mustache +3 -3
  40. package/src/tasks/create/templates/SDK-React/Field/Integer/index.tsx.mustache +3 -3
  41. package/src/tasks/create/templates/SDK-React/Field/Text/index.tsx.mustache +1 -1
  42. package/src/tasks/create/templates/SDK-React/Field/Text-Email/index.tsx.mustache +3 -3
  43. package/src/tasks/create/templates/SDK-React/Field/Text-Input/index.tsx.mustache +1 -1
  44. package/src/tasks/create/templates/SDK-React/Field/Text-Paragraph/index.tsx.mustache +1 -1
  45. package/src/tasks/create/templates/SDK-React/Field/Text-Phone/index.tsx.mustache +1 -1
  46. package/src/tasks/create/templates/SDK-React/Field/Text-URL/index.tsx.mustache +3 -3
  47. package/src/tasks/create/templates/SDK-React/Field/TimeofDay/index.tsx.mustache +2 -2
  48. package/src/tasks/create/templates/SDK-React/Template/DETAILS/index.tsx.mustache +2 -2
  49. package/src/tasks/create/templates/SDK-React/Template/DETAILS-region/index.tsx.mustache +2 -2
  50. package/src/tasks/create/templates/SDK-React/Template/FORM/index.tsx.mustache +1 -1
  51. package/src/tasks/create/templates/SDK-React/Template/FORM-region/index.tsx.mustache +1 -1
  52. package/src/tasks/create/templates/SDK-React/Template/PAGE/index.tsx.mustache +1 -1
  53. package/src/tasks/create/templates/SDK-React/Widget/CASE/index.tsx.mustache +1 -1
  54. package/src/tasks/create/templates/SDK-React/Widget/PAGE/index.tsx.mustache +1 -1
  55. package/src/tasks/create/templates/SDK-React/Widget/PAGE-CASE/mock.stories.js.mustache +1 -1
  56. package/src/tasks/delete/helper.js +1 -0
  57. package/src/tasks/index.js +1 -0
  58. package/src/tasks/map/map.js +5 -4
  59. package/src/tasks/override/index.js +34 -22
  60. package/src/tasks/publish/index.js +2 -2
  61. package/src/tasks/publish-all/index.js +5 -5
  62. package/src/tasks/validator/index.js +10 -1
  63. package/src/util.js +18 -32
@@ -44,15 +44,25 @@ const checkAndCreateConfigComponentKey = async (targetDirectory) => {
44
44
  const configFile = path.join(targetDirectory, "config-ext.json");
45
45
  try {
46
46
  const configData = fs.readFileSync(path.resolve(configFile), 'utf8');
47
- const configObj = JSON.parse(configData);
47
+ let configObj = JSON.parse(configData);
48
48
 
49
- if (!configObj.componentKey) {
49
+ let writeUpdate = false;
50
+ if (!configObj.componentKey || !configObj.label) {
50
51
  const name = configObj.name;
51
- const componentKey = name;
52
- const newConfigObj = { componentKey, ...configObj };
52
+
53
+ if (!configObj.componentKey) {
54
+ const componentKey = name;
55
+ configObj = { componentKey, ...configObj };
56
+ }
57
+
58
+ if (!configObj.label) {
59
+ const label = name;
60
+ configObj = { label, ...configObj };
61
+ }
62
+
53
63
 
54
64
  // stringify "4", makes the json string look like JSON in the file
55
- const configContent = JSON.stringify(newConfigObj, null, 4);
65
+ const configContent = JSON.stringify(configObj, null, 4);
56
66
 
57
67
  // update file
58
68
  fs.writeFileSync(configFile, configContent, { encoding: 'utf8' });
@@ -73,13 +83,15 @@ const getListAvailableComponents = async (type) => {
73
83
  for (var el in fullList) {
74
84
 
75
85
  let listEl = fullList[el].value;
86
+
76
87
  if (listEl.indexOf("/") >=0) {
77
88
  const arKey = listEl.split("/");
78
89
  listEl = arKey[arKey.length - 1];
79
90
  }
80
91
 
81
92
  if (components.includes(listEl)) {
82
- availList.push(new inquirer.Separator("** " + fullList[el].name));
93
+ // currently don't show, because too many separators inquirer flaky
94
+ //availList.push(new inquirer.Separator("** " + fullList[el].name));
83
95
  }
84
96
  else {
85
97
  availList.push(fullList[el]);
@@ -149,22 +161,22 @@ export default async options => {
149
161
  let inputType = options.params[3];
150
162
 
151
163
  switch (inputType.toLowerCase()) {
152
- case "forms" :
164
+ case "field" :
153
165
  case "f" :
154
- promptType = "forms";
166
+ promptType = "field";
155
167
  break;
156
- case "templates" :
168
+ case "template" :
157
169
  case "t" :
158
- promptType = "templates";
170
+ promptType = "template";
159
171
  break;
160
- case "widgets" :
172
+ case "widget" :
161
173
  case "w" :
162
- promptType = "widgets";
174
+ promptType = "widget";
163
175
  break;
164
- case "designsystemextensions" :
176
+ case "designsystemextension" :
165
177
  case "des" :
166
178
  case "d" :
167
- promptType = "designSystemExtensions";
179
+ promptType = "designSystemExtension";
168
180
  break;
169
181
  case "infra" :
170
182
  case "i" :
@@ -185,10 +197,10 @@ export default async options => {
185
197
  let componentDefaults = await getComponentDefaults();
186
198
  componentDefaults.library = library;
187
199
 
188
- const formsList = await getListAvailableComponents("forms");
189
- const desList = await getListAvailableComponents("designSystemExtensions");
190
- const templateList = await getListAvailableComponents("templates");
191
- const widgetList = await getListAvailableComponents("widgets");
200
+ const formsList = await getListAvailableComponents("field");
201
+ const desList = await getListAvailableComponents("designSystemExtension");
202
+ const templateList = await getListAvailableComponents("template");
203
+ const widgetList = await getListAvailableComponents("widget");
192
204
  const infraList = await getListAvailableComponents("infra");
193
205
 
194
206
  const questions = [
@@ -208,7 +220,7 @@ export default async options => {
208
220
  choices: formsList,
209
221
  pageSize: 15,
210
222
  when(answers) {
211
- return answers.type === 'forms' || promptType === 'forms';
223
+ return answers.type === 'field' || promptType === 'field';
212
224
  }
213
225
  },
214
226
  {
@@ -218,7 +230,7 @@ export default async options => {
218
230
  choices: desList,
219
231
  pageSize: 15,
220
232
  when(answers) {
221
- return answers.type === 'designSystemExtensions' || promptType === 'designSystemExtensions';
233
+ return answers.type === 'designSystemExtension' || promptType === 'designSystemExtension';
222
234
  }
223
235
  },
224
236
  {
@@ -238,7 +250,7 @@ export default async options => {
238
250
  choices: templateList,
239
251
  pageSize: 15,
240
252
  when(answers) {
241
- return answers.type === 'templates' || promptType === 'templates';
253
+ return answers.type === 'template' || promptType === 'template';
242
254
  }
243
255
  },
244
256
  {
@@ -248,7 +260,7 @@ export default async options => {
248
260
  choices: widgetList,
249
261
  pageSize: 15,
250
262
  when(answers) {
251
- return answers.type === 'widgets' || promptType === 'widgets';
263
+ return answers.type === 'widget' || promptType === 'widget';
252
264
  }
253
265
  },
254
266
 
@@ -126,14 +126,14 @@ export default async options => {
126
126
  }
127
127
  },
128
128
  {
129
- title: 'Zip component',
129
+ title: 'Zip component config',
130
130
  task: async () => {
131
131
  const output = await zipComponent(componentKey, category);
132
132
  content = { ...content, ...output };
133
133
  }
134
134
  },
135
135
  {
136
- title: 'Publish component',
136
+ title: 'Publish component config',
137
137
  task: async () => {
138
138
  await publishComponentToServer(content);
139
139
  }
@@ -82,7 +82,7 @@ export default async options => {
82
82
  title: 'Zip companion component',
83
83
  task: async () => {
84
84
  const output = await zipComponent(componentKey, CATEGORY_CONSTELLATION);
85
- content = { ...content, ...output };
85
+ content = { ...content, ...output, componentKey };
86
86
  }
87
87
  },
88
88
  {
@@ -114,25 +114,25 @@ export default async options => {
114
114
  }
115
115
  },
116
116
  {
117
- title: 'Bundle Component',
117
+ title: 'Bundle component',
118
118
  task: async () => await bundleComponent(componentKey, sourceMap, devBuild, category),
119
119
  skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
120
120
  },
121
121
  {
122
- title: 'Update Component Map',
122
+ title: 'Update component map',
123
123
  task: async () => {
124
124
  await updateComponentMap(componentKey, category);
125
125
  }
126
126
  },
127
127
  {
128
- title: 'Zip Component',
128
+ title: 'Zip component config',
129
129
  task: async () => {
130
130
  const output = await zipComponent(componentKey, category);
131
131
  content = { ...content, ...output, componentKey };
132
132
  }
133
133
  },
134
134
  {
135
- title: 'Publish component',
135
+ title: 'Publish component config',
136
136
  task: async () => {
137
137
  await publishComponentToServer(content);
138
138
  }
@@ -30,6 +30,15 @@ const allowedSubtypes = [
30
30
  ])
31
31
  ];
32
32
 
33
+ // additional subtypes are manually added below
34
+ const allowedOverrideSubtypes = [
35
+ ...new Set([
36
+ ...COMPONENT_SCHEMA.subtype.field.map(({ value }) => value),
37
+ ...COMPONENT_SCHEMA.subtype.template,
38
+ ...COMPONENT_SCHEMA.subtype.widget.map(({ value }) => value)
39
+ ]), "ACTION", "DATA_CAPTURE", "SUMMARY", "CASEVIEW", "DATAVIEW", "LIST"
40
+ ];
41
+
33
42
  const schema = {
34
43
  type: 'object',
35
44
  properties: {
@@ -183,7 +192,7 @@ const overrideSchema = {
183
192
  subtype: {
184
193
  anyOf: [{ type: 'string' }, { type: 'array' }],
185
194
 
186
- enum: allowedSubtypes
195
+ enum: allowedOverrideSubtypes
187
196
  },
188
197
  icon: { type: 'string' },
189
198
  properties: {
package/src/util.js CHANGED
@@ -22,22 +22,17 @@ import {
22
22
  FIELD_PATH,
23
23
  WIDGET_PATH,
24
24
  TEMPLATE_PATH,
25
- FORMS_PATH,
26
- TEMPLATES_PATH,
27
- WIDGETS_PATH,
28
25
  DSE_PATH,
29
26
  INFRA_PATH,
30
27
  COMPONENT_PREFIX_FIELD_PATH,
31
28
  COMPONENT_PREFIX_TEMPLATE_PATH,
32
29
  COMPONENT_PREFIX_WIDGET_PATH,
33
- COMPONENT_PREFIX_FORMS_PATH,
34
- COMPONENT_PREFIX_TEMPLATES_PATH,
35
- COMPONENT_PREFIX_WIDGETS_PATH,
36
30
  COMPONENT_PREFIX_DSE_PATH,
37
31
  COMPONENT_PREFIX_INFRA_PATH,
38
32
  CATEGORY_CUSTOM,
39
33
  CATEGORY_OVERRIDE,
40
- CATEGORY_CONSTELLATION
34
+ CATEGORY_CONSTELLATION,
35
+ COMPONENT_DIRECTORY_PREFIX_CUSTOM
41
36
  } from './constants.js';
42
37
 
43
38
 
@@ -60,7 +55,7 @@ export const checkPathAccess = async (path, options = {}) => {
60
55
  export const deleteLocalComponent = async (componentKey, category = CATEGORY_CUSTOM) => {
61
56
  const currentDirectory = process.cwd();
62
57
  const pegaConfigJsonPath = join(currentDirectory, DXCB_CONFIG_JSON_FILENAME);
63
- const categoryDirectory = join("/", category.toLowerCase());
58
+ const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase());
64
59
 
65
60
  await checkPathAccess(pegaConfigJsonPath);
66
61
 
@@ -172,7 +167,7 @@ export const getOptionsSource = (options) => {
172
167
  export const getComponents = async (showSeparator = false, category = CATEGORY_CUSTOM) => {
173
168
  const currentDirectory = process.cwd();
174
169
  const pegaConfigJsonPath = join(currentDirectory, DXCB_CONFIG_JSON_FILENAME);
175
- const categoryDirectory = join("/", category.toLowerCase());
170
+ const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase());
176
171
 
177
172
  await checkPathAccess(pegaConfigJsonPath);
178
173
 
@@ -215,14 +210,14 @@ export const getComponents = async (showSeparator = false, category = CATEGORY_C
215
210
  }
216
211
  break;
217
212
  case CATEGORY_OVERRIDE:
218
- const formsComps = await getSubComponents(directory, FORMS_PATH);
219
- const templatesComps = await getSubComponents(directory, TEMPLATES_PATH);
220
- const widgetsComps = await getSubComponents(directory, WIDGETS_PATH);
213
+ const formsComps = await getSubComponents(directory, FIELD_PATH);
214
+ const templatesComps = await getSubComponents(directory, TEMPLATE_PATH);
215
+ const widgetsComps = await getSubComponents(directory, WIDGET_PATH);
221
216
  const dseComps = await getSubComponents(directory, DSE_PATH);
222
217
  const infraComps = await getSubComponents(directory, INFRA_PATH);
223
218
 
224
219
  if (formsComps.length > 0) {
225
- if (showSeparator) compList.push(new inquirer.Separator("---- forms (fields) ----"));
220
+ if (showSeparator) compList.push(new inquirer.Separator("---- fields ----"));
226
221
  compList.push(...formsComps);
227
222
  }
228
223
 
@@ -291,7 +286,7 @@ export const createBlankConfigExt = async (directory, name) => {
291
286
  export const getComponentsObj = async (showSeparator = false, category = CATEGORY_CUSTOM) => {
292
287
  const currentDirectory = process.cwd();
293
288
  const pegaConfigJsonPath = join(currentDirectory, DXCB_CONFIG_JSON_FILENAME);
294
- const categoryDirectory = join("/", category.toLowerCase());
289
+ const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase());
295
290
 
296
291
  await checkPathAccess(pegaConfigJsonPath);
297
292
 
@@ -355,20 +350,20 @@ export const getComponentsObj = async (showSeparator = false, category = CATEGOR
355
350
  }
356
351
  break;
357
352
  case CATEGORY_OVERRIDE:
358
- const formsComps = await getSubComponents(directory, FORMS_PATH);
359
- const templatesComps = await getSubComponents(directory, TEMPLATES_PATH);
360
- const widgetsComps = await getSubComponents(directory, WIDGETS_PATH);
353
+ const formsComps = await getSubComponents(directory, FIELD_PATH);
354
+ const templatesComps = await getSubComponents(directory, TEMPLATE_PATH);
355
+ const widgetsComps = await getSubComponents(directory, WIDGET_PATH);
361
356
  const dseComps = await getSubComponents(directory, DSE_PATH);
362
357
  const infraComps = await getSubComponents(directory, INFRA_PATH);
363
358
 
364
359
  if (formsComps.length > 0) {
365
- if (showSeparator) compList.push(new inquirer.Separator("---- forms (fields) ----"));
360
+ if (showSeparator) compList.push(new inquirer.Separator("---- fields ----"));
366
361
 
367
362
  compList.push(...formsComps.map(
368
363
  name => {
369
364
  const container = {};
370
365
  container.name = name;
371
- container.value = COMPONENT_PREFIX_FORMS_PATH + name;
366
+ container.value = COMPONENT_PREFIX_FIELD_PATH + name;
372
367
 
373
368
  return container;
374
369
  }
@@ -381,7 +376,7 @@ export const getComponentsObj = async (showSeparator = false, category = CATEGOR
381
376
  name => {
382
377
  const container = {};
383
378
  container.name = name;
384
- container.value = COMPONENT_PREFIX_TEMPLATES_PATH + name;
379
+ container.value = COMPONENT_PREFIX_TEMPLATE_PATH + name;
385
380
 
386
381
  return container;
387
382
  }
@@ -394,7 +389,7 @@ export const getComponentsObj = async (showSeparator = false, category = CATEGOR
394
389
  name => {
395
390
  const container = {};
396
391
  container.name = name;
397
- container.value = COMPONENT_PREFIX_WIDGETS_PATH + name;
392
+ container.value = COMPONENT_PREFIX_WIDGET_PATH + name;
398
393
 
399
394
  return container;
400
395
  }
@@ -451,7 +446,7 @@ export const getSubComponentsAndDir = async (directory, type) => {
451
446
  export const getComponentsAndSubDirectory = async (category = CATEGORY_CUSTOM) => {
452
447
  const currentDirectory = process.cwd();
453
448
  const pegaConfigJsonPath = join(currentDirectory, DXCB_CONFIG_JSON_FILENAME);
454
- const categoryDirectory = join("/", category.toLowerCase());
449
+ const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase());
455
450
 
456
451
  await checkPathAccess(pegaConfigJsonPath);
457
452
 
@@ -490,15 +485,6 @@ export const removeComponentPrefix = (componentName) => {
490
485
  else if (componentName.indexOf(COMPONENT_PREFIX_WIDGET_PATH) == 0) {
491
486
  componentName = componentName.substring(COMPONENT_PREFIX_WIDGET_PATH.length);
492
487
  }
493
- else if (componentName.indexOf(COMPONENT_PREFIX_FORMS_PATH) == 0) {
494
- componentName = componentName.substring(COMPONENT_PREFIX_FORMS_PATH.length);
495
- }
496
- else if (componentName.indexOf(COMPONENT_PREFIX_TEMPLATES_PATH) == 0) {
497
- componentName = componentName.substring(COMPONENT_PREFIX_TEMPLATES_PATH.length);
498
- }
499
- else if (componentName.indexOf(COMPONENT_PREFIX_WIDGETS_PATH) == 0) {
500
- componentName = componentName.substring(COMPONENT_PREFIX_WIDGETS_PATH.length);
501
- }
502
488
  else if (componentName.indexOf(COMPONENT_PREFIX_DSE_PATH) == 0) {
503
489
  componentName = componentName.substring(COMPONENT_PREFIX_DSE_PATH.length);
504
490
  }
@@ -535,7 +521,7 @@ export const getComponentDefaults = async () => {
535
521
  export const getComponentDirectoryPath = async (componentKey, category = CATEGORY_CUSTOM) => {
536
522
  const currentDirectory = process.cwd();
537
523
  const pegaConfigJsonPath = join(currentDirectory, DXCB_CONFIG_JSON_FILENAME);
538
- const categoryDirectory = join("/", category.toLowerCase());
524
+ const categoryDirectory = (category === CATEGORY_CONSTELLATION) ? join("/", COMPONENT_DIRECTORY_PREFIX_CUSTOM + category.toLowerCase()) : join("/", category.toLowerCase());
539
525
 
540
526
  await checkPathAccess(pegaConfigJsonPath);
541
527