@pega/custom-dx-components 0.25.22 → 0.25.23

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.
Files changed (46) hide show
  1. package/package.json +1 -1
  2. package/src/tasks/build-jest-assets/index.js +0 -1
  3. package/src/tasks/build-lib/helper.js +0 -2
  4. package/src/tasks/build-lib/index.js +3 -3
  5. package/src/tasks/delete/helper.js +0 -1
  6. package/src/tasks/delete/index.js +5 -1
  7. package/src/tasks/delete-lib/helper.js +0 -1
  8. package/src/tasks/delete-pub/helper.js +7 -2
  9. package/src/tasks/delete-version/index.js +0 -1
  10. package/src/tasks/export-archive/helper.js +7 -1
  11. package/src/tasks/export-archive/index.js +10 -34
  12. package/src/tasks/import-archive/helper.js +19 -5
  13. package/src/tasks/import-archive/index.js +247 -35
  14. package/src/tasks/import-comp/helper.js +0 -2
  15. package/src/tasks/init/template/package.json.mustache +1 -1
  16. package/src/tasks/init/template/tasks.config.json +1 -1
  17. package/src/tasks/list/helper.js +17 -2
  18. package/src/tasks/list-lib/index.js +10 -1
  19. package/src/tasks/list-pub/helper.js +2 -4
  20. package/src/tasks/list-pub/index.js +15 -2
  21. package/src/tasks/publish/helper.js +0 -1
  22. package/src/tasks/publish/index.js +13 -1
  23. package/src/tasks/publish-all/index.js +10 -1
  24. package/src/tasks/publish-archive/index.js +51 -83
  25. package/src/tasks/publish-lib/index.js +0 -23
  26. package/src/tasks/rename/index.js +9 -1
  27. package/src/tasks/restore/index.js +19 -13
  28. package/src/tasks/set-perm/index.js +0 -2
  29. package/src/tasks/show-help/index.js +1 -5
  30. package/src/tasks/show-status/index.js +19 -6
  31. package/src/tasks/store/index.js +39 -18
  32. package/src/tasks/switch-lib/helper.js +0 -1
  33. package/src/util.js +6 -77
  34. package/tests/assets/library/components/create/shared/create-nonce.ts +1 -0
  35. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDate/date.ts +0 -24
  36. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MySearchbox/repeat-utils.ts +0 -4
  37. package/tests/assets/library/components/createAll/Constellation/shared/create-nonce.ts +1 -0
  38. package/tests/functional/localCreateBuildAllDeleteAll.test.js +8 -8
  39. package/tests/functional/localCreateBuildDelete.test.js +8 -8
  40. package/tests/functional/localCreateListDelete.test.js +8 -8
  41. package/tests/functional/localCreatePublishAllDeleteAll.test.js +8 -8
  42. package/tests/functional/localCreatePublishDelete.test.js +8 -8
  43. package/tests/functional/localCreateRenameDelete.test.js +8 -8
  44. package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +1 -1
  45. package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +1 -1
  46. package/tests/functional/localLibCreateLibStoreRestoreDeleteLib.test.js +376 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.25.22",
3
+ "version": "0.25.23",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -2,7 +2,6 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { join } from 'path';
4
4
  import inquirer from 'inquirer';
5
- import { Listr } from 'listr2';
6
5
  import chalk from 'chalk';
7
6
 
8
7
  import { showVersion, getServerType, setServerType, getSubComponents, deleteLocalComponent, checkPathAccess, getComponents, getLibraryBasedCL, setLibraryBasedCL, forceDefaultsUpdate } from '../../util.js';
@@ -1,5 +1,3 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
1
  import chalk from 'chalk';
4
2
 
