@pega/custom-dx-components 8.8.16 → 8.8.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 (246) hide show
  1. package/.prettierrc.json +7 -1
  2. package/babel.config.cjs +13 -0
  3. package/jest.config.cjs +37 -0
  4. package/package.json +12 -4
  5. package/src/auth.js +9 -3
  6. package/src/cli.js +12 -0
  7. package/src/constants.js +9 -4
  8. package/src/currentPath.cjs +1 -0
  9. package/src/tasks/authenticate/index.js +43 -40
  10. package/src/tasks/build/helper.js +18 -31
  11. package/src/tasks/build/index.js +26 -6
  12. package/src/tasks/build-all/index.js +15 -3
  13. package/src/tasks/bundle/builder/index.js +5 -0
  14. package/src/tasks/bundle/builder/webpack.config.js +1 -3
  15. package/src/tasks/create/index.js +17 -7
  16. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +13 -6
  17. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +7 -7
  18. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +8 -8
  19. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +13 -6
  20. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +10 -10
  21. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +6 -5
  22. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +6 -3
  23. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +13 -6
  24. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +13 -6
  25. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +13 -6
  26. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +13 -6
  27. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +13 -6
  28. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +13 -6
  29. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +13 -6
  30. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +13 -6
  31. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +13 -6
  32. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +13 -6
  33. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +13 -6
  34. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +13 -6
  35. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +13 -6
  36. package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +6 -5
  37. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +13 -6
  38. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +13 -6
  39. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +13 -6
  40. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +13 -6
  41. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +13 -6
  42. package/src/tasks/create/templates/Constellation/Widget/CASE/styles.js.mustache +13 -6
  43. package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +13 -6
  44. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +13 -6
  45. package/src/tasks/create-all/index.js +109 -150
  46. package/src/tasks/delete/helper.js +87 -53
  47. package/src/tasks/delete/index.js +8 -15
  48. package/src/tasks/delete-all/helper.js +132 -85
  49. package/src/tasks/delete-all/index.js +8 -15
  50. package/src/tasks/index.js +2 -0
  51. package/src/tasks/init/index.js +20 -22
  52. package/src/tasks/init/template/babel.config.cjs +13 -0
  53. package/src/tasks/init/template/jest.config.cjs +21 -0
  54. package/src/tasks/init/template/package.json.mustache +6 -4
  55. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/config.json +55 -0
  56. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/demo.stories.jsx +51 -0
  57. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/index.jsx +60 -0
  58. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/mock.stories.js +13 -0
  59. package/src/tasks/init/template/test/assets/components/create/Pega_DXIL_MyTestText/styles.js +14 -0
  60. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/Boolean.js +38 -0
  61. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/boolean-format.js +26 -0
  62. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/config.json +145 -0
  63. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/demo.stories.jsx +61 -0
  64. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/event-utils.js +18 -0
  65. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/index.jsx +170 -0
  66. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/mock.stories.js +21 -0
  67. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyBoolean/styles.js +14 -0
  68. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/OneColumnPage.svg +36 -0
  69. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/config.json +23 -0
  70. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/demo.stories.jsx +78 -0
  71. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/index.jsx +73 -0
  72. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/mock.stories.js +390 -0
  73. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCaseWidget/styles.js +14 -0
  74. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/config.json +291 -0
  75. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/demo.stories.jsx +53 -0
  76. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/event-utils.js +18 -0
  77. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/index.jsx +296 -0
  78. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/mock.stories.js +23 -0
  79. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/styles.js +14 -0
  80. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyCurrency/suggestions-handler.js +10 -0
  81. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/DateFormatter.js +61 -0
  82. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/FormattedText.jsx +41 -0
  83. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/config.json +195 -0
  84. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/date.js +439 -0
  85. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/demo.stories.jsx +73 -0
  86. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/index.jsx +256 -0
  87. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/mock.stories.js +23 -0
  88. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/styles.js +14 -0
  89. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDate/suggestions-handler.js +10 -0
  90. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/config.json +256 -0
  91. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date-time.js +92 -0
  92. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date-utils.js +288 -0
  93. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/date.js +331 -0
  94. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/demo.stories.jsx +73 -0
  95. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/index.jsx +254 -0
  96. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/mock.stories.js +23 -0
  97. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/styles.js +14 -0
  98. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDateTime/suggestions-handler.js +10 -0
  99. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/config.json +278 -0
  100. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/demo.stories.jsx +49 -0
  101. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/event-utils.js +18 -0
  102. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/index.jsx +270 -0
  103. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/mock.stories.js +21 -0
  104. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/styles.js +14 -0
  105. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDecimal/suggestions-handler.js +10 -0
  106. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/OneColumnDetails.svg +22 -0
  107. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/StatusWork.jsx +26 -0
  108. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/config.json +35 -0
  109. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/demo.stories.jsx +132 -0
  110. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/index.jsx +83 -0
  111. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/mock.stories.js +189 -0
  112. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/styles.js +14 -0
  113. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyDetails/utils.js +152 -0
  114. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/config.json +111 -0
  115. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/demo.stories.jsx +48 -0
  116. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/event-utils.js +18 -0
  117. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/index.jsx +231 -0
  118. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/mock.stories.js +22 -0
  119. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/styles.js +14 -0
  120. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyEmail/suggestions-handler.js +10 -0
  121. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/DefaultForm.svg +29 -0
  122. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/config.json +45 -0
  123. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/demo.stories.jsx +166 -0
  124. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/index.jsx +42 -0
  125. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/mock.stories.js +137 -0
  126. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyForm/styles.js +14 -0
  127. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/config.json +344 -0
  128. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/demo.stories.jsx +49 -0
  129. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/event-utils.js +18 -0
  130. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/index.jsx +333 -0
  131. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/mock.stories.js +21 -0
  132. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/styles.js +14 -0
  133. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyInteger/suggestions-handler.js +10 -0
  134. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/GetNextWork.jsx +35 -0
  135. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/OneColumnPage.svg +36 -0
  136. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/config.json +32 -0
  137. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/demo.stories.jsx +102 -0
  138. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/index.jsx +70 -0
  139. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/localizations.json +4 -0
  140. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/mock.stories.js +94 -0
  141. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/styles.js +14 -0
  142. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPage/utils.js +229 -0
  143. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/Avatar.jsx +75 -0
  144. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/OneColumnPage.svg +36 -0
  145. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/Operator.jsx +237 -0
  146. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/config.json +66 -0
  147. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/demo.stories.jsx +68 -0
  148. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/index.jsx +108 -0
  149. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/mock.stories.js +51 -0
  150. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageCaseWidget/styles.js +14 -0
  151. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/OneColumnPage.svg +36 -0
  152. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/config.json +59 -0
  153. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/demo.stories.jsx +30 -0
  154. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/index.jsx +48 -0
  155. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/mock.stories.js +23 -0
  156. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPageWidget/styles.js +14 -0
  157. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/config.json +111 -0
  158. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/demo.stories.jsx +48 -0
  159. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/event-utils.js +18 -0
  160. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/index.jsx +231 -0
  161. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/mock.stories.js +20 -0
  162. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/styles.js +14 -0
  163. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyParagraph/suggestions-handler.js +10 -0
  164. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/config.json +93 -0
  165. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/demo.stories.jsx +49 -0
  166. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/event-utils.js +18 -0
  167. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/index.jsx +275 -0
  168. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/mock.stories.js +21 -0
  169. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/styles.js +14 -0
  170. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPercentage/suggestions-handler.js +10 -0
  171. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/config.json +123 -0
  172. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/demo.stories.jsx +46 -0
  173. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/event-utils.js +18 -0
  174. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/index.jsx +266 -0
  175. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/mock.stories.js +37 -0
  176. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/styles.js +14 -0
  177. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPhone/suggestions-handler.js +10 -0
  178. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/config.json +114 -0
  179. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/demo.stories.jsx +78 -0
  180. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/event-utils.js +18 -0
  181. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/index.jsx +351 -0
  182. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/mock.stories.js +67 -0
  183. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/styles.js +14 -0
  184. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyPicklist/suggestions-handler.js +10 -0
  185. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/config.json +55 -0
  186. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/demo.stories.jsx +51 -0
  187. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/index.jsx +60 -0
  188. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/mock.stories.js +13 -0
  189. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyText/styles.js +14 -0
  190. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/StatusWork.jsx +26 -0
  191. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/config.json +111 -0
  192. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/demo.stories.jsx +48 -0
  193. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/event-utils.js +18 -0
  194. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/index.jsx +239 -0
  195. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/mock.stories.js +21 -0
  196. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/styles.js +14 -0
  197. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTextInput/suggestions-handler.js +10 -0
  198. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/config.json +185 -0
  199. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/demo.stories.jsx +57 -0
  200. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/index.jsx +213 -0
  201. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/mock.stories.js +20 -0
  202. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/styles.js +14 -0
  203. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/suggestions-handler.js +10 -0
  204. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTimeOfDay/time-of-day.js +288 -0
  205. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/StatusWork.jsx +26 -0
  206. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/TwoColumnDetails.svg +28 -0
  207. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/config.json +42 -0
  208. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/demo.stories.jsx +136 -0
  209. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/index.jsx +83 -0
  210. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/mock.stories.js +230 -0
  211. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/styles.js +14 -0
  212. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnDetails/utils.js +155 -0
  213. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/TwoColumn.svg +38 -0
  214. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/config.json +27 -0
  215. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/demo.stories.jsx +175 -0
  216. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/index.jsx +45 -0
  217. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/mock.stories.js +143 -0
  218. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyTwoColumnForm/styles.js +14 -0
  219. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/config.json +237 -0
  220. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/demo.stories.jsx +46 -0
  221. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/event-utils.js +18 -0
  222. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/index.jsx +232 -0
  223. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/mock.stories.js +22 -0
  224. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/styles.js +14 -0
  225. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/suggestions-handler.js +10 -0
  226. package/src/tasks/init/template/test/assets/components/createAll/Pega_DXIL_MyURL/text-url.jsx +173 -0
  227. package/src/tasks/init/template/test/functionTest/localCreateAllListDeleteAll.test.js +157 -0
  228. package/src/tasks/init/template/test/functionTest/localCreateBuildAllDeleteAll.test.js +148 -0
  229. package/src/tasks/init/template/test/functionTest/localCreateBuildDelete.test.js +84 -0
  230. package/src/tasks/init/template/test/functionTest/localCreateListDelete.test.js +108 -0
  231. package/src/tasks/init/template/test/functionTest/localCreatePublishAllDeleteAll.test.js +148 -0
  232. package/src/tasks/init/template/test/functionTest/localCreatePublishDelete.test.js +84 -0
  233. package/src/tasks/init/template/test/functionTest/localCreateRenameDelete.test.js +84 -0
  234. package/src/tasks/init/template/test/functionTest/localPromoteRevertWP.test.js +59 -0
  235. package/src/tasks/list/helper.js +129 -61
  236. package/src/tasks/list/index.js +3 -4
  237. package/src/tasks/promote-webpack/index.js +126 -0
  238. package/src/tasks/promote-webpack/webpack.config.js +376 -0
  239. package/src/tasks/publish/helper.js +69 -80
  240. package/src/tasks/publish/index.js +29 -12
  241. package/src/tasks/publish-all/helper.js +66 -83
  242. package/src/tasks/publish-all/index.js +30 -18
  243. package/src/tasks/rename/index.js +127 -97
  244. package/src/tasks/revert-webpack/index.js +71 -0
  245. package/src/util.js +205 -108
  246. package/test/unitTest/util.test.js +544 -0
