@pega/custom-dx-components 0.242.28 → 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.
- package/package.json +1 -1
- package/src/cli.js +30 -0
- package/src/constants.js +3 -2
- package/src/tasks/build-comp/helper.js +6 -4
- package/src/tasks/bundle/builder/index.js +8 -6
- package/src/tasks/create/index.js +4 -2
- package/src/tasks/create-all/index.js +5 -3
- package/src/tasks/create-lib/index.js +4 -6
- package/src/tasks/create-version/helper.js +1 -0
- package/src/tasks/create-version/index.js +10 -6
- package/src/tasks/delete/index.js +1 -1
- package/src/tasks/delete-all/index.js +1 -1
- package/src/tasks/delete-lib/index.js +55 -32
- package/src/tasks/delete-pub/index.js +3 -2
- package/src/tasks/delete-version/index.js +45 -0
- package/src/tasks/export-archive/helper.js +85 -0
- package/src/tasks/export-archive/index.js +224 -0
- package/src/tasks/import-archive/helper.js +51 -0
- package/src/tasks/import-archive/index.js +301 -0
- package/src/tasks/index.js +5 -0
- package/src/tasks/init/template/package.json.mustache +20 -12
- package/src/tasks/list/helper.js +2 -2
- package/src/tasks/list/index.js +1 -1
- package/src/tasks/list-lib/index.js +8 -10
- package/src/tasks/list-pub/index.js +3 -3
- package/src/tasks/move/helper.js +56 -0
- package/src/tasks/move/index.js +441 -0
- package/src/tasks/promote-webpack/index.js +2 -3
- package/src/tasks/publish/index.js +1 -2
- package/src/tasks/publish-all/index.js +2 -2
- package/src/tasks/publish-lib/index.js +8 -4
- package/src/tasks/rename-lib/index.js +2 -3
- package/src/tasks/revert-webpack/index.js +2 -3
- package/src/tasks/show-status/index.js +2 -3
- package/src/tasks/store/index.js +53 -0
- package/src/tasks/switch-lib/index.js +4 -4
- package/src/tasks/switch-version/index.js +10 -6
- package/src/util.js +229 -177
package/src/tasks/list/index.js
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
getListComponentsQuestions
|
|
14
14
|
} from './helper.js';
|
|
15
15
|
|
|
16
|
-
const isLibraryBased = getLibraryBased();
|
|
17
16
|
|
|
18
17
|
const getList = async (sourceOfComponents, answers) => {
|
|
19
18
|
addDebugLog("getList", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
@@ -69,6 +68,7 @@ addDebugLog("getList", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
|
69
68
|
export default async (options) => {
|
|
70
69
|
await showVersion();
|
|
71
70
|
await checkLibraryAndArchives();
|
|
71
|
+
const isLibraryBased = getLibraryBased();
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
addDebugLog("list", "", "+");
|
|
@@ -4,13 +4,11 @@ import chalk from 'chalk';
|
|
|
4
4
|
import {showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives, getLibraryArchivesVersions, getConfigDefaults, getLocalArchivedLibrraryVersionData, getComponentsConfigs } from '../../util.js';
|
|
5
5
|
import { getArchiveLibraryQuestions } from './helper.js';
|
|
6
6
|
|
|
7
|
-
const isLibraryBased = getLibraryBased();
|
|
8
|
-
|
|
9
|
-
|
|
10
7
|
export default async (options) => {
|
|
8
|
+
const isLibraryBased = getLibraryBased();
|
|
11
9
|
|
|
12
10
|
if (!isLibraryBased) {
|
|
13
|
-
console.log(`Command only supported for ${chalk.bold.green('library
|
|
11
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
14
12
|
process.exit();
|
|
15
13
|
}
|
|
16
14
|
|
|
@@ -71,20 +69,20 @@ addDebugLog("listLibrary", "", "+");
|
|
|
71
69
|
if (libraryName === compDef.currentOrgLib && selectedVersion === compDef.buildVersion) {
|
|
72
70
|
|
|
73
71
|
console.log("\nYou've selected the current working library/version.");
|
|
74
|
-
console.log("You can list current components or the last
|
|
72
|
+
console.log("You can list current components or the last store of this library/version.");
|
|
75
73
|
const archAnswers = await inquirer.prompt([
|
|
76
74
|
{
|
|
77
|
-
name: '
|
|
75
|
+
name: 'currentOrStore',
|
|
78
76
|
type: 'rawlist',
|
|
79
|
-
message: 'Select current or
|
|
77
|
+
message: 'Select current or store',
|
|
80
78
|
default: "Current",
|
|
81
|
-
choices: ["Current", "
|
|
79
|
+
choices: ["Current", "Store"]
|
|
82
80
|
},
|
|
83
81
|
]);
|
|
84
82
|
|
|
85
|
-
const
|
|
83
|
+
const currentOrStore = archAnswers.currentOrStore;
|
|
86
84
|
|
|
87
|
-
if (
|
|
85
|
+
if (currentOrStore === "Current") {
|
|
88
86
|
data = await getComponentsConfigs();
|
|
89
87
|
builtOn = "(no date - current)";
|
|
90
88
|
}
|
|
@@ -7,7 +7,7 @@ import { listLibJSONResponse } from '@pega/constellation-dx-components-build-uti
|
|
|
7
7
|
|
|
8
8
|
import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
|
|
12
12
|
export const getServerLibraryVersions = async(libraryName) => {
|
|
13
13
|
addDebugLog("getServerLibraryVersions", `libraryName: ${libraryName}`, "");
|
|
@@ -34,9 +34,9 @@ addDebugLog("listLibJSONResponse", "services end", "");
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export default async (options) => {
|
|
37
|
-
|
|
37
|
+
const isLibraryBased = getLibraryBased();
|
|
38
38
|
if (!isLibraryBased) {
|
|
39
|
-
console.log(`Command only supported for ${chalk.bold.green('library
|
|
39
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
40
40
|
process.exit();
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
import { addDebugLog, getConfigDefaults } from '../../util.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const getComponentKeyQuestion = async(localComponents, copyMoveLC, paramComponentKey = null) => {
|
|
7
|
+
const orAll = localComponents.length > 1 ? "or ALL" : "";
|
|
8
|
+
|
|
9
|
+
return [
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
name: 'componentKey',
|
|
13
|
+
type: 'rawlist',
|
|
14
|
+
pageSize: 15,
|
|
15
|
+
message: `Select component to ${copyMoveLC} ${orAll}`,
|
|
16
|
+
choices: localComponents,
|
|
17
|
+
when: () => !paramComponentKey
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export const getLibraryQuestions = async (archLibs) => {
|
|
25
|
+
addDebugLog("getLibraryQuestions", "", "");
|
|
26
|
+
const configDef = getConfigDefaults();
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
name: 'libraryName',
|
|
32
|
+
type: 'rawlist',
|
|
33
|
+
message: 'Select library to move to',
|
|
34
|
+
choices: archLibs
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getLibraryVersionQuestion = async (libraryName, libVersions) => {
|
|
40
|
+
addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}`, "");
|
|
41
|
+
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
name: 'version',
|
|
45
|
+
type: 'rawlist',
|
|
46
|
+
message: `Select ${chalk.green.bold(`${libraryName}`)} library version to move to`,
|
|
47
|
+
choices: libVersions
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'copyShared',
|
|
51
|
+
type: 'confirm',
|
|
52
|
+
message: `Copy ${chalk.yellow.bold("/shared")} directory (same named files will be overridden) ?`,
|
|
53
|
+
default: true
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
};
|
|
@@ -0,0 +1,441 @@
|
|
|
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
|
+
getLibraryArchiveDirectories
|
|
22
|
+
} from '../../util.js';
|
|
23
|
+
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, COMPONENTS_PATH, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
|
|
24
|
+
import { getComponentKeyQuestion, getLibraryQuestions, getLibraryVersionQuestion } from './helper.js';
|
|
25
|
+
|
|
26
|
+
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
27
|
+
const currentDirectory = process.cwd();
|
|
28
|
+
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
import {
|
|
32
|
+
convertIntoPascalCase,
|
|
33
|
+
getComponentDirectoryPath
|
|
34
|
+
} from '../../util.js';
|
|
35
|
+
import { or } from 'ajv/dist/compile/codegen/index.js';
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const copy = promisify(ncp);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export const updateConfig = async (
|
|
42
|
+
{
|
|
43
|
+
oldComponentKey,
|
|
44
|
+
newComponentKey,
|
|
45
|
+
library,
|
|
46
|
+
version,
|
|
47
|
+
targetDirectory,
|
|
48
|
+
},
|
|
49
|
+
options,
|
|
50
|
+
onlyCompanion = false
|
|
51
|
+
) => {
|
|
52
|
+
|
|
53
|
+
addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
|
|
54
|
+
|
|
55
|
+
let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
|
|
56
|
+
configData = configData && JSON.parse(configData);
|
|
57
|
+
|
|
58
|
+
configData.name = newComponentKey;
|
|
59
|
+
if (configData.componentKey) configData.componentKey = newComponentKey;
|
|
60
|
+
configData.library = library;
|
|
61
|
+
configData.version = version;
|
|
62
|
+
|
|
63
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
64
|
+
fs.writeFileSync(join(targetDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const updateFile = async (
|
|
69
|
+
fileName,
|
|
70
|
+
oldComponentKeyPC,
|
|
71
|
+
newComponentKeyPC,
|
|
72
|
+
targetDirectory,
|
|
73
|
+
) => {
|
|
74
|
+
|
|
75
|
+
addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, targetDirectory: ${targetDirectory}`, "");
|
|
76
|
+
|
|
77
|
+
let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
|
|
78
|
+
|
|
79
|
+
if (fileData.indexOf(oldComponentKeyPC) >= 0) {
|
|
80
|
+
fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
|
|
81
|
+
|
|
82
|
+
fs.writeFileSync(join(targetDirectory, "/", fileName), fileData, { encoding: 'utf8' });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
// rename the component
|
|
89
|
+
export const renameComponent = async (
|
|
90
|
+
componentKey,
|
|
91
|
+
library,
|
|
92
|
+
version,
|
|
93
|
+
copyMove,
|
|
94
|
+
options
|
|
95
|
+
) => {
|
|
96
|
+
|
|
97
|
+
addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
const componentName = componentKey.split("_")[2];
|
|
101
|
+
|
|
102
|
+
const configDef = getConfigDefaults();
|
|
103
|
+
|
|
104
|
+
const newComponentKey = `${library}_${componentName}`;
|
|
105
|
+
|
|
106
|
+
const oldComponentKey = componentKey;
|
|
107
|
+
const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
|
|
108
|
+
const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
|
|
109
|
+
|
|
110
|
+
const currentDirectory = await getComponentDirectoryPath(componentKey);
|
|
111
|
+
const targetDirectory = await getComponentDirectoryPath(newComponentKey);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if (copyMove === "Move") {
|
|
116
|
+
// custom component
|
|
117
|
+
try {
|
|
118
|
+
fs.renameSync(currentDirectory, targetDirectory);
|
|
119
|
+
} catch(err) {
|
|
120
|
+
console.log(err)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// copy
|
|
125
|
+
// custom component
|
|
126
|
+
try {
|
|
127
|
+
fs.cpSync(currentDirectory, targetDirectory, { recursive: true});
|
|
128
|
+
} catch(err) {
|
|
129
|
+
console.log(err)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
const targetFileList = await getDirectoryFiles(targetDirectory);
|
|
137
|
+
|
|
138
|
+
for (var fileIndex in targetFileList) {
|
|
139
|
+
const fileName = targetFileList[fileIndex];
|
|
140
|
+
|
|
141
|
+
if (fileName === "config.json") {
|
|
142
|
+
await updateConfig(
|
|
143
|
+
{
|
|
144
|
+
oldComponentKey,
|
|
145
|
+
newComponentKey,
|
|
146
|
+
componentName,
|
|
147
|
+
library,
|
|
148
|
+
version,
|
|
149
|
+
targetDirectory,
|
|
150
|
+
},
|
|
151
|
+
options
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
await updateFile(
|
|
156
|
+
fileName,
|
|
157
|
+
oldComponentKeyPC,
|
|
158
|
+
newComponentKeyPC,
|
|
159
|
+
targetDirectory );
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
} // for
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
return newComponentKey;
|
|
167
|
+
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
export const moveComp = async(componentKey, copyMove, orgLibName, version, copyShared, localComponents, options) => {
|
|
172
|
+
// put lib/version into temp directory
|
|
173
|
+
const currentDirectory = process.cwd();
|
|
174
|
+
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
175
|
+
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${version}`);
|
|
176
|
+
const fileName = `${orgLibName}_${version}.zip`;
|
|
177
|
+
const archFileName = join(archiveDirectory, fileName);
|
|
178
|
+
const currentCompPath = join(currentDirectory, "src", "components");
|
|
179
|
+
const tempCompPath = join(tempDirectory, "src", "components");
|
|
180
|
+
|
|
181
|
+
await unZipFromArchive(archFileName);
|
|
182
|
+
|
|
183
|
+
const copiedOrMoved = copyMove === "Copy" ? "Copied" : "Moved";
|
|
184
|
+
|
|
185
|
+
let newComponentKey;
|
|
186
|
+
|
|
187
|
+
if (componentKey === 'ALL') {
|
|
188
|
+
for (let index in localComponents) {
|
|
189
|
+
// skip first ALL
|
|
190
|
+
if (index > 1) {
|
|
191
|
+
const localComponentKey = localComponents[index];
|
|
192
|
+
newComponentKey = await localMoveCopyComp(localComponentKey.value, orgLibName, version, copyMove, currentDirectory, tempDirectory);
|
|
193
|
+
if (newComponentKey) {
|
|
194
|
+
console.log(`${copiedOrMoved} ${chalk.green(`${localComponentKey.value}`)} to ${chalk.green(`${orgLibName}/${version}`)} as ${chalk.green(`${newComponentKey}`)}`);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
console.log(chalk.yellow(`Not ${copiedOrMoved}`));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const currentSharedPath = join(currentCompPath, "shared");
|
|
204
|
+
const targetSharedPatah = join(tempCompPath, "shared");
|
|
205
|
+
|
|
206
|
+
// copy shared
|
|
207
|
+
if (copyShared) {
|
|
208
|
+
fs.cpSync(currentSharedPath, targetSharedPatah, { recursive: true, force: true });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// rearchive temp directory
|
|
212
|
+
await zipVersionAndArchive(orgLibName, version, tempDirectory);
|
|
213
|
+
|
|
214
|
+
// delete temp directory
|
|
215
|
+
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
|
|
222
|
+
// if (copyMove === "Move") {
|
|
223
|
+
// await localMoveComp(componentKey, orgLibName, version, currentDirectory, tempDirectory);
|
|
224
|
+
// }
|
|
225
|
+
// else {
|
|
226
|
+
// await localCopyComp(componentKey, orgLibName, version, currentDirectory, tempDirectory);
|
|
227
|
+
// }
|
|
228
|
+
|
|
229
|
+
const newComponentKey = await localMoveCopyComp(componentKey, orgLibName, version, copyMove, currentDirectory, tempDirectory);
|
|
230
|
+
|
|
231
|
+
if (newComponentKey) {
|
|
232
|
+
const currentSharedPath = join(currentCompPath, "shared");
|
|
233
|
+
const targetSharedPatah = join(tempCompPath, "shared");
|
|
234
|
+
|
|
235
|
+
// copy shared
|
|
236
|
+
if (copyShared) {
|
|
237
|
+
fs.cpSync(currentSharedPath, targetSharedPatah, { recursive: true, force: true });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
console.log(`\n${copiedOrMoved} ${chalk.green(`${componentKey}`)} to ${chalk.green(`${orgLibName}/${version}`)} as ${chalk.green(`${newComponentKey}`)}\n`);
|
|
242
|
+
|
|
243
|
+
// rearchive temp directory
|
|
244
|
+
await zipVersionAndArchive(orgLibName, version, tempDirectory);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
console.log(chalk.yellow(`No components were ${copiedOrMoved}`));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
// delete temp directory
|
|
252
|
+
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export const localMoveCopyComp = async(componentKey, orgLibName, version, copyMove, currentDirectory, tempDirectory ) => {
|
|
260
|
+
const currentCompPath = join(currentDirectory, "src", "components");
|
|
261
|
+
const tempCompPath = join(tempDirectory, "src", "components");
|
|
262
|
+
|
|
263
|
+
const tempCompName = componentKey.split("_")[2];
|
|
264
|
+
const newTempComponentKey = `${orgLibName}_${tempCompName}`;
|
|
265
|
+
const tempDirComp = join(tempCompPath, `${newTempComponentKey}`);
|
|
266
|
+
|
|
267
|
+
if (fs.existsSync(tempDirComp)) {
|
|
268
|
+
const answers = await inquirer.prompt([
|
|
269
|
+
{
|
|
270
|
+
name: 'confirmOverride',
|
|
271
|
+
type: 'confirm',
|
|
272
|
+
message: `Component ${chalk.yellow(`${tempCompName}`)} currently exists in ${chalk.yellow(`${orgLibName}/${version}`)}, override?`,
|
|
273
|
+
default: false
|
|
274
|
+
}
|
|
275
|
+
]);
|
|
276
|
+
if (!answers.confirmOverride) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
// rename the component
|
|
283
|
+
const newComponentKey = await renameComponent(componentKey, orgLibName, version, copyMove);
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
const currentComponentsPath = join(currentCompPath, `${newComponentKey}`);
|
|
289
|
+
const tempDirectoryComponents = join(tempCompPath, `${newComponentKey}`);
|
|
290
|
+
|
|
291
|
+
// copy component into temp directory
|
|
292
|
+
fs.cpSync(currentComponentsPath, tempDirectoryComponents, { recursive: true, force: true });
|
|
293
|
+
|
|
294
|
+
// remove from components
|
|
295
|
+
fs.rmSync(currentComponentsPath, { recursive: true, force: true, maxRetries: 2 });
|
|
296
|
+
|
|
297
|
+
return newComponentKey;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
export default async options => {
|
|
303
|
+
await showVersion();
|
|
304
|
+
await checkLibraryAndArchives();
|
|
305
|
+
|
|
306
|
+
addDebugLog("move", "", "+");
|
|
307
|
+
|
|
308
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
309
|
+
const isLibraryBased = getLibraryBased();
|
|
310
|
+
if (!isLibraryBased) {
|
|
311
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
312
|
+
process.exit();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
316
|
+
data = data && JSON.parse(data);
|
|
317
|
+
|
|
318
|
+
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
319
|
+
console.error(
|
|
320
|
+
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
321
|
+
);
|
|
322
|
+
process.exit(1);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let copyMove;
|
|
326
|
+
let copyMoveLC;
|
|
327
|
+
let componentKey;
|
|
328
|
+
let orgLibName;
|
|
329
|
+
let version;
|
|
330
|
+
let copyShared;
|
|
331
|
+
|
|
332
|
+
let localComponents = await getComponentsObj();
|
|
333
|
+
|
|
334
|
+
if (!localComponents || localComponents.length === 0 ) {
|
|
335
|
+
console.log(chalk.red.bold("No components to move/copy."));
|
|
336
|
+
process.exit();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (options.params.length >= 8) {
|
|
340
|
+
componentKey = options.params[3];
|
|
341
|
+
copyMove = options.param[4];
|
|
342
|
+
orgLibName = options.params[5];
|
|
343
|
+
version = options.params[6];
|
|
344
|
+
copyShared = options.params[7];
|
|
345
|
+
|
|
346
|
+
await moveComp(
|
|
347
|
+
componentKey,
|
|
348
|
+
copyMove,
|
|
349
|
+
orgLibName,
|
|
350
|
+
version,
|
|
351
|
+
copyShared,
|
|
352
|
+
localComponents,
|
|
353
|
+
options
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
|
|
359
|
+
// VS Code pluggin would send in the component
|
|
360
|
+
let paramComponentKey;
|
|
361
|
+
if (options.params.length == 4) {
|
|
362
|
+
paramComponentKey = options.params[3];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const configDef = getConfigDefaults();
|
|
366
|
+
console.log(`Current library: ${chalk.green(`${configDef.displayLibVersion}`)}`);
|
|
367
|
+
|
|
368
|
+
// test to see if currnet library has more than one version
|
|
369
|
+
// if no available versions can not move/copy to it, so send in current lib
|
|
370
|
+
// as library to be removed from the list
|
|
371
|
+
let removeOrgLib = "";
|
|
372
|
+
let libVersions;
|
|
373
|
+
try {
|
|
374
|
+
libVersions = await getLibraryArchivesVersions(configDef.currentOrgLib, configDef.buildVersion);
|
|
375
|
+
}
|
|
376
|
+
catch (ex) {}
|
|
377
|
+
if (!libVersions || libVersions.length === 0) {
|
|
378
|
+
removeOrgLib = configDef.currentOrgLib;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const archLibs = await getLibraryArchiveDirectories(removeOrgLib);
|
|
382
|
+
|
|
383
|
+
if (!archLibs || archLibs.length === 0) {
|
|
384
|
+
console.log(chalk.red.bold("No available libraries to move/copy to."));
|
|
385
|
+
process.exit();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const copyMoveQuestion = [
|
|
389
|
+
{
|
|
390
|
+
name: 'copyMove',
|
|
391
|
+
type: 'rawlist',
|
|
392
|
+
message: "Copy or Move",
|
|
393
|
+
choices: ["Copy", "Move"],
|
|
394
|
+
default: "Copy"
|
|
395
|
+
}
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
const copyMoveAnswer = await inquirer.prompt(copyMoveQuestion);
|
|
399
|
+
({copyMove} = copyMoveAnswer);
|
|
400
|
+
copyMoveLC = copyMove.toLowerCase();
|
|
401
|
+
|
|
402
|
+
if (localComponents && localComponents.length > 1) {
|
|
403
|
+
localComponents.unshift({name: 'ALL', value: 'ALL'});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const keyQuestions = await getComponentKeyQuestion(localComponents, copyMoveLC, paramComponentKey);
|
|
407
|
+
|
|
408
|
+
const answers = await inquirer.prompt(keyQuestions);
|
|
409
|
+
({ componentKey = paramComponentKey} = answers);
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
const libQuestions = await getLibraryQuestions(archLibs);
|
|
414
|
+
const libAnswers = await inquirer.prompt(libQuestions);
|
|
415
|
+
orgLibName = libAnswers.libraryName;
|
|
416
|
+
const buildVersion = configDef.currentOrgLib === orgLibName ? configDef.buildVersion : "";
|
|
417
|
+
|
|
418
|
+
try {
|
|
419
|
+
libVersions = await getLibraryArchivesVersions(orgLibName, buildVersion);
|
|
420
|
+
}
|
|
421
|
+
catch (ex) {}
|
|
422
|
+
|
|
423
|
+
const versionQuestions = await getLibraryVersionQuestion(orgLibName, libVersions);
|
|
424
|
+
const versionAnswers = await inquirer.prompt(versionQuestions);
|
|
425
|
+
({version, copyShared} = versionAnswers);
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
await moveComp(
|
|
429
|
+
componentKey,
|
|
430
|
+
copyMove,
|
|
431
|
+
orgLibName,
|
|
432
|
+
version,
|
|
433
|
+
copyShared,
|
|
434
|
+
localComponents,
|
|
435
|
+
options
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
addDebugLog("rename", "END", "-");
|
|
440
|
+
|
|
441
|
+
};
|
|
@@ -21,8 +21,6 @@ import {
|
|
|
21
21
|
BUILDER_DIR_FILE_PATH
|
|
22
22
|
} from '../../constants.js';
|
|
23
23
|
|
|
24
|
-
const isLibraryBased = getLibraryBased();
|
|
25
|
-
|
|
26
24
|
|
|
27
25
|
export const copyWebPack = async () => {
|
|
28
26
|
addDebugLog("copyWebPack","", "");
|
|
@@ -94,8 +92,9 @@ addDebugLog("copyWebPack","", "");
|
|
|
94
92
|
|
|
95
93
|
|
|
96
94
|
export default async options => {
|
|
95
|
+
const isLibraryBased = getLibraryBased();
|
|
97
96
|
if (isLibraryBased) {
|
|
98
|
-
console.log(`Command only supported for ${chalk.bold.green('non library
|
|
97
|
+
console.log(`Command only supported for ${chalk.bold.green('non library mode')} components.`)
|
|
99
98
|
process.exit();
|
|
100
99
|
}
|
|
101
100
|
|
|
@@ -11,12 +11,11 @@ import { getPublishComponentQuestions, publishComponentToServer, zipComponent }
|
|
|
11
11
|
import { default as buildLibrary } from '../build-lib/index.js';
|
|
12
12
|
import { default as publishLibrary } from '../publish-lib/index.js';
|
|
13
13
|
|
|
14
|
-
const isLibraryBased = getLibraryBased();
|
|
15
|
-
|
|
16
14
|
export default async options => {
|
|
17
15
|
|
|
18
16
|
await showVersion();
|
|
19
17
|
await checkLibraryAndArchives();
|
|
18
|
+
const isLibraryBased = getLibraryBased();
|
|
20
19
|
|
|
21
20
|
if (isLibraryBased) {
|
|
22
21
|
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
cleanUp
|
|
15
15
|
} from './helper.js';
|
|
16
16
|
|
|
17
|
-
const isLibraryBased = getLibraryBased();
|
|
18
17
|
|
|
19
18
|
export function getCustomTasks(componentKey, sourceMap, devBuild, content, options) {
|
|
20
19
|
addDebugLog("getCustomTasks", `componentKey: ${componentKey}, sourceMap: ${sourceMap}, devBuild: ${devBuild}`, "");
|
|
@@ -64,8 +63,9 @@ addDebugLog("getCustomTasks", `componentKey: ${componentKey}, sourceMap: ${sourc
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
export default async options => {
|
|
66
|
+
const isLibraryBased = getLibraryBased();
|
|
67
67
|
if (isLibraryBased) {
|
|
68
|
-
console.log(`Command only supported for ${chalk.bold.green('non library
|
|
68
|
+
console.log(`Command only supported for ${chalk.bold.green('non library mode')} components.`)
|
|
69
69
|
process.exit();
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -11,8 +11,6 @@ import { publishLib, listLibJSONResponse, deleteLibVersion } from '@pega/constel
|
|
|
11
11
|
import { getLibraryVersionQuestion } from './helper.js';
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
const isLibraryBased = getLibraryBased();
|
|
15
|
-
|
|
16
14
|
export function getCustomTasks(componentKey, sourceMap, devBuild, options) {
|
|
17
15
|
addDebugLog("getCustomTasks", `componentKey: ${componentKey}, sourceMap: ${sourceMap}, devBuild: ${devBuild}`, "");
|
|
18
16
|
|
|
@@ -63,11 +61,16 @@ addDebugLog("publishNewLibraryAsync", `libraryName: ${libraryName}, version: ${v
|
|
|
63
61
|
|
|
64
62
|
if (checkDeleted ) {
|
|
65
63
|
console.log(chalk.yellow(`Verifying library has been deleted..`));
|
|
66
|
-
let libExists =
|
|
64
|
+
let libExists = true;
|
|
67
65
|
let count = 0;
|
|
68
66
|
while (libExists) {
|
|
67
|
+
|
|
68
|
+
// sleep a second and try again
|
|
69
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
70
|
+
|
|
69
71
|
// keep checking until no longer exists
|
|
70
72
|
libExists = await doesLibraryExist(libraryName, version);
|
|
73
|
+
|
|
71
74
|
count ++;
|
|
72
75
|
|
|
73
76
|
if (count > 100) {
|
|
@@ -88,8 +91,9 @@ addDebugLog("deleteLib", "services end", "");
|
|
|
88
91
|
|
|
89
92
|
|
|
90
93
|
export default async (options) => {
|
|
94
|
+
const isLibraryBased = getLibraryBased();
|
|
91
95
|
if (!isLibraryBased) {
|
|
92
|
-
console.log(`Command only supported for ${chalk.bold.green('library
|
|
96
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
|
|
93
97
|
process.exit();
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -34,8 +34,6 @@ export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
|
34
34
|
const currentDirectory = process.cwd();
|
|
35
35
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
36
36
|
|
|
37
|
-
const isLibraryBased = getLibraryBased();
|
|
38
|
-
|
|
39
37
|
import {
|
|
40
38
|
convertIntoPascalCase,
|
|
41
39
|
getComponentDirectoryPath,
|
|
@@ -243,8 +241,9 @@ addDebugLog("renameComponent", `library: ${library}, organization: ${organizatio
|
|
|
243
241
|
};
|
|
244
242
|
|
|
245
243
|
export default async options => {
|
|
244
|
+
const isLibraryBased = getLibraryBased();
|
|
246
245
|
if (!isLibraryBased) {
|
|
247
|
-
console.log(`Command only supported for ${chalk.bold.green('library
|
|
246
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
|
|
248
247
|
process.exit();
|
|
249
248
|
}
|
|
250
249
|
|