@pega/custom-dx-components 0.23.9 → 0.23.10
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/tasks/authenticate/index.js +1 -1
- package/src/tasks/build/helper.js +2 -3
- package/src/tasks/bundle/builder/webpack.config.js +1 -1
- package/src/tasks/delete/helper.js +17 -33
- package/src/tasks/delete/index.js +3 -10
- package/src/tasks/delete-all/helper.js +44 -57
- package/src/tasks/delete-all/index.js +2 -9
- package/src/tasks/init/index.js +1 -1
- package/src/tasks/init/template/package.json.mustache +5 -4
- package/src/tasks/list/helper.js +21 -56
- package/src/tasks/list/index.js +3 -4
- package/src/tasks/publish/helper.js +2 -3
- package/src/tasks/publish/index.js +7 -15
- package/src/tasks/publish-all/helper.js +0 -1
- package/src/tasks/publish-all/index.js +12 -21
- package/src/tasks/revert-webpack/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import https from 'https';
|
|
4
3
|
|
|
5
4
|
import fetch from 'node-fetch';
|
|
6
5
|
import AdmZip from 'adm-zip';
|
|
@@ -14,7 +13,7 @@ export const getPublishComponentQuestions = async () => {
|
|
|
14
13
|
|
|
15
14
|
if (components.length === 0) {
|
|
16
15
|
console.log(chalk.redBright('No components to build'));
|
|
17
|
-
process.exit(
|
|
16
|
+
process.exit();
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
@@ -80,7 +79,7 @@ export const publishComponentToServer = async (data) => {
|
|
|
80
79
|
try {
|
|
81
80
|
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
82
81
|
if (OauthData) {
|
|
83
|
-
const { access_token: accessToken, token_type: tokenType
|
|
82
|
+
const { access_token: accessToken, token_type: tokenType } = JSON.parse(OauthData);
|
|
84
83
|
let status = 500;
|
|
85
84
|
fetch(url, {
|
|
86
85
|
method: 'POST',
|
|
@@ -49,7 +49,7 @@ export default (
|
|
|
49
49
|
{ inputFile, outputFile, componentKey, externals, globals, sourceMap, devBuild }
|
|
50
50
|
) => {
|
|
51
51
|
const isEnvDevelopment = webpackEnv === 'development' || devBuild;
|
|
52
|
-
const isEnvProduction = webpackEnv === 'production'
|
|
52
|
+
const isEnvProduction = webpackEnv === 'production';
|
|
53
53
|
sourceMap = sourceMap === 'true';
|
|
54
54
|
shouldUseSourceMap = shouldUseSourceMap || sourceMap;
|
|
55
55
|
|
|
@@ -2,7 +2,6 @@ import chalk from 'chalk';
|
|
|
2
2
|
import inquirer from 'inquirer';
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
import {
|
|
7
6
|
deleteLocalComponent,
|
|
8
7
|
deleteInfinityServerComponent,
|
|
@@ -13,14 +12,12 @@ import {
|
|
|
13
12
|
} from '../../util.js';
|
|
14
13
|
import { getComponentsFromServer } from '../list/helper.js';
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
15
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
19
16
|
SERVER: 'Server',
|
|
20
17
|
LOCAL: 'Local'
|
|
21
18
|
};
|
|
22
19
|
|
|
23
|
-
export const getDeleteComponentsQuestions = async (options
|
|
20
|
+
export const getDeleteComponentsQuestions = async (options) => {
|
|
24
21
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
25
22
|
|
|
26
23
|
return [
|
|
@@ -40,22 +37,15 @@ export const getDeleteComponentsQuestions = async (options, sourceOfComponentsOp
|
|
|
40
37
|
export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
41
38
|
const localComponents = await getComponents();
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
40
|
if (localComponents.length > 0) {
|
|
46
|
-
|
|
47
41
|
if (options.params.length >= 6) {
|
|
48
42
|
const componentKey = options.params[4];
|
|
49
43
|
const sDeletion = options.params[5];
|
|
50
|
-
const confirmDeletion =
|
|
51
|
-
sDeletion === 'y' ||
|
|
52
|
-
sDeletion === true ||
|
|
53
|
-
sDeletion === 'true') ? true : false;
|
|
44
|
+
const confirmDeletion = sDeletion === 'Y' || sDeletion === 'y' || sDeletion === true || sDeletion === 'true';
|
|
54
45
|
if (confirmDeletion) {
|
|
55
46
|
await deleteLocalComponent(componentKey);
|
|
56
47
|
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
48
|
+
} else {
|
|
59
49
|
const answers = await inquirer.prompt([
|
|
60
50
|
{
|
|
61
51
|
name: 'componentKey',
|
|
@@ -74,7 +64,6 @@ export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
|
74
64
|
await deleteLocalComponent(answers.componentKey);
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
|
-
|
|
78
67
|
} else {
|
|
79
68
|
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
|
|
80
69
|
}
|
|
@@ -86,22 +75,19 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
86
75
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
87
76
|
const data = await getComponentsFromServer(answers);
|
|
88
77
|
|
|
89
|
-
// const serverComponents = isLaunchpad ? data : JSON.parse(data).pxResults;
|
|
90
78
|
let serverComponents;
|
|
91
79
|
if (isLaunchpad) {
|
|
92
80
|
serverComponents = data;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
81
|
+
} else {
|
|
95
82
|
try {
|
|
96
|
-
if (typeof
|
|
83
|
+
if (typeof data === 'object') {
|
|
97
84
|
serverComponents = data.pxResults;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
85
|
+
} else {
|
|
100
86
|
serverComponents = JSON.parse(data).pxResults;
|
|
101
87
|
}
|
|
102
|
-
|
|
88
|
+
} catch (ex) {
|
|
89
|
+
/* empty */
|
|
103
90
|
}
|
|
104
|
-
catch (ex) {}
|
|
105
91
|
}
|
|
106
92
|
spinner.stop();
|
|
107
93
|
|
|
@@ -132,23 +118,21 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
132
118
|
const choicesArr = serverComponents.map(({ label, pyRuleSet, pyRuleSetVersion }) => {
|
|
133
119
|
const name = `${standardizeStr(label, 45)} ${standardizeStr(pyRuleSet, 30)} ${standardizeStr(pyRuleSetVersion, 20)}`;
|
|
134
120
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
`${label} ${pyRuleSet} : ${pyRuleSetVersion}`
|
|
138
|
-
)}`;
|
|
121
|
+
const value = `${label}~|~${pyRuleSet}~|~${pyRuleSetVersion}`;
|
|
122
|
+
const short = `\n Selected component : ${chalk.redBright(`${label} ${pyRuleSet} : ${pyRuleSetVersion}`)}`;
|
|
139
123
|
|
|
140
|
-
|
|
141
|
-
|
|
124
|
+
return { name, value, short };
|
|
125
|
+
});
|
|
142
126
|
const infinityAnswers = await inquirer.prompt({
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
127
|
+
name: 'componentToDelete',
|
|
128
|
+
type: 'rawlist',
|
|
129
|
+
pageSize: 10,
|
|
146
130
|
message: `Select component to delete \n ${standardizeStr('Rule name', 48)} ${standardizeStr('Ruleset name', 30)} ${standardizeStr(
|
|
147
131
|
'Ruleset version',
|
|
148
132
|
22
|
|
149
133
|
)}`,
|
|
150
|
-
|
|
151
|
-
|
|
134
|
+
choices: choicesArr
|
|
135
|
+
});
|
|
152
136
|
await deleteInfinityServerComponent(infinityAnswers.componentToDelete);
|
|
153
137
|
}
|
|
154
138
|
} else {
|
|
@@ -1,16 +1,9 @@
|
|
|
1
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
2
|
|
|
12
3
|
import { showVersion } from '../../util.js';
|
|
13
4
|
|
|
5
|
+
import { deleteLocalComponents, SOURCE_OF_COMPONENT_TYPES, deleteServerComponents, getDeleteComponentsQuestions } from './helper.js';
|
|
6
|
+
|
|
14
7
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
15
8
|
switch (sourceOfComponents) {
|
|
16
9
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
@@ -28,7 +21,7 @@ const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
|
28
21
|
}
|
|
29
22
|
};
|
|
30
23
|
|
|
31
|
-
export default async options => {
|
|
24
|
+
export default async (options) => {
|
|
32
25
|
showVersion();
|
|
33
26
|
|
|
34
27
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
deleteInfinityServerComponent,
|
|
7
7
|
deleteLaunchpadServerComponent,
|
|
8
8
|
deleteLocalComponent,
|
|
9
|
-
deleteServerComponent,
|
|
10
9
|
getComponents,
|
|
11
10
|
getPegaServerConfig,
|
|
12
11
|
standardizeStr,
|
|
@@ -19,10 +18,9 @@ export const SOURCE_OF_COMPONENT_TYPES = {
|
|
|
19
18
|
LOCAL: 'Local'
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
export const getDeleteComponentsQuestions = async (options
|
|
21
|
+
export const getDeleteComponentsQuestions = async (options) => {
|
|
23
22
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
24
23
|
|
|
25
|
-
|
|
26
24
|
return [
|
|
27
25
|
{
|
|
28
26
|
name: 'sourceOfComponents',
|
|
@@ -37,34 +35,29 @@ export const getDeleteComponentsQuestions = async (options, sourceOfComponentsOp
|
|
|
37
35
|
];
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
38
|
export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
43
39
|
const localComponents = await getComponents();
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
42
|
+
for (const index in localComponents) {
|
|
46
43
|
console.log(chalk.bold.green(localComponents[index]));
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
if (localComponents.length > 0) {
|
|
50
|
-
|
|
51
47
|
if (options.params.length >= 5) {
|
|
52
48
|
const sDeletion = options.params[4];
|
|
53
|
-
const confirmDeletion =
|
|
54
|
-
sDeletion === 'y' ||
|
|
55
|
-
sDeletion === true ||
|
|
56
|
-
sDeletion === 'true') ? true : false;
|
|
49
|
+
const confirmDeletion = sDeletion === 'Y' || sDeletion === 'y' || sDeletion === true || sDeletion === 'true';
|
|
57
50
|
if (confirmDeletion) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
52
|
+
for (const index in localComponents) {
|
|
53
|
+
const componentToDelete = localComponents[index];
|
|
54
|
+
// console.log(chalk.bold.green("Deleting: " + componentToDelete));
|
|
55
|
+
// eslint-disable-next-line no-await-in-loop
|
|
61
56
|
await deleteLocalComponent(componentToDelete);
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
|
-
}
|
|
65
|
-
else{
|
|
59
|
+
} else {
|
|
66
60
|
const answers = await inquirer.prompt([
|
|
67
|
-
|
|
68
61
|
{
|
|
69
62
|
name: 'confirmDeletion',
|
|
70
63
|
type: 'confirm',
|
|
@@ -80,9 +73,7 @@ export const deleteLocalComponents = async (sourceOfComponents, options) => {
|
|
|
80
73
|
}
|
|
81
74
|
}
|
|
82
75
|
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
76
|
+
} else {
|
|
86
77
|
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
|
|
87
78
|
}
|
|
88
79
|
};
|
|
@@ -97,18 +88,16 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
97
88
|
let serverComponents;
|
|
98
89
|
if (isLaunchpad) {
|
|
99
90
|
serverComponents = data;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
91
|
+
} else {
|
|
102
92
|
try {
|
|
103
|
-
if (typeof
|
|
93
|
+
if (typeof data === 'object') {
|
|
104
94
|
serverComponents = data.pxResults;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
95
|
+
} else {
|
|
107
96
|
serverComponents = JSON.parse(data).pxResults;
|
|
108
97
|
}
|
|
109
|
-
|
|
98
|
+
} catch (ex) {
|
|
99
|
+
/* empty */
|
|
110
100
|
}
|
|
111
|
-
catch (ex) {}
|
|
112
101
|
}
|
|
113
102
|
|
|
114
103
|
spinner.stop();
|
|
@@ -139,35 +128,35 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
139
128
|
const choicesArr = serverComponents.map(({ label, pyRuleSet, pyRuleSetVersion }) => {
|
|
140
129
|
const name = `${standardizeStr(label, 45)} ${standardizeStr(pyRuleSet, 30)} ${standardizeStr(pyRuleSetVersion, 20)}`;
|
|
141
130
|
|
|
142
|
-
|
|
131
|
+
const value = `${label}~|~${pyRuleSet}~|~${pyRuleSetVersion}`;
|
|
143
132
|
const short = `\n Selected component : ${chalk.redBright(`${label} ${pyRuleSet} : ${pyRuleSetVersion}`)}`;
|
|
144
133
|
|
|
145
|
-
|
|
146
|
-
|
|
134
|
+
return { name, value, short };
|
|
135
|
+
});
|
|
147
136
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
const selectedComp = await inquirer.prompt([
|
|
138
|
+
{
|
|
139
|
+
name: 'rulesetName',
|
|
140
|
+
message: 'Enter ruleset name',
|
|
141
|
+
default: defaultPegaServerConfig.rulesetName,
|
|
153
142
|
validate: (value) => {
|
|
154
|
-
|
|
155
|
-
|
|
143
|
+
if (value.trim()) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
return 'Ruleset name cannot be empty';
|
|
156
147
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
name: 'rulesetVersion',
|
|
162
|
-
message: 'Enter ruleset version',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'rulesetVersion',
|
|
151
|
+
message: 'Enter ruleset version',
|
|
163
152
|
default: defaultPegaServerConfig.rulesetVersion,
|
|
164
153
|
validate: (value) => {
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
if (validateRulesetVersion(value)) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return 'Please provide compatible version e.g 01-01-01';
|
|
167
158
|
}
|
|
168
|
-
return 'Please provide compatible version e.g 01-01-01';
|
|
169
159
|
}
|
|
170
|
-
}
|
|
171
160
|
]);
|
|
172
161
|
|
|
173
162
|
let bHasAtLeastOneComponent = false;
|
|
@@ -182,17 +171,17 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
182
171
|
|
|
183
172
|
if (!bHasAtLeastOneComponent) {
|
|
184
173
|
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents} that match ruleSet:${selectedComp.rulesetName}.`));
|
|
185
|
-
process.exit(
|
|
174
|
+
process.exit();
|
|
186
175
|
}
|
|
187
176
|
|
|
188
177
|
const confirmDeletionAnswers = await inquirer.prompt([
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
{
|
|
179
|
+
name: 'confirmDeletion',
|
|
180
|
+
type: 'confirm',
|
|
181
|
+
message: 'Do you want to delete these components ?',
|
|
182
|
+
default: false
|
|
183
|
+
}
|
|
184
|
+
]);
|
|
196
185
|
if (confirmDeletionAnswers.confirmDeletion) {
|
|
197
186
|
for (const choice of choicesArr) {
|
|
198
187
|
const componentToDelete = choice.value;
|
|
@@ -205,8 +194,6 @@ export const deleteServerComponents = async (sourceOfComponents, answers) => {
|
|
|
205
194
|
}
|
|
206
195
|
}
|
|
207
196
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
197
|
} else {
|
|
211
198
|
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
|
|
212
199
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
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
2
|
|
|
12
3
|
import { showVersion } from '../../util.js';
|
|
13
4
|
|
|
5
|
+
import { deleteLocalComponents, SOURCE_OF_COMPONENT_TYPES, deleteServerComponents, getDeleteComponentsQuestions } from './helper.js';
|
|
6
|
+
|
|
14
7
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
15
8
|
switch (sourceOfComponents) {
|
|
16
9
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
package/src/tasks/init/index.js
CHANGED
|
@@ -94,7 +94,7 @@ export default async (options) => {
|
|
|
94
94
|
fs.mkdirSync(projectDirectory);
|
|
95
95
|
} else {
|
|
96
96
|
console.log(chalk.bold.red(`A project with name ${projectName} already exists. Exiting...`));
|
|
97
|
-
process.exit(
|
|
97
|
+
process.exit();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
const targetDirectory = options.targetDirectory || process.cwd();
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"deleteAll": "custom-dx-components deleteAll",
|
|
24
24
|
"promoteWebPack": "custom-dx-components promoteWebPack",
|
|
25
25
|
"revertWebPack": "custom-dx-components revertWebPack",
|
|
26
|
-
"test": "
|
|
26
|
+
"test": "echo 'Running functional and unit tests will DELETE existing local components, proceed (y/n)?' && read proceed && if test \"$proceed\" = \"y\"; then npm run test:full; fi ",
|
|
27
|
+
"test:full": "npm run test:functional && npm run test:unit",
|
|
27
28
|
"test:functional": "jest --runInBand test/functionTest --detectOpenHandles --coverage",
|
|
28
29
|
"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",
|
|
29
30
|
"test:unit": "npm run test:unit:local --prefix node_modules/@pega/custom-dx-components",
|
|
@@ -50,8 +51,8 @@
|
|
|
50
51
|
"license": "Enter License",
|
|
51
52
|
"sideEffects": false,
|
|
52
53
|
"dependencies": {
|
|
53
|
-
"@pega/cosmos-react-core": "^3.0.
|
|
54
|
-
"@pega/cosmos-react-work": "3.0.
|
|
54
|
+
"@pega/cosmos-react-core": "^3.0.11",
|
|
55
|
+
"@pega/cosmos-react-work": "3.0.11",
|
|
55
56
|
"dayjs": "^1.11.5",
|
|
56
57
|
"polished": "^4.2.2",
|
|
57
58
|
"prop-types": "^15.8.1",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@pega/configs": "^0.5.3",
|
|
68
|
-
"@pega/custom-dx-components": "^0.23.
|
|
69
|
+
"@pega/custom-dx-components": "^0.23.10",
|
|
69
70
|
"@pega/eslint-config": "^0.3.2",
|
|
70
71
|
"@storybook/addon-actions": "^6.5.12",
|
|
71
72
|
"@storybook/addon-essentials": "^6.5.12",
|
package/src/tasks/list/helper.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import https from 'https';
|
|
3
2
|
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import fetch from 'node-fetch';
|
|
@@ -12,7 +11,7 @@ export const SOURCE_OF_COMPONENT_TYPES = {
|
|
|
12
11
|
LOCAL: 'Local'
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
export const getListComponentsQuestions = async (options
|
|
14
|
+
export const getListComponentsQuestions = async (options) => {
|
|
16
15
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
17
16
|
|
|
18
17
|
return [
|
|
@@ -56,7 +55,7 @@ async function fetchComponentsFromInfinity(apiUrl, headers) {
|
|
|
56
55
|
.then((resp) => {
|
|
57
56
|
// const respData = JSON.parse(resp);
|
|
58
57
|
if (status === 401) {
|
|
59
|
-
throw new Error('Error
|
|
58
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
60
59
|
// console.log(accessTokenUri, refreshToken);
|
|
61
60
|
/* TODO - Handle refresh_token */
|
|
62
61
|
} else if (status === 200) {
|
|
@@ -100,7 +99,7 @@ async function fetchComponentsFromLaunchpad(apiUrl, headers) {
|
|
|
100
99
|
resolve(components);
|
|
101
100
|
}
|
|
102
101
|
if (statuses.every((status) => [401, 503].includes(status))) {
|
|
103
|
-
throw new Error('Error
|
|
102
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
104
103
|
} else {
|
|
105
104
|
throw new Error(`${data.map((resp) => resp.message || resp)}`);
|
|
106
105
|
}
|
|
@@ -115,7 +114,7 @@ export const getComponentsFromServer = async () => {
|
|
|
115
114
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
116
115
|
const url = constructCompleteUrl(
|
|
117
116
|
defaultPegaServerConfig.server,
|
|
118
|
-
isLaunchpad ? LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT :
|
|
117
|
+
isLaunchpad ? LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT : LIST_COMPONENT_SERVICE_REST_ENDPOINT
|
|
119
118
|
);
|
|
120
119
|
return new Promise((resolve, reject) => {
|
|
121
120
|
try {
|
|
@@ -125,16 +124,9 @@ export const getComponentsFromServer = async () => {
|
|
|
125
124
|
reject(`\n${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
126
125
|
}
|
|
127
126
|
if (data) {
|
|
128
|
-
const {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
refresh_token: refreshToken
|
|
132
|
-
} = JSON.parse(data);
|
|
133
|
-
let status = 500;
|
|
134
|
-
|
|
135
|
-
const headers = {
|
|
136
|
-
Authorization: `${tokenType} ${accessToken}`
|
|
137
|
-
}
|
|
127
|
+
const { access_token: accessToken, token_type: tokenType } = JSON.parse(data);
|
|
128
|
+
|
|
129
|
+
const headers = {};
|
|
138
130
|
|
|
139
131
|
if (isLaunchpad) {
|
|
140
132
|
headers.cookie = `Pega-AAT=${accessToken}`;
|
|
@@ -149,31 +141,6 @@ export const getComponentsFromServer = async () => {
|
|
|
149
141
|
.then((response) => resolve(response))
|
|
150
142
|
.catch((e) => reject(e));
|
|
151
143
|
}
|
|
152
|
-
|
|
153
|
-
fetch(url, {
|
|
154
|
-
method: 'GET',
|
|
155
|
-
agent: getHttpsAgent(defaultPegaServerConfig),
|
|
156
|
-
headers
|
|
157
|
-
})
|
|
158
|
-
.then(response => {
|
|
159
|
-
status = response.status;
|
|
160
|
-
return response.text();
|
|
161
|
-
})
|
|
162
|
-
.then(resp => {
|
|
163
|
-
const respData = JSON.parse(resp);
|
|
164
|
-
if (status === 401) {
|
|
165
|
-
throw new Error(
|
|
166
|
-
'Error occured in authentication. Please regenerate using authenticate'
|
|
167
|
-
);
|
|
168
|
-
// console.log(accessTokenUri, refreshToken);
|
|
169
|
-
/* TODO - Handle refresh_token */
|
|
170
|
-
} else if (status == 200) {
|
|
171
|
-
resolve(resp);
|
|
172
|
-
} else {
|
|
173
|
-
throw new Error(`${respData.message}`);
|
|
174
|
-
}
|
|
175
|
-
})
|
|
176
|
-
.catch(e => reject(`${chalk.bold.red(e)}`));
|
|
177
144
|
}
|
|
178
145
|
});
|
|
179
146
|
} catch (error) {
|
|
@@ -187,24 +154,20 @@ export const getComponentsFromServer = async () => {
|
|
|
187
154
|
export const displayServerComponents = async (data) => {
|
|
188
155
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
189
156
|
const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
|
|
190
|
-
// const parsedData = JSON.parse(data);
|
|
191
157
|
let list;
|
|
192
158
|
if (isLaunchpad) {
|
|
193
159
|
list = data;
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
160
|
+
} else {
|
|
196
161
|
try {
|
|
197
|
-
if (typeof
|
|
162
|
+
if (typeof data === 'object') {
|
|
198
163
|
list = data.pxResults;
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
164
|
+
} else {
|
|
201
165
|
list = JSON.parse(data).pxResults;
|
|
202
166
|
}
|
|
203
|
-
|
|
167
|
+
} catch (ex) {
|
|
168
|
+
/* empty */
|
|
204
169
|
}
|
|
205
|
-
catch (ex) {}
|
|
206
170
|
}
|
|
207
|
-
//const list = isLaunchpad ? data : JSON.parse(data).pxResults;
|
|
208
171
|
/**
|
|
209
172
|
* TODO: Need to modify the components list mapping code to support Launchpad components
|
|
210
173
|
*/
|
|
@@ -217,17 +180,19 @@ export const displayServerComponents = async (data) => {
|
|
|
217
180
|
}
|
|
218
181
|
|
|
219
182
|
return {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
183
|
+
'Rule name': label,
|
|
184
|
+
'Ruleset name': pyRuleSet,
|
|
185
|
+
'Ruleset version': pyRuleSetVersion
|
|
223
186
|
};
|
|
224
187
|
});
|
|
225
188
|
|
|
226
189
|
if (componentList && componentList.length > 0) {
|
|
227
|
-
console.log(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
190
|
+
console.log(chalk.bold.blueBright(`List of custom components in ${defaultPegaServerConfig.server}`));
|
|
191
|
+
if (isLaunchpad) {
|
|
192
|
+
console.table(componentList, ['Component Name', 'Type']);
|
|
193
|
+
} else {
|
|
194
|
+
console.table(componentList, ['Rule name', 'Ruleset name', 'Ruleset version']);
|
|
195
|
+
}
|
|
231
196
|
} else {
|
|
232
197
|
console.log(chalk.bold.redBright(`No custom components in ${defaultPegaServerConfig.server}`));
|
|
233
198
|
}
|
package/src/tasks/list/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import ora from 'ora';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { showVersion } from '../../util.js';
|
|
4
5
|
|
|
5
6
|
import {
|
|
6
7
|
listLocalComponents,
|
|
@@ -10,8 +11,6 @@ import {
|
|
|
10
11
|
getListComponentsQuestions
|
|
11
12
|
} from './helper.js';
|
|
12
13
|
|
|
13
|
-
import { showVersion } from '../../util.js';
|
|
14
|
-
|
|
15
14
|
const getList = async (sourceOfComponents, answers) => {
|
|
16
15
|
switch (sourceOfComponents) {
|
|
17
16
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
@@ -33,7 +32,7 @@ const getList = async (sourceOfComponents, answers) => {
|
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
export default async options => {
|
|
35
|
+
export default async (options) => {
|
|
37
36
|
showVersion();
|
|
38
37
|
|
|
39
38
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import https from 'https';
|
|
4
3
|
|
|
5
4
|
import fetch from 'node-fetch';
|
|
6
5
|
import AdmZip from 'adm-zip';
|
|
@@ -19,9 +18,9 @@ import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, LP_PUBLISH_COMPONENT_SERVICE_R
|
|
|
19
18
|
export const getPublishComponentQuestions = async () => {
|
|
20
19
|
const components = await getComponents();
|
|
21
20
|
|
|
22
|
-
if (components.length
|
|
21
|
+
if (components.length === 0) {
|
|
23
22
|
console.log(chalk.redBright('No components to publish'));
|
|
24
|
-
process.exit(
|
|
23
|
+
process.exit();
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
@@ -3,14 +3,13 @@ import Listr from 'listr';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
|
-
|
|
7
6
|
import bundleComponent from '../bundle/index.js';
|
|
8
7
|
import { lintComponent } from '../linter/index.js';
|
|
9
|
-
|
|
10
8
|
import { getComponentDirectoryPath, showVersion } from '../../util.js';
|
|
9
|
+
|
|
11
10
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
12
11
|
|
|
13
|
-
export default async options => {
|
|
12
|
+
export default async (options) => {
|
|
14
13
|
showVersion();
|
|
15
14
|
|
|
16
15
|
let componentKey;
|
|
@@ -25,15 +24,11 @@ export default async options => {
|
|
|
25
24
|
const rulesetName = options.params[4];
|
|
26
25
|
const rulesetVersion = options.params[5];
|
|
27
26
|
const dBuild = options.params[6];
|
|
28
|
-
devBuild =
|
|
29
|
-
dBuild === 'y' ||
|
|
30
|
-
dBuild === true ||
|
|
31
|
-
dBuild === 'true') ? true : false;
|
|
27
|
+
devBuild = dBuild === 'Y' || dBuild === 'y' || dBuild === true || dBuild === 'true';
|
|
32
28
|
doFetch = false;
|
|
33
29
|
|
|
34
|
-
content = { componentKey, rulesetName, rulesetVersion, devBuild}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
30
|
+
content = { componentKey, rulesetName, rulesetVersion, devBuild };
|
|
31
|
+
} else {
|
|
37
32
|
const questions = await getPublishComponentQuestions();
|
|
38
33
|
const answers = await inquirer.prompt(questions);
|
|
39
34
|
({ componentKey, sourceMap, devBuild } = answers);
|
|
@@ -43,9 +38,6 @@ export default async options => {
|
|
|
43
38
|
};
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
41
|
const sDevBuild = devBuild ? '(dev build)' : '';
|
|
50
42
|
const tasks = new Listr(
|
|
51
43
|
[
|
|
@@ -65,7 +57,7 @@ export default async options => {
|
|
|
65
57
|
},
|
|
66
58
|
{
|
|
67
59
|
title: `Bundle Component ${sDevBuild}`,
|
|
68
|
-
task: async () =>
|
|
60
|
+
task: async () => bundleComponent(componentKey, sourceMap, devBuild),
|
|
69
61
|
skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
|
|
70
62
|
},
|
|
71
63
|
{
|
|
@@ -87,7 +79,7 @@ export default async options => {
|
|
|
87
79
|
}
|
|
88
80
|
);
|
|
89
81
|
|
|
90
|
-
await tasks.run().catch(err => {
|
|
82
|
+
await tasks.run().catch((err) => {
|
|
91
83
|
console.log(chalk.bold.red(err.toString()));
|
|
92
84
|
});
|
|
93
85
|
return true;
|
|
@@ -7,16 +7,12 @@ import bundleComponent from '../bundle/index.js';
|
|
|
7
7
|
import { lintComponent } from '../linter/index.js';
|
|
8
8
|
import { getComponents, getComponentDirectoryPath, showVersion } from '../../util.js';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
getPublishComponentQuestions,
|
|
12
|
-
publishComponentToServer,
|
|
13
|
-
zipComponent,
|
|
14
|
-
cleanUp
|
|
15
|
-
} from './helper.js';
|
|
10
|
+
import { getPublishComponentQuestions, publishComponentToServer, zipComponent, cleanUp } from './helper.js';
|
|
16
11
|
|
|
17
12
|
export function getCustomTasks(componentKey, sourceMap, devBuild, content, options) {
|
|
18
13
|
const sDevBuild = devBuild ? '(dev build)' : '';
|
|
19
|
-
|
|
14
|
+
// eslint-disable-next-line no-unneeded-ternary
|
|
15
|
+
const doFetch = options.params.length >= 7 ? false : true;
|
|
20
16
|
return new Listr(
|
|
21
17
|
[
|
|
22
18
|
{
|
|
@@ -60,14 +56,14 @@ export function getCustomTasks(componentKey, sourceMap, devBuild, content, optio
|
|
|
60
56
|
);
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
export default async options => {
|
|
59
|
+
export default async (options) => {
|
|
64
60
|
showVersion();
|
|
65
61
|
|
|
66
62
|
const components = await getComponents();
|
|
67
63
|
|
|
68
|
-
if (components.length
|
|
69
|
-
console.log(chalk.redBright(
|
|
70
|
-
process.exit(
|
|
64
|
+
if (components.length === 0) {
|
|
65
|
+
console.log(chalk.redBright('No components to publish'));
|
|
66
|
+
process.exit();
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
let componentKey;
|
|
@@ -79,14 +75,10 @@ export default async options => {
|
|
|
79
75
|
const rulesetName = options.params[3];
|
|
80
76
|
const rulesetVersion = options.params[4];
|
|
81
77
|
const dBuild = options.params[5];
|
|
82
|
-
devBuild =
|
|
83
|
-
dBuild === 'y' ||
|
|
84
|
-
dBuild === true ||
|
|
85
|
-
dBuild === 'true') ? true : false;
|
|
78
|
+
devBuild = dBuild === 'Y' || dBuild === 'y' || dBuild === true || dBuild === 'true';
|
|
86
79
|
|
|
87
|
-
content = { componentKey, rulesetName, rulesetVersion, devBuild}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
80
|
+
content = { componentKey, rulesetName, rulesetVersion, devBuild };
|
|
81
|
+
} else {
|
|
90
82
|
const questions = await getPublishComponentQuestions();
|
|
91
83
|
const answers = await inquirer.prompt(questions);
|
|
92
84
|
({ sourceMap, devBuild } = answers);
|
|
@@ -96,15 +88,14 @@ export default async options => {
|
|
|
96
88
|
};
|
|
97
89
|
}
|
|
98
90
|
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
// eslint-disable-next-line no-shadow
|
|
101
92
|
for (const componentKey of components) {
|
|
102
93
|
console.log(chalk.bold.green(`Publishing: ${componentKey}`));
|
|
103
94
|
|
|
104
95
|
const myCustomTasks = getCustomTasks(componentKey, sourceMap, devBuild, content, options);
|
|
105
96
|
|
|
106
97
|
// eslint-disable-next-line no-await-in-loop
|
|
107
|
-
await myCustomTasks.run().catch(err => {
|
|
98
|
+
await myCustomTasks.run().catch((err) => {
|
|
108
99
|
console.log(chalk.bold.red(err.toString()));
|
|
109
100
|
});
|
|
110
101
|
}
|
|
@@ -32,7 +32,7 @@ export const renamePromotedWebPack = async () => {
|
|
|
32
32
|
}
|
|
33
33
|
catch (ex) {
|
|
34
34
|
console.log(chalk.bold.red(`File ${promoteWebPackDir} not found.`));
|
|
35
|
-
process.exit(
|
|
35
|
+
process.exit();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
console.log(chalk.bold.green(`File ${promoteWebPackDir} marked as not used.`));
|