@pega/custom-dx-components 0.25.44 → 0.25.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/util.js CHANGED
@@ -5,9 +5,9 @@ import { promisify } from 'util';
5
5
  import https from 'https';
6
6
  import crypto from 'node:crypto';
7
7
  import { createRequire } from 'module';
8
- import {jwtDecode} from 'jwt-decode';
8
+ import { jwtDecode } from 'jwt-decode';
9
9
  import archiver from 'archiver';
10
- import {unarchive} from 'unarchive';
10
+ import { unarchive } from 'unarchive';
11
11
  import ora from 'ora';
12
12
 
13
13
  import chalk from 'chalk';
@@ -83,32 +83,32 @@ let sPegaServerConfig;
83
83
  export const modAddAboutData = (addInAboutData) => {
84
84
  // used by jest to not put in to match assets without aboutData
85
85
  addAboutData = addInAboutData;
86
- }
86
+ };
87
87
 
88
88
  export const addDebugLog = (sFunctionName, sLogData, sIncDec) => {
89
89
 
90
90
  let sLog;
91
91
  if (showDebug) {
92
- if (sIncDec === "-") {
93
- debugLevel--;
94
- }
92
+ if (sIncDec === "-") {
93
+ debugLevel--;
94
+ }
95
95
 
96
- sLog = `>> log ${debugLevel} `;
96
+ sLog = `>> log ${debugLevel} `;
97
97
 
98
- for (let i =0; i < debugLevel; i++) {
99
- sLog = sLog.concat("-");
100
- }
98
+ for (let i = 0; i < debugLevel; i++) {
99
+ sLog = sLog.concat("-");
100
+ }
101
101
 
102
- sLog = sLog.concat(sFunctionName).concat(": ").concat(sLogData);
102
+ sLog = sLog.concat(sFunctionName).concat(": ").concat(sLogData);
103
103
 
104
- console.log(`${chalk.hex('#A0522D')(sLog)}`);
104
+ console.log(`${chalk.hex('#A0522D')(sLog)}`);
105
105
 
106
- if (sIncDec === "+") {
107
- debugLevel++;
108
- }
106
+ if (sIncDec === "+") {
107
+ debugLevel++;
108
+ }
109
109
 
110
110
  }
111
- }
111
+ };
112
112
 
113
113
  export const setUpDefaults = async () => {
114
114
 
@@ -183,11 +183,11 @@ export const setUpDefaults = async () => {
183
183
 
184
184
  retrievedConfigData.serverType = data["server-config"].serverType;
185
185
  retrievedConfigData.devBuild = data["server-config"].devBuild;
186
- retrievedConfigData.devServerPort = data["server-config"].devServerPort;
186
+ retrievedConfigData.devServerPort = data["server-config"].devServerPort;
187
187
 
188
188
  retrievedConfigData.buildVersion = retrievedConfigData.devBuild ? `${retrievedConfigData.version}-dev` : retrievedConfigData.version;
189
189
  retrievedConfigData.currentOrgLib = `${retrievedConfigData.organization}_${retrievedConfigData.library}`;
190
- retrievedConfigData.displayLibVersion = `${retrievedConfigData.currentOrgLib }/${retrievedConfigData.buildVersion}`;
190
+ retrievedConfigData.displayLibVersion = `${retrievedConfigData.currentOrgLib}/${retrievedConfigData.buildVersion}`;
191
191
 
192
192
  }
193
193
  catch (ex) {
@@ -197,7 +197,7 @@ export const setUpDefaults = async () => {
197
197
  }
198
198
 
199
199
  return JSON.parse(JSON.stringify(retrievedConfigData));
200
- }
200
+ };
201
201
 
202
202
  export const convertYNToBoolean = (inputYN) => {
203
203
  switch (inputYN) {
@@ -213,7 +213,7 @@ export const convertYNToBoolean = (inputYN) => {
213
213
  }
214
214
 
215
215
  return false;
216
- }
216
+ };
217
217
 
218
218
  export const getInputConfigForCommand = async (commandName) => {
219
219
  // retrievedConfigData
@@ -254,7 +254,7 @@ export const getInputConfigForCommand = async (commandName) => {
254
254
 
255
255
  return {};
256
256
 
257
- }
257
+ };
258
258
 
259
259
  // initialize
260
260
  // await setUpDefaults();
@@ -268,18 +268,18 @@ export const checkPathAccess = async (path, options = {}, throwError = false) =>
268
268
  await access(path, fs.constants.R_OK);
269
269
  } catch (err) {
270
270
  if (throwError) {
271
- if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
272
- if (showDebug) addDebugLog("checkPathAccess", "Error: ".concat(err), "");
273
- if (showDebug) addDebugLog("checkPathAccess", "END", "-");
271
+ if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
272
+ if (showDebug) addDebugLog("checkPathAccess", "Error: ".concat(err), "");
273
+ if (showDebug) addDebugLog("checkPathAccess", "END", "-");
274
274
  throw new Error(err);
275
275
 
276
276
  }
277
277
  else {
278
- if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
278
+ if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
279
279
  const message =
280
280
  errorMessage || `${chalk.red.bold('ERROR')} Could not able to access path - ${path}`;
281
281
  console.error(message);
282
- if (showDebug) addDebugLog("checkPathAccess", "END", "-");
282
+ if (showDebug) addDebugLog("checkPathAccess", "END", "-");
283
283
  process.exit(1);
284
284
  }
285
285
 
@@ -287,7 +287,7 @@ if (showDebug) addDebugLog("checkPathAccess", "END", "-");
287
287
  };
288
288
 
289
289
  export const getUseWebPackPromotion = async () => {
290
- if (showDebug) addDebugLog("getUseWebPackPromotion", "", "");
290
+ if (showDebug) addDebugLog("getUseWebPackPromotion", "", "");
291
291
  const currentDirectory = process.cwd();
292
292
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
293
293
 
@@ -319,10 +319,10 @@ if (showDebug) addDebugLog("getUseWebPackPromotion", "", "");
319
319
 
320
320
  return data[USE_PROMOTED_WEB_PACK];
321
321
 
322
- }
322
+ };
323
323
 
324
- export const updateUseWebPackPromotion = async ( useValue = false ) => {
325
- if (showDebug) addDebugLog("updateUseWebPackPromotion", "", "");
324
+ export const updateUseWebPackPromotion = async (useValue = false) => {
325
+ if (showDebug) addDebugLog("updateUseWebPackPromotion", "", "");
326
326
 
327
327
  const currentDirectory = process.cwd();
328
328
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
@@ -341,12 +341,12 @@ if (showDebug) addDebugLog("updateUseWebPackPromotion", "", "");
341
341
 
342
342
  data["usePromotedWebPack"] = useValue;
343
343
 
344
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
344
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8', flag: 'w' });
345
345
 
346
- }
346
+ };
347
347
 
