@pega/custom-dx-components 2.0.10 → 2.0.12
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 +73 -57
- 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 +2 -4
- 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 +29 -18
- 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 +39 -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 +39 -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 +92 -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 +125 -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/styles.js.mustache +1 -1
- 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/CASE/styles.js.mustache +1 -1
- 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/styles.js.mustache +1 -1
- 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/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +1 -1
- 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/package.json.mustache +19 -4
- 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
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
} from '../../util.js';
|
|
14
14
|
import { getComponentsFromServer } from '../list/helper.js';
|
|
15
15
|
|
|
16
|
+
|
|
17
|
+
|
|
16
18
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
17
19
|
SERVER: 'Server',
|
|
18
20
|
LOCAL: 'Local'
|
|
@@ -92,6 +94,8 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
92
94
|
choices: choicesArr
|
|
93
95
|
});
|
|
94
96
|
await deleteServerComponent(answers.componentToDelete);
|
|
97
|
+
|
|
98
|
+
|
|
95
99
|
} else {
|
|
96
100
|
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
|
|
97
101
|
}
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
getDeleteComponentsQuestions
|
|
10
10
|
} from './helper.js';
|
|
11
11
|
|
|
12
|
+
import { showVersion } from '../../util.js';
|
|
13
|
+
|
|
12
14
|
const deleteComponentsFn = async (sourceOfComponents, answers) => {
|
|
13
15
|
switch (sourceOfComponents) {
|
|
14
16
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
@@ -27,6 +29,8 @@ const deleteComponentsFn = async (sourceOfComponents, answers) => {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export default async options => {
|
|
32
|
+
showVersion();
|
|
33
|
+
|
|
30
34
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
31
35
|
if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
32
36
|
sourceOfComponentsOption = options.params[3];
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
|
|
5
|
+
import { LIST_COMPONENT_SERVICE_REST_ENDPOINT } from '../../constants.js';
|
|
6
|
+
import {
|
|
7
|
+
constructCompleteUrl,
|
|
8
|
+
deleteLocalComponent,
|
|
9
|
+
deleteServerComponent,
|
|
10
|
+
getComponents,
|
|
11
|
+
getPegaServerConfig,
|
|
12
|
+
validateRulesetVersion,
|
|
13
|
+
nodeFetch
|
|
14
|
+
} from '../../util.js';
|
|
15
|
+
import { getComponentsFromServer } from '../list/helper.js';
|
|
16
|
+
|
|
17
|
+
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
18
|
+
SERVER: 'Server',
|
|
19
|
+
LOCAL: 'Local'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const getDeleteComponentsQuestions = async (options, sourceOfComponentsOption) => {
|
|
23
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
name: 'sourceOfComponents',
|
|
29
|
+
type: 'rawlist',
|
|
30
|
+
message: 'Delete components from Server or Local ?',
|
|
31
|
+
choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
|
|
32
|
+
default: defaultPegaServerConfig.sourceOfComponents,
|
|
33
|
+
when() {
|
|
34
|
+
return !options.params[3];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export const deleteLocalComponents = async sourceOfComponents => {
|
|
43
|
+
const localComponents = await getComponents();
|
|
44
|
+
|
|
45
|
+
for (var index in localComponents) {
|
|
46
|
+
console.log(chalk.bold.green(localComponents[index]));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (localComponents.length > 0) {
|
|
50
|
+
const answers = await inquirer.prompt([
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
name: 'confirmDeletion',
|
|
54
|
+
type: 'confirm',
|
|
55
|
+
message: 'Delete all local ?',
|
|
56
|
+
default: false
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
if (answers.confirmDeletion) {
|
|
60
|
+
for (var index in localComponents) {
|
|
61
|
+
var componentToDelete = localComponents[index];
|
|
62
|
+
//console.log(chalk.bold.green("Deleting: " + componentToDelete));
|
|
63
|
+
await deleteLocalComponent(componentToDelete);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
72
|
+
const spinner = ora('Fetching components from server').start();
|
|
73
|
+
const data = await getComponentsFromServer(answers);
|
|
74
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
75
|
+
|
|
76
|
+
const serverComponents = JSON.parse(data);
|
|
77
|
+
spinner.stop();
|
|
78
|
+
if (serverComponents && serverComponents.pxResults?.length > 0) {
|
|
79
|
+
const choicesArr = serverComponents.pxResults.map(({ label, pyRuleSet, pyRuleSetVersion }) => {
|
|
80
|
+
const name = `${standardizeStr(label, 45)} ${standardizeStr(pyRuleSet, 30)} ${standardizeStr(
|
|
81
|
+
pyRuleSetVersion,
|
|
82
|
+
20
|
|
83
|
+
)}`;
|
|
84
|
+
|
|
85
|
+
const value = `${label}~|~${pyRuleSet}~|~${pyRuleSetVersion}`;
|
|
86
|
+
const short = `Selected component : ${chalk.redBright(
|
|
87
|
+
`${label} ${pyRuleSet} : ${pyRuleSetVersion}`
|
|
88
|
+
)}`;
|
|
89
|
+
|
|
90
|
+
return { name, value, short };
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const selectedComp = await inquirer.prompt([
|
|
94
|
+
{
|
|
95
|
+
name: 'rulesetName',
|
|
96
|
+
message: 'Enter ruleset name',
|
|
97
|
+
default: defaultPegaConfig.rulesetName,
|
|
98
|
+
validate: value => {
|
|
99
|
+
if (value.trim()) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return 'Ruleset name cannot be empty';
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'rulesetVersion',
|
|
107
|
+
message: 'Enter ruleset version',
|
|
108
|
+
default: defaultPegaConfig.rulesetVersion,
|
|
109
|
+
validate: value => {
|
|
110
|
+
if (validateRulesetVersion(value)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return 'Please provide compatible version e.g 01-01-01';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
]);
|
|
117
|
+
|
|
118
|
+
for (var index in choicesArr) {
|
|
119
|
+
var componentToDelete = choicesArr[index].value;
|
|
120
|
+
var arData = componentToDelete.split("~|~");
|
|
121
|
+
if (arData[1] == selectedComp.rulesetName && arData[2] == selectedComp.rulesetVersion) {
|
|
122
|
+
console.log(chalk.bold.green(arData[0]));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
const answers = await inquirer.prompt([
|
|
128
|
+
{
|
|
129
|
+
name: 'confirmDeletion',
|
|
130
|
+
type: 'confirm',
|
|
131
|
+
message: 'Do you want to delete these components ?',
|
|
132
|
+
default: false
|
|
133
|
+
}
|
|
134
|
+
]);
|
|
135
|
+
if (answers.confirmDeletion) {
|
|
136
|
+
for (var index in choicesArr) {
|
|
137
|
+
var componentToDelete = choicesArr[index].value;
|
|
138
|
+
var arData = componentToDelete.split("~|~");
|
|
139
|
+
if (arData[1] == selectedComp.rulesetName && arData[2] == selectedComp.rulesetVersion) {
|
|
140
|
+
await deleteServerComponent(componentToDelete);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/*
|
|
146
|
+
const answers = await inquirer.prompt({
|
|
147
|
+
name: 'componentToDelete',
|
|
148
|
+
type: 'rawlist',
|
|
149
|
+
pageSize: 10,
|
|
150
|
+
message: `Select component to delete \n ${standardizeStr('Rule name', 48)} ${standardizeStr(
|
|
151
|
+
'Ruleset name',
|
|
152
|
+
30
|
|
153
|
+
)} ${standardizeStr('Ruleset version', 22)}`,
|
|
154
|
+
choices: choicesArr
|
|
155
|
+
});
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
/*
|
|
161
|
+
await deleteServerComponent(answers.componentToDelete);
|
|
162
|
+
await deleteFromComponentMap(answers.componentToDelete.split("~")[0]);
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
} else {
|
|
166
|
+
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const standardizeStr = (str, leng) => {
|
|
171
|
+
for (let i = str.length; i <= leng; i++) {
|
|
172
|
+
str += ' ';
|
|
173
|
+
}
|
|
174
|
+
return str;
|
|
175
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
deleteLocalComponents,
|
|
7
|
+
SOURCE_OF_COMPONENT_TYPES,
|
|
8
|
+
deleteServerComponents,
|
|
9
|
+
getDeleteComponentsQuestions
|
|
10
|
+
} from './helper.js';
|
|
11
|
+
|
|
12
|
+
import { showVersion } from '../../util.js';
|
|
13
|
+
|
|
14
|
+
const deleteComponentsFn = async (sourceOfComponents, answers) => {
|
|
15
|
+
switch (sourceOfComponents) {
|
|
16
|
+
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
17
|
+
await deleteLocalComponents(sourceOfComponents);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
case SOURCE_OF_COMPONENT_TYPES.SERVER: {
|
|
21
|
+
await deleteServerComponents(sourceOfComponents, answers);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
default: {
|
|
25
|
+
console.log('Source of components needs to be either Local or Server');
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default async options => {
|
|
32
|
+
showVersion();
|
|
33
|
+
|
|
34
|
+
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
35
|
+
if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
36
|
+
sourceOfComponentsOption = options.params[3];
|
|
37
|
+
await deleteComponentsFn(sourceOfComponentsOption);
|
|
38
|
+
} else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
|
|
39
|
+
sourceOfComponentsOption = options.params[3];
|
|
40
|
+
const questions = await getDeleteComponentsQuestions(options, sourceOfComponentsOption);
|
|
41
|
+
const answers = await inquirer.prompt(questions);
|
|
42
|
+
await deleteComponentsFn(sourceOfComponentsOption, answers);
|
|
43
|
+
} else {
|
|
44
|
+
const questions = await getDeleteComponentsQuestions(options);
|
|
45
|
+
const answers = await inquirer.prompt(questions);
|
|
46
|
+
const { sourceOfComponents } = answers;
|
|
47
|
+
await deleteComponentsFn(sourceOfComponents, answers);
|
|
48
|
+
}
|
|
49
|
+
};
|
package/src/tasks/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { default as createComponent } from './create/index.js';
|
|
2
2
|
export { default as deleteComponent } from './delete/index.js';
|
|
3
|
+
export { default as deleteAllComponents } from './delete-all/index.js';
|
|
3
4
|
export { default as initProject } from './init/index.js';
|
|
4
5
|
export { default as publishComponent } from './publish/index.js';
|
|
6
|
+
export { default as publishAllComponents } from './publish-all/index.js';
|
|
5
7
|
export { default as listComponents } from './list/index.js';
|
|
6
8
|
export { default as updateComponent } from './update/index.js';
|
|
7
9
|
export { default as validate } from './validator/index.js';
|
|
8
10
|
export { default as authenticate } from './authenticate/index.js';
|
|
9
11
|
export { default as upgrade } from './upgrade/index.js';
|
|
12
|
+
export { default as buildComponent } from './build/index.js';
|
package/src/tasks/init/index.js
CHANGED
|
@@ -123,7 +123,7 @@ export default async options => {
|
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
title: installDependenciesText,
|
|
126
|
-
task: () => execPromise('npm i --production=false', { cwd: options.targetDirectory })
|
|
126
|
+
task: () => execPromise('npm i --force --production=false', { cwd: options.targetDirectory })
|
|
127
127
|
}
|
|
128
128
|
],
|
|
129
129
|
{
|
|
@@ -1,10 +1,191 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": ["@pega"],
|
|
3
|
-
"parserOptions": { "project": "tsconfig.json" },
|
|
4
2
|
"root": true,
|
|
5
|
-
"
|
|
3
|
+
"extends": ["@pega"],
|
|
4
|
+
"parserOptions": {
|
|
5
|
+
"project": "tsconfig.json",
|
|
6
|
+
"ecmaVersion": 13
|
|
7
|
+
},
|
|
8
|
+
"settings": {
|
|
9
|
+
"import/resolver": {
|
|
10
|
+
"typescript": {},
|
|
11
|
+
"node": {
|
|
12
|
+
"extensions": [".js", ".jsx"]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"react": {
|
|
16
|
+
"version": "detect"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"ignorePatterns": ["node_modules", "packages/*/lib", "!.storybook", ".storybook/public"],
|
|
6
20
|
"rules": {
|
|
21
|
+
// Prettier recommends running separately from a linter.
|
|
22
|
+
// https://prettier.io/docs/en/integrating-with-linters.html#notes
|
|
7
23
|
"prettier/prettier": "off",
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
|
|
25
|
+
// Disable rules from shared configs we're not ready for yet.
|
|
26
|
+
"sonarjs/cognitive-complexity": "off",
|
|
27
|
+
"sonarjs/no-identical-functions": "off",
|
|
28
|
+
"sonarjs/no-duplicate-string": "off",
|
|
29
|
+
"sonarjs/no-nested-template-literals": "off",
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// JA - Override some default lint handling here
|
|
33
|
+
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
|
|
34
|
+
// "import/extensions": ["warn", "never"], // Turning off for now (see below)
|
|
35
|
+
|
|
36
|
+
//
|
|
37
|
+
// Initial release: turning these off; phase in to "warn" or "error" over time
|
|
38
|
+
// For "quotes" and "@typescript-eslint/quotes", see override below for .ts/.tsx files
|
|
39
|
+
"import/extensions": ["off", "never"],
|
|
40
|
+
"import/named": "off",
|
|
41
|
+
"import/no-cycle": "off",
|
|
42
|
+
"import/no-duplicates": "off",
|
|
43
|
+
"import/no-extraneous-dependencies": "off",
|
|
44
|
+
"import/no-named-as-default": "off",
|
|
45
|
+
"import/no-named-as-default-member": "off",
|
|
46
|
+
"import/no-self-import": "off",
|
|
47
|
+
"import/no-unresolved": "off",
|
|
48
|
+
"import/no-useless-path-segments": "off",
|
|
49
|
+
"import/order": "off",
|
|
50
|
+
|
|
51
|
+
"no-else-return": "off",
|
|
52
|
+
"no-restricted-syntax": "off",
|
|
53
|
+
"no-underscore-dangle": "off",
|
|
54
|
+
|
|
55
|
+
"jsx-a11y/alt-text": "off",
|
|
56
|
+
"jsx-a11y/anchor-is-valid": "off",
|
|
57
|
+
"jsx-a11y/click-events-have-key-events": "off",
|
|
58
|
+
"jsx-a11y/label-has-associated-control": "off",
|
|
59
|
+
"jsx-a11y/no-static-element-interactions": "off",
|
|
60
|
+
|
|
61
|
+
"react/jsx-fragments": "off",
|
|
62
|
+
"react/jsx-no-bind": "off",
|
|
63
|
+
"react/self-closing-comp": "off",
|
|
64
|
+
|
|
65
|
+
"sonarjs/prefer-immediate-return": "off",
|
|
66
|
+
|
|
67
|
+
"@typescript-eslint/dot-notation": "off", // prefer warn but needs different parserOptions
|
|
68
|
+
"@typescript-eslint/naming-convention": "off", // prefer warn but needs different parserOptions
|
|
69
|
+
"@typescript-eslint/ban-types": "off", // also, see override below
|
|
70
|
+
|
|
71
|
+
//
|
|
72
|
+
// Initial release: set to error
|
|
73
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
74
|
+
"eqeqeq": "error",
|
|
75
|
+
"no-alert": "error",
|
|
76
|
+
"no-console": "error",
|
|
77
|
+
"no-fallthrough": "error",
|
|
78
|
+
"no-undef": "error",
|
|
79
|
+
"no-unused-vars": "error",
|
|
80
|
+
"no-var": "error",
|
|
81
|
+
"prefer-const": "error",
|
|
82
|
+
"yoda": "error",
|
|
83
|
+
|
|
84
|
+
"import/no-mutable-exports": "error",
|
|
85
|
+
"sonarjs/max-switch-cases": "error",
|
|
86
|
+
"sonarjs/no-collapsible-if": "error",
|
|
87
|
+
"sonarjs/no-all-duplicated-branches": "error",
|
|
88
|
+
"sonarjs/no-duplicated-branches": "error",
|
|
89
|
+
"sonarjs/no-gratuitous-expressions": "error",
|
|
90
|
+
"sonarjs/no-ignored-return": "error",
|
|
91
|
+
"sonarjs/no-small-switch": "error",
|
|
92
|
+
"sonarjs/prefer-object-literal": "error",
|
|
93
|
+
"sonarjs/prefer-single-boolean-return": "error",
|
|
94
|
+
"@typescript-eslint/no-shadow": "error",
|
|
95
|
+
"react/default-props-match-prop-types": "error",
|
|
96
|
+
"react/no-unescaped-entities": "error",
|
|
97
|
+
"react/no-unused-prop-types": "error",
|
|
98
|
+
"react/static-property-placement": "error",
|
|
99
|
+
"array-callback-return": "error",
|
|
100
|
+
"camelcase": "error",
|
|
101
|
+
"default-case": "error",
|
|
102
|
+
"func-names": "error",
|
|
103
|
+
"no-case-declarations": "error",
|
|
104
|
+
"no-lonely-if": "error",
|
|
105
|
+
"no-nested-ternary": "error",
|
|
106
|
+
"no-plusplus": "error",
|
|
107
|
+
"no-restricted-globals": "error",
|
|
108
|
+
"no-restricted-properties": "error",
|
|
109
|
+
"no-shadow": "error",
|
|
110
|
+
"radix": "error",
|
|
111
|
+
"spaced-comment": "error",
|
|
112
|
+
|
|
113
|
+
"import/newline-after-import": "error",
|
|
114
|
+
"sonarjs/no-nested-switch": "error",
|
|
115
|
+
"@typescript-eslint/no-array-constructor": "error",
|
|
116
|
+
"@typescript-eslint/no-empty-function": "error",
|
|
117
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
118
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
119
|
+
"react/button-has-type": "error",
|
|
120
|
+
"react/jsx-curly-brace-presence": "error",
|
|
121
|
+
"react/jsx-boolean-value": "error",
|
|
122
|
+
"react/no-array-index-key": "error",
|
|
123
|
+
"class-methods-use-this": "error",
|
|
124
|
+
"guard-for-in": "error",
|
|
125
|
+
"no-unneeded-ternary": "error",
|
|
126
|
+
"no-unused-expressions": "error",
|
|
127
|
+
"operator-assignment": "error",
|
|
128
|
+
"prefer-template": "error",
|
|
129
|
+
"vars-on-top": "error",
|
|
130
|
+
|
|
131
|
+
"no-use-before-define": "off", // doc for @typescript-eslint/no-use-before-define says to turn off the base implementation
|
|
132
|
+
"@typescript-eslint/no-use-before-define": "error"
|
|
133
|
+
},
|
|
134
|
+
"overrides": [
|
|
135
|
+
{
|
|
136
|
+
"files": "*.@(ts|tsx)",
|
|
137
|
+
"rules": {
|
|
138
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
139
|
+
// "@typescript-eslint/ban-types": [
|
|
140
|
+
// "warn",
|
|
141
|
+
// {
|
|
142
|
+
// "types": {
|
|
143
|
+
// "Omit": "Please use the 'OmitStrict' type from 'src/types/' instead.",
|
|
144
|
+
// "object": false,
|
|
145
|
+
// "Function": false
|
|
146
|
+
// },
|
|
147
|
+
// "extendDefaults": true
|
|
148
|
+
// }
|
|
149
|
+
// ],
|
|
150
|
+
|
|
151
|
+
"quotes": "off",
|
|
152
|
+
"@typescript-eslint/quotes": "off"
|
|
153
|
+
// [
|
|
154
|
+
// "error",
|
|
155
|
+
// "single",
|
|
156
|
+
// {
|
|
157
|
+
// "avoidEscape": true,
|
|
158
|
+
// "allowTemplateLiterals": false
|
|
159
|
+
// }
|
|
160
|
+
// ]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"files": "*.@(jsx|tsx|mdx)",
|
|
165
|
+
"rules": {
|
|
166
|
+
"react/react-in-jsx-scope": "off",
|
|
167
|
+
// Set up configuration for future sweep
|
|
168
|
+
"react-hooks/exhaustive-deps": [
|
|
169
|
+
"off",
|
|
170
|
+
{
|
|
171
|
+
"additionalHooks": "useAfterInitialEffect"
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"files": "*.@(js|jsx|ts|tsx|mdx)",
|
|
178
|
+
"rules": {}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"files": ".storybook/*.js",
|
|
182
|
+
"extends": ["@pega/eslint-config/script"]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"files": "*/**/mocks/**.@(mocks|styles).@(tsx|ts)",
|
|
186
|
+
"rules": {
|
|
187
|
+
"import/prefer-default-export": ["off"]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
]
|
|
10
191
|
}
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
"lint": "run-p -cl lint:*",
|
|
11
11
|
"fix": "run-p -cl fix:*",
|
|
12
12
|
"authenticate": "custom-dx-components authenticate",
|
|
13
|
+
"buildComponent": "custom-dx-components buildComponent",
|
|
13
14
|
"create": "custom-dx-components create",
|
|
14
15
|
"publish": "custom-dx-components publish",
|
|
16
|
+
"publishAll": "custom-dx-components publishAll",
|
|
15
17
|
"list": "custom-dx-components list",
|
|
16
18
|
"validate-schema": "custom-dx-components validateSchema",
|
|
17
19
|
"update": "custom-dx-components update",
|
|
18
20
|
"delete": "custom-dx-components delete",
|
|
21
|
+
"deleteAll": "custom-dx-components deleteAll",
|
|
19
22
|
"lint:types": "tsc --noEmit",
|
|
20
23
|
"lint:es": "eslint .",
|
|
21
24
|
"lint:styles": "stylelint \"./**/*.@(js|jsx|ts|tsx)\"",
|
|
@@ -35,8 +38,8 @@
|
|
|
35
38
|
"license": "Enter License",
|
|
36
39
|
"sideEffects": false,
|
|
37
40
|
"dependencies": {
|
|
38
|
-
"@pega/cosmos-react-core": "^3.0.
|
|
39
|
-
"@pega/cosmos-react-work": "3.0.
|
|
41
|
+
"@pega/cosmos-react-core": "^3.0.1",
|
|
42
|
+
"@pega/cosmos-react-work": "3.0.1",
|
|
40
43
|
"@storybook/addon-knobs": "^6.3.1",
|
|
41
44
|
"dayjs": "^1.11.5",
|
|
42
45
|
"jest": "^29.3.1",
|
|
@@ -52,7 +55,8 @@
|
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"@pega/configs": "^0.3.4",
|
|
55
|
-
"@pega/custom-dx-components": "^2.0.
|
|
58
|
+
"@pega/custom-dx-components": "^2.0.12",
|
|
59
|
+
"@pega/eslint-config": "^0.3.2",
|
|
56
60
|
"@storybook/addon-actions": "^6.5.12",
|
|
57
61
|
"@storybook/addon-essentials": "^6.5.12",
|
|
58
62
|
"@storybook/addon-links": "^6.5.12",
|
|
@@ -65,7 +69,18 @@
|
|
|
65
69
|
"@types/react-color": "^3.0.6",
|
|
66
70
|
"@types/react-dom": "^17.0.11",
|
|
67
71
|
"@types/styled-components": "^5.1.26",
|
|
68
|
-
"eslint": "^
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
|
73
|
+
"eslint": "^8.4.1",
|
|
74
|
+
"eslint-plugin-import": "^2.25.3",
|
|
75
|
+
"eslint-plugin-jest": "^25.3.0",
|
|
76
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
77
|
+
"eslint-plugin-mdx": "^2.0.5",
|
|
78
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
79
|
+
"eslint-plugin-react": "^7.27.1",
|
|
80
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
81
|
+
"eslint-plugin-sonarjs": "^0.11.0",
|
|
82
|
+
"jest": "^29.3.1",
|
|
83
|
+
"jest-environment-jsdom": "^29.3.1",
|
|
69
84
|
"npm-run-all": "^4.1.5",
|
|
70
85
|
"prettier": "2.7.1",
|
|
71
86
|
"stylelint": "^14.11.0",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ESLint } from 'eslint';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
export const lintComponent = async (dirToLint) => {
|
|
5
|
+
// console.log("in dx-component-builder-sdk: lintComponent - dirToLint: " + dirToLint);
|
|
6
|
+
console.log(chalk.green(` linting ${dirToLint}`));
|
|
7
|
+
|
|
8
|
+
// 1. Create an instance.
|
|
9
|
+
const eslint = new ESLint();
|
|
10
|
+
|
|
11
|
+
// 2. Lint files.
|
|
12
|
+
const results = await eslint.lintFiles([dirToLint]);
|
|
13
|
+
|
|
14
|
+
// 3. Format the results.
|
|
15
|
+
const formatter = await eslint.loadFormatter("stylish");
|
|
16
|
+
const resultText = formatter.format(results);
|
|
17
|
+
|
|
18
|
+
// 4. Output it.
|
|
19
|
+
// console.log(`lint resultText: ${resultText}`);
|
|
20
|
+
console.log(resultText);
|
|
21
|
+
|
|
22
|
+
// Indicate linting is complete
|
|
23
|
+
console.log(chalk.green(` linting complete...`));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// inpsired by https://eslint.org/docs/latest/developer-guide/nodejs-api
|
|
27
|
+
|
|
28
|
+
// (async function main() {
|
|
29
|
+
// // 1. Create an instance.
|
|
30
|
+
// const eslint = new ESLint();
|
|
31
|
+
|
|
32
|
+
// // 2. Lint files.
|
|
33
|
+
// const results = await eslint.lintFiles(["lib/**/*.js"]);
|
|
34
|
+
|
|
35
|
+
// // 3. Format the results.
|
|
36
|
+
// const formatter = await eslint.loadFormatter("stylish");
|
|
37
|
+
// const resultText = formatter.format(results);
|
|
38
|
+
|
|
39
|
+
// // 4. Output it.
|
|
40
|
+
// console.log(resultText);
|
|
41
|
+
// })().catch((error) => {
|
|
42
|
+
// process.exitCode = 1;
|
|
43
|
+
// console.error(error);
|
|
44
|
+
// });
|
|
45
|
+
|
|
46
|
+
export default lintComponent;
|
package/src/tasks/list/index.js
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
getListComponentsQuestions
|
|
11
11
|
} from './helper.js';
|
|
12
12
|
|
|
13
|
+
import { showVersion } from '../../util.js';
|
|
14
|
+
|
|
13
15
|
const getList = async (sourceOfComponents, answers) => {
|
|
14
16
|
switch (sourceOfComponents) {
|
|
15
17
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
@@ -32,6 +34,8 @@ const getList = async (sourceOfComponents, answers) => {
|
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
export default async options => {
|
|
37
|
+
showVersion();
|
|
38
|
+
|
|
35
39
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
36
40
|
|
|
37
41
|
if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
@@ -4,10 +4,15 @@ import chalk from 'chalk';
|
|
|
4
4
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
6
|
|
|
7
|
-
import bundleComponent from '
|
|
7
|
+
import bundleComponent from '../bundle/index.js';
|
|
8
|
+
import { lintComponent } from '../linter/index.js';
|
|
9
|
+
|
|
10
|
+
import { getComponentDirectoryPath, showVersion } from '../../util.js';
|
|
8
11
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
9
12
|
|
|
10
13
|
export default async options => {
|
|
14
|
+
showVersion();
|
|
15
|
+
|
|
11
16
|
const questions = await getPublishComponentQuestions();
|
|
12
17
|
const answers = await inquirer.prompt(questions);
|
|
13
18
|
const { componentKey, sourceMap, devBuild } = answers;
|
|
@@ -24,6 +29,14 @@ export default async options => {
|
|
|
24
29
|
await validate(componentKey);
|
|
25
30
|
}
|
|
26
31
|
},
|
|
32
|
+
{
|
|
33
|
+
title: 'Lint component',
|
|
34
|
+
task: async () => {
|
|
35
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
36
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
37
|
+
await lintComponent(targetDirectory);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
27
40
|
{
|
|
28
41
|
title: 'Bundle Component',
|
|
29
42
|
task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
|