@pega/custom-dx-components 25.1.18 → 25.1.20

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": "25.1.18",
3
+ "version": "25.1.20",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "keywords": [
@@ -26,7 +26,9 @@ import {
26
26
  getConfigDefaults,
27
27
  getSubTypeLabel,
28
28
  getMaxComponentNameCount,
29
- getStandaloneMaxComponentNameCount
29
+ getStandaloneMaxLibraryCount,
30
+ getStandaloneMaxComponentNameCount,
31
+ getStandaloneMaxLibraryFromPrefixCount
30
32
  } from '../../util.js';
31
33
  import { COMPONENT_SCHEMA, SHARED_FILE_NAMES } from '../../constants.js';
32
34
 
@@ -38,6 +40,7 @@ const copyComponentTemplate = async options => {
38
40
  });
39
41
  };
40
42
 
43
+
41
44
  const compileMustacheTemplates = async (
42
45
  componentDirectory,
43
46
  {
@@ -305,6 +308,7 @@ addDebugLog("create", "", "+");
305
308
  options
306
309
  );
307
310
  } else {
311
+ const framework = "Constellation";
308
312
  const componentDefaults = getConfigDefaults();
309
313
  const serverType = getServerType();
310
314
  const maxChars = isLibraryBased ? getMaxComponentNameCount() : getStandaloneMaxComponentNameCount();
@@ -400,10 +404,24 @@ addDebugLog("create", "", "+");
400
404
  return 'Please provide semver compatible version e.g 0.0.1';
401
405
  },
402
406
  when: () => !isLibraryBased
403
- },
407
+ }
408
+
409
+ ];
410
+
411
+ const answers = await inquirer.prompt(questions);
412
+ const maxLibChars = await getStandaloneMaxLibraryCount(answers.componentName);
413
+
414
+ const libQuestions = [
404
415
  {
405
416
  name: 'library',
406
- message: 'Enter library name (required)',
417
+ message: value => {
418
+ if (serverType === "launchpad") {
419
+ return `Enter library name (required)`;
420
+ }
421
+ else {
422
+ return `Enter library name (required) (${maxLibChars} max chars)`;
423
+ }
424
+ },
407
425
  default: componentDefaults.library,
408
426
  validate: value => {
409
427
  /* value should not be empty
@@ -412,6 +430,9 @@ addDebugLog("create", "", "+");
412
430
  Only case-insensitive alphanumeric values are allowed
413
431
  */
414
432
  if (value && !/^\d/.test(value) && value === sanitize(value)) {
433
+ if (value.length > maxLibChars && serverType != "launchpad") {
434
+ return `${value.length - maxLibChars} too many characters.`
435
+ }
415
436
  return true;
416
437
  }
417
438
  return 'Only alphanumeric values are allowed, starting with alphabets';
@@ -426,32 +447,22 @@ addDebugLog("create", "", "+");
426
447
  }
427
448
  ];
428
449
 
429
- await inquirer.prompt(questions).then(async answers => {
430
- const {
431
- componentName,
432
- componentLabel,
433
- library,
434
- version,
450
+ const libAnswers = await inquirer.prompt(libQuestions);
451
+
452
+ await validateCompile(
453
+ {
454
+ componentName : answers.componentName,
455
+ componentLabel : answers.componentLabel,
456
+ library : libAnswers.library,
457
+ version : answers.version,
435
458
  framework,
436
- type,
437
- subtype,
438
- description
439
- } = answers;
440
-
441
- await validateCompile(
442
- {
443
- componentName,
444
- componentLabel,
445
- library,
446
- version,
447
- framework,
448
- type,
449
- subtype,
450
- description
451
- },
452
- options
453
- );
454
- });
459
+ type : answers.type,
460
+ subtype : answers.subtype,
461
+ description : libAnswers.description
462
+ },
463
+ options
464
+ );
465
+
455
466
  }
456
467
 