348
348
  export const getAboutData = async (currentOrgLib, buildVersion, dateStamp) => {
349
- if (showDebug) addDebugLog("getAboutData", `currentOrgLib: ${currentOrgLib}, buildVersion: ${buildVersion}, dateStamp: ${dateStamp}`,"");
349
+ if (showDebug) addDebugLog("getAboutData", `currentOrgLib: ${currentOrgLib}, buildVersion: ${buildVersion}, dateStamp: ${dateStamp}`, "");
350
350
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
351
351
 
352
352
  if (tokenAndStaticServer.C11NB2S === undefined) {
@@ -355,16 +355,16 @@ if (showDebug) addDebugLog("getAboutData", `currentOrgLib: ${currentOrgLib}, bui
355
355
  }
356
356
 
357
357
  const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
358
- let infinityVersion= jwt.infinity_version;
358
+ let infinityVersion = jwt.infinity_version;
359
359
  infinityVersion = infinityVersion.replace("8.", "");
360
360
 
361
361
  return `${currentOrgLib} ${buildVersion}, ${dateStamp}, ${infinityVersion}`;
362
- }
362
+ };
363
363
 
364
364
  export const applyPegaData = async (configJson) => {
365
- if (showDebug) addDebugLog("applyPegaData", "", "");
365
+ if (showDebug) addDebugLog("applyPegaData", "", "");
366
366
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
367
- const currentDirectory = process.cwd()
367
+ const currentDirectory = process.cwd();
368
368
  // const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
369
369
  const currentPackageLockPath = join(currentDirectory, PACKAGE_LOCK_JSON_FILENAME);
370
370
  // let currentPackageData;
@@ -391,7 +391,7 @@ if (showDebug) addDebugLog("applyPegaData", "", "");
391
391
  }
392
392
  else {
393
393
  const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
394
- infinityVersion= jwt.infinity_version;
394
+ infinityVersion = jwt.infinity_version;
395
395
  // don't remove "8." from infinity version so can do a comparison
396
396
  }
397
397
 
@@ -400,7 +400,7 @@ if (showDebug) addDebugLog("applyPegaData", "", "");
400
400
  configJson.packageCosmosVersion = cosmosVersion;
401
401
 
402
402
 
403
- }
403
+ };
404
404
 
405
405
  export const checkJWTExpiration = async () => {
406
406
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
@@ -413,7 +413,7 @@ export const checkJWTExpiration = async () => {
413
413
  }
414
414
 
415
415
  const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
416
- const { exp, customer_org } = jwt;
416
+ const { exp, customer_org } = jwt;
417
417
  if (exp < (new Date().getTime() + 1) / 1000) {
418
418
  console.log(chalk.redBright("JWT token has expired, please reauthenticate."));
419
419
  process.exit(1);
@@ -432,9 +432,9 @@ export const checkJWTExpiration = async () => {
432
432
  }
433
433
 
434
434
 
435
- }
435
+ };
436
436
 
437
- export const checkAccessTokenExpiration = async() => {
437
+ export const checkAccessTokenExpiration = async () => {
438
438
 
439
439
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
440
440
 
@@ -444,16 +444,16 @@ export const checkAccessTokenExpiration = async() => {
444
444
  }
445
445
 
446
446
  const jwt = jwtDecode(tokenAndStaticServer.access_token);
447
- const { exp, customer_org } = jwt;
447
+ const { exp, customer_org } = jwt;
448
448
  if (exp < (new Date().getTime() + 1) / 1000) {
449
449
  console.log(chalk.redBright("Authentication token has expired, please reauthenticate."));
450
450
  process.exit(1);
451
451
  }
452
452
 
453
453
 
454
- }
454
+ };
455
455
 
456
- export const getApplicationAndVersionFromToken = async() => {
456
+ export const getApplicationAndVersionFromToken = async () => {
457
457
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
458
458
 
459
459
  if (tokenAndStaticServer.access_token === undefined) {
@@ -465,27 +465,27 @@ export const getApplicationAndVersionFromToken = async() => {
465
465
  const { app_name, app_version } = jwt;
466
466
  return { app_name, app_version };
467
467
 
468
- }
468
+ };
469
469
 
470
470
  export const getLibraryBased = () => {
471
- if (showDebug) addDebugLog("getLibraryBased", "", "");
471
+ if (showDebug) addDebugLog("getLibraryBased", "", "");
472
472
  return defaultConfigs.isLibraryBased;
473
- }
473
+ };
474
474
 
475
475
  export const getLibraryBasedCL = () => {
476
- if (showDebug) addDebugLog("getLibraryBasedCL", "", "");
476
+ if (showDebug) addDebugLog("getLibraryBasedCL", "", "");
477
477
  return defaultConfigs.isLibraryBasedCL;
478
- }
478
+ };
479
479
 
480
480
  export const getUseInputConfig = () => {
481
- if (showDebug) addDebugLog("getUseInputConfig", "", "");
481
+ if (showDebug) addDebugLog("getUseInputConfig", "", "");
482
482
 
483
483
 
484
484
  return defaultConfigs.useInputConfig;
485
- }
485
+ };
486
486
 
487
487
  export const setLibraryBased = async (isLibraryBased) => {
488
- if (showDebug) addDebugLog("setLibraryBased", "", "");
488
+ if (showDebug) addDebugLog("setLibraryBased", "", "");
489
489
  const currentDirectory = process.cwd();
490
490
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
491
491
 
@@ -508,7 +508,7 @@ if (showDebug) addDebugLog("setLibraryBased", "", "");
508
508
  // update file
509
509
  // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
510
510
  try {
511
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
511
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8', flag: 'w' });
512
512
  }
513
513
  catch (err) {
514
514
  console.error(err);
@@ -522,66 +522,66 @@ if (showDebug) addDebugLog("setLibraryBased", "", "");
522
522
 
523
523
  }
524
524
 
525
- }
525
+ };
526
526
 
527
527
  export const setLibraryBasedCL = async (isLibraryBasedCL) => {
528
528
  if (showDebug) addDebugLog("setLibraryBased", "", "");
529
- const currentDirectory = process.cwd();
530
- const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
531
-
532
- try {
533
- // force to throw error and not console log
534
- await checkPathAccess(pegaConfigJsonPath, {}, true);
535
- }
536
- catch (ex) {
537
- // when can't find it, always be false, assume no library based.
538
- // This is IMPORTANT for init (npx install)
539
- return false;
540
- }
529
+ const currentDirectory = process.cwd();
530
+ const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
541
531
 
542
- let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
543
- data = JSON.parse(data);
532
+ try {
533
+ // force to throw error and not console log
534
+ await checkPathAccess(pegaConfigJsonPath, {}, true);
535
+ }
536
+ catch (ex) {
537
+ // when can't find it, always be false, assume no library based.
538
+ // This is IMPORTANT for init (npx install)
539
+ return false;
540
+ }
544
541
 
545
- if (data[LIBRARY_BASED_CL] != undefined) {
546
- data[LIBRARY_BASED_CL] = isLibraryBasedCL;
542
+ let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
543
+ data = JSON.parse(data);
547
544
 
548
- // if not undefined, force this as well
549
- if (data[LIBRARY_BASED] != undefined) {
550
- data[LIBRARY_BASED] = isLibraryBasedCL;
551
- }
545
+ if (data[LIBRARY_BASED_CL] != undefined) {
546
+ data[LIBRARY_BASED_CL] = isLibraryBasedCL;
552
547
 
553
- // update file
554
- // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
555
- try {
556
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
557
- }
558
- catch (err) {
559
- console.error(err);
560
- }
561
- //await forceDefaultsUpdate();
562
- defaultConfigs.isLibraryBasedCL = isLibraryBasedCL;
548
+ // if not undefined, force this as well
549
+ if (data[LIBRARY_BASED] != undefined) {
550
+ data[LIBRARY_BASED] = isLibraryBasedCL;
551
+ }
563
552
 
564
- // force libraryBased if isLibraryBasedCL is true
565
- defaultConfigs.isLibraryBased = isLibraryBasedCL;
553
+ // update file
554
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
555
+ try {
556
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8', flag: 'w' });
557
+ }
558
+ catch (err) {
559
+ console.error(err);
560
+ }
561
+ //await forceDefaultsUpdate();
562
+ defaultConfigs.isLibraryBasedCL = isLibraryBasedCL;
566
563
 
564
+ // force libraryBased if isLibraryBasedCL is true
565
+ defaultConfigs.isLibraryBased = isLibraryBasedCL;
567
566
 
568
- // reset
569
- pegaData = null;
570
- pegaConfig = null;
571
567
 
572
- }
568
+ // reset
569
+ pegaData = null;
570
+ pegaConfig = null;
573
571
 
574
572
  }
575
573
 
574
+ };
575
+
576
576
  export const getShowDebug = () => {
577
577
 
578
578
  return defaultConfigs.showDebug;
579
579
 
580
- }
580
+ };
581
581
 
582
582
 
583
583
  export const deleteLocalComponent = async componentKey => {
584
- if (showDebug) addDebugLog("deleteLocalComponent", `componentKey: ${componentKey}`, "");
584
+ if (showDebug) addDebugLog("deleteLocalComponent", `componentKey: ${componentKey}`, "");
585
585
  const currentDirectory = process.cwd();
586
586
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
587
587
 
@@ -617,7 +617,7 @@ export const getHttpsAgent = serverConfig => {
617
617
  };
618
618
 
619
619
  export const deleteServerComponent = async componentKey => {
620
- if (showDebug) addDebugLog("deleteServerComponent", `componentKey: ${componentKey}`, "");
620
+ if (showDebug) addDebugLog("deleteServerComponent", `componentKey: ${componentKey}`, "");
621
621
  const serverConfig = await getPegaServerConfig();
622
622
  const { server, user, password } = serverConfig;
623
623
  const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
@@ -662,8 +662,8 @@ if (showDebug) addDebugLog("deleteServerComponent", `componentKey: ${componentKe
662
662
  }
663
663
  };
664
664
 
665
- export const copyFileToShared = async ( fileName, fileContents) => {
666
- if (showDebug) addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
665
+ export const copyFileToShared = async (fileName, fileContents) => {
666
+ if (showDebug) addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
667
667
  const currentDirectory = process.cwd();
668
668
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
669
669
 
@@ -697,7 +697,7 @@ if (showDebug) addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
697
697
  };
698
698
 
699
699
  export const getComponents = async (overrideDirectory = null) => {
700
- if (showDebug) addDebugLog("getComponents", "", "");
700
+ if (showDebug) addDebugLog("getComponents", "", "");
701
701
  const currentDirectory = process.cwd();
702
702
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
703
703
 
@@ -723,39 +723,39 @@ if (showDebug) addDebugLog("getComponents", "", "");
723
723
  };
724
724
 
725
725
  export const getTopLevelConfigFiles = async (directory) => {
726
- if (showDebug) addDebugLog("getTopLevelConfigFiles", `directory: ${directory}`, "");
726
+ if (showDebug) addDebugLog("getTopLevelConfigFiles", `directory: ${directory}`, "");
727
727
  if (fs.existsSync(directory)) {
728
728
  return fs
729
- .readdirSync(directory, { withFileTypes: true })
730
- .filter(dirent => !dirent.isDirectory())
731
- .map(dirent => dirent.name);
729
+ .readdirSync(directory, { withFileTypes: true })
730
+ .filter(dirent => !dirent.isDirectory())
731
+ .map(dirent => dirent.name);
732
732
  }
733
733
  else {
734
734
  return [];
735
735
  }
736
- }
736
+ };
737
737
 
738
738
  export const removeTopLevelConfigFiles = async (directory) => {
739
- if (showDebug) addDebugLog("removeTopLevelConfigFiles", `directory: ${directory}`, "");
739
+ if (showDebug) addDebugLog("removeTopLevelConfigFiles", `directory: ${directory}`, "");
740
740
  const configFiles = await getTopLevelConfigFiles(directory);
741
741
 
742
742
  if (configFiles && configFiles.length > 0) {
743
743
  for (const configF of configFiles) {
744
744
  // don't remove these files, otherwise, remove it
745
745
  if (configF !== "package-lock.json" &&
746
- configF !== "package.json" &&
747
- configF !== "tasks.config.json" &&
748
- configF !== ".gitignore" &&
749
- configF !== ".npmrc" &&
750
- configF !== ".prettierignore") {
751
- fs.rmSync( join(directory, configF), { recursive: true, force: true, maxRetries: 2 });
746
+ configF !== "package.json" &&
747
+ configF !== "tasks.config.json" &&
748
+ configF !== ".gitignore" &&
749
+ configF !== ".npmrc" &&
750
+ configF !== ".prettierignore") {
751
+ fs.rmSync(join(directory, configF), { recursive: true, force: true, maxRetries: 2 });
752
752
  }
753
753
  }
754
754
  }
755
- }
755
+ };
756
756
 
757
- export const restoreTopLevelConfigFiles = async(directory) => {
758
- if (showDebug) addDebugLog("restoreTopLevelConfigFiles", `directory: ${directory}`, "");
757
+ export const restoreTopLevelConfigFiles = async (directory) => {
758
+ if (showDebug) addDebugLog("restoreTopLevelConfigFiles", `directory: ${directory}`, "");
759
759
  const currentDirectory = process.cwd();
760
760
  const tempDirectory = join(currentDirectory, TEMP_PATH);
761
761
  const configFiles = await getTopLevelConfigFiles(tempDirectory);
@@ -772,28 +772,28 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFiles", `directory: ${directory
772
772
  }
773
773
  }
774
774
  }
775
- }
775
+ };
776
776
 
777
777
  export const getTemplateConfigFiles = async () => {
778
- if (showDebug) addDebugLog("getTemplateConfigFiles", ``, "");
778
+ if (showDebug) addDebugLog("getTemplateConfigFiles", ``, "");
779
779
  const currentDirectory = process.cwd();
780
780
  const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
781
781
  const templateDir = join(initDir, "template");
782
782
 
783
783
  if (fs.existsSync(templateDir)) {
784
784
  return fs
785
- .readdirSync(templateDir, { withFileTypes: true })
786
- .filter(dirent => !dirent.isDirectory())
787
- .map(dirent => dirent.name);
785
+ .readdirSync(templateDir, { withFileTypes: true })
786
+ .filter(dirent => !dirent.isDirectory())
787
+ .map(dirent => dirent.name);
788
788
  }
789
789
  else {
790
790
  return [];
791
791
  }
792
792
 
793
- }
793
+ };
794
794
 
795
- export const restoreTopLevelConfigFilesFromTemplate = async(clearDep = true) => {
796
- if (showDebug) addDebugLog("restoreTopLevelConfigFilesFromTemplate", ``, "");
795
+ export const restoreTopLevelConfigFilesFromTemplate = async (clearDep = true) => {
796
+ if (showDebug) addDebugLog("restoreTopLevelConfigFilesFromTemplate", ``, "");
797
797
  // we can't loose devDep that is part of install, so go get the template mustache and push
798
798
  // those in, replacing any changes there, but allowing additional, an keeping it updated
799
799
  // so won't loose new function if an old archive
@@ -812,7 +812,7 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFilesFromTemplate", ``, "");
812
812
  currentPackageData = fs.readFileSync(currentPackagePath);
813
813
  }
814
814
  catch (ex) {
815
- console.log($chalk.red(`\nUnable to retrieve current package.json.`))
815
+ console.log($chalk.red(`\nUnable to retrieve current package.json.`));
816
816
  process.exit(1);
817
817
  }
818
818
  let cData = JSON.parse(currentPackageData);
@@ -822,7 +822,7 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFilesFromTemplate", ``, "");
822
822
  retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
823
823
  }
