@pega/custom-dx-components 0.25.14 → 0.25.15
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 -2
- package/src/constants.js +1 -0
- package/src/tasks/authenticate/index.js +5 -0
- package/src/tasks/create-lib/index.js +6 -0
- package/src/tasks/create-version/index.js +9 -1
- package/src/tasks/delete-pub/helper.js +137 -1
- package/src/tasks/delete-pub/index.js +69 -11
- package/src/tasks/import-archive/index.js +10 -2
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/list-pub/helper.js +40 -40
- package/src/tasks/list-pub/index.js +78 -74
- package/src/tasks/publish/index.js +7 -2
- package/src/tasks/publish-lib/index.js +8 -0
- package/src/tasks/rename-lib/index.js +10 -1
- package/src/util.js +87 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/custom-dx-components",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.15",
|
|
4
4
|
"description": "Utility for building custom UI components",
|
|
5
5
|
"bin": "./bin/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
20
20
|
"@babel/preset-react": "^7.26.3",
|
|
21
21
|
"@pega/auth": "^0.2.23",
|
|
22
|
-
"@pega/constellation-dx-components-build-utils": "^2.0.
|
|
22
|
+
"@pega/constellation-dx-components-build-utils": "^2.0.1-dev",
|
|
23
23
|
"@pega/inquirer-fuzzy-path": "^3.0.0",
|
|
24
24
|
"ajv": "^8.17.1",
|
|
25
25
|
"ajv-keywords": "^5.1.0",
|
package/src/constants.js
CHANGED
|
@@ -42,6 +42,7 @@ export const LP_DELETE_COMPONENT_SERVICE_REST_ENDPOINT =
|
|
|
42
42
|
export const PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component_library';
|
|
43
43
|
export const PUBLISH_COMPONENT_ARCHIVE_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component_archive';
|
|
44
44
|
export const LIST_COMPONENT_LIBRARIES_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/list_component_libraries';
|
|
45
|
+
export const DELETE_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/delete_component_library';
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
export const FIELD_PATH = '/field';
|
|
@@ -174,6 +174,11 @@ export default async options => {
|
|
|
174
174
|
const serverConfig = data['server-config'];
|
|
175
175
|
const isPwdNonEmpty = !!serverConfig.password;
|
|
176
176
|
|
|
177
|
+
|
|
178
|
+
console.log(`\nAuthenticating to server: ${chalk.green.bold(`${serverConfig.server}`)}\n`);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
177
182
|
// console.log(`serverConfig: ${JSON.stringify(serverConfig)}`);
|
|
178
183
|
const questions = await getAuthQuestions(serverConfig);
|
|
179
184
|
// console.log(`questions: ${JSON.stringify(questions)}`);
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
updateComponentDefaultLibrary,
|
|
9
9
|
updateComponentDefaultVersion,
|
|
10
10
|
getLibraryBased,
|
|
11
|
+
getLibraryBasedCL,
|
|
11
12
|
addDebugLog,
|
|
12
13
|
zipVersionAndArchive,
|
|
13
14
|
hasArchives,
|
|
@@ -25,6 +26,7 @@ import { showCurrentStatus } from '../show-status/index.js';
|
|
|
25
26
|
|
|
26
27
|
export default async options => {
|
|
27
28
|
const isLibraryBased = getLibraryBased();
|
|
29
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
28
30
|
if (!isLibraryBased) {
|
|
29
31
|
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`);
|
|
30
32
|
process.exit();
|
|
@@ -75,6 +77,10 @@ addDebugLog("createLibrary", "", "+");
|
|
|
75
77
|
({ libraryName, version, permBuild } = answers);
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
if (isLibraryBasedCL) {
|
|
81
|
+
// no -dev for PegaInfinity
|
|
82
|
+
permBuild = true;
|
|
83
|
+
}
|
|
78
84
|
|
|
79
85
|
|
|
80
86
|
// if have store, then that means there is a current library, so
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
showVersion,
|
|
11
11
|
updateComponentDefaultVersion,
|
|
12
12
|
getLibraryBased,
|
|
13
|
+
getLibraryBasedCL,
|
|
13
14
|
addDebugLog,
|
|
14
15
|
zipVersionAndArchive,
|
|
15
16
|
setConfigDevBuild,
|
|
@@ -25,6 +26,8 @@ import { showCurrentStatus } from '../show-status/index.js';
|
|
|
25
26
|
|
|
26
27
|
export default async options => {
|
|
27
28
|
const isLibraryBased = getLibraryBased();
|
|
29
|
+
const isLibraryBasedCL = getLibraryBasedCL()
|
|
30
|
+
|
|
28
31
|
if (!isLibraryBased) {
|
|
29
32
|
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
|
|
30
33
|
process.exit();
|
|
@@ -67,11 +70,16 @@ addDebugLog("createVersion", "", "+");
|
|
|
67
70
|
({ version, permBuild, copyExisting } = answers);
|
|
68
71
|
}
|
|
69
72
|
|
|
73
|
+
if (isLibraryBasedCL) {
|
|
74
|
+
// no -dev for PegaInfinity
|
|
75
|
+
permBuild = true;
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
const orgLib = getConfigDefaults();
|
|
71
79
|
const savedNewVersion = version;
|
|
72
80
|
const existingOrgLib = orgLib.currentOrgLib;
|
|
73
81
|
let oldVersion = componentDefaults.version;
|
|
74
|
-
if (componentDefaults.devBuild) {
|
|
82
|
+
if (componentDefaults.devBuild && !isLibraryBasedCL) {
|
|
75
83
|
oldVersion = oldVersion.concat("-dev");
|
|
76
84
|
}
|
|
77
85
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
1
3
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
4
|
+
import fetch from 'node-fetch';
|
|
5
|
+
|
|
6
|
+
import { getPegaServerConfig, addDebugLog, getApplicationAndVersionFromToken, constructCompleteUrl, getHttpsAgent, validateRulesetVersion } from '../../util.js';
|
|
7
|
+
import { LIST_COMPONENT_LIBRARIES_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
3
8
|
|
|
4
9
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
5
10
|
SERVER: 'Server',
|
|
@@ -33,3 +38,134 @@ addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}`, "");
|
|
|
33
38
|
}
|
|
34
39
|
];
|
|
35
40
|
};
|
|
41
|
+
|
|
42
|
+
export const getRulesetAndVersionQuestion = async (serverConfig) => {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
name: 'rulesetName',
|
|
46
|
+
message: 'Enter ruleset name',
|
|
47
|
+
default: serverConfig.rulesetName,
|
|
48
|
+
validate: value => {
|
|
49
|
+
if (value.trim()) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return 'Ruleset name cannot be empty';
|
|
53
|
+
},
|
|
54
|
+
when: () => {
|
|
55
|
+
return serverConfig.serverType === 'infinity';
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'rulesetVersion',
|
|
60
|
+
message: 'Enter ruleset version',
|
|
61
|
+
default: serverConfig.rulesetVersion,
|
|
62
|
+
validate: value => {
|
|
63
|
+
if (validateRulesetVersion(value)) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return 'Please provide compatible version e.g 01-01-01';
|
|
67
|
+
},
|
|
68
|
+
when: () => {
|
|
69
|
+
return serverConfig.serverType === 'infinity';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
async function fetchComponenLibrariessFromInfinity(apiUrl, headers) {
|
|
78
|
+
addDebugLog("fetchComponenLibrariessFromInfinity", `apiUrl: ${apiUrl}`, "");
|
|
79
|
+
const serverConfig = await getPegaServerConfig();
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
let status = 500;
|
|
82
|
+
fetch(apiUrl, {
|
|
83
|
+
method: 'GET',
|
|
84
|
+
agent: getHttpsAgent(serverConfig),
|
|
85
|
+
headers
|
|
86
|
+
})
|
|
87
|
+
.then((response) => {
|
|
88
|
+
status = response.status;
|
|
89
|
+
if (status === 401) {
|
|
90
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
91
|
+
}
|
|
92
|
+
else if (status === 404){
|
|
93
|
+
throw new Error('404: Server resource not found');
|
|
94
|
+
}
|
|
95
|
+
else if (status === 405){
|
|
96
|
+
throw new Error('405: Server method not allowed');
|
|
97
|
+
}
|
|
98
|
+
else if (status === 408){
|
|
99
|
+
throw new Error('408: Server timed out');
|
|
100
|
+
}
|
|
101
|
+
return response.json();
|
|
102
|
+
})
|
|
103
|
+
.then((resp) => {
|
|
104
|
+
// const respData = JSON.parse(resp);
|
|
105
|
+
if (status === 401) {
|
|
106
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
107
|
+
// console.log(accessTokenUri, refreshToken);
|
|
108
|
+
/* TODO - Handle refresh_token */
|
|
109
|
+
} else if (status === 200) {
|
|
110
|
+
resolve(resp);
|
|
111
|
+
} else {
|
|
112
|
+
throw new Error(`${resp.message}`);
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
116
|
+
.catch((e) => reject(`${chalk.bold.red(e)}`));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const getInfinityLibraries = async(rulesetName, rulesetVersion) => {
|
|
121
|
+
addDebugLog("getInfinityLibraries", '', "");
|
|
122
|
+
|
|
123
|
+
const { app_name, app_version } = await getApplicationAndVersionFromToken();
|
|
124
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
125
|
+
let url = constructCompleteUrl(
|
|
126
|
+
defaultPegaServerConfig.server,
|
|
127
|
+
LIST_COMPONENT_LIBRARIES_SERVICE_REST_ENDPOINT
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const ApplicationName = app_name;
|
|
131
|
+
const ApplicationVersion = app_version;
|
|
132
|
+
// const rulesetName = defaultPegaServerConfig.rulesetName;
|
|
133
|
+
// const rulesetVersion = defaultPegaServerConfig.rulesetVersion;
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
// inquire
|
|
137
|
+
|
|
138
|
+
let urlParams = `/AppName/${ApplicationName}/AppVersion/${ApplicationVersion}/ruleset/${rulesetName}/rulesetVersion/${rulesetVersion}`;
|
|
139
|
+
//let urlParams = `&ApplicationName=${ApplicationName}&ApplicationVersion=${ApplicationVersion}&RulesetName=${rulesetName}&RulesetVersion=${rulesetVersion}`;
|
|
140
|
+
//urlParams = encodeURIComponent(urlParams);
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
url = url.concat(urlParams);
|
|
144
|
+
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
try {
|
|
147
|
+
fs.readFile(TOKEN_PATH, 'utf8', (err, data) => {
|
|
148
|
+
if (err) {
|
|
149
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
150
|
+
reject(`\n${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
151
|
+
}
|
|
152
|
+
if (data) {
|
|
153
|
+
const { access_token: accessToken, token_type: tokenType } = JSON.parse(data);
|
|
154
|
+
|
|
155
|
+
const headers = {};
|
|
156
|
+
headers.Authorization = `${tokenType} ${accessToken}`;
|
|
157
|
+
|
|
158
|
+
fetchComponenLibrariessFromInfinity(url, headers)
|
|
159
|
+
.then((response) => resolve(response))
|
|
160
|
+
.catch((e) => reject(e));
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.log(`\n${chalk.bold.red(error)}`);
|
|
166
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
167
|
+
reject(`${chalk.bold.red(error)}`);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
|
+
import ora from 'ora';
|
|
2
3
|
|
|
3
4
|
import chalk from 'chalk';
|
|
4
5
|
|
|
5
|
-
import { showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion, addDebugLog, getConfigDefaults } from '../../util.js';
|
|
6
|
+
import { showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion, addDebugLog, getConfigDefaults, getLibraryBasedCL, getPegaServerConfig, deleteInfinityServerComponentLibrary } from '../../util.js';
|
|
6
7
|
import { deleteLib } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
7
8
|
|
|
8
|
-
import { getDeleteLibraryQuestions, getLibraryVersionQuestion, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
|
|
9
|
+
import { getDeleteLibraryQuestions, getLibraryVersionQuestion, getRulesetAndVersionQuestion, SOURCE_OF_COMPONENT_TYPES, getInfinityLibraries } from './helper.js';
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
|
|
@@ -84,18 +85,75 @@ addDebugLog("deletePublished", "END", "-");
|
|
|
84
85
|
|
|
85
86
|
}
|
|
86
87
|
else {
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
89
|
+
if (isLibraryBasedCL) {
|
|
90
|
+
|
|
91
|
+
const serverConfg = await getPegaServerConfig();
|
|
92
|
+
|
|
93
|
+
console.log();
|
|
94
|
+
console.log(`Current server: ${chalk.green.bold(`${serverConfg.server}`)}`);
|
|
95
|
+
|
|
96
|
+
const questions = await getRulesetAndVersionQuestion(serverConfg);
|
|
97
|
+
const answers = await inquirer.prompt(questions);
|
|
98
|
+
const { rulesetName, rulesetVersion } = answers;
|
|
99
|
+
|
|
100
|
+
const arLibs = await getInfinityLibraries(rulesetName, rulesetVersion);
|
|
101
|
+
|
|
102
|
+
if (arLibs && arLibs.pxResults && arLibs.pxResults.length > 0) {
|
|
103
|
+
|
|
104
|
+
const libs = arLibs.pxResults.map((oLib, index) => ({ name: oLib.pyLabel, value: oLib.pyRuleName}));
|
|
105
|
+
|
|
106
|
+
const libAnswers = await inquirer.prompt([
|
|
107
|
+
{
|
|
108
|
+
name: 'library',
|
|
109
|
+
type: 'rawlist',
|
|
110
|
+
message: 'Pick component library to delete',
|
|
111
|
+
choices: libs
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
const libraryName = libAnswers.library;
|
|
116
|
+
// let spinner;
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
await deleteInfinityServerComponentLibrary(libraryName, rulesetName, rulesetVersion);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.log(chalk.redBright.bold(err));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// spinner.stop();
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// No library with that name
|
|
133
|
+
const serverConfig = await getPegaServerConfig();
|
|
134
|
+
console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`));
|
|
135
|
+
addDebugLog("listPublished", "END", "-");
|
|
136
|
+
process.exit(1);
|
|
137
|
+
|
|
138
|
+
}
|
|
89
139
|
|
|
90
|
-
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
91
|
-
console.log(chalk.redBright("Need to authenticate, missing services token.\nDeleting a library requires authentication to acquire a token to delete."));
|
|
92
|
-
addDebugLog("deletePublished", "END", "-");
|
|
93
|
-
process.exit(1);
|
|
94
140
|
}
|
|
141
|
+
else {
|
|
142
|
+
// ap static server
|
|
143
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
144
|
+
|
|
145
|
+
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
146
|
+
console.log(chalk.redBright("Need to authenticate, missing services token.\nDeleting a library requires authentication to acquire a token to delete."));
|
|
147
|
+
addDebugLog("deletePublished", "END", "-");
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
addDebugLog("deleteLib", "services call", "");
|
|
152
|
+
await deleteLib(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
153
|
+
addDebugLog("deleteLib", "services end", "");
|
|
154
|
+
}
|
|
155
|
+
|
|
95
156
|
|
|
96
|
-
addDebugLog("deleteLib", "services call", "");
|
|
97
|
-
await deleteLib(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
98
|
-
addDebugLog("deleteLib", "services end", "");
|
|
99
157
|
}
|
|
100
158
|
|
|
101
159
|
|
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
cleanUpTemp,
|
|
28
28
|
hasArchives,
|
|
29
29
|
restoreFromArchive,
|
|
30
|
-
forceDefaultsUpdate
|
|
30
|
+
forceDefaultsUpdate,
|
|
31
|
+
getLibraryBasedCL
|
|
31
32
|
} from '../../util.js';
|
|
32
33
|
import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
|
|
33
34
|
import { getFilePathQuestions, getFileNameQuestions, updateTempArchive, updateSavedFilePath } from './helper.js';
|
|
@@ -166,11 +167,18 @@ export const getPackgeOrg = async(packagePath) => {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
export const getLocalConfigData = async(tasksPath) => {
|
|
170
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
169
171
|
let configData = { library: "", version: "", buildVersion: "", devBuild: false};
|
|
170
172
|
const sTaskData = fs.readFileSync(tasksPath, { encoding: 'utf8' });
|
|
171
173
|
const taskData = sTaskData && JSON.parse(sTaskData);
|
|
172
174
|
|
|
173
|
-
|
|
175
|
+
let devBuild = taskData["server-config"].devBuild;
|
|
176
|
+
|
|
177
|
+
// no -dev in PegaInfinity
|
|
178
|
+
if (isLibraryBasedCL) {
|
|
179
|
+
devBuild = false;
|
|
180
|
+
}
|
|
181
|
+
|
|
174
182
|
configData.library = taskData["component"].library;
|
|
175
183
|
configData.version = taskData["component"].version;
|
|
176
184
|
configData.devBuild = devBuild;
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"@babel/preset-react": "^7.26.3",
|
|
107
107
|
"@babel/preset-typescript": "^7.26.0",
|
|
108
108
|
"@pega/configs": "^0.16.2",
|
|
109
|
-
"@pega/custom-dx-components": "~0.25.
|
|
109
|
+
"@pega/custom-dx-components": "~0.25.15",
|
|
110
110
|
"@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
|
|
111
111
|
"@storybook/addon-actions": "^7.6.19",
|
|
112
112
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -84,47 +84,47 @@ addDebugLog("listLibJSONResponse", "services end", "");
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async function fetchComponenLibrariessFromInfinity(apiUrl, headers) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
addDebugLog("fetchComponenLibrariessFromInfinity", `apiUrl: ${apiUrl}`, "");
|
|
88
|
+
const serverConfig = await getPegaServerConfig();
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
let status = 500;
|
|
91
|
+
fetch(apiUrl, {
|
|
92
|
+
method: 'GET',
|
|
93
|
+
agent: getHttpsAgent(serverConfig),
|
|
94
|
+
headers
|
|
95
|
+
})
|
|
96
|
+
.then((response) => {
|
|
97
|
+
status = response.status;
|
|
98
|
+
if (status === 401) {
|
|
99
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
100
|
+
}
|
|
101
|
+
else if (status === 404){
|
|
102
|
+
throw new Error('404: Server resource not found');
|
|
103
|
+
}
|
|
104
|
+
else if (status === 405){
|
|
105
|
+
throw new Error('405: Server method not allowed');
|
|
106
|
+
}
|
|
107
|
+
else if (status === 408){
|
|
108
|
+
throw new Error('408: Server timed out');
|
|
109
|
+
}
|
|
110
|
+
return response.json();
|
|
95
111
|
})
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
.then((resp) => {
|
|
113
|
-
// const respData = JSON.parse(resp);
|
|
114
|
-
if (status === 401) {
|
|
115
|
-
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
116
|
-
// console.log(accessTokenUri, refreshToken);
|
|
117
|
-
/* TODO - Handle refresh_token */
|
|
118
|
-
} else if (status === 200) {
|
|
119
|
-
resolve(resp);
|
|
120
|
-
} else {
|
|
121
|
-
throw new Error(`${resp.message}`);
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
// eslint-disable-next-line prefer-promise-reject-errors
|
|
125
|
-
.catch((e) => reject(`${chalk.bold.red(e)}`));
|
|
126
|
-
});
|
|
127
|
-
}
|
|
112
|
+
.then((resp) => {
|
|
113
|
+
// const respData = JSON.parse(resp);
|
|
114
|
+
if (status === 401) {
|
|
115
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
116
|
+
// console.log(accessTokenUri, refreshToken);
|
|
117
|
+
/* TODO - Handle refresh_token */
|
|
118
|
+
} else if (status === 200) {
|
|
119
|
+
resolve(resp);
|
|
120
|
+
} else {
|
|
121
|
+
throw new Error(`${resp.message}`);
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
125
|
+
.catch((e) => reject(`${chalk.bold.red(e)}`));
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
128
|
|
|
129
129
|
export const getInfinityLibraries = async() => {
|
|
130
130
|
addDebugLog("getInfinityLibraries", '', "");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraries, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults, cleanUpTemp, getPegaServerConfig } from '../../util.js';
|
|
4
|
+
import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraries, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults, cleanUpTemp, getPegaServerConfig, getLibraryBasedCL } from '../../util.js';
|
|
5
5
|
|
|
6
6
|
import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
7
7
|
|
|
@@ -139,107 +139,111 @@ addDebugLog("listPublished", "END", "-");
|
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
141
141
|
|
|
142
|
-
const
|
|
142
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
143
|
+
if (isLibraryBasedCL) {
|
|
144
|
+
const arLibs = await getInfinityLibraries();
|
|
143
145
|
|
|
144
|
-
|
|
146
|
+
if (arLibs && arLibs.pxResults && arLibs.pxResults.length > 0) {
|
|
145
147
|
|
|
146
|
-
|
|
148
|
+
const libs = arLibs.pxResults.map((oLib, index) => ({ name: oLib.pyLabel, value: index}));
|
|
147
149
|
|
|
148
150
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
const libAnswers = await inquirer.prompt([
|
|
152
|
+
{
|
|
153
|
+
name: 'library',
|
|
154
|
+
type: 'rawlist',
|
|
155
|
+
message: 'Pick library',
|
|
156
|
+
choices: libs
|
|
157
|
+
}
|
|
158
|
+
]);
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
const libraryIndex = libAnswers.library;
|
|
159
161
|
|
|
160
|
-
|
|
162
|
+
const data = JSON.parse(arLibs.pxResults[libraryIndex].pxComponentDefinition);
|
|
161
163
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
// get built on from first component if exists
|
|
165
|
+
let builtOn = "(date unavailable)";
|
|
166
|
+
if (data[0] && data[0].buildDate) {
|
|
167
|
+
builtOn = data[0].buildDate;
|
|
168
|
+
}
|
|
167
169
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
|
|
171
|
+
console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
|
|
172
|
+
console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
|
|
171
173
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
addDebugLog("listPublished", "END", "-");
|
|
179
|
-
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// No library with that name
|
|
177
|
+
const serverConfig = await getPegaServerConfig();
|
|
178
|
+
console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`));
|
|
179
|
+
console.log(chalk.redBright(`You need to publish a library to this ruleset first.`));
|
|
180
|
+
addDebugLog("listPublished", "END", "-");
|
|
181
|
+
process.exit(1);
|
|
180
182
|
|
|
183
|
+
}
|
|
181
184
|
}
|
|
185
|
+
else {
|
|
182
186
|
|
|
183
|
-
|
|
184
|
-
// old app static server
|
|
185
|
-
|
|
186
|
-
const arLibs = await getServerLibraries();
|
|
187
|
-
if (arLibs && arLibs.length > 0) {
|
|
188
|
-
|
|
189
|
-
const libAnswers = await inquirer.prompt([
|
|
190
|
-
{
|
|
191
|
-
name: 'library',
|
|
192
|
-
type: 'rawlist',
|
|
193
|
-
message: 'Pick library',
|
|
194
|
-
choices: arLibs
|
|
195
|
-
}
|
|
196
|
-
]);
|
|
197
|
-
|
|
198
|
-
libraryName = libAnswers.library;
|
|
199
|
-
const libVersions = await getServerLibraryVersions(libraryName);
|
|
187
|
+
// old app static server
|
|
200
188
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const libVersionAnswers = await inquirer.prompt([
|
|
189
|
+
const arLibs = await getServerLibraries();
|
|
190
|
+
if (arLibs && arLibs.length > 0) {
|
|
204
191
|
|
|
192
|
+
const libAnswers = await inquirer.prompt([
|
|
205
193
|
{
|
|
206
|
-
name: '
|
|
194
|
+
name: 'library',
|
|
207
195
|
type: 'rawlist',
|
|
208
|
-
message: '
|
|
209
|
-
choices:
|
|
196
|
+
message: 'Pick library',
|
|
197
|
+
choices: arLibs
|
|
210
198
|
}
|
|
211
199
|
]);
|
|
212
200
|
|
|
213
|
-
|
|
201
|
+
libraryName = libAnswers.library;
|
|
202
|
+
const libVersions = await getServerLibraryVersions(libraryName);
|
|
214
203
|
|
|
215
|
-
|
|
216
|
-
|
|
204
|
+
if (libVersions) {
|
|
205
|
+
const keys = Object.keys(libVersions);
|
|
206
|
+
const libVersionAnswers = await inquirer.prompt([
|
|
217
207
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
208
|
+
{
|
|
209
|
+
name: 'libVersion',
|
|
210
|
+
type: 'rawlist',
|
|
211
|
+
message: 'Enter version',
|
|
212
|
+
choices: keys
|
|
213
|
+
}
|
|
214
|
+
]);
|
|
215
|
+
|
|
216
|
+
const selectedVersion = libVersionAnswers.libVersion;
|
|
217
|
+
|
|
218
|
+
const versionData = libVersions[selectedVersion];
|
|
219
|
+
const data = JSON.parse(versionData);
|
|
220
|
+
|
|
221
|
+
// get built on from first component if exists
|
|
222
|
+
let builtOn = "(date unavailable)";
|
|
223
|
+
if (data[0] && data[0].buildDate) {
|
|
224
|
+
builtOn = data[0].buildDate;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
|
|
228
|
+
console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
|
|
229
|
+
console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
console.log(chalk.red("No libraries available on server."));
|
|
222
233
|
}
|
|
223
234
|
|
|
224
|
-
|
|
225
|
-
console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
|
|
226
|
-
console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
|
|
235
|
+
|
|
227
236
|
}
|
|
228
237
|
else {
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
// No library with that name
|
|
239
|
+
console.log(chalk.redBright(`No server library named: ${libraryName} exists.`));
|
|
240
|
+
console.log(chalk.redBright(`You need to publish library: ${libraryName} first.`));
|
|
241
|
+
addDebugLog("listPublished", "END", "-");
|
|
242
|
+
process.exit(1);
|
|
231
243
|
|
|
244
|
+
}
|
|
232
245
|
|
|
233
246
|
}
|
|
234
|
-
else {
|
|
235
|
-
// No library with that name
|
|
236
|
-
console.log(chalk.redBright(`No server library named: ${libraryName} exists.`));
|
|
237
|
-
console.log(chalk.redBright(`You need to publish library: ${libraryName} first.`));
|
|
238
|
-
addDebugLog("listPublished", "END", "-");
|
|
239
|
-
process.exit(1);
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
*/
|
|
243
247
|
|
|
244
248
|
}
|
|
245
249
|
|
|
@@ -6,7 +6,7 @@ import fs from 'fs';
|
|
|
6
6
|
import validate from '../validator/index.js';
|
|
7
7
|
import bundleComponent from '../bundle/index.js';
|
|
8
8
|
import { lintComponent } from '../linter/index.js';
|
|
9
|
-
import { getComponentDirectoryPath, showVersion, getLibraryBased, addDebugLog, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives, getConfigDevBuild, checkAccessTokenExpiration, checkJWTExpiration, getConfigDefaults } from '../../util.js';
|
|
9
|
+
import { getComponentDirectoryPath, getPegaServerConfig, showVersion, getLibraryBased, addDebugLog, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives, getConfigDevBuild, checkAccessTokenExpiration, checkJWTExpiration, getConfigDefaults, getLibraryBasedCL } from '../../util.js';
|
|
10
10
|
|
|
11
11
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
12
12
|
import { default as buildLibrary } from '../build-lib/index.js';
|
|
@@ -21,6 +21,7 @@ export default async options => {
|
|
|
21
21
|
await showVersion();
|
|
22
22
|
await checkLibraryAndArchives();
|
|
23
23
|
const isLibraryBased = getLibraryBased();
|
|
24
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
24
25
|
|
|
25
26
|
addDebugLog("publish", "", "+");
|
|
26
27
|
|
|
@@ -41,6 +42,10 @@ addDebugLog("publish", "", "+");
|
|
|
41
42
|
const currentOrgLib = orgLib.currentOrgLib;
|
|
42
43
|
// const currentVersion = devBuild ? `${orgLib.version}-dev`: orgLib.version;
|
|
43
44
|
const currentVersion = orgLib.buildVersion;
|
|
45
|
+
const serverConfg = await getPegaServerConfig();
|
|
46
|
+
|
|
47
|
+
console.log();
|
|
48
|
+
console.log(`Publishing to server: ${chalk.green.bold(`${serverConfg.server}`)}`);
|
|
44
49
|
|
|
45
50
|
const publishThisVersion = await inquirer.prompt([
|
|
46
51
|
{
|
|
@@ -82,7 +87,7 @@ addDebugLog("publish", "", "+");
|
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
if (okToPublish && !devBuild) {
|
|
90
|
+
if (okToPublish && !devBuild && !isLibraryBasedCL) {
|
|
86
91
|
okToPublish = false;
|
|
87
92
|
console.log("");
|
|
88
93
|
const publishAnswers = await inquirer.prompt([
|
|
@@ -5,6 +5,7 @@ import fetch from 'node-fetch';
|
|
|
5
5
|
import archiver from 'archiver';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import fs from 'fs';
|
|
8
|
+
import ora from 'ora';
|
|
8
9
|
|
|
9
10
|
import validate from '../validator/index.js';
|
|
10
11
|
import { lintComponent } from '../linter/index.js';
|
|
@@ -166,6 +167,11 @@ export const publishComponentLibraryToServer = async (data, doFetch) => {
|
|
|
166
167
|
headers.Authorization = `${tokenType} ${accessToken}`;
|
|
167
168
|
}
|
|
168
169
|
|
|
170
|
+
let spinner;
|
|
171
|
+
|
|
172
|
+
console.log();
|
|
173
|
+
spinner = ora(chalk.green.bold('Publishing library...')).start();
|
|
174
|
+
|
|
169
175
|
const response = await fetch(url, {
|
|
170
176
|
method: 'POST',
|
|
171
177
|
agent: getHttpsAgent(defaultPegaConfig),
|
|
@@ -173,6 +179,8 @@ export const publishComponentLibraryToServer = async (data, doFetch) => {
|
|
|
173
179
|
body: JSON.stringify(apiBody)
|
|
174
180
|
});
|
|
175
181
|
|
|
182
|
+
spinner.stop();
|
|
183
|
+
|
|
176
184
|
status = response.status;
|
|
177
185
|
if (!response.ok) {
|
|
178
186
|
if (status === 401) {
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
updateDefaultOrganization,
|
|
20
20
|
addDebugLog,
|
|
21
21
|
checkLibraryAndArchives,
|
|
22
|
-
getConfigDefaults
|
|
22
|
+
getConfigDefaults,
|
|
23
|
+
getLibraryBasedCL
|
|
23
24
|
} from '../../util.js';
|
|
24
25
|
import {
|
|
25
26
|
TASKS_CONFIG_JSON_FILENAME,
|
|
@@ -105,6 +106,8 @@ addDebugLog("renameLibrary", `library: ${library}, organization: ${organization}
|
|
|
105
106
|
const currentLibrary = compDef.library;
|
|
106
107
|
const currentVersion = compDef.version;
|
|
107
108
|
|
|
109
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
110
|
+
|
|
108
111
|
let compVersion;
|
|
109
112
|
|
|
110
113
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
@@ -143,6 +146,12 @@ addDebugLog("renameLibrary", `library: ${library}, organization: ${organization}
|
|
|
143
146
|
if (compVersion && compVersion.indexOf('-dev') != -1) {
|
|
144
147
|
wasDevBuild = true;
|
|
145
148
|
}
|
|
149
|
+
|
|
150
|
+
// no -dev with PegaInfinity
|
|
151
|
+
if (isLibraryBasedCL) {
|
|
152
|
+
wasDevBuild = false;
|
|
153
|
+
}
|
|
154
|
+
|
|
146
155
|
const allowedApplications = configData.allowedApplications;
|
|
147
156
|
|
|
148
157
|
await renameComponent(
|
package/src/util.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createRequire } from 'module';
|
|
|
8
8
|
import {jwtDecode} from 'jwt-decode';
|
|
9
9
|
import archiver from 'archiver';
|
|
10
10
|
import {unarchive} from 'unarchive';
|
|
11
|
+
import ora from 'ora';
|
|
11
12
|
|
|
12
13
|
import chalk from 'chalk';
|
|
13
14
|
import mustache from 'mustache';
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
OOTB_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
27
28
|
DELETE_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
28
29
|
LP_DELETE_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
30
|
+
DELETE_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT,
|
|
29
31
|
OOTB_COMPONENTS,
|
|
30
32
|
USE_PROMOTED_WEB_PACK,
|
|
31
33
|
BOOTSTRAP_CONFIG,
|
|
@@ -1331,6 +1333,91 @@ if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${com
|
|
|
1331
1333
|
}
|
|
1332
1334
|
};
|
|
1333
1335
|
|
|
1336
|
+
export const deleteInfinityServerComponentLibrary = async (libraryName, rulesetName, rulesetVersion) => {
|
|
1337
|
+
if (showDebug) addDebugLog("deleteInfinityServerComponentLibrary", `componentKey: ${componentKey}, rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
|
|
1338
|
+
const serverConfig = await getPegaServerConfig();
|
|
1339
|
+
const { server } = serverConfig;
|
|
1340
|
+
const url = constructCompleteUrl(server, DELETE_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT);
|
|
1341
|
+
const deleteUrl = `${url}/${libraryName}/rulesetname/${rulesetName}/rulesetversion/${rulesetVersion}`;
|
|
1342
|
+
try {
|
|
1343
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
1344
|
+
|
|
1345
|
+
let status = 500;
|
|
1346
|
+
|
|
1347
|
+
if (OauthData) {
|
|
1348
|
+
const { access_token: accessToken, token_type: tokenType } = JSON.parse(OauthData);
|
|
1349
|
+
let spinner;
|
|
1350
|
+
|
|
1351
|
+
console.log();
|
|
1352
|
+
spinner = ora(chalk.green.bold('Deleting component library...')).start();
|
|
1353
|
+
|
|
1354
|
+
const response = await fetch(deleteUrl, {
|
|
1355
|
+
method: 'DELETE',
|
|
1356
|
+
agent: getHttpsAgent(serverConfig),
|
|
1357
|
+
headers: {
|
|
1358
|
+
Authorization: `${tokenType} ${accessToken}`
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
spinner.stop();
|
|
1363
|
+
console.log();
|
|
1364
|
+
|
|
1365
|
+
status = response.status;
|
|
1366
|
+
if (!response.ok) {
|
|
1367
|
+
if (status === 401) {
|
|
1368
|
+
throw new Error(
|
|
1369
|
+
'Error occurred in authentication. Please regenerate using authenticate'
|
|
1370
|
+
);
|
|
1371
|
+
// console.log(accessTokenUri, refreshToken);
|
|
1372
|
+
/* TODO - Handle refresh_token */
|
|
1373
|
+
}
|
|
1374
|
+
else if (status === 404){
|
|
1375
|
+
throw new Error('404: Server resource not found');
|
|
1376
|
+
}
|
|
1377
|
+
else if (status === 405){
|
|
1378
|
+
throw new Error('405: Server method not allowed');
|
|
1379
|
+
}
|
|
1380
|
+
else if (status === 408){
|
|
1381
|
+
throw new Error('408: Server timed out');
|
|
1382
|
+
}
|
|
1383
|
+
else if (response.status === 403) {
|
|
1384
|
+
throw new Error(
|
|
1385
|
+
'Error forbidden: User does not have privileges to Publish.'
|
|
1386
|
+
);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
try {
|
|
1392
|
+
const respData = await response.json();
|
|
1393
|
+
console.log(
|
|
1394
|
+
chalk.bold.green(`${respData.message}`)
|
|
1395
|
+
);
|
|
1396
|
+
|
|
1397
|
+
if (status === 500) {
|
|
1398
|
+
status = 999;
|
|
1399
|
+
throw new Error(respData.message);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
catch (err) {
|
|
1403
|
+
if (status === 500) {
|
|
1404
|
+
throw new Error(
|
|
1405
|
+
`Error occurred in authentication. Please regenerate using authenticate`
|
|
1406
|
+
);
|
|
1407
|
+
}
|
|
1408
|
+
else if (status === 999) {
|
|
1409
|
+
throw new Error (err);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
}
|
|
1414
|
+
} catch (error) {
|
|
1415
|
+
|
|
1416
|
+
throw new Error(error);
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
|
|
1334
1421
|
export const deleteLaunchpadServerComponent = async componentKey => {
|
|
1335
1422
|
if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "");
|
|
1336
1423
|
const { server, isolationId } = await getPegaServerConfig();
|