@pega/custom-dx-components 0.242.31 → 0.242.32

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": "0.242.31",
3
+ "version": "0.242.32",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@ addDebugLog("getCreateLibComponentQuestions", "", "");
17
17
  name: 'okToContinue',
18
18
  type: 'confirm',
19
19
  message: 'Ok to continue ?',
20
- default: false
20
+ default: true
21
21
  }
22
22
  ];
23
23
 
@@ -56,7 +56,7 @@ addDebugLog("getCreateLibComponentQuestions", "", "");
56
56
  }
57
57
  else {
58
58
  return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
59
- }
59
+ }
60
60
  }
61
61
  },
62
62
  {
@@ -201,7 +201,7 @@ export default async options => {
201
201
  const filePathAnswers = await inquirer.prompt(filePathQuestions);
202
202
  const { filePath } = filePathAnswers;
203
203
 
204
- await exportArch( zipFilePath, orgLibName, selectedVersion);
204
+ await exportArch( filePath, orgLibName, selectedVersion);
205
205
 
206
206
  }
207
207
 
@@ -1,13 +1,244 @@
1
1
  import chalk from 'chalk';
2
+ import fs from 'fs';
2
3
  import path from 'path';
3
4
  import { join } from 'path';
4
- import { addDebugLog, getConfigDefaults, getLibraryArchiveDirectories, getLibraryBased } from '../../util.js';
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';
8
+
5
9
 
6
10
  export const SOURCE_OF_COMPONENT_TYPES = {
7
11
  SERVER: 'Server',
8
12
  LOCAL: 'Local'
9
13
  };
10
14
 
15
+ export const setTasksConfig = async (libraryName, version, devBuild, currDir) => {
16
+ addDebugLog("setTasksConfig", `libraryName: ${libraryName}, version: ${version}, devBuild: ${devBuild}`, "");
17
+ const pegaConfigJsonPath = join(currDir, TASKS_CONFIG_JSON_FILENAME);
18
+ const sPegaData = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
19
+ const configData = JSON.parse(sPegaData);
20
+ let serverConfig = configData['server-config'];
21
+ serverConfig.devBuild = devBuild;
22
+ let compConfig = configData['component'];
23
+ compConfig.library = libraryName;
24
+ compConfig.version = version;
25
+
26
+ // update file
27
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
28
+ fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8' });
29
+ }
30
+
31
+ export const setPackageOrg = async (organization, currDir) => {
32
+ addDebugLog("setPackageOrg", "", "");
33
+ const packageJsonPath = join(currDir, PACKAGE_JSON_FILENAME);
34
+ const sPackage = fs.readFileSync(packageJsonPath, { encoding: 'utf8'});
35
+ const packageData = JSON.parse(sPackage);
36
+
37
+ packageData.organization = organization;
38
+
39
+ // update file
40
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
41
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 4), { encoding: 'utf8' });
42
+
43
+ }
44
+
45
+ export const updateConfig = async (
46
+ {
47
+ oldComponentKey,
48
+ newComponentKey,
49
+ organization,
50
+ library,
51
+ version,
52
+ currentDirectory,
53
+ }
54
+ ) => {
55
+
56
+ addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
57
+
58
+ let configData = fs.readFileSync(join(currentDirectory, "/config.json"), { encoding: 'utf8' });
59
+ configData = configData && JSON.parse(configData);
60
+
61
+ configData.name = newComponentKey;
62
+ if (configData.componentKey) configData.componentKey = newComponentKey;
63
+ configData.organization = organization;
64
+ configData.library = library;
65
+ configData.version = version;
66
+
67
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
68
+ fs.writeFileSync(join(currentDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
69
+
70
+ };
71
+
72
+ export const updateFile = async (
73
+ fileName,
74
+ oldComponentKeyPC,
75
+ newComponentKeyPC,
76
+ currentDirectory,
77
+ ) => {
78
+
79
+ addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, currentDirectory: ${currentDirectory}`, "");
80
+
81
+ let fileData = fs.readFileSync(join(currentDirectory, "/", fileName), { encoding: 'utf8' });
82
+
83
+ if (fileData.indexOf(oldComponentKeyPC) >= 0) {
84
+ fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
85
+
86
+ fs.writeFileSync(join(currentDirectory, "/", fileName), fileData, { encoding: 'utf8' });
87
+ }
88
+
89
+ };
90
+
91
+ export const reanmeDirectory = async(currentDirectory, targetDirectory) => {
92
+ if (!fs.existsSync(targetDirectory)) {
93
+ fs.mkdirSync(targetDirectory, { recursive: true });
94
+ }
95
+
96
+ const targetFileList = await getDirectoryFiles(currentDirectory);
97
+ for (const targetFile of targetFileList) {
98
+ const currentFilePath = join(currentDirectory, targetFile);
99
+ const targetFilePath = join(targetDirectory, targetFile);
100
+ fs.copyFileSync(currentFilePath, targetFilePath)
101
+ }
102
+
103
+ // fs.rm(currentDirectory, { recursive: true }, err => {
104
+ // if (err) {
105
+ // throw err;
106
+ // }
107
+ // });
108
+
109
+ fs.rmSync(currentDirectory, { recursive: true, force: true, maxRetries: 2 });
110
+
111
+
112
+ }
113
+
114
+ // rename the component
115
+ export const renameComponent = async (
116
+ componentKey,
117
+ library,
118
+ version,
119
+ currDir
120
+ ) => {
121
+
122
+ addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
123
+
124
+
125
+ const componentName = componentKey.split("_")[2];
126
+
127
+ const configDef = getConfigDefaults();
128
+ const orgLibName = `${configDef.organization}_${library}`;
129
+ const organization = configDef.organization;
130
+
131
+ const newComponentKey = `${orgLibName}_${componentName}`;
132
+
133
+ const oldComponentKey = componentKey;
134
+ const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
135
+ const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
136
+
137
+ const currentDirectory = await getComponentDirectoryPath(componentKey, currDir);
138
+ const targetDirectory = await getComponentDirectoryPath(newComponentKey, currDir);
139
+
140
+ const targetFileList = await getDirectoryFiles(currentDirectory);
141
+
142
+ for (const fileIndex in targetFileList) {
143
+ const fileName = targetFileList[fileIndex];
144
+
145
+ if (fileName === "config.json") {
146
+ await updateConfig(
147
+ {
148
+ oldComponentKey,
149
+ newComponentKey,
150
+ componentName,
151
+ organization,
152
+ library,
153
+ version,
154
+ currentDirectory,
155
+ }
156
+ );
157
+ }
158
+ else {
159
+ await updateFile(
160
+ fileName,
161
+ oldComponentKeyPC,
162
+ newComponentKeyPC,
163
+ currentDirectory );
164
+
165
+ }
166
+
167
+ } // for
168
+
169
+
170
+
171
+ // rename the directory
172
+ await reanmeDirectory(currentDirectory, targetDirectory);
173
+
174
+
175
+ return newComponentKey;
176
+
177
+ };
178
+
179
+ export const renameComponents = async(compList, libraryName, version, compDir) => {
180
+ for (const componentKey of compList) {
181
+ await renameComponent(componentKey, libraryName, version, compDir);
182
+ }
183
+ }
184
+
185
+ export const updateTempArchive = async(libraryName, version, devBuild) => {
186
+ const currentDirectory = process.cwd();
187
+ const tempStoreDirectory = join(currentDirectory, TEMP_PATH);
188
+ const configDef = getConfigDefaults();
189
+
190
+ // remove -dev if exists
191
+ const justVersion = version.replace("-dev", "");
192
+
193
+ // open tasks.config and update it
194
+ // await setTasksConfig(libraryName, justVersion, devBuild, tempStoreDirectory);
195
+
196
+ // open package.json, update org
197
+ // await setPackageOrg(configDef.organization, tempStoreDirectory);
198
+
199
+ // update all the components
200
+ // const compDir = join(tempStoreDirectory, "src", "components");
201
+ // const compList = await getComponents(compDir);
202
+
203
+ // await renameComponents(compList, libraryName, version, compDir);
204
+
205
+ const tasks = new Listr(
206
+ [
207
+ {
208
+ title: 'Update tasks.config',
209
+ task: async () => {
210
+ await setTasksConfig(libraryName, justVersion, devBuild, tempStoreDirectory);
211
+ }
212
+ },
213
+ {
214
+ title: 'Update package.json',
215
+ task: async () => {
216
+ await setPackageOrg(configDef.organization, tempStoreDirectory);
217
+ }
218
+ },
219
+ {
220
+ title: `Renaming components`,
221
+ task: async () => {
222
+ const compDir = join(tempStoreDirectory, "src", "components");
223
+ const compList = await getComponents(compDir);
224
+
225
+ await renameComponents(compList, libraryName, version, compDir);
226
+ }
227
+ }
228
+ ],
229
+ {
230
+ exitOnError: true
231
+ }
232
+ );
233
+
234
+ await tasks.run().catch(err => {
235
+ console.log(chalk.bold.red(err.toString()));
236
+ process.exit(1);
237
+ });
238
+
239
+
240
+ }
241
+
11
242
 
12
243
  export const getFilePathQuestions = async () => {
13
244
  addDebugLog("getFilePathQuestions", "", "");
@@ -7,9 +7,9 @@ import ncp from 'ncp';
7
7
  import chalk from 'chalk';
8
8
 
9
9
  import {
10
+ sanitize,
10
11
  checkPathAccess,
11
12
  showVersion,
12
- getComponentsObj,
13
13
  getDirectoryFiles,
14
14
  addDebugLog,
15
15
  checkLibraryAndArchives,
@@ -17,16 +17,16 @@ import {
17
17
  getLibraryBased,
18
18
  unZipFromArchive,
19
19
  zipVersionAndArchive,
20
- getLibraryArchivesVersions
20
+ getLibraryArchiveDirectories,
21
+ hasLibraryAndVersion
21
22
  } from '../../util.js';
22
- import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
23
- import { getFilePathQuestions, getFileNameQuestions } from './helper.js';
23
+ import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
24
+ import { getFilePathQuestions, getFileNameQuestions, updateTempArchive } from './helper.js';
24
25
 
25
26
  export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
26
27
  const currentDirectory = process.cwd();
27
28
  const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
28
29
 
29
-
30
30
  import {
31
31
  convertIntoPascalCase,
32
32
  getComponentDirectoryPath
@@ -212,9 +212,86 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
212
212
 
213
213
  }
214
214
 
215
+
216
+
215
217
  const arFileData = fileName.split("_");
216
- const orgLibName = `${arFileData[0]}_${arFileData[1]}`;
218
+ let orgLibName = `${arFileData[0]}_${arFileData[1]}`;
219
+ let libName = arFileData[1];
217
220
  const version = arFileData[2].replace(".zip", "");
221
+ const devBuild = version.indexOf("-dev") > 0 ? true : false;
222
+ const configDef = getConfigDefaults();
223
+
224
+ if (arFileData[0] !== configDef.organization) {
225
+ console.log(`\nImported ${chalk.yellow(`${orgLibName}/${version}`)} is not the same organization as your current organization: ${chalk.yellow(`${configDef.organization}`)}.`);
226
+ console.log(`\nTo import, the organization of the components will be changed to match your organization.`);
227
+ console.log(`\n\t>>> If you don't want this to happen, then end and create a new project with an organization`);
228
+ console.log(`\t of ${chalk.yellow(`${arFileData[0]}`)} and import there.\n`);
229
+
230
+ const proceedAnswers = await inquirer.prompt([
231
+
232
+ {
233
+ name: 'okToContinue',
234
+ type: 'confirm',
235
+ message: `Ok to proceed ?`,
236
+ default: true
237
+ }
238
+ ]);
239
+
240
+ if (proceedAnswers.okToContinue) {
241
+ // check if new version matches existing
242
+ // -dev is already on version, if present, so "false", for devBuild here
243
+ const alreadyExists = await hasLibraryAndVersion(libName, version, false);
244
+ if (alreadyExists) {
245
+ console.log(`${chalk.yellow(`${configDef.organization}_${libName}/${version}`)} already exists.`);
246
+ const archDirectories = await getLibraryArchiveDirectories();
247
+ const newLibNameAnswers = await inquirer.prompt([
248
+ {
249
+ name: 'libraryName',
250
+ message: 'Enter new libray name',
251
+ validate: value => {
252
+ /* value should not be empty
253
+ It should not have spaces
254
+ It should not start with a number
255
+ Only case-insensitive alphanumeric values are allowed
256
+ */
257
+ if (value && !/^\d/.test(value) && value === sanitize(value)) {
258
+ if (archDirectories && archDirectories.length > 0) {
259
+ const newOrgLib = `${configDef.organization}_${value}`;
260
+ if (archDirectories.includes(newOrgLib)) {
261
+ return `Library ${value} already exists.`;
262
+ }
263
+ else {
264
+ return true;
265
+ }
266
+ }
267
+ else {
268
+ return true;
269
+ }
270
+
271
+ }
272
+ else {
273
+ return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
274
+ }
275
+ }
276
+ }
277
+ ]);
278
+
279
+ libName = newLibNameAnswers.libraryName;
280
+ }
281
+
282
+ // rename orgLibName
283
+ orgLibName = `${configDef.organization}_${libName}`;
284
+
285
+ // update temp with new info
286
+ await updateTempArchive(libName, version, devBuild);
287
+
288
+ }
289
+ else {
290
+ process.exit();
291
+ }
292
+
293
+
294
+ }
218
295
 
219
296
  // rearchive temp directory
220
297
  await zipVersionAndArchive(orgLibName, version, tempDirectory);
@@ -34,6 +34,7 @@
34
34
  "deleteLib": "custom-dx-components deleteLibrary",
35
35
  "deletePublishedLib": "custom-dx-components deletePublished",
36
36
  "deleteLibVersion": "custom-dx-components deleteVersion",
37
+ "moveLibVersion": "custom-dx-components moveComponent",
37
38
  "publishLibVersion": "custom-dx-components publish",
38
39
  "storeLibVersion": "custom-dx-components storeComponents",
39
40
  "showStatus": "custom-dx-components showStatus",
@@ -97,7 +98,7 @@
97
98
  },
98
99
  "devDependencies": {
99
100
  "@pega/configs": "^0.6.0",
100
- "@pega/custom-dx-components": "0.242.31",
101
+ "@pega/custom-dx-components": "0.242.32",
101
102
  "@pega/pcore-pconnect-typedefs": "~3.0.0",
102
103
  "@storybook/addon-actions": "^7.6.7",
103
104
  "@storybook/addon-essentials": "^7.6.19",
@@ -2,9 +2,12 @@ import chalk from 'chalk';
2
2
 
3
3
  import {
4
4
  getPegaServerConfig,
5
- addDebugLog
5
+ addDebugLog,
6
+ getC11NB2STokenAndStaticServer
6
7
  } from '../../util.js';
7
8
 
9
+ import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
10
+
8
11
  export const SOURCE_OF_COMPONENT_TYPES = {
9
12
  SERVER: 'Server',
10
13
  LOCAL: 'Local'
@@ -39,4 +42,33 @@ addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}, libVersio
39
42
  }
40
43
  ];