824
824
  catch (ex) {
825
- console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
825
+ console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`));
826
826
  process.exit(1);
827
827
  }
828
828
 
@@ -865,7 +865,7 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFilesFromTemplate", ``, "");
865
865
  }
866
866
 
867
867
  // update current package json file
868
- fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',flag:'w' });
868
+ fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8', flag: 'w' });
869
869
 
870
870
  // restore from template
871
871
  const templateFiles = await getTemplateConfigFiles();
@@ -877,10 +877,10 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFilesFromTemplate", ``, "");
877
877
  }
878
878
  }
879
879
 
880
- }
880
+ };
881
881
 
882
882
  export const getSubComponents = async (directory, type) => {
883
- if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}, type: ${type}`, "");
883
+ if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}, type: ${type}`, "");
884
884
  const subDirectory = join(directory, type);
885
885
  return fs
886
886
  .readdirSync(subDirectory, { withFileTypes: true })
@@ -889,7 +889,7 @@ if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}, type:
889
889
  };
890
890
 
891
891
  export const getDirectoryFiles = async directory => {
892
- if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
892
+ if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
893
893
  return fs
894
894
  .readdirSync(directory, { withFileTypes: true })
895
895
  .filter(dirent => !dirent.isDirectory())
@@ -897,7 +897,7 @@ if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
897
897
  };
898
898
 
899
899
  export const getComponentsObj = async () => {
900
- if (showDebug) addDebugLog("getComponentsObj", "", "+");
900
+ if (showDebug) addDebugLog("getComponentsObj", "", "+");
901
901
  const compList = [];
902
902
 
903
903
  // const componentList = await getDirectoryFiles(directory);
@@ -910,21 +910,21 @@ if (showDebug) addDebugLog("getComponentsObj", "", "+");
910
910
  container.name = name;
911
911
  container.value = name;
912
912
 
913
- if (showDebug) addDebugLog("getComponentsObj", "container: " + JSON.stringify(container), "");
913
+ if (showDebug) addDebugLog("getComponentsObj", "container: " + JSON.stringify(container), "");
914
914
  return container;
915
915
  })
916
916
  );
917
917
  }
918
918
 
919
- if (showDebug) addDebugLog("getComponentsObj", "END", "-");
919
+ if (showDebug) addDebugLog("getComponentsObj", "END", "-");
920
920
  return compList;
921
921
  };
922
922
 
923
923
  export const getPegaConfig = async (force = false) => {
924
- if (showDebug) { addDebugLog("getPegaConfig", "", "+"); }
924
+ if (showDebug) { addDebugLog("getPegaConfig", "", "+"); }
925
925
  if (!pegaData || force) {
926
926
 
927
- if (showDebug) { addDebugLog("getPegaConfig", "retrieveData", ""); }
927
+ if (showDebug) { addDebugLog("getPegaConfig", "retrieveData", ""); }
928
928
  const currentDirectory = process.cwd();
929
929
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
930
930
 
@@ -935,14 +935,14 @@ if (showDebug) { addDebugLog("getPegaConfig", "retrieveData", ""); }
935
935
  }
936
936
 
937
937
 
938
- if (showDebug) { addDebugLog("getPegaConfig", "pegaData: " + sPegaData, ""); }
939
- if (showDebug) { addDebugLog("getPegaConfig", "END", "-"); }
938
+ if (showDebug) { addDebugLog("getPegaConfig", "pegaData: " + sPegaData, ""); }
939
+ if (showDebug) { addDebugLog("getPegaConfig", "END", "-"); }
940
940
 
941
941
  return pegaData;
942
942
  };
943
943
 
944
944
  export const getPegaServerConfig = async (force = false) => {
945
- if (showDebug) addDebugLog("getPegaServerConfig", "", "+");
945
+ if (showDebug) addDebugLog("getPegaServerConfig", "", "+");
946
946
  if (!pegaConfig || force) {
947
947
  pegaConfig = await getPegaConfig();
948
948
 
@@ -971,26 +971,26 @@ if (showDebug) addDebugLog("getPegaServerConfig", "", "+");
971
971
  sPegaServerConfig = JSON.stringify(pegaConfig['server-config']);
972
972
  }
973
973
 
974
- if (showDebug) addDebugLog("getPegaServerConfig", "server config:" + sPegaServerConfig, "");
975
- if (showDebug) addDebugLog("getPegaServerConfig", "END", "-");
974
+ if (showDebug) addDebugLog("getPegaServerConfig", "server config:" + sPegaServerConfig, "");
975
+ if (showDebug) addDebugLog("getPegaServerConfig", "END", "-");
976
976
  return pegaConfig['server-config'];
977
977
  };
978
978
 
979
979
 
980
980
  // contains all the config, task config, etc. created upon start
981
981
  export const getConfigDefaults = () => {
982
- if (showDebug) addDebugLog("getConfigDefaults", `defaults: ${JSON.stringify(defaultConfigs)}`, "");
982
+ if (showDebug) addDebugLog("getConfigDefaults", `defaults: ${JSON.stringify(defaultConfigs)}`, "");
983
983
 
984
984
  return defaultConfigs;
985
985
 
986
- }
986
+ };
987
987
 
988
988
  export const forceDefaultsUpdate = async () => {
989
989
  defaultConfigs = await setUpDefaults();
990
- }
990
+ };
991
991
 
992
992
  export const updateServerConfigRuleSetAndVersion = async (rulesetName, rulesetVersion) => {
993
- if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
993
+ if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
994
994
  const currentDirectory = process.cwd();
995
995
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
996
996
  let configData = await getPegaConfig(true);
@@ -1001,12 +1001,12 @@ if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName:
1001
1001
 
1002
1002
  // update file
1003
1003
  // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
1004
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
1004
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8', flag: 'w' });
1005
1005
 
1006
- }
1006
+ };
1007
1007
 
1008
1008
  export const updateComponentDefaultLibrary = async (library) => {
1009
- if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
1009
+ if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
1010
1010
  const currentDirectory = process.cwd();
1011
1011
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1012
1012
 
@@ -1017,12 +1017,12 @@ if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}
1017
1017
  componentsDefault.library = library;
1018
1018
 
1019
1019
 
1020
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4), { encoding: 'utf8',flag:'w' });
1020
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4), { encoding: 'utf8', flag: 'w' });
1021
1021
 
1022
- }
1022
+ };
1023
1023
 
1024
1024
  export const updateComponentDefaultVersion = async (version) => {
1025
- if (showDebug) addDebugLog("updateComponentDefaultVersion", `version: ${version}`, "");
1025
+ if (showDebug) addDebugLog("updateComponentDefaultVersion", `version: ${version}`, "");
1026
1026
  const currentDirectory = process.cwd();
1027
1027
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1028
1028
 
@@ -1033,21 +1033,21 @@ if (showDebug) addDebugLog("updateComponentDefaultVersion", `version: ${version}
1033
1033
  componentsDefault.version = version;
1034
1034
 
1035
1035
 
1036
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4), { encoding: 'utf8',flag:'w' });
1036
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4), { encoding: 'utf8', flag: 'w' });
1037
1037
 
1038
- }
1038
+ };
1039
1039
 
1040
- export const getConfigDevBuild = async() => {
1041
- if (showDebug) addDebugLog("getConfigDevBuild", "", "");
1040
+ export const getConfigDevBuild = async () => {
1041
+ if (showDebug) addDebugLog("getConfigDevBuild", "", "");
1042
1042
  // const serverConfig = await getPegaServerConfig();
1043
1043
 
1044
1044
  // return serverConfig.devBuild;
1045
1045
  return defaultConfigs.devBuild;
1046
1046
 
1047
- }
1047
+ };
1048
1048
 
1049
1049
  export const setConfigDevBuild = async (devBuild) => {
1050
- if (showDebug) addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
1050
+ if (showDebug) addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
1051
1051
  const currentDirectory = process.cwd();
1052
1052
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1053
1053
  let configData = await getPegaConfig(true);
@@ -1056,19 +1056,19 @@ if (showDebug) addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
1056
1056
 
1057
1057
  // update file
1058
1058
  // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
1059
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
1060
- }
1059
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8', flag: 'w' });
1060
+ };
1061
1061
 
1062
- export const getConfigDevServerPort = async() => {
1063
- if (showDebug) addDebugLog("getConfigDevServerPort", "", "");
1062
+ export const getConfigDevServerPort = async () => {
1063
+ if (showDebug) addDebugLog("getConfigDevServerPort", "", "");
1064
1064
  // const serverConfig = await getPegaServerConfig();
1065
1065
 
1066
1066
  return defaultConfigs.devServerPort;
1067
1067
 
1068
- }
1068
+ };
1069
1069
 
1070
1070
  export const setConfigImportRelativePath = async (importRelativePath) => {
1071
- if (showDebug) addDebugLog("setConfigImportRelativePath", `importRelativePath: ${importRelativePath}`, "");
1071
+ if (showDebug) addDebugLog("setConfigImportRelativePath", `importRelativePath: ${importRelativePath}`, "");
1072
1072
  const currentDirectory = process.cwd();
1073
1073
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1074
1074
  let configData = await getPegaConfig(true);
@@ -1076,11 +1076,11 @@ if (showDebug) addDebugLog("setConfigImportRelativePath", `importRelativePath: $
1076
1076
 
1077
1077
  // update file
1078
1078
  // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
1079
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
1080
- }
1079
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8', flag: 'w' });
1080
+ };
1081
1081
 
1082
1082
  export const setConfigExportRelativePath = async (exportRelativePath) => {
1083
- if (showDebug) addDebugLog("setConfigExportRelativePath", `exportRelativePath: ${exportRelativePath}`, "");
1083
+ if (showDebug) addDebugLog("setConfigExportRelativePath", `exportRelativePath: ${exportRelativePath}`, "");
1084
1084
  const currentDirectory = process.cwd();
1085
1085
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1086
1086
  let configData = await getPegaConfig(true);
@@ -1088,21 +1088,21 @@ if (showDebug) addDebugLog("setConfigExportRelativePath", `exportRelativePath: $
1088
1088
 
1089
1089
  // update file
1090
1090
  // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
1091
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
1092
- }
1091
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8', flag: 'w' });
1092
+ };
1093
1093
 
1094
1094
  export const updateDefaultOrganization = async (organization) => {
1095
- if (showDebug) addDebugLog("updateDefaultOrganization", `organization: ${organization}`, "");
1095
+ if (showDebug) addDebugLog("updateDefaultOrganization", `organization: ${organization}`, "");
1096
1096
  let packageData = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf-8'));
1097
1097
 
1098
1098
  packageData.organization = organization;
1099
1099
 
1100
- fs.writeFileSync(path.resolve('package.json'), JSON.stringify(packageData, null, 4), { encoding: 'utf8',flag:'w' });
1100
+ fs.writeFileSync(path.resolve('package.json'), JSON.stringify(packageData, null, 4), { encoding: 'utf8', flag: 'w' });
1101
1101
 
1102
- }
1102
+ };
1103
1103
 
1104
1104
  export const updateConfigVersion = async (componentKey, buildVersion, currentOrgLib) => {
1105
- if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}, buildVersion: ${buildVersion}, currentOrgLib: ${currentOrgLib}`, "");
1105
+ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}, buildVersion: ${buildVersion}, currentOrgLib: ${currentOrgLib}`, "");
1106
1106
  const componentDirectory = await getComponentDirectoryPath(componentKey);
1107
1107
  const configFileName = 'config.json';
1108
1108
 
@@ -1144,7 +1144,7 @@ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}
1144
1144
  }
1145
1145
  else {
1146
1146
  // don't have "About"
1147
- const aboutLabelJSON = {
1147
+ const aboutLabelJSON = {
1148
1148
  "format": "LABEL",
1149
1149
  "label": "About",
1150
1150
  "name": "PegaAboutLabel",
@@ -1155,7 +1155,7 @@ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}
1155
1155
  "label": aboutData,
1156
1156
  "name": "PegaAboutData",
1157
1157
  "variant": "primary"
1158
- }
1158
+ };
1159
1159
  properties.push(aboutLabelJSON);
1160
1160
  properties.push(aboutDataJSON);
1161
1161
  }
@@ -1177,20 +1177,20 @@ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}
1177
1177
 
1178
1178
 
1179
1179
  // write back file
1180
- fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
1180
+ fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8', flag: 'w' });
1181
1181
  };
1182
1182
 
1183
- export const getServerType = () => {
1184
- if (showDebug) addDebugLog("getServerType", "", "+");
1185
- // const defaultPegaServerConfig = await getPegaServerConfig();
1186
- // if (showDebug) addDebugLog("getServerType", "serverType:" + defaultPegaServerConfig.serverType, "");
1187
- if (showDebug) addDebugLog("getServerType", "END", "-");
1183
+ export const getServerType = () => {
1184
+ if (showDebug) addDebugLog("getServerType", "", "+");
1185
+ // const defaultPegaServerConfig = await getPegaServerConfig();
1186
+ // if (showDebug) addDebugLog("getServerType", "serverType:" + defaultPegaServerConfig.serverType, "");
1187
+ if (showDebug) addDebugLog("getServerType", "END", "-");
1188
1188
  // return defaultPegaServerConfig.serverType;
1189
1189
  return defaultConfigs.serverType;
1190
- }
1190
+ };
1191
1191
 
