@pega/custom-dx-components 24.2.12 → 24.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "24.2.12",
3
+ "version": "24.2.13",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/constants.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // cSpell:ignore words timeofday caseview casepreview objectview
2
2
  export const TASKS_CONFIG_JSON_FILENAME = 'tasks.config.json';
3
+ export const INPUT_CONFIG_JSON_FILENAME = 'input.config.json';
3
4
  export const PACKAGE_JSON_FILENAME = 'package.json';
4
5
  export const BUILD_CONFIG_JSON_FILENAME = 'build.config.json';
5
6
  export const WEBPACK_CONFIG_JS_FILENAME = 'webpack.config.js';
@@ -12,6 +13,7 @@ export const COMPONENTS_PATH = 'component';
12
13
  export const TOKEN_PATH = 'node_modules/@pega/custom-dx-components/.access_token';
13
14
  export const OOTB_COMPONENTS = 'node_modules/@pega/custom-dx-components/.ootb_components';
14
15
  export const LIBRARY_BASED = 'libraryMode';
16
+ export const USE_INPUT_CONFIG = 'useInputConfig';
15
17
  export const SHARED_DIRECTORY = 'shared';
16
18
  export const SHOW_DEBUG = 'showDebug';
17
19
  export const ARCHIVES_PATH = 'store';
@@ -17,7 +17,10 @@ import {
17
17
  forceDefaultsUpdate,
18
18
  cleanUpTemp,
19
19
  restoreTopLevelConfigFilesFromTemplate,
20
- getHaveDependencyDifference
20
+ getHaveDependencyDifference,
21
+ getUseInputConfig,
22
+ getInputConfigForCommand,
23
+ convertYNToBoolean
21
24
  } from '../../util.js';
22
25
 
23
26
  import { getCreateLibComponentQuestions, getOkToProceedQuestion, updateAllComponentsConfig, getCurrentOrOriginalQuestion } from './helper.js';
@@ -25,6 +28,7 @@ import { showCurrentStatus } from '../show-status/index.js';
25
28
 
