@pega/custom-dx-components 0.23.6 → 0.23.7
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/auth.js +9 -3
- package/src/tasks/authenticate/index.js +42 -39
- package/src/tasks/build/helper.js +5 -19
- package/src/tasks/bundle/builder/webpack.config.js +2 -4
- package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -1
- package/src/tasks/create/templates/Constellation/Widget/CASE/styles.js.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +6 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +6 -0
- package/src/tasks/create-all/index.js +51 -116
- package/src/tasks/init/index.js +1 -1
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/list/helper.js +8 -6
- package/src/tasks/publish/helper.js +16 -30
- package/src/tasks/publish-all/helper.js +9 -27
- package/src/util.js +43 -78
|
@@ -22,51 +22,32 @@ import {
|
|
|
22
22
|
sanitize,
|
|
23
23
|
validateSemver
|
|
24
24
|
} from '../../util.js';
|
|
25
|
-
import {
|
|
26
|
-
COMPONENT_SCHEMA,
|
|
27
|
-
COMPONENTS_DIRECTORY_PATH,
|
|
28
|
-
TASKS_CONFIG_JSON_FILENAME,
|
|
29
|
-
COMPONENTS_PATH,
|
|
30
|
-
CATEGORY_CONSTELLATION
|
|
31
|
-
} from '../../constants.js';
|
|
25
|
+
import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION } from '../../constants.js';
|
|
32
26
|
|
|
33
27
|
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
34
28
|
|
|
35
29
|
const copy = promisify(ncp);
|
|
36
30
|
|
|
37
|
-
const copyComponentTemplate = async options => {
|
|
31
|
+
const copyComponentTemplate = async (options) => {
|
|
38
32
|
if (options.targetDirectory) {
|
|
39
33
|
return copy(options.templateDirectory, options.targetDirectory, {
|
|
40
34
|
clobber: false
|
|
41
35
|
});
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
36
|
+
} else {
|
|
44
37
|
return copy(options.templateDirectoryConstellation, options.targetDirectoryConstellation, {
|
|
45
38
|
clobber: false,
|
|
46
39
|
filter: (fileName) => {
|
|
47
40
|
// filter out the file config.json or config.json.mustache
|
|
48
|
-
if (fileName.indexOf(
|
|
41
|
+
if (fileName.indexOf('config.json') >= 0) return false;
|
|
49
42
|
else return true;
|
|
50
43
|
}
|
|
51
44
|
});
|
|
52
45
|
}
|
|
53
|
-
|
|
54
46
|
};
|
|
55
47
|
|
|
56
48
|
export const compileMustacheTemplates = async (
|
|
57
49
|
componentDirectory,
|
|
58
|
-
{
|
|
59
|
-
componentKey,
|
|
60
|
-
componentName,
|
|
61
|
-
componentLabel,
|
|
62
|
-
library,
|
|
63
|
-
version,
|
|
64
|
-
type,
|
|
65
|
-
subtype,
|
|
66
|
-
description,
|
|
67
|
-
organization,
|
|
68
|
-
allowedApplications
|
|
69
|
-
}
|
|
50
|
+
{ componentKey, componentName, componentLabel, library, version, type, subtype, description, organization, allowedApplications }
|
|
70
51
|
) => {
|
|
71
52
|
const files = fs.readdirSync(componentDirectory);
|
|
72
53
|
const componentClassName = convertIntoPascalCase(componentKey);
|
|
@@ -83,19 +64,18 @@ export const compileMustacheTemplates = async (
|
|
|
83
64
|
let mustacheSubType = subtype;
|
|
84
65
|
|
|
85
66
|
// overrides
|
|
86
|
-
if (typeof
|
|
67
|
+
if (typeof mustacheSubType == 'string') {
|
|
87
68
|
switch (mustacheSubType) {
|
|
88
|
-
case
|
|
89
|
-
mustacheSubType =
|
|
69
|
+
case 'FORM-region':
|
|
70
|
+
mustacheSubType = 'FORM';
|
|
90
71
|
break;
|
|
91
|
-
case
|
|
92
|
-
mustacheSubType =
|
|
72
|
+
case 'DETAILS-region':
|
|
73
|
+
mustacheSubType = 'DETAILS';
|
|
93
74
|
break;
|
|
94
|
-
case
|
|
95
|
-
mustacheSubType =
|
|
75
|
+
case 'Text-Input':
|
|
76
|
+
mustacheSubType = 'Text';
|
|
96
77
|
break;
|
|
97
78
|
}
|
|
98
|
-
|
|
99
79
|
}
|
|
100
80
|
|
|
101
81
|
if (allowedApplications.trim() === '') {
|
|
@@ -107,8 +87,8 @@ export const compileMustacheTemplates = async (
|
|
|
107
87
|
allowedApplications = [].concat(allowedApplications);
|
|
108
88
|
}
|
|
109
89
|
|
|
110
|
-
allowedApplications = allowedApplications.filter(el => !!el.trim()).map(el => el.trim());
|
|
111
|
-
files.forEach(file => {
|
|
90
|
+
allowedApplications = allowedApplications.filter((el) => !!el.trim()).map((el) => el.trim());
|
|
91
|
+
files.forEach((file) => {
|
|
112
92
|
const filePath = path.join(componentDirectory, file);
|
|
113
93
|
|
|
114
94
|
const output = compileMustacheTemplate(filePath, {
|
|
@@ -133,27 +113,14 @@ export const compileMustacheTemplates = async (
|
|
|
133
113
|
});
|
|
134
114
|
};
|
|
135
115
|
|
|
136
|
-
|
|
137
|
-
export const validateCompileAll = async (
|
|
138
|
-
{
|
|
139
|
-
prefix,
|
|
140
|
-
library,
|
|
141
|
-
version,
|
|
142
|
-
allowedApplications,
|
|
143
|
-
organization
|
|
144
|
-
},
|
|
145
|
-
options,
|
|
146
|
-
|
|
147
|
-
) => {
|
|
148
|
-
|
|
149
|
-
|
|
116
|
+
export const validateCompileAll = async ({ prefix, library, version, allowedApplications, organization }, options) => {
|
|
150
117
|
for (let fieldIdx in COMPONENT_SCHEMA.subtype.field) {
|
|
151
|
-
const type =
|
|
118
|
+
const type = 'Field';
|
|
152
119
|
const subtype = COMPONENT_SCHEMA.subtype.field[fieldIdx].value;
|
|
153
120
|
const prefixNoSpace = prefix.replace(/\s+/g, '');
|
|
154
121
|
const componentNameNoSpace = COMPONENT_SCHEMA.subtype.field[fieldIdx].name.replace(/\s+/g, '');
|
|
155
|
-
const componentName =
|
|
156
|
-
const componentLabel =
|
|
122
|
+
const componentName = ''.concat(prefixNoSpace).concat(componentNameNoSpace);
|
|
123
|
+
const componentLabel = ''.concat(prefix).concat(' ').concat(COMPONENT_SCHEMA.subtype.field[fieldIdx].name);
|
|
157
124
|
const description = componentLabel;
|
|
158
125
|
|
|
159
126
|
await validateCompile(
|
|
@@ -169,23 +136,23 @@ export const validateCompileAll = async (
|
|
|
169
136
|
allowedApplications
|
|
170
137
|
},
|
|
171
138
|
options
|
|
172
|
-
)
|
|
139
|
+
);
|
|
173
140
|
}
|
|
174
141
|
|
|
175
142
|
for (let templateIdx in COMPONENT_SCHEMA.subtype.template) {
|
|
176
|
-
const type =
|
|
143
|
+
const type = 'Template';
|
|
177
144
|
const subtype = COMPONENT_SCHEMA.subtype.template[templateIdx].value;
|
|
178
145
|
const prefixNoSpace = prefix.replace(/\s+/g, '');
|
|
179
|
-
let templateNameOriginal
|
|
180
|
-
let templateName =
|
|
146
|
+
let templateNameOriginal = COMPONENT_SCHEMA.subtype.template[templateIdx].name;
|
|
147
|
+
let templateName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
|
|
181
148
|
let templateLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.template[templateIdx].name);
|
|
182
|
-
if (templateNameOriginal.indexOf(
|
|
183
|
-
let templateNameBase = convertIntoPascalCase(templateNameOriginal.replace(
|
|
184
|
-
templateName =
|
|
185
|
-
templateLabel =
|
|
149
|
+
if (templateNameOriginal.indexOf('region') >= 0) {
|
|
150
|
+
let templateNameBase = convertIntoPascalCase(templateNameOriginal.replace(' region', ''));
|
|
151
|
+
templateName = 'TwoColumn'.concat(templateNameBase);
|
|
152
|
+
templateLabel = 'Two Column '.concat(templateNameBase);
|
|
186
153
|
}
|
|
187
|
-
const componentName =
|
|
188
|
-
const componentLabel =
|
|
154
|
+
const componentName = ''.concat(prefixNoSpace).concat(templateName);
|
|
155
|
+
const componentLabel = ''.concat(prefix).concat(' ').concat(templateLabel);
|
|
189
156
|
const description = componentLabel;
|
|
190
157
|
|
|
191
158
|
await validateCompile(
|
|
@@ -201,22 +168,21 @@ export const validateCompileAll = async (
|
|
|
201
168
|
allowedApplications
|
|
202
169
|
},
|
|
203
170
|
options
|
|
204
|
-
)
|
|
171
|
+
);
|
|
205
172
|
}
|
|
206
173
|
|
|
207
|
-
|
|
208
174
|
for (let widgetIdx in COMPONENT_SCHEMA.subtype.widget) {
|
|
209
|
-
const type =
|
|
175
|
+
const type = 'Widget';
|
|
210
176
|
const subtype = COMPONENT_SCHEMA.subtype.widget[widgetIdx].value;
|
|
211
177
|
const prefixNoSpace = prefix.replace(/\s+/g, '');
|
|
212
|
-
let widgetNameOriginal
|
|
213
|
-
let widgetName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat(
|
|
214
|
-
let widgetLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat(
|
|
215
|
-
if (widgetName.indexOf(
|
|
216
|
-
widgetName = convertIntoPascalCase(widgetNameOriginal.replace(
|
|
178
|
+
let widgetNameOriginal = COMPONENT_SCHEMA.subtype.widget[widgetIdx].name;
|
|
179
|
+
let widgetName = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat('Widget');
|
|
180
|
+
let widgetLabel = convertIntoPascalCase(COMPONENT_SCHEMA.subtype.widget[widgetIdx].name).concat(' Widget');
|
|
181
|
+
if (widgetName.indexOf('&') >= 0) {
|
|
182
|
+
widgetName = convertIntoPascalCase(widgetNameOriginal.replace(' & ', ''));
|
|
217
183
|
}
|
|
218
|
-
const componentName =
|
|
219
|
-
const componentLabel =
|
|
184
|
+
const componentName = ''.concat(prefixNoSpace).concat(widgetName);
|
|
185
|
+
const componentLabel = ''.concat(prefix).concat(' ').concat(widgetLabel);
|
|
220
186
|
const description = componentLabel;
|
|
221
187
|
|
|
222
188
|
await validateCompile(
|
|
@@ -232,32 +198,17 @@ export const validateCompileAll = async (
|
|
|
232
198
|
allowedApplications
|
|
233
199
|
},
|
|
234
200
|
options
|
|
235
|
-
)
|
|
201
|
+
);
|
|
236
202
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
203
|
+
};
|
|
241
204
|
|
|
242
205
|
export const validateCompile = async (
|
|
243
|
-
{
|
|
244
|
-
library,
|
|
245
|
-
organization,
|
|
246
|
-
componentName,
|
|
247
|
-
componentLabel,
|
|
248
|
-
version,
|
|
249
|
-
framework,
|
|
250
|
-
type,
|
|
251
|
-
subtype,
|
|
252
|
-
description,
|
|
253
|
-
allowedApplications
|
|
254
|
-
},
|
|
206
|
+
{ library, organization, componentName, componentLabel, version, framework, type, subtype, description, allowedApplications },
|
|
255
207
|
options
|
|
256
208
|
) => {
|
|
257
|
-
|
|
258
209
|
let sSubType = subtype;
|
|
259
210
|
if (Array.isArray(subtype)) {
|
|
260
|
-
sSubType = subtype.join(
|
|
211
|
+
sSubType = subtype.join('-');
|
|
261
212
|
}
|
|
262
213
|
|
|
263
214
|
const typeLC = type.toLowerCase();
|
|
@@ -269,10 +220,9 @@ export const validateCompile = async (
|
|
|
269
220
|
let pegaConfig = await getPegaConfig();
|
|
270
221
|
let templateParentDir = `./templates/${framework}`;
|
|
271
222
|
|
|
272
|
-
|
|
273
223
|
const templateDir = `${templateParentDir}/${type}/${sSubType}`;
|
|
274
224
|
let templateDirectory = fileURLToPath(new URL(templateDir, import.meta.url));
|
|
275
|
-
templateDirectory = templateDirectory.replace(
|
|
225
|
+
templateDirectory = templateDirectory.replace(path.sep + 'create-all', path.sep + 'create');
|
|
276
226
|
|
|
277
227
|
const componentKey = `${organization}_${library}_${componentName}`;
|
|
278
228
|
|
|
@@ -280,7 +230,6 @@ export const validateCompile = async (
|
|
|
280
230
|
|
|
281
231
|
const components = await getComponents(false);
|
|
282
232
|
|
|
283
|
-
|
|
284
233
|
if (components.includes(componentKey)) {
|
|
285
234
|
console.log(chalk.red(`${componentKey} component already exists in ${targetDirectory}`));
|
|
286
235
|
|
|
@@ -306,14 +255,10 @@ export const validateCompile = async (
|
|
|
306
255
|
allowedApplications
|
|
307
256
|
});
|
|
308
257
|
|
|
309
|
-
|
|
310
258
|
console.log(chalk.green(`created ${componentKey} component in ${targetDirectory}`));
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
259
|
};
|
|
315
260
|
|
|
316
|
-
export default async options => {
|
|
261
|
+
export default async (options) => {
|
|
317
262
|
showVersion();
|
|
318
263
|
|
|
319
264
|
await checkPathAccess(pegaConfigJsonPath);
|
|
@@ -322,9 +267,7 @@ export default async options => {
|
|
|
322
267
|
data = data && JSON.parse(data);
|
|
323
268
|
|
|
324
269
|
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
325
|
-
console.error(
|
|
326
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
327
|
-
);
|
|
270
|
+
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
328
271
|
process.exit(1);
|
|
329
272
|
}
|
|
330
273
|
|
|
@@ -336,7 +279,6 @@ export default async options => {
|
|
|
336
279
|
let componentDefaults = await getComponentDefaults();
|
|
337
280
|
componentDefaults.library = library;
|
|
338
281
|
|
|
339
|
-
|
|
340
282
|
if (options.params.length >= 8) {
|
|
341
283
|
const prefix = options.params[3];
|
|
342
284
|
const version = options.params[4];
|
|
@@ -356,8 +298,7 @@ export default async options => {
|
|
|
356
298
|
},
|
|
357
299
|
options
|
|
358
300
|
);
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
301
|
+
} else {
|
|
361
302
|
const questions = [
|
|
362
303
|
{
|
|
363
304
|
name: 'prefix',
|
|
@@ -367,7 +308,7 @@ export default async options => {
|
|
|
367
308
|
name: 'version',
|
|
368
309
|
message: 'Enter component version',
|
|
369
310
|
default: componentDefaults.version,
|
|
370
|
-
validate: value => {
|
|
311
|
+
validate: (value) => {
|
|
371
312
|
if (validateSemver(value)) {
|
|
372
313
|
return true;
|
|
373
314
|
}
|
|
@@ -378,7 +319,7 @@ export default async options => {
|
|
|
378
319
|
name: 'library',
|
|
379
320
|
message: 'Enter library name (required)',
|
|
380
321
|
default: componentDefaults.library,
|
|
381
|
-
validate: value => {
|
|
322
|
+
validate: (value) => {
|
|
382
323
|
/* value should not be empty
|
|
383
324
|
It should not have spaces
|
|
384
325
|
It should not start with a number
|
|
@@ -397,13 +338,10 @@ export default async options => {
|
|
|
397
338
|
}
|
|
398
339
|
];
|
|
399
340
|
|
|
400
|
-
await inquirer.prompt(questions).then(async answers => {
|
|
401
|
-
const {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
version,
|
|
405
|
-
allowedApplications
|
|
406
|
-
} = answers;
|
|
341
|
+
await inquirer.prompt(questions).then(async (answers) => {
|
|
342
|
+
const { library, version, allowedApplications } = answers;
|
|
343
|
+
let { prefix } = answers;
|
|
344
|
+
prefix = prefix.replace(/\W+/g, '');
|
|
407
345
|
await validateCompileAll(
|
|
408
346
|
{
|
|
409
347
|
prefix,
|
|
@@ -416,7 +354,4 @@ export default async options => {
|
|
|
416
354
|
);
|
|
417
355
|
});
|
|
418
356
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
357
|
};
|
package/src/tasks/init/index.js
CHANGED
|
@@ -124,7 +124,7 @@ export default async (options) => {
|
|
|
124
124
|
task: () => execPromise('npm i --force --production=false', { cwd: options.targetDirectory })
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
|
-
title: 'Installing
|
|
127
|
+
title: 'Installing tasks dependencies',
|
|
128
128
|
task: () => execPromise('npm i --force --production=false', { cwd: options.componentDirectory })
|
|
129
129
|
}
|
|
130
130
|
],
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@pega/configs": "^0.5.3",
|
|
67
|
-
"@pega/custom-dx-components": "^0.23.
|
|
67
|
+
"@pega/custom-dx-components": "^0.23.7",
|
|
68
68
|
"@pega/eslint-config": "^0.3.2",
|
|
69
69
|
"@storybook/addon-actions": "^6.5.12",
|
|
70
70
|
"@storybook/addon-essentials": "^6.5.12",
|
package/src/tasks/list/helper.js
CHANGED
|
@@ -5,7 +5,7 @@ import chalk from 'chalk';
|
|
|
5
5
|
import fetch from 'node-fetch';
|
|
6
6
|
|
|
7
7
|
import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
8
|
-
import { constructCompleteUrl, getComponents, getPegaServerConfig } from '../../util.js';
|
|
8
|
+
import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent } from '../../util.js';
|
|
9
9
|
|
|
10
10
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
11
11
|
SERVER: 'Server',
|
|
@@ -40,12 +40,13 @@ export const listLocalComponents = async (sourceOfComponents) => {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
function fetchComponentsFromInfinity(apiUrl, headers) {
|
|
43
|
+
async function fetchComponentsFromInfinity(apiUrl, headers) {
|
|
44
|
+
const serverConfig = await getPegaServerConfig();
|
|
44
45
|
return new Promise((resolve, reject) => {
|
|
45
46
|
let status = 500;
|
|
46
47
|
fetch(apiUrl, {
|
|
47
48
|
method: 'GET',
|
|
48
|
-
agent:
|
|
49
|
+
agent: getHttpsAgent(serverConfig),
|
|
49
50
|
headers
|
|
50
51
|
})
|
|
51
52
|
.then((response) => {
|
|
@@ -69,7 +70,8 @@ function fetchComponentsFromInfinity(apiUrl, headers) {
|
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
function fetchComponentsFromLaunchpad(apiUrl, headers) {
|
|
73
|
+
async function fetchComponentsFromLaunchpad(apiUrl, headers) {
|
|
74
|
+
const serverConfig = await getPegaServerConfig();
|
|
73
75
|
// constucting urls for all type of components
|
|
74
76
|
const urls = COMPONENT_SCHEMA.type.map((type) => apiUrl.replace('{type}', type.value));
|
|
75
77
|
const statuses = [];
|
|
@@ -79,7 +81,7 @@ function fetchComponentsFromLaunchpad(apiUrl, headers) {
|
|
|
79
81
|
urls.map(async (url) => {
|
|
80
82
|
return fetch(url, {
|
|
81
83
|
method: 'GET',
|
|
82
|
-
agent:
|
|
84
|
+
agent: getHttpsAgent(serverConfig),
|
|
83
85
|
headers
|
|
84
86
|
});
|
|
85
87
|
})
|
|
@@ -150,7 +152,7 @@ export const getComponentsFromServer = async () => {
|
|
|
150
152
|
|
|
151
153
|
fetch(url, {
|
|
152
154
|
method: 'GET',
|
|
153
|
-
agent:
|
|
155
|
+
agent: getHttpsAgent(defaultPegaServerConfig),
|
|
154
156
|
headers
|
|
155
157
|
})
|
|
156
158
|
.then(response => {
|
|
@@ -11,19 +11,16 @@ import {
|
|
|
11
11
|
getComponentDirectoryPath,
|
|
12
12
|
getComponents,
|
|
13
13
|
getPegaServerConfig,
|
|
14
|
-
validateRulesetVersion
|
|
14
|
+
validateRulesetVersion,
|
|
15
|
+
getHttpsAgent
|
|
15
16
|
} from '../../util.js';
|
|
16
|
-
import {
|
|
17
|
-
PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
18
|
-
LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
19
|
-
TOKEN_PATH
|
|
20
|
-
} from '../../constants.js';
|
|
17
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
21
18
|
|
|
22
19
|
export const getPublishComponentQuestions = async () => {
|
|
23
20
|
const components = await getComponents();
|
|
24
21
|
|
|
25
22
|
if (components.length == 0) {
|
|
26
|
-
console.log(chalk.redBright(
|
|
23
|
+
console.log(chalk.redBright('No components to publish'));
|
|
27
24
|
process.exit(1);
|
|
28
25
|
}
|
|
29
26
|
|
|
@@ -40,7 +37,7 @@ export const getPublishComponentQuestions = async () => {
|
|
|
40
37
|
name: 'rulesetName',
|
|
41
38
|
message: 'Enter ruleset name',
|
|
42
39
|
default: defaultPegaConfig.rulesetName,
|
|
43
|
-
validate: value => {
|
|
40
|
+
validate: (value) => {
|
|
44
41
|
if (value.trim()) {
|
|
45
42
|
return true;
|
|
46
43
|
}
|
|
@@ -54,7 +51,7 @@ export const getPublishComponentQuestions = async () => {
|
|
|
54
51
|
name: 'rulesetVersion',
|
|
55
52
|
message: 'Enter ruleset version',
|
|
56
53
|
default: defaultPegaConfig.rulesetVersion,
|
|
57
|
-
validate: value => {
|
|
54
|
+
validate: (value) => {
|
|
58
55
|
if (validateRulesetVersion(value)) {
|
|
59
56
|
return true;
|
|
60
57
|
}
|
|
@@ -109,10 +106,7 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
109
106
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
110
107
|
const { serverType, isolationId } = defaultPegaServerConfig;
|
|
111
108
|
const isLaunchpad = serverType === 'launchpad';
|
|
112
|
-
const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace(
|
|
113
|
-
'{isolationId}',
|
|
114
|
-
isolationId
|
|
115
|
-
);
|
|
109
|
+
const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace('{isolationId}', isolationId);
|
|
116
110
|
let apiBody;
|
|
117
111
|
|
|
118
112
|
if (isLaunchpad) {
|
|
@@ -136,10 +130,7 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
136
130
|
}
|
|
137
131
|
|
|
138
132
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
139
|
-
const url = constructCompleteUrl(
|
|
140
|
-
defaultPegaConfig.server,
|
|
141
|
-
isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
|
|
142
|
-
);
|
|
133
|
+
const url = constructCompleteUrl(defaultPegaConfig.server, isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT);
|
|
143
134
|
|
|
144
135
|
if (doFetch) {
|
|
145
136
|
try {
|
|
@@ -151,9 +142,9 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
151
142
|
// refresh_token: refreshToken
|
|
152
143
|
} = JSON.parse(OauthData);
|
|
153
144
|
let status = 500;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
const headers = {
|
|
146
|
+
Authorization: `${tokenType} ${accessToken}`
|
|
147
|
+
};
|
|
157
148
|
|
|
158
149
|
if (isLaunchpad) {
|
|
159
150
|
headers.cookie = `Pega-AAT=${accessToken}`;
|
|
@@ -162,20 +153,18 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
162
153
|
|
|
163
154
|
fetch(url, {
|
|
164
155
|
method: 'POST',
|
|
165
|
-
agent:
|
|
156
|
+
agent: getHttpsAgent(defaultPegaConfig),
|
|
166
157
|
headers,
|
|
167
158
|
body: JSON.stringify(apiBody)
|
|
168
159
|
})
|
|
169
|
-
|
|
160
|
+
.then((response) => {
|
|
170
161
|
status = response.status;
|
|
171
162
|
return response.text();
|
|
172
163
|
})
|
|
173
|
-
|
|
164
|
+
.then((resp) => {
|
|
174
165
|
const respData = isLaunchpad ? resp : JSON.parse(resp);
|
|
175
166
|
if (status === 401) {
|
|
176
|
-
throw new Error(
|
|
177
|
-
'Error occurred in authentication. Please regenerate using authenticate'
|
|
178
|
-
);
|
|
167
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
179
168
|
// console.log(accessTokenUri, refreshToken);
|
|
180
169
|
/* TODO - Handle refresh_token */
|
|
181
170
|
} else if (status === 200 || status === 201) {
|
|
@@ -184,7 +173,7 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
184
173
|
throw new Error(`${respData.message}`);
|
|
185
174
|
}
|
|
186
175
|
})
|
|
187
|
-
|
|
176
|
+
.catch((e) => {
|
|
188
177
|
if (e.code === 'ECONNREFUSED') {
|
|
189
178
|
// eslint-disable-next-line prefer-promise-reject-errors
|
|
190
179
|
Promise.reject(`${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
@@ -202,8 +191,5 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
202
191
|
} catch (err) {
|
|
203
192
|
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
204
193
|
}
|
|
205
|
-
|
|
206
194
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
195
|
};
|
|
@@ -6,17 +6,8 @@ import fetch from 'node-fetch';
|
|
|
6
6
|
import AdmZip from 'adm-zip';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
getComponentDirectoryPath,
|
|
12
|
-
getPegaServerConfig,
|
|
13
|
-
validateRulesetVersion
|
|
14
|
-
} from '../../util.js';
|
|
15
|
-
import {
|
|
16
|
-
PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
17
|
-
LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
18
|
-
TOKEN_PATH
|
|
19
|
-
} from '../../constants.js';
|
|
9
|
+
import { constructCompleteUrl, getComponentDirectoryPath, getPegaServerConfig, validateRulesetVersion, getHttpsAgent } from '../../util.js';
|
|
10
|
+
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
20
11
|
|
|
21
12
|
export const getPublishComponentQuestions = async () => {
|
|
22
13
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
@@ -108,10 +99,7 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
108
99
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
109
100
|
const { serverType, isolationId } = defaultPegaServerConfig;
|
|
110
101
|
const isLaunchpad = serverType === 'launchpad';
|
|
111
|
-
const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace(
|
|
112
|
-
'{isolationId}',
|
|
113
|
-
isolationId
|
|
114
|
-
);
|
|
102
|
+
const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace('{isolationId}', isolationId);
|
|
115
103
|
let apiBody;
|
|
116
104
|
|
|
117
105
|
if (isLaunchpad) {
|
|
@@ -135,10 +123,7 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
135
123
|
}
|
|
136
124
|
|
|
137
125
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
138
|
-
const url = constructCompleteUrl(
|
|
139
|
-
defaultPegaConfig.server,
|
|
140
|
-
isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT
|
|
141
|
-
);
|
|
126
|
+
const url = constructCompleteUrl(defaultPegaConfig.server, isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT);
|
|
142
127
|
|
|
143
128
|
if (doFetch) {
|
|
144
129
|
try {
|
|
@@ -161,20 +146,18 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
161
146
|
|
|
162
147
|
fetch(url, {
|
|
163
148
|
method: 'POST',
|
|
164
|
-
agent:
|
|
149
|
+
agent: getHttpsAgent(defaultPegaConfig),
|
|
165
150
|
headers,
|
|
166
151
|
body: JSON.stringify(apiBody)
|
|
167
152
|
})
|
|
168
|
-
|
|
153
|
+
.then((response) => {
|
|
169
154
|
status = response.status;
|
|
170
155
|
return response.text();
|
|
171
156
|
})
|
|
172
|
-
|
|
157
|
+
.then((resp) => {
|
|
173
158
|
const respData = isLaunchpad ? resp : JSON.parse(resp);
|
|
174
159
|
if (status === 401) {
|
|
175
|
-
throw new Error(
|
|
176
|
-
'Error occurred in authentication. Please regenerate using authenticate'
|
|
177
|
-
);
|
|
160
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
178
161
|
// console.log(accessTokenUri, refreshToken);
|
|
179
162
|
/* TODO - Handle refresh_token */
|
|
180
163
|
} else if (status === 200 || status === 201) {
|
|
@@ -183,7 +166,7 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
183
166
|
throw new Error(`${respData.message}`);
|
|
184
167
|
}
|
|
185
168
|
})
|
|
186
|
-
|
|
169
|
+
.catch((e) => {
|
|
187
170
|
if (e.code === 'ECONNREFUSED') {
|
|
188
171
|
// eslint-disable-next-line prefer-promise-reject-errors
|
|
189
172
|
Promise.reject(`${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
@@ -202,5 +185,4 @@ export const publishComponentToServer = async (data, doFetch) => {
|
|
|
202
185
|
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
203
186
|
}
|
|
204
187
|
}
|
|
205
|
-
|
|
206
188
|
};
|