1192
- export const setServerType = async(serverType) => {
1193
- if (showDebug) addDebugLog("setServerType", `serverType: ${serverType}`, "");
1192
+ export const setServerType = async (serverType) => {
1193
+ if (showDebug) addDebugLog("setServerType", `serverType: ${serverType}`, "");
1194
1194
  const currentDirectory = process.cwd();
1195
1195
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1196
1196
  let configData = await getPegaConfig(true);
@@ -1199,23 +1199,23 @@ if (showDebug) addDebugLog("setServerType", `serverType: ${serverType}`, "");
1199
1199
 
1200
1200
  // update file
1201
1201
  // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
1202
- fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
1202
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8', flag: 'w' });
1203
1203
 
1204
1204
  // reset
1205
1205
  pegaData = null;
1206
1206
  pegaConfig = null;
1207
1207
 
1208
1208
  await forceDefaultsUpdate();
1209
- }
1209
+ };
1210
1210
 
1211
1211
  export const getSrcDirectoryPath = async () => {
1212
1212
  const currentDirectory = process.cwd();
1213
1213
 
1214
1214
  return join(currentDirectory, "src");
1215
- }
1215
+ };
1216
1216
 
1217
1217
  export const getComponentDirectoryPath = async (componentKey, overrideDir = null) => {
1218
- if (showDebug) addDebugLog("getComponentDirectoryPath", "", "+");
1218
+ if (showDebug) addDebugLog("getComponentDirectoryPath", "", "+");
1219
1219
  const currentDirectory = process.cwd();
1220
1220
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1221
1221
 
@@ -1230,14 +1230,14 @@ if (showDebug) addDebugLog("getComponentDirectoryPath", "", "+");
1230
1230
  );
1231
1231
  process.exit(1);
1232
1232
  }
1233
- if (showDebug) addDebugLog("getComponentDirectoryPath", "path: " + join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey), "");
1234
- if (showDebug) addDebugLog("getComponentDirectoryPath", "END", "-");
1233
+ if (showDebug) addDebugLog("getComponentDirectoryPath", "path: " + join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey), "");
1234
+ if (showDebug) addDebugLog("getComponentDirectoryPath", "END", "-");
1235
1235
  return overrideDir ? join(overrideDir, componentKey) : join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
1236
1236
  };
1237
1237
 
1238
1238
 
1239
1239
  export const compileMustacheTemplate = (file, data) => {
1240
- if (showDebug) addDebugLog("compileMustacheTemplate", `file: ${file}`, "");
1240
+ if (showDebug) addDebugLog("compileMustacheTemplate", `file: ${file}`, "");
1241
1241
  const content = fs.readFileSync(file, 'utf8');
1242
1242
  return mustache.render(content, data);
1243
1243
  };
@@ -1251,7 +1251,7 @@ export const convertIntoPascalCase = string => {
1251
1251
  };
1252
1252
 
1253
1253
  export const constructCompleteUrl = (baseServer, endPoint) => {
1254
- if (showDebug) addDebugLog("constructCompleteUrl", "url: " + baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`, "");
1254
+ if (showDebug) addDebugLog("constructCompleteUrl", "url: " + baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`, "");
1255
1255
  return baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`;
1256
1256
  };
1257
1257
 
@@ -1306,7 +1306,7 @@ export const showVersion = async () => {
1306
1306
  const nodeMajorVersion = parseInt(arNodeVersion[0]);
1307
1307
  const nodeMinorVersion = parseInt(arNodeVersion[1]);
1308
1308
 
1309
- if (nodeMajorVersion < 22 && nodeMinorVersion < 15 ) {
1309
+ if (nodeMajorVersion < 22 && nodeMinorVersion < 15) {
1310
1310
  console.log(
1311
1311
  chalk.redBright(
1312
1312
  `DX Component Builder - SDK requires node v20.15.0 or greater, current version: ${process.version}`
@@ -1321,24 +1321,24 @@ export const showVersion = async () => {
1321
1321
 
1322
1322
  };
1323
1323
 
1324
- export const checkForBranch = async(rulesetName) => {
1324
+ export const checkForBranch = async (rulesetName) => {
1325
1325
  if (rulesetName === "") {
1326
1326
  const serverConfig = await getPegaServerConfig();
1327
1327
  rulesetName = serverConfig.rulesetName;
1328
1328
  }
1329
1329
 
1330
1330
  if (rulesetName.toLowerCase().indexOf("_branch") >= 0) {
1331
- console.log(
1331
+ console.log(
1332
1332
  chalk.redBright(
1333
1333
  `Ruleset ${chalk.bold(`${rulesetName}`)} cannot be a branch ruleset.`
1334
1334
  )
1335
1335
  );
1336
1336
  process.exit(1);
1337
1337
  }
1338
- }
1338
+ };
1339
1339
 
1340
1340
  export const getOOTBComponents = async () => {
1341
- if (showDebug) addDebugLog("getOOTBComponents", "", "");
1341
+ if (showDebug) addDebugLog("getOOTBComponents", "", "");
1342
1342
  return new Promise(resolve => {
1343
1343
  fs.readFile(OOTB_COMPONENTS, 'utf-8', async (error, ootbComponentsData) => {
1344
1344
  if (error) {
@@ -1391,7 +1391,7 @@ if (showDebug) addDebugLog("getOOTBComponents", "", "");
1391
1391
  };
1392
1392
 
1393
1393
  export const deleteInfinityServerComponent = async componentKey => {
1394
- if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${componentKey}`, "");
1394
+ if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${componentKey}`, "");
1395
1395
  const serverConfig = await getPegaServerConfig();
1396
1396
  const { server } = serverConfig;
1397
1397
  const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
@@ -1422,13 +1422,13 @@ if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${com
1422
1422
  // console.log(accessTokenUri, refreshToken);
1423
1423
  /* TODO - Handle refresh_token */
1424
1424
  }
1425
- else if (status === 404){
1425
+ else if (status === 404) {
1426
1426
  throw new Error('404: Server resource not found');
1427
1427
  }
1428
- else if (status === 405){
1428
+ else if (status === 405) {
1429
1429
  throw new Error('405: Server method not allowed');
1430
1430
  }
1431
- else if (status === 408){
1431
+ else if (status === 408) {
1432
1432
  throw new Error('408: Server timed out');
1433
1433
  }
1434
1434
  else if (response.status === 403) {
@@ -1443,7 +1443,7 @@ if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${com
1443
1443
  try {
1444
1444
  const respData = await response.json();
1445
1445
  console.log(
1446
- chalk.bold.green(`Success : ${respData.message}`)
1446
+ chalk.bold.green(`Success : ${respData.message}`)
1447
1447
  );
1448
1448
 
1449
1449
  if (status === 500) {
@@ -1453,12 +1453,12 @@ if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${com
1453
1453
  }
1454
1454
  catch (err) {
1455
1455
  if (status === 500) {
1456
- throw new Error(
1457
- `Error occurred in authentication. Please regenerate using authenticate`
1458
- );
1456
+ throw new Error(
1457
+ `Error occurred in authentication. Please regenerate using authenticate`
1458
+ );
1459
1459
  }
1460
1460
  else if (status === 999) {
1461
- throw new Error (err);
1461
+ throw new Error(err);
1462
1462
  }
1463
1463
  }
1464
1464
 
@@ -1470,7 +1470,7 @@ if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${com
1470
1470
  };
1471
1471
 
1472
1472
  export const deleteInfinityServerComponentLibrary = async (libraryName, rulesetName, rulesetVersion) => {
1473
- if (showDebug) addDebugLog("deleteInfinityServerComponentLibrary", `componentKey: ${componentKey}, rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
1473
+ if (showDebug) addDebugLog("deleteInfinityServerComponentLibrary", `componentKey: ${componentKey}, rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
1474
1474
  const serverConfig = await getPegaServerConfig();
1475
1475
  const { server } = serverConfig;
1476
1476
  const url = constructCompleteUrl(server, DELETE_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT);
@@ -1507,13 +1507,13 @@ if (showDebug) addDebugLog("deleteInfinityServerComponentLibrary", `componentKey
1507
1507
  // console.log(accessTokenUri, refreshToken);
1508
1508
  /* TODO - Handle refresh_token */
1509
1509
  }
