@pega/custom-dx-components 0.242.30 → 0.242.32
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/create-lib/helper.js +2 -2
- package/src/tasks/export-archive/index.js +3 -17
- package/src/tasks/import-archive/helper.js +232 -1
- package/src/tasks/import-archive/index.js +86 -22
- package/src/tasks/index.js +1 -0
- package/src/tasks/init/template/package.json.mustache +3 -1
- package/src/tasks/init/template/tasks.config.json +1 -1
- package/src/tasks/list-pub/helper.js +33 -1
- package/src/tasks/list-pub/index.js +55 -24
- package/src/tasks/set-perm/index.js +134 -0
- package/src/tasks/show-status/index.js +6 -1
- package/src/tasks/switch-lib/helper.js +5 -2
- package/src/tasks/switch-lib/index.js +4 -0
- package/src/tasks/switch-version/helper.js +1 -1
- package/src/util.js +28 -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;
|
|
@@ -17,7 +17,7 @@ addDebugLog("getCreateLibComponentQuestions", "", "");
|
|
|
17
17
|
name: 'okToContinue',
|
|
18
18
|
type: 'confirm',
|
|
19
19
|
message: 'Ok to continue ?',
|
|
20
|
-
default:
|
|
20
|
+
default: true
|
|
21
21
|
}
|
|
22
22
|
];
|
|
23
23
|
|
|
@@ -56,7 +56,7 @@ addDebugLog("getCreateLibComponentQuestions", "", "");
|
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
58
|
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
59
|
-
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
{
|
|
@@ -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,10 +201,7 @@ export default async options => {
|
|
|
212
201
|
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
213
202
|
const { filePath } = filePathAnswers;
|
|
214
203
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
await exportArch( zipFilePath, orgLibName, selectedVersion);
|
|
204
|
+
await exportArch( filePath, orgLibName, selectedVersion);
|
|
219
205
|
|
|
220
206
|
}
|
|
221
207
|
|
|
@@ -1,13 +1,244 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
import fs from 'fs';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { join } from 'path';
|
|
4
|
-
import {
|
|
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
|
+
|
|
5
9
|
|
|
6
10
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
7
11
|
SERVER: 'Server',
|
|
8
12
|
LOCAL: 'Local'
|
|
9
13
|
};
|
|
10
14
|
|
|
15
|
+
export const setTasksConfig = async (libraryName, version, devBuild, currDir) => {
|
|
16
|
+
addDebugLog("setTasksConfig", `libraryName: ${libraryName}, version: ${version}, devBuild: ${devBuild}`, "");
|
|
17
|
+
const pegaConfigJsonPath = join(currDir, TASKS_CONFIG_JSON_FILENAME);
|
|
18
|
+
const sPegaData = fs.readFileSync(pegaConfigJsonPath, { encoding: 'utf8' });
|
|
19
|
+
const configData = JSON.parse(sPegaData);
|
|
20
|
+
let serverConfig = configData['server-config'];
|
|
21
|
+
serverConfig.devBuild = devBuild;
|
|
22
|
+
let compConfig = configData['component'];
|
|
23
|
+
compConfig.library = libraryName;
|
|
24
|
+
compConfig.version = version;
|
|
25
|
+
|
|
26
|
+
// update file
|
|
27
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
28
|
+
fs.writeFileSync(pegaConfigJsonPath, JSON.stringify(configData, null, 4), { encoding: 'utf8' });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const setPackageOrg = async (organization, currDir) => {
|
|
32
|
+
addDebugLog("setPackageOrg", "", "");
|
|
33
|
+
const packageJsonPath = join(currDir, PACKAGE_JSON_FILENAME);
|
|
34
|
+
const sPackage = fs.readFileSync(packageJsonPath, { encoding: 'utf8'});
|
|
35
|
+
const packageData = JSON.parse(sPackage);
|
|
36
|
+
|
|
37
|
+
packageData.organization = organization;
|
|
38
|
+
|
|
39
|
+
// update file
|
|
40
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
41
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 4), { encoding: 'utf8' });
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const updateConfig = async (
|
|
46
|
+
{
|
|
47
|
+
oldComponentKey,
|
|
48
|
+
newComponentKey,
|
|
49
|
+
organization,
|
|
50
|
+
library,
|
|
51
|
+
version,
|
|
52
|
+
currentDirectory,
|
|
53
|
+
}
|
|
54
|
+
) => {
|
|
55
|
+
|
|
56
|
+
addDebugLog("updateConfig", `oldComponentKey: ${oldComponentKey}, newComponentKey: ${newComponentKey}`, "");
|
|
57
|
+
|
|
58
|
+
let configData = fs.readFileSync(join(currentDirectory, "/config.json"), { encoding: 'utf8' });
|
|
59
|
+
configData = configData && JSON.parse(configData);
|
|
60
|
+
|
|
61
|
+
configData.name = newComponentKey;
|
|
62
|
+
if (configData.componentKey) configData.componentKey = newComponentKey;
|
|
63
|
+
configData.organization = organization;
|
|
64
|
+
configData.library = library;
|
|
65
|
+
configData.version = version;
|
|
66
|
+
|
|
67
|
+
// stringify "4", makes the json string look like JSON in the file, formated instead of a single line
|
|
68
|
+
fs.writeFileSync(join(currentDirectory, "/config.json"), JSON.stringify(configData, null, 4), { encoding: 'utf8' });
|
|
69
|
+
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const updateFile = async (
|
|
73
|
+
fileName,
|
|
74
|
+
oldComponentKeyPC,
|
|
75
|
+
newComponentKeyPC,
|
|
76
|
+
currentDirectory,
|
|
77
|
+
) => {
|
|
78
|
+
|
|
79
|
+
addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldComponentKeyPC}, newComponentKeyPC: ${newComponentKeyPC}, currentDirectory: ${currentDirectory}`, "");
|
|
80
|
+
|
|
81
|
+
let fileData = fs.readFileSync(join(currentDirectory, "/", fileName), { encoding: 'utf8' });
|
|
82
|
+
|
|
83
|
+
if (fileData.indexOf(oldComponentKeyPC) >= 0) {
|
|
84
|
+
fileData = fileData.replaceAll(oldComponentKeyPC, newComponentKeyPC);
|
|
85
|
+
|
|
86
|
+
fs.writeFileSync(join(currentDirectory, "/", fileName), fileData, { encoding: 'utf8' });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const reanmeDirectory = async(currentDirectory, targetDirectory) => {
|
|
92
|
+
if (!fs.existsSync(targetDirectory)) {
|
|
93
|
+
fs.mkdirSync(targetDirectory, { recursive: true });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const targetFileList = await getDirectoryFiles(currentDirectory);
|
|
97
|
+
for (const targetFile of targetFileList) {
|
|
98
|
+
const currentFilePath = join(currentDirectory, targetFile);
|
|
99
|
+
const targetFilePath = join(targetDirectory, targetFile);
|
|
100
|
+
fs.copyFileSync(currentFilePath, targetFilePath)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// fs.rm(currentDirectory, { recursive: true }, err => {
|
|
104
|
+
// if (err) {
|
|
105
|
+
// throw err;
|
|
106
|
+
// }
|
|
107
|
+
// });
|
|
108
|
+
|
|
109
|
+
fs.rmSync(currentDirectory, { recursive: true, force: true, maxRetries: 2 });
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// rename the component
|
|
115
|
+
export const renameComponent = async (
|
|
116
|
+
componentKey,
|
|
117
|
+
library,
|
|
118
|
+
version,
|
|
119
|
+
currDir
|
|
120
|
+
) => {
|
|
121
|
+
|
|
122
|
+
addDebugLog("renameComponent", `library: ${library}, componentKey: ${componentKey}`, "");
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
const componentName = componentKey.split("_")[2];
|
|
126
|
+
|
|
127
|
+
const configDef = getConfigDefaults();
|
|
128
|
+
const orgLibName = `${configDef.organization}_${library}`;
|
|
129
|
+
const organization = configDef.organization;
|
|
130
|
+
|
|
131
|
+
const newComponentKey = `${orgLibName}_${componentName}`;
|
|
132
|
+
|
|
133
|
+
const oldComponentKey = componentKey;
|
|
134
|
+
const newComponentKeyPC = convertIntoPascalCase(newComponentKey);
|
|
135
|
+
const oldComponentKeyPC = convertIntoPascalCase(oldComponentKey);
|
|
136
|
+
|
|
137
|
+
const currentDirectory = await getComponentDirectoryPath(componentKey, currDir);
|
|
138
|
+
const targetDirectory = await getComponentDirectoryPath(newComponentKey, currDir);
|
|
139
|
+
|
|
140
|
+
const targetFileList = await getDirectoryFiles(currentDirectory);
|
|
141
|
+
|
|
142
|
+
for (const fileIndex in targetFileList) {
|
|
143
|
+
const fileName = targetFileList[fileIndex];
|
|
144
|
+
|
|
145
|
+
if (fileName === "config.json") {
|
|
146
|
+
await updateConfig(
|
|
147
|
+
{
|
|
148
|
+
oldComponentKey,
|
|
149
|
+
newComponentKey,
|
|
150
|
+
componentName,
|
|
151
|
+
organization,
|
|
152
|
+
library,
|
|
153
|
+
version,
|
|
154
|
+
currentDirectory,
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
await updateFile(
|
|
160
|
+
fileName,
|
|
161
|
+
oldComponentKeyPC,
|
|
162
|
+
newComponentKeyPC,
|
|
163
|
+
currentDirectory );
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
} // for
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
// rename the directory
|
|
172
|
+
await reanmeDirectory(currentDirectory, targetDirectory);
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
return newComponentKey;
|
|
176
|
+
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const renameComponents = async(compList, libraryName, version, compDir) => {
|
|
180
|
+
for (const componentKey of compList) {
|
|
181
|
+
await renameComponent(componentKey, libraryName, version, compDir);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export const updateTempArchive = async(libraryName, version, devBuild) => {
|
|
186
|
+
const currentDirectory = process.cwd();
|
|
187
|
+
const tempStoreDirectory = join(currentDirectory, TEMP_PATH);
|
|
188
|
+
const configDef = getConfigDefaults();
|
|
189
|
+
|
|
190
|
+
// remove -dev if exists
|
|
191
|
+
const justVersion = version.replace("-dev", "");
|
|
192
|
+
|
|
193
|
+
// open tasks.config and update it
|
|
194
|
+
// await setTasksConfig(libraryName, justVersion, devBuild, tempStoreDirectory);
|
|
195
|
+
|
|
196
|
+
// open package.json, update org
|
|
197
|
+
// await setPackageOrg(configDef.organization, tempStoreDirectory);
|
|
198
|
+
|
|
199
|
+
// update all the components
|
|
200
|
+
// const compDir = join(tempStoreDirectory, "src", "components");
|
|
201
|
+
// const compList = await getComponents(compDir);
|
|
202
|
+
|
|
203
|
+
// await renameComponents(compList, libraryName, version, compDir);
|
|
204
|
+
|
|
205
|
+
const tasks = new Listr(
|
|
206
|
+
[
|
|
207
|
+
{
|
|
208
|
+
title: 'Update tasks.config',
|
|
209
|
+
task: async () => {
|
|
210
|
+
await setTasksConfig(libraryName, justVersion, devBuild, tempStoreDirectory);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
title: 'Update package.json',
|
|
215
|
+
task: async () => {
|
|
216
|
+
await setPackageOrg(configDef.organization, tempStoreDirectory);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
title: `Renaming components`,
|
|
221
|
+
task: async () => {
|
|
222
|
+
const compDir = join(tempStoreDirectory, "src", "components");
|
|
223
|
+
const compList = await getComponents(compDir);
|
|
224
|
+
|
|
225
|
+
await renameComponents(compList, libraryName, version, compDir);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
{
|
|
230
|
+
exitOnError: true
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
await tasks.run().catch(err => {
|
|
235
|
+
console.log(chalk.bold.red(err.toString()));
|
|
236
|
+
process.exit(1);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
11
242
|
|
|
12
243
|
export const getFilePathQuestions = async () => {
|
|
13
244
|
addDebugLog("getFilePathQuestions", "", "");
|
|
@@ -7,9 +7,9 @@ import ncp from 'ncp';
|
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
+
sanitize,
|
|
10
11
|
checkPathAccess,
|
|
11
12
|
showVersion,
|
|
12
|
-
getComponentsObj,
|
|
13
13
|
getDirectoryFiles,
|
|
14
14
|
addDebugLog,
|
|
15
15
|
checkLibraryAndArchives,
|
|
@@ -17,16 +17,16 @@ import {
|
|
|
17
17
|
getLibraryBased,
|
|
18
18
|
unZipFromArchive,
|
|
19
19
|
zipVersionAndArchive,
|
|
20
|
-
|
|
20
|
+
getLibraryArchiveDirectories,
|
|
21
|
+
hasLibraryAndVersion
|
|
21
22
|
} from '../../util.js';
|
|
22
|
-
import { TASKS_CONFIG_JSON_FILENAME,
|
|
23
|
-
import { getFilePathQuestions, getFileNameQuestions } from './helper.js';
|
|
23
|
+
import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
|
|
24
|
+
import { getFilePathQuestions, getFileNameQuestions, updateTempArchive } from './helper.js';
|
|
24
25
|
|
|
25
26
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
26
27
|
const currentDirectory = process.cwd();
|
|
27
28
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
28
29
|
|
|
29
|
-
|
|
30
30
|
import {
|
|
31
31
|
convertIntoPascalCase,
|
|
32
32
|
getComponentDirectoryPath
|
|
@@ -212,9 +212,86 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
212
212
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
|
|
216
|
+
|
|
215
217
|
const arFileData = fileName.split("_");
|
|
216
|
-
|
|
218
|
+
let orgLibName = `${arFileData[0]}_${arFileData[1]}`;
|
|
219
|
+
let libName = arFileData[1];
|
|
217
220
|
const version = arFileData[2].replace(".zip", "");
|
|
221
|
+
const devBuild = version.indexOf("-dev") > 0 ? true : false;
|
|
222
|
+
const configDef = getConfigDefaults();
|
|
223
|
+
|
|
224
|
+
if (arFileData[0] !== configDef.organization) {
|
|
225
|
+
console.log(`\nImported ${chalk.yellow(`${orgLibName}/${version}`)} is not the same organization as your current organization: ${chalk.yellow(`${configDef.organization}`)}.`);
|
|
226
|
+
console.log(`\nTo import, the organization of the components will be changed to match your organization.`);
|
|
227
|
+
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(`${arFileData[0]}`)} and import there.\n`);
|
|
229
|
+
|
|
230
|
+
const proceedAnswers = await inquirer.prompt([
|
|
231
|
+
|
|
232
|
+
{
|
|
233
|
+
name: 'okToContinue',
|
|
234
|
+
type: 'confirm',
|
|
235
|
+
message: `Ok to proceed ?`,
|
|
236
|
+
default: true
|
|
237
|
+
}
|
|
238
|
+
]);
|
|
239
|
+
|
|
240
|
+
if (proceedAnswers.okToContinue) {
|
|
241
|
+
// check if new version matches existing
|
|
242
|
+
// -dev is already on version, if present, so "false", for devBuild here
|
|
243
|
+
const alreadyExists = await hasLibraryAndVersion(libName, version, false);
|
|
244
|
+
if (alreadyExists) {
|
|
245
|
+
console.log(`${chalk.yellow(`${configDef.organization}_${libName}/${version}`)} already exists.`);
|
|
246
|
+
const archDirectories = await getLibraryArchiveDirectories();
|
|
247
|
+
const newLibNameAnswers = await inquirer.prompt([
|
|
248
|
+
{
|
|
249
|
+
name: 'libraryName',
|
|
250
|
+
message: 'Enter new libray name',
|
|
251
|
+
validate: value => {
|
|
252
|
+
/* value should not be empty
|
|
253
|
+
It should not have spaces
|
|
254
|
+
It should not start with a number
|
|
255
|
+
Only case-insensitive alphanumeric values are allowed
|
|
256
|
+
*/
|
|
257
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
258
|
+
if (archDirectories && archDirectories.length > 0) {
|
|
259
|
+
const newOrgLib = `${configDef.organization}_${value}`;
|
|
260
|
+
if (archDirectories.includes(newOrgLib)) {
|
|
261
|
+
return `Library ${value} already exists.`;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
]);
|
|
278
|
+
|
|
279
|
+
libName = newLibNameAnswers.libraryName;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// rename orgLibName
|
|
283
|
+
orgLibName = `${configDef.organization}_${libName}`;
|
|
284
|
+
|
|
285
|
+
// update temp with new info
|
|
286
|
+
await updateTempArchive(libName, version, devBuild);
|
|
287
|
+
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
process.exit();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
}
|
|
218
295
|
|
|
219
296
|
// rearchive temp directory
|
|
220
297
|
await zipVersionAndArchive(orgLibName, version, tempDirectory);
|
|
@@ -227,22 +304,13 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
227
304
|
|
|
228
305
|
}
|
|
229
306
|
|
|
230
|
-
export const convertPath = (filePath) => {
|
|
231
307
|
|
|
232
|
-
if (filePath.indexOf(":") > 0) {
|
|
233
|
-
const arFileData = filePath.split("\\");
|
|
234
|
-
filePath = join(arFileData);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return filePath;
|
|
238
|
-
}
|
|
239
308
|
|
|
240
309
|
export const getZipFileList = async(filePath) => {
|
|
241
310
|
|
|
242
|
-
|
|
243
|
-
if (fs.existsSync(zipFilePath)) {
|
|
311
|
+
if (fs.existsSync(filePath)) {
|
|
244
312
|
return fs
|
|
245
|
-
.readdirSync(
|
|
313
|
+
.readdirSync(filePath, { withFileTypes: true })
|
|
246
314
|
.filter(dirent => !dirent.isDirectory() && dirent.name.match(/.*\.(zip?)/ig))
|
|
247
315
|
.map(dirent => dirent.name);
|
|
248
316
|
}
|
|
@@ -267,10 +335,7 @@ export default async options => {
|
|
|
267
335
|
|
|
268
336
|
|
|
269
337
|
if (options.params.length >= 5) {
|
|
270
|
-
const filePath = convertPath(options.params[3]);
|
|
271
338
|
const fileName = options.params[4];
|
|
272
|
-
|
|
273
|
-
|
|
274
339
|
await importArch( filePath, fileName);
|
|
275
340
|
|
|
276
341
|
}
|
|
@@ -279,12 +344,11 @@ export default async options => {
|
|
|
279
344
|
const filePathQuestions = await getFilePathQuestions();
|
|
280
345
|
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
281
346
|
const { filePath } = filePathAnswers;
|
|
282
|
-
|
|
283
|
-
const zipFilePath = convertPath(filePath);
|
|
284
347
|
const zipFileList = await getZipFileList(filePath);
|
|
285
348
|
|
|
286
349
|
if (!zipFileList || zipFileList.length === 0) {
|
|
287
350
|
console.log(chalk.red.bold(`No zip files exist at path: ${filePath}`));
|
|
351
|
+
process.exit();
|
|
288
352
|
}
|
|
289
353
|
|
|
290
354
|
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';
|
|
@@ -34,9 +34,11 @@
|
|
|
34
34
|
"deleteLib": "custom-dx-components deleteLibrary",
|
|
35
35
|
"deletePublishedLib": "custom-dx-components deletePublished",
|
|
36
36
|
"deleteLibVersion": "custom-dx-components deleteVersion",
|
|
37
|
+
"moveLibVersion": "custom-dx-components moveComponent",
|
|
37
38
|
"publishLibVersion": "custom-dx-components publish",
|
|
38
39
|
"storeLibVersion": "custom-dx-components storeComponents",
|
|
39
40
|
"showStatus": "custom-dx-components showStatus",
|
|
41
|
+
"setPermanent": "custom-dx-components setPermanent",
|
|
40
42
|
"moveLibVersion": "custom-dx-components moveComponent",
|
|
41
43
|
"importLibVersion": "custom-dx-components importArchive",
|
|
42
44
|
"exportLibVersion": "custom-dx-components exportArchive",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
},
|
|
97
99
|
"devDependencies": {
|
|
98
100
|
"@pega/configs": "^0.6.0",
|
|
99
|
-
"@pega/custom-dx-components": "0.242.
|
|
101
|
+
"@pega/custom-dx-components": "0.242.32",
|
|
100
102
|
"@pega/pcore-pconnect-typedefs": "~3.0.0",
|
|
101
103
|
"@storybook/addon-actions": "^7.6.7",
|
|
102
104
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -2,9 +2,12 @@ import chalk from 'chalk';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
getPegaServerConfig,
|
|
5
|
-
addDebugLog
|
|
5
|
+
addDebugLog,
|
|
6
|
+
getC11NB2STokenAndStaticServer
|
|
6
7
|
} from '../../util.js';
|
|
7
8
|
|
|
9
|
+
import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
10
|
+
|
|
8
11
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
9
12
|
SERVER: 'Server',
|
|
10
13
|
LOCAL: 'Local'
|
|
@@ -39,4 +42,33 @@ addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}, libVersio
|
|
|
39
42
|
}
|
|
40
43
|
];
|
|
41
44
|
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const getServerLocalQuestion = async() => {
|
|
48
|
+
addDebugLog("getServerLocalQuestion", "", "");
|
|
49
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
50
|
+
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
name: 'sourceOfLibrary',
|
|
54
|
+
type: 'rawlist',
|
|
55
|
+
message: `List from Server or Local ?`,
|
|
56
|
+
choices: Object.values(SOURCE_OF_COMPONENT_TYPES),
|
|
57
|
+
default: "defaultPegaConfig.sourceOfComponents",
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const getServerLibraries = async() => {
|
|
63
|
+
addDebugLog("listLibJSONResponse", "services call", "");
|
|
64
|
+
// server
|
|
65
|
+
const tokenAndStaticServer = await getC11NB2STokenAndStaticServer();
|
|
66
|
+
const oLibList = await listLibJSONResponse(tokenAndStaticServer.C11NB2S, tokenAndStaticServer.appStaticContentServer);
|
|
67
|
+
addDebugLog("listLibJSONResponse", "services end", "");
|
|
68
|
+
if (oLibList) {
|
|
69
|
+
return Object.keys(oLibList);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return [];
|
|
73
|
+
|
|
42
74
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults } from '../../util.js';
|
|
4
|
+
import {showVersion, getC11NB2STokenAndStaticServer, getLocalLibraries, getLocalLibraryVersions, getLocalLibraryVersionData, getLibraryBased, addDebugLog, checkLibraryAndArchives, getConfigDefaults } from '../../util.js';
|
|
5
5
|
|
|
6
6
|
import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
7
7
|
|
|
8
|
-
import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES } from './helper.js';
|
|
8
|
+
import { getListLibraryQuestions, SOURCE_OF_COMPONENT_TYPES, getServerLibraries, getServerLocalQuestion } from './helper.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -51,7 +51,7 @@ addDebugLog("listPublished", "", "+");
|
|
|
51
51
|
const compDef = getConfigDefaults();
|
|
52
52
|
organization = compDef.organization;
|
|
53
53
|
library = compDef.library;
|
|
54
|
-
|
|
54
|
+
let libraryName;
|
|
55
55
|
let selectedVersion;
|
|
56
56
|
let libVersions = [];
|
|
57
57
|
|
|
@@ -64,7 +64,7 @@ addDebugLog("listPublished", "", "+");
|
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
|
|
67
|
-
const questions = await
|
|
67
|
+
const questions = await getServerLocalQuestion();
|
|
68
68
|
const answers = await inquirer.prompt(questions);
|
|
69
69
|
({ sourceOfLibrary } = answers);
|
|
70
70
|
|
|
@@ -72,6 +72,18 @@ addDebugLog("listPublished", "", "+");
|
|
|
72
72
|
|
|
73
73
|
if (sourceOfLibrary === SOURCE_OF_COMPONENT_TYPES.LOCAL ) {
|
|
74
74
|
// local
|
|
75
|
+
const arLibs = await getLocalLibraries();
|
|
76
|
+
|
|
77
|
+
const libAnswers = await inquirer.prompt([
|
|
78
|
+
{
|
|
79
|
+
name: 'library',
|
|
80
|
+
type: 'rawlist',
|
|
81
|
+
message: 'Pick library',
|
|
82
|
+
choices: arLibs
|
|
83
|
+
}
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
libraryName = libAnswers.library;
|
|
75
87
|
|
|
76
88
|
if (libVersions.length == 0) {
|
|
77
89
|
try {
|
|
@@ -86,7 +98,6 @@ addDebugLog("listPublished", "", "+");
|
|
|
86
98
|
|
|
87
99
|
if (selectedVersion === undefined) {
|
|
88
100
|
const libAnswers = await inquirer.prompt([
|
|
89
|
-
|
|
90
101
|
{
|
|
91
102
|
name: 'libVersion',
|
|
92
103
|
type: 'rawlist',
|
|
@@ -123,34 +134,54 @@ addDebugLog("listPublished", "END", "-");
|
|
|
123
134
|
|
|
124
135
|
}
|
|
125
136
|
else {
|
|
126
|
-
const libVersions = await getServerLibraryVersions(libraryName);
|
|
127
137
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const libAnswers = await inquirer.prompt([
|
|
138
|
+
const arLibs = await getServerLibraries();
|
|
139
|
+
if (arLibs && arLibs.length > 0) {
|
|
131
140
|
|
|
141
|
+
const libAnswers = await inquirer.prompt([
|
|
132
142
|
{
|
|
133
|
-
name: '
|
|
143
|
+
name: 'library',
|
|
134
144
|
type: 'rawlist',
|
|
135
|
-
message: '
|
|
136
|
-
choices:
|
|
137
|
-
}
|
|
145
|
+
message: 'Pick library',
|
|
146
|
+
choices: arLibs
|
|
147
|
+
}
|
|
138
148
|
]);
|
|
139
149
|
|
|
140
|
-
|
|
150
|
+
libraryName = libAnswers.library;
|
|
151
|
+
const libVersions = await getServerLibraryVersions(libraryName);
|
|
141
152
|
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
if (libVersions) {
|
|
154
|
+
const keys = Object.keys(libVersions);
|
|
155
|
+
const libVersionAnswers = await inquirer.prompt([
|
|
156
|
+
|
|
157
|
+
{
|
|
158
|
+
name: 'libVersion',
|
|
159
|
+
type: 'rawlist',
|
|
160
|
+
message: 'Enter version',
|
|
161
|
+
choices: keys
|
|
162
|
+
}
|
|
163
|
+
]);
|
|
164
|
+
|
|
165
|
+
const selectedVersion = libVersionAnswers.libVersion;
|
|
166
|
+
|
|
167
|
+
const versionData = libVersions[selectedVersion];
|
|
168
|
+
const data = JSON.parse(versionData);
|
|
169
|
+
|
|
170
|
+
// get built on from first component if exists
|
|
171
|
+
let builtOn = "(date unavailable)";
|
|
172
|
+
if (data[0] && data[0].buildDate) {
|
|
173
|
+
builtOn = data[0].buildDate;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
|
|
177
|
+
console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
|
|
178
|
+
console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
console.log(chalk.red("No libraries available on server."));
|
|
182
|
+
}
|
|
144
183
|
|
|
145
|
-
// get built on from first component if exists
|
|
146
|
-
let builtOn = "(date unavailable)";
|
|
147
|
-
if (data[0] && data[0].buildDate) {
|
|
148
|
-
builtOn = data[0].buildDate;
|
|
149
|
-
}
|
|
150
184
|
|
|
151
|
-
let libData = data.map((component) => ( {'Component': component.name, 'Label': component.label, 'Version': component.version, 'Type': component.type, 'Sub Type' : component.subtype}));
|
|
152
|
-
console.log(chalk.bold.blueBright(`\nList of ${libraryName}:${selectedVersion} components built on ${builtOn}.`));
|
|
153
|
-
console.table(libData, ['Component', 'Label', 'Version', 'Type', 'Sub Type']);
|
|
154
185
|
|
|
155
186
|
}
|
|
156
187
|
else {
|
|
@@ -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("");
|
|
@@ -48,13 +48,16 @@ addDebugLog("getSwitchLibraryComponentQuestions", "", "");
|
|
|
48
48
|
name: 'okToContinue',
|
|
49
49
|
type: 'confirm',
|
|
50
50
|
message: 'Ok to continue ?',
|
|
51
|
-
default:
|
|
51
|
+
default: true
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
name: 'newOrgLib',
|
|
55
55
|
type: 'rawlist',
|
|
56
56
|
message: `Select a library (current library is ${chalk.bold.green(`${currentOrgLib}`)}) `,
|
|
57
|
-
choices: archVersionList
|
|
57
|
+
choices: archVersionList,
|
|
58
|
+
when(answers) {
|
|
59
|
+
return answers.okToContinue === true;
|
|
60
|
+
}
|
|
58
61
|
}
|
|
59
62
|
];
|
|
60
63
|
};
|
|
@@ -56,6 +56,10 @@ addDebugLog("switchLibrary", "", "+");
|
|
|
56
56
|
const answers = await inquirer.prompt(questions);
|
|
57
57
|
({ okToContinue, newOrgLib } = answers);
|
|
58
58
|
|
|
59
|
+
if (!answers.okToContinue) {
|
|
60
|
+
process.exit()
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
const nextQuestion = await getSwitchVersionComponentQuestions(newOrgLib);
|
|
60
64
|
const nextAnswers = await inquirer.prompt(nextQuestion);
|
|
61
65
|
({ version } = nextAnswers);
|
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}`;
|
|
@@ -1160,6 +1162,18 @@ if (showDebug) addDebugLog("getC11NB2STokenAndStaticServer", "", "");
|
|
|
1160
1162
|
return ({});
|
|
1161
1163
|
};
|
|
1162
1164
|
|
|
1165
|
+
export const getLocalLibraries = async () => {
|
|
1166
|
+
if (showDebug) addDebugLog("getLocalLibraries", "" , "");
|
|
1167
|
+
const currentDirectory = process.cwd();
|
|
1168
|
+
const configDef = getConfigDefaults();
|
|
1169
|
+
const libFilter = configDef.organization.concat("_");
|
|
1170
|
+
|
|
1171
|
+
return fs
|
|
1172
|
+
.readdirSync(currentDirectory, { withFileTypes: true })
|
|
1173
|
+
.filter(dirent => dirent.isDirectory() && dirent.name.startsWith(libFilter))
|
|
1174
|
+
.map(dirent => dirent.name);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1163
1177
|
export const getLocalLibraryVersions = async (libraryName, currentVersion = "0.0.0") => {
|
|
1164
1178
|
if (showDebug) addDebugLog("getLocalLibraryVersions", `libraryName: ${libraryName}` , "");
|
|
1165
1179
|
const currentDirectory = process.cwd();
|
|
@@ -1538,10 +1552,20 @@ export const restoreFromArchive = async (fileName, orgLibName, version) => {
|
|
|
1538
1552
|
}
|
|
1539
1553
|
|
|
1540
1554
|
// copy temp src/components
|
|
1541
|
-
fs.
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1555
|
+
if (fs.existsSync(tempDirectoryComponents)) {
|
|
1556
|
+
fs.cpSync(tempDirectoryComponents, currentComponentsPath, { recursive: true, force: true });
|
|
1557
|
+
}
|
|
1558
|
+
else {
|
|
1559
|
+
// nothing was archived (no src/components)
|
|
1560
|
+
// so make a src/components if doesn't exist
|
|
1561
|
+
if (!fs.existsSync(currentComponentsPath)) {
|
|
1562
|
+
fs.mkdirSync(currentComponentsPath, { "recursive" : true});
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
// remove temp (windows not working well with "sync", can be async, since as long as deleted, fine)
|
|
1568
|
+
fs.rm(tempDirectory, { recursive: true, force: true, maxRetries: 5 }, () => {});
|
|
1545
1569
|
|
|
1546
1570
|
};
|
|
1547
1571
|
|