@pega/custom-dx-components 0.242.33 → 0.242.35
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 -2
- package/src/cli.js +12 -0
- package/src/tasks/create-lib/index.js +0 -1
- package/src/tasks/create-version/index.js +10 -1
- package/src/tasks/delete-lib/index.js +5 -5
- package/src/tasks/import-archive/index.js +34 -8
- package/src/tasks/import-comp/helper.js +49 -0
- package/src/tasks/import-comp/index.js +321 -0
- package/src/tasks/index.js +2 -0
- package/src/tasks/init/template/package.json.mustache +4 -2
- package/src/tasks/list-lib/index.js +22 -15
- package/src/tasks/move/index.js +13 -41
- package/src/tasks/show-help/index.js +130 -0
- package/src/tasks/switch-version/index.js +9 -1
- package/src/util.js +34 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/custom-dx-components",
|
|
3
|
-
"version": "0.242.
|
|
3
|
+
"version": "0.242.35",
|
|
4
4
|
"description": "Utility for building custom UI components",
|
|
5
5
|
"bin": "./bin/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/plugin-transform-class-properties": "^7.23.3",
|
|
20
20
|
"@babel/preset-react": "^7.23.3",
|
|
21
21
|
"@pega/auth": "^0.1.6",
|
|
22
|
-
"@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.
|
|
22
|
+
"@pega/constellation-dx-components-build-utils": "^1.0.1-dev-0.17",
|
|
23
23
|
"ajv": "^8.12.0",
|
|
24
24
|
"ajv-keywords": "^5.1.0",
|
|
25
25
|
"archiver": "^7.0.1",
|
package/src/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
deleteVersion,
|
|
20
20
|
importArchive,
|
|
21
21
|
exportArchive,
|
|
22
|
+
importComponent,
|
|
22
23
|
initProject,
|
|
23
24
|
listComponents,
|
|
24
25
|
listLibrary,
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
revertWebPack,
|
|
33
34
|
promoteWebPack,
|
|
34
35
|
showStatus,
|
|
36
|
+
showHelp,
|
|
35
37
|
setPermanent,
|
|
36
38
|
storeComponents,
|
|
37
39
|
updateComponent,
|
|
@@ -63,6 +65,7 @@ const TASKS = {
|
|
|
63
65
|
LIST_LIB: 'listLibrary',
|
|
64
66
|
LIST_PUB: 'listPublished',
|
|
65
67
|
SHOW_STATUS: 'showStatus',
|
|
68
|
+
SHOW_HELP: 'showHelp',
|
|
66
69
|
SET_PERM: 'setPermanent',
|
|
67
70
|
STORE: 'storeComponents',
|
|
68
71
|
VALIDATE_SCHEMA: 'validateSchema',
|
|
@@ -74,6 +77,7 @@ const TASKS = {
|
|
|
74
77
|
DELETE_VERSION: 'deleteVersion',
|
|
75
78
|
IMPORT_ARCHIVE: 'importArchive',
|
|
76
79
|
EXPORT_ARCHIVE: 'exportArchive',
|
|
80
|
+
IMPORT_COMP: 'importComponent',
|
|
77
81
|
AUTHENTICATE: 'authenticate',
|
|
78
82
|
UPGRADE: 'upgrade',
|
|
79
83
|
BUILD_JEST_ASSETS: 'buildJestAssets'
|
|
@@ -190,6 +194,10 @@ export default async (args = []) => {
|
|
|
190
194
|
showStatus(options);
|
|
191
195
|
break;
|
|
192
196
|
}
|
|
197
|
+
case TASKS.SHOW_HELP: {
|
|
198
|
+
showHelp(options);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
193
201
|
case TASKS.SET_PERM: {
|
|
194
202
|
setPermanent(options);
|
|
195
203
|
break;
|
|
@@ -206,6 +214,10 @@ export default async (args = []) => {
|
|
|
206
214
|
exportArchive(options);
|
|
207
215
|
break;
|
|
208
216
|
}
|
|
217
|
+
case TASKS.IMPORT_COMP: {
|
|
218
|
+
importComponent(options);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
209
221
|
case TASKS.VALIDATE_SCHEMA: {
|
|
210
222
|
validate(options);
|
|
211
223
|
break;
|
|
@@ -67,7 +67,6 @@ addDebugLog("createLibrary", "", "+");
|
|
|
67
67
|
// store it before clearing out /src/components
|
|
68
68
|
|
|
69
69
|
if (hasArch) {
|
|
70
|
-
|
|
71
70
|
const hasLib = await hasLibraryAndVersion(libraryName, version, !permBuild);
|
|
72
71
|
if (hasLib) {
|
|
73
72
|
console.log(`${chalk.bold.red(`Library ${orgLib.organization}_${libraryName} already exists.`)}`);
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
setConfigDevBuild,
|
|
16
16
|
checkLibraryAndArchives,
|
|
17
17
|
getConfigDefaults,
|
|
18
|
-
forceDefaultsUpdate
|
|
18
|
+
forceDefaultsUpdate,
|
|
19
|
+
modAddAboutData
|
|
19
20
|
} from '../../util.js';
|
|
20
21
|
|
|
21
22
|
import { getCreateVersionComponentQuestions, updateAllComponentsConfig } from './helper.js';
|
|
@@ -47,6 +48,14 @@ addDebugLog("createVersion", "", "+");
|
|
|
47
48
|
version = options.params[3];
|
|
48
49
|
const dPerm = options.params[4];
|
|
49
50
|
const copyExist = options.params[5]
|
|
51
|
+
|
|
52
|
+
// if have [6] will be "NoAbout" from Jest, to turn off build date
|
|
53
|
+
if (options.params.length >= 7 ) {
|
|
54
|
+
if (options.params[6] === "NoAbout") {
|
|
55
|
+
modAddAboutData(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
permBuild = !!(dPerm === 'Y' || dPerm === 'y' || dPerm === true || dPerm === 'true');
|
|
51
60
|
copyExisting = !!(copyExist === 'Y' || copyExist === 'y' || copyExist === true || copyExist === 'true');
|
|
52
61
|
|
|
@@ -35,12 +35,12 @@ addDebugLog("deleteLibraryVersion", "", "+");
|
|
|
35
35
|
process.exit();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
catch (ex) {}
|
|
38
|
+
try {
|
|
39
|
+
libVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
40
|
+
}
|
|
41
|
+
catch (ex) {}
|
|
43
42
|
|
|
43
|
+
if (version === "") {
|
|
44
44
|
|
|
45
45
|
if (libVersions.length > 0) {
|
|
46
46
|
// ALL option
|
|
@@ -148,6 +148,27 @@ addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKe
|
|
|
148
148
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
+
export const getPackgeOrg = async(packagePath) => {
|
|
152
|
+
const sPackData = fs.readFileSync(packagePath, { encoding: 'utf8' });
|
|
153
|
+
const packData = sPackData && JSON.parse(sPackData);
|
|
154
|
+
|
|
155
|
+
return packData.organization;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const getLocalConfigData = async(tasksPath) => {
|
|
159
|
+
let configData = { library: "", version: "", buildVersion: "", devBuild: false};
|
|
160
|
+
const sTaskData = fs.readFileSync(tasksPath, { encoding: 'utf8' });
|
|
161
|
+
const taskData = sTaskData && JSON.parse(sTaskData);
|
|
162
|
+
|
|
163
|
+
const devBuild = taskData["server-config"].devBuild;
|
|
164
|
+
configData.library = taskData["component"].library;
|
|
165
|
+
configData.version = taskData["component"].version;
|
|
166
|
+
configData.devBuild = devBuild;
|
|
167
|
+
|
|
168
|
+
configData.buildVersion = devBuild ? configData.version.concat("-dev") : configData.version;
|
|
169
|
+
|
|
170
|
+
return configData;
|
|
171
|
+
}
|
|
151
172
|
|
|
152
173
|
export const moveComp = async(componentKey, orgLibName, version, copyShared, options) => {
|
|
153
174
|
|
|
@@ -203,7 +224,9 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
203
224
|
|
|
204
225
|
// check to see if have a tasks.config.json file, if not, archive not good
|
|
205
226
|
const tempTasksConfig = join(tempDirectory, "tasks.config.json");
|
|
206
|
-
|
|
227
|
+
const tempPackage = join(tempDirectory, "package.json");
|
|
228
|
+
|
|
229
|
+
if (!fs.existsSync(tempTasksConfig) || !fs.existsSync(tempPackage)) {
|
|
207
230
|
console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
|
|
208
231
|
console.log(chalk.red.bold("Cleaning up..."));
|
|
209
232
|
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
|
|
@@ -212,20 +235,23 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
212
235
|
|
|
213
236
|
}
|
|
214
237
|
|
|
238
|
+
// need to get info from tasks.config and package.json
|
|
239
|
+
// we won't rely on name of file, as owner can change it
|
|
240
|
+
|
|
241
|
+
let organization = await getPackgeOrg(tempPackage);
|
|
242
|
+
let localConfig = await getLocalConfigData(tempTasksConfig);
|
|
215
243
|
|
|
244
|
+
let orgLibName = `${organization}_${localConfig.library}`;
|
|
245
|
+
const version = localConfig.buildVersion;
|
|
246
|
+
const devBuild = localConfig.devBuild;
|
|
216
247
|
|
|
217
|
-
const arFileData = fileName.split("_");
|
|
218
|
-
let orgLibName = `${arFileData[0]}_${arFileData[1]}`;
|
|
219
|
-
let libName = arFileData[1];
|
|
220
|
-
const version = arFileData[2].replace(".zip", "");
|
|
221
|
-
const devBuild = version.indexOf("-dev") > 0 ? true : false;
|
|
222
248
|
const configDef = getConfigDefaults();
|
|
223
249
|
|
|
224
|
-
if (
|
|
250
|
+
if (organization !== configDef.organization) {
|
|
225
251
|
console.log(`\nImported ${chalk.yellow(`${orgLibName}/${version}`)} is not the same organization as your current organization: ${chalk.yellow(`${configDef.organization}`)}.`);
|
|
226
252
|
console.log(`\nTo import, the organization of the components will be changed to match your organization.`);
|
|
227
253
|
console.log(`\n\t>>> If you don't want this to happen, then end and create a new project with an organization`);
|
|
228
|
-
console.log(`\t of ${chalk.yellow(`${
|
|
254
|
+
console.log(`\t of ${chalk.yellow(`${organization}`)} and import there.\n`);
|
|
229
255
|
|
|
230
256
|
const proceedAnswers = await inquirer.prompt([
|
|
231
257
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { Listr } from 'listr2';
|
|
6
|
+
import { addDebugLog, getConfigDefaults, convertIntoPascalCase, getComponents, getComponentDirectoryPath, getDirectoryFiles } from '../../util.js';
|
|
7
|
+
import { TASKS_CONFIG_JSON_FILENAME, TEMP_PATH, PACKAGE_JSON_FILENAME } from '../../constants.js';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const getFilePathQuestions = async () => {
|
|
11
|
+
addDebugLog("getFilePathQuestions", "", "");
|
|
12
|
+
|
|
13
|
+
console.log("\nFile path examples:");
|
|
14
|
+
if (path.sep === "/") {
|
|
15
|
+
console.log("\tMac OS/Unix:\t/Users/name/...\n");
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log("\tWindows:\tC:\\Users\\name\\...\n");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const currentDirectory = process.cwd();
|
|
22
|
+
const arPathParts = currentDirectory.split(path.sep);
|
|
23
|
+
let defaultPath = join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
|
|
24
|
+
if (path.sep === "/") {
|
|
25
|
+
defaultPath = "/".concat(defaultPath);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
name: 'filePath',
|
|
32
|
+
message: 'Enter full file path of zip file location:',
|
|
33
|
+
default: defaultPath
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getFileNameQuestions = async (zipFileList) => {
|
|
39
|
+
addDebugLog("getFileNameQuestions", "", "");
|
|
40
|
+
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
name: 'fileName',
|
|
44
|
+
type: 'rawlist',
|
|
45
|
+
message: `Select zip file`,
|
|
46
|
+
choices: zipFileList
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
};
|
|
@@ -0,0 +1,321 @@
|
|
|
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
|
+
import Choice from 'inquirer/lib/objects/choice.js';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const copy = promisify(ncp);
|
|
34
|
+
|
|
35
|
+
let gFilePath = "";
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export const updateConfig = async (
|
|
39
|
+
{
|
|
40
|
+
oldComponentKey,
|
|
41
|
+
newComponentKey,
|
|
42
|
+
library,
|
|
43
|
+
version,
|
|
44
|
+
targetDirectory,
|
|
45
|
+
newLabel = "",
|
|
46
|
+
},
|
|
47
|
+
options,
|
|
48
|
+
onlyCompanion = false
|
|
49
|
+
) => {
|
|
50
|
+
|
|
51
|
+
addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
|
|
52
|
+
|
|
53
|
+
let configData = fs.readFileSync(join(targetDirectory, "/config.json"), { encoding: 'utf8' });
|
|
54
|
+
configData = configData && JSON.parse(configData);
|
|
55
|
+
|
|
56
|
+
configData.name = newComponentKey;
|
|
57
|
+
if (configData.componentKey) configData.componentKey = newComponentKey;
|
|
58
|
+
configData.library = library;
|
|
59
|
+
configData.version = version;
|
|
60
|
+
|
|
61
|
+
if (newLabel != "") {
|
|
62
|
+
configData.label = newLabel;
|
|
63
|
+
configData.description = newLabel;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
67
|
+
fs.writeFileSync(join(targetDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
|
|
68
|
+
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const updateFile = async (
|
|
72
|
+
fileName,
|
|
73
|
+
oldComponentKeyPC,
|
|
74
|
+
newComponentKeyPC,
|
|
75
|
+
targetDirectory,
|
|
76
|
+
) => {
|
|
77
|
+
|
|
78
|
+
addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, targetDirectory: ${targetDirectory}`, "");
|
|
79
|
+
|
|
80
|
+
let fileData = fs.readFileSync(join(targetDirectory, "/", fileName), { encoding: 'utf8' });
|
|
81
|
+
|
|
82
|
+
if (fileData.indexOf(oldComponentKeyPC) >= 0) {
|
|
83
|
+
fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
|
|
84
|
+
|
|
85
|
+
fs.writeFileSync(join(targetDirectory, "/", fileName), fileData, { encoding: 'utf8' });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
// rename the component
|
|
92
|
+
export const renameComponent = async (
|
|
93
|
+
componentKey,
|
|
94
|
+
library,
|
|
95
|
+
version,
|
|
96
|
+
newName = "",
|
|
97
|
+
newLabel = "",
|
|
98
|
+
options
|
|
99
|
+
) => {
|
|
100
|
+
|
|
101
|
+
addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
|
|
102
|
+
|
|
103
|
+
const componentName = newName != "" ? newName : componentKey.split("_")[2];
|
|
104
|
+
const newComponentKey = `${library}_${componentName}`;
|
|
105
|
+
const oldComponentKey = componentKey;
|
|
106
|
+
const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
|
|
107
|
+
const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
|
|
108
|
+
|
|
109
|
+
const currentDirectory = await getComponentDirectoryPath(componentKey);
|
|
110
|
+
const targetDirectory = await getComponentDirectoryPath(newComponentKey);
|
|
111
|
+
|
|
112
|
+
// custom component
|
|
113
|
+
try {
|
|
114
|
+
fs.renameSync(currentDirectory, targetDirectory);
|
|
115
|
+
} catch(err) {
|
|
116
|
+
console.log(err)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const targetFileList = await getDirectoryFiles(targetDirectory);
|
|
120
|
+
|
|
121
|
+
for (var fileIndex in targetFileList) {
|
|
122
|
+
const fileName = targetFileList[fileIndex];
|
|
123
|
+
|
|
124
|
+
if (fileName === "config.json") {
|
|
125
|
+
await updateConfig(
|
|
126
|
+
{
|
|
127
|
+
oldComponentKey,
|
|
128
|
+
newComponentKey,
|
|
129
|
+
componentName,
|
|
130
|
+
library,
|
|
131
|
+
version,
|
|
132
|
+
targetDirectory,
|
|
133
|
+
newLabel
|
|
134
|
+
},
|
|
135
|
+
options
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
await updateFile(
|
|
140
|
+
fileName,
|
|
141
|
+
oldComponentKeyPC,
|
|
142
|
+
newComponentKeyPC,
|
|
143
|
+
targetDirectory );
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
} // for
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
return newComponentKey;
|
|
151
|
+
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
export const importComp = async(filePath, fileName) => {
|
|
156
|
+
addDebugLog("importComp", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
157
|
+
|
|
158
|
+
const currentDirectory = process.cwd();
|
|
159
|
+
const compDirectory = join(currentDirectory, "src", "components");
|
|
160
|
+
const copyFilePath = join(filePath, fileName);
|
|
161
|
+
|
|
162
|
+
const configDef = getConfigDefaults();
|
|
163
|
+
const copyDir = join(compDirectory, fileName);
|
|
164
|
+
|
|
165
|
+
if (fs.existsSync(copyFilePath)) {
|
|
166
|
+
fs.cpSync(copyFilePath, copyDir, { recursive: true, force: true });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let configData = fs.readFileSync(join(copyDir, "/config.json"), { encoding: 'utf8' });
|
|
170
|
+
configData = configData && JSON.parse(configData);
|
|
171
|
+
|
|
172
|
+
const compName = configData.componentKey.split("_")[2];
|
|
173
|
+
const potentialCompKey = `${configDef.currentOrgLib}_${compName}`;
|
|
174
|
+
const currentCompList = await getComponents();
|
|
175
|
+
let newName = "";
|
|
176
|
+
let newLabel = "";
|
|
177
|
+
|
|
178
|
+
if (currentCompList && currentCompList.includes(potentialCompKey)) {
|
|
179
|
+
console.log(`\nComponent ${chalk.yellow(`${potentialCompKey}`)} already exists.`);
|
|
180
|
+
const proceedAnswers = await inquirer.prompt([
|
|
181
|
+
|
|
182
|
+
{
|
|
183
|
+
name: 'proceedAs',
|
|
184
|
+
type: 'rawlist',
|
|
185
|
+
message: `Proceed as ?`,
|
|
186
|
+
default: 'No import',
|
|
187
|
+
choices: ['No import', 'Overwrite', 'New name']
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: 'componentName',
|
|
191
|
+
message: 'Enter component name (required)',
|
|
192
|
+
when(answers) {
|
|
193
|
+
return answers.proceedAs === 'New name';
|
|
194
|
+
},
|
|
195
|
+
validate: value => {
|
|
196
|
+
/* value should not be empty
|
|
197
|
+
It should not have spaces
|
|
198
|
+
It should not start with a number
|
|
199
|
+
Only case-insensitive alphanumeric values are allowed
|
|
200
|
+
*/
|
|
201
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: 'componentLabel',
|
|
209
|
+
message: 'Enter component label for display (required)',
|
|
210
|
+
when(answers) {
|
|
211
|
+
return answers.proceedAs === 'New name';
|
|
212
|
+
},
|
|
213
|
+
validate: value => {
|
|
214
|
+
if (value) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
return 'Please provide value for label';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
]);
|
|
221
|
+
|
|
222
|
+
switch (proceedAnswers.proceedAs) {
|
|
223
|
+
case 'No import':
|
|
224
|
+
// removed copied
|
|
225
|
+
fs.rmSync(copyDir, { recursive: true, force: true, maxRetries: 2 });
|
|
226
|
+
process.exit();
|
|
227
|
+
break;
|
|
228
|
+
case 'Overwrite':
|
|
229
|
+
// remove existing
|
|
230
|
+
const exitingComp = join(compDirectory, potentialCompKey);
|
|
231
|
+
fs.rmSync(exitingComp, { recursive: true, force: true, maxRetries: 2 });
|
|
232
|
+
break;
|
|
233
|
+
case 'New name':
|
|
234
|
+
newName = proceedAnswers.componentName;
|
|
235
|
+
newLabel = proceedAnswers.componentLabel;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const newCompKey = await renameComponent(configData.componentKey, configDef.currentOrgLib, configDef.buildVersion, newName, newLabel, null);
|
|
242
|
+
console.log(`\n${chalk.green(`${fileName}`)} has been imported as ${chalk.green(`${newCompKey}`)}`);
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
export const getFolderList = async (filePath) => {
|
|
249
|
+
addDebugLog("getFolderList", `filePath: ${filePath}`, "");
|
|
250
|
+
if (fs.existsSync(filePath)) {
|
|
251
|
+
return fs
|
|
252
|
+
.readdirSync(filePath, { withFileTypes: true })
|
|
253
|
+
.filter(dirent => dirent.isDirectory())
|
|
254
|
+
.map(dirent => dirent.name);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
console.log(chalk.red.bold(`File path: ${filePath} does not exist or no permissions.`));
|
|
258
|
+
process.exit(1);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export const hasConfig = (dir) => {
|
|
263
|
+
const configPath = join(gFilePath, dir, "config.json");
|
|
264
|
+
if (fs.existsSync(configPath)) {
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export const getComponentList = async(filePath) => {
|
|
272
|
+
addDebugLog("getComponentList", `filePath: ${filePath}`, "");
|
|
273
|
+
let compList = await getFolderList(filePath);
|
|
274
|
+
|
|
275
|
+
gFilePath = filePath;
|
|
276
|
+
|
|
277
|
+
if (compList.length > 0) {
|
|
278
|
+
return compList.filter(hasConfig);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return compList;
|
|
282
|
+
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export default async options => {
|
|
286
|
+
await showVersion();
|
|
287
|
+
await checkLibraryAndArchives();
|
|
288
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
289
|
+
|
|
290
|
+
addDebugLog("importComponent", "", "+");
|
|
291
|
+
|
|
292
|
+
if (options.params.length >= 5) {
|
|
293
|
+
const filePath = options.param[3];
|
|
294
|
+
const fileName = options.params[4];
|
|
295
|
+
await importComp( filePath, fileName);
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
|
|
300
|
+
const filePathQuestions = await getFilePathQuestions();
|
|
301
|
+
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
302
|
+
const { filePath } = filePathAnswers;
|
|
303
|
+
|
|
304
|
+
const compFileList = await getComponentList(filePath);
|
|
305
|
+
|
|
306
|
+
if (!compFileList || compFileList.length === 0) {
|
|
307
|
+
console.log(chalk.red.bold(`No component files exist at path: ${filePath}`));
|
|
308
|
+
process.exit();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const fileNameQuestions = await getFileNameQuestions(compFileList);
|
|
312
|
+
const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
|
|
313
|
+
const {fileName} = fileNameAnswers;
|
|
314
|
+
|
|
315
|
+
await importComp( filePath, fileName);
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
addDebugLog("importComponent", "END", "-");
|
|
320
|
+
|
|
321
|
+
};
|
package/src/tasks/index.js
CHANGED
|
@@ -22,10 +22,12 @@ 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 showHelp } from './show-help/index.js';
|
|
25
26
|
export { default as setPermanent } from './set-perm/index.js';
|
|
26
27
|
export { default as storeComponents } from './store/index.js';
|
|
27
28
|
export { default as importArchive } from './import-archive/index.js';
|
|
28
29
|
export { default as exportArchive } from './export-archive/index.js';
|
|
30
|
+
export { default as importComponent } from './import-comp/index.js';
|
|
29
31
|
export { default as updateComponent } from './update/index.js';
|
|
30
32
|
export { default as validate } from './validator/index.js';
|
|
31
33
|
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",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"exportLibVersion": "custom-dx-components exportArchive",
|
|
44
45
|
"validate": "custom-dx-components buildComponent",
|
|
45
46
|
"validateAll": "custom-dx-components buildAllComponents",
|
|
47
|
+
"help": "custom-dx-components showHelp",
|
|
46
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",
|
|
47
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 ",
|
|
48
50
|
"_internal-test-full": "npm run _internal-test-functional && npm run _internal-test-unit",
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
},
|
|
98
100
|
"devDependencies": {
|
|
99
101
|
"@pega/configs": "^0.6.0",
|
|
100
|
-
"@pega/custom-dx-components": "0.242.
|
|
102
|
+
"@pega/custom-dx-components": "0.242.35",
|
|
101
103
|
"@pega/pcore-pconnect-typedefs": "~3.0.0",
|
|
102
104
|
"@storybook/addon-actions": "^7.6.7",
|
|
103
105
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -16,7 +16,6 @@ export default async (options) => {
|
|
|
16
16
|
await checkLibraryAndArchives();
|
|
17
17
|
addDebugLog("listLibrary", "", "+");
|
|
18
18
|
|
|
19
|
-
let sourceOfLibrary;
|
|
20
19
|
let organization;
|
|
21
20
|
let library;
|
|
22
21
|
|
|
@@ -29,24 +28,28 @@ addDebugLog("listLibrary", "", "+");
|
|
|
29
28
|
let libVersions = [];
|
|
30
29
|
|
|
31
30
|
if (options.params.length >= 5) {
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
libraryName = options.params[3];
|
|
32
|
+
selectedVersion = options.params[4];
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
try {
|
|
35
|
+
libVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
36
|
+
}
|
|
37
|
+
catch (ex) {}
|
|
36
38
|
|
|
37
39
|
}
|
|
40
|
+
else {
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const questions = await getArchiveLibraryQuestions();
|
|
43
|
+
const answers = await inquirer.prompt(questions);
|
|
44
|
+
({ libraryName } = answers);
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
try {
|
|
47
|
+
libVersions = await getLibraryArchivesVersions(libraryName, "");
|
|
48
|
+
}
|
|
49
|
+
catch (ex) {}
|
|
47
50
|
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
if (libVersions.length > 0) {
|
|
50
53
|
|
|
51
54
|
if (selectedVersion === undefined) {
|
|
52
55
|
const libAnswers = await inquirer.prompt([
|
|
@@ -61,10 +64,14 @@ addDebugLog("listLibrary", "", "+");
|
|
|
61
64
|
|
|
62
65
|
selectedVersion = libAnswers.libVersion;
|
|
63
66
|
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let data;
|
|
71
|
+
// get built on from first component if exists
|
|
72
|
+
let builtOn = "(date unavailable)";
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
// get built on from first component if exists
|
|
67
|
-
let builtOn = "(date unavailable)";
|
|
74
|
+
if (libVersions.length > 0) {
|
|
68
75
|
|
|
69
76
|
if (libraryName === compDef.currentOrgLib && selectedVersion === compDef.buildVersion) {
|
|
70
77
|
|
package/src/tasks/move/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
getLibraryArchivesVersions,
|
|
21
21
|
getLibraryArchiveDirectories
|
|
22
22
|
} from '../../util.js';
|
|
23
|
-
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH,
|
|
23
|
+
import { TASKS_CONFIG_JSON_FILENAME, COMPONENTS_DIRECTORY_PATH, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
|
|
24
24
|
import { getComponentKeyQuestion, getLibraryQuestions, getLibraryVersionQuestion } from './helper.js';
|
|
25
25
|
|
|
26
26
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
@@ -96,26 +96,21 @@ export const renameComponent = async (
|
|
|
96
96
|
|
|
97
97
|
addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
|
|
98
98
|
|
|
99
|
-
|
|
100
99
|
const componentName = componentKey.split("_")[2];
|
|
101
|
-
|
|
102
|
-
const configDef = getConfigDefaults();
|
|
103
|
-
|
|
104
100
|
const newComponentKey = `${library}_${componentName}`;
|
|
105
|
-
|
|
106
101
|
const oldComponentKey = componentKey;
|
|
107
102
|
const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
|
|
108
103
|
const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
|
|
109
104
|
|
|
110
|
-
const currentDirectory =
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
const currentDirectory = process.cwd();
|
|
106
|
+
const tempDirectory = join(currentDirectory, TEMP_PATH, "src", "components");
|
|
107
|
+
const existingDirectory = await getComponentDirectoryPath(componentKey);
|
|
108
|
+
const targetDirectory = await getComponentDirectoryPath(newComponentKey, tempDirectory);
|
|
114
109
|
|
|
115
110
|
if (copyMove === "Move") {
|
|
116
111
|
// custom component
|
|
117
112
|
try {
|
|
118
|
-
fs.renameSync(
|
|
113
|
+
fs.renameSync(existingDirectory, targetDirectory);
|
|
119
114
|
} catch(err) {
|
|
120
115
|
console.log(err)
|
|
121
116
|
}
|
|
@@ -124,15 +119,12 @@ addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKe
|
|
|
124
119
|
// copy
|
|
125
120
|
// custom component
|
|
126
121
|
try {
|
|
127
|
-
fs.cpSync(
|
|
122
|
+
fs.cpSync(existingDirectory, targetDirectory, { recursive: true});
|
|
128
123
|
} catch(err) {
|
|
129
124
|
console.log(err)
|
|
130
125
|
}
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
128
|
const targetFileList = await getDirectoryFiles(targetDirectory);
|
|
137
129
|
|
|
138
130
|
for (var fileIndex in targetFileList) {
|
|
@@ -214,18 +206,9 @@ export const moveComp = async(componentKey, copyMove, orgLibName, version, copyS
|
|
|
214
206
|
// delete temp directory
|
|
215
207
|
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
|
|
216
208
|
|
|
217
|
-
|
|
218
|
-
|
|
219
209
|
}
|
|
220
210
|
else {
|
|
221
211
|
|
|
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
212
|
const newComponentKey = await localMoveCopyComp(componentKey, orgLibName, version, copyMove, currentDirectory, tempDirectory);
|
|
230
213
|
|
|
231
214
|
if (newComponentKey) {
|
|
@@ -237,7 +220,6 @@ export const moveComp = async(componentKey, copyMove, orgLibName, version, copyS
|
|
|
237
220
|
fs.cpSync(currentSharedPath, targetSharedPatah, { recursive: true, force: true });
|
|
238
221
|
}
|
|
239
222
|
|
|
240
|
-
|
|
241
223
|
console.log(`\n${copiedOrMoved} ${chalk.green(`${componentKey}`)} to ${chalk.green(`${orgLibName}/${version}`)} as ${chalk.green(`${newComponentKey}`)}\n`);
|
|
242
224
|
|
|
243
225
|
// rearchive temp directory
|
|
@@ -247,7 +229,6 @@ export const moveComp = async(componentKey, copyMove, orgLibName, version, copyS
|
|
|
247
229
|
console.log(chalk.yellow(`No components were ${copiedOrMoved}`));
|
|
248
230
|
}
|
|
249
231
|
|
|
250
|
-
|
|
251
232
|
// delete temp directory
|
|
252
233
|
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
|
|
253
234
|
}
|
|
@@ -276,24 +257,15 @@ export const localMoveCopyComp = async(componentKey, orgLibName, version, copyMo
|
|
|
276
257
|
if (!answers.confirmOverride) {
|
|
277
258
|
return null;
|
|
278
259
|
}
|
|
260
|
+
else {
|
|
261
|
+
// delete the one in the temp directory, so can move/copy latest
|
|
262
|
+
fs.rmSync(tempDirComp, { recursive: true, force: true, maxRetries: 2 });
|
|
263
|
+
}
|
|
279
264
|
}
|
|
280
265
|
|
|
281
|
-
|
|
282
266
|
// rename the component
|
|
283
267
|
const newComponentKey = await renameComponent(componentKey, orgLibName, version, copyMove);
|
|
284
268
|
|
|
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
269
|
return newComponentKey;
|
|
298
270
|
}
|
|
299
271
|
|
|
@@ -337,8 +309,8 @@ addDebugLog("move", "", "+");
|
|
|
337
309
|
}
|
|
338
310
|
|
|
339
311
|
if (options.params.length >= 8) {
|
|
340
|
-
|
|
341
|
-
|
|
312
|
+
copyMove = options.params[3];
|
|
313
|
+
componentKey = options.params[4];
|
|
342
314
|
orgLibName = options.params[5];
|
|
343
315
|
version = options.params[6];
|
|
344
316
|
copyShared = options.params[7];
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
import { showVersion, getLibraryBased } from '../../util.js';
|
|
7
|
+
|
|
8
|
+
export const showCurrentStatus = async () => {
|
|
9
|
+
|
|
10
|
+
const configDefaults = await getConfigDefaults();
|
|
11
|
+
const componentList = await getComponents();
|
|
12
|
+
|
|
13
|
+
console.log("");
|
|
14
|
+
console.log("\tCurrent status");
|
|
15
|
+
console.log("\t---------------------");
|
|
16
|
+
console.log(`\tOrganization:\t ${chalk.bold.green(`${configDefaults.organization}`)}`);
|
|
17
|
+
console.log(`\tLibrary:\t ${chalk.bold.green(`${configDefaults.library}`)}`);
|
|
18
|
+
console.log(`\tVersion:\t ${chalk.bold.green(`${configDefaults.buildVersion}`)}`);
|
|
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
|
+
}
|
|
25
|
+
console.log(`\tComponent count: ${chalk.bold.green(`${componentList.length}`)}`);
|
|
26
|
+
|
|
27
|
+
console.log("");
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const showHelpV1 = () => {
|
|
32
|
+
console.log("");
|
|
33
|
+
console.log(`\nnpm run <command>`);
|
|
34
|
+
console.log(`\nUsage:`);
|
|
35
|
+
|
|
36
|
+
console.log(`\n${chalk.underline(`Authenticate (for Server commands)`)}`);
|
|
37
|
+
console.log(`${chalk.cyan('npm run authenticate')}\t\tauthenticate to a server`);
|
|
38
|
+
|
|
39
|
+
console.log(`\n${chalk.underline(`Components`)}`);
|
|
40
|
+
console.log(`${chalk.cyan('npm run create ')}\tcreate a component`);
|
|
41
|
+
console.log(`${chalk.cyan('npm run createAll ')}\tcreate components of all different types`);
|
|
42
|
+
console.log(`${chalk.cyan('npm run buildComponent ')}\tvalidate a component before publishing, checking for errors`);
|
|
43
|
+
console.log(`${chalk.cyan('npm run buildAllComponents')}\tvalidate and build a component before publishing, checking for errors`);
|
|
44
|
+
console.log(`${chalk.cyan('npm run validateAll ')}\tvalidate and build ALL components before publishing, checking for errors`);
|
|
45
|
+
console.log(`${chalk.cyan('npm run rename ')}\trename a component`);
|
|
46
|
+
console.log(`${chalk.cyan('npm run importComponent ')}\timport a component from a path`);
|
|
47
|
+
console.log(`${chalk.cyan('npm run startStorybook ')}\tstorybook components for testing`);
|
|
48
|
+
|
|
49
|
+
console.log(`\n${chalk.underline(`Local and Server`)}`);
|
|
50
|
+
console.log(`${chalk.cyan('npm run list ')}\tget list of components`);
|
|
51
|
+
console.log(`${chalk.cyan('npm run delete ')}\tdelete a component`);
|
|
52
|
+
console.log(`${chalk.cyan('npm run deleteAll ')}\tdelete ALL components`);
|
|
53
|
+
|
|
54
|
+
console.log(`\n${chalk.underline(`Server`)}`);
|
|
55
|
+
console.log(`${chalk.cyan('npm run publish ')}\tpublish a component to server`);
|
|
56
|
+
console.log(`${chalk.cyan('npm run publishAll ')}\tpublish ALL components to server`);
|
|
57
|
+
|
|
58
|
+
console.log("");
|
|
59
|
+
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const showHelpV2 = () => {
|
|
63
|
+
console.log("");
|
|
64
|
+
console.log(`All commands will not work until a library is created via ${chalk.cyan(`npm run createLib`)}.`);
|
|
65
|
+
console.log(`\nnpm run <command>`);
|
|
66
|
+
console.log(`\nUsage:`);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
console.log(`\n${chalk.underline(`Authenticate`)}`);
|
|
70
|
+
console.log(`${chalk.cyan('npm run authenticate')}\t\tauthenticate to a server (required for publish commands)`);
|
|
71
|
+
|
|
72
|
+
console.log(`\n${chalk.underline(`Library`)}`);
|
|
73
|
+
console.log(`${chalk.cyan('npm run createLib' )}\t\tcreate a new library and version`);
|
|
74
|
+
console.log(`${chalk.cyan('npm run switchLib' )}\t\tswitch to different library and version`);
|
|
75
|
+
console.log(`${chalk.cyan('npm run listLib ')}\t\tget contents of library and version`);
|
|
76
|
+
console.log(`${chalk.cyan('npm run deleteLib ')}\t\tdelete library, version or ALL versions`);
|
|
77
|
+
console.log(`${chalk.cyan('npm run showStatus')}\t\tshow state of current library`);
|
|
78
|
+
|
|
79
|
+
console.log(`\n${chalk.underline(`Library Versions`)}`);
|
|
80
|
+
console.log(`${chalk.cyan('npm run createLibVersion')}\tcreate a new version within the current library`);
|
|
81
|
+
console.log(`${chalk.cyan('npm run switchLibVersion')}\tswitch to different version within the current library`);
|
|
82
|
+
console.log(`${chalk.cyan('npm run deleteLibVersion')}\tdelete current version, move to another version`);
|
|
83
|
+
console.log(`${chalk.cyan('npm run storeLibVersion ')}\tstore current version to local storage (must SAVE before)`);
|
|
84
|
+
console.log(`${chalk.cyan('npm run exportLibVersion')}\texport currnet version as a zip file to a given local path`);
|
|
85
|
+
console.log(`${chalk.cyan('npm run importLibVersion')}\timport a zip file (created by export) from a given local path`);
|
|
86
|
+
console.log(`${chalk.cyan('npm run setPermanent ')}\tmake current version permanent or non permanent upon publish`);
|
|
87
|
+
|
|
88
|
+
console.log(`\n${chalk.underline(`Published Versions (needs authentication)`)}`);
|
|
89
|
+
console.log(`${chalk.cyan('npm run publishLibVersion')}\tpublish current library/version to server (creates a local published library as well)`);
|
|
90
|
+
console.log(`${chalk.cyan('npm run listPublishedLib')}\tget contents of published library/version (local or server)`);
|
|
91
|
+
console.log(`${chalk.cyan('npm run deletePublishedLib')}\tdelete ALL contents of published libary/version (local or server)`);
|
|
92
|
+
|
|
93
|
+
console.log(`\n${chalk.underline(`Components (in current library/version context)`)}`);
|
|
94
|
+
console.log(`${chalk.cyan('npm run create ')}\t\tcreate a component`);
|
|
95
|
+
console.log(`${chalk.cyan('npm run createAll ')}\t\tcreate components of all different types`);
|
|
96
|
+
console.log(`${chalk.cyan('npm run validate ')}\t\tvalidate a component before publishing, checking for errors`);
|
|
97
|
+
console.log(`${chalk.cyan('npm run validateAll')}\t\tvalidate ALL components before publishing, checking for errors`);
|
|
98
|
+
console.log(`${chalk.cyan('npm run rename ')}\t\trename a component`);
|
|
99
|
+
console.log(`${chalk.cyan('npm run move ')}\t\tmove (or copy) single component or ALL in current version to another version or library`);
|
|
100
|
+
console.log(`${chalk.cyan('npm run importComponent')}\t\timport a component from a path`);
|
|
101
|
+
console.log(`${chalk.cyan('npm run list ')}\t\tget list of components`);
|
|
102
|
+
console.log(`${chalk.cyan('npm run delete ')}\t\tdelete a component`);
|
|
103
|
+
console.log(`${chalk.cyan('npm run deleteAll ')}\t\tdelete ALL components`);
|
|
104
|
+
console.log(`${chalk.cyan('npm run startStorybook')}\t\tstorybook components for testing`);
|
|
105
|
+
console.log("");
|
|
106
|
+
|
|
107
|
+
console.log(`\n${chalk.underline(`Notes`)}`);
|
|
108
|
+
console.log(`The following commands will store existing version in storage before executing the command:`);
|
|
109
|
+
console.log(`${chalk.cyan(`createLib, switchLib, createLibVersion, switchLibVersion, publishLibVersion, exportLibVersion`)}`);
|
|
110
|
+
console.log(`\nWhen editing in an IDE, always ${chalk.yellow("SAVE")} changes to components before doing a library/version context switch`);
|
|
111
|
+
console.log(`or changes will be lost!`);
|
|
112
|
+
console.log("");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
export default async options => {
|
|
117
|
+
const isLibraryBased = getLibraryBased();
|
|
118
|
+
|
|
119
|
+
await showVersion();
|
|
120
|
+
|
|
121
|
+
if (isLibraryBased) {
|
|
122
|
+
await showHelpV2();
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
await showHelpV1();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
}
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
checkLibraryAndArchives,
|
|
17
17
|
getConfigDefaults,
|
|
18
18
|
getHaveDependencyDifference,
|
|
19
|
-
forceDefaultsUpdate
|
|
19
|
+
forceDefaultsUpdate,
|
|
20
|
+
modAddAboutData
|
|
20
21
|
} from '../../util.js';
|
|
21
22
|
|
|
22
23
|
import { getSwitchVersionComponentQuestions } from './helper.js';
|
|
@@ -49,6 +50,13 @@ addDebugLog("switchVersion", "", "+");
|
|
|
49
50
|
const okToCont = options.params[3];
|
|
50
51
|
version = options.params[4];
|
|
51
52
|
|
|
53
|
+
// if have [5] will be "NoAbout" from Jest, to turn off build date
|
|
54
|
+
if (options.params.length >= 6 ) {
|
|
55
|
+
if (options.params[5] === "NoAbout") {
|
|
56
|
+
modAddAboutData(false);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
okToContinue = !!(okToCont === 'Y' || okToCont === 'y' || okToCont === true || okToCont === 'true');
|
|
53
61
|
|
|
54
62
|
} else {
|
package/src/util.js
CHANGED
|
@@ -42,6 +42,7 @@ const access = promisify(fs.access);
|
|
|
42
42
|
let showDebug = false;
|
|
43
43
|
let debugLevel = 1;
|
|
44
44
|
let haveDependencyDifference = false;
|
|
45
|
+
let addAboutData = true;
|
|
45
46
|
|
|
46
47
|
// updated upon start
|
|
47
48
|
let defaultConfigs = {
|
|
@@ -62,6 +63,11 @@ let pegaData = null;
|
|
|
62
63
|
let sPegaData;
|
|
63
64
|
let sPegaServerConfig;
|
|
64
65
|
|
|
66
|
+
export const modAddAboutData = (addInAboutData) => {
|
|
67
|
+
// used by jest to not put in to match assets without aboutData
|
|
68
|
+
addAboutData = addInAboutData;
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
export const addDebugLog = (sFunctionName, sLogData, sIncDec) => {
|
|
66
72
|
|
|
67
73
|
let sLog;
|
|
@@ -703,33 +709,42 @@ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}
|
|
|
703
709
|
}
|
|
704
710
|
}
|
|
705
711
|
|
|
706
|
-
if (
|
|
707
|
-
foundProp
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
712
|
+
if (addAboutData) {
|
|
713
|
+
if (foundProp) {
|
|
714
|
+
foundProp.label = aboutData;
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
// don't have "About"
|
|
718
|
+
const aboutLabelJSON = {
|
|
719
|
+
"format": "LABEL",
|
|
720
|
+
"label": "About",
|
|
721
|
+
"name": "PegaAboutLabel",
|
|
722
|
+
"variant": "h3"
|
|
723
|
+
};
|
|
724
|
+
const aboutDataJSON = {
|
|
725
|
+
"format": "LABEL",
|
|
726
|
+
"label": aboutData,
|
|
727
|
+
"name": "PegaAboutData",
|
|
728
|
+
"variant": "primary"
|
|
729
|
+
}
|
|
730
|
+
properties.push(aboutLabelJSON);
|
|
731
|
+
properties.push(aboutDataJSON);
|
|
722
732
|
}
|
|
723
|
-
properties.push(aboutLabelJSON);
|
|
724
|
-
properties.push(aboutDataJSON);
|
|
725
733
|
}
|
|
734
|
+
|
|
735
|
+
|
|
726
736
|
}
|
|
727
737
|
} catch (er) {
|
|
728
738
|
throw new Error(`Invalid schema json in config.json: ${er}`);
|
|
729
739
|
}
|
|
730
740
|
|
|
731
741
|
data.version = buildVersion;
|
|
732
|
-
|
|
742
|
+
|
|
743
|
+
if (addAboutData) {
|
|
744
|
+
data.buildDate = dateStamp;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
|
|
733
748
|
|
|
734
749
|
// write back file
|
|
735
750
|
fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8' });
|