@pega/custom-dx-components 2.0.23 → 2.0.25
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 +3 -6
- package/src/cli.js +0 -18
- package/src/constants.js +2 -32
- package/src/tasks/authenticate/helper.js +5 -63
- package/src/tasks/authenticate/index.js +50 -107
- package/src/tasks/create/index.js +63 -59
- 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 +16 -33
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +2 -1
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +67 -179
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +17 -46
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +1 -3
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/{date-utils.js.mustache → date-utils.js} +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +17 -46
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +17 -22
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +17 -26
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +4 -3
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +17 -22
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +2 -8
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +17 -22
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +16 -50
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +1 -44
- package/src/tasks/create/templates/Constellation/Field/Picklist/picklist.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +16 -23
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +17 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +2 -44
- package/src/tasks/create/templates/Constellation/Field/Text-Email/text-email.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/{StatusWork.jsx → StatusWork.js} +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +17 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +3 -46
- package/src/tasks/create/templates/Constellation/Field/Text-Input/text-input.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +17 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +2 -44
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/text-paragraph.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +17 -19
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +3 -47
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/text-phone.js.mustache +43 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +17 -19
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Field/Text-URL/{text-url.jsx.mustache → text-url.js.mustache} +1 -2
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/demo.stories.jsx.mustache +17 -30
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +29 -14
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +77 -3
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +29 -14
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +74 -3
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +10 -6
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +8 -10
- package/src/tasks/create/templates/Constellation/Template/PAGE/{GetNextWork.jsx.mustache → GetNextWork.js.mustache} +0 -6
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +7 -9
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +1 -4
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +8 -8
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Avatar.jsx.mustache → Avatar.js.mustache} +0 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/{Operator.jsx.mustache → Operator.js.mustache} +1 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +9 -9
- package/src/tasks/delete/helper.js +0 -4
- package/src/tasks/delete/index.js +0 -4
- package/src/tasks/index.js +0 -3
- package/src/tasks/init/index.js +3 -3
- package/src/tasks/init/template/.eslintrc.json +5 -186
- package/src/tasks/init/template/README.md +59 -75
- package/src/tasks/init/template/package.json.mustache +6 -21
- package/src/tasks/init/template/tasks.config.json +2 -5
- package/src/tasks/list/index.js +0 -4
- package/src/tasks/{bundle → publish/bundle}/builder/webpack.config.js +2 -0
- package/src/tasks/{bundle → publish/bundle}/index.js +2 -2
- package/src/tasks/publish/index.js +1 -14
- package/src/util.js +6 -11
- package/src/auth.js +0 -563
- package/src/tasks/build/helper.js +0 -123
- package/src/tasks/build/index.js +0 -54
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -61
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -41
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +0 -67
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +0 -13
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +0 -22
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +0 -21
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +0 -20
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +0 -37
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +0 -22
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/mock.stories.js.mustache +0 -20
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +0 -26
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +0 -118
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +0 -179
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +0 -26
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +0 -123
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +0 -215
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +0 -93
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +0 -125
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +0 -100
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +0 -131
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +0 -101
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +0 -94
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +0 -78
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +0 -390
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +0 -30
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +0 -23
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +0 -68
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +0 -51
- package/src/tasks/delete-all/helper.js +0 -175
- package/src/tasks/delete-all/index.js +0 -49
- package/src/tasks/init/template/.eslintignore +0 -8
- package/src/tasks/linter/index.js +0 -46
- package/src/tasks/publish-all/helper.js +0 -139
- package/src/tasks/publish-all/index.js +0 -84
- /package/src/tasks/{bundle → publish/bundle}/builder/index.js +0 -0
- /package/src/tasks/{bundle → publish/bundle}/builder/modules.js +0 -0
- /package/src/tasks/{bundle → publish/bundle}/builder/paths.js +0 -0
|
@@ -1,175 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
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;
|
|
@@ -1,139 +0,0 @@
|
|
|
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: 'rulesetName',
|
|
25
|
-
message: 'Enter ruleset name',
|
|
26
|
-
default: defaultPegaConfig.rulesetName,
|
|
27
|
-
validate: value => {
|
|
28
|
-
if (value.trim()) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return 'Ruleset name cannot be empty';
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'rulesetVersion',
|
|
36
|
-
message: 'Enter ruleset version',
|
|
37
|
-
default: defaultPegaConfig.rulesetVersion,
|
|
38
|
-
validate: value => {
|
|
39
|
-
if (validateRulesetVersion(value)) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
return 'Please provide compatible version e.g 01-01-01';
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'sourceMap',
|
|
47
|
-
message: 'Generate source map ?',
|
|
48
|
-
default: defaultPegaConfig.sourceMap,
|
|
49
|
-
when: () => false && !process.env.SOURCE_MAP
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'devBuild',
|
|
53
|
-
message: 'Generate development build ?',
|
|
54
|
-
default: defaultPegaConfig.devBuild
|
|
55
|
-
}
|
|
56
|
-
];
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const zipComponent = async componentKey => {
|
|
60
|
-
const srcDirectory = await getComponentDirectoryPath(componentKey);
|
|
61
|
-
const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
|
|
62
|
-
const configJson = `${srcDirectory}/config.json`;
|
|
63
|
-
|
|
64
|
-
const zip = new AdmZip();
|
|
65
|
-
|
|
66
|
-
zip.addLocalFolder(srcDirectory, 'src/');
|
|
67
|
-
zip.addLocalFile(configJson);
|
|
68
|
-
zip.addLocalFolder(buildDirectory);
|
|
69
|
-
const zipContent = zip.toBuffer().toString('base64');
|
|
70
|
-
|
|
71
|
-
const configContent = Buffer.from(fs.readFileSync(`${srcDirectory}/config.json`)).toString();
|
|
72
|
-
fs.rmdir('dist', { recursive: true }, err => {
|
|
73
|
-
if (err) {
|
|
74
|
-
throw err;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return { zipContent, configContent };
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const publishComponentToServer = async data => {
|
|
81
|
-
const { configContent, zipContent, componentKey, rulesetName, rulesetVersion } = data;
|
|
82
|
-
|
|
83
|
-
const apiBody = {
|
|
84
|
-
configContent,
|
|
85
|
-
zipContent,
|
|
86
|
-
componentKey: JSON.parse(configContent).componentKey,
|
|
87
|
-
publishFor: 'constellation',
|
|
88
|
-
rulesetName,
|
|
89
|
-
rulesetVersion,
|
|
90
|
-
category: ''
|
|
91
|
-
};
|
|
92
|
-
const defaultPegaConfig = await getPegaServerConfig();
|
|
93
|
-
const url = constructCompleteUrl(
|
|
94
|
-
defaultPegaConfig.server,
|
|
95
|
-
PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
|
|
96
|
-
);
|
|
97
|
-
try {
|
|
98
|
-
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
99
|
-
if (OauthData) {
|
|
100
|
-
const {
|
|
101
|
-
access_token: accessToken,
|
|
102
|
-
token_type: tokenType,
|
|
103
|
-
refresh_token: refreshToken
|
|
104
|
-
} = JSON.parse(OauthData);
|
|
105
|
-
let status = 500;
|
|
106
|
-
fetch(url, {
|
|
107
|
-
method: 'POST',
|
|
108
|
-
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
109
|
-
headers: {
|
|
110
|
-
Authorization: `${tokenType} ${accessToken}`
|
|
111
|
-
},
|
|
112
|
-
body: JSON.stringify(apiBody)
|
|
113
|
-
})
|
|
114
|
-
.then(response => {
|
|
115
|
-
status = response.status;
|
|
116
|
-
return response.text();
|
|
117
|
-
})
|
|
118
|
-
.then(resp => {
|
|
119
|
-
const respData = JSON.parse(resp);
|
|
120
|
-
if (status === 401) {
|
|
121
|
-
throw new Error(
|
|
122
|
-
'Error occured in authentication. Please regenerate using authenticate'
|
|
123
|
-
);
|
|
124
|
-
// console.log(accessTokenUri, refreshToken);
|
|
125
|
-
/* TODO - Handle refresh_token */
|
|
126
|
-
} else if (status == 200) {
|
|
127
|
-
console.log(chalk.bold.green(`Success : ${respData.message}`));
|
|
128
|
-
} else {
|
|
129
|
-
throw new Error(`${respData.message}`);
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
.catch(e => Promise.reject(`${chalk.bold.red(e)}`));
|
|
133
|
-
} else {
|
|
134
|
-
throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
|
|
135
|
-
}
|
|
136
|
-
} catch (err) {
|
|
137
|
-
throw new Error(`Error occured in authentication. Please regenerate using authenticate`);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
12
|
-
import {
|
|
13
|
-
getComponents,
|
|
14
|
-
getComponentDirectoryPath,
|
|
15
|
-
showVersion
|
|
16
|
-
} from '../../util.js';
|
|
17
|
-
|
|
18
|
-
export default async options => {
|
|
19
|
-
showVersion();
|
|
20
|
-
|
|
21
|
-
const components = await getComponents();
|
|
22
|
-
const questions = await getPublishComponentQuestions();
|
|
23
|
-
const answers = await inquirer.prompt(questions);
|
|
24
|
-
const {sourceMap, devBuild } = answers;
|
|
25
|
-
|
|
26
|
-
let content = {
|
|
27
|
-
...answers
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var componentKey;
|
|
31
|
-
|
|
32
|
-
const tasks = new Listr(
|
|
33
|
-
[
|
|
34
|
-
{
|
|
35
|
-
title: 'Validate config schema',
|
|
36
|
-
task: async () => {
|
|
37
|
-
await validate(componentKey);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
title: 'Bundle Component',
|
|
42
|
-
task: async () => await bundleComponent(componentKey, sourceMap, devBuild),
|
|
43
|
-
skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
title: 'Lint component',
|
|
47
|
-
task: async () => {
|
|
48
|
-
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
49
|
-
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
50
|
-
await lintComponent(targetDirectory);
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
title: 'Zip Component',
|
|
55
|
-
task: async () => {
|
|
56
|
-
const output = await zipComponent(componentKey);
|
|
57
|
-
content = { ...content, ...output };
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
title: 'Publish Component',
|
|
62
|
-
task: async () => {
|
|
63
|
-
await publishComponentToServer(content);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
{
|
|
68
|
-
exitOnError: true
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
for (var index in components) {
|
|
73
|
-
componentKey = components[index];
|
|
74
|
-
console.log(chalk.bold.green("Publishing: " + componentKey));
|
|
75
|
-
await tasks.run().catch(err => {
|
|
76
|
-
console.log(chalk.bold.red(err.toString()));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// await tasks.run().catch(err => {
|
|
81
|
-
// console.log(chalk.bold.red(err.toString()));
|
|
82
|
-
// });
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|