@pega/custom-dx-components 0.25.22 → 0.25.24

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 (159) 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/create/index.js +5 -1
  6. package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +1 -0
  7. package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +1 -0
  8. package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +1 -0
  9. package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +1 -0
  10. package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +1 -0
  11. package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +1 -0
  12. package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/config.json.mustache +1 -0
  13. package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +1 -0
  14. package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +1 -0
  15. package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/config.json.mustache +1 -0
  16. package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/config.json.mustache +1 -0
  17. package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +1 -0
  18. package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +1 -0
  19. package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +1 -0
  20. package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +1 -0
  21. package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +1 -0
  22. package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +1 -0
  23. package/src/tasks/create/templates/Constellation/Field/TimeofDay/config.json.mustache +1 -0
  24. package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +1 -0
  25. package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +1 -0
  26. package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +1 -0
  27. package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +1 -0
  28. package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +1 -0
  29. package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +1 -0
  30. package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +1 -0
  31. package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +1 -0
  32. package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/config.json.mustache +1 -0
  33. package/src/tasks/create/templates/Launchpad/Widget/CASE/config.json.mustache +1 -0
  34. package/src/tasks/create/templates/Launchpad/Widget/PAGE/config.json.mustache +1 -0
  35. package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/config.json.mustache +1 -0
  36. package/src/tasks/create-all/index.js +5 -1
  37. package/src/tasks/delete/helper.js +0 -1
  38. package/src/tasks/delete/index.js +5 -1
  39. package/src/tasks/delete-lib/helper.js +0 -1
  40. package/src/tasks/delete-pub/helper.js +7 -2
  41. package/src/tasks/delete-version/index.js +0 -1
  42. package/src/tasks/export-archive/helper.js +7 -1
  43. package/src/tasks/export-archive/index.js +10 -34
  44. package/src/tasks/import-archive/helper.js +19 -5
  45. package/src/tasks/import-archive/index.js +247 -35
  46. package/src/tasks/import-comp/helper.js +0 -2
  47. package/src/tasks/init/template/package.json.mustache +1 -1
  48. package/src/tasks/init/template/tasks.config.json +1 -1
  49. package/src/tasks/list/helper.js +17 -2
  50. package/src/tasks/list-lib/index.js +10 -1
  51. package/src/tasks/list-pub/helper.js +2 -4
  52. package/src/tasks/list-pub/index.js +15 -2
  53. package/src/tasks/publish/helper.js +0 -1
  54. package/src/tasks/publish/index.js +13 -1
  55. package/src/tasks/publish-all/index.js +10 -1
  56. package/src/tasks/publish-archive/index.js +53 -83
  57. package/src/tasks/publish-lib/index.js +0 -23
  58. package/src/tasks/rename/index.js +9 -1
  59. package/src/tasks/restore/index.js +19 -13
  60. package/src/tasks/set-perm/index.js +0 -2
  61. package/src/tasks/show-help/index.js +1 -5
  62. package/src/tasks/show-status/index.js +19 -6
  63. package/src/tasks/store/index.js +39 -18
  64. package/src/tasks/switch-lib/helper.js +0 -1
  65. package/src/tasks/validator/index.js +10 -5
  66. package/src/util.js +21 -77
  67. package/tests/assets/library/components/create/Pega_DXIL_MyTestText/config.json +1 -0
  68. package/tests/assets/library/components/create/shared/create-nonce.ts +1 -0
  69. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyBoolean/config.json +1 -0
  70. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/config.json +1 -0
  71. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyCurrency/config.json +1 -0
  72. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDate/config.json +1 -0
  73. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDate/date.ts +0 -24
  74. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDateTime/config.json +1 -0
  75. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDecimal/config.json +1 -0
  76. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDetails/config.json +1 -0
  77. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyEmail/config.json +1 -0
  78. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyForm/config.json +1 -0
  79. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/config.json +1 -0
  80. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyInteger/config.json +1 -0
  81. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPage/config.json +1 -0
  82. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/config.json +1 -0
  83. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageWidget/config.json +1 -0
  84. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyParagraph/config.json +1 -0
  85. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPercentage/config.json +1 -0
  86. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPhone/config.json +1 -0
  87. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPicklist/config.json +1 -0
  88. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyRadiobuttons/config.json +1 -0
  89. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MySearchbox/config.json +1 -0
  90. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MySearchbox/repeat-utils.ts +0 -4
  91. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyText/config.json +1 -0
  92. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTextInput/config.json +1 -0
  93. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/config.json +1 -0
  94. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/config.json +1 -0
  95. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/config.json +1 -0
  96. package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyURL/config.json +1 -0
  97. package/tests/assets/library/components/createAll/Constellation/shared/create-nonce.ts +1 -0
  98. package/tests/assets/original/components/create/Pega_DXIL_MyTestText/config.json +1 -0
  99. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyBoolean/config.json +1 -0
  100. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/config.json +1 -0
  101. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyCurrency/config.json +1 -0
  102. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDate/config.json +1 -0
  103. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDateTime/config.json +1 -0
  104. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDecimal/config.json +1 -0
  105. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDetails/config.json +1 -0
  106. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyEmail/config.json +1 -0
  107. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyForm/config.json +1 -0
  108. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/config.json +1 -0
  109. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyInteger/config.json +1 -0
  110. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPage/config.json +1 -0
  111. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/config.json +1 -0
  112. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPageWidget/config.json +1 -0
  113. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyParagraph/config.json +1 -0
  114. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPercentage/config.json +1 -0
  115. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPhone/config.json +1 -0
  116. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPicklist/config.json +1 -0
  117. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyRadiobuttons/config.json +1 -0
  118. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MySearchbox/config.json +1 -0
  119. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyText/config.json +1 -0
  120. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTextInput/config.json +1 -0
  121. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/config.json +1 -0
  122. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/config.json +1 -0
  123. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/config.json +1 -0
  124. package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyURL/config.json +1 -0
  125. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyBoolean/config.json +1 -0
  126. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/config.json +1 -0
  127. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyCurrency/config.json +1 -0
  128. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDate/config.json +1 -0
  129. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDateTime/config.json +1 -0
  130. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDecimal/config.json +1 -0
  131. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDetails/config.json +1 -0
  132. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyEmail/config.json +1 -0
  133. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyForm/config.json +1 -0
  134. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/config.json +1 -0
  135. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyInteger/config.json +1 -0
  136. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPage/config.json +1 -0
  137. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/config.json +1 -0
  138. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/config.json +1 -0
  139. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyParagraph/config.json +1 -0
  140. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPercentage/config.json +1 -0
  141. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPhone/config.json +1 -0
  142. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPicklist/config.json +1 -0
  143. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyRadiobuttons/config.json +1 -0
  144. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MySearchbox/config.json +1 -0
  145. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyText/config.json +1 -0
  146. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTextInput/config.json +1 -0
  147. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/config.json +1 -0
  148. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/config.json +1 -0
  149. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/config.json +1 -0
  150. package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyURL/config.json +1 -0
  151. package/tests/functional/localCreateBuildAllDeleteAll.test.js +8 -8
  152. package/tests/functional/localCreateBuildDelete.test.js +8 -8
  153. package/tests/functional/localCreateListDelete.test.js +8 -8
  154. package/tests/functional/localCreatePublishAllDeleteAll.test.js +8 -8
  155. package/tests/functional/localCreatePublishDelete.test.js +8 -8
  156. package/tests/functional/localCreateRenameDelete.test.js +8 -8
  157. package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +1 -1
  158. package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +1 -1
  159. package/tests/functional/localLibCreateLibStoreRestoreDeleteLib.test.js +376 -0
