@pega/custom-dx-components 0.0.1 → 0.23.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.
Files changed (234) hide show
  1. package/.vscode/extensions.json +1 -1
  2. package/README.md +6 -189
  3. package/package.json +34 -32
  4. package/src/auth.js +608 -0
  5. package/src/cli.js +42 -0
  6. package/src/constants.js +125 -8
  7. package/src/tasks/authenticate/helper.js +91 -8
  8. package/src/tasks/authenticate/index.js +169 -49
  9. package/src/tasks/build/helper.js +122 -0
  10. package/src/tasks/build/index.js +54 -0
  11. package/src/tasks/build-all/helper.js +70 -0
  12. package/src/tasks/build-all/index.js +79 -0
  13. package/src/tasks/{publish/bundle → bundle}/builder/index.js +49 -5
  14. package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +5 -3
  15. package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
  16. package/src/tasks/create/index.js +87 -64
  17. package/src/tasks/create/templates/Constellation/Field/Boolean/Boolean.js.mustache +38 -0
  18. package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +26 -0
  19. package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +146 -0
  20. package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +61 -0
  21. package/src/tasks/create/templates/Constellation/Field/Boolean/event-utils.js.mustache +18 -0
  22. package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +170 -0
  23. package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
  24. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -0
  25. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
  26. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
  27. package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +196 -0
  28. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +439 -0
  29. package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +73 -0
  30. package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +256 -0
  31. package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
  32. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -0
  33. package/src/tasks/create/templates/Constellation/Field/Date/suggestions-handler.js +10 -0
  34. package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +257 -0
  35. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +92 -0
  36. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +287 -0
  37. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +328 -0
  38. package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +73 -0
  39. package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +254 -0
  40. package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
  41. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -0
  42. package/src/tasks/create/templates/Constellation/Field/DateTime/suggestions-handler.js +10 -0
  43. package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +279 -0
  44. package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +49 -0
  45. package/src/tasks/create/templates/Constellation/Field/Decimal/event-utils.js.mustache +18 -0
  46. package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +273 -0
  47. package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
  48. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -0
  49. package/src/tasks/create/templates/Constellation/Field/Decimal/suggestions-handler.js +10 -0
  50. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +292 -0
  51. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +53 -0
  52. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/event-utils.js.mustache +18 -0
  53. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +299 -0
  54. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
  55. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -0
  56. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/suggestions-handler.js +10 -0
  57. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +94 -0
  58. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +49 -0
  59. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/event-utils.js.mustache +18 -0
  60. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +281 -0
  61. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
  62. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -0
  63. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/suggestions-handler.js +10 -0
  64. package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +348 -0
  65. package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +49 -0
  66. package/src/tasks/create/templates/Constellation/Field/Integer/event-utils.js.mustache +18 -0
  67. package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +336 -0
  68. package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
  69. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -0
  70. package/src/tasks/create/templates/Constellation/Field/Integer/suggestions-handler.js +10 -0
  71. package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +115 -0
  72. package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +78 -0
  73. package/src/tasks/create/templates/Constellation/Field/Picklist/event-utils.js.mustache +18 -0
  74. package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +351 -0
  75. package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
  76. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -0
  77. package/src/tasks/create/templates/Constellation/Field/Picklist/suggestions-handler.js +10 -0
  78. package/src/tasks/create/{template → templates/Constellation/Field/Text}/config.json.mustache +15 -5
  79. package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +51 -0
  80. package/src/tasks/create/{template → templates/Constellation/Field/Text}/index.jsx.mustache +5 -0
  81. package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
  82. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -0
  83. package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +112 -0
  84. package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +48 -0
  85. package/src/tasks/create/templates/Constellation/Field/Text-Email/event-utils.js.mustache +18 -0
  86. package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +231 -0
  87. package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
  88. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -0
  89. package/src/tasks/create/templates/Constellation/Field/Text-Email/suggestions-handler.js +10 -0
  90. package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +26 -0
  91. package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +112 -0
  92. package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +48 -0
  93. package/src/tasks/create/templates/Constellation/Field/Text-Input/event-utils.js.mustache +18 -0
  94. package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +239 -0
  95. package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
  96. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -0
  97. package/src/tasks/create/templates/Constellation/Field/Text-Input/suggestions-handler.js +10 -0
  98. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +112 -0
  99. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +48 -0
  100. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/event-utils.js.mustache +18 -0
  101. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +231 -0
  102. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
  103. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -0
  104. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/suggestions-handler.js +10 -0
  105. package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +124 -0
  106. package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +46 -0
  107. package/src/tasks/create/templates/Constellation/Field/Text-Phone/event-utils.js.mustache +18 -0
  108. package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +267 -0
  109. package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
  110. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -0
  111. package/src/tasks/create/templates/Constellation/Field/Text-Phone/suggestions-handler.js +10 -0
  112. package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +238 -0
  113. package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +46 -0
  114. package/src/tasks/create/templates/Constellation/Field/Text-URL/event-utils.js.mustache +18 -0
  115. package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +232 -0
  116. package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
  117. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -0
  118. package/src/tasks/create/templates/Constellation/Field/Text-URL/suggestions-handler.js +10 -0
  119. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +173 -0
  120. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +186 -0
  121. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/demo.stories.jsx.mustache +57 -0
  122. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/index.jsx.mustache +213 -0
  123. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/mock.stories.js.mustache +20 -0
  124. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +7 -0
  125. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/suggestions-handler.js +10 -0
  126. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +287 -0
  127. package/src/tasks/create/templates/Constellation/Template/DETAILS/OneColumnDetails.svg +22 -0
  128. package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
  129. package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +36 -0
  130. package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +132 -0
  131. package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +86 -0
  132. package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +189 -0
  133. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
  134. package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +152 -0
  135. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
  136. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
  137. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +43 -0
  138. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +136 -0
  139. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +86 -0
  140. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +230 -0
  141. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
  142. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +155 -0
  143. package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
  144. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +46 -0
  145. package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +169 -0
  146. package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +45 -0
  147. package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +137 -0
  148. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
  149. package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
  150. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +28 -0
  151. package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +178 -0
  152. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +48 -0
  153. package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +143 -0
  154. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
  155. package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.jsx.mustache +35 -0
  156. package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
  157. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +33 -0
  158. package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
  159. package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +70 -0
  160. package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
  161. package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
  162. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
  163. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +229 -0
  164. package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
  165. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +24 -0
  166. package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
  167. package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +76 -0
  168. package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +390 -0
  169. package/src/tasks/create/{template → templates/Constellation/Widget/CASE}/styles.js.mustache +1 -1
  170. package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
  171. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +60 -0
  172. package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
  173. package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
  174. package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +23 -0
  175. package/src/tasks/{init/template/src/components/Organization_Library_VideoPlayer/styles.js → create/templates/Constellation/Widget/PAGE/styles.js.mustache} +3 -1
  176. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.jsx.mustache +75 -0
  177. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
  178. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +240 -0
  179. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +67 -0
  180. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
  181. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
  182. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
  183. package/src/tasks/{init/template/src/components/Organization_Library_MediaURL/MediaURL.styles.ts → create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache} +3 -1
  184. package/src/tasks/create-all/index.js +398 -0
  185. package/src/tasks/delete/helper.js +6 -4
  186. package/src/tasks/delete/index.js +4 -0
  187. package/src/tasks/delete-all/helper.js +153 -0
  188. package/src/tasks/delete-all/index.js +49 -0
  189. package/src/tasks/generate-ai/aiPrompt.txt.mustache +23 -0
  190. package/src/tasks/generate-ai/aiPromptDavinci.txt.mustache +14 -0
  191. package/src/tasks/generate-ai/helper.js +357 -0
  192. package/src/tasks/generate-ai/index.js +34 -0
  193. package/src/tasks/index.js +7 -0
  194. package/src/tasks/init/index.js +9 -3
  195. package/src/tasks/init/template/.eslintignore +8 -0
  196. package/src/tasks/init/template/.eslintrc.json +186 -5
  197. package/src/tasks/init/template/.vscode/extensions.json +1 -1
  198. package/src/tasks/init/template/README.md +80 -61
  199. package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
  200. package/src/tasks/init/template/keys/dxcb.crt +32 -0
  201. package/src/tasks/init/template/keys/dxcb.key +51 -0
  202. package/src/tasks/init/template/package.json.mustache +44 -21
  203. package/src/tasks/init/template/src/components/_components.md +1 -0
  204. package/src/tasks/init/template/tasks.config.json +19 -5
  205. package/src/tasks/init/template/templateNPMRC.txt +8 -0
  206. package/src/tasks/linter/index.js +46 -0
  207. package/src/tasks/list/helper.js +19 -6
  208. package/src/tasks/list/index.js +4 -0
  209. package/src/tasks/publish/helper.js +13 -4
  210. package/src/tasks/publish/index.js +14 -1
  211. package/src/tasks/publish-all/helper.js +154 -0
  212. package/src/tasks/publish-all/index.js +95 -0
  213. package/src/tasks/rename/index.js +314 -0
  214. package/src/tasks/validator/index.js +291 -18
  215. package/src/util.js +372 -6
  216. package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
  217. package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +0 -10
  218. package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +0 -122
  219. package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +0 -14
  220. package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +0 -13
  221. package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +0 -10
  222. package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +0 -14
  223. package/src/tasks/init/template/src/components/MBTAList/index.ts +0 -2
  224. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.stories.tsx +0 -19
  225. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURL.types.ts +0 -10
  226. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLDisplay.tsx +0 -25
  227. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/MediaURLInput.tsx +0 -24
  228. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/config.json +0 -13
  229. package/src/tasks/init/template/src/components/Organization_Library_MediaURL/index.ts +0 -2
  230. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/config.json +0 -44
  231. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/demo.stories.jsx +0 -40
  232. package/src/tasks/init/template/src/components/Organization_Library_VideoPlayer/index.jsx +0 -42
  233. /package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
  234. /package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
