@pega/custom-dx-components 25.1.10-alpha-0.5 → 25.1.10-alpha-0.6

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.10-alpha-0.5",
3
+ "version": "25.1.10-alpha-0.6",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -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,
@@ -159,7 +159,6 @@ addDebugLog("exportCLArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName
159
159
  }
160
160
 
161
161
 
162
-
163
162
  }
164
163
 
165
164
 
@@ -370,9 +369,6 @@ export default async options => {
370
369
  exportTo = "Directory";
371
370
  }
372
371
 
373
- //exportTo = "Directory"; // remove this line when above is uncommented out
374
-
375
-
376
372
  if (exportTo === "Directory") {
377
373
  inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
378
374
 
@@ -382,12 +378,6 @@ export default async options => {
382
378
 
383
379
  await updateSavedExportFilePath(filePath);
384
380
 
385
- // if (path.sep === "/") {
386
- // if (filePath.lastIndexOf(path.sep) != filePath.length - 1) {
387
- // filePath = filePath.concat(path.sep);
388
- // }
389
- // }
390
-
391
381
  await exportArch( filePath, orgLibName, selectedVersion, fullArchive);
392
382
 
393
383
  }
@@ -397,7 +387,6 @@ export default async options => {
397
387
  // archive it
398
388
  await zipVersionAndArchive(orgLibName, selectedVersion);
399
389
 
400
-
401
390
  // publish to server
402
391
  await publishArchive(orgLibName, selectedVersion);
403
392
 
@@ -141,57 +141,56 @@ export const renameComponent = async (
141
141
  addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
142
142
 
143
143
 
144
- const componentName = componentKey.split("_")[2];
144
+ const componentName = componentKey.split("_")[2];
145
145
 
146
- const configDef = getConfigDefaults();
147
- const orgLibName = `${configDef.organization}_${library}`;
148
- const organization = configDef.organization;
149
-
150
- const newComponentKey = `${orgLibName}_${componentName}`;
151
-
152
- const oldComponentKey = componentKey;
153
- const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
154
- const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
146
+ const configDef = getConfigDefaults();
147
+ const orgLibName = `${configDef.organization}_${library}`;
148
+ const organization = configDef.organization;
155
149
 
156
- const currentDirectory = await getComponentDirectoryPath(componentKey, currDir);
157
- const targetDirectory = await getComponentDirectoryPath(newComponentKey, currDir);
150
+ const newComponentKey = `${orgLibName}_${componentName}`;
158
151
 
159
- const targetFileList = await getDirectoryFiles(currentDirectory);
152
+ const oldComponentKey = componentKey;
153
+ const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
154
+ const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
160
155
 
161
- for (const fileIndex in targetFileList) {
162
- const fileName = targetFileList[fileIndex];
156
+ const currentDirectory = await getComponentDirectoryPath(componentKey, currDir);
157
+ const targetDirectory = await getComponentDirectoryPath(newComponentKey, currDir);
163
158
 
164
- if (fileName === "config.json") {
165
- await updateConfig(
166
- {
167
- oldComponentKey,
168
- newComponentKey,
169
- componentName,
170
- organization,
171
- library,
172
- version,
173
- currentDirectory,
174
- }
175
- );
176
- }
177
- else {
178
- await updateFile(
179
- fileName,
180
- oldComponentKeyPC,
181
- newComponentKeyPC,
182
- currentDirectory );
159
+ const targetFileList = await getDirectoryFiles(currentDirectory);
183
160
 
184
- }
161
+ for (const fileIndex in targetFileList) {
162
+ const fileName = targetFileList[fileIndex];
163
+
164
+ if (fileName === "config.json") {
165
+ await updateConfig(
166
+ {
167
+ oldComponentKey,
168
+ newComponentKey,
169
+ componentName,
170
+ organization,
171
+ library,
172
+ version,
173
+ currentDirectory,
174
+ }
175
+ );
176
+ }
177
+ else {
178
+ await updateFile(
179
+ fileName,
180
+ oldComponentKeyPC,
181
+ newComponentKeyPC,
182
+ currentDirectory );
185
183
 
186
- } // for
184
+ }
187
185
 
186
+ } // for
188
187
 
189
188
 
190
- // rename the directory
191
- await reanmeDirectory(currentDirectory, targetDirectory);
189
+ // rename the directory
190
+ await reanmeDirectory(currentDirectory, targetDirectory);
192
191
 
193
192
 
194
- return newComponentKey;
193
+ return newComponentKey;
195
194
 
196
195
  };
197
196
 
@@ -648,11 +648,9 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
648
648
 
649
649
  }
650
650
 
651
-
652
651
  }
