@pega/custom-dx-components 0.25.29 → 0.25.31

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.25.29",
3
+ "version": "0.25.31",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -138,7 +138,7 @@ addDebugLog("deletePublished", "END", "-");
138
138
  else {
139
139
  // No library with that name
140
140
  const serverConfig = await getPegaServerConfig();
141
- console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`));
141
+ console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${rulesetName}:${rulesetVersion}`)}`));
142
142
  addDebugLog("listPublished", "END", "-");
143
143
  process.exit(1);
144
144
 
@@ -24,13 +24,15 @@ import {
24
24
  unZipFromArchive,
25
25
  zipVersionAndArchive,
26
26
  getLibraryArchiveDirectories,
27
+ getHaveDependencyDifference,
27
28
  hasLibraryAndVersion,
28
29
  cleanUpTemp,
29
30
  hasArchives,
30
31
  restoreFromArchive,
31
32
  forceDefaultsUpdate,
32
33
  getUseInputConfig,
33
- getInputConfigForCommand
34
+ getInputConfigForCommand,
35
+ getPegaServerConfig
34
36
  } from '../../util.js';
35
37
  import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
36
38
  import { getFilePathQuestions, getFileNameQuestions, updateTempArchive, updateSavedFilePath, getServerOrDirectoryQuestion, getLibraryArchiveQuestion, getServerLibraryArchives, getServerLibraryArchive } from './helper.js';
@@ -238,6 +240,12 @@ export const importArch = async(filePath, fileName, hadArchive) => {
238
240
  addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
239
241
 
240
242
  const currentDirectory = process.cwd();
243
+
244
+ const storeDirectory = join (currentDirectory, ARCHIVES_PATH);
245
+ if (!fs.existsSync(storeDirectory)) {
246
+ fs.mkdirSync(storeDirectory);
247
+ }
248
+
241
249
  const tempDirectory = join(currentDirectory, TEMP_PATH);
242
250
 
243
251
 
@@ -403,10 +411,13 @@ export const importArch = async(filePath, fileName, hadArchive) => {
403
411
  await forceDefaultsUpdate();
404
412
  await showCurrentStatus();
405
413
 
406
- console.log('\n***************************************************************');
407
- console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
408
- console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
409
- console.log('***************************************************************\n');
414
+ if (getHaveDependencyDifference()) {
415
+ console.log('\n***************************************************************');
416
+ console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
417
+ console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
418
+ console.log('***************************************************************\n');
419
+ }
420
+
410
421
  }
411
422
 
412
423
 
@@ -416,6 +427,11 @@ export const importArchServer = async(filePath, fileName, hadArchive) => {
416
427
  addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
417
428
 
418
429
  const currentDirectory = process.cwd();
430
+ const storeDirectory = join (currentDirectory, ARCHIVES_PATH);
431
+ if (!fs.existsSync(storeDirectory)) {
432
+ fs.mkdirSync(storeDirectory);
433
+ }
434
+
419
435
  const tempDirectory = join(currentDirectory, TEMP_PATH);
420
436
 
421
437
  const zipFilePath = join(filePath, fileName);
@@ -593,10 +609,13 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
593
609
  await forceDefaultsUpdate();
594
610
  await showCurrentStatus();
595
611
 
596
- console.log('\n***************************************************************');
597
- console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
598
- console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
599
- console.log('***************************************************************\n');
612
+ if (getHaveDependencyDifference()) {
613
+ console.log('\n***************************************************************');
614
+ console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
615
+ console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
616
+ console.log('***************************************************************\n');
617
+ }
618
+
600
619
  }
601
620
 
602
621
 
@@ -632,6 +651,11 @@ export const writeZipBuffer = async(fileName, fileBuffer) => {
632
651
  const currentDirectory = process.cwd();
633
652
  const tempDirectory = join(currentDirectory, TEMP_PATH);
634
653
 
654
+ const storeDirectory = join (currentDirectory, ARCHIVES_PATH);
655
+ if (!fs.existsSync(storeDirectory)) {
656
+ fs.mkdirSync(storeDirectory);
657
+ }
658
+
635
659
  if (!fs.existsSync (tempDirectory)) {
636
660
  fs.mkdirSync(tempDirectory);
637
661
  }
@@ -733,6 +757,9 @@ export default async options => {
733
757
 
734
758
  if (archiveVersions && archiveVersions.pxResults.length > 0) {
735
759
  // ALL option
760
+ const defaultPegaServerConfig = await getPegaServerConfig();
761
+
762
+ console.log(`\nRetrieved archives from server ${chalk.bold.green(`${defaultPegaServerConfig.server}`)}.`)
736
763
 
737
764
  // to name value pairs
738
765
  const archiveResults = archiveVersions["pxResults"].map( archive => ( { value: `${archive.pyApplicationName},${archive.pyFileName},${archive.pyFileType},${archive.pyRuleSet},${archive.pyRuleSetVersion}`, name: `${archive.pyLabel}, ${archive.pyRuleSet}:${archive.pyRuleSetVersion}` }) );
@@ -107,7 +107,7 @@
107
107
  "@babel/preset-react": "^7.27.1",
108
108
  "@babel/preset-typescript": "^7.27.1",
109
109
  "@pega/configs": "^0.16.3",
110
- "@pega/custom-dx-components": "~0.25.29",
110
+ "@pega/custom-dx-components": "~0.25.31",
111
111
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
112
112
  "@storybook/addon-actions": "^8.6.12",
113
113
  "@storybook/addon-essentials": "^8.6.12",
@@ -162,7 +162,10 @@ addDebugLog("listPublished", "END", "-");
162
162
 
163
163
 
164
164
  const {app_name, app_version } = await getApplicationAndVersionFromToken();
165
- console.log(chalk.green(`\nList of libraries for Application: ${chalk.bold.green(`${app_name} - ${app_version}`)}\n`));
165
+ const serverConfig = await getPegaServerConfig();
166
+ console.log(`\nServer ${chalk.green.bold(`${serverConfig.server}`)}.`);
167
+ console.log(chalk.green(`List of libraries for Application: ${chalk.bold.green(`${app_name} - ${app_version}`)}`));
168
+ console.log(`in ruleset: ${chalk.green.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`);
166
169
 
167
170
 
168
171
  const libAnswers = await inquirer.prompt([
@@ -84,9 +84,6 @@ addDebugLog("copyWebPack","", "");
84
84
  }
85
85
 
86
86
 
87
-
88
-
89
-
90
87
  }
91
88
 
92
89
 
@@ -119,6 +119,8 @@ addDebugLog("publish", "", "+");
119
119
  // };
120
120
  options.params.push(answers.rulesetName);
121
121
  options.params.push(answers.rulesetVersion);
122
+
123
+ updateServerConfigRuleSetAndVersion(answers.rulesetName, answers.rulesetVersion);
122
124
  }
123
125
  }
124
126
 
@@ -3,6 +3,7 @@ import chalk from 'chalk';
3
3
  import fetch from 'node-fetch';
4
4
  import { join } from 'path';
5
5
  import fs from 'fs';
6
+ import ora from 'ora';
6
7
 
7
8
  import { zipUnArchiveToTempAndReturnBuffer, constructCompleteUrl, getHttpsAgent, getPegaServerConfig, addDebugLog, getConfigDefaults } from '../../util.js';
8
9
 
@@ -157,6 +158,7 @@ export default async (orgLibName, selectedVersion) => {
157
158
 
158
159
  const archiveFileName = `${orgLibName}_${selectedVersion}.arch.zip`;
159
160
  const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${selectedVersion}`);
