@pega/custom-dx-components 0.242.28 → 0.242.30

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 (39) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +30 -0
  3. package/src/constants.js +3 -2
  4. package/src/tasks/build-comp/helper.js +6 -4
  5. package/src/tasks/bundle/builder/index.js +8 -6
  6. package/src/tasks/create/index.js +4 -2
  7. package/src/tasks/create-all/index.js +5 -3
  8. package/src/tasks/create-lib/helper.js +1 -1
  9. package/src/tasks/create-lib/index.js +4 -6
  10. package/src/tasks/create-version/helper.js +2 -1
  11. package/src/tasks/create-version/index.js +10 -6
  12. package/src/tasks/delete/index.js +1 -1
  13. package/src/tasks/delete-all/index.js +1 -1
  14. package/src/tasks/delete-lib/index.js +55 -32
  15. package/src/tasks/delete-pub/index.js +3 -2
  16. package/src/tasks/delete-version/index.js +45 -0
  17. package/src/tasks/export-archive/helper.js +85 -0
  18. package/src/tasks/export-archive/index.js +224 -0
  19. package/src/tasks/import-archive/helper.js +51 -0
  20. package/src/tasks/import-archive/index.js +301 -0
  21. package/src/tasks/index.js +5 -0
  22. package/src/tasks/init/template/package.json.mustache +20 -12
  23. package/src/tasks/list/helper.js +2 -2
  24. package/src/tasks/list/index.js +1 -1
  25. package/src/tasks/list-lib/index.js +8 -10
  26. package/src/tasks/list-pub/index.js +3 -3
  27. package/src/tasks/move/helper.js +56 -0
  28. package/src/tasks/move/index.js +441 -0
  29. package/src/tasks/promote-webpack/index.js +2 -3
  30. package/src/tasks/publish/index.js +1 -2
  31. package/src/tasks/publish-all/index.js +2 -2
  32. package/src/tasks/publish-lib/index.js +8 -4
  33. package/src/tasks/rename-lib/index.js +2 -3
  34. package/src/tasks/revert-webpack/index.js +2 -3
  35. package/src/tasks/show-status/index.js +2 -3
  36. package/src/tasks/store/index.js +53 -0
  37. package/src/tasks/switch-lib/index.js +4 -4
  38. package/src/tasks/switch-version/index.js +10 -6
  39. package/src/util.js +229 -177
package/src/util.js CHANGED
@@ -32,12 +32,10 @@ import {
32
32
  SHARED_DIRECTORY,
33
33
  SHOW_DEBUG,
34
34
  COMPONENTS_PATH,
35
- ARCHIVES_PATH
35
+ ARCHIVES_PATH,
36
+ TEMP_PATH
36
37
  } from './constants.js';
37
- import { arch } from 'os';
38
- import lib from 'fs-extra';
39
- import { or } from 'ajv/dist/compile/codegen/index.js';
40
- import def from 'ajv/dist/vocabularies/applicator/additionalItems.js';
38
+
41
39
 
42
40
  const access = promisify(fs.access);
43
41
 
@@ -59,6 +57,11 @@ let defaultConfigs = {
59
57
  showDebug: false
60
58
  };
61
59
 