@@ -0,0 +1,376 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+
4
+ const webpack = require('webpack');
5
+ const TerserPlugin = require('terser-webpack-plugin');
6
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
8
+ const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent.js');
9
+ const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin.js');
10
+ const CompressionPlugin = require('compression-webpack-plugin');
11
+
12
+ // Source maps are resource heavy and can cause out of memory issue for large source files.
13
+
14
+ const compressionBRConfObj = {
15
+ filename: '[path][base].br',
16
+ algorithm: 'brotliCompress',
17
+ test: /\.(js|css|html|svg|png|jpg|woff|woff2)$/,
18
+ compressionOptions: { level: 11 }
19
+ };
20
+
21
+ /* For gzip use below */
22
+ const compressionGZConfObj = {
23
+ filename: '[path][base].gz',
24
+ algorithm: 'gzip',
25
+ test: /\.(js|css|html|svg|png|jpg|woff|woff2)$/,
26
+ compressionOptions: { level: 9 }
27
+ };
28
+
29
+ let shouldUseSourceMap = process.env.SOURCE_MAP;
30
+
31
+ const imageInlineSizeLimit = Number.parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || '10000', 10);
32
+
33
+ // style files regex
34
+ const cssRegex = /\.css$/;
35
+ const cssModuleRegex = /\.module\.css$/;
36
+ const sassRegex = /\.(scss|sass)$/;
37
+ const sassModuleRegex = /\.module\.(scss|sass)$/;
38
+
39
+ // Make sure any symlinks in the project folder are resolved:
40
+ // https://github.com/facebook/create-react-app/issues/637
41
+ const appDirectory = fs.realpathSync(process.cwd());
42
+ const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
43
+
44
+ buildPath = 'dist/components';
45
+
46
+ const moduleFileExtensions = [
47
+ 'web.mjs',
48
+ 'mjs',
49
+ 'web.js',
50
+ 'js',
51
+ 'web.ts',
52
+ 'ts',
53
+ 'web.tsx',
54
+ 'tsx',
55
+ 'json',
56
+ 'web.jsx',
57
+ 'jsx'
58
+ ];
59
+
60
+ // Resolve file paths in the same order as webpack
61
+ const resolveModule = (resolveFn, filePath) => {
62
+ const extension = moduleFileExtensions.find(ext =>
63
+ fs.existsSync(resolveFn(`${filePath}.${ext}`))
64
+ );
65
+
66
+ if (extension) {
67
+ return resolveFn(`${filePath}.${extension}`);
68
+ }
69
+
70
+ return resolveFn(`${filePath}.js`);
71
+ };
72
+
73
+ // config after eject: we're in ./config/
74
+
75
+ const appPath = resolveApp('.');
76
+ const appBuild = resolveApp(buildPath);
77
+ const appSrc = resolveApp('src');
78
+
79
+
80
+ // This is the production and development configuration.
81
+ // It is focused on developer experience, fast rebuilds, and a minimal bundle.
82
+ //export default (
83
+ module.exports = (
84
+ webpackEnv,
85
+ // eslint-disable-next-line no-unused-vars
86
+ { inputFile, outputFile, componentKey, externals, globals, sourceMap, devBuild }
87
+ ) => {
88
+ const isEnvDevelopment = webpackEnv === 'development' || devBuild;
89
+ const isEnvProduction = webpackEnv === 'production';
90
+ sourceMap = sourceMap === 'true';
91
+ shouldUseSourceMap = shouldUseSourceMap || sourceMap;
92
+
93
+ // common function to get style loaders
94
+ const getStyleLoaders = (cssOptions, preProcessor) => {
95
+ const loaders = [
96
+ isEnvProduction && {
97
+ loader: MiniCssExtractPlugin.loader
98
+ },
99
+ {
100
+ loader: require.resolve('css-loader'),
101
+ options: cssOptions
102
+ },
103
+ {
104
+ // Options for PostCSS as we reference these options twice
105
+ // Adds vendor prefixing based on your specified browser support in
106
+ // package.json
107
+ loader: require.resolve('postcss-loader'),
108
+ options: {
109
+ postcssOptions: {
110
+ plugins: [
111
+ [
112
+ 'postcss-preset-env',
113
+ {
114
+ // Options
115
+ }
116
+ ]
117
+ ]
118
+ },
119
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment
120
+ }
121
+ }
122
+ ].filter(Boolean);
123
+ if (preProcessor) {
124
+ loaders.push(
125
+ {
126
+ loader: require.resolve('resolve-url-loader'),
127
+ options: {
128
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
129
+ root: appSrc
130
+ }
131
+ },
132
+ {
133
+ loader: require.resolve(preProcessor),
134
+ options: {
135
+ sourceMap: true
136
+ }
137
+ }
138
+ );
139
+ }
140
+ return loaders;
141
+ };
142
+ return {
143
+ mode: devBuild ? 'development' : 'production',
144
+ // Stop compilation early in production
145
+ bail: isEnvProduction,
146
+ // These are the "entry points" to our application.
147
+ // This means they will be the "root" imports that are included in JS bundle.
148
+ entry: inputFile,
149
+ devtool: devBuild ? 'eval-cheap-module-source-map' : false,
150
+ output: {
151
+ // The build folder.
152
+ //path: paths.appBuild,
153
+ //path: resolveApp('dist/components'),
154
+ path: appBuild,
155
+ // There will be one main bundle, and one file per asynchronous chunk.
156
+ // In development, it does not produce real files.
157
+ filename: isEnvProduction
158
+ ? `${componentKey}/${componentKey}.js`
159
+ : isEnvDevelopment && `${componentKey}/${componentKey}.js`,
160
+ chunkFilename: isEnvProduction
161
+ ? `${componentKey}/js/[name].[contenthash:8].chunk.js`
162
+ : isEnvDevelopment && `${componentKey}/js/[name].chunk.js`,
163
+ library: {
164
+ name: componentKey,
165
+ type: 'umd',
166
+ export: 'default'
167
+ },
168
+ publicPath: ''
169
+ },
170
+ optimization: {
171
+ minimize: isEnvProduction,
172
+ minimizer: [new TerserPlugin(), new CssMinimizerPlugin()]
173
+ },
174
+ resolve: {
175
+ plugins: [],
176
+ extensions: ['.tsx', '.ts', '.js']
177
+ },
178
+ resolveLoader: {
179
+ plugins: []
180
+ },
181
+ module: {
182
+ strictExportPresence: true,
183
+ rules: [
184
+ {
185
+ // "oneOf" will traverse all following loaders until one will
186
+ // match the requirements. When no loader matches it will fall
187
+ // back to the "file" loader at the end of the loader list.
188
+ oneOf: [
189
+ // TODO: Merge this config once `image/avif` is in the mime-db
190
+ // https://github.com/jshttp/mime-db
191
+ {
192
+ test: [/\.avif$/],
193
+ loader: require.resolve('url-loader'),
194
+ options: {
195
+ limit: imageInlineSizeLimit,
196
+ mimetype: 'image/avif',
197
+ name: `${componentKey}/media/[name].[hash:8].[ext]`
198
+ }
199
+ },
200
+ // "url" loader works like "file" loader except that it embeds assets
201
+ // smaller than specified limit in bytes as data URLs to avoid requests.
202
+ // A missing `test` is equivalent to a match.
203
+ {
204
+ test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.svg$/],
205
+ loader: require.resolve('url-loader'),
206
+ options: {
207
+ limit: imageInlineSizeLimit,
208
+ name: `${componentKey}/media/[name].[hash:8].[ext]`
209
+ }
210
+ },
211
+ // Process application JS with TS-Loader.
212
+ // The preset includes JSX, Flow, TypeScript, and some ESnext features.
213
+ {
214
+ test: /\.(js|mjs|jsx)$/,
215
+ include: appSrc,
216
+ loader: 'ts-loader',
217
+ options: {
218
+ configFile: 'tsconfig.build.json'
219
+ },
220
+ exclude: /node_modules/
221
+ },
222
+
223
+ {
224
+ test: /\.(ts|tsx)$/,
225
+ loader: 'ts-loader',
226
+ options: {
227
+ configFile: 'tsconfig.build.json'
228
+ },
229
+ exclude: /node_modules/
230
+ },
231
+ // "postcss" loader applies autoprefixer to our CSS.
232
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
233
+ // "style" loader turns CSS into JS modules that inject <style> tags.
234
+ // In production, we use MiniCSSExtractPlugin to extract that CSS
235
+ // to a file, but in development "style" loader enables hot editing
236
+ // of CSS.
237
+ // By default we support CSS Modules with the extension .module.css
238
+ {
239
+ test: cssRegex,
240
+ exclude: cssModuleRegex,
241
+ use: getStyleLoaders({
242
+ importLoaders: 1,
243
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment
244
+ }),
245
+ // Don't consider CSS imports dead code even if the
246
+ // containing package claims to have no side effects.
247
+ // Remove this when webpack adds a warning or an error for this.
248
+ // See https://github.com/webpack/webpack/issues/6571
249
+ sideEffects: true
250
+ },
251
+ // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
252
+ // using the extension .module.css
253
+ {
254
+ test: cssModuleRegex,
255
+ use: getStyleLoaders({
256
+ importLoaders: 1,
257
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
258
+ modules: {
259
+ getLocalIdent: getCSSModuleLocalIdent
260
+ }
261
+ })
262
+ },
263
+ // Opt-in support for SASS (using .scss or .sass extensions).
264
+ // By default we support SASS Modules with the
265
+ // extensions .module.scss or .module.sass
266
+ {
267
+ test: sassRegex,
268
+ exclude: sassModuleRegex,
269
+ use: getStyleLoaders(
270
+ {
271
+ importLoaders: 3,
272
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment
273
+ },
274
+ 'sass-loader'
275
+ ),
276
+ // Don't consider CSS imports dead code even if the
277
+ // containing package claims to have no side effects.
278
+ // Remove this when webpack adds a warning or an error for this.
279
+ // See https://github.com/webpack/webpack/issues/6571
280
+ sideEffects: true
281
+ },
282
+ // Adds support for CSS Modules, but using SASS
283
+ // using the extension .module.scss or .module.sass
284
+ {
285
+ test: sassModuleRegex,
286
+ use: getStyleLoaders(
287
+ {
288
+ importLoaders: 3,
289
+ sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
290
+ modules: {
291
+ getLocalIdent: getCSSModuleLocalIdent
292
+ }
293
+ },
294
+ 'sass-loader'
295
+ )
296
+ },
297
+ // "file" loader makes sure those assets get served by WebpackDevServer.
298
+ // When you `import` an asset, you get its (virtual) filename.
299
+ // In production, they would get copied to the `build` folder.
300
+ // This loader doesn't use a "test" so it will catch all modules
301
+ // that fall through the other loaders.
302
+ {
303
+ loader: require.resolve('file-loader'),
304
+ // Exclude `js` files to keep "css" loader working as it injects
305
+ // its runtime that would otherwise be processed through "file" loader.
306
+ // Also exclude `html` and `json` extensions so they get processed
307
+ // by webpack's internal loaders.
308
+ exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
309
+ options: {
310
+ name: `${componentKey}/media/[name].[hash:8].[ext]`
311
+ }
312
+ }
313
+ // ** STOP ** Are you adding a new loader?
314
+ // Make sure to add the new loader(s) before the "file" loader.
315
+ ]
316
+ }
317
+ ]
318
+ },
319
+ plugins: [
320
+ // This gives some necessary context to module not found errors, such as
321
+ // the requesting resource.
322
+ new ModuleNotFoundPlugin(appPath),
323
+ // Makes some environment variables available to the JS code, for example:
324
+ // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
325
+ // It is absolutely essential that NODE_ENV is set to production
326
+ // during a production build.
327
+ // Otherwise React will be compiled in the very slow development mode.
328
+ isEnvProduction &&
329
+ new webpack.DefinePlugin({
330
+ PRODUCTION: JSON.stringify(true)
331
+ }),
332
+ isEnvProduction &&
333
+ new MiniCssExtractPlugin({
334
+ // Options similar to the same options in webpackOptions.output
335
+ // both options are optional
336
+ filename: `${componentKey}/css/${componentKey}.[contenthash:8].css`,
337
+ chunkFilename: `${componentKey}/css/${componentKey}.[contenthash:8].chunk.css`
338
+ }),
339
+ // Moment.js is an extremely popular library that bundles large locale files
340
+ // by default due to how webpack interprets its code. This is a practical
341
+ // solution that requires the user to opt into importing specific locales.
342
+ // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
343
+ // You can remove this if you don't use Moment.js:
344
+ new webpack.IgnorePlugin({
345
+ resourceRegExp: /^\.\/locale$/,
346
+ contextRegExp: /moment$/
347
+ }),
348
+ /* Ignore cosmos icons */
349
+ new webpack.IgnorePlugin({
350
+ resourceRegExp: /^\.\/icons$/,
351
+ contextRegExp: /@pega\/cosmos-react-core\/lib\/components\/Icon$/
352
+ }),
353
+
354
+ /* Ignore cosmos icons - windows */
355
+ new webpack.IgnorePlugin({
356
+ resourceRegExp: /^\.\/icons$/,
357
+ contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
358
+ }),
359
+
360
+ new webpack.optimize.LimitChunkCountPlugin({
361
+ maxChunks: 1
362
+ }),
363
+ new webpack.optimize.MinChunkSizePlugin({
364
+ minChunkSize: 100000 // Minimum number of characters
365
+ }),
366
+ !devBuild && new CompressionPlugin(compressionBRConfObj)
367
+
368
+ /* Don't generate gzip file */
369
+ /* isEnvProduction && new CompressionPlugin(compressionGZConfObj) */
370
+ ].filter(Boolean),
371
+ performance: {
372
+ hints: 'warning'
373
+ },
374
+ externals
375
+ };
376
+ };
@@ -1,6 +1,5 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import https from 'https';
4
3
 