1510
- else if (status === 404){
1510
+ else if (status === 404) {
1511
1511
  throw new Error('404: Server resource not found');
1512
1512
  }
1513
- else if (status === 405){
1513
+ else if (status === 405) {
1514
1514
  throw new Error('405: Server method not allowed');
1515
1515
  }
1516
- else if (status === 408){
1516
+ else if (status === 408) {
1517
1517
  throw new Error('408: Server timed out');
1518
1518
  }
1519
1519
  else if (response.status === 403) {
@@ -1542,12 +1542,12 @@ if (showDebug) addDebugLog("deleteInfinityServerComponentLibrary", `componentKey
1542
1542
  }
1543
1543
  catch (err) {
1544
1544
  if (status === 500) {
1545
- throw new Error(
1546
- `Error occurred in authentication. Please regenerate using authenticate`
1547
- );
1545
+ throw new Error(
1546
+ `Error occurred in authentication. Please regenerate using authenticate`
1547
+ );
1548
1548
  }
1549
1549
  else if (status === 999) {
1550
- throw new Error (err);
1550
+ throw new Error(err);
1551
1551
  }
1552
1552
  }
1553
1553
 
@@ -1560,7 +1560,7 @@ if (showDebug) addDebugLog("deleteInfinityServerComponentLibrary", `componentKey
1560
1560
 
1561
1561
 
1562
1562
  export const deleteLaunchpadServerComponent = async componentKey => {
1563
- if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "");
1563
+ if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "");
1564
1564
  const { server, isolationId } = await getPegaServerConfig();
1565
1565
  const deleteUrl = constructCompleteUrl(
1566
1566
  server,
@@ -1604,13 +1604,13 @@ if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${co
1604
1604
  // console.log(accessTokenUri, refreshToken);
1605
1605
  /* TODO - Handle refresh_token */
1606
1606
  }
1607
- else if (status === 404){
1607
+ else if (status === 404) {
1608
1608
  throw new Error('404: Server resource not found');
1609
1609
  }
1610
- else if (status === 405){
1610
+ else if (status === 405) {
1611
1611
  throw new Error('405: Server method not allowed');
1612
1612
  }
1613
- else if (status === 408){
1613
+ else if (status === 408) {
1614
1614
  throw new Error('408: Server timed out');
1615
1615
  }
1616
1616
  else if (response.status === 403) {
@@ -1623,7 +1623,7 @@ if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${co
1623
1623
  try {
1624
1624
  const respData = await response.text();
1625
1625
  console.log(
1626
- chalk.bold.green(`Success : ${respData}`)
1626
+ chalk.bold.green(`Success : ${respData}`)
1627
1627
  );
1628
1628
 
1629
1629
  if (status === 500) {
@@ -1633,12 +1633,12 @@ if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${co
1633
1633
  }
1634
1634
  catch (err) {
1635
1635
  if (status === 500) {
1636
- throw new Error(
1637
- `Error occurred in authentication. Please regenerate using authenticate`
1638
- );
1636
+ throw new Error(
1637
+ `Error occurred in authentication. Please regenerate using authenticate`
1638
+ );
1639
1639
  }
1640
1640
  else if (status === 999) {
1641
- throw new Error (err);
1641
+ throw new Error(err);
1642
1642
  }
1643
1643
  }
1644
1644
  }
@@ -1648,7 +1648,7 @@ if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${co
1648
1648
  };
1649
1649
 
1650
1650
  export const getBootstrapConfig = async (restServerUrl, authorizationHeader) => {
1651
- if (showDebug) addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl}`, "");
1651
+ if (showDebug) addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl}`, "");
1652
1652
  const serverConfig = await getPegaServerConfig();
1653
1653
 
1654
1654
  return fetch(`${restServerUrl}/${BOOTSTRAP_CONFIG}`, {
@@ -1666,7 +1666,7 @@ if (showDebug) addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl
1666
1666
  };
1667
1667
 
1668
1668
  export const updateC11NB2SForInfinity = async () => {
1669
- if (showDebug) addDebugLog("updateC11NB2SForInfinity", "", "");
1669
+ if (showDebug) addDebugLog("updateC11NB2SForInfinity", "", "");
1670
1670
  const serverConfig = await getPegaServerConfig();
1671
1671
  const { server } = serverConfig;
1672
1672
  const OAuthData = fs.readFileSync(TOKEN_PATH, 'utf8');
@@ -1685,7 +1685,7 @@ if (showDebug) addDebugLog("updateC11NB2SForInfinity", "", "");
1685
1685
  objOauthData["appStaticContentServer"] = (bootstrap.serviceConfig.appStaticContentServer != "no-cdn" && bootstrap.serviceConfig.appStaticContentServer != "") ? bootstrap.serviceConfig.appStaticContentServer : bootstrap.serviceConfig.staticContentServer;
1686
1686
 
1687
1687
  // write out file
1688
- fs.writeFileSync(TOKEN_PATH, JSON.stringify(objOauthData), { encoding: 'utf8',flag:'w' });
1688
+ fs.writeFileSync(TOKEN_PATH, JSON.stringify(objOauthData), { encoding: 'utf8', flag: 'w' });
1689
1689
  }
1690
1690
 
1691
1691
  }
@@ -1698,7 +1698,7 @@ export const updateC11NB2SForLaunchpad = async () => {
1698
1698
  };
1699
1699
 
1700
1700
  export const getC11NB2STokenAndStaticServer = async () => {
1701
- if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1701
+ if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1702
1702
  const serverConfig = await getPegaServerConfig();
1703
1703
  const { server } = serverConfig;
1704
1704
  let OAuthData;
@@ -1710,28 +1710,28 @@ if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1710
1710
  }
1711
1711
 
1712
1712
  if (OAuthData) {
1713
- const { C11NB2S, appStaticContentServer, access_token } = JSON.parse(OAuthData)
1713
+ const { C11NB2S, appStaticContentServer, access_token } = JSON.parse(OAuthData);
1714
1714
 
1715
- return ({ C11NB2S, appStaticContentServer, access_token});
1715
+ return ({ C11NB2S, appStaticContentServer, access_token });
1716
1716
 
1717
1717
  }
1718
1718
  return ({});
1719
1719
  };
1720
1720
 
1721
1721
  export const getLocalLibraries = async () => {
1722
- if (showDebug) addDebugLog("getLocalLibraries", "" , "");
1722
+ if (showDebug) addDebugLog("getLocalLibraries", "", "");
1723
1723
  const currentDirectory = process.cwd();
1724
1724
  const configDef = getConfigDefaults();
1725
1725
  const libFilter = configDef.organization.concat("_");
1726
1726
 
1727
1727
  return fs
1728
- .readdirSync(currentDirectory, { withFileTypes: true })
1729
- .filter(dirent => dirent.isDirectory() && dirent.name.startsWith(libFilter))
1730
- .map(dirent => dirent.name);
1731
- }
1728
+ .readdirSync(currentDirectory, { withFileTypes: true })
1729
+ .filter(dirent => dirent.isDirectory() && dirent.name.startsWith(libFilter))
1730
+ .map(dirent => dirent.name);
1731
+ };
1732
1732
 
1733
1733
  export const getLocalLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
1734
- if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
1734
+ if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}`, "");
1735
1735
  const currentDirectory = process.cwd();
1736
1736
 
1737
1737
  const directory = join(currentDirectory, libraryName);
@@ -1742,9 +1742,9 @@ if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryNam
1742
1742
  };
1743
1743
 
1744
1744
  export const getLocalArchivedLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
1745
- if (showDebug) addDebugLog("getLocalArchivedLibraryVersions", `libraryName: ${libraryName}` , "");
1745
+ if (showDebug) addDebugLog("getLocalArchivedLibraryVersions", `libraryName: ${libraryName}`, "");
1746
1746
  const currentDirectory = process.cwd();
1747
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${libraryName}`);
1747
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${libraryName}`);
1748
1748
 
1749
1749
  return fs
1750
1750
  .readdirSync(archiveDirectory, { withFileTypes: true })
@@ -1752,31 +1752,31 @@ if (showDebug) addDebugLog("getLocalArchivedLibraryVersions", `libraryName: ${li
1752
1752
  .map(dirent => dirent.name);
1753
1753
  };
1754
1754
 
1755
- export const getLocalArchivedLibrraryVersionData = async(libraryName, libraryVersion) => {
1756
- if (showDebug) addDebugLog("getLocalArchivedLibrraryVersionData", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}`, "");
1755
+ export const getLocalArchivedLibrraryVersionData = async (libraryName, libraryVersion) => {
1756
+ if (showDebug) addDebugLog("getLocalArchivedLibrraryVersionData", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}`, "");
1757
1757
  const currentDirectory = process.cwd();
1758
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${libraryName}`, `${libraryVersion}`);
1758
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${libraryName}`, `${libraryVersion}`);
1759
1759
 
1760
- const componentConfigFile = join (archiveDirectory, COMPONENTS_CONFIG_FILE_NAME);
1760
+ const componentConfigFile = join(archiveDirectory, COMPONENTS_CONFIG_FILE_NAME);
1761
1761
 
1762
- let data = fs.readFileSync(componentConfigFile, { encoding: 'utf8' })
1762
+ let data = fs.readFileSync(componentConfigFile, { encoding: 'utf8' });
1763
1763
 
1764
1764
  return data;
1765
- }
1765
+ };
1766
1766
 
1767
1767
  export const getLocalLibraryVersionData = async (libraryName, libraryVersion) => {
1768
- if (showDebug) addDebugLog("getLocalLibraryVersionDate", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1769
- const currentDirectory = process.cwd();
1770
- const libDir = join(currentDirectory, libraryName, libraryVersion);
1771
- const libDataFile = join(libDir, COMPONENTS_CONFIG_FILE_NAME);
1768
+ if (showDebug) addDebugLog("getLocalLibraryVersionDate", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}`, "");
1769
+ const currentDirectory = process.cwd();
1770
+ const libDir = join(currentDirectory, libraryName, libraryVersion);
1771
+ const libDataFile = join(libDir, COMPONENTS_CONFIG_FILE_NAME);
1772
1772
 
1773
- let data = fs.readFileSync(libDataFile, { encoding: 'utf8' })
1773
+ let data = fs.readFileSync(libDataFile, { encoding: 'utf8' });
1774
1774
 
1775
- return data;
1775
+ return data;
1776
1776
  };
1777
1777
 
1778
1778
  export const deleteLocalLibrary = async (libraryName) => {
1779
- if (showDebug) addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}` , "");
1779
+ if (showDebug) addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}`, "");
1780
1780
  const currentDirectory = process.cwd();
1781
1781
 
1782
1782
  const directory = join(currentDirectory, libraryName);
@@ -1805,7 +1805,7 @@ if (showDebug) addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}` ,
1805
1805
  };
1806
1806
 
1807
1807
  export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) => {
1808
- if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1808
+ if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}`, "");
1809
1809
  const currentDirectory = process.cwd();
1810
1810
 
1811
1811
  const directory = join(currentDirectory, libraryName, libraryVersion);
@@ -1813,7 +1813,7 @@ if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryNam
1813
1813
  try {
1814
1814
  if (fs.existsSync(directory)) {
1815
1815
  console.log(`Deleting library version: ${chalk.green.bold(libraryName)}:${chalk.green.bold(libraryVersion)}`);
1816
- fs.rmSync(directory, { recursive: true, force: true, maxRetries: 2 });
1816
+ fs.rmSync(directory, { recursive: true, force: true, maxRetries: 2 });
1817
1817
  console.log(`Library version: ${chalk.green.bold(libraryName)}:${chalk.green.bold(libraryVersion)} is deleted from Local`);
1818
1818
  }
1819
1819
  else {
@@ -1828,7 +1828,7 @@ if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryNam
1828
1828
  };
1829
1829
 
1830
1830
  export const deletePublishExtras = async (libraryName, libraryVersion) => {
1831
- if (showDebug) addDebugLog("deletePublishExtras", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
1831
+ if (showDebug) addDebugLog("deletePublishExtras", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}`, "");
1832
1832
  // this function will delete LibraryName.zip file, so new one created by publish
1833
1833
  // check if .DS_store file exists in Library, if so delete it because causes issue with services
1834
1834
 
