@pega/custom-dx-components 0.0.1 → 0.23.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.
Files changed (223) 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 +122 -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 +145 -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 +195 -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 +256 -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 +278 -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 +291 -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 +93 -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 +347 -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 +114 -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 +14 -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 +111 -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 +111 -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 +111 -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 +123 -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 +237 -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 +185 -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 +35 -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 +42 -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 +45 -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 +27 -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 +32 -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 +23 -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 +59 -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/create/templates/Constellation/Widget/PAGE/styles.js.mustache +7 -0
  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 +66 -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/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +7 -0
  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 +121 -0
  190. package/src/tasks/generate-ai/helper.js +184 -0
  191. package/src/tasks/generate-ai/index.js +33 -0
  192. package/src/tasks/index.js +7 -0
  193. package/src/tasks/init/index.js +9 -3
  194. package/src/tasks/init/template/.eslintignore +8 -0
  195. package/src/tasks/init/template/.eslintrc.json +186 -5
  196. package/src/tasks/init/template/.vscode/extensions.json +1 -1
  197. package/src/tasks/init/template/README.md +80 -61
  198. package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
  199. package/src/tasks/init/template/keys/dxcb.crt +32 -0
  200. package/src/tasks/init/template/keys/dxcb.key +51 -0
  201. package/src/tasks/init/template/package.json.mustache +44 -21
  202. package/src/tasks/init/template/tasks.config.json +19 -5
  203. package/src/tasks/init/template/templateNPMRC.txt +8 -0
  204. package/src/tasks/linter/index.js +46 -0
  205. package/src/tasks/list/helper.js +19 -6
  206. package/src/tasks/list/index.js +4 -0
  207. package/src/tasks/publish/helper.js +13 -4
  208. package/src/tasks/publish/index.js +14 -1
  209. package/src/tasks/publish-all/helper.js +154 -0
  210. package/src/tasks/publish-all/index.js +95 -0
  211. package/src/tasks/rename/index.js +314 -0
  212. package/src/tasks/validator/index.js +291 -18
  213. package/src/util.js +247 -6
  214. package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
  215. package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +0 -10
  216. package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +0 -122
  217. package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +0 -14
  218. package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +0 -13
  219. package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +0 -10
  220. package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +0 -14
  221. package/src/tasks/init/template/src/components/MBTAList/index.ts +0 -2
  222. /package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
  223. /package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
