pegasystems / constellation-ui-gallery

This open-source repository provides a collection of ready-to-use and customizable Constellation DX components. Use this resource to gain inspiration, best practices, and a solid foundation for implementing custom components.
https://pegasystems.github.io/constellation-ui-gallery/
Apache License 2.0
30 stars 22 forks source link

Issues faced with @pega/custom-dx-components #39

Closed ke-vbe closed 5 months ago

ke-vbe commented 5 months ago

Hello,

I'm currently facing a few issues with the package https://www.npmjs.com/package/@pega/custom-dx-components which is used in this repository constellation-ui-gallery.

  1. When executing the command npm run promoteWebPack, it uncomments a line in node_modules/@pega/custom-dx-components/src/tasks/bundle/builder/index.js to point to the new webpack.config.js file placed in the project's root path. However, when installing or updating an npm package, the whole node_modules directory is refreshed and the changes made by promoteWebPack are lost image

  2. I tried to pass rulesetName, rulesetVersion and dBuild as arguments to npm run publishAll but it didn't work. When having a look at the source code of custom-dx-components, I found the condition causing this issue. In node_modules/@pega/custom-dx-components/src/tasks/publish-all/index.js, at line 79, there is a condition checking if options.params.length >= 7 but there is only a total of 6 params including the 3 I'm manually passing. BTW, there is no reference to options.params[6] in this file, which means checking for a length of 7 is not even accurate. image I then tried to pass a 4th argument (counting as the 7th) but I encountered another issue. The whole process started without asking any question but nothing was sent to Pega. FYI, when running npm run publishAll and answering questions, the components are sent to Pega and the message "Success : Component successfully created in ruleset Demo:01-01-01" is displayed. Again, I started searching in the source code and found this in node_modules/@pega/custom-dx-components/src/tasks/publish-all/index.js image The boolean variable doFetch is then passed as an argument to the function publishComponentToServer which is then calling Pega only if doFetch is true image So, if I pass only 3 arguments like npm run publishAll Demo 01-01-01 N, then I still have to answer the questions if it's a dev build and what is the ruleset name and version. And if I pass 4 arguments like npm run publishAll Demo 01-01-01 N dummyText, then I don't have to answer the previous questions but during the task "Publish Component", nothing is sent to Pega.

paulgagnon-pega commented 5 months ago

Passing all arguments via the command line is for testing and passing arguments is NOT published in our documentation. Due to the fact that is very finicky and if not done correctly, will cause problems.

If you want to use them (but we are not supporting issues), the last argument is true (without quotes) as that will allow the fetch to happen.

npm run publishAll Demo 01-01-01 N true

ke-vbe commented 5 months ago

Hello @paulgagnon-pega, thank you for your answer. Would it be possible to support passing arguments ? It would allow running commands during automated tasks like CI/CD pipelines... Regarding the following npm run publishAll Demo 01-01-01 N true, it doesn't work as the last argument true is not affecting the variable doFetch which is preventing Pega API call. FYI, I'm using the latest version 23.1.11.

paulgagnon-pega commented 5 months ago

HI, I will fix in next release as commands/arguments are only used with testing and we don't want a fetch during then, so they work fine for testing. Though commands/arguments will be there, support are not going to be official, there are too many ways it can fail in that scenario. There is no error checking, etc, because the questions restrict and provide the correct input, and command line bypasses that.

paulgagnon-pega commented 5 months ago

Hello @paulgagnon-pega, thank you for your answer. Would it be possible to support passing arguments ? It would allow running commands during automated tasks like CI/CD pipelines... Regarding the following npm run publishAll Demo 01-01-01 N true, it doesn't work as the last argument true is not affecting the variable doFetch which is preventing Pega API call. FYI, I'm using the latest version 23.1.11.

For now, you can go into publish-all/index.js on line 20, you can set "doFetch" to true and that should allow you to move forward.

ricmars commented 5 months ago

closing the issue - next time, please post issue in Pega community - this question is unrelated to this project - it is not recommended to run promoteWebPack - You can also suggest edit to the documentation https://docs.pega.com/bundle/constellation-dx-components/page/constellation-dx-components/custom-components/advanced-webpack-configuration.html

ke-vbe commented 5 months ago

@ricmars I've posted here as there is no github repo for @pega/custom-dx-components. BTW, on npmjs.com, what are the differences between these 2 packages

ricmars commented 5 months ago

https://www.npmjs.com/package/@pega/constellation-dx-components-build-utils is a work in progress and should not be used right now - it is not supported by the platform.

ke-vbe commented 5 months ago

it is not recommended to run promoteWebPack

@ricmars I'd like to discuss this point please. Why is it not recommended ?

Is it because of the following note on the documentation page you linked ?

Note: If you modify the internal webpack.config.js file, you are responsible for troubleshooting any build issues and integrating your changes into new versions of Constellation DX Component Builder

If so, I know I have to troubleshoot issues I might have created by playing with the webpack config. What I mentioned in my first message is that promoteWebPack command is commenting/uncommenting lines of the file node_modules/@pega/custom-dx-components/src/tasks/bundle/builder/index.js which is in the folder node_modules and this folder is refreshed each time npm update or npm install is ran, reverting changes made by promoteWebPack inside node_modules/@pega/custom-dx-components/src/tasks/bundle/builder/index.js.

ricmars commented 5 months ago

yes this is a known issue - in future release, we will change the way promoteWebPack so that the index.js in the node_modules is not updated.