@pega/custom-dx-components 0.242.34 → 0.242.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.js +12 -0
- package/src/constants.js +1 -0
- package/src/tasks/build-lib/helper.js +0 -1
- package/src/tasks/create-lib/index.js +5 -3
- package/src/tasks/create-version/index.js +12 -1
- package/src/tasks/delete-lib/index.js +4 -1
- package/src/tasks/delete-version/index.js +3 -1
- package/src/tasks/export-archive/index.js +58 -41
- package/src/tasks/import-archive/index.js +5 -1
- package/src/tasks/import-comp/helper.js +47 -0
- package/src/tasks/import-comp/index.js +320 -0
- package/src/tasks/index.js +2 -0
- package/src/tasks/init/template/package.json.mustache +5 -3
- package/src/tasks/list-lib/index.js +25 -16
- package/src/tasks/list-pub/index.js +18 -14
- package/src/tasks/move/helper.js +6 -3
- package/src/tasks/move/index.js +99 -58
- package/src/tasks/publish/helper.js +8 -5
- package/src/tasks/publish/index.js +4 -4
- package/src/tasks/publish-all/helper.js +16 -10
- package/src/tasks/quarantine/index.js +84 -0
- package/src/tasks/rename-lib/index.js +0 -1
- package/src/tasks/revert-webpack/index.js +0 -2
- package/src/tasks/set-perm/index.js +18 -2
- package/src/tasks/show-help/index.js +6 -4
- package/src/tasks/store/index.js +4 -1
- package/src/tasks/switch-lib/index.js +3 -1
- package/src/tasks/switch-version/index.js +11 -1
- package/src/util.js +84 -25
- package/tests/functional/localCreateAllListDeleteAll.test.js +56 -10
- package/tests/functional/localCreateBuildAllDeleteAll.test.js +56 -48
- package/tests/functional/localCreateBuildDelete.test.js +57 -10
- package/tests/functional/localCreateListDelete.test.js +55 -102
- package/tests/functional/localCreatePublishAllDeleteAll.test.js +68 -61
- package/tests/functional/localCreatePublishDelete.test.js +62 -21
- package/tests/functional/localCreateRenameDelete.test.js +55 -140
- package/tests/functional/localLibCreateLibAlreadyDeleteLib.test.js +118 -0
- package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +241 -0
- package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +246 -0
- package/tests/functional/localLibCreateLibDeleteLib.test.js +109 -0
- package/tests/functional/localLibCreateLibExportImportLib.test.js +242 -0
- package/tests/functional/localLibCreateLibExportLib.test.js +219 -0
- package/tests/functional/localLibCreateLibImportCompDeleteLib.test.js +131 -0
- package/tests/functional/localLibCreateLibListDeleteLib.test.js +261 -0
- package/tests/functional/localLibCreateLibListMoveDeleteLib.test.js +236 -0
- package/tests/functional/localLibCreateLibListSwitchDeleteLib.test.js +237 -0
- package/tests/functional/localLibCreateLibPermDeleteLib.test.js +144 -0
- package/tests/functional/localLibCreateLibStatusDeleteLib.test.js +194 -0
- package/tests/functional/localLibCreateLibVersionDeleteLib.test.js +453 -0
- package/tests/functional/localPromoteRevertWP.test.js +83 -38
|
@@ -0,0 +1,320 @@
|
|
|
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
|
+
sanitize,
|
|
11
|
+
checkPathAccess,
|
|
12
|
+
showVersion,
|
|
13
|
+
getDirectoryFiles,
|
|
14
|
+
addDebugLog,
|
|
15
|
+
checkLibraryAndArchives,
|
|
16
|
+
getConfigDefaults,
|
|
17
|
+
getComponents
|
|
18
|
+
} from '../../util.js';
|
|
19
|
+
import { TASKS_CONFIG_JSON_FILENAME } from '../../constants.js';
|
|
20
|
+
import { getFilePathQuestions, getFileNameQuestions } from './helper.js';
|
|
21
|
+
|
|
22
|
+
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
23
|
+
const currentDirectory = process.cwd();
|
|
24
|
+
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
convertIntoPascalCase,
|
|
28
|
+
getComponentDirectoryPath
|
|
29
|
+
} from '../../util.js';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const copy = promisify(ncp);
|
|
33
|
+
|
|
34
|
+
let gFilePath = "";
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export const updateConfig = async (
|
|
38
|
+
{
|
|
39
|
+
oldComponentKey,
|
|
40
|
+
newComponentKey,
|
|
41
|
+
library,
|
|
42
|
+
version,
|
|
43
|
+
targetDirectory,
|
|
44
|
+
newLabel = "",
|
|
45
|
+
},
|
|
46
|
+
options,
|
|
47
|
+
onlyCompanion = false
|
|
48
|
+
) => {
|
|
49
|
+
|
|
50
|
+
addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
|
|
51
|
+
|
|
52
|
+
let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
|
|
53
|
+
configData = configData && JSON.parse(configData);
|
|
54
|
+
|
|
55
|
+
configData.name = newComponentKey;
|
|
56
|
+
if (configData.componentKey) configData.componentKey = newComponentKey;
|
|
57
|
+
configData.library = library;
|
|
58
|
+
configData.version = version;
|
|
59
|
+
|
|
60
|
+
if (newLabel != "") {
|
|
61
|
+
configData.label = newLabel;
|
|
62
|
+
configData.description = newLabel;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
66
|
+
fs.writeFileSync(join(targetDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
|
|
67
|
+
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const updateFile = async (
|
|
71
|
+
fileName,
|
|
72
|
+
oldComponentKeyPC,
|
|
73
|
+
newComponentKeyPC,
|
|
74
|
+
targetDirectory,
|
|
75
|
+
) => {
|
|
76
|
+
|
|
77
|
+
addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, targetDirectory: ${targetDirectory}`, "");
|
|
78
|
+
|
|
79
|
+
let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
|
|
80
|
+
|
|
81
|
+
if (fileData.indexOf(oldComponentKeyPC) >= 0) {
|
|
82
|
+
fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
|
|
83
|
+
|
|
84
|
+
fs.writeFileSync(join(targetDirectory, "/", fileName), fileData, { encoding: 'utf8' });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// rename the component
|
|
91
|
+
export const renameComponent = async (
|
|
92
|
+
componentKey,
|
|
93
|
+
library,
|
|
94
|
+
version,
|
|
95
|
+
newName = "",
|
|
96
|
+
newLabel = "",
|
|
97
|
+
options
|
|
98
|
+
) => {
|
|
99
|
+
|
|
100
|
+
addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
|
|
101
|
+
|
|
102
|
+
const componentName = newName != "" ? newName : componentKey.split("_")[2];
|
|
103
|
+
const newComponentKey = `${library}_${componentName}`;
|
|
104
|
+
const oldComponentKey = componentKey;
|
|
105
|
+
const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
|
|
106
|
+
const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
|
|
107
|
+
|
|
108
|
+
const currentDirectory = await getComponentDirectoryPath(componentKey);
|
|
109
|
+
const targetDirectory = await getComponentDirectoryPath(newComponentKey);
|
|
110
|
+
|
|
111
|
+
// custom component
|
|
112
|
+
try {
|
|
113
|
+
fs.renameSync(currentDirectory, targetDirectory);
|
|
114
|
+
} catch(err) {
|
|
115
|
+
console.log(err)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const targetFileList = await getDirectoryFiles(targetDirectory);
|
|
119
|
+
|
|
120
|
+
for (var fileIndex in targetFileList) {
|
|
121
|
+
const fileName = targetFileList[fileIndex];
|
|
122
|
+
|
|
123
|
+
if (fileName === "config.json") {
|
|
124
|
+
await updateConfig(
|
|
125
|
+
{
|
|
126
|
+
oldComponentKey,
|
|
127
|
+
newComponentKey,
|
|
128
|
+
componentName,
|
|
129
|
+
library,
|
|
130
|
+
version,
|
|
131
|
+
targetDirectory,
|
|
132
|
+
newLabel
|
|
133
|
+
},
|
|
134
|
+
options
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
await updateFile(
|
|
139
|
+
fileName,
|
|
140
|
+
oldComponentKeyPC,
|
|
141
|
+
newComponentKeyPC,
|
|
142
|
+
targetDirectory );
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
} // for
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
return newComponentKey;
|
|
150
|
+
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
export const importComp = async(filePath, fileName) => {
|
|
155
|
+
addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
156
|
+
|
|
157
|
+
const currentDirectory = process.cwd();
|
|
158
|
+
const compDirectory = join(currentDirectory, "src", "components");
|
|
159
|
+
const copyFilePath = join(filePath, fileName);
|
|
160
|
+
|
|
161
|
+
const configDef = getConfigDefaults();
|
|
162
|
+
const copyDir = join(compDirectory, fileName);
|
|
163
|
+
|
|
164
|
+
if (fs.existsSync(copyFilePath)) {
|
|
165
|
+
fs.cpSync(copyFilePath, copyDir, { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let configData = fs.readFileSync(join(copyDir, "/config.json"), { encoding: 'utf8' });
|
|
169
|
+
configData = configData && JSON.parse(configData);
|
|
170
|
+
|
|
171
|
+
const compName = configData.componentKey.split("_")[2];
|
|
172
|
+
const potentialCompKey = `${configDef.currentOrgLib}_${compName}`;
|
|
173
|
+
const currentCompList = await getComponents();
|
|
174
|
+
let newName = "";
|
|
175
|
+
let newLabel = "";
|
|
176
|
+
|
|
177
|
+
if (currentCompList && currentCompList.includes(potentialCompKey)) {
|
|
178
|
+
console.log(`\nComponent ${chalk.yellow(`${potentialCompKey}`)} already exists.`);
|
|
179
|
+
const proceedAnswers = await inquirer.prompt([
|
|
180
|
+
|
|
181
|
+
{
|
|
182
|
+
name: 'proceedAs',
|
|
183
|
+
type: 'rawlist',
|
|
184
|
+
message: `Proceed as ?`,
|
|
185
|
+
default: 'No import',
|
|
186
|
+
choices: ['No import', 'Overwrite', 'New name']
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'componentName',
|
|
190
|
+
message: 'Enter component name (required)',
|
|
191
|
+
when(answers) {
|
|
192
|
+
return answers.proceedAs === 'New name';
|
|
193
|
+
},
|
|
194
|
+
validate: value => {
|
|
195
|
+
/* value should not be empty
|
|
196
|
+
It should not have spaces
|
|
197
|
+
It should not start with a number
|
|
198
|
+
Only case-insensitive alphanumeric values are allowed
|
|
199
|
+
*/
|
|
200
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'componentLabel',
|
|
208
|
+
message: 'Enter component label for display (required)',
|
|
209
|
+
when(answers) {
|
|
210
|
+
return answers.proceedAs === 'New name';
|
|
211
|
+
},
|
|
212
|
+
validate: value => {
|
|
213
|
+
if (value) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
return 'Please provide value for label';
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
]);
|
|
220
|
+
|
|
221
|
+
switch (proceedAnswers.proceedAs) {
|
|
222
|
+
case 'No import':
|
|
223
|
+
// removed copied
|
|
224
|
+
fs.rmSync(copyDir, { recursive: true, force: true, maxRetries: 2 });
|
|
225
|
+
process.exit();
|
|
226
|
+
break;
|
|
227
|
+
case 'Overwrite':
|
|
228
|
+
// remove existing
|
|
229
|
+
const exitingComp = join(compDirectory, potentialCompKey);
|
|
230
|
+
fs.rmSync(exitingComp, { recursive: true, force: true, maxRetries: 2 });
|
|
231
|
+
break;
|
|
232
|
+
case 'New name':
|
|
233
|
+
newName = proceedAnswers.componentName;
|
|
234
|
+
newLabel = proceedAnswers.componentLabel;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const newCompKey = await renameComponent(configData.componentKey, configDef.currentOrgLib, configDef.buildVersion, newName, newLabel, null);
|
|
241
|
+
console.log(`\n${chalk.green(`${fileName}`)} has been imported as ${chalk.green(`${newCompKey}`)}`);
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
export const getFolderList = async (filePath) => {
|
|
248
|
+
addDebugLog("getFolderList", `filePath: ${filePath}`, "");
|
|
249
|
+
if (fs.existsSync(filePath)) {
|
|
250
|
+
return fs
|
|
251
|
+
.readdirSync(filePath, { withFileTypes: true })
|
|
252
|
+
.filter(dirent => dirent.isDirectory())
|
|
253
|
+
.map(dirent => dirent.name);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
console.log(chalk.red.bold(`File path: ${filePath} does not exist or no permissions.`));
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export const hasConfig = (dir) => {
|
|
262
|
+
const configPath = join(gFilePath, dir, "config.json");
|
|
263
|
+
if (fs.existsSync(configPath)) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export const getComponentList = async(filePath) => {
|
|
271
|
+
addDebugLog("getComponentList", `filePath: ${filePath}`, "");
|
|
272
|
+
let compList = await getFolderList(filePath);
|
|
273
|
+
|
|
274
|
+
gFilePath = filePath;
|
|
275
|
+
|
|
276
|
+
if (compList.length > 0) {
|
|
277
|
+
return compList.filter(hasConfig);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return compList;
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export default async options => {
|
|
285
|
+
await showVersion();
|
|
286
|
+
await checkLibraryAndArchives();
|
|
287
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
288
|
+
|
|
289
|
+
addDebugLog("importComponent", "", "+");
|
|
290
|
+
|
|
291
|
+
if (options.params.length >= 5) {
|
|
292
|
+
const filePath = options.params[3];
|
|
293
|
+
const fileName = options.params[4];
|
|
294
|
+
await importComp( filePath, fileName);
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
|
|
299
|
+
const filePathQuestions = await getFilePathQuestions();
|
|
300
|
+
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
301
|
+
const { filePath } = filePathAnswers;
|
|
302
|
+
|
|
303
|
+
const compFileList = await getComponentList(filePath);
|
|
304
|
+
|
|
305
|
+
if (!compFileList || compFileList.length === 0) {
|
|
306
|
+
console.log(chalk.red.bold(`No component files exist at path: ${filePath}`));
|
|
307
|
+
process.exit();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const fileNameQuestions = await getFileNameQuestions(compFileList);
|
|
311
|
+
const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
|
|
312
|
+
const {fileName} = fileNameAnswers;
|
|
313
|
+
|
|
314
|
+
await importComp( filePath, fileName);
|
|
315
|
+
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
addDebugLog("importComponent", "END", "-");
|
|
319
|
+
|
|
320
|
+
};
|
package/src/tasks/index.js
CHANGED
|
@@ -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';
|
|
@@ -27,6 +28,7 @@ export { default as setPermanent } from './set-perm/index.js';
|
|
|
27
28
|
export { default as storeComponents } from './store/index.js';
|
|
28
29
|
export { default as importArchive } from './import-archive/index.js';
|
|
29
30
|
export { default as exportArchive } from './export-archive/index.js';
|
|
31
|
+
export { default as importComponent } from './import-comp/index.js';
|
|
30
32
|
export { default as updateComponent } from './update/index.js';
|
|
31
33
|
export { default as validate } from './validator/index.js';
|
|
32
34
|
export { default as authenticate } from './authenticate/index.js';
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"update": "custom-dx-components update",
|
|
20
20
|
"delete": "custom-dx-components delete",
|
|
21
21
|
"deleteAll": "custom-dx-components deleteAll",
|
|
22
|
+
"importComponent": "custom-dx-components importComponent",
|
|
22
23
|
"_***Component_mode_only***": "Component only commands",
|
|
23
24
|
"publish": "custom-dx-components publish",
|
|
24
25
|
"publishAll": "custom-dx-components publishAll",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"deleteLib": "custom-dx-components deleteLibrary",
|
|
35
36
|
"deletePublishedLib": "custom-dx-components deletePublished",
|
|
36
37
|
"deleteLibVersion": "custom-dx-components deleteVersion",
|
|
37
|
-
"
|
|
38
|
+
"move": "custom-dx-components moveComponent",
|
|
38
39
|
"publishLibVersion": "custom-dx-components publish",
|
|
39
40
|
"storeLibVersion": "custom-dx-components storeComponents",
|
|
40
41
|
"showStatus": "custom-dx-components showStatus",
|
|
@@ -47,11 +48,12 @@
|
|
|
47
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",
|
|
48
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 ",
|
|
49
50
|
"_internal-test-full": "npm run _internal-test-functional && npm run _internal-test-unit",
|
|
50
|
-
"_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",
|
|
51
52
|
"_internal-test-unit": "npm run test:unit:local --prefix node_modules/@pega/custom-dx-components",
|
|
52
53
|
"_internal-build-jest-assets": "custom-dx-components buildJestAssets",
|
|
53
54
|
"_internal-buildLibrary": "custom-dx-components buildLibrary",
|
|
54
55
|
"_internal-publishLibrary": "custom-dx-components publishLibrary",
|
|
56
|
+
"_internal-test-quarantine": "custom-dx-components quarantine",
|
|
55
57
|
"_lint:styles": "stylelint \"./**/*.@(js|jsx|ts|tsx)\"",
|
|
56
58
|
"_lint:format": "prettier -c .",
|
|
57
59
|
"_lint:spelling": "cspell --no-progress **/*",
|
|
@@ -98,7 +100,7 @@
|
|
|
98
100
|
},
|
|
99
101
|
"devDependencies": {
|
|
100
102
|
"@pega/configs": "^0.6.0",
|
|
101
|
-
"@pega/custom-dx-components": "0.242.
|
|
103
|
+
"@pega/custom-dx-components": "0.242.36",
|
|
102
104
|
"@pega/pcore-pconnect-typedefs": "~3.0.0",
|
|
103
105
|
"@storybook/addon-actions": "^7.6.7",
|
|
104
106
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -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,7 +16,8 @@ export default async (options) => {
|
|
|
16
16
|
await checkLibraryAndArchives();
|
|
17
17
|
addDebugLog("listLibrary", "", "+");
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
await cleanUpTemp();
|
|
20
|
+
|
|
20
21
|
let organization;
|
|
21
22
|
let library;
|
|
22
23
|
|
|
@@ -29,24 +30,28 @@ addDebugLog("listLibrary", "", "+");
|
|
|
29
30
|
let libVersions = [];
|
|
30
31
|
|
|
31
32
|
if (options.params.length >= 5) {
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
libraryName = options.params[3];
|
|
34
|
+
selectedVersion = options.params[4];
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
try {
|
|
37
|
+
libVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
38
|
+
}
|
|
39
|
+
catch (ex) {}
|
|
36
40
|
|
|
37
41
|
}
|
|
42
|
+
else {
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
const questions = await getArchiveLibraryQuestions();
|
|
45
|
+
const answers = await inquirer.prompt(questions);
|
|
46
|
+
({ libraryName } = answers);
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
try {
|
|
49
|
+
libVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
50
|
+
}
|
|
51
|
+
catch (ex) {}
|
|
47
52
|
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
if (libVersions.length > 0) {
|
|
50
55
|
|
|
51
56
|
if (selectedVersion === undefined) {
|
|
52
57
|
const libAnswers = await inquirer.prompt([
|
|
@@ -61,10 +66,14 @@ addDebugLog("listLibrary", "", "+");
|
|
|
61
66
|
|
|
62
67
|
selectedVersion = libAnswers.libVersion;
|
|
63
68
|
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let data;
|
|
73
|
+
// get built on from first component if exists
|
|
74
|
+
let builtOn = "(date unavailable)";
|
|
64
75
|
|
|
65
|
-
|
|
66
|
-
// get built on from first component if exists
|
|
67
|
-
let builtOn = "(date unavailable)";
|
|
76
|
+
if (libVersions.length > 0) {
|
|
68
77
|
|
|
69
78
|
if (libraryName === compDef.currentOrgLib && selectedVersion === compDef.buildVersion) {
|
|
70
79
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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 ===
|
|
103
|
+
if (selectedVersion === "") {
|
|
100
104
|
const libAnswers = await inquirer.prompt([
|
|
101
105
|
{
|
|
102
106
|
name: 'libVersion',
|
package/src/tasks/move/helper.js
CHANGED
|
@@ -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
|
|
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
|
};
|