@pega/custom-dx-components 0.25.46 → 0.25.48

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.48",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -97,7 +97,9 @@ export const updateAllMigrateToLibChanges = async() => {
97
97
 
98
98
  }
99
99
 
100
+ console.log();
100
101
  console.log(`${chalk.green(`>> Code base was upgraded. You may still have some lint errors that need to be fixed manually.`)}`);
102
+ console.log(`${chalk.green(`>> Run ${chalk.bold(`npm run validateAll`)} to check for issues.`)}`);
101
103
 
102
104
  }
103
105
 
@@ -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 application ${chalk.redBright.bold(`${app_name} - ${app_version}`)}.`));
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", "-");
@@ -382,19 +382,19 @@ export const importArch = async(filePath, fileName, hadArchive) => {
382
382
  if (hadArchive) {
383
383
 
384
384
  if (orgLibName === configDef.currentOrgLib && version === configDef.version) {
385
- console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
385
+ console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
386
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`)}.`);
387
+ console.log(`--> You can retrieve and replace current source via ${chalk.bold.green(`npm run restoreLibVersion`)}.`);
388
388
  console.log("\n");
389
389
  }
390
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`)}.`);
391
+ console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
392
+ console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLibVersion`)}.`);
393
393
  console.log("\n");
394
394
  }
395
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`)}.`);
396
+ console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
397
+ console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLib`)}.`);
398
398
  console.log("\n");
399
399
  }
400
400
 
@@ -595,19 +595,19 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
595
595
 
596
596
  if (hadArchive) {
597
597
  if (orgLibName === configDef.currentOrgLib && version === configDef.version) {
598
- console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
598
+ console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
599
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`)}.`);
600
+ console.log(`--> You can retrieve and replace current source via ${chalk.bold.green(`npm run restoreLibVersion`)}.`);
601
601
  console.log("\n");
602
602
  }
603
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`)}.`);
604
+ console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
605
+ console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLibVersion`)}.`);
606
606
  console.log("\n");
607
607
  }
608
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`)}.`);
609
+ console.log(`\n${chalk.bold.green(`${fileName}`)} has been imported!`);
610
+ console.log(`--> You can switch to ${chalk.bold.green(`${orgLibName}/${version}`)} via ${chalk.bold.green(`npm run switchLib`)}.`);
611
611
  console.log("\n");
612
612
  }
613
613
 
@@ -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.48",
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,22 +140,29 @@ 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
 
155
162
  const isLibraryBasedCL = getLibraryBasedCL();
156
163
  if (isLibraryBasedCL) {
157
164
  const arLibs = await getInfinityLibraries();
165
+ const {app_name, app_version } = await getApplicationAndVersionFromToken();
158
166
 
159
167
  if (arLibs && arLibs.pxResults && arLibs.pxResults.length > 0) {
160
168
 
@@ -162,7 +170,7 @@ addDebugLog("listPublished", "END", "-");
162
170
  const libs = arLibs.pxResults.map((oLib, index) => ({ name: oLib.pyLabel + " (" + oLib.pyRuleSet + ":" + oLib.pyRuleSetVersion + ")", value: index}));
163
171
 
164
172
 
165
- const {app_name, app_version } = await getApplicationAndVersionFromToken();
173
+
166
174
  const serverConfig = await getPegaServerConfig();
167
175
  console.log(`\nServer ${chalk.green.bold(`${serverConfig.server}`)}.`);
168
176
  console.log(`List of libraries (including built on) for Application: ${chalk.bold.green(`${app_name} - ${app_version}`)}`);
@@ -200,8 +208,9 @@ addDebugLog("listPublished", "END", "-");
200
208
  else {
201
209
  // No library with that name
202
210
  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.`));
211
+ console.log(chalk.redBright(`No server component libraries exist in application ${chalk.redBright.bold(`${app_name} - ${app_version}`)}.`));
212
+ // console.log(chalk.redBright(`No server component libraries exist in given ruleset ${chalk.bold(`${serverConfig.rulesetName}:${serverConfig.rulesetVersion}`)}`));
213
+ console.log(chalk.redBright(`You need to publish a library to a ruleset in this application first.`));
205
214
  addDebugLog("listPublished", "END", "-");
206
215
  process.exit(1);
207
216
 
@@ -23,6 +23,7 @@ import {
23
23
  getInputConfigForCommand,
24
24
  convertYNToBoolean,
25
25
  checkForBranch,
26
+ getApplicationAndVersionFromToken,
26
27
  applyPegaData } from '../../util.js';
27
28
 
28
29
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
@@ -64,10 +65,13 @@ addDebugLog("publish", "", "+");
64
65
  const serverConfg = await getPegaServerConfig();
