@pega/custom-dx-components 0.242.26 → 0.242.27
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 +2 -1
- package/src/cli.js +44 -2
- package/src/constants.js +2 -0
- package/src/tasks/build-all/helper.js +1 -1
- package/src/tasks/build-all/index.js +4 -3
- package/src/tasks/build-comp/helper.js +7 -4
- package/src/tasks/build-comp/index.js +4 -2
- package/src/tasks/build-jest-assets/index.js +1 -1
- package/src/tasks/build-lib/helper.js +2 -34
- package/src/tasks/build-lib/index.js +36 -85
- package/src/tasks/create/index.js +31 -19
- package/src/tasks/create-all/index.js +31 -16
- package/src/tasks/create-lib/helper.js +80 -0
- package/src/tasks/create-lib/index.js +109 -0
- package/src/tasks/create-version/helper.js +81 -0
- package/src/tasks/create-version/index.js +108 -0
- package/src/tasks/delete/index.js +7 -4
- package/src/tasks/delete-all/index.js +14 -9
- package/src/tasks/delete-lib/helper.js +19 -46
- package/src/tasks/delete-lib/index.js +107 -49
- package/src/tasks/delete-pub/helper.js +35 -0
- package/src/tasks/delete-pub/index.js +105 -0
- package/src/tasks/index.js +7 -0
- package/src/tasks/init/helper.js +5 -5
- package/src/tasks/init/template/package.json.mustache +15 -6
- package/src/tasks/list/helper.js +29 -8
- package/src/tasks/list/index.js +4 -9
- package/src/tasks/list-lib/helper.js +18 -53
- package/src/tasks/list-lib/index.js +68 -110
- package/src/tasks/list-pub/helper.js +42 -0
- package/src/tasks/list-pub/index.js +170 -0
- package/src/tasks/promote-webpack/index.js +1 -1
- package/src/tasks/publish/helper.js +44 -44
- package/src/tasks/publish/index.js +70 -5
- package/src/tasks/publish-all/index.js +10 -2
- package/src/tasks/publish-lib/helper.js +0 -38
- package/src/tasks/publish-lib/index.js +39 -13
- package/src/tasks/rename/index.js +25 -10
- package/src/tasks/rename-lib/index.js +8 -41
- package/src/tasks/revert-webpack/index.js +1 -1
- package/src/tasks/show-status/index.js +41 -0
- package/src/tasks/switch-lib/helper.js +81 -0
- package/src/tasks/switch-lib/index.js +134 -0
- package/src/tasks/switch-version/helper.js +92 -0
- package/src/tasks/switch-version/index.js +142 -0
- package/src/util.js +728 -59
|
@@ -15,14 +15,15 @@ import { checkPathAccess, showVersion ,
|
|
|
15
15
|
getComponentDirectoryPath,
|
|
16
16
|
getPegaServerConfig,
|
|
17
17
|
getComponents,
|
|
18
|
-
getComponentDefaults,
|
|
19
18
|
sanitize,
|
|
20
19
|
validateSemver,
|
|
21
20
|
updateComponentDefaultLibrary,
|
|
22
21
|
updateComponentDefaultVersion,
|
|
23
22
|
copyFileToShared,
|
|
24
23
|
getLibraryBased,
|
|
25
|
-
addDebugLog
|
|
24
|
+
addDebugLog,
|
|
25
|
+
checkLibraryAndArchives,
|
|
26
|
+
getConfigDefaults
|
|
26
27
|
} from '../../util.js';
|
|
27
28
|
|
|
28
29
|
import { COMPONENT_SCHEMA, COMPONENTS_DIRECTORY_PATH, TASKS_CONFIG_JSON_FILENAME, COMPONENTS_PATH, CATEGORY_CONSTELLATION, SHARED_FILE_NAMES } from '../../constants.js';
|
|
@@ -33,7 +34,7 @@ const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME)
|
|
|
33
34
|
|
|
34
35
|
const copy = promisify(ncp);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
const isLibraryBased = getLibraryBased();
|
|
37
38
|
|
|
38
39
|
const copyComponentTemplate = async (options) => {
|
|
39
40
|
if (options.targetDirectory) {
|
|
@@ -174,7 +175,6 @@ export const validateCompile = async (
|
|
|
174
175
|
sSubType = subtype.join('-');
|
|
175
176
|
}
|
|
176
177
|
|
|
177
|
-
// await checkPathAccess(pegaConfigInternalJsonPath);
|
|
178
178
|
|
|
179
179
|
framework = convertIntoPascalCase(CATEGORY_CONSTELLATION);
|
|
180
180
|
|
|
@@ -189,12 +189,22 @@ export const validateCompile = async (
|
|
|
189
189
|
const originalFramework = framework;
|
|
190
190
|
|
|
191
191
|
// check of library or version has changed from default, if so, update componentDefaults
|
|
192
|
-
const componentDefaults =
|
|
192
|
+
const componentDefaults = getConfigDefaults();
|
|
193
193
|
if (componentDefaults.library == null || componentDefaults.library !== library) {
|
|
194
194
|
await updateComponentDefaultLibrary(library);
|
|
195
195
|
}
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
|
|
197
|
+
// library based, get version from defaults
|
|
198
|
+
if (isLibraryBased) {
|
|
199
|
+
version = componentDefaults.version;
|
|
200
|
+
if (defaultPegaServerConfig.devBuild) {
|
|
201
|
+
version = version.concat("-dev");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
if (componentDefaults.version == null || componentDefaults.version !== version) {
|
|
206
|
+
await updateComponentDefaultVersion(version);
|
|
207
|
+
}
|
|
198
208
|
}
|
|
199
209
|
|
|
200
210
|
if (isLaunchpad) {
|
|
@@ -216,12 +226,8 @@ export const validateCompile = async (
|
|
|
216
226
|
|
|
217
227
|
}
|
|
218
228
|
|
|
219
|
-
|
|
220
|
-
|
|
221
229
|
const componentKey = `${organization}_${library}_${componentName}`;
|
|
222
|
-
|
|
223
230
|
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
224
|
-
|
|
225
231
|
const components = await getComponents(false);
|
|
226
232
|
|
|
227
233
|
if (components.includes(componentKey)) {
|
|
@@ -254,8 +260,6 @@ export const validateCompile = async (
|
|
|
254
260
|
|
|
255
261
|
export const validateCompileAll = async ({ prefix, library, version, allowedApplications, organization }, options) => {
|
|
256
262
|
|
|
257
|
-
isLibraryBased = await getLibraryBased();
|
|
258
|
-
|
|
259
263
|
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
260
264
|
for (const fieldIdx in COMPONENT_SCHEMA.subtype.field) {
|
|
261
265
|
const type = 'Field';
|
|
@@ -355,6 +359,8 @@ export const validateCompileAll = async ({ prefix, library, version, allowedAppl
|
|
|
355
359
|
export default async (options) => {
|
|
356
360
|
await showVersion();
|
|
357
361
|
|
|
362
|
+
await checkLibraryAndArchives();
|
|
363
|
+
|
|
358
364
|
addDebugLog("createAll", "", "+");
|
|
359
365
|
|
|
360
366
|
await checkPathAccess(pegaConfigJsonPath);
|
|
@@ -373,7 +379,7 @@ addDebugLog("createAll", "", "+");
|
|
|
373
379
|
({ library } = componentData);
|
|
374
380
|
let { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
375
381
|
|
|
376
|
-
const componentDefaults =
|
|
382
|
+
const componentDefaults = getConfigDefaults();
|
|
377
383
|
componentDefaults.library = library;
|
|
378
384
|
|
|
379
385
|
if (options.params.length >= 8) {
|
|
@@ -410,7 +416,8 @@ addDebugLog("createAll", "", "+");
|
|
|
410
416
|
return true;
|
|
411
417
|
}
|
|
412
418
|
return 'Please provide semver compatible version e.g 0.0.1';
|
|
413
|
-
}
|
|
419
|
+
},
|
|
420
|
+
when: () => !isLibraryBased
|
|
414
421
|
},
|
|
415
422
|
{
|
|
416
423
|
name: 'library',
|
|
@@ -426,7 +433,8 @@ addDebugLog("createAll", "", "+");
|
|
|
426
433
|
return true;
|
|
427
434
|
}
|
|
428
435
|
return 'Only alphanumeric values are allowed, starting with alphabets';
|
|
429
|
-
}
|
|
436
|
+
},
|
|
437
|
+
when: () => !isLibraryBased
|
|
430
438
|
},
|
|
431
439
|
{
|
|
432
440
|
name: 'allowedApplications',
|
|
@@ -438,6 +446,13 @@ addDebugLog("createAll", "", "+");
|
|
|
438
446
|
|
|
439
447
|
await inquirer.prompt(questions).then(async (answers) => {
|
|
440
448
|
({library} = answers);
|
|
449
|
+
|
|
450
|
+
if (isLibraryBased) {
|
|
451
|
+
// library comes from config
|
|
452
|
+
const orgLib = getConfigDefaults();
|
|
453
|
+
library = orgLib.library;
|
|
454
|
+
}
|
|
455
|
+
|
|
441
456
|
const { version, allowedApplications } = answers;
|
|
442
457
|
let { prefix } = answers;
|
|
443
458
|
prefix = prefix.replace(/[^a-zA-Z0-9 ]/g, '');
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
sanitize,
|
|
6
|
+
validateSemver,
|
|
7
|
+
getLibraryArchiveDirectories,
|
|
8
|
+
addDebugLog,
|
|
9
|
+
getConfigDefaults
|
|
10
|
+
} from '../../util.js';
|
|
11
|
+
|
|
12
|
+
export const getOkToProceedQuestion = async () => {
|
|
13
|
+
addDebugLog("getCreateLibComponentQuestions", "", "");
|
|
14
|
+
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'okToContinue',
|
|
18
|
+
type: 'confirm',
|
|
19
|
+
message: 'Ok to continue ?',
|
|
20
|
+
default: false
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const getCreateLibComponentQuestions = async () => {
|
|
27
|
+
addDebugLog("getCreateLibComponentQuestions", "", "");
|
|
28
|
+
const archDirectories = await getLibraryArchiveDirectories();
|
|
29
|
+
const orgLib = getConfigDefaults();
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
name: 'libraryName',
|
|
35
|
+
message: 'Enter libray name',
|
|
36
|
+
validate: value => {
|
|
37
|
+
/* value should not be empty
|
|
38
|
+
It should not have spaces
|
|
39
|
+
It should not start with a number
|
|
40
|
+
Only case-insensitive alphanumeric values are allowed
|
|
41
|
+
*/
|
|
42
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
43
|
+
if (archDirectories && archDirectories.length > 0) {
|
|
44
|
+
const newOrgLib = `${orgLib.organization}_${value}`;
|
|
45
|
+
if (archDirectories.includes(newOrgLib)) {
|
|
46
|
+
return `Library ${value} already exists.`;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'version',
|
|
64
|
+
message: 'Enter version ',
|
|
65
|
+
default: '0.0.1',
|
|
66
|
+
validate: value => {
|
|
67
|
+
if (validateSemver(value)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return 'Please provide semver compatible version e.g 0.0.1';
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'permBuild',
|
|
75
|
+
type: 'confirm',
|
|
76
|
+
message: `Version to be ${chalk.bold.yellow('PERMENANT')} upon publish `,
|
|
77
|
+
default: false
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line import/order
|
|
6
|
+
import {
|
|
7
|
+
showVersion,
|
|
8
|
+
updateComponentDefaultLibrary,
|
|
9
|
+
updateComponentDefaultVersion,
|
|
10
|
+
getLibraryBased,
|
|
11
|
+
addDebugLog,
|
|
12
|
+
zipVersionAndArchive,
|
|
13
|
+
hasArchives,
|
|
14
|
+
clearSrcComponentsDirectory,
|
|
15
|
+
hasLibraryAndVersion,
|
|
16
|
+
getConfigDefaults,
|
|
17
|
+
forceDefaultsUpdate
|
|
18
|
+
} from '../../util.js';
|
|
19
|
+
|
|
20
|
+
import { getCreateLibComponentQuestions, getOkToProceedQuestion } from './helper.js';
|
|
21
|
+
import { showCurrentStatus } from '../show-status/index.js';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const isLibraryBased = getLibraryBased();
|
|
25
|
+
|
|
26
|
+
export default async options => {
|
|
27
|
+
if (!isLibraryBased) {
|
|
28
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`);
|
|
29
|
+
process.exit();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await showVersion();
|
|
33
|
+
|
|
34
|
+
addDebugLog("createLibrary", "", "+");
|
|
35
|
+
let libraryName;
|
|
36
|
+
let version;
|
|
37
|
+
// permBuild is the opposite of devBuild
|
|
38
|
+
let permBuild;
|
|
39
|
+
const orgLib = getConfigDefaults();
|
|
40
|
+
const hasArch = await hasArchives();
|
|
41
|
+
|
|
42
|
+
if (hasArch) {
|
|
43
|
+
console.log(chalk.bold.yellow('\nBe sure to SAVE all changes before creating a new library, unsaved changes will be LOST.'))
|
|
44
|
+
console.log(chalk.bold.yellow('Current library/version will be archived and the newly created library/version will be your default.'))
|
|
45
|
+
|
|
46
|
+
const okQuestion = await getOkToProceedQuestion();
|
|
47
|
+
const okAnswers = await inquirer.prompt(okQuestion);
|
|
48
|
+
const { okToContinue } = okAnswers;
|
|
49
|
+
|
|
50
|
+
if (!okToContinue) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (options.params.length >= 6) {
|
|
56
|
+
libraryName = options.params[3];
|
|
57
|
+
version = options.params[4];
|
|
58
|
+
const dPerm = options.params[5];
|
|
59
|
+
permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
|
|
60
|
+
} else {
|
|
61
|
+
const questions = await getCreateLibComponentQuestions();
|
|
62
|
+
const answers = await inquirer.prompt(questions);
|
|
63
|
+
({ libraryName, version, permBuild } = answers);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// if have archives, then that means there is a current library, so
|
|
69
|
+
// archive it before clearing out /src/components
|
|
70
|
+
|
|
71
|
+
if (hasArch) {
|
|
72
|
+
|
|
73
|
+
const hasLib = await hasLibraryAndVersion(libraryName, version, !permBuild);
|
|
74
|
+
if (hasLib) {
|
|
75
|
+
console.log(`${chalk.bold.red(`Library ${orgLib.organization}_${libraryName} already exists.`)}`);
|
|
76
|
+
console.log("You can switch to that version by entering 'npm run switchVersion'.\n")
|
|
77
|
+
process.exit();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const currentOrgLib = orgLib.currentOrgLib;
|
|
81
|
+
const currentVersion = orgLib.buildVersion;
|
|
82
|
+
await zipVersionAndArchive(currentOrgLib, currentVersion);
|
|
83
|
+
await clearSrcComponentsDirectory();
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const newOrgLib = `${orgLib.organization}_${libraryName}`;
|
|
88
|
+
|
|
89
|
+
if (orgLib.version == null || orgLib.version !== version) {
|
|
90
|
+
await updateComponentDefaultVersion(version);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!permBuild) {
|
|
94
|
+
version = version.concat("-dev");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// update library name in config and create a blank archive
|
|
98
|
+
await updateComponentDefaultLibrary(libraryName);
|
|
99
|
+
await zipVersionAndArchive(newOrgLib, version);
|
|
100
|
+
|
|
101
|
+
console.log(`${chalk.bold.green(`\nLibrary ${newOrgLib}/${version} has been created!\n`)}`);
|
|
102
|
+
|
|
103
|
+
await forceDefaultsUpdate();
|
|
104
|
+
await showCurrentStatus();
|
|
105
|
+
|
|
106
|
+
addDebugLog("createLibrary", "END", "-");
|
|
107
|
+
|
|
108
|
+
return true;
|
|
109
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getComponents,
|
|
5
|
+
validateSemver,
|
|
6
|
+
updateConfigVersion,
|
|
7
|
+
addDebugLog,
|
|
8
|
+
getLibraryArchivesVersions,
|
|
9
|
+
getConfigDefaults
|
|
10
|
+
} from '../../util.js';
|
|
11
|
+
|
|
12
|
+
export const updateAllComponentsConfig = async( newVersion ) => {
|
|
13
|
+
addDebugLog("updateAllComponentsConfig", `newVersion: ${newVersion}`, "");
|
|
14
|
+
const componentList = await getComponents();
|
|
15
|
+
const orgLib = getConfigDefaults();
|
|
16
|
+
// const currentOrgLib = `${orgLib.organization}_${orgLib.library}`;
|
|
17
|
+
const currentOrgLib = orgLib.currentOrgLib;
|
|
18
|
+
|
|
19
|
+
for (const index in componentList) {
|
|
20
|
+
const componentKey = componentList[index];
|
|
21
|
+
await updateConfigVersion(componentKey, newVersion, currentOrgLib);
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getNextVersion = async () => {
|
|
27
|
+
addDebugLog("getNextVersion", "", "");
|
|
28
|
+
const orgLib = getConfigDefaults();
|
|
29
|
+
const currentOrgLib = orgLib.currentOrgLib;
|
|
30
|
+
const archiveVersionList = await getLibraryArchivesVersions(currentOrgLib);
|
|
31
|
+
|
|
32
|
+
if (archiveVersionList && archiveVersionList.length > 0) {
|
|
33
|
+
let lastVersion = archiveVersionList[archiveVersionList.length - 1];
|
|
34
|
+
lastVersion = lastVersion.replaceAll("-dev", "");
|
|
35
|
+
|
|
36
|
+
const arVer = lastVersion.split(".");
|
|
37
|
+
arVer[2] = (parseInt(arVer[2]) + 1).toString();
|
|
38
|
+
const incrVersion = arVer.join(".");
|
|
39
|
+
|
|
40
|
+
return incrVersion;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return "0.0.1";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const getCreateVersionComponentQuestions = async () => {
|
|
50
|
+
addDebugLog("getCreateVersionComponentQuestions", "", "");
|
|
51
|
+
const componentDefaults = getConfigDefaults();
|
|
52
|
+
|
|
53
|
+
// increment the version
|
|
54
|
+
const incrVersion = await getNextVersion();
|
|
55
|
+
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
name: 'version',
|
|
59
|
+
message: 'Enter version ',
|
|
60
|
+
default: incrVersion,
|
|
61
|
+
validate: value => {
|
|
62
|
+
if (validateSemver(value)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return 'Please provide semver compatible version e.g 0.0.1';
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'permBuild',
|
|
70
|
+
type: 'confirm',
|
|
71
|
+
message: `Version ${chalk.bold.yellow('PERMENANT')} upon publish ?`,
|
|
72
|
+
default: !componentDefaults.devBuild
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'copyExisting',
|
|
76
|
+
type: 'confirm',
|
|
77
|
+
message: 'Copy current components to new version ?',
|
|
78
|
+
default: true
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line import/order
|
|
9
|
+
import {
|
|
10
|
+
showVersion,
|
|
11
|
+
updateComponentDefaultVersion,
|
|
12
|
+
getLibraryBased,
|
|
13
|
+
addDebugLog,
|
|
14
|
+
zipVersionAndArchive,
|
|
15
|
+
setConfigDevBuild,
|
|
16
|
+
checkLibraryAndArchives,
|
|
17
|
+
getConfigDefaults
|
|
18
|
+
} from '../../util.js';
|
|
19
|
+
|
|
20
|
+
import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
|
|
21
|
+
|
|
22
|
+
const isLibraryBased = getLibraryBased();
|
|
23
|
+
|
|
24
|
+
export default async options => {
|
|
25
|
+
if (!isLibraryBased) {
|
|
26
|
+
console.log(`Command only supported for ${chalk.bold.green('library based')} components.`);
|
|
27
|
+
process.exit();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await showVersion();
|
|
31
|
+
await checkLibraryAndArchives();
|
|
32
|
+
|
|
33
|
+
addDebugLog("createVersion", "", "+");
|
|
34
|
+
let libraryName;
|
|
35
|
+
let version;
|
|
36
|
+
// permBuild is the opposite of devBuild
|
|
37
|
+
let permBuild;
|
|
38
|
+
let copyExisting;
|
|
39
|
+
|
|
40
|
+
const componentDefaults = getConfigDefaults();
|
|
41
|
+
const currentDirectory = process.cwd();
|
|
42
|
+
const componentDirectory = join (currentDirectory, "src", "components");
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if (options.params.length >= 6) {
|
|
46
|
+
version = options.params[3];
|
|
47
|
+
const dPerm = options.params[4];
|
|
48
|
+
const copyExist = options.params[5]
|
|
49
|
+
permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
|
|
50
|
+
copyExisting = !!(copyExist === 'Y' || copyExist === 'y' || copyExist === true || copyExist === 'true');
|
|
51
|
+
|
|
52
|
+
} else {
|
|
53
|
+
const questions = await getCreateVersionComponentQuestions();
|
|
54
|
+
const answers = await inquirer.prompt(questions);
|
|
55
|
+
({ version, permBuild, copyExisting } = answers);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const orgLib = getConfigDefaults();
|
|
59
|
+
const savedNewVersion = version;
|
|
60
|
+
const existingOrgLib = orgLib.currentOrgLib;
|
|
61
|
+
let oldVersion = componentDefaults.version;
|
|
62
|
+
if (componentDefaults.devBuild) {
|
|
63
|
+
oldVersion = oldVersion.concat("-dev");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!permBuild) {
|
|
67
|
+
version = version.concat("-dev");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// archive existing
|
|
71
|
+
await zipVersionAndArchive(existingOrgLib, oldVersion);
|
|
72
|
+
|
|
73
|
+
if (copyExisting) {
|
|
74
|
+
// change all existing config to new version
|
|
75
|
+
await updateAllComponentsConfig(version);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// wipe out /src/components
|
|
79
|
+
try {
|
|
80
|
+
fs.rmSync(componentDirectory, { recursive: true });
|
|
81
|
+
addDebugLog("createVersion", `clear out: ${componentDirectory}`, "");
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.log(`No such directory: ${componentDirectory} `);
|
|
84
|
+
throw new Error(`No such file ${componentDirectory}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// create a blank directory
|
|
88
|
+
addDebugLog("createVersion", `make new directory: ${componentDirectory}`, "");
|
|
89
|
+
fs.mkdirSync(componentDirectory, { recursive: true });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// update config with new version
|
|
93
|
+
await updateComponentDefaultVersion(savedNewVersion);
|
|
94
|
+
await setConfigDevBuild(!permBuild);
|
|
95
|
+
|
|
96
|
+
// create archive of new
|
|
97
|
+
await zipVersionAndArchive(existingOrgLib, version);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
console.log(`${chalk.bold.green(`\nLibrary ${existingOrgLib}/${oldVersion} has been archived.`)}`);
|
|
102
|
+
console.log(`${chalk.bold.green(`Library ${existingOrgLib}/${version} has been created!\n`)}`);
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
addDebugLog("createVersion", "END", "-");
|
|
106
|
+
|
|
107
|
+
return true;
|
|
108
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
|
|
3
|
-
import { showVersion, getLibraryBased, addDebugLog } from '../../util.js';
|
|
3
|
+
import { showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives } from '../../util.js';
|
|
4
4
|
|
|
5
5
|
import { deleteLocalComponents, SOURCE_OF_COMPONENT_TYPES, deleteServerComponents, getDeleteComponentsQuestions } from './helper.js';
|
|
6
6
|
|
|
7
|
-
const isLibraryBased =
|
|
7
|
+
const isLibraryBased = getLibraryBased();
|
|
8
8
|
|
|
9
9
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
10
10
|
addDebugLog("deleteComponentsFn", `sourceOfComponents: ${sourceOfComponents}`, "");
|
|
@@ -26,6 +26,7 @@ addDebugLog("deleteComponentsFn", `sourceOfComponents: ${sourceOfComponents}`, "
|
|
|
26
26
|
|
|
27
27
|
export default async (options) => {
|
|
28
28
|
await showVersion();
|
|
29
|
+
await checkLibraryAndArchives();
|
|
29
30
|
|
|
30
31
|
addDebugLog("delete", "", "+");
|
|
31
32
|
|
|
@@ -37,12 +38,14 @@ addDebugLog("delete", "", "+");
|
|
|
37
38
|
else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
38
39
|
sourceOfComponentsOption = options.params[3];
|
|
39
40
|
await deleteComponentsFn(sourceOfComponentsOption, null, options);
|
|
40
|
-
}
|
|
41
|
+
}
|
|
42
|
+
else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
|
|
41
43
|
sourceOfComponentsOption = options.params[3];
|
|
42
44
|
const questions = await getDeleteComponentsQuestions(options, sourceOfComponentsOption);
|
|
43
45
|
const answers = await inquirer.prompt(questions);
|
|
44
46
|
await deleteComponentsFn(sourceOfComponentsOption, answers, options);
|
|
45
|
-
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
46
49
|
const questions = await getDeleteComponentsQuestions(options);
|
|
47
50
|
const answers = await inquirer.prompt(questions);
|
|
48
51
|
const { sourceOfComponents } = answers;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
|
|
3
|
-
import { showVersion, getLibraryBased, addDebugLog } from '../../util.js';
|
|
3
|
+
import { showVersion, getLibraryBased, addDebugLog, checkLibraryAndArchives } from '../../util.js';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
deleteLocalComponents,
|
|
7
|
+
SOURCE_OF_COMPONENT_TYPES,
|
|
8
|
+
deleteServerComponents,
|
|
9
|
+
getDeleteComponentsQuestions
|
|
10
|
+
} from './helper.js';
|
|
6
11
|
|
|
7
|
-
const isLibraryBased =
|
|
12
|
+
const isLibraryBased = getLibraryBased();
|
|
8
13
|
|
|
9
14
|
const deleteComponentsFn = async (sourceOfComponents, answers, options) => {
|
|
10
|
-
addDebugLog(
|
|
15
|
+
addDebugLog('deleteComponentsFn', `sourceOfComponents: ${sourceOfComponents}`, '');
|
|
11
16
|
switch (sourceOfComponents) {
|
|
12
17
|
case SOURCE_OF_COMPONENT_TYPES.LOCAL: {
|
|
13
18
|
await deleteLocalComponents(sourceOfComponents, options);
|
|
@@ -24,17 +29,17 @@ addDebugLog("deleteComponentsFn", `sourceOfComponents: ${sourceOfComponents}`, "
|
|
|
24
29
|
}
|
|
25
30
|
};
|
|
26
31
|
|
|
27
|
-
export default async
|
|
32
|
+
export default async options => {
|
|
28
33
|
await showVersion();
|
|
34
|
+
await checkLibraryAndArchives();
|
|
29
35
|
|
|
30
|
-
addDebugLog(
|
|
36
|
+
addDebugLog('deleteAll', '', '+');
|
|
31
37
|
|
|
32
38
|
let sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
33
39
|
if (isLibraryBased) {
|
|
34
40
|
sourceOfComponentsOption = SOURCE_OF_COMPONENT_TYPES.LOCAL;
|
|
35
41
|
await deleteComponentsFn(sourceOfComponentsOption, null, options);
|
|
36
|
-
}
|
|
37
|
-
else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
42
|
+
} else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.LOCAL) {
|
|
38
43
|
sourceOfComponentsOption = options.params[3];
|
|
39
44
|
await deleteComponentsFn(sourceOfComponentsOption, null, options);
|
|
40
45
|
} else if (options.params[3] === SOURCE_OF_COMPONENT_TYPES.SERVER) {
|
|
@@ -49,5 +54,5 @@ addDebugLog("deleteAll", "", "+");
|
|
|
49
54
|
await deleteComponentsFn(sourceOfComponents, answers, options);
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
addDebugLog(
|
|
57
|
+
addDebugLog('deleteAll', 'END', '-');
|
|
53
58
|
};
|
|
@@ -1,76 +1,49 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
1
|
import path from 'path';
|
|
3
|
-
|
|
4
2
|
import chalk from 'chalk';
|
|
5
3
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
TASKS_CONFIG_JSON_FILENAME,
|
|
9
|
-
COMPONENTS_DIRECTORY_PATH,
|
|
10
|
-
COMPONENTS_PATH
|
|
11
|
-
} from '../../constants.js';
|
|
4
|
+
import { addDebugLog, getConfigDefaults, getLibraryArchiveDirectories } from '../../util.js';
|
|
12
5
|
|
|
13
6
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
14
7
|
SERVER: 'Server',
|
|
15
8
|
LOCAL: 'Local'
|
|
16
9
|
};
|
|
17
10
|
|
|
18
|
-
const pegaConfigJsonPath = path.join(path.resolve(), TASKS_CONFIG_JSON_FILENAME);
|
|
19
|
-
|
|
20
|
-
export const getOrgLib = async () => {
|
|
21
|
-
addDebugLog("getOrgLib", "", "+");
|
|
22
|
-
const defaultPegaConfig = await getPegaServerConfig();
|
|
23
|
-
|
|
24
|
-
await checkPathAccess(pegaConfigJsonPath);
|
|
25
|
-
|
|
26
|
-
let data = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
27
|
-
data = data && JSON.parse(data);
|
|
28
|
-
|
|
29
|
-
if (!data[COMPONENTS_DIRECTORY_PATH]) {
|
|
30
|
-
console.error(
|
|
31
|
-
`${chalk.red.bold('ERROR')} Could not able find components directory path in config.json`
|
|
32
|
-
);
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const componentData = data[COMPONENTS_PATH];
|
|
37
|
-
|
|
38
|
-
let library;
|
|
39
|
-
({ library } = componentData);
|
|
40
|
-
const { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
41
|
-
|
|
42
|
-
const componentDefaults = await getComponentDefaults();
|
|
43
|
-
componentDefaults.library = library;
|
|
44
|
-
componentDefaults.organization = organization;
|
|
45
|
-
|
|
46
|
-
addDebugLog("getOrgLib", `componentsDefaults: ${JSON.stringify(componentDefaults)}`, "");
|
|
47
|
-
addDebugLog("getOrgLib", "END", "-");
|
|
48
|
-
return componentDefaults;
|
|
49
|
-
};
|
|
50
11
|
|
|
51
12
|
export const getDeleteLibraryQuestions = async () => {
|
|
52
13
|
addDebugLog("getDeleteLibraryQuestions", "", "");
|
|
53
|
-
const
|
|
14
|
+
const configDef = getConfigDefaults();
|
|
15
|
+
const archLibs = await getLibraryArchiveDirectories("");
|
|
54
16
|
|
|
55
17
|
return [
|
|
56
18
|
{
|
|
57
|
-
name: '
|
|
19
|
+
name: 'libraryName',
|
|
58
20
|
type: 'rawlist',
|
|
59
|
-
message: '
|
|
60
|
-
choices:
|
|
61
|
-
default: defaultPegaConfig.sourceOfComponents
|
|
21
|
+
message: 'Select library',
|
|
22
|
+
choices: archLibs
|
|
62
23
|
}
|
|
63
24
|
];
|
|
64
25
|
};
|
|
65
26
|
|
|
66
27
|
export const getLibraryVersionQuestion = async (libraryName, libVersions) => {
|
|
67
28
|
addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}`, "");
|
|
29
|
+
|
|
30
|
+
let orAll = "";
|
|
31
|
+
if (libVersions.length > 1) {
|
|
32
|
+
orAll = "(or All) ";
|
|
33
|
+
}
|
|
34
|
+
|
|
68
35
|
return [
|
|
69
36
|
{
|
|
70
37
|
name: 'version',
|
|
71
38
|
type: 'rawlist',
|
|
72
|
-
message: `Select ${chalk.green.bold(`${libraryName}`)} library version
|
|
39
|
+
message: `Select ${chalk.green.bold(`${libraryName}`)} library version ${orAll}to delete`,
|
|
73
40
|
choices: libVersions
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'confirmDeletion',
|
|
44
|
+
type: 'confirm',
|
|
45
|
+
message: 'Confirm deletion ?',
|
|
46
|
+
default: false
|
|
74
47
|
}
|
|
75
48
|
];
|
|
76
49
|
};
|