@pega/custom-dx-components 0.242.10 → 0.242.11

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.10",
3
+ "version": "0.242.11",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -32,17 +32,17 @@ export const getInitProjectQuestions = () => {
32
32
  return 'Only alphanumeric values are allowed, starting with alphabets';
33
33
  }
34
34
  },
35
- {
36
- name: 'version',
37
- message: 'Version',
38
- default: '1.0.0',
39
- validate: value => {
40
- if (validateSemver(value)) {
41
- return true;
42
- }
43
- return 'Please provide semver compatible version e.g 0.0.1';
44
- }
45
- },
35
+ // {
36
+ // name: 'version',
37
+ // message: 'Version',
38
+ // default: '1.0.0',
39
+ // validate: value => {
40
+ // if (validateSemver(value)) {
41
+ // return true;
42
+ // }
43
+ // return 'Please provide semver compatible version e.g 0.0.1';
44
+ // }
45
+ // },
46
46
  {
47
47
  name: 'description',
48
48
  message: 'Description',
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "{{projectName}}",
3
- "version": "{{version}}",
4
3
  "description": "{{description}}",
5
4
  "organization": "{{organization}}",
6
5
  "main": "src/index.js",
@@ -60,7 +59,7 @@
60
59
  "@babel/preset-env": "^7.24.7",
61
60
  "@babel/preset-react": "^7.24.7",
62
61
  "@material-ui/core": "^4.12.4",
63
- "@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.10",
62
+ "@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.12",
64
63
  "@pega/cosmos-react-condition-builder": "7.0.0-build.6.0",
65
64
  "@pega/cosmos-react-core": "7.0.0-build.6.0",
66
65
  "@pega/cosmos-react-work": "7.0.0-build.6.0",
@@ -90,7 +89,7 @@
90
89
  "@babel/preset-env": "^7.24.7",
91
90
  "@babel/preset-react": "^7.24.7",
92
91
  "@pega/configs": "^0.6.0",
93
- "@pega/custom-dx-components": "0.242.10",
92
+ "@pega/custom-dx-components": "0.242.11",
94
93
  "@pega/pcore-pconnect-typedefs": "2.0.0",
95
94
  "@storybook/addon-actions": "^7.6.7",
96
95
  "@storybook/addon-essentials": "^7.6.19",
@@ -3,12 +3,33 @@ import chalk from 'chalk';
3
3
 
4
4
  import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased } from '../../util.js';
5
5
 
6
- import { listLib } from '@pega/constellation-dx-components-build-utils/index.js';
6
+ import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
7
7
 
8
8
  import { getListLibraryQuestions, getLibraryVersionQuestion, getOrgLib, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
9
9
 
10
10
  const isLibraryBased = await getLibraryBased();
11
11
 
12
+ export const getServerLibraryVersions = async(libraryName) => {
13
+ // server
14
+ const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
15
+
16
+ if (tokenAndStaticServer.C11NB2S === undefined) {
17
+ console.log(chalk.redBright("Need to authenticate, missing services token.\nDeleting a library requires authentication to acquire a token to delete."));
18
+ process.exit(1);
19
+ }
20
+
21
+
22
+ const oLibList = await listLibJSONResponse(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
23
+
24
+ let versionList = null;
25
+ if (oLibList && oLibList[libraryName]) {
26
+ versionList = oLibList[libraryName];
27
+ }
28
+
29
+ return versionList;
30
+
31
+ }
32
+
12
33
  export default async (options) => {
13
34
  if (!isLibraryBased) {
14
35
  console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
@@ -50,9 +71,6 @@ export default async (options) => {
50
71
 
51
72
 
52
73
  if (libVersions.length > 0) {
53
- // libVersions = libVersions.map((name) => ({ 'Version': name}));
54
- // console.log(chalk.bold.blueBright(`\nList of ${libraryName} library versions`));
55
- // console.table(libVersions, ['Version']);
56
74
  const libAnswers = await inquirer.prompt([
57
75
 
58
76
  {
@@ -82,16 +100,36 @@ export default async (options) => {
82
100
 
83
101
  }
84
102
  else {
85
- // server
86
- const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
103
+ const libVersions = await getServerLibraryVersions(libraryName);
104
+
105
+ if (libVersions) {
106
+ const keys = Object.keys(libVersions);
107
+ const libAnswers = await inquirer.prompt([
108
+
109
+ {
110
+ name: 'libVersion',
111
+ type: 'rawlist',
112
+ message: 'Enter version',
113
+ choices: keys
114
+ },
115
+ ]);
116
+
117
+ const selectedVersion = libAnswers.libVersion;
118
+
119
+ const versionData = libVersions[selectedVersion];
120
+ const data = JSON.parse(versionData);
121
+
122
+ let libData = data.map((component) => ( {'Component': component.name, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
123
+ console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components`));
124
+ console.table(libData, ['Component', 'Version', 'Type', 'Sub Type']);
87
125
 
88
- if (tokenAndStaticServer.C11NB2S === undefined) {
89
- console.log(chalk.redBright("Need to authenticate, missing services token.\nDeleting a library requires authentication to acquire a token to delete."));
90
- process.e
91
- exit(1);
92
126
  }
127
+ else {
128
+ // No library with that name
129
+ console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
130
+ process.exit(1);
93
131
 
94
- await listLib(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
132
+ }
95
133
 
96
134
  }
97
135
 
@@ -44,17 +44,11 @@ export const doesLibraryExist = async (libraryName, libraryVersion) => {
44
44
 
45
45
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
46
46
  const libList = await listLibJSONResponse(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
47
- const oList = JSON.parse(libList);
48
47
 
49
48
  let libVersionExists = false;
50
49
  let overrideExisting = false;
51
- if (oList && Object.keys(oList).length !== 0 ) {
52
- // need to parse data to find versions
53
- let versionList = oList[libraryName];
54
-
55
- if (versionList && versionList.includes(libraryVersion)) {
50
+ if (libList && libList[libraryName] && libList[libraryName][libraryVersion]) {
56
51
  libVersionExists = true;
57
- }
58
52
  }
59
53
 
60
54
  return libVersionExists;
@@ -181,8 +175,6 @@ export default async (options) => {
181
175
  });
182
176
  }
183
177
 
184
-
185
-
186
178
  if (libVersionExists) {
187
179
  if (overrideExisting) {
188
180
  console.log("\nDeleting existing library " + chalk.bold.yellow(`${libraryName}:${version}`) + " ...");
@@ -197,16 +189,11 @@ export default async (options) => {
197
189
  }
198
190
  }
199
191
 
200
-
201
-
202
192
  // need a timeout to give services time to delete the library
203
193
  setTimeout( function(){ publishNewLibraryAsync(libraryName, version, checkDeleted)}, 700 );
204
194
 
205
-
206
195
  }
207
196
 
208
-
209
-
210
197
  }
211
198
  else {
212
199
  console.log(chalk.bold.redBright(`No library versions in ${libraryName}`));