@pega/custom-dx-components 0.242.23 → 0.242.25
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 +1 -1
- package/src/constants.js +1 -0
- package/src/tasks/authenticate/index.js +1 -1
- package/src/tasks/build-all/helper.js +5 -18
- package/src/tasks/build-all/index.js +43 -10
- package/src/tasks/build-comp/helper.js +6 -2
- package/src/tasks/build-comp/index.js +19 -3
- package/src/tasks/build-jest-assets/index.js +1 -1
- package/src/tasks/build-lib/helper.js +10 -2
- package/src/tasks/build-lib/index.js +15 -3
- package/src/tasks/bundle/builder/index.js +11 -3
- package/src/tasks/bundle/builder/webpack.config.js +3 -1
- package/src/tasks/bundle/index.js +3 -1
- package/src/tasks/create/index.js +11 -4
- package/src/tasks/create-all/index.js +10 -4
- package/src/tasks/delete/helper.js +7 -2
- package/src/tasks/delete/index.js +6 -2
- package/src/tasks/delete-all/helper.js +6 -2
- package/src/tasks/delete-all/index.js +7 -2
- package/src/tasks/delete-lib/helper.js +6 -1
- package/src/tasks/delete-lib/index.js +10 -4
- package/src/tasks/init/template/package.json.mustache +1 -2
- package/src/tasks/init/template/tasks.config.json +2 -1
- package/src/tasks/linter/index.js +4 -0
- package/src/tasks/list/helper.js +9 -2
- package/src/tasks/list/index.js +10 -2
- package/src/tasks/list-lib/helper.js +8 -2
- package/src/tasks/list-lib/index.js +12 -3
- package/src/tasks/promote-webpack/index.js +7 -2
- package/src/tasks/promote-webpack/webpack.config.js +3 -1
- package/src/tasks/publish/helper.js +5 -1
- package/src/tasks/publish/index.js +6 -2
- package/src/tasks/publish-all/helper.js +8 -1
- package/src/tasks/publish-all/index.js +8 -2
- package/src/tasks/publish-lib/helper.js +4 -2
- package/src/tasks/publish-lib/index.js +17 -8
- package/src/tasks/rename/index.js +10 -3
- package/src/tasks/rename-lib/index.js +23 -5
- package/src/tasks/revert-webpack/index.js +5 -2
- package/src/tasks/validator/index.js +4 -1
- package/src/util.js +135 -5
|
@@ -7,7 +7,7 @@ import inquirer from 'inquirer';
|
|
|
7
7
|
import ncp from 'ncp';
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
|
|
10
|
-
import { checkPathAccess, showVersion, getComponentsObj, getDirectoryFiles } from '../../util.js';
|
|
10
|
+
import { checkPathAccess, showVersion, getComponentsObj, getDirectoryFiles, addDebugLog } from '../../util.js';
|
|
11
11
|
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH } from '../../constants.js';
|
|
12
12
|
|
|
13
13
|
|
|
@@ -47,6 +47,8 @@ export const updateConfig = async (
|
|
|
47
47
|
onlyCompanion = false
|
|
48
48
|
) => {
|
|
49
49
|
|
|
50
|
+
addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
|
|
51
|
+
|
|
50
52
|
let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
|
|
51
53
|
configData = configData && JSON.parse(configData);
|
|
52
54
|
|
|
@@ -83,6 +85,8 @@ export const updateFile = async (
|
|
|
83
85
|
targetDirectory,
|
|
84
86
|
) => {
|
|
85
87
|
|
|
88
|
+
addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, targetDirectory: ${targetDirectory}`, "");
|
|
89
|
+
|
|
86
90
|
let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
|
|
87
91
|
|
|
88
92
|
if (fileData.indexOf(oldComponentKeyPC) >= 0) {
|
|
@@ -109,6 +113,7 @@ export const renameComponent = async (
|
|
|
109
113
|
onlyCompanion = false
|
|
110
114
|
) => {
|
|
111
115
|
|
|
116
|
+
addDebugLog("renameComponent", `library: ${library}, organization: ${organization}, componentKey: ${componentKey}`, "");
|
|
112
117
|
|
|
113
118
|
let pegaConfig = await getPegaConfig();
|
|
114
119
|
|
|
@@ -174,7 +179,9 @@ export const renameComponent = async (
|
|
|
174
179
|
|
|
175
180
|
|
|
176
181
|
export default async options => {
|
|
177
|
-
showVersion();
|
|
182
|
+
await showVersion();
|
|
183
|
+
|
|
184
|
+
addDebugLog("rename", "", "+");
|
|
178
185
|
|
|
179
186
|
await checkPathAccess(pegaConfigJsonPath);
|
|
180
187
|
|
|
@@ -347,6 +354,6 @@ export default async options => {
|
|
|
347
354
|
});
|
|
348
355
|
}
|
|
349
356
|
|
|
350
|
-
|
|
357
|
+
addDebugLog("rename", "END", "-");
|
|
351
358
|
|
|
352
359
|
};
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
deleteLocalLibrary,
|
|
18
18
|
getC11NB2STokenAndStaticServer,
|
|
19
19
|
updateComponentDefaultLibrary,
|
|
20
|
-
updateDefaultOrganization
|
|
20
|
+
updateDefaultOrganization,
|
|
21
|
+
addDebugLog
|
|
21
22
|
} from '../../util.js';
|
|
22
23
|
import {
|
|
23
24
|
TASKS_CONFIG_JSON_FILENAME,
|
|
@@ -39,13 +40,15 @@ import {
|
|
|
39
40
|
getPegaConfig,
|
|
40
41
|
getComponentDefaults,
|
|
41
42
|
getComponents,
|
|
42
|
-
getAboutData,
|
|
43
43
|
sanitize
|
|
44
44
|
} from '../../util.js';
|
|
45
45
|
|
|
46
46
|
const copy = promisify(ncp);
|
|
47
47
|
|
|
48
48
|
export const getOrgLib = async () => {
|
|
49
|
+
|
|
50
|
+
addDebugLog("getOrgLib", "", "+");
|
|
51
|
+
|
|
49
52
|
const defaultPegaConfig = await getPegaServerConfig();
|
|
50
53
|
|
|
51
54
|
await checkPathAccess(pegaConfigJsonPath);
|
|
@@ -70,6 +73,9 @@ export const getOrgLib = async () => {
|
|
|
70
73
|
componentDefaults.library = library;
|
|
71
74
|
componentDefaults.organization = organization;
|
|
72
75
|
|
|
76
|
+
addDebugLog("getOrgLib", `componentsDefaults: ${JSON.stringify(componentDefaults)}`, "");
|
|
77
|
+
addDebugLog("getOrgLib", "END", "-");
|
|
78
|
+
|
|
73
79
|
return componentDefaults;
|
|
74
80
|
};
|
|
75
81
|
|
|
@@ -89,6 +95,9 @@ export const updateConfig = async (
|
|
|
89
95
|
options,
|
|
90
96
|
onlyCompanion = false
|
|
91
97
|
) => {
|
|
98
|
+
|
|
99
|
+
addDebugLog("updateConfig", "", "");
|
|
100
|
+
|
|
92
101
|
let configData = fs.readFileSync(join(targetDirectory, '/config.json'), { encoding: 'utf8' });
|
|
93
102
|
configData = configData && JSON.parse(configData);
|
|
94
103
|
|
|
@@ -114,6 +123,8 @@ export const updateFile = async (
|
|
|
114
123
|
newComponentKeyPC,
|
|
115
124
|
targetDirectory
|
|
116
125
|
) => {
|
|
126
|
+
|
|
127
|
+
addDebugLog("updateFile", "", "");
|
|
117
128
|
let fileData = fs.readFileSync(join(targetDirectory, '/', fileName), { encoding: 'utf8' });
|
|
118
129
|
|
|
119
130
|
if (fileData.indexOf(oldComponentKeyPC) >= 0) {
|
|
@@ -124,6 +135,7 @@ export const updateFile = async (
|
|
|
124
135
|
};
|
|
125
136
|
|
|
126
137
|
export const renameLibrary = async ({ library, organization }, options) => {
|
|
138
|
+
addDebugLog("renameLibrary", `library: ${library}, organization: ${organization}`, "");
|
|
127
139
|
const compDef = await getOrgLib();
|
|
128
140
|
const currentOrganization = compDef.organization;
|
|
129
141
|
const currentLibrary = compDef.library;
|
|
@@ -145,7 +157,7 @@ export const renameLibrary = async ({ library, organization }, options) => {
|
|
|
145
157
|
const currentOrgLib = currentOrganization.concat('_').concat(currentLibrary);
|
|
146
158
|
const newOrgLib = organization.concat('_').concat(library);
|
|
147
159
|
|
|
148
|
-
//
|
|
160
|
+
// rename all the components
|
|
149
161
|
const components = await getComponents();
|
|
150
162
|
|
|
151
163
|
let wasDevBuild = false;
|
|
@@ -197,7 +209,7 @@ export const renameLibrary = async ({ library, organization }, options) => {
|
|
|
197
209
|
// with subdirectories for each version.
|
|
198
210
|
// If "buildDev", we append to version "-dev". Currently, only "-dev" versions, when published, can be deleted.
|
|
199
211
|
if (newOrgLib && compVersion) {
|
|
200
|
-
localBuildLibrary(organization, library, currentVersion, wasDevBuild);
|
|
212
|
+
await localBuildLibrary(organization, library, currentVersion, wasDevBuild);
|
|
201
213
|
}
|
|
202
214
|
};
|
|
203
215
|
|
|
@@ -215,6 +227,9 @@ export const renameComponent = async (
|
|
|
215
227
|
options,
|
|
216
228
|
onlyCompanion = false
|
|
217
229
|
) => {
|
|
230
|
+
|
|
231
|
+
addDebugLog("renameComponent", `library: ${library}, organization: ${organization}, componentKey: ${componentKey}`, "");
|
|
232
|
+
|
|
218
233
|
let pegaConfig = await getPegaConfig();
|
|
219
234
|
|
|
220
235
|
const newComponentKey = `${organization}_${library}_${componentName}`;
|
|
@@ -268,7 +283,8 @@ export default async options => {
|
|
|
268
283
|
process.exit();
|
|
269
284
|
}
|
|
270
285
|
|
|
271
|
-
showVersion();
|
|
286
|
+
await showVersion();
|
|
287
|
+
addDebugLog("renameLibrary", "", "+");
|
|
272
288
|
|
|
273
289
|
await checkPathAccess(pegaConfigJsonPath);
|
|
274
290
|
|
|
@@ -346,4 +362,6 @@ export default async options => {
|
|
|
346
362
|
);
|
|
347
363
|
});
|
|
348
364
|
}
|
|
365
|
+
|
|
366
|
+
addDebugLog("renameLibrary", "END", "-");
|
|
349
367
|
};
|
|
@@ -3,12 +3,13 @@ import path from 'path';
|
|
|
3
3
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
|
|
6
|
-
import { showVersion, updateUseWebPackPromotion, getLibraryBased } from '../../util.js';
|
|
6
|
+
import { showVersion, updateUseWebPackPromotion, getLibraryBased, addDebugLog } from '../../util.js';
|
|
7
7
|
import { WEBPACK_CONFIG_JS_FILENAME } from '../../constants.js';
|
|
8
8
|
|
|
9
9
|
const isLibraryBased = await getLibraryBased();
|
|
10
10
|
|
|
11
11
|
export const renamePromotedWebPack = async () => {
|
|
12
|
+
addDebugLog("renamePromotedWebPack","", "");
|
|
12
13
|
// call this function from top level
|
|
13
14
|
// fs.copyFileSync("./webpack.config.js", "webpack.config.js")
|
|
14
15
|
|
|
@@ -32,8 +33,10 @@ export default async () => {
|
|
|
32
33
|
process.exit();
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
showVersion();
|
|
36
|
+
await showVersion();
|
|
37
|
+
addDebugLog("revertWebPack","", "+");
|
|
36
38
|
|
|
37
39
|
await renamePromotedWebPack();
|
|
38
40
|
await updateUseWebPackPromotion(false);
|
|
41
|
+
addDebugLog("revertWebPack","END", "-");
|
|
39
42
|
};
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
getComponentDirectoryPath,
|
|
13
13
|
getComponents,
|
|
14
|
-
getOOTBComponents
|
|
14
|
+
getOOTBComponents,
|
|
15
|
+
addDebugLog } from '../../util.js';
|
|
15
16
|
|
|
16
17
|
const ajv = new Ajv({ allErrors: true });
|
|
17
18
|
|
|
@@ -314,6 +315,8 @@ const validateOverideSchema = ajv.compile(overrideSchema);
|
|
|
314
315
|
|
|
315
316
|
|
|
316
317
|
export default async (option) => {
|
|
318
|
+
// addDebugLog("validate","", "");
|
|
319
|
+
|
|
317
320
|
let componentToValidate = null;
|
|
318
321
|
if (option.params && option.params[3]) {
|
|
319
322
|
componentToValidate = option.params[3];
|
package/src/util.js
CHANGED
|
@@ -25,24 +25,62 @@ import {
|
|
|
25
25
|
USE_PROMOTED_WEB_PACK,
|
|
26
26
|
BOOTSTRAP_CONFIG,
|
|
27
27
|
LIBRARY_BASED,
|
|
28
|
-
SHARED_DIRECTORY
|
|
28
|
+
SHARED_DIRECTORY,
|
|
29
|
+
SHOW_DEBUG
|
|
29
30
|
} from './constants.js';
|
|
30
31
|
|
|
31
32
|
const access = promisify(fs.access);
|
|
32
33
|
|
|
34
|
+
let showDebug = false;
|
|
35
|
+
let debugLevel = 1;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export const addDebugLog = (sFunctionName, sLogData, sIncDec) => {
|
|
39
|
+
|
|
40
|
+
let sLog;
|
|
41
|
+
if (showDebug) {
|
|
42
|
+
if (sIncDec === "-") {
|
|
43
|
+
debugLevel--;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
sLog = `>> log ${debugLevel} `;
|
|
47
|
+
|
|
48
|
+
for (let i =0; i < debugLevel; i++) {
|
|
49
|
+
sLog = sLog.concat("-");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
sLog = sLog.concat(sFunctionName).concat(": ").concat(sLogData);
|
|
53
|
+
|
|
54
|
+
console.log(`${chalk.hex('#A0522D')(sLog)}`);
|
|
55
|
+
|
|
56
|
+
if (sIncDec === "+") {
|
|
57
|
+
debugLevel++;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
33
63
|
export const checkPathAccess = async (path, options = {}, throwError = false) => {
|
|
64
|
+
|
|
65
|
+
|
|
34
66
|
const { errorMessage } = options;
|
|
35
67
|
|
|
36
68
|
try {
|
|
37
69
|
await access(path, fs.constants.R_OK);
|
|
38
70
|
} catch (err) {
|
|
39
71
|
if (throwError) {
|
|
72
|
+
addDebugLog("checkPathAccess", "path: ".concat(path), "+");
|
|
73
|
+
addDebugLog("checkPathAccess", "Error: ".concat(err), "");
|
|
74
|
+
addDebugLog("checkPathAccess", "END", "-");
|
|
40
75
|
throw new Error(err);
|
|
76
|
+
|
|
41
77
|
}
|
|
42
78
|
else {
|
|
79
|
+
addDebugLog("checkPathAccess", "path: ".concat(path), "+");
|
|
43
80
|
const message =
|
|
44
81
|
errorMessage || `${chalk.red.bold('ERROR')} Could not able to access path - ${path}`;
|
|
45
82
|
console.error(message);
|
|
83
|
+
addDebugLog("checkPathAccess", "END", "-");
|
|
46
84
|
process.exit(1);
|
|
47
85
|
}
|
|
48
86
|
|
|
@@ -106,6 +144,7 @@ export const updateUseWebPackPromotion = async ( useValue = false ) => {
|
|
|
106
144
|
}
|
|
107
145
|
|
|
108
146
|
export const getAboutData = async (currentOrgLib, buildVersion, dateStamp) => {
|
|
147
|
+
addDebugLog("getAboutData", `currentOrgLib: ${currentOrgLib}, buildVersion: ${buildVersion}, dateStamp: ${dateStamp}`)
|
|
109
148
|
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
110
149
|
|
|
111
150
|
if (tokenAndStaticServer.C11NB2S === undefined) {
|
|
@@ -121,6 +160,7 @@ export const getAboutData = async (currentOrgLib, buildVersion, dateStamp) => {
|
|
|
121
160
|
}
|
|
122
161
|
|
|
123
162
|
export const getLibraryBased = async () => {
|
|
163
|
+
addDebugLog("getLibraryBased", "", "+");
|
|
124
164
|
const currentDirectory = process.cwd();
|
|
125
165
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
126
166
|
|
|
@@ -138,9 +178,14 @@ export const getLibraryBased = async () => {
|
|
|
138
178
|
data = JSON.parse(data);
|
|
139
179
|
|
|
140
180
|
if (data[LIBRARY_BASED]) {
|
|
181
|
+
addDebugLog("getLibraryBased", `based: ${data[LIBRARY_BASED]}`, "");
|
|
182
|
+
addDebugLog("getLibraryBased", "END", "-");
|
|
141
183
|
return data[LIBRARY_BASED];
|
|
142
184
|
}
|
|
143
|
-
else
|
|
185
|
+
else {
|
|
186
|
+
addDebugLog("getLibraryBased", "END", "-");
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
144
189
|
}
|
|
145
190
|
|
|
146
191
|
export const setLibraryBased = async (isLibraryBased) => {
|
|
@@ -170,8 +215,32 @@ export const setLibraryBased = async (isLibraryBased) => {
|
|
|
170
215
|
|
|
171
216
|
}
|
|
172
217
|
|
|
218
|
+
export const getShowDebug = async () => {
|
|
219
|
+
const currentDirectory = process.cwd();
|
|
220
|
+
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
// force to throw error and not console log
|
|
224
|
+
await checkPathAccess(pegaConfigJsonPath, {}, true);
|
|
225
|
+
}
|
|
226
|
+
catch (ex) {
|
|
227
|
+
// when can't find it, always be false, assume no library based.
|
|
228
|
+
// This is IMPORTANT for init (npx install)
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
233
|
+
data = JSON.parse(data);
|
|
234
|
+
|
|
235
|
+
if (data[SHOW_DEBUG]) {
|
|
236
|
+
return data[SHOW_DEBUG];
|
|
237
|
+
}
|
|
238
|
+
else return false;
|
|
239
|
+
}
|
|
240
|
+
|
|
173
241
|
|
|
174
242
|
export const deleteLocalComponent = async componentKey => {
|
|
243
|
+
addDebugLog("deleteLocalComponent", `componentKey: ${componentKey}`, "");
|
|
175
244
|
const currentDirectory = process.cwd();
|
|
176
245
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
177
246
|
|
|
@@ -207,6 +276,7 @@ export const getHttpsAgent = serverConfig => {
|
|
|
207
276
|
};
|
|
208
277
|
|
|
209
278
|
export const deleteServerComponent = async componentKey => {
|
|
279
|
+
addDebugLog("deleteServerComponent", `componentKey: ${componentKey}`, "");
|
|
210
280
|
const serverConfig = await getPegaServerConfig();
|
|
211
281
|
const { server, user, password } = serverConfig;
|
|
212
282
|
const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
|
|
@@ -252,6 +322,7 @@ export const deleteServerComponent = async componentKey => {
|
|
|
252
322
|
};
|
|
253
323
|
|
|
254
324
|
export const copyFileToShared = async ( fileName, fileContents) => {
|
|
325
|
+
addDebugLog("copyFileToShared", `fileName: ${fileName}`, "");
|
|
255
326
|
const currentDirectory = process.cwd();
|
|
256
327
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
257
328
|
|
|
@@ -285,6 +356,7 @@ export const copyFileToShared = async ( fileName, fileContents) => {
|
|
|
285
356
|
};
|
|
286
357
|
|
|
287
358
|
export const getComponents = async () => {
|
|
359
|
+
addDebugLog("getComponents", "", "");
|
|
288
360
|
const currentDirectory = process.cwd();
|
|
289
361
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
290
362
|
|
|
@@ -309,6 +381,7 @@ export const getComponents = async () => {
|
|
|
309
381
|
};
|
|
310
382
|
|
|
311
383
|
export const getSubComponents = async (directory, type) => {
|
|
384
|
+
addDebugLog("getDirectoryFiles", `directory: ${directory}, type: ${type}`, "");
|
|
312
385
|
const subDirectory = join(directory, type);
|
|
313
386
|
return fs
|
|
314
387
|
.readdirSync(subDirectory, { withFileTypes: true })
|
|
@@ -317,6 +390,7 @@ export const getSubComponents = async (directory, type) => {
|
|
|
317
390
|
};
|
|
318
391
|
|
|
319
392
|
export const getDirectoryFiles = async directory => {
|
|
393
|
+
addDebugLog("getDirectoryFiles", `directory: ${directory}`, "");
|
|
320
394
|
return fs
|
|
321
395
|
.readdirSync(directory, { withFileTypes: true })
|
|
322
396
|
.filter(dirent => !dirent.isDirectory())
|
|
@@ -324,6 +398,7 @@ export const getDirectoryFiles = async directory => {
|
|
|
324
398
|
};
|
|
325
399
|
|
|
326
400
|
export const getComponentsObj = async () => {
|
|
401
|
+
addDebugLog("getComponentsObj", "", "+");
|
|
327
402
|
const compList = [];
|
|
328
403
|
|
|
329
404
|
// const componentList = await getDirectoryFiles(directory);
|
|
@@ -336,15 +411,18 @@ export const getComponentsObj = async () => {
|
|
|
336
411
|
container.name = name;
|
|
337
412
|
container.value = name;
|
|
338
413
|
|
|
414
|
+
addDebugLog("getComponentsObj", "container: " + JSON.stringify(container), "");
|
|
339
415
|
return container;
|
|
340
416
|
})
|
|
341
417
|
);
|
|
342
418
|
}
|
|
343
419
|
|
|
420
|
+
addDebugLog("getComponentsObj", "END", "-");
|
|
344
421
|
return compList;
|
|
345
422
|
};
|
|
346
423
|
|
|
347
424
|
export const getPegaConfig = async () => {
|
|
425
|
+
addDebugLog("getPegaConfig", "", "+");
|
|
348
426
|
const currentDirectory = process.cwd();
|
|
349
427
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
350
428
|
|
|
@@ -353,20 +431,31 @@ export const getPegaConfig = async () => {
|
|
|
353
431
|
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
354
432
|
data = JSON.parse(data);
|
|
355
433
|
|
|
434
|
+
addDebugLog("getPegaConfig", "data: " + JSON.stringify(data), "");
|
|
435
|
+
addDebugLog("getPegaConfig", "END", "-");
|
|
436
|
+
|
|
356
437
|
return data;
|
|
357
438
|
};
|
|
358
439
|
|
|
359
440
|
export const getPegaServerConfig = async () => {
|
|
441
|
+
addDebugLog("getPegaServerConfig", "", "+");
|
|
360
442
|
const config = await getPegaConfig();
|
|
443
|
+
addDebugLog("getPegaServerConfig", "server config:" + JSON.stringify(config['server-config']), "");
|
|
444
|
+
addDebugLog("getPegaServerConfig", "END", "-");
|
|
361
445
|
return config['server-config'];
|
|
362
446
|
};
|
|
363
447
|
|
|
364
448
|
export const getComponentDefaults = async () => {
|
|
449
|
+
addDebugLog("getComponentDefaults", "", "+");
|
|
365
450
|
const config = await getPegaConfig();
|
|
451
|
+
addDebugLog("getComponentDefaults", "config:" + JSON.stringify(config), "");
|
|
452
|
+
|
|
453
|
+
addDebugLog("getComponentDefaults", "END", "-");
|
|
366
454
|
return config.component;
|
|
367
455
|
};
|
|
368
456
|
|
|
369
457
|
export const updateComponentDefaultLibrary = async (library) => {
|
|
458
|
+
addDebugLog("updateComponentDefaultLibrary", `library: ${library}`, "");
|
|
370
459
|
const currentDirectory = process.cwd();
|
|
371
460
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
372
461
|
|
|
@@ -382,6 +471,7 @@ export const updateComponentDefaultLibrary = async (library) => {
|
|
|
382
471
|
}
|
|
383
472
|
|
|
384
473
|
export const updateComponentDefaultVersion = async (version) => {
|
|
474
|
+
addDebugLog("updateComponentDefaultVersion", `version: ${version}`, "");
|
|
385
475
|
const currentDirectory = process.cwd();
|
|
386
476
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
387
477
|
|
|
@@ -397,6 +487,7 @@ export const updateComponentDefaultVersion = async (version) => {
|
|
|
397
487
|
}
|
|
398
488
|
|
|
399
489
|
export const updateDefaultOrganization = async (organization) => {
|
|
490
|
+
addDebugLog("updateDefaultOrganization", `organization: ${organization}`, "");
|
|
400
491
|
let packageData = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf-8'));
|
|
401
492
|
|
|
402
493
|
packageData.organization = organization;
|
|
@@ -406,11 +497,15 @@ export const updateDefaultOrganization = async (organization) => {
|
|
|
406
497
|
}
|
|
407
498
|
|
|
408
499
|
export const getServerType = async () => {
|
|
500
|
+
addDebugLog("getServerType", "", "+");
|
|
409
501
|
const defaultPegaServerConfig = await getPegaServerConfig();
|
|
502
|
+
addDebugLog("getServerType", "serverType:" + defaultPegaServerConfig.serverType, "");
|
|
503
|
+
addDebugLog("getServerType", "END", "-");
|
|
410
504
|
return defaultPegaServerConfig.serverType;
|
|
411
505
|
}
|
|
412
506
|
|
|
413
507
|
export const setServerType = async(serverType) => {
|
|
508
|
+
addDebugLog("setServerType", `serverType: ${serverType}`, "");
|
|
414
509
|
const currentDirectory = process.cwd();
|
|
415
510
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
416
511
|
let configData = await getPegaConfig();
|
|
@@ -424,6 +519,7 @@ export const setServerType = async(serverType) => {
|
|
|
424
519
|
}
|
|
425
520
|
|
|
426
521
|
export const getComponentDirectoryPath = async componentKey => {
|
|
522
|
+
addDebugLog("getComponentDirectoryPath", "", "+");
|
|
427
523
|
const currentDirectory = process.cwd();
|
|
428
524
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
429
525
|
|
|
@@ -438,11 +534,13 @@ export const getComponentDirectoryPath = async componentKey => {
|
|
|
438
534
|
);
|
|
439
535
|
process.exit(1);
|
|
440
536
|
}
|
|
441
|
-
|
|
537
|
+
addDebugLog("getComponentDirectoryPath", "path: " + join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey), "");
|
|
538
|
+
addDebugLog("getComponentDirectoryPath", "END", "-");
|
|
442
539
|
return join(currentDirectory, data[COMPONENTS_DIRECTORY_PATH], componentKey);
|
|
443
540
|
};
|
|
444
541
|
|
|
445
542
|
export const compileMustacheTemplate = (file, data) => {
|
|
543
|
+
addDebugLog("compileMustacheTemplate", `file: ${file}`, "");
|
|
446
544
|
const content = fs.readFileSync(file, 'utf8');
|
|
447
545
|
return mustache.render(content, data);
|
|
448
546
|
};
|
|
@@ -456,6 +554,7 @@ export const convertIntoPascalCase = string => {
|
|
|
456
554
|
};
|
|
457
555
|
|
|
458
556
|
export const constructCompleteUrl = (baseServer, endPoint) => {
|
|
557
|
+
addDebugLog("constructCompleteUrl", "url: " + baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`, "");
|
|
459
558
|
return baseServer.endsWith('/') ? `${baseServer}${endPoint}` : `${baseServer}/${endPoint}`;
|
|
460
559
|
};
|
|
461
560
|
|
|
@@ -487,7 +586,7 @@ export const standardizeStr = (str, length) => {
|
|
|
487
586
|
return str.padEnd(length);
|
|
488
587
|
};
|
|
489
588
|
|
|
490
|
-
export const showVersion = () => {
|
|
589
|
+
export const showVersion = async () => {
|
|
491
590
|
// get package version, so can display at start
|
|
492
591
|
// const require = createRequire(import.meta.url);
|
|
493
592
|
const require = createRequire(currentPath.default);
|
|
@@ -495,6 +594,7 @@ export const showVersion = () => {
|
|
|
495
594
|
const pData = require('@pega/custom-dx-components/package.json');
|
|
496
595
|
|
|
497
596
|
console.log(chalk.green(`DX Component Builder v${pData.version}`));
|
|
597
|
+
showDebug = await getShowDebug();
|
|
498
598
|
|
|
499
599
|
// do a check of node version, it should be 18 or greater
|
|
500
600
|
const arNodeVersion = process.versions.node.split('.');
|
|
@@ -517,9 +617,12 @@ export const showVersion = () => {
|
|
|
517
617
|
console.log(chalk.redBright('DX Component Builder - Git needs to be installed.'));
|
|
518
618
|
process.exit(1);
|
|
519
619
|
}
|
|
620
|
+
|
|
621
|
+
|
|
520
622
|
};
|
|
521
623
|
|
|
522
624
|
export const getOOTBComponents = async () => {
|
|
625
|
+
addDebugLog("getOOTBComponents", "", "");
|
|
523
626
|
return new Promise(resolve => {
|
|
524
627
|
fs.readFile(OOTB_COMPONENTS, 'utf-8', async (error, ootbComponentsData) => {
|
|
525
628
|
if (error) {
|
|
@@ -572,6 +675,7 @@ export const getOOTBComponents = async () => {
|
|
|
572
675
|
};
|
|
573
676
|
|
|
574
677
|
export const deleteInfinityServerComponent = async componentKey => {
|
|
678
|
+
addDebugLog("deleteInfinityServerComponent", `componentKey: ${componentKey}`, "");
|
|
575
679
|
const serverConfig = await getPegaServerConfig();
|
|
576
680
|
const { server } = serverConfig;
|
|
577
681
|
const url = constructCompleteUrl(server, DELETE_COMPONENT_SERVICE_REST_ENDPOINT);
|
|
@@ -650,6 +754,7 @@ export const deleteInfinityServerComponent = async componentKey => {
|
|
|
650
754
|
};
|
|
651
755
|
|
|
652
756
|
export const deleteLaunchpadServerComponent = async componentKey => {
|
|
757
|
+
addDebugLog("deleteLaunchpadServerComponent", `componentKey: ${componentKey}`, "");
|
|
653
758
|
const { server, isolationId } = await getPegaServerConfig();
|
|
654
759
|
const deleteUrl = constructCompleteUrl(
|
|
655
760
|
server,
|
|
@@ -737,7 +842,7 @@ export const deleteLaunchpadServerComponent = async componentKey => {
|
|
|
737
842
|
};
|
|
738
843
|
|
|
739
844
|
export const getBootstrapConfig = async (restServerUrl, authorizationHeader) => {
|
|
740
|
-
|
|
845
|
+
addDebugLog("getBootstrapConfig", `restServerUrl: ${restServerUrl}`, "");
|
|
741
846
|
const serverConfig = await getPegaServerConfig();
|
|
742
847
|
|
|
743
848
|
return fetch(`${restServerUrl}/${BOOTSTRAP_CONFIG}`, {
|
|
@@ -755,6 +860,7 @@ export const getBootstrapConfig = async (restServerUrl, authorizationHeader) =>
|
|
|
755
860
|
};
|
|
756
861
|
|
|
757
862
|
export const updateC11NB2SForInfinity = async () => {
|
|
863
|
+
addDebugLog("updateC11NB2SForInfinity", "", "");
|
|
758
864
|
const serverConfig = await getPegaServerConfig();
|
|
759
865
|
const { server } = serverConfig;
|
|
760
866
|
const OAuthData = fs.readFileSync(TOKEN_PATH, 'utf8');
|
|
@@ -785,6 +891,7 @@ export const updateC11NB2SForLaunchpad = async () => {
|
|
|
785
891
|
};
|
|
786
892
|
|
|
787
893
|
export const getC11NB2STokenAndStaticServer = async () => {
|
|
894
|
+
addDebugLog("getC11NB2STokenAndStaticServer", "", "");
|
|
788
895
|
const serverConfig = await getPegaServerConfig();
|
|
789
896
|
const { server } = serverConfig;
|
|
790
897
|
let OAuthData;
|
|
@@ -807,6 +914,7 @@ export const getC11NB2STokenAndStaticServer = async () => {
|
|
|
807
914
|
}
|
|
808
915
|
|
|
809
916
|
export const getLocalLibraryVersions = async (libraryName) => {
|
|
917
|
+
addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
|
|
810
918
|
const currentDirectory = process.cwd();
|
|
811
919
|
|
|
812
920
|
const directory = join(currentDirectory, libraryName);
|
|
@@ -817,6 +925,7 @@ export const getLocalLibraryVersions = async (libraryName) => {
|
|
|
817
925
|
};
|
|
818
926
|
|
|
819
927
|
export const getLocalLibraryVersionData = async (libraryName, libraryVersion) => {
|
|
928
|
+
addDebugLog("getLocalLibraryVersionDate", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
|
|
820
929
|
const currentDirectory = process.cwd();
|
|
821
930
|
const libDir = join(currentDirectory, libraryName, libraryVersion);
|
|
822
931
|
const libDataFile = join(libDir, 'componentsconfig.json');
|
|
@@ -827,6 +936,7 @@ export const getLocalLibraryVersionData = async (libraryName, libraryVersion) =>
|
|
|
827
936
|
}
|
|
828
937
|
|
|
829
938
|
export const deleteLocalLibrary = async (libraryName) => {
|
|
939
|
+
addDebugLog("deleteLocalLibrary", `libraryName: ${libraryName}` , "");
|
|
830
940
|
const currentDirectory = process.cwd();
|
|
831
941
|
|
|
832
942
|
const directory = join(currentDirectory, libraryName);
|
|
@@ -857,6 +967,7 @@ export const deleteLocalLibrary = async (libraryName) => {
|
|
|
857
967
|
}
|
|
858
968
|
|
|
859
969
|
export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) => {
|
|
970
|
+
addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
|
|
860
971
|
const currentDirectory = process.cwd();
|
|
861
972
|
|
|
862
973
|
const directory = join(currentDirectory, libraryName, libraryVersion);
|
|
@@ -880,6 +991,7 @@ export const deleteLocalLibraryVersion = async (libraryName, libraryVersion) =>
|
|
|
880
991
|
}
|
|
881
992
|
|
|
882
993
|
export const deletePublishExtras = async (libraryName, libraryVersion) => {
|
|
994
|
+
addDebugLog("deletePublishExtras", `libraryName: ${libraryName}, libraryVersion: ${libraryVersion}` , "");
|
|
883
995
|
// this function will delete LibraryName.zip file, so new one created by publish
|
|
884
996
|
// check if .DS_store file exists in Library, if so delete it because causes issue with services
|
|
885
997
|
|
|
@@ -901,3 +1013,21 @@ export const deletePublishExtras = async (libraryName, libraryVersion) => {
|
|
|
901
1013
|
|
|
902
1014
|
|
|
903
1015
|
}
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
export const cleanUp = async () => {
|
|
1021
|
+
addDebugLog("cleanUp", "", "");
|
|
1022
|
+
fs.rm('dist/components', { recursive: true }, err => {
|
|
1023
|
+
if (err) {
|
|
1024
|
+
throw err;
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
fs.rm('lib', { recursive: true }, err => {
|
|
1029
|
+
if (err) {
|
|
1030
|
+
throw err;
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
};
|