@@ -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.24",
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',
@@ -1,7 +1,16 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
 
4
- import {showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives, getLibraryArchivesVersions, getConfigDefaults, getLocalArchivedLibrraryVersionData, getComponentsConfigs, cleanUpTemp } from '../../util.js';
4
+ import {
5
+ showVersion,
6
+ getLibraryBased,
7
+ addDebugLog,
8
+ checkLibraryAndArchives,
9
+ getLibraryArchivesVersions,
10
+ getConfigDefaults,
11
+ getLocalArchivedLibrraryVersionData,
12
+ getComponentsConfigs,
13
+ cleanUpTemp } from '../../util.js';
5
14
  import { getArchiveLibraryQuestions } from './helper.js';
6
15
 
7
16
  export default async (options) => {
@@ -1,9 +1,8 @@
1
1
 
2
2
  import fs from 'fs';
3
- import path from 'path';
4
3
  import chalk from 'chalk';
5
4
  import fetch from 'node-fetch';
6
- import { join } from 'path';
5
+
7
6
 
8
7
  import {
9
8
  getPegaServerConfig,
@@ -11,8 +10,7 @@ import {
11
10
  getC11NB2STokenAndStaticServer,
12
11
  getApplicationAndVersionFromToken,
13
12
  constructCompleteUrl,
14
- getHttpsAgent,
15
- getConfigDefaults
13
+ getHttpsAgent
16
14
  } from '../../util.js';
17
15
 
18
16
  import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
@@ -1,11 +1,24 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
 
4
- import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraries, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults, cleanUpTemp, getPegaServerConfig, getLibraryBasedCL, getApplicationAndVersionFromToken } from '../../util.js';
4
+ import {
5
+ showVersion,
6
+ getC11NB2STokenAndStaticServer,
7
+ getLocalLibraries,
8
+ getLocalLibraryVersions,
9
+ getLocalLibraryVersionData,
10
+ getLibraryBased,
11
+ addDebugLog,
12
+ checkLibraryAndArchives,
13
+ getConfigDefaults,
14
+ cleanUpTemp,
15
+ getPegaServerConfig,
16
+ getLibraryBasedCL,
17
+ getApplicationAndVersionFromToken } from '../../util.js';
5
18
 
6
19
  import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
7
20
 
8
- import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES, getServerLibraries, getInfinityLibraries, getServerLocalQuestion } from './helper.js';
21
+ import { SOURCE_OF_COMPONENT_TYPES, getServerLibraries, getInfinityLibraries, getServerLocalQuestion } from './helper.js';
9
22
 