@@ -0,0 +1,398 @@
1
+ import path from 'path';
2
+ import { URL, fileURLToPath } from 'url';
3
+ import fs from 'fs';
4
+ import { promisify } from 'util';
5
+ import { join } from 'path';
6
+
7
+ import inquirer from 'inquirer';
8
+ import ncp from 'ncp';
9
+ import chalk from 'chalk';
10
+
11
+ import { checkPathAccess, showVersion } from '../../util.js';
12
+
13
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
14
+
15
+ import {
16
+ convertIntoPascalCase,
17
+ compileMustacheTemplate,
18
+ getComponentDirectoryPath,
19
+ getPegaConfig,
20
+ getComponents,
21
+ getComponentDefaults,
22
+ sanitize,
23
+ validateSemver
24
+ } from '../../util.js';
25
+ import {
26
+ COMPONENT_SCHEMA,
27
+ COMPONENTS_DIRECTORY_PATH,
28
+ TASKS_CONFIG_JSON_FILENAME,
29
+ COMPONENTS_PATH,
30
+ CATEGORY_CONSTELLATION
31
+ } from '../../constants.js';
32
+
33
+ const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
34
+
35
+ const copy = promisify(ncp);
36
+
37
+ const copyComponentTemplate = async options => {
38
+ if (options.targetDirectory) {
39
+ return copy(options.templateDirectory, options.targetDirectory, {
40
+ clobber: false
41
+ });
42
+ }
43
+ else {
44
+ return copy(options.templateDirectoryConstellation, options.targetDirectoryConstellation, {
45
+ clobber: false,
46
+ filter: (fileName) => {
47
+ // filter out the file config.json or config.json.mustache
48
+ if (fileName.indexOf("config.json") >= 0) return false;
49
+ else return true;
50
+ }
51
+ });
52
+ }
53
+
54
+ };
55
+
56
+ export const compileMustacheTemplates = async (
57
+ componentDirectory,
58
+ {
59
+ componentKey,
60
+ componentName,
61
+ componentLabel,
62
+ library,
63
+ version,
64
+ type,
65
+ subtype,
66
+ description,
67
+ organization,
68
+ allowedApplications
69
+ }
70
+ ) => {
71
+ const files = fs.readdirSync(componentDirectory);
72
+ const componentClassName = convertIntoPascalCase(componentKey);
73
+
74
+ const isTemplate = type === 'Template';
75
+ const isPicklist = subtype === 'Picklist';
76
+ const isBool = subtype === 'Boolean';
77
+ const isPhone = subtype === 'Phone';
78
+
79
+ if (Array.isArray(subtype) && subtype.length === 1) {
80
+ subtype = subtype.toString();
81
+ }
82
+
83
+ let mustacheSubType = subtype;
84
+
85
+ // overrides
86
+ if (typeof(mustacheSubType) == "string") {
87
+ switch (mustacheSubType) {
88
+ case "FORM-region" :
89
+ mustacheSubType = "FORM";
90
+ break;
91
+ case "DETAILS-region" :
92
+ mustacheSubType = "DETAILS";
93
+ break;
94
+ case "Text-Input" :
95
+ mustacheSubType = "Text";
96
+ break;
97
+ }
98
+
99
+ }
100
+
101
+ if (allowedApplications.trim() === '') {
102
+ allowedApplications = [];
103
+ } else {
104
+ if (allowedApplications.indexOf(',') !== -1) {
105
+ allowedApplications = allowedApplications.split(',');
106
+ }
107
+ allowedApplications = [].concat(allowedApplications);
108
+ }
109
+
110
+ allowedApplications = allowedApplications.filter(el => !!el.trim()).map(el => el.trim());
111
+ files.forEach(file => {
112
+ const filePath = path.join(componentDirectory, file);
113
+
114
+ const output = compileMustacheTemplate(filePath, {
115
+ COMPONENT_KEY: componentKey,
116
+ COMPONENT_NAME: componentName,
117
+ COMPONENT_LABEL: componentLabel,
118
+ COMPONENT_CLASS_NAME: componentClassName,
119
+ ORGANIZATION: organization,
120
+ VERSION: version,
121
+ LIBRARY: library,
122
+ ALLOWEDAPPS: JSON.stringify(allowedApplications),
123
+ TYPE: type,
124
+ SUB_TYPE: JSON.stringify(mustacheSubType),
125
+ DESCRIPTION: description || componentLabel,
126
+ IS_TEMPLATE: isTemplate,
127
+ IS_PICKLIST: isPicklist,
128
+ IS_BOOLEAN: isBool,
129
+ IS_PHONE: isPhone
130
+ });
131
+ fs.writeFileSync(filePath, output);
132
+ fs.renameSync(filePath, filePath.replace('.mustache', ''));
133
+ });
134
+ };
135
+
136
+
137
+ export const validateCompileAll = async (
138
+ {
139
+ prefix,
140
+ library,
141
+ version,
142
+ allowedApplications,
143
+ organization
144
+ },
145
+ options,
146
+
147
+ ) => {
148
+
149
+
150
+ for (let fieldIdx in COMPONENT_SCHEMA.subtype.field) {
151
+ const type = "Field";
152
+ const subtype = COMPONENT_SCHEMA.subtype.field[fieldIdx].value;
153
+ const prefixNoSpace = prefix.replace(/\s+/g, '');
154
+ const componentNameNoSpace = COMPONENT_SCHEMA.subtype.field[fieldIdx].name.replace(/\s+/g, '');
155
+ const componentName = "".concat(prefixNoSpace).concat(componentNameNoSpace);
156
+ const componentLabel = "".concat(prefix).concat(" ").concat(COMPONENT_SCHEMA.subtype.field[fieldIdx].name);
157
+ const description = componentLabel;
158
+
159
+ await validateCompile(
160
+ {
161
+ library,
162
+ organization,
163
+ componentName,
164
+ componentLabel,
165
+ version,
166
+ type,
167
+ subtype,
168
+ description,
169
+ allowedApplications
170
+ },
171
+ options
172
+ )
173
+ }
174
+
175
+ for (let templateIdx in COMPONENT_SCHEMA.subtype.template) {
176
+ const type = "Template";
177
+ const subtype = COMPONENT_SCHEMA.subtype.template[templateIdx].value;
178
+ const prefixNoSpace = prefix.replace(/\s+/g, '');
179
+ let templateNameOriginal = COMPONENT_SCHEMA.subtype.template[templateIdx].name;
180
+ let templateName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
181
+ let templateLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
182
+ if (templateNameOriginal.indexOf("region") >= 0) {
183
+ let templateNameBase = convertIntoPascalCase(templateNameOriginal.replace(" region", ""));
184
+ templateName = "TwoColumn".concat(templateNameBase);
185
+ templateLabel = "Two Column ".concat(templateNameBase);
186
+ }
187
+ const componentName = "".concat(prefixNoSpace).concat(templateName);
188
+ const componentLabel = "".concat(prefix).concat(" ").concat(templateLabel);
189
+ const description = componentLabel;
190
+
191
+ await validateCompile(
192
+ {
193
+ library,
194
+ organization,
195
+ componentName,
196
+ componentLabel,
197
+ version,
198
+ type,
199
+ subtype,
200
+ description,
201
+ allowedApplications
202
+ },
203
+ options
204
+ )
205
+ }
206
+
207
+
208
+ for (let widgetIdx in COMPONENT_SCHEMA.subtype.widget) {
209
+ const type = "Widget";
210
+ const subtype = COMPONENT_SCHEMA.subtype.widget[widgetIdx].value;
211
+ const prefixNoSpace = prefix.replace(/\s+/g, '');
212
+ let widgetNameOriginal = COMPONENT_SCHEMA.subtype.widget[widgetIdx].name;
213
+ let widgetName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat("Widget");
214
+ let widgetLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat(" Widget");
215
+ if (widgetName.indexOf("&") >= 0) {
216
+ widgetName = convertIntoPascalCase(widgetNameOriginal.replace(" & ", ""));
217
+ }
218
+ const componentName = "".concat(prefixNoSpace).concat(widgetName);
219
+ const componentLabel = "".concat(prefix).concat(" ").concat(widgetLabel);
220
+ const description = componentLabel;
221
+
222
+ await validateCompile(
223
+ {
224
+ library,
225
+ organization,
226
+ componentName,
227
+ componentLabel,
228
+ version,
229
+ type,
230
+ subtype,
231
+ description,
232
+ allowedApplications
233
+ },
234
+ options
235
+ )
236
+ }
237
+
238
+
239
+ }
240
+
241
+
242
+ export const validateCompile = async (
243
+ {
244
+ library,
245
+ organization,
246
+ componentName,
247
+ componentLabel,
248
+ version,
249
+ framework,
250
+ type,
251
+ subtype,
252
+ description,
253
+ allowedApplications
254
+ },
255
+ options
256
+ ) => {
257
+
258
+ let sSubType = subtype;
259
+ if (Array.isArray(subtype)) {
260
+ sSubType = subtype.join("-");
261
+ }
262
+
263
+ const typeLC = type.toLowerCase();
264
+
265
+ //await checkPathAccess(pegaConfigInternalJsonPath);
266
+
267
+ framework = convertIntoPascalCase(CATEGORY_CONSTELLATION);
268
+
269
+ let pegaConfig = await getPegaConfig();
270
+ let templateParentDir = `./templates/${framework}`;
271
+
272
+
273
+ const templateDir = `${templateParentDir}/${type}/${sSubType}`;
274
+ let templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
275
+ templateDirectory = templateDirectory.replace( path.sep + "create-all", path.sep + "create");
276
+
277
+ const componentKey = `${organization}_${library}_${componentName}`;
278
+
279
+ const targetDirectory = await getComponentDirectoryPath(componentKey);
280
+
281
+ const components = await getComponents(false);
282
+
283
+
284
+ if (components.includes(componentKey)) {
285
+ console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
286
+
287
+ return;
288
+ }
289
+
290
+ // component
291
+ await copyComponentTemplate({
292
+ ...options,
293
+ targetDirectory,
294
+ templateDirectory
295
+ });
296
+ await compileMustacheTemplates(targetDirectory, {
297
+ componentKey,
298
+ componentName,
299
+ componentLabel,
300
+ library,
301
+ version,
302
+ type,
303
+ subtype,
304
+ description,
305
+ organization,
306
+ allowedApplications
307
+ });
308
+
309
+
310
+ console.log(chalk.green(`created ${componentKey} component in ${targetDirectory}`));
311
+
312
+
313
+
314
+ };
315
+
316
+ export default async options => {
317
+ showVersion();
318
+
319
+ await checkPathAccess(pegaConfigJsonPath);
320
+
321
+ let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
322
+ data = data && JSON.parse(data);
323
+
324
+ if (!data[COMPONENTS_DIRECTORY_PATH]) {
325
+ console.error(
326
+ `${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
327
+ );
328
+ process.exit(1);
329
+ }
330
+
331
+ const componentData = data[COMPONENTS_PATH];
332
+
333
+ const { library } = componentData;
334
+ const { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
335
+
336
+ let componentDefaults = await getComponentDefaults();
337
+ componentDefaults.library = library;
338
+
339
+
340
+ const questions = [
341
+ {
342
+ name: 'prefix',
343
+ message: 'Enter prefix label'
344
+ },
345
+ {
346
+ name: 'version',
347
+ message: 'Enter component version',
348
+ default: componentDefaults.version,
349
+ validate: value => {
350
+ if (validateSemver(value)) {
351
+ return true;
352
+ }
353
+ return 'Please provide semver compatible version e.g 0.0.1';
354
+ }
355
+ },
356
+ {
357
+ name: 'library',
358
+ message: 'Enter library name (required)',
359
+ default: componentDefaults.library,
360
+ validate: value => {
361
+ /* value should not be empty
362
+ It should not have spaces
363
+ It should not start with a number
364
+ Only case-insensitive alphanumeric values are allowed
365
+ */
366
+ if (value && !/^\d/.test(value) && value === sanitize(value)) {
367
+ return true;
368
+ }
369
+ return 'Only alphanumeric values are allowed, starting with alphabets';
370
+ }
371
+ },
372
+ {
373
+ name: 'allowedApplications',
374
+ message: 'Please enter the application names to be supported (comma-separated). ',
375
+ suffix: 'Keep empty for all applications'
376
+ }
377
+ ];
378
+
379
+ await inquirer.prompt(questions).then(async answers => {
380
+ const {
381
+ prefix,
382
+ library,
383
+ version,
384
+ allowedApplications
385
+ } = answers;
386
+ await validateCompileAll(
387
+ {
388
+ prefix,
389
+ library,
390
+ version,
391
+ allowedApplications,
392
+ organization
393
+ },
394
+ options
395
+ );
396
+ });
397
+
398
+ };
@@ -2,17 +2,17 @@ import chalk from 'chalk';
2
2
  import inquirer from 'inquirer';
3
3
  import ora from 'ora';
4
4
 
5
- import { LIST_COMPONENT_SERVICE_REST_ENDPOINT } from '../../constants.js';
5
+
6
6
  import {
7
- constructCompleteUrl,
8
7
  deleteLocalComponent,
9
8
  deleteServerComponent,
10
9
  getComponents,
11
- getPegaServerConfig,
12
- nodeFetch
10
+ getPegaServerConfig
13
11
  } from '../../util.js';
14
12
  import { getComponentsFromServer } from '../list/helper.js';
15
13
 
14
+
15
+
16
16
  export const SOURCE_OF_COMPONENT_TYPES = {
17
17
  SERVER: 'Server',
18
18
  LOCAL: 'Local'
@@ -92,6 +92,8 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
92
92
  choices: choicesArr
93
93
  });
94
94
  await deleteServerComponent(answers.componentToDelete);
95
+
96
+
95
97
  } else {
96
98
  console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
97
99
  }
@@ -9,6 +9,8 @@ import {
9
9
  getDeleteComponentsQuestions
10
10
  } from './helper.js';
11
11
 
12
+ import { showVersion } from '../../util.js';
13
+
12
14
  const deleteComponentsFn = async (sourceOfComponents, answers) => {
13
15
  switch (sourceOfComponents) {
14
16
  case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
@@ -27,6 +29,8 @@ const deleteComponentsFn = async (sourceOfComponents, answers) => {
27
29
  };
28
30
 
29
31
  export default async options => {
32
+ showVersion();
33
+
30
34
  let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
31
35
  if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
32
36
  sourceOfComponentsOption = options.params[3];
@@ -0,0 +1,153 @@
1
+ import chalk from 'chalk';
2
+ import inquirer from 'inquirer';
3
+ import ora from 'ora';
4
+
5
+ import {
6
+ deleteLocalComponent,
7
+ deleteServerComponent,
8
+ getComponents,
9
+ getPegaServerConfig,
10
+ validateRulesetVersion
11
+ } from '../../util.js';
12
+ import { getComponentsFromServer } from '../list/helper.js';
13
+
14
+ export const SOURCE_OF_COMPONENT_TYPES = {
15
+ SERVER: 'Server',
16
+ LOCAL: 'Local'
17
+ };
18
+
19
+ export const getDeleteComponentsQuestions = async (options, sourceOfComponentsOption) => {
20
+ const defaultPegaServerConfig = await getPegaServerConfig();
21
+
22
+
23
+ return [
24
+ {
25
+ name: 'sourceOfComponents',
26
+ type: 'rawlist',
27
+ message: 'Delete components from Server or Local ?',
28
+ choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
29
+ default: defaultPegaServerConfig.sourceOfComponents,
30
+ when() {
31
+ return !options.params[3];
32
+ }
33
+ }
34
+ ];
35
+ };
36
+
37
+
38
+
39
+ export const deleteLocalComponents = async sourceOfComponents => {
40
+ const localComponents = await getComponents();
41
+
42
+ for (var index in localComponents) {
43
+ console.log(chalk.bold.green(localComponents[index]));
44
+ }
45
+
46
+ if (localComponents.length > 0) {
47
+ const answers = await inquirer.prompt([
48
+
49
+ {
50
+ name: 'confirmDeletion',
51
+ type: 'confirm',
52
+ message: 'Delete all local ?',
53
+ default: false
54
+ }
55
+ ]);
56
+ if (answers.confirmDeletion) {
57
+ for (var index in localComponents) {
58
+ var componentToDelete = localComponents[index];
59
+ //console.log(chalk.bold.green("Deleting: " + componentToDelete));
60
+ await deleteLocalComponent(componentToDelete);
61
+ }
62
+ }
63
+ } else {
64
+ console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
65
+ }
66
+ };
67
+
68
+ export const deleteServerComponents = async (sourceOfComponents, answers) => {
69
+ const spinner = ora('Fetching components from server').start();
70
+ const data = await getComponentsFromServer(answers);
71
+ const defaultPegaConfig = await getPegaServerConfig();
72
+
73
+ const serverComponents = JSON.parse(data);
74
+ spinner.stop();
75
+ if (serverComponents && serverComponents.pxResults?.length > 0) {
76
+ const choicesArr = serverComponents.pxResults.map(({ label, pyRuleSet, pyRuleSetVersion }) => {
77
+ const name = `${standardizeStr(label, 45)} ${standardizeStr(pyRuleSet, 30)} ${standardizeStr(
78
+ pyRuleSetVersion,
79
+ 20
80
+ )}`;
81
+
82
+ const value = `${label}~|~${pyRuleSet}~|~${pyRuleSetVersion}`;
83
+ const short = `Selected component : ${chalk.redBright(
84
+ `${label} ${pyRuleSet} : ${pyRuleSetVersion}`
85
+ )}`;
86
+
87
+ return { name, value, short };
88
+ });
89
+
90
+ const selectedComp = await inquirer.prompt([
91
+ {
92
+ name: 'rulesetName',
93
+ message: 'Enter ruleset name',
94
+ default: defaultPegaConfig.rulesetName,
95
+ validate: value => {
96
+ if (value.trim()) {
97
+ return true;
98
+ }
99
+ return 'Ruleset name cannot be empty';
100
+ }
101
+ },
102
+ {
103
+ name: 'rulesetVersion',
104
+ message: 'Enter ruleset version',
105
+ default: defaultPegaConfig.rulesetVersion,
106
+ validate: value => {
107
+ if (validateRulesetVersion(value)) {
108
+ return true;
109
+ }
110
+ return 'Please provide compatible version e.g 01-01-01';
111
+ }
112
+ }
113
+ ]);
114
+
115
+ for (var index in choicesArr) {
116
+ var componentToDelete = choicesArr[index].value;
117
+ var arData = componentToDelete.split("~|~");
118
+ if (arData[1] == selectedComp.rulesetName && arData[2] == selectedComp.rulesetVersion) {
119
+ console.log(chalk.bold.green(arData[0]));
120
+ }
121
+ }
122
+
123
+
124
+ const answers = await inquirer.prompt([
125
+ {
126
+ name: 'confirmDeletion',
127
+ type: 'confirm',
128
+ message: 'Do you want to delete these components ?',
129
+ default: false
130
+ }
131
+ ]);
132
+ if (answers.confirmDeletion) {
133
+ for (var index in choicesArr) {
134
+ var componentToDelete = choicesArr[index].value;
135
+ var arData = componentToDelete.split("~|~");
136
+ if (arData[1] == selectedComp.rulesetName && arData[2] == selectedComp.rulesetVersion) {
137
+ await deleteServerComponent(componentToDelete);
138
+ }
139
+ }
140
+ }
141
+
142
+
143
+ } else {
144
+ console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
145
+ }
146
+ };
147
+
148
+ export const standardizeStr = (str, leng) => {
149
+ for (let i = str.length; i <= leng; i++) {
150
+ str += ' ';
151
+ }
152
+ return str;
153
+ };
@@ -0,0 +1,49 @@
1
+ import inquirer from 'inquirer';
2
+ import ora from 'ora';
3
+ import chalk from 'chalk';
4
+
5
+ import {
6
+ deleteLocalComponents,
7
+ SOURCE_OF_COMPONENT_TYPES,
8
+ deleteServerComponents,
9
+ getDeleteComponentsQuestions
10
+ } from './helper.js';
11
+
12
+ import { showVersion } from '../../util.js';
13
+
14
+ const deleteComponentsFn = async (sourceOfComponents, answers) => {
15
+ switch (sourceOfComponents) {
16
+ case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
17
+ await deleteLocalComponents(sourceOfComponents);
18
+ break;
19
+ }
20
+ case SOURCE_OF_COMPONENT_TYPES.SERVER: {
21
+ await deleteServerComponents(sourceOfComponents, answers);
22
+ break;
23
+ }
24
+ default: {
25
+ console.log('Source of components needs to be either Local or Server');
26
+ break;
27
+ }
28
+ }
29
+ };
30
+
31
+ export default async options => {
32
+ showVersion();
33
+
34
+ let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
35
+ if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
36
+ sourceOfComponentsOption = options.params[3];
37
+ await deleteComponentsFn(sourceOfComponentsOption);
38
+ } else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
39
+ sourceOfComponentsOption = options.params[3];
40
+ const questions = await getDeleteComponentsQuestions(options, sourceOfComponentsOption);
41
+ const answers = await inquirer.prompt(questions);
42
+ await deleteComponentsFn(sourceOfComponentsOption, answers);
43
+ } else {
44
+ const questions = await getDeleteComponentsQuestions(options);
45
+ const answers = await inquirer.prompt(questions);
46
+ const { sourceOfComponents } = answers;
47
+ await deleteComponentsFn(sourceOfComponents, answers);
48
+ }
49
+ };
@@ -0,0 +1,23 @@
1
+ You are a Pega Digital Experience (DX) Component and React expert who only produces sample code with no additional narrative. A Pega React DX Component is a functional component that uses hooks, PropTypes and StyledComponents.
2
+
3
+
4
+ Very important: The name of the component comes from component definition compName.
5
+
6
+ Very important: The type of component to be created comes from component definition subtype.
7
+
8
+ Very important: A DX component has all of it's data passed in via a single object that must always be called props. The object properties are then destructured in the component. There is always a function passed in called getPConnect() that is required. All event handlers are created in the same component and not passed in via the props object. Apart from getPConnect() all of the object properties are defined in an array called properties in a file called config.json (a.k.a the component definition).
9
+
10
+
11
+ Presentation components are imported from the Constellation Design System from the packages @pega/cosmos-react-core, @pega/cosmos-react-work, @pega/cosmos-react-social.
12
+
13
+ {{COMPONENT_ADDITIONAL}}
14
+
15
+ Build a component defined by subtype in component definition.
16
+
17
+ Should use the following design system components
18
+
19
+ DesignSystemComponents:
20
+ {{COMPONENT_DSC}}
21
+
22
+ Here is the component definition
23
+ {{COMPONENT_CONFIG}}
@@ -0,0 +1,14 @@
1
+ You are a Pega Digital Experience (DX) Component and React expert who only produces sample code with no additional narrative. A Pega React DX Component is a functional component that uses hooks, PropTypes and StyledComponents.
2
+
3
+
4
+ Very important: The name of the component comes from component definition compName.
5
+
6
+ Very important: A DX component has all of it's data passed in via a single object that must always be called props. The object properties are then destructured in the component. There is always a function passed in called getPConnect() that is required. All event handlers are created in the same component and not passed in via the props object. Apart from getPConnect() all of the object properties are defined in an array called properties in a file called config.json (a.k.a the component definition).
7
+
8
+
9
+ Presentation components are imported from the Constellation Design System from the packages @pega/cosmos-react-core, @pega/cosmos-react-work, @pega/cosmos-react-social.
10
+
11
+ {{COMPONENT_ADDITIONAL}}
12
+
13
+ Here is the component definition
14
+ {{COMPONENT_CONFIG}}