@pega/custom-dx-components 0.242.35 → 0.242.37

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 (52) hide show
  1. package/package.json +2 -2
  2. package/src/cli.js +6 -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 +3 -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 +2 -4
  12. package/src/tasks/import-comp/index.js +1 -2
  13. package/src/tasks/index.js +1 -0
  14. package/src/tasks/init/template/package.json.mustache +6 -5
  15. package/src/tasks/list/helper.js +8 -0
  16. package/src/tasks/list-lib/index.js +27 -11
  17. package/src/tasks/list-pub/index.js +18 -14
  18. package/src/tasks/move/helper.js +6 -3
  19. package/src/tasks/move/index.js +86 -17
  20. package/src/tasks/publish/helper.js +8 -5
  21. package/src/tasks/publish/index.js +4 -4
  22. package/src/tasks/publish-all/helper.js +16 -10
  23. package/src/tasks/quarantine/index.js +84 -0
  24. package/src/tasks/rename-lib/index.js +0 -1
  25. package/src/tasks/revert-webpack/index.js +0 -2
  26. package/src/tasks/set-perm/index.js +18 -2
  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 +3 -1
  30. package/src/util.js +50 -6
  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 +161 -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/localLibCreateLibValidateDeleteLib.test.js +217 -0
  51. package/tests/functional/localLibCreateLibVersionDeleteLib.test.js +453 -0
  52. 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.35",
3
+ "version": "0.242.37",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "@babel/plugin-transform-class-properties": "^7.23.3",
20
20
  "@babel/preset-react": "^7.23.3",
21
21
  "@pega/auth": "^0.1.6",
22
- "@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.17",
22
+ "@pega/constellation-dx-components-build-utils": "^1.0.1",
23
23
  "ajv": "^8.12.0",
24
24
  "ajv-keywords": "^5.1.0",
25
25
  "archiver": "^7.0.1",
package/src/cli.js CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  publishComponent,
28
28
  publishAllComponents,
29
29
  publishLibrary,
30
+ quarantine,
30
31
  renameComponent,
31
32
  moveComponent,
32
33
  renameLibrary,