@@ -1852,7 +1852,7 @@ if (showDebug) addDebugLog("deletePublishExtras", `libraryName: ${libraryName},
1852
1852
 
1853
1853
 
1854
1854
  export const cleanUp = async () => {
1855
- if (showDebug) addDebugLog("cleanUp", "", "");
1855
+ if (showDebug) addDebugLog("cleanUp", "", "");
1856
1856
  if (fs.existsSync('dist/components')) {
1857
1857
  fs.rm('dist/components', { recursive: true }, err => {
1858
1858
  if (err) {
@@ -1872,7 +1872,7 @@ if (showDebug) addDebugLog("cleanUp", "", "");
1872
1872
  };
1873
1873
 
1874
1874
  export const getComponentsConfigs = async (compDir = null) => {
1875
- if (showDebug) addDebugLog("getComponentsConfigs", "", "");
1875
+ if (showDebug) addDebugLog("getComponentsConfigs", "", "");
1876
1876
  const componentsList = await getComponents(compDir);
1877
1877
 
1878
1878
  let componentsConfigJSON = [];
@@ -1894,22 +1894,22 @@ if (showDebug) addDebugLog("getComponentsConfigs", "", "");
1894
1894
  }
1895
1895
  }
1896
1896
  return componentsConfigJSON;
1897
- }
1897
+ };
1898
1898
 
1899
1899
 
1900
1900
  export const createComponentsConfigFile = async (filePath, compDir) => {
1901
- if (showDebug) addDebugLog("createComponentsConfigFile", `filePath: ${filePath}`, "");
1901
+ if (showDebug) addDebugLog("createComponentsConfigFile", `filePath: ${filePath}`, "");
1902
1902
  const componentsConfigJSON = await getComponentsConfigs(compDir);
1903
1903
  const compConfgFile = join(filePath, COMPONENTS_CONFIG_FILE_NAME);
1904
1904
 
1905
1905
  // write out file
1906
- fs.writeFileSync(compConfgFile, JSON.stringify(componentsConfigJSON), { encoding: 'utf8',flag:'w' });
1906
+ fs.writeFileSync(compConfgFile, JSON.stringify(componentsConfigJSON), { encoding: 'utf8', flag: 'w' });
1907
1907
 
1908
1908
  };
1909
1909
 
1910
1910
 
1911
1911
  export const zipVersionAndArchive = async (orgLibName, version, currentDirectory = "") => {
1912
- if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
1912
+ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
1913
1913
  // const srcDirectoryPath = await getSrcDirectoryPath();
1914
1914
  if (currentDirectory === "") {
1915
1915
  currentDirectory = process.cwd();
@@ -1922,7 +1922,7 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
1922
1922
 
1923
1923
  // const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
1924
1924
  const mainDirectory = process.cwd();
1925
- const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
1925
+ const archiveDirectory = join(mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
1926
1926
  if (!fs.existsSync(archiveDirectory)) {
1927
1927
  fs.mkdirSync(archiveDirectory, { recursive: true });
1928
1928
  }
@@ -1961,13 +1961,13 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
1961
1961
  // pipe archive data to the file
1962
1962
  archive.pipe(output);
1963
1963
 
1964
- output.on('end', function() {
1964
+ output.on('end', function () {
1965
1965
  console.log('Data has been drained');
1966
1966
  });
1967
1967
 
1968
1968
 
1969
1969
  // good practice to catch warnings (ie stat failures and other non-blocking errors)
1970
- archive.on('warning', function(err) {
1970
+ archive.on('warning', function (err) {
1971
1971
  if (err.code === 'ENOENT') {
1972
1972
  // log warning
1973
1973
  } else {
@@ -1977,7 +1977,7 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
1977
1977
  });
1978
1978
 
1979
1979
  // good practice to catch this error explicitly
1980
- archive.on('error', function(err) {
1980
+ archive.on('error', function (err) {
1981
1981
  throw err;
1982
1982
  });
1983
1983
 
@@ -1991,7 +1991,7 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
1991
1991
 
1992
1992
 
1993
1993
  export const zipVersionAndArchiveAndReturnBuffer = async (orgLibName, version, currentDirectory = "") => {
1994
- if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
1994
+ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
1995
1995
  // const srcDirectoryPath = await getSrcDirectoryPath();
1996
1996
  if (currentDirectory === "") {
1997
1997
  currentDirectory = process.cwd();
@@ -2004,7 +2004,7 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
2004
2004
 
2005
2005
  // const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
2006
2006
  const mainDirectory = process.cwd();
2007
- const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
2007
+ const archiveDirectory = join(mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
2008
2008
  if (!fs.existsSync(archiveDirectory)) {
2009
2009
  fs.mkdirSync(archiveDirectory, { recursive: true });
2010
2010
  }
@@ -2044,13 +2044,13 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
2044
2044
  // pipe archive data to the file
2045
2045
  archive.pipe(output);
2046
2046
 
2047
- output.on('end', function() {
2047
+ output.on('end', function () {
2048
2048
  console.log('Data has been drained');
2049
2049
  });
2050
2050
 
2051
2051
 
2052
2052
  // good practice to catch warnings (ie stat failures and other non-blocking errors)
2053
- archive.on('warning', function(err) {
2053
+ archive.on('warning', function (err) {
2054
2054
  if (err.code === 'ENOENT') {
2055
2055
  // log warning
2056
2056
  } else {
@@ -2060,7 +2060,7 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
2060
2060
  });
2061
2061
 
2062
2062
  // good practice to catch this error explicitly
2063
- archive.on('error', function(err) {
2063
+ archive.on('error', function (err) {
2064
2064
  throw err;
2065
2065
  });
2066
2066
 
@@ -2069,19 +2069,19 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
2069
2069
  const zipBuffer = Buffer.concat(zipChunks);
2070
2070
  const zipContent = zipBuffer.toString('base64');
2071
2071
 
2072
- return { output, zipContent};
2072
+ return { output, zipContent };
2073
2073
 
2074
2074
  };
2075
2075
 
2076
- export const zipUnArchiveToTempAndReturnBuffer = async(orgLibName, version) => {
2076
+ export const zipUnArchiveToTempAndReturnBuffer = async (orgLibName, version) => {
2077
2077
 
2078
2078
  // unarchive to temp
2079
2079
  const currentDirectory = process.cwd();
2080
- const tempDirectory = join (currentDirectory, TEMP_PATH);
2080
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
2081
2081
  const srcDirectoryPath = join(tempDirectory, "src");
2082
2082
 
2083
2083
  const archiveFileName = `${orgLibName}_${version}.arch.zip`;
2084
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
2084
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
2085
2085
  const archFileName = join(archiveDirectory, archiveFileName);
2086
2086
 
2087
2087
  await unZipFromArchive(archFileName);
@@ -2115,13 +2115,13 @@ export const zipUnArchiveToTempAndReturnBuffer = async(orgLibName, version) => {
2115
2115
  // pipe archive data to the file
2116
2116
  archive.pipe(output);
2117
2117
 
2118
- output.on('end', function() {
2118
+ output.on('end', function () {
2119
2119
  console.log('Data has been drained');
2120
2120
  });
2121
2121
 
2122
2122
 
2123
2123
  // good practice to catch warnings (ie stat failures and other non-blocking errors)
2124
- archive.on('warning', function(err) {
2124
+ archive.on('warning', function (err) {
2125
2125
  if (err.code === 'ENOENT') {
2126
2126
  // log warning
2127
2127
  } else {
@@ -2131,7 +2131,7 @@ export const zipUnArchiveToTempAndReturnBuffer = async(orgLibName, version) => {
2131
2131
  });
2132
2132
 
2133
2133
  // good practice to catch this error explicitly
2134
- archive.on('error', function(err) {
2134
+ archive.on('error', function (err) {
2135
2135
  throw err;
2136
2136
  });
2137
2137
 
@@ -2140,13 +2140,13 @@ export const zipUnArchiveToTempAndReturnBuffer = async(orgLibName, version) => {
2140
2140
  const zipBuffer = Buffer.concat(zipChunks);
2141
2141
  const zipContent = zipBuffer.toString('base64');
2142
2142
 
2143
- return { output, zipContent};
2143
+ return { output, zipContent };
2144
2144
 
2145
2145
 
2146
- }
2146
+ };
2147
2147
 
2148
2148
  export const zipVersionAndArchiveCL = async (orgLibName, version, currentDirectory = "") => {
2149
- if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName}, version: ${version}, currentDirectory: ${currentDirectory}`, "");
2149
+ if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName}, version: ${version}, currentDirectory: ${currentDirectory}`, "");
2150
2150
  // const srcDirectoryPath = await getSrcDirectoryPath();
2151
2151
  if (currentDirectory === "") {
2152
2152
  currentDirectory = process.cwd();
@@ -2159,7 +2159,7 @@ if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName},
2159
2159
 
2160
2160
  // const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
2161
2161
  const mainDirectory = process.cwd();
2162
- const archiveDirectory = join (mainDirectory, BIN_ARCHIVES_PATH);
2162
+ const archiveDirectory = join(mainDirectory, BIN_ARCHIVES_PATH);
2163
2163
  if (!fs.existsSync(archiveDirectory)) {
2164
2164
  fs.mkdirSync(archiveDirectory, { recursive: true });
2165
2165
  }
@@ -2185,13 +2185,13 @@ if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName},
2185
2185
  // pipe archive data to the file
2186
2186
  archive.pipe(output);
2187
2187
 
2188
- output.on('end', function() {
2188
+ output.on('end', function () {
2189
2189
  console.log('Data has been drained');
2190
2190
  });
2191
2191
 
2192
2192
 
2193
2193
  // good practice to catch warnings (ie stat failures and other non-blocking errors)
2194
- archive.on('warning', function(err) {
2194
+ archive.on('warning', function (err) {
2195
2195
  if (err.code === 'ENOENT') {
2196
2196
  // log warning
2197
2197
  } else {
@@ -2201,7 +2201,7 @@ if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName},
2201
2201
  });
2202
2202
 
2203
2203
  // good practice to catch this error explicitly
2204
- archive.on('error', function(err) {
2204
+ archive.on('error', function (err) {
2205
2205
  throw err;
2206
2206
  });
2207
2207
 
@@ -2212,14 +2212,14 @@ if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName},
2212
2212
  };
2213
2213
 
2214
2214
  export const unZipFromArchive = async (fileName) => {
2215
- if (showDebug) addDebugLog("unZipFromArchive", `fileName: ${fileName}`, "");
2215
+ if (showDebug) addDebugLog("unZipFromArchive", `fileName: ${fileName}`, "");
2216
2216
  await unarchive(fileName, TEMP_PATH);
2217
2217
  };
2218
2218
 
2219
2219
 
2220
2220
 
2221
2221
  export const updateComponentTaskConfig = async () => {
2222
- if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2222
+ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2223
2223
  const currentDirectory = process.cwd();
2224
2224
  const tempDirectory = join(currentDirectory, TEMP_PATH);
2225
2225
 
@@ -2243,18 +2243,18 @@ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2243
2243
 
2244
2244
  // if we don't have a devServerPort, add the default
2245
2245
  if (originalContentsData["server-config"].devServerPort === undefined) {
2246
- originalContentsData["server-config"].devServerPort = "3030"
2246
+ originalContentsData["server-config"].devServerPort = "3030";
2247
2247
  }
2248
2248
 
2249
- fs.writeFileSync(currentConfigPath, JSON.stringify(originalContentsData, null, 4), { encoding: 'utf8',flag:'w' });
2249
+ fs.writeFileSync(currentConfigPath, JSON.stringify(originalContentsData, null, 4), { encoding: 'utf8', flag: 'w' });
2250
2250
 
2251
- }
2251
+ };
2252
2252
 
2253
2253
  export const restoreDependenciesFromPackage = async () => {
2254
- if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
2254
+ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
2255
2255
  const currentDirectory = process.cwd();
2256
2256
  const tempDirectory = join(currentDirectory, TEMP_PATH);
2257
- const tempPackagePath = join (tempDirectory, PACKAGE_JSON_FILENAME);
2257
+ const tempPackagePath = join(tempDirectory, PACKAGE_JSON_FILENAME);
2258
2258
  const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
2259
2259
 
2260
2260
  let retrievedPackageData;
@@ -2267,7 +2267,7 @@ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
2267
2267
  retrievedPackageData = fs.readFileSync(tempPackagePath);
2268
2268
  }
2269
2269
  catch (ex) {
2270
- console.log(chalk.red(`\nUnable to retrieve package.json from store.`))
2270
+ console.log(chalk.red(`\nUnable to retrieve package.json from store.`));
2271
2271
  process.exit(1);
2272
2272
  }
2273
2273
 
@@ -2275,7 +2275,7 @@ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
2275
2275
  currentPackageData = fs.readFileSync(currentPackagePath);
2276
2276
  }
2277
2277
  catch (ex) {
2278
- console.log(chalk.red(`\nUnable to retrieve current package.json.`))
2278
+ console.log(chalk.red(`\nUnable to retrieve current package.json.`));
2279
2279
  process.exit(1);
2280
2280
  }
2281
2281
 
@@ -2313,7 +2313,7 @@ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
2313
2313
  retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
2314
2314
  }
2315
2315
  catch (ex) {
2316
- console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
2316
+ console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`));
2317
2317
  process.exit(1);
2318
2318
  }
2319
2319
  const tData = JSON.parse(retrievedTemplateData);
@@ -2335,167 +2335,167 @@ if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
2335
2335
 
2336
2336
 
2337
2337
  // update current package json file
2338
- fs.writeFileSync(currentPackagePath, JSON.stringify(rData, null, 4), { encoding: 'utf8',flag:'w' });
2338
+ fs.writeFileSync(currentPackagePath, JSON.stringify(rData, null, 4), { encoding: 'utf8', flag: 'w' });
2339
2339
 
2340
2340
 
2341
- }
2341
+ };
2342
2342
 
2343
2343
 
