@pega/custom-dx-components 0.25.45 → 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 +33 -27
- package/src/tasks/build-jest-assets/index.js +4 -4
- package/src/tasks/bundle/builder/index.js +15 -15
- package/src/tasks/create/index.js +19 -33
- package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.tsx.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +0 -1
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/config.json.mustache +0 -1
- package/src/tasks/create/templates/Launchpad/Widget/CASE/config.json.mustache +0 -1
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/config.json.mustache +0 -1
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/config.json.mustache +0 -1
- package/src/tasks/create-all/index.js +22 -35
- package/src/tasks/delete-pub/helper.js +5 -5
- package/src/tasks/delete-pub/index.js +22 -9
- package/src/tasks/export-archive/index.js +36 -23
- package/src/tasks/init/index.js +62 -59
- package/src/tasks/init/template/package.json.mustache +2 -1
- package/src/tasks/init/template/tasks.config.json +3 -1
- package/src/tasks/list-pub/helper.js +6 -3
- package/src/tasks/list-pub/index.js +22 -13
- package/src/tasks/publish-archive/helper.js +2 -2
- package/src/tasks/publish-archive/index.js +16 -7
- package/src/tasks/show-status/index.js +1 -1
- package/src/tasks/validator/index.js +0 -2
- package/src/util.js +508 -473
- package/tests/assets/library/components/create/Pega_DXIL_MyTestText/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyBoolean/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyCurrency/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDate/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDateTime/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDecimal/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDetails/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyEmail/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyForm/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyInteger/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPage/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPage/demo.stories.tsx +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageWidget/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyParagraph/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPercentage/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPhone/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPicklist/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyRadiobuttons/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MySearchbox/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyText/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTextInput/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/config.json +0 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyURL/config.json +0 -1
- package/tests/assets/original/components/create/Pega_DXIL_MyTestText/config.json +0 -1
- package/tests/assets/original/components/create/shared/PConnProps.d.ts +46 -0
- package/tests/assets/original/components/create/shared/create-nonce.ts +5 -0
- package/tests/assets/original/components/create/shared/suggestions-handler.ts +9 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyBoolean/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyCurrency/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDate/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDateTime/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDecimal/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDetails/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyEmail/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyForm/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyInteger/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPage/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPage/demo.stories.tsx +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPageWidget/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyParagraph/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPercentage/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPhone/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPicklist/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyRadiobuttons/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MySearchbox/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyText/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTextInput/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyURL/config.json +0 -1
- package/tests/assets/original/components/createAll/Constellation/shared/PConnProps.d.ts +46 -0
- package/tests/assets/original/components/createAll/Constellation/shared/create-nonce.ts +5 -0
- package/tests/assets/original/components/createAll/Constellation/shared/suggestions-handler.ts +9 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyBoolean/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyCurrency/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDate/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDateTime/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDecimal/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDetails/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyEmail/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyForm/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyInteger/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPage/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPage/demo.stories.tsx +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyParagraph/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPercentage/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPhone/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPicklist/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyRadiobuttons/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MySearchbox/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyText/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTextInput/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyURL/config.json +0 -1
- package/tests/assets/original/components/createAll/Launchpad/shared/PConnProps.d.ts +46 -0
- package/tests/assets/original/components/createAll/Launchpad/shared/create-nonce.ts +5 -0
- package/tests/assets/original/components/createAll/Launchpad/shared/suggestions-handler.ts +9 -0
- package/tests/functional/localCreateAllListDeleteAll.test.js +1 -1
- package/tests/functional/localCreateBuildAllDeleteAll.test.js +3 -3
- package/tests/functional/localCreateBuildDelete.test.js +1 -1
- package/tests/functional/localCreateListDelete.test.js +1 -1
- package/tests/functional/localCreatePublishAllDeleteAll.test.js +3 -3
- package/tests/functional/localCreatePublishDelete.test.js +1 -1
- package/tests/functional/localCreateRenameDelete.test.js +1 -1
- package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +3 -3
- package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +3 -3
- package/tests/functional/localLibCreateLibExportImportLib.test.js +1 -1
- package/tests/functional/localLibCreateLibExportLib.test.js +1 -1
- package/tests/functional/localLibCreateLibListDeleteLib.test.js +1 -1
- package/tests/functional/localLibCreateLibListMoveDeleteLib.test.js +1 -1
- package/tests/functional/localLibCreateLibListSwitchDeleteLib.test.js +1 -1
- package/tests/functional/localLibCreateLibStatusDeleteLib.test.js +1 -1
- package/tests/functional/localLibCreateLibStoreRestoreDeleteLib.test.js +1 -1
- package/tests/functional/localLibCreateLibValidateDeleteLib.test.js +3 -3
- package/tests/functional/localLibCreateLibVersionDeleteLib.test.js +1 -1
package/src/util.js
CHANGED
|
@@ -5,9 +5,9 @@ import { promisify } from 'util';
|
|
|
5
5
|
import https from 'https';
|
|
6
6
|
import crypto from 'node:crypto';
|
|
7
7
|
import { createRequire } from 'module';
|
|
8
|
-
import {
|
|
8
|
+
import {jwtDecode} from 'jwt-decode';
|
|
9
9
|
import archiver from 'archiver';
|
|
10
|
-
import {
|
|
10
|
+
import {unarchive} from 'unarchive';
|
|
11
11
|
import ora from 'ora';
|
|
12
12
|
|
|
13
13
|
import chalk from 'chalk';
|
|
@@ -83,32 +83,32 @@ let sPegaServerConfig;
|
|
|
83
83
|
export const modAddAboutData = (addInAboutData) => {
|
|
84
84
|
// used by jest to not put in to match assets without aboutData
|
|
85
85
|
addAboutData = addInAboutData;
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
87
|
|
|
88
88
|
export const addDebugLog = (sFunctionName, sLogData, sIncDec) => {
|
|
89
89
|
|
|
90
90
|
let sLog;
|
|
91
91
|
if (showDebug) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
if (sIncDec === "-") {
|
|
93
|
+
debugLevel--;
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
sLog = `>> log ${debugLevel} `;
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
for (let i =0; i < debugLevel; i++) {
|
|
99
|
+
sLog = sLog.concat("-");
|
|
100
|
+
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
sLog = sLog.concat(sFunctionName).concat(": ").concat(sLogData);
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
console.log(`${chalk.hex('#A0522D')(sLog)}`);
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
if (sIncDec === "+") {
|
|
107
|
+
debugLevel++;
|
|
108
|
+
}
|
|
109
109
|
|
|
110
110
|
}
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
112
|
|
|
113
113
|
export const setUpDefaults = async () => {
|
|
114
114
|
|
|
@@ -183,11 +183,11 @@ export const setUpDefaults = async () => {
|
|
|
183
183
|
|
|
184
184
|
retrievedConfigData.serverType = data["server-config"].serverType;
|
|
185
185
|
retrievedConfigData.devBuild = data["server-config"].devBuild;
|
|
186
|
-
|
|
186
|
+
retrievedConfigData.devServerPort = data["server-config"].devServerPort;
|
|
187
187
|
|
|
188
188
|
retrievedConfigData.buildVersion = retrievedConfigData.devBuild ? `${retrievedConfigData.version}-dev` : retrievedConfigData.version;
|
|
189
189
|
retrievedConfigData.currentOrgLib = `${retrievedConfigData.organization}_${retrievedConfigData.library}`;
|
|
190
|
-
retrievedConfigData.displayLibVersion = `${retrievedConfigData.currentOrgLib}/${retrievedConfigData.buildVersion}`;
|
|
190
|
+
retrievedConfigData.displayLibVersion = `${retrievedConfigData.currentOrgLib }/${retrievedConfigData.buildVersion}`;
|
|
191
191
|
|
|
192
192
|
}
|
|
193
193
|
catch (ex) {
|
|
@@ -197,7 +197,7 @@ export const setUpDefaults = async () => {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
return JSON.parse(JSON.stringify(retrievedConfigData));
|
|
200
|
-
}
|
|
200
|
+
}
|
|
201
201
|
|
|
202
202
|
export const convertYNToBoolean = (inputYN) => {
|
|
203
203
|
switch (inputYN) {
|
|
@@ -213,7 +213,7 @@ export const convertYNToBoolean = (inputYN) => {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
return false;
|
|
216
|
-
}
|
|
216
|
+
}
|
|
217
217
|
|
|
218
218
|
export const getInputConfigForCommand = async (commandName) => {
|
|
219
219
|
// retrievedConfigData
|
|
@@ -254,7 +254,7 @@ export const getInputConfigForCommand = async (commandName) => {
|
|
|
254
254
|
|
|
255
255
|
return {};
|
|
256
256
|
|
|
257
|
-
}
|
|
257
|
+
}
|
|
258
258
|
|
|
259
259
|
// initialize
|
|
260
260
|
// await setUpDefaults();
|
|
@@ -268,18 +268,18 @@ export const checkPathAccess = async (path, options = {}, throwError = false) =>
|
|
|
268
268
|
await access(path, fs.constants.R_OK);
|
|
269
269
|
} catch (err) {
|
|
270
270
|
if (throwError) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
|
|
272
|
+
if (showDebug) addDebugLog("checkPathAccess", "Error: ".concat(err), "");
|
|
273
|
+
if (showDebug) addDebugLog("checkPathAccess", "END", "-");
|
|
274
274
|
throw new Error(err);
|
|
275
275
|
|
|
276
276
|
}
|
|
277
277
|
else {
|
|
278
|
-
|
|
278
|
+
if (showDebug) addDebugLog("checkPathAccess", "path: ".concat(path), "+");
|
|
279
279
|
const message =
|
|
280
280
|
errorMessage || `${chalk.red.bold('ERROR')} Could not able to access path - ${path}`;
|
|
281
281
|
console.error(message);
|
|
282
|
-
|
|
282
|
+
if (showDebug) addDebugLog("checkPathAccess", "END", "-");
|
|
283
283
|
process.exit(1);
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -287,7 +287,7 @@ export const checkPathAccess = async (path, options = {}, throwError = false) =>
|
|
|
287
287
|
};
|
|
288
288
|
|
|
289
289
|
export const getUseWebPackPromotion = async () => {
|
|
290
|
-
|
|
290
|
+
if (showDebug) addDebugLog("getUseWebPackPromotion", "", "");
|
|
291
291
|
const currentDirectory = process.cwd();
|
|
292
292
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
293
293
|
|
|
@@ -319,10 +319,10 @@ export const getUseWebPackPromotion = async () => {
|
|
|
319
319
|
|
|
320
320
|
return data[USE_PROMOTED_WEB_PACK];
|
|
321
321
|
|
|
322
|
-
}
|
|
322
|
+
}
|
|
323
323
|
|
|
324
|
-
export const updateUseWebPackPromotion = async (useValue = false) => {
|
|
325
|
-
|
|
324
|
+
export const updateUseWebPackPromotion = async ( useValue = false ) => {
|
|
325
|
+
if (showDebug) addDebugLog("updateUseWebPackPromotion", "", "");
|
|
326
326
|
|
|
327
327
|
const currentDirectory = process.cwd();
|
|
328
328
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
@@ -341,12 +341,12 @@ export const updateUseWebPackPromotion = async (useValue = false) => {
|
|
|
341
341
|
|
|
342
342
|
data["usePromotedWebPack"] = useValue;
|
|
343
343
|
|
|
344
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',
|
|
344
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
|
|
345
345
|
|
|
346
|
-
}
|
|
346
|
+
}
|
|
347
347
|
|
|
348
348
|
export const getAboutData = async (currentOrgLib, buildVersion, dateStamp) => {
|
|
349
|
-
|
|
349
|
+
if (showDebug) addDebugLog("getAboutData", `currentOrgLib: ${currentOrgLib}, buildVersion: ${buildVersion}, dateStamp: ${dateStamp}`,"");
|
|
350
350
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
351
351
|
|
|
352
352
|
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
@@ -355,16 +355,16 @@ export const getAboutData = async (currentOrgLib, buildVersion, dateStamp) => {
|
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
|
|
358
|
-
let infinityVersion
|
|
358
|
+
let infinityVersion= jwt.infinity_version;
|
|
359
359
|
infinityVersion = infinityVersion.replace("8.", "");
|
|
360
360
|
|
|
361
361
|
return `${currentOrgLib} ${buildVersion}, ${dateStamp}, ${infinityVersion}`;
|
|
362
|
-
}
|
|
362
|
+
}
|
|
363
363
|
|
|
364
364
|
export const applyPegaData = async (configJson) => {
|
|
365
|
-
|
|
365
|
+
if (showDebug) addDebugLog("applyPegaData", "", "");
|
|
366
366
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
367
|
-
const currentDirectory = process.cwd()
|
|
367
|
+
const currentDirectory = process.cwd()
|
|
368
368
|
// const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
|
|
369
369
|
const currentPackageLockPath = join(currentDirectory, PACKAGE_LOCK_JSON_FILENAME);
|
|
370
370
|
// let currentPackageData;
|
|
@@ -391,7 +391,7 @@ export const applyPegaData = async (configJson) => {
|
|
|
391
391
|
}
|
|
392
392
|
else {
|
|
393
393
|
const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
|
|
394
|
-
infinityVersion
|
|
394
|
+
infinityVersion= jwt.infinity_version;
|
|
395
395
|
// don't remove "8." from infinity version so can do a comparison
|
|
396
396
|
}
|
|
397
397
|
|
|
@@ -400,7 +400,7 @@ export const applyPegaData = async (configJson) => {
|
|
|
400
400
|
configJson.packageCosmosVersion = cosmosVersion;
|
|
401
401
|
|
|
402
402
|
|
|
403
|
-
}
|
|
403
|
+
}
|
|
404
404
|
|
|
405
405
|
export const checkJWTExpiration = async () => {
|
|
406
406
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
@@ -413,7 +413,7 @@ export const checkJWTExpiration = async () => {
|
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
const jwt = jwtDecode(tokenAndStaticServer.C11NB2S);
|
|
416
|
-
const
|
|
416
|
+
const { exp, customer_org } = jwt;
|
|
417
417
|
if (exp < (new Date().getTime() + 1) / 1000) {
|
|
418
418
|
console.log(chalk.redBright("JWT token has expired, please reauthenticate."));
|
|
419
419
|
process.exit(1);
|
|
@@ -432,9 +432,9 @@ export const checkJWTExpiration = async () => {
|
|
|
432
432
|
}
|
|
433
433
|
|
|
434
434
|
|
|
435
|
-
}
|
|
435
|
+
}
|
|
436
436
|
|
|
437
|
-
export const checkAccessTokenExpiration = async
|
|
437
|
+
export const checkAccessTokenExpiration = async() => {
|
|
438
438
|
|
|
439
439
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
440
440
|
|
|
@@ -444,16 +444,16 @@ export const checkAccessTokenExpiration = async () => {
|
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
const jwt = jwtDecode(tokenAndStaticServer.access_token);
|
|
447
|
-
const
|
|
447
|
+
const { exp, customer_org } = jwt;
|
|
448
448
|
if (exp < (new Date().getTime() + 1) / 1000) {
|
|
449
449
|
console.log(chalk.redBright("Authentication token has expired, please reauthenticate."));
|
|
450
450
|
process.exit(1);
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
|
|
454
|
-
}
|
|
454
|
+
}
|
|
455
455
|
|
|
456
|
-
export const getApplicationAndVersionFromToken = async
|
|
456
|
+
export const getApplicationAndVersionFromToken = async() => {
|
|
457
457
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
458
458
|
|
|
459
459
|
if (tokenAndStaticServer.access_token === undefined) {
|
|
@@ -465,27 +465,27 @@ export const getApplicationAndVersionFromToken = async () => {
|
|
|
465
465
|
const { app_name, app_version } = jwt;
|
|
466
466
|
return { app_name, app_version };
|
|
467
467
|
|
|
468
|
-
}
|
|
468
|
+
}
|
|
469
469
|
|
|
470
470
|
export const getLibraryBased = () => {
|
|
471
|
-
|
|
471
|
+
if (showDebug) addDebugLog("getLibraryBased", "", "");
|
|
472
472
|
return defaultConfigs.isLibraryBased;
|
|
473
|
-
}
|
|
473
|
+
}
|
|
474
474
|
|
|
475
475
|
export const getLibraryBasedCL = () => {
|
|
476
|
-
|
|
476
|
+
if (showDebug) addDebugLog("getLibraryBasedCL", "", "");
|
|
477
477
|
return defaultConfigs.isLibraryBasedCL;
|
|
478
|
-
}
|
|
478
|
+
}
|
|
479
479
|
|
|
480
480
|
export const getUseInputConfig = () => {
|
|
481
|
-
|
|
481
|
+
if (showDebug) addDebugLog("getUseInputConfig", "", "");
|
|
482
482
|
|
|
483
483
|
|
|
484
484
|
return defaultConfigs.useInputConfig;
|
|
485
|
-
}
|
|
485
|
+
}
|
|
486
486
|
|
|
487
487
|
export const setLibraryBased = async (isLibraryBased) => {
|
|
488
|
-
|
|
488
|
+
if (showDebug) addDebugLog("setLibraryBased", "", "");
|
|
489
489
|
const currentDirectory = process.cwd();
|
|
490
490
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
491
491
|
|
|
@@ -508,7 +508,7 @@ export const setLibraryBased = async (isLibraryBased) => {
|
|
|
508
508
|
// update file
|
|
509
509
|
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
510
510
|
try {
|
|
511
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',
|
|
511
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
|
|
512
512
|
}
|
|
513
513
|
catch (err) {
|
|
514
514
|
console.error(err);
|
|
@@ -522,66 +522,66 @@ export const setLibraryBased = async (isLibraryBased) => {
|
|
|
522
522
|
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
}
|
|
525
|
+
}
|
|
526
526
|
|
|
527
527
|
export const setLibraryBasedCL = async (isLibraryBasedCL) => {
|
|
528
528
|
if (showDebug) addDebugLog("setLibraryBased", "", "");
|
|
529
|
-
|
|
530
|
-
|
|
529
|
+
const currentDirectory = process.cwd();
|
|
530
|
+
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
531
531
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
532
|
+
try {
|
|
533
|
+
// force to throw error and not console log
|
|
534
|
+
await checkPathAccess(pegaConfigJsonPath, {}, true);
|
|
535
|
+
}
|
|
536
|
+
catch (ex) {
|
|
537
|
+
// when can't find it, always be false, assume no library based.
|
|
538
|
+
// This is IMPORTANT for init (npx install)
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
541
|
|
|
542
|
-
|
|
543
|
-
|
|
542
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
543
|
+
data = JSON.parse(data);
|
|
544
544
|
|
|
545
|
-
|
|
546
|
-
|
|
545
|
+
if (data[LIBRARY_BASED_CL] != undefined) {
|
|
546
|
+
data[LIBRARY_BASED_CL] = isLibraryBasedCL;
|
|
547
547
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
548
|
+
// if not undefined, force this as well
|
|
549
|
+
if (data[LIBRARY_BASED] != undefined) {
|
|
550
|
+
data[LIBRARY_BASED] = isLibraryBasedCL;
|
|
551
|
+
}
|
|
552
552
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
553
|
+
// update file
|
|
554
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
555
|
+
try {
|
|
556
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
|
|
557
|
+
}
|
|
558
|
+
catch (err) {
|
|
559
|
+
console.error(err);
|
|
560
|
+
}
|
|
561
|
+
//await forceDefaultsUpdate();
|
|
562
|
+
defaultConfigs.isLibraryBasedCL = isLibraryBasedCL;
|
|
563
563
|
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
// force libraryBased if isLibraryBasedCL is true
|
|
565
|
+
defaultConfigs.isLibraryBased = isLibraryBasedCL;
|
|
566
566
|
|
|
567
567
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
568
|
+
// reset
|
|
569
|
+
pegaData = null;
|
|
570
|
+
pegaConfig = null;
|
|
571
571
|
|
|
572
|
-
|
|
572
|
+
}
|
|
573
573
|
|
|
574
|
-
}
|
|
574
|
+
}
|
|
575
575
|
|
|
576
576
|
export const getShowDebug = () => {
|
|
577
577
|
|
|
578
578
|
return defaultConfigs.showDebug;
|
|
579
579
|
|
|
580
|
-
}
|
|
580
|
+
}
|
|
581
581
|
|
|
582
582
|
|
|
583
583
|
export const deleteLocalComponent = async componentKey => {
|
|
584
|
-
|
|
584
|
+
if (showDebug) addDebugLog("deleteLocalComponent", `componentKey: ${componentKey}`, "");
|
|
585
585
|
const currentDirectory = process.cwd();
|
|
586
586
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
587
587
|
|
|
@@ -617,7 +617,7 @@ export const getHttpsAgent = serverConfig => {
|
|
|
617
617
|
};
|
|
618
618
|
|
|
619
619
|
export const deleteServerComponent = async componentKey => {
|
|
620
|
-
|
|
620
|
+
if (showDebug) addDebugLog("deleteServerComponent", `componentKey: ${componentKey}`, "");
|
|
621
621
|
const serverConfig = await getPegaServerConfig();
|
|
622
622
|
const { server, user, password } = serverConfig;
|
|
623
623
|
const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
|
|
@@ -662,8 +662,8 @@ export const deleteServerComponent = async componentKey => {
|
|
|
662
662
|
}
|
|
663
663
|
};
|
|
664
664
|
|
|
665
|
-
export const copyFileToShared = async (fileName, fileContents) => {
|
|
666
|
-
|
|
665
|
+
export const copyFileToShared = async ( fileName, fileContents) => {
|
|
666
|
+
if (showDebug) addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
|
|
667
667
|
const currentDirectory = process.cwd();
|
|
668
668
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
669
669
|
|
|
@@ -697,7 +697,7 @@ export const copyFileToShared = async (fileName, fileContents) => {
|
|
|
697
697
|
};
|
|
698
698
|
|
|
699
699
|
export const getComponents = async (overrideDirectory = null) => {
|
|
700
|
-
|
|
700
|
+
if (showDebug) addDebugLog("getComponents", "", "");
|
|
701
701
|
const currentDirectory = process.cwd();
|
|
702
702
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
703
703
|
|
|
@@ -723,39 +723,39 @@ export const getComponents = async (overrideDirectory = null) => {
|
|
|
723
723
|
};
|
|
724
724
|
|
|
725
725
|
export const getTopLevelConfigFiles = async (directory) => {
|
|
726
|
-
|
|
726
|
+
if (showDebug) addDebugLog("getTopLevelConfigFiles", `directory: ${directory}`, "");
|
|
727
727
|
if (fs.existsSync(directory)) {
|
|
728
728
|
return fs
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
729
|
+
.readdirSync(directory, { withFileTypes: true })
|
|
730
|
+
.filter(dirent => !dirent.isDirectory())
|
|
731
|
+
.map(dirent => dirent.name);
|
|
732
732
|
}
|
|
733
733
|
else {
|
|
734
734
|
return [];
|
|
735
735
|
}
|
|
736
|
-
}
|
|
736
|
+
}
|
|
737
737
|
|
|
738
738
|
export const removeTopLevelConfigFiles = async (directory) => {
|
|
739
|
-
|
|
739
|
+
if (showDebug) addDebugLog("removeTopLevelConfigFiles", `directory: ${directory}`, "");
|
|
740
740
|
const configFiles = await getTopLevelConfigFiles(directory);
|
|
741
741
|
|
|
742
742
|
if (configFiles && configFiles.length > 0) {
|
|
743
743
|
for (const configF of configFiles) {
|
|
744
744
|
// don't remove these files, otherwise, remove it
|
|
745
745
|
if (configF !== "package-lock.json" &&
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
fs.rmSync(join(directory, configF), { recursive: true, force: true, maxRetries: 2 });
|
|
746
|
+
configF !== "package.json" &&
|
|
747
|
+
configF !== "tasks.config.json" &&
|
|
748
|
+
configF !== ".gitignore" &&
|
|
749
|
+
configF !== ".npmrc" &&
|
|
750
|
+
configF !== ".prettierignore") {
|
|
751
|
+
fs.rmSync( join(directory, configF), { recursive: true, force: true, maxRetries: 2 });
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
}
|
|
755
|
+
}
|
|
756
756
|
|
|
757
|
-
export const restoreTopLevelConfigFiles = async
|
|
758
|
-
|
|
757
|
+
export const restoreTopLevelConfigFiles = async(directory) => {
|
|
758
|
+
if (showDebug) addDebugLog("restoreTopLevelConfigFiles", `directory: ${directory}`, "");
|
|
759
759
|
const currentDirectory = process.cwd();
|
|
760
760
|
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
761
761
|
const configFiles = await getTopLevelConfigFiles(tempDirectory);
|
|
@@ -772,28 +772,28 @@ export const restoreTopLevelConfigFiles = async (directory) => {
|
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
|
-
}
|
|
775
|
+
}
|
|
776
776
|
|
|
777
777
|
export const getTemplateConfigFiles = async () => {
|
|
778
|
-
|
|
778
|
+
if (showDebug) addDebugLog("getTemplateConfigFiles", ``, "");
|
|
779
779
|
const currentDirectory = process.cwd();
|
|
780
780
|
const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
|
|
781
781
|
const templateDir = join(initDir, "template");
|
|
782
782
|
|
|
783
783
|
if (fs.existsSync(templateDir)) {
|
|
784
784
|
return fs
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
785
|
+
.readdirSync(templateDir, { withFileTypes: true })
|
|
786
|
+
.filter(dirent => !dirent.isDirectory())
|
|
787
|
+
.map(dirent => dirent.name);
|
|
788
788
|
}
|
|
789
789
|
else {
|
|
790
790
|
return [];
|
|
791
791
|
}
|
|
792
792
|
|
|
793
|
-
}
|
|
793
|
+
}
|
|
794
794
|
|
|
795
|
-
export const restoreTopLevelConfigFilesFromTemplate = async
|
|
796
|
-
|
|
795
|
+
export const restoreTopLevelConfigFilesFromTemplate = async(clearDep = true) => {
|
|
796
|
+
if (showDebug) addDebugLog("restoreTopLevelConfigFilesFromTemplate", ``, "");
|
|
797
797
|
// we can't loose devDep that is part of install, so go get the template mustache and push
|
|
798
798
|
// those in, replacing any changes there, but allowing additional, an keeping it updated
|
|
799
799
|
// so won't loose new function if an old archive
|
|
@@ -812,7 +812,7 @@ export const restoreTopLevelConfigFilesFromTemplate = async (clearDep = true) =>
|
|
|
812
812
|
currentPackageData = fs.readFileSync(currentPackagePath);
|
|
813
813
|
}
|
|
814
814
|
catch (ex) {
|
|
815
|
-
console.log($chalk.red(`\nUnable to retrieve current package.json.`))
|
|
815
|
+
console.log($chalk.red(`\nUnable to retrieve current package.json.`))
|
|
816
816
|
process.exit(1);
|
|
817
817
|
}
|
|
818
818
|
let cData = JSON.parse(currentPackageData);
|
|
@@ -822,7 +822,7 @@ export const restoreTopLevelConfigFilesFromTemplate = async (clearDep = true) =>
|
|
|
822
822
|
retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
|
|
823
823
|
}
|
|
824
824
|
catch (ex) {
|
|
825
|
-
console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
|
|
825
|
+
console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
|
|
826
826
|
process.exit(1);
|
|
827
827
|
}
|
|
828
828
|
|
|
@@ -865,7 +865,7 @@ export const restoreTopLevelConfigFilesFromTemplate = async (clearDep = true) =>
|
|
|
865
865
|
}
|
|
866
866
|
|
|
867
867
|
// update current package json file
|
|
868
|
-
fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',
|
|
868
|
+
fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
869
869
|
|
|
870
870
|
// restore from template
|
|
871
871
|
const templateFiles = await getTemplateConfigFiles();
|
|
@@ -877,10 +877,10 @@ export const restoreTopLevelConfigFilesFromTemplate = async (clearDep = true) =>
|
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
879
|
|
|
880
|
-
}
|
|
880
|
+
}
|
|
881
881
|
|
|
882
882
|
export const getSubComponents = async (directory, type) => {
|
|
883
|
-
|
|
883
|
+
if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}, type: ${type}`, "");
|
|
884
884
|
const subDirectory = join(directory, type);
|
|
885
885
|
return fs
|
|
886
886
|
.readdirSync(subDirectory, { withFileTypes: true })
|
|
@@ -889,7 +889,7 @@ export const getSubComponents = async (directory, type) => {
|
|
|
889
889
|
};
|
|
890
890
|
|
|
891
891
|
export const getDirectoryFiles = async directory => {
|
|
892
|
-
|
|
892
|
+
if (showDebug) addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
|
|
893
893
|
return fs
|
|
894
894
|
.readdirSync(directory, { withFileTypes: true })
|
|
895
895
|
.filter(dirent => !dirent.isDirectory())
|
|
@@ -897,7 +897,7 @@ export const getDirectoryFiles = async directory => {
|
|
|
897
897
|
};
|
|
898
898
|
|
|
899
899
|
export const getComponentsObj = async () => {
|
|
900
|
-
|
|
900
|
+
if (showDebug) addDebugLog("getComponentsObj", "", "+");
|
|
901
901
|
const compList = [];
|
|
902
902
|
|
|
903
903
|
// const componentList = await getDirectoryFiles(directory);
|
|
@@ -910,21 +910,21 @@ export const getComponentsObj = async () => {
|
|
|
910
910
|
container.name = name;
|
|
911
911
|
container.value = name;
|
|
912
912
|
|
|
913
|
-
|
|
913
|
+
if (showDebug) addDebugLog("getComponentsObj", "container: " + JSON.stringify(container), "");
|
|
914
914
|
return container;
|
|
915
915
|
})
|
|
916
916
|
);
|
|
917
917
|
}
|
|
918
918
|
|
|
919
|
-
|
|
919
|
+
if (showDebug) addDebugLog("getComponentsObj", "END", "-");
|
|
920
920
|
return compList;
|
|
921
921
|
};
|
|
922
922
|
|
|
923
923
|
export const getPegaConfig = async (force = false) => {
|
|
924
|
-
|
|
924
|
+
if (showDebug) { addDebugLog("getPegaConfig", "", "+"); }
|
|
925
925
|
if (!pegaData || force) {
|
|
926
926
|
|
|
927
|
-
|
|
927
|
+
if (showDebug) { addDebugLog("getPegaConfig", "retrieveData", ""); }
|
|
928
928
|
const currentDirectory = process.cwd();
|
|
929
929
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
930
930
|
|
|
@@ -935,14 +935,14 @@ export const getPegaConfig = async (force = false) => {
|
|
|
935
935
|
}
|
|
936
936
|
|
|
937
937
|
|
|
938
|
-
|
|
939
|
-
|
|
938
|
+
if (showDebug) { addDebugLog("getPegaConfig", "pegaData: " + sPegaData, ""); }
|
|
939
|
+
if (showDebug) { addDebugLog("getPegaConfig", "END", "-"); }
|
|
940
940
|
|
|
941
941
|
return pegaData;
|
|
942
942
|
};
|
|
943
943
|
|
|
944
944
|
export const getPegaServerConfig = async (force = false) => {
|
|
945
|
-
|
|
945
|
+
if (showDebug) addDebugLog("getPegaServerConfig", "", "+");
|
|
946
946
|
if (!pegaConfig || force) {
|
|
947
947
|
pegaConfig = await getPegaConfig();
|
|
948
948
|
|
|
@@ -971,26 +971,26 @@ export const getPegaServerConfig = async (force = false) => {
|
|
|
971
971
|
sPegaServerConfig = JSON.stringify(pegaConfig['server-config']);
|
|
972
972
|
}
|
|
973
973
|
|
|
974
|
-
|
|
975
|
-
|
|
974
|
+
if (showDebug) addDebugLog("getPegaServerConfig", "server config:" + sPegaServerConfig, "");
|
|
975
|
+
if (showDebug) addDebugLog("getPegaServerConfig", "END", "-");
|
|
976
976
|
return pegaConfig['server-config'];
|
|
977
977
|
};
|
|
978
978
|
|
|
979
979
|
|
|
980
980
|
// contains all the config, task config, etc. created upon start
|
|
981
981
|
export const getConfigDefaults = () => {
|
|
982
|
-
|
|
982
|
+
if (showDebug) addDebugLog("getConfigDefaults", `defaults: ${JSON.stringify(defaultConfigs)}`, "");
|
|
983
983
|
|
|
984
984
|
return defaultConfigs;
|
|
985
985
|
|
|
986
|
-
}
|
|
986
|
+
}
|
|
987
987
|
|
|
988
988
|
export const forceDefaultsUpdate = async () => {
|
|
989
989
|
defaultConfigs = await setUpDefaults();
|
|
990
|
-
}
|
|
990
|
+
}
|
|
991
991
|
|
|
992
992
|
export const updateServerConfigRuleSetAndVersion = async (rulesetName, rulesetVersion) => {
|
|
993
|
-
|
|
993
|
+
if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
|
|
994
994
|
const currentDirectory = process.cwd();
|
|
995
995
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
996
996
|
let configData = await getPegaConfig(true);
|
|
@@ -1001,12 +1001,29 @@ export const updateServerConfigRuleSetAndVersion = async (rulesetName, rulesetVe
|
|
|
1001
1001
|
|
|
1002
1002
|
// update file
|
|
1003
1003
|
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
1004
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',
|
|
1004
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1005
|
+
|
|
1006
|
+
}
|
|
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
|
+
}
|
|
1005
1023
|
|
|
1006
|
-
};
|
|
1007
1024
|
|
|
1008
1025
|
export const updateComponentDefaultLibrary = async (library) => {
|
|
1009
|
-
|
|
1026
|
+
if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
|
|
1010
1027
|
const currentDirectory = process.cwd();
|
|
1011
1028
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1012
1029
|
|
|
@@ -1017,12 +1034,12 @@ export const updateComponentDefaultLibrary = async (library) => {
|
|
|
1017
1034
|
componentsDefault.library = library;
|
|
1018
1035
|
|
|
1019
1036
|
|
|
1020
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4),
|
|
1037
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1021
1038
|
|
|
1022
|
-
}
|
|
1039
|
+
}
|
|
1023
1040
|
|
|
1024
1041
|
export const updateComponentDefaultVersion = async (version) => {
|
|
1025
|
-
|
|
1042
|
+
if (showDebug) addDebugLog("updateComponentDefaultVersion", `version: ${version}`, "");
|
|
1026
1043
|
const currentDirectory = process.cwd();
|
|
1027
1044
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1028
1045
|
|
|
@@ -1033,21 +1050,21 @@ export const updateComponentDefaultVersion = async (version) => {
|
|
|
1033
1050
|
componentsDefault.version = version;
|
|
1034
1051
|
|
|
1035
1052
|
|
|
1036
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4),
|
|
1053
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(config, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1037
1054
|
|
|
1038
|
-
}
|
|
1055
|
+
}
|
|
1039
1056
|
|
|
1040
|
-
export const getConfigDevBuild = async
|
|
1041
|
-
|
|
1057
|
+
export const getConfigDevBuild = async() => {
|
|
1058
|
+
if (showDebug) addDebugLog("getConfigDevBuild", "", "");
|
|
1042
1059
|
// const serverConfig = await getPegaServerConfig();
|
|
1043
1060
|
|
|
1044
1061
|
// return serverConfig.devBuild;
|
|
1045
1062
|
return defaultConfigs.devBuild;
|
|
1046
1063
|
|
|
1047
|
-
}
|
|
1064
|
+
}
|
|
1048
1065
|
|
|
1049
1066
|
export const setConfigDevBuild = async (devBuild) => {
|
|
1050
|
-
|
|
1067
|
+
if (showDebug) addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
|
|
1051
1068
|
const currentDirectory = process.cwd();
|
|
1052
1069
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1053
1070
|
let configData = await getPegaConfig(true);
|
|
@@ -1056,19 +1073,19 @@ export const setConfigDevBuild = async (devBuild) => {
|
|
|
1056
1073
|
|
|
1057
1074
|
// update file
|
|
1058
1075
|
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
1059
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',
|
|
1060
|
-
}
|
|
1076
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1077
|
+
}
|
|
1061
1078
|
|
|
1062
|
-
export const getConfigDevServerPort = async
|
|
1063
|
-
|
|
1079
|
+
export const getConfigDevServerPort = async() => {
|
|
1080
|
+
if (showDebug) addDebugLog("getConfigDevServerPort", "", "");
|
|
1064
1081
|
// const serverConfig = await getPegaServerConfig();
|
|
1065
1082
|
|
|
1066
1083
|
return defaultConfigs.devServerPort;
|
|
1067
1084
|
|
|
1068
|
-
}
|
|
1085
|
+
}
|
|
1069
1086
|
|
|
1070
1087
|
export const setConfigImportRelativePath = async (importRelativePath) => {
|
|
1071
|
-
|
|
1088
|
+
if (showDebug) addDebugLog("setConfigImportRelativePath", `importRelativePath: ${importRelativePath}`, "");
|
|
1072
1089
|
const currentDirectory = process.cwd();
|
|
1073
1090
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1074
1091
|
let configData = await getPegaConfig(true);
|
|
@@ -1076,11 +1093,11 @@ export const setConfigImportRelativePath = async (importRelativePath) => {
|
|
|
1076
1093
|
|
|
1077
1094
|
// update file
|
|
1078
1095
|
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
1079
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',
|
|
1080
|
-
}
|
|
1096
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1097
|
+
}
|
|
1081
1098
|
|
|
1082
1099
|
export const setConfigExportRelativePath = async (exportRelativePath) => {
|
|
1083
|
-
|
|
1100
|
+
if (showDebug) addDebugLog("setConfigExportRelativePath", `exportRelativePath: ${exportRelativePath}`, "");
|
|
1084
1101
|
const currentDirectory = process.cwd();
|
|
1085
1102
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1086
1103
|
let configData = await getPegaConfig(true);
|
|
@@ -1088,21 +1105,21 @@ export const setConfigExportRelativePath = async (exportRelativePath) => {
|
|
|
1088
1105
|
|
|
1089
1106
|
// update file
|
|
1090
1107
|
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
1091
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',
|
|
1092
|
-
}
|
|
1108
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1109
|
+
}
|
|
1093
1110
|
|
|
1094
1111
|
export const updateDefaultOrganization = async (organization) => {
|
|
1095
|
-
|
|
1112
|
+
if (showDebug) addDebugLog("updateDefaultOrganization", `organization: ${organization}`, "");
|
|
1096
1113
|
let packageData = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf-8'));
|
|
1097
1114
|
|
|
1098
1115
|
packageData.organization = organization;
|
|
1099
1116
|
|
|
1100
|
-
fs.writeFileSync(path.resolve('package.json'), JSON.stringify(packageData, null, 4),
|
|
1117
|
+
fs.writeFileSync(path.resolve('package.json'), JSON.stringify(packageData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1101
1118
|
|
|
1102
|
-
}
|
|
1119
|
+
}
|
|
1103
1120
|
|
|
1104
1121
|
export const updateConfigVersion = async (componentKey, buildVersion, currentOrgLib) => {
|
|
1105
|
-
|
|
1122
|
+
if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}, buildVersion: ${buildVersion}, currentOrgLib: ${currentOrgLib}`, "");
|
|
1106
1123
|
const componentDirectory = await getComponentDirectoryPath(componentKey);
|
|
1107
1124
|
const configFileName = 'config.json';
|
|
1108
1125
|
|
|
@@ -1144,7 +1161,7 @@ export const updateConfigVersion = async (componentKey, buildVersion, currentOrg
|
|
|
1144
1161
|
}
|
|
1145
1162
|
else {
|
|
1146
1163
|
// don't have "About"
|
|
1147
|
-
const aboutLabelJSON =
|
|
1164
|
+
const aboutLabelJSON = {
|
|
1148
1165
|
"format": "LABEL",
|
|
1149
1166
|
"label": "About",
|
|
1150
1167
|
"name": "PegaAboutLabel",
|
|
@@ -1155,7 +1172,7 @@ export const updateConfigVersion = async (componentKey, buildVersion, currentOrg
|
|
|
1155
1172
|
"label": aboutData,
|
|
1156
1173
|
"name": "PegaAboutData",
|
|
1157
1174
|
"variant": "primary"
|
|
1158
|
-
}
|
|
1175
|
+
}
|
|
1159
1176
|
properties.push(aboutLabelJSON);
|
|
1160
1177
|
properties.push(aboutDataJSON);
|
|
1161
1178
|
}
|
|
@@ -1177,20 +1194,20 @@ export const updateConfigVersion = async (componentKey, buildVersion, currentOrg
|
|
|
1177
1194
|
|
|
1178
1195
|
|
|
1179
1196
|
// write back file
|
|
1180
|
-
fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8',
|
|
1197
|
+
fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1181
1198
|
};
|
|
1182
1199
|
|
|
1183
|
-
export const getServerType =
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1200
|
+
export const getServerType = () => {
|
|
1201
|
+
if (showDebug) addDebugLog("getServerType", "", "+");
|
|
1202
|
+
// const defaultPegaServerConfig = await getPegaServerConfig();
|
|
1203
|
+
// if (showDebug) addDebugLog("getServerType", "serverType:" + defaultPegaServerConfig.serverType, "");
|
|
1204
|
+
if (showDebug) addDebugLog("getServerType", "END", "-");
|
|
1188
1205
|
// return defaultPegaServerConfig.serverType;
|
|
1189
1206
|
return defaultConfigs.serverType;
|
|
1190
|
-
}
|
|
1207
|
+
}
|
|
1191
1208
|
|
|
1192
|
-
export const setServerType = async
|
|
1193
|
-
|
|
1209
|
+
export const setServerType = async(serverType) => {
|
|
1210
|
+
if (showDebug) addDebugLog("setServerType", `serverType: ${serverType}`, "");
|
|
1194
1211
|
const currentDirectory = process.cwd();
|
|
1195
1212
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1196
1213
|
let configData = await getPegaConfig(true);
|
|
@@ -1199,23 +1216,23 @@ export const setServerType = async (serverType) => {
|
|
|
1199
1216
|
|
|
1200
1217
|
// update file
|
|
1201
1218
|
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
1202
|
-
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',
|
|
1219
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
1203
1220
|
|
|
1204
1221
|
// reset
|
|
1205
1222
|
pegaData = null;
|
|
1206
1223
|
pegaConfig = null;
|
|
1207
1224
|
|
|
1208
1225
|
await forceDefaultsUpdate();
|
|
1209
|
-
}
|
|
1226
|
+
}
|
|
1210
1227
|
|
|
1211
1228
|
export const getSrcDirectoryPath = async () => {
|
|
1212
1229
|
const currentDirectory = process.cwd();
|
|
1213
1230
|
|
|
1214
1231
|
return join(currentDirectory, "src");
|
|
1215
|
-
}
|
|
1232
|
+
}
|
|
1216
1233
|
|
|
1217
1234
|
export const getComponentDirectoryPath = async (componentKey, overrideDir = null) => {
|
|
1218
|
-
|
|
1235
|
+
if (showDebug) addDebugLog("getComponentDirectoryPath", "", "+");
|
|
1219
1236
|
const currentDirectory = process.cwd();
|
|
1220
1237
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1221
1238
|
|
|
@@ -1230,14 +1247,14 @@ export const getComponentDirectoryPath = async (componentKey, overrideDir = null
|
|
|
1230
1247
|
);
|
|
1231
1248
|
process.exit(1);
|
|
1232
1249
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1250
|
+
if (showDebug) addDebugLog("getComponentDirectoryPath", "path: " + join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey), "");
|
|
1251
|
+
if (showDebug) addDebugLog("getComponentDirectoryPath", "END", "-");
|
|
1235
1252
|
return overrideDir ? join(overrideDir, componentKey) : join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
|
|
1236
1253
|
};
|
|
1237
1254
|
|
|
1238
1255
|
|
|
1239
1256
|
export const compileMustacheTemplate = (file, data) => {
|
|
1240
|
-
|
|
1257
|
+
if (showDebug) addDebugLog("compileMustacheTemplate", `file: ${file}`, "");
|
|
1241
1258
|
const content = fs.readFileSync(file, 'utf8');
|
|
1242
1259
|
return mustache.render(content, data);
|
|
1243
1260
|
};
|
|
@@ -1251,7 +1268,7 @@ export const convertIntoPascalCase = string => {
|
|
|
1251
1268
|
};
|
|
1252
1269
|
|
|
1253
1270
|
export const constructCompleteUrl = (baseServer, endPoint) => {
|
|
1254
|
-
|
|
1271
|
+
if (showDebug) addDebugLog("constructCompleteUrl", "url: " + baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`, "");
|
|
1255
1272
|
return baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`;
|
|
1256
1273
|
};
|
|
1257
1274
|
|
|
@@ -1306,7 +1323,7 @@ export const showVersion = async () => {
|
|
|
1306
1323
|
const nodeMajorVersion = parseInt(arNodeVersion[0]);
|
|
1307
1324
|
const nodeMinorVersion = parseInt(arNodeVersion[1]);
|
|
1308
1325
|
|
|
1309
|
-
if (nodeMajorVersion < 22 && nodeMinorVersion < 15) {
|
|
1326
|
+
if (nodeMajorVersion < 22 && nodeMinorVersion < 15 ) {
|
|
1310
1327
|
console.log(
|
|
1311
1328
|
chalk.redBright(
|
|
1312
1329
|
`DX Component Builder - SDK requires node v20.15.0 or greater, current version: ${process.version}`
|
|
@@ -1321,24 +1338,27 @@ export const showVersion = async () => {
|
|
|
1321
1338
|
|
|
1322
1339
|
};
|
|
1323
1340
|
|
|
1324
|
-
export const checkForBranch = async
|
|
1325
|
-
if (rulesetName === "") {
|
|
1326
|
-
const serverConfig = await getPegaServerConfig();
|
|
1327
|
-
rulesetName = serverConfig.rulesetName;
|
|
1328
|
-
}
|
|
1341
|
+
export const checkForBranch = async(rulesetName) => {
|
|
1329
1342
|
|
|
1330
|
-
if (
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1343
|
+
if (getServerType() === "infinity") {
|
|
1344
|
+
if (rulesetName === "") {
|
|
1345
|
+
const serverConfig = await getPegaServerConfig();
|
|
1346
|
+
rulesetName = serverConfig.rulesetName;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
if (rulesetName.toLowerCase().indexOf("_branch") >= 0) {
|
|
1350
|
+
console.log(
|
|
1351
|
+
chalk.redBright(
|
|
1352
|
+
`Ruleset ${chalk.bold(`${rulesetName}`)} cannot be a branch ruleset.`
|
|
1353
|
+
)
|
|
1354
|
+
);
|
|
1355
|
+
process.exit(1);
|
|
1356
|
+
}
|
|
1337
1357
|
}
|
|
1338
|
-
}
|
|
1358
|
+
}
|
|
1339
1359
|
|
|
1340
1360
|
export const getOOTBComponents = async () => {
|
|
1341
|
-
|
|
1361
|
+
if (showDebug) addDebugLog("getOOTBComponents", "", "");
|
|
1342
1362
|
return new Promise(resolve => {
|
|
1343
1363
|
fs.readFile(OOTB_COMPONENTS, 'utf-8', async (error, ootbComponentsData) => {
|
|
1344
1364
|
if (error) {
|
|
@@ -1391,7 +1411,7 @@ export const getOOTBComponents = async () => {
|
|
|
1391
1411
|
};
|
|
1392
1412
|
|
|
1393
1413
|
export const deleteInfinityServerComponent = async componentKey => {
|
|
1394
|
-
|
|
1414
|
+
if (showDebug) addDebugLog("deleteInfinityServerComponent", `componentKey: ${componentKey}`, "");
|
|
1395
1415
|
const serverConfig = await getPegaServerConfig();
|
|
1396
1416
|
const { server } = serverConfig;
|
|
1397
1417
|
const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
|
|
@@ -1422,13 +1442,13 @@ export const deleteInfinityServerComponent = async componentKey => {
|
|
|
1422
1442
|
// console.log(accessTokenUri, refreshToken);
|
|
1423
1443
|
/* TODO - Handle refresh_token */
|
|
1424
1444
|
}
|
|
1425
|
-
else if (status === 404)
|
|
1445
|
+
else if (status === 404){
|
|
1426
1446
|
throw new Error('404: Server resource not found');
|
|
1427
1447
|
}
|
|
1428
|
-
else if (status === 405)
|
|
1448
|
+
else if (status === 405){
|
|
1429
1449
|
throw new Error('405: Server method not allowed');
|
|
1430
1450
|
}
|
|
1431
|
-
else if (status === 408)
|
|
1451
|
+
else if (status === 408){
|
|
1432
1452
|
throw new Error('408: Server timed out');
|
|
1433
1453
|
}
|
|
1434
1454
|
else if (response.status === 403) {
|
|
@@ -1443,7 +1463,7 @@ export const deleteInfinityServerComponent = async componentKey => {
|
|
|
1443
1463
|
try {
|
|
1444
1464
|
const respData = await response.json();
|
|
1445
1465
|
console.log(
|
|
1446
|
-
|
|
1466
|
+
chalk.bold.green(`Success : ${respData.message}`)
|
|
1447
1467
|
);
|
|
1448
1468
|
|
|
1449
1469
|
if (status === 500) {
|
|
@@ -1453,12 +1473,12 @@ export const deleteInfinityServerComponent = async componentKey => {
|
|
|
1453
1473
|
}
|
|
1454
1474
|
catch (err) {
|
|
1455
1475
|
if (status === 500) {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1476
|
+
throw new Error(
|
|
1477
|
+
`Error occurred in authentication. Please regenerate using authenticate`
|
|
1478
|
+
);
|
|
1459
1479
|
}
|
|
1460
1480
|
else if (status === 999) {
|
|
1461
|
-
throw new Error(err);
|
|
1481
|
+
throw new Error (err);
|
|
1462
1482
|
}
|
|
1463
1483
|
}
|
|
1464
1484
|
|
|
@@ -1470,7 +1490,7 @@ export const deleteInfinityServerComponent = async componentKey => {
|
|
|
1470
1490
|
};
|
|
1471
1491
|
|
|
1472
1492
|
export const deleteInfinityServerComponentLibrary = async (libraryName, rulesetName, rulesetVersion) => {
|
|
1473
|
-
|
|
1493
|
+
if (showDebug) addDebugLog("deleteInfinityServerComponentLibrary", `componentKey: ${componentKey}, rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
|
|
1474
1494
|
const serverConfig = await getPegaServerConfig();
|
|
1475
1495
|
const { server } = serverConfig;
|
|
1476
1496
|
const url = constructCompleteUrl(server, DELETE_COMPONENT_LIBRARY_SERVICE_REST_ENDPOINT);
|
|
@@ -1507,13 +1527,13 @@ export const deleteInfinityServerComponentLibrary = async (libraryName, rulesetN
|
|
|
1507
1527
|
// console.log(accessTokenUri, refreshToken);
|
|
1508
1528
|
/* TODO - Handle refresh_token */
|
|
1509
1529
|
}
|
|
1510
|
-
else if (status === 404)
|
|
1530
|
+
else if (status === 404){
|
|
1511
1531
|
throw new Error('404: Server resource not found');
|
|
1512
1532
|
}
|
|
1513
|
-
else if (status === 405)
|
|
1533
|
+
else if (status === 405){
|
|
1514
1534
|
throw new Error('405: Server method not allowed');
|
|
1515
1535
|
}
|
|
1516
|
-
else if (status === 408)
|
|
1536
|
+
else if (status === 408){
|
|
1517
1537
|
throw new Error('408: Server timed out');
|
|
1518
1538
|
}
|
|
1519
1539
|
else if (response.status === 403) {
|
|
@@ -1542,12 +1562,12 @@ export const deleteInfinityServerComponentLibrary = async (libraryName, rulesetN
|
|
|
1542
1562
|
}
|
|
1543
1563
|
catch (err) {
|
|
1544
1564
|
if (status === 500) {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1565
|
+
throw new Error(
|
|
1566
|
+
`Error occurred in authentication. Please regenerate using authenticate`
|
|
1567
|
+
);
|
|
1548
1568
|
}
|
|
1549
1569
|
else if (status === 999) {
|
|
1550
|
-
throw new Error(err);
|
|
1570
|
+
throw new Error (err);
|
|
1551
1571
|
}
|
|
1552
1572
|
}
|
|
1553
1573
|
|
|
@@ -1560,7 +1580,7 @@ export const deleteInfinityServerComponentLibrary = async (libraryName, rulesetN
|
|
|
1560
1580
|
|
|
1561
1581
|
|
|
1562
1582
|
export const deleteLaunchpadServerComponent = async componentKey => {
|
|
1563
|
-
|
|
1583
|
+
if (showDebug) addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "");
|
|
1564
1584
|
const { server, isolationId } = await getPegaServerConfig();
|
|
1565
1585
|
const deleteUrl = constructCompleteUrl(
|
|
1566
1586
|
server,
|
|
@@ -1604,13 +1624,13 @@ export const deleteLaunchpadServerComponent = async componentKey => {
|
|
|
1604
1624
|
// console.log(accessTokenUri, refreshToken);
|
|
1605
1625
|
/* TODO - Handle refresh_token */
|
|
1606
1626
|
}
|
|
1607
|
-
else if (status === 404)
|
|
1627
|
+
else if (status === 404){
|
|
1608
1628
|
throw new Error('404: Server resource not found');
|
|
1609
1629
|
}
|
|
1610
|
-
else if (status === 405)
|
|
1630
|
+
else if (status === 405){
|
|
1611
1631
|
throw new Error('405: Server method not allowed');
|
|
1612
1632
|
}
|
|
1613
|
-
else if (status === 408)
|
|
1633
|
+
else if (status === 408){
|
|
1614
1634
|
throw new Error('408: Server timed out');
|
|
1615
1635
|
}
|
|
1616
1636
|
else if (response.status === 403) {
|
|
@@ -1623,7 +1643,7 @@ export const deleteLaunchpadServerComponent = async componentKey => {
|
|
|
1623
1643
|
try {
|
|
1624
1644
|
const respData = await response.text();
|
|
1625
1645
|
console.log(
|
|
1626
|
-
|
|
1646
|
+
chalk.bold.green(`Success : ${respData}`)
|
|
1627
1647
|
);
|
|
1628
1648
|
|
|
1629
1649
|
if (status === 500) {
|
|
@@ -1633,12 +1653,12 @@ export const deleteLaunchpadServerComponent = async componentKey => {
|
|
|
1633
1653
|
}
|
|
1634
1654
|
catch (err) {
|
|
1635
1655
|
if (status === 500) {
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1656
|
+
throw new Error(
|
|
1657
|
+
`Error occurred in authentication. Please regenerate using authenticate`
|
|
1658
|
+
);
|
|
1639
1659
|
}
|
|
1640
1660
|
else if (status === 999) {
|
|
1641
|
-
throw new Error(err);
|
|
1661
|
+
throw new Error (err);
|
|
1642
1662
|
}
|
|
1643
1663
|
}
|
|
1644
1664
|
}
|
|
@@ -1648,7 +1668,7 @@ export const deleteLaunchpadServerComponent = async componentKey => {
|
|
|
1648
1668
|
};
|
|
1649
1669
|
|
|
1650
1670
|
export const getBootstrapConfig = async (restServerUrl, authorizationHeader) => {
|
|
1651
|
-
|
|
1671
|
+
if (showDebug) addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl}`, "");
|
|
1652
1672
|
const serverConfig = await getPegaServerConfig();
|
|
1653
1673
|
|
|
1654
1674
|
return fetch(`${restServerUrl}/${BOOTSTRAP_CONFIG}`, {
|
|
@@ -1666,7 +1686,7 @@ export const getBootstrapConfig = async (restServerUrl, authorizationHeader) =>
|
|
|
1666
1686
|
};
|
|
1667
1687
|
|
|
1668
1688
|
export const updateC11NB2SForInfinity = async () => {
|
|
1669
|
-
|
|
1689
|
+
if (showDebug) addDebugLog("updateC11NB2SForInfinity", "", "");
|
|
1670
1690
|
const serverConfig = await getPegaServerConfig();
|
|
1671
1691
|
const { server } = serverConfig;
|
|
1672
1692
|
const OAuthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
@@ -1685,7 +1705,7 @@ export const updateC11NB2SForInfinity = async () => {
|
|
|
1685
1705
|
objOauthData["appStaticContentServer"] = (bootstrap.serviceConfig.appStaticContentServer != "no-cdn" && bootstrap.serviceConfig.appStaticContentServer != "") ? bootstrap.serviceConfig.appStaticContentServer : bootstrap.serviceConfig.staticContentServer;
|
|
1686
1706
|
|
|
1687
1707
|
// write out file
|
|
1688
|
-
fs.writeFileSync(TOKEN_PATH, JSON.stringify(objOauthData), { encoding: 'utf8',
|
|
1708
|
+
fs.writeFileSync(TOKEN_PATH, JSON.stringify(objOauthData), { encoding: 'utf8',flag:'w' });
|
|
1689
1709
|
}
|
|
1690
1710
|
|
|
1691
1711
|
}
|
|
@@ -1698,7 +1718,7 @@ export const updateC11NB2SForLaunchpad = async () => {
|
|
|
1698
1718
|
};
|
|
1699
1719
|
|
|
1700
1720
|
export const getC11NB2STokenAndStaticServer = async () => {
|
|
1701
|
-
|
|
1721
|
+
if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
|
|
1702
1722
|
const serverConfig = await getPegaServerConfig();
|
|
1703
1723
|
const { server } = serverConfig;
|
|
1704
1724
|
let OAuthData;
|
|
@@ -1710,28 +1730,28 @@ export const getC11NB2STokenAndStaticServer = async () => {
|
|
|
1710
1730
|
}
|
|
1711
1731
|
|
|
1712
1732
|
if (OAuthData) {
|
|
1713
|
-
const { C11NB2S, appStaticContentServer, access_token } = JSON.parse(OAuthData)
|
|
1733
|
+
const { C11NB2S, appStaticContentServer, access_token } = JSON.parse(OAuthData)
|
|
1714
1734
|
|
|
1715
|
-
return ({ C11NB2S, appStaticContentServer, access_token
|
|
1735
|
+
return ({ C11NB2S, appStaticContentServer, access_token});
|
|
1716
1736
|
|
|
1717
1737
|
}
|
|
1718
1738
|
return ({});
|
|
1719
1739
|
};
|
|
1720
1740
|
|
|
1721
1741
|
export const getLocalLibraries = async () => {
|
|
1722
|
-
|
|
1742
|
+
if (showDebug) addDebugLog("getLocalLibraries", "" , "");
|
|
1723
1743
|
const currentDirectory = process.cwd();
|
|
1724
1744
|
const configDef = getConfigDefaults();
|
|
1725
1745
|
const libFilter = configDef.organization.concat("_");
|
|
1726
1746
|
|
|
1727
1747
|
return fs
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
}
|
|
1748
|
+
.readdirSync(currentDirectory, { withFileTypes: true })
|
|
1749
|
+
.filter(dirent => dirent.isDirectory() && dirent.name.startsWith(libFilter))
|
|
1750
|
+
.map(dirent => dirent.name);
|
|
1751
|
+
}
|
|
1732
1752
|
|
|
1733
1753
|
export const getLocalLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
|
|
1734
|
-
|
|
1754
|
+
if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
|
|
1735
1755
|
const currentDirectory = process.cwd();
|
|
1736
1756
|
|
|
1737
1757
|
const directory = join(currentDirectory, libraryName);
|
|
@@ -1742,9 +1762,9 @@ export const getLocalLibraryVersions = async (libraryName, currentVersion = "0.0
|
|
|
1742
1762
|
};
|
|
1743
1763
|
|
|
1744
1764
|
export const getLocalArchivedLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
|
|
1745
|
-
|
|
1765
|
+
if (showDebug) addDebugLog("getLocalArchivedLibraryVersions", `libraryName: ${libraryName}` , "");
|
|
1746
1766
|
const currentDirectory = process.cwd();
|
|
1747
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${libraryName}`);
|
|
1767
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${libraryName}`);
|
|
1748
1768
|
|
|
1749
1769
|
return fs
|
|
1750
1770
|
.readdirSync(archiveDirectory, { withFileTypes: true })
|
|
@@ -1752,31 +1772,31 @@ export const getLocalArchivedLibraryVersions = async (libraryName, currentVersio
|
|
|
1752
1772
|
.map(dirent => dirent.name);
|
|
1753
1773
|
};
|
|
1754
1774
|
|
|
1755
|
-
export const getLocalArchivedLibrraryVersionData = async
|
|
1756
|
-
|
|
1775
|
+
export const getLocalArchivedLibrraryVersionData = async(libraryName, libraryVersion) => {
|
|
1776
|
+
if (showDebug) addDebugLog("getLocalArchivedLibrraryVersionData", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}`, "");
|
|
1757
1777
|
const currentDirectory = process.cwd();
|
|
1758
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${libraryName}`, `${libraryVersion}`);
|
|
1778
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${libraryName}`, `${libraryVersion}`);
|
|
1759
1779
|
|
|
1760
|
-
const componentConfigFile = join(archiveDirectory, COMPONENTS_CONFIG_FILE_NAME);
|
|
1780
|
+
const componentConfigFile = join (archiveDirectory, COMPONENTS_CONFIG_FILE_NAME);
|
|
1761
1781
|
|
|
1762
|
-
let data = fs.readFileSync(componentConfigFile, { encoding: 'utf8' })
|
|
1782
|
+
let data = fs.readFileSync(componentConfigFile, { encoding: 'utf8' })
|
|
1763
1783
|
|
|
1764
1784
|
return data;
|
|
1765
|
-
}
|
|
1785
|
+
}
|
|
1766
1786
|
|
|
1767
1787
|
export const getLocalLibraryVersionData = async (libraryName, libraryVersion) => {
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1788
|
+
if (showDebug) addDebugLog("getLocalLibraryVersionDate", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
|
|
1789
|
+
const currentDirectory = process.cwd();
|
|
1790
|
+
const libDir = join(currentDirectory, libraryName, libraryVersion);
|
|
1791
|
+
const libDataFile = join(libDir, COMPONENTS_CONFIG_FILE_NAME);
|
|
1772
1792
|
|
|
1773
|
-
|
|
1793
|
+
let data = fs.readFileSync(libDataFile, { encoding: 'utf8' })
|
|
1774
1794
|
|
|
1775
|
-
|
|
1795
|
+
return data;
|
|
1776
1796
|
};
|
|
1777
1797
|
|
|
1778
1798
|
export const deleteLocalLibrary = async (libraryName) => {
|
|
1779
|
-
|
|
1799
|
+
if (showDebug) addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}` , "");
|
|
1780
1800
|
const currentDirectory = process.cwd();
|
|
1781
1801
|
|
|
1782
1802
|
const directory = join(currentDirectory, libraryName);
|
|
@@ -1805,7 +1825,7 @@ export const deleteLocalLibrary = async (libraryName) => {
|
|
|
1805
1825
|
};
|
|
1806
1826
|
|
|
1807
1827
|
export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) => {
|
|
1808
|
-
|
|
1828
|
+
if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
|
|
1809
1829
|
const currentDirectory = process.cwd();
|
|
1810
1830
|
|
|
1811
1831
|
const directory = join(currentDirectory, libraryName, libraryVersion);
|
|
@@ -1813,7 +1833,7 @@ export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) =>
|
|
|
1813
1833
|
try {
|
|
1814
1834
|
if (fs.existsSync(directory)) {
|
|
1815
1835
|
console.log(`Deleting library version: ${chalk.green.bold(libraryName)}:${chalk.green.bold(libraryVersion)}`);
|
|
1816
|
-
fs.rmSync(directory, { recursive: true, force: true, maxRetries: 2
|
|
1836
|
+
fs.rmSync(directory, { recursive: true, force: true, maxRetries: 2 });
|
|
1817
1837
|
console.log(`Library version: ${chalk.green.bold(libraryName)}:${chalk.green.bold(libraryVersion)} is deleted from Local`);
|
|
1818
1838
|
}
|
|
1819
1839
|
else {
|
|
@@ -1828,7 +1848,7 @@ export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) =>
|
|
|
1828
1848
|
};
|
|
1829
1849
|
|
|
1830
1850
|
export const deletePublishExtras = async (libraryName, libraryVersion) => {
|
|
1831
|
-
|
|
1851
|
+
if (showDebug) addDebugLog("deletePublishExtras", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
|
|
1832
1852
|
// this function will delete LibraryName.zip file, so new one created by publish
|
|
1833
1853
|
// check if .DS_store file exists in Library, if so delete it because causes issue with services
|
|
1834
1854
|
|
|
@@ -1852,7 +1872,7 @@ export const deletePublishExtras = async (libraryName, libraryVersion) => {
|
|
|
1852
1872
|
|
|
1853
1873
|
|
|
1854
1874
|
export const cleanUp = async () => {
|
|
1855
|
-
|
|
1875
|
+
if (showDebug) addDebugLog("cleanUp", "", "");
|
|
1856
1876
|
if (fs.existsSync('dist/components')) {
|
|
1857
1877
|
fs.rm('dist/components', { recursive: true }, err => {
|
|
1858
1878
|
if (err) {
|
|
@@ -1872,7 +1892,7 @@ export const cleanUp = async () => {
|
|
|
1872
1892
|
};
|
|
1873
1893
|
|
|
1874
1894
|
export const getComponentsConfigs = async (compDir = null) => {
|
|
1875
|
-
|
|
1895
|
+
if (showDebug) addDebugLog("getComponentsConfigs", "", "");
|
|
1876
1896
|
const componentsList = await getComponents(compDir);
|
|
1877
1897
|
|
|
1878
1898
|
let componentsConfigJSON = [];
|
|
@@ -1894,22 +1914,22 @@ export const getComponentsConfigs = async (compDir = null) => {
|
|
|
1894
1914
|
}
|
|
1895
1915
|
}
|
|
1896
1916
|
return componentsConfigJSON;
|
|
1897
|
-
}
|
|
1917
|
+
}
|
|
1898
1918
|
|
|
1899
1919
|
|
|
1900
1920
|
export const createComponentsConfigFile = async (filePath, compDir) => {
|
|
1901
|
-
|
|
1921
|
+
if (showDebug) addDebugLog("createComponentsConfigFile", `filePath: ${filePath}`, "");
|
|
1902
1922
|
const componentsConfigJSON = await getComponentsConfigs(compDir);
|
|
1903
1923
|
const compConfgFile = join(filePath, COMPONENTS_CONFIG_FILE_NAME);
|
|
1904
1924
|
|
|
1905
1925
|
// write out file
|
|
1906
|
-
fs.writeFileSync(compConfgFile, JSON.stringify(componentsConfigJSON), { encoding: 'utf8',
|
|
1926
|
+
fs.writeFileSync(compConfgFile, JSON.stringify(componentsConfigJSON), { encoding: 'utf8',flag:'w' });
|
|
1907
1927
|
|
|
1908
1928
|
};
|
|
1909
1929
|
|
|
1910
1930
|
|
|
1911
1931
|
export const zipVersionAndArchive = async (orgLibName, version, currentDirectory = "") => {
|
|
1912
|
-
|
|
1932
|
+
if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
|
|
1913
1933
|
// const srcDirectoryPath = await getSrcDirectoryPath();
|
|
1914
1934
|
if (currentDirectory === "") {
|
|
1915
1935
|
currentDirectory = process.cwd();
|
|
@@ -1922,7 +1942,7 @@ export const zipVersionAndArchive = async (orgLibName, version, currentDirectory
|
|
|
1922
1942
|
|
|
1923
1943
|
// const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
|
|
1924
1944
|
const mainDirectory = process.cwd();
|
|
1925
|
-
const archiveDirectory = join(mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
1945
|
+
const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
1926
1946
|
if (!fs.existsSync(archiveDirectory)) {
|
|
1927
1947
|
fs.mkdirSync(archiveDirectory, { recursive: true });
|
|
1928
1948
|
}
|
|
@@ -1961,13 +1981,13 @@ export const zipVersionAndArchive = async (orgLibName, version, currentDirectory
|
|
|
1961
1981
|
// pipe archive data to the file
|
|
1962
1982
|
archive.pipe(output);
|
|
1963
1983
|
|
|
1964
|
-
output.on('end', function
|
|
1984
|
+
output.on('end', function() {
|
|
1965
1985
|
console.log('Data has been drained');
|
|
1966
1986
|
});
|
|
1967
1987
|
|
|
1968
1988
|
|
|
1969
1989
|
// good practice to catch warnings (ie stat failures and other non-blocking errors)
|
|
1970
|
-
archive.on('warning', function
|
|
1990
|
+
archive.on('warning', function(err) {
|
|
1971
1991
|
if (err.code === 'ENOENT') {
|
|
1972
1992
|
// log warning
|
|
1973
1993
|
} else {
|
|
@@ -1977,7 +1997,7 @@ export const zipVersionAndArchive = async (orgLibName, version, currentDirectory
|
|
|
1977
1997
|
});
|
|
1978
1998
|
|
|
1979
1999
|
// good practice to catch this error explicitly
|
|
1980
|
-
archive.on('error', function
|
|
2000
|
+
archive.on('error', function(err) {
|
|
1981
2001
|
throw err;
|
|
1982
2002
|
});
|
|
1983
2003
|
|
|
@@ -1991,7 +2011,7 @@ export const zipVersionAndArchive = async (orgLibName, version, currentDirectory
|
|
|
1991
2011
|
|
|
1992
2012
|
|
|
1993
2013
|
export const zipVersionAndArchiveAndReturnBuffer = async (orgLibName, version, currentDirectory = "") => {
|
|
1994
|
-
|
|
2014
|
+
if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, version: ${version}`, "");
|
|
1995
2015
|
// const srcDirectoryPath = await getSrcDirectoryPath();
|
|
1996
2016
|
if (currentDirectory === "") {
|
|
1997
2017
|
currentDirectory = process.cwd();
|
|
@@ -2004,7 +2024,7 @@ export const zipVersionAndArchiveAndReturnBuffer = async (orgLibName, version, c
|
|
|
2004
2024
|
|
|
2005
2025
|
// const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
|
|
2006
2026
|
const mainDirectory = process.cwd();
|
|
2007
|
-
const archiveDirectory = join(mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
2027
|
+
const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
2008
2028
|
if (!fs.existsSync(archiveDirectory)) {
|
|
2009
2029
|
fs.mkdirSync(archiveDirectory, { recursive: true });
|
|
2010
2030
|
}
|
|
@@ -2044,13 +2064,13 @@ export const zipVersionAndArchiveAndReturnBuffer = async (orgLibName, version, c
|
|
|
2044
2064
|
// pipe archive data to the file
|
|
2045
2065
|
archive.pipe(output);
|
|
2046
2066
|
|
|
2047
|
-
output.on('end', function
|
|
2067
|
+
output.on('end', function() {
|
|
2048
2068
|
console.log('Data has been drained');
|
|
2049
2069
|
});
|
|
2050
2070
|
|
|
2051
2071
|
|
|
2052
2072
|
// good practice to catch warnings (ie stat failures and other non-blocking errors)
|
|
2053
|
-
archive.on('warning', function
|
|
2073
|
+
archive.on('warning', function(err) {
|
|
2054
2074
|
if (err.code === 'ENOENT') {
|
|
2055
2075
|
// log warning
|
|
2056
2076
|
} else {
|
|
@@ -2060,7 +2080,7 @@ export const zipVersionAndArchiveAndReturnBuffer = async (orgLibName, version, c
|
|
|
2060
2080
|
});
|
|
2061
2081
|
|
|
2062
2082
|
// good practice to catch this error explicitly
|
|
2063
|
-
archive.on('error', function
|
|
2083
|
+
archive.on('error', function(err) {
|
|
2064
2084
|
throw err;
|
|
2065
2085
|
});
|
|
2066
2086
|
|
|
@@ -2069,19 +2089,19 @@ export const zipVersionAndArchiveAndReturnBuffer = async (orgLibName, version, c
|
|
|
2069
2089
|
const zipBuffer = Buffer.concat(zipChunks);
|
|
2070
2090
|
const zipContent = zipBuffer.toString('base64');
|
|
2071
2091
|
|
|
2072
|
-
return { output, zipContent
|
|
2092
|
+
return { output, zipContent};
|
|
2073
2093
|
|
|
2074
2094
|
};
|
|
2075
2095
|
|
|
2076
|
-
export const zipUnArchiveToTempAndReturnBuffer = async
|
|
2096
|
+
export const zipUnArchiveToTempAndReturnBuffer = async(orgLibName, version) => {
|
|
2077
2097
|
|
|
2078
2098
|
// unarchive to temp
|
|
2079
2099
|
const currentDirectory = process.cwd();
|
|
2080
|
-
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
2100
|
+
const tempDirectory = join (currentDirectory, TEMP_PATH);
|
|
2081
2101
|
const srcDirectoryPath = join(tempDirectory, "src");
|
|
2082
2102
|
|
|
2083
2103
|
const archiveFileName = `${orgLibName}_${version}.arch.zip`;
|
|
2084
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
2104
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
2085
2105
|
const archFileName = join(archiveDirectory, archiveFileName);
|
|
2086
2106
|
|
|
2087
2107
|
await unZipFromArchive(archFileName);
|
|
@@ -2115,13 +2135,13 @@ export const zipUnArchiveToTempAndReturnBuffer = async (orgLibName, version) =>
|
|
|
2115
2135
|
// pipe archive data to the file
|
|
2116
2136
|
archive.pipe(output);
|
|
2117
2137
|
|
|
2118
|
-
output.on('end', function
|
|
2138
|
+
output.on('end', function() {
|
|
2119
2139
|
console.log('Data has been drained');
|
|
2120
2140
|
});
|
|
2121
2141
|
|
|
2122
2142
|
|
|
2123
2143
|
// good practice to catch warnings (ie stat failures and other non-blocking errors)
|
|
2124
|
-
archive.on('warning', function
|
|
2144
|
+
archive.on('warning', function(err) {
|
|
2125
2145
|
if (err.code === 'ENOENT') {
|
|
2126
2146
|
// log warning
|
|
2127
2147
|
} else {
|
|
@@ -2131,7 +2151,7 @@ export const zipUnArchiveToTempAndReturnBuffer = async (orgLibName, version) =>
|
|
|
2131
2151
|
});
|
|
2132
2152
|
|
|
2133
2153
|
// good practice to catch this error explicitly
|
|
2134
|
-
archive.on('error', function
|
|
2154
|
+
archive.on('error', function(err) {
|
|
2135
2155
|
throw err;
|
|
2136
2156
|
});
|
|
2137
2157
|
|
|
@@ -2140,13 +2160,13 @@ export const zipUnArchiveToTempAndReturnBuffer = async (orgLibName, version) =>
|
|
|
2140
2160
|
const zipBuffer = Buffer.concat(zipChunks);
|
|
2141
2161
|
const zipContent = zipBuffer.toString('base64');
|
|
2142
2162
|
|
|
2143
|
-
return { output, zipContent
|
|
2163
|
+
return { output, zipContent};
|
|
2144
2164
|
|
|
2145
2165
|
|
|
2146
|
-
}
|
|
2166
|
+
}
|
|
2147
2167
|
|
|
2148
2168
|
export const zipVersionAndArchiveCL = async (orgLibName, version, currentDirectory = "") => {
|
|
2149
|
-
|
|
2169
|
+
if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName}, version: ${version}, currentDirectory: ${currentDirectory}`, "");
|
|
2150
2170
|
// const srcDirectoryPath = await getSrcDirectoryPath();
|
|
2151
2171
|
if (currentDirectory === "") {
|
|
2152
2172
|
currentDirectory = process.cwd();
|
|
@@ -2159,7 +2179,7 @@ export const zipVersionAndArchiveCL = async (orgLibName, version, currentDirecto
|
|
|
2159
2179
|
|
|
2160
2180
|
// const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
|
|
2161
2181
|
const mainDirectory = process.cwd();
|
|
2162
|
-
const archiveDirectory = join(mainDirectory, BIN_ARCHIVES_PATH);
|
|
2182
|
+
const archiveDirectory = join (mainDirectory, BIN_ARCHIVES_PATH);
|
|
2163
2183
|
if (!fs.existsSync(archiveDirectory)) {
|
|
2164
2184
|
fs.mkdirSync(archiveDirectory, { recursive: true });
|
|
2165
2185
|
}
|
|
@@ -2185,13 +2205,13 @@ export const zipVersionAndArchiveCL = async (orgLibName, version, currentDirecto
|
|
|
2185
2205
|
// pipe archive data to the file
|
|
2186
2206
|
archive.pipe(output);
|
|
2187
2207
|
|
|
2188
|
-
output.on('end', function
|
|
2208
|
+
output.on('end', function() {
|
|
2189
2209
|
console.log('Data has been drained');
|
|
2190
2210
|
});
|
|
2191
2211
|
|
|
2192
2212
|
|
|
2193
2213
|
// good practice to catch warnings (ie stat failures and other non-blocking errors)
|
|
2194
|
-
archive.on('warning', function
|
|
2214
|
+
archive.on('warning', function(err) {
|
|
2195
2215
|
if (err.code === 'ENOENT') {
|
|
2196
2216
|
// log warning
|
|
2197
2217
|
} else {
|
|
@@ -2201,7 +2221,7 @@ export const zipVersionAndArchiveCL = async (orgLibName, version, currentDirecto
|
|
|
2201
2221
|
});
|
|
2202
2222
|
|
|
2203
2223
|
// good practice to catch this error explicitly
|
|
2204
|
-
archive.on('error', function
|
|
2224
|
+
archive.on('error', function(err) {
|
|
2205
2225
|
throw err;
|
|
2206
2226
|
});
|
|
2207
2227
|
|
|
@@ -2212,14 +2232,14 @@ export const zipVersionAndArchiveCL = async (orgLibName, version, currentDirecto
|
|
|
2212
2232
|
};
|
|
2213
2233
|
|
|
2214
2234
|
export const unZipFromArchive = async (fileName) => {
|
|
2215
|
-
|
|
2235
|
+
if (showDebug) addDebugLog("unZipFromArchive", `fileName: ${fileName}`, "");
|
|
2216
2236
|
await unarchive(fileName, TEMP_PATH);
|
|
2217
2237
|
};
|
|
2218
2238
|
|
|
2219
2239
|
|
|
2220
2240
|
|
|
2221
2241
|
export const updateComponentTaskConfig = async () => {
|
|
2222
|
-
|
|
2242
|
+
if (showDebug) addDebugLog("updateComponentTaskConfig", "", "");
|
|
2223
2243
|
const currentDirectory = process.cwd();
|
|
2224
2244
|
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
2225
2245
|
|
|
@@ -2232,6 +2252,8 @@ export const updateComponentTaskConfig = async () => {
|
|
|
2232
2252
|
let originalContentsData = JSON.parse(originalContents);
|
|
2233
2253
|
const orgRuleset = originalContentsData["server-config"].rulesetName;
|
|
2234
2254
|
const orgRulesetVersion = originalContentsData["server-config"].rulesetVersion;
|
|
2255
|
+
const orgArchiveRuleset = originalContentsData["server-config"].archiveRulesetName;
|
|
2256
|
+
const orgArchiveRulesetVersion = originalContentsData["server-config"].archiveRulesetVersion;
|
|
2235
2257
|
|
|
2236
2258
|
// we keep server-config but we will restore from archive the
|
|
2237
2259
|
// rulset/version. Other stuff in task.config will come from archive
|
|
@@ -2239,22 +2261,24 @@ export const updateComponentTaskConfig = async () => {
|
|
|
2239
2261
|
// restore ruleset and verion
|
|
2240
2262
|
originalContentsData["server-config"].rulesetName = orgRuleset;
|
|
2241
2263
|
originalContentsData["server-config"].rulesetVersion = orgRulesetVersion;
|
|
2264
|
+
originalContentsData["server-config"].archiveRulesetName = orgArchiveRuleset;
|
|
2265
|
+
originalContentsData["server-config"].archiveRulesetVersion = orgArchiveRulesetVersion;
|
|
2242
2266
|
|
|
2243
2267
|
|
|
2244
2268
|
// if we don't have a devServerPort, add the default
|
|
2245
2269
|
if (originalContentsData["server-config"].devServerPort === undefined) {
|
|
2246
|
-
originalContentsData["server-config"].devServerPort = "3030"
|
|
2270
|
+
originalContentsData["server-config"].devServerPort = "3030"
|
|
2247
2271
|
}
|
|
2248
2272
|
|
|
2249
|
-
fs.writeFileSync(currentConfigPath, JSON.stringify(originalContentsData, null, 4), { encoding: 'utf8',
|
|
2273
|
+
fs.writeFileSync(currentConfigPath, JSON.stringify(originalContentsData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
2250
2274
|
|
|
2251
|
-
}
|
|
2275
|
+
}
|
|
2252
2276
|
|
|
2253
2277
|
export const restoreDependenciesFromPackage = async () => {
|
|
2254
|
-
|
|
2278
|
+
if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
|
|
2255
2279
|
const currentDirectory = process.cwd();
|
|
2256
2280
|
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
2257
|
-
const tempPackagePath = join(tempDirectory, PACKAGE_JSON_FILENAME);
|
|
2281
|
+
const tempPackagePath = join (tempDirectory, PACKAGE_JSON_FILENAME);
|
|
2258
2282
|
const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
|
|
2259
2283
|
|
|
2260
2284
|
let retrievedPackageData;
|
|
@@ -2267,7 +2291,7 @@ export const restoreDependenciesFromPackage = async () => {
|
|
|
2267
2291
|
retrievedPackageData = fs.readFileSync(tempPackagePath);
|
|
2268
2292
|
}
|
|
2269
2293
|
catch (ex) {
|
|
2270
|
-
console.log(chalk.red(`\nUnable to retrieve package.json from store.`))
|
|
2294
|
+
console.log(chalk.red(`\nUnable to retrieve package.json from store.`))
|
|
2271
2295
|
process.exit(1);
|
|
2272
2296
|
}
|
|
2273
2297
|
|
|
@@ -2275,7 +2299,7 @@ export const restoreDependenciesFromPackage = async () => {
|
|
|
2275
2299
|
currentPackageData = fs.readFileSync(currentPackagePath);
|
|
2276
2300
|
}
|
|
2277
2301
|
catch (ex) {
|
|
2278
|
-
console.log(chalk.red(`\nUnable to retrieve current package.json.`))
|
|
2302
|
+
console.log(chalk.red(`\nUnable to retrieve current package.json.`))
|
|
2279
2303
|
process.exit(1);
|
|
2280
2304
|
}
|
|
2281
2305
|
|
|
@@ -2313,7 +2337,7 @@ export const restoreDependenciesFromPackage = async () => {
|
|
|
2313
2337
|
retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
|
|
2314
2338
|
}
|
|
2315
2339
|
catch (ex) {
|
|
2316
|
-
console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
|
|
2340
|
+
console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
|
|
2317
2341
|
process.exit(1);
|
|
2318
2342
|
}
|
|
2319
2343
|
const tData = JSON.parse(retrievedTemplateData);
|
|
@@ -2335,167 +2359,167 @@ export const restoreDependenciesFromPackage = async () => {
|
|
|
2335
2359
|
|
|
2336
2360
|
|
|
2337
2361
|
// update current package json file
|
|
2338
|
-
fs.writeFileSync(currentPackagePath, JSON.stringify(rData, null, 4), { encoding: 'utf8',
|
|
2362
|
+
fs.writeFileSync(currentPackagePath, JSON.stringify(rData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
2339
2363
|
|
|
2340
2364
|
|
|
2341
|
-
}
|
|
2365
|
+
}
|
|
2342
2366
|
|
|
2343
2367
|
|
|
2344
2368
|
export const restoreDependenciesFromTemplate = async () => {
|
|
2345
2369
|
if (showDebug) addDebugLog("restoreDependenciesFromTemplate", "", "");
|
|
2346
|
-
|
|
2347
|
-
|
|
2370
|
+
const currentDirectory = process.cwd();
|
|
2371
|
+
const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
|
|
2348
2372
|
|
|
2349
|
-
|
|
2373
|
+
let currentPackageData;
|
|
2350
2374
|
|
|
2351
|
-
|
|
2352
|
-
|
|
2375
|
+
// reset
|
|
2376
|
+
haveDependencyDifference = true;
|
|
2353
2377
|
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2378
|
+
try {
|
|
2379
|
+
currentPackageData = fs.readFileSync(currentPackagePath);
|
|
2380
|
+
}
|
|
2381
|
+
catch (ex) {
|
|
2382
|
+
console.log(chalk.red(`\nUnable to retrieve current package.json.`))
|
|
2383
|
+
process.exit(1);
|
|
2384
|
+
}
|
|
2361
2385
|
|
|
2362
2386
|
|
|
2363
|
-
|
|
2387
|
+
let cData = JSON.parse(currentPackageData);
|
|
2364
2388
|
|
|
2365
2389
|
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2390
|
+
// we can't loose devDep that is part of install, so go get the template mustache and push
|
|
2391
|
+
// those in, replacing any changes there, but allowing additional, an keeping it updated
|
|
2392
|
+
// so won't loose new function if an old archive
|
|
2393
|
+
const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
|
|
2394
|
+
const templateDir = join(initDir, "template");
|
|
2395
|
+
const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
|
|
2396
|
+
let retrievedTemplateData;
|
|
2397
|
+
try {
|
|
2398
|
+
retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
|
|
2399
|
+
}
|
|
2400
|
+
catch (ex) {
|
|
2401
|
+
console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
|
|
2402
|
+
process.exit(1);
|
|
2403
|
+
}
|
|
2404
|
+
const tData = JSON.parse(retrievedTemplateData);
|
|
2405
|
+
const tDevDep = tData.devDependencies;
|
|
2406
|
+
const tDep = tData.dependencies;
|
|
2383
2407
|
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2408
|
+
for (const [key, value] of Object.entries(tDevDep)) {
|
|
2409
|
+
cData.devDependencies[key] = value;
|
|
2410
|
+
}
|
|
2387
2411
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2412
|
+
for (const [key, value] of Object.entries(tDep)) {
|
|
2413
|
+
cData.dependencies[key] = value;
|
|
2414
|
+
}
|
|
2391
2415
|
|
|
2392
2416
|
|
|
2393
|
-
|
|
2394
|
-
|
|
2417
|
+
// update current package json file
|
|
2418
|
+
fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
2395
2419
|
|
|
2396
2420
|
|
|
2397
|
-
}
|
|
2421
|
+
}
|
|
2398
2422
|
|
|
2399
2423
|
|
|
2400
2424
|
export const restoreDependenciesFromPackage_old = async () => {
|
|
2401
2425
|
if (showDebug) addDebugLog("restoreDependenciesFromPackage", "", "");
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2426
|
+
const currentDirectory = process.cwd();
|
|
2427
|
+
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
2428
|
+
const tempPackagePath = join (tempDirectory, PACKAGE_JSON_FILENAME);
|
|
2429
|
+
const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
|
|
2406
2430
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2431
|
+
let retrievedPackageData;
|
|
2432
|
+
let currentPackageData;
|
|
2409
2433
|
|
|
2410
|
-
|
|
2411
|
-
|
|
2434
|
+
// reset
|
|
2435
|
+
haveDependencyDifference = false;
|
|
2412
2436
|
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2437
|
+
try {
|
|
2438
|
+
retrievedPackageData = fs.readFileSync(tempPackagePath);
|
|
2439
|
+
}
|
|
2440
|
+
catch (ex) {
|
|
2441
|
+
console.log($chalk.red(`\nUnable to retrieve package.json from store.`))
|
|
2442
|
+
process.exit(1);
|
|
2443
|
+
}
|
|
2420
2444
|
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2445
|
+
try {
|
|
2446
|
+
currentPackageData = fs.readFileSync(currentPackagePath);
|
|
2447
|
+
}
|
|
2448
|
+
catch (ex) {
|
|
2449
|
+
console.log($chalk.red(`\nUnable to retrieve current package.json.`))
|
|
2450
|
+
process.exit(1);
|
|
2451
|
+
}
|
|
2428
2452
|
|
|
2429
2453
|
|
|
2430
|
-
|
|
2431
|
-
|
|
2454
|
+
const rData = JSON.parse(retrievedPackageData);
|
|
2455
|
+
let cData = JSON.parse(currentPackageData);
|
|
2432
2456
|
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2457
|
+
// now keep current package.json, but replace devDependencies and dependencies.
|
|
2458
|
+
const sDep = JSON.stringify(rData.dependencies);
|
|
2459
|
+
const sDevDep = JSON.stringify(rData.devDependencies);
|
|
2436
2460
|
|
|
2437
|
-
|
|
2438
|
-
|
|
2461
|
+
const sCurDep = JSON.stringify(cData.dependencies);
|
|
2462
|
+
const sCurDevDep = JSON.stringify(cData.devDependencies);
|
|
2439
2463
|
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2464
|
+
// any changes, update haveDependencyDifference variable
|
|
2465
|
+
if (sDep != sCurDep) {
|
|
2466
|
+
haveDependencyDifference = true;
|
|
2467
|
+
}
|
|
2468
|
+
else if (sDevDep != sCurDevDep) {
|
|
2469
|
+
haveDependencyDifference = true;
|
|
2470
|
+
}
|
|
2447
2471
|
|
|
2448
2472
|
|
|
2449
|
-
|
|
2450
|
-
|
|
2473
|
+
cData.dependencies = JSON.parse(sDep);
|
|
2474
|
+
cData.devDependencies = JSON.parse(sDevDep);
|
|
2451
2475
|
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2476
|
+
// we can't loose devDep that is part of install, so go get the template mustache and push
|
|
2477
|
+
// those in, replacing any changes there, but allowing additional, an keeping it updated
|
|
2478
|
+
// so won't loose new function if an old archive
|
|
2479
|
+
const initDir = join(currentDirectory, "node_modules", "@pega", "custom-dx-components", "src", "tasks", "init");
|
|
2480
|
+
const templateDir = join(initDir, "template");
|
|
2481
|
+
const packageTemplateJsonPath = path.join(templateDir, 'package.json.mustache');
|
|
2482
|
+
let retrievedTemplateData;
|
|
2483
|
+
try {
|
|
2484
|
+
retrievedTemplateData = fs.readFileSync(packageTemplateJsonPath);
|
|
2485
|
+
}
|
|
2486
|
+
catch (ex) {
|
|
2487
|
+
console.log($chalk.red(`\nUnable to retrieve package.json.mustache from code.`))
|
|
2488
|
+
process.exit(1);
|
|
2489
|
+
}
|
|
2490
|
+
const tData = JSON.parse(retrievedTemplateData);
|
|
2491
|
+
const tDevDep = tData.devDependencies;
|
|
2492
|
+
for (const [key, value] of Object.entries(tDevDep)) {
|
|
2493
|
+
cData.devDependencies[key] = value;
|
|
2494
|
+
}
|
|
2471
2495
|
|
|
2472
2496
|
|
|
2473
|
-
|
|
2474
|
-
|
|
2497
|
+
// update current package json file
|
|
2498
|
+
fs.writeFileSync(currentPackagePath, JSON.stringify(cData, null, 4), { encoding: 'utf8',flag:'w' });
|
|
2475
2499
|
|
|
2476
2500
|
|
|
2477
|
-
}
|
|
2501
|
+
}
|
|
2478
2502
|
|
|
2479
2503
|
export const getHaveDependencyDifference = () => {
|
|
2480
|
-
|
|
2504
|
+
if (showDebug) addDebugLog("getHaveDependencyDifference", ``, "");
|
|
2481
2505
|
return haveDependencyDifference;
|
|
2482
|
-
}
|
|
2506
|
+
}
|
|
2483
2507
|
|
|
2484
2508
|
export const restoreFromArchive = async (fileName, orgLibName, version) => {
|
|
2485
|
-
|
|
2509
|
+
if (showDebug) addDebugLog("restoreFromArchive", `fileName: ${fileName}, orgLibName: ${orgLibName}, version: ${version}`, "");
|
|
2486
2510
|
const currentDirectory = process.cwd();
|
|
2487
2511
|
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
2488
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
2512
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
2489
2513
|
const archFileName = join(archiveDirectory, fileName);
|
|
2490
2514
|
|
|
2491
2515
|
|
|
2492
2516
|
if (!fs.existsSync(archiveDirectory)) {
|
|
2493
|
-
throw new Error(`Archive ${orgLibName}/${version} does NOT exist.`);
|
|
2517
|
+
throw new Error (`Archive ${orgLibName}/${version} does NOT exist.`);
|
|
2494
2518
|
}
|
|
2495
2519
|
|
|
2496
2520
|
await unZipFromArchive(archFileName);
|
|
2497
2521
|
|
|
2498
|
-
const tempPackagePath = join(tempDirectory, PACKAGE_JSON_FILENAME);
|
|
2522
|
+
const tempPackagePath = join (tempDirectory, PACKAGE_JSON_FILENAME);
|
|
2499
2523
|
const currentPackagePath = join(currentDirectory, PACKAGE_JSON_FILENAME);
|
|
2500
2524
|
const tempDirectoryComponents = join(tempDirectory, "src");
|
|
2501
2525
|
const currentComponentsPath = join(currentDirectory, "src");
|
|
@@ -2512,11 +2536,11 @@ export const restoreFromArchive = async (fileName, orgLibName, version) => {
|
|
|
2512
2536
|
await restoreDependenciesFromPackage();
|
|
2513
2537
|
|
|
2514
2538
|
// remove current components
|
|
2515
|
-
fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2
|
|
2539
|
+
fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
|
|
2516
2540
|
|
|
2517
2541
|
if (fs.existsSync(currentComponentsPath)) {
|
|
2518
2542
|
// try another round of rm
|
|
2519
|
-
fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2
|
|
2543
|
+
fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
|
|
2520
2544
|
|
|
2521
2545
|
if (fs.existsSync(currentComponentsPath)) {
|
|
2522
2546
|
// still an issue
|
|
@@ -2532,29 +2556,29 @@ export const restoreFromArchive = async (fileName, orgLibName, version) => {
|
|
|
2532
2556
|
// copy temp src/components
|
|
2533
2557
|
if (fs.existsSync(tempDirectoryComponents)) {
|
|
2534
2558
|
|
|
2535
|
-
fs.cpSync(tempDirectoryComponents, currentComponentsPath, { recursive: true, force: true
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2559
|
+
fs.cpSync(tempDirectoryComponents, currentComponentsPath, { recursive: true, force: true });
|
|
2560
|
+
}
|
|
2561
|
+
else {
|
|
2562
|
+
// nothing was archived (no src/components)
|
|
2563
|
+
// so make a src/components if doesn't exist
|
|
2564
|
+
if (!fs.existsSync(currentComponentsPath)) {
|
|
2565
|
+
fs.mkdirSync(currentComponentsPath, { "recursive" : true});
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2544
2568
|
|
|
2545
2569
|
|
|
2546
|
-
|
|
2547
|
-
|
|
2570
|
+
// remove temp (windows not working well with "sync", can be async, since as long as deleted, fine)
|
|
2571
|
+
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 }, () => {});
|
|
2548
2572
|
|
|
2549
2573
|
};
|
|
2550
2574
|
|
|
2551
2575
|
export const clearSrcComponentsDirectory = async () => {
|
|
2552
|
-
|
|
2576
|
+
if (showDebug) addDebugLog("clearSrcComponentsDirectory", ``, "");
|
|
2553
2577
|
const currentDirectory = process.cwd();
|
|
2554
2578
|
const currentComponentsPath = join(currentDirectory, "src", "components");
|
|
2555
2579
|
|
|
2556
2580
|
// remove current components
|
|
2557
|
-
fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2
|
|
2581
|
+
fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
|
|
2558
2582
|
|
|
2559
2583
|
// create blank src
|
|
2560
2584
|
fs.mkdirSync(currentComponentsPath, { recursive: true });
|
|
@@ -2568,23 +2592,23 @@ export const isHiddenFile = (fileName) => {
|
|
|
2568
2592
|
return false;
|
|
2569
2593
|
};
|
|
2570
2594
|
|
|
2571
|
-
export const getCurrentOrgLib = () =>
|
|
2595
|
+
export const getCurrentOrgLib = () =>{
|
|
2572
2596
|
return defaultConfigs.currentOrgLib;
|
|
2573
2597
|
};
|
|
2574
2598
|
|
|
2575
2599
|
export const hasArchives = async () => {
|
|
2576
|
-
|
|
2600
|
+
if (showDebug) addDebugLog("hasArchives", "call", "");
|
|
2577
2601
|
const currentDirectory = process.cwd();
|
|
2578
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH);
|
|
2602
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
|
|
2579
2603
|
const hasArc = fs.existsSync(archiveDirectory);
|
|
2580
|
-
|
|
2604
|
+
if (showDebug) addDebugLog("hasArchives", `${hasArc}`, "");
|
|
2581
2605
|
return hasArc;
|
|
2582
2606
|
};
|
|
2583
2607
|
|
|
2584
2608
|
export const deleteArchives = async () => {
|
|
2585
|
-
|
|
2609
|
+
if (showDebug) addDebugLog("deleteArchives", ``, "");
|
|
2586
2610
|
const currentDirectory = process.cwd();
|
|
2587
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH);
|
|
2611
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
|
|
2588
2612
|
const hasArc = fs.existsSync(archiveDirectory);
|
|
2589
2613
|
|
|
2590
2614
|
if (hasArc) {
|
|
@@ -2593,11 +2617,11 @@ export const deleteArchives = async () => {
|
|
|
2593
2617
|
} catch (err) {
|
|
2594
2618
|
}
|
|
2595
2619
|
}
|
|
2596
|
-
}
|
|
2620
|
+
}
|
|
2597
2621
|
|
|
2598
2622
|
export const checkLibraryAndArchives = async () => {
|
|
2599
|
-
|
|
2600
|
-
const isLibraryBased =
|
|
2623
|
+
if (showDebug) addDebugLog("checkLibraryAndArchives", ``, "");
|
|
2624
|
+
const isLibraryBased = getLibraryBased();
|
|
2601
2625
|
const hasArch = await hasArchives();
|
|
2602
2626
|
|
|
2603
2627
|
if (isLibraryBased && !hasArch) {
|
|
@@ -2608,7 +2632,7 @@ export const checkLibraryAndArchives = async () => {
|
|
|
2608
2632
|
};
|
|
2609
2633
|
|
|
2610
2634
|
export const hasLibraryAndVersion = async (libraryName, version, devBuild) => {
|
|
2611
|
-
|
|
2635
|
+
if (showDebug) addDebugLog("hasLibraryAndVersion", `libraryName: ${libraryName}, version: ${version}, devBuild: ${devBuild}`, "");
|
|
2612
2636
|
|
|
2613
2637
|
const orgLib = getConfigDefaults();
|
|
2614
2638
|
const currentOrgLib = `${orgLib.organization}_${libraryName}`;
|
|
@@ -2628,9 +2652,9 @@ export const hasLibraryAndVersion = async (libraryName, version, devBuild) => {
|
|
|
2628
2652
|
};
|
|
2629
2653
|
|
|
2630
2654
|
export const getLibraryArchiveDirectories = async (currentOrgLib = "") => {
|
|
2631
|
-
|
|
2655
|
+
if (showDebug) addDebugLog("getLibraryArchiveDirectories", "", "");
|
|
2632
2656
|
const currentDirectory = process.cwd();
|
|
2633
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH);
|
|
2657
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
|
|
2634
2658
|
|
|
2635
2659
|
|
|
2636
2660
|
if (!fs.existsSync(archiveDirectory)) {
|
|
@@ -2638,18 +2662,18 @@ export const getLibraryArchiveDirectories = async (currentOrgLib = "") => {
|
|
|
2638
2662
|
}
|
|
2639
2663
|
|
|
2640
2664
|
return fs
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2665
|
+
.readdirSync(archiveDirectory, { withFileTypes: true })
|
|
2666
|
+
.filter(dirent => dirent.isDirectory() && (dirent.name != currentOrgLib) )
|
|
2667
|
+
.map(dirent => dirent.name);
|
|
2644
2668
|
};
|
|
2645
2669
|
|
|
2646
2670
|
|
|
2647
2671
|
|
|
2648
2672
|
export const getLibraryArchivesVersions = async (orgLibName, currentVersion) => {
|
|
2649
|
-
|
|
2673
|
+
if (showDebug) addDebugLog("getLibraryArchivesVersions", `orgLibName: ${orgLibName}`, "");
|
|
2650
2674
|
|
|
2651
2675
|
const currentDirectory = process.cwd();
|
|
2652
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, `${orgLibName}`);
|
|
2676
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`);
|
|
2653
2677
|
|
|
2654
2678
|
if (!fs.existsSync(archiveDirectory)) {
|
|
2655
2679
|
return [];
|
|
@@ -2657,17 +2681,17 @@ export const getLibraryArchivesVersions = async (orgLibName, currentVersion) =>
|
|
|
2657
2681
|
|
|
2658
2682
|
return fs
|
|
2659
2683
|
.readdirSync(archiveDirectory, { withFileTypes: true })
|
|
2660
|
-
.filter(dirent => dirent.isDirectory() && dirent.name != currentVersion)
|
|
2684
|
+
.filter(dirent => dirent.isDirectory() && dirent.name != currentVersion )
|
|
2661
2685
|
.map(dirent => dirent.name);
|
|
2662
2686
|
|
|
2663
2687
|
|
|
2664
2688
|
|
|
2665
2689
|
};
|
|
2666
2690
|
|
|
2667
|
-
export const deleteLocalArchiveLibrary = async
|
|
2668
|
-
|
|
2691
|
+
export const deleteLocalArchiveLibrary = async(libraryName) => {
|
|
2692
|
+
if (showDebug) addDebugLog("deleteLocalArchiveLibrary", `libraryName: ${libraryName}`, "");
|
|
2669
2693
|
const currentDirectory = process.cwd();
|
|
2670
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, libraryName);
|
|
2694
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, libraryName);
|
|
2671
2695
|
|
|
2672
2696
|
try {
|
|
2673
2697
|
fs.rmSync(archiveDirectory, { recursive: true });
|
|
@@ -2680,17 +2704,17 @@ export const deleteLocalArchiveLibrary = async (libraryName) => {
|
|
|
2680
2704
|
// check if no other libraries, the remove /store
|
|
2681
2705
|
const archList = getLibraryArchiveDirectories();
|
|
2682
2706
|
if (archList.length === 0) {
|
|
2683
|
-
const archPath = join(currentDirectory, ARCHIVES_PATH);
|
|
2707
|
+
const archPath = join (currentDirectory, ARCHIVES_PATH);
|
|
2684
2708
|
|
|
2685
|
-
fs.rmSync(archPath, { recursive: true
|
|
2709
|
+
fs.rmSync(archPath, { recursive : true});
|
|
2686
2710
|
}
|
|
2687
2711
|
|
|
2688
|
-
}
|
|
2712
|
+
}
|
|
2689
2713
|
|
|
2690
|
-
export const deleteLocalArchiveLibraryVersion = async
|
|
2691
|
-
|
|
2714
|
+
export const deleteLocalArchiveLibraryVersion = async(libraryName, version) => {
|
|
2715
|
+
if (showDebug) addDebugLog("deleteLocalArchiveLibraryVersion", `libraryName: ${libraryName}, version: ${version}`, "");
|
|
2692
2716
|
const currentDirectory = process.cwd();
|
|
2693
|
-
const archiveDirectory = join(currentDirectory, ARCHIVES_PATH, libraryName, version);
|
|
2717
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, libraryName, version);
|
|
2694
2718
|
|
|
2695
2719
|
try {
|
|
2696
2720
|
fs.rmSync(archiveDirectory, { recursive: true });
|
|
@@ -2703,45 +2727,45 @@ export const deleteLocalArchiveLibraryVersion = async (libraryName, version) =>
|
|
|
2703
2727
|
// throw new Error(`No such file ${libraryName}/${version}`);
|
|
2704
2728
|
}
|
|
2705
2729
|
|
|
2706
|
-
}
|
|
2730
|
+
}
|
|
2707
2731
|
|
|
2708
|
-
export const cleanUpTemp = async
|
|
2709
|
-
|
|
2732
|
+
export const cleanUpTemp = async() => {
|
|
2733
|
+
if (showDebug) addDebugLog("cleanUpTemp", ``, "");
|
|
2710
2734
|
const currentDirectory = process.cwd();
|
|
2711
|
-
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
2735
|
+
const tempDirectory = join (currentDirectory, TEMP_PATH);
|
|
2712
2736
|
|
|
2713
2737
|
if (fs.existsSync(tempDirectory)) {
|
|
2714
2738
|
fs.rmSync(tempDirectory, { recursive: true });
|
|
2715
2739
|
}
|
|
2716
2740
|
|
|
2717
|
-
}
|
|
2741
|
+
}
|
|
2718
2742
|
|
|
2719
2743
|
|
|
2720
|
-
export const getJestFunctionalTestList = async
|
|
2721
|
-
|
|
2744
|
+
export const getJestFunctionalTestList = async(whichTests) => {
|
|
2745
|
+
if (showDebug) addDebugLog("getJestFunctionalTestList", ``, "");
|
|
2722
2746
|
const functionalDir = path.join(path.resolve(), JEST_TESTS_FUNCTIONAL_PATH);
|
|
2723
2747
|
const libFilter = "localLib";
|
|
2724
2748
|
|
|
2725
2749
|
switch (whichTests) {
|
|
2726
|
-
case "ALL":
|
|
2750
|
+
case "ALL" :
|
|
2727
2751
|
return fs
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2752
|
+
.readdirSync(functionalDir, { withFileTypes: true })
|
|
2753
|
+
.filter(dirent => !dirent.isDirectory() )
|
|
2754
|
+
.map(dirent => dirent.name);
|
|
2731
2755
|
case "Original":
|
|
2732
2756
|
return fs
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
case "Library":
|
|
2757
|
+
.readdirSync(functionalDir, { withFileTypes: true })
|
|
2758
|
+
.filter(dirent => !dirent.isDirectory() && !dirent.name.startsWith(libFilter))
|
|
2759
|
+
.map(dirent => dirent.name);
|
|
2760
|
+
case "Library" :
|
|
2737
2761
|
return fs
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2762
|
+
.readdirSync(functionalDir, { withFileTypes: true })
|
|
2763
|
+
.filter(dirent => !dirent.isDirectory() && dirent.name.startsWith(libFilter))
|
|
2764
|
+
.map(dirent => dirent.name);
|
|
2741
2765
|
}
|
|
2742
2766
|
|
|
2743
2767
|
|
|
2744
|
-
}
|
|
2768
|
+
}
|
|
2745
2769
|
|
|
2746
2770
|
export const getSubTypeLabel = (type, subtype) => {
|
|
2747
2771
|
const subTypeList = COMPONENT_SCHEMA.subtype;
|
|
@@ -2755,7 +2779,7 @@ export const getSubTypeLabel = (type, subtype) => {
|
|
|
2755
2779
|
}
|
|
2756
2780
|
|
|
2757
2781
|
return "";
|
|
2758
|
-
}
|
|
2782
|
+
}
|
|
2759
2783
|
|
|
2760
2784
|
export const getMaxComponentNameCount = () => {
|
|
2761
2785
|
let count = MAX_RFT_CHARS;
|
|
@@ -2768,12 +2792,28 @@ export const getMaxComponentNameCount = () => {
|
|
|
2768
2792
|
|
|
2769
2793
|
return count;
|
|
2770
2794
|
|
|
2771
|
-
}
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
export const getStandaloneMaxComponentNameCount = () => {
|
|
2798
|
+
let count = MAX_RFT_CHARS;
|
|
2799
|
+
const configDef = getConfigDefaults();
|
|
2800
|
+
const orgLibCount = configDef.currentOrgLib.length + 1;
|
|
2801
|
+
|
|
2802
|
+
count = count - orgLibCount; // 9 chars for trailing hash
|
|
2803
|
+
|
|
2804
|
+
return count;
|
|
2805
|
+
|
|
2806
|
+
}
|
|
2772
2807
|
|
|
2773
2808
|
export const getMaxPrefixCount = () => {
|
|
2774
2809
|
// TwoColumnDetails is 16 chars
|
|
2775
2810
|
return (getMaxComponentNameCount() - 16);
|
|
2776
|
-
}
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
export const getStandaloneMaxPrefixCount = () => {
|
|
2814
|
+
// TwoColumnDetails is 16 chars
|
|
2815
|
+
return (getStandaloneMaxComponentNameCount() - 16);
|
|
2816
|
+
}
|
|
2777
2817
|
|
|
2778
2818
|
export const isComponentValidLength = (componentKey) => {
|
|
2779
2819
|
const configDef = getConfigDefaults();
|
|
@@ -2783,12 +2823,7 @@ export const isComponentValidLength = (componentKey) => {
|
|
|
2783
2823
|
}
|
|
2784
2824
|
|
|
2785
2825
|
return false;
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
export const emptyDirSync = dir => (
|
|
2789
|
-
fs.rmSync(dir, { recursive: true, force: true }),
|
|
2790
|
-
fs.mkdirSync(dir, { recursive: true })
|
|
2791
|
-
);
|
|
2826
|
+
}
|
|
2792
2827
|
|
|
2793
2828
|
// init
|
|
2794
2829
|
await forceDefaultsUpdate();
|