@pega/custom-dx-components 0.242.30 → 0.242.31
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 +6 -0
- package/src/tasks/export-archive/index.js +2 -16
- package/src/tasks/import-archive/index.js +3 -16
- package/src/tasks/index.js +1 -0
- package/src/tasks/init/template/package.json.mustache +2 -1
- package/src/tasks/init/template/tasks.config.json +1 -1
- package/src/tasks/set-perm/index.js +134 -0
- package/src/tasks/show-status/index.js +6 -1
- package/src/util.js +16 -4
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
revertWebPack,
|
|
33
33
|
promoteWebPack,
|
|
34
34
|
showStatus,
|
|
35
|
+
setPermanent,
|
|
35
36
|
storeComponents,
|
|
36
37
|
updateComponent,
|
|
37
38
|
validate,
|
|
@@ -62,6 +63,7 @@ const TASKS = {
|
|
|
62
63
|
LIST_LIB: 'listLibrary',
|
|
63
64
|
LIST_PUB: 'listPublished',
|
|
64
65
|
SHOW_STATUS: 'showStatus',
|
|
66
|
+
SET_PERM: 'setPermanent',
|
|
65
67
|
STORE: 'storeComponents',
|
|
66
68
|
VALIDATE_SCHEMA: 'validateSchema',
|
|
67
69
|
UPDATE: 'update',
|
|
@@ -188,6 +190,10 @@ export default async (args = []) => {
|
|
|
188
190
|
showStatus(options);
|
|
189
191
|
break;
|
|
190
192
|
}
|
|
193
|
+
case TASKS.SET_PERM: {
|
|
194
|
+
setPermanent(options);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
191
197
|
case TASKS.STORE: {
|
|
192
198
|
storeComponents(options);
|
|
193
199
|
break;
|
|
@@ -151,22 +151,12 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
|
|
|
151
151
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
export const convertPath = (filePath) => {
|
|
155
|
-
|
|
156
|
-
if (filePath.indexOf(":") > 0) {
|
|
157
|
-
const arFileData = filePath.split("\\");
|
|
158
|
-
filePath = join(arFileData);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return filePath;
|
|
162
|
-
}
|
|
163
154
|
|
|
164
155
|
export const getZipFileList = async(filePath) => {
|
|
165
156
|
|
|
166
|
-
|
|
167
|
-
if (fs.existsSync(zipFilePath)) {
|
|
157
|
+
if (fs.existsSync(filePath)) {
|
|
168
158
|
return fs
|
|
169
|
-
.readdirSync(
|
|
159
|
+
.readdirSync(filePath, { withFileTypes: true })
|
|
170
160
|
.filter(dirent => !dirent.isDirectory() && dirent.name.match(/.*\.(zip?)/ig))
|
|
171
161
|
.map(dirent => dirent.name);
|
|
172
162
|
}
|
|
@@ -191,7 +181,6 @@ export default async options => {
|
|
|
191
181
|
|
|
192
182
|
|
|
193
183
|
if (options.params.length >= 6) {
|
|
194
|
-
const filePath = convertPath(options.params[3]);
|
|
195
184
|
const libraryName = options.params[4];
|
|
196
185
|
const libraryVersion = options.params[5];
|
|
197
186
|
|
|
@@ -212,9 +201,6 @@ export default async options => {
|
|
|
212
201
|
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
213
202
|
const { filePath } = filePathAnswers;
|
|
214
203
|
|
|
215
|
-
const zipFilePath = convertPath(filePath);
|
|
216
|
-
|
|
217
|
-
|
|
218
204
|
await exportArch( zipFilePath, orgLibName, selectedVersion);
|
|
219
205
|
|
|
220
206
|
}
|
|
@@ -227,22 +227,13 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
227
227
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
export const convertPath = (filePath) => {
|
|
231
230
|
|
|
232
|
-
if (filePath.indexOf(":") > 0) {
|
|
233
|
-
const arFileData = filePath.split("\\");
|
|
234
|
-
filePath = join(arFileData);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return filePath;
|
|
238
|
-
}
|
|
239
231
|
|
|
240
232
|
export const getZipFileList = async(filePath) => {
|
|
241
233
|
|
|
242
|
-
|
|
243
|
-
if (fs.existsSync(zipFilePath)) {
|
|
234
|
+
if (fs.existsSync(filePath)) {
|
|
244
235
|
return fs
|
|
245
|
-
.readdirSync(
|
|
236
|
+
.readdirSync(filePath, { withFileTypes: true })
|
|
246
237
|
.filter(dirent => !dirent.isDirectory() && dirent.name.match(/.*\.(zip?)/ig))
|
|
247
238
|
.map(dirent => dirent.name);
|
|
248
239
|
}
|
|
@@ -267,10 +258,7 @@ export default async options => {
|
|
|
267
258
|
|
|
268
259
|
|
|
269
260
|
if (options.params.length >= 5) {
|
|
270
|
-
const filePath = convertPath(options.params[3]);
|
|
271
261
|
const fileName = options.params[4];
|
|
272
|
-
|
|
273
|
-
|
|
274
262
|
await importArch( filePath, fileName);
|
|
275
263
|
|
|
276
264
|
}
|
|
@@ -279,12 +267,11 @@ export default async options => {
|
|
|
279
267
|
const filePathQuestions = await getFilePathQuestions();
|
|
280
268
|
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
281
269
|
const { filePath } = filePathAnswers;
|
|
282
|
-
|
|
283
|
-
const zipFilePath = convertPath(filePath);
|
|
284
270
|
const zipFileList = await getZipFileList(filePath);
|
|
285
271
|
|
|
286
272
|
if (!zipFileList || zipFileList.length === 0) {
|
|
287
273
|
console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
|
|
274
|
+
process.exit();
|
|
288
275
|
}
|
|
289
276
|
|
|
290
277
|
const fileNameQuestions = await getFileNameQuestions(zipFileList);
|
package/src/tasks/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { default as listComponents } from './list/index.js';
|
|
|
22
22
|
export { default as listLibrary } from './list-lib/index.js';
|
|
23
23
|
export { default as listPublished } from './list-pub/index.js';
|
|
24
24
|
export { default as showStatus } from './show-status/index.js';
|
|
25
|
+
export { default as setPermanent } from './set-perm/index.js';
|
|
25
26
|
export { default as storeComponents } from './store/index.js';
|
|
26
27
|
export { default as importArchive } from './import-archive/index.js';
|
|
27
28
|
export { default as exportArchive } from './export-archive/index.js';
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"publishLibVersion": "custom-dx-components publish",
|
|
38
38
|
"storeLibVersion": "custom-dx-components storeComponents",
|
|
39
39
|
"showStatus": "custom-dx-components showStatus",
|
|
40
|
+
"setPermanent": "custom-dx-components setPermanent",
|
|
40
41
|
"moveLibVersion": "custom-dx-components moveComponent",
|
|
41
42
|
"importLibVersion": "custom-dx-components importArchive",
|
|
42
43
|
"exportLibVersion": "custom-dx-components exportArchive",
|
|
@@ -96,7 +97,7 @@
|
|
|
96
97
|
},
|
|
97
98
|
"devDependencies": {
|
|
98
99
|
"@pega/configs": "^0.6.0",
|
|
99
|
-
"@pega/custom-dx-components": "0.242.
|
|
100
|
+
"@pega/custom-dx-components": "0.242.31",
|
|
100
101
|
"@pega/pcore-pconnect-typedefs": "~3.0.0",
|
|
101
102
|
"@storybook/addon-actions": "^7.6.7",
|
|
102
103
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
showVersion,
|
|
9
|
+
getLibraryBased,
|
|
10
|
+
addDebugLog,
|
|
11
|
+
getComponents,
|
|
12
|
+
getConfigDefaults,
|
|
13
|
+
setConfigDevBuild,
|
|
14
|
+
updateConfigVersion,
|
|
15
|
+
checkLibraryAndArchives,
|
|
16
|
+
forceDefaultsUpdate } from '../../util.js';
|
|
17
|
+
import { showCurrentStatus } from '../show-status/index.js';
|
|
18
|
+
|
|
19
|
+
export const updateAllComponentsConfig = async( newVersion ) => {
|
|
20
|
+
addDebugLog("updateAllComponentsConfig", `newVersion: ${newVersion}`, "");
|
|
21
|
+
const componentList = await getComponents();
|
|
22
|
+
const orgLib = getConfigDefaults();
|
|
23
|
+
// const currentOrgLib = `${orgLib.organization}_${orgLib.library}`;
|
|
24
|
+
const currentOrgLib = orgLib.currentOrgLib;
|
|
25
|
+
|
|
26
|
+
for (const index in componentList) {
|
|
27
|
+
const componentKey = componentList[index];
|
|
28
|
+
await updateConfigVersion(componentKey, newVersion, currentOrgLib);
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export const setPermVersion = async (isPerm) => {
|
|
36
|
+
addDebugLog("setPermVersion", `isPerm: ${isPerm}`, "");
|
|
37
|
+
const configDefaults = await getConfigDefaults();
|
|
38
|
+
const devBuild = !isPerm;
|
|
39
|
+
|
|
40
|
+
let version = configDefaults.version;
|
|
41
|
+
if (devBuild) {
|
|
42
|
+
version = version.concat("-dev");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await updateAllComponentsConfig(version);
|
|
46
|
+
await setConfigDevBuild(devBuild);
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
export const setPermanent = async () => {
|
|
53
|
+
addDebugLog("setPermanent", "", "");
|
|
54
|
+
|
|
55
|
+
const configDefaults = await getConfigDefaults();
|
|
56
|
+
|
|
57
|
+
const isOrNot = configDefaults.devBuild ? "NOT PERMANENT" : "PERMANENT";
|
|
58
|
+
|
|
59
|
+
console.log(`Currently ${chalk.green(`${configDefaults.displayLibVersion}`)} is ${chalk.yellow(`${isOrNot}`)}.`);
|
|
60
|
+
|
|
61
|
+
if (configDefaults.devBuild) {
|
|
62
|
+
console.log(`You can switch ${chalk.green(`${configDefaults.displayLibVersion}`)} to be ${chalk.yellow('PERMANENT')}.`);
|
|
63
|
+
console.log(`\nNotes after change:`);
|
|
64
|
+
console.log(`\tUpon publish you will ${chalk.yellow('NOT')} be able to delete the published version from the server.`);
|
|
65
|
+
console.log(`\tYou CAN delete the local copies, etc. and you can revert local copies to NON permanent.\n`)
|
|
66
|
+
|
|
67
|
+
const makePermAnswer = await inquirer.prompt([
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
name: 'makePerm',
|
|
71
|
+
type: 'confirm',
|
|
72
|
+
message: `Make ${chalk.green(`${configDefaults.displayLibVersion}`)} ${chalk.yellow('PERMANENT')} ?`,
|
|
73
|
+
default: false
|
|
74
|
+
}
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
if (makePermAnswer.makePerm) {
|
|
78
|
+
await setPermVersion(makePermAnswer.makePerm);
|
|
79
|
+
await forceDefaultsUpdate();
|
|
80
|
+
await showCurrentStatus();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.log(chalk.green("No changes made."));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.log(`\nYou can switch ${chalk.green(`${configDefaults.displayLibVersion}`)} to be ${chalk.yellow('NON PERMANENT')}.`);
|
|
89
|
+
console.log(`\nNotes after change:`);
|
|
90
|
+
console.log(`\tIf ${chalk.green(`${configDefaults.displayLibVersion}`)} has been published, it can not deleted.`);
|
|
91
|
+
console.log(`\tIf not published, then a future publish can be deleted.\n`);
|
|
92
|
+
|
|
93
|
+
const makeNonPermAnswer = await inquirer.prompt([
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
name: 'makeNonPerm',
|
|
97
|
+
type: 'confirm',
|
|
98
|
+
message: `Make this library/version ${chalk.yellow('NON PERMANENT')} ?`,
|
|
99
|
+
default: true
|
|
100
|
+
}
|
|
101
|
+
]);
|
|
102
|
+
|
|
103
|
+
if (makeNonPermAnswer.makeNonPerm) {
|
|
104
|
+
await setPermVersion(!makeNonPermAnswer.makeNonPerm);
|
|
105
|
+
|
|
106
|
+
await forceDefaultsUpdate();
|
|
107
|
+
await showCurrentStatus();
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.log(chalk.green("No changes made."));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
export default async options => {
|
|
119
|
+
const isLibraryBased = getLibraryBased();
|
|
120
|
+
if (!isLibraryBased) {
|
|
121
|
+
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`);
|
|
122
|
+
process.exit();
|
|
123
|
+
}
|
|
124
|
+
addDebugLog("setPerm", "", "+");
|
|
125
|
+
|
|
126
|
+
await showVersion();
|
|
127
|
+
await checkLibraryAndArchives();
|
|
128
|
+
// await showCurrentStatus();
|
|
129
|
+
await setPermanent();
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
addDebugLog("setPerm", "END", "-");
|
|
133
|
+
|
|
134
|
+
}
|
|
@@ -16,7 +16,12 @@ export const showCurrentStatus = async () => {
|
|
|
16
16
|
console.log(`\tOrganization:\t ${chalk.bold.green(`${configDefaults.organization}`)}`);
|
|
17
17
|
console.log(`\tLibrary:\t ${chalk.bold.green(`${configDefaults.library}`)}`);
|
|
18
18
|
console.log(`\tVersion:\t ${chalk.bold.green(`${configDefaults.buildVersion}`)}`);
|
|
19
|
-
|
|
19
|
+
if (!configDefaults.devBuild) {
|
|
20
|
+
console.log(`\tPermanent:\t ${chalk.bold.magentaBright(`${!configDefaults.devBuild}`)}`);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.log(`\tPermanent:\t ${chalk.bold.green(`${!configDefaults.devBuild}`)}`);
|
|
24
|
+
}
|
|
20
25
|
console.log(`\tComponent count: ${chalk.bold.green(`${componentList.length}`)}`);
|
|
21
26
|
|
|
22
27
|
console.log("");
|
package/src/util.js
CHANGED
|
@@ -122,6 +122,7 @@ export const setUpDefaults = async () => {
|
|
|
122
122
|
retrievedConfigData.library = data.component.library;
|
|
123
123
|
retrievedConfigData.version = data.component.version;
|
|
124
124
|
|
|
125
|
+
|
|
125
126
|
const { organization } = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
126
127
|
retrievedConfigData.organization = organization;
|
|
127
128
|
|
|
@@ -131,6 +132,7 @@ export const setUpDefaults = async () => {
|
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
retrievedConfigData.serverType = data["server-config"].serverType;
|
|
135
|
+
retrievedConfigData.devBuild = data["server-config"].devBuild;
|
|
134
136
|
|
|
135
137
|
retrievedConfigData.buildVersion = retrievedConfigData.devBuild ? `${retrievedConfigData.version}-dev` : retrievedConfigData.version;
|
|
136
138
|
retrievedConfigData.currentOrgLib = `${retrievedConfigData.organization}_${retrievedConfigData.library}`;
|
|
@@ -1538,10 +1540,20 @@ export const restoreFromArchive = async (fileName, orgLibName, version) => {
|
|
|
1538
1540
|
}
|
|
1539
1541
|
|
|
1540
1542
|
// copy temp src/components
|
|
1541
|
-
fs.
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1543
|
+
if (fs.existsSync(tempDirectoryComponents)) {
|
|
1544
|
+
fs.cpSync(tempDirectoryComponents, currentComponentsPath, { recursive: true, force: true });
|
|
1545
|
+
}
|
|
1546
|
+
else {
|
|
1547
|
+
// nothing was archived (no src/components)
|
|
1548
|
+
// so make a src/components if doesn't exist
|
|
1549
|
+
if (!fs.existsSync(currentComponentsPath)) {
|
|
1550
|
+
fs.mkdirSync(currentComponentsPath, { "recursive" : true});
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
|
|
1555
|
+
// remove temp (windows not working well with "sync", can be async, since as long as deleted, fine)
|
|
1556
|
+
fs.rm(tempDirectory, { recursive: true, force: true, maxRetries: 5 }, () => {});
|
|
1545
1557
|
|
|
1546
1558
|
};
|
|
1547
1559
|
|