457
468
  addDebugLog("create", "END", "-");
@@ -27,10 +27,13 @@ import { checkPathAccess, showVersion ,
27
27
  getConfigDefaults,
28
28
  getSubTypeLabel,
29
29
  getMaxPrefixCount,
30
- getStandaloneMaxPrefixCount
30
+ getStandaloneMaxPrefixCount,
31
+ getMaxComponentLibraryCount,
32
+ getStandaloneMaxLibraryFromPrefixCount
31
33
  } from '../../util.js';
32
34
 
33
35
  import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION, SHARED_FILE_NAMES } from '../../constants.js';
36
+ import lib from 'babel-loader';
34
37
 
35
38
  export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
36
39
 
@@ -418,7 +421,7 @@ addDebugLog("createAll", "", "+");
418
421
  return `Enter prefix label (${maxPrefixCount} max chars)`;
419
422
  }
420
423
  },
421
- validate: value => {
424
+ validate: value => {
422
425
  /* value should not be empty
423
426
  It should not start with a number
424
427
  Only case-insensitive alphanumeric values are allowed
@@ -444,10 +447,24 @@ addDebugLog("createAll", "", "+");
444
447
  return 'Please provide semver compatible version e.g 0.0.1';
445
448
  },
446
449
  when: () => !isLibraryBased
447
- },
448
- {
450
+ }
451
+
452
+ ];
453
+
454
+ const answers = await inquirer.prompt(questions);
455
+ const maxLibChars = await getStandaloneMaxLibraryFromPrefixCount(answers.prefix);
456
+
457
+ const libQuestions = [
458
+ {
449
459
  name: 'library',
450
- message: 'Enter library name (required)',
460
+ message: value => {
461
+ if (serverType === "launchpad") {
462
+ return `Enter library name (required)`;
463
+ }
464
+ else {
465
+ return `Enter library name (required) (${maxLibChars} max chars)`;
466
+ }
467
+ },
451
468
  default: componentDefaults.library,
452
469
  validate: (value) => {
453
470
  /* value should not be empty
@@ -456,6 +473,9 @@ addDebugLog("createAll", "", "+");
456
473
  Only case-insensitive alphanumeric values are allowed
457
474
  */
458
475
  if (value && !/^\d/.test(value) && value === sanitize(value)) {
476
+ if (value.length > maxLibChars && serverType != "launchpad") {
477
+ return `${value.length - maxLibChars} too many characters.`
478
+ }
459
479
  return true;
460
480
  }
461
481
  return 'Only alphanumeric values are allowed, starting with alphabets';
@@ -464,28 +484,28 @@ addDebugLog("createAll", "", "+");
464
484
  }
465
485
  ];
466
486
 
467
- await inquirer.prompt(questions).then(async (answers) => {
468
- ({library} = answers);
487
+ const libAnswers = await inquirer.prompt(libQuestions);
488
+ library = libAnswers.library;
469
489
 
470
- if (isLibraryBased) {
471
- // library comes from config
472
- const orgLib = getConfigDefaults();
473
- library = orgLib.library;
474
- }
490
+ if (isLibraryBased) {
491
+ // library comes from config
492
+ const orgLib = getConfigDefaults();
493
+ library = orgLib.library;
494
+ }
495
+
496
+ const { version } = answers;
497
+ let { prefix } = answers;
498
+ prefix = prefix.replace(/[^a-zA-Z0-9 ]/g, '');
499
+ await validateCompileAll(
500
+ {
501
+ prefix,
502
+ library,
503
+ version,
504
+ organization
505
+ },
506
+ options
507
+ );
475
508
 
476
- const { version } = answers;
477
- let { prefix } = answers;
478
- prefix = prefix.replace(/[^a-zA-Z0-9 ]/g, '');
479
- await validateCompileAll(
480
- {
481
- prefix,
482
- library,
483
- version,
484
- organization
485
- },
486
- options
487
- );
488
- });
489
509
  }