26
29
  export default async options => {
27
30
  const isLibraryBased = getLibraryBased();
31
+ const useInputConfig = getUseInputConfig();
28
32
  if (!isLibraryBased) {
29
33
  console.log(`Command only supported for ${chalk.bold.green('library based')} components.`);
30
34
  process.exit();
@@ -33,9 +37,89 @@ export default async options => {
33
37
  await showVersion();
34
38
  await cleanUpTemp();
35
39
 
40
+
41
+ // if we have choosen to use INPUT CONFIG FILE
42
+ // process and exit
43
+ if (useInputConfig) {
44
+ const inputConfig = await getInputConfigForCommand("createLib");
45
+
46
+ if (convertYNToBoolean(inputConfig.okToContinue)) {
47
+ const libraryName = inputConfig.libraryName;
48
+ let version = inputConfig.libraryVersion;
49
+ const currentOrOriginal = inputConfig.currentOrOriginal;
50
+ const isPermanent = inputConfig.isPermanent;
51
+ const permBuild = convertYNToBoolean(isPermanent);
52
+
53
+
54
+ // if have store, then that means there is a current library, so
55
+ // store it before clearing out /src/components
56
+
57
+ const hasArch = await hasArchives();
58
+ const orgLib = getConfigDefaults();
59
+ const newOrgLib = `${orgLib.organization}_${libraryName}`;
60
+
61
+ if (hasArch) {
62
+ const hasLib = await hasLibraryAndVersion(libraryName, version, !permBuild);
63
+ if (hasLib) {
64
+ console.log(`${chalk.bold.red(`Library ${orgLib.organization}_${libraryName} already exists.`)}`);
65
+ console.log("You can switch to that library by entering 'npm run switchLib'.\n")
66
+ process.exit();
67
+ }
68
+
69
+ const currentOrgLib = orgLib.currentOrgLib;
70
+ const currentVersion = orgLib.buildVersion;
71
+ await zipVersionAndArchive(currentOrgLib, currentVersion);
72
+ await clearSrcComponentsDirectory();
73
+
74
+ }
75
+
76
+ if (!permBuild) {
77
+ version = version.concat("-dev");
78
+ }
79
+
80
+ if (currentOrOriginal === 'Original') {
81
+ await restoreTopLevelConfigFilesFromTemplate();
82
+ }
83
+
84
+ // update library name in config and create a blank archive
85
+ await updateComponentDefaultLibrary(libraryName);
86
+ await zipVersionAndArchive(newOrgLib, version);
87
+
88
+ // if didn't have an archive, in case you currently have components there
89
+ // update the config jsons
90
+ if (!hasArch) {
91
+ await updateAllComponentsConfig(version);
92
+ }
93
+
94
+ console.log(`${chalk.bold.green(`\nLibrary ${newOrgLib}/${version} has been created!\n`)}`);
95
+
96
+ await forceDefaultsUpdate();
97
+ await showCurrentStatus();
98
+
99
+ if (currentOrOriginal === 'Original') {
100
+ if (getHaveDependencyDifference()) {
101
+
102
+ console.log('\n***************************************************************');
103
+ console.log(chalk.bold.yellow('Dependencies have changed between libraries, recommend updating.'));
104
+ console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
105
+ console.log('***************************************************************\n');
106
+
107
+ }
108
+ }
109
+
110
+
111
+
112
+ }
113
+
114
+ process.exit();
115
+
116
+
117
+ }
118
+
36
119
  addDebugLog("createLibrary", "", "+");
37
120
  let libraryName = "";
38
121
  let version;
122
+
39
123
  // permBuild is the opposite of devBuild
40
124
  let permBuild;
41
125
  const orgLib = getConfigDefaults();
@@ -17,7 +17,12 @@ import {
17
17
  getConfigDefaults,
18
18
  forceDefaultsUpdate,
19
19
  modAddAboutData,
20
- cleanUpTemp
20
+ cleanUpTemp,
21
+ getUseInputConfig,
22
+ getInputConfigForCommand,
23
+ convertYNToBoolean,
24
+ hasArchives,
25
+ hasLibraryAndVersion
21
26
  } from '../../util.js';
22
27
 
23
28
  import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
@@ -25,6 +30,8 @@ import { showCurrentStatus } from '../show-status/index.js';
25
30
 
26
31
  export default async options => {
27
32
  const isLibraryBased = getLibraryBased();
33
+ const useInputConfig = getUseInputConfig();
34
+
28
35
  if (!isLibraryBased) {
29
36
  console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
30
37
  process.exit();
@@ -34,6 +41,8 @@ export default async options => {
34
41
  await checkLibraryAndArchives();
35
42
  await cleanUpTemp();
36
43
 
44
+
45
+
37
46
  addDebugLog("createVersion", "", "+");
38
47
  let libraryName;
39
48
  let version;
@@ -45,26 +54,61 @@ addDebugLog("createVersion", "", "+");
45
54
  const currentDirectory = process.cwd();
46
55
  const componentDirectory = join (currentDirectory, "src", "components");
47
56
 
57
+ // if we have choosen to use INPUT CONFIG FILE
58
+ // process and no inputs
59
+ if (useInputConfig) {
60
+ const inputConfig = await getInputConfigForCommand("createLibVersion");
61
+
62
+ if (convertYNToBoolean(inputConfig.okToContinue)) {
63
+ version = inputConfig.libraryVersion;
64
+ const isPermanent = inputConfig.isPermanent;
65
+ permBuild = convertYNToBoolean(isPermanent);
66
+ copyExisting = convertYNToBoolean(inputConfig.copyComponents);
67
+
68
+ const hasArch = await hasArchives();
69
+ const orgLib = getConfigDefaults();
70
+ const hasLib = await hasLibraryAndVersion(orgLib.library, version, !permBuild);
71
+ if (hasArch) {
72
+ if (hasLib) {
73
+ console.log(`${chalk.bold.red(`Library ${orgLib.displayLibVersion} already exists.`)}`);
74
+ console.log("You can switch to that library by entering 'npm run switchLib'.\n")
75
+ process.exit();
76
+ }
77
+ }
78
+ else {
79
+ console.log(`${chalk.bold.red(`No libraries exist.`)}`);
80
+ console.log("You need to create a library first via 'npm run createLib'.\n")
81
+ process.exit();
82
+ }
48
83
 
49
- if (options.params.length >= 6) {
50
- version = options.params[3];
51
- const dPerm = options.params[4];
52
- const copyExist = options.params[5]
53
84
 
54
- // if have [6] will be "NoAbout" from Jest, to turn off build date
55
- if (options.params.length >= 7 ) {
56
- if (options.params[6] === "NoAbout") {
57
- modAddAboutData(false);
58
- }
59
85
  }
86
+ else {
87
+ process.exit();
88
+ }
89
+
90
+ }
91
+ else {
92
+ if (options.params.length >= 6) {
93
+ version = options.params[3];
94
+ const dPerm = options.params[4];
95
+ const copyExist = options.params[5]
96
+
97
+ // if have [6] will be "NoAbout" from Jest, to turn off build date
98
+ if (options.params.length >= 7 ) {
99
+ if (options.params[6] === "NoAbout") {
100
+ modAddAboutData(false);
101
+ }
102
+ }
60
103
 
61
- permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
62
- copyExisting = !!(copyExist === 'Y' || copyExist === 'y' || copyExist === true || copyExist === 'true');
104
+ permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
105
+ copyExisting = !!(copyExist === 'Y' || copyExist === 'y' || copyExist === true || copyExist === 'true');
63
106
 
64
- } else {
65
- const questions = await getCreateVersionComponentQuestions();
66
- const answers = await inquirer.prompt(questions);
67
- ({ version, permBuild, copyExisting } = answers);
107
+ } else {
108
+ const questions = await getCreateVersionComponentQuestions();
109
+ const answers = await inquirer.prompt(questions);
110
+ ({ version, permBuild, copyExisting } = answers);
111
+ }
68
112
  }
69
113
 
70
114
  const orgLib = getConfigDefaults();
@@ -17,7 +17,10 @@ import {
17
17
  deleteArchives,
18
18
  forceDefaultsUpdate,
19
19
  restoreFromArchive,
20
- cleanUpTemp
20
+ cleanUpTemp,
21
+ getUseInputConfig,
22
+ getInputConfigForCommand,
23
+ convertYNToBoolean
21
24
  } from '../../util.js';
22
25
 
23
26
  import { getDeleteLibraryQuestions, getLibraryVersionQuestion } from './helper.js';
@@ -29,6 +32,7 @@ export const deleteLibraryVersion = async (libraryName, version = "", okToDelete
29
32
  addDebugLog("deleteLibraryVersion", "", "+");
30
33
 
31
34
  const isLibraryBased = getLibraryBased();
35
+
32
36
  const compDef = getConfigDefaults();
33
37
  let libVersions = [];
34
38
  let confirmDeletion;
@@ -38,6 +42,10 @@ addDebugLog("deleteLibraryVersion", "", "+");
38
42
  process.exit();
39
43
  }
40
44
 
45
+
46
+
47
+
48
+
41
49
  try {
42
50
  libVersions = await getLibraryArchivesVersions(libraryName, "");
43
51
  }
@@ -209,6 +217,8 @@ addDebugLog("deleteLibraryVersion", "END", "-");
209
217
 
210
218
  export default async (options) => {
211
219
  const isLibraryBased = getLibraryBased();
220
+ const useInputConfig = getUseInputConfig();
221
+
212
222
  if (!isLibraryBased) {
213
223
  console.log(`Command only supported for ${chalk.bold.green('library based')} components.`)
214
224
  process.exit();
@@ -227,33 +237,52 @@ addDebugLog("deleteLibrary", "", "+");
227
237
  const compDef = getConfigDefaults();
228
238
  let libraryName;
229
239
 
230
- if (options.params.length >= 5) {
231
- libraryName = options.params[3];
232
- version = options.params[4];
240
+ if (useInputConfig) {
241
+ const inputConfig = await getInputConfigForCommand("deleteLib");
242
+ libraryName = inputConfig.libraryName;
243
+ version = inputConfig.libraryVersion;
244
+ const isPermanent = inputConfig.isPermanent;
245
+ const permBuild = convertYNToBoolean(isPermanent);
233
246
 
234
- if (options.params.length >=6 ) {
235
- const okToDel = options.params[5];
236
- okToDelete = !!(okToDel === 'Y' || okToDel === 'y' || okToDel === true || okToDel === 'true');
247
+ if (!permBuild && version != "ALL") {
248
+ version = version.concat("-dev");
237
249
  }
238
250
 
251
+ okToDelete = convertYNToBoolean(inputConfig.confirmDelete);
239
252
 
240
253
  }
241
254
  else {
242
-
243
- if (options.params.length === 4) {
255
+ if (options.params.length >= 5) {
244
256
  libraryName = options.params[3];
245
- version = "ALL"
257
+ version = options.params[4];
258
+
259
+ if (options.params.length >=6 ) {
260
+ const okToDel = options.params[5];
261
+ okToDelete = !!(okToDel === 'Y' || okToDel === 'y' || okToDel === true || okToDel === 'true');
262
+ }
263
+
264
+
246
265
  }
247
266
  else {
248
- const questions = await getDeleteLibraryQuestions();
249
- const answers = await inquirer.prompt(questions);
250
- ({ libraryName } = answers);
251
- }
267
+
268
+ if (options.params.length === 4) {
269
+ libraryName = options.params[3];
270
+ version = "ALL"
271
+ }
272
+ else {
273
+ const questions = await getDeleteLibraryQuestions();
274
+ const answers = await inquirer.prompt(questions);
275
+ ({ libraryName } = answers);
276
+ }
277
+
252
278
 
253
279
 
280
+ }
254
281
 
255
282
  }
256
283
 
284
+
285
+
257
286
  await deleteLibraryVersion(libraryName, version, okToDelete);
258
287
 
259
288
 
@@ -7,7 +7,10 @@ import {
7
7
  checkLibraryAndArchives,
8
8
  getConfigDefaults,
9
9
  addDebugLog,
10
- cleanUpTemp
10
+ cleanUpTemp,
11
+ getUseInputConfig,
12
+ getInputConfigForCommand,
13
+ convertYNToBoolean
11
14
  } from '../../util.js';
12
15
 
13
16
  import { deleteLibraryVersion } from '../delete-lib/index.js';
@@ -15,6 +18,8 @@ import { deleteLibraryVersion } from '../delete-lib/index.js';
15
18
 
16
19
  export default async (options) => {
17
20
  const isLibraryBased = getLibraryBased();
21
+ const useInputConfig = getUseInputConfig();
22
+
18
23
  if (!isLibraryBased) {
19
24
  console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
20
25
  process.exit();
@@ -33,19 +38,35 @@ addDebugLog("deleteVersion", "", "+");
33
38
  const configDef = getConfigDefaults();
34
39
  let libraryName = configDef.currentOrgLib;
35
40
 
36
- if (options.params.length >= 5) {
37
- libraryName = options.params[3]
38
- version = options.params[4];
41
+ if (useInputConfig) {
42
+ const inputConfig = await getInputConfigForCommand("deleteLibVersion");
43
+ version = inputConfig.libraryVersion;
44
+ const isPermanent = inputConfig.isPermanent;
45
+ const permBuild = convertYNToBoolean(isPermanent);
39
46
 
40
- if (options.params.length >=6 ) {
41
- const okToDel = options.params[5];
42
- okToDelete = !!(okToDel === 'Y' || okToDel === 'y' || okToDel === true || okToDel === 'true');
47
+ if (!permBuild && version != "ALL") {
48
+ version = version.concat("-dev");
43
49
  }
50
+
51
+ okToDelete = convertYNToBoolean(inputConfig.confirmDelete);
44
52
  }
45
- else if (options.params.length >= 4) {
46
- libraryName = options.params[3];
53
+ else {
54
+ if (options.params.length >= 5) {
55
+ libraryName = options.params[3]
56
+ version = options.params[4];
57
+
58
+ if (options.params.length >=6 ) {
59
+ const okToDel = options.params[5];
60
+ okToDelete = !!(okToDel === 'Y' || okToDel === 'y' || okToDel === true || okToDel === 'true');
61
+ }
62
+ }
63
+ else if (options.params.length >= 4) {
64
+ libraryName = options.params[3];
65
+ }
47
66
  }
48
67
 
68
+
69
+
49
70
  await deleteLibraryVersion(libraryName, version, okToDelete);
50
71
 
51
72
 
@@ -23,7 +23,9 @@ import {
23
23
  cleanUpTemp,
24
24
  hasArchives,
25
25
  restoreFromArchive,
26
- forceDefaultsUpdate
26
+ forceDefaultsUpdate,
27
+ getUseInputConfig,
28
+ getInputConfigForCommand
27
29
  } from '../../util.js';
28
30
  import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
29
31
  import { getFilePathQuestions, getFileNameQuestions, updateTempArchive, updateSavedFilePath } from './helper.js';
@@ -395,6 +397,8 @@ export default async options => {
395
397
 
396
398
  await checkPathAccess(pegaConfigJsonPath);
397
399
  const isLibraryBased = getLibraryBased();
400
+ const useInputConfig = getUseInputConfig();
401
+
398
402
  if (!isLibraryBased) {
399
403
  console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
400
404
  process.exit();
@@ -415,22 +419,33 @@ export default async options => {
415
419
  }
416
420
  else {
417
421
 
418
- const filePathQuestions = await getFilePathQuestions();
419
- const filePathAnswers = await inquirer.prompt(filePathQuestions);
420
- const { filePath } = filePathAnswers;
421
- const zipFileList = await getZipFileList(filePath);
422
+ let filePath;
423
+ let fileName;
424
+
425
+ if (useInputConfig) {
426
+ const inputConfig = await getInputConfigForCommand("importLibVersion");
427
+ filePath = inputConfig.fileLocation;
428
+ fileName = inputConfig.fileName;
422
429
 
423
- if (!zipFileList || zipFileList.length === 0) {
424
- console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
425
- process.exit();
426
430
  }
431
+ else {
432
+ const filePathQuestions = await getFilePathQuestions();
433
+ const filePathAnswers = await inquirer.prompt(filePathQuestions);
434
+ ({ filePath } = filePathAnswers);
435
+ const zipFileList = await getZipFileList(filePath);
436
+
437
+ if (!zipFileList || zipFileList.length === 0) {
438
+ console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
439
+ process.exit();
440
+ }
427
441
 
428
- await updateSavedFilePath(filePath);
442
+ await updateSavedFilePath(filePath);
429
443
 
430
- const fileNameQuestions = await getFileNameQuestions(zipFileList);
431
- const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
432
- const {fileName} = fileNameAnswers;
444
+ const fileNameQuestions = await getFileNameQuestions(zipFileList);
445
+ const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
446
+ ({fileName} = fileNameAnswers);
433
447
 
448
+ }
434
449
 
435
450
  await importArch( filePath, fileName, hasArch);
436
451
 
@@ -438,8 +453,6 @@ export default async options => {
438
453
  // to keep what was entered as the latest
439
454
  await updateSavedFilePath(filePath);
440
455
 
441
-
442
-
443
456
  }
444
457
 
445
458
  addDebugLog("importArchive", "END", "-");