@pega/custom-dx-components 2.0.16 → 2.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +2 -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 +32 -16
- 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 +40 -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 +40 -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 +100 -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 +131 -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/README.md +75 -59
- package/src/tasks/init/template/package.json.mustache +20 -5
- package/src/tasks/init/template/tasks.config.json +1 -0
- 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
|
@@ -8,7 +8,7 @@ This project provides you with an environment to extend Constellation by giving
|
|
|
8
8
|
|
|
9
9
|
Ensure you have access to the following in your system:
|
|
10
10
|
|
|
11
|
-
- Pega Infinity Server version 8.
|
|
11
|
+
- Pega Infinity Server version 8.7 or later
|
|
12
12
|
|
|
13
13
|
- Git version 2.30 or later
|
|
14
14
|
|
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.18",
|
|
4
4
|
"description": "Utility for building custom UI components",
|
|
5
5
|
"bin": "./bin/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"css-loader": "6.7.1",
|
|
27
27
|
"css-minimizer-webpack-plugin": "^4.1.0",
|
|
28
28
|
"execa": "^6.1.0",
|
|
29
|
+
"eslint": "^8.4.1",
|
|
29
30
|
"file-loader": "6.2.0",
|
|
30
31
|
"fs-extra": "^10.1.0",
|
|
31
32
|
"gitignore": "^0.7.0",
|
|
@@ -61,7 +62,6 @@
|
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@pega/configs": "^0.3.3",
|
|
63
64
|
"cspell": "^6.9.0",
|
|
64
|
-
"eslint": "^8.23.1",
|
|
65
65
|
"prettier": "2.7.1"
|
|
66
66
|
}
|
|
67
67
|
}
|
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.16"));
|
|
316
319
|
await inquirer.prompt(questions).then(async answers => {
|
|
317
320
|
const {
|
|
318
321
|
componentName,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { withKnobs
|
|
2
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { configProps, stateProps } from './mock.stories';
|
|
5
|
+
|
|
6
|
+
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
5
7
|
|
|
6
8
|
export default {
|
|
7
9
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -10,30 +12,44 @@ export default {
|
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export const base{{COMPONENT_CLASS_NAME}} = () => {
|
|
13
|
-
const [value, setValue] = useState(
|
|
15
|
+
const [value, setValue] = useState(configProps.value);
|
|
14
16
|
|
|
15
17
|
const props = {
|
|
18
|
+
value,
|
|
19
|
+
label: configProps.label,
|
|
20
|
+
helperText: configProps.helperText,
|
|
21
|
+
caption: configProps.caption,
|
|
22
|
+
validatemessage: configProps.validatemessage,
|
|
23
|
+
hideLabel: configProps.hideLabel,
|
|
24
|
+
testId: configProps.testId,
|
|
25
|
+
additionalProps: configProps.additionalProps,
|
|
26
|
+
displayMode: configProps.displayMode,
|
|
27
|
+
variant: configProps.variant,
|
|
28
|
+
trueLabel: configProps.trueLabel,
|
|
29
|
+
falseLabel: configProps.falseLabel,
|
|
30
|
+
disabled: configProps.disabled,
|
|
31
|
+
readOnly: configProps.readOnly,
|
|
32
|
+
required: configProps.required,
|
|
16
33
|
getPConnect: () => {
|
|
17
34
|
return {
|
|
35
|
+
getStateProps: () => {
|
|
36
|
+
return stateProps;
|
|
37
|
+
},
|
|
18
38
|
getActionsApi: () => {
|
|
19
39
|
return {
|
|
20
|
-
updateFieldValue: (propName,
|
|
21
|
-
setValue(
|
|
22
|
-
}
|
|
40
|
+
updateFieldValue: (propName, theValue) => {
|
|
41
|
+
setValue(theValue);
|
|
42
|
+
},
|
|
43
|
+
triggerFieldChange: () => { /* nothing */}
|
|
23
44
|
};
|
|
24
45
|
},
|
|
25
|
-
|
|
26
|
-
return {
|
|
46
|
+
getValidationApi: () => {
|
|
47
|
+
return {
|
|
48
|
+
validate: () => { /* nothing */}
|
|
49
|
+
};
|
|
27
50
|
}
|
|
28
51
|
};
|
|
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')
|
|
52
|
+
}
|
|
37
53
|
};
|
|
38
54
|
|
|
39
55
|
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') {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: true,
|
|
3
|
+
label: 'Boolean label',
|
|
4
|
+
helperText: 'Test helper text',
|
|
5
|
+
caption: 'Boolean caption',
|
|
6
|
+
validatemessage: '',
|
|
7
|
+
hideLabel: false,
|
|
8
|
+
testId: '12345678',
|
|
9
|
+
additionalProps: {},
|
|
10
|
+
displayMode: '',
|
|
11
|
+
variant: '',
|
|
12
|
+
trueLabel: 'True',
|
|
13
|
+
falseLabel: 'False',
|
|
14
|
+
disabled: false,
|
|
15
|
+
readOnly: false,
|
|
16
|
+
required: true
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const stateProps = {
|
|
20
|
+
value: '.Test'
|
|
21
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
3
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
4
|
+
import utc from 'dayjs/plugin/utc';
|
|
5
|
+
import tzone from 'dayjs/plugin/timezone';
|
|
6
|
+
|
|
7
|
+
dayjs.extend(relativeTime);
|
|
8
|
+
dayjs.extend(localizedFormat);
|
|
9
|
+
dayjs.extend(utc);
|
|
10
|
+
dayjs.extend(tzone);
|
|
11
|
+
|
|
12
|
+
const types = ['fromNow', 'customFormat'];
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// value should be in ISO 8601 format.
|
|
17
|
+
function DateFormatter(
|
|
18
|
+
value,
|
|
19
|
+
{ type = types[1], format = "DD/MM/YYYY", timezone } = {}
|
|
20
|
+
) {
|
|
21
|
+
if (!value) return value;
|
|
22
|
+
switch (type) {
|
|
23
|
+
case types[1]:
|
|
24
|
+
if (timezone) return dayjs(value).tz(timezone).format(format);
|
|
25
|
+
return dayjs(value).format(format);
|
|
26
|
+
case types[0]:
|
|
27
|
+
return dayjs(value).from(dayjs());
|
|
28
|
+
default:
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// value should be in hh:mm:ss format (00:00:00 - 23:59:59).
|
|
34
|
+
function TimeFormatter(value, options) {
|
|
35
|
+
if (!value) return value;
|
|
36
|
+
const { locale = "en-US" } = options;
|
|
37
|
+
const timeOnlyRegex = /^(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)$/;
|
|
38
|
+
if (value.length === 8 && timeOnlyRegex.test(value)) {
|
|
39
|
+
const tempDate = new Date();
|
|
40
|
+
const hours = parseInt(value.substr(0, 2), 10);
|
|
41
|
+
const minutes = parseInt(value.substr(3, 2), 10);
|
|
42
|
+
const seconds = parseInt(value.substr(6, 2), 10);
|
|
43
|
+
tempDate.setHours(hours);
|
|
44
|
+
tempDate.setMinutes(minutes);
|
|
45
|
+
tempDate.setSeconds(seconds);
|
|
46
|
+
return tempDate.toLocaleTimeString(locale);
|
|
47
|
+
}
|
|
48
|
+
return DateFormatter(value, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
Date: (value, options) => DateFormatter(value, { type: 'customFormat', ...options }),
|
|
53
|
+
'Date-Time-Default': (value, options) =>
|
|
54
|
+
DateFormatter(value, { ...options, type: 'customFormat', format: 'lll' }),
|
|
55
|
+
'Time-Default': (value, options) =>
|
|
56
|
+
TimeFormatter(value, {
|
|
57
|
+
...options,
|
|
58
|
+
type: 'customFormat',
|
|
59
|
+
format: 'hh:mm A'
|
|
60
|
+
})
|
|
61
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FieldValueList } from '@pega/cosmos-react-core';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { format } from './date.js';
|
|
5
|
+
|
|
6
|
+
export default function FormattedText(props) {
|
|
7
|
+
const { formatType, label, value, testId, hideLabel, variant, additionalProps } = props;
|
|
8
|
+
|
|
9
|
+
let text = value;
|
|
10
|
+
|
|
11
|
+
text = format(text, formatType, additionalProps);
|
|
12
|
+
|
|
13
|
+
const fields = [
|
|
14
|
+
{
|
|
15
|
+
id: label.toLowerCase(),
|
|
16
|
+
name: hideLabel ? '' : label,
|
|
17
|
+
value: text
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
return <FieldValueList variant={variant} fields={fields} data-testid={testId} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
FormattedText.defaultProps = {
|
|
24
|
+
formatType: 'none',
|
|
25
|
+
variant: 'stacked',
|
|
26
|
+
value: undefined,
|
|
27
|
+
label: '',
|
|
28
|
+
testId: null,
|
|
29
|
+
hideLabel: false,
|
|
30
|
+
additionalProps: {}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
FormattedText.propTypes = {
|
|
34
|
+
formatType: PropTypes.string,
|
|
35
|
+
variant: PropTypes.oneOf(['inline', 'stacked']),
|
|
36
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
37
|
+
label: PropTypes.string,
|
|
38
|
+
testId: PropTypes.string,
|
|
39
|
+
additionalProps: PropTypes.objectOf(PropTypes.any),
|
|
40
|
+
hideLabel: PropTypes.bool
|
|
41
|
+
};
|