60
+ let pegaConfig = null;
61
+ let pegaData = null;
62
+ let sPegaData;
63
+ let sPegaServerConfig;
64
+
62
65
  export const addDebugLog = (sFunctionName, sLogData, sIncDec) => {
63
66
 
64
67
  let sLog;
@@ -124,9 +127,9 @@ export const setUpDefaults = async () => {
124
127
 
125
128
  if (data["showDebug"]) {
126
129
  retrievedConfigData.showDebug = data.showDebug;
130
+ showDebug = data.showDebug;
127
131
  }
128
132
 
129
- retrievedConfigData.showDebug = data["server-config"].devBuild;
130
133
  retrievedConfigData.serverType = data["server-config"].serverType;
131
134
 
132
135
  retrievedConfigData.buildVersion = retrievedConfigData.devBuild ? `${retrievedConfigData.version}-dev` : retrievedConfigData.version;
@@ -146,7 +149,7 @@ export const setUpDefaults = async () => {
146
149
  }
147
150
 
148
151
  // initialize
149
- await setUpDefaults();
152
+ // await setUpDefaults();
150
153
 
151
154
  export const checkPathAccess = async (path, options = {}, throwError = false) => {
152
155
 
@@ -157,18 +160,18 @@ export const checkPathAccess = async (path, options = {}, throwError = false) =>
157
160
  await access(path, fs.constants.R_OK);
158
161
  } catch (err) {
159
162
  if (throwError) {
160
- addDebugLog("checkPathAccess", "path: ".concat(path), "+");
161
- addDebugLog("checkPathAccess", "Error: ".concat(err), "");
162
- addDebugLog("checkPathAccess", "END", "-");
163
+ if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
164
+ if (showDebug) addDebugLog("checkPathAccess", "Error: ".concat(err), "");
165
+ if (showDebug) addDebugLog("checkPathAccess", "END", "-");
163
166
  throw new Error(err);
164
167
 
165
168
  }
166
169
  else {
167
- addDebugLog("checkPathAccess", "path: ".concat(path), "+");
170
+ if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
168
171
  const message =
169
172
  errorMessage || `${chalk.red.bold('ERROR')} Could not able to access path - ${path}`;
170
173
  console.error(message);
171
- addDebugLog("checkPathAccess", "END", "-");
174
+ if (showDebug) addDebugLog("checkPathAccess", "END", "-");
172
175
  process.exit(1);
173
176
  }
174
177
 
@@ -176,6 +179,7 @@ addDebugLog("checkPathAccess", "END", "-");
176
179
  };
177
180
 
178
181
  export const getUseWebPackPromotion = async () => {
182
+ if (showDebug) addDebugLog("getUseWebPackPromotion", "", "");
179
183
  const currentDirectory = process.cwd();
180
184
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
181
185
 
@@ -210,6 +214,8 @@ export const getUseWebPackPromotion = async () => {
210
214
  }
211
215
 
212
216
  export const updateUseWebPackPromotion = async ( useValue = false ) => {
217
+ if (showDebug) addDebugLog("updateUseWebPackPromotion", "", "");
218
+
213
219
  const currentDirectory = process.cwd();
214
220
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
215
221
 
@@ -232,7 +238,7 @@ export const updateUseWebPackPromotion = async ( useValue = false ) => {
232
238
  }
233
239
 
234
240
  export const getAboutData = async (currentOrgLib, buildVersion, dateStamp) => {
235
- addDebugLog("getAboutData", `currentOrgLib: ${currentOrgLib}, buildVersion: ${buildVersion}, dateStamp: ${dateStamp}`)
241
+ if (showDebug) addDebugLog("getAboutData", `currentOrgLib: ${currentOrgLib}, buildVersion: ${buildVersion}, dateStamp: ${dateStamp}`)
236
242
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
237
243
 
238
244
  if (tokenAndStaticServer.C11NB2S === undefined) {
@@ -265,7 +271,7 @@ export const checkJWTExpiration = async () => {
265
271
  }
266
272
 
267
273
  export const getLibraryBased = () => {
268
- // addDebugLog("getLibraryBased", "", "+");
274
+ if (showDebug) addDebugLog("getLibraryBased", "", "");
269
275
  // const currentDirectory = process.cwd();
270
276
  // const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
271
277
 
@@ -283,12 +289,12 @@ export const getLibraryBased = () => {
283
289
  // data = JSON.parse(data);
284
290
 
285
291
  // if (data[LIBRARY_BASED]) {
286
- // addDebugLog("getLibraryBased", `based: ${data[LIBRARY_BASED]}`, "");
287
- // addDebugLog("getLibraryBased", "END", "-");
292
+ // if (showDebug) addDebugLog("getLibraryBased", `based: ${data[LIBRARY_BASED]}`, "");
293
+ // if (showDebug) addDebugLog("getLibraryBased", "END", "-");
288
294
  // return data[LIBRARY_BASED];
289
295
  // }
290
296
  // else {
291
- // addDebugLog("getLibraryBased", "END", "-");
297
+ // if (showDebug) addDebugLog("getLibraryBased", "END", "-");
292
298
  // return false;
293
299
  // }
294
300
 
@@ -296,6 +302,7 @@ export const getLibraryBased = () => {
296
302
  }
297
303
 
298
304
  export const setLibraryBased = async (isLibraryBased) => {
305
+ if (showDebug) addDebugLog("setLibraryBased", "", "");
299
306
  const currentDirectory = process.cwd();
300
307
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
301
308
 
@@ -322,32 +329,34 @@ export const setLibraryBased = async (isLibraryBased) => {
322
329
 
323
330
  }
324
331
 
325
- export const getShowDebug = async () => {
326
- const currentDirectory = process.cwd();
327
- const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
332
+ export const getShowDebug = () => {
333
+ // const currentDirectory = process.cwd();
334
+ // const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
328
335
 
329
- try {
330
- // force to throw error and not console log
331
- await checkPathAccess(pegaConfigJsonPath, {}, true);
332
- }
333
- catch (ex) {
334
- // when can't find it, always be false, assume no library based.
335
- // This is IMPORTANT for init (npx install)
336
- return false;
337
- }
336
+ // try {
337
+ // // force to throw error and not console log
338
+ // await checkPathAccess(pegaConfigJsonPath, {}, true);
339
+ // }
340
+ // catch (ex) {
341
+ // // when can't find it, always be false, assume no library based.
342
+ // // This is IMPORTANT for init (npx install)
343
+ // return false;
344
+ // }
338
345
 
339
- let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
340
- data = JSON.parse(data);
346
+ // let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
347
+ // data = JSON.parse(data);
348
+
349
+ // if (data[SHOW_DEBUG]) {
350
+ // return data[SHOW_DEBUG];
351
+ // }
352
+ // else return false;
353
+ return defaultConfigs.showDebug;
341
354
 
342
- if (data[SHOW_DEBUG]) {
343
- return data[SHOW_DEBUG];
344
- }
345
- else return false;
346
355
  }
347
356
 
348
357
 
349
358
  export const deleteLocalComponent = async componentKey => {
350
- addDebugLog("deleteLocalComponent", `componentKey: ${componentKey}`, "");
359
+ if (showDebug) addDebugLog("deleteLocalComponent", `componentKey: ${componentKey}`, "");
351
360
  const currentDirectory = process.cwd();
352
361
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
353
362
 
@@ -383,7 +392,7 @@ export const getHttpsAgent = serverConfig => {
383
392
  };
384
393
 
385
394
  export const deleteServerComponent = async componentKey => {
386
- addDebugLog("deleteServerComponent", `componentKey: ${componentKey}`, "");
395
+ if (showDebug) addDebugLog("deleteServerComponent", `componentKey: ${componentKey}`, "");
387
396
  const serverConfig = await getPegaServerConfig();
388
397
  const { server, user, password } = serverConfig;
389
398
  const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
@@ -429,7 +438,7 @@ addDebugLog("deleteServerComponent", `componentKey: ${componentKey}`, "");
429
438
  };
430
439
 
431
440
  export const copyFileToShared = async ( fileName, fileContents) => {
432
- addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
441
+ if (showDebug) addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
433
442
  const currentDirectory = process.cwd();
434
443
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
435
444
 
@@ -462,8 +471,8 @@ addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
462
471
 
463
472
  };
464
473
 
465
- export const getComponents = async () => {
466
- addDebugLog("getComponents", "", "");
474
+ export const getComponents = async (overrideDirectory = null) => {
475
+ if (showDebug) addDebugLog("getComponents", "", "");
467
476
  const currentDirectory = process.cwd();
468
477
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
469
478
 
@@ -480,7 +489,8 @@ addDebugLog("getComponents", "", "");
480
489
  process.exit(1);
481
490
  }
482
491
 
483
- const directory = join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH]);
492
+ const directory = overrideDirectory || join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH]);
493
+
484
494
  return fs
485
495
  .readdirSync(directory, { withFileTypes: true })
486
496
  .filter(dirent => dirent.isDirectory() && dirent.name !== SHARED_DIRECTORY)
@@ -488,7 +498,7 @@ addDebugLog("getComponents", "", "");
488
498
  };
489
499
 
490
500
  export const getSubComponents = async (directory, type) => {
491
- addDebugLog("getDirectoryFiles", `directory: ${directory}, type: ${type}`, "");
501
+ if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}, type: ${type}`, "");
492
502
  const subDirectory = join(directory, type);
493
503
  return fs
494
504
  .readdirSync(subDirectory, { withFileTypes: true })
@@ -497,7 +507,7 @@ addDebugLog("getDirectoryFiles", `directory: ${directory}, type: ${type}`, "");
497
507
  };
498
508
 
499
509
  export const getDirectoryFiles = async directory => {
500
- addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
510
+ if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
501
511
  return fs
502
512
  .readdirSync(directory, { withFileTypes: true })
503
513
  .filter(dirent => !dirent.isDirectory())
@@ -505,7 +515,7 @@ addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
505
515
  };
506
516
 
507
517
  export const getComponentsObj = async () => {
508
- addDebugLog("getComponentsObj", "", "+");
518
+ if (showDebug) addDebugLog("getComponentsObj", "", "+");
509
519
  const compList = [];
510
520
 
511
521
  // const componentList = await getDirectoryFiles(directory);
@@ -518,44 +528,53 @@ addDebugLog("getComponentsObj", "", "+");
518
528
  container.name = name;
519
529
  container.value = name;
520
530
 
521
- addDebugLog("getComponentsObj", "container: " + JSON.stringify(container), "");
531
+ if (showDebug) addDebugLog("getComponentsObj", "container: " + JSON.stringify(container), "");
522
532
  return container;
523
533
  })
524
534
  );
525
535
  }
526
536
 
527
- addDebugLog("getComponentsObj", "END", "-");
537
+ if (showDebug) addDebugLog("getComponentsObj", "END", "-");
528
538
  return compList;
529
539
  };
530
540
 
531
541
  export const getPegaConfig = async () => {
532
- addDebugLog("getPegaConfig", "", "+");
533
- const currentDirectory = process.cwd();
534
- const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
542
+ if (showDebug) { addDebugLog("getPegaConfig", "", "+"); }
543
+ if (!pegaData) {
535
544
 
536
- await checkPathAccess(pegaConfigJsonPath);
545
+ if (showDebug) { addDebugLog("getPegaConfig", "retrieveData", ""); }
546
+ const currentDirectory = process.cwd();
547
+ const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
537
548
 
538
- let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
539
- data = JSON.parse(data);
549
+ await checkPathAccess(pegaConfigJsonPath);
540
550
 
541
- addDebugLog("getPegaConfig", "data: " + JSON.stringify(data), "");
542
- addDebugLog("getPegaConfig", "END", "-");
551
+ sPegaData = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
552
+ pegaData = JSON.parse(sPegaData);
553
+ }
543
554
 
544
- return data;
555
+
556
+ if (showDebug) { addDebugLog("getPegaConfig", "pegaData: " + sPegaData, ""); }
557
+ if (showDebug) { addDebugLog("getPegaConfig", "END", "-"); }
558
+
559
+ return pegaData;
545
560
  };
546
561
 
547
562
  export const getPegaServerConfig = async () => {
548
- addDebugLog("getPegaServerConfig", "", "+");
549
- const config = await getPegaConfig();
550
- addDebugLog("getPegaServerConfig", "server config:" + JSON.stringify(config['server-config']), "");
551
- addDebugLog("getPegaServerConfig", "END", "-");
552
- return config['server-config'];
563
+ if (showDebug) addDebugLog("getPegaServerConfig", "", "+");
564
+ if (!pegaConfig) {
565
+ pegaConfig = await getPegaConfig();
566
+ sPegaServerConfig = JSON.stringify(pegaConfig['server-config']);
567
+ }
568
+
569
+ if (showDebug) addDebugLog("getPegaServerConfig", "server config:" + sPegaServerConfig, "");
570
+ if (showDebug) addDebugLog("getPegaServerConfig", "END", "-");
571
+ return pegaConfig['server-config'];
553
572
  };
554
573
 
555
574
 
556
575
  // contains all the config, task config, etc. created upon start
557
576
  export const getConfigDefaults = () => {
558
- addDebugLog("getConfigDefaults", `defaults: ${JSON.stringify(defaultConfigs)}`, "");
577
+ if (showDebug) addDebugLog("getConfigDefaults", `defaults: ${JSON.stringify(defaultConfigs)}`, "");
559
578
 
560
579
  return defaultConfigs;
561
580
 
@@ -566,7 +585,7 @@ export const forceDefaultsUpdate = async () => {
566
585
  }
567
586
 
568
587
  export const updateServerConfigRuleSetAndVersion = async (rulesetName, rulesetVersion) => {
569
- addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
588
+ if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
570
589
  const currentDirectory = process.cwd();
571
590
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
572
591
  let configData = await getPegaConfig();
@@ -582,7 +601,7 @@ addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName: ${rulesetName},
582
601
  }
583
602
 
584
603
  export const updateComponentDefaultLibrary = async (library) => {
585
- addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
604
+ if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
586
605
  const currentDirectory = process.cwd();
587
606
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
588
607
 
@@ -598,7 +617,7 @@ addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
598
617
  }
599
618
 
600
619
  export const updateComponentDefaultVersion = async (version) => {
601
- addDebugLog("updateComponentDefaultVersion", `version: ${version}`, "");
620
+ if (showDebug) addDebugLog("updateComponentDefaultVersion", `version: ${version}`, "");
602
621
  const currentDirectory = process.cwd();
603
622
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
604
623
 
@@ -614,7 +633,7 @@ addDebugLog("updateComponentDefaultVersion", `version: ${version}`, "");
614
633
  }
615
634
 
616
635
  export const getConfigDevBuild = async() => {
617
- addDebugLog("getConfigDevBuild", "", "");
636
+ if (showDebug) addDebugLog("getConfigDevBuild", "", "");
618
637
  // const serverConfig = await getPegaServerConfig();
619
638
 
620
639
  // return serverConfig.devBuild;
@@ -623,7 +642,7 @@ addDebugLog("getConfigDevBuild", "", "");
623
642
  }
624
643
 
625
644
  export const setConfigDevBuild = async (devBuild) => {
626
- addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
645
+ if (showDebug) addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
627
646
  const currentDirectory = process.cwd();
628
647
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
629
648
  let configData = await getPegaConfig();
@@ -636,7 +655,7 @@ addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
636
655
  }
637
656
 
638
657
  export const updateDefaultOrganization = async (organization) => {
639
- addDebugLog("updateDefaultOrganization", `organization: ${organization}`, "");
658
+ if (showDebug) addDebugLog("updateDefaultOrganization", `organization: ${organization}`, "");
640
659
  let packageData = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf-8'));
641
660
 
642
661
  packageData.organization = organization;
@@ -646,85 +665,85 @@ addDebugLog("updateDefaultOrganization", `organization: ${organization}`, "");
646
665
  }
647
666
 
648
667
  export const updateConfigVersion = async (componentKey, buildVersion, currentOrgLib) => {
649
- addDebugLog("updateConfigVersion", `componentKey: ${componentKey}, buildVersion: ${buildVersion}, currentOrgLib: ${currentOrgLib}`, "");
650
- const componentDirectory = await getComponentDirectoryPath(componentKey);
651
- const configFileName = 'config.json';
668
+ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}, buildVersion: ${buildVersion}, currentOrgLib: ${currentOrgLib}`, "");
669
+ const componentDirectory = await getComponentDirectoryPath(componentKey);
670
+ const configFileName = 'config.json';
652
671
 
653
- const configFile = path.join(componentDirectory, configFileName);
654
- let configData;
655
- try {
656
- configData = fs.readFileSync(path.resolve(configFile), 'utf8');
657
- } catch (err) {
658
- // for now, if now file just end
659
- console.log(`${chalk.bold.yellow(`Config file not available for: ${componentKey}`)}`);
660
- return;
661
- }
662
- const currentDate = new Date(Date.now());
663
- const dateStamp = currentDate.toDateString();
664
- const aboutData = await getAboutData(currentOrgLib, buildVersion, dateStamp);
672
+ const configFile = path.join(componentDirectory, configFileName);
673
+ let configData;
674
+ try {
675
+ configData = fs.readFileSync(path.resolve(configFile), 'utf8');
676
+ } catch (err) {
677
+ // for now, if now file just end
678
+ console.log(`${chalk.bold.yellow(`Config file not available for: ${componentKey}`)}`);
679
+ return;
680
+ }
681
+ const currentDate = new Date(Date.now());
682
+ const dateStamp = currentDate.toDateString();
683
+ const aboutData = await getAboutData(currentOrgLib, buildVersion, dateStamp);
665
684
 
666
- let data;
667
- try {
668
- data = JSON.parse(configData);
669
-
670
- //find "About" and create or update
671
- const properties = data.properties;
672
- if (properties) {
673
- let foundProp = null;
674
-
675
- // check to see if PegaAboutData exists. If customer decides to put
676
- // data under PegaAboutData, we won't change the order
677
- // otherise, will put at bottom
678
- for (let i in properties) {
679
- if (properties[i].name && properties[i].name === "PegaAboutData") {
680
- foundProp = properties[i];
681
- break;
682
- }
685
+ let data;
686
+ try {
687
+ data = JSON.parse(configData);
688
+
689
+ //find "About" and create or update
690
+ const properties = data.properties;
691
+ if (properties) {
692
+ let foundProp = null;
693
+
694
+ // check to see if PegaAboutData exists. If customer decides to put
695
+ // data under PegaAboutData, we won't change the order
696
+ // otherise, will put at bottom
697
+ for (let i in properties) {
698
+ if (properties[i].name && properties[i].name === "PegaAboutData") {
699
+ foundProp = properties[i];
700
+ break;
683
701
  }
702
+ }
684
703
 
685
- if (foundProp) {
686
- foundProp.label = aboutData;
687
- }
688
- else {
689
- // don't have "About"
690
- const aboutLabelJSON = {
691
- "format": "LABEL",
692
- "label": "About",
693
- "name": "PegaAboutLabel",
694
- "variant": "h3"
695
- };
696
- const aboutDataJSON = {
697
- "format": "LABEL",
698
- "label": aboutData,
699
- "name": "PegaAboutData",
700
- "variant": "primary"
701
- }
702
- properties.push(aboutLabelJSON);
703
- properties.push(aboutDataJSON);
704
+ if (foundProp) {
705
+ foundProp.label = aboutData;
706
+ }
707
+ else {
708
+ // don't have "About"
709
+ const aboutLabelJSON = {
710
+ "format": "LABEL",
711
+ "label": "About",
712
+ "name": "PegaAboutLabel",
713
+ "variant": "h3"
714
+ };
715
+ const aboutDataJSON = {
716
+ "format": "LABEL",
717
+ "label": aboutData,
718
+ "name": "PegaAboutData",
719
+ "variant": "primary"
704
720
  }
721
+ properties.push(aboutLabelJSON);
722
+ properties.push(aboutDataJSON);
705
723
  }
706
- } catch (er) {
707
- throw new Error(`Invalid schema json in config.json: ${er}`);
708
724
  }
725
+ } catch (er) {
726
+ throw new Error(`Invalid schema json in config.json: ${er}`);
727
+ }
709
728
 
710
- data.version = buildVersion;
711
- data.buildDate = dateStamp;
729
+ data.version = buildVersion;
730
+ data.buildDate = dateStamp;
712
731
 
713
- // write back file
714
- fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8' });
715
- };
732
+ // write back file
733
+ fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8' });
734
+ };
716
735
 
717
736
  export const getServerType = () => {
718
- addDebugLog("getServerType", "", "+");
737
+ if (showDebug) addDebugLog("getServerType", "", "+");
719
738
  // const defaultPegaServerConfig = await getPegaServerConfig();
720
- // addDebugLog("getServerType", "serverType:" + defaultPegaServerConfig.serverType, "");
721
- addDebugLog("getServerType", "END", "-");
739
+ // if (showDebug) addDebugLog("getServerType", "serverType:" + defaultPegaServerConfig.serverType, "");
740
+ if (showDebug) addDebugLog("getServerType", "END", "-");
722
741
  // return defaultPegaServerConfig.serverType;
723
742
  return defaultConfigs.serverType;
724
743
  }
725
744
 
726
745
  export const setServerType = async(serverType) => {
727
- addDebugLog("setServerType", `serverType: ${serverType}`, "");
746
+ if (showDebug) addDebugLog("setServerType", `serverType: ${serverType}`, "");
728
747
  const currentDirectory = process.cwd();
729
748
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
730
749
  let configData = await getPegaConfig();
@@ -743,8 +762,8 @@ export const getSrcDirectoryPath = async () => {
743
762
  return join(currentDirectory, "src");
744
763
  }
745
764
 
746
- export const getComponentDirectoryPath = async componentKey => {
747
- addDebugLog("getComponentDirectoryPath", "", "+");
765
+ export const getComponentDirectoryPath = async (componentKey, overrideDir = null) => {
766
+ if (showDebug) addDebugLog("getComponentDirectoryPath", "", "+");
748
767
  const currentDirectory = process.cwd();
749
768
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
750
769
 
@@ -759,13 +778,13 @@ addDebugLog("getComponentDirectoryPath", "", "+");
759
778
  );
760
779
  process.exit(1);
761
780
  }
762
- addDebugLog("getComponentDirectoryPath", "path: " + join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey), "");
763
- addDebugLog("getComponentDirectoryPath", "END", "-");
764
- return join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
781
+ if (showDebug) addDebugLog("getComponentDirectoryPath", "path: " + join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey), "");
782
+ if (showDebug) addDebugLog("getComponentDirectoryPath", "END", "-");
783
+ return overrideDir ? join(overrideDir, componentKey) : join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
765
784
  };
766
785
 
767
786
  export const compileMustacheTemplate = (file, data) => {
768
- addDebugLog("compileMustacheTemplate", `file: ${file}`, "");
787
+ if (showDebug) addDebugLog("compileMustacheTemplate", `file: ${file}`, "");
769
788
  const content = fs.readFileSync(file, 'utf8');
770
789
  return mustache.render(content, data);
771
790
  };
@@ -779,7 +798,7 @@ export const convertIntoPascalCase = string => {
779
798
  };
780
799
 
781
800
  export const constructCompleteUrl = (baseServer, endPoint) => {
782
- addDebugLog("constructCompleteUrl", "url: " + baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`, "");
801
+ if (showDebug) addDebugLog("constructCompleteUrl", "url: " + baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`, "");
783
802
  return baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`;
784
803
  };
785
804
 
@@ -819,7 +838,12 @@ export const showVersion = async () => {
819
838
  const pData = require('@pega/custom-dx-components/package.json');
820
839
 
821
840
  console.log(chalk.green(`DX Component Builder v${pData.version}`));
822
- showDebug = await getShowDebug();
841
+ showDebug = getShowDebug();
842
+
843
+ if (getLibraryBased() && getServerType() === "launchpad") {
844
+ console.log(`\nLaunchpad commands only supported for ${chalk.bold.green('non library mode')} components.\n`);
845
+ process.exit();
846
+ }
823
847
 
824
848
  // do a check of node version, it should be 18 or greater
825
849
  const arNodeVersion = process.versions.node.split('.');
@@ -845,7 +869,7 @@ export const showVersion = async () => {
845
869
  };
846
870
 
847
871
  export const getOOTBComponents = async () => {
848
- addDebugLog("getOOTBComponents", "", "");
872
+ if (showDebug) addDebugLog("getOOTBComponents", "", "");
849
873
  return new Promise(resolve => {
850
874
  fs.readFile(OOTB_COMPONENTS, 'utf-8', async (error, ootbComponentsData) => {
851
875
  if (error) {
@@ -898,7 +922,7 @@ addDebugLog("getOOTBComponents", "", "");
898
922
  };
899
923
 
900
924
  export const deleteInfinityServerComponent = async componentKey => {
901
- addDebugLog("deleteInfinityServerComponent", `componentKey: ${componentKey}`, "");
925
+ if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${componentKey}`, "");
902
926
  const serverConfig = await getPegaServerConfig();
903
927
  const { server } = serverConfig;
904
928
  const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
@@ -977,7 +1001,7 @@ addDebugLog("deleteInfinityServerComponent", `componentKey: ${componentKey}`, ""
977
1001
  };
978
1002
 
979
1003
  export const deleteLaunchpadServerComponent = async componentKey => {
980
- addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "");
1004
+ if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "");
981
1005
  const { server, isolationId } = await getPegaServerConfig();
982
1006
  const deleteUrl = constructCompleteUrl(
983
1007
  server,
@@ -1065,7 +1089,7 @@ addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "
1065
1089
  };
1066
1090
 
1067
1091
  export const getBootstrapConfig = async (restServerUrl, authorizationHeader) => {
1068
- addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl}`, "");
1092
+ if (showDebug) addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl}`, "");
1069
1093
  const serverConfig = await getPegaServerConfig();
1070
1094
 
1071
1095
  return fetch(`${restServerUrl}/${BOOTSTRAP_CONFIG}`, {
@@ -1083,7 +1107,7 @@ addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl}`, "");
1083
1107
  };
1084
1108
 
1085
1109
  export const updateC11NB2SForInfinity = async () => {
1086
- addDebugLog("updateC11NB2SForInfinity", "", "");
1110
+ if (showDebug) addDebugLog("updateC11NB2SForInfinity", "", "");
1087
1111
  const serverConfig = await getPegaServerConfig();
1088
1112
  const { server } = serverConfig;
1089
1113
  const OAuthData = fs.readFileSync(TOKEN_PATH, 'utf8');
@@ -1114,7 +1138,7 @@ export const updateC11NB2SForLaunchpad = async () => {
1114
1138
  };
1115
1139
 
1116
1140
  export const getC11NB2STokenAndStaticServer = async () => {
1117
- addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1141
+ if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1118
1142
  const serverConfig = await getPegaServerConfig();
1119
1143
  const { server } = serverConfig;
1120
1144
  let OAuthData;
@@ -1137,7 +1161,7 @@ addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1137
1161
  };
1138
1162
 
1139
1163
  export const getLocalLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
1140
- addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
1164
+ if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
1141
1165
  const currentDirectory = process.cwd();
1142
1166
 
1143
1167
  const directory = join(currentDirectory, libraryName);
@@ -1148,7 +1172,7 @@ addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
1148
1172
  };
1149
1173
 
1150
1174
  export const getLocalArchivedLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
1151
- addDebugLog("getLocalArchivedLibraryVersions", `libraryName: ${libraryName}` , "");
1175
+ if (showDebug) addDebugLog("getLocalArchivedLibraryVersions", `libraryName: ${libraryName}` , "");
1152
1176
  const currentDirectory = process.cwd();
1153
1177
  const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${libraryName}`);
1154
1178
 
@@ -1170,7 +1194,7 @@ export const getLocalArchivedLibrraryVersionData = async(libraryName, libraryVer
1170
1194
  }
1171
1195
 
1172
1196
  export const getLocalLibraryVersionData = async (libraryName, libraryVersion) => {
1173
- addDebugLog("getLocalLibraryVersionDate", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1197
+ if (showDebug) addDebugLog("getLocalLibraryVersionDate", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1174
1198
  const currentDirectory = process.cwd();
1175
1199
  const libDir = join(currentDirectory, libraryName, libraryVersion);
1176
1200
  const libDataFile = join(libDir, COMPONENTS_CONFIG_FILE_NAME);
@@ -1181,7 +1205,7 @@ addDebugLog("getLocalLibraryVersionDate", `libraryName: ${libraryName}, libraryV
1181
1205
  };
1182
1206
 
1183
1207
  export const deleteLocalLibrary = async (libraryName) => {
1184
- addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}` , "");
1208
+ if (showDebug) addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}` , "");
1185
1209
  const currentDirectory = process.cwd();
1186
1210
 
1187
1211
  const directory = join(currentDirectory, libraryName);
@@ -1210,7 +1234,7 @@ addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}` , "");
1210
1234
  };
1211
1235
 
1212
1236
  export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) => {
1213
- addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1237
+ if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1214
1238
  const currentDirectory = process.cwd();
1215
1239
 
1216
1240
  const directory = join(currentDirectory, libraryName, libraryVersion);
@@ -1233,7 +1257,7 @@ addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}, libraryVers
1233
1257
  };
1234
1258
 
1235
1259
  export const deletePublishExtras = async (libraryName, libraryVersion) => {
1236
- addDebugLog("deletePublishExtras", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1260
+ if (showDebug) addDebugLog("deletePublishExtras", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1237
1261
  // this function will delete LibraryName.zip file, so new one created by publish
1238
1262
  // check if .DS_store file exists in Library, if so delete it because causes issue with services
1239
1263
 
@@ -1257,7 +1281,7 @@ addDebugLog("deletePublishExtras", `libraryName: ${libraryName}, libraryVersion:
1257
1281
 
1258
1282
 
1259
1283
  export const cleanUp = async () => {
1260
- addDebugLog("cleanUp", "", "");
1284
+ if (showDebug) addDebugLog("cleanUp", "", "");
1261
1285
  fs.rm('dist/components', { recursive: true }, err => {
1262
1286
  if (err) {
1263
1287
  throw err;
@@ -1271,15 +1295,16 @@ addDebugLog("cleanUp", "", "");
1271
1295
  });
1272
1296
  };
1273
1297
 
1274
- export const getComponentsConfigs = async () => {
1275
- addDebugLog("getComponentsConfigs", "", "");
1276
- const componentsList = await getComponents();
1298
+ export const getComponentsConfigs = async (compDir = null) => {
1299
+ if (showDebug) addDebugLog("getComponentsConfigs", "", "");
1300
+ const componentsList = await getComponents(compDir);
1301
+
1277
1302
  let componentsConfigJSON = [];
1278
1303
  if (componentsList && componentsList.length > 0) {
1279
1304
  // open each config.json and copy into componentsConfigJSON
1280
1305
  for (let i in componentsList) {
1281
1306
  const componentKey = componentsList[i];
1282
- const componentDirectory = await getComponentDirectoryPath(componentKey);
1307
+ const componentDirectory = await getComponentDirectoryPath(componentKey, compDir);
1283
1308
  const configPath = join(componentDirectory, 'config.json');
1284
1309
 
1285
1310
  let data = fs.readFileSync(configPath, { encoding: 'utf8' });
@@ -1293,9 +1318,9 @@ addDebugLog("getComponentsConfigs", "", "");
1293
1318
  }
1294
1319
 
1295
1320
 
1296
- export const createComponentsConfigFile = async (filePath) => {
1297
- addDebugLog("createComponentsConfigFile", `filePath: ${filePath}`, "");
1298
- const componentsConfigJSON = await getComponentsConfigs();
1321
+ export const createComponentsConfigFile = async (filePath, compDir) => {
1322
+ if (showDebug) addDebugLog("createComponentsConfigFile", `filePath: ${filePath}`, "");
1323
+ const componentsConfigJSON = await getComponentsConfigs(compDir);
1299
1324
  const compConfgFile = join(filePath, COMPONENTS_CONFIG_FILE_NAME);
1300
1325
 
1301
1326
  // write out file
@@ -1304,21 +1329,28 @@ addDebugLog("createComponentsConfigFile", `filePath: ${filePath}`, "");
1304
1329
  };
1305
1330
 
1306
1331
 
1307
- export const zipVersionAndArchive = async (orgLibName, version, copyExisting) => {
1308
- addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
1309
- const srcDirectoryPath = await getSrcDirectoryPath();
1310
- const currentDirectory = process.cwd();
1332
+ export const zipVersionAndArchive = async (orgLibName, version, currentDirectory = "") => {
1333
+ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
1334
+ // const srcDirectoryPath = await getSrcDirectoryPath();
1335
+ if (currentDirectory === "") {
1336
+ currentDirectory = process.cwd();
1337
+ }
1338
+ const srcDirectoryPath = join(currentDirectory, "src");
1311
1339
  const tasksConfig = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1312
1340
  const packageJson = join(currentDirectory, PACKAGE_JSON_FILENAME);
1313
1341
  const archiveFileName = `${orgLibName}_${version}.zip`;
1314
1342
 
1315
1343
 
1316
1344
  // const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
1317
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
1345
+ const mainDirectory = process.cwd();
1346
+ const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
1318
1347
  if (!fs.existsSync(archiveDirectory)) {
1319
1348
  fs.mkdirSync(archiveDirectory, { recursive: true });
1320
1349
  }
1321
1350
 
1351
+ // create componentsconfig.json
1352
+ await createComponentsConfigFile(archiveDirectory, join(srcDirectoryPath, "components"));
1353
+
1322
1354
  const archiveFile = join(archiveDirectory, archiveFileName);
1323
1355
  if (fs.existsSync(orgLibName)) {
1324
1356
 
@@ -1369,8 +1401,7 @@ addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${versi
1369
1401
 
1370
1402
  await archive.finalize();
1371
1403
 
1372
- // create componentsconfig.json
1373
- await createComponentsConfigFile(archiveDirectory);
1404
+
1374
1405
 
1375
1406
  // const zipBuffer = Buffer.concat(zipChunks);
1376
1407
  // console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
@@ -1381,13 +1412,13 @@ addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${versi
1381
1412
  };
1382
1413
 
1383
1414
  export const unZipFromArchive = async (fileName) => {
1384
- await unarchive(fileName, 'temp');
1415
+ await unarchive(fileName, TEMP_PATH);
1385
1416
  };
1386
1417
 
1387
1418
 
1388
1419
  export const restoreDependenciesFromPackage = async () => {
1389
1420
  const currentDirectory = process.cwd();
1390
- const tempDirectory = join(currentDirectory, "temp");
1421
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
1391
1422
  const tempPackagePath = join (tempDirectory, PACKAGE_JSON_FILENAME);
1392
1423
  const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
1393
1424
 
@@ -1401,7 +1432,7 @@ export const restoreDependenciesFromPackage = async () => {
1401
1432
  retrievedPackageData = fs.readFileSync(tempPackagePath);
1402
1433
  }
1403
1434
  catch (ex) {
1404
- console.log($chalk.red(`\nUnable to retrieve package.json from archive.`))
1435
+ console.log($chalk.red(`\nUnable to retrieve package.json from store.`))
1405
1436
  process.exit(1);
1406
1437
  }
1407
1438
 
@@ -1436,6 +1467,27 @@ export const restoreDependenciesFromPackage = async () => {
1436
1467
  cData.dependencies = JSON.parse(sDep);
1437
1468
  cData.devDependencies = JSON.parse(sDevDep);
1438
1469
 
1470
+ // we can't loose devDep that is part of install, so go get the template mustache and push
1471
+ // those in, replacing any changes there, but allowing additional, an keeping it updated
1472
+ // so won't loose new function if an old archive
1473
+ const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
1474
+ const templateDir = join(initDir, "template");
1475
+ const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
1476
+ let retrievedTemplateData;
1477
+ try {
1478
+ retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
1479
+ }
1480
+ catch (ex) {
1481
+ console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
1482
+ process.exit(1);
1483
+ }
1484
+ const tData = JSON.parse(retrievedTemplateData);
1485
+ const tDevDep = tData.devDependencies;
1486
+ for (const [key, value] of Object.entries(tDevDep)) {
1487
+ cData.devDependencies[key] = value;
1488
+ }
1489
+
1490
+
1439
1491
  // update current package json file
1440
1492
  fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8' });
1441
1493
 
@@ -1448,7 +1500,7 @@ export const getHaveDependencyDifference = () => {
1448
1500
 
1449
1501
  export const restoreFromArchive = async (fileName, orgLibName, version) => {
1450
1502
  const currentDirectory = process.cwd();
1451
- const tempDirectory = join(currentDirectory, "temp");
1503
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
1452
1504
  const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
1453
1505
  const archFileName = join(archiveDirectory, fileName);
1454
1506
 
@@ -1478,9 +1530,9 @@ export const restoreFromArchive = async (fileName, orgLibName, version) => {
1478
1530
  if (fs.existsSync(currentComponentsPath)) {
1479
1531
  // still an issue
1480
1532
  console.log(chalk.red('\nUnable to complete clear out src/components directory.\n'));
1481
- console.log(chalk.red('\nUnarchived components are in /temp directory.\n'));
1482
- console.log(chalk.red('\nYou can migrate /temp/components to src/components manually.\n'));
1483
- console.log(chalk.red('\nYou can replace /temp/tasks.config.json with tasks.config.json.\n'));
1533
+ console.log(chalk.red('\nUnstored components are in /temp directory.\n'));
1534
+ console.log(chalk.red('\nYou can migrate /store/temp/components to src/components manually.\n'));
1535
+ console.log(chalk.red('\nYou can replace /store/temp/tasks.config.json with tasks.config.json.\n'));
1484
1536
  process.exit();
1485
1537
  }
1486
1538
  }
@@ -1517,11 +1569,11 @@ export const getCurrentOrgLib = () =>{
1517
1569
  };
1518
1570
 
1519
1571
  export const hasArchives = async () => {
1520
- addDebugLog("hasArchives", "call", "");
1572
+ if (showDebug) addDebugLog("hasArchives", "call", "");
1521
1573
  const currentDirectory = process.cwd();
1522
1574
  const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
1523
1575
  const hasArc = fs.existsSync(archiveDirectory);
1524
- addDebugLog("hasArchives", `${hasArc}`, "");
1576
+ if (showDebug) addDebugLog("hasArchives", `${hasArc}`, "");
1525
1577
  return hasArc;
1526
1578
  };
1527
1579
 
@@ -1550,7 +1602,7 @@ export const checkLibraryAndArchives = async () => {
1550
1602
  };
1551
1603
 
1552
1604
  export const hasLibraryAndVersion = async (libraryName, version, devBuild) => {
1553
- addDebugLog("hasLibraryAndVersion", `libraryName: ${libraryName}, version: ${version}, devBuild: ${devBuild}`, "");
1605
+ if (showDebug) addDebugLog("hasLibraryAndVersion", `libraryName: ${libraryName}, version: ${version}, devBuild: ${devBuild}`, "");
1554
1606
  // const orgLib = getConfigDefaults();
1555
1607
  // const currentOrgLib = `${orgLib.organization}_${libraryName}`;
1556
1608
  // const libFiles = await getLibraryArchivesFiles(currentOrgLib);
@@ -1585,7 +1637,7 @@ addDebugLog("hasLibraryAndVersion", `libraryName: ${libraryName}, version: ${ver
1585
1637
  };
1586
1638
 
1587
1639
  export const getLibraryArchiveDirectories = async (currentOrgLib = "") => {
1588
- addDebugLog("getLibraryArchiveDirectories", "", "");
1640
+ if (showDebug) addDebugLog("getLibraryArchiveDirectories", "", "");
1589
1641
  const currentDirectory = process.cwd();
1590
1642
  const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
1591
1643
 
@@ -1600,7 +1652,7 @@ addDebugLog("getLibraryArchiveDirectories", "", "");
1600
1652
  };
1601
1653
 
1602
1654
  // export const getLibraryArchivesFiles = async (orgLibName, version) => {
1603
- // addDebugLog("getLibraryArchives", `orgLibName: ${orgLibName}`, "");
1655
+ // if (showDebug) addDebugLog("getLibraryArchives", `orgLibName: ${orgLibName}`, "");
1604
1656
  // const currentDirectory = process.cwd();
1605
1657
  // const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
1606
1658
 
@@ -1616,7 +1668,7 @@ addDebugLog("getLibraryArchiveDirectories", "", "");
1616
1668
  // };
1617
1669
 
1618
1670
  export const getLibraryArchivesVersions = async (orgLibName, currentVersion) => {
1619
- addDebugLog("getLibraryArchivesVersions", `orgLibName: ${orgLibName}`, "");
1671
+ if (showDebug) addDebugLog("getLibraryArchivesVersions", `orgLibName: ${orgLibName}`, "");
1620
1672
  // const archFileList = await getLibraryArchivesFiles(orgLibName, currentVersion);
1621
1673
  // let archiveVersionList = [];
1622
1674