@@ -0,0 +1,122 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import https from 'https';
4
+
5
+ import fetch from 'node-fetch';
6
+ import AdmZip from 'adm-zip';
7
+ import chalk from 'chalk';
8
+
9
+ import {
10
+ constructCompleteUrl,
11
+ getComponentDirectoryPath,
12
+ getComponents,
13
+ getPegaServerConfig
14
+ } from '../../util.js';
15
+ import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
16
+
17
+ export const getPublishComponentQuestions = async () => {
18
+ const components = await getComponents();
19
+ const defaultPegaConfig = await getPegaServerConfig();
20
+
21
+ return [
22
+ {
23
+ name: 'componentKey',
24
+ type: 'rawlist',
25
+ message: 'Select component to build',
26
+ choices: components
27
+ },
28
+ {
29
+ name: 'sourceMap',
30
+ message: 'Generate source map ?',
31
+ default: defaultPegaConfig.sourceMap,
32
+ when: () => false && !process.env.SOURCE_MAP
33
+ },
34
+ {
35
+ name: 'devBuild',
36
+ message: 'Generate development build ?',
37
+ default: defaultPegaConfig.devBuild
38
+ }
39
+ ];
40
+ };
41
+
42
+ export const zipComponent = async componentKey => {
43
+ const srcDirectory = await getComponentDirectoryPath(componentKey);
44
+ const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
45
+ const configJson = `${srcDirectory}/config.json`;
46
+
47
+ const zip = new AdmZip();
48
+
49
+ zip.addLocalFolder(srcDirectory, 'src/');
50
+ zip.addLocalFile(configJson);
51
+ zip.addLocalFolder(buildDirectory);
52
+ const zipContent = zip.toBuffer().toString('base64');
53
+
54
+ const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
55
+ fs.rmdir('dist', { recursive: true }, err => {
56
+ if (err) {
57
+ throw err;
58
+ }
59
+ });
60
+ return { zipContent, configContent };
61
+ };
62
+
63
+ export const publishComponentToServer = async data => {
64
+ const { configContent, zipContent, componentKey, rulesetName, rulesetVersion } = data;
65
+
66
+ const apiBody = {
67
+ configContent,
68
+ zipContent,
69
+ componentKey: JSON.parse(configContent).componentKey,
70
+ publishFor: 'constellation',
71
+ rulesetName,
72
+ rulesetVersion,
73
+ category: ''
74
+ };
75
+ const defaultPegaConfig = await getPegaServerConfig();
76
+ const url = constructCompleteUrl(
77
+ defaultPegaConfig.server,
78
+ PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
79
+ );
80
+ try {
81
+ const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
82
+ if (OauthData) {
83
+ const {
84
+ access_token: accessToken,
85
+ token_type: tokenType,
86
+ refresh_token: refreshToken
87
+ } = JSON.parse(OauthData);
88
+ let status = 500;
89
+ fetch(url, {
90
+ method: 'POST',
91
+ agent: new https.Agent({ rejectUnauthorized: false }),
92
+ headers: {
93
+ Authorization: `${tokenType} ${accessToken}`
94
+ },
95
+ body: JSON.stringify(apiBody)
96
+ })
97
+ .then(response => {
98
+ status = response.status;
99
+ return response.text();
100
+ })
101
+ .then(resp => {
102
+ const respData = JSON.parse(resp);
103
+ if (status === 401) {
104
+ throw new Error(
105
+ 'Error occurred in authentication. Please regenerate using authenticate'
106
+ );
107
+ // console.log(accessTokenUri, refreshToken);
108
+ /* TODO - Handle refresh_token */
109
+ } else if (status == 200) {
110
+ console.log(chalk.bold.green(`Success : ${respData.message}`));
111
+ } else {
112
+ throw new Error(`${respData.message}`);
113
+ }
114
+ })
115
+ .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
116
+ } else {
117
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
118
+ }
119
+ } catch (err) {
120
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
121
+ }
122
+ };
@@ -0,0 +1,54 @@
1
+ import inquirer from 'inquirer';
2
+ import Listr from 'listr';
3
+ import chalk from 'chalk';
4
+
5
+ import validate from '../validator/index.js';
6
+
7
+ import bundleComponent from '../bundle/index.js';
8
+ import lintComponent from '../linter/index.js';
9
+ import { getPublishComponentQuestions } from './helper.js';
10
+ import { getComponentDirectoryPath, showVersion } from '../../util.js';
11
+
12
+ export default async options => {
13
+ showVersion();
14
+
15
+ const questions = await getPublishComponentQuestions();
16
+ const answers = await inquirer.prompt(questions);
17
+ const { componentKey, sourceMap, devBuild } = answers;
18
+
19
+ let content = {
20
+ ...answers
21
+ };
22
+
23
+ const tasks = new Listr(
24
+ [
25
+ {
26
+ title: 'Validate config schema',
27
+ task: async () => {
28
+ await validate(componentKey);
29
+ }
30
+ },
31
+ {
32
+ title: 'Lint component',
33
+ task: async () => {
34
+ const targetDirectory = await getComponentDirectoryPath(componentKey);
35
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
36
+ await lintComponent(targetDirectory);
37
+ }
38
+ },
39
+ {
40
+ title: 'Bundle Component',
41
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
42
+ skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
43
+ }
44
+ ],
45
+ {
46
+ exitOnError: true
47
+ }
48
+ );
49
+
50
+ await tasks.run().catch(err => {
51
+ console.log(chalk.bold.red(err.toString()));
52
+ });
53
+ return true;
54
+ };
@@ -0,0 +1,70 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ import AdmZip from 'adm-zip';
5
+ import chalk from 'chalk';
6
+
7
+ import {
8
+ getComponentDirectoryPath,
9
+ getComponents,
10
+ getPegaServerConfig
11
+ } from '../../util.js';
12
+ import { COMPONENT_SCHEMA } from '../../constants.js';
13
+
14
+ export const cleanUp = async () => {
15
+ fs.rm('dist/components', { recursive: true }, err => {
16
+ if (err) {
17
+ throw err;
18
+ }
19
+ });
20
+
21
+ fs.rm('lib', { recursive: true }, err => {
22
+ if (err) {
23
+ throw err;
24
+ }
25
+ });
26
+ }
27
+
28
+
29
+
30
+ export const getBuildComponentQuestions = async () => {
31
+ const components = await getComponents();
32
+ const defaultPegaConfig = await getPegaServerConfig();
33
+
34
+ if (components.length == 0) {
35
+ console.log(chalk.bold.yellow(`No components to build`));
36
+ process.exit(1);
37
+ }
38
+
39
+ return [
40
+ {
41
+ name: 'devBuild',
42
+ message: 'Generate development build ?',
43
+ default: defaultPegaConfig.devBuild
44
+ }
45
+ ];
46
+ };
47
+
48
+
49
+
50
+ export const zipComponent = async (componentKey) => {
51
+ const srcDirectory = await getComponentDirectoryPath(componentKey);
52
+ const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
53
+ const configJson = `${srcDirectory}/config.json`;
54
+
55
+ const zip = new AdmZip();
56
+
57
+ zip.addLocalFolder(srcDirectory, 'src/');
58
+ zip.addLocalFile(configJson);
59
+ zip.addLocalFolder(buildDirectory);
60
+ const zipContent = zip.toBuffer().toString('base64');
61
+
62
+ const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
63
+ // clean up now happens in function cleanUp
64
+ // fs.rmd('dist/components', { recursive: true }, err => {
65
+ // if (err) {
66
+ // throw err;
67
+ // }
68
+ // });
69
+ return { zipContent, configContent };
70
+ };
@@ -0,0 +1,79 @@
1
+ import inquirer from 'inquirer';
2
+ import Listr from 'listr';
3
+ import chalk from 'chalk';
4
+
5
+ import validate from '../validator/index.js';
6
+
7
+ import bundleComponent from '../bundle/index.js';
8
+ import lintComponent from '../linter/index.js';
9
+ import { getBuildComponentQuestions, cleanUp } from './helper.js';
10
+ import { getComponentDirectoryPath, showVersion, getComponentsObj } from '../../util.js';
11
+
12
+ import { CATEGORY_CONSTELLATION } from '../../constants.js';
13
+
14
+
15
+ export function getCustomTasks(componentKey, sourceMap, devBuild) {
16
+
17
+ const customTasks = new Listr(
18
+ [
19
+ {
20
+ title: 'Validate config schema',
21
+ task: async () => {
22
+ await validate(componentKey);
23
+ }
24
+ },
25
+ {
26
+ title: 'Lint component',
27
+ task: async () => {
28
+ const targetDirectory = await getComponentDirectoryPath(componentKey);
29
+ // console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
30
+ await lintComponent(targetDirectory);
31
+ }
32
+ },
33
+ {
34
+ title: 'Bundle component',
35
+ task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
36
+ }
37
+ ],
38
+ {
39
+ exitOnError: true
40
+ }
41
+ );
42
+
43
+ return customTasks;
44
+ }
45
+
46
+
47
+
48
+
49
+ export default async options => {
50
+ showVersion();
51
+
52
+ let category = CATEGORY_CONSTELLATION;
53
+
54
+ const components = await getComponentsObj();
55
+ const questions = await getBuildComponentQuestions();
56
+ const answers = await inquirer.prompt(questions);
57
+ const { sourceMap, devBuild } = answers;
58
+
59
+
60
+
61
+ var componentKey;
62
+
63
+
64
+ for (var index in components) {
65
+ componentKey = components[index].value;
66
+ console.log(chalk.bold.green("Building: " + components[index].name));
67
+
68
+ let myCustomTasks = getCustomTasks(componentKey, sourceMap, devBuild );
69
+
70
+ await myCustomTasks.run().catch(err => {
71
+ console.log(chalk.bold.red(err.toString()));
72
+ });
73
+ }
74
+
75
+
76
+ cleanUp();
77
+
78
+ return true;
79
+ };
@@ -36,13 +36,40 @@ const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
36
36
  const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
