@pega/custom-dx-components 0.25.11 → 0.25.12

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.11",
3
+ "version": "0.25.12",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -12,6 +12,7 @@ export const COMPONENTS_PATH = 'component';
12
12
  export const TOKEN_PATH = 'node_modules/@pega/custom-dx-components/.access_token';
13
13
  export const OOTB_COMPONENTS = 'node_modules/@pega/custom-dx-components/.ootb_components';
14
14
  export const LIBRARY_BASED = 'libraryMode';
15
+ export const LIBRARY_BASED_CL = 'libraryModeCL';
15
16
  export const SHARED_DIRECTORY = 'shared';
16
17
  export const SHOW_DEBUG = 'showDebug';
17
18
  export const ARCHIVES_PATH = 'store';
@@ -37,6 +38,8 @@ export const LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT =
37
38
  export const LP_DELETE_COMPONENT_SERVICE_REST_ENDPOINT =
38
39
  'pegalaunchpad/c11n/isolations/{isolationId}/v102/assetsUpdate';
39
40
 
41
+ export const PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT = 'PRRestService/dev/v1/publish_component_library';
42
+
40
43
  export const FIELD_PATH = '/field';
41
44
  export const TEMPLATE_PATH = '/template';
42
45
  export const WIDGET_PATH = '/widget';
@@ -132,7 +132,7 @@ export default async options => {
132
132
  process.exit();
133
133
  }
134
134
 
