@pega/custom-dx-components 0.242.25 → 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 +28 -13
- 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
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import { exec as LocalExec } from "child_process";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
getComponents,
|
|
7
|
+
updateConfigVersion,
|
|
8
|
+
getLibraryArchivesVersions,
|
|
9
|
+
addDebugLog,
|
|
10
|
+
getConfigDefaults
|
|
11
|
+
} from '../../util.js';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const exec = promisify(LocalExec);
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export const updateAllComponentsConfig = async( newVersion ) => {
|
|
18
|
+
addDebugLog("updateAllComponentsConfig", `newVersion: ${newVersion}`, "");
|
|
19
|
+
const componentList = await getComponents();
|
|
20
|
+
const orgLib = getConfigDefaults();
|
|
21
|
+
const currentOrgLib = `${orgLib.organization}_${orgLib.library}`;
|
|
22
|
+
|
|
23
|
+
for (const index in componentList) {
|
|
24
|
+
const componentKey = componentList[index];
|
|
25
|
+
await updateConfigVersion(componentKey, newVersion, currentOrgLib);
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getSwitchVersionComponentQuestions = async () => {
|
|
31
|
+
addDebugLog("getSwitchVersionComponentQuestions", "", "");
|
|
32
|
+
const orgLib = getConfigDefaults();
|
|
33
|
+
const currentOrgLib = orgLib.currentOrgLib;
|
|
34
|
+
const currentVersion = orgLib.buildVersion;
|
|
35
|
+
|
|
36
|
+
const archVersionList = await getLibraryArchivesVersions(currentOrgLib, currentVersion);
|
|
37
|
+
if (archVersionList && archVersionList.length == 0) {
|
|
38
|
+
console.log(chalk.bold.redBright(`\nCurrently no other versions exist in library: ${currentOrgLib}`));
|
|
39
|
+
process.exit();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log(chalk.bold.yellow('\nBe sure to SAVE all changes before switching versions, unsaved changes will be LOST.'))
|
|
43
|
+
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
name: 'okToContinue',
|
|
47
|
+
type: 'confirm',
|
|
48
|
+
message: 'Ok to continue ?',
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'version',
|
|
53
|
+
type: 'rawlist',
|
|
54
|
+
message: `Select a version (current version is ${chalk.bold.green(`${currentVersion}`)}) `,
|
|
55
|
+
choices: archVersionList,
|
|
56
|
+
when(answers) {
|
|
57
|
+
return answers.okToContinue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const getRunNpmQuestions = async () => {
|
|
64
|
+
addDebugLog("getSwitchVersionComponentQuestions", "", "");
|
|
65
|
+
|
|
66
|
+
console.log(chalk.bold.yellow('\nDependencies have changed between versions, recommend updating.'));
|
|
67
|
+
|
|
68
|
+
return [
|
|
69
|
+
{
|
|
70
|
+
name: 'updateNpm',
|
|
71
|
+
type: 'confirm',
|
|
72
|
+
message: 'Run npm update?',
|
|
73
|
+
default: true
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
export const runNpmUpdate = async () => {
|
|
81
|
+
const script = `npm update`;
|
|
82
|
+
|
|
83
|
+
const { stdout, stderr } = await exec(script);
|
|
84
|
+
|
|
85
|
+
if (stdout) {
|
|
86
|
+
console.log(stdout);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (stderr) {
|
|
90
|
+
console.log(stderr);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { Listr } from 'listr2';
|
|
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
|
+
getPegaServerConfig,
|
|
12
|
+
getLibraryBased,
|
|
13
|
+
addDebugLog,
|
|
14
|
+
zipVersionAndArchive,
|
|
15
|
+
restoreFromArchive,
|
|
16
|
+
checkLibraryAndArchives,
|
|
17
|
+
getConfigDefaults,
|
|
18
|
+
getHaveDependencyDifference
|
|
19
|
+
} from '../../util.js';
|
|
20
|
+
|
|
21
|
+
import { getSwitchVersionComponentQuestions } from './helper.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
|
+
await checkLibraryAndArchives();
|
|
34
|
+
|
|
35
|
+
addDebugLog("switchVersion", "", "+");
|
|
36
|
+
let libraryName;
|
|
37
|
+
let version;
|
|
38
|
+
// permBuild is the opposite of devBuild
|
|
39
|
+
|
|
40
|
+
let okToContinue;
|
|
41
|
+
|
|
42
|
+
const serverConfig = await getPegaServerConfig();
|
|
43
|
+
const currentDirectory = process.cwd();
|
|
44
|
+
const componentDirectory = join (currentDirectory, "src", "components");
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if (options.params.length >= 5) {
|
|
48
|
+
const okToCont = options.params[3];
|
|
49
|
+
version = options.params[4];
|
|
50
|
+
|
|
51
|
+
okToContinue = !!(okToCont === 'Y' || okToCont === 'y' || okToCont === true || okToCont === 'true');
|
|
52
|
+
|
|
53
|
+
} else {
|
|
54
|
+
const questions = await getSwitchVersionComponentQuestions();
|
|
55
|
+
const answers = await inquirer.prompt(questions);
|
|
56
|
+
({ okToContinue, version } = answers);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (okToContinue) {
|
|
60
|
+
// in this scenario, version contains "-dev", if appropriate
|
|
61
|
+
|
|
62
|
+
const orgLib = getConfigDefaults();
|
|
63
|
+
const newVersion = version;
|
|
64
|
+
const existingOrgLib = orgLib.currentOrgLib;
|
|
65
|
+
const oldVersion = orgLib.buildVersion;
|
|
66
|
+
|
|
67
|
+
const switchToFileName = `${existingOrgLib}_${newVersion}.zip`;
|
|
68
|
+
|
|
69
|
+
console.log("");
|
|
70
|
+
|
|
71
|
+
const tasks = new Listr(
|
|
72
|
+
[
|
|
73
|
+
{
|
|
74
|
+
title: `Archive ${orgLib.displayLibVersion}`,
|
|
75
|
+
task: async () => {
|
|
76
|
+
await zipVersionAndArchive(existingOrgLib, oldVersion);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
title: `Restore ${existingOrgLib}/${newVersion}`,
|
|
81
|
+
task: async () => {
|
|
82
|
+
await restoreFromArchive(switchToFileName, existingOrgLib, newVersion);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
{ concurrent: false, exitOnError: true }
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
await tasks.run().catch(err => {
|
|
90
|
+
console.log(chalk.bold.red(err.toString()));
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
// const anotherTask = new Listr(
|
|
96
|
+
// [
|
|
97
|
+
// {
|
|
98
|
+
// title: `npm update (may take a few minutes)`,
|
|
99
|
+
// task: async () => {
|
|
100
|
+
// await runNpmUpdate();
|
|
101
|
+
// }
|
|
102
|
+
// }
|
|
103
|
+
// ],
|
|
104
|
+
// { concurrent: false, exitOnError: true }
|
|
105
|
+
// );
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
// archive existing
|
|
109
|
+
// await zipVersionAndArchive(existingOrgLib, oldVersion);
|
|
110
|
+
|
|
111
|
+
// restore from archive
|
|
112
|
+
//
|
|
113
|
+
|
|
114
|
+
console.log(`${chalk.bold.green(`\nSwitched to ${orgLib.currentOrgLib}/${newVersion}!\n`)}`);
|
|
115
|
+
|
|
116
|
+
if (getHaveDependencyDifference()) {
|
|
117
|
+
|
|
118
|
+
console.log('\n***************************************************************');
|
|
119
|
+
console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
|
|
120
|
+
console.log(`PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
|
|
121
|
+
console.log('****************************************************************\n');
|
|
122
|
+
|
|
123
|
+
// const upateQuestions = await getRunNpmQuestions();
|
|
124
|
+
// const answers = await inquirer.prompt(upateQuestions);
|
|
125
|
+
// const { updateNpm } = answers;
|
|
126
|
+
|
|
127
|
+
// if (updateNpm) {
|
|
128
|
+
// await anotherTask.run().catch(err => {
|
|
129
|
+
// console.log(chalk.bold.red(err.toString()));
|
|
130
|
+
// process.exit(1);
|
|
131
|
+
// });
|
|
132
|
+
// }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
addDebugLog("switchVersion", "END", "-");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
return true;
|
|
142
|
+
};
|