@pega/custom-dx-components 0.25.26 → 0.25.27

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.
@@ -20,6 +20,7 @@ import {
20
20
  checkAccessTokenExpiration,
21
21
  getConfigDefaults,
22
22
  getLibraryBased,
23
+ getLibraryBasedCL,
23
24
  unZipFromArchive,
24
25
  zipVersionAndArchive,
25
26
  getLibraryArchiveDirectories,
@@ -28,7 +29,8 @@ import {
28
29
  hasArchives,
29
30
  restoreFromArchive,
30
31
  forceDefaultsUpdate,
31
- getLibraryBasedCL
32
+ getUseInputConfig,
33
+ getInputConfigForCommand
32
34
  } from '../../util.js';
33
35
  import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
34
36
  import { getFilePathQuestions, getFileNameQuestions, updateTempArchive, updateSavedFilePath, getServerOrDirectoryQuestion, getLibraryArchiveQuestion, getServerLibraryArchives, getServerLibraryArchive } from './helper.js';
@@ -646,6 +648,7 @@ export default async options => {
646
648
  await checkPathAccess(pegaConfigJsonPath);
647
649
  const isLibraryBased = getLibraryBased();
648
650
  const isLibraryBasedCL = getLibraryBasedCL();
651
+ const useInputConfig = getUseInputConfig();
649
652
 
650
653
  if (!isLibraryBased) {
651
654
  console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
@@ -669,150 +672,187 @@ export default async options => {
669
672
  }
670
673
  else {
671
674
 
672
- inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
675
+ if (useInputConfig) {
676
+ const inputConfig = await getInputConfigForCommand("importLibVersion");
677
+ const filePath = inputConfig.fileLocation;
678
+ const fileName = inputConfig.fileName;
673
679
 
674
- let importFrom = "Directory";
675
680
 
676
- if (isLibraryBasedCL) {
677
- const localOrServerQuestion = await getServerOrDirectoryQuestion();
678
- const localOrServerAnswer = await inquirer.prompt(localOrServerQuestion);
679
- ({importFrom} = localOrServerAnswer);
681
+ console.log("");
682
+
683
+ const tasks = new Listr(
684
+ [
685
+ {
686
+ title: `Importing archive`,
687
+ task: async () => {
688
+ await importArch( filePath, fileName, hasArch);
689
+ }
690
+ }
691
+ ],
692
+ { concurrent: false, exitOnError: true }
693
+ );
694
+
695
+
696
+ await tasks.run().catch(err => {
697
+ console.log(chalk.bold.red(err.toString()));
698
+ process.exit(1);
699
+ });
700
+
701
+ console.log("");
702
+
703
+ // reapply to save if changed, because imported task.config may have overriden and we want
704
+ // to keep what was entered as the latest
705
+ await updateSavedFilePath(filePath);
706
+
680
707
  }
681
708
  else {
682
- importFrom = "Directory";
683
- }
709
+ inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
684
710
 
685
- if (importFrom === "Server") {
686
- await checkAccessTokenExpiration();
711
+ let importFrom = "Directory";
687
712
 
688
- let archiveVersions = [];
689
- try {
690
- archiveVersions = await getServerLibraryArchives();
713
+ if (isLibraryBasedCL) {
714
+ const localOrServerQuestion = await getServerOrDirectoryQuestion();
715
+ const localOrServerAnswer = await inquirer.prompt(localOrServerQuestion);
716
+ ({importFrom} = localOrServerAnswer);
691
717
  }
692
- catch (ex) {
693
- console.log(chalk.redBright(ex));
718
+ else {
719
+ importFrom = "Directory";
694
720
  }
695
721
 
722
+ if (importFrom === "Server") {
723
+ await checkAccessTokenExpiration();
696
724
 
697
- if (archiveVersions && archiveVersions.pxResults.length > 0) {
698
- // ALL option
725
+ let archiveVersions = [];
726
+ try {
727
+ archiveVersions = await getServerLibraryArchives();
728
+ }
729
+ catch (ex) {
730
+ console.log(chalk.redBright(ex));
731
+ }
699
732
 
700
- // to name value pairs
701
- const archiveResults = archiveVersions["pxResults"].map( archive => ( { value: `${archive.pyApplicationName},${archive.pyFileName},${archive.pyFileType},${archive.pyRuleSet},${archive.pyRuleSetVersion}`, name: `${archive.pyLabel}, ${archive.pyRuleSet}:${archive.pyRuleSetVersion}` }) );
702
733
 
734
+ if (archiveVersions && archiveVersions.pxResults.length > 0) {
735
+ // ALL option
703
736
 
704
- const versionQuestions = await getLibraryArchiveQuestion(archiveResults);
705
- const versionAnswers = await inquirer.prompt(versionQuestions);
737
+ // to name value pairs
738
+ const archiveResults = archiveVersions["pxResults"].map( archive => ( { value: `${archive.pyApplicationName},${archive.pyFileName},${archive.pyFileType},${archive.pyRuleSet},${archive.pyRuleSetVersion}`, name: `${archive.pyLabel}, ${archive.pyRuleSet}:${archive.pyRuleSetVersion}` }) );
706
739
 
707
- const {archiveData} = versionAnswers;
708
740
 
709
- if (archiveData != "") {
741
+ const versionQuestions = await getLibraryArchiveQuestion(archiveResults);
742
+ const versionAnswers = await inquirer.prompt(versionQuestions);
710
743
 
711
- const arArchData = archiveData.split(",");
712
- let fileName = `${arArchData[1]}.${arArchData[2]}`;
713
- let fileData;
744
+ const {archiveData} = versionAnswers;
714
745
 
715
- console.log("");
746
+ if (archiveData != "") {
716
747
 
717
- const tasks = new Listr(
718
- [
719
- {
720
- title: 'Fetching archive from server',
721
- task: async () => {
722
- // get archive
723
- fileData = await getServerLibraryArchive(arArchData[0],arArchData[1], arArchData[2], arArchData[3], arArchData[4]);
724
- }
725
- },
726
- {
727
- title: 'Saving archive in store',
728
- task: async () => {
729
- await writeZipBuffer(fileName, fileData.pyFileSource);
748
+ const arArchData = archiveData.split(",");
749
+ let fileName = `${arArchData[1]}.${arArchData[2]}`;
750
+ let fileData;
730
751
 
731
- // import archive
732
- const currentDirectory = process.cwd();
733
- const tempDirectory = join(currentDirectory, TEMP_PATH);
752
+ console.log("");
734
753
 
735
- await importArchServer( tempDirectory, fileName, hasArch);
754
+ const tasks = new Listr(
755
+ [
756
+ {
757
+ title: 'Fetching archive from server',
758
+ task: async () => {
759
+ // get archive
760
+ fileData = await getServerLibraryArchive(arArchData[0],arArchData[1], arArchData[2], arArchData[3], arArchData[4]);
761
+ }
762
+ },
763
+ {
764
+ title: 'Saving archive in store',
765
+ task: async () => {
766
+ await writeZipBuffer(fileName, fileData.pyFileSource);
767
+
768
+ // import archive
769
+ const currentDirectory = process.cwd();
770
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
771
+
772
+ await importArchServer( tempDirectory, fileName, hasArch);
773
+ }
736
774
  }
737
- }
738
- ],
739
- { concurrent: false, exitOnError: true }
740
- );
775
+ ],
776
+ { concurrent: false, exitOnError: true }
777
+ );
741
778
 
742
- await tasks.run().catch(err => {
743
- console.log(chalk.bold.red(err.toString()));
744
- process.exit(1);
745
- });
779
+ await tasks.run().catch(err => {
780
+ console.log(chalk.bold.red(err.toString()));
781
+ process.exit(1);
782
+ });
783
+
784
+ }
785
+
786
+ }
787
+ else {
788
+ // No library with that name
789
+ console.log(chalk.redBright(`No library archives exist on server.`));
790
+ process.exit(1);
746
791
 
747
792
  }
748
793
 
749
794
  }
750
795
  else {
751
- // No library with that name
752
- console.log(chalk.redBright(`No library archives exist on server.`));
753
- process.exit(1);
796
+ let filePathQuestions;
797
+ try {
798
+ filePathQuestions = await getFilePathQuestions();
799
+ }
800
+ catch (ex) {
801
+ process.exit(1);
802
+ }
754
803
 
755
- }
756
804
 
757
- }
758
- else {
759
- let filePathQuestions;
760
- try {
761
- filePathQuestions = await getFilePathQuestions();
762
- }
763
- catch (ex) {
764
- process.exit(1);
765
- }
805
+ let filePathAnswers;
806
+ try {
807
+ filePathAnswers = await inquirer.prompt(filePathQuestions);
808
+ }
809
+ catch(ex) {
810
+ process.exit(1);
811
+ }
766
812
 
813
+ const { filePath } = filePathAnswers;
814
+ const zipFileList = await getZipFileList(filePath);
767
815
 
768
- let filePathAnswers;
769
- try {
770
- filePathAnswers = await inquirer.prompt(filePathQuestions);
771
- }
772
- catch(ex) {
773
- process.exit(1);
774
- }
816
+ if (!zipFileList || zipFileList.length === 0) {
817
+ console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
818
+ process.exit();
819
+ }
775
820
 
776
- const { filePath } = filePathAnswers;
777
- const zipFileList = await getZipFileList(filePath);
821
+ await updateSavedFilePath(filePath);
778
822
 
779
- if (!zipFileList || zipFileList.length === 0) {
780
- console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
781
- process.exit();
782
- }
823
+ const fileNameQuestions = await getFileNameQuestions(zipFileList);
824
+ const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
825
+ const {fileName} = fileNameAnswers;
783
826
 
784
- await updateSavedFilePath(filePath);
785
827
 
786
- const fileNameQuestions = await getFileNameQuestions(zipFileList);
787
- const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
788
- const {fileName} = fileNameAnswers;
789
828
 
790
- console.log("");
829
+ console.log("");
791
830
 
792
- const tasks = new Listr(
793
- [
794
- {
795
- title: `Importing archive`,
796
- task: async () => {
797
- await importArch( filePath, fileName, hasArch);
831
+ const tasks = new Listr(
832
+ [
833
+ {
834
+ title: `Importing archive`,
835
+ task: async () => {
836
+ await importArch( filePath, fileName, hasArch);
837
+ }
798
838
  }
799
- }
800
- ],
801
- { concurrent: false, exitOnError: true }
802
- );
839
+ ],
840
+ { concurrent: false, exitOnError: true }
841
+ );
803
842
 
804
843
 
805
- await tasks.run().catch(err => {
806
- console.log(chalk.bold.red(err.toString()));
807
- process.exit(1);
808
- });
844
+ await tasks.run().catch(err => {
845
+ console.log(chalk.bold.red(err.toString()));
846
+ process.exit(1);
847
+ });
809
848
 
810
- console.log("");
849
+ console.log("");
811
850
 
812
851
 
813
- // reapply to save if changed, because imported task.config may have overriden and we want
814
- // to keep what was entered as the latest
815
- await updateSavedFilePath(filePath);
852
+ // reapply to save if changed, because imported task.config may have overriden and we want
853
+ // to keep what was entered as the latest
854
+ await updateSavedFilePath(filePath);
855
+ }
816
856
  }
817
857
 
818
858
 
@@ -820,6 +860,8 @@ export default async options => {
820
860
 
821
861
 
822
862
 
863
+
864
+
823
865
  }
824
866
 
825
867
  addDebugLog("importArchive", "END", "-");
@@ -14,7 +14,10 @@ import {
14
14
  addDebugLog,
15
15
  checkLibraryAndArchives,
16
16
  getConfigDefaults,
17
- getComponents
17
+ getComponents,
18
+ getUseInputConfig,
19
+ getInputConfigForCommand,
20
+ convertYNToBoolean
18
21
  } from '../../util.js';
19
22
  import { TASKS_CONFIG_JSON_FILENAME } from '../../constants.js';
20
23
  import { getFilePathQuestions, getFileNameQuestions, updateSavedFilePath } from './helper.js';
@@ -322,6 +325,7 @@ export default async options => {
322
325
  await showVersion();
323
326
  await checkLibraryAndArchives();
324
327
  await checkPathAccess(pegaConfigJsonPath);
328
+ const useInputConfig = getUseInputConfig();
325
329
 
326
330
  addDebugLog("importComponent", "", "+");
327
331
 
@@ -342,26 +346,41 @@ addDebugLog("importComponent", "", "+");
342
346
  }
343
347
  else {
344
348
 
345
- inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
349
+ let filePath;
350
+ let fileName;
346
351
 
347
- const filePathQuestions = await getFilePathQuestions();
348
- const filePathAnswers = await inquirer.prompt(filePathQuestions);
349
- const { filePath } = filePathAnswers;
352
+ if (useInputConfig) {
353
+ const inputConfig = await getInputConfigForCommand("importComponent");
354
+ filePath = inputConfig.fileLocation;
355
+ fileName = inputConfig.fileName;
350
356
 
351
- const compFileList = await getComponentList(filePath);
357
+ await importComp( filePath, fileName, false);
358
+ }
359
+ else {
360
+ inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
361
+
362
+ const filePathQuestions = await getFilePathQuestions();
363
+ const filePathAnswers = await inquirer.prompt(filePathQuestions);
364
+ const { filePath } = filePathAnswers;
365
+
366
+ const compFileList = await getComponentList(filePath);
367
+
368
+ if (!compFileList || compFileList.length === 0) {
369
+ console.log(chalk.red.bold(`No component files exist at path: ${filePath}`));
370
+ process.exit();
371
+ }
372
+
373
+ await updateSavedFilePath(filePath);
374
+
375
+ const fileNameQuestions = await getFileNameQuestions(compFileList);
376
+ const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
377
+ const {fileName} = fileNameAnswers;
352
378
 
353
- if (!compFileList || compFileList.length === 0) {
354
- console.log(chalk.red.bold(`No component files exist at path: ${filePath}`));
355
- process.exit();
379
+ await importComp( filePath, fileName, true);
356
380
  }
357
381
 
358
- await updateSavedFilePath(filePath);
359
382
 
360
- const fileNameQuestions = await getFileNameQuestions(compFileList);
361
- const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
362
- const {fileName} = fileNameAnswers;
363
383
 
364
- await importComp( filePath, fileName, true);
365
384
 
366
385
  }
367
386
 
@@ -107,7 +107,7 @@
107
107
  "@babel/preset-react": "^7.26.3",
108
108
  "@babel/preset-typescript": "^7.26.0",
109
109
  "@pega/configs": "^0.16.2",
110
- "@pega/custom-dx-components": "~0.25.26",
110
+ "@pega/custom-dx-components": "~0.25.27",
111
111
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
112
112
  "@storybook/addon-actions": "^7.6.19",
113
113
  "@storybook/addon-essentials": "^7.6.19",
@@ -11,6 +11,8 @@ import {
11
11
  getPegaServerConfig,
12
12
  showVersion,
13
13
  getLibraryBased,
14
+ getLibraryBasedCL,
15
+ getUseInputConfig,
14
16
  addDebugLog,
15
17
  updateServerConfigRuleSetAndVersion,
16
18
  checkLibraryAndArchives,
@@ -18,7 +20,7 @@ import {
18
20
  checkAccessTokenExpiration,
19
21
  checkJWTExpiration,
20
22
  getConfigDefaults,
21
- getLibraryBasedCL } from '../../util.js';
23
+ getInputConfigForCommand } from '../../util.js';
22
24
 
23
25
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
24
26
  import { default as buildLibrary } from '../build-lib/index.js';
@@ -34,6 +36,8 @@ export default async options => {
34
36
  await checkLibraryAndArchives();
35
37
  const isLibraryBased = getLibraryBased();
36
38
  const isLibraryBasedCL = getLibraryBasedCL();
39
+ const useInputConfig = getUseInputConfig();
40
+
37
41
 
38
42
  addDebugLog("publish", "", "+");
39
43
 
@@ -59,23 +63,42 @@ addDebugLog("publish", "", "+");
59
63
  console.log();
60
64
  console.log(`Publishing to server: ${chalk.green.bold(`${serverConfg.server}`)}`);
61
65
 
62
- const publishThisVersion = await inquirer.prompt([
63
- {
64
- name: 'confirmPublish',
65
- type: 'confirm',
66
- message: `Publish ${chalk.bold.green(`${orgLib.displayLibVersion}`)}, proceed ?`,
67
- default: true
66
+ if (useInputConfig) {
67
+ const inputConfig = await getInputConfigForCommand("publish");
68
+
69
+ // console.log("Input config: ");
70
+ // console.log(inputConfig);
71
+
72
+ if (inputConfig.okToPublish ) {
73
+ if (devBuild || (!devBuild && inputConfig.okToPublishPermanent)) {
74
+ okToPublish = true;
75
+ }
76
+
68
77
  }
69
- ]);
70
78
 
71
- if (publishThisVersion.confirmPublish) {
72
- okToPublish = true;
79
+
80
+ options.params.push(inputConfig.ruleSetName);
81
+ options.params.push(inputConfig.ruleSetVersion);
82
+
73
83
  }
84
+ else {
85
+ const publishThisVersion = await inquirer.prompt([
86
+ {
87
+ name: 'confirmPublish',
88
+ type: 'confirm',
89
+ message: `Publish ${chalk.bold.green(`${orgLib.displayLibVersion}`)}, proceed ?`,
90
+ default: true
91
+ }
92
+ ]);
74
93
 
94
+ if (publishThisVersion.confirmPublish) {
95
+ okToPublish = true;
96
+ }
75
97
 
98
+ }
76
99
 
77
100
  if (okToPublish) {
78
- if (options.params.length >= 8) {
101
+ if (options.params.length >= 8 || useInputConfig) {
79
102
  // const rulesetName = options.params[3];
80
103
  // const rulesetVersion = options.params[4]
81
104
 
@@ -128,6 +151,9 @@ addDebugLog("publish", "", "+");
128
151
 
129
152
  // end of V2 publishing
130
153
  return true;
154
+
155
+
156
+
131
157
  }
132
158
 
133
159
  // otherwise continue with original V1 publishig of individual components
@@ -11,6 +11,8 @@ import {
11
11
  setConfigDevBuild,
12
12
  updateConfigVersion,
13
13
  checkLibraryAndArchives,
14
+ getUseInputConfig,
15
+ getInputConfigForCommand,
14
16
  forceDefaultsUpdate } from '../../util.js';
15
17
  import { showCurrentStatus } from '../show-status/index.js';
16
18
 
@@ -124,6 +126,8 @@ addDebugLog("setPermanent", "", "");
124
126
 
125
127
  export default async options => {
126
128
  const isLibraryBased = getLibraryBased();
129
+ const useInputConfig = getUseInputConfig();
130
+
127
131
  if (!isLibraryBased) {
128
132
  console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
129
133
  process.exit();
@@ -135,8 +139,17 @@ addDebugLog("setPerm", "", "+");
135
139
 
136
140
  let inputYN = "";
137
141
 
138
- if (options.params.length >= 4) {
139
- inputYN = options.params[3];
142
+ if (useInputConfig) {
143
+ const inputConfig = await getInputConfigForCommand("setPermanent");
144
+ inputYN = inputConfig.makePermanent;
145
+
146
+ }
147
+ else {
148
+
149
+ if (options.params.length >= 4) {
150
+ inputYN = options.params[3];
151
+ }
152
+
140
153
  }
141
154
 
142
155
  // await showCurrentStatus();