@pega/custom-dx-components 0.25.42 → 0.25.44

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.42",
3
+ "version": "0.25.44",
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.27.1",
20
20
  "@babel/preset-react": "^7.27.1",
21
21
  "@pega/auth": "^0.2.24",
22
- "@pega/constellation-dx-components-build-utils": "^2.0.5",
22
+ "@pega/constellation-dx-components-build-utils": "^2.0.6",
23
23
  "@pega/inquirer-fuzzy-path": "^3.0.0",
24
24
  "ajv": "^8.17.1",
25
25
  "ajv-keywords": "^5.1.0",
@@ -119,7 +119,7 @@ const compileMustacheTemplates = async (
119
119
  TYPE: type,
120
120
  SUB_TYPE: JSON.stringify(mustacheSubType),
121
121
  SUB_TYPE_LABEL: subTypeLabel,
122
- DESCRIPTION: description,
122
+ DESCRIPTION: description || componentLabel,
123
123
  IS_TEMPLATE: isTemplate,
124
124
  IS_PICKLIST: isPicklist,
125
125
  IS_BOOLEAN: isBool,
@@ -190,6 +190,8 @@ const validateCompile = async (
190
190
  framework = "Constellation";
191
191
  }
192
192
 
193
+
194
+
193
195
  const orgLib = getConfigDefaults();
194
196
  if (isLibraryBased) {
195
197
  // library comes from config
@@ -440,6 +442,7 @@ addDebugLog("create", "", "+");
440
442
  description,
441
443
  allowedApplications
442
444
  } = answers;
445
+
443
446
  await validateCompile(
444
447
  {
445
448
  componentName,
@@ -32,7 +32,7 @@ import {
32
32
 
33
33
  console.log("");
34
34
  console.log(`Debugging Library: ${chalk.bold.green(`${confDef.currentOrgLib}/${confDef.version}`)}`);
35
- console.log(`Starting dev server: ${chalk.bold.green(`http://localhost:${confDef.devServerPort}`)}\n`);
35
+ console.log(`Starting dev server: ${chalk.bold.green(`http://localhost:${confDef.devServerPort}/`)}\n`);
36
36
  console.log(chalk.yellow(`Be sure you have your PegaInfinity Operator using the above URL.`));
37
37
  console.log("");
38
38
 
@@ -380,9 +380,25 @@ export const importArch = async(filePath, fileName, hadArchive) => {
380
380
 
381
381
 
382
382
  if (hadArchive) {
383
- console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
384
- console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.`);
385
- console.log("");
383
+
384
+ if (orgLibName === configDef.currentOrgLib && version === configDef.version) {
385
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
386
+ console.log(`It is the same library/version as your current source.`);
387
+ console.log(`--> You can retrieve and replace current source via ${chalk.green(`npm run restoreLibVersion`)}.`);
388
+ console.log("\n");
389
+ }
390
+ else if (orgLibName === configDef.currentOrgLib && version != configDef.version) {
391
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
392
+ console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLibVersion`)}.`);
393
+ console.log("\n");
394
+ }
395
+ else {
396
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
397
+ console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLib`)}.`);
398
+ console.log("\n");
399
+ }
400
+
401
+
386
402
  }
387
403
  else {
388
404
  const switchToFileName = `${orgLibName}_${version}.arch.zip`;
@@ -578,9 +594,23 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
578
594
 
579
595
 
580
596
  if (hadArchive) {
581
- console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
582
- console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.`);
583
- console.log("");
597
+ if (orgLibName === configDef.currentOrgLib && version === configDef.version) {
598
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
599
+ console.log(`It is the same library/version as your current source.`);
600
+ console.log(`--> You can retrieve and replace current source via ${chalk.green(`npm run restoreLibVersion`)}.`);
601
+ console.log("\n");
602
+ }
603
+ else if (orgLibName === configDef.currentOrgLib && version != configDef.version) {
604
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
605
+ console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLibVersion`)}.`);
606
+ console.log("\n");
607
+ }
608
+ else {
609
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
610
+ console.log(`--> You can switch to ${chalk.green(`${orgLibName}/${version}`)} via ${chalk.green(`npm run switchLib`)}.`);
611
+ console.log("\n");
612
+ }
613
+
584
614
  }
585
615
  else {
586
616
  const switchToFileName = `${orgLibName}_${version}.arch.zip`;
@@ -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": "~0.25.42",
111
+ "@pega/custom-dx-components": "~0.25.44",
112
112
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
113
113
  "@storybook/addon-actions": "^8.6.14",
114
114
  "@storybook/addon-essentials": "^8.6.14",
@@ -370,10 +370,18 @@ export default async (option) => {
370
370
  throw new Error(`Invalid schema json in config.json: ${er}`);
371
371
  }
372
372
 
373
+
374
+
375
+
373
376
  const valid = validateSchema(data);
374
377
 
375
378
  if (valid) {
376
379
 
380
+ if (data.description === "") {
381
+ throw new Error(`Invalid schema json in config.json: 'description' cannot be blank.`);
382
+ process.exit(1);
383
+ }
384
+
377
385
  if (
378
386
  componentToValidate &&
379
387
  !/^[A-Za-z0-9]+_[A-Za-z0-9]+_[A-Za-z0-9]+$/.test(componentToValidate)
package/src/util.js CHANGED
@@ -760,6 +760,11 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFiles", `directory: ${directory
760
760
  const tempDirectory = join(currentDirectory, TEMP_PATH);
761
761
  const configFiles = await getTopLevelConfigFiles(tempDirectory);
762
762
 
763
+ // we force to get the tasks.config.json and store it locally
764
+ // when we call updateComponentTaskConfig we will use this stored version to bring back server-config (except ruleset/version)
765
+ // and component objects
766
+ await getPegaConfig(true);
767
+
763
768
  if (configFiles && configFiles.length > 0) {
764
769
  for (const configF of configFiles) {
765
770
  if (configF !== "package-lock.json" && configF !== "package.json") {
@@ -936,9 +941,9 @@ if (showDebug) { addDebugLog("getPegaConfig", "END", "-"); }
936
941
  return pegaData;
937
942
  };
938
943
 
939
- export const getPegaServerConfig = async () => {
944
+ export const getPegaServerConfig = async (force = false) => {
940
945
  if (showDebug) addDebugLog("getPegaServerConfig", "", "+");
941
- if (!pegaConfig) {
946
+ if (!pegaConfig || force) {
942
947
  pegaConfig = await getPegaConfig();
943
948
 
944
949
  if (getServerType() === "launchpad") {
@@ -2218,19 +2223,28 @@ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2218
2223
  const currentDirectory = process.cwd();
2219
2224
  const tempDirectory = join(currentDirectory, TEMP_PATH);
2220
2225
 
2221
- const tempConfigPath = join(tempDirectory, TASKS_CONFIG_JSON_FILENAME);
2222
2226
  const currentConfigPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
2223
-
2224
- const contents = fs.readFileSync(tempConfigPath);
2225
2227
  const originalContents = fs.readFileSync(currentConfigPath);
2226
2228
 
2227
- let contentsData = JSON.parse(contents);
2229
+ // was previously stored in
2230
+ let contentsData = await getPegaConfig();
2231
+
2228
2232
  let originalContentsData = JSON.parse(originalContents);
2233
+ const orgRuleset = originalContentsData["server-config"].rulesetName;
2234
+ const orgRulesetVersion = originalContentsData["server-config"].rulesetVersion;
2229
2235
 
2230
- // only copy "components" from archived task.config and "devBuild"
2231
- // that way, your current tasks.config isn't messed up
2232
- originalContentsData["server-config"].devBuild = contentsData["server-config"].devBuild;
2233
- originalContentsData["component"] = contentsData["component"];
2236
+ // we keep server-config but we will restore from archive the
2237
+ // rulset/version. Other stuff in task.config will come from archive
2238
+ originalContentsData["server-config"] = contentsData["server-config"];
2239
+ // restore ruleset and verion
2240
+ originalContentsData["server-config"].rulesetName = orgRuleset;
2241
+ originalContentsData["server-config"].rulesetVersion = orgRulesetVersion;
2242
+
2243
+
2244
+ // if we don't have a devServerPort, add the default
2245
+ if (originalContentsData["server-config"].devServerPort === undefined) {
2246
+ originalContentsData["server-config"].devServerPort = "3030"
2247
+ }
2234
2248
 
2235
2249
  fs.writeFileSync(currentConfigPath, JSON.stringify(originalContentsData, null, 4), { encoding: 'utf8',flag:'w' });
2236
2250
 
@@ -196,7 +196,7 @@ describe(`createLib createAll exportStore importStore deleteLib: ${serverDir} -
196
196
  const { stdout, stderr } = await exec(script);
197
197
 
198
198
  expect(stdout).toContain('Pega_DXIL_0.0.1.arch.zip has been imported!');
199
- expect(stdout).toContain('You can switch to Pega_DXIL/0.0.1 via npm run switchLib.');
199
+ expect(stdout).toContain('--> You can retrieve and replace current source via npm run restoreLibVersion.');
200
200
 
201
201
  const zipFile = path.join(defaultPath, "Pega_DXIL_0.0.1.arch.zip");
202
202
  expect(fs.existsSync(zipFile)).toBeTruthy();