41
44
 
45
+ };
46
+
47
+ export const getServerLocalQuestion = async() => {
48
+ addDebugLog("getServerLocalQuestion", "", "");
49
+ const defaultPegaConfig = await getPegaServerConfig();
50
+
51
+ return [
52
+ {
53
+ name: 'sourceOfLibrary',
54
+ type: 'rawlist',
55
+ message: `List from Server or Local ?`,
56
+ choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
57
+ default: "defaultPegaConfig.sourceOfComponents",
58
+ }
59
+ ];
60
+ };
61
+
62
+ export const getServerLibraries = async() => {
63
+ addDebugLog("listLibJSONResponse", "services call", "");
64
+ // server
65
+ const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
66
+ const oLibList = await listLibJSONResponse(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
67
+ addDebugLog("listLibJSONResponse", "services end", "");
68
+ if (oLibList) {
69
+ return Object.keys(oLibList);
70
+ }
71
+
72
+ return [];
73
+
42
74
  }
@@ -1,11 +1,11 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
3
 
4
- import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults } from '../../util.js';
4
+ import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraries, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults } from '../../util.js';
5
5
 
6
6
  import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
7
7
 
8
- import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
8
+ import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES, getServerLibraries, getServerLocalQuestion } from './helper.js';
9
9
 
