@pega/custom-dx-components 0.242.36 → 0.242.37

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.36",
3
+ "version": "0.242.37",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "@babel/plugin-transform-class-properties": "^7.23.3",
20
20
  "@babel/preset-react": "^7.23.3",
21
21
  "@pega/auth": "^0.1.6",
22
- "@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.17",
22
+ "@pega/constellation-dx-components-build-utils": "^1.0.1",
23
23
  "ajv": "^8.12.0",
24
24
  "ajv-keywords": "^5.1.0",
25
25
  "archiver": "^7.0.1",
@@ -75,9 +75,9 @@
75
75
  "author": "",
76
76
  "license": "Enter License",
77
77
  "dependencies": {
78
- "@pega/cosmos-react-condition-builder": "7.0.0-build.29.2",
79
- "@pega/cosmos-react-core": "7.0.0-build.29.2",
80
- "@pega/cosmos-react-work": "7.0.0-build.29.2",
78
+ "@pega/cosmos-react-condition-builder": "7.0.0-rc.2",
79
+ "@pega/cosmos-react-core": "7.0.0-rc.2",
80
+ "@pega/cosmos-react-work": "7.0.0-rc.2",
81
81
  "@pega/eslint-config": "^0.10.2",
82
82
  "@pega/tsconfig": "^0.10.2",
83
83
  "babel-loader": "^9.1.3",
@@ -100,7 +100,7 @@
100
100
  },
101
101
  "devDependencies": {
102
102
  "@pega/configs": "^0.6.0",
103
- "@pega/custom-dx-components": "0.242.36",
103
+ "@pega/custom-dx-components": "0.242.37",
104
104
  "@pega/pcore-pconnect-typedefs": "~3.0.0",
105
105
  "@storybook/addon-actions": "^7.6.7",
106
106
  "@storybook/addon-essentials": "^7.6.19",
@@ -92,6 +92,11 @@ addDebugLog("listLocalComponents", `sourceOfComponents: ${sourceOfComponents}`,
92
92
  builtOn = data[0].buildDate;
93
93
  }
94
94
 
95
+ if (data.length === 0) {
96
+ console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
97
+ process.exit();
98
+ }
99
+
95
100
  let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
96
101
  console.log(chalk.bold.blueBright(`\nList of ${defConfig.library}:${defConfig.buildVersion} components.`));
97
102
  console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
@@ -261,6 +266,9 @@ addDebugLog("displayServerComponents", "", "");
261
266
  /* empty */
262
267
  }
263
268
  }
269
+
270
+
271
+
264
272
  /**
265
273
  * TODO: Need to modify the components list mapping code to support Launchpad components
266
274
  */
@@ -28,10 +28,15 @@ addDebugLog("listLibrary", "", "+");
28
28
  const currnetVersion = compDef.buildVersion;
29
29
  let selectedVersion;
30
30
  let libVersions = [];
31
+ let currentOrStore = "";
31
32
 