5
3
  import {
@@ -106,9 +106,9 @@ addDebugLog("localBuildLibrary", `organization: ${organization}, library: ${libr
106
106
  // warnings are part of buildLib
107
107
 
108
108
  // for now
109
- console.log(chalk.green.bold('Compile check...'));
110
- await bundleComponent(components[0], null, devBuild, false);
111
- console.log('');
109
+ // console.log(chalk.green.bold('Compile check...'));
110
+ // await bundleComponent(components[0], null, devBuild, false);
111
+ // console.log('');
112
112
 
113
113
  // remove dist/lib stuff
114
114
  await cleanUp();
@@ -13,7 +13,6 @@ import {
13
13
  getComponents,
14
14
  getPegaServerConfig,
15
15
  standardizeStr,
16
- sanitize,
17
16
  addDebugLog,
18
17
  checkAccessTokenExpiration
19
18
  } from '../../util.js';
@@ -2,7 +2,11 @@ import inquirer from 'inquirer';
2
2
 
3
3
  import { showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives } from '../../util.js';
4
4
 
5
- import { deleteLocalComponents, SOURCE_OF_COMPONENT_TYPES, deleteServerComponents, getDeleteComponentsQuestions } from './helper.js';
5
+ import {
6
+ deleteLocalComponents,
7
+ SOURCE_OF_COMPONENT_TYPES,
8
+ deleteServerComponents,
9
+ getDeleteComponentsQuestions } from './helper.js';
6
10
 
7
11
 
8
12
  const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
@@ -1,4 +1,3 @@
1
- import path from 'path';
2
1
  import chalk from 'chalk';
3
2
 
4
3
  import { addDebugLog, getConfigDefaults, getLibraryArchiveDirectories } from '../../util.js';
@@ -1,9 +1,14 @@
1
1
  import fs from 'fs';
2
- import path from 'path';
3
2
  import chalk from 'chalk';
4
3
  import fetch from 'node-fetch';
5
4
 
6
- import { getPegaServerConfig, addDebugLog, getApplicationAndVersionFromToken, constructCompleteUrl, getHttpsAgent, validateRulesetVersion } from '../../util.js';
5
+ import {
6
+ getPegaServerConfig,
7
+ addDebugLog,
8
+ getApplicationAndVersionFromToken,
9
+ constructCompleteUrl,
10
+ getHttpsAgent,
11
+ validateRulesetVersion } from '../../util.js';
7
12
  import { LIST_COMPONENT_LIBRARIES_SERVICE_REST_ENDPOINT, TOKEN_PATH } from '../../constants.js';
8
13
 
9
14
  export const SOURCE_OF_COMPONENT_TYPES = {
@@ -1,4 +1,3 @@
1
- import inquirer from 'inquirer';
2
1
  import chalk from 'chalk';
3
2
 
4
3
  import {
@@ -1,7 +1,13 @@
1
1
  import chalk from 'chalk';
2
2
  import path from 'path';
3
3
  import { join } from 'path';
4
- import { addDebugLog, getConfigDefaults, getLibraryArchiveDirectories, getLibraryArchivesVersions, setConfigExportRelativePath, forceDefaultsUpdate } from '../../util.js';
4
+ import {
5
+ addDebugLog,
6
+ getConfigDefaults,
7
+ getLibraryArchiveDirectories,
8
+ getLibraryArchivesVersions,
9
+ setConfigExportRelativePath,
10
+ forceDefaultsUpdate } from '../../util.js';
5
11
 
6
12
  export const SOURCE_OF_COMPONENT_TYPES = {
7
13
  SERVER: 'Server',
@@ -1,7 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import { promisify } from 'util';
3
3
  import { join } from 'path';
4
- import path from 'path';
5
4
 
6
5
  import inquirer from 'inquirer';
7
6
  import ncp from 'ncp';
@@ -21,7 +20,7 @@ import {
21
20
  checkAccessTokenExpiration
22
21
  } from '../../util.js';
23
22
  import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, BIN_ARCHIVES_PATH } from '../../constants.js';
24
- import { getFilePathQuestions, getLibraryQuestion, getLibraryVersionQuestion, updateSavedExportFilePath, getFullArchiveQuestions, getServerOrDirectoryQuestion } from './helper.js';
23
+ import { getFilePathQuestions, getLibraryQuestion, getLibraryVersionQuestion, updateSavedExportFilePath, getServerOrDirectoryQuestion } from './helper.js';
25
24
  import { localBuildLibrary } from '../build-lib/index.js';
26
25
  import publishArchive from '../publish-archive/index.js';
27
26
 
@@ -143,8 +142,6 @@ addDebugLog("exportCLArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName
143
142
  }
144
143
  }
145
144
 
146
-
147
-
148
145
  // archive it
149
146
  output = await zipVersionAndArchiveCL(configDef.currentOrgLib, configDef.buildVersion);
150
147
 
@@ -163,9 +160,6 @@ addDebugLog("exportCLArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName
163
160
 
164
161
 
165
162
 
166
-
167
-
168
-
169
163
  }
170
164
 
171
165
 
@@ -191,30 +185,6 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
191
185
 
192
186
  if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
193
187
 
194
- /*
195
- let currentOrStore = currentOrArchive;
196
- if (currentOrArchive === "") {
197
- console.log("\nYou've selected the current working library/version.");
198
- console.log("Export store or the current.");
199
- const archAnswers = await inquirer.prompt([
200
- {
201
- name: 'currentOrStore',
202
- type: 'rawlist',
203
- message: 'Select current or store',
204
- default: "Current",
205
- choices: ["Current", "Store"]
206
- },
207
- ]);
208
-
209
- currentOrStore = archAnswers.currentOrStore;
210
-
211
- }
212
-
213
- if (currentOrStore === "Current") {
214
- archiveBeforeStore = true;
215
- }
216
- */
217
-
218
188
  // We are just going to archive before store and not ask
219
189
  archiveBeforeStore = true;
220
190
 
@@ -262,6 +232,8 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
262
232
 
263
233
 
264
234
  if (archiveBeforeStore) {
235
+
236
+
265
237
  // archive it
266
238
  output = await zipVersionAndArchive(configDef.currentOrgLib, configDef.buildVersion);
267
239
 
@@ -386,7 +358,7 @@ export default async options => {
386
358
  ({ selectedVersion } = libraryVersionAnswer);
387
359
  }
388
360
 
389
- /* when we can export to server, un comment this out
361
+ // when we can export to server, un comment this out
390
362
  if (isLibraryBasedCL) {
391
363
  if (exportTo === "") {
392
364
  const serverOrDirectoryQuestion = await getServerOrDirectoryQuestion();
@@ -397,8 +369,8 @@ export default async options => {
397
369
  else {
398
370
  exportTo = "Directory";
399
371
  }
400
- */
401
- exportTo = "Directory"; // remove this line when above is uncommented out
372
+
373
+ //exportTo = "Directory"; // remove this line when above is uncommented out
402
374
 
403
375
 
404
376
  if (exportTo === "Directory") {
@@ -422,6 +394,10 @@ export default async options => {
422
394
  else {
423
395
  await checkAccessTokenExpiration();
424
396
 
397
+ // archive it
398
+ await zipVersionAndArchive(orgLibName, selectedVersion);
399
+
400
+
425
401
  // publish to server
426
402
  await publishArchive(orgLibName, selectedVersion);
427
403
 
@@ -4,8 +4,25 @@ import path from 'path';
4
4
  import fetch from 'node-fetch';
5
5
  import { join } from 'path';
6
6
  import { Listr } from 'listr2';
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';
7
+ import {
8
+ addDebugLog,
9
+ getHttpsAgent,
10
+ getConfigDefaults,
11
+ getPegaServerConfig,
12
+ convertIntoPascalCase,
13
+ getComponents,
14
+ getComponentDirectoryPath,
15
+ getDirectoryFiles,
16
+ setConfigImportRelativePath,
17
+ forceDefaultsUpdate,
18
+ constructCompleteUrl } from '../../util.js';
19
+ import {
20
+ TASKS_CONFIG_JSON_FILENAME,
21
+ TEMP_PATH,
22
+ PACKAGE_JSON_FILENAME,
23
+ LIST_COMPONENT_LIBRARY_ARCHIVES_SERVICE_REST_ENDPOINT,
24
+ COMPONENT_LIBRARY_ARCHIVE_SERVICE_REST_ENDPOINT,
25
+ TOKEN_PATH} from '../../constants.js';
9
26
 
10
27
 
11
28
 
@@ -513,9 +530,6 @@ async function fetchComponentLibraryArchivesFromInfinity(apiUrl, headers) {
513
530
  );
514
531
 
515
532
  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
533
 
520
534
  url = url.concat(urlParams);
521
535
 
@@ -6,7 +6,6 @@ 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';
10
9
 
11
10
  import StreamZip from 'node-stream-zip';
12
11
 
@@ -19,7 +18,6 @@ import {
19
18
  getDirectoryFiles,
20
19
  addDebugLog,
21
20
  checkAccessTokenExpiration,
22
- checkLibraryAndArchives,
23
21
  getConfigDefaults,
24
22
  getLibraryBased,
25
23
  unZipFromArchive,
@@ -233,16 +231,193 @@ export const moveComp = async(componentKey, orgLibName, version, copyShared, opt
233
231
  fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
234
232
  }
235
233
 
234
+
236
235
  export const importArch = async(filePath, fileName, hadArchive) => {
236
+ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
237
+
238
+ const currentDirectory = process.cwd();
239
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
240
+
241
+
242
+ const zipFilePath = join(filePath, fileName);
243
+
244
+
245
+ // we are going to use node stream zip to list contents of archive first,
246
+ // before we un archive to a temp directory. If pass, then un archive
247
+ let passCount = 0;
248
+
249
+ // check to see if have a tasks.config.json and package,json file, if not, archive not good
250
+ const tempTasksConfig = join(tempDirectory, "tasks.config.json");
251
+ const tempPackage = join(tempDirectory, "package.json");
252
+ const tasksConfig = "tasks.config.json";
253
+ const packageJson = "package.json";
254
+ try {
255
+ const testZip = new StreamZip.async({ file: zipFilePath});
256
+ const entries = await testZip.entries();
257
+
258
+ for (const entry of Object.values(entries)) {
259
+ if ( entry.name.indexOf(packageJson) >= 0 || entry.name.indexOf(tasksConfig) >= 0) {
260
+ passCount++;
261
+ }
262
+ }
263
+
264
+ // Do not forget to close the file once you're done
265
+ await testZip.close();
266
+ }
267
+ catch (ex) {
268
+ passCount = 0;
269
+ }
270
+
271
+
272
+ if (passCount < 2) {
273
+ console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
274
+ process.exit(1);
275
+
276
+ }
277
+
278
+ await unZipFromArchive(zipFilePath);
279
+
280
+ // need to get info from tasks.config and package.json
281
+ // we won't rely on name of file, as owner can change it
282
+
283
+ let organization = await getPackgeOrg(tempPackage);
284
+ let localConfig = await getLocalConfigData(tempTasksConfig);
285
+
286
+ let libName = localConfig.library;
287
+ let orgLibName = `${organization}_${libName}`;
288
+ const version = localConfig.buildVersion;
289
+ const devBuild = localConfig.devBuild;
290
+
291
+ const configDef = getConfigDefaults();
292
+
293
+ if (organization !== configDef.organization) {
294
+ console.log(`\nImported ${chalk.yellow(`${orgLibName}/${version}`)} is not the same organization as your current organization: ${chalk.yellow(`${configDef.organization}`)}.`);
295
+ console.log(`\nTo import, the organization of the components will be changed to match your organization.`);
296
+ console.log(`\n\t>>> If you don't want this to happen, then end and create a new project with an organization`);
297
+ console.log(`\t of ${chalk.yellow(`${organization}`)} and import there.\n`);
298
+
299
+ const proceedAnswers = await inquirer.prompt([
300
+
301
+ {
302
+ name: 'okToContinue',
303
+ type: 'confirm',
304
+ message: `Ok to proceed ?`,
305
+ default: true
306
+ }
307
+ ]);
308
+
309
+ if (proceedAnswers.okToContinue) {
310
+ // check if new version matches existing
311
+ // -dev is already on version, if present, so "false", for devBuild here
312
+ const alreadyExists = await hasLibraryAndVersion(libName, version, false);
313
+ if (alreadyExists) {
314
+ console.log(`${chalk.yellow(`${configDef.organization}_${libName}/${version}`)} already exists.`);
315
+ const archDirectories = await getLibraryArchiveDirectories();
316
+ const newLibNameAnswers = await inquirer.prompt([
317
+ {
318
+ name: 'libraryName',
319
+ message: 'Enter new libray name',
320
+ validate: value => {
321
+ /* value should not be empty
322
+ It should not have spaces
323
+ It should not start with a number
324
+ Only case-insensitive alphanumeric values are allowed
325
+ */
326
+ if (value && !/^\d/.test(value) && value === sanitize(value)) {
327
+ if (archDirectories && archDirectories.length > 0) {
328
+ const newOrgLib = `${configDef.organization}_${value}`;
329
+ if (archDirectories.includes(newOrgLib)) {
330
+ return `Library ${value} already exists.`;
331
+ }
332
+ else {
333
+ return true;
334
+ }
335
+ }
336
+ else {
337
+ return true;
338
+ }
339
+
340
+ }
341
+ else {
342
+ return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
343
+ }
344
+ }
345
+ }
346
+ ]);
347
+
348
+ libName = newLibNameAnswers.libraryName;
349
+ }
350
+
351
+ // rename orgLibName
352
+ orgLibName = `${configDef.organization}_${libName}`;
353
+
354
+ // update temp with new info
355
+ await updateTempArchive(libName, version, devBuild);
356
+
357
+ }
358
+ else {
359
+ process.exit();
360
+ }
361
+
362
+
363
+ }
364
+
365
+ // rearchive temp directory
366
+ await zipVersionAndArchive(orgLibName, version, tempDirectory);
367
+
368
+ // delete temp directory
369
+ fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
370
+
371
+
372
+ if (hadArchive) {
373
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
374
+ console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.`);
375
+ console.log("");
376
+ }
377
+ else {
378
+ const switchToFileName = `${orgLibName}_${version}.arch.zip`;
379
+
380
+ const tasks = new Listr(
381
+ [
382
+ {
383
+ title: `Restoring ${orgLibName}/${version}`,
384
+ task: async () => {
385
+ await restoreFromArchive(switchToFileName, orgLibName, version);
386
+ }
387
+ }
388
+ ],
389
+ { concurrent: false, exitOnError: true }
390
+ );
391
+
392
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
393
+
394
+ await tasks.run().catch(err => {
395
+ console.log(chalk.bold.red(err.toString()));
396
+ process.exit(1);
397
+ });
398
+
399
+ console.log(`${chalk.bold.green(`\nSwitched to ${orgLibName}/${version}!\n`)}`);
400
+
401
+ await forceDefaultsUpdate();
402
+ await showCurrentStatus();
403
+
404
+ console.log('\n***************************************************************');
405
+ console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
406
+ console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
407
+ console.log('***************************************************************\n');
408
+ }
409
+
410
+
411
+ }
412
+
413
+ export const importArchServer = async(filePath, fileName, hadArchive) => {
237
414
  addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
238
415
 
239
416
  const currentDirectory = process.cwd();
240
417
  const tempDirectory = join(currentDirectory, TEMP_PATH);
241
418
 
242
-
243
419
  const zipFilePath = join(filePath, fileName);
244
420
 
245
-
246
421
  // we are going to use node stream zip to list contents of archive first,
247
422
  // before we un archive to a temp directory. If pass, then un archive
248
423
  let passCount = 0;
@@ -252,8 +427,9 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
252
427
  const tempPackage = join(tempDirectory, "package.json");
253
428
  const tasksConfig = "tasks.config.json";
254
429
  const packageJson = "package.json";
430
+ let testZip;
255
431
  try {
256
- const testZip = new StreamZip.async({ file: zipFilePath});
432
+ testZip = new StreamZip.async({ file: zipFilePath});
257
433
  const entries = await testZip.entries();
258
434
 
259
435
  for (const entry of Object.values(entries)) {
@@ -262,32 +438,34 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
262
438
  }
263
439
  }
264
440
 
265
- // Do not forget to close the file once you're done
266
- await testZip.close();
267
441
  }
268
442
  catch (ex) {
269
443
  passCount = 0;
270
444
  }
271
445
 
272
-
273
446
  if (passCount < 2) {
274
447
  console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
448
+ // Do not forget to close the file once you're done
449
+ await testZip.close();
450
+
275
451
  process.exit(1);
276
452
 
277
453
  }
278
454
 
279
- await unZipFromArchive(zipFilePath);
455
+ // make directory in temp dir, can NOT be the same directory as the zip file is in
456
+ const dirName = fileName.replaceAll(".zip", "");
457
+ const newDirPath = join(TEMP_PATH, dirName);
458
+ fs.mkdirSync(newDirPath);
280
459
 
460
+ const count = await testZip.extract(null, newDirPath);
281
461
 
462
+ // Do not forget to close the file once you're done
463
+ await testZip.close();
282
464
 
283
- // if (!fs.existsSync(tempTasksConfig) || !fs.existsSync(tempPackage)) {
284
- // console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
285
- // console.log(chalk.red.bold("Cleaning up..."));
286
- // fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
287
- // console.log(chalk.red.bold("Done."));
288
- // process.exit(1);
465
+ // we want file contents to be in the TEMP_PATH (copying, but temp directory eventually will be deleted)
466
+ fs.cpSync(newDirPath, TEMP_PATH, {recursive: true});
289
467
 
290
- // }
468
+ // await unZipFromArchive(zipFilePath);
291
469
 
292
470
  // need to get info from tasks.config and package.json
293
471
  // we won't rely on name of file, as owner can change it
@@ -383,7 +561,8 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
383
561
 
384
562
  if (hadArchive) {
385
563
  console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
386
- console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.\n`);
564
+ console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.`);
565
+ console.log("");
387
566
  }
388
567
  else {
389
568
  const switchToFileName = `${orgLibName}_${version}.arch.zip`;
@@ -451,19 +630,11 @@ export const writeZipBuffer = async(fileName, fileBuffer) => {
451
630
  const currentDirectory = process.cwd();
452
631
  const tempDirectory = join(currentDirectory, TEMP_PATH);
453
632
 
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
633
  if (!fs.existsSync (tempDirectory)) {
462
634
  fs.mkdirSync(tempDirectory);
463
635
  }
464
636
 
465
637
  const filePath = join(tempDirectory, fileName);
466
-
467
638
  fs.writeFileSync(filePath, fileBuffer, 'base64');
468
639
 
469
640
  }
@@ -539,18 +710,39 @@ export default async options => {
539
710
 
540
711
  const arArchData = archiveData.split(",");
541
712
  let fileName = `${arArchData[1]}.${arArchData[2]}`;
713
+ let fileData;
714
+
715
+ console.log("");
542
716
 
543
- // get archive
544
- const fileData = await getServerLibraryArchive(arArchData[0],arArchData[1], arArchData[2], arArchData[3], arArchData[4]);
545
- await writeZipBuffer(fileName, fileData.pyFileSource);
717
+ const tasks = new Listr(
718
+ [
719
+ {
720
+ title: 'Fetching archive from server',
721
+ task: async () => {
722
+ // get archive
723
+ fileData = await getServerLibraryArchive(arArchData[0],arArchData[1], arArchData[2], arArchData[3], arArchData[4]);
724
+ }
725
+ },
726
+ {
727
+ title: 'Saving archive in store',
728
+ task: async () => {
729
+ await writeZipBuffer(fileName, fileData.pyFileSource);
730
+
731
+ // import archive
732
+ const currentDirectory = process.cwd();
733
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
546
734
 
547
- // import archive
548
- const currentDirectory = process.cwd();
549
- const tempDirectory = join(currentDirectory, TEMP_PATH);
735
+ await importArchServer( tempDirectory, fileName, hasArch);
736
+ }
737
+ }
738
+ ],
739
+ { concurrent: false, exitOnError: true }
740
+ );
550
741
 
551
- await importArch( tempDirectory, fileName, hasArch);
552
- // const zipFilePath = join(tempDirectory, fileName);
553
- //await unZipFromArchive(zipFilePath);
742
+ await tasks.run().catch(err => {
743
+ console.log(chalk.bold.red(err.toString()));
744
+ process.exit(1);
745
+ });
554
746
 
555
747
  }
556
748
 
@@ -595,8 +787,28 @@ export default async options => {
595
787
  const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
596
788
  const {fileName} = fileNameAnswers;
597
789
 
790
+ console.log("");
791
+
792
+ const tasks = new Listr(
793
+ [
794
+ {
795
+ title: `Importing archive`,
796
+ task: async () => {
797
+ await importArch( filePath, fileName, hasArch);
798
+ }
799
+ }
800
+ ],
801
+ { concurrent: false, exitOnError: true }
802
+ );
803
+
804
+
805
+ await tasks.run().catch(err => {
806
+ console.log(chalk.bold.red(err.toString()));
807
+ process.exit(1);
808
+ });
809
+
810
+ console.log("");
598
811
 
599
- await importArch( filePath, fileName, hasArch);
600
812
 
601
813
  // reapply to save if changed, because imported task.config may have overriden and we want
602
814
  // to keep what was entered as the latest
@@ -1,5 +1,3 @@
1
- import chalk from 'chalk';
2
- import fs from 'fs';
3
1
  import path from 'path';
4
2
  import { join } from 'path';
5
3
  import { addDebugLog, getConfigDefaults, setConfigImportRelativePath, forceDefaultsUpdate } from '../../util.js';
@@ -107,7 +107,7 @@
107
107
  "@babel/preset-react": "^7.26.3",
108
108
  "@babel/preset-typescript": "^7.26.0",
109
109
  "@pega/configs": "^0.16.2",
110
- "@pega/custom-dx-components": "~0.25.22",
110
+ "@pega/custom-dx-components": "~0.25.23",
111
111
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
112
112
  "@storybook/addon-actions": "^7.6.19",
113
113
  "@storybook/addon-essentials": "^7.6.19",
@@ -38,6 +38,6 @@
38
38
  "icon": ""
39
39
  },
40
40
  "usePromotedWebPack": false,
41
- "libraryMode": false,
41
+ "libraryModeCL": false,
42
42
  "showDebug": false
43
43
  }
@@ -4,8 +4,23 @@ import chalk from 'chalk';
4
4
  import fetch from 'node-fetch';
5
5
  import { join } from 'path';
6
6
 
7
- import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
8
- import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent, addDebugLog, getLibraryBased, getComponentsConfigs, getConfigDefaults, checkAccessTokenExpiration } from '../../util.js';
7
+ import {
8
+ LIST_COMPONENT_SERVICE_REST_ENDPOINT,
9
+ LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT,
10
+ TOKEN_PATH, COMPONENT_SCHEMA,
11
+ TASKS_CONFIG_JSON_FILENAME,
12
+ COMPONENTS_DIRECTORY_PATH,
13
+ COMPONENTS_PATH } from '../../constants.js';
14
+ import {
15
+ constructCompleteUrl,
16
+ getComponents,
17
+ getPegaServerConfig,
18
+ getHttpsAgent,
19
+ addDebugLog,
20
+ getLibraryBased,
21
+ getComponentsConfigs,
22
+ getConfigDefaults,
23
+ checkAccessTokenExpiration } from '../../util.js';
9
24
 
10
25
  export const SOURCE_OF_COMPONENT_TYPES = {
11
26
  SERVER: 'Server',