2344
2344
  export const restoreDependenciesFromTemplate = async () => {
2345
2345
  if (showDebug) addDebugLog("restoreDependenciesFromTemplate", "", "");
2346
- const currentDirectory = process.cwd();
2347
- const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
2346
+ const currentDirectory = process.cwd();
2347
+ const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
2348
2348
 
2349
- let currentPackageData;
2349
+ let currentPackageData;
2350
2350
 
2351
- // reset
2352
- haveDependencyDifference = true;
2351
+ // reset
2352
+ haveDependencyDifference = true;
2353
2353
 
2354
- try {
2355
- currentPackageData = fs.readFileSync(currentPackagePath);
2356
- }
2357
- catch (ex) {
2358
- console.log(chalk.red(`\nUnable to retrieve current package.json.`))
2359
- process.exit(1);
2360
- }
2354
+ try {
2355
+ currentPackageData = fs.readFileSync(currentPackagePath);
2356
+ }
2357
+ catch (ex) {
2358
+ console.log(chalk.red(`\nUnable to retrieve current package.json.`));
2359
+ process.exit(1);
2360
+ }
2361
2361
 
2362
2362
 
2363
- let cData = JSON.parse(currentPackageData);
2363
+ let cData = JSON.parse(currentPackageData);
2364
2364
 
2365
2365
 
2366
- // we can't loose devDep that is part of install, so go get the template mustache and push
2367
- // those in, replacing any changes there, but allowing additional, an keeping it updated
2368
- // so won't loose new function if an old archive
2369
- const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
2370
- const templateDir = join(initDir, "template");
2371
- const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
2372
- let retrievedTemplateData;
2373
- try {
2374
- retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
2375
- }
2376
- catch (ex) {
2377
- console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
2378
- process.exit(1);
2379
- }
2380
- const tData = JSON.parse(retrievedTemplateData);
2381
- const tDevDep = tData.devDependencies;
2382
- const tDep = tData.dependencies;
2366
+ // we can't loose devDep that is part of install, so go get the template mustache and push
2367
+ // those in, replacing any changes there, but allowing additional, an keeping it updated
2368
+ // so won't loose new function if an old archive
2369
+ const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
2370
+ const templateDir = join(initDir, "template");
2371
+ const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
2372
+ let retrievedTemplateData;
2373
+ try {
2374
+ retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
2375
+ }
2376
+ catch (ex) {
2377
+ console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`));
2378
+ process.exit(1);
2379
+ }
2380
+ const tData = JSON.parse(retrievedTemplateData);
2381
+ const tDevDep = tData.devDependencies;
2382
+ const tDep = tData.dependencies;
2383
2383
 
2384
- for (const [key, value] of Object.entries(tDevDep)) {
2385
- cData.devDependencies[key] = value;
2386
- }
2384
+ for (const [key, value] of Object.entries(tDevDep)) {
2385
+ cData.devDependencies[key] = value;
2386
+ }
2387
2387
 
2388
- for (const [key, value] of Object.entries(tDep)) {
2389
- cData.dependencies[key] = value;
2390
- }
2388
+ for (const [key, value] of Object.entries(tDep)) {
2389
+ cData.dependencies[key] = value;
2390
+ }
2391
2391
 
2392
2392
 
2393
- // update current package json file
2394
- fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',flag:'w' });
2393
+ // update current package json file
2394
+ fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8', flag: 'w' });
2395
2395
 
2396
2396
 
2397
- }
2397
+ };
2398
2398
 
2399
2399
 
2400
2400
  export const restoreDependenciesFromPackage_old = async () => {
2401
2401
  if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
2402
- const currentDirectory = process.cwd();
2403
- const tempDirectory = join(currentDirectory, TEMP_PATH);
2404
- const tempPackagePath = join (tempDirectory, PACKAGE_JSON_FILENAME);
2405
- const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
2402
+ const currentDirectory = process.cwd();
2403
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
2404
+ const tempPackagePath = join(tempDirectory, PACKAGE_JSON_FILENAME);
2405
+ const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
2406
2406
 
2407
- let retrievedPackageData;
2408
- let currentPackageData;
2407
+ let retrievedPackageData;
2408
+ let currentPackageData;
2409
2409
 
2410
- // reset
2411
- haveDependencyDifference = false;
2410
+ // reset
2411
+ haveDependencyDifference = false;
2412
2412
 
2413
- try {
2414
- retrievedPackageData = fs.readFileSync(tempPackagePath);
2415
- }
2416
- catch (ex) {
2417
- console.log($chalk.red(`\nUnable to retrieve package.json from store.`))
2418
- process.exit(1);
2419
- }
2413
+ try {
2414
+ retrievedPackageData = fs.readFileSync(tempPackagePath);
2415
+ }
2416
+ catch (ex) {
2417
+ console.log($chalk.red(`\nUnable to retrieve package.json from store.`));
2418
+ process.exit(1);
2419
+ }
2420
2420
 
2421
- try {
2422
- currentPackageData = fs.readFileSync(currentPackagePath);
2423
- }
2424
- catch (ex) {
2425
- console.log($chalk.red(`\nUnable to retrieve current package.json.`))
2426
- process.exit(1);
2427
- }
2421
+ try {
2422
+ currentPackageData = fs.readFileSync(currentPackagePath);
2423
+ }
2424
+ catch (ex) {
2425
+ console.log($chalk.red(`\nUnable to retrieve current package.json.`));
2426
+ process.exit(1);
2427
+ }
2428
2428
 
2429
2429
 
2430
- const rData = JSON.parse(retrievedPackageData);
2431
- let cData = JSON.parse(currentPackageData);
2430
+ const rData = JSON.parse(retrievedPackageData);
2431
+ let cData = JSON.parse(currentPackageData);
2432
2432
 
2433
- // now keep current package.json, but replace devDependencies and dependencies.
2434
- const sDep = JSON.stringify(rData.dependencies);
2435
- const sDevDep = JSON.stringify(rData.devDependencies);
2433
+ // now keep current package.json, but replace devDependencies and dependencies.
2434
+ const sDep = JSON.stringify(rData.dependencies);
2435
+ const sDevDep = JSON.stringify(rData.devDependencies);
2436
2436
 
2437
- const sCurDep = JSON.stringify(cData.dependencies);
2438
- const sCurDevDep = JSON.stringify(cData.devDependencies);
2437
+ const sCurDep = JSON.stringify(cData.dependencies);
2438
+ const sCurDevDep = JSON.stringify(cData.devDependencies);
2439
2439
 
2440
- // any changes, update haveDependencyDifference variable
2441
- if (sDep != sCurDep) {
2442
- haveDependencyDifference = true;
2443
- }
2444
- else if (sDevDep != sCurDevDep) {
2445
- haveDependencyDifference = true;
2446
- }
2440
+ // any changes, update haveDependencyDifference variable
2441
+ if (sDep != sCurDep) {
2442
+ haveDependencyDifference = true;
2443
+ }
2444
+ else if (sDevDep != sCurDevDep) {
2445
+ haveDependencyDifference = true;
2446
+ }
2447
2447
 
2448
2448
 
2449
- cData.dependencies = JSON.parse(sDep);
2450
- cData.devDependencies = JSON.parse(sDevDep);
2449
+ cData.dependencies = JSON.parse(sDep);
2450
+ cData.devDependencies = JSON.parse(sDevDep);
2451
2451
 
2452
- // we can't loose devDep that is part of install, so go get the template mustache and push
2453
- // those in, replacing any changes there, but allowing additional, an keeping it updated
2454
- // so won't loose new function if an old archive
2455
- const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
2456
- const templateDir = join(initDir, "template");
2457
- const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
2458
- let retrievedTemplateData;
2459
- try {
2460
- retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
2461
- }
2462
- catch (ex) {
2463
- console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
2464
- process.exit(1);
2465
- }
2466
- const tData = JSON.parse(retrievedTemplateData);
2467
- const tDevDep = tData.devDependencies;
2468
- for (const [key, value] of Object.entries(tDevDep)) {
2469
- cData.devDependencies[key] = value;
2470
- }
2452
+ // we can't loose devDep that is part of install, so go get the template mustache and push
2453
+ // those in, replacing any changes there, but allowing additional, an keeping it updated
2454
+ // so won't loose new function if an old archive
2455
+ const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
2456
+ const templateDir = join(initDir, "template");
2457
+ const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
2458
+ let retrievedTemplateData;
2459
+ try {
2460
+ retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
2461
+ }
2462
+ catch (ex) {
2463
+ console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`));
2464
+ process.exit(1);
2465
+ }
2466
+ const tData = JSON.parse(retrievedTemplateData);
2467
+ const tDevDep = tData.devDependencies;
2468
+ for (const [key, value] of Object.entries(tDevDep)) {
2469
+ cData.devDependencies[key] = value;
2470
+ }
2471
2471
 
2472
2472
 
2473
- // update current package json file
2474
- fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',flag:'w' });
2473
+ // update current package json file
2474
+ fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8', flag: 'w' });
2475
2475
 
2476
2476
 
2477
- }
2477
+ };
2478
2478
 
2479
2479
  export const getHaveDependencyDifference = () => {
2480
- if (showDebug) addDebugLog("getHaveDependencyDifference", ``, "");
2480
+ if (showDebug) addDebugLog("getHaveDependencyDifference", ``, "");
2481
2481
  return haveDependencyDifference;
2482
- }
2482
+ };
2483
2483
 
2484
2484
  export const restoreFromArchive = async (fileName, orgLibName, version) => {
2485
- if (showDebug) addDebugLog("restoreFromArchive", `fileName: ${fileName}, orgLibName: ${orgLibName}, version: ${version}`, "");
2485
+ if (showDebug) addDebugLog("restoreFromArchive", `fileName: ${fileName}, orgLibName: ${orgLibName}, version: ${version}`, "");
2486
2486
  const currentDirectory = process.cwd();
2487
2487
  const tempDirectory = join(currentDirectory, TEMP_PATH);
2488
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
2488
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
2489
2489
  const archFileName = join(archiveDirectory, fileName);
2490
2490
 
2491
2491
 
2492
2492
  if (!fs.existsSync(archiveDirectory)) {
2493
- throw new Error (`Archive ${orgLibName}/${version} does NOT exist.`);
2493
+ throw new Error(`Archive ${orgLibName}/${version} does NOT exist.`);
2494
2494
  }
2495
2495
 
2496
2496
  await unZipFromArchive(archFileName);
2497
2497
 
2498
- const tempPackagePath = join (tempDirectory, PACKAGE_JSON_FILENAME);
2498
+ const tempPackagePath = join(tempDirectory, PACKAGE_JSON_FILENAME);
2499
2499
  const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
2500
2500
  const tempDirectoryComponents = join(tempDirectory, "src");
2501
2501
  const currentComponentsPath = join(currentDirectory, "src");
@@ -2512,11 +2512,11 @@ if (showDebug) addDebugLog("restoreFromArchive", `fileName: ${fileName}, orgLibN
2512
2512
  await restoreDependenciesFromPackage();
2513
2513
 
2514
2514
  // remove current components
2515
- fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
2515
+ fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
2516
2516
 
2517
2517
  if (fs.existsSync(currentComponentsPath)) {
2518
2518
  // try another round of rm
2519
- fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
2519
+ fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
2520
2520
 
2521
2521
  if (fs.existsSync(currentComponentsPath)) {
2522
2522
  // still an issue
@@ -2532,29 +2532,29 @@ if (showDebug) addDebugLog("restoreFromArchive", `fileName: ${fileName}, orgLibN
2532
2532
  // copy temp src/components
2533
2533
  if (fs.existsSync(tempDirectoryComponents)) {
2534
2534
 
2535
- fs.cpSync(tempDirectoryComponents, currentComponentsPath, { recursive: true, force: true });
2536
- }
2537
- else {
2538
- // nothing was archived (no src/components)
2539
- // so make a src/components if doesn't exist
2540
- if (!fs.existsSync(currentComponentsPath)) {
2541
- fs.mkdirSync(currentComponentsPath, { "recursive" : true});
2542
- }
2543
- }
2535
+ fs.cpSync(tempDirectoryComponents, currentComponentsPath, { recursive: true, force: true });
2536
+ }
2537
+ else {
2538
+ // nothing was archived (no src/components)
2539
+ // so make a src/components if doesn't exist
2540
+ if (!fs.existsSync(currentComponentsPath)) {
2541
+ fs.mkdirSync(currentComponentsPath, { "recursive": true });
2542
+ }
2543
+ }
2544
2544
 
2545
2545
 
2546
- // remove temp (windows not working well with "sync", can be async, since as long as deleted, fine)
2547
- fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 }, () => {});
2546
+ // remove temp (windows not working well with "sync", can be async, since as long as deleted, fine)
2547
+ fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 }, () => { });
2548
2548
 
2549
2549
  };
2550
2550
 
