@pega/custom-dx-components 0.25.46 → 0.25.47

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.46",
3
+ "version": "0.25.47",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -99,9 +99,6 @@ addDebugLog("deletePublished", "END", "-");
99
99
  console.log();
100
100
  console.log(`Current server: ${chalk.green.bold(`${serverConfg.server}`)}`);
101
101
  console.log(`List of libraries for Application: ${chalk.green.bold(`${app_name} - ${app_version}`)}`);
102
- console.log(chalk.bold.yellow(`>> Caution...`));
103
- console.log(chalk.bold.yellow(`>> This list may contain built on libraries if your application is built on an application.`));
104
- console.log(chalk.bold.yellow(`>> Deleting built on libraries may cause issues with built on application.`));
105
102
 
106
103
 
107
104
  // want to get all in application, so ignore ruleset/version questions
@@ -113,6 +110,10 @@ addDebugLog("deletePublished", "END", "-");
113
110
  const arLibs = await getInfinityLibraries();
114
111
 
115
112
  if (arLibs && arLibs.pxResults && arLibs.pxResults.length > 0) {
113
+ console.log(chalk.bold.yellow(`\n>> Caution...`));
114
+ console.log(chalk.bold.yellow(`>> This list may contain built on libraries if your application is built on an application.`));
115
+ console.log(chalk.bold.yellow(`>> Deleting built on libraries may cause issues with built on application.\n`));
116
+
116
117
 
117
118
  const libs = arLibs.pxResults.map((oLib, index) => ({ name: oLib.pyLabel + " (" + oLib.pyRuleSet + ":" + oLib.pyRuleSetVersion + ")", value: index}));
118
119
 
@@ -148,8 +149,8 @@ addDebugLog("deletePublished", "END", "-");
148
149
  else {
149
150
  // No library with that name
150
151
  const serverConfig = await getPegaServerConfig();
151
- // console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${rulesetName}:${rulesetVersion}`)}`));
152
- console.log(chalk.redBright(`No server component libraries exist in given application`));
152
+ console.log("");
153
+ console.log(chalk.redBright(`No server component libraries exist in current authenticated application.`));
153
154
 
154
155
  addDebugLog("listPublished", "END", "-");
155
156
  process.exit(1);
@@ -288,6 +288,9 @@ export default async options => {
288
288
  let exportTo = "";
289
289
 
290
290
  if (options.params.length >= 8) {
291
+
292
+ // params pick full, what library/name and path
293
+ // vs no params then we will select the current library
291
294
  let fullArchive = options.params[3];
292
295
  const libraryName = options.params[4];
293
296
  const libraryVersion = options.params[5];
@@ -306,13 +309,13 @@ export default async options => {
306
309
  let fullArchive = "";
307
310
 
308
311
 
309
- if (options.params.length >= 5) {
310
- fullArchive = options.params[3];
311
- orgLibName = options.params[4];
312
- if (options.params.length >= 6) {
313
- selectedVersion = options.params[5];
314
- }
315
- }
312
+ // if (options.params.length >= 5) {
313
+ // fullArchive = options.params[3];
314
+ // orgLibName = options.params[4];
315
+ // if (options.params.length >= 6) {
316
+ // selectedVersion = options.params[5];
317
+ // }
318
+ // }
316
319
 
317
320
  // diable question to build "CL"
318
321
  // if (fullArchive === "" ) {
@@ -320,6 +323,8 @@ export default async options => {
320
323
  // const fullArchiveAnswers = await inquirer.prompt(fullArchiveQuestions);
321
324
  // ({ fullArchive } = fullArchiveAnswers);
322
325
  // }
326
+
327
+ // force full archive, binary deprecated
323
328
  fullArchive = "Full";
324
329
 
325
330
  let filePathQuestions;
@@ -328,6 +333,7 @@ export default async options => {
328
333
 
329
334
  // if Binary, then we need to just build the current library, get the results and
330
335
  // and export an archive as zip
336
+ // currently this is depricated, we are not going to export a CL as of yet.
331
337
  if (fullArchive === "Binary") {
332
338
 
333
339
  inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
@@ -345,19 +351,31 @@ export default async options => {
345
351
 
346
352
  }
347
353
  else {
348
- if (orgLibName === "") {
349
- const libraryQuestion = await getLibraryQuestion();
350
- const libraryAnswers = await inquirer.prompt(libraryQuestion);
351
- ({ orgLibName } = libraryAnswers);
352
- }
353
354
 
354
- if (selectedVersion === "") {
355
- const libraryVersionQuestion = await getLibraryVersionQuestion(orgLibName);
356
- const libraryVersionAnswer = await inquirer.prompt(libraryVersionQuestion);
357
- ({ selectedVersion } = libraryVersionAnswer);
358
- }
355
+ const configDef = getConfigDefaults();
356
+ orgLibName = configDef.currentOrgLib;
357
+ selectedVersion = configDef.buildVersion;
358
+
359
+ console.log(`\nExporting library ${chalk.bold.green(`${orgLibName}/${selectedVersion}`)}\n`);
360
+
361
+ // deprecating this code, only export current libary, don't ask for others
362
+ // need to switchLib/Version to that library to export it
363
+
364
+ // await zipVersionAndArchive(configDef.currentOrgLib, configDef.buildVersion);
365
+ // console.log(chalk.bold.yellow(`Exporting from local store, be sure to "npm run storeLibVersion" if archiving current library.\n`));
366
+ // if (orgLibName === "") {
367
+ // const libraryQuestion = await getLibraryQuestion();
368
+ // const libraryAnswers = await inquirer.prompt(libraryQuestion);
369
+ // ({ orgLibName } = libraryAnswers);
370
+ // }
371
+
372
+ // if (selectedVersion === "") {
373
+ // const libraryVersionQuestion = await getLibraryVersionQuestion(orgLibName);
374
+ // const libraryVersionAnswer = await inquirer.prompt(libraryVersionQuestion);
375
+ // ({ selectedVersion } = libraryVersionAnswer);
376
+ // }
377
+
359
378
 
360
- // when we can export to server, un comment this out
361
379
  if (isLibraryBasedCL) {
362
380
  if (exportTo === "") {
363
381
  const serverOrDirectoryQuestion = await getServerOrDirectoryQuestion();
@@ -384,19 +402,14 @@ export default async options => {
384
402
  else {
385
403
  await checkAccessTokenExpiration();
386
404
 
387
- // archive it
388
- await zipVersionAndArchive(orgLibName, selectedVersion);
389
-
390
405
  // publish to server
391
406
  await publishArchive(orgLibName, selectedVersion);
392
407
 
393
408
  }
394
409
 
395
-
396
410
  }
397
411
 
398
412
 
399
-
400
413
  }
401
414
 
402
415
  addDebugLog("exportArchive", "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": "~0.25.46",
111
+ "@pega/custom-dx-components": "~0.25.47",
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",
@@ -28,7 +28,9 @@
28
28
  "questions_askAlways": "",
29
29
  "questions_askNever": "",
30
30
  "questions_askOnce": "server,authService",
31
- "questions_askedOnce": ""
31
+ "questions_askedOnce": "",
32
+ "archiveRulesetName": "CustomDXArch",
33
+ "archiveRulesetVersion": "01-01-01"
32
34
  },
33
35
  "component": {
34
36
  "library": "YourLibrary",
@@ -89,7 +89,8 @@ addDebugLog("listPublished", "", "+");
89
89
  // local
90
90
  const arLibs = await getLocalLibraries();
91
91
 
92
- if (libraryName === "") {
92
+ if (arLibs && arLibs.length > 0) {
93
+ if (libraryName === "") {
93
94
  const libAnswers = await inquirer.prompt([
94
95
  {
95
96
  name: 'library',
@@ -139,16 +140,22 @@ addDebugLog("listPublished", "", "+");
139
140
  console.log(chalk.bold.blueBright(`\nList of ${chalk.inverse(`Local`)} ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
140
141
  console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
141
142
 
143
+ }
144
+ else {
145
+ // No library with that name
146
+ console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
147
+ console.log(chalk.redBright(`You need to publish library: ${libraryName} first.`));
148
+ addDebugLog("listPublished", "END", "-");
149
+ process.exit(1);
150
+
151
+ }
152
+
142
153
  }
143
154
  else {
144
- // No library with that name
145
- console.log(chalk.redBright(`No local library named: ${libraryName} exists.`));
146
- console.log(chalk.redBright(`You need to publish library: ${libraryName} first.`));
147
- addDebugLog("listPublished", "END", "-");
148
- process.exit(1);
149
-
155
+ console.log(chalk.redBright(`\nNo local libraries exist.`));
150
156
  }
151
157
 
158
+
152
159
  }
153
160
  else {
154
161
 
@@ -200,8 +207,9 @@ addDebugLog("listPublished", "END", "-");
200
207
  else {
201
208
  // No library with that name
202
209
  const serverConfig = await getPegaServerConfig();
203
- console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`));
204
- console.log(chalk.redBright(`You need to publish a library to this ruleset first.`));
210
+ console.log(chalk.redBright(`No server component libraries exist in authenticated application.`));
211
+ // console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`));
212
+ console.log(chalk.redBright(`You need to publish a library to a ruleset in this application first.`));
205
213
  addDebugLog("listPublished", "END", "-");
206
214
  process.exit(1);
207
215
 
@@ -28,7 +28,7 @@ addDebugLog("getPublishComponentQuestions", `componentKey: ${componentKey}`, "")
28
28
  {
29
29
  name: 'rulesetName',
30
30
  message: 'Enter ruleset name',
31
- default: defaultPegaConfig.rulesetName,
31
+ default: defaultPegaConfig.archiveRulesetName,
32
32
  validate: value => {
33
33
  if (value.trim()) {
34
34
  return true;
@@ -42,7 +42,7 @@ addDebugLog("getPublishComponentQuestions", `componentKey: ${componentKey}`, "")
42
42
  {
43
43
  name: 'rulesetVersion',
44
44
  message: 'Enter ruleset version',
45
- default: defaultPegaConfig.rulesetVersion,
45
+ default: defaultPegaConfig.archiveRulesetVersion,
46
46
  validate: value => {
47
47
  if (validateRulesetVersion(value)) {
48
48
  return true;
@@ -5,7 +5,15 @@ import { join } from 'path';
5
5
  import fs from 'fs';
6
6
  import ora from 'ora';
7
7
 
8
- import { zipUnArchiveToTempAndReturnBuffer, constructCompleteUrl, getHttpsAgent, getPegaServerConfig, addDebugLog, getConfigDefaults } from '../../util.js';
8
+ import {
9
+ zipUnArchiveToTempAndReturnBuffer,
10
+ constructCompleteUrl,
11
+ getHttpsAgent,
12
+ getPegaServerConfig,
13
+ addDebugLog,
14
+ getConfigDefaults,
15
+ zipVersionAndArchive,
16
+ updateServerConfigArchiveRuleSetAndVersion } from '../../util.js';
9
17
 
10
18
  import { getPublishComponentQuestions } from './helper.js';
11
19
 
@@ -126,10 +134,6 @@ export const publishComponentLibraryArchiveToServer = async (data, zipContent, d
126
134
 
127
135
 
128
136
 
129
-
130
-
131
-
132
-
133
137
  export default async (orgLibName, selectedVersion) => {
134
138
  // console.log(orgLibName + ", " + selectedVersion);
135
139
  const configDef = await getConfigDefaults();
@@ -147,15 +151,15 @@ export default async (orgLibName, selectedVersion) => {
147
151
  rulesetName, rulesetVersion
148
152
  };
149
153
 
154
+ // update so will get archived
155
+ updateServerConfigArchiveRuleSetAndVersion(content.rulesetName, content.rulesetVersion);
150
156
 
151
157
  if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
152
158
 
153
159
  archiveBeforeStore = true;
154
160
 
155
-
156
161
  if (archiveBeforeStore) {
157
162
 
158
-
159
163
  const archiveFileName = `${orgLibName}_${selectedVersion}.arch.zip`;
160
164
  const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${selectedVersion}`);
161
165
  const defaultPegaConfig = await getPegaServerConfig();
@@ -171,6 +175,9 @@ export default async (orgLibName, selectedVersion) => {
171
175
  let spinner;
172
176
  try {
173
177
  console.log("");
178
+ // archive it, which will save updated archiveRuleset/Version
179
+ await zipVersionAndArchive(content.libraryName, content.version);
180
+
174
181
  spinner = ora(`Exporting to server ${defaultPegaConfig.server}. \n`).start();
175
182
  publishComponentLibraryArchiveToServer(content, zipContent, true )
176
183
  .then( () => {
@@ -235,4 +242,6 @@ export default async (orgLibName, selectedVersion) => {
235
242
 
236
243
  }
237
244
 
245
+
246
+
238
247
  };
package/src/util.js CHANGED
@@ -1005,6 +1005,23 @@ if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName:
1005
1005
 
1006
1006
  }
1007
1007
 
1008
+ export const updateServerConfigArchiveRuleSetAndVersion = async (rulesetName, rulesetVersion) => {
1009
+ if (showDebug) addDebugLog("updateServerConfigArchiveRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
1010
+ const currentDirectory = process.cwd();
1011
+ const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1012
+ let configData = await getPegaConfig(true);
1013
+ let serverConfig = configData['server-config'];
1014
+
1015
+ serverConfig.archiveRulesetName = rulesetName;
1016
+ serverConfig.archiveRulesetVersion = rulesetVersion;
1017
+
1018
+ // update file
1019
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
1020
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
1021
+
1022
+ }
1023
+
1024
+
1008
1025
  export const updateComponentDefaultLibrary = async (library) => {
1009
1026
  if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
1010
1027
  const currentDirectory = process.cwd();
@@ -2235,6 +2252,8 @@ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2235
2252
  let originalContentsData = JSON.parse(originalContents);
2236
2253
  const orgRuleset = originalContentsData["server-config"].rulesetName;
2237
2254
  const orgRulesetVersion = originalContentsData["server-config"].rulesetVersion;
2255
+ const orgArchiveRuleset = originalContentsData["server-config"].archiveRulesetName;
2256
+ const orgArchiveRulesetVersion = originalContentsData["server-config"].archiveRulesetVersion;
2238
2257
 
2239
2258
  // we keep server-config but we will restore from archive the
2240
2259
  // rulset/version. Other stuff in task.config will come from archive
@@ -2242,6 +2261,8 @@ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2242
2261
  // restore ruleset and verion
2243
2262
  originalContentsData["server-config"].rulesetName = orgRuleset;
2244
2263
  originalContentsData["server-config"].rulesetVersion = orgRulesetVersion;
2264
+ originalContentsData["server-config"].archiveRulesetName = orgArchiveRuleset;
2265
+ originalContentsData["server-config"].archiveRulesetVersion = orgArchiveRulesetVersion;
2245
2266
 
2246
2267
 
2247
2268
  // if we don't have a devServerPort, add the default