32
33
  if (options.params.length >= 5) {
33
34
  libraryName = options.params[3];
34
35
  selectedVersion = options.params[4];
36
+ if (options.params.length >= 6) {
37
+ currentOrStore = options.params[5];
38
+ }
39
+
35
40
 
36
41
  try {
37
42
  libVersions = await getLibraryArchivesVersions(libraryName, "");
@@ -79,17 +84,21 @@ addDebugLog("listLibrary", "", "+");
79
84
 
80
85
  console.log("\nYou've selected the current working library/version.");
81
86
  console.log("You can list current components or the last store of this library/version.");
82
- const archAnswers = await inquirer.prompt([
83
- {
84
- name: 'currentOrStore',
85
- type: 'rawlist',
86
- message: 'Select current or store',
87
- default: "Current",
88
- choices: ["Current", "Store"]
89
- },
90
- ]);
91
87
 
92
- const currentOrStore = archAnswers.currentOrStore;
88
+ if (currentOrStore === "") {
89
+ const archAnswers = await inquirer.prompt([
90
+ {
91
+ name: 'currentOrStore',
92
+ type: 'rawlist',
93
+ message: 'Select current or store',
94
+ default: "Current",
95
+ choices: ["Current", "Store"]
96
+ },
97
+ ]);
98
+
99
+ currentOrStore = archAnswers.currentOrStore;
100
+ }
101
+
93
102
 
94
103
  if (currentOrStore === "Current") {
95
104
  data = await getComponentsConfigs();
@@ -114,6 +123,11 @@ addDebugLog("listLibrary", "", "+");
114
123
  }
115
124
  }
116
125
 
126
+ if (data.length === 0) {
127
+ console.log(chalk.bold.redBright(`No custom components in ${libraryName}/${selectedVersion}`));
128
+ process.exit();
129
+ }
130
+
117
131
  let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
118
132
  console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
119
133
  console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
@@ -79,6 +79,19 @@ describe(`createLib deleteLib: ${serverDir} - ${compType}` , () => {
79
79
 
80
80
  });
81
81
 
82
+ it('npm run list (need create lib)', async () => {
83
+ const script = 'npm run list --prefix ../../..';
84
+ const { stdout, stderr } = await exec(script);
85
+
86
+ expect(stderr).not.toBeNull();
87
+
88
+ // console.log(stdout);
89
+ expect(stdout).not.toBeNull();
90
+ expect(stdout).toContain('Please create a library before proceeding.');
91
+
92
+ // done();
93
+ }, 10000);
94
+
82
95
 
83
96
  it(`npm run createLib - ${isLibraryBased}`, async() => {
84
97
 
@@ -94,8 +107,47 @@ describe(`createLib deleteLib: ${serverDir} - ${compType}` , () => {
94
107
 
95
108
  }, 30000);
96
109
 
110
+ it('npm run list (nothing)', async () => {
111
+ const script = 'npm run list --prefix ../../..';
112
+ const { stdout, stderr } = await exec(script);
113
+
114
+ expect(stderr).not.toBeNull();
115
+
116
+ // console.log(stdout);
117
+ expect(stdout).not.toBeNull();
118
+ expect(stdout).toContain('No custom components in Local');
119
+
120
+ // done();
121
+ }, 10000);
122
+
123
+ it('npm run listLib (nothing current)', async () => {
124
+ const script = 'npm run listLib Pega_DXIL 0.0.1-dev Current --prefix ../../..';
125
+ const { stdout, stderr } = await exec(script);
126
+
127
+ expect(stderr).not.toBeNull();
128
+
129
+ // console.log(stdout);
130
+ expect(stdout).not.toBeNull();
131
+ expect(stdout).toContain('No custom components in Pega_DXIL/0.0.1-dev');
132
+
133
+ // done();
134
+ }, 10000);
135
+
136
+ it('npm run listLib (nothing store)', async () => {
137
+ const script = 'npm run listLib Pega_DXIL 0.0.1-dev Store --prefix ../../..';
138
+ const { stdout, stderr } = await exec(script);
139
+
140
+ expect(stderr).not.toBeNull();
141
+
142
+ // console.log(stdout);
143
+ expect(stdout).not.toBeNull();
144
+ expect(stdout).toContain('No custom components in Pega_DXIL/0.0.1-dev');
145
+
146
+ // done();
147
+ }, 10000);
148
+
97
149
 
98
- it(`npm run deleteLib- ${isLibraryBased}`, async() => {
150
+ it(`npm run deleteLib - ${isLibraryBased}`, async() => {
99
151
 
100
152
  const script = `npm run deleteLib Pega_DXIL 0.0.1-dev --prefix ../../..`;
101
153
  const { stdout, stderr } = await exec(script);
@@ -0,0 +1,217 @@
1
+ // import { exec } from 'child_process';
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+ const util = require('node:util');
5
+ const error = require('console');
6
+ const exec = util.promisify(require('node:child_process').exec);
7
+
8
+ const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
9
+ const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
10
+ let tasksConfigJSON = JSON.parse(tasksConfigData);
11
+
12
+ const packageJSONDir = path.resolve('../../..', 'package.json');
13
+ const packageJSONData = fs.readFileSync(packageJSONDir, { encoding: 'utf8'});
14
+ let packageJSON = JSON.parse(packageJSONData);
15
+
16
+ let isLibraryBased = tasksConfigJSON['libraryMode'];
17
+ const savedLibraryBased = isLibraryBased;
18
+ const savedOrganization = packageJSON.organization;
19
+
20
+ const serverType = tasksConfigJSON['server-config'].serverType;
21
+ const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
22
+ let compType = isLibraryBased ? "library" : "original";
23
+
24
+
25
+ describe(`createLib create validate deleteLib: ${serverDir} - ${compType}` , () => {
26
+
27
+ beforeAll( async() => {
28
+
29
+ // make libraryBased
30
+ isLibraryBased = true;
31
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
32
+ compType = isLibraryBased ? "library" : "original";
33
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
34
+
35
+ const storeDir = path.join(path.resolve('../../..'), 'store');
36
+ if (fs.existsSync(storeDir)) {
37
+ fs.rmSync(storeDir, { recursive: true, force: true, maxRetries: 2 });
38
+ }
39
+
40
+ // make organzation Pega
41
+ packageJSON.organization = "Pega";
42
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
43
+
44
+
45
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
46
+ if (fs.existsSync(componentsDir)) {
47
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
48
+ fs.mkdirSync(componentsDir, { recursive: true });
49
+ }
50
+
51
+ await new Promise((r) => setTimeout(r, 2000));
52
+
53
+
54
+ });
55
+
56
+ afterAll( async() => {
57
+
58
+ //restore
59
+ isLibraryBased = savedLibraryBased
60
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
61
+
62
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
63
+
64
+ // return organzation
65
+ packageJSON.organization = savedOrganization;
66
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
67
+
68
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
69
+ if (fs.existsSync(componentsDir)) {
70
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
71
+ fs.mkdirSync(componentsDir, { recursive: true });
72
+ }
73
+
74
+ await new Promise((r) => setTimeout(r, 2000));
75
+
76
+ });
77
+
78
+
79
+ it(`npm run createLib - ${isLibraryBased}`, async() => {
80
+
81
+ const script = `npm run createLib DXIL 0.0.1 N --prefix ../../..`;
82
+ const compConf = path.join("store", "Pega_DXIL","0.0.1-dev", "componentsconfig.json");
83
+
84
+ const { stdout, stderr } = await exec(script);
85
+ expect(stdout).toContain('Library Pega_DXIL/0.0.1-dev has been created!');
86
+
87
+ const doesExist = fs.existsSync(path.resolve('../../..', compConf));
88
+
89
+ expect(doesExist).toBeTruthy();
90
+
91
+ }, 30000);
92
+
93
+ it('npm run create Local text', async () => {
94
+ const fileName = 'MyTestText';
95
+ const newFileName = `Pega_DXIL_${fileName}`;
96
+ const script = `npm run create Field Text ${fileName} "My Test Text" 0.0.1 DXIL "" "My Test Text Description" Pega --prefix ../../..`;
97
+
98
+ const { stdout, stderr } = await exec(script);
99
+ // console.log(stdout);
100
+ expect(stdout).not.toBeNull();
101
+ expect(stderr).not.toBeNull();
102
+
103
+ // want message to contain component name
104
+ expect(stdout).toContain(newFileName);
105
+
106
+ // don't want message with already exists
107
+ expect(stdout).not.toContain('already exists');
108
+
109
+ // check to see file exists
110
+
111
+ // const fileDir = path.resolve(`src/components/${newFileName}`);
112
+ const createFile = path.resolve(
113
+ '../../..',
114
+ path.join(`src/components/${newFileName}`, 'index.tsx')
115
+ );
116
+ const doesExist = fs.existsSync(createFile);
117
+ expect(doesExist).toBeTruthy();
118
+
119
+ // if (doesExist) {
120
+ // // remove it
121
+ // fs.rmdirSync(fileDir, { recursive: true });
122
+ // }
123
+ }, 10000);
124
+
125
+ it('npm run create Local page', async () => {
126
+ const fileName = 'MyTestPage';
127
+ const newFileName = `Pega_DXIL_${fileName}`;
128
+ const script = `npm run create Widget PAGE ${fileName} "My Test Page" 0.0.1 DXIL "" "My Test Page Description" Pega --prefix ../../..`;
129
+
130
+ const { stdout, stderr } = await exec(script);
131
+ // console.log(stdout);
132
+ expect(stdout).not.toBeNull();
133
+ expect(stderr).not.toBeNull();
134
+
135
+ // want message to contain component name
136
+ expect(stdout).toContain(newFileName);
137
+
138
+ // don't want message with already exists
139
+ expect(stdout).not.toContain('already exists');
140
+
141
+ // check to see file exists
142
+
143
+ // const fileDir = path.resolve(`src/components/${newFileName}`);
144
+ const createFile = path.resolve(
145
+ '../../..',
146
+ path.join(`src/components/${newFileName}`, 'index.tsx')
147
+ );
148
+ const doesExist = fs.existsSync(createFile);
149
+ expect(doesExist).toBeTruthy();
150
+
151
+ // if (doesExist) {
152
+ // // remove it
153
+ // fs.rmdirSync(fileDir, { recursive: true });
154
+ // }
155
+ }, 10000);
156
+
157
+ it('npm run create Local details', async () => {
158
+ const fileName = 'MyTestDetails';
159
+ const newFileName = `Pega_DXIL_${fileName}`;
160
+ const script = `npm run create Template DETAILS ${fileName} "My Test Details" 0.0.1 DXIL "" "My Test Details Description" Pega --prefix ../../..`;
161
+
162
+ const { stdout, stderr } = await exec(script);
163
+ // console.log(stdout);
164
+ expect(stdout).not.toBeNull();
165
+ expect(stderr).not.toBeNull();
166
+
167
+ // want message to contain component name
168
+ expect(stdout).toContain(newFileName);
169
+
170
+ // don't want message with already exists
171
+ expect(stdout).not.toContain('already exists');
172
+
173
+ // check to see file exists
174
+
175
+ // const fileDir = path.resolve(`src/components/${newFileName}`);
176
+ const createFile = path.resolve(
177
+ '../../..',
178
+ path.join(`src/components/${newFileName}`, 'index.tsx')
179
+ );
180
+ const doesExist = fs.existsSync(createFile);
181
+ expect(doesExist).toBeTruthy();
182
+
183
+ // if (doesExist) {
184
+ // // remove it
185
+ // fs.rmdirSync(fileDir, { recursive: true });
186
+ // }
187
+ }, 10000);
188
+
189
+ it(`npm run valdidateAll - ${isLibraryBased}`, async() => {
190
+
191
+ const script = `npm run validateAll --prefix ../../..`;
192
+ const { stdout, stderr } = await exec(script);
193
+
194
+ expect(stdout).toContain('Pega_DXIL_MyTestText schema is valid');
195
+ expect(stdout).toContain('Pega_DXIL_MyTestPage schema is valid');
196
+ expect(stdout).toContain('Pega_DXIL_MyTestDetails schema is valid');
197
+
198
+ expect(stdout).toContain('Validation compile...');
199
+ expect(stdout).toContain('Done.');
200
+
201
+ }, 200000);
202
+
203
+
204
+ it(`npm run deleteLib - ${isLibraryBased}`, async() => {
205
+
206
+ const script = `npm run deleteLib Pega_DXIL 0.0.1-dev --prefix ../../..`;
207
+ const { stdout, stderr } = await exec(script);
208
+ expect(stdout).toContain('Pega_DXIL is deleted from Local.');
209
+
210
+ }, 30000);
211
+
212
+
213
+
214
+
215
+
216
+
217
+ });