@pega/custom-dx-components 8.8.20 → 23.1.10
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/.prettierrc.json +1 -7
- package/package.json +5 -5
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +3 -3
- package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +5 -1
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +3 -3
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +3 -3
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +6 -5
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +4 -3
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Text/index.jsx.mustache +5 -4
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/{TimeOfDay → TimeofDay}/index.jsx.mustache +5 -4
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +3 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +3 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +5 -2
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +18 -12
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +5 -2
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +14 -11
- package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +2 -2
- package/src/tasks/create/templates/Launchpad/Widget/CASE/config.json.mustache +1 -1
- package/src/tasks/create/templates/Launchpad/Widget/CASE/index.jsx.mustache +2 -2
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/Operator.jsx.mustache +2 -2
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/index.jsx.mustache +2 -2
- package/src/tasks/create-all/index.js +105 -98
- package/src/tasks/delete/helper.js +32 -24
- package/src/tasks/delete-all/helper.js +15 -12
- package/src/tasks/init/template/jest.config.cjs +21 -0
- package/src/tasks/init/template/package.json.mustache +9 -4
- package/src/tasks/list/helper.js +14 -19
- package/tests/assets/components/create/Pega_DXIL_MyTestText/index.jsx +5 -4
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyBoolean/index.jsx +3 -3
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/config.json +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyCurrency/index.jsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/config.json +5 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/index.jsx +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/index.jsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDecimal/index.jsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyEmail/index.jsx +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.jsx +15 -9
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyInteger/index.jsx +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyParagraph/index.jsx +1 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPercentage/index.jsx +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPhone/index.jsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPicklist/index.jsx +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyText/index.jsx +5 -4
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTextInput/index.jsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/index.jsx +5 -4
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/index.jsx +12 -9
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/index.jsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyBoolean/index.jsx +3 -3
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/config.json +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyCurrency/index.jsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/config.json +5 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/index.jsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/index.jsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDecimal/index.jsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyEmail/index.jsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.jsx +15 -9
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyInteger/index.jsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyParagraph/index.jsx +1 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPercentage/index.jsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPhone/index.jsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPicklist/index.jsx +2 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyText/index.jsx +5 -4
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTextInput/index.jsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/index.jsx +5 -4
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/demo.stories.jsx +3 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/index.jsx +12 -9
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/index.jsx +1 -1
- package/tests/functional/localCreateBuildAllDeleteAll.test.js +15 -6
- package/tests/functional/localCreateBuildDelete.test.js +1 -1
- package/tests/functional/localCreatePublishAllDeleteAll.test.js +15 -6
- package/tests/functional/localCreatePublishDelete.test.js +2 -1
- /package/src/tasks/create/templates/Constellation/Field/{TimeOfDay → TimeofDay}/config.json.mustache +0 -0
- /package/src/tasks/create/templates/Constellation/Field/{TimeOfDay → TimeofDay}/demo.stories.jsx.mustache +0 -0
- /package/src/tasks/create/templates/Constellation/Field/{TimeOfDay → TimeofDay}/mock.stories.js.mustache +0 -0
- /package/src/tasks/create/templates/Constellation/Field/{TimeOfDay → TimeofDay}/styles.js.mustache +0 -0
- /package/src/tasks/create/templates/Constellation/Field/{TimeOfDay → TimeofDay}/suggestions-handler.js +0 -0
- /package/src/tasks/create/templates/Constellation/Field/{TimeOfDay → TimeofDay}/time-of-day.js.mustache +0 -0
|
@@ -46,11 +46,11 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
|
|
|
46
46
|
<Card>
|
|
47
47
|
<CardHeader>{title}</CardHeader>
|
|
48
48
|
<CardContent>
|
|
49
|
-
{{! pick new
|
|
49
|
+
{{! pick new delimiters for mustache }} {{=<% %>=}}
|
|
50
50
|
<Flex container={{ direction: 'row'}}>
|
|
51
51
|
<Operator label={hideLabel ? null : _label} name={user.userName} id={user.userId} getPConnect={getPConnect} />
|
|
52
52
|
|
|
53
|
-
<%={{ }}=%> {{! revert
|
|
53
|
+
<%={{ }}=%> {{! revert delimiters for mustache }}
|
|
54
54
|
{dateTimeValue && (
|
|
55
55
|
<Fragment>
|
|
56
56
|
{' '}
|
|
@@ -33,7 +33,7 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
|
|
|
33
33
|
if (response.data.data !== null) {
|
|
34
34
|
setHistory(
|
|
35
35
|
response.data.data.map((entry, index) => {
|
|
36
|
-
{{! pick new
|
|
36
|
+
{{! pick new delimiters for mustache }}
|
|
37
37
|
{{=<% %>=}}
|
|
38
38
|
return {
|
|
39
39
|
date: new Date(entry.CreateDateTime).toLocaleString(),
|
|
@@ -41,7 +41,7 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
|
|
|
41
41
|
user: entry.PerformerID,
|
|
42
42
|
id: index
|
|
43
43
|
};
|
|
44
|
-
<%={{ }}=%> {{! revert
|
|
44
|
+
<%={{ }}=%> {{! revert delimiters for mustache }}
|
|
45
45
|
})
|
|
46
46
|
);
|
|
47
47
|
} else {
|
|
@@ -31,7 +31,7 @@ const Operator = (props) => {
|
|
|
31
31
|
}, [id]);
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
{{! pick new
|
|
34
|
+
{{! pick new delimiters for mustache }}
|
|
35
35
|
{{=<% %>=}}
|
|
36
36
|
|
|
37
37
|
const OperatorPreview = () => {
|
|
@@ -187,7 +187,7 @@ const Operator = (props) => {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
<%={{ }}=%> {{! revert
|
|
190
|
+
<%={{ }}=%> {{! revert delimiters for mustache }}
|
|
191
191
|
|
|
192
192
|
const clickAction = (e) => {
|
|
193
193
|
setPopoverTarget(e.currentTarget);
|
|
@@ -38,11 +38,11 @@ export default function {{COMPONENT_CLASS_NAME}}(props) {
|
|
|
38
38
|
<Card>
|
|
39
39
|
<CardHeader>{title}</CardHeader>
|
|
40
40
|
<CardContent>
|
|
41
|
-
{{! pick new
|
|
41
|
+
{{! pick new delimiters for mustache }} {{=<% %>=}}
|
|
42
42
|
<Flex container={{ direction: 'row'}}>
|
|
43
43
|
<Operator label={_label} name={user} id={user} getPConnect={getPConnect} />
|
|
44
44
|
|
|
45
|
-
<%={{ }}=%> {{! revert
|
|
45
|
+
<%={{ }}=%> {{! revert delimiters for mustache }}
|
|
46
46
|
{dateTimeValue && (
|
|
47
47
|
<Fragment>
|
|
48
48
|
{' '}
|
|
@@ -2,29 +2,28 @@ import path from 'path';
|
|
|
2
2
|
import { URL, fileURLToPath } from 'url';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { promisify } from 'util';
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
|
|
7
7
|
import inquirer from 'inquirer';
|
|
8
8
|
import ncp from 'ncp';
|
|
9
9
|
import chalk from 'chalk';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
14
|
-
|
|
15
|
-
import {
|
|
11
|
+
// eslint-disable-next-line import/order
|
|
12
|
+
import { checkPathAccess, showVersion ,
|
|
16
13
|
convertIntoPascalCase,
|
|
17
14
|
compileMustacheTemplate,
|
|
18
15
|
getComponentDirectoryPath,
|
|
19
16
|
getPegaServerConfig,
|
|
20
|
-
getPegaConfig,
|
|
21
17
|
getComponents,
|
|
22
18
|
getComponentDefaults,
|
|
23
19
|
sanitize,
|
|
24
20
|
validateSemver
|
|
25
21
|
} from '../../util.js';
|
|
22
|
+
|
|
26
23
|
import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION } from '../../constants.js';
|
|
27
24
|
|
|
25
|
+
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
26
|
+
|
|
28
27
|
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
29
28
|
|
|
30
29
|
const copy = promisify(ncp);
|
|
@@ -65,7 +64,8 @@ export const compileMustacheTemplates = async (
|
|
|
65
64
|
let mustacheSubType = subtype;
|
|
66
65
|
|
|
67
66
|
// overrides
|
|
68
|
-
if (typeof mustacheSubType
|
|
67
|
+
if (typeof mustacheSubType === 'string') {
|
|
68
|
+
// eslint-disable-next-line default-case
|
|
69
69
|
switch (mustacheSubType) {
|
|
70
70
|
case 'FORM-region':
|
|
71
71
|
mustacheSubType = 'FORM';
|
|
@@ -114,8 +114,87 @@ export const compileMustacheTemplates = async (
|
|
|
114
114
|
});
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
+
export const validateCompile = async (
|
|
118
|
+
{ library, organization, componentName, componentLabel, version, framework, type, subtype, description, allowedApplications },
|
|
119
|
+
options
|
|
120
|
+
) => {
|
|
121
|
+
let sSubType = subtype;
|
|
122
|
+
if (Array.isArray(subtype)) {
|
|
123
|
+
sSubType = subtype.join('-');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// await checkPathAccess(pegaConfigInternalJsonPath);
|
|
127
|
+
|
|
128
|
+
framework = convertIntoPascalCase(CATEGORY_CONSTELLATION);
|
|
129
|
+
|
|
130
|
+
const templateParentDir = `./templates/${framework}`;
|
|
131
|
+
|
|
132
|
+
let templateDir = `${templateParentDir}/${type}/${sSubType}`;
|
|
133
|
+
let templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
134
|
+
templateDirectory = templateDirectory.replace(`${path.sep }create-all`, `${path.sep }create`);
|
|
135
|
+
|
|
136
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
137
|
+
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
138
|
+
const originalFramework = framework;
|
|
139
|
+
|
|
140
|
+
if (isLaunchpad) {
|
|
141
|
+
framework = "Launchpad";
|
|
142
|
+
|
|
143
|
+
templateDir = `./templates/${framework}/${type}/${sSubType}`;
|
|
144
|
+
templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
145
|
+
templateDirectory = templateDirectory.replace(`${path.sep }create-all`, `${path.sep }create`);
|
|
146
|
+
|
|
147
|
+
// if doesn't exist, revert
|
|
148
|
+
if (!fs.existsSync(templateDirectory)) {
|
|
149
|
+
framework = originalFramework;
|
|
150
|
+
|
|
151
|
+
templateDir = `./templates/${framework}/${type}/${sSubType}`;
|
|
152
|
+
templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
153
|
+
templateDirectory = templateDirectory.replace(`${path.sep }create-all`, `${path.sep }create`);
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
const componentKey = `${organization}_${library}_${componentName}`;
|
|
162
|
+
|
|
163
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
164
|
+
|
|
165
|
+
const components = await getComponents(false);
|
|
166
|
+
|
|
167
|
+
if (components.includes(componentKey)) {
|
|
168
|
+
console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
|
|
169
|
+
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// component
|
|
174
|
+
await copyComponentTemplate({
|
|
175
|
+
...options,
|
|
176
|
+
targetDirectory,
|
|
177
|
+
templateDirectory
|
|
178
|
+
});
|
|
179
|
+
await compileMustacheTemplates(targetDirectory, {
|
|
180
|
+
componentKey,
|
|
181
|
+
componentName,
|
|
182
|
+
componentLabel,
|
|
183
|
+
library,
|
|
184
|
+
version,
|
|
185
|
+
type,
|
|
186
|
+
subtype,
|
|
187
|
+
description,
|
|
188
|
+
organization,
|
|
189
|
+
allowedApplications
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
console.log(chalk.green(`created ${componentKey} component in ${targetDirectory}`));
|
|
193
|
+
};
|
|
194
|
+
|
|
117
195
|
export const validateCompileAll = async ({ prefix, library, version, allowedApplications, organization }, options) => {
|
|
118
|
-
|
|
196
|
+
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
197
|
+
for (const fieldIdx in COMPONENT_SCHEMA.subtype.field) {
|
|
119
198
|
const type = 'Field';
|
|
120
199
|
const subtype = COMPONENT_SCHEMA.subtype.field[fieldIdx].value;
|
|
121
200
|
const prefixNoSpace = prefix.replace(/\s+/g, '');
|
|
@@ -124,6 +203,7 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
124
203
|
const componentLabel = ''.concat(prefix).concat(' ').concat(COMPONENT_SCHEMA.subtype.field[fieldIdx].name);
|
|
125
204
|
const description = componentLabel;
|
|
126
205
|
|
|
206
|
+
// eslint-disable-next-line no-await-in-loop
|
|
127
207
|
await validateCompile(
|
|
128
208
|
{
|
|
129
209
|
library,
|
|
@@ -140,15 +220,16 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
140
220
|
);
|
|
141
221
|
}
|
|
142
222
|
|
|
143
|
-
|
|
223
|
+
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
224
|
+
for (const templateIdx in COMPONENT_SCHEMA.subtype.template) {
|
|
144
225
|
const type = 'Template';
|
|
145
226
|
const subtype = COMPONENT_SCHEMA.subtype.template[templateIdx].value;
|
|
146
227
|
const prefixNoSpace = prefix.replace(/\s+/g, '');
|
|
147
|
-
|
|
228
|
+
const templateNameOriginal = COMPONENT_SCHEMA.subtype.template[templateIdx].name;
|
|
148
229
|
let templateName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
|
|
149
230
|
let templateLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
|
|
150
231
|
if (templateNameOriginal.indexOf('region') >= 0) {
|
|
151
|
-
|
|
232
|
+
const templateNameBase = convertIntoPascalCase(templateNameOriginal.replace(' region', ''));
|
|
152
233
|
templateName = 'TwoColumn'.concat(templateNameBase);
|
|
153
234
|
templateLabel = 'Two Column '.concat(templateNameBase);
|
|
154
235
|
}
|
|
@@ -156,6 +237,7 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
156
237
|
const componentLabel = ''.concat(prefix).concat(' ').concat(templateLabel);
|
|
157
238
|
const description = componentLabel;
|
|
158
239
|
|
|
240
|
+
// eslint-disable-next-line no-await-in-loop
|
|
159
241
|
await validateCompile(
|
|
160
242
|
{
|
|
161
243
|
library,
|
|
@@ -172,13 +254,14 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
172
254
|
);
|
|
173
255
|
}
|
|
174
256
|
|
|
175
|
-
|
|
257
|
+
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
258
|
+
for (const widgetIdx in COMPONENT_SCHEMA.subtype.widget) {
|
|
176
259
|
const type = 'Widget';
|
|
177
260
|
const subtype = COMPONENT_SCHEMA.subtype.widget[widgetIdx].value;
|
|
178
261
|
const prefixNoSpace = prefix.replace(/\s+/g, '');
|
|
179
|
-
|
|
262
|
+
const widgetNameOriginal = COMPONENT_SCHEMA.subtype.widget[widgetIdx].name;
|
|
180
263
|
let widgetName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat('Widget');
|
|
181
|
-
|
|
264
|
+
const widgetLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat(' Widget');
|
|
182
265
|
if (widgetName.indexOf('&') >= 0) {
|
|
183
266
|
widgetName = convertIntoPascalCase(widgetNameOriginal.replace(' & ', ''));
|
|
184
267
|
}
|
|
@@ -186,6 +269,7 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
186
269
|
const componentLabel = ''.concat(prefix).concat(' ').concat(widgetLabel);
|
|
187
270
|
const description = componentLabel;
|
|
188
271
|
|
|
272
|
+
// eslint-disable-next-line no-await-in-loop
|
|
189
273
|
await validateCompile(
|
|
190
274
|
{
|
|
191
275
|
library,
|
|
@@ -203,86 +287,7 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
203
287
|
}
|
|
204
288
|
};
|
|
205
289
|
|
|
206
|
-
export const validateCompile = async (
|
|
207
|
-
{ library, organization, componentName, componentLabel, version, framework, type, subtype, description, allowedApplications },
|
|
208
|
-
options
|
|
209
|
-
) => {
|
|
210
|
-
let sSubType = subtype;
|
|
211
|
-
if (Array.isArray(subtype)) {
|
|
212
|
-
sSubType = subtype.join('-');
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const typeLC = type.toLowerCase();
|
|
216
|
-
|
|
217
|
-
//await checkPathAccess(pegaConfigInternalJsonPath);
|
|
218
|
-
|
|
219
|
-
framework = convertIntoPascalCase(CATEGORY_CONSTELLATION);
|
|
220
|
-
|
|
221
|
-
let pegaConfig = await getPegaConfig();
|
|
222
|
-
let templateParentDir = `./templates/${framework}`;
|
|
223
|
-
|
|
224
|
-
let templateDir = `${templateParentDir}/${type}/${sSubType}`;
|
|
225
|
-
let templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
226
|
-
templateDirectory = templateDirectory.replace(path.sep + 'create-all', path.sep + 'create');
|
|
227
|
-
|
|
228
|
-
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
229
|
-
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
230
|
-
let originalFramework = framework;
|
|
231
|
-
|
|
232
|
-
if (isLaunchpad) {
|
|
233
|
-
framework = "Launchpad";
|
|
234
|
-
|
|
235
|
-
templateDir = `./templates/${framework}/${type}/${sSubType}`;
|
|
236
|
-
templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
237
|
-
templateDirectory = templateDirectory.replace(path.sep + 'create-all', path.sep + 'create');
|
|
238
|
-
|
|
239
|
-
// if doesn't exist, revert
|
|
240
|
-
if (!fs.existsSync(templateDirectory)) {
|
|
241
|
-
framework = originalFramework;
|
|
242
|
-
|
|
243
|
-
templateDir = `./templates/${framework}/${type}/${sSubType}`;
|
|
244
|
-
templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
245
|
-
templateDirectory = templateDirectory.replace(path.sep + 'create-all', path.sep + 'create');
|
|
246
|
-
|
|
247
|
-
}
|
|
248
290
|
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const componentKey = `${organization}_${library}_${componentName}`;
|
|
254
|
-
|
|
255
|
-
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
256
|
-
|
|
257
|
-
const components = await getComponents(false);
|
|
258
|
-
|
|
259
|
-
if (components.includes(componentKey)) {
|
|
260
|
-
console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
|
|
261
|
-
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// component
|
|
266
|
-
await copyComponentTemplate({
|
|
267
|
-
...options,
|
|
268
|
-
targetDirectory,
|
|
269
|
-
templateDirectory
|
|
270
|
-
});
|
|
271
|
-
await compileMustacheTemplates(targetDirectory, {
|
|
272
|
-
componentKey,
|
|
273
|
-
componentName,
|
|
274
|
-
componentLabel,
|
|
275
|
-
library,
|
|
276
|
-
version,
|
|
277
|
-
type,
|
|
278
|
-
subtype,
|
|
279
|
-
description,
|
|
280
|
-
organization,
|
|
281
|
-
allowedApplications
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
console.log(chalk.green(`created ${componentKey} component in ${targetDirectory}`));
|
|
285
|
-
};
|
|
286
291
|
|
|
287
292
|
export default async (options) => {
|
|
288
293
|
showVersion();
|
|
@@ -299,16 +304,17 @@ export default async (options) => {
|
|
|
299
304
|
|
|
300
305
|
const componentData = data[COMPONENTS_PATH];
|
|
301
306
|
|
|
302
|
-
|
|
307
|
+
let library;
|
|
308
|
+
({ library } = componentData);
|
|
303
309
|
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
304
310
|
|
|
305
|
-
|
|
311
|
+
const componentDefaults = await getComponentDefaults();
|
|
306
312
|
componentDefaults.library = library;
|
|
307
313
|
|
|
308
314
|
if (options.params.length >= 8) {
|
|
309
315
|
const prefix = options.params[3];
|
|
310
316
|
const version = options.params[4];
|
|
311
|
-
|
|
317
|
+
library = options.params[5];
|
|
312
318
|
const allowedApplications = options.params[6];
|
|
313
319
|
|
|
314
320
|
// overwrite
|
|
@@ -365,7 +371,8 @@ export default async (options) => {
|
|
|
365
371
|
];
|
|
366
372
|
|
|
367
373
|
await inquirer.prompt(questions).then(async (answers) => {
|
|
368
|
-
|
|
374
|
+
({library} = answers);
|
|
375
|
+
const { version, allowedApplications } = answers;
|
|
369
376
|
let { prefix } = answers;
|
|
370
377
|
prefix = prefix.replace(/[^a-zA-Z0-9 ]/g, '');
|
|
371
378
|
await validateCompileAll(
|
|
@@ -27,6 +27,7 @@ export const SOURCE_OF_COMPONENT_TYPES = {
|
|
|
27
27
|
let library;
|
|
28
28
|
let organization;
|
|
29
29
|
|
|
30
|
+
|
|
30
31
|
export const getDeleteComponentsQuestions = async (options) => {
|
|
31
32
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
32
33
|
|
|
@@ -54,40 +55,42 @@ export const getLaunchPadFilterQuestions = async () => {
|
|
|
54
55
|
data = data && JSON.parse(data);
|
|
55
56
|
|
|
56
57
|
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
57
|
-
console.error(
|
|
58
|
+
console.error(
|
|
59
|
+
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
60
|
+
);
|
|
58
61
|
process.exit(1);
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
const componentData = data[COMPONENTS_PATH];
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
({ library } = componentData);
|
|
67
|
+
({ organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8')));
|
|
65
68
|
|
|
66
69
|
return [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
return 'Please provide value for organization';
|
|
70
|
+
{
|
|
71
|
+
name: 'organization',
|
|
72
|
+
message: 'Enter component organization (required)',
|
|
73
|
+
default: organization,
|
|
74
|
+
validate: value => {
|
|
75
|
+
if (value) {
|
|
76
|
+
return true;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return
|
|
78
|
+
return 'Please provide value for organization';
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'library',
|
|
83
|
+
message: 'Enter library name (required)',
|
|
84
|
+
default: library,
|
|
85
|
+
validate: value => {
|
|
86
|
+
if (value) {
|
|
87
|
+
return true;
|
|
87
88
|
}
|
|
89
|
+
return 'Please provide value for library';
|
|
88
90
|
}
|
|
91
|
+
}
|
|
89
92
|
];
|
|
90
|
-
}
|
|
93
|
+
}
|
|
91
94
|
|
|
92
95
|
export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
93
96
|
const localComponents = await getComponents();
|
|
@@ -125,23 +128,27 @@ export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
|
125
128
|
};
|
|
126
129
|
|
|
127
130
|
export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
131
|
+
|
|
128
132
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
129
133
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
130
134
|
|
|
135
|
+
|
|
131
136
|
if (isLaunchpad) {
|
|
132
137
|
const questions = await getLaunchPadFilterQuestions();
|
|
133
138
|
const lpAnswers = await inquirer.prompt(questions);
|
|
134
139
|
|
|
135
|
-
({
|
|
140
|
+
({library, organization} = lpAnswers);
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
const spinner = ora('Fetching components from server').start();
|
|
139
144
|
const data = await getComponentsFromServer(library, organization);
|
|
140
145
|
spinner.stop();
|
|
141
146
|
|
|
147
|
+
|
|
142
148
|
let serverComponents;
|
|
143
149
|
if (isLaunchpad) {
|
|
144
150
|
serverComponents = data;
|
|
151
|
+
|
|
145
152
|
} else {
|
|
146
153
|
try {
|
|
147
154
|
if (typeof data === 'object') {
|
|
@@ -154,6 +161,7 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
163
|
|
|
164
|
+
|
|
157
165
|
if (serverComponents && serverComponents?.length > 0) {
|
|
158
166
|
if (isLaunchpad) {
|
|
159
167
|
const choicesArr = serverComponents.map(({ name: componentName, type, version }) => {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import path, {join} from 'path';
|
|
3
|
+
|
|
2
4
|
import chalk from 'chalk';
|
|
3
5
|
import inquirer from 'inquirer';
|
|
4
6
|
import ora from 'ora';
|
|
5
7
|
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { join } from 'path';
|
|
8
|
-
|
|
9
8
|
import {
|
|
10
9
|
deleteInfinityServerComponent,
|
|
11
10
|
deleteLaunchpadServerComponent,
|
|
@@ -13,11 +12,9 @@ import {
|
|
|
13
12
|
getComponents,
|
|
14
13
|
getPegaServerConfig,
|
|
15
14
|
standardizeStr,
|
|
16
|
-
validateRulesetVersion
|
|
17
|
-
sanitize
|
|
15
|
+
validateRulesetVersion
|
|
18
16
|
} from '../../util.js';
|
|
19
17
|
import { getComponentsFromServer } from '../list/helper.js';
|
|
20
|
-
|
|
21
18
|
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
|
|
22
19
|
|
|
23
20
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
@@ -28,6 +25,7 @@ export const SOURCE_OF_COMPONENT_TYPES = {
|
|
|
28
25
|
let library;
|
|
29
26
|
let organization;
|
|
30
27
|
|
|
28
|
+
|
|
31
29
|
export const getDeleteComponentsQuestions = async (options) => {
|
|
32
30
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
33
31
|
|
|
@@ -46,7 +44,6 @@ export const getDeleteComponentsQuestions = async (options) => {
|
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
export const getLaunchPadFilterQuestions = async () => {
|
|
49
|
-
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
50
47
|
const currentDirectory = process.cwd();
|
|
51
48
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
52
49
|
|
|
@@ -54,7 +51,9 @@ export const getLaunchPadFilterQuestions = async () => {
|
|
|
54
51
|
data = data && JSON.parse(data);
|
|
55
52
|
|
|
56
53
|
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
57
|
-
console.error(
|
|
54
|
+
console.error(
|
|
55
|
+
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
56
|
+
);
|
|
58
57
|
process.exit(1);
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -68,7 +67,7 @@ export const getLaunchPadFilterQuestions = async () => {
|
|
|
68
67
|
name: 'organization',
|
|
69
68
|
message: 'Enter component organization (required)',
|
|
70
69
|
default: organization,
|
|
71
|
-
validate:
|
|
70
|
+
validate: value => {
|
|
72
71
|
if (value) {
|
|
73
72
|
return true;
|
|
74
73
|
}
|
|
@@ -79,7 +78,7 @@ export const getLaunchPadFilterQuestions = async () => {
|
|
|
79
78
|
name: 'library',
|
|
80
79
|
message: 'Enter library name (required)',
|
|
81
80
|
default: library,
|
|
82
|
-
validate:
|
|
81
|
+
validate: value => {
|
|
83
82
|
if (value) {
|
|
84
83
|
return true;
|
|
85
84
|
}
|
|
@@ -87,7 +86,7 @@ export const getLaunchPadFilterQuestions = async () => {
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
];
|
|
90
|
-
}
|
|
89
|
+
}
|
|
91
90
|
|
|
92
91
|
export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
93
92
|
const localComponents = await getComponents();
|
|
@@ -133,6 +132,7 @@ export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
|
133
132
|
};
|
|
134
133
|
|
|
135
134
|
export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
135
|
+
|
|
136
136
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
137
137
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
138
138
|
|
|
@@ -140,13 +140,14 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
140
140
|
const questions = await getLaunchPadFilterQuestions();
|
|
141
141
|
const lpAnswers = await inquirer.prompt(questions);
|
|
142
142
|
|
|
143
|
-
({
|
|
143
|
+
({library, organization} = lpAnswers);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
const spinner = ora('Fetching components from server').start();
|
|
147
147
|
const data = await getComponentsFromServer(library, organization);
|
|
148
148
|
spinner.stop();
|
|
149
149
|
|
|
150
|
+
|
|
150
151
|
// const serverComponents = isLaunchpad ? data : data.pxResults;
|
|
151
152
|
let serverComponents;
|
|
152
153
|
if (isLaunchpad) {
|
|
@@ -163,6 +164,8 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
|
|
168
|
+
|
|
166
169
|
if (serverComponents && serverComponents?.length > 0) {
|
|
167
170
|
if (isLaunchpad) {
|
|
168
171
|
serverComponents.forEach((component) => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
verbose: true,
|
|
3
|
+
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
|
|
4
|
+
transform: {
|
|
5
|
+
'^.+\\.[t|j]sx?$': 'babel-jest'
|
|
6
|
+
},
|
|
7
|
+
collectCoverage: true,
|
|
8
|
+
testPathIgnorePatterns: [],
|
|
9
|
+
transformIgnorePatterns: [],
|
|
10
|
+
modulePathIgnorePatterns: [],
|
|
11
|
+
coveragePathIgnorePatterns: [],
|
|
12
|
+
collectCoverageFrom: ['./node_modules/@pega/custom-dx-components/src/*.js'],
|
|
13
|
+
coverageThreshold: {
|
|
14
|
+
global: {
|
|
15
|
+
statements: 79,
|
|
16
|
+
branches: 74,
|
|
17
|
+
functions: 81,
|
|
18
|
+
lines: 80
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -27,7 +27,12 @@
|
|
|
27
27
|
"lint:es": "eslint .",
|
|
28
28
|
"lint:styles": "stylelint \"./**/*.@(js|jsx|ts|tsx)\"",
|
|
29
29
|
"lint:format": "prettier -c .",
|
|
30
|
-
"lint:spelling": "cspell --no-progress **/*"
|
|
30
|
+
"lint:spelling": "cspell --no-progress **/*",
|
|
31
|
+
"test": "echo 'Running functional and unit tests will DELETE existing local components, proceed (y/n)?' && read proceed && if test \"$proceed\" = \"y\"; then npm run test:full; fi ",
|
|
32
|
+
"test:full": "npm run test:functional && npm run test:unit",
|
|
33
|
+
"test:functional": "npm run test:functional:local --prefix node_modules/@pega/custom-dx-components",
|
|
34
|
+
"test-coverage": "node --input-type=module --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand node_modules/@pega/custom-dx-component --ci --testResultsProcessor='jest-junit' --coverage",
|
|
35
|
+
"test:unit": "npm run test:unit:local --prefix node_modules/@pega/custom-dx-components"
|
|
31
36
|
},
|
|
32
37
|
"scriptsComments": {
|
|
33
38
|
"build": "tsc -b tsconfig.build.json",
|
|
@@ -46,8 +51,8 @@
|
|
|
46
51
|
"license": "Enter License",
|
|
47
52
|
"sideEffects": false,
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"@pega/cosmos-react-core": "^
|
|
50
|
-
"@pega/cosmos-react-work": "
|
|
54
|
+
"@pega/cosmos-react-core": "^4.0.1",
|
|
55
|
+
"@pega/cosmos-react-work": "4.0.1",
|
|
51
56
|
"dayjs": "^1.11.5",
|
|
52
57
|
"polished": "^4.2.2",
|
|
53
58
|
"prop-types": "^15.8.1",
|
|
@@ -61,7 +66,7 @@
|
|
|
61
66
|
},
|
|
62
67
|
"devDependencies": {
|
|
63
68
|
"@pega/configs": "^0.5.3",
|
|
64
|
-
"@pega/custom-dx-components": "^
|
|
69
|
+
"@pega/custom-dx-components": "^23.1.10",
|
|
65
70
|
"@pega/eslint-config": "^0.3.2",
|
|
66
71
|
"@storybook/addon-actions": "^6.5.12",
|
|
67
72
|
"@storybook/addon-essentials": "^6.5.12",
|