@pega/custom-dx-components 2.0.24 → 8.8.1

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.
Files changed (44) hide show
  1. package/package.json +1 -1
  2. package/src/auth.js +5 -5
  3. package/src/cli.js +18 -0
  4. package/src/constants.js +35 -1
  5. package/src/tasks/authenticate/index.js +72 -31
  6. package/src/tasks/build/helper.js +3 -3
  7. package/src/tasks/build-all/helper.js +69 -0
  8. package/src/tasks/build-all/index.js +79 -0
  9. package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +1 -1
  10. package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +1 -1
  11. package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +1 -1
  12. package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +1 -1
  13. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +1 -1
  14. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +1 -1
  15. package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +1 -1
  16. package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +1 -1
  17. package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +14 -0
  18. package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +1 -1
  19. package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +1 -1
  20. package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +1 -1
  21. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +1 -1
  22. package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +1 -1
  23. package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +1 -1
  24. package/src/tasks/create/templates/Constellation/Field/TimeofDay/styles.js.mustache +1 -1
  25. package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +1 -1
  26. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +1 -1
  27. package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +1 -1
  28. package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +4 -1
  29. package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +1 -1
  30. package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +1 -1
  31. package/src/tasks/create-all/index.js +400 -0
  32. package/src/tasks/index.js +3 -0
  33. package/src/tasks/init/template/package.json.mustache +5 -2
  34. package/src/tasks/list/helper.js +19 -6
  35. package/src/tasks/publish/helper.js +3 -3
  36. package/src/tasks/publish-all/helper.js +20 -6
  37. package/src/tasks/publish-all/index.js +29 -18
  38. package/src/tasks/rename/index.js +315 -0
  39. package/src/tasks/validator/index.js +182 -7
  40. package/src/util.js +66 -3
  41. package/src/tasks/create/template/config.json.mustache +0 -62
  42. package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
  43. package/src/tasks/create/template/index.jsx.mustache +0 -55
  44. package/src/tasks/create/template/styles.js.mustache +0 -7
package/src/util.js CHANGED
@@ -16,7 +16,13 @@ import {
16
16
  TOKEN_PATH,
17
17
  OOTB_COMPONENT_SERVICE_REST_ENDPOINT,
18
18
  DELETE_COMPONENT_SERVICE_REST_ENDPOINT,
19
- OOTB_COMPONENTS
19
+ OOTB_COMPONENTS,
20
+ FIELD_PATH,
21
+ WIDGET_PATH,
22
+ TEMPLATE_PATH,
23
+ COMPONENT_PREFIX_FIELD_PATH,
24
+ COMPONENT_PREFIX_TEMPLATE_PATH,
25
+ COMPONENT_PREFIX_WIDGET_PATH
20
26
  } from './constants.js';
21
27
 
22
28
  const access = promisify(fs.access);