5
4
  import fetch from 'node-fetch';
6
5
  import AdmZip from 'adm-zip';
@@ -11,20 +10,17 @@ import {
11
10
  getComponentDirectoryPath,
12
11
  getComponents,
13
12
  getPegaServerConfig,
14
- validateRulesetVersion
13
+ validateRulesetVersion,
14
+ getHttpsAgent
15
15
  } from '../../util.js';
16
- import {
17
- PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
18
- LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
19
- TOKEN_PATH
20
- } from '../../constants.js';
16
+ import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
21
17
 
22
18
  export const getPublishComponentQuestions = async () => {
23
19
  const components = await getComponents();
24
20
 
25
- if (components.length == 0) {
26
- console.log(chalk.redBright("No components to publish"));
27
- process.exit(1);
21
+ if (components.length === 0) {
22
+ console.log(chalk.redBright('No components to publish'));
23
+ process.exit();
28
24
  }
29
25
 
30
26
  const defaultPegaConfig = await getPegaServerConfig();
@@ -40,7 +36,7 @@ export const getPublishComponentQuestions = async () => {
40
36
  name: 'rulesetName',
41
37
  message: 'Enter ruleset name',
42
38
  default: defaultPegaConfig.rulesetName,
43
- validate: value => {
39
+ validate: (value) => {
44
40
  if (value.trim()) {
45
41
  return true;
46
42
  }
@@ -54,7 +50,7 @@ export const getPublishComponentQuestions = async () => {
54
50
  name: 'rulesetVersion',
55
51
  message: 'Enter ruleset version',
56
52
  default: defaultPegaConfig.rulesetVersion,
57
- validate: value => {
53
+ validate: (value) => {
58
54
  if (validateRulesetVersion(value)) {
59
55
  return true;
60
56
  }
@@ -80,7 +76,7 @@ export const getPublishComponentQuestions = async () => {
80
76
  ];
81
77
  };
82
78
 
83
- export const zipComponent = async componentKey => {
79
+ export const zipComponent = async (componentKey) => {
84
80
  const srcDirectory = await getComponentDirectoryPath(componentKey);
85
81
  const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
86
82
  const configJson = `${srcDirectory}/config.json`;
@@ -94,7 +90,7 @@ export const zipComponent = async componentKey => {
94
90
 
95
91
  const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
96
92
 
97
- fs.rmdir('dist', { recursive: true }, err => {
93
+ fs.rmdir('dist', { recursive: true }, (err) => {
98
94
  if (err) {
99
95
  throw err;
100
96
  }
@@ -103,16 +99,13 @@ export const zipComponent = async componentKey => {
103
99
  return { zipContent, configContent };
104
100
  };
105
101
 
106
- export const publishComponentToServer = async data => {
102
+ export const publishComponentToServer = async (data, doFetch) => {
107
103
  const { configContent, zipContent, rulesetName, rulesetVersion } = data;
108
104
 
109
105
  const defaultPegaServerConfig = await getPegaServerConfig();
110
106
  const { serverType, isolationId } = defaultPegaServerConfig;
111
107
  const isLaunchpad = serverType === 'launchpad';
112
- const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace(
113
- '{isolationId}',
114
- isolationId
115
- );
108
+ const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace('{isolationId}', isolationId);
116
109
  let apiBody;
117
110
 
118
111
  if (isLaunchpad) {
@@ -136,70 +129,66 @@ export const publishComponentToServer = async data => {
136
129
  }
137
130
 
138
131
  const defaultPegaConfig = await getPegaServerConfig();
139
- const url = constructCompleteUrl(
140
- defaultPegaConfig.server,
141
- isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
142
- );
143
-
144
- try {
145
- const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
146
- if (OauthData) {
147
- const {
148
- access_token: accessToken,
149
- token_type: tokenType
150
- // refresh_token: refreshToken
151
- } = JSON.parse(OauthData);
152
- let status = 500;
153
- const headers = {};
154
-
155
- if (isLaunchpad) {
156
- headers.cookie = `Pega-AAT=${accessToken}`;
157
- headers['Content-Type'] = 'application/json';
158
- } else {
159
- headers.Authorization = `${tokenType} ${accessToken}`;
160
- }
132
+ const url = constructCompleteUrl(defaultPegaConfig.server, isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT);
133
+
134
+ if (doFetch) {
135
+ try {
136
+ const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
137
+ if (OauthData) {
138
+ const {
139
+ access_token: accessToken,
140
+ token_type: tokenType
141
+ // refresh_token: refreshToken
142
+ } = JSON.parse(OauthData);
143
+ let status = 500;
144
+ const headers = {
145
+ Authorization: `${tokenType} ${accessToken}`
146
+ };
147
+
148
+ if (isLaunchpad) {
149
+ headers.cookie = `Pega-AAT=${accessToken}`;
150
+ headers['Content-Type'] = 'application/json';
151
+ }
161
152
 
162
- fetch(url, {
163
- method: 'POST',
164
- agent: new https.Agent({ rejectUnauthorized: false }),
165
- headers,
166
- body: JSON.stringify(apiBody)
167
- })
168
- .then(response => {
169
- status = response.status;
170
- return response.text();
153
+ fetch(url, {
154
+ method: 'POST',
155
+ agent: getHttpsAgent(defaultPegaConfig),
156
+ headers,
157
+ body: JSON.stringify(apiBody)
171
158
  })
172
- .then(resp => {
173
- const respData = isLaunchpad ? resp : JSON.parse(resp);
174
- if (status === 401) {
175
- throw new Error(
176
- 'Error occurred in authentication. Please regenerate using authenticate'
177
- );
178
- // console.log(accessTokenUri, refreshToken);
179
- /* TODO - Handle refresh_token */
180
- } else if (status === 200 || status === 201) {
181
- console.log(chalk.bold.green(`Success : ${isLaunchpad ? respData : respData.message}`));
182
- } else {
183
- throw new Error(`${respData.message}`);
184
- }
185
- })
186
- .catch(e => {
187
- if (e.code === 'ECONNREFUSED') {
188
- // eslint-disable-next-line prefer-promise-reject-errors
189
- Promise.reject(
190
- `${chalk.bold.red(
191
- 'Error occurred in authentication. Please regenerate using authenticate'
192
- )}`
193
- );
194
- } else {
195
- // eslint-disable-next-line prefer-promise-reject-errors
196
- Promise.reject(`${chalk.bold.red(e)}`);
197
- }
198
- });
199
- } else {
159
+ .then((response) => {
160
+ status = response.status;
161
+ return response.text();
162
+ })
163
+ .then((resp) => {
164
+ const respData = isLaunchpad ? resp : JSON.parse(resp);
165
+ if (status === 401) {
166
+ throw new Error('Error occurred in authentication. Please regenerate using authenticate');
167
+ // console.log(accessTokenUri, refreshToken);
168
+ /* TODO - Handle refresh_token */
169
+ } else if (status === 200 || status === 201) {
170
+ console.log(chalk.bold.green(`Success : ${isLaunchpad ? respData : respData.message}`));
171
+ } else {
172
+ throw new Error(`${respData.message}`);
173
+ }
174
+ })
175
+ .catch((e) => {
176
+ if (e.code === 'ECONNREFUSED') {
177
+ // eslint-disable-next-line prefer-promise-reject-errors
178
+ Promise.reject(`${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
179
+ } else if (status === 403) {
180
+ // eslint-disable-next-line prefer-promise-reject-errors
181
+ Promise.reject(`${chalk.bold.red('Error forbidden: User does not have privileges to Publish.')}`);
182
+ } else {
183
+ // eslint-disable-next-line prefer-promise-reject-errors
184
+ Promise.reject(`${chalk.bold.red(e)}`);
185
+ }
186
+ });
187
+ } else {
188
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
189
+ }
190
+ } catch (err) {
200
191
  throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
201
192
  }
202
- } catch (err) {
203
- throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
204
193
  }
205
194
  };
@@ -3,23 +3,40 @@ import Listr from 'listr';
3
3
  import chalk from 'chalk';
4
4
 
5
5
  import validate from '../validator/index.js';
6
-
7
6
  import bundleComponent from '../bundle/index.js';
8
7
  import { lintComponent } from '../linter/index.js';
9
-
10
8
  import { getComponentDirectoryPath, showVersion } from '../../util.js';
9
+
11
10
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
12
11
 
13
- export default async options => {
12
+ export default async (options) => {
14
13
  showVersion();
15
14
 
16
- const questions = await getPublishComponentQuestions();
17
- const answers = await inquirer.prompt(questions);
18
- const { componentKey, sourceMap, devBuild } = answers;
15
+ let componentKey;
16
+ let sourceMap;
17
+ let devBuild;
18
+ let content;
19
+
20
+ let doFetch = true;
21
+
22
+ if (options.params.length >= 8) {
23
+ componentKey = options.params[3];
24
+ const rulesetName = options.params[4];
25
+ const rulesetVersion = options.params[5];
26
+ const dBuild = options.params[6];
27
+ devBuild = dBuild === 'Y' || dBuild === 'y' || dBuild === true || dBuild === 'true';
28
+ doFetch = false;
29
+
30
+ content = { componentKey, rulesetName, rulesetVersion, devBuild };
31
+ } else {
32
+ const questions = await getPublishComponentQuestions();
33
+ const answers = await inquirer.prompt(questions);
34
+ ({ componentKey, sourceMap, devBuild } = answers);
19
35
 
20
- let content = {
21
- ...answers
22
- };
36
+ content = {
37
+ ...answers
38
+ };
39
+ }
23
40
 
24
41
  const sDevBuild = devBuild ? '(dev build)' : '';
25
42
  const tasks = new Listr(
@@ -40,7 +57,7 @@ export default async options => {
40
57
  },
41
58
  {
42
59
  title: `Bundle Component ${sDevBuild}`,
43
- task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
60
+ task: async () => bundleComponent(componentKey, sourceMap, devBuild),
44
61
  skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
45
62
  },
46
63
  {
@@ -53,7 +70,7 @@ export default async options => {
53
70
  {
54
71
  title: 'Publish Component',
55
72
  task: async () => {
56
- await publishComponentToServer(content);
73
+ await publishComponentToServer(content, doFetch);
57
74
  }
58
75
  }
59
76
  ],
@@ -62,7 +79,7 @@ export default async options => {
62
79
  }
63
80
  );
64
81
 
65
- await tasks.run().catch(err => {
82
+ await tasks.run().catch((err) => {
66
83
  console.log(chalk.bold.red(err.toString()));
67
84
  });
68
85
  return true;