@pega/custom-dx-components 0.25.17 → 0.25.19
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 +1 -1
- package/src/cli.js +6 -0
- package/src/constants.js +3 -1
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/localizations.json.mustache +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/localizations.json.mustache +5 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/localizations.json.mustache +8 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/localizations.json.mustache +10 -0
- package/src/tasks/create-version/helper.js +30 -0
- package/src/tasks/create-version/index.js +12 -4
- package/src/tasks/delete-pub/helper.js +1 -1
- package/src/tasks/delete-pub/index.js +6 -1
- package/src/tasks/export-archive/helper.js +12 -12
- package/src/tasks/export-archive/index.js +6 -0
- package/src/tasks/import-archive/helper.js +205 -3
- package/src/tasks/import-archive/index.js +146 -31
- package/src/tasks/index.js +1 -0
- package/src/tasks/init/template/package.json.mustache +2 -1
- package/src/tasks/list-pub/helper.js +3 -3
- package/src/tasks/publish-archive/index.js +5 -2
- package/src/tasks/publish-lib/index.js +16 -4
- package/src/tasks/restore/index.js +72 -0
- package/src/tasks/show-help/index.js +25 -7
- package/src/util.js +4 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
moveComponent,
|
|
33
33
|
renameLibrary,
|
|
34
34
|
restoreConfig,
|
|
35
|
+
restore,
|
|
35
36
|
revertWebPack,
|
|
36
37
|
promoteWebPack,
|
|
37
38
|
showStatus,
|
|
@@ -63,6 +64,7 @@ const TASKS = {
|
|
|
63
64
|
RENAME: 'rename',
|
|
64
65
|
RENAME_LIB: 'renameLibrary',
|
|
65
66
|
RESTORE_CONFIG: 'restoreConfig',
|
|
67
|
+
RESTORE_LIB: 'restore',
|
|
66
68
|
QUARANTINE: 'quarantine',
|
|
67
69
|
MOVE: 'moveComponent',
|
|
68
70
|
LIST: 'list',
|
|
@@ -170,6 +172,10 @@ export default async (args = []) => {
|
|
|
170
172
|
restoreConfig(options);
|
|
171
173
|
break;
|
|
172
174
|
}
|
|
175
|
+
case TASKS.RESTORE_LIB: {
|
|
176
|
+
restore(options);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
173
179
|
case TASKS.QUARANTINE: {
|
|
174
180
|
quarantine(options);
|
|
175
181
|
break;
|
package/src/constants.js
CHANGED
|
@@ -40,9 +40,11 @@ export const LP_DELETE_COMPONENT_SERVICE_REST_ENDPOINT =
|
|
|
40
40
|
'pegalaunchpad/c11n/isolations/{isolationId}/v102/assetsUpdate';
|
|
41
41
|
|
|
42
42
|
export const PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component_library';
|
|
43
|
-
export const
|
|
43
|
+
export const PUBLISH_COMPONENT_LIBRARY_ARCHIVE_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component_library_archive';
|
|
44
44
|
export const LIST_COMPONENT_LIBRARIES_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/list_component_libraries';
|
|
45
|
+
export const LIST_COMPONENT_LIBRARY_ARCHIVES_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/list_component_library_archives';
|
|
45
46
|
export const DELETE_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/delete_component_library';
|
|
47
|
+
export const COMPONENT_LIBRARY_ARCHIVE_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/component_library_archive';
|
|
46
48
|
|
|
47
49
|
|
|
48
50
|
export const FIELD_PATH = '/field';
|
package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/localizations.json.mustache
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fields": {
|
|
3
|
+
"State name" : "State name",
|
|
4
|
+
"State code" : "State code",
|
|
5
|
+
"State list for": "State list for",
|
|
6
|
+
"Click to show/hide state list": "Click to show/hide state list",
|
|
7
|
+
"State list": "State list",
|
|
8
|
+
"Loading state list": "Loading state list"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -80,3 +80,33 @@ addDebugLog("getCreateVersionComponentQuestions", "", "");
|
|
|
80
80
|
},
|
|
81
81
|
];
|
|
82
82
|
};
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export const getCreateVersionComponentCLQuestions = async () => {
|
|
86
|
+
addDebugLog("getCreateVersionComponentCLQuestions", "", "");
|
|
87
|
+
const componentDefaults = getConfigDefaults();
|
|
88
|
+
|
|
89
|
+
// increment the version
|
|
90
|
+
const incrVersion = await getNextVersion();
|
|
91
|
+
console.log(`\nCurrent library: ${chalk.green(`${componentDefaults.currentOrgLib}`)}`);
|
|
92
|
+
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
name: 'version',
|
|
96
|
+
message: 'Enter version ',
|
|
97
|
+
default: incrVersion,
|
|
98
|
+
validate: value => {
|
|
99
|
+
if (validateSemver(value)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return 'Please provide semver compatible version e.g 0.0.1';
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'copyExisting',
|
|
107
|
+
type: 'confirm',
|
|
108
|
+
message: 'Copy current components to new version ?',
|
|
109
|
+
default: true
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
};
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
cleanUpTemp
|
|
22
22
|
} from '../../util.js';
|
|
23
23
|
|
|
24
|
-
import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
|
|
24
|
+
import { getCreateVersionComponentQuestions, updateAllComponentsConfig, getCreateVersionComponentCLQuestions } from './helper.js';
|
|
25
25
|
import { showCurrentStatus } from '../show-status/index.js';
|
|
26
26
|
|
|
27
27
|
export default async options => {
|
|
@@ -65,9 +65,17 @@ addDebugLog("createVersion", "", "+");
|
|
|
65
65
|
copyExisting = !!(copyExist === 'Y' || copyExist === 'y' || copyExist === true || copyExist === 'true');
|
|
66
66
|
|
|
67
67
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
if (isLibraryBasedCL) {
|
|
69
|
+
const questions = await getCreateVersionComponentCLQuestions();
|
|
70
|
+
const answers = await inquirer.prompt(questions);
|
|
71
|
+
({ version, copyExisting } = answers);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const questions = await getCreateVersionComponentQuestions();
|
|
75
|
+
const answers = await inquirer.prompt(questions);
|
|
76
|
+
({ version, permBuild, copyExisting } = answers);
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
if (isLibraryBasedCL) {
|
|
@@ -135,7 +135,7 @@ addDebugLog("getInfinityLibraries", '', "");
|
|
|
135
135
|
|
|
136
136
|
// inquire
|
|
137
137
|
|
|
138
|
-
let urlParams = `/
|
|
138
|
+
let urlParams = `/app-name/${ApplicationName}/app-version/${ApplicationVersion}/rulesetname/${rulesetName}/rulesetversion/${rulesetVersion}`;
|
|
139
139
|
//let urlParams = `&ApplicationName=${ApplicationName}&ApplicationVersion=${ApplicationVersion}&RulesetName=${rulesetName}&RulesetVersion=${rulesetVersion}`;
|
|
140
140
|
//urlParams = encodeURIComponent(urlParams);
|
|
141
141
|
|
|
@@ -3,7 +3,7 @@ import ora from 'ora';
|
|
|
3
3
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
|
|
6
|
-
import { showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion, addDebugLog, getConfigDefaults, getLibraryBasedCL, getPegaServerConfig, deleteInfinityServerComponentLibrary } from '../../util.js';
|
|
6
|
+
import { showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion, addDebugLog, getConfigDefaults, getLibraryBasedCL, getPegaServerConfig, deleteInfinityServerComponentLibrary, checkAccessTokenExpiration } from '../../util.js';
|
|
7
7
|
import { deleteLib } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
8
8
|
|
|
9
9
|
import { getDeleteLibraryQuestions, getLibraryVersionQuestion, getRulesetAndVersionQuestion, SOURCE_OF_COMPONENT_TYPES, getInfinityLibraries } from './helper.js';
|
|
@@ -85,7 +85,12 @@ addDebugLog("deletePublished", "END", "-");
|
|
|
85
85
|
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
+
// server
|
|
89
|
+
|
|
90
|
+
await checkAccessTokenExpiration();
|
|
91
|
+
|
|
88
92
|
const isLibraryBasedCL = getLibraryBasedCL();
|
|
93
|
+
|
|
89
94
|
if (isLibraryBasedCL) {
|
|
90
95
|
|
|
91
96
|
const serverConfg = await getPegaServerConfig();
|
|
@@ -111,18 +111,18 @@ addDebugLog("getLibraryVersionQuestion", "", "");
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
export const getServerOrDirectoryQuestion = async () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
+
default: 'Directory'
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
};
|
|
126
126
|
|
|
127
127
|
export const getFullArchiveQuestions = async () => {
|
|
128
128
|
|
|
@@ -191,6 +191,7 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
|
|
|
191
191
|
|
|
192
192
|
if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
|
|
193
193
|
|
|
194
|
+
/*
|
|
194
195
|
let currentOrStore = currentOrArchive;
|
|
195
196
|
if (currentOrArchive === "") {
|
|
196
197
|
console.log("\nYou've selected the current working library/version.");
|
|
@@ -212,6 +213,11 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
|
|
|
212
213
|
if (currentOrStore === "Current") {
|
|
213
214
|
archiveBeforeStore = true;
|
|
214
215
|
}
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
// We are just going to archive before store and not ask
|
|
219
|
+
archiveBeforeStore = true;
|
|
220
|
+
|
|
215
221
|
}
|
|
216
222
|
|
|
217
223
|
if (!fs.existsSync(exportPath)) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import fetch from 'node-fetch';
|
|
4
5
|
import { join } from 'path';
|
|
5
6
|
import { Listr } from 'listr2';
|
|
6
|
-
import { addDebugLog, getConfigDefaults, convertIntoPascalCase, getComponents, getComponentDirectoryPath, getDirectoryFiles, setConfigImportRelativePath, forceDefaultsUpdate } from '../../util.js';
|
|
7
|
-
import { TASKS_CONFIG_JSON_FILENAME, TEMP_PATH, PACKAGE_JSON_FILENAME } from '../../constants.js';
|
|
7
|
+
import { addDebugLog, getHttpsAgent, getConfigDefaults, getPegaServerConfig, convertIntoPascalCase, getComponents, getComponentDirectoryPath, getDirectoryFiles, setConfigImportRelativePath, forceDefaultsUpdate, constructCompleteUrl } from '../../util.js';
|
|
8
|
+
import { TASKS_CONFIG_JSON_FILENAME, TEMP_PATH, PACKAGE_JSON_FILENAME, LIST_COMPONENT_LIBRARY_ARCHIVES_SERVICE_REST_ENDPOINT, COMPONENT_LIBRARY_ARCHIVE_SERVICE_REST_ENDPOINT, TOKEN_PATH} from '../../constants.js';
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -229,6 +230,20 @@ export const updateTempArchive = async(libraryName, version, devBuild) => {
|
|
|
229
230
|
|
|
230
231
|
}
|
|
231
232
|
|
|
233
|
+
export const getServerOrDirectoryQuestion = async () => {
|
|
234
|
+
addDebugLog("getLibraryVersionQuestion", "", "");
|
|
235
|
+
|
|
236
|
+
return [
|
|
237
|
+
{
|
|
238
|
+
name: 'importFrom',
|
|
239
|
+
type: 'rawlist',
|
|
240
|
+
message: `Import from`,
|
|
241
|
+
choices: [{name: 'Local directory', value: 'Directory'}, {name: 'Server', value: 'Server'}],
|
|
242
|
+
defaut: 'Directory'
|
|
243
|
+
}
|
|
244
|
+
];
|
|
245
|
+
};
|
|
246
|
+
|
|
232
247
|
|
|
233
248
|
export const getFilePathQuestions = async () => {
|
|
234
249
|
addDebugLog("getFilePathQuestions", "", "");
|
|
@@ -304,7 +319,6 @@ addDebugLog("getFileNameQuestions", "", "");
|
|
|
304
319
|
export const updateSavedFilePath = async(filePath) => {
|
|
305
320
|
const currentDirectory = process.cwd();
|
|
306
321
|
const arPathParts = currentDirectory.split(path.sep);
|
|
307
|
-
const configDef = getConfigDefaults();
|
|
308
322
|
|
|
309
323
|
let defaultPath = join(path.sep, arPathParts[0], arPathParts[1], arPathParts[2]);
|
|
310
324
|
|
|
@@ -345,3 +359,191 @@ export const updateSavedFilePath = async(filePath) => {
|
|
|
345
359
|
}
|
|
346
360
|
|
|
347
361
|
}
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
async function fetchComponentLibraryArchivesFromInfinity(apiUrl, headers) {
|
|
368
|
+
addDebugLog("fetchComponentLibraryArchivesFromInfinity", `apiUrl: ${apiUrl}`, "");
|
|
369
|
+
const serverConfig = await getPegaServerConfig();
|
|
370
|
+
return new Promise((resolve, reject) => {
|
|
371
|
+
let status = 500;
|
|
372
|
+
fetch(apiUrl, {
|
|
373
|
+
method: 'GET',
|
|
374
|
+
agent: getHttpsAgent(serverConfig),
|
|
375
|
+
headers
|
|
376
|
+
})
|
|
377
|
+
.then((response) => {
|
|
378
|
+
status = response.status;
|
|
379
|
+
if (status === 401) {
|
|
380
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
381
|
+
}
|
|
382
|
+
else if (status === 404){
|
|
383
|
+
throw new Error('404: Server resource not found');
|
|
384
|
+
}
|
|
385
|
+
else if (status === 405){
|
|
386
|
+
throw new Error('405: Server method not allowed');
|
|
387
|
+
}
|
|
388
|
+
else if (status === 408){
|
|
389
|
+
throw new Error('408: Server timed out');
|
|
390
|
+
}
|
|
391
|
+
return response.json();
|
|
392
|
+
})
|
|
393
|
+
.then((resp) => {
|
|
394
|
+
// const respData = JSON.parse(resp);
|
|
395
|
+
if (status === 401) {
|
|
396
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
397
|
+
// console.log(accessTokenUri, refreshToken);
|
|
398
|
+
/* TODO - Handle refresh_token */
|
|
399
|
+
} else if (status === 200) {
|
|
400
|
+
resolve(resp);
|
|
401
|
+
} else {
|
|
402
|
+
throw new Error(`${resp.message}`);
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
406
|
+
.catch((e) => reject(`${chalk.bold.red(e)}`));
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export const getServerLibraryArchives = async() => {
|
|
411
|
+
addDebugLog("getServerLibraryArchives", '', "");
|
|
412
|
+
|
|
413
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
414
|
+
let url = constructCompleteUrl(
|
|
415
|
+
defaultPegaServerConfig.server,
|
|
416
|
+
LIST_COMPONENT_LIBRARY_ARCHIVES_SERVICE_REST_ENDPOINT
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
return new Promise((resolve, reject) => {
|
|
421
|
+
try {
|
|
422
|
+
fs.readFile(TOKEN_PATH, 'utf8', (err, data) => {
|
|
423
|
+
if (err) {
|
|
424
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
425
|
+
reject(`\n${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
426
|
+
}
|
|
427
|
+
if (data) {
|
|
428
|
+
const { access_token: accessToken, token_type: tokenType } = JSON.parse(data);
|
|
429
|
+
|
|
430
|
+
const headers = {};
|
|
431
|
+
headers.Authorization = `${tokenType} ${accessToken}`;
|
|
432
|
+
|
|
433
|
+
fetchComponentLibraryArchivesFromInfinity(url, headers)
|
|
434
|
+
.then((response) => resolve(response))
|
|
435
|
+
.catch((e) => reject(e));
|
|
436
|
+
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
} catch (error) {
|
|
440
|
+
console.log(`\n${chalk.bold.red(error)}`);
|
|
441
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
442
|
+
reject(`${chalk.bold.red(error)}`);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
export const getLibraryArchiveQuestion = async (archiveVersions) => {
|
|
450
|
+
addDebugLog("getLibraryArchiveQuestion", `archiveVersions: ${archiveVersions}`, "");
|
|
451
|
+
return [
|
|
452
|
+
{
|
|
453
|
+
name: 'archiveData',
|
|
454
|
+
type: 'rawlist',
|
|
455
|
+
message: `Select an archive`,
|
|
456
|
+
choices: archiveVersions
|
|
457
|
+
}
|
|
458
|
+
];
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
async function fetchComponentLibraryArchiveFromInfinity(apiUrl, headers) {
|
|
464
|
+
addDebugLog("fetchComponentLibraryArchivesFromInfinity", `apiUrl: ${apiUrl}`, "");
|
|
465
|
+
const serverConfig = await getPegaServerConfig();
|
|
466
|
+
return new Promise((resolve, reject) => {
|
|
467
|
+
let status = 500;
|
|
468
|
+
fetch(apiUrl, {
|
|
469
|
+
method: 'GET',
|
|
470
|
+
agent: getHttpsAgent(serverConfig),
|
|
471
|
+
headers
|
|
472
|
+
})
|
|
473
|
+
.then((response) => {
|
|
474
|
+
status = response.status;
|
|
475
|
+
if (status === 401) {
|
|
476
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
477
|
+
}
|
|
478
|
+
else if (status === 404){
|
|
479
|
+
throw new Error('404: Server resource not found');
|
|
480
|
+
}
|
|
481
|
+
else if (status === 405){
|
|
482
|
+
throw new Error('405: Server method not allowed');
|
|
483
|
+
}
|
|
484
|
+
else if (status === 408){
|
|
485
|
+
throw new Error('408: Server timed out');
|
|
486
|
+
}
|
|
487
|
+
return response.json();
|
|
488
|
+
})
|
|
489
|
+
.then((resp) => {
|
|
490
|
+
// const respData = JSON.parse(resp);
|
|
491
|
+
if (status === 401) {
|
|
492
|
+
throw new Error('Error occurred in authentication. Please regenerate using authenticate');
|
|
493
|
+
// console.log(accessTokenUri, refreshToken);
|
|
494
|
+
/* TODO - Handle refresh_token */
|
|
495
|
+
} else if (status === 200) {
|
|
496
|
+
resolve(resp);
|
|
497
|
+
} else {
|
|
498
|
+
throw new Error(`${resp.message}`);
|
|
499
|
+
}
|
|
500
|
+
})
|
|
501
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
502
|
+
.catch((e) => reject(`${chalk.bold.red(e)}`));
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export const getServerLibraryArchive = async(appName, fileName, fileType, ruleSet, ruleSetVersion) => {
|
|
507
|
+
addDebugLog("getServerLibraryArchives", '', "");
|
|
508
|
+
|
|
509
|
+
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
510
|
+
let url = constructCompleteUrl(
|
|
511
|
+
defaultPegaServerConfig.server,
|
|
512
|
+
COMPONENT_LIBRARY_ARCHIVE_SERVICE_REST_ENDPOINT
|
|
513
|
+
);
|
|
514
|
+
|
|
515
|
+
let urlParams = `/app-name/${appName}/file-name/${fileName}/file-type/${fileType}/rulesetname/${ruleSet}/rulesetversion/${ruleSetVersion}`;
|
|
516
|
+
//let urlParams = `&ApplicationName=${ApplicationName}&ApplicationVersion=${ApplicationVersion}&RulesetName=${rulesetName}&RulesetVersion=${rulesetVersion}`;
|
|
517
|
+
//urlParams = encodeURIComponent(urlParams);
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
url = url.concat(urlParams);
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
return new Promise((resolve, reject) => {
|
|
524
|
+
try {
|
|
525
|
+
fs.readFile(TOKEN_PATH, 'utf8', (err, data) => {
|
|
526
|
+
if (err) {
|
|
527
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
528
|
+
reject(`\n${chalk.bold.red('Error occurred in authentication. Please regenerate using authenticate')}`);
|
|
529
|
+
}
|
|
530
|
+
if (data) {
|
|
531
|
+
const { access_token: accessToken, token_type: tokenType } = JSON.parse(data);
|
|
532
|
+
|
|
533
|
+
const headers = {};
|
|
534
|
+
headers.Authorization = `${tokenType} ${accessToken}`;
|
|
535
|
+
|
|
536
|
+
fetchComponentLibraryArchiveFromInfinity(url, headers)
|
|
537
|
+
.then((response) => resolve(response))
|
|
538
|
+
.catch((e) => reject(e));
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
} catch (error) {
|
|
543
|
+
console.log(`\n${chalk.bold.red(error)}`);
|
|
544
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
545
|
+
reject(`${chalk.bold.red(error)}`);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
}
|
|
@@ -6,6 +6,7 @@ import inquirer from 'inquirer';
|
|
|
6
6
|
import ncp from 'ncp';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import { Listr } from 'listr2';
|
|
9
|
+
import archiver from 'archiver';
|
|
9
10
|
|
|
10
11
|
import StreamZip from 'node-stream-zip';
|
|
11
12
|
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
showVersion,
|
|
18
19
|
getDirectoryFiles,
|
|
19
20
|
addDebugLog,
|
|
21
|
+
checkAccessTokenExpiration,
|
|
20
22
|
checkLibraryAndArchives,
|
|
21
23
|
getConfigDefaults,
|
|
22
24
|
getLibraryBased,
|
|
@@ -31,7 +33,7 @@ import {
|
|
|
31
33
|
getLibraryBasedCL
|
|
32
34
|
} from '../../util.js';
|
|
33
35
|
import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
|
|
34
|
-
import { getFilePathQuestions, getFileNameQuestions, updateTempArchive, updateSavedFilePath } from './helper.js';
|
|
36
|
+
import { getFilePathQuestions, getFileNameQuestions, updateTempArchive, updateSavedFilePath, getServerOrDirectoryQuestion, getLibraryArchiveQuestion, getServerLibraryArchives, getServerLibraryArchive } from './helper.js';
|
|
35
37
|
import { showCurrentStatus } from '../show-status/index.js';
|
|
36
38
|
|
|
37
39
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
@@ -236,6 +238,8 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
236
238
|
|
|
237
239
|
const currentDirectory = process.cwd();
|
|
238
240
|
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
241
|
+
|
|
242
|
+
|
|
239
243
|
const zipFilePath = join(filePath, fileName);
|
|
240
244
|
|
|
241
245
|
|
|
@@ -274,6 +278,8 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
274
278
|
|
|
275
279
|
await unZipFromArchive(zipFilePath);
|
|
276
280
|
|
|
281
|
+
|
|
282
|
+
|
|
277
283
|
// if (!fs.existsSync(tempTasksConfig) || !fs.existsSync(tempPackage)) {
|
|
278
284
|
// console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
|
|
279
285
|
// console.log(chalk.red.bold("Cleaning up..."));
|
|
@@ -431,6 +437,37 @@ export const getZipFileList = async(filePath) => {
|
|
|
431
437
|
}
|
|
432
438
|
}
|
|
433
439
|
|
|
440
|
+
function decodeBase64(encodedString) {
|
|
441
|
+
try {
|
|
442
|
+
const decodedString = atob(encodedString);
|
|
443
|
+
return decodedString;
|
|
444
|
+
} catch (error) {
|
|
445
|
+
console.error("Error decoding base64 string:", error);
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export const writeZipBuffer = async(fileName, fileBuffer) => {
|
|
451
|
+
const currentDirectory = process.cwd();
|
|
452
|
+
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
453
|
+
|
|
454
|
+
// have to decode it and then re-encode it.
|
|
455
|
+
let decodedString;
|
|
456
|
+
try {
|
|
457
|
+
decodedString = atob(fileBuffer);
|
|
458
|
+
} catch (error) {
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (!fs.existsSync (tempDirectory)) {
|
|
462
|
+
fs.mkdirSync(tempDirectory);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const filePath = join(tempDirectory, fileName);
|
|
466
|
+
|
|
467
|
+
fs.writeFileSync(filePath, fileBuffer, 'base64');
|
|
468
|
+
|
|
469
|
+
}
|
|
470
|
+
|
|
434
471
|
export default async options => {
|
|
435
472
|
await showVersion();
|
|
436
473
|
// await checkLibraryAndArchives();
|
|
@@ -449,9 +486,11 @@ export default async options => {
|
|
|
449
486
|
addDebugLog("importArchive", "", "+");
|
|
450
487
|
|
|
451
488
|
|
|
452
|
-
if (options.params.length >=
|
|
453
|
-
const
|
|
454
|
-
const
|
|
489
|
+
if (options.params.length >= 6) {
|
|
490
|
+
const localOrServer = options.params[3];
|
|
491
|
+
const filePath = options.params[4];
|
|
492
|
+
const fileName = options.params[5];
|
|
493
|
+
|
|
455
494
|
await importArch( filePath, fileName, hasArch);
|
|
456
495
|
|
|
457
496
|
}
|
|
@@ -459,43 +498,119 @@ export default async options => {
|
|
|
459
498
|
|
|
460
499
|
inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
|
|
461
500
|
|
|
462
|
-
let filePathQuestions;
|
|
463
|
-
try {
|
|
464
|
-
filePathQuestions = await getFilePathQuestions();
|
|
465
|
-
}
|
|
466
|
-
catch (ex) {
|
|
467
|
-
process.exit(1);
|
|
468
|
-
}
|
|
469
501
|
|
|
502
|
+
const localOrServerQuestion = await getServerOrDirectoryQuestion();
|
|
503
|
+
const localOrServerAnswer = await inquirer.prompt(localOrServerQuestion);
|
|
504
|
+
const {importFrom} = localOrServerAnswer;
|
|
470
505
|
|
|
471
|
-
|
|
472
|
-
try {
|
|
473
|
-
filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
474
|
-
}
|
|
475
|
-
catch(ex) {
|
|
476
|
-
process.exit(1);
|
|
477
|
-
}
|
|
506
|
+
if (importFrom === "Server") {
|
|
478
507
|
|
|
479
|
-
const { filePath } = filePathAnswers;
|
|
480
|
-
const zipFileList = await getZipFileList(filePath);
|
|
481
508
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
509
|
+
await checkAccessTokenExpiration();
|
|
510
|
+
|
|
511
|
+
let archiveVersions = [];
|
|
512
|
+
try {
|
|
513
|
+
archiveVersions = await getServerLibraryArchives();
|
|
514
|
+
}
|
|
515
|
+
catch (ex) {
|
|
516
|
+
console.log(chalk.redBright(ex));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
if (archiveVersions && archiveVersions.pxResults.length > 0) {
|
|
521
|
+
// ALL option
|
|
522
|
+
|
|
523
|
+
// to name value pairs
|
|
524
|
+
const archiveResults = archiveVersions["pxResults"].map( archive => ( { value: `${archive.pyApplicationName},${archive.pyFileName},${archive.pyFileType},${archive.pyRuleSet},${archive.pyRuleSetVersion}`, name: `${archive.pyLabel}, ${archive.pyRuleSet}:${archive.pyRuleSetVersion}` }) );
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
const versionQuestions = await getLibraryArchiveQuestion(archiveResults);
|
|
528
|
+
const versionAnswers = await inquirer.prompt(versionQuestions);
|
|
529
|
+
|
|
530
|
+
const {archiveData} = versionAnswers;
|
|
531
|
+
|
|
532
|
+
if (archiveData != "") {
|
|
533
|
+
|
|
534
|
+
const arArchData = archiveData.split(",");
|
|
535
|
+
let fileName = `${arArchData[1]}.${arArchData[2]}`;
|
|
536
|
+
// get archive
|
|
537
|
+
const fileData = await getServerLibraryArchive(arArchData[0],arArchData[1], arArchData[2], arArchData[3], arArchData[4]);
|
|
538
|
+
|
|
539
|
+
// console.log(fileSource);
|
|
540
|
+
|
|
541
|
+
// fileName = "big.zip";
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
await writeZipBuffer(fileName, fileData.pyFileSource);
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
// import archive
|
|
549
|
+
const currentDirectory = process.cwd();
|
|
550
|
+
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
551
|
+
|
|
552
|
+
await importArch( tempDirectory, fileName, hasArch);
|
|
553
|
+
// const zipFilePath = join(tempDirectory, fileName);
|
|
554
|
+
//await unZipFromArchive(zipFilePath);
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
// No library with that name
|
|
566
|
+
console.log(chalk.redBright(`No library archives exist on server.`));
|
|
567
|
+
process.exit(1);
|
|
568
|
+
|
|
569
|
+
}
|
|
570
|
+
|
|
485
571
|
}
|
|
572
|
+
else {
|
|
573
|
+
let filePathQuestions;
|
|
574
|
+
try {
|
|
575
|
+
filePathQuestions = await getFilePathQuestions();
|
|
576
|
+
}
|
|
577
|
+
catch (ex) {
|
|
578
|
+
process.exit(1);
|
|
579
|
+
}
|
|
486
580
|
|
|
487
|
-
await updateSavedFilePath(filePath);
|
|
488
581
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
582
|
+
let filePathAnswers;
|
|
583
|
+
try {
|
|
584
|
+
filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
585
|
+
}
|
|
586
|
+
catch(ex) {
|
|
587
|
+
process.exit(1);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const { filePath } = filePathAnswers;
|
|
591
|
+
const zipFileList = await getZipFileList(filePath);
|
|
592
|
+
|
|
593
|
+
if (!zipFileList || zipFileList.length === 0) {
|
|
594
|
+
console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
|
|
595
|
+
process.exit();
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
await updateSavedFilePath(filePath);
|
|
599
|
+
|
|
600
|
+
const fileNameQuestions = await getFileNameQuestions(zipFileList);
|
|
601
|
+
const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
|
|
602
|
+
const {fileName} = fileNameAnswers;
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
await importArch( filePath, fileName, hasArch);
|
|
606
|
+
|
|
607
|
+
// reapply to save if changed, because imported task.config may have overriden and we want
|
|
608
|
+
// to keep what was entered as the latest
|
|
609
|
+
await updateSavedFilePath(filePath);
|
|
610
|
+
}
|
|
492
611
|
|
|
493
612
|
|
|
494
|
-
await importArch( filePath, fileName, hasArch);
|
|
495
613
|
|
|
496
|
-
// reapply to save if changed, because imported task.config may have overriden and we want
|
|
497
|
-
// to keep what was entered as the latest
|
|
498
|
-
await updateSavedFilePath(filePath);
|
|
499
614
|
|
|
500
615
|
|
|
501
616
|
|
package/src/tasks/index.js
CHANGED
|
@@ -38,3 +38,4 @@ export { default as buildAllComponents } from './build-all/index.js';
|
|
|
38
38
|
export { default as buildLibrary } from './build-lib/index.js';
|
|
39
39
|
export { default as buildJestAssets } from './build-jest-assets/index.js';
|
|
40
40
|
export { default as restoreConfig } from './restore-config/index.js';
|
|
41
|
+
export { default as restore } from './restore/index.js';
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"deleteLibVersion": "custom-dx-components deleteVersion",
|
|
42
42
|
"move": "custom-dx-components moveComponent",
|
|
43
43
|
"publishLibVersion": "custom-dx-components publish",
|
|
44
|
+
"restoreLibVersion": "custom-dx-components restore",
|
|
44
45
|
"storeLibVersion": "custom-dx-components storeComponents",
|
|
45
46
|
"showStatus": "custom-dx-components showStatus",
|
|
46
47
|
"setPermanent": "custom-dx-components setPermanent",
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
"@babel/preset-react": "^7.26.3",
|
|
107
108
|
"@babel/preset-typescript": "^7.26.0",
|
|
108
109
|
"@pega/configs": "^0.16.2",
|
|
109
|
-
"@pega/custom-dx-components": "~0.25.
|
|
110
|
+
"@pega/custom-dx-components": "~0.25.19",
|
|
110
111
|
"@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
|
|
111
112
|
"@storybook/addon-actions": "^7.6.19",
|
|
112
113
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -83,8 +83,8 @@ addDebugLog("listLibJSONResponse", "services end", "");
|
|
|
83
83
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
async function
|
|
87
|
-
addDebugLog("
|
|
86
|
+
async function fetchComponentLibrariesFromInfinity(apiUrl, headers) {
|
|
87
|
+
addDebugLog("fetchComponentLibrariesFromInfinity", `apiUrl: ${apiUrl}`, "");
|
|
88
88
|
const serverConfig = await getPegaServerConfig();
|
|
89
89
|
return new Promise((resolve, reject) => {
|
|
90
90
|
let status = 500;
|
|
@@ -161,7 +161,7 @@ addDebugLog("getInfinityLibraries", '', "");
|
|
|
161
161
|
const headers = {};
|
|
162
162
|
headers.Authorization = `${tokenType} ${accessToken}`;
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
fetchComponentLibrariesFromInfinity(url, headers)
|
|
165
165
|
.then((response) => resolve(response))
|
|
166
166
|
.catch((e) => reject(e));
|
|
167
167
|
|
|
@@ -11,7 +11,7 @@ import { getPublishComponentQuestions } from './helper.js';
|
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
14
|
-
|
|
14
|
+
PUBLISH_COMPONENT_LIBRARY_ARCHIVE_SERVICE_REST_ENDPOINT,
|
|
15
15
|
TEMP_PATH,
|
|
16
16
|
TOKEN_PATH,
|
|
17
17
|
ARCHIVES_PATH
|
|
@@ -56,7 +56,7 @@ export const publishComponentLibraryArchiveToServer = async (data, doFetch) => {
|
|
|
56
56
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
57
57
|
const url = constructCompleteUrl(
|
|
58
58
|
defaultPegaConfig.server,
|
|
59
|
-
isLaunchpad ? launchpadRestEndpoint :
|
|
59
|
+
isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_LIBRARY_ARCHIVE_SERVICE_REST_ENDPOINT
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
if (doFetch) {
|
|
@@ -157,6 +157,7 @@ export default async (orgLibName, selectedVersion) => {
|
|
|
157
157
|
|
|
158
158
|
if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
|
|
159
159
|
|
|
160
|
+
/*
|
|
160
161
|
console.log("\nYou've selected the current working library/version.");
|
|
161
162
|
console.log("Export store or the current.");
|
|
162
163
|
const archAnswers = await inquirer.prompt([
|
|
@@ -174,6 +175,8 @@ export default async (orgLibName, selectedVersion) => {
|
|
|
174
175
|
if (currentOrStore === "Current") {
|
|
175
176
|
archiveBeforeStore = true;
|
|
176
177
|
}
|
|
178
|
+
*/
|
|
179
|
+
archiveBeforeStore = true;
|
|
177
180
|
|
|
178
181
|
if (archiveBeforeStore) {
|
|
179
182
|
|
|
@@ -70,7 +70,9 @@ export const zipLibraryComponent = async (libraryName, version) => {
|
|
|
70
70
|
const currentDirectory = process.cwd();
|
|
71
71
|
const libraryDirName = `${libraryName}/${version}`;
|
|
72
72
|
const libraryDirectory = path.join(currentDirectory, libraryDirName);
|
|
73
|
-
const componentsConfigJson =
|
|
73
|
+
const componentsConfigJson = path.join(libraryDirectory, "componentsconfig.json");
|
|
74
|
+
// const componentsConfigJson = `${libraryDirectory}/componentsconfig.json`;
|
|
75
|
+
const localizationsJson = path.join(libraryDirectory, "componentslocalization.json");
|
|
74
76
|
|
|
75
77
|
|
|
76
78
|
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
@@ -85,6 +87,11 @@ export const zipLibraryComponent = async (libraryName, version) => {
|
|
|
85
87
|
archive.file(componentsConfigJson, { name: path.basename(componentsConfigJson) });
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
// Add localizations file
|
|
91
|
+
if (fs.existsSync(localizationsJson)) {
|
|
92
|
+
archive.file(localizationsJson, { name: path.basename(localizationsJson) });
|
|
93
|
+
}
|
|
94
|
+
|
|
88
95
|
|
|
89
96
|
await archive.finalize();
|
|
90
97
|
|
|
@@ -93,6 +100,10 @@ export const zipLibraryComponent = async (libraryName, version) => {
|
|
|
93
100
|
const zipContent = zipBuffer.toString('base64');
|
|
94
101
|
|
|
95
102
|
const configContent = Buffer.from(fs.readFileSync(componentsConfigJson)).toString();
|
|
103
|
+
let localizationsContent = "[]";
|
|
104
|
+
if (fs.existsSync(localizationsJson)) {
|
|
105
|
+
localizationsContent = Buffer.from(fs.readFileSync(localizationsJson)).toString();
|
|
106
|
+
}
|
|
96
107
|
|
|
97
108
|
// if (fs.existsSync(libraryDirectory)) {
|
|
98
109
|
// fs.rm(libraryDirectory, { recursive: true }, err => {
|
|
@@ -102,13 +113,13 @@ export const zipLibraryComponent = async (libraryName, version) => {
|
|
|
102
113
|
// });
|
|
103
114
|
// }
|
|
104
115
|
|
|
105
|
-
return { zipContent, configContent };
|
|
116
|
+
return { zipContent, configContent, localizationsContent};
|
|
106
117
|
};
|
|
107
118
|
|
|
108
119
|
|
|
109
120
|
export const publishComponentLibraryToServer = async (data, doFetch) => {
|
|
110
121
|
addDebugLog("publishComponentToServer", `data: ${data}`, "");
|
|
111
|
-
const { configContent, zipContent, rulesetName, rulesetVersion, libraryName, version } = data;
|
|
122
|
+
const { configContent, zipContent, localizationsContent, rulesetName, rulesetVersion, libraryName, version } = data;
|
|
112
123
|
|
|
113
124
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
114
125
|
const { serverType, isolationId } = defaultPegaServerConfig;
|
|
@@ -138,7 +149,8 @@ export const publishComponentLibraryToServer = async (data, doFetch) => {
|
|
|
138
149
|
rulesetVersion,
|
|
139
150
|
libraryName,
|
|
140
151
|
version,
|
|
141
|
-
category: ''
|
|
152
|
+
category: '',
|
|
153
|
+
localizationsContent
|
|
142
154
|
};
|
|
143
155
|
}
|
|
144
156
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
import { Listr } from 'listr2';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
showVersion,
|
|
8
|
+
addDebugLog,
|
|
9
|
+
checkLibraryAndArchives,
|
|
10
|
+
getConfigDefaults,
|
|
11
|
+
getLibraryBased,
|
|
12
|
+
restoreFromArchive,
|
|
13
|
+
cleanUpTemp
|
|
14
|
+
} from '../../util.js';
|
|
15
|
+
|
|
16
|
+
export default async options => {
|
|
17
|
+
await showVersion();
|
|
18
|
+
await checkLibraryAndArchives();
|
|
19
|
+
|
|
20
|
+
addDebugLog("restoreComponent", "", "+");
|
|
21
|
+
|
|
22
|
+
await cleanUpTemp();
|
|
23
|
+
|
|
24
|
+
const isLibraryBased = getLibraryBased();
|
|
25
|
+
if (!isLibraryBased) {
|
|
26
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
27
|
+
process.exit();
|
|
28
|
+
}
|
|
29
|
+
const confDef = getConfigDefaults();
|
|
30
|
+
|
|
31
|
+
console.log(chalk.bold.yellow('\nChanges not saved to local storage will be LOST, code will be restored from local storage.'));
|
|
32
|
+
console.log("");
|
|
33
|
+
|
|
34
|
+
const restoreFromStore = await inquirer.prompt([
|
|
35
|
+
{
|
|
36
|
+
name: 'confirmRestore',
|
|
37
|
+
type: 'confirm',
|
|
38
|
+
message: `Restoring ${chalk.bold.green(`${confDef.displayLibVersion}`)} from local storage, proceed ?`,
|
|
39
|
+
default: true
|
|
40
|
+
}
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
if (restoreFromStore.confirmRestore) {
|
|
44
|
+
const switchToFileName = `${confDef.currentOrgLib}_${confDef.version}.arch.zip`;
|
|
45
|
+
const tasks = new Listr(
|
|
46
|
+
[
|
|
47
|
+
{
|
|
48
|
+
title: `Restoring ${confDef.displayLibVersion}`,
|
|
49
|
+
task: async () => {
|
|
50
|
+
// await zipVersionAndArchive(confDef.currentOrgLib, confDef.buildVersion);
|
|
51
|
+
await restoreFromArchive(switchToFileName, confDef.currentOrgLib, confDef.version);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
{ concurrent: false, exitOnError: true }
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
await tasks.run().catch(err => {
|
|
59
|
+
console.log(chalk.bold.red(err.toString()));
|
|
60
|
+
addDebugLog("restoreComponent", "", "-");
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
|
63
|
+
console.log(chalk.greenBright('\nComponents restored'));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
addDebugLog("restoreComponent", "", "-");
|
|
71
|
+
|
|
72
|
+
};
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
|
|
6
|
-
import { showVersion, getLibraryBased } from '../../util.js';
|
|
6
|
+
import { showVersion, getLibraryBased, getLibraryBasedCL } from '../../util.js';
|
|
7
7
|
|
|
8
8
|
export const showCurrentStatus = async () => {
|
|
9
9
|
|
|
@@ -58,9 +58,11 @@ export const showHelpV1 = () => {
|
|
|
58
58
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
export const showHelpV2 = () => {
|
|
61
|
+
export const showHelpV2 = (isCL) => {
|
|
62
62
|
console.log("");
|
|
63
|
-
|
|
63
|
+
if (!isCL) {
|
|
64
|
+
console.log(chalk.yellow("**** Beta capability and subject to change. Developer experimental. Do not use in a Production Deployment. ***\n"));
|
|
65
|
+
}
|
|
64
66
|
console.log(`--> All commands will not work until a library is created via ${chalk.cyan(`npm run createLib`)}.`);
|
|
65
67
|
console.log(`\nnpm run <command>`);
|
|
66
68
|
console.log(`\nUsage:`);
|
|
@@ -80,10 +82,18 @@ export const showHelpV2 = () => {
|
|
|
80
82
|
console.log(`${chalk.cyan('npm run createLibVersion')}\tcreate a new version within the current library`);
|
|
81
83
|
console.log(`${chalk.cyan('npm run switchLibVersion')}\tswitch to different version within the current library`);
|
|
82
84
|
console.log(`${chalk.cyan('npm run deleteLibVersion')}\tdelete current version, move to another version`);
|
|
85
|
+
console.log(`${chalk.cyan('npm run restoreLibVersion ')}\trestore current version from local storage (current changes will be LOST)`);
|
|
83
86
|
console.log(`${chalk.cyan('npm run storeLibVersion ')}\tstore current version to local storage (must SAVE components before)`);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
if (isCL) {
|
|
88
|
+
console.log(`${chalk.cyan('npm run exportLibVersion')}\texport current version as a zip file to a given local path or a server (must SAVE components before)`);
|
|
89
|
+
console.log(`${chalk.cyan('npm run importLibVersion')}\timport a zip file (created by export) from a given local path or a server`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log(`${chalk.cyan('npm run exportLibVersion')}\texport current version as a zip file to a given local path (must SAVE components before)`);
|
|
93
|
+
console.log(`${chalk.cyan('npm run importLibVersion')}\timport a zip file (created by export) from a given local path`);
|
|
94
|
+
console.log(`${chalk.cyan('npm run setPermanent ')}\tmake current version permanent or non permanent upon publish`);
|
|
95
|
+
}
|
|
96
|
+
|
|
87
97
|
|
|
88
98
|
console.log(`\n${chalk.underline(`Published Versions (needs authentication)`)}`);
|
|
89
99
|
console.log(`${chalk.cyan('npm run publish ')}\tpublish current library/version to server (creates a local published library as well)`);
|
|
@@ -109,17 +119,25 @@ export const showHelpV2 = () => {
|
|
|
109
119
|
console.log(`${chalk.cyan(`createLib, switchLib, createLibVersion, switchLibVersion, publishLibVersion, exportLibVersion`)}`);
|
|
110
120
|
console.log(`\nWhen editing in an IDE, always ${chalk.yellow("SAVE")} changes to components before doing a library/version context switch`);
|
|
111
121
|
console.log(`or changes will be lost!`);
|
|
122
|
+
console.log(`\nStoring is to LOCAL storage and is not backed up. You should export your library/versions archives to ${chalk.yellow("git")}`);
|
|
123
|
+
if (isCL) {
|
|
124
|
+
console.log(`or export archives to ${chalk.yellow("server")} for backup storage.`);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.log(`for backup storage.`);
|
|
128
|
+
}
|
|
112
129
|
console.log("");
|
|
113
130
|
}
|
|
114
131
|
|
|
115
132
|
|
|
116
133
|
export default async options => {
|
|
117
134
|
const isLibraryBased = getLibraryBased();
|
|
135
|
+
const isLibraryBasedCL = getLibraryBasedCL();
|
|
118
136
|
|
|
119
137
|
await showVersion();
|
|
120
138
|
|
|
121
139
|
if (isLibraryBased) {
|
|
122
|
-
await showHelpV2();
|
|
140
|
+
await showHelpV2(isLibraryBasedCL);
|
|
123
141
|
}
|
|
124
142
|
else {
|
|
125
143
|
await showHelpV1();
|
package/src/util.js
CHANGED
|
@@ -1847,6 +1847,9 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
|
|
|
1847
1847
|
|
|
1848
1848
|
};
|
|
1849
1849
|
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
|
|
1850
1853
|
export const zipVersionAndArchiveAndReturnBuffer = async (orgLibName, version, currentDirectory = "") => {
|
|
1851
1854
|
if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
|
|
1852
1855
|
// const srcDirectoryPath = await getSrcDirectoryPath();
|
|
@@ -1963,7 +1966,7 @@ export const zipUnArchiveToTempAndReturnBuffer = async(orgLibName, version) => {
|
|
|
1963
1966
|
for (const configF of configFiles) {
|
|
1964
1967
|
if (configF !== "package-lock.json") {
|
|
1965
1968
|
archive.file(
|
|
1966
|
-
join(
|
|
1969
|
+
join(tempDirectory, configF), { name: configF });
|
|
1967
1970
|
}
|
|
1968
1971
|
|
|
1969
1972
|
}
|