@pega/custom-dx-components 0.242.25 → 0.242.27
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 +2 -1
- package/src/cli.js +44 -2
- package/src/constants.js +2 -0
- package/src/tasks/build-all/helper.js +1 -1
- package/src/tasks/build-all/index.js +4 -3
- package/src/tasks/build-comp/helper.js +7 -4
- package/src/tasks/build-comp/index.js +4 -2
- package/src/tasks/build-jest-assets/index.js +1 -1
- package/src/tasks/build-lib/helper.js +2 -34
- package/src/tasks/build-lib/index.js +36 -85
- package/src/tasks/create/index.js +31 -19
- package/src/tasks/create-all/index.js +31 -16
- package/src/tasks/create-lib/helper.js +80 -0
- package/src/tasks/create-lib/index.js +109 -0
- package/src/tasks/create-version/helper.js +81 -0
- package/src/tasks/create-version/index.js +108 -0
- package/src/tasks/delete/index.js +7 -4
- package/src/tasks/delete-all/index.js +14 -9
- package/src/tasks/delete-lib/helper.js +19 -46
- package/src/tasks/delete-lib/index.js +107 -49
- package/src/tasks/delete-pub/helper.js +35 -0
- package/src/tasks/delete-pub/index.js +105 -0
- package/src/tasks/index.js +7 -0
- package/src/tasks/init/helper.js +5 -5
- package/src/tasks/init/template/package.json.mustache +15 -6
- package/src/tasks/list/helper.js +28 -13
- package/src/tasks/list/index.js +4 -9
- package/src/tasks/list-lib/helper.js +18 -53
- package/src/tasks/list-lib/index.js +68 -110
- package/src/tasks/list-pub/helper.js +42 -0
- package/src/tasks/list-pub/index.js +170 -0
- package/src/tasks/promote-webpack/index.js +1 -1
- package/src/tasks/publish/helper.js +44 -44
- package/src/tasks/publish/index.js +70 -5
- package/src/tasks/publish-all/index.js +10 -2
- package/src/tasks/publish-lib/helper.js +0 -38
- package/src/tasks/publish-lib/index.js +39 -13
- package/src/tasks/rename/index.js +25 -10
- package/src/tasks/rename-lib/index.js +8 -41
- package/src/tasks/revert-webpack/index.js +1 -1
- package/src/tasks/show-status/index.js +41 -0
- package/src/tasks/switch-lib/helper.js +81 -0
- package/src/tasks/switch-lib/index.js +134 -0
- package/src/tasks/switch-version/helper.js +92 -0
- package/src/tasks/switch-version/index.js +142 -0
- package/src/util.js +728 -59
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
|
-
|
|
3
2
|
import chalk from 'chalk';
|
|
4
3
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import {
|
|
5
|
+
showVersion,
|
|
6
|
+
getLibraryBased,
|
|
7
|
+
checkLibraryAndArchives,
|
|
8
|
+
addDebugLog,
|
|
9
|
+
getConfigDefaults,
|
|
10
|
+
getLibraryArchivesVersions,
|
|
11
|
+
deleteLocalArchiveLibrary,
|
|
12
|
+
deleteLocalArchiveLibraryVersion,
|
|
13
|
+
deleteLocalComponent,
|
|
14
|
+
getComponents,
|
|
15
|
+
getLibraryArchiveDirectories,
|
|
16
|
+
deleteArchives,
|
|
17
|
+
forceDefaultsUpdate,
|
|
18
|
+
restoreFromArchive } from '../../util.js';
|
|
19
|
+
|
|
20
|
+
import { getDeleteLibraryQuestions, getLibraryVersionQuestion } from './helper.js';
|
|
21
|
+
import { showCurrentStatus } from '../show-status/index.js';
|
|
22
|
+
|
|
23
|
+
const isLibraryBased = getLibraryBased();
|
|
13
24
|
|
|
14
25
|
export default async (options) => {
|
|
15
26
|
if (!isLibraryBased) {
|
|
@@ -18,6 +29,7 @@ export default async (options) => {
|
|
|
18
29
|
}
|
|
19
30
|
|
|
20
31
|
await showVersion();
|
|
32
|
+
await checkLibraryAndArchives();
|
|
21
33
|
|
|
22
34
|
addDebugLog("deleteLibrary", "", "+");
|
|
23
35
|
|
|
@@ -27,13 +39,13 @@ addDebugLog("deleteLibrary", "", "+");
|
|
|
27
39
|
let version;
|
|
28
40
|
let devBuild;
|
|
29
41
|
|
|
30
|
-
const compDef =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
const compDef = getConfigDefaults();
|
|
43
|
+
let libraryName;
|
|
44
|
+
let libVersions = [];
|
|
45
|
+
let confirmDeletion;
|
|
34
46
|
|
|
35
47
|
if (options.params.length >= 5) {
|
|
36
|
-
|
|
48
|
+
libraryName = options.params[3];
|
|
37
49
|
version = options.params[4];
|
|
38
50
|
|
|
39
51
|
}
|
|
@@ -41,63 +53,109 @@ addDebugLog("deleteLibrary", "", "+");
|
|
|
41
53
|
|
|
42
54
|
const questions = await getDeleteLibraryQuestions();
|
|
43
55
|
const answers = await inquirer.prompt(questions);
|
|
44
|
-
({
|
|
56
|
+
({ libraryName } = answers);
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
try {
|
|
59
|
+
libVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
60
|
+
}
|
|
61
|
+
catch (ex) {}
|
|
48
62
|
|
|
49
|
-
let libVersions = [];
|
|
50
|
-
try {
|
|
51
|
-
libVersions = await getLocalLibraryVersions(libraryName);
|
|
52
|
-
}
|
|
53
|
-
catch (ex) {}
|
|
54
63
|
|
|
64
|
+
if (libVersions.length > 0) {
|
|
65
|
+
// ALL option
|
|
55
66
|
|
|
56
|
-
if (libVersions.length >
|
|
57
|
-
// ALL option
|
|
67
|
+
if (libVersions.length > 1) {
|
|
58
68
|
libVersions.unshift('ALL');
|
|
69
|
+
}
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
const versionQuestions = await getLibraryVersionQuestion(libraryName, libVersions);
|
|
72
|
+
const versionAnswers = await inquirer.prompt(versionQuestions);
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
({version, confirmDeletion} = versionAnswers);
|
|
64
75
|
|
|
76
|
+
if (!confirmDeletion) {
|
|
77
|
+
console.log(chalk.green(`Library not deleted.`));
|
|
78
|
+
process.exit();
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
console.log(chalk.
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
|
|
81
|
+
if (libraryName === compDef.currentOrgLib && (version === "ALL" || version === compDef.buildVersion)) {
|
|
82
|
+
console.log(`\n${chalk.bold.yellow(`${compDef.displayLibVersion}`)} is your ${chalk.yellow('CURRENT')} library/version.`);
|
|
83
|
+
console.log(chalk.bold.yellow('Your current components will be DELETED!!!'))
|
|
84
|
+
const confirmAnswers = await inquirer.prompt([
|
|
85
|
+
{
|
|
86
|
+
name: 'confirmDeletion',
|
|
87
|
+
type: 'confirm',
|
|
88
|
+
message: 'Ok to delete?',
|
|
89
|
+
default: false
|
|
90
|
+
}
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
if (!confirmAnswers.confirmDeletion) {
|
|
94
|
+
console.log(chalk.green(`Library not deleted.`));
|
|
95
|
+
process.exit();
|
|
96
|
+
}
|
|
71
97
|
|
|
72
98
|
}
|
|
73
99
|
|
|
74
100
|
}
|
|
101
|
+
else {
|
|
102
|
+
// No library with that name
|
|
103
|
+
console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
|
|
104
|
+
addDebugLog("deleteLibrary", "END", "-");
|
|
105
|
+
process.exit();
|
|
106
|
+
|
|
107
|
+
}
|
|
75
108
|
|
|
76
109
|
}
|
|
77
110
|
|
|
111
|
+
// so if going to remove the only version, then remove ALL
|
|
112
|
+
if (version === 'ALL' || libVersions.length == 1) {
|
|
113
|
+
await deleteLocalArchiveLibrary(libraryName);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
await deleteLocalArchiveLibraryVersion(libraryName, version);
|
|
117
|
+
}
|
|
78
118
|
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
119
|
+
if (libraryName === compDef.currentOrgLib && (version === "ALL" || version === compDef.buildVersion)) {
|
|
120
|
+
// delete all components
|
|
121
|
+
const localComponents = await getComponents()
|
|
122
|
+
for (const component of localComponents) {
|
|
123
|
+
// console.log(chalk.bold.green("Deleting: " + componentToDelete));
|
|
124
|
+
// eslint-disable-next-line no-await-in-loop
|
|
125
|
+
await deleteLocalComponent(component);
|
|
85
126
|
}
|
|
86
127
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
128
|
+
// switch to another version, if no versions to switch to then delete /archives so will be back to state of nothing
|
|
129
|
+
const archiveLibraries = await getLibraryArchiveDirectories("");
|
|
130
|
+
if (archiveLibraries && archiveLibraries.length > 0) {
|
|
131
|
+
if (archiveLibraries.includes(libraryName)) {
|
|
132
|
+
const archLibVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
133
|
+
const lastVersion = archLibVersions[archLibVersions.length -1];
|
|
134
|
+
const switchToFileName = `${libraryName}_${lastVersion}.zip`;
|
|
135
|
+
await restoreFromArchive(switchToFileName, libraryName, lastVersion);
|
|
91
136
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
137
|
+
await forceDefaultsUpdate();
|
|
138
|
+
await showCurrentStatus();
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// pick first
|
|
143
|
+
const newLib = archiveLibraries[0];
|
|
144
|
+
const archLibVersions = await getLibraryArchivesVersions(newLib, "");
|
|
145
|
+
const lastVersion = archLibVersions[archLibVersions.length -1];
|
|
146
|
+
const switchToFileName = `${newLib}_${lastVersion}.zip`;
|
|
147
|
+
await restoreFromArchive(switchToFileName, newLib, lastVersion);
|
|
148
|
+
|
|
149
|
+
await forceDefaultsUpdate();
|
|
150
|
+
await showCurrentStatus();
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
// no libraries, so remove "/archives"
|
|
156
|
+
await deleteArchives();
|
|
96
157
|
}
|
|
97
158
|
|
|
98
|
-
addDebugLog("deleteLib", "services call", "");
|
|
99
|
-
await deleteLib(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
100
|
-
addDebugLog("deleteLib", "services end", "");
|
|
101
159
|
}
|
|
102
160
|
|
|
103
161
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getPegaServerConfig, addDebugLog } from '../../util.js';
|
|
3
|
+
|
|
4
|
+
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
5
|
+
SERVER: 'Server',
|
|
6
|
+
LOCAL: 'Local'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const getDeleteLibraryQuestions = async () => {
|
|
11
|
+
addDebugLog("getDeleteLibraryQuestions", "", "");
|
|
12
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
13
|
+
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: 'sourceOfLibrary',
|
|
17
|
+
type: 'rawlist',
|
|
18
|
+
message: 'Delete library from Server or Local ?',
|
|
19
|
+
choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
|
|
20
|
+
default: defaultPegaConfig.sourceOfComponents
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const getLibraryVersionQuestion = async (libraryName, libVersions) => {
|
|
26
|
+
addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}`, "");
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
name: 'version',
|
|
30
|
+
type: 'rawlist',
|
|
31
|
+
message: `Select ${chalk.green.bold(`${libraryName}`)} library version (or ALL) to delete`,
|
|
32
|
+
choices: libVersions
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
import { showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion, addDebugLog, getConfigDefaults } from '../../util.js';
|
|
6
|
+
import { deleteLib } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
7
|
+
|
|
8
|
+
import { getDeleteLibraryQuestions, getLibraryVersionQuestion, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
|
|
9
|
+
|
|
10
|
+
const isLibraryBased = getLibraryBased();
|
|
11
|
+
|
|
12
|
+
export default async (options) => {
|
|
13
|
+
if (!isLibraryBased) {
|
|
14
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
|
|
15
|
+
process.exit();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await showVersion();
|
|
19
|
+
|
|
20
|
+
addDebugLog("deletePublished", "", "+");
|
|
21
|
+
|
|
22
|
+
let sourceOfLibrary;
|
|
23
|
+
let organization;
|
|
24
|
+
let library;
|
|
25
|
+
let version;
|
|
26
|
+
|
|
27
|
+
const compDef = getConfigDefaults();
|
|
28
|
+
organization = compDef.organization;
|
|
29
|
+
library = compDef.library;
|
|
30
|
+
const libraryName = compDef.currentOrgLib;
|
|
31
|
+
|
|
32
|
+
if (options.params.length >= 5) {
|
|
33
|
+
sourceOfLibrary = options.params[3];
|
|
34
|
+
version = options.params[4];
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
|
|
39
|
+
const questions = await getDeleteLibraryQuestions();
|
|
40
|
+
const answers = await inquirer.prompt(questions);
|
|
41
|
+
({ sourceOfLibrary } = answers);
|
|
42
|
+
|
|
43
|
+
if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
|
|
44
|
+
// local
|
|
45
|
+
|
|
46
|
+
let libVersions = [];
|
|
47
|
+
try {
|
|
48
|
+
libVersions = await getLocalLibraryVersions(libraryName);
|
|
49
|
+
}
|
|
50
|
+
catch (ex) {}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if (libVersions.length > 0) {
|
|
54
|
+
// ALL option
|
|
55
|
+
libVersions.unshift('ALL');
|
|
56
|
+
|
|
57
|
+
const versionQuestions = await getLibraryVersionQuestion(libraryName, libVersions);
|
|
58
|
+
const versionAnswers = await inquirer.prompt(versionQuestions);
|
|
59
|
+
|
|
60
|
+
({version} = versionAnswers);
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// No library with that name
|
|
65
|
+
console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
|
|
66
|
+
addDebugLog("deletePublished", "END", "-");
|
|
67
|
+
process.exit(1);
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
|
|
77
|
+
if (version === 'ALL') {
|
|
78
|
+
await deleteLocalLibrary(libraryName);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
await deleteLocalLibraryVersion(libraryName, version);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// server
|
|
87
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
88
|
+
|
|
89
|
+
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
90
|
+
console.log(chalk.redBright("Need to authenticate, missing services token.\nDeleting a library requires authentication to acquire a token to delete."));
|
|
91
|
+
addDebugLog("deletePublished", "END", "-");
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
addDebugLog("deleteLib", "services call", "");
|
|
96
|
+
await deleteLib(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
97
|
+
addDebugLog("deleteLib", "services end", "");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
addDebugLog("deletePublished", "END", "-");
|
|
103
|
+
|
|
104
|
+
return true;
|
|
105
|
+
};
|
package/src/tasks/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export { default as createComponent } from './create/index.js';
|
|
2
2
|
export { default as createAllComponents } from './create-all/index.js';
|
|
3
|
+
export { default as createLibrary } from './create-lib/index.js';
|
|
4
|
+
export { default as switchLibrary } from './switch-lib/index.js';
|
|
5
|
+
export { default as createVersion } from './create-version/index.js';
|
|
6
|
+
export { default as switchVersion } from './switch-version/index.js';
|
|
3
7
|
export { default as deleteComponent } from './delete/index.js';
|
|
4
8
|
export { default as deleteAllComponents } from './delete-all/index.js';
|
|
5
9
|
export { default as deleteLibrary } from './delete-lib/index.js';
|
|
10
|
+
export { default as deletePublished } from './delete-pub/index.js';
|
|
6
11
|
export { default as initProject } from './init/index.js';
|
|
7
12
|
export { default as promoteWebPack } from './promote-webpack/index.js';
|
|
8
13
|
export { default as publishComponent } from './publish/index.js';
|
|
@@ -13,6 +18,8 @@ export { default as renameLibrary } from './rename-lib/index.js';
|
|
|
13
18
|
export { default as revertWebPack } from './revert-webpack/index.js';
|
|
14
19
|
export { default as listComponents } from './list/index.js';
|
|
15
20
|
export { default as listLibrary } from './list-lib/index.js';
|
|
21
|
+
export { default as listPublished } from './list-pub/index.js';
|
|
22
|
+
export { default as showStatus } from './show-status/index.js';
|
|
16
23
|
export { default as updateComponent } from './update/index.js';
|
|
17
24
|
export { default as validate } from './validator/index.js';
|
|
18
25
|
export { default as authenticate } from './authenticate/index.js';
|
package/src/tasks/init/helper.js
CHANGED
|
@@ -48,11 +48,11 @@ export const getInitProjectQuestions = () => {
|
|
|
48
48
|
message: 'Description',
|
|
49
49
|
default: ''
|
|
50
50
|
},
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
51
|
+
// {
|
|
52
|
+
// name: 'gitRepositoryUrl',
|
|
53
|
+
// message: 'Git repository url (optional)',
|
|
54
|
+
// default: ''
|
|
55
|
+
// },
|
|
56
56
|
{
|
|
57
57
|
name: 'author',
|
|
58
58
|
message: 'Author',
|
|
@@ -23,17 +23,26 @@
|
|
|
23
23
|
"promoteWebPack": "custom-dx-components promoteWebPack",
|
|
24
24
|
"revertWebPack": "custom-dx-components revertWebPack",
|
|
25
25
|
"_library_comments": "library based commands",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"createLibrary": "custom-dx-components createLibrary",
|
|
27
|
+
"switchLibrary": "custom-dx-components switchLibrary",
|
|
28
|
+
"createVersion": "custom-dx-components createVersion",
|
|
29
|
+
"switchVersion": "custom-dx-components switchVersion",
|
|
28
30
|
"renameLibrary": "custom-dx-components renameLibrary",
|
|
29
31
|
"listLibrary": "custom-dx-components listLibrary",
|
|
32
|
+
"listPublished": "custom-dx-components listPublished",
|
|
30
33
|
"deleteLibrary": "custom-dx-components deleteLibrary",
|
|
34
|
+
"deletePublished": "custom-dx-components deletePublished",
|
|
35
|
+
"showStatus": "custom-dx-components showStatus",
|
|
36
|
+
"validate": "custom-dx-components buildComponent",
|
|
37
|
+
"validateAll": "custom-dx-components buildAllComponents",
|
|
31
38
|
"_internal-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",
|
|
32
39
|
"_internal-test": "echo 'Running functional and unit tests will DELETE existing local components, proceed (y/n)?' && read proceed && if test \"$proceed\" = \"y\"; then npm run _internal-test-full; fi ",
|
|
33
40
|
"_internal-test-full": "npm run _internal-test-functional && npm run _internal-test-unit",
|
|
34
41
|
"_internal-test-functional": "npm run test:functional:local --prefix node_modules/@pega/custom-dx-components",
|
|
35
42
|
"_internal-test-unit": "npm run test:unit:local --prefix node_modules/@pega/custom-dx-components",
|
|
36
43
|
"_internal-build-jest-assets": "custom-dx-components buildJestAssets",
|
|
44
|
+
"_internal-buildLibrary": "custom-dx-components buildLibrary",
|
|
45
|
+
"_internal-publishLibrary": "custom-dx-components publishLibrary",
|
|
37
46
|
"_lint:styles": "stylelint \"./**/*.@(js|jsx|ts|tsx)\"",
|
|
38
47
|
"_lint:format": "prettier -c .",
|
|
39
48
|
"_lint:spelling": "cspell --no-progress **/*",
|
|
@@ -55,9 +64,9 @@
|
|
|
55
64
|
"author": "",
|
|
56
65
|
"license": "Enter License",
|
|
57
66
|
"dependencies": {
|
|
58
|
-
"@pega/cosmos-react-condition-builder": "7.0.0-build.
|
|
59
|
-
"@pega/cosmos-react-core": "7.0.0-build.
|
|
60
|
-
"@pega/cosmos-react-work": "7.0.0-build.
|
|
67
|
+
"@pega/cosmos-react-condition-builder": "7.0.0-build.29.2",
|
|
68
|
+
"@pega/cosmos-react-core": "7.0.0-build.29.2",
|
|
69
|
+
"@pega/cosmos-react-work": "7.0.0-build.29.2",
|
|
61
70
|
"@pega/eslint-config": "^0.10.2",
|
|
62
71
|
"@pega/tsconfig": "^0.10.2",
|
|
63
72
|
"babel-loader": "^9.1.3",
|
|
@@ -80,7 +89,7 @@
|
|
|
80
89
|
},
|
|
81
90
|
"devDependencies": {
|
|
82
91
|
"@pega/configs": "^0.6.0",
|
|
83
|
-
"@pega/custom-dx-components": "0.242.
|
|
92
|
+
"@pega/custom-dx-components": "0.242.27",
|
|
84
93
|
"@pega/pcore-pconnect-typedefs": "~3.0.0",
|
|
85
94
|
"@storybook/addon-actions": "^7.6.7",
|
|
86
95
|
"@storybook/addon-essentials": "^7.6.19",
|
package/src/tasks/list/helper.js
CHANGED
|
@@ -3,20 +3,16 @@ import path from 'path';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import fetch from 'node-fetch';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
-
import ora from 'ora';
|
|
7
|
-
|
|
8
|
-
import inquirer from 'inquirer';
|
|
9
6
|
|
|
10
7
|
import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
|
|
11
|
-
import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent, sanitize, addDebugLog } from '../../util.js';
|
|
12
|
-
import lib from 'webpack-bundle-analyzer';
|
|
8
|
+
import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent, sanitize, addDebugLog, getLibraryBased, getComponentsConfigs, getConfigDefaults } from '../../util.js';
|
|
13
9
|
|
|
14
10
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
15
11
|
SERVER: 'Server',
|
|
16
12
|
LOCAL: 'Local'
|
|
17
13
|
};
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
const isLibraryBased = getLibraryBased();
|
|
20
16
|
|
|
21
17
|
export const getListComponentsQuestions = async (options) => {
|
|
22
18
|
addDebugLog("getListComponentsQuestions", "", "");
|
|
@@ -85,14 +81,33 @@ addDebugLog("getLaunchPadFilterQuestions", "", "");
|
|
|
85
81
|
|
|
86
82
|
export const listLocalComponents = async (sourceOfComponents) => {
|
|
87
83
|
addDebugLog("listLocalComponents", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
|
|
85
|
+
if (isLibraryBased) {
|
|
86
|
+
const defConfig = getConfigDefaults();
|
|
87
|
+
const data = await getComponentsConfigs();
|
|
88
|
+
|
|
89
|
+
// get built on from first component if exists
|
|
90
|
+
let builtOn = "(date unavailable)";
|
|
91
|
+
if (data[0] && data[0].buildDate) {
|
|
92
|
+
builtOn = data[0].buildDate;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
|
|
96
|
+
console.log(chalk.bold.blueBright(`\nList of ${defConfig.library}:${defConfig.buildVersion} components.`));
|
|
97
|
+
console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
let localComponents = await getComponents();
|
|
102
|
+
localComponents = localComponents.map((name) => ({ 'Rule name': name }));
|
|
103
|
+
if (localComponents.length > 0) {
|
|
104
|
+
console.log(chalk.bold.blueBright(`List of custom components in ${sourceOfComponents}`));
|
|
105
|
+
console.table(localComponents, ['Rule name']);
|
|
106
|
+
} else {
|
|
107
|
+
console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
|
|
108
|
+
}
|
|
95
109
|
}
|
|
110
|
+
|
|
96
111
|
};
|
|
97
112
|
|
|
98
113
|
async function fetchComponentsFromInfinity(apiUrl, headers) {
|
package/src/tasks/list/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import inquirer from 'inquirer';
|
|
|
2
2
|
import ora from 'ora';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
|
|
5
|
-
import { showVersion, getPegaServerConfig, getLibraryBased, addDebugLog } from '../../util.js';
|
|
5
|
+
import { showVersion, getPegaServerConfig, getLibraryBased, addDebugLog, checkLibraryAndArchives } from '../../util.js';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
listLocalComponents,
|
|
@@ -13,8 +13,7 @@ import {
|
|
|
13
13
|
getListComponentsQuestions
|
|
14
14
|
} from './helper.js';
|
|
15
15
|
|
|
16
|
-
const isLibraryBased =
|
|
17
|
-
|
|
16
|
+
const isLibraryBased = getLibraryBased();
|
|
18
17
|
|
|
19
18
|
const getList = async (sourceOfComponents, answers) => {
|
|
20
19
|
addDebugLog("getList", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
@@ -38,7 +37,6 @@ addDebugLog("getList", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
|
38
37
|
({library, organization} = lpAnswers);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
|
|
42
40
|
const spinner = ora('Fetching components from server\n').start();
|
|
43
41
|
|
|
44
42
|
try {
|
|
@@ -59,7 +57,6 @@ addDebugLog("getList", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
|
59
57
|
process.exit(1);
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
|
|
63
60
|
break;
|
|
64
61
|
}
|
|
65
62
|
default: {
|
|
@@ -71,6 +68,8 @@ addDebugLog("getList", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
|
71
68
|
|
|
72
69
|
export default async (options) => {
|
|
73
70
|
await showVersion();
|
|
71
|
+
await checkLibraryAndArchives();
|
|
72
|
+
|
|
74
73
|
|
|
75
74
|
addDebugLog("list", "", "+");
|
|
76
75
|
|
|
@@ -95,7 +94,3 @@ addDebugLog("list", "", "+");
|
|
|
95
94
|
}
|
|
96
95
|
addDebugLog("list", "END", "-");
|
|
97
96
|
};
|
|
98
|
-
`
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
+`
|
|
@@ -1,67 +1,32 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
1
|
import chalk from 'chalk';
|
|
4
2
|
|
|
5
3
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
addDebugLog
|
|
4
|
+
addDebugLog,
|
|
5
|
+
getConfigDefaults,
|
|
6
|
+
getLibraryArchiveDirectories
|
|
10
7
|
} from '../../util.js';
|
|
11
|
-
|
|
8
|
+
|
|
12
9
|
|
|
13
10
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
14
11
|
SERVER: 'Server',
|
|
15
12
|
LOCAL: 'Local'
|
|
16
13
|
};
|
|
17
14
|
|
|
18
|
-
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
19
|
-
|
|
20
|
-
export const getOrgLib = async () => {
|
|
21
|
-
addDebugLog("getOrgLib", "", "+");
|
|
22
|
-
const defaultPegaConfig = await getPegaServerConfig();
|
|
23
|
-
|
|
24
|
-
await checkPathAccess(pegaConfigJsonPath);
|
|
25
|
-
|
|
26
|
-
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
27
|
-
data = data && JSON.parse(data);
|
|
28
|
-
|
|
29
|
-
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
30
|
-
console.error(`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const componentData = data[COMPONENTS_PATH];
|
|
35
|
-
|
|
36
|
-
let library;
|
|
37
|
-
({ library } = componentData);
|
|
38
|
-
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
39
|
-
|
|
40
|
-
const componentDefaults = await getComponentDefaults();
|
|
41
|
-
componentDefaults.library = library;
|
|
42
|
-
componentDefaults.organization = organization;
|
|
43
|
-
|
|
44
|
-
addDebugLog("getOrgLib", `componentsDefaults: ${JSON.stringify(componentDefaults)}`, "");
|
|
45
|
-
addDebugLog("getOrgLib", "END", "-");
|
|
46
|
-
|
|
47
|
-
return componentDefaults;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const getListLibraryQuestions = async (libraryName) => {
|
|
51
|
-
addDebugLog("getListLibraryQuestions", `libraryName: ${libraryName}`, "");
|
|
52
|
-
const defaultPegaConfig = await getPegaServerConfig();
|
|
53
15
|
|
|
16
|
+
export const getArchiveLibraryQuestions = async () => {
|
|
17
|
+
addDebugLog("getDeleteLibraryQuestions", "", "");
|
|
18
|
+
const configDef = getConfigDefaults();
|
|
19
|
+
const archLibs = await getLibraryArchiveDirectories("");
|
|
54
20
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
name: 'libraryName',
|
|
24
|
+
type: 'rawlist',
|
|
25
|
+
message: 'Select library',
|
|
26
|
+
choices: archLibs
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
};
|
|
65
30
|
|
|
66
31
|
|
|
67
32
|
export const getLibraryVersionQuestion = async(libraryName, libVersions) => {
|
|
@@ -70,7 +35,7 @@ addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}, libVersio
|
|
|
70
35
|
{
|
|
71
36
|
name: 'version',
|
|
72
37
|
type: 'rawlist',
|
|
73
|
-
message: `Select ${chalk.green.bold(`${libraryName}`)} library version
|
|
38
|
+
message: `Select ${chalk.green.bold(`${libraryName}`)} library version`,
|
|
74
39
|
choices: libVersions
|
|
75
40
|
}
|
|
76
41
|
];
|