@pega/custom-dx-components 0.242.34 → 0.242.36

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +12 -0
  3. package/src/constants.js +1 -0
  4. package/src/tasks/build-lib/helper.js +0 -1
  5. package/src/tasks/create-lib/index.js +5 -3
  6. package/src/tasks/create-version/index.js +12 -1
  7. package/src/tasks/delete-lib/index.js +4 -1
  8. package/src/tasks/delete-version/index.js +3 -1
  9. package/src/tasks/export-archive/index.js +58 -41
  10. package/src/tasks/import-archive/index.js +5 -1
  11. package/src/tasks/import-comp/helper.js +47 -0
  12. package/src/tasks/import-comp/index.js +320 -0
  13. package/src/tasks/index.js +2 -0
  14. package/src/tasks/init/template/package.json.mustache +5 -3
  15. package/src/tasks/list-lib/index.js +25 -16
  16. package/src/tasks/list-pub/index.js +18 -14
  17. package/src/tasks/move/helper.js +6 -3
  18. package/src/tasks/move/index.js +99 -58
  19. package/src/tasks/publish/helper.js +8 -5
  20. package/src/tasks/publish/index.js +4 -4
  21. package/src/tasks/publish-all/helper.js +16 -10
  22. package/src/tasks/quarantine/index.js +84 -0
  23. package/src/tasks/rename-lib/index.js +0 -1
  24. package/src/tasks/revert-webpack/index.js +0 -2
  25. package/src/tasks/set-perm/index.js +18 -2
  26. package/src/tasks/show-help/index.js +6 -4
  27. package/src/tasks/store/index.js +4 -1
  28. package/src/tasks/switch-lib/index.js +3 -1
  29. package/src/tasks/switch-version/index.js +11 -1
  30. package/src/util.js +84 -25
  31. package/tests/functional/localCreateAllListDeleteAll.test.js +56 -10
  32. package/tests/functional/localCreateBuildAllDeleteAll.test.js +56 -48
  33. package/tests/functional/localCreateBuildDelete.test.js +57 -10
  34. package/tests/functional/localCreateListDelete.test.js +55 -102
  35. package/tests/functional/localCreatePublishAllDeleteAll.test.js +68 -61
  36. package/tests/functional/localCreatePublishDelete.test.js +62 -21
  37. package/tests/functional/localCreateRenameDelete.test.js +55 -140
  38. package/tests/functional/localLibCreateLibAlreadyDeleteLib.test.js +118 -0
  39. package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +241 -0
  40. package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +246 -0
  41. package/tests/functional/localLibCreateLibDeleteLib.test.js +109 -0
  42. package/tests/functional/localLibCreateLibExportImportLib.test.js +242 -0
  43. package/tests/functional/localLibCreateLibExportLib.test.js +219 -0
  44. package/tests/functional/localLibCreateLibImportCompDeleteLib.test.js +131 -0
  45. package/tests/functional/localLibCreateLibListDeleteLib.test.js +261 -0
  46. package/tests/functional/localLibCreateLibListMoveDeleteLib.test.js +236 -0
  47. package/tests/functional/localLibCreateLibListSwitchDeleteLib.test.js +237 -0
  48. package/tests/functional/localLibCreateLibPermDeleteLib.test.js +144 -0
  49. package/tests/functional/localLibCreateLibStatusDeleteLib.test.js +194 -0
  50. package/tests/functional/localLibCreateLibVersionDeleteLib.test.js +453 -0
  51. package/tests/functional/localPromoteRevertWP.test.js +83 -38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.242.34",
3
+ "version": "0.242.36",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
package/src/cli.js CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  deleteVersion,
20
20
  importArchive,
21
21
  exportArchive,
22
+ importComponent,
22
23
  initProject,
23
24
  listComponents,
24
25
  listLibrary,