490
510
 
491
511
  addDebugLog("createAll", "END", "-");
@@ -25,13 +25,13 @@
25
25
  "delete": "custom-dx-components delete",
26
26
  "deleteAll": "custom-dx-components deleteAll",
27
27
  "importComponent": "custom-dx-components importComponent",
28
- "exportRC" : "custom-dx-components exportRC",
29
28
  "help": "custom-dx-components showHelp",
30
29
  "publish": "custom-dx-components publish",
31
30
  "_***Component_mode_only***": "Component only commands",
32
31
  "publishAll": "custom-dx-components publishAll",
33
32
  "promoteWebPack": "custom-dx-components promoteWebPack",
34
33
  "revertWebPack": "custom-dx-components revertWebPack",
34
+ "exportRC" : "custom-dx-components exportRC",
35
35
  "_***Library_mode_only***": "Library CL mode only commands",
36
36
  "createLib": "custom-dx-components createLibrary",
37
37
  "switchLib": "custom-dx-components switchLibrary",
@@ -108,7 +108,7 @@
108
108
  "@babel/preset-react": "^7.27.1",
109
109
  "@babel/preset-typescript": "^7.27.1",
110
110
  "@pega/configs": "^0.16.3",
111
- "@pega/custom-dx-components": "~25.1.18",
111
+ "@pega/custom-dx-components": "~25.1.20",
112
112
  "@pega/pcore-pconnect-typedefs": "^4.1.0",
113
113
  "@storybook/addon-actions": "^8.6.14",
114
114
  "@storybook/addon-essentials": "^8.6.14",
@@ -423,6 +423,20 @@ export default async (option) => {
423
423
  throw new Error (`${chalk.redBright(`Error: Invalid folder name or componentKey in config.json for component '${data.name}'.\n --> Component folder name: '${componentToValidate}' must match component key '${data.componentKey}'.\n --> NOTE: Values are case sensitve.`)}`);
424
424
  }
425
425
 
426
+ if (data.name !== componentToValidate) {
427
+ throw new Error (`${chalk.redBright(`Error: Invalid folder name or name in config.json for component '${data.name}'.\n --> Component folder name: '${componentToValidate}' must match name '${data.name}'.\n --> NOTE: Values are case sensitve.`)}`);
428
+ }
429
+
430
+ }
431
+ else {
432
+ if (data.componentKey !== componentToValidate) {
433
+ throw new Error (`${chalk.redBright(`Error: Invalid folder name or componentKey in config.json for component '${data.name}'.\n --> Component folder name: '${componentToValidate}' must match component key '${data.componentKey}'.\n --> NOTE: Values are case sensitve.`)}`);
434
+ }
435
+
436
+ if (data.name !== componentToValidate) {
437
+ throw new Error (`${chalk.redBright(`Error: Invalid folder name or name in config.json for component '${data.name}'.\n --> Component folder name: '${componentToValidate}' must match name '${data.name}'.\n --> NOTE: Values are case sensitve.`)}`);
438
+ }
439
+
426
440
  }
427
441
 
428
442
  console.log(`${chalk.bold.green(componentToValidate)} schema is valid`);
