@pega/custom-dx-components 0.23.38 → 0.23.39
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
CHANGED
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@pega/configs": "^0.6.0",
|
|
72
|
-
"@pega/custom-dx-components": "0.23.
|
|
72
|
+
"@pega/custom-dx-components": "0.23.39",
|
|
73
73
|
"@pega/pcore-pconnect-typedefs": "~2.1.1",
|
|
74
74
|
"@storybook/addon-actions": "^7.6.7",
|
|
75
75
|
"@storybook/addon-essentials": "^7.6.7",
|
package/src/util.js
CHANGED
|
@@ -25,16 +25,20 @@ import {
|
|
|
25
25
|
|
|
26
26
|
const access = promisify(fs.access);
|
|
27
27
|
|
|
28
|
-
export const checkPathAccess = async (path, options = {}) => {
|
|
28
|
+
export const checkPathAccess = async (path, options = {}, throwError = false) => {
|
|
29
29
|
const { errorMessage } = options;
|
|
30
30
|
|
|
31
31
|
try {
|
|
32
32
|
await access(path, fs.constants.R_OK);
|
|
33
33
|
} catch (err) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (throwError) {
|
|
35
|
+
throw new Error(err);
|
|
36
|
+
} else {
|
|
37
|
+
const message =
|
|
38
|
+
errorMessage || `${chalk.red.bold('ERROR')} Could not able to access path - ${path}`;
|
|
39
|
+
console.error(message);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
44
|
|
|
@@ -42,7 +46,14 @@ export const getUseWebPackPromotion = async () => {
|
|
|
42
46
|
const currentDirectory = process.cwd();
|
|
43
47
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
try {
|
|
50
|
+
// force to throw error and not console log
|
|
51
|
+
await checkPathAccess(pegaConfigJsonPath, {}, true);
|
|
52
|
+
} catch (ex) {
|
|
53
|
+
// when can't find it, always be false, assume no webpack override.
|
|
54
|
+
// This is IMPORTANT for init (npx install)
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
46
57
|
|
|
47
58
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
48
59
|
data = JSON.parse(data);
|
|
@@ -61,10 +72,9 @@ export const getUseWebPackPromotion = async () => {
|
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
return data[USE_PROMOTED_WEB_PACK];
|
|
75
|
+
};
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export const updateUseWebPackPromotion = async ( useValue = false ) => {
|
|
77
|
+
export const updateUseWebPackPromotion = async (useValue = false) => {
|
|
68
78
|
const currentDirectory = process.cwd();
|
|
69
79
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
70
80
|
|
|
@@ -80,11 +90,10 @@ export const updateUseWebPackPromotion = async ( useValue = false ) => {
|
|
|
80
90
|
process.exit(1);
|
|
81
91
|
}
|
|
82
92
|
|
|
83
|
-
data
|
|
93
|
+
data.usePromotedWebPack = useValue;
|
|
84
94
|
|
|
85
95
|
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8' });
|
|
86
|
-
|
|
87
|
-
}
|
|
96
|
+
};
|
|
88
97
|
|
|
89
98
|
export const deleteLocalComponent = async componentKey => {
|
|
90
99
|
const currentDirectory = process.cwd();
|
|
@@ -421,55 +430,37 @@ export const deleteInfinityServerComponent = async componentKey => {
|
|
|
421
430
|
status = response.status;
|
|
422
431
|
if (!response.ok) {
|
|
423
432
|
if (status === 401) {
|
|
424
|
-
throw new Error(
|
|
425
|
-
'Error occurred in authentication. Please regenerate using authenticate'
|
|
426
|
-
);
|
|
433
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
427
434
|
// console.log(accessTokenUri, refreshToken);
|
|
428
435
|
/* TODO - Handle refresh_token */
|
|
429
|
-
}
|
|
430
|
-
else if (status === 404){
|
|
436
|
+
} else if (status === 404) {
|
|
431
437
|
throw new Error('404: Server resource not found');
|
|
432
|
-
}
|
|
433
|
-
else if (status === 405){
|
|
438
|
+
} else if (status === 405) {
|
|
434
439
|
throw new Error('405: Server method not allowed');
|
|
435
|
-
}
|
|
436
|
-
else if (status === 408){
|
|
440
|
+
} else if (status === 408) {
|
|
437
441
|
throw new Error('408: Server timed out');
|
|
442
|
+
} else if (response.status === 403) {
|
|
443
|
+
throw new Error('Error forbidden: User does not have privileges to Publish.');
|
|
438
444
|
}
|
|
439
|
-
else if (response.status === 403) {
|
|
440
|
-
throw new Error(
|
|
441
|
-
'Error forbidden: User does not have privileges to Publish.'
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
446
445
|
}
|
|
447
446
|
|
|
448
447
|
try {
|
|
449
448
|
const respData = await response.json();
|
|
450
|
-
console.log(
|
|
451
|
-
chalk.bold.green(`Success : ${respData.message}`)
|
|
452
|
-
);
|
|
449
|
+
console.log(chalk.bold.green(`Success : ${respData.message}`));
|
|
453
450
|
|
|
454
451
|
if (status === 500) {
|
|
455
452
|
status = 999;
|
|
456
453
|
throw new Error(respData.message);
|
|
457
454
|
}
|
|
458
|
-
}
|
|
459
|
-
catch (err) {
|
|
455
|
+
} catch (err) {
|
|
460
456
|
if (status === 500) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
else if (status === 999) {
|
|
466
|
-
throw new Error (err);
|
|
457
|
+
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
458
|
+
} else if (status === 999) {
|
|
459
|
+
throw new Error(err);
|
|
467
460
|
}
|
|
468
461
|
}
|
|
469
|
-
|
|
470
462
|
}
|
|
471
463
|
} catch (error) {
|
|
472
|
-
|
|
473
464
|
throw new Error(error);
|
|
474
465
|
}
|
|
475
466
|
};
|
|
@@ -501,7 +492,6 @@ export const deleteLaunchpadServerComponent = async componentKey => {
|
|
|
501
492
|
componentName
|
|
502
493
|
};
|
|
503
494
|
|
|
504
|
-
|
|
505
495
|
const response = await fetch(deleteUrl, {
|
|
506
496
|
method: 'DELETE',
|
|
507
497
|
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
@@ -512,47 +502,33 @@ export const deleteLaunchpadServerComponent = async componentKey => {
|
|
|
512
502
|
status = response.status;
|
|
513
503
|
if (!response.ok) {
|
|
514
504
|
if (status === 401) {
|
|
515
|
-
throw new Error(
|
|
516
|
-
'Error occurred in authentication. Please regenerate using authenticate'
|
|
517
|
-
);
|
|
505
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
518
506
|
// console.log(accessTokenUri, refreshToken);
|
|
519
507
|
/* TODO - Handle refresh_token */
|
|
520
|
-
}
|
|
521
|
-
else if (status === 404){
|
|
508
|
+
} else if (status === 404) {
|
|
522
509
|
throw new Error('404: Server resource not found');
|
|
523
|
-
}
|
|
524
|
-
else if (status === 405){
|
|
510
|
+
} else if (status === 405) {
|
|
525
511
|
throw new Error('405: Server method not allowed');
|
|
526
|
-
}
|
|
527
|
-
else if (status === 408){
|
|
512
|
+
} else if (status === 408) {
|
|
528
513
|
throw new Error('408: Server timed out');
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
throw new Error(
|
|
532
|
-
'Error forbidden: User does not have privileges to Publish.'
|
|
533
|
-
);
|
|
514
|
+
} else if (response.status === 403) {
|
|
515
|
+
throw new Error('Error forbidden: User does not have privileges to Publish.');
|
|
534
516
|
}
|
|
535
517
|
}
|
|
536
518
|
|
|
537
519
|
try {
|
|
538
520
|
const respData = await response.text();
|
|
539
|
-
console.log(
|
|
540
|
-
chalk.bold.green(`Success : ${respData}`)
|
|
541
|
-
);
|
|
521
|
+
console.log(chalk.bold.green(`Success : ${respData}`));
|
|
542
522
|
|
|
543
523
|
if (status === 500) {
|
|
544
524
|
status = 999;
|
|
545
525
|
throw new Error(respData.message);
|
|
546
526
|
}
|
|
547
|
-
}
|
|
548
|
-
catch (err) {
|
|
527
|
+
} catch (err) {
|
|
549
528
|
if (status === 500) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
else if (status === 999) {
|
|
555
|
-
throw new Error (err);
|
|
529
|
+
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
530
|
+
} else if (status === 999) {
|
|
531
|
+
throw new Error(err);
|
|
556
532
|
}
|
|
557
533
|
}
|
|
558
534
|
}
|