@@ -26,6 +27,7 @@ import {
26
27
  publishComponent,
27
28
  publishAllComponents,
28
29
  publishLibrary,
30
+ quarantine,
29
31
  renameComponent,
30
32
  moveComponent,
31
33
  renameLibrary,
@@ -59,6 +61,7 @@ const TASKS = {
59
61
  PUBLISH_LIB: 'publishLibrary',
60
62
  RENAME: 'rename',
61
63
  RENAME_LIB: 'renameLibrary',
64
+ QUARANTINE: 'quarantine',
62
65
  MOVE: 'moveComponent',
63
66
  LIST: 'list',
64
67
  LIST_LIB: 'listLibrary',
@@ -76,6 +79,7 @@ const TASKS = {
76
79
  DELETE_VERSION: 'deleteVersion',
77
80
  IMPORT_ARCHIVE: 'importArchive',
78
81
  EXPORT_ARCHIVE: 'exportArchive',
82
+ IMPORT_COMP: 'importComponent',
79
83
  AUTHENTICATE: 'authenticate',
80
84
  UPGRADE: 'upgrade',
81
85
  BUILD_JEST_ASSETS: 'buildJestAssets'
@@ -160,6 +164,10 @@ export default async (args = []) => {
160
164
  renameLibrary(options);
161
165
  break;
162
166
  }
167
+ case TASKS.QUARANTINE: {
168
+ quarantine(options);
169
+ break;
170
+ }
163
171
  case TASKS.MOVE: {
164
172
  moveComponent(options);
165
173
  break;
@@ -212,6 +220,10 @@ export default async (args = []) => {
212
220
  exportArchive(options);
213
221
  break;
214
222
  }
223
+ case TASKS.IMPORT_COMP: {
224
+ importComponent(options);
225
+ break;
226
+ }
215
227
  case TASKS.VALIDATE_SCHEMA: {
216
228
  validate(options);
217
229
  break;
package/src/constants.js CHANGED
@@ -49,6 +49,7 @@ export const BOOTSTRAP_CONFIG = 'PRRestService/api/application/v2/data_views/D_p
49
49
 
50
50
  export const JEST_ASSETS_ORIGINAL_PATH = 'node_modules/@pega/custom-dx-components/tests/assets/original/components/';
51
51
  export const JEST_ASSETS_LIBRARY_PATH = 'node_modules/@pega/custom-dx-components/tests/assets/library/components/';
52
+ export const JEST_TESTS_FUNCTIONAL_PATH = 'node_modules/@pega/custom-dx-components/tests/functional/';
52
53
  export const JEST_CREATE_PATH = 'create/';
53
54
  export const JEST_CREATE_ALL_CONSTELLATION_PATH = 'createAll/Constellation/';
54
55
  export const JEST_CREATE_ALL_LAUNCHPAD_PATH = 'createAll/Launchpad';
@@ -9,7 +9,6 @@ import {
9
9
  addDebugLog,
10
10
  getLibraryBased
11
11
  } from '../../util.js';
12
- import { TASKS_CONFIG_JSON_FILENAME } from '../../constants.js';
13
12
 
14
13
 
15
14
  export const getBuildComponentQuestions = async (defaultVersion) => {
@@ -14,7 +14,8 @@ import {
14
14
  clearSrcComponentsDirectory,
15
15
  hasLibraryAndVersion,
16
16
  getConfigDefaults,
17
- forceDefaultsUpdate
17
+ forceDefaultsUpdate,
18
+ cleanUpTemp
18
19
  } from '../../util.js';
19
20
 
20
21
  import { getCreateLibComponentQuestions, getOkToProceedQuestion } from './helper.js';
@@ -28,6 +29,7 @@ export default async options => {
28
29
  }
29
30
 
30
31
  await showVersion();
32
+ await cleanUpTemp();
31
33
 
32
34
  addDebugLog("createLibrary", "", "+");
33
35
  let libraryName;
@@ -37,7 +39,7 @@ addDebugLog("createLibrary", "", "+");
37
39
  const orgLib = getConfigDefaults();
38
40
  const hasArch = await hasArchives();
39
41
 
40
- if (hasArch) {
42
+ if (hasArch && options.params.length < 6) {
41
43
  console.log(chalk.bold.yellow('\nBe sure to SAVE all changes before creating a new library, unsaved changes will be LOST.'))
42
44
  console.log(chalk.bold.yellow('Current library/version will be stored and the newly created library/version will be your default.'))
43
45
 
@@ -70,7 +72,7 @@ addDebugLog("createLibrary", "", "+");
70
72
  const hasLib = await hasLibraryAndVersion(libraryName, version, !permBuild);
71
73
  if (hasLib) {
72
74
  console.log(`${chalk.bold.red(`Library ${orgLib.organization}_${libraryName} already exists.`)}`);
73
- console.log("You can switch to that version by entering 'npm run switchVersion'.\n")
75
+ console.log("You can switch to that library by entering 'npm run switchLib'.\n")
74
76
  process.exit();
75
77
  }
76
78
 
@@ -15,7 +15,9 @@ import {
15
15
  setConfigDevBuild,
16
16
  checkLibraryAndArchives,
17
17
  getConfigDefaults,
18
- forceDefaultsUpdate
18
+ forceDefaultsUpdate,
19
+ modAddAboutData,
20
+ cleanUpTemp
19
21
  } from '../../util.js';
20
22
 
21
23
  import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
@@ -30,6 +32,7 @@ export default async options => {
30
32
 
31
33
  await showVersion();
32
34
  await checkLibraryAndArchives();
35
+ await cleanUpTemp();
33
36
 
34
37
  addDebugLog("createVersion", "", "+");
35
38
  let libraryName;
@@ -47,6 +50,14 @@ addDebugLog("createVersion", "", "+");
47
50
  version = options.params[3];
48
51
  const dPerm = options.params[4];
49
52
  const copyExist = options.params[5]
53
+
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
+ }
60
+
50
61
  permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
51
62
  copyExisting = !!(copyExist === 'Y' || copyExist === 'y' || copyExist === true || copyExist === 'true');
52
63
 
@@ -15,7 +15,9 @@ import {
15
15
  getLibraryArchiveDirectories,
16
16
  deleteArchives,
17
17
  forceDefaultsUpdate,
18
- restoreFromArchive } from '../../util.js';
18
+ restoreFromArchive,
19
+ cleanUpTemp
20
+ } from '../../util.js';
19
21
 
20
22
  import { getDeleteLibraryQuestions, getLibraryVersionQuestion } from './helper.js';
21
23
  import { showCurrentStatus } from '../show-status/index.js';
@@ -157,6 +159,7 @@ export default async (options) => {
157
159
 
158
160
  await showVersion();
159
161
  await checkLibraryAndArchives();
162
+ await cleanUpTemp();
160
163
 
161
164
  addDebugLog("deleteLibrary", "", "+");
162
165
 
@@ -6,7 +6,8 @@ import {
6
6
  getLibraryBased,
7
7
  checkLibraryAndArchives,
8
8
  getConfigDefaults,
9
- addDebugLog
9
+ addDebugLog,
10
+ cleanUpTemp
10
11
  } from '../../util.js';
11
12
 
12
13
  import { deleteLibraryVersion } from '../delete-lib/index.js';
@@ -21,6 +22,7 @@ export default async (options) => {
21
22
 
22
23
  await showVersion();
23
24
  await checkLibraryAndArchives();
25
+ await cleanUpTemp();
24
26
 
25
27
  addDebugLog("deleteVersion", "", "+");
26
28
 
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import { promisify } from 'util';
3
3
  import { join } from 'path';
4
+ import path from 'path';
4
5
 
5
6
  import inquirer from 'inquirer';
6
7
  import ncp from 'ncp';
@@ -13,10 +14,11 @@ import {
13
14
  checkLibraryAndArchives,
14
15
  getConfigDefaults,
15
16
  getLibraryBased,
16
- zipVersionAndArchive
17
+ zipVersionAndArchive,
18
+ cleanUpTemp
17
19
  } from '../../util.js';
18
- import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
19
- import { getFilePathQuestions, getFileNameQuestions, getLibraryQuestion, getLibraryVersionQuestion } from './helper.js';
20
+ import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH } from '../../constants.js';
21
+ import { getFilePathQuestions, getLibraryQuestion, getLibraryVersionQuestion } from './helper.js';
20
22
 
21
23
  export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
22
24
  const currentDirectory = process.cwd();
@@ -74,7 +76,7 @@ addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldCompon
74
76
 
75
77
 
76
78
 
77
- export const exportArch = async(exportPath, orgLibName, selectedVersion) => {
79
+ export const exportArch = async(exportPath, orgLibName, selectedVersion, currentOrArchive = "") => {
78
80
  addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName}, selectedVersion: ${selectedVersion}`, "");
79
81
  const currentDirectory = process.cwd();
80
82
  const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${selectedVersion}`);
@@ -84,25 +86,33 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
84
86
 
85
87
  const exportFile = join(exportPath, fileName);
86
88
 
89
+ let output;
90
+
91
+ let archiveBeforeStore = false;
92
+
87
93
 
88
94
  if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
89
95
 
90
- console.log("\nYou've selected the current working library/version.");
91
- console.log("You export store or the current.");
92
- const archAnswers = await inquirer.prompt([
93
- {
94
- name: 'currentOrStore',
95
- type: 'rawlist',
96
- message: 'Select current or store',
97
- default: "Current",
98
- choices: ["Current", "Store"]
99
- },
100
- ]);
96
+ let currentOrStore = currentOrArchive;
97
+ if (currentOrArchive === "") {
98
+ console.log("\nYou've selected the current working library/version.");
99
+ console.log("Export store or the current.");
100
+ const archAnswers = await inquirer.prompt([
101
+ {
102
+ name: 'currentOrStore',
103
+ type: 'rawlist',
104
+ message: 'Select current or store',
105
+ default: "Current",
106
+ choices: ["Current", "Store"]
107
+ },
108
+ ]);
109
+
110
+ currentOrStore = archAnswers.currentOrStore;
111
+
112
+ }
101
113
 
102
- const currentOrStore = archAnswers.currentOrStore;
103
114
  if (currentOrStore === "Current") {
104
- // archive it
105
- await zipVersionAndArchive(configDef.currentOrgLib, configDef.buildVersion);
115
+ archiveBeforeStore = true;
106
116
  }
107
117
  }
108
118
 
@@ -126,28 +136,24 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
126
136
  }
127
137
  }
128
138
 
129
- if (fs.existsSync(exportFile)) {
130
- console.log(`\nFile: ${chalk.green(`${exportFile}`)} already exists.`);
131
- const overrideAnswer = await inquirer.prompt([
132
- {
133
- name: 'overrideExisting',
134
- type: 'confirm',
135
- message: 'Override existing',
136
- default: false
137
- },
138
- ]);
139
+ if (archiveBeforeStore) {
140
+ // archive it
141
+ output = await zipVersionAndArchive(configDef.currentOrgLib, configDef.buildVersion);
139
142
 
140
- const overrideExisting = overrideAnswer.overrideExisting;
141
- if (!overrideExisting) {
142
- console.log(chalk.green("Store not exported."));
143
- process.exit();
144
- }
145
- }
143
+ // if archiving, need to wait before copying
144
+ output.on('close', function() {
145
+ fs.copyFileSync(archFileName, exportFile );
146
146
 
147
+ console.log(`\n${chalk.green(`${fileName}`)} has been exported to ${chalk.green(`${exportPath}`)}`);
147
148
 
148
- fs.copyFileSync(archFileName, exportFile );
149
+ });
150
+ }
151
+ else {
152
+ fs.copyFileSync(archFileName, exportFile );
153
+
154
+ console.log(`\n${chalk.green(`${fileName}`)} has been exported to ${chalk.green(`${exportPath}`)}`);
155
+ }
149
156
 
150
- console.log(`\n${chalk.green(`${fileName}`)} has been exported to ${chalk.green(`${exportPath}`)}`);
151
157
 
152
158
  }
153
159
 
@@ -177,14 +183,18 @@ export default async options => {
177
183
  process.exit();
178
184
  }
179
185
 
186
+ await cleanUpTemp();
187
+
180
188
  addDebugLog("exportArchive", "", "+");
181
189
 
182
190
 
183
- if (options.params.length >= 6) {
184
- const libraryName = options.params[4];
185
- const libraryVersion = options.params[5];
191
+ if (options.params.length >= 7) {
192
+ const libraryName = options.params[3];
193
+ const libraryVersion = options.params[4];
194
+ const filePath = options.params[5];
195
+ const currentOrArchive = options.params[6];
186
196
 
187
- await exportArch(filePath, libraryName, libraryVersion );
197
+ await exportArch(filePath, libraryName, libraryVersion, currentOrArchive );
188
198
 
189
199
  }
190
200
  else {
@@ -199,7 +209,14 @@ export default async options => {
199
209
 
200
210
  const filePathQuestions = await getFilePathQuestions();
201
211
  const filePathAnswers = await inquirer.prompt(filePathQuestions);
202
- const { filePath } = filePathAnswers;
212
+ let { filePath } = filePathAnswers;
213
+
214
+
215
+ // if (path.sep === "/") {
216
+ // if (filePath.lastIndexOf(path.sep) != filePath.length - 1) {
217
+ // filePath = filePath.concat(path.sep);
218
+ // }
219
+ // }
203
220
 
204
221
  await exportArch( filePath, orgLibName, selectedVersion);
205
222
 
@@ -18,7 +18,8 @@ import {
18
18
  unZipFromArchive,
19
19
  zipVersionAndArchive,
20
20
  getLibraryArchiveDirectories,
21
- hasLibraryAndVersion
21
+ hasLibraryAndVersion,
22
+ cleanUpTemp
22
23
  } from '../../util.js';
23
24
  import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
24
25
  import { getFilePathQuestions, getFileNameQuestions, updateTempArchive } from './helper.js';
@@ -357,10 +358,13 @@ export default async options => {
357
358
  process.exit();
358
359
  }
359
360
 
361
+ await cleanUpTemp();
362
+
360
363
  addDebugLog("importArchive", "", "+");
361
364
 
362
365
 
363
366
  if (options.params.length >= 5) {
367
+ const filePath = options.params[3];
364
368
  const fileName = options.params[4];
365
369
  await importArch( filePath, fileName);
366
370
 
@@ -0,0 +1,47 @@
1
+ import chalk from 'chalk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { join } from 'path';
5
+ import { addDebugLog } from '../../util.js';
6
+
7
+
8
+ export const getFilePathQuestions = async () => {
9
+ addDebugLog("getFilePathQuestions", "", "");
10
+
11
+ console.log("\nFile path examples:");
12
+ if (path.sep === "/") {
13
+ console.log("\tMac OS/Unix:\t/Users/name/...\n");
14
+ }
15
+ else {
16
+ console.log("\tWindows:\tC:\\Users\\name\\...\n");
17
+ }
18
+
19
+ const currentDirectory = process.cwd();
20
+ const arPathParts = currentDirectory.split(path.sep);
21
+ let defaultPath = join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
22
+ if (path.sep === "/") {
23
+ defaultPath = "/".concat(defaultPath);
24
+ }
25
+
26
+
27
+ return [
28
+ {
29
+ name: 'filePath',
30
+ message: 'Enter full file path of zip file location:',
31
+ default: defaultPath
32
+ }
33
+ ];
34
+ };
35
+
36
+ export const getFileNameQuestions = async (zipFileList) => {
37
+ addDebugLog("getFileNameQuestions", "", "");
38
+
39
+ return [
40
+ {
41
+ name: 'fileName',
42
+ type: 'rawlist',
43
+ message: `Select component`,
44
+ choices: zipFileList
45
+ },
46
+ ];
47
+ };