65
66
  let configJson = {};
66
67
  await applyPegaData(configJson);
68
+ const {app_name, app_version, sub } = await getApplicationAndVersionFromToken();
67
69
 
68
70
  console.log();
69
71
  console.log(`Publishing to server: ${chalk.green.bold(`${serverConfg.server}`)}`);
70
72
  console.log(`Cosmos version: ${chalk.green.bold(`${configJson.packageCosmosVersion}`)}`);
73
+ console.log(`Application: ${chalk.green.bold(`${app_name} - ${app_version}`)} for ${chalk.magentaBright.bold(`${sub}`)}`);
74
+ console.log();
71
75
 
72
76
  if (useInputConfig) {
73
77
  const inputConfig = await getInputConfigForCommand("publish");
@@ -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
  };
@@ -8,7 +8,7 @@ import {
8
8
  checkLibraryAndArchives,
9
9
  getPegaServerConfig,
10
10
  getLibraryBasedCL,
11
- applyPegaData } from '../../util.js';
11
+ getApplicationAndVersionFromToken } from '../../util.js';
12
12
 
13
13
  export const showCurrentStatus = async () => {
14
14
 
@@ -17,6 +17,7 @@ export const showCurrentStatus = async () => {
17
17
  const isLibraryBased = getLibraryBased();
18
18
  const isLibraryBasedCL = getLibraryBasedCL();
19
19
  const pegaServer = await getPegaServerConfig(true);
20
+ const { app_name, app_version } = await getApplicationAndVersionFromToken();
20
21
 
21
22
  console.log("");
22
23
  console.log("\tCurrent status");
@@ -33,7 +34,13 @@ export const showCurrentStatus = async () => {
33
34
  }
34
35
  }
35
36
 
36
- console.log(`\tComponent count: ${chalk.bold.green(`${componentList.length}`)}`);
37
+ if (componentList.length === 0) {
38
+ console.log(`\tComponent count: ${chalk.bold.yellow(`${componentList.length}`)}`);
39
+ }
40
+ else {
41
+ console.log(`\tComponent count: ${chalk.bold.green(`${componentList.length}`)}`);
42
+ }
43
+
37
44
 
38
45
  console.log("");
39
46
 
@@ -42,10 +49,15 @@ export const showCurrentStatus = async () => {
42
49
  }
43
50
  else {
44
51
 
45
- console.log(`\tPublish to:\t ${chalk.bold.green(`${pegaServer.server}`)} `);
46
- // console.log("\t---------------------");
47
- console.log(`\tRuleSet:\t ${chalk.bold.green(`${pegaServer.rulesetName}`)}`);
48
- console.log(`\tRuleSet Version: ${chalk.bold.green(`${pegaServer.rulesetVersion}`)}`);
52
+ console.log(`\tPublish configuration`)
53
+ console.log(`\t Server:\t ${chalk.bold.green(`${pegaServer.server}`)} `);
54
+ if (app_name === "**") {
55
+ console.log(`\t Application:\t ${chalk.bold.yellow(`Need to authenticate`)}`);
56
+ }
57
+ else {
58
+ console.log(`\t Application:\t ${chalk.bold.green(`${app_name} - ${app_version}`)}`);
59
+ }
60
+ console.log(`\t Ruleset:\t ${chalk.bold.green(`${pegaServer.rulesetName}:`)}${chalk.bold.magenta(`${pegaServer.rulesetVersion}`)}`);
49
61
  console.log("");
50
62
  }
51
63
 
package/src/util.js CHANGED
@@ -75,6 +75,7 @@ let defaultConfigs = {
75
75
  useInputConfig: false
76
76
  };
77
77
 
78
+
78
79
  let pegaConfig = null;
79
80
  let pegaData = null;
80
81
  let sPegaData;
@@ -407,9 +408,11 @@ export const checkJWTExpiration = async () => {
407
408
  const isLibraryBased = getLibraryBased();
408
409
  const isLibraryBasedCL = getLibraryBasedCL();
409
410
 
410
- if (tokenAndStaticServer.C11NB2S === undefined) {
411
- console.log(chalk.redBright("Need to authenticate, missing services token.\nBuilding a library requires authentication to acquire a token to build."));
412
- process.exit(1);
411
+ if (!isLibraryBasedCL && isLibraryBased) {
412
+ if (tokenAndStaticServer.C11NB2S === undefined) {
413
+ console.log(chalk.redBright("Need to authenticate, missing services token.\nBuilding a library requires authentication to acquire a token to build."));
414
+ process.exit(1);
415
+ }
413
416
  }
414
417
 
415
418
  const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
@@ -444,26 +447,36 @@ export const checkAccessTokenExpiration = async() => {
444
447
  }
445
448
 
446
449
  const jwt = jwtDecode(tokenAndStaticServer.access_token);
447
- const { exp, customer_org } = jwt;
450
+ const { exp, customer_org, sub, app_name, app_version, operator_access } = jwt;
451
+
452
+
448
453
  if (exp < (new Date().getTime() + 1) / 1000) {
449
454
  console.log(chalk.redBright("Authentication token has expired, please reauthenticate."));
450
455
  process.exit(1);
451
456
  }
452
457
 
453
458
 
459
+
454
460
  }
455
461
 
462
+
463
+
456
464
  export const getApplicationAndVersionFromToken = async() => {
457
465
  const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
458
466
 
459
467
  if (tokenAndStaticServer.access_token === undefined) {
460
- console.log(chalk.redBright("Need to authenticate, missing token.\n"));
461
- process.exit(1);
468
+ // console.log(chalk.redBright("Need to authenticate, missing token.\n"));
469
+ // process.exit(1);
470
+ const app_name = "**";
471
+ const app_version = "**";
472
+ const sub = "**";
473
+ const operator_access = "**";
474
+ return { app_name, app_version, sub, operator_access};
462
475
  }
463
476
 
464
477
  const jwt = jwtDecode(tokenAndStaticServer.access_token);
465
- const { app_name, app_version } = jwt;
466
- return { app_name, app_version };
478
+ const { app_name, app_version, sub, operator_access } = jwt;
479
+ return { app_name, app_version, sub, operator_access};
467
480
 
468
481
  }
469
482
 
@@ -767,7 +780,8 @@ if (showDebug) addDebugLog("restoreTopLevelConfigFiles", `directory: ${directory
767
780
 
768
781
  if (configFiles && configFiles.length > 0) {
769
782
  for (const configF of configFiles) {
770
- if (configF !== "package-lock.json" && configF !== "package.json") {
783
+ // don't want to restore package, package-lock or an archive file
784
+ if (configF !== "package-lock.json" && configF !== "package.json" && (configF.indexOf(".zip") < 0) ) {
771
785
  fs.copyFileSync(join(tempDirectory, configF), join(directory, configF));
772
786
  }
773
787
  }
@@ -1005,6 +1019,23 @@ if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName:
1005
1019
 
1006
1020
  }
1007
1021
 
1022
+ export const updateServerConfigArchiveRuleSetAndVersion = async (rulesetName, rulesetVersion) => {
1023
+ if (showDebug) addDebugLog("updateServerConfigArchiveRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
1024
+ const currentDirectory = process.cwd();
1025
+ const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
1026
+ let configData = await getPegaConfig(true);
1027
+ let serverConfig = configData['server-config'];
1028
+
1029
+ serverConfig.archiveRulesetName = rulesetName;
1030
+ serverConfig.archiveRulesetVersion = rulesetVersion;
1031
+
1032
+ // update file
1033
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
1034
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
1035
+
1036
+ }
1037
+
1038
+
1008
1039
  export const updateComponentDefaultLibrary = async (library) => {
1009
1040
  if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
1010
1041
  const currentDirectory = process.cwd();
@@ -2235,6 +2266,8 @@ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2235
2266
  let originalContentsData = JSON.parse(originalContents);
2236
2267
  const orgRuleset = originalContentsData["server-config"].rulesetName;
2237
2268
  const orgRulesetVersion = originalContentsData["server-config"].rulesetVersion;
2269
+ const orgArchiveRuleset = originalContentsData["server-config"].archiveRulesetName;
2270
+ const orgArchiveRulesetVersion = originalContentsData["server-config"].archiveRulesetVersion;
2238
2271
 
2239
2272
  // we keep server-config but we will restore from archive the
2240
2273
  // rulset/version. Other stuff in task.config will come from archive
@@ -2243,6 +2276,12 @@ if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
2243
2276
  originalContentsData["server-config"].rulesetName = orgRuleset;
2244
2277
  originalContentsData["server-config"].rulesetVersion = orgRulesetVersion;
2245
2278
 
2279
+ // replace if exists
2280
+ if (orgArchiveRuleset) {
2281
+ originalContentsData["server-config"].archiveRulesetName = orgArchiveRuleset;
2282
+ originalContentsData["server-config"].archiveRulesetVersion = orgArchiveRulesetVersion;
2283
+ }
2284
+
2246
2285
 
2247
2286
  // if we don't have a devServerPort, add the default
2248
2287
  if (originalContentsData["server-config"].devServerPort === undefined) {