@pega/custom-dx-components 0.24.15 → 0.242.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.
- package/package.json +1 -1
- package/src/cli.js +32 -2
- package/src/constants.js +9 -0
- package/src/tasks/authenticate/index.js +12 -1
- package/src/tasks/build-lib/helper.js +71 -0
- package/src/tasks/build-lib/index.js +165 -0
- package/src/tasks/create/index.js +59 -6
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/HighlightRender.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.tsx.mustache +46 -13
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/HighlightRender.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache +46 -12
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/index.tsx.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/index.tsx.mustache +1 -0
- package/src/tasks/create-all/index.js +57 -6
- package/src/tasks/delete/index.js +8 -2
- package/src/tasks/delete-all/index.js +8 -2
- package/src/tasks/delete-lib/helper.js +75 -0
- package/src/tasks/delete-lib/index.js +97 -0
- package/src/tasks/index.js +5 -0
- package/src/tasks/init/template/package.json.mustache +32 -9
- package/src/tasks/init/template/tasks.config.json +3 -2
- package/src/tasks/list/index.js +9 -3
- package/src/tasks/list-lib/helper.js +72 -0
- package/src/tasks/list-lib/index.js +75 -0
- package/src/tasks/promote-webpack/index.js +8 -1
- package/src/tasks/promote-webpack/webpack.config.js +26 -0
- package/src/tasks/publish/index.js +8 -1
- package/src/tasks/publish-all/index.js +8 -1
- package/src/tasks/publish-lib/helper.js +53 -0
- package/src/tasks/publish-lib/index.js +212 -0
- package/src/tasks/rename-lib/index.js +353 -0
- package/src/tasks/revert-webpack/index.js +8 -1
- package/src/util.js +201 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/index.tsx +2 -2
package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
5
|
import { Text, FieldValueList, Button, DateTimeDisplay, useTheme } from '@pega/cosmos-react-core';
|
|
6
6
|
import {{COMPONENT_CLASS_NAME}} from './index';
|
|
7
|
-
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved } from './mock';
|
|
7
|
+
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved, operatorDetails, configProps } from './mock';
|
|
8
8
|
import StatusWorkRenderer from './StatusWork';
|
|
9
|
+
import Operator from './Operator';
|
|
9
10
|
|
|
10
11
|
const meta: Meta<typeof {{COMPONENT_CLASS_NAME}}> = {
|
|
11
12
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
@@ -19,6 +20,28 @@ const meta: Meta<typeof {{COMPONENT_CLASS_NAME}}> = {
|
|
|
19
20
|
export default meta;
|
|
20
21
|
type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
|
|
21
22
|
|
|
23
|
+
if (!window.PCore) {
|
|
24
|
+
window.PCore = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
window.PCore.getLocaleUtils = () => {
|
|
28
|
+
return {
|
|
29
|
+
getLocaleValue: value => {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
window.PCore.getUserApi = () => {
|
|
36
|
+
return {
|
|
37
|
+
getOperatorDetails: () => {
|
|
38
|
+
return new Promise(resolve => {
|
|
39
|
+
resolve(operatorDetails);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
22
45
|
const Region = props => {
|
|
23
46
|
return <></>;
|
|
24
47
|
};
|
|
@@ -58,19 +81,30 @@ const renderField = resolvedProps => {
|
|
|
58
81
|
|
|
59
82
|
if (displayAsStatus === true) val = <StatusWorkRenderer value={value} key={key} />;
|
|
60
83
|
|
|
84
|
+
const [_label] =
|
|
85
|
+
label === 'Create operator'
|
|
86
|
+
? [configProps.createLabel, configProps.createOperator, configProps.createDateTime]
|
|
87
|
+
: label === 'Update operator'
|
|
88
|
+
? [configProps.updateLabel, configProps.updateOperator, configProps.updateDateTime]
|
|
89
|
+
: [configProps.resolveLabel, configProps.resolveOperator, configProps.resolveDateTime];
|
|
90
|
+
|
|
61
91
|
if (label === 'Create Operator')
|
|
62
92
|
val = (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
93
|
+
<Operator
|
|
94
|
+
label={configProps.hideLabel ? '' : _label}
|
|
95
|
+
name={configProps.createOperator.userName}
|
|
96
|
+
id={configProps.createOperator.userId}
|
|
97
|
+
value={undefined}
|
|
98
|
+
validatemessage=''
|
|
99
|
+
hideLabel={false}
|
|
100
|
+
readOnly={false}
|
|
101
|
+
required={false}
|
|
102
|
+
disabled={false}
|
|
103
|
+
externalUser={undefined}
|
|
104
|
+
metaObj={undefined}
|
|
105
|
+
testId=''
|
|
106
|
+
helperText=''
|
|
107
|
+
/>
|
|
74
108
|
);
|
|
75
109
|
|
|
76
110
|
if (variant === 'inline') {
|
|
@@ -35,7 +35,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
35
35
|
const numRegions = getAllFields(getPConnect)?.length;
|
|
36
36
|
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
37
37
|
|
|
38
|
-
const gridContainer: GridContainerProps = { colGap:
|
|
38
|
+
const gridContainer: GridContainerProps = { colGap: 6 };
|
|
39
39
|
gridContainer.cols = gridRepeat;
|
|
40
40
|
gridContainer.alignItems = 'start';
|
|
41
41
|
|
|
@@ -75,7 +75,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
75
75
|
{children.map((child: any, i: number) => (
|
|
76
76
|
<Flex
|
|
77
77
|
// @ts-ignore
|
|
78
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
78
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
79
79
|
key={`r-${i + 1}`}
|
|
80
80
|
>
|
|
81
81
|
<DetailsRender child={child} />
|
|
@@ -233,3 +233,58 @@ export const regionChildrenResolved = [
|
|
|
233
233
|
key: 'SLA Start Time'
|
|
234
234
|
}
|
|
235
235
|
];
|
|
236
|
+
|
|
237
|
+
export const operatorDetails = {
|
|
238
|
+
data: {
|
|
239
|
+
pzLoadTime: 'January 18, 2023 10:33:19 AM EST',
|
|
240
|
+
pzPageNameHash: '_pa1519192551088960pz',
|
|
241
|
+
pyOperatorInfo: {
|
|
242
|
+
pyUserName: 'french DigV2',
|
|
243
|
+
pyPosition: '',
|
|
244
|
+
pyImageInsKey: '',
|
|
245
|
+
pySkills: [
|
|
246
|
+
{
|
|
247
|
+
pySkillName: '',
|
|
248
|
+
pzIndexOwnerKey: 'DATA-ADMIN-OPERATOR-ID FRENCHTEST.DIGV2',
|
|
249
|
+
pySkillRating: 0
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
pyReportToUserName: '',
|
|
253
|
+
pyReportTo: '',
|
|
254
|
+
pyOrganization: 'DXIL',
|
|
255
|
+
pyTitle: '',
|
|
256
|
+
pyLabel: 'frenchTest.DigV2',
|
|
257
|
+
pyEmailAddress: 'User@DigV2',
|
|
258
|
+
pyTelephone: ''
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
status: 200,
|
|
262
|
+
statusText: '',
|
|
263
|
+
headers: {
|
|
264
|
+
'content-length': '435',
|
|
265
|
+
'content-type': 'application/json;charset=UTF-8'
|
|
266
|
+
},
|
|
267
|
+
request: {}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
export const configProps = {
|
|
271
|
+
label: 'Create operator',
|
|
272
|
+
createLabel: 'Created',
|
|
273
|
+
updateLabel: 'Updated',
|
|
274
|
+
updateDateTime: '2023-01-16T14:53:33.280Z',
|
|
275
|
+
createDateTime: '2023-01-16T14:53:33.198Z',
|
|
276
|
+
updateOperator: {
|
|
277
|
+
userId: 'admin@mediaco',
|
|
278
|
+
userName: 'admin'
|
|
279
|
+
},
|
|
280
|
+
createOperator: {
|
|
281
|
+
userId: 'admin@mediaco',
|
|
282
|
+
userName: 'admin'
|
|
283
|
+
},
|
|
284
|
+
resolveLabel: '',
|
|
285
|
+
resolveOperator: '',
|
|
286
|
+
resolveDateTime: '',
|
|
287
|
+
hideLabel: true,
|
|
288
|
+
key: '_532zx1dah',
|
|
289
|
+
displayMode: 'LABELS_LEFT'
|
|
290
|
+
};
|
|
@@ -40,7 +40,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
40
40
|
{children.map((child: any, i: number) => (
|
|
41
41
|
<Flex
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
43
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
44
44
|
key={`r-${i + 1}`}
|
|
45
45
|
>
|
|
46
46
|
<DetailsRender child={child} />
|
|
@@ -22,7 +22,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
22
22
|
|
|
23
23
|
const numRegions = children?.length;
|
|
24
24
|
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
25
|
-
const gridContainer = {"colGap" :
|
|
25
|
+
const gridContainer = {"colGap" : 6};
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
gridContainer.cols = gridRepeat;
|
|
28
28
|
// @ts-ignore
|
|
@@ -42,7 +42,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
42
42
|
{children.map((child: any, i: number) => (
|
|
43
43
|
<Flex
|
|
44
44
|
// @ts-ignore
|
|
45
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
45
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
46
46
|
key={`r-${i + 1}`}
|
|
47
47
|
>
|
|
48
48
|
<DetailsRender child={child} />
|
|
@@ -116,6 +116,7 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
|
|
|
116
116
|
// only retrieve table data if table is shown
|
|
117
117
|
if (showTable) {
|
|
118
118
|
PCore.getDataPageUtils()
|
|
119
|
+
// @ts-ignore
|
|
119
120
|
.getDataAsync(dataViewName, context, params, null, null)
|
|
120
121
|
// @ts-ignore
|
|
121
122
|
.then((response: any) => {
|
|
@@ -17,10 +17,14 @@ import { checkPathAccess, showVersion ,
|
|
|
17
17
|
getComponents,
|
|
18
18
|
getComponentDefaults,
|
|
19
19
|
sanitize,
|
|
20
|
-
validateSemver
|
|
20
|
+
validateSemver,
|
|
21
|
+
updateComponentDefaultLibrary,
|
|
22
|
+
updateComponentDefaultVersion,
|
|
23
|
+
copyFileToShared,
|
|
24
|
+
getLibraryBased
|
|
21
25
|
} from '../../util.js';
|
|
22
26
|
|
|
23
|
-
import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION } from '../../constants.js';
|
|
27
|
+
import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION, SHARED_FILE_NAMES } from '../../constants.js';
|
|
24
28
|
|
|
25
29
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
26
30
|
|
|
@@ -28,6 +32,8 @@ const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME)
|
|
|
28
32
|
|
|
29
33
|
const copy = promisify(ncp);
|
|
30
34
|
|
|
35
|
+
const isLibraryBased = await getLibraryBased();
|
|
36
|
+
|
|
31
37
|
const copyComponentTemplate = async (options) => {
|
|
32
38
|
if (options.targetDirectory) {
|
|
33
39
|
return copy(options.templateDirectory, options.targetDirectory, {
|
|
@@ -99,6 +105,10 @@ export const compileMustacheTemplates = async (
|
|
|
99
105
|
allowedApplications = [].concat(allowedApplications);
|
|
100
106
|
}
|
|
101
107
|
|
|
108
|
+
const orgLib = organization.concat("_").concat(library);
|
|
109
|
+
const componentLabelOrgLib = componentLabel.concat(` (${orgLib})`);
|
|
110
|
+
const desciptionOrgLib = description == null || description === "" ? componentLabelOrgLib : description.concat(` (${orgLib})`);
|
|
111
|
+
|
|
102
112
|
allowedApplications = allowedApplications.filter((el) => !!el.trim()).map((el) => el.trim());
|
|
103
113
|
files.forEach((file) => {
|
|
104
114
|
const filePath = path.join(componentDirectory, file);
|
|
@@ -106,7 +116,7 @@ export const compileMustacheTemplates = async (
|
|
|
106
116
|
const output = compileMustacheTemplate(filePath, {
|
|
107
117
|
COMPONENT_KEY: componentKey,
|
|
108
118
|
COMPONENT_NAME: componentName,
|
|
109
|
-
COMPONENT_LABEL: componentLabel,
|
|
119
|
+
COMPONENT_LABEL: isLibraryBased ? componentLabelOrgLib : componentLabel,
|
|
110
120
|
COMPONENT_CLASS_NAME: componentClassName,
|
|
111
121
|
ORGANIZATION: organization,
|
|
112
122
|
VERSION: version,
|
|
@@ -114,14 +124,46 @@ export const compileMustacheTemplates = async (
|
|
|
114
124
|
ALLOWEDAPPS: JSON.stringify(allowedApplications),
|
|
115
125
|
TYPE: type,
|
|
116
126
|
SUB_TYPE: JSON.stringify(mustacheSubType),
|
|
117
|
-
DESCRIPTION:
|
|
127
|
+
DESCRIPTION: isLibraryBased ? desciptionOrgLib : description,
|
|
118
128
|
IS_TEMPLATE: isTemplate,
|
|
119
129
|
IS_PICKLIST: isPicklist,
|
|
120
130
|
IS_BOOLEAN: isBool,
|
|
121
131
|
IS_PHONE: isPhone
|
|
122
132
|
});
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
|
|
134
|
+
const realFileName = file.replace('.mustache', '');
|
|
135
|
+
if ( isLibraryBased) {
|
|
136
|
+
if (SHARED_FILE_NAMES.includes(realFileName)) {
|
|
137
|
+
// write to shared
|
|
138
|
+
copyFileToShared(realFileName, output);
|
|
139
|
+
|
|
140
|
+
// delete file from main components
|
|
141
|
+
fs.rmSync(filePath);
|
|
142
|
+
}
|
|
143
|
+
else if (realFileName === "index.tsx" || realFileName === "index.ts" ) {
|
|
144
|
+
// going to search for shared file names an change the import path
|
|
145
|
+
let newOutput = output;
|
|
146
|
+
for (const index in SHARED_FILE_NAMES) {
|
|
147
|
+
const sFileName = SHARED_FILE_NAMES[index].split(".")[0];
|
|
148
|
+
const orgPath = "./".concat(sFileName);
|
|
149
|
+
const newPath = "../shared/".concat(sFileName);
|
|
150
|
+
|
|
151
|
+
newOutput = newOutput.replaceAll(orgPath, newPath);
|
|
152
|
+
}
|
|
153
|
+
fs.writeFileSync(filePath, newOutput);
|
|
154
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
fs.writeFileSync(filePath, output);
|
|
158
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
fs.writeFileSync(filePath, output);
|
|
164
|
+
fs.renameSync(filePath, filePath.replace('.mustache', ''));
|
|
165
|
+
}
|
|
166
|
+
|
|
125
167
|
});
|
|
126
168
|
};
|
|
127
169
|
|
|
@@ -148,6 +190,15 @@ export const validateCompile = async (
|
|
|
148
190
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
149
191
|
const originalFramework = framework;
|
|
150
192
|
|
|
193
|
+
// check of library or version has changed from default, if so, update componentDefaults
|
|
194
|
+
const componentDefaults = await getComponentDefaults();
|
|
195
|
+
if (componentDefaults.library == null || componentDefaults.library !== library) {
|
|
196
|
+
await updateComponentDefaultLibrary(library);
|
|
197
|
+
}
|
|
198
|
+
if (componentDefaults.version == null || componentDefaults.version !== version) {
|
|
199
|
+
await updateComponentDefaultVersion(version);
|
|
200
|
+
}
|
|
201
|
+
|
|
151
202
|
if (isLaunchpad) {
|
|
152
203
|
framework = "Launchpad";
|
|
153
204
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
|
|
3
|
-
import { showVersion } from '../../util.js';
|
|
3
|
+
import { showVersion, getLibraryBased } from '../../util.js';
|
|
4
4
|
|
|
5
5
|
import { deleteLocalComponents, SOURCE_OF_COMPONENT_TYPES, deleteServerComponents, getDeleteComponentsQuestions } from './helper.js';
|
|
6
6
|
|
|
7
|
+
const isLibraryBased = await getLibraryBased();
|
|
8
|
+
|
|
7
9
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
8
10
|
switch (sourceOfComponents) {
|
|
9
11
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
@@ -25,7 +27,11 @@ export default async (options) => {
|
|
|
25
27
|
showVersion();
|
|
26
28
|
|
|
27
29
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
28
|
-
if (
|
|
30
|
+
if (isLibraryBased) {
|
|
31
|
+
sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
32
|
+
await deleteComponentsFn(sourceOfComponentsOption, null, options);
|
|
33
|
+
}
|
|
34
|
+
else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
29
35
|
sourceOfComponentsOption = options.params[3];
|
|
30
36
|
await deleteComponentsFn(sourceOfComponentsOption, null, options);
|
|
31
37
|
} else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
|
|
3
|
-
import { showVersion } from '../../util.js';
|
|
3
|
+
import { showVersion, getLibraryBased } from '../../util.js';
|
|
4
4
|
|
|
5
5
|
import { deleteLocalComponents, SOURCE_OF_COMPONENT_TYPES, deleteServerComponents, getDeleteComponentsQuestions } from './helper.js';
|
|
6
6
|
|
|
7
|
+
const isLibraryBased = await getLibraryBased();
|
|
8
|
+
|
|
7
9
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
8
10
|
switch (sourceOfComponents) {
|
|
9
11
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
@@ -25,7 +27,11 @@ export default async (options) => {
|
|
|
25
27
|
showVersion();
|
|
26
28
|
|
|
27
29
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
28
|
-
if (
|
|
30
|
+
if (isLibraryBased) {
|
|
31
|
+
sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
32
|
+
await deleteComponentsFn(sourceOfComponentsOption, null, options);
|
|
33
|
+
}
|
|
34
|
+
else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
29
35
|
sourceOfComponentsOption = options.params[3];
|
|
30
36
|
await deleteComponentsFn(sourceOfComponentsOption, null, options);
|
|
31
37
|
} else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import AdmZip from 'adm-zip';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
getPegaServerConfig,
|
|
9
|
+
checkPathAccess,
|
|
10
|
+
getComponentDefaults,
|
|
11
|
+
} from '../../util.js';
|
|
12
|
+
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
|
|
13
|
+
|
|
14
|
+
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
15
|
+
SERVER: 'Server',
|
|
16
|
+
LOCAL: 'Local'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
21
|
+
|
|
22
|
+
export const getOrgLib = async () => {
|
|
23
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
24
|
+
|
|
25
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
26
|
+
|
|
27
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
28
|
+
data = data && JSON.parse(data);
|
|
29
|
+
|
|
30
|
+
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
31
|
+
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const componentData = data[COMPONENTS_PATH];
|
|
36
|
+
|
|
37
|
+
let library;
|
|
38
|
+
({ library } = componentData);
|
|
39
|
+
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
40
|
+
|
|
41
|
+
const componentDefaults = await getComponentDefaults();
|
|
42
|
+
componentDefaults.library = library;
|
|
43
|
+
componentDefaults.organization = organization;
|
|
44
|
+
|
|
45
|
+
return componentDefaults;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const getDeleteLibraryQuestions = async () => {
|
|
49
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
name: 'sourceOfLibrary',
|
|
55
|
+
type: 'rawlist',
|
|
56
|
+
message: 'Delete library from Server or Local ?',
|
|
57
|
+
choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
|
|
58
|
+
default: defaultPegaConfig.sourceOfComponents,
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export const getLibraryVersionQuestion = async(libraryName, libVersions) => {
|
|
65
|
+
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
name: 'version',
|
|
69
|
+
type: 'rawlist',
|
|
70
|
+
message: `Select ${chalk.green.bold(`${libraryName}`)} library version (or ALL) to delete`,
|
|
71
|
+
choices: libVersions
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import { showVersion, getC11NB2STokenAndStaticServer, getLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion } from '../../util.js';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import { deleteLib } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
9
|
+
|
|
10
|
+
import { getDeleteLibraryQuestions, getLibraryVersionQuestion, getOrgLib, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
|
|
11
|
+
|
|
12
|
+
const isLibraryBased = await getLibraryBased();
|
|
13
|
+
|
|
14
|
+
export default async (options) => {
|
|
15
|
+
if (!isLibraryBased) {
|
|
16
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
17
|
+
process.exit();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
showVersion();
|
|
21
|
+
|
|
22
|
+
let sourceOfLibrary;
|
|
23
|
+
let organization;
|
|
24
|
+
let library;
|
|
25
|
+
let version;
|
|
26
|
+
let devBuild;
|
|
27
|
+
|
|
28
|
+
const compDef = await getOrgLib();
|
|
29
|
+
organization = compDef.organization;
|
|
30
|
+
library = compDef.library;
|
|
31
|
+
const libraryName = organization.concat("_").concat(library);
|
|
32
|
+
|
|
33
|
+
if (options.params.length >= 5) {
|
|
34
|
+
sourceOfLibrary = options.param[3];
|
|
35
|
+
version = options.params[4];
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
|
|
40
|
+
const questions = await getDeleteLibraryQuestions();
|
|
41
|
+
const answers = await inquirer.prompt(questions);
|
|
42
|
+
({ sourceOfLibrary } = answers);
|
|
43
|
+
|
|
44
|
+
if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
|
|
45
|
+
// local
|
|
46
|
+
|
|
47
|
+
let libVersions = await getLibraryVersions(libraryName);
|
|
48
|
+
|
|
49
|
+
if (libVersions.length > 0) {
|
|
50
|
+
// ALL option
|
|
51
|
+
libVersions.unshift('ALL');
|
|
52
|
+
|
|
53
|
+
const versionQuestions = await getLibraryVersionQuestion(libraryName, libVersions);
|
|
54
|
+
const versionAnswers = await inquirer.prompt(versionQuestions);
|
|
55
|
+
|
|
56
|
+
({version} = versionAnswers);
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// No library with that name
|
|
61
|
+
console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
|
|
72
|
+
if (version === 'ALL') {
|
|
73
|
+
await deleteLocalLibrary(libraryName);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
await deleteLocalLibraryVersion(libraryName, version);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// server
|
|
82
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
83
|
+
|
|
84
|
+
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
85
|
+
console.log(chalk.redBright("Need to authenticate, missing services token.\nDeleting a library requires authentication to acquire a token to delete."));
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
await deleteLib(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
return true;
|
|
97
|
+
};
|
package/src/tasks/index.js
CHANGED
|
@@ -2,17 +2,22 @@ export { default as createComponent } from './create/index.js';
|
|
|
2
2
|
export { default as createAllComponents } from './create-all/index.js';
|
|
3
3
|
export { default as deleteComponent } from './delete/index.js';
|
|
4
4
|
export { default as deleteAllComponents } from './delete-all/index.js';
|
|
5
|
+
export { default as deleteLibrary } from './delete-lib/index.js';
|
|
5
6
|
export { default as initProject } from './init/index.js';
|
|
6
7
|
export { default as promoteWebPack } from './promote-webpack/index.js';
|
|
7
8
|
export { default as publishComponent } from './publish/index.js';
|
|
8
9
|
export { default as publishAllComponents } from './publish-all/index.js';
|
|
10
|
+
export { default as publishLibrary } from './publish-lib/index.js';
|
|
9
11
|
export { default as renameComponent } from './rename/index.js';
|
|
12
|
+
export { default as renameLibrary } from './rename-lib/index.js';
|
|
10
13
|
export { default as revertWebPack } from './revert-webpack/index.js';
|
|
11
14
|
export { default as listComponents } from './list/index.js';
|
|
15
|
+
export { default as listLibrary } from './list-lib/index.js';
|
|
12
16
|
export { default as updateComponent } from './update/index.js';
|
|
13
17
|
export { default as validate } from './validator/index.js';
|
|
14
18
|
export { default as authenticate } from './authenticate/index.js';
|
|
15
19
|
export { default as upgrade } from './upgrade/index.js';
|
|
16
20
|
export { default as buildComponent } from './build-comp/index.js';
|
|
17
21
|
export { default as buildAllComponents } from './build-all/index.js';
|
|
22
|
+
export { default as buildLibrary } from './build-lib/index.js';
|
|
18
23
|
export { default as buildJestAssets } from './build-jest-assets/index.js';
|
|
@@ -11,16 +11,21 @@
|
|
|
11
11
|
"authenticate": "custom-dx-components authenticate",
|
|
12
12
|
"buildComponent": "custom-dx-components buildComponent",
|
|
13
13
|
"buildAllComponents": "custom-dx-components buildAllComponents",
|
|
14
|
+
"buildLibrary": "custom-dx-components buildLibrary",
|
|
14
15
|
"create": "custom-dx-components create",
|
|
15
16
|
"createAll": "custom-dx-components createAll",
|
|
16
17
|
"publish": "custom-dx-components publish",
|
|
17
18
|
"publishAll": "custom-dx-components publishAll",
|
|
19
|
+
"publishLibrary": "custom-dx-components publishLibrary",
|
|
18
20
|
"rename": "custom-dx-components rename",
|
|
21
|
+
"renameLibrary": "custom-dx-components renameLibrary",
|
|
19
22
|
"list": "custom-dx-components list",
|
|
23
|
+
"listLibrary": "custom-dx-components listLibrary",
|
|
20
24
|
"validate-schema": "custom-dx-components validateSchema",
|
|
21
25
|
"update": "custom-dx-components update",
|
|
22
26
|
"delete": "custom-dx-components delete",
|
|
23
27
|
"deleteAll": "custom-dx-components deleteAll",
|
|
28
|
+
"deleteLibrary": "custom-dx-components deleteLibrary",
|
|
24
29
|
"promoteWebPack": "custom-dx-components promoteWebPack",
|
|
25
30
|
"revertWebPack": "custom-dx-components revertWebPack",
|
|
26
31
|
"_internal-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",
|
|
@@ -49,30 +54,47 @@
|
|
|
49
54
|
],
|
|
50
55
|
"author": "",
|
|
51
56
|
"license": "Enter License",
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@babel/cli": "^7.23.0",
|
|
59
|
+
"@babel/core": "^7.23.3",
|
|
60
|
+
"@babel/preset-env": "^7.23.3",
|
|
61
|
+
"@babel/preset-react": "^7.23.3",
|
|
62
|
+
"@material-ui/core": "^4.12.4",
|
|
63
|
+
"@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.10",
|
|
64
|
+
"@pega/cosmos-react-condition-builder": "7.0.0-build.6.0",
|
|
65
|
+
"@pega/cosmos-react-core": "7.0.0-build.6.0",
|
|
66
|
+
"@pega/cosmos-react-work": "7.0.0-build.6.0",
|
|
67
|
+
"babel-loader": "^9.1.3",
|
|
57
68
|
"dayjs": "^1.11.10",
|
|
69
|
+
"lodash": "^4.17.21",
|
|
58
70
|
"lodash.get": "^4.4.2",
|
|
71
|
+
"npm": "^10.5.0",
|
|
59
72
|
"polished": "^4.2.2",
|
|
60
73
|
"prop-types": "^15.8.1",
|
|
61
74
|
"react": "^17.0.2",
|
|
62
75
|
"react-autosuggest": "^10.1.0",
|
|
63
76
|
"react-dom": "^17.0.2",
|
|
64
|
-
"react-is": "^
|
|
77
|
+
"react-is": "^18.2.0",
|
|
65
78
|
"react-player": "^2.10.1",
|
|
66
79
|
"react-redux": "^7.2.6",
|
|
80
|
+
"serve": "^14.2.1",
|
|
81
|
+
"shelljs": "^0.8.5",
|
|
67
82
|
"styled-components": "^5.3.5",
|
|
68
|
-
"ts-loader": "^9.5.1"
|
|
83
|
+
"ts-loader": "^9.5.1",
|
|
84
|
+
"webpack": "5.74.0",
|
|
85
|
+
"webpack-cli": "^5.1.4"
|
|
69
86
|
},
|
|
70
87
|
"devDependencies": {
|
|
88
|
+
"@babel/cli": "^7.23.0",
|
|
89
|
+
"@babel/core": "^7.23.3",
|
|
90
|
+
"@babel/preset-env": "^7.23.3",
|
|
91
|
+
"@babel/preset-react": "^7.23.3",
|
|
71
92
|
"@pega/configs": "^0.6.0",
|
|
72
|
-
"@pega/custom-dx-components": "0.
|
|
73
|
-
"@pega/pcore-pconnect-typedefs": "
|
|
93
|
+
"@pega/custom-dx-components": "0.242.1",
|
|
94
|
+
"@pega/pcore-pconnect-typedefs": "2.0.0",
|
|
74
95
|
"@storybook/addon-actions": "^7.6.7",
|
|
75
96
|
"@storybook/addon-essentials": "^7.6.7",
|
|
97
|
+
"@storybook/addon-knobs": "^7.0.2",
|
|
76
98
|
"@storybook/addon-links": "^7.6.7",
|
|
77
99
|
"@storybook/addon-storysource": "^7.6.7",
|
|
78
100
|
"@storybook/react": "^7.6.7",
|
|
@@ -84,6 +106,7 @@
|
|
|
84
106
|
"@types/react-dom": "^17.0.11",
|
|
85
107
|
"@types/styled-components": "^5.1.34",
|
|
86
108
|
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
|
109
|
+
"babel-loader": "^9.1.3",
|
|
87
110
|
"eslint": "^8.56.0",
|
|
88
111
|
"eslint-plugin-import": "^2.29.1",
|
|
89
112
|
"eslint-plugin-jest": "^27.6.1",
|