@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
|
@@ -1,11 +1,11 @@
|
|
|
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 } 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
|
|
|
8
|
-
import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES, getServerLibraries, getServerLocalQuestion } from './helper.js';
|
|
8
|
+
import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES, getServerLibraries, getInfinityLibraries, getServerLocalQuestion } from './helper.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -139,37 +139,27 @@ addDebugLog("listPublished", "END", "-");
|
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
141
141
|
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
142
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
143
|
+
if (isLibraryBasedCL) {
|
|
144
|
+
const arLibs = await getInfinityLibraries();
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
name: 'library',
|
|
148
|
-
type: 'rawlist',
|
|
149
|
-
message: 'Pick library',
|
|
150
|
-
choices: arLibs
|
|
151
|
-
}
|
|
152
|
-
]);
|
|
146
|
+
if (arLibs && arLibs.pxResults && arLibs.pxResults.length > 0) {
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
const libVersions = await getServerLibraryVersions(libraryName);
|
|
148
|
+
const libs = arLibs.pxResults.map((oLib, index) => ({ name: oLib.pyLabel, value: index}));
|
|
156
149
|
|
|
157
|
-
if (libVersions) {
|
|
158
|
-
const keys = Object.keys(libVersions);
|
|
159
|
-
const libVersionAnswers = await inquirer.prompt([
|
|
160
150
|
|
|
151
|
+
const libAnswers = await inquirer.prompt([
|
|
161
152
|
{
|
|
162
|
-
name: '
|
|
153
|
+
name: 'library',
|
|
163
154
|
type: 'rawlist',
|
|
164
|
-
message: '
|
|
165
|
-
choices:
|
|
155
|
+
message: 'Pick library',
|
|
156
|
+
choices: libs
|
|
166
157
|
}
|
|
167
158
|
]);
|
|
168
159
|
|
|
169
|
-
const
|
|
160
|
+
const libraryIndex = libAnswers.library;
|
|
170
161
|
|
|
171
|
-
const
|
|
172
|
-
const data = JSON.parse(versionData);
|
|
162
|
+
const data = JSON.parse(arLibs.pxResults[libraryIndex].pxComponentDefinition);
|
|
173
163
|
|
|
174
164
|
// get built on from first component if exists
|
|
175
165
|
let builtOn = "(date unavailable)";
|
|
@@ -180,20 +170,78 @@ addDebugLog("listPublished", "END", "-");
|
|
|
180
170
|
let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
|
|
181
171
|
console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
|
|
182
172
|
console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
|
|
173
|
+
|
|
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);
|
|
182
|
+
|
|
183
|
+
}
|
|
183
184
|
}
|
|
184
185
|
else {
|
|
185
|
-
console.log(chalk.red("No libraries available on server."));
|
|
186
|
-
}
|
|
187
186
|
|
|
187
|
+
// old app static server
|
|
188
188
|
|
|
189
|
+
const arLibs = await getServerLibraries();
|
|
190
|
+
if (arLibs && arLibs.length > 0) {
|
|
189
191
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
const libAnswers = await inquirer.prompt([
|
|
193
|
+
{
|
|
194
|
+
name: 'library',
|
|
195
|
+
type: 'rawlist',
|
|
196
|
+
message: 'Pick library',
|
|
197
|
+
choices: arLibs
|
|
198
|
+
}
|
|
199
|
+
]);
|
|
200
|
+
|
|
201
|
+
libraryName = libAnswers.library;
|
|
202
|
+
const libVersions = await getServerLibraryVersions(libraryName);
|
|
203
|
+
|
|
204
|
+
if (libVersions) {
|
|
205
|
+
const keys = Object.keys(libVersions);
|
|
206
|
+
const libVersionAnswers = await inquirer.prompt([
|
|
207
|
+
|
|
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."));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
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);
|
|
243
|
+
|
|
244
|
+
}
|
|
197
245
|
|
|
198
246
|
}
|
|
199
247
|
|
|
@@ -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,
|
|
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,11 +21,15 @@ 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
|
|
|
27
28
|
await checkAccessTokenExpiration();
|
|
28
29
|
|
|
30
|
+
//
|
|
31
|
+
// library based V2 publishing
|
|
32
|
+
//
|
|
29
33
|
if (isLibraryBased) {
|
|
30
34
|
|
|
31
35
|
await checkJWTExpiration();
|
|
@@ -38,6 +42,10 @@ addDebugLog("publish", "", "+");
|
|
|
38
42
|
const currentOrgLib = orgLib.currentOrgLib;
|
|
39
43
|
// const currentVersion = devBuild ? `${orgLib.version}-dev`: orgLib.version;
|
|
40
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}`)}`);
|
|
41
49
|
|
|
42
50
|
const publishThisVersion = await inquirer.prompt([
|
|
43
51
|
{
|
|
@@ -79,7 +87,7 @@ addDebugLog("publish", "", "+");
|
|
|
79
87
|
}
|
|
80
88
|
}
|
|
81
89
|
|
|
82
|
-
if (okToPublish && !devBuild) {
|
|
90
|
+
if (okToPublish && !devBuild && !isLibraryBasedCL) {
|
|
83
91
|
okToPublish = false;
|
|
84
92
|
console.log("");
|
|
85
93
|
const publishAnswers = await inquirer.prompt([
|
|
@@ -106,9 +114,15 @@ addDebugLog("publish", "", "+");
|
|
|
106
114
|
|
|
107
115
|
}
|
|
108
116
|
|
|
117
|
+
// end of V2 publishing
|
|
109
118
|
return true;
|
|
110
119
|
}
|
|
111
120
|
|
|
121
|
+
// otherwise continue with original V1 publishig of individual components
|
|
122
|
+
|
|
123
|
+
//
|
|
124
|
+
// orginial V1 publish
|
|
125
|
+
//
|
|
112
126
|
|
|
113
127
|
let OauthData;
|
|
114
128
|
try {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addDebugLog,
|
|
3
|
+
getPegaServerConfig,
|
|
4
|
+
validateRulesetVersion
|
|
5
|
+
} from '../../util.js';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const getLibraryVersionQuestion = async(libVersions) => {
|
|
9
|
+
addDebugLog("getLibraryVersionQuestion", `libVersions: ${libVersions}`, "");
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
name: 'version',
|
|
13
|
+
type: 'rawlist',
|
|
14
|
+
message: 'Select library version to publish',
|
|
15
|
+
choices: libVersions
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const getPublishComponentQuestions = async componentKey => {
|
|
22
|
+
addDebugLog("getPublishComponentQuestions", `componentKey: ${componentKey}`, "");
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
26
|
+
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
name: 'rulesetName',
|
|
30
|
+
message: 'Enter ruleset name',
|
|
31
|
+
default: defaultPegaConfig.rulesetName,
|
|
32
|
+
validate: value => {
|
|
33
|
+
if (value.trim()) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return 'Ruleset name cannot be empty';
|
|
37
|
+
},
|
|
38
|
+
when: () => {
|
|
39
|
+
return defaultPegaConfig.serverType === 'infinity';
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'rulesetVersion',
|
|
44
|
+
message: 'Enter ruleset version',
|
|
45
|
+
default: defaultPegaConfig.rulesetVersion,
|
|
46
|
+
validate: value => {
|
|
47
|
+
if (validateRulesetVersion(value)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return 'Please provide compatible version e.g 01-01-01';
|
|
51
|
+
},
|
|
52
|
+
when: () => {
|
|
53
|
+
return defaultPegaConfig.serverType === 'infinity';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import fetch from 'node-fetch';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import { zipUnArchiveToTempAndReturnBuffer, constructCompleteUrl, getHttpsAgent, getPegaServerConfig, addDebugLog, getConfigDefaults, zipVersionAndArchiveAndReturnBuffer } from '../../util.js';
|
|
9
|
+
|
|
10
|
+
import { getPublishComponentQuestions } from './helper.js';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
14
|
+
PUBLISH_COMPONENT_ARCHIVE_SERVICE_REST_ENDPOINT,
|
|
15
|
+
TEMP_PATH,
|
|
16
|
+
TOKEN_PATH,
|
|
17
|
+
ARCHIVES_PATH
|
|
18
|
+
} from '../../constants.js';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const publishComponentLibraryArchiveToServer = async (data, doFetch) => {
|
|
22
|
+
addDebugLog("publishComponentToServer", `data: ${data}`, "");
|
|
23
|
+
const { zipContent, rulesetName, rulesetVersion, libraryName, version } = data;
|
|
24
|
+
|
|
25
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
26
|
+
const { serverType, isolationId } = defaultPegaServerConfig;
|
|
27
|
+
const isLaunchpad = serverType === 'launchpad';
|
|
28
|
+
const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace(
|
|
29
|
+
'{isolationId}',
|
|
30
|
+
isolationId || 'undefined'
|
|
31
|
+
);
|
|
32
|
+
let apiBody;
|
|
33
|
+
|
|
34
|
+
if (isLaunchpad) {
|
|
35
|
+
// currently no launchpad records to rule resolve a library
|
|
36
|
+
|
|
37
|
+
// apiBody = {
|
|
38
|
+
// type: 'CustomComponent',
|
|
39
|
+
// zipContent,
|
|
40
|
+
// componentName: JSON.parse(configContent).componentKey,
|
|
41
|
+
// pxUpdateDateTime: '',
|
|
42
|
+
// environmentID: defaultPegaServerConfig.isolationId
|
|
43
|
+
// };
|
|
44
|
+
} else {
|
|
45
|
+
apiBody = {
|
|
46
|
+
zipContent,
|
|
47
|
+
publishFor: 'constellation',
|
|
48
|
+
rulesetName,
|
|
49
|
+
rulesetVersion,
|
|
50
|
+
libraryName,
|
|
51
|
+
version,
|
|
52
|
+
category: ''
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
57
|
+
const url = constructCompleteUrl(
|
|
58
|
+
defaultPegaConfig.server,
|
|
59
|
+
isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_ARCHIVE_SERVICE_REST_ENDPOINT
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (doFetch) {
|
|
63
|
+
try {
|
|
64
|
+
const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
65
|
+
if (OauthData) {
|
|
66
|
+
const {
|
|
67
|
+
access_token: accessToken,
|
|
68
|
+
token_type: tokenType
|
|
69
|
+
// refresh_token: refreshToken
|
|
70
|
+
} = JSON.parse(OauthData);
|
|
71
|
+
let status = 500;
|
|
72
|
+
let headers = {};
|
|
73
|
+
|
|
74
|
+
if (isLaunchpad) {
|
|
75
|
+
headers.cookie = `Pega-AAT=${accessToken}`;
|
|
76
|
+
headers['Content-Type'] = 'application/json';
|
|
77
|
+
} else {
|
|
78
|
+
headers.Authorization = `${tokenType} ${accessToken}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const response = await fetch(url, {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
agent: getHttpsAgent(defaultPegaConfig),
|
|
84
|
+
headers,
|
|
85
|
+
body: JSON.stringify(apiBody)
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
status = response.status;
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
if (status === 401) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
'Error occurred in authentication. Please regenerate using authenticate'
|
|
93
|
+
);
|
|
94
|
+
// console.log(accessTokenUri, refreshToken);
|
|
95
|
+
/* TODO - Handle refresh_token */
|
|
96
|
+
} else if (status === 404) {
|
|
97
|
+
throw new Error('404: Server resource not found');
|
|
98
|
+
} else if (status === 405) {
|
|
99
|
+
throw new Error('405: Server method not allowed');
|
|
100
|
+
} else if (status === 408) {
|
|
101
|
+
throw new Error('408: Server timed out');
|
|
102
|
+
} else if (response.status === 403) {
|
|
103
|
+
throw new Error('Error forbidden: User does not have privileges to Publish.');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const respData = isLaunchpad ? await response.text() : await response.json();
|
|
109
|
+
console.log(chalk.bold.green(`Success : ${isLaunchpad ? respData : respData.message}`));
|
|
110
|
+
|
|
111
|
+
if (status === 500) {
|
|
112
|
+
status = 999;
|
|
113
|
+
throw new Error(respData.message);
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
if (status === 500) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`Error occurred in authentication. Please regenerate using authenticate`
|
|
119
|
+
);
|
|
120
|
+
} else if (status === 999) {
|
|
121
|
+
throw new Error(err);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
// throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
|
|
129
|
+
throw Error(err);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
export default async (orgLibName, selectedVersion) => {
|
|
142
|
+
// console.log(orgLibName + ", " + selectedVersion);
|
|
143
|
+
const configDef = await getConfigDefaults();
|
|
144
|
+
let archiveBeforeStore = false;
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
const rulesetQuestions = await getPublishComponentQuestions();
|
|
148
|
+
const rulesetAnswers = await inquirer.prompt(rulesetQuestions);
|
|
149
|
+
const { rulesetName, rulesetVersion} = rulesetAnswers;
|
|
150
|
+
|
|
151
|
+
let content = {
|
|
152
|
+
libraryName : orgLibName,
|
|
153
|
+
version : selectedVersion,
|
|
154
|
+
rulesetName, rulesetVersion
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
|
|
159
|
+
|
|
160
|
+
console.log("\nYou've selected the current working library/version.");
|
|
161
|
+
console.log("Export store or the current.");
|
|
162
|
+
const archAnswers = await inquirer.prompt([
|
|
163
|
+
{
|
|
164
|
+
name: 'currentOrStore',
|
|
165
|
+
type: 'rawlist',
|
|
166
|
+
message: 'Select current or store',
|
|
167
|
+
default: "Current",
|
|
168
|
+
choices: ["Current", "Store"]
|
|
169
|
+
},
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
const currentOrStore = archAnswers.currentOrStore;
|
|
173
|
+
|
|
174
|
+
if (currentOrStore === "Current") {
|
|
175
|
+
archiveBeforeStore = true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (archiveBeforeStore) {
|
|
179
|
+
|
|
180
|
+
// returns both the output promise and the buffer that can be sent to PegaInfinity
|
|
181
|
+
let zipBuffer = await zipVersionAndArchiveAndReturnBuffer(configDef.currentOrgLib, configDef.buildVersion);
|
|
182
|
+
|
|
183
|
+
zipBuffer.output.on('close', function() {
|
|
184
|
+
if (zipBuffer.zipContent != null) {
|
|
185
|
+
content = { ...content, zipContent: zipBuffer.zipContent};
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
publishComponentLibraryArchiveToServer(content, true )
|
|
189
|
+
.then( () => {
|
|
190
|
+
console.log(chalk.green.bold(`Success: Published Archive ${content.libraryName}/${content.version} to server.`));
|
|
191
|
+
})
|
|
192
|
+
.catch( (err) => {
|
|
193
|
+
console.log(chalk.red.bold(err));
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
console.log(chalk.bold.red(err.toString()));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return;
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
|
|
210
|
+
// for now, to get a "buffer" from a zip file, need to unzip it in a /temp directory
|
|
211
|
+
// then re-zip. During the re-zip, create a buffer that can be passed to PegaInfinity
|
|
212
|
+
|
|
213
|
+
const mainDirectory = process.cwd();
|
|
214
|
+
const archiveFileName = `${orgLibName}_${selectedVersion}.arch.zip`;
|
|
215
|
+
const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${selectedVersion}`);
|
|
216
|
+
if (fs.existsSync(archiveDirectory)) {
|
|
217
|
+
const archiveFile = join(archiveDirectory, archiveFileName);
|
|
218
|
+
|
|
219
|
+
// unzip to /temp, then re-zip and retrieve the buffer (remove /temp later)
|
|
220
|
+
let zipBuffer = await zipUnArchiveToTempAndReturnBuffer(orgLibName, selectedVersion);
|
|
221
|
+
|
|
222
|
+
zipBuffer.output.on('close', function() {
|
|
223
|
+
|
|
224
|
+
// get rid of temp directory, regardless
|
|
225
|
+
const tempDirectory = join (mainDirectory, TEMP_PATH);
|
|
226
|
+
if (fs.existsSync(tempDirectory)) {
|
|
227
|
+
fs.rmSync(tempDirectory, { recursive: true });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (zipBuffer.zipContent != null) {
|
|
231
|
+
|
|
232
|
+
content = { ...content, zipContent: zipBuffer.zipContent};
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
publishComponentLibraryArchiveToServer(content, true )
|
|
236
|
+
.then( () => {
|
|
237
|
+
console.log(chalk.green.bold(`Success: Published Archive ${content.libraryName}/${content.version} to server.`));
|
|
238
|
+
})
|
|
239
|
+
.catch( (err) => {
|
|
240
|
+
console.log(chalk.red.bold(err));
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
console.log(chalk.bold.red(err.toString()));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
};
|