2551
2551
  export const clearSrcComponentsDirectory = async () => {
2552
- if (showDebug) addDebugLog("clearSrcComponentsDirectory", ``, "");
2552
+ if (showDebug) addDebugLog("clearSrcComponentsDirectory", ``, "");
2553
2553
  const currentDirectory = process.cwd();
2554
2554
  const currentComponentsPath = join(currentDirectory, "src", "components");
2555
2555
 
2556
2556
  // remove current components
2557
- fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
2557
+ fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
2558
2558
 
2559
2559
  // create blank src
2560
2560
  fs.mkdirSync(currentComponentsPath, { recursive: true });
@@ -2568,23 +2568,23 @@ export const isHiddenFile = (fileName) => {
2568
2568
  return false;
2569
2569
  };
2570
2570
 
2571
- export const getCurrentOrgLib = () =>{
2571
+ export const getCurrentOrgLib = () => {
2572
2572
  return defaultConfigs.currentOrgLib;
2573
2573
  };
2574
2574
 
2575
2575
  export const hasArchives = async () => {
2576
- if (showDebug) addDebugLog("hasArchives", "call", "");
2576
+ if (showDebug) addDebugLog("hasArchives", "call", "");
2577
2577
  const currentDirectory = process.cwd();
2578
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
2578
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH);
2579
2579
  const hasArc = fs.existsSync(archiveDirectory);
2580
- if (showDebug) addDebugLog("hasArchives", `${hasArc}`, "");
2580
+ if (showDebug) addDebugLog("hasArchives", `${hasArc}`, "");
2581
2581
  return hasArc;
2582
2582
  };
2583
2583
 
2584
2584
  export const deleteArchives = async () => {
2585
- if (showDebug) addDebugLog("deleteArchives", ``, "");
2585
+ if (showDebug) addDebugLog("deleteArchives", ``, "");
2586
2586
  const currentDirectory = process.cwd();
2587
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
2587
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH);
2588
2588
  const hasArc = fs.existsSync(archiveDirectory);
2589
2589
 
2590
2590
  if (hasArc) {
@@ -2593,11 +2593,11 @@ if (showDebug) addDebugLog("deleteArchives", ``, "");
2593
2593
  } catch (err) {
2594
2594
  }
2595
2595
  }
2596
- }
2596
+ };
2597
2597
 
2598
2598
  export const checkLibraryAndArchives = async () => {
2599
- if (showDebug) addDebugLog("checkLibraryAndArchives", ``, "");
2600
- const isLibraryBased = getLibraryBased();
2599
+ if (showDebug) addDebugLog("checkLibraryAndArchives", ``, "");
2600
+ const isLibraryBased = getLibraryBased();
2601
2601
  const hasArch = await hasArchives();
2602
2602
 
2603
2603
  if (isLibraryBased && !hasArch) {
@@ -2608,7 +2608,7 @@ if (showDebug) addDebugLog("checkLibraryAndArchives", ``, "");
2608
2608
  };
2609
2609
 
2610
2610
  export const hasLibraryAndVersion = async (libraryName, version, devBuild) => {
2611
- if (showDebug) addDebugLog("hasLibraryAndVersion", `libraryName: ${libraryName}, version: ${version}, devBuild: ${devBuild}`, "");
2611
+ if (showDebug) addDebugLog("hasLibraryAndVersion", `libraryName: ${libraryName}, version: ${version}, devBuild: ${devBuild}`, "");
2612
2612
 
2613
2613
  const orgLib = getConfigDefaults();
2614
2614
  const currentOrgLib = `${orgLib.organization}_${libraryName}`;
@@ -2628,9 +2628,9 @@ if (showDebug) addDebugLog("hasLibraryAndVersion", `libraryName: ${libraryName},
2628
2628
  };
2629
2629
 
2630
2630
  export const getLibraryArchiveDirectories = async (currentOrgLib = "") => {
2631
- if (showDebug) addDebugLog("getLibraryArchiveDirectories", "", "");
2631
+ if (showDebug) addDebugLog("getLibraryArchiveDirectories", "", "");
2632
2632
  const currentDirectory = process.cwd();
2633
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
2633
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH);
2634
2634
 
2635
2635
 
2636
2636
  if (!fs.existsSync(archiveDirectory)) {
@@ -2638,18 +2638,18 @@ if (showDebug) addDebugLog("getLibraryArchiveDirectories", "", "");
2638
2638
  }
2639
2639
 
2640
2640
  return fs
2641
- .readdirSync(archiveDirectory, { withFileTypes: true })
2642
- .filter(dirent => dirent.isDirectory() && (dirent.name != currentOrgLib) )
2643
- .map(dirent => dirent.name);
2641
+ .readdirSync(archiveDirectory, { withFileTypes: true })
2642
+ .filter(dirent => dirent.isDirectory() && (dirent.name != currentOrgLib))
2643
+ .map(dirent => dirent.name);
2644
2644
  };
2645
2645
 
2646
2646
 
2647
2647
 
2648
2648
  export const getLibraryArchivesVersions = async (orgLibName, currentVersion) => {
2649
- if (showDebug) addDebugLog("getLibraryArchivesVersions", `orgLibName: ${orgLibName}`, "");
2649
+ if (showDebug) addDebugLog("getLibraryArchivesVersions", `orgLibName: ${orgLibName}`, "");
2650
2650
 
2651
2651
  const currentDirectory = process.cwd();
2652
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`);
2652
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${orgLibName}`);
2653
2653
 
2654
2654
  if (!fs.existsSync(archiveDirectory)) {
2655
2655
  return [];
@@ -2657,17 +2657,17 @@ if (showDebug) addDebugLog("getLibraryArchivesVersions", `orgLibName: ${orgLibNa
2657
2657
 
2658
2658
  return fs
2659
2659
  .readdirSync(archiveDirectory, { withFileTypes: true })
2660
- .filter(dirent => dirent.isDirectory() && dirent.name != currentVersion )
2660
+ .filter(dirent => dirent.isDirectory() && dirent.name != currentVersion)
2661
2661
  .map(dirent => dirent.name);
2662
2662
 
2663
2663
 
2664
2664
 
2665
2665
  };
2666
2666
 
2667
- export const deleteLocalArchiveLibrary = async(libraryName) => {
2668
- if (showDebug) addDebugLog("deleteLocalArchiveLibrary", `libraryName: ${libraryName}`, "");
2667
+ export const deleteLocalArchiveLibrary = async (libraryName) => {
2668
+ if (showDebug) addDebugLog("deleteLocalArchiveLibrary", `libraryName: ${libraryName}`, "");
2669
2669
  const currentDirectory = process.cwd();
2670
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, libraryName);
2670
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, libraryName);
2671
2671
 
2672
2672
  try {
2673
2673
  fs.rmSync(archiveDirectory, { recursive: true });
@@ -2680,17 +2680,17 @@ if (showDebug) addDebugLog("deleteLocalArchiveLibrary", `libraryName: ${libraryN
2680
2680
  // check if no other libraries, the remove /store
2681
2681
  const archList = getLibraryArchiveDirectories();
2682
2682
  if (archList.length === 0) {
2683
- const archPath = join (currentDirectory, ARCHIVES_PATH);
2683
+ const archPath = join(currentDirectory, ARCHIVES_PATH);
2684
2684
 
2685
- fs.rmSync(archPath, { recursive : true});
2685
+ fs.rmSync(archPath, { recursive: true });
2686
2686
  }
2687
2687
 
2688
- }
2688
+ };
2689
2689
 
2690
- export const deleteLocalArchiveLibraryVersion = async(libraryName, version) => {
2691
- if (showDebug) addDebugLog("deleteLocalArchiveLibraryVersion", `libraryName: ${libraryName}, version: ${version}`, "");
2690
+ export const deleteLocalArchiveLibraryVersion = async (libraryName, version) => {
2691
+ if (showDebug) addDebugLog("deleteLocalArchiveLibraryVersion", `libraryName: ${libraryName}, version: ${version}`, "");
2692
2692
  const currentDirectory = process.cwd();
2693
- const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, libraryName, version);
2693
+ const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, libraryName, version);
2694
2694
 
2695
2695
  try {
2696
2696
  fs.rmSync(archiveDirectory, { recursive: true });
@@ -2703,45 +2703,45 @@ if (showDebug) addDebugLog("deleteLocalArchiveLibraryVersion", `libraryName: ${l
2703
2703
  // throw new Error(`No such file ${libraryName}/${version}`);
2704
2704
  }
2705
2705
 
2706
- }
2706
+ };
2707
2707
 
2708
- export const cleanUpTemp = async() => {
2709
- if (showDebug) addDebugLog("cleanUpTemp", ``, "");
2708
+ export const cleanUpTemp = async () => {
2709
+ if (showDebug) addDebugLog("cleanUpTemp", ``, "");
2710
2710
  const currentDirectory = process.cwd();
2711
- const tempDirectory = join (currentDirectory, TEMP_PATH);
2711
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
2712
2712
 
2713
2713
  if (fs.existsSync(tempDirectory)) {
2714
2714
  fs.rmSync(tempDirectory, { recursive: true });
2715
2715
  }
2716
2716
 
2717
- }
2717
+ };
2718
2718
 
2719
2719
 
2720
- export const getJestFunctionalTestList = async(whichTests) => {
2721
- if (showDebug) addDebugLog("getJestFunctionalTestList", ``, "");
2720
+ export const getJestFunctionalTestList = async (whichTests) => {
2721
+ if (showDebug) addDebugLog("getJestFunctionalTestList", ``, "");
2722
2722
  const functionalDir = path.join(path.resolve(), JEST_TESTS_FUNCTIONAL_PATH);
2723
2723
  const libFilter = "localLib";
2724
2724
 
2725
2725
  switch (whichTests) {
2726
- case "ALL" :
2726
+ case "ALL":
2727
2727
  return fs
2728
- .readdirSync(functionalDir, { withFileTypes: true })
2729
- .filter(dirent => !dirent.isDirectory() )
2730
- .map(dirent => dirent.name);
2728
+ .readdirSync(functionalDir, { withFileTypes: true })
2729
+ .filter(dirent => !dirent.isDirectory())
2730
+ .map(dirent => dirent.name);
2731
2731
  case "Original":
2732
2732
  return fs
2733
- .readdirSync(functionalDir, { withFileTypes: true })
2734
- .filter(dirent => !dirent.isDirectory() && !dirent.name.startsWith(libFilter))
2735
- .map(dirent => dirent.name);
2736
- case "Library" :
2733
+ .readdirSync(functionalDir, { withFileTypes: true })
2734
+ .filter(dirent => !dirent.isDirectory() && !dirent.name.startsWith(libFilter))
2735
+ .map(dirent => dirent.name);
2736
+ case "Library":
2737
2737
  return fs
2738
- .readdirSync(functionalDir, { withFileTypes: true })
2739
- .filter(dirent => !dirent.isDirectory() && dirent.name.startsWith(libFilter))
2740
- .map(dirent => dirent.name);
2738
+ .readdirSync(functionalDir, { withFileTypes: true })
2739
+ .filter(dirent => !dirent.isDirectory() && dirent.name.startsWith(libFilter))
2740
+ .map(dirent => dirent.name);
2741
2741
  }
2742
2742
 
2743
2743
 
2744
- }
2744
+ };
2745
2745
 
2746
2746
  export const getSubTypeLabel = (type, subtype) => {
2747
2747
  const subTypeList = COMPONENT_SCHEMA.subtype;
@@ -2755,7 +2755,7 @@ export const getSubTypeLabel = (type, subtype) => {
2755
2755
  }
2756
2756
 
2757
2757
  return "";
2758
- }
2758
+ };
2759
2759
 
2760
2760
  export const getMaxComponentNameCount = () => {
2761
2761
  let count = MAX_RFT_CHARS;
@@ -2768,12 +2768,12 @@ export const getMaxComponentNameCount = () => {
2768
2768
 
2769
2769
  return count;
2770
2770
 
2771
- }
2771
+ };
2772
2772
 
2773
2773
  export const getMaxPrefixCount = () => {
2774
2774
  // TwoColumnDetails is 16 chars
2775
2775
  return (getMaxComponentNameCount() - 16);
2776
- }
2776
+ };
2777
2777
 
2778
2778
  export const isComponentValidLength = (componentKey) => {
2779
2779
  const configDef = getConfigDefaults();
@@ -2783,7 +2783,12 @@ export const isComponentValidLength = (componentKey) => {
2783
2783
  }
2784
2784
 
2785
2785
  return false;
2786
- }
2786
+ };
2787
+
2788
+ export const emptyDirSync = dir => (
2789
+ fs.rmSync(dir, { recursive: true, force: true }),
2790
+ fs.mkdirSync(dir, { recursive: true })
2791
+ );
2787
2792
 
2788
2793
  // init
2789
2794
  await forceDefaultsUpdate();