10
10
 
11
11
 
@@ -51,7 +51,7 @@ addDebugLog("listPublished", "", "+");
51
51
  const compDef = getConfigDefaults();
52
52
  organization = compDef.organization;
53
53
  library = compDef.library;
54
- const libraryName = compDef.currentOrgLib;
54
+ let libraryName;
55
55
  let selectedVersion;
56
56
  let libVersions = [];
57
57
 
@@ -64,7 +64,7 @@ addDebugLog("listPublished", "", "+");
64
64
  }
65
65
  else {
66
66
 
67
- const questions = await getListLibraryQuestions(libraryName);
67
+ const questions = await getServerLocalQuestion();
68
68
  const answers = await inquirer.prompt(questions);
69
69
  ({ sourceOfLibrary } = answers);
70
70
 
@@ -72,6 +72,18 @@ addDebugLog("listPublished", "", "+");
72
72
 
73
73
  if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
74
74
  // local
75
+ const arLibs = await getLocalLibraries();
76
+
77
+ const libAnswers = await inquirer.prompt([
78
+ {
79
+ name: 'library',
80
+ type: 'rawlist',
81
+ message: 'Pick library',
82
+ choices: arLibs
83
+ }
84
+ ]);
85
+
86
+ libraryName = libAnswers.library;
75
87
 
76
88
  if (libVersions.length == 0) {
77
89
  try {
@@ -86,7 +98,6 @@ addDebugLog("listPublished", "", "+");
86
98
 
87
99
  if (selectedVersion === undefined) {
88
100
  const libAnswers = await inquirer.prompt([
89
-
90
101
  {
91
102
  name: 'libVersion',
92
103
  type: 'rawlist',
@@ -123,34 +134,54 @@ addDebugLog("listPublished", "END", "-");
123
134
 
124
135
  }
125
136
  else {
126
- const libVersions = await getServerLibraryVersions(libraryName);
127
137
 
128
- if (libVersions) {
129
- const keys = Object.keys(libVersions);
130
- const libAnswers = await inquirer.prompt([
138
+ const arLibs = await getServerLibraries();
139
+ if (arLibs && arLibs.length > 0) {
131
140
 
141
+ const libAnswers = await inquirer.prompt([
132
142
  {
133
- name: 'libVersion',
143
+ name: 'library',
134
144
  type: 'rawlist',
135
- message: 'Enter version',
136
- choices: keys
137
- },
145
+ message: 'Pick library',
146
+ choices: arLibs
147
+ }
138
148
  ]);
139
149
 
140
- const selectedVersion = libAnswers.libVersion;
150
+ libraryName = libAnswers.library;
151
+ const libVersions = await getServerLibraryVersions(libraryName);
141
152
 
142
- const versionData = libVersions[selectedVersion];
143
- const data = JSON.parse(versionData);
153
+ if (libVersions) {
154
+ const keys = Object.keys(libVersions);
155
+ const libVersionAnswers = await inquirer.prompt([
156
+
157
+ {
158
+ name: 'libVersion',
159
+ type: 'rawlist',
160
+ message: 'Enter version',
161
+ choices: keys
162
+ }
163
+ ]);
164
+
165
+ const selectedVersion = libVersionAnswers.libVersion;
166
+
167
+ const versionData = libVersions[selectedVersion];
168
+ const data = JSON.parse(versionData);
169
+
170
+ // get built on from first component if exists
171
+ let builtOn = "(date unavailable)";
172
+ if (data[0] && data[0].buildDate) {
173
+ builtOn = data[0].buildDate;
174
+ }
175
+
176
+ let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
177
+ console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
178
+ console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
179
+ }
180
+ else {
181
+ console.log(chalk.red("No libraries available on server."));
182
+ }
144
183
 
145
- // get built on from first component if exists
146
- let builtOn = "(date unavailable)";
147
- if (data[0] && data[0].buildDate) {
148
- builtOn = data[0].buildDate;
149
- }
150
184
 
151
- let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
152
- console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
153
- console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
154
185
 
155
186
  }
156
187
  else {
@@ -48,13 +48,16 @@ addDebugLog("getSwitchLibraryComponentQuestions", "", "");
48
48
  name: 'okToContinue',
49
49
  type: 'confirm',
50
50
  message: 'Ok to continue ?',
51
- default: false
51
+ default: true
52
52
  },
53
53
  {
54
54
  name: 'newOrgLib',
55
55
  type: 'rawlist',
56
56
  message: `Select a library (current library is ${chalk.bold.green(`${currentOrgLib}`)}) `,
57
- choices: archVersionList
57
+ choices: archVersionList,
58
+ when(answers) {
59
+ return answers.okToContinue === true;
60
+ }
58
61
  }
59
62
  ];
60
63
  };
@@ -56,6 +56,10 @@ addDebugLog("switchLibrary", "", "+");
56
56
  const answers = await inquirer.prompt(questions);
57
57
  ({ okToContinue, newOrgLib } = answers);
58
58
 
59
+ if (!answers.okToContinue) {
60
+ process.exit()
61
+ }
62
+
59
63
  const nextQuestion = await getSwitchVersionComponentQuestions(newOrgLib);
60
64
  const nextAnswers = await inquirer.prompt(nextQuestion);
61
65
  ({ version } = nextAnswers);
@@ -46,7 +46,7 @@ addDebugLog("getSwitchVersionComponentQuestions", "", "");
46
46
  name: 'okToContinue',
47
47
  type: 'confirm',
48
48
  message: 'Ok to continue ?',
49
- default: false
49
+ default: true
50
50
  },
51
51
  {
52
52
  name: 'version',
package/src/util.js CHANGED
@@ -1162,6 +1162,18 @@ if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
1162
1162
  return ({});
1163
1163
  };
1164
1164
 
1165
+ export const getLocalLibraries = async () => {
1166
+ if (showDebug) addDebugLog("getLocalLibraries", "" , "");
1167
+ const currentDirectory = process.cwd();
1168
+ const configDef = getConfigDefaults();
1169
+ const libFilter = configDef.organization.concat("_");
1170
+
1171
+ return fs
1172
+ .readdirSync(currentDirectory, { withFileTypes: true })
1173
+ .filter(dirent => dirent.isDirectory() && dirent.name.startsWith(libFilter))
1174
+ .map(dirent => dirent.name);
1175
+ }
1176
+
1165
1177
  export const getLocalLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
1166
1178
  if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
1167
1179
  const currentDirectory = process.cwd();