package/src/util.js CHANGED
@@ -963,7 +963,7 @@ if (showDebug) { addDebugLog("getPegaConfig", "END", "-"); }
963
963
  export const getPegaServerConfig = async (force = false) => {
964
964
  if (showDebug) addDebugLog("getPegaServerConfig", "", "+");
965
965
  if (!pegaConfig || force) {
966
- pegaConfig = await getPegaConfig();
966
+ pegaConfig = await getPegaConfig(force);
967
967
 
968
968
  if (getServerType() === "launchpad") {
969
969
 
@@ -1729,7 +1729,7 @@ if (showDebug) addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl
1729
1729
 
1730
1730
  export const updateC11NB2SForInfinity = async () => {
1731
1731
  if (showDebug) addDebugLog("updateC11NB2SForInfinity", "", "");
1732
- const serverConfig = await getPegaServerConfig();
1732
+ const serverConfig = await getPegaServerConfig(true);
1733
1733
  const { server } = serverConfig;
1734
1734
  const OAuthData = fs.readFileSync(TOKEN_PATH, 'utf8');
1735
1735
 
@@ -2670,10 +2670,14 @@ if (showDebug) addDebugLog("deleteArchives", ``, "");
2670
2670
  }
2671
2671
  }
2672
2672
 
2673
- export const checkLibraryAndArchives = async () => {
2673
+ export const checkLibraryAndArchives = async (checkArch = true) => {
2674
2674
  if (showDebug) addDebugLog("checkLibraryAndArchives", ``, "");
2675
2675
  const isLibraryBased = getLibraryBased();
2676
- const hasArch = await hasArchives();
2676
+ let hasArch = true;
2677
+ if (checkArch) {
2678
+ hasArch = await hasArchives();
2679
+
2680
+ }
2677
2681
 
2678
2682
  if (isLibraryBased && !hasArch) {
2679
2683
  console.log(chalk.yellow('\nPlease create/import a library before proceeding.'));
@@ -2835,7 +2839,20 @@ export const getSubTypeLabel = (type, subtype) => {
2835
2839
  export const getMaxComponentNameCount = () => {
2836
2840
  let count = MAX_RFT_CHARS;
2837
2841
  const configDef = getConfigDefaults();
2838
- const orgLibCount = configDef.currentOrgLib.length + 1;
2842
+ const orgLibCount = configDef.currentOrgLib.length + 1; // trailing underscore
2843
+ const versionCount = configDef.version.length - 2;
2844
+ const prefixCount = versionCount + 4;
2845
+
2846
+ count = count - orgLibCount - prefixCount - 9; // 9 chars for trailing hash
2847
+
2848
+ return count;
2849
+
2850
+ }
2851
+
2852
+ export const getMaxComponentLibraryCount = (componentName) => {
2853
+ let count = MAX_RFT_CHARS;
2854
+ const configDef = getConfigDefaults();
2855
+ const orgLibCount = configDef.organization.length + componentName.length + 2; // 2 underscores
2839
2856
  const versionCount = configDef.version.length - 2;
2840
2857
  const prefixCount = versionCount + 4;
2841
2858
 
@@ -2856,16 +2873,35 @@ export const getStandaloneMaxComponentNameCount = () => {
2856
2873
 
2857
2874
  }
2858
2875
 
2876
+ export const getStandaloneMaxLibraryCount = async(componentName) => {
2877
+
2878
+ let count = MAX_RFT_CHARS;
2879
+ const configDef = await getConfigDefaults();
2880
+ const orgComp = `${configDef.organization}__${componentName}`;
2881
+ const orgCompCount = orgComp.length + 1;
2882
+
2883
+ count = count - orgCompCount; // 9 chars for trailing hash
2884
+
2885
+ return count;
2886
+
2887
+ }
2888
+
2859
2889
  export const getMaxPrefixCount = () => {
2860
2890
  // TwoColumnDetails is 16 chars
2861
2891
  return (getMaxComponentNameCount() - 16);
2862
2892
  }
2863
2893
 
2894
+
2895
+
2864
2896
  export const getStandaloneMaxPrefixCount = () => {
2865
2897
  // TwoColumnDetails is 16 chars
2866
2898
  return (getStandaloneMaxComponentNameCount() - 16);
2867
2899
  }
2868
2900
 
2901
+ export const getStandaloneMaxLibraryFromPrefixCount = async(componentName) => {
2902
+ return (await getStandaloneMaxLibraryCount(componentName) - 16);
2903
+ }
2904
+
2869
2905
  export const isComponentValidLength = (componentKey) => {
2870
2906
  const serverType = getServerType();
2871
2907
  if (serverType === "launchpad") {