161
+ const defaultPegaConfig = await getPegaServerConfig();
160
162
  if (fs.existsSync(archiveDirectory)) {
161
163
  const archiveFile = join(archiveDirectory, archiveFileName);
162
164
 
@@ -166,16 +168,22 @@ export default async (orgLibName, selectedVersion) => {
166
168
 
167
169
  zipContent = zipContent.replaceAll('"', "");
168
170
 
171
+ let spinner;
169
172
  try {
173
+ console.log("");
174
+ spinner = ora(`Exporting to server ${defaultPegaConfig.server}. \n`).start();
170
175
  publishComponentLibraryArchiveToServer(content, zipContent, true )
171
176
  .then( () => {
177
+ spinner.stop();
172
178
  console.log(chalk.green.bold(`Success: Published Archive ${content.libraryName}/${content.version} to server.`));
173
179
  })
174
180
  .catch( (err) => {
181
+ spinner.stop();
175
182
  console.log(chalk.red.bold(err));
176
183
  })
177
184
  }
178
185
  catch (err) {
186
+ spinner.stop();
179
187
  console.log(chalk.bold.red(err.toString()));
180
188
  }
181
189
 
@@ -51,6 +51,10 @@ export const showHelpV1 = () => {
51
51
  console.log(`${chalk.cyan('npm run publishAll ')}\tpublish ALL components to server`);
52
52
 
53
53
  console.log("");
54
+ console.log(`\n${chalk.underline(`Notes`)}`);
55
+ console.log(`Cannot publish a component with prefix (Org_Lib) that matches a Rule-UI-ComponentLibrary (libraryModeCL) in same ruleset.`);
56
+
57
+ console.log("");
54
58
 
55
59
  };
56
60
 
@@ -77,8 +81,8 @@ export const showHelpV2 = (isCL) => {
77
81
  console.log(`\n${chalk.underline(`Library Versions`)}`);
78
82
  console.log(`${chalk.cyan('npm run createLibVersion')}\tcreate a new version within the current library`);
79
83
  console.log(`${chalk.cyan('npm run switchLibVersion')}\tswitch to different version within the current library`);
80
- console.log(`${chalk.cyan('npm run deleteLibVersion')}\tdelete current version, move to another version`);
81
- console.log(`${chalk.cyan('npm run restoreLibVersion ')}\trestore current version from local storage (current changes will be LOST)`);
84
+ console.log(`${chalk.cyan('npm run deleteLibVersion')}\tdelete current version, move to another version, delete is permanent`);
85
+ console.log(`${chalk.cyan('npm run restoreLibVersion ')}\trestores to current version from local storage (current changes will be LOST)`);
82
86
  console.log(`${chalk.cyan('npm run storeLibVersion ')}\tstore current version to local storage (must SAVE components before)`);
83
87
  if (isCL) {
84
88
  console.log(`${chalk.cyan('npm run exportLibVersion')}\texport current version as a zip file to a given local path or a server (must SAVE components before)`);
@@ -107,7 +111,10 @@ export const showHelpV2 = (isCL) => {
107
111
  console.log(`${chalk.cyan('npm run list ')}\t\tget list of components`);
108
112
  console.log(`${chalk.cyan('npm run delete ')}\t\tdelete a component`);
109
113
  console.log(`${chalk.cyan('npm run deleteAll ')}\t\tdelete ALL components`);
114
+
115
+ console.log("");
110
116
  console.log(`${chalk.cyan('npm run startStorybook')}\t\tstorybook components for testing`);
117
+ console.log(`${chalk.cyan('npm run test')}\t\t\trun component unit tests`);
111
118
  console.log("");
112
119
 
113
120
  console.log(`\n${chalk.underline(`Notes`)}`);
@@ -13,6 +13,7 @@ export const showCurrentStatus = async () => {
13
13
 
14
14
  const configDefaults = getConfigDefaults();
15
15
  const componentList = await getComponents();
16
+ const isLibraryBased = getLibraryBased();
16
17
  const isLibraryBasedCL = getLibraryBasedCL();
17
18
  const pegaServer = await getPegaServerConfig();
18
19
 
@@ -35,8 +36,13 @@ export const showCurrentStatus = async () => {
35
36
 
36
37
  console.log("");
37
38
 
38
- if (isLibraryBasedCL) {
39
+ if (isLibraryBased && !isLibraryBasedCL ) {
40
+ // no publishing for just libraryBased, that goes to App Static
41
+ }
42
+ else {
39
43
 
44
+ console.log(`\tPublish to:\t ${chalk.bold.green(`${pegaServer.server}`)} `);
45
+ // console.log("\t---------------------");
40
46
  console.log(`\tRuleSet:\t ${chalk.bold.green(`${pegaServer.rulesetName}`)}`);
41
47
  console.log(`\tRuleSet Version: ${chalk.bold.green(`${pegaServer.rulesetVersion}`)}`);
42
48
  console.log("");
@@ -28,6 +28,10 @@ describe(`createAll list deleteAll local: ${serverDir} - ${compType}` , () => {
28
28
  // make non libraryBased
29
29
  isLibraryBasedCL = false;
30
30
  tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
31
+
32
+ // delete if exists
33
+ delete tasksConfigJSON['libraryMode'];
34
+
31
35
  compType = isLibraryBasedCL ? "library" : "original";
32
36
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
33
37
 
@@ -27,6 +27,10 @@ describe(`create buildAll deleteAll local: ${serverDir} - ${compType}`, () => {
27
27
  // make non libraryBased
28
28
  isLibraryBasedCL = false;
29
29
  tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
30
+
31
+ // delete if exists
32
+ delete tasksConfigJSON['libraryMode'];
33
+
30
34
  compType = isLibraryBasedCL ? "library" : "original";
31
35
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
36
 
@@ -29,6 +29,10 @@ describe(`create library delete Library: ${serverDir} - ${compType}`, () => {
29
29
  // make non libraryBased
30
30
  isLibraryBasedCL = false;
31
31
  tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
32
+
33
+ // delete if exists
34
+ delete tasksConfigJSON['libraryMode'];
35
+
32
36
  compType = isLibraryBasedCL ? "library" : "original";
33
37
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
34
38
 
@@ -12,21 +12,26 @@ const packageJSONDir = path.resolve('../../..', 'package.json');
12
12
  const packageJSONData = fs.readFileSync(packageJSONDir, { encoding: 'utf8'});
13
13
  let packageJSON = JSON.parse(packageJSONData);
14
14
 
15
- let isLibraryBasedCL = tasksConfigJSON['librayModeCL'];
16
- const savedLibraryBased = isLibraryBasedCL;
15
+
16
+ let isLibraryBasedCL = tasksConfigJSON['libraryModeCL'];
17
+ const savedLibraryBasedCL = isLibraryBasedCL;
17
18
  const savedOrganization = packageJSON.organization;
18
19
 
19
20
  const serverType = tasksConfigJSON['server-config'].serverType;
20
21
  const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
21
22
  let compType = isLibraryBasedCL ? "library" : "original";
22
23
 
23
- describe(`createLib createAll list deleteLib: ${serverDir} - ${compType}`, () => {
24
+ describe(`create list delete: ${serverDir} - ${compType}`, () => {
24
25
 
25
26
  beforeAll( async() => {
26
27
 
27
28
  // make non libraryBased
28
29
  isLibraryBasedCL = false;
29
- tasksConfigJSON['librayModeCL'] = isLibraryBasedCL;
30
+ tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
31
+
32
+ // delete if exists
33
+ delete tasksConfigJSON['libraryMode'];
34
+
30
35
  compType = isLibraryBasedCL ? "library" : "original";
31
36
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
37
 
@@ -48,8 +53,8 @@ describe(`createLib createAll list deleteLib: ${serverDir} - ${compType}`, () =>
48
53
  afterAll( async() => {
49
54
 
50
55
  //restore
51
- isLibraryBasedCL = savedLibraryBased
52
- tasksConfigJSON['librayModeCL'] = isLibraryBasedCL;
56
+ isLibraryBasedCL = savedLibraryBasedCL;
57
+ tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
53
58
 
54
59
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
55
60
 
@@ -27,6 +27,10 @@ describe(`create publish deleteAll local: ${serverDir} - ${compType}`, () => {
27
27
  // make non libraryBased
28
28
  isLibraryBasedCL = false;
29
29
  tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
30
+
31
+ // delete if exists
32
+ delete tasksConfigJSON['libraryMode'];
33
+
30
34
  compType = isLibraryBasedCL ? "library" : "original";
31
35
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
36
 
@@ -27,6 +27,10 @@ describe(`create publish delete local: ${serverDir} - ${compType}`, () => {
27
27
  // make non libraryBased
28
28
  isLibraryBasedCL = false;
29
29
  tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
30
+
31
+ // delete if exists
32
+ delete tasksConfigJSON['libraryMode'];
33
+
30
34
  compType = isLibraryBasedCL ? "library" : "original";
31
35
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
36
 
@@ -27,6 +27,10 @@ describe(`create rename delete local: ${serverDir} - ${compType}`, () => {
27
27
  // make non libraryBased
28
28
  isLibraryBasedCL = false;
29
29
  tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
30
+
31
+ // delete if exists
32
+ delete tasksConfigJSON['libraryMode'];
33
+
30
34
  compType = isLibraryBasedCL ? "library" : "original";
31
35
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
36
 
@@ -152,7 +152,7 @@ describe(`createLib create validate deleteLib: ${serverDir} - ${compType}` , ()
152
152
  // // remove it
153
153
  // fs.rmdirSync(fileDir, { recursive: true });
154
154
  // }
155
- }, 10000);
155
+ }, 30000);
156
156
 
157
157
  it('npm run create Local details', async () => {
158
158
  const fileName = 'MyTestDetails';
@@ -184,7 +184,7 @@ describe(`createLib create validate deleteLib: ${serverDir} - ${compType}` , ()
184
184
  // // remove it
185
185
  // fs.rmdirSync(fileDir, { recursive: true });
186
186
  // }
187
- }, 10000);
187
+ }, 30000);
188
188
 
189
189
  it(`npm run validate Pega_DXIL_MyTestText - ${isLibraryBasedCL}`, async() => {
190
190
 
@@ -205,7 +205,7 @@ describe(`createLib create validate deleteLib: ${serverDir} - ${compType}` , ()
205
205
  expect(stdout).toContain('Pega_DXIL_MyTestPage schema is valid');
206
206
  expect(stdout).toContain('Pega_DXIL_MyTestDetails schema is valid');
207
207
 
208
- expect(stdout).toContain('Validation compile...');
208
+ expect(stdout).toContain('Validation via build library...');
209
209
  expect(stdout).toContain('Done.');
210
210
 
211
211
  }, 200000);
@@ -12,22 +12,23 @@ const packageJSONDir = path.resolve('../../..', 'package.json');
12
12
  const packageJSONData = fs.readFileSync(packageJSONDir, { encoding: 'utf8'});
13
13
  let packageJSON = JSON.parse(packageJSONData);
14
14
 
15
- let isLibraryBased = tasksConfigJSON['libraryMode'];
16
- const savedLibraryBased = isLibraryBased;
15
+ let isLibraryBasedCL = tasksConfigJSON['libraryModeCL'];
16
+ const savedLibraryBasedCL = isLibraryBasedCL;
17
+
17
18
  const savedOrganization = packageJSON.organization;
18
19
 
19
20
  const serverType = tasksConfigJSON['server-config'].serverType;
20
21
  const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
21
- let compType = isLibraryBased ? "library" : "original";
22
+ let compType = isLibraryBasedCL ? "library" : "original";
22
23
 
23
24
  describe(`promote revert webpack: ${serverDir} - ${compType}`, () => {
24
25
 
25
26
  beforeAll( async() => {
26
27
 
27
28
  // make non libraryBased
28
- isLibraryBased = false;
29
- tasksConfigJSON['libraryMode'] = isLibraryBased;
30
- compType = isLibraryBased ? "library" : "original";
29
+ isLibraryBasedCL = false;
30
+ tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
31
+ compType = isLibraryBasedCL ? "library" : "original";
31
32
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
33
 
33
34
  // make organzation Pega
@@ -48,8 +49,8 @@ describe(`promote revert webpack: ${serverDir} - ${compType}`, () => {
48
49
  afterAll( async() => {
49
50
 
50
51
  //restore
51
- isLibraryBased = savedLibraryBased
52
- tasksConfigJSON['libraryMode'] = isLibraryBased;
52
+ isLibraryBasedCL = savedLibraryBasedCL
53
+ tasksConfigJSON['libraryModeCL'] = isLibraryBasedCL;
53
54
 
54
55
  fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
55
56