@pega/custom-dx-components 8.8.6 → 8.8.8
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 +2 -204
- package/package.json +3 -2
- package/src/tasks/init/index.js +7 -1
- package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
- package/src/tasks/init/template/package.json.mustache +1 -2
- package/src/tasks/init/template/tasks.config.json +2 -1
- package/src/tasks/init/template/templateNPMRC.txt +8 -0
- package/src/tasks/publish/helper.js +8 -1
- package/src/util.js +11 -0
package/README.md
CHANGED
|
@@ -16,208 +16,6 @@ Ensure you have access to the following in your system:
|
|
|
16
16
|
|
|
17
17
|
- System npm version 8
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Latest Documentation
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
1. Enter the following command to initialize the project.
|
|
24
|
-
|
|
25
|
-
Pega 8.7 - `npx @pega/custom-dx-components@1 init`
|
|
26
|
-
|
|
27
|
-
Pega 8.8 - `npx @pega/custom-dx-components@2 init`
|
|
28
|
-
|
|
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.
|
|
31
|
-
|
|
32
|
-
3. Enter the following details:
|
|
33
|
-
- Name of the project (required)
|
|
34
|
-
Example - `mycustomcomponents`
|
|
35
|
-
- Name of the organization (required)
|
|
36
|
-
Example - `customorg`
|
|
37
|
-
- Version (required)
|
|
38
|
-
Example - `1.0.0`
|
|
39
|
-
- Description of the project (optional)
|
|
40
|
-
Example - `This project is intended to create and publish a custom component.`
|
|
41
|
-
- Git repository URL (optional)
|
|
42
|
-
Example - `https://git.custom-components.io/custom-cc.git`
|
|
43
|
-
- Author (optional)
|
|
44
|
-
Example - `Michelle`
|
|
45
|
-
|
|
46
|
-
The workspace is now set up to create custom components and publish them to the server.
|
|
47
|
-
|
|
48
|
-
## Create custom components
|
|
49
|
-
|
|
50
|
-
Create custom components using the following procedure:
|
|
51
|
-
|
|
52
|
-
1. Enter the following command to create a component:
|
|
53
|
-
`npm run create`
|
|
54
|
-
You will then be asked to enter or review the following details of the component:
|
|
55
|
-
- Name of the component (required)
|
|
56
|
-
Example - `customcomp0`
|
|
57
|
-
- Name of component label (required)
|
|
58
|
-
Example - `custom component`
|
|
59
|
-
- Name of the library (required)
|
|
60
|
-
Example - `basic`
|
|
61
|
-
- Component version (required)
|
|
62
|
-
Example - `0.0.1`
|
|
63
|
-
- Type of component (required)
|
|
64
|
-
Example - `Field`
|
|
65
|
-
- Sub-type of component (required)
|
|
66
|
-
Example - `Text`
|
|
67
|
-
- Description of the component (optional)
|
|
68
|
-
Example - `This is a customized searchbox that filters data.`
|
|
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
|
-
```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
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
>**Note**:
|
|
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:
|
|
86
|
-
`npm run create <enter_component_name>`
|
|
87
|
-
|
|
88
|
-
A _src/components_ folder is created and the necessary files required to build the component are initialized as seen below.
|
|
89
|
-
|
|
90
|
-
```sh
|
|
91
|
-
├── src
|
|
92
|
-
├── components
|
|
93
|
-
├── <component_name>
|
|
94
|
-
├── index.js
|
|
95
|
-
├── demo.stories.js
|
|
96
|
-
├── config.json
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
The *index.js* file contains the actual component rendering logic.
|
|
101
|
-
The *demo.stories.js* file contains the demo that can be viewed in the storybook.
|
|
102
|
-
The *config.json* file contains the mapping of properties for configuring the auto generated property panel. This property panel appears in AppStudio when an application is being authored to use the custom component.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
2. Enter the following command to start the storybook to view the demo.
|
|
106
|
-
`npm start`
|
|
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.
|
|
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>`.
|
|
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
|
-
|
|
117
|
-
## Authenticate the user
|
|
118
|
-
|
|
119
|
-
Before we publish the custom component to the Pega Infinity Server, authenticate the user to access the resources in the Pega Infinity Server.
|
|
120
|
-
|
|
121
|
-
>**Note**:
|
|
122
|
-
It is required that you configure a value for clientId, clientSecret, and accessTokenUri.
|
|
123
|
-
1. Login to Pega Infinity Server, navigate to Records / Security / OAuth 2.0 Client Registration landing page and open the *DX-CustomComponents* record.
|
|
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.
|
|
125
|
-
3. Update the the task.config.json file with these downloaded values:
|
|
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
|
-
```
|
|
136
|
-
4. Enter the following command to initiate authentication.
|
|
137
|
-
`npm run authenticate`
|
|
138
|
-
|
|
139
|
-
The user is now authenticated and can proceed to either publish or list the components.
|
|
140
|
-
|
|
141
|
-
## Publish custom components
|
|
142
|
-
Enter the following command to publish custom components to Pega Infinity Server:
|
|
143
|
-
`npm run publish`
|
|
144
|
-
`npm run publishAll`
|
|
145
|
-
Publish the finalized custom components changes to Pega Infinity Server so that it can be discoverable in authoring (design palette).
|
|
146
|
-
You will then be asked to enter the following details:
|
|
147
|
-
|
|
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
|
|
150
|
-
- The name of the ruleset where the component must be published.
|
|
151
|
-
- The version of the ruleset where the component must be published.
|
|
152
|
-
- Specify if the development build should be generated for debugging.
|
|
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.
|
|
171
|
-
|
|
172
|
-
> **Note**:
|
|
173
|
-
> The Rule-UI-Component instance (with component name) is created on the Pega Infinity Server after publishing the component.
|
|
174
|
-
|
|
175
|
-
## List custom components
|
|
176
|
-
|
|
177
|
-
View the available components in the local machine or the server.
|
|
178
|
-
|
|
179
|
-
Enter the following command to list custom components:
|
|
180
|
-
`npm run list`
|
|
181
|
-
|
|
182
|
-
You will then be asked to enter the following details:
|
|
183
|
-
|
|
184
|
-
- List components from Server or Local?
|
|
185
|
-
Example - `Server`
|
|
186
|
-
|
|
187
|
-
The custom components will now be listed in the terminal.
|
|
188
|
-
|
|
189
|
-
## Delete custom components
|
|
190
|
-
|
|
191
|
-
Delete the available or published components in the local machine or the server.
|
|
192
|
-
|
|
193
|
-
Enter the following command to delete custom components:
|
|
194
|
-
`npm run delete`
|
|
195
|
-
`npm run deleteAll`
|
|
196
|
-
|
|
197
|
-
You will then be asked to enter the following details:
|
|
198
|
-
|
|
199
|
-
- Delete components from Server or Local?
|
|
200
|
-
Example - `Local`
|
|
201
|
-
|
|
202
|
-
- Select component to delete
|
|
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.
|
|
206
|
-
|
|
207
|
-
- Are you sure?
|
|
208
|
-
Example - `yes`
|
|
209
|
-
|
|
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.
|
|
212
|
-
|
|
213
|
-
## View existing custom components in storybook
|
|
214
|
-
|
|
215
|
-
View custom components in a storybook by performing the following procedure:
|
|
216
|
-
|
|
217
|
-
1. Enter the following command to open the project.
|
|
218
|
-
`cd <enter your project's name>`
|
|
219
|
-
|
|
220
|
-
2. Enter the following command to start the storybook in development mode.
|
|
221
|
-
`npm start`
|
|
222
|
-
|
|
223
|
-
The storybook is launched in a browser where you can view the components working in isolation.
|
|
21
|
+
Find the latest documentation on using **DX Component Builder** [here](https://docs.pega.com/bundle/constellation-dx-components-88/page/constellation-dx-components/custom-components/lifecycle-dx-cosmos-components.html)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/custom-dx-components",
|
|
3
|
-
"version": "8.8.
|
|
3
|
+
"version": "8.8.8",
|
|
4
4
|
"description": "Utility for building custom UI components",
|
|
5
5
|
"bin": "./bin/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"@babel/preset-env": "^7.19.1",
|
|
19
19
|
"@babel/preset-react": "^7.18.6",
|
|
20
20
|
"adm-zip": "^0.5.9",
|
|
21
|
-
"ajv": "^8.
|
|
21
|
+
"ajv": "^8.12.0",
|
|
22
|
+
"ajv-keywords": "^5.1.0",
|
|
22
23
|
"arg": "^5.0.2",
|
|
23
24
|
"babel-loader": "^8.2.5",
|
|
24
25
|
"chalk": "^5.0.1",
|
package/src/tasks/init/index.js
CHANGED
|
@@ -47,6 +47,7 @@ const copyProjectTemplate = async options => {
|
|
|
47
47
|
clobber: false
|
|
48
48
|
});
|
|
49
49
|
const packageJsonPath = path.join(options.targetDirectory, 'package.json.mustache');
|
|
50
|
+
const templateNPMRCPath = path.join(options.targetDirectory, 'templateNPMRC.txt');
|
|
50
51
|
|
|
51
52
|
let { organization, projectName } = options;
|
|
52
53
|
|
|
@@ -65,6 +66,10 @@ const copyProjectTemplate = async options => {
|
|
|
65
66
|
const output = compileMustacheTemplate(packageJsonPath, options);
|
|
66
67
|
fs.writeFileSync(packageJsonPath, output);
|
|
67
68
|
fs.renameSync(packageJsonPath, packageJsonPath.replace('.mustache', ''));
|
|
69
|
+
|
|
70
|
+
// rename template NPMRC to .npmrc, need to do this because npmjs won't publish an .npmrc file
|
|
71
|
+
fs.renameSync(templateNPMRCPath, templateNPMRCPath.replace('templateNPMRC.txt', '.npmrc'));
|
|
72
|
+
|
|
68
73
|
await createLicense(options);
|
|
69
74
|
};
|
|
70
75
|
|
|
@@ -123,7 +128,8 @@ export default async options => {
|
|
|
123
128
|
},
|
|
124
129
|
{
|
|
125
130
|
title: installDependenciesText,
|
|
126
|
-
task: () =>
|
|
131
|
+
task: () =>
|
|
132
|
+
execPromise('npm i --force --production=false', { cwd: options.targetDirectory })
|
|
127
133
|
}
|
|
128
134
|
],
|
|
129
135
|
{
|
|
Binary file
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@pega/cosmos-react-core": "^3.0.1",
|
|
45
45
|
"@pega/cosmos-react-work": "3.0.1",
|
|
46
46
|
"dayjs": "^1.11.5",
|
|
47
|
-
"jest": "^29.3.1",
|
|
48
47
|
"polished": "^4.2.2",
|
|
49
48
|
"prop-types": "^15.8.1",
|
|
50
49
|
"react": "^17.0.2",
|
|
@@ -57,7 +56,7 @@
|
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
59
58
|
"@pega/configs": "^0.5.3",
|
|
60
|
-
"@pega/custom-dx-components": "^8.8.
|
|
59
|
+
"@pega/custom-dx-components": "^8.8.8",
|
|
61
60
|
"@pega/eslint-config": "^0.3.2",
|
|
62
61
|
"@storybook/addon-actions": "^6.5.12",
|
|
63
62
|
"@storybook/addon-essentials": "^6.5.12",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"devBuild": false,
|
|
8
8
|
"serverType": "infinity",
|
|
9
9
|
"server": "https://localhost:38764/prweb",
|
|
10
|
-
"clientId": "",
|
|
10
|
+
"clientId": "10095186356008396159",
|
|
11
11
|
"clientSecret_comment": "Needed only when using 'passwordCreds' or 'clientCreds' grantType",
|
|
12
12
|
"clientSecret": "",
|
|
13
13
|
"grantType": "authCode",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"user_and_password_comment": "useful primarily when grantType is set to 'passwordCreds'",
|
|
20
20
|
"user": "",
|
|
21
21
|
"password": "",
|
|
22
|
+
"questions_comment": "useful for designating certain questions should always or never be asked during npm run authenticate",
|
|
22
23
|
"questions_askAlways": "",
|
|
23
24
|
"questions_askNever": ""
|
|
24
25
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Use default npmjs registry for the SDKs
|
|
2
|
+
registry = https://registry.npmjs.org/
|
|
3
|
+
# For now, turn off npm auto-install of peer dependencies to get rid of warnings
|
|
4
|
+
legacy-peer-deps=true
|
|
5
|
+
# Turn off messages such as > react-sdk@0.1.0 list and > dx-component-builder-sdk list
|
|
6
|
+
loglevel=silent
|
|
7
|
+
#
|
|
8
|
+
#
|
|
@@ -137,7 +137,14 @@ export const publishComponentToServer = async data => {
|
|
|
137
137
|
throw new Error(`${respData.message}`);
|
|
138
138
|
}
|
|
139
139
|
})
|
|
140
|
-
.catch(e =>
|
|
140
|
+
.catch( e => {
|
|
141
|
+
if (e.code == 'ECONNREFUSED') {
|
|
142
|
+
Promise.reject(`${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
Promise.reject(`${chalk.bold.red(e)}`);
|
|
146
|
+
}
|
|
147
|
+
})
|
|
141
148
|
} else {
|
|
142
149
|
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
143
150
|
}
|
package/src/util.js
CHANGED
|
@@ -282,6 +282,17 @@ export const showVersion = () => {
|
|
|
282
282
|
const pData = require("@pega/custom-dx-components/package.json");
|
|
283
283
|
|
|
284
284
|
console.log(chalk.green("DX Component Builder v" + pData.version));
|
|
285
|
+
|
|
286
|
+
// do a check of node version, it should be 18 or greater
|
|
287
|
+
const arNodeVersion = process.versions.node.split(".");
|
|
288
|
+
|
|
289
|
+
const nodeMajorVersion = parseInt(arNodeVersion[0]);
|
|
290
|
+
const nodeMinorVersion = parseInt(arNodeVersion[1]);
|
|
291
|
+
|
|
292
|
+
if (nodeMajorVersion < 18) {
|
|
293
|
+
console.log(chalk.redBright("DX Component Builder - SDK requires node v18 or greater, current version: " + process.version));
|
|
294
|
+
process.exit(1);
|
|
295
|
+
}
|
|
285
296
|
};
|
|
286
297
|
|
|
287
298
|
export const getOOTBComponents = async () => {
|