135
- if (options.params.length != 4) {
135
+ if (options.params.length != 7) {
136
136
  // internal so already called
137
137
  await showVersion();
138
138
  await checkLibraryAndArchives();
@@ -150,17 +150,17 @@ addDebugLog("buildLibrary", "", "+");
150
150
  let version;
151
151
  let devBuild;
152
152
 
153
- if (options.params.length >= 5) {
154
- version = options.params[3];
155
- const dBuild = options.params[4];
156
- devBuild = !!(dBuild === 'Y' || dBuild === 'y' || dBuild === true || dBuild === 'true');
157
- }
158
- else if (options.params.length === 4) {
153
+ if (options.params.length === 6) {
159
154
  // internally called from publish
160
155
  const orgLib = getConfigDefaults();
161
156
  version = orgLib.version;
162
157
  devBuild = await getConfigDevBuild();
163
158
  }
159
+ else if (options.params.length >= 5) {
160
+ version = options.params[3];
161
+ const dBuild = options.params[4];
162
+ devBuild = !!(dBuild === 'Y' || dBuild === 'y' || dBuild === true || dBuild === 'true');
163
+ }
164
164
  else {
165
165
  console.log(`\nLibrary ${chalk.bold.green(currentOrgLib)} `);
166
166
  const questions = await getBuildComponentQuestions(compDef.version);
@@ -14,7 +14,8 @@ import {
14
14
  getPegaServerConfig,
15
15
  standardizeStr,
16
16
  sanitize,
17
- addDebugLog
17
+ addDebugLog,
18
+ checkAccessTokenExpiration
18
19
  } from '../../util.js';
19
20
  import { getComponentsFromServer } from '../list/helper.js';
20
21
 
@@ -137,6 +138,10 @@ addDebugLog("deleteServerComponents", `sourceOfComponents: ${sourceOfComponents}
137
138
  const defaultPegaServerConfig = await getPegaServerConfig();
138
139
  const isLaunchpad = defaultPegaServerConfig.serverType === 'launchpad';
139
140
 
141
+ if (!isLaunchpad) {
142
+ await checkAccessTokenExpiration();
143
+ }
144
+
140
145
 
141
146
  if (isLaunchpad) {
142
147
  const questions = await getLaunchPadFilterQuestions();
@@ -106,7 +106,7 @@
106
106
  "@babel/preset-react": "^7.26.3",
107
107
  "@babel/preset-typescript": "^7.26.0",
108
108
  "@pega/configs": "^0.16.2",
109
- "@pega/custom-dx-components": "~0.25.11",
109
+ "@pega/custom-dx-components": "~0.25.12",
110
110
  "@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
111
111
  "@storybook/addon-actions": "^7.6.19",
112
112
  "@storybook/addon-essentials": "^7.6.19",
@@ -5,7 +5,7 @@ import fetch from 'node-fetch';
5
5
  import { join } from 'path';
6
6
 
7
7
  import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
8
- import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent, addDebugLog, getLibraryBased, getComponentsConfigs, getConfigDefaults } from '../../util.js';
8
+ import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent, addDebugLog, getLibraryBased, getComponentsConfigs, getConfigDefaults, checkAccessTokenExpiration } from '../../util.js';
9
9
 
10
10
  export const SOURCE_OF_COMPONENT_TYPES = {
11
11
  SERVER: 'Server',
@@ -208,6 +208,10 @@ addDebugLog("getComponentsFromServer", `library: ${library}, organization: ${org
208
208
  isLaunchpad ? LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT : LIST_COMPONENT_SERVICE_REST_ENDPOINT
209
209
  );
210
210
 
211
+ if (!isLaunchpad) {
212
+ await checkAccessTokenExpiration;
213
+ }
214
+
211
215
 
212
216
 
213
217
  return new Promise((resolve, reject) => {
@@ -17,6 +17,7 @@ import {
17
17
  import {
18
18
  PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
19
19
  LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
20
+ PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT,
20
21
  TOKEN_PATH
21
22
  } from '../../constants.js';
22
23
 
@@ -79,7 +80,8 @@ addDebugLog("getPublishComponentQuestions", `componentKey: ${componentKey}`, "")
79
80
  name: 'devBuild',
80
81
  type: 'confirm',
81
82
  message: 'Generate development build ?',
82
- default: defaultPegaConfig.devBuild
83
+ default: defaultPegaConfig.devBuild,
84
+ when: () => componentKey !== "LibraryMode"
83
85
  }
84
86
  ];
85
87
  };
@@ -6,7 +6,7 @@ import fs from 'fs';
6
6
  import validate from '../validator/index.js';
7
7
  import bundleComponent from '../bundle/index.js';
8
8
  import { lintComponent } from '../linter/index.js';
9
- import { getComponentDirectoryPath, showVersion, getLibraryBased, addDebugLog, getPegaServerConfig, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives, getConfigDevBuild, checkJWTExpiration, getConfigDefaults } from '../../util.js';
9
+ import { getComponentDirectoryPath, showVersion, getLibraryBased, addDebugLog, getPegaServerConfig, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives, getConfigDevBuild, checkAccessTokenExpiration, checkJWTExpiration, getConfigDefaults } from '../../util.js';
10
10
 
11
11
  import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
12
12
  import { default as buildLibrary } from '../build-lib/index.js';
@@ -24,20 +24,21 @@ export default async options => {
24
24
 
25
25
  addDebugLog("publish", "", "+");
26
26
 
27
+ await checkAccessTokenExpiration();
28
+
27
29
  if (isLibraryBased) {
28
30
 
29
31
  await checkJWTExpiration();
30
32
 
31
33
  const devBuild = await getConfigDevBuild();
32
34
  let okToPublish = false;
35
+ // let content;
33
36
 
34
37
  const orgLib = getConfigDefaults();
35
38
  const currentOrgLib = orgLib.currentOrgLib;
36
39
  // const currentVersion = devBuild ? `${orgLib.version}-dev`: orgLib.version;
37
40
  const currentVersion = orgLib.buildVersion;
38
41
 
39
-
40
-
41
42
  const publishThisVersion = await inquirer.prompt([
42
43
  {
43
44
  name: 'confirmPublish',
@@ -51,6 +52,33 @@ addDebugLog("publish", "", "+");
51
52
  okToPublish = true;
52
53
  }
53
54
 
55
+
56
+
57
+ if (okToPublish) {
58
+ if (options.params.length >= 8) {
59
+ // const rulesetName = options.params[3];
60
+ // const rulesetVersion = options.params[4]
61
+
62
+
63
+ // content = { rulesetName, rulesetVersion };
64
+ } else {
65
+ // VS Code pluggin would send in the component
66
+ let paramComponentKey;
67
+ if (options.params.length == 4) {
68
+ paramComponentKey = options.params[3];
69
+ }
70
+
71
+ const questions = await getPublishComponentQuestions("LibraryMode");
72
+ const answers = await inquirer.prompt(questions);
73
+
74
+ // content = {
75
+ // ...answers
76
+ // };
77
+ options.params.push(answers.rulesetName);
78
+ options.params.push(answers.rulesetVersion);
79
+ }
80
+ }
81
+
54
82
  if (okToPublish && !devBuild) {
55
83
  okToPublish = false;
56
84
  console.log("");
@@ -71,8 +99,11 @@ addDebugLog("publish", "", "+");
71
99
  // marking as internal, so no questions will be ask
72
100
  options.params.push("internal");
73
101
 
102
+
74
103
  await buildLibrary(options);
75
104
  await publishLibrary(options);
105
+
106
+
76
107
  }
77
108
 
78
109
  return true;
@@ -5,7 +5,7 @@ import chalk from 'chalk';
5
5
  import validate from '../validator/index.js';
6
6
  import bundleComponent from '../bundle/index.js';
7
7
  import { lintComponent } from '../linter/index.js';
8
- import { getComponents, getComponentDirectoryPath, showVersion, getLibraryBased, addDebugLog, getPegaServerConfig, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives } from '../../util.js';
8
+ import { getComponents, getComponentDirectoryPath, checkAccessTokenExpiration, showVersion, getLibraryBased, addDebugLog, getPegaServerConfig, updateServerConfigRuleSetAndVersion, checkLibraryAndArchives } from '../../util.js';
9
9
 
10
10
  import {
11
11
  getPublishComponentQuestions,
@@ -72,6 +72,8 @@ export default async options => {
72
72
  await showVersion();
73
73
  await checkLibraryAndArchives();
74
74
 
75
+ await checkAccessTokenExpiration();
76
+
75
77
  addDebugLog("publishAll", "", "+");
76
78
 
77
79
  const components = await getComponents();
@@ -1,15 +1,25 @@
1
1
  import inquirer from 'inquirer';
2
2
  import { Listr } from 'listr2';
3
3
  import chalk from 'chalk';
4
+ import fetch from 'node-fetch';
5
+ import archiver from 'archiver';
6
+ import path from 'path';
7
+ import fs from 'fs';
4
8
 
5
9
  import validate from '../validator/index.js';
6
10
  import { lintComponent } from '../linter/index.js';
7
- import { getComponentDirectoryPath, showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, deletePublishExtras, addDebugLog, checkLibraryAndArchives, checkJWTExpiration, getConfigDefaults } from '../../util.js';
11
+ import { constructCompleteUrl, getComponentDirectoryPath, getHttpsAgent, getPegaServerConfig, showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLibraryBased, getLibraryBasedCL, deletePublishExtras, addDebugLog, checkLibraryAndArchives, checkJWTExpiration, getConfigDefaults } from '../../util.js';
8
12
 
9
13
  import { publishLib, listLibJSONResponse, deleteLibVersion } from '@pega/constellation-dx-components-build-utils/index.js';
10
14
 
11
15
  import { getLibraryVersionQuestion } from './helper.js';
12
16
 
17
+ import {
18
+ LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
19
+ PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT,
20
+ TOKEN_PATH
21
+ } from '../../constants.js';
22
+
13
23
 
14
24
  export function getCustomTasks(componentKey, sourceMap, devBuild, options) {
15
25
  addDebugLog("getCustomTasks", `componentKey: ${componentKey}, sourceMap: ${sourceMap}, devBuild: ${devBuild}`, "");
@@ -54,6 +64,191 @@ addDebugLog("doesLibraryExist", `libraryName: ${libraryName}, libraryVersion: ${
54
64
  }
55
65
 
56
66
 
67
+ export const zipLibraryComponent = async (libraryName, version) => {
68
+ const currentDirectory = process.cwd();
69
+ const libraryDirName = `${libraryName}/${version}`;
70
+ const libraryDirectory = path.join(currentDirectory, libraryDirName);
71
+ const componentsConfigJson = `${libraryDirectory}/componentsconfig.json`;
72
+
73
+
74
+ const archive = archiver('zip', { zlib: { level: 9 } });
75
+ const zipChunks = [];
76
+ archive.on('data', chunk => zipChunks.push(chunk));
77
+
78
+ // Add src directory
79
+ archive.directory(libraryDirectory, 'src');
80
+
81
+ // Add config.json file
82
+ if (fs.existsSync(componentsConfigJson)) {
83
+ archive.file(componentsConfigJson, { name: path.basename(componentsConfigJson) });
84
+ }
85
+
86
+
87
+ await archive.finalize();
88
+
89
+ const zipBuffer = Buffer.concat(zipChunks);
90
+ console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
91
+ const zipContent = zipBuffer.toString('base64');
92
+
93
+ const configContent = Buffer.from(fs.readFileSync(componentsConfigJson)).toString();
94
+
95
+ // if (fs.existsSync(libraryDirectory)) {
96
+ // fs.rm(libraryDirectory, { recursive: true }, err => {
97
+ // if (err) {
98
+ // throw err;
99
+ // }
100
+ // });
101
+ // }
102
+
103
+ return { zipContent, configContent };
104
+ };
105
+
106
+
107
+ export const publishComponentLibraryToServer = async (data, doFetch) => {
108
+ addDebugLog("publishComponentToServer", `data: ${data}`, "");
109
+ const { configContent, zipContent, rulesetName, rulesetVersion, libraryName, version } = data;
110
+
111
+ const defaultPegaServerConfig = await getPegaServerConfig();
112
+ const { serverType, isolationId } = defaultPegaServerConfig;
113
+ const isLaunchpad = serverType === 'launchpad';
114
+ const launchpadRestEndpoint = LP_PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT.replace(
115
+ '{isolationId}',
116
+ isolationId || 'undefined'
117
+ );
118
+ let apiBody;
119
+
120
+ if (isLaunchpad) {
121
+ // currently no launchpad records to rule resolve a library
122
+
123
+ // apiBody = {
124
+ // type: 'CustomComponent',
125
+ // zipContent,
126
+ // componentName: JSON.parse(configContent).componentKey,
127
+ // pxUpdateDateTime: '',
128
+ // environmentID: defaultPegaServerConfig.isolationId
129
+ // };
130
+ } else {
131
+ apiBody = {
132
+ configContent,
133
+ zipContent,
134
+ publishFor: 'constellation',
135
+ rulesetName,
136
+ rulesetVersion,
137
+ libraryName,
138
+ version,
139
+ category: ''
140
+ };
141
+ }
142
+
143
+ const defaultPegaConfig = await getPegaServerConfig();
144
+ const url = constructCompleteUrl(
145
+ defaultPegaConfig.server,
146
+ isLaunchpad ? launchpadRestEndpoint : PUBLISH_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT
147
+ );
148
+
149
+ if (doFetch) {
150
+ try {
151
+ const OauthData = fs.readFileSync(TOKEN_PATH, 'utf8');
152
+ if (OauthData) {
153
+ const {
154
+ access_token: accessToken,
155
+ token_type: tokenType
156
+ // refresh_token: refreshToken
157
+ } = JSON.parse(OauthData);
158
+ let status = 500;
159
+ let headers = {};
160
+
161
+ if (isLaunchpad) {
162
+ headers.cookie = `Pega-AAT=${accessToken}`;
163
+ headers['Content-Type'] = 'application/json';
164
+ } else {
165
+ headers.Authorization = `${tokenType} ${accessToken}`;
166
+ }
167
+
168
+ const response = await fetch(url, {
169
+ method: 'POST',
170
+ agent: getHttpsAgent(defaultPegaConfig),
171
+ headers,
172
+ body: JSON.stringify(apiBody)
173
+ });
174
+
175
+ status = response.status;
176
+ if (!response.ok) {
177
+ if (status === 401) {
178
+ throw new Error(
179
+ 'Error occurred in authentication. Please regenerate using authenticate'
180
+ );
181
+ // console.log(accessTokenUri, refreshToken);
182
+ /* TODO - Handle refresh_token */
183
+ } else if (status === 404) {
184
+ throw new Error('404: Server resource not found');
185
+ } else if (status === 405) {
186
+ throw new Error('405: Server method not allowed');
187
+ } else if (status === 408) {
188
+ throw new Error('408: Server timed out');
189
+ } else if (response.status === 403) {
190
+ throw new Error('Error forbidden: User does not have privileges to Publish.');
191
+ }
192
+ }
193
+
194
+ try {
195
+ const respData = isLaunchpad ? await response.text() : await response.json();
196
+ console.log(chalk.bold.green(`Success : ${isLaunchpad ? respData : respData.message}`));
197
+
198
+ if (status === 500) {
199
+ status = 999;
200
+ throw new Error(respData.message);
201
+ }
202
+ } catch (err) {
203
+ if (status === 500) {
204
+ throw new Error(
205
+ `Error occurred in authentication. Please regenerate using authenticate`
206
+ );
207
+ } else if (status === 999) {
208
+ throw new Error(err);
209
+ }
210
+ }
211
+ } else {
212
+ throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
213
+ }
214
+ } catch (err) {
215
+ // throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
216
+ throw new Error(err);
217
+ }
218
+ }
219
+ };
220
+
221
+
222
+ export const publishUILibraryComponentToInfinity = async (content) => {
223
+ // const compDef = getConfigDefaults();
224
+ // const organization = compDef.organization;
225
+ // const library = compDef.library;
226
+ // const version = compDef.buildVersion;
227
+ // // const currentOrgLib = organization.concat('_').concat(library);
228
+ // const currentOrgLib = compDef.currentOrgLib;
229
+
230
+ console.log(chalk.green(`Publishing ${content.libraryName}/${content.version} to server...`));
231
+
232
+ const fromZip = await zipLibraryComponent(content.libraryName, content.version);
233
+
234
+ content = { ...fromZip, ...content };
235
+
236
+ // console.log(content);
237
+ try {
238
+ await publishComponentLibraryToServer(content, true );
239
+ // console.log(chalk.green.bold(`Success: Published ${content.libraryName}/${content.version} to server as a CL.`));
240
+ }
241
+ catch (ex) {
242
+ console.log(chalk.bold.red(err.toString()));
243
+ }
244
+
245
+
246
+
247
+ }
248
+
249
+
250
+
251
+
57
252
  export const publishNewLibraryAsync = async (libraryName, version, checkDeleted = false) => {
58
253
  addDebugLog("publishNewLibraryAsync", `libraryName: ${libraryName}, version: ${version}, checkDeleted: ${checkDeleted} `, "");
59
254
 
@@ -87,6 +282,9 @@ addDebugLog("publishLib", "services call", "");
87
282
  await publishLib(libraryName, version, tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
88
283
  addDebugLog("deleteLib", "services end", "");
89
284
 
285
+
286
+
287
+
90
288
  }
91
289
 
92
290
 
@@ -97,7 +295,7 @@ export default async (options) => {
97
295
  process.exit();
98
296
  }
99
297
 
100
- if (options.params.length != 4) {
298
+ if (options.params.length >= 4) {
101
299
  // internal so already called
102
300
  await showVersion();
103
301
  await checkLibraryAndArchives();
@@ -111,21 +309,29 @@ addDebugLog("publishLibrary", "", "+");
111
309
  let version;
112
310
  let devBuild;
113
311
  let internalPublish = false;
312
+ let rulesetName;
313
+ let rulesetVersion;
114
314
 
115
315
  let libraryName;
116
316
  let noRealPublish = false;
117
317
 
118
318
 
119
- if (options.params.length === 5) {
319
+ if (options.params.length === 7) {
120
320
  libraryName = options.params[3];
121
321
  version = options.params[4];
322
+ rulesetName = options.params[5];
323
+ rulesetVersion = options.params[6];
122
324
  }
123
- else if (options.params.length === 6) {
325
+ else if (options.params.length === 8) {
124
326
  libraryName = options.params[3];
125
327
  version = options.params[4];
328
+ rulesetName = options.params[5];
329
+ rulesetVersion = options.params[6];
126
330
  noRealPublish = true;
127
331
  }
128
- else if (options.params.length === 4) {
332
+ else if (options.params.length === 6) {
333
+ rulesetName = options.params[3];
334
+ rulesetVersion = options.params[4];
129
335
  // internal call from publish
130
336
  internalPublish = true;
131
337
  const orgLib = getConfigDefaults();
@@ -181,6 +387,7 @@ addDebugLog("publishLibrary", "", "+");
181
387
 
182
388
  let okToPublish = true;
183
389
 
390
+
184
391
  // this check matches check below, but for JEST, we don't want to go any further, just verifying if will
185
392
  // be caught
186
393
  if (noRealPublish && !version.includes("-dev")) {
@@ -212,6 +419,8 @@ addDebugLog("publishLibrary", "", "+");
212
419
 
213
420
  if (okToPublish) {
214
421
 
422
+ // /*
423
+
215
424
  let libVersionExists = await doesLibraryExist(libraryName, version);
216
425
  let overrideExisting = false;
217
426
  let checkDeleted = false;
@@ -254,6 +463,16 @@ addDebugLog("publishLibrary", "END", "-");
254
463
  // need a timeout to give services time to delete the library
255
464
  // setTimeout( function(){ await publishNewLibraryAsync(libraryName, version, checkDeleted)}, 700 );
256
465
  await publishNewLibraryAsync(libraryName, version, checkDeleted);
466
+ // */
467
+
468
+ // developer test
469
+ const isLibraryBasedCL = getLibraryBasedCL();
470
+ if (isLibraryBasedCL) {
471
+ let content = { libraryName, version, rulesetName, rulesetVersion };
472
+
473
+ await publishUILibraryComponentToInfinity(content);
474
+ }
475
+
257
476
  }
258
477
 
259
478
  }
package/src/util.js CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  USE_PROMOTED_WEB_PACK,
30
30
  BOOTSTRAP_CONFIG,
31
31
  LIBRARY_BASED,
32
+ LIBRARY_BASED_CL,
32
33
  SHARED_DIRECTORY,
33
34
  SHOW_DEBUG,
34
35
  COMPONENTS_PATH,
@@ -53,6 +54,7 @@ let addAboutData = true;
53
54
  let defaultConfigs = {
54
55
  serverType: "",
55
56
  isLibraryBased: false,
57
+ isLibraryBasedCL: false,
56
58
  devBuild: true,
57
59
  library: "",
58
60
  organization: "",
@@ -108,6 +110,7 @@ export const setUpDefaults = async () => {
108
110
  let retrievedConfigData = {
109
111
  serverType: "",
110
112
  isLibraryBased: false,
113
+ isLibraryBasedCL: false,
111
114
  devBuild: true,
112
115
  library: "",
113
116
  organization: "",
@@ -146,6 +149,10 @@ export const setUpDefaults = async () => {
146
149
  retrievedConfigData.library = data.component.library;
147
150
  retrievedConfigData.version = data.component.version;
148
151
 
152
+ if (data[LIBRARY_BASED_CL]) {
153
+ retrievedConfigData.isLibraryBasedCL = data[LIBRARY_BASED_CL];
154
+ }
155
+
149
156
 
150
157
  const { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
151
158
  retrievedConfigData.organization = organization;
@@ -335,6 +342,25 @@ export const checkJWTExpiration = async () => {
335
342
 
336
343
  }
337
344
 
345
+ export const checkAccessTokenExpiration = async() => {
346
+
347
+ const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
348
+
349
+ if (tokenAndStaticServer.access_token === undefined) {
350
+ console.log(chalk.redBright("Need to authenticate, missing token.\n"));
351
+ process.exit(1);
352
+ }
353
+
354
+ const jwt = jwtDecode(tokenAndStaticServer.access_token);
355
+ const { exp, customer_org } = jwt;
356
+ if (exp < (new Date().getTime() + 1) / 1000) {
357
+ console.log(chalk.redBright("Authentication token has expired, please reauthenticate."));
358
+ process.exit(1);
359
+ }
360
+
361
+
362
+ }
363
+
338
364
  export const getLibraryBased = () => {
339
365
  if (showDebug) addDebugLog("getLibraryBased", "", "");
340
366
  // const currentDirectory = process.cwd();
@@ -366,6 +392,11 @@ if (showDebug) addDebugLog("getLibraryBased", "", "");
366
392
  return defaultConfigs.isLibraryBased;
367
393
  }
368
394
 
395
+ export const getLibraryBasedCL = () => {
396
+ if (showDebug) addDebugLog("getLibraryBasedCL", "", "");
397
+ return defaultConfigs.isLibraryBasedCL;
398
+ }
399
+
369
400
  export const setLibraryBased = async (isLibraryBased) => {
370
401
  if (showDebug) addDebugLog("setLibraryBased", "", "");
371
402
  const currentDirectory = process.cwd();
@@ -986,7 +1017,7 @@ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}
986
1017
  data.version = buildVersion;
987
1018
 
988
1019
  if (addAboutData) {
989
- data.buildDate = dateStamp;
1020
+ data.buildDate = currentDate;
990
1021
  await applyPegaData(data);
991
1022
  }
992
1023
 
@@ -1419,10 +1450,10 @@ if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1419
1450
  }
1420
1451
 
1421
1452
  if (OAuthData) {
1422
- const { C11NB2S, appStaticContentServer } = JSON.parse(OAuthData)
1453
+ const { C11NB2S, appStaticContentServer, access_token } = JSON.parse(OAuthData)
1423
1454
 
1424
1455
  if (C11NB2S) {
1425
- return ({ C11NB2S, appStaticContentServer});
1456
+ return ({ C11NB2S, appStaticContentServer, access_token});
1426
1457
  }
1427
1458
 
1428
1459
  }