@pega/custom-dx-components 0.25.13 → 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 +5 -0
- package/src/tasks/authenticate/index.js +5 -0
- package/src/tasks/build-lib/index.js +2 -2
- 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/export-archive/helper.js +14 -0
- package/src/tasks/export-archive/index.js +46 -13
- 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 +104 -1
- package/src/tasks/list-pub/index.js +80 -32
- package/src/tasks/publish/index.js +16 -2
- package/src/tasks/publish-archive/helper.js +58 -0
- package/src/tasks/publish-archive/index.js +257 -0
- package/src/tasks/publish-lib/index.js +69 -51
- package/src/tasks/rename-lib/index.js +10 -1
- package/src/util.js +279 -6
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": "^
|
|
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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// cSpell:ignore words timeofday caseview casepreview objectview
|
|
2
2
|
export const TASKS_CONFIG_JSON_FILENAME = 'tasks.config.json';
|
|
3
3
|
export const PACKAGE_JSON_FILENAME = 'package.json';
|
|
4
|
+
export const PACKAGE_LOCK_JSON_FILENAME = 'package-lock.json';
|
|
4
5
|
export const BUILD_CONFIG_JSON_FILENAME = 'build.config.json';
|
|
5
6
|
export const WEBPACK_CONFIG_JS_FILENAME = 'webpack.config.js';
|
|
6
7
|
export const WEBPACK_PATHS_JS_FILENAME = 'paths.js';
|
|
@@ -39,6 +40,10 @@ export const LP_DELETE_COMPONENT_SERVICE_REST_ENDPOINT =
|
|
|
39
40
|
'pegalaunchpad/c11n/isolations/{isolationId}/v102/assetsUpdate';
|
|
40
41
|
|
|
41
42
|
export const PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component_library';
|
|
43
|
+
export const PUBLISH_COMPONENT_ARCHIVE_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component_archive';
|
|
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';
|
|
46
|
+
|
|
42
47
|
|
|
43
48
|
export const FIELD_PATH = '/field';
|
|
44
49
|
export const TEMPLATE_PATH = '/template';
|
|
@@ -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)}`);
|
|
@@ -3,7 +3,7 @@ import inquirer from 'inquirer';
|
|
|
3
3
|
import { Listr } from 'listr2';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
|
|
6
|
-
import { buildLib } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
6
|
+
import { buildLib, buildLibV3 } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
7
7
|
|
|
8
8
|
import validate from '../validator/index.js';
|
|
9
9
|
import { lintComponent } from '../linter/index.js';
|
|
@@ -115,7 +115,7 @@ addDebugLog("localBuildLibrary", `organization: ${organization}, library: ${libr
|
|
|
115
115
|
// with subdirectories for each version.
|
|
116
116
|
// If "buildDev", we append to version "-dev". Currently, only "-dev" versions, when published, can be deleted.
|
|
117
117
|
addDebugLog("buildLib", "services call", "");
|
|
118
|
-
|
|
118
|
+
buildLibV3(
|
|
119
119
|
buildLibName,
|
|
120
120
|
buildVersion,
|
|
121
121
|
tokenAndStaticServer.C11NB2S,
|
|
@@ -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
|
|
|
@@ -110,6 +110,20 @@ addDebugLog("getLibraryVersionQuestion", "", "");
|
|
|
110
110
|
];
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
export const getServerOrDirectoryQuestion = async () => {
|
|
114
|
+
addDebugLog("getLibraryVersionQuestion", "", "");
|
|
115
|
+
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
name: 'exportTo',
|
|
119
|
+
type: 'rawlist',
|
|
120
|
+
message: `Export to`,
|
|
121
|
+
choices: [{name: 'Local directory', value: 'Directory'}, {name: 'Server', value: 'Server'}],
|
|
122
|
+
defaut: 'Directory'
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
};
|
|
126
|
+
|
|
113
127
|
export const getFullArchiveQuestions = async () => {
|
|
114
128
|
|
|
115
129
|
return [
|
|
@@ -14,13 +14,16 @@ import {
|
|
|
14
14
|
checkLibraryAndArchives,
|
|
15
15
|
getConfigDefaults,
|
|
16
16
|
getLibraryBased,
|
|
17
|
+
getLibraryBasedCL,
|
|
17
18
|
zipVersionAndArchive,
|
|
18
19
|
zipVersionAndArchiveCL,
|
|
19
|
-
cleanUpTemp
|
|
20
|
+
cleanUpTemp,
|
|
21
|
+
checkAccessTokenExpiration
|
|
20
22
|
} from '../../util.js';
|
|
21
23
|
import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, BIN_ARCHIVES_PATH } from '../../constants.js';
|
|
22
|
-
import { getFilePathQuestions, getLibraryQuestion, getLibraryVersionQuestion, updateSavedExportFilePath, getFullArchiveQuestions } from './helper.js';
|
|
24
|
+
import { getFilePathQuestions, getLibraryQuestion, getLibraryVersionQuestion, updateSavedExportFilePath, getFullArchiveQuestions, getServerOrDirectoryQuestion } from './helper.js';
|
|
23
25
|
import { localBuildLibrary } from '../build-lib/index.js';
|
|
26
|
+
import publishArchive from '../publish-archive/index.js';
|
|
24
27
|
|
|
25
28
|
import inquirerFuzzyPath from '@pega/inquirer-fuzzy-path';
|
|
26
29
|
|
|
@@ -293,22 +296,26 @@ export default async options => {
|
|
|
293
296
|
await checkLibraryAndArchives();
|
|
294
297
|
|
|
295
298
|
await checkPathAccess(pegaConfigJsonPath);
|
|
299
|
+
|
|
296
300
|
const isLibraryBased = getLibraryBased();
|
|
297
301
|
if (!isLibraryBased) {
|
|
298
302
|
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
299
303
|
process.exit();
|
|
300
304
|
}
|
|
305
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
301
306
|
|
|
302
307
|
await cleanUpTemp();
|
|
303
308
|
|
|
304
309
|
addDebugLog("exportArchive", "", "+");
|
|
305
310
|
|
|
311
|
+
let exportTo = "";
|
|
306
312
|
|
|
307
313
|
if (options.params.length >= 8) {
|
|
308
314
|
let fullArchive = options.params[3];
|
|
309
315
|
const libraryName = options.params[4];
|
|
310
316
|
const libraryVersion = options.params[5];
|
|
311
317
|
const filePath = options.params[6];
|
|
318
|
+
exportTo = "Directory";
|
|
312
319
|
|
|
313
320
|
|
|
314
321
|
const currentOrArchive = options.params[7];
|
|
@@ -321,6 +328,7 @@ export default async options => {
|
|
|
321
328
|
let selectedVersion = "";
|
|
322
329
|
let fullArchive = "";
|
|
323
330
|
|
|
331
|
+
|
|
324
332
|
if (options.params.length >= 5) {
|
|
325
333
|
fullArchive = options.params[3];
|
|
326
334
|
orgLibName = options.params[4];
|
|
@@ -370,23 +378,48 @@ export default async options => {
|
|
|
370
378
|
({ selectedVersion } = libraryVersionAnswer);
|
|
371
379
|
}
|
|
372
380
|
|
|
373
|
-
|
|
381
|
+
if (isLibraryBasedCL) {
|
|
382
|
+
if (exportTo === "") {
|
|
383
|
+
const serverOrDirectoryQuestion = await getServerOrDirectoryQuestion();
|
|
384
|
+
const serverOrDirectoryAnswer = await inquirer.prompt(serverOrDirectoryQuestion);
|
|
385
|
+
({ exportTo } = serverOrDirectoryAnswer);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
exportTo = "Directory";
|
|
390
|
+
}
|
|
374
391
|
|
|
375
|
-
filePathQuestions = await getFilePathQuestions();
|
|
376
|
-
filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
377
|
-
({ filePath } = filePathAnswers);
|
|
378
392
|
|
|
379
|
-
|
|
393
|
+
if (exportTo === "Directory") {
|
|
394
|
+
inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
|
|
395
|
+
|
|
396
|
+
filePathQuestions = await getFilePathQuestions();
|
|
397
|
+
filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
398
|
+
({ filePath } = filePathAnswers);
|
|
399
|
+
|
|
400
|
+
await updateSavedExportFilePath(filePath);
|
|
401
|
+
|
|
402
|
+
// if (path.sep === "/") {
|
|
403
|
+
// if (filePath.lastIndexOf(path.sep) != filePath.length - 1) {
|
|
404
|
+
// filePath = filePath.concat(path.sep);
|
|
405
|
+
// }
|
|
406
|
+
// }
|
|
407
|
+
|
|
408
|
+
await exportArch( filePath, orgLibName, selectedVersion, fullArchive);
|
|
409
|
+
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
await checkAccessTokenExpiration();
|
|
413
|
+
|
|
414
|
+
// publish to server
|
|
415
|
+
await publishArchive(orgLibName, selectedVersion);
|
|
416
|
+
|
|
417
|
+
}
|
|
418
|
+
|
|
380
419
|
|
|
381
420
|
}
|
|
382
421
|
|
|
383
|
-
// if (path.sep === "/") {
|
|
384
|
-
// if (filePath.lastIndexOf(path.sep) != filePath.length - 1) {
|
|
385
|
-
// filePath = filePath.concat(path.sep);
|
|
386
|
-
// }
|
|
387
|
-
// }
|
|
388
422
|
|
|
389
|
-
await exportArch( filePath, orgLibName, selectedVersion, fullArchive);
|
|
390
423
|
|
|
391
424
|
}
|
|
392
425
|
|
|
@@ -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",
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
1
4
|
import chalk from 'chalk';
|
|
5
|
+
import fetch from 'node-fetch';
|
|
6
|
+
import { join } from 'path';
|
|
2
7
|
|
|
3
8
|
import {
|
|
4
9
|
getPegaServerConfig,
|
|
5
10
|
addDebugLog,
|
|
6
|
-
getC11NB2STokenAndStaticServer
|
|
11
|
+
getC11NB2STokenAndStaticServer,
|
|
12
|
+
getApplicationAndVersionFromToken,
|
|
13
|
+
constructCompleteUrl,
|
|
14
|
+
getHttpsAgent,
|
|
15
|
+
getConfigDefaults
|
|
7
16
|
} from '../../util.js';
|
|
8
17
|
|
|
9
18
|
import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
19
|
+
import { LIST_COMPONENT_LIBRARIES_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
|
|
10
20
|
|
|
11
21
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
12
22
|
SERVER: 'Server',
|
|
@@ -72,3 +82,96 @@ addDebugLog("listLibJSONResponse", "services end", "");
|
|
|
72
82
|
return [];
|
|
73
83
|
|
|
74
84
|
}
|
|
85
|
+
|
|
86
|
+
async function fetchComponenLibrariessFromInfinity(apiUrl, headers) {
|
|
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();
|
|
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
|
+
}
|
|
128
|
+
|
|
129
|
+
export const getInfinityLibraries = async() => {
|
|
130
|
+
addDebugLog("getInfinityLibraries", '', "");
|
|
131
|
+
|
|
132
|
+
const { app_name, app_version } = await getApplicationAndVersionFromToken();
|
|
133
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
134
|
+
let url = constructCompleteUrl(
|
|
135
|
+
defaultPegaServerConfig.server,
|
|
136
|
+
LIST_COMPONENT_LIBRARIES_SERVICE_REST_ENDPOINT
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const ApplicationName = app_name;
|
|
140
|
+
const ApplicationVersion = app_version;
|
|
141
|
+
const rulesetName = defaultPegaServerConfig.rulesetName;
|
|
142
|
+
const rulesetVersion = defaultPegaServerConfig.rulesetVersion;
|
|
143
|
+
|
|
144
|
+
let urlParams = `/AppName/${ApplicationName}/AppVersion/${ApplicationVersion}/ruleset/${rulesetName}/rulesetVersion/${rulesetVersion}`;
|
|
145
|
+
//let urlParams = `&ApplicationName=${ApplicationName}&ApplicationVersion=${ApplicationVersion}&RulesetName=${rulesetName}&RulesetVersion=${rulesetVersion}`;
|
|
146
|
+
//urlParams = encodeURIComponent(urlParams);
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
url = url.concat(urlParams);
|
|
150
|
+
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
try {
|
|
153
|
+
fs.readFile(TOKEN_PATH, 'utf8', (err, data) => {
|
|
154
|
+
if (err) {
|
|
155
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
156
|
+
reject(`\n${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
157
|
+
}
|
|
158
|
+
if (data) {
|
|
159
|
+
const { access_token: accessToken, token_type: tokenType } = JSON.parse(data);
|
|
160
|
+
|
|
161
|
+
const headers = {};
|
|
162
|
+
headers.Authorization = `${tokenType} ${accessToken}`;
|
|
163
|
+
|
|
164
|
+
fetchComponenLibrariessFromInfinity(url, headers)
|
|
165
|
+
.then((response) => resolve(response))
|
|
166
|
+
.catch((e) => reject(e));
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.log(`\n${chalk.bold.red(error)}`);
|
|
172
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
173
|
+
reject(`${chalk.bold.red(error)}`);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
}
|