37
37
  const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
38
38
 
39
+ let compilationErrors = null;
40
+
39
41
  // Create the build and print the deployment instructions.
40
42
  function build(config, previousFileSizes) {
41
43
  console.log(`Creating a ${Env} build...`);
42
44
 
45
+
46
+
43
47
  const compiler = webpack(config);
44
48
  return new Promise((resolve, reject) => {
45
49
  compiler.run((err, stats) => {
50
+
51
+ if (err != null && typeof (err) == "object") {
52
+ if (err.error != undefined) {
53
+ //store and print elsewhere
54
+ compilationErrors = err.error;
55
+ //console.log("err:" + err);
56
+ }
57
+ }
58
+ if (stats != null & typeof(stats) == "object") {
59
+ if (stats.errors != undefined) {
60
+ console.log("stats:" + stats);
61
+ }
62
+ else if (stats.compilation != undefined && stats.compilation.errors != undefined) {
63
+
64
+ //store and print elsewhere
65
+ compilationErrors = stats.compilation.errors;
66
+
67
+ console.log("stats:" + stats);
68
+ }
69
+
70
+ }
71
+
72
+
46
73
  let messages;
47
74
  if (err) {
48
75
  if (!err.message) {
@@ -131,7 +158,11 @@ export default ({
131
158
  .then(
132
159
  ({ stats, previousFileSizes, warnings }) => {
133
160
  if (warnings.length) {
134
- console.log(chalk.yellow('Compiled with warnings.\n'), warnings[0].message);
161
+ //console.log(chalk.yellow('Compiled with warnings.\n'), warnings[0].message);
162
+ console.log(chalk.yellow('Compiled with warnings.\n'));
163
+ for (let warning in warnings) {
164
+ console.log(chalk.yellow("Warning.."), warnings[warning].message);
165
+ }
135
166
  } else {
136
167
  console.log(chalk.green('Compiled successfully.\n'));
137
168
  }
@@ -146,7 +177,7 @@ export default ({
146
177
  );
147
178
  resolve('done emitting');
148
179
  },
149
- err => {
180
+ err => {
150
181
  reject();
151
182
  const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
152
183
  if (tscCompileOnError) {
@@ -156,11 +187,24 @@ export default ({
156
187
  )
157
188
  );
158
189
  printBuildError(err);
159
- } else {
160
- console.log(chalk.red('Failed to compile.\n'));
161
- printBuildError(err);
190
+ }
191
+ else if (compilationErrors != null) {
192
+ if (compilationErrors.length == undefined) {
193
+ console.log(chalk.red("Error..."), compilationErrors.message);
194
+ }
195
+ else {
196
+ for (let error in compilationErrors) {
197
+ console.log(chalk.red("Error..."), compilationErrors[error].message);
198
+ }
199
+ }
200
+
162
201
  process.exit(1);
163
202
  }
203
+ else {
204
+ console.log(chalk.red('Failed to compile.\n'));
205
+ printBuildError(JSON.stringify(err));
206
+
207
+ }
164
208
  }
165
209
  )
166
210
  .catch(err => {
@@ -103,13 +103,13 @@ export default (
103
103
  return loaders;
104
104
  };
105
105
  return {
106
- mode: isEnvDevelopment ? 'development' : 'production',
106
+ mode: devBuild ? 'development' : 'production',
107
107
  // Stop compilation early in production
108
108
  bail: isEnvProduction,
109
109
  // These are the "entry points" to our application.
110
110
  // This means they will be the "root" imports that are included in JS bundle.
111
111
  entry: inputFile,
112
- devtool: shouldUseSourceMap ? 'source-map' : false,
112
+ devtool: devBuild ? 'eval-cheap-module-source-map' : false,
113
113
  output: {
114
114
  // The build folder.
115
115
  path: paths.appBuild,
@@ -310,18 +310,20 @@ export default (
310
310
  resourceRegExp: /^\.\/icons$/,
311
311
  contextRegExp: /@pega\/cosmos-react-core\/lib\/components\/Icon$/
312
312
  }),
313
+
313
314
  /* Ignore cosmos icons - windows */
314
315
  new webpack.IgnorePlugin({
315
316
  resourceRegExp: /^\.\/icons$/,
316
317
  contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
317
318
  }),
319
+
318
320
  new webpack.optimize.LimitChunkCountPlugin({
319
321
  maxChunks: 5
320
322
  }),
321
323
  new webpack.optimize.MinChunkSizePlugin({
322
324
  minChunkSize: 100000 // Minimum number of characters
323
325
  }),
324
- isEnvProduction && new CompressionPlugin(compressionBRConfObj)
326
+ !devBuild && new CompressionPlugin(compressionBRConfObj)
325
327
 
326
328
  /* Dont generate gzip file */
327
329
  /* isEnvProduction && new CompressionPlugin(compressionGZConfObj) */
@@ -2,8 +2,8 @@ import path from 'path';
2
2
  import fs from 'fs';
3
3
  import { stat } from 'fs/promises';
4
4
 
5
- import { BUILD_CONFIG_JSON_FILENAME } from '../../../constants.js';
6
- import { getComponentDirectoryPath } from '../../../util.js';
5
+ import { BUILD_CONFIG_JSON_FILENAME } from '../../constants.js';
6
+ import { getComponentDirectoryPath } from '../../util.js';
7
7
 
8
8
  import buildComponent from './builder/index.js';
9
9