@pega/custom-dx-components 2.0.11 → 2.0.13
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.
- package/README.md +73 -57
- package/package.json +10 -2
- package/src/cli.js +18 -0
- package/src/tasks/authenticate/index.js +3 -1
- package/src/tasks/build/helper.js +123 -0
- package/src/tasks/build/index.js +54 -0
- package/src/tasks/{publish/bundle → bundle}/builder/index.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
- package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +0 -2
- package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
- package/src/tasks/create/index.js +6 -3
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +29 -18
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +179 -67
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +39 -16
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +3 -1
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js → date-utils.js.mustache} +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +39 -15
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +2 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +25 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -4
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +8 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +22 -17
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +42 -14
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +44 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +21 -16
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +20 -16
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.js → StatusWork.jsx} +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +46 -3
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +21 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +44 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +46 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +19 -17
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +174 -3
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +24 -16
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +110 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +179 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +3 -77
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +118 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +14 -29
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +215 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +3 -74
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +89 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +6 -10
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +92 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +10 -8
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +125 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.js.mustache → GetNextWork.jsx.mustache} +6 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +9 -7
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +4 -1
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +389 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.js.mustache → Avatar.jsx.mustache} +2 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.js.mustache → Operator.jsx.mustache} +2 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
- package/src/tasks/delete/helper.js +4 -0
- package/src/tasks/delete/index.js +4 -0
- package/src/tasks/delete-all/helper.js +175 -0
- package/src/tasks/delete-all/index.js +49 -0
- package/src/tasks/index.js +3 -0
- package/src/tasks/init/index.js +1 -1
- package/src/tasks/init/template/.eslintignore +8 -0
- package/src/tasks/init/template/.eslintrc.json +186 -5
- package/src/tasks/init/template/package.json.mustache +19 -4
- package/src/tasks/linter/index.js +46 -0
- package/src/tasks/list/index.js +4 -0
- package/src/tasks/publish/index.js +14 -1
- package/src/tasks/publish-all/helper.js +139 -0
- package/src/tasks/publish-all/index.js +84 -0
- package/src/util.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +0 -43
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.js.mustache +0 -172
package/README.md
CHANGED
|
@@ -22,12 +22,12 @@ Initialize the project by performing the following procedure in a terminal:
|
|
|
22
22
|
|
|
23
23
|
1. Enter the following command to initialize the project.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Pega 8.7 - `npx @pega/custom-dx-components@1 init`
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Pega 8.8 - `npx @pega/custom-dx-components@2 init`
|
|
28
28
|
|
|
29
29
|
2. If prompted, enter `y` to install the Custom UI Components package.
|
|
30
|
-
You will then be asked to set up the project by entering the required details.
|
|
30
|
+
You will then be asked to set up the project by entering the required details.
|
|
31
31
|
|
|
32
32
|
3. Enter the following details:
|
|
33
33
|
- Name of the project (required)
|
|
@@ -41,7 +41,7 @@ Example - `This project is intended to create and publish a custom component.`
|
|
|
41
41
|
- Git repository URL (optional)
|
|
42
42
|
Example - `https://git.custom-components.io/custom-cc.git`
|
|
43
43
|
- Author (optional)
|
|
44
|
-
Example - `Michelle`
|
|
44
|
+
Example - `Michelle`
|
|
45
45
|
|
|
46
46
|
The workspace is now set up to create custom components and publish them to the server.
|
|
47
47
|
|
|
@@ -50,7 +50,7 @@ The workspace is now set up to create custom components and publish them to the
|
|
|
50
50
|
Create custom components using the following procedure:
|
|
51
51
|
|
|
52
52
|
1. Enter the following command to create a component:
|
|
53
|
-
`npm run create`
|
|
53
|
+
`npm run create`
|
|
54
54
|
You will then be asked to enter or review the following details of the component:
|
|
55
55
|
- Name of the component (required)
|
|
56
56
|
Example - `customcomp0`
|
|
@@ -65,21 +65,22 @@ Example - `Field`
|
|
|
65
65
|
- Sub-type of component (required)
|
|
66
66
|
Example - `Text`
|
|
67
67
|
- Description of the component (optional)
|
|
68
|
-
Example - `This is a customized searchbox that filters data.`
|
|
68
|
+
Example - `This is a customized searchbox that filters data.`
|
|
69
69
|
The component is created in the following path: _/Users/your_user_name/project_name/src/components/component_name_
|
|
70
|
-
You can also pre-configure the values for the above options in a tasks.config.json file as shown below.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
You can also pre-configure the values for the above options in a tasks.config.json file as shown below.
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"component": {
|
|
75
|
+
"library": "basic",
|
|
76
|
+
"version": "0.0.1",
|
|
77
|
+
"type": "field",
|
|
78
|
+
"subtype": "text",
|
|
79
|
+
"description": "basic field for capturing textual data",
|
|
80
|
+
"icon": "basic-field-text.svg"
|
|
81
|
+
}
|
|
80
82
|
}
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
+
```
|
|
83
84
|
>**Note**:
|
|
84
85
|
Alternatively, you can enter the following command to skip entering the details of the component now and can manually enter the details in the config.json file after the component is created:
|
|
85
86
|
`npm run create <enter_component_name>`
|
|
@@ -102,13 +103,19 @@ The *config.json* file contains the mapping of properties for configuring the au
|
|
|
102
103
|
|
|
103
104
|
|
|
104
105
|
2. Enter the following command to start the storybook to view the demo.
|
|
105
|
-
`npm start`
|
|
106
|
+
`npm start`
|
|
106
107
|
|
|
107
108
|
3. Modify the source files to build your own component. You can also install and import third-party libraries if required for your component.
|
|
108
109
|
|
|
109
110
|
The custom component is now created. We use the information provided to create uniquely namespaced components in this convention - `<organization>_<library>_<component name>`.
|
|
110
111
|
|
|
112
|
+
4. local build, you can build the component locally to check for config validation and component validation. Enter
|
|
113
|
+
`npm buildComponent`
|
|
114
|
+
|
|
115
|
+
buildComponent will do the same first 2 steps as publish, but will not publish to the server. This allows you to compile your component locally and fix errors before publish.
|
|
116
|
+
|
|
111
117
|
## Authenticate the user
|
|
118
|
+
|
|
112
119
|
Before we publish the custom component to the Pega Infinity Server, authenticate the user to access the resources in the Pega Infinity Server.
|
|
113
120
|
|
|
114
121
|
>**Note**:
|
|
@@ -116,53 +123,57 @@ It is required that you configure a value for clientId, clientSecret, and access
|
|
|
116
123
|
1. Login to Pega Infinity Server, navigate to Records / Security / OAuth 2.0 Client Registration landing page and open the *DX-CustomComponents* record.
|
|
117
124
|
2. Click **Regenerate Client Secret**, download the Client Credentials (as the Client ID, Client Secret, and Access token endpoint will be needed), and save the record.
|
|
118
125
|
3. Update the the task.config.json file with these downloaded values:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
```json
|
|
127
|
+
"server-config": {
|
|
128
|
+
"server": "https://127.0.0.1:8080/prweb",
|
|
129
|
+
"user": "customcomponentoperator",
|
|
130
|
+
"password": "pwd",
|
|
131
|
+
"clientId": "<mention client ID here>",
|
|
132
|
+
"clientSecret": "<mention client secret here>",
|
|
133
|
+
"accessTokenUri": "https://127.0.0.1:8080/prweb/PRRestService/oauth2/v1/token"
|
|
134
|
+
},
|
|
135
|
+
```
|
|
129
136
|
4. Enter the following command to initiate authentication.
|
|
130
|
-
`npm run authenticate`
|
|
137
|
+
`npm run authenticate`
|
|
131
138
|
|
|
132
139
|
The user is now authenticated and can proceed to either publish or list the components.
|
|
133
140
|
|
|
134
141
|
## Publish custom components
|
|
135
142
|
Enter the following command to publish custom components to Pega Infinity Server:
|
|
136
143
|
`npm run publish`
|
|
144
|
+
`npm run publishAll`
|
|
137
145
|
Publish the finalized custom components changes to Pega Infinity Server so that it can be discoverable in authoring (design palette).
|
|
138
146
|
You will then be asked to enter the following details:
|
|
139
147
|
|
|
140
148
|
- The component to be published to Pega Infinity Server. It will be updated if the component exists.
|
|
149
|
+
- If publishAll, then you won't get a list
|
|
141
150
|
- The name of the ruleset where the component must be published.
|
|
142
151
|
- The version of the ruleset where the component must be published.
|
|
143
152
|
- Specify if the development build should be generated for debugging.
|
|
144
|
-
You can also pre-configure the values for the above options in a tasks.config.json file as shown below. The server, user name, and password must be pre-configured.
|
|
145
|
-
|
|
146
|
-
```json
|
|
147
|
-
{
|
|
148
|
-
"components-server-config": {
|
|
149
|
-
"server": "http://127.0.0.1:8080/prweb",
|
|
150
|
-
"user": "customcomponentoperator",
|
|
151
|
-
"password": "pwd"
|
|
152
|
-
"rulesetName": "TestPega-C11nGall",
|
|
153
|
-
"rulesetVersion": "01-01-03",
|
|
154
|
-
"sourceOfComponents": "Server",
|
|
155
|
-
"devBuild": false,
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
```
|
|
159
|
-
When the component is successfully published, you can use the newly published component in App Studio's view authoring.
|
|
160
153
|
|
|
154
|
+
- If publishAll, will sequentiall go through the list of local components and publish them
|
|
155
|
+
You can also pre-configure the values for the above options in a tasks.config.json file as shown below. The server, user name, and password must be pre-configured.
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"components-server-config": {
|
|
160
|
+
"server": "http://127.0.0.1:8080/prweb",
|
|
161
|
+
"user": "customcomponentoperator",
|
|
162
|
+
"password": "pwd"
|
|
163
|
+
"rulesetName": "TestPega-C11nGall",
|
|
164
|
+
"rulesetVersion": "01-01-03",
|
|
165
|
+
"sourceOfComponents": "Server",
|
|
166
|
+
"devBuild": false,
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
When the component is successfully published, you can use the newly published component in App Studio's view authoring.
|
|
161
171
|
|
|
162
|
-
|
|
163
|
-
The Rule-UI-Component instance (with component name) is created on the Pega Infinity Server after publishing the component.
|
|
172
|
+
> **Note**:
|
|
173
|
+
> The Rule-UI-Component instance (with component name) is created on the Pega Infinity Server after publishing the component.
|
|
164
174
|
|
|
165
175
|
## List custom components
|
|
176
|
+
|
|
166
177
|
View the available components in the local machine or the server.
|
|
167
178
|
|
|
168
179
|
Enter the following command to list custom components:
|
|
@@ -171,37 +182,42 @@ Enter the following command to list custom components:
|
|
|
171
182
|
You will then be asked to enter the following details:
|
|
172
183
|
|
|
173
184
|
- List components from Server or Local?
|
|
174
|
-
Example - `Server`
|
|
185
|
+
Example - `Server`
|
|
175
186
|
|
|
176
187
|
The custom components will now be listed in the terminal.
|
|
177
188
|
|
|
178
189
|
## Delete custom components
|
|
190
|
+
|
|
179
191
|
Delete the available or published components in the local machine or the server.
|
|
180
192
|
|
|
181
193
|
Enter the following command to delete custom components:
|
|
182
194
|
`npm run delete`
|
|
195
|
+
`npm run deleteAll`
|
|
183
196
|
|
|
184
197
|
You will then be asked to enter the following details:
|
|
185
198
|
|
|
186
199
|
- Delete components from Server or Local?
|
|
187
|
-
Example - `Local`
|
|
200
|
+
Example - `Local`
|
|
188
201
|
|
|
189
202
|
- Select component to delete
|
|
190
|
-
The list of available components in the following path will be displayed:
|
|
191
|
-
Select the component to be deleted from this list.
|
|
203
|
+
The list of available components in the following path will be displayed: \_/Users/your_user_name/project_name/src/components
|
|
204
|
+
Select the component to be deleted from this list.
|
|
205
|
+
- For deleteAll you will see the full list and asked if you want to delete them all.
|
|
192
206
|
|
|
193
207
|
- Are you sure?
|
|
194
|
-
Example - `yes`
|
|
208
|
+
Example - `yes`
|
|
195
209
|
|
|
196
|
-
|
|
197
|
-
If you choose to delete components from the server, the successfully published components along with their ruleset name and ruleset version from the Pega Infinity Server will be displayed. Select the component to be deleted from this list.
|
|
210
|
+
> **Note**:
|
|
211
|
+
> If you choose to delete components from the server, the successfully published components along with their ruleset name and ruleset version from the Pega Infinity Server will be displayed. Select the component to be deleted from this list.
|
|
198
212
|
|
|
199
213
|
## View existing custom components in storybook
|
|
214
|
+
|
|
200
215
|
View custom components in a storybook by performing the following procedure:
|
|
216
|
+
|
|
201
217
|
1. Enter the following command to open the project.
|
|
202
|
-
`cd <enter your project's name>`
|
|
218
|
+
`cd <enter your project's name>`
|
|
203
219
|
|
|
204
220
|
2. Enter the following command to start the storybook in development mode.
|
|
205
|
-
`npm start`
|
|
221
|
+
`npm start`
|
|
206
222
|
|
|
207
223
|
The storybook is launched in a browser where you can view the components working in isolation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/custom-dx-components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"description": "Utility for building custom UI components",
|
|
5
5
|
"bin": "./bin/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,7 +61,15 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@pega/configs": "^0.3.3",
|
|
63
63
|
"cspell": "^6.9.0",
|
|
64
|
-
"eslint": "^8.
|
|
64
|
+
"eslint": "^8.4.1",
|
|
65
|
+
"eslint-plugin-import": "^2.25.3",
|
|
66
|
+
"eslint-plugin-jest": "^25.3.0",
|
|
67
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
68
|
+
"eslint-plugin-mdx": "^2.0.5",
|
|
69
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
70
|
+
"eslint-plugin-react": "^7.27.1",
|
|
71
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
72
|
+
"eslint-plugin-sonarjs": "^0.11.0",
|
|
65
73
|
"prettier": "2.7.1"
|
|
66
74
|
}
|
|
67
75
|
}
|
package/src/cli.js
CHANGED
|
@@ -3,11 +3,14 @@ import chalk from 'chalk';
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
authenticate,
|
|
6
|
+
buildComponent,
|
|
6
7
|
createComponent,
|
|
7
8
|
deleteComponent,
|
|
9
|
+
deleteAllComponents,
|
|
8
10
|
initProject,
|
|
9
11
|
listComponents,
|
|
10
12
|
publishComponent,
|
|
13
|
+
publishAllComponents,
|
|
11
14
|
updateComponent,
|
|
12
15
|
validate,
|
|
13
16
|
upgrade
|
|
@@ -16,11 +19,14 @@ import {
|
|
|
16
19
|
const TASKS = {
|
|
17
20
|
INIT: 'init',
|
|
18
21
|
CREATE: 'create',
|
|
22
|
+
BUILD: 'buildComponent',
|
|
19
23
|
PUBLISH: 'publish',
|
|
24
|
+
PUBLISH_All: 'publishAll',
|
|
20
25
|
LIST: 'list',
|
|
21
26
|
VALIDATE_SCHEMA: 'validateSchema',
|
|
22
27
|
UPDATE: 'update',
|
|
23
28
|
DELETE: 'delete',
|
|
29
|
+
DELETE_ALL: "deleteAll",
|
|
24
30
|
AUTHENTICATE: 'authenticate',
|
|
25
31
|
UPGRADE: 'upgrade'
|
|
26
32
|
};
|
|
@@ -60,6 +66,14 @@ export default async (args = []) => {
|
|
|
60
66
|
publishComponent(options);
|
|
61
67
|
break;
|
|
62
68
|
}
|
|
69
|
+
case TASKS.PUBLISH_All: {
|
|
70
|
+
publishAllComponents(options);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case TASKS.BUILD: {
|
|
74
|
+
buildComponent(options);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
63
77
|
case TASKS.LIST: {
|
|
64
78
|
listComponents(options);
|
|
65
79
|
break;
|
|
@@ -76,6 +90,10 @@ export default async (args = []) => {
|
|
|
76
90
|
deleteComponent(options);
|
|
77
91
|
break;
|
|
78
92
|
}
|
|
93
|
+
case TASKS.DELETE_ALL: {
|
|
94
|
+
deleteAllComponents(options);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
79
97
|
case TASKS.AUTHENTICATE: {
|
|
80
98
|
authenticate(options);
|
|
81
99
|
break;
|
|
@@ -6,7 +6,7 @@ import chalk from 'chalk';
|
|
|
6
6
|
import inquirer from 'inquirer';
|
|
7
7
|
import fetch from 'node-fetch';
|
|
8
8
|
|
|
9
|
-
import { checkPathAccess, getTokenUrl } from '../../util.js';
|
|
9
|
+
import { checkPathAccess, getTokenUrl, showVersion } from '../../util.js';
|
|
10
10
|
import { TOKEN_PATH } from '../../constants.js';
|
|
11
11
|
|
|
12
12
|
import { getAuthQuestions } from './helper.js';
|
|
@@ -57,6 +57,8 @@ const generateAccessToken = async config => {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
export default async options => {
|
|
60
|
+
showVersion();
|
|
61
|
+
|
|
60
62
|
await checkPathAccess(pegaConfigJsonPath);
|
|
61
63
|
|
|
62
64
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
validateRulesetVersion
|
|
15
|
+
} from '../../util.js';
|
|
16
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
17
|
+
|
|
18
|
+
export const getPublishComponentQuestions = async () => {
|
|
19
|
+
const components = await getComponents();
|
|
20
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: 'componentKey',
|
|
25
|
+
type: 'rawlist',
|
|
26
|
+
message: 'Select component to build',
|
|
27
|
+
choices: components
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'sourceMap',
|
|
31
|
+
message: 'Generate source map ?',
|
|
32
|
+
default: defaultPegaConfig.sourceMap,
|
|
33
|
+
when: () => false && !process.env.SOURCE_MAP
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'devBuild',
|
|
37
|
+
message: 'Generate development build ?',
|
|
38
|
+
default: defaultPegaConfig.devBuild
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const zipComponent = async componentKey => {
|
|
44
|
+
const srcDirectory = await getComponentDirectoryPath(componentKey);
|
|
45
|
+
const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
|
|
46
|
+
const configJson = `${srcDirectory}/config.json`;
|
|
47
|
+
|
|
48
|
+
const zip = new AdmZip();
|
|
49
|
+
|
|
50
|
+
zip.addLocalFolder(srcDirectory, 'src/');
|
|
51
|
+
zip.addLocalFile(configJson);
|
|
52
|
+
zip.addLocalFolder(buildDirectory);
|
|
53
|
+
const zipContent = zip.toBuffer().toString('base64');
|
|
54
|
+
|
|
55
|
+
const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
|
|
56
|
+
fs.rmdir('dist', { recursive: true }, err => {
|
|
57
|
+
if (err) {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return { zipContent, configContent };
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const publishComponentToServer = async data => {
|
|
65
|
+
const { configContent, zipContent, componentKey, rulesetName, rulesetVersion } = data;
|
|
66
|
+
|
|
67
|
+
const apiBody = {
|
|
68
|
+
configContent,
|
|
69
|
+
zipContent,
|
|
70
|
+
componentKey: JSON.parse(configContent).componentKey,
|
|
71
|
+
publishFor: 'constellation',
|
|
72
|
+
rulesetName,
|
|
73
|
+
rulesetVersion,
|
|
74
|
+
category: ''
|
|
75
|
+
};
|
|
76
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
77
|
+
const url = constructCompleteUrl(
|
|
78
|
+
defaultPegaConfig.server,
|
|
79
|
+
PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
|
|
80
|
+
);
|
|
81
|
+
try {
|
|
82
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
83
|
+
if (OauthData) {
|
|
84
|
+
const {
|
|
85
|
+
access_token: accessToken,
|
|
86
|
+
token_type: tokenType,
|
|
87
|
+
refresh_token: refreshToken
|
|
88
|
+
} = JSON.parse(OauthData);
|
|
89
|
+
let status = 500;
|
|
90
|
+
fetch(url, {
|
|
91
|
+
method: 'POST',
|
|
92
|
+
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
93
|
+
headers: {
|
|
94
|
+
Authorization: `${tokenType} ${accessToken}`
|
|
95
|
+
},
|
|
96
|
+
body: JSON.stringify(apiBody)
|
|
97
|
+
})
|
|
98
|
+
.then(response => {
|
|
99
|
+
status = response.status;
|
|
100
|
+
return response.text();
|
|
101
|
+
})
|
|
102
|
+
.then(resp => {
|
|
103
|
+
const respData = JSON.parse(resp);
|
|
104
|
+
if (status === 401) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
'Error occured in authentication. Please regenerate using authenticate'
|
|
107
|
+
);
|
|
108
|
+
// console.log(accessTokenUri, refreshToken);
|
|
109
|
+
/* TODO - Handle refresh_token */
|
|
110
|
+
} else if (status == 200) {
|
|
111
|
+
console.log(chalk.bold.green(`Success : ${respData.message}`));
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error(`${respData.message}`);
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
.catch(e => Promise.reject(`${chalk.bold.red(e)}`));
|
|
117
|
+
} else {
|
|
118
|
+
throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
@@ -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, publishComponentToServer, zipComponent } 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
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -306,14 +306,12 @@ export default (
|
|
|
306
306
|
contextRegExp: /moment$/
|
|
307
307
|
}),
|
|
308
308
|
/* Ignore cosmos icons */
|
|
309
|
-
|
|
310
309
|
new webpack.IgnorePlugin({
|
|
311
310
|
resourceRegExp: /^\.\/icons$/,
|
|
312
311
|
contextRegExp: /@pega\/cosmos-react-core\/lib\/components\/Icon$/
|
|
313
312
|
}),
|
|
314
313
|
|
|
315
314
|
/* Ignore cosmos icons - windows */
|
|
316
|
-
|
|
317
315
|
new webpack.IgnorePlugin({
|
|
318
316
|
resourceRegExp: /^\.\/icons$/,
|
|
319
317
|
contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
|
|
@@ -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 '
|
|
6
|
-
import { getComponentDirectoryPath } from '
|
|
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
|
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
getComponents,
|
|
15
15
|
getComponentDefaults,
|
|
16
16
|
sanitize,
|
|
17
|
-
validateSemver
|
|
17
|
+
validateSemver,
|
|
18
|
+
showVersion
|
|
18
19
|
} from '../../util.js';
|
|
19
20
|
import { COMPONENT_SCHEMA } from '../../constants.js';
|
|
20
21
|
|
|
@@ -87,7 +88,7 @@ const compileMustacheTemplates = async (
|
|
|
87
88
|
ALLOWEDAPPS: JSON.stringify(allowedApplications),
|
|
88
89
|
TYPE: type,
|
|
89
90
|
SUB_TYPE: JSON.stringify(mustacheSubType),
|
|
90
|
-
DESCRIPTION: description,
|
|
91
|
+
DESCRIPTION: description || componentLabel,
|
|
91
92
|
IS_TEMPLATE: isTemplate,
|
|
92
93
|
IS_PICKLIST: isPicklist,
|
|
93
94
|
IS_BOOLEAN: isBool,
|
|
@@ -172,6 +173,8 @@ const validateCompile = async (
|
|
|
172
173
|
};
|
|
173
174
|
|
|
174
175
|
export default async options => {
|
|
176
|
+
showVersion();
|
|
177
|
+
|
|
175
178
|
if (options.params[10]) {
|
|
176
179
|
const componentName = options.params[3];
|
|
177
180
|
const componentLabel = options.params[4];
|
|
@@ -226,6 +229,7 @@ export default async options => {
|
|
|
226
229
|
{
|
|
227
230
|
name: 'version',
|
|
228
231
|
message: 'Enter component version',
|
|
232
|
+
default: componentDefaults.version,
|
|
229
233
|
validate: value => {
|
|
230
234
|
if (validateSemver(value)) {
|
|
231
235
|
return true;
|
|
@@ -312,7 +316,6 @@ export default async options => {
|
|
|
312
316
|
}
|
|
313
317
|
];
|
|
314
318
|
|
|
315
|
-
console.log(chalk.green("DX Component Builder v2.0.11"));
|
|
316
319
|
await inquirer.prompt(questions).then(async answers => {
|
|
317
320
|
const {
|
|
318
321
|
componentName,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withKnobs, text, boolean } from '@storybook/addon-knobs';
|
|
1
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { configProps, stateProps } from './mock.stories';
|
|
4
|
+
|
|
5
|
+
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,30 +11,40 @@ export default {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState('test value');
|
|
14
|
-
|
|
15
14
|
const props = {
|
|
15
|
+
value: configProps.value,
|
|
16
|
+
label: configProps.label,
|
|
17
|
+
helperText: configProps.helperText,
|
|
18
|
+
caption: configProps.caption,
|
|
19
|
+
validatemessage: configProps.validatemessage,
|
|
20
|
+
hideLabel: configProps.hideLabel,
|
|
21
|
+
testId: configProps.testId,
|
|
22
|
+
additionalProps: configProps.additionalProps,
|
|
23
|
+
displayMode: configProps.displayMode,
|
|
24
|
+
variant: configProps.variant,
|
|
25
|
+
trueLabel: configProps.trueLabel,
|
|
26
|
+
falseLabel: configProps.falseLabel,
|
|
27
|
+
disabled: configProps.disabled,
|
|
28
|
+
readOnly: configProps.readOnly,
|
|
29
|
+
required: configProps.required,
|
|
16
30
|
getPConnect: () => {
|
|
17
31
|
return {
|
|
32
|
+
getStateProps: () => {
|
|
33
|
+
return stateProps;
|
|
34
|
+
},
|
|
18
35
|
getActionsApi: () => {
|
|
19
36
|
return {
|
|
20
|
-
updateFieldValue: (
|
|
21
|
-
|
|
22
|
-
}
|
|
37
|
+
updateFieldValue: () => { /* nothing */},
|
|
38
|
+
triggerFieldChange: () => { /* nothing */}
|
|
23
39
|
};
|
|
24
40
|
},
|
|
25
|
-
|
|
26
|
-
return {
|
|
41
|
+
getValidationApi: () => {
|
|
42
|
+
return {
|
|
43
|
+
validate: () => { /* nothing */}
|
|
44
|
+
};
|
|
27
45
|
}
|
|
28
46
|
};
|
|
29
|
-
}
|
|
30
|
-
value,
|
|
31
|
-
placeholder: text('Placeholder', 'Test placeholder'),
|
|
32
|
-
disabled: boolean('Disabled', false),
|
|
33
|
-
readOnly: boolean('Disabled', false),
|
|
34
|
-
required: boolean('Disabled', false),
|
|
35
|
-
label: text('Label', 'Sample Label'),
|
|
36
|
-
testId: text('Test id', 'text-12344566')
|
|
47
|
+
}
|
|
37
48
|
};
|
|
38
49
|
|
|
39
50
|
return (
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
import PropTypes from "prop-types";
|
|
8
8
|
|
|
9
9
|
// includes in bundle
|
|
10
|
-
import { format } from "./boolean-format";
|
|
11
10
|
import handleEvent from "./event-utils";
|
|
12
11
|
|
|
13
12
|
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
@@ -70,7 +69,7 @@ const {{COMPONENT_CLASS_NAME}} = props => {
|
|
|
70
69
|
|
|
71
70
|
let displayComponent;
|
|
72
71
|
if (displayMode) {
|
|
73
|
-
displayComponent = <
|
|
72
|
+
displayComponent = <{{COMPONENT_CLASS_NAME}} value={value} trueLabel={trueLabel} falseLabel={falseLabel} />;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
if (displayMode === 'DISPLAY_ONLY') {
|