@pega/custom-dx-components 0.242.27 → 0.242.29

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 (40) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +30 -0
  3. package/src/constants.js +3 -2
  4. package/src/tasks/build-all/index.js +14 -1
  5. package/src/tasks/build-comp/helper.js +6 -4
  6. package/src/tasks/build-comp/index.js +12 -1
  7. package/src/tasks/bundle/builder/index.js +8 -6
  8. package/src/tasks/create/index.js +4 -2
  9. package/src/tasks/create-all/index.js +5 -3
  10. package/src/tasks/create-lib/index.js +4 -6
  11. package/src/tasks/create-version/helper.js +1 -0
  12. package/src/tasks/create-version/index.js +10 -6
  13. package/src/tasks/delete/index.js +1 -1
  14. package/src/tasks/delete-all/index.js +1 -1
  15. package/src/tasks/delete-lib/index.js +55 -32
  16. package/src/tasks/delete-pub/index.js +3 -2
  17. package/src/tasks/delete-version/index.js +45 -0
  18. package/src/tasks/export-archive/helper.js +85 -0
  19. package/src/tasks/export-archive/index.js +224 -0
  20. package/src/tasks/import-archive/helper.js +51 -0
  21. package/src/tasks/import-archive/index.js +301 -0
  22. package/src/tasks/index.js +5 -0
  23. package/src/tasks/init/template/package.json.mustache +20 -13
  24. package/src/tasks/list/helper.js +2 -2
  25. package/src/tasks/list/index.js +1 -1
  26. package/src/tasks/list-lib/index.js +8 -10
  27. package/src/tasks/list-pub/index.js +5 -5
  28. package/src/tasks/move/helper.js +56 -0
  29. package/src/tasks/move/index.js +441 -0
  30. package/src/tasks/promote-webpack/index.js +2 -3
  31. package/src/tasks/publish/index.js +1 -2
  32. package/src/tasks/publish-all/index.js +2 -2
  33. package/src/tasks/publish-lib/index.js +8 -4
  34. package/src/tasks/rename-lib/index.js +2 -3
  35. package/src/tasks/revert-webpack/index.js +2 -3
  36. package/src/tasks/show-status/index.js +2 -3
  37. package/src/tasks/store/index.js +53 -0
  38. package/src/tasks/switch-lib/index.js +4 -4
  39. package/src/tasks/switch-version/index.js +10 -6
  40. package/src/util.js +231 -179
