@pega/custom-dx-components 25.1.17 → 25.1.19

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/README.md CHANGED
@@ -37,9 +37,9 @@ Ensure you have access to the following in your system:
37
37
 
38
38
  - Git version 2.30 or later
39
39
 
40
- - System node version >= 22.15.0
40
+ - System node version >= 24.4.1
41
41
 
42
- - System npm version 10.9.2
42
+ - System npm version 11.4.2
43
43
 
44
44
  ## Latest Documentation
45
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "25.1.17",
3
+ "version": "25.1.19",
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", "-");
@@ -37,9 +37,9 @@ Ensure you have access to the following in your system:
37
37
 
38
38
  - Git version 2.30 or later
39
39
 
40
- - System node version >= 22.15.0
40
+ - System node version >= 24.4.1
41
41
 
42
- - System npm version 10.9.2
42
+ - System npm version 11.4.2
43
43
 
44
44
  ## Latest Documentation
45
45
 
@@ -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.17",
111
+ "@pega/custom-dx-components": "~25.1.19",
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
@@ -1347,11 +1347,28 @@ export const showVersion = async () => {
1347
1347
 
1348
1348
  const nodeMajorVersion = parseInt(arNodeVersion[0]);
1349
1349
  const nodeMinorVersion = parseInt(arNodeVersion[1]);
1350
+ const nodePatchVersion = parseInt(arNodeVersion[2]);
1350
1351
 
1351
- if (nodeMajorVersion < 22 && nodeMinorVersion < 15 ) {
1352
+ if (nodeMajorVersion < 24) {
1352
1353
  console.log(
1353
1354
  chalk.redBright(
1354
- `DX Component Builder - requires node v22.15.0 or greater, current version: ${process.version}`
1355
+ `DX Component Builder - requires node v24.14.1 or greater, current version: ${process.version}`
1356
+ )
1357
+ );
1358
+ process.exit(1);
1359
+ }
1360
+ else if ( nodeMajorVersion == 24 && nodeMinorVersion < 4) {
1361
+ console.log(
1362
+ chalk.redBright(
1363
+ `DX Component Builder - requires node v24.14.1 or greater, current version: ${process.version}`
1364
+ )
1365
+ );
1366
+ process.exit(1);
1367
+ }
1368
+ else if (nodeMajorVersion == 24 && nodeMinorVersion == 4 && nodePatchVersion < 1 ) {
1369
+ console.log(
1370
+ chalk.redBright(
1371
+ `DX Component Builder - requires node v24.14.1 or greater, current version: ${process.version}`
1355
1372
  )
1356
1373
  );
1357
1374
  process.exit(1);
@@ -2653,10 +2670,14 @@ if (showDebug) addDebugLog("deleteArchives", ``, "");
2653
2670
  }
2654
2671
  }
2655
2672
 
2656
- export const checkLibraryAndArchives = async () => {
2673
+ export const checkLibraryAndArchives = async (checkArch = true) => {
2657
2674
  if (showDebug) addDebugLog("checkLibraryAndArchives", ``, "");
2658
2675
  const isLibraryBased = getLibraryBased();
2659
- const hasArch = await hasArchives();
2676
+ let hasArch = true;
2677
+ if (checkArch) {
2678
+ hasArch = await hasArchives();
2679
+
2680
+ }
2660
2681
 
2661
2682
  if (isLibraryBased && !hasArch) {
2662
2683
  console.log(chalk.yellow('\nPlease create/import a library before proceeding.'));
@@ -2818,7 +2839,20 @@ export const getSubTypeLabel = (type, subtype) => {
2818
2839
  export const getMaxComponentNameCount = () => {
2819
2840
  let count = MAX_RFT_CHARS;
2820
2841
  const configDef = getConfigDefaults();
2821
- 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
2822
2856
  const versionCount = configDef.version.length - 2;
2823
2857
  const prefixCount = versionCount + 4;
2824
2858
 
@@ -2839,16 +2873,35 @@ export const getStandaloneMaxComponentNameCount = () => {
2839
2873
 
2840
2874
  }
2841
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
+
2842
2889
  export const getMaxPrefixCount = () => {
2843
2890
  // TwoColumnDetails is 16 chars
2844
2891
  return (getMaxComponentNameCount() - 16);
2845
2892
  }
2846
2893
 
2894
+
2895
+
2847
2896
  export const getStandaloneMaxPrefixCount = () => {
2848
2897
  // TwoColumnDetails is 16 chars
2849
2898
  return (getStandaloneMaxComponentNameCount() - 16);
2850
2899
  }
2851
2900
 
2901
+ export const getStandaloneMaxLibraryFromPrefixCount = async(componentName) => {
2902
+ return (await getStandaloneMaxLibraryCount(componentName) - 16);
2903
+ }
2904
+
2852
2905
  export const isComponentValidLength = (componentKey) => {
2853
2906
  const serverType = getServerType();
2854
2907
  if (serverType === "launchpad") {