@@ -52,7 +58,7 @@ export const deleteLocalComponent = async componentKey => {
52
58
 
53
59
  const directory = join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
54
60
 
55
- fs.rmdir(directory, { recursive: true }, err => {
61
+ fs.rm(directory, { recursive: true }, err => {
56
62
  if (err) {
57
63
  throw err;
58
64
  }
@@ -84,12 +90,23 @@ export const deleteServerComponent = async componentKey => {
84
90
  })
85
91
  .then(response => response.text())
86
92
  .then(resp => {
87
- const respData = JSON.parse(resp);
93
+ let respData;
94
+ try {
95
+ respData = JSON.parse(resp);
96
+
97
+ }
98
+ catch (e) {
99
+ console.log(chalk.bold.redBright(`Failure : ${resp}`));
100
+ process.exit(1);
101
+ }
102
+
88
103
  if (respData.status == 200) {
89
104
  console.log(chalk.bold.green(`Success : ${respData.message}`));
90
105
  } else {
91
106
  throw new Error(`${respData.message}`);
92
107
  }
108
+
109
+
93
110
  })
94
111
  .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
95
112
  }
@@ -98,6 +115,7 @@ export const deleteServerComponent = async componentKey => {
98
115
  }
99
116
  };
100
117
 
118
+
101
119
  export const getComponents = async () => {
102
120
  const currentDirectory = process.cwd();
103
121
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
@@ -121,6 +139,51 @@ export const getComponents = async () => {
121
139
  .map(dirent => dirent.name);
122
140
  };
123
141
 
142
+
143
+
144
+
145
+ export const getSubComponents = async (directory, type) => {
146
+
147
+ const subDirectory = join(directory, type);
148
+ return fs
149
+ .readdirSync(subDirectory, { withFileTypes: true })
150
+ .filter(dirent => dirent.isDirectory())
151
+ .map(dirent => dirent.name);
152
+ }
153
+
154
+
155
+ export const getDirectoryFiles = async (directory) => {
156
+ return fs
157
+ .readdirSync(directory, { withFileTypes: true })
158
+ .filter(dirent => !dirent.isDirectory())
159
+ .map(dirent => dirent.name);
160
+ }
161
+
162
+
163
+ export const getComponentsObj = async () => {
164
+
165
+ let compList = new Array();
166
+
167
+ //const componentList = await getDirectoryFiles(directory);
168
+ const componentList = await getComponents();
169
+
170
+
171
+ if (componentList.length > 0) {
172
+
173
+ compList.push(...componentList.map(
174
+ name => {
175
+ const container = {};
176
+ container.name = name;
177
+ container.value = name;
178
+
179
+ return container;
180
+ }
181
+ ));
182
+ }
183
+
184
+ return compList;
185
+ }
186
+
124
187
  export const getPegaConfig = async () => {
125
188
  const currentDirectory = process.cwd();
126
189
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
@@ -1,62 +0,0 @@
1
- {
2
- "name": "{{COMPONENT_KEY}}",
3
- "label": "{{COMPONENT_LABEL}}",
4
- "description": "{{DESCRIPTION}}",
5
- "organization": "{{ORGANIZATION}}",
6
- "version": "{{VERSION}}",
7
- "library": "{{LIBRARY}}",
8
- "allowedApplications": {{{ALLOWEDAPPS}}},
9
- "componentKey": "{{COMPONENT_KEY}}",
10
- "type": "{{TYPE}}",
11
- "subtype": {{{SUB_TYPE}}},
12
- {{#IS_TEMPLATE}}
13
- "icon": "images/pz-text-input-active.svg",
14
- {{/IS_TEMPLATE}}
15
- "properties": [
16
- {
17
- "name": "label",
18
- "label": "Label value",
19
- "format": "TEXT"
20
- },
21
- {
22
- "name": "placeholder",
23
- "label": "Placeholder",
24
- "format": "TEXT"
25
- },
26
- {
27
- "name": "visibility",
28
- "label": "Visible",
29
- "format": "VISIBILITY"
30
- },
31
- {
32
- "name": "disabled",
33
- "label": "Disabled",
34
- "format": "DISABLED"
35
- },
36
- {
37
- "name": "required",
38
- "label": "Required",
39
- "format": "REQUIRED"
40
- }
41
- ],
42
- "defaultConfig": {
43
- {{#IS_PICKLIST}}
44
- "label": "@L $this.label",
45
- "placeholder": "@L Select...",
46
- "listType": "associated",
47
- "datasource": "@ASSOCIATED .$this.name"
48
- {{/IS_PICKLIST}}
49
- {{#IS_BOOLEAN}}
50
- "trueText": "True",
51
- "falseText": "False"
52
- {{/IS_BOOLEAN}}
53
- {{#IS_PHONE}}
54
- "datasource": {
55
- "source": "@DATASOURCE D_pyCountryCallingCodeList.pxResults",
56
- "fields": {
57
- "value": "@P .pyCallingCode"
58
- }
59
- }
60
- {{/IS_PHONE}}
61
- }
62
- }
@@ -1,44 +0,0 @@
1
- import { useState } from 'react';
2
- import { withKnobs, text, boolean } from '@storybook/addon-knobs';
3
-
4
- import {{COMPONENT_CLASS_NAME}} from './index.jsx';
5
-
6
- export default {
7
- title: '{{COMPONENT_CLASS_NAME}}',
8
- decorators: [withKnobs],
9
- component: {{COMPONENT_CLASS_NAME}}
10
- };
11
-
12
- export const base{{COMPONENT_CLASS_NAME}} = () => {
13
- const [value, setValue] = useState('test value');
14
-
15
- const props = {
16
- getPConnect: () => {
17
- return {
18
- getActionsApi: () => {
19
- return {
20
- updateFieldValue: (propName, value) => {
21
- setValue(value);
22
- }
23
- };
24
- },
25
- getStateProps: () => {
26
- return { value: '.name' };
27
- }
28
- };
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')
37
- };
38
-
39
- return (
40
- <>
41
- <{{COMPONENT_CLASS_NAME}} {...props} />
42
- </>
43
- );
44
- };
@@ -1,55 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { Input, Label } from '@pega/cosmos-react-core';
3
-
4
- import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
5
-
6
- const {{COMPONENT_CLASS_NAME}} = props => {
7
- const { getPConnect, value, placeholder, disabled, readOnly, required, label, testId } = props;
8
-
9
- const pConn = getPConnect();
10
- const actions = pConn.getActionsApi();
11
- const propName = pConn?.getStateProps()?.value;
12
-
13
- const handleOnChange = event => {
14
- const { value: updatedValue } = event.target;
15
- actions.updateFieldValue(propName, updatedValue);
16
- };
17
-
18
- return (
19
- <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
20
- <Label>{label}</Label>
21
- <Input
22
- type='text'
23
- value={value}
24
- placeholder={placeholder}
25
- disabled={disabled}
26
- readOnly={readOnly}
27
- required={required}
28
- onChange={handleOnChange}
29
- testId={testId}
30
- />
31
- </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
32
- );
33
- };
34
-
35
- {{COMPONENT_CLASS_NAME}}.defaultProps = {
36
- value: '',
37
- placeholder: '',
38
- disabled: false,
39
- readOnly: false,
40
- required: false,
41
- testId: null
42
- };
43
-
44
- {{COMPONENT_CLASS_NAME}}.propTypes = {
45
- label: PropTypes.string,
46
- value: PropTypes.string,
47
- placeholder: PropTypes.string,
48
- getPConnect: PropTypes.func.isRequired,
49
- disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
50
- readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
51
- required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
52
- testId: PropTypes.string
53
- };
54
-
55
- export default {{COMPONENT_CLASS_NAME}};
@@ -1,7 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- export default styled.div(() => {
4
- return css`
5
- margin: 8px 0;
6
- `;
7
- });