@@ -0,0 +1,85 @@
1
+ import chalk from 'chalk';
2
+ import path from 'path';
3
+ import { join } from 'path';
4
+ import { addDebugLog, getConfigDefaults, getLibraryArchiveDirectories, getLibraryArchivesVersions } from '../../util.js';
5
+
6
+ export const SOURCE_OF_COMPONENT_TYPES = {
7
+ SERVER: 'Server',
8
+ LOCAL: 'Local'
9
+ };
10
+
11
+
12
+ export const getFilePathQuestions = async () => {
13
+ addDebugLog("getFilePathQuestions", "", "");
14
+
15
+ console.log("\nFile path examples:");
16
+ if (path.sep === "/") {
17
+ console.log("\tMac OS/Unix:\t/Users/name/...");
18
+ }
19
+ else {
20
+ console.log("\tWindows:\tC:\\Users\\name\\...\n");
21
+ }
22
+
23
+ const currentDirectory = process.cwd();
24
+ const arPathParts = currentDirectory.split(path.sep);
25
+ let defaultPath = join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
26
+ if (path.sep === "/") {
27
+ defaultPath = "/".concat(defaultPath);
28
+ }
29
+
30
+
31
+ return [
32
+ {
33
+ name: 'filePath',
34
+ message: 'Enter full file path of zip file location:',
35
+ default: defaultPath
36
+ }
37
+ ];
38
+ };
39
+
40
+ export const getFileNameQuestions = async (zipFileList) => {
41
+ addDebugLog("getFileNameQuestions", "", "");
42
+
43
+ return [
44
+ {
45
+ name: 'fileName',
46
+ type: 'rawlist',
47
+ message: `Select zip file`,
48
+ choices: zipFileList
49
+ },
50
+ ];
51
+ };
52
+
53
+ export const getLibraryQuestion = async () => {
54
+ addDebugLog("getLibraryQuestion", "", "");
55
+ const componentDefaults = getConfigDefaults();
56
+ const orgLib = getConfigDefaults();
57
+ const currentOrgLib = `${orgLib.organization}_${orgLib.library}`;
58
+
59
+ const archVersionList = await getLibraryArchiveDirectories("");
60
+
61
+
62
+ return [
63
+ {
64
+ name: 'orgLibName',
65
+ type: 'rawlist',
66
+ message: `Select a library (current library is ${chalk.bold.green(`${currentOrgLib}`)}) `,
67
+ choices: archVersionList
68
+ }
69
+ ];
70
+ };
71
+
72
+ export const getLibraryVersionQuestion = async (newOrgLib) => {
73
+ addDebugLog("getLibraryVersionQuestion", "", "");
74
+
75
+ const archVersionList = await getLibraryArchivesVersions(newOrgLib, "0.0.0");
76
+
77
+ return [
78
+ {
79
+ name: 'selectedVersion',
80
+ type: 'rawlist',
81
+ message: `Select a version `,
82
+ choices: archVersionList
83
+ }
84
+ ];
85
+ };
@@ -0,0 +1,224 @@
1
+ import fs from 'fs';
2
+ import { promisify } from 'util';
3
+ import { join } from 'path';
4
+
5
+ import inquirer from 'inquirer';
6
+ import ncp from 'ncp';
7
+ import chalk from 'chalk';
8
+
9
+ import {
10
+ checkPathAccess,
11
+ showVersion,
12
+ addDebugLog,
13
+ checkLibraryAndArchives,
14
+ getConfigDefaults,
15
+ getLibraryBased,
16
+ zipVersionAndArchive
17
+ } 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
+
21
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
22
+ const currentDirectory = process.cwd();
23
+ const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
24
+
25
+
26
+ const copy = promisify(ncp);
27
+
28
+ export const updateConfig = async (
29
+ {
30
+ oldComponentKey,
31
+ newComponentKey,
32
+ library,
33
+ version,
34
+ targetDirectory,
35
+ },
36
+ options,
37
+ onlyCompanion = false
38
+ ) => {
39
+
40
+ addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
41
+
42
+ let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
43
+ configData = configData && JSON.parse(configData);
44
+
45
+ configData.name = newComponentKey;
46
+ if (configData.componentKey) configData.componentKey = newComponentKey;
47
+ configData.library = library;
48
+ configData.version = version;
49
+
50
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
51
+ fs.writeFileSync(join(targetDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
52
+
53
+ };
54
+
55
+ export const updateFile = async (
56
+ fileName,
57
+ oldComponentKeyPC,
58
+ newComponentKeyPC,
59
+ targetDirectory,
60
+ ) => {
61
+
62
+ addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, targetDirectory: ${targetDirectory}`, "");
63
+
64
+ let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
65
+
66
+ if (fileData.indexOf(oldComponentKeyPC) >= 0) {
67
+ fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
68
+
69
+ fs.writeFileSync(join(targetDirectory, "/", fileName), fileData, { encoding: 'utf8' });
70
+ }
71
+
72
+ };
73
+
74
+
75
+
76
+
77
+ export const exportArch = async(exportPath, orgLibName, selectedVersion) => {
78
+ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName}, selectedVersion: ${selectedVersion}`, "");
79
+ const currentDirectory = process.cwd();
80
+ const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${selectedVersion}`);
81
+ const fileName = `${orgLibName}_${selectedVersion}.zip`;
82
+ const archFileName = join(archiveDirectory, fileName);
83
+ const configDef = await getConfigDefaults();
84
+
85
+ const exportFile = join(exportPath, fileName);
86
+
87
+
88
+ if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
89
+
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
+ ]);
101
+
102
+ const currentOrStore = archAnswers.currentOrStore;
103
+ if (currentOrStore === "Current") {
104
+ // archive it
105
+ await zipVersionAndArchive(configDef.currentOrgLib, configDef.buildVersion);
106
+ }
107
+ }
108
+
109
+ if (!fs.existsSync(exportPath)) {
110
+ console.log(`\Path: ${chalk.yellow(`${exportPath}`)} doesn't exist.`);
111
+ const newPathAnswer = await inquirer.prompt([
112
+ {
113
+ name: 'createNewPath',
114
+ type: 'confirm',
115
+ message: 'Create path',
116
+ default: true
117
+ },
118
+ ]);
119
+ const createNewPath = newPathAnswer.createNewPath;
120
+ if (createNewPath) {
121
+ fs.mkdirSync(exportPath, { recursive: true });
122
+ }
123
+ else {
124
+ console.log(chalk.green("Store not exported."));
125
+ process.exit();
126
+ }
127
+ }
128
+
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
+
140
+ const overrideExisting = overrideAnswer.overrideExisting;
141
+ if (!overrideExisting) {
142
+ console.log(chalk.green("Store not exported."));
143
+ process.exit();
144
+ }
145
+ }
146
+
147
+
148
+ fs.copyFileSync(archFileName, exportFile );
149
+
150
+ console.log(`\n${chalk.green(`${fileName}`)} has been exported to ${chalk.green(`${exportPath}`)}`);
151
+
152
+ }
153
+
154
+ export const convertPath = (filePath) => {
155
+
156
+ if (filePath.indexOf(":") > 0) {
157
+ const arFileData = filePath.split("\\");
158
+ filePath = join(arFileData);
159
+ }
160
+
161
+ return filePath;
162
+ }
163
+
164
+ export const getZipFileList = async(filePath) => {
165
+
166
+ const zipFilePath = convertPath(filePath);
167
+ if (fs.existsSync(zipFilePath)) {
168
+ return fs
169
+ .readdirSync(zipFilePath, { withFileTypes: true })
170
+ .filter(dirent => !dirent.isDirectory() && dirent.name.match(/.*\.(zip?)/ig))
171
+ .map(dirent => dirent.name);
172
+ }
173
+ else {
174
+ console.log(chalk.red.bold(`File path: ${filePath} does not exist or no permissions.`));
175
+ process.exit(1);
176
+ }
177
+ }
178
+
179
+ export default async options => {
180
+ await showVersion();
181
+ await checkLibraryAndArchives();
182
+
183
+ await checkPathAccess(pegaConfigJsonPath);
184
+ const isLibraryBased = getLibraryBased();
185
+ if (!isLibraryBased) {
186
+ console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
187
+ process.exit();
188
+ }
189
+
190
+ addDebugLog("exportArchive", "", "+");
191
+
192
+
193
+ if (options.params.length >= 6) {
194
+ const filePath = convertPath(options.params[3]);
195
+ const libraryName = options.params[4];
196
+ const libraryVersion = options.params[5];
197
+
198
+ await exportArch(filePath, libraryName, libraryVersion );
199
+
200
+ }
201
+ else {
202
+
203
+ const libraryQuestion = await getLibraryQuestion();
204
+ const libraryAnswers = await inquirer.prompt(libraryQuestion);
205
+ const { orgLibName } = libraryAnswers;
206
+
207
+ const libraryVersionQuestion = await getLibraryVersionQuestion(orgLibName);
208
+ const libraryVersionAnswer = await inquirer.prompt(libraryVersionQuestion);
209
+ const { selectedVersion } = libraryVersionAnswer;
210
+
211
+ const filePathQuestions = await getFilePathQuestions();
212
+ const filePathAnswers = await inquirer.prompt(filePathQuestions);
213
+ const { filePath } = filePathAnswers;
214
+
215
+ const zipFilePath = convertPath(filePath);
216
+
217
+
218
+ await exportArch( zipFilePath, orgLibName, selectedVersion);
219
+
220
+ }
221
+
222
+ addDebugLog("exportArchive", "END", "-");
223
+
224
+ };
@@ -0,0 +1,51 @@
1
+ import chalk from 'chalk';
2
+ import path from 'path';
3
+ import { join } from 'path';
4
+ import { addDebugLog, getConfigDefaults, getLibraryArchiveDirectories, getLibraryBased } from '../../util.js';
5
+
6
+ export const SOURCE_OF_COMPONENT_TYPES = {
7
+ SERVER: 'Server',
8
+ LOCAL: 'Local'
9
+ };
10
+
11
+
12
+ export const getFilePathQuestions = async () => {
13
+ addDebugLog("getFilePathQuestions", "", "");
14
+
15
+ console.log("\nFile path examples:");
16
+ if (path.sep === "/") {
17
+ console.log("\tMac OS/Unix:\t/Users/name/...\n");
18
+ }
19
+ else {
20
+ console.log("\tWindows:\tC:\\Users\\name\\...\n");
21
+ }
22
+
23
+ const currentDirectory = process.cwd();
24
+ const arPathParts = currentDirectory.split(path.sep);
25
+ let defaultPath = join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
26
+ if (path.sep === "/") {
27
+ defaultPath = "/".concat(defaultPath);
28
+ }
29
+
30
+
31
+ return [
32
+ {
33
+ name: 'filePath',
34
+ message: 'Enter full file path of zip file location:',
35
+ default: defaultPath
36
+ }
37
+ ];
38
+ };
39
+
40
+ export const getFileNameQuestions = async (zipFileList) => {
41
+ addDebugLog("getFileNameQuestions", "", "");
42
+
43
+ return [
44
+ {
45
+ name: 'fileName',
46
+ type: 'rawlist',
47
+ message: `Select zip file`,
48
+ choices: zipFileList
49
+ },
50
+ ];
51
+ };
@@ -0,0 +1,301 @@
1
+ import fs from 'fs';
2
+ import { promisify } from 'util';
3
+ import { join } from 'path';
4
+
5
+ import inquirer from 'inquirer';
6
+ import ncp from 'ncp';
7
+ import chalk from 'chalk';
8
+
9
+ import {
10
+ checkPathAccess,
11
+ showVersion,
12
+ getComponentsObj,
13
+ getDirectoryFiles,
14
+ addDebugLog,
15
+ checkLibraryAndArchives,
16
+ getConfigDefaults,
17
+ getLibraryBased,
18
+ unZipFromArchive,
19
+ zipVersionAndArchive,
20
+ getLibraryArchivesVersions
21
+ } 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';
24
+
25
+ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
26
+ const currentDirectory = process.cwd();
27
+ const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
28
+
29
+
30
+ import {
31
+ convertIntoPascalCase,
32
+ getComponentDirectoryPath
33
+ } from '../../util.js';
34
+
35
+
36
+ const copy = promisify(ncp);
37
+
38
+
39
+ export const updateConfig = async (
40
+ {
41
+ oldComponentKey,
42
+ newComponentKey,
43
+ library,
44
+ version,
45
+ targetDirectory,
46
+ },
47
+ options,
48
+ onlyCompanion = false
49
+ ) => {
50
+
51
+ addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
52
+
53
+ let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
54
+ configData = configData && JSON.parse(configData);
55
+
56
+ configData.name = newComponentKey;
57
+ if (configData.componentKey) configData.componentKey = newComponentKey;
58
+ configData.library = library;
59
+ configData.version = version;
60
+
61
+ // stringify "4", makes the json string look like JSON in the file, formated instead of a single line
62
+ fs.writeFileSync(join(targetDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
63
+
64
+ };
65
+
66
+ export const updateFile = async (
67
+ fileName,
68
+ oldComponentKeyPC,
69
+ newComponentKeyPC,
70
+ targetDirectory,
71
+ ) => {
72
+
73
+ addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, targetDirectory: ${targetDirectory}`, "");
74
+
75
+ let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
76
+
77
+ if (fileData.indexOf(oldComponentKeyPC) >= 0) {
78
+ fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
79
+
80
+ fs.writeFileSync(join(targetDirectory, "/", fileName), fileData, { encoding: 'utf8' });
81
+ }
82
+
83
+ };
84
+
85
+
86
+ // rename the component
87
+ export const renameComponent = async (
88
+ componentKey,
89
+ library,
90
+ version,
91
+ options
92
+ ) => {
93
+
94
+ addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
95
+
96
+
97
+ const componentName = componentKey.split("_")[2];
98
+
99
+ const configDef = getConfigDefaults();
100
+
101
+ const newComponentKey = `${library}_${componentName}`;
102
+
103
+ const oldComponentKey = componentKey;
104
+ const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
105
+ const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
106
+
107
+ const currentDirectory = await getComponentDirectoryPath(componentKey);
108
+ const targetDirectory = await getComponentDirectoryPath(newComponentKey);
109
+
110
+ // custom component
111
+ try {
112
+ fs.renameSync(currentDirectory, targetDirectory);
113
+ } catch(err) {
114
+ console.log(err)
115
+ }
116
+
117
+ const targetFileList = await getDirectoryFiles(targetDirectory);
118
+
119
+ for (var fileIndex in targetFileList) {
120
+ const fileName = targetFileList[fileIndex];
121
+
122
+ if (fileName === "config.json") {
123
+ await updateConfig(
124
+ {
125
+ oldComponentKey,
126
+ newComponentKey,
127
+ componentName,
128
+ library,
129
+ version,
130
+ targetDirectory,
131
+ },
132
+ options
133
+ );
134
+ }
135
+ else {
136
+ await updateFile(
137
+ fileName,
138
+ oldComponentKeyPC,
139
+ newComponentKeyPC,
140
+ targetDirectory );
141
+
142
+ }
143
+
144
+ } // for
145
+
146
+
147
+ return newComponentKey;
148
+
149
+ };
150
+
151
+
152
+ export const moveComp = async(componentKey, orgLibName, version, copyShared, options) => {
153
+
154
+ // put lib/version into temp directory
155
+ const currentDirectory = process.cwd();
156
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
157
+ const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
158
+ const fileName = `${orgLibName}_${version}.zip`;
159
+ const archFileName = join(archiveDirectory, fileName);
160
+
161
+
162
+ await unZipFromArchive(archFileName);
163
+
164
+ // rename the component
165
+ const newComponentKey = await renameComponent(componentKey, orgLibName, version);
166
+ const currentCompPath = join(currentDirectory, "src", "components");
167
+ const tempCompPath = join(tempDirectory, "src", "components");
168
+
169
+ const currentComponentsPath = join(currentCompPath, `${newComponentKey}`);
170
+ const tempDirectoryComponents = join(tempCompPath, `${newComponentKey}`);
171
+
172
+ const currentSharedPath = join(currentCompPath, "shared");
173
+ const targetSharedPatah = join(tempCompPath, "shared");
174
+
175
+ // copy component into temp directory
176
+ fs.cpSync(currentComponentsPath, tempDirectoryComponents, { recursive: true, force: true });
177
+
178
+ // remove from components
179
+ fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
180
+
181
+ // copy shared
182
+ if (copyShared) {
183
+ fs.cpSync(currentSharedPath, targetSharedPatah, { recursive: true, force: true });
184
+ }
185
+
186
+ console.log(`\nCopied ${chalk.green(`${componentKey}`)} to ${chalk.green(`${orgLibName}/${version}`)} as ${chalk.green(`${newComponentKey}`)}\n`);
187
+
188
+ // rearchive temp directory
189
+ await zipVersionAndArchive(orgLibName, version, tempDirectory);
190
+
191
+ // delete temp directory
192
+ fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
193
+ }
194
+
195
+ export const importArch = async(filePath, fileName) => {
196
+ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
197
+
198
+ const currentDirectory = process.cwd();
199
+ const tempDirectory = join(currentDirectory, TEMP_PATH);
200
+ const zipFilePath = join(filePath, fileName);
201
+
202
+ await unZipFromArchive(zipFilePath);
203
+
204
+ // check to see if have a tasks.config.json file, if not, archive not good
205
+ const tempTasksConfig = join(tempDirectory, "tasks.config.json");
206
+ if (!fs.existsSync(tempTasksConfig)) {
207
+ console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
208
+ console.log(chalk.red.bold("Cleaning up..."));
209
+ fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
210
+ console.log(chalk.red.bold("Done."));
211
+ process.exit(1);
212
+
213
+ }
214
+
215
+ const arFileData = fileName.split("_");
216
+ const orgLibName = `${arFileData[0]}_${arFileData[1]}`;
217
+ const version = arFileData[2].replace(".zip", "");
218
+
219
+ // rearchive temp directory
220
+ await zipVersionAndArchive(orgLibName, version, tempDirectory);
221
+
222
+ // delete temp directory
223
+ fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
224
+
225
+ console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
226
+ console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.\n`);
227
+
228
+ }
229
+
230
+ export const convertPath = (filePath) => {
231
+
232
+ if (filePath.indexOf(":") > 0) {
233
+ const arFileData = filePath.split("\\");
234
+ filePath = join(arFileData);
235
+ }
236
+
237
+ return filePath;
238
+ }
239
+
240
+ export const getZipFileList = async(filePath) => {
241
+
242
+ const zipFilePath = convertPath(filePath);
243
+ if (fs.existsSync(zipFilePath)) {
244
+ return fs
245
+ .readdirSync(zipFilePath, { withFileTypes: true })
246
+ .filter(dirent => !dirent.isDirectory() && dirent.name.match(/.*\.(zip?)/ig))
247
+ .map(dirent => dirent.name);
248
+ }
249
+ else {
250
+ console.log(chalk.red.bold(`File path: ${filePath} does not exist or no permissions.`));
251
+ process.exit(1);
252
+ }
253
+ }
254
+
255
+ export default async options => {
256
+ await showVersion();
257
+ await checkLibraryAndArchives();
258
+
259
+ await checkPathAccess(pegaConfigJsonPath);
260
+ const isLibraryBased = getLibraryBased();
261
+ if (!isLibraryBased) {
262
+ console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
263
+ process.exit();
264
+ }
265
+
266
+ addDebugLog("importArchive", "", "+");
267
+
268
+
269
+ if (options.params.length >= 5) {
270
+ const filePath = convertPath(options.params[3]);
271
+ const fileName = options.params[4];
272
+
273
+
274
+ await importArch( filePath, fileName);
275
+
276
+ }
277
+ else {
278
+
279
+ const filePathQuestions = await getFilePathQuestions();
280
+ const filePathAnswers = await inquirer.prompt(filePathQuestions);
281
+ const { filePath } = filePathAnswers;
282
+
283
+ const zipFilePath = convertPath(filePath);
284
+ const zipFileList = await getZipFileList(filePath);
285
+
286
+ if (!zipFileList || zipFileList.length === 0) {
287
+ console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
288
+ }
289
+
290
+ const fileNameQuestions = await getFileNameQuestions(zipFileList);
291
+ const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
292
+ const {fileName} = fileNameAnswers;
293
+
294
+
295
+ await importArch( filePath, fileName);
296
+
297
+ }
298
+
299
+ addDebugLog("importArchive", "END", "-");
300
+
301
+ };
@@ -8,11 +8,13 @@ export { default as deleteComponent } from './delete/index.js';
8
8
  export { default as deleteAllComponents } from './delete-all/index.js';
9
9
  export { default as deleteLibrary } from './delete-lib/index.js';
10
10
  export { default as deletePublished } from './delete-pub/index.js';
11
+ export { default as deleteVersion } from './delete-version/index.js';
11
12
  export { default as initProject } from './init/index.js';
12
13
  export { default as promoteWebPack } from './promote-webpack/index.js';
13
14
  export { default as publishComponent } from './publish/index.js';
14
15
  export { default as publishAllComponents } from './publish-all/index.js';
15
16
  export { default as publishLibrary } from './publish-lib/index.js';
17
+ export { default as moveComponent } from './move/index.js';
16
18
  export { default as renameComponent } from './rename/index.js';
17
19
  export { default as renameLibrary } from './rename-lib/index.js';
18
20
  export { default as revertWebPack } from './revert-webpack/index.js';
@@ -20,6 +22,9 @@ export { default as listComponents } from './list/index.js';
20
22
  export { default as listLibrary } from './list-lib/index.js';
21
23
  export { default as listPublished } from './list-pub/index.js';
22
24
  export { default as showStatus } from './show-status/index.js';
25
+ export { default as storeComponents } from './store/index.js';
26
+ export { default as importArchive } from './import-archive/index.js';
27
+ export { default as exportArchive } from './export-archive/index.js';
23
28
  export { default as updateComponent } from './update/index.js';
24
29
  export { default as validate } from './validator/index.js';
25
30
  export { default as authenticate } from './authenticate/index.js';