10
23
 
11
24
 
@@ -17,7 +17,6 @@ import {
17
17
  import {
18
18
  PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
19
19
  LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
20
- PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT,
21
20
  TOKEN_PATH
22
21
  } from '../../constants.js';
23
22
 
@@ -6,7 +6,19 @@ 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, getPegaServerConfig, showVersion, getLibraryBased, addDebugLog, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives, getConfigDevBuild, checkAccessTokenExpiration, checkJWTExpiration, getConfigDefaults, getLibraryBasedCL } from '../../util.js';
9
+ import {
10
+ getComponentDirectoryPath,
11
+ getPegaServerConfig,
12
+ showVersion,
13
+ getLibraryBased,
14
+ addDebugLog,
15
+ updateServerConfigRuleSetAndVersion,
16
+ checkLibraryAndArchives,
17
+ getConfigDevBuild,
18
+ checkAccessTokenExpiration,
19
+ checkJWTExpiration,
20
+ getConfigDefaults,
21
+ getLibraryBasedCL } from '../../util.js';
10
22
 
11
23
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
12
24
  import { default as buildLibrary } from '../build-lib/index.js';
@@ -5,7 +5,16 @@ import chalk from 'chalk';
5
5
  import validate from '../validator/index.js';
6
6
  import bundleComponent from '../bundle/index.js';
7
7
  import { lintComponent } from '../linter/index.js';
8
- import { getComponents, getComponentDirectoryPath, checkAccessTokenExpiration, showVersion, getLibraryBased, addDebugLog, getPegaServerConfig, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives } from '../../util.js';
8
+ import {
9
+ getComponents,
10
+ getComponentDirectoryPath,
11
+ checkAccessTokenExpiration,
12
+ showVersion,
13
+ getLibraryBased,
14
+ addDebugLog,
15
+ getPegaServerConfig,
16
+ updateServerConfigRuleSetAndVersion,
17
+ checkLibraryAndArchives } from '../../util.js';
9
18
 
10
19
  import {
11
20
  getPublishComponentQuestions,