653
652
 
654
653
 
655
-
656
654
  export const getZipFileList = async(filePath) => {
657
655
 
658
656
  if (fs.existsSync(filePath)) {
@@ -782,6 +780,7 @@ export default async options => {
782
780
  }
783
781
  catch (ex) {
784
782
  console.log(chalk.redBright(ex));
783
+ process.exit(1);
785
784
  }
786
785
 
787
786
 
@@ -844,7 +843,7 @@ export default async options => {
844
843
  else {
845
844
  // No library with that name
846
845
  console.log(chalk.redBright(`No library archives exist on server.`));
847
- process.exit(1);
846
+ process.exit();
848
847
 
849
848
  }
850
849
 
@@ -913,12 +912,6 @@ export default async options => {
913
912
  }
914
913
 
915
914
 
916
-
917
-
918
-
919
-
920
-
921
-
922
915
  }
923
916
 
924
917
  addDebugLog("importArchive", "END", "-");
@@ -273,14 +273,8 @@ addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
273
273
  }
274
274
  }
275
275
 
276
-
277
-
278
-
279
276
  }
280
277
 
281
-
282
-
283
-
284
278
  }
285
279
 
286
280
 
@@ -379,9 +373,6 @@ addDebugLog("importComponent", "", "+");
379
373
  await importComp( filePath, fileName, true);
380
374
  }
381
375
 
382
-
383
-
384
-
385
376
  }
386
377
 
387
378
  addDebugLog("importComponent", "END", "-");
@@ -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.10-alpha-0.5",
111
+ "@pega/custom-dx-components": "~25.1.10-alpha-0.6",
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",
@@ -140,9 +140,6 @@ addDebugLog("getInfinityLibraries", '', "");
140
140
  const rulesetVersion = defaultPegaServerConfig.rulesetVersion;
141
141
 
142
142
  let urlParams = `/app-name/${ApplicationName}/app-version/${ApplicationVersion}/rulesetname/${rulesetName}/rulesetversion/${rulesetVersion}`;
143
- //let urlParams = `&ApplicationName=${ApplicationName}&ApplicationVersion=${ApplicationVersion}&RulesetName=${rulesetName}&RulesetVersion=${rulesetVersion}`;
144
- //urlParams = encodeURIComponent(urlParams);
145
-
146
143
 
147
144
  url = url.concat(urlParams);
148
145
 
@@ -110,13 +110,6 @@ addDebugLog("zipLibraryComponent", `libraryName: ${libraryName}, libraryVersion:
110
110
  localizationsContent = Buffer.from(fs.readFileSync(localizationsJson)).toString();
111
111
  }
112
112
 
113
- // if (fs.existsSync(libraryDirectory)) {
114
- // fs.rm(libraryDirectory, { recursive: true }, err => {
115
- // if (err) {
116
- // throw err;
117
- // }
118
- // });
119
- // }
120
113
 
121
114
  return { zipContent, configContent, localizationsContent};
122
115
  };
@@ -51,9 +51,6 @@ addDebugLog("restoreComponent", "", "+");
51
51
  ]);
52
52
  }
53
53
 
54
-
55
-
56
-
57
54
  if (restoreFromStore.confirmRestore) {
58
55
  const switchToFileName = `${confDef.currentOrgLib}_${confDef.version}.arch.zip`;
59
56
  const tasks = new Listr(
@@ -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,23 @@ 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;
2235
+
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;
2229
2242
 
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"];
2234
2243
 
2235
2244
  // if we don't have a devServerPort, add the default
2236
2245
  if (originalContentsData["server-config"].devServerPort === undefined) {