@pega/custom-dx-components 0.242.4 → 0.242.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.242.4",
3
+ "version": "0.242.5",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -2,7 +2,7 @@ import inquirer from 'inquirer';
2
2
 
3
3
  import chalk from 'chalk';
4
4
 
5
- import { showVersion, getC11NB2STokenAndStaticServer, getLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion } from '../../util.js';
5
+ import { showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deleteLocalLibrary, deleteLocalLibraryVersion } from '../../util.js';
6
6
 
7
7
 
8
8
  import { deleteLib } from '@pega/constellation-dx-components-build-utils/index.js';
@@ -44,7 +44,12 @@ export default async (options) => {
44
44
  if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
45
45
  // local
46
46
 
47
- let libVersions = await getLibraryVersions(libraryName);
47
+ let libVersions = [];
48
+ try {
49
+ libVersions = await getLocalLibraryVersions(libraryName);
50
+ }
51
+ catch (ex) {}
52
+
48
53
 
49
54
  if (libVersions.length > 0) {
50
55
  // ALL option
@@ -139,6 +139,11 @@ export default async options => {
139
139
  title: 'Installing tasks dependencies',
140
140
  task: () =>
141
141
  execPromise('npm i --force --production=false', { cwd: options.componentDirectory })
142
+ },
143
+ {
144
+ title: 'Updating',
145
+ task: () =>
146
+ execPromise('npm update', { cwd: options.componentDirectory })
142
147
  }
143
148
  /* {
144
149
  title: 'Installing quick run',
@@ -90,7 +90,7 @@
90
90
  "@babel/preset-env": "^7.23.3",
91
91
  "@babel/preset-react": "^7.23.3",
92
92
  "@pega/configs": "^0.6.0",
93
- "@pega/custom-dx-components": "0.242.4",
93
+ "@pega/custom-dx-components": "0.242.5",
94
94
  "@pega/pcore-pconnect-typedefs": "2.0.0",
95
95
  "@storybook/addon-actions": "^7.6.7",
96
96
  "@storybook/addon-essentials": "^7.6.7",
@@ -1,7 +1,7 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
 
4
- import {showVersion, getC11NB2STokenAndStaticServer, getLibraryVersions, getLibraryBased } from '../../util.js';
4
+ import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased } from '../../util.js';
5
5
 
6
6
  import { listLib } from '@pega/constellation-dx-components-build-utils/index.js';
7
7
 
@@ -41,12 +41,36 @@ export default async (options) => {
41
41
  if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
42
42
  // local
43
43
 
44
- let libVersions = await getLibraryVersions(libraryName);
44
+ let libVersions = [];
45
+ try {
46
+ libVersions = await getLocalLibraryVersions(libraryName);
47
+ }
48
+ catch (ex) {
49
+ }
50
+
45
51
 
46
52
  if (libVersions.length > 0) {
47
- libVersions = libVersions.map((name) => ({ 'Version': name}));
48
- console.log(chalk.bold.blueBright(`\nList of ${libraryName} library versions`));
49
- console.table(libVersions, ['Version']);
53
+ // libVersions = libVersions.map((name) => ({ 'Version': name}));
54
+ // console.log(chalk.bold.blueBright(`\nList of ${libraryName} library versions`));
55
+ // console.table(libVersions, ['Version']);
56
+ const libAnswers = await inquirer.prompt([
57
+
58
+ {
59
+ name: 'libVersion',
60
+ type: 'rawlist',
61
+ message: 'Enter version',
62
+ choices: libVersions
63
+ },
64
+ ]);
65
+
66
+ const selectedVersion = libAnswers.libVersion;
67
+
68
+ let data = await getLocalLibraryVersionData(libraryName, selectedVersion);
69
+ data = JSON.parse(data);
70
+
71
+ let libData = data.map((component) => ( {'Component': component.name, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
72
+ console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components`));
73
+ console.table(libData, ['Component', 'Version', 'Type', 'Sub Type']);
50
74
 
51
75
  }
52
76
  else {
@@ -4,7 +4,7 @@ import chalk from 'chalk';
4
4
 
5
5
  import validate from '../validator/index.js';
6
6
  import { lintComponent } from '../linter/index.js';
7
- import { getComponentDirectoryPath, showVersion, getC11NB2STokenAndStaticServer, getLibraryVersions, getLibraryBased } from '../../util.js';
7
+ import { getComponentDirectoryPath, showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deletePublishExtras } from '../../util.js';
8
8
 
9
9
  import { publishLib, listLibJSONResponse, deleteLibVersion } from '@pega/constellation-dx-components-build-utils/index.js';
10
10
 
@@ -83,9 +83,7 @@ export const publishNewLibraryAsync = async (libraryName, version, checkDeleted
83
83
  console.log(chalk.green(`Deleted..`));
84
84
  }
85
85
 
86
-
87
-
88
- console.log(chalk.green.bold(`Publishing Library ${libraryName}:${version} ... `));
86
+ console.log("\nPublishing Library " + chalk.bold.green(`${libraryName}:${version}`) + " to " + chalk.bold.green(`${tokenAndStaticServer.appStaticContentServer}`));
89
87
  publishLib(libraryName, version, tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
90
88
 
91
89
  }
@@ -130,7 +128,11 @@ export default async (options) => {
130
128
 
131
129
  console.log(`\nLibrary ${chalk.bold.green(libraryName)} `)
132
130
 
133
- const libVersions = await getLibraryVersions(libraryName);
131
+ let libVersions = [];
132
+ try {
133
+ libVersions = await getLocalLibraryVersions(libraryName);
134
+ }
135
+ catch (ex) {}
134
136
 
135
137
  if (libVersions.length > 0) {
136
138
  const versionQuestions = await getLibraryVersionQuestion(libVersions);
@@ -161,6 +163,8 @@ export default async (options) => {
161
163
  let overrideExisting = false;
162
164
  let checkDeleted = false;
163
165
 
166
+ await deletePublishExtras(libraryName, version);
167
+
164
168
  if (libVersionExists) {
165
169
  console.log("\nLibrary " + chalk.bold.yellow(`${libraryName}:${version}`) + " already exists.");
166
170
  const questions = [
@@ -193,6 +197,8 @@ export default async (options) => {
193
197
  }
194
198
  }
195
199
 
200
+
201
+
196
202
  // need a timeout to give services time to delete the library
197
203
  setTimeout( function(){ publishNewLibraryAsync(libraryName, version, checkDeleted)}, 700 );
198
204
 
package/src/util.js CHANGED
@@ -762,7 +762,7 @@ export const getC11NB2STokenAndStaticServer = async () => {
762
762
  return ({});
763
763
  }
764
764
 
765
- export const getLibraryVersions = async (libraryName) => {
765
+ export const getLocalLibraryVersions = async (libraryName) => {
766
766
  const currentDirectory = process.cwd();
767
767
 
768
768
  const directory = join(currentDirectory, libraryName);
@@ -772,18 +772,46 @@ export const getLibraryVersions = async (libraryName) => {
772
772
  .map(dirent => dirent.name);
773
773
  };
774
774
 
775
+ export const getLocalLibraryVersionData = async (libraryName, libraryVersion) => {
776
+ const currentDirectory = process.cwd();
777
+ const libDir = join(currentDirectory, libraryName, libraryVersion);
778
+ const libDataFile = join(libDir, 'componentsconfig.json');
779
+
780
+ let data = fs.readFileSync(libDataFile, { encoding: 'utf8' })
781
+
782
+ return data;
783
+ }
784
+
775
785
  export const deleteLocalLibrary = async (libraryName) => {
776
786
  const currentDirectory = process.cwd();
777
787
 
778
788
  const directory = join(currentDirectory, libraryName);
779
- fs.rmSync(directory, { recursive: true }, err => {
780
- if (err) {
781
- throw err;
782
- }
783
- else {
784
- console.log(`Library:${chalk.green.bold(libraryName)} is deleted from Local`);
785
- }
786
- });
789
+
790
+ // for some odd reason, it errors out with an error in "err", but it does delete
791
+ // all the contents. The try/catch then calls again to delete the top level
792
+ try {
793
+ fs.rmSync(directory, { recursive: true, force: true, maxRetries: 2 }, err => {
794
+ if (err) {
795
+ throw err;
796
+ }
797
+ else {
798
+ console.log(`Library:${chalk.green.bold(libraryName)} is deleted from Local`);
799
+ }
800
+ });
801
+ }
802
+ catch (ex) {
803
+ fs.rmSync(directory, { recursive: true, force: true, maxRetries: 2 }, err => {
804
+ if (err) {
805
+ throw err;
806
+ }
807
+ else {
808
+ console.log(`Library:${chalk.green.bold(libraryName)} is deleted from Local`);
809
+ }
810
+ });
811
+ }
812
+
813
+
814
+
787
815
  }
788
816
 
789
817
  export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) => {
@@ -799,3 +827,26 @@ export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) =>
799
827
  }
800
828
  });
801
829
  }
830
+
831
+ export const deletePublishExtras = async (libraryName, libraryVersion) => {
832
+ // this function will delete LibraryName.zip file, so new one created by publish
833
+ // check if .DS_store file exists in Library, if so delete it because causes issue with services
834
+
835
+ const currentDirectory = process.cwd();
836
+ const zipFile = libraryName.concat(".zip");
837
+
838
+ // delete zip file
839
+ const zipPath = join(currentDirectory, zipFile);
840
+ if (fs.existsSync(zipPath)) {
841
+ fs.rmSync(zipPath, { force: true });
842
+ }
843
+
844
+ // mac issue
845
+ const libVersion = join(currentDirectory, libraryName);
846
+ const dsStore = join(libVersion, ".DS_Store");
847
+ if (fs.existsSync(dsStore)) {
848
+ fs.rmSync(dsStore, { force: true });
849
+ }
850
+
851
+
852
+ }