@@ -60,6 +61,7 @@ const TASKS = {
60
61
  PUBLISH_LIB: 'publishLibrary',
61
62
  RENAME: 'rename',
62
63
  RENAME_LIB: 'renameLibrary',
64
+ QUARANTINE: 'quarantine',
63
65
  MOVE: 'moveComponent',
64
66
  LIST: 'list',
65
67
  LIST_LIB: 'listLibrary',
@@ -162,6 +164,10 @@ export default async (args = []) => {
162
164
  renameLibrary(options);
163
165
  break;
164
166
  }
167
+ case TASKS.QUARANTINE: {
168
+ quarantine(options);
169
+ break;
170
+ }
165
171
  case TASKS.MOVE: {
166
172
  moveComponent(options);
167
173
  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
 
@@ -16,7 +16,8 @@ import {
16
16
  checkLibraryAndArchives,
17
17
  getConfigDefaults,
18
18
  forceDefaultsUpdate,
19
- modAddAboutData
19
+ modAddAboutData,
20
+ cleanUpTemp
20
21
  } from '../../util.js';
21
22
 
22
23
  import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
@@ -31,6 +32,7 @@ export default async options => {
31
32
 
32
33
  await showVersion();
33
34
  await checkLibraryAndArchives();
35
+ await cleanUpTemp();
34
36
 
35
37
  addDebugLog("createVersion", "", "+");
36
38
  let libraryName;
@@ -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
 
@@ -2,9 +2,7 @@ import chalk from 'chalk';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { join } from 'path';
5
- import { Listr } from 'listr2';
6
- import { addDebugLog, getConfigDefaults, convertIntoPascalCase, getComponents, getComponentDirectoryPath, getDirectoryFiles } from '../../util.js';
7
- import { TASKS_CONFIG_JSON_FILENAME, TEMP_PATH, PACKAGE_JSON_FILENAME } from '../../constants.js';
5
+ import { addDebugLog } from '../../util.js';
8
6
 
9
7
 
10
8
  export const getFilePathQuestions = async () => {
@@ -42,7 +40,7 @@ addDebugLog("getFileNameQuestions", "", "");
42
40
  {
43
41
  name: 'fileName',
44
42
  type: 'rawlist',
45
- message: `Select zip file`,
43
+ message: `Select component`,
46
44
  choices: zipFileList
47
45
  },
48
46
  ];
@@ -27,7 +27,6 @@ import {
27
27
  convertIntoPascalCase,
28
28
  getComponentDirectoryPath
29
29
  } from '../../util.js';
30
- import Choice from 'inquirer/lib/objects/choice.js';
31
30
 
32
31
 
33
32
  const copy = promisify(ncp);
@@ -290,7 +289,7 @@ export default async options => {
290
289
  addDebugLog("importComponent", "", "+");
291
290
 
292
291
  if (options.params.length >= 5) {
293
- const filePath = options.param[3];
292
+ const filePath = options.params[3];
294
293
  const fileName = options.params[4];
295
294
  await importComp( filePath, fileName);
296
295
 
@@ -18,6 +18,7 @@ export { default as moveComponent } from './move/index.js';
18
18
  export { default as renameComponent } from './rename/index.js';
19
19
  export { default as renameLibrary } from './rename-lib/index.js';
20
20
  export { default as revertWebPack } from './revert-webpack/index.js';
21
+ export { default as quarantine } from './quarantine/index.js';
21
22
  export { default as listComponents } from './list/index.js';
22
23
  export { default as listLibrary } from './list-lib/index.js';
23
24
  export { default as listPublished } from './list-pub/index.js';
@@ -48,11 +48,12 @@
48
48
  "_internal-test-coverage": "node --input-type=module --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand node_modules/@pega/custom-dx-component --ci --testResultsProcessor='jest-junit' --coverage",
49
49
  "_internal-test": "echo 'Running functional and unit tests will DELETE existing local components, proceed (y/n)?' && read proceed && if test \"$proceed\" = \"y\"; then npm run _internal-test-full; fi ",
50
50
  "_internal-test-full": "npm run _internal-test-functional && npm run _internal-test-unit",
51
- "_internal-test-functional": "npm run test:functional:local --prefix node_modules/@pega/custom-dx-components",
51
+ "_internal-test-functional": "echo '\nMake sure you authenticate!!\n' && npm run test:functional:local --prefix node_modules/@pega/custom-dx-components",
52
52
  "_internal-test-unit": "npm run test:unit:local --prefix node_modules/@pega/custom-dx-components",
53
53
  "_internal-build-jest-assets": "custom-dx-components buildJestAssets",
54
54
  "_internal-buildLibrary": "custom-dx-components buildLibrary",
55
55
  "_internal-publishLibrary": "custom-dx-components publishLibrary",
56
+ "_internal-test-quarantine": "custom-dx-components quarantine",
56
57
  "_lint:styles": "stylelint \"./**/*.@(js|jsx|ts|tsx)\"",
57
58
  "_lint:format": "prettier -c .",
58
59
  "_lint:spelling": "cspell --no-progress **/*",
@@ -74,9 +75,9 @@
74
75
  "author": "",
75
76
  "license": "Enter License",
76
77
  "dependencies": {
77
- "@pega/cosmos-react-condition-builder": "7.0.0-build.29.2",
78
- "@pega/cosmos-react-core": "7.0.0-build.29.2",
79
- "@pega/cosmos-react-work": "7.0.0-build.29.2",
78
+ "@pega/cosmos-react-condition-builder": "7.0.0-rc.2",
79
+ "@pega/cosmos-react-core": "7.0.0-rc.2",
80
+ "@pega/cosmos-react-work": "7.0.0-rc.2",
80
81
  "@pega/eslint-config": "^0.10.2",
81
82
  "@pega/tsconfig": "^0.10.2",
82
83
  "babel-loader": "^9.1.3",
@@ -99,7 +100,7 @@
99
100
  },
100
101
  "devDependencies": {
101
102
  "@pega/configs": "^0.6.0",
102
- "@pega/custom-dx-components": "0.242.35",
103
+ "@pega/custom-dx-components": "0.242.37",
103
104
  "@pega/pcore-pconnect-typedefs": "~3.0.0",
104
105
  "@storybook/addon-actions": "^7.6.7",
105
106
  "@storybook/addon-essentials": "^7.6.19",
@@ -92,6 +92,11 @@ addDebugLog("listLocalComponents", `sourceOfComponents: ${sourceOfComponents}`,
92
92
  builtOn = data[0].buildDate;
93
93
  }
94
94
 
95
+ if (data.length === 0) {
96
+ console.log(chalk.bold.redBright(`No custom components in ${sourceOfComponents}`));
97
+ process.exit();
98
+ }
99
+
95
100
  let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
96
101
  console.log(chalk.bold.blueBright(`\nList of ${defConfig.library}:${defConfig.buildVersion} components.`));
97
102
  console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
@@ -261,6 +266,9 @@ addDebugLog("displayServerComponents", "", "");
261
266
  /* empty */
262
267
  }
263
268
  }
269
+
270
+
271
+
264
272
  /**
265
273
  * TODO: Need to modify the components list mapping code to support Launchpad components
266
274
  */
@@ -1,7 +1,7 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
 
4
- import {showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives, getLibraryArchivesVersions, getConfigDefaults, getLocalArchivedLibrraryVersionData, getComponentsConfigs } from '../../util.js';
4
+ import {showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives, getLibraryArchivesVersions, getConfigDefaults, getLocalArchivedLibrraryVersionData, getComponentsConfigs, cleanUpTemp } from '../../util.js';
5
5
  import { getArchiveLibraryQuestions } from './helper.js';
6
6
 
7
7
  export default async (options) => {
@@ -16,6 +16,8 @@ export default async (options) => {
16
16
  await checkLibraryAndArchives();
17
17
  addDebugLog("listLibrary", "", "+");
18
18
 
19
+ await cleanUpTemp();
20
+
19
21
  let organization;
20
22
  let library;
21
23
 
@@ -26,10 +28,15 @@ addDebugLog("listLibrary", "", "+");
26
28
  const currnetVersion = compDef.buildVersion;
27
29
  let selectedVersion;
28
30
  let libVersions = [];
31
+ let currentOrStore = "";
29
32
 
30
33
  if (options.params.length >= 5) {
31
34
  libraryName = options.params[3];
32
35
  selectedVersion = options.params[4];
36
+ if (options.params.length >= 6) {
37
+ currentOrStore = options.params[5];
38
+ }
39
+
33
40
 
34
41
  try {
35
42
  libVersions = await getLibraryArchivesVersions(libraryName, "");
@@ -77,17 +84,21 @@ addDebugLog("listLibrary", "", "+");
77
84
 
78
85
  console.log("\nYou've selected the current working library/version.");
79
86
  console.log("You can list current components or the last store of this library/version.");
80
- const archAnswers = await inquirer.prompt([
81
- {
82
- name: 'currentOrStore',
83
- type: 'rawlist',
84
- message: 'Select current or store',
85
- default: "Current",
86
- choices: ["Current", "Store"]
87
- },
88
- ]);
89
87
 
90
- const currentOrStore = archAnswers.currentOrStore;
88
+ if (currentOrStore === "") {
89
+ const archAnswers = await inquirer.prompt([
90
+ {
91
+ name: 'currentOrStore',
92
+ type: 'rawlist',
93
+ message: 'Select current or store',
94
+ default: "Current",
95
+ choices: ["Current", "Store"]
96
+ },
97
+ ]);
98
+
99
+ currentOrStore = archAnswers.currentOrStore;
100
+ }
101
+
91
102
 
92
103
  if (currentOrStore === "Current") {
93
104
  data = await getComponentsConfigs();
@@ -112,6 +123,11 @@ addDebugLog("listLibrary", "", "+");
112
123
  }
113
124
  }
114
125
 
126
+ if (data.length === 0) {
127
+ console.log(chalk.bold.redBright(`No custom components in ${libraryName}/${selectedVersion}`));
128
+ process.exit();
129
+ }
130
+
115
131
  let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
116
132
  console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
117
133
  console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
@@ -1,7 +1,7 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
 
4
- import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraries, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults } from '../../util.js';
4
+ import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraries, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults, cleanUpTemp } from '../../util.js';
5
5
 
6
6
  import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
7
7
 
@@ -43,6 +43,7 @@ export default async (options) => {
43
43
  await showVersion();
44
44
  await checkLibraryAndArchives();
45
45
  addDebugLog("listPublished", "", "+");
46
+ await cleanUpTemp();
46
47
 
47
48
  let sourceOfLibrary;
48
49
  let organization;
@@ -51,13 +52,14 @@ addDebugLog("listPublished", "", "+");
51
52
  const compDef = getConfigDefaults();
52
53
  organization = compDef.organization;
53
54
  library = compDef.library;
54
- let libraryName;
55
- let selectedVersion;
55
+ let libraryName = "";
56
+ let selectedVersion = "";
56
57
  let libVersions = [];
57
58
 
58
59
  if (options.params.length >= 5) {
59
60
  sourceOfLibrary = options.params[3];
60
- selectedVersion = options.params[4];
61
+ libraryName = options.params[4];
62
+ selectedVersion = options.params[5];
61
63
 
62
64
  libVersions.push(selectedVersion);
63
65
 
@@ -74,16 +76,18 @@ addDebugLog("listPublished", "", "+");
74
76
  // local
75
77
  const arLibs = await getLocalLibraries();
76
78
 
77
- const libAnswers = await inquirer.prompt([
78
- {
79
- name: 'library',
80
- type: 'rawlist',
81
- message: 'Pick library',
82
- choices: arLibs
83
- }
84
- ]);
79
+ if (libraryName === "") {
80
+ const libAnswers = await inquirer.prompt([
81
+ {
82
+ name: 'library',
83
+ type: 'rawlist',
84
+ message: 'Pick library',
85
+ choices: arLibs
86
+ }
87
+ ]);
85
88
 
86
- libraryName = libAnswers.library;
89
+ libraryName = libAnswers.library;
90
+ }
87
91
 
88
92
  if (libVersions.length == 0) {
89
93
  try {
@@ -96,7 +100,7 @@ addDebugLog("listPublished", "", "+");
96
100
 
97
101
  if (libVersions.length > 0) {
98
102
 
99
- if (selectedVersion === undefined) {
103
+ if (selectedVersion === "") {
100
104
  const libAnswers = await inquirer.prompt([
101
105
  {
102
106
  name: 'libVersion',
@@ -36,21 +36,24 @@ addDebugLog("getLibraryQuestions", "", "");
36
36
  ];
37
37
  };
38
38
 
39
- export const getLibraryVersionQuestion = async (libraryName, libVersions) => {
39
+ export const getLibraryVersionQuestion = async (libraryName, libVersions, copyOrMove) => {
40
40
  addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}`, "");
41
+ const configDef = getConfigDefaults();
41
42
 
42
43
  return [
43
44
  {
44
45
  name: 'version',
45
46
  type: 'rawlist',
46
- message: `Select ${chalk.green.bold(`${libraryName}`)} library version to move to`,
47
+ message: `Select ${chalk.green.bold(`${libraryName}`)} library version to ${copyOrMove} to`,
47
48
  choices: libVersions
48
49
  },
49
50
  {
50
51
  name: 'copyShared',
51
52
  type: 'confirm',
52
53
  message: `Copy ${chalk.yellow.bold("/shared")} directory (same named files will be overridden) ?`,
53
- default: true
54
+ default: true,
55
+ when: (answers) => (answers.version != configDef.buildVersion && libraryName != configDef.library)
56
+
54
57
  },
55
58
  ];
56
59
  };