@pega/custom-dx-components 0.25.60 → 0.25.62
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/helper.js +1 -1
- package/src/tasks/export-rc/helper.js +356 -0
- package/src/tasks/export-rc/index.js +268 -0
- package/src/tasks/import-archive/helper.js +1 -1
- package/src/tasks/import-comp/helper.js +1 -1
- package/src/tasks/index.js +1 -0
- package/src/tasks/init/template/package.json.mustache +2 -1
- package/src/tasks/list-pub/index.js +1 -1
- package/src/util.js +6 -3
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
deleteVersion,
|
|
20
20
|
importArchive,
|
|
21
21
|
exportArchive,
|
|
22
|
+
exportRC,
|
|
22
23
|
importComponent,
|
|
23
24
|
initProject,
|
|
24
25
|
listComponents,
|
|
@@ -84,6 +85,7 @@ const TASKS = {
|
|
|
84
85
|
DELETE_VERSION: 'deleteVersion',
|
|
85
86
|
IMPORT_ARCHIVE: 'importArchive',
|
|
86
87
|
EXPORT_ARCHIVE: 'exportArchive',
|
|
88
|
+
EXPORT_RC: 'exportRC',
|
|
87
89
|
IMPORT_COMP: 'importComponent',
|
|
88
90
|
AUTHENTICATE: 'authenticate',
|
|
89
91
|
UPGRADE: 'upgrade',
|
|
@@ -234,6 +236,10 @@ export default async (args = []) => {
|
|
|
234
236
|
exportArchive(options);
|
|
235
237
|
break;
|
|
236
238
|
}
|
|
239
|
+
case TASKS.EXPORT_RC: {
|
|
240
|
+
exportRC(options);
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
237
243
|
case TASKS.IMPORT_COMP: {
|
|
238
244
|
importComponent(options);
|
|
239
245
|
break;
|
|
@@ -162,7 +162,7 @@ export const updateSavedExportFilePath = async(filePath) => {
|
|
|
162
162
|
let relativePath = "";
|
|
163
163
|
if (filePath !== defaultPath) {
|
|
164
164
|
// same starting path, so we can save the relative
|
|
165
|
-
relativePath = filePath.replace(defaultPath.concat(
|
|
165
|
+
relativePath = filePath.replace(defaultPath.concat(path.sep), "");
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
await setConfigExportRelativePath(relativePath);
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import fetch from 'node-fetch';
|
|
5
|
+
import archiver from 'archiver';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import {
|
|
8
|
+
addDebugLog,
|
|
9
|
+
getConfigDefaults,
|
|
10
|
+
getLibraryArchiveDirectories,
|
|
11
|
+
getLibraryArchivesVersions,
|
|
12
|
+
setConfigExportRelativePath,
|
|
13
|
+
getComponentDirectoryPath,
|
|
14
|
+
getPegaServerConfig,
|
|
15
|
+
forceDefaultsUpdate } from '../../util.js';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
20
|
+
SERVER: 'Server',
|
|
21
|
+
LOCAL: 'Local'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export const getFilePathQuestions = async () => {
|
|
26
|
+
addDebugLog("getFilePathQuestions", "", "");
|
|
27
|
+
|
|
28
|
+
console.log("\nFile path examples:");
|
|
29
|
+
if (path.sep === "/") {
|
|
30
|
+
console.log("\tMac OS/Unix:\t/Users/name/...");
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.log("\tWindows:\tC:\\Users\\name\\...\n");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const configDef = getConfigDefaults();
|
|
37
|
+
|
|
38
|
+
const currentDirectory = process.cwd();
|
|
39
|
+
const arPathParts = currentDirectory.split(path.sep);
|
|
40
|
+
let defaultPath = join(arPathParts[0], arPathParts[1], arPathParts[2], configDef.exportRelativePath);
|
|
41
|
+
let startDirectory = join(arPathParts[0], arPathParts[1], arPathParts[2]);
|
|
42
|
+
|
|
43
|
+
if (path.sep === "/") {
|
|
44
|
+
defaultPath = "/".concat(defaultPath);
|
|
45
|
+
startDirectory = "/".concat(startDirectory).concat("/");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
name: 'filePath',
|
|
51
|
+
type: 'fuzzypath',
|
|
52
|
+
message: 'Enter full file path of directory to export zip file:',
|
|
53
|
+
default: defaultPath,
|
|
54
|
+
excludePath: nodePath => nodePath.startsWith('node_modules'),
|
|
55
|
+
// excludePath :: (String) -> Bool
|
|
56
|
+
// excludePath to exclude some paths from the file-system scan
|
|
57
|
+
excludeFilter: nodePath => nodePath.indexOf('/.') >= 0,
|
|
58
|
+
// excludeFilter :: (String) -> Bool
|
|
59
|
+
// excludeFilter to exclude some paths from the final list, e.g. '.'
|
|
60
|
+
itemType: 'directory',
|
|
61
|
+
// itemType :: 'any' | 'directory' | 'file'
|
|
62
|
+
// specify the type of nodes to display
|
|
63
|
+
// default value: 'any'
|
|
64
|
+
// example: itemType: 'file' - hides directories from the item list
|
|
65
|
+
rootPath: startDirectory,
|
|
66
|
+
// rootPath :: String
|
|
67
|
+
// Root search directory
|
|
68
|
+
suggestOnly: true,
|
|
69
|
+
// suggestOnly :: Bool
|
|
70
|
+
// Restrict prompt answer to available choices or use them as suggestions
|
|
71
|
+
depthLimit: 2,
|
|
72
|
+
// depthLimit :: integer >= 0
|
|
73
|
+
// Limit the depth of sub-folders to scan
|
|
74
|
+
// Defaults to infinite depth if undefined
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const getFileNameQuestions = async (zipFileList) => {
|
|
80
|
+
addDebugLog("getFileNameQuestions", "", "");
|
|
81
|
+
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
name: 'fileName',
|
|
85
|
+
type: 'rawlist',
|
|
86
|
+
message: `Select zip file`,
|
|
87
|
+
choices: zipFileList
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const getLibraryQuestion = async () => {
|
|
93
|
+
addDebugLog("getLibraryQuestion", "", "");
|
|
94
|
+
const componentDefaults = getConfigDefaults();
|
|
95
|
+
const orgLib = getConfigDefaults();
|
|
96
|
+
const currentOrgLib = `${orgLib.organization}_${orgLib.library}`;
|
|
97
|
+
|
|
98
|
+
const archVersionList = await getLibraryArchiveDirectories("");
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
return [
|
|
102
|
+
{
|
|
103
|
+
name: 'orgLibName',
|
|
104
|
+
type: 'rawlist',
|
|
105
|
+
message: `Select a library (current library is ${chalk.bold.green(`${currentOrgLib}`)}) `,
|
|
106
|
+
choices: archVersionList
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const getLibraryVersionQuestion = async (newOrgLib) => {
|
|
112
|
+
addDebugLog("getLibraryVersionQuestion", "", "");
|
|
113
|
+
|
|
114
|
+
const archVersionList = await getLibraryArchivesVersions(newOrgLib, "0.0.0");
|
|
115
|
+
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
name: 'selectedVersion',
|
|
119
|
+
type: 'rawlist',
|
|
120
|
+
message: `Select a version `,
|
|
121
|
+
choices: archVersionList
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const getServerOrDirectoryQuestion = async () => {
|
|
127
|
+
addDebugLog("getLibraryVersionQuestion", "", "");
|
|
128
|
+
|
|
129
|
+
return [
|
|
130
|
+
{
|
|
131
|
+
name: 'exportTo',
|
|
132
|
+
type: 'rawlist',
|
|
133
|
+
message: `Export to`,
|
|
134
|
+
choices: [{name: 'Local directory', value: 'Directory'}, {name: 'Server', value: 'Server'}],
|
|
135
|
+
default: 'Directory'
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const getFullArchiveQuestions = async () => {
|
|
141
|
+
|
|
142
|
+
return [
|
|
143
|
+
{
|
|
144
|
+
name: 'fullArchive',
|
|
145
|
+
type: 'rawlist',
|
|
146
|
+
message: 'Type of export',
|
|
147
|
+
choices: [{name: 'Full Archive (code)', value: 'Full'}, {name: 'CL Binary (runtime only)', value: 'Binary'}],
|
|
148
|
+
default: 'Full'
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const getComponentInfoQuestions = async (rPackageJSON, library) => {
|
|
155
|
+
|
|
156
|
+
return [
|
|
157
|
+
{
|
|
158
|
+
name: 'author',
|
|
159
|
+
message: 'Author of this component',
|
|
160
|
+
default: rPackageJSON.author
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'isLocalized',
|
|
164
|
+
type: 'confirm',
|
|
165
|
+
message: 'Is this component fully localized',
|
|
166
|
+
default: false
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'isAccessible',
|
|
170
|
+
type: 'confirm',
|
|
171
|
+
message: 'Is this component accessible',
|
|
172
|
+
default: false
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'isSecure',
|
|
176
|
+
type: 'confirm',
|
|
177
|
+
message: 'Is this component and dependent modules secure',
|
|
178
|
+
default: false
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: 'license',
|
|
182
|
+
message: 'License of this component (MIT, Apache, GPL, etc.)',
|
|
183
|
+
default: rPackageJSON.license
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: 'organization',
|
|
187
|
+
message: 'Organization name',
|
|
188
|
+
default: rPackageJSON.organization
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'library',
|
|
192
|
+
message: 'Library name',
|
|
193
|
+
default: library
|
|
194
|
+
}
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const zipComponent = async componentKey => {
|
|
199
|
+
addDebugLog("zipComponent", `componentKey: ${componentKey}`, "");
|
|
200
|
+
const srcDirectory = await getComponentDirectoryPath(componentKey);
|
|
201
|
+
const buildDirectory = await path.join(path.resolve(), 'dist/components', componentKey);
|
|
202
|
+
const configJson = `${srcDirectory}/config.json`;
|
|
203
|
+
const localizationJson = `${srcDirectory}/localizations.json`;
|
|
204
|
+
|
|
205
|
+
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
206
|
+
const zipChunks = [];
|
|
207
|
+
archive.on('data', chunk => zipChunks.push(chunk));
|
|
208
|
+
|
|
209
|
+
// Add src directory
|
|
210
|
+
archive.directory(srcDirectory, 'src');
|
|
211
|
+
|
|
212
|
+
// Add config.json file
|
|
213
|
+
if (fs.existsSync(configJson)) {
|
|
214
|
+
archive.file(configJson, { name: path.basename(configJson) });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
let lJson = "";
|
|
218
|
+
|
|
219
|
+
// Add localizations.json file if it exists
|
|
220
|
+
if (fs.existsSync(localizationJson)) {
|
|
221
|
+
archive.file(localizationJson, { name: path.basename(localizationJson) });
|
|
222
|
+
lJson = JSON.parse(Buffer.from(fs.readFileSync((localizationJson))).toString());
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Add build directory
|
|
226
|
+
archive.directory(buildDirectory, false);
|
|
227
|
+
|
|
228
|
+
await archive.finalize();
|
|
229
|
+
|
|
230
|
+
const zipBuffer = Buffer.concat(zipChunks);
|
|
231
|
+
console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
|
|
232
|
+
const zipContent = zipBuffer.toString('base64');
|
|
233
|
+
|
|
234
|
+
//let configContent = Buffer.from(fs.readFileSync(configJson)).toString();
|
|
235
|
+
const configContent = JSON.parse(Buffer.from(fs.readFileSync(configJson)).toString());
|
|
236
|
+
// configContent = configContent.replaceAll("\n", "");
|
|
237
|
+
|
|
238
|
+
let output = { configContent };
|
|
239
|
+
if (lJson != "") {
|
|
240
|
+
output = { ...output, localizationJson: lJson};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (fs.existsSync('dist')) {
|
|
244
|
+
fs.rm('dist', { recursive: true }, err => {
|
|
245
|
+
if (err) {
|
|
246
|
+
throw err;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
return { zipContent, ...output};
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export const zipRC = async (content, archiveDirectory, archiveFileName) => {
|
|
256
|
+
addDebugLog("zipRC", ``, "");
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
// const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
|
|
261
|
+
// const mainDirectory = process.cwd();
|
|
262
|
+
// const archiveDirectory = join (mainDirectory, ARCHIVES_PATH, `${componentKey}`, `${version}`);
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
if (!fs.existsSync(archiveDirectory)) {
|
|
266
|
+
fs.mkdirSync(archiveDirectory, { recursive: true });
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const archiveFile = join(archiveDirectory, archiveFileName);
|
|
270
|
+
|
|
271
|
+
const output = fs.createWriteStream(archiveFile);
|
|
272
|
+
const archive = archiver('zip', {
|
|
273
|
+
zlib: { level: 9 } // Sets the compression level.
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const zipChunks = [];
|
|
277
|
+
archive.on('data', chunk => zipChunks.push(chunk));
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
archive.append( JSON.stringify(content), { name: 'componentData.json' });
|
|
281
|
+
|
|
282
|
+
// pipe archive data to the file
|
|
283
|
+
archive.pipe(output);
|
|
284
|
+
|
|
285
|
+
output.on('end', function() {
|
|
286
|
+
console.log('Data has been drained');
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
// good practice to catch warnings (ie stat failures and other non-blocking errors)
|
|
291
|
+
archive.on('warning', function(err) {
|
|
292
|
+
if (err.code === 'ENOENT') {
|
|
293
|
+
// log warning
|
|
294
|
+
} else {
|
|
295
|
+
// throw error
|
|
296
|
+
throw err;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// good practice to catch this error explicitly
|
|
301
|
+
archive.on('error', function(err) {
|
|
302
|
+
throw err;
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
await archive.finalize();
|
|
306
|
+
|
|
307
|
+
return output;
|
|
308
|
+
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
export const updateSavedExportFilePath = async(filePath) => {
|
|
314
|
+
const currentDirectory = process.cwd();
|
|
315
|
+
const arPathParts = currentDirectory.split(path.sep);
|
|
316
|
+
const configDef = getConfigDefaults();
|
|
317
|
+
|
|
318
|
+
let defaultPath = join(path.sep, arPathParts[0], arPathParts[1], arPathParts[2]);
|
|
319
|
+
|
|
320
|
+
if (path.sep != "/") {
|
|
321
|
+
// windows
|
|
322
|
+
if (defaultPath.indexOf(path.sep) === 0) {
|
|
323
|
+
// if start with \\, then remove
|
|
324
|
+
defaultPath = defaultPath.substring(1);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (filePath.indexOf(defaultPath) === 0) {
|
|
328
|
+
let relativePath = "";
|
|
329
|
+
if (filePath !== defaultPath) {
|
|
330
|
+
// same starting path, so we can save the relative
|
|
331
|
+
relativePath = filePath.replace(defaultPath.concat(path.sep), "");
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
await setConfigExportRelativePath(relativePath);
|
|
335
|
+
await forceDefaultsUpdate();
|
|
336
|
+
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
// mac
|
|
341
|
+
if (filePath.indexOf(defaultPath) === 0) {
|
|
342
|
+
|
|
343
|
+
let relativePath = "";
|
|
344
|
+
if (filePath !== defaultPath) {
|
|
345
|
+
// same starting path, so we can save the relative
|
|
346
|
+
relativePath = filePath.replace(defaultPath.concat("/"), "");
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
await setConfigExportRelativePath(relativePath);
|
|
351
|
+
await forceDefaultsUpdate();
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { Listr } from 'listr2';
|
|
7
|
+
|
|
8
|
+
import validate from '../validator/index.js';
|
|
9
|
+
import bundleComponent from '../bundle/index.js';
|
|
10
|
+
import { lintComponent } from '../linter/index.js';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
checkPathAccess,
|
|
14
|
+
showVersion,
|
|
15
|
+
addDebugLog,
|
|
16
|
+
getComponents,
|
|
17
|
+
getConfigDefaults,
|
|
18
|
+
getPegaServerConfig,
|
|
19
|
+
getLibraryBased,
|
|
20
|
+
getComponentDirectoryPath,
|
|
21
|
+
getServerType
|
|
22
|
+
} from '../../util.js';
|
|
23
|
+
import { TASKS_CONFIG_JSON_FILENAME, PACKAGE_JSON_FILENAME } from '../../constants.js';
|
|
24
|
+
import { getFilePathQuestions, updateSavedExportFilePath, zipComponent, zipRC, getComponentInfoQuestions } from './helper.js';
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
import inquirerFuzzyPath from '@pega/inquirer-fuzzy-path';
|
|
28
|
+
|
|
29
|
+
const currentDirectory = process.cwd();
|
|
30
|
+
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
31
|
+
|
|
32
|
+
export default async options => {
|
|
33
|
+
await showVersion();
|
|
34
|
+
|
|
35
|
+
await checkPathAccess(pegaConfigJsonPath);
|
|
36
|
+
|
|
37
|
+
const isLibraryBasedCL = getLibraryBased();
|
|
38
|
+
if (isLibraryBasedCL) {
|
|
39
|
+
console.log(`Command only supported for ${chalk.bold.green('non library mode')} components.`)
|
|
40
|
+
process.exit();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const serverType = getServerType();
|
|
44
|
+
if (serverType != "launchpad") {
|
|
45
|
+
console.log(`Command only supported for ${chalk.green('Launchpad')}.`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
addDebugLog("export RC", "", "+");
|
|
51
|
+
|
|
52
|
+
let exportTo = "";
|
|
53
|
+
|
|
54
|
+
if (options.params.length >= 8) {
|
|
55
|
+
|
|
56
|
+
// params pick full, what library/name and path
|
|
57
|
+
// vs no params then we will select the current library
|
|
58
|
+
// let fullArchive = options.params[3];
|
|
59
|
+
// const libraryName = options.params[4];
|
|
60
|
+
// const libraryVersion = options.params[5];
|
|
61
|
+
// const filePath = options.params[6];
|
|
62
|
+
// exportTo = "Directory";
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// const currentOrArchive = options.params[7];
|
|
66
|
+
|
|
67
|
+
// await exportArch(filePath, libraryName, libraryVersion, fullArchive, currentOrArchive );
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
let orgLibName = "";
|
|
72
|
+
let selectedVersion = "";
|
|
73
|
+
let fullArchive = "";
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// if (options.params.length >= 5) {
|
|
77
|
+
// fullArchive = options.params[3];
|
|
78
|
+
// orgLibName = options.params[4];
|
|
79
|
+
// if (options.params.length >= 6) {
|
|
80
|
+
// selectedVersion = options.params[5];
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
83
|
+
|
|
84
|
+
// disable question to build "CL"
|
|
85
|
+
// if (fullArchive === "" ) {
|
|
86
|
+
// const fullArchiveQuestions = await getFullArchiveQuestions();
|
|
87
|
+
// const fullArchiveAnswers = await inquirer.prompt(fullArchiveQuestions);
|
|
88
|
+
// ({ fullArchive } = fullArchiveAnswers);
|
|
89
|
+
// }
|
|
90
|
+
|
|
91
|
+
// force full archive, binary deprecated
|
|
92
|
+
fullArchive = "Full";
|
|
93
|
+
|
|
94
|
+
let filePathQuestions;
|
|
95
|
+
let filePathAnswers;
|
|
96
|
+
let filePath;
|
|
97
|
+
let content;
|
|
98
|
+
|
|
99
|
+
const localComponents = await getComponents();
|
|
100
|
+
const defaultPegaConfig = await getPegaServerConfig();
|
|
101
|
+
const configDef = getConfigDefaults();
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (localComponents.length > 0) {
|
|
105
|
+
|
|
106
|
+
const compAnswers = await inquirer.prompt([
|
|
107
|
+
{
|
|
108
|
+
name: 'componentKey',
|
|
109
|
+
type: 'rawlist',
|
|
110
|
+
message: 'Select component to export as a runtime component',
|
|
111
|
+
choices: localComponents
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'devBuild',
|
|
115
|
+
type: 'confirm',
|
|
116
|
+
message: 'Generate development build ?',
|
|
117
|
+
default: defaultPegaConfig.devBuild
|
|
118
|
+
}
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
content = {
|
|
122
|
+
...compAnswers
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
inquirer.registerPrompt('fuzzypath', inquirerFuzzyPath);
|
|
127
|
+
const filePathQuestions = await getFilePathQuestions();
|
|
128
|
+
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
129
|
+
const exportPath = filePathAnswers.filePath;
|
|
130
|
+
const componentKey = compAnswers.componentKey;
|
|
131
|
+
const devBuild = compAnswers.devBuild;
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
if (!fs.existsSync(exportPath)) {
|
|
136
|
+
console.log(`\Path: ${chalk.yellow(`${exportPath}`)} doesn't exist.`);
|
|
137
|
+
const newPathAnswer = await inquirer.prompt([
|
|
138
|
+
{
|
|
139
|
+
name: 'createNewPath',
|
|
140
|
+
type: 'confirm',
|
|
141
|
+
message: 'Create path',
|
|
142
|
+
default: true
|
|
143
|
+
},
|
|
144
|
+
]);
|
|
145
|
+
const createNewPath = newPathAnswer.createNewPath;
|
|
146
|
+
if (createNewPath) {
|
|
147
|
+
fs.mkdirSync(exportPath, { recursive: true });
|
|
148
|
+
|
|
149
|
+
await updateSavedExportFilePath(exportPath);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.log(chalk.green("Store not exported."));
|
|
153
|
+
process.exit();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const archiveFileName = `${componentKey}_${configDef.version}.RC.zip`;
|
|
158
|
+
|
|
159
|
+
if (fs.existsSync(join(exportPath, archiveFileName))) {
|
|
160
|
+
console.log(`\nFile: ${chalk.yellow(`${archiveFileName}`)} already exists in ${chalk.yellow(`${exportPath}`)}.`);
|
|
161
|
+
const overwriteQuestion = await inquirer.prompt([
|
|
162
|
+
{
|
|
163
|
+
name: 'overWriteFile',
|
|
164
|
+
type: 'confirm',
|
|
165
|
+
message: 'Overwrite',
|
|
166
|
+
default: true
|
|
167
|
+
},
|
|
168
|
+
]);
|
|
169
|
+
|
|
170
|
+
if (!overwriteQuestion.overWriteFile) {
|
|
171
|
+
console.log(chalk.green("Archive not created."));
|
|
172
|
+
process.exit();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
console.log(chalk.yellow(`\n>> You are about to create a zip file containing an independent component `));
|
|
177
|
+
console.log(chalk.yellow(`>> that others can import directly into Launchpad.`));
|
|
178
|
+
console.log(chalk.yellow(`>> You will be asked a series of questions for the benefit of others`));
|
|
179
|
+
console.log(chalk.yellow(`>> who might choose to use your component.`));
|
|
180
|
+
console.log(chalk.yellow(`\n>> These answers will be recorded in a json file within the zip file.`));
|
|
181
|
+
console.log(chalk.yellow(`>> These questions will NOT be used as a gate to prevent the creation of this component.\n`));
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
const currentDirectory = process.cwd();
|
|
185
|
+
const packagePath = join (currentDirectory, PACKAGE_JSON_FILENAME);
|
|
186
|
+
let retrievedPackageData;
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
retrievedPackageData = fs.readFileSync(packagePath);
|
|
190
|
+
}
|
|
191
|
+
catch (ex) {
|
|
192
|
+
console.log(chalk.red(`\nUnable to retrieve package.json.`))
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const rPackage = JSON.parse(retrievedPackageData);
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
const componentInfoQuestions = await getComponentInfoQuestions(rPackage, configDef.library);
|
|
200
|
+
let componentInfo = await inquirer.prompt(componentInfoQuestions);
|
|
201
|
+
|
|
202
|
+
const currentDate = new Date(Date.now());
|
|
203
|
+
const dateStamp = currentDate.toString();
|
|
204
|
+
const timeStamp = currentDate.toJSON();
|
|
205
|
+
|
|
206
|
+
componentInfo = { ...componentInfo, dependencies: rPackage.dependencies, buildDate: dateStamp, timeStamp };
|
|
207
|
+
|
|
208
|
+
console.log("\nBuilding RC...");
|
|
209
|
+
|
|
210
|
+
const sDevBuild = devBuild ? '(dev build)' : '';
|
|
211
|
+
const tasks = new Listr(
|
|
212
|
+
[
|
|
213
|
+
{
|
|
214
|
+
title: 'Validate config schema',
|
|
215
|
+
task: async () => {
|
|
216
|
+
await validate(componentKey);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
title: 'Lint component',
|
|
221
|
+
task: async () => {
|
|
222
|
+
const targetDirectory = await getComponentDirectoryPath(componentKey);
|
|
223
|
+
// console.log(`in buildComponent Lint component task: componentKey: ${componentKey} targetDirectory: ${targetDirectory}`);
|
|
224
|
+
await lintComponent(targetDirectory);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
title: `Bundle Component ${sDevBuild}`,
|
|
229
|
+
task: async () => bundleComponent(componentKey, defaultPegaConfig.sourceMap, devBuild),
|
|
230
|
+
skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
title: 'Create internal zip of component',
|
|
234
|
+
task: async () => {
|
|
235
|
+
const output = await zipComponent(componentKey);
|
|
236
|
+
content = { ...content, ...output, componentInfo: componentInfo };
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
title: 'Create zip file',
|
|
241
|
+
task: async () => {
|
|
242
|
+
const output = await zipRC(content, exportPath, archiveFileName);
|
|
243
|
+
content = { ...content, ...output };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
{
|
|
248
|
+
exitOnError: true
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
await tasks.run().catch(err => {
|
|
253
|
+
console.log(chalk.bold.red(err.toString()));
|
|
254
|
+
process.exit(1);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
console.log(`\nRuntime component ${chalk.green(`${archiveFileName}`)} has been created in ${chalk.green(`${exportPath}`)}.\n`);
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
console.log(chalk.bold.red(`\nNo components to export.\n`));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
addDebugLog("export RC", "END", "-");
|
|
267
|
+
|
|
268
|
+
};
|
|
@@ -350,7 +350,7 @@ export const updateSavedFilePath = async(filePath) => {
|
|
|
350
350
|
let relativePath = "";
|
|
351
351
|
if (filePath !== defaultPath) {
|
|
352
352
|
// same starting path, so we can save the relative
|
|
353
|
-
relativePath = filePath.replace(defaultPath.concat(
|
|
353
|
+
relativePath = filePath.replace(defaultPath.concat(path.sep), "");
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
await setConfigImportRelativePath(relativePath);
|
|
@@ -30,7 +30,7 @@ addDebugLog("getFilePathQuestions", "", "");
|
|
|
30
30
|
{
|
|
31
31
|
name: 'filePath',
|
|
32
32
|
type: 'fuzzypath',
|
|
33
|
-
message: 'Enter full
|
|
33
|
+
message: 'Enter full path of the component folder',
|
|
34
34
|
default: defaultPath,
|
|
35
35
|
excludePath: nodePath => nodePath.startsWith('node_modules'),
|
|
36
36
|
// excludePath :: (String) -> Bool
|
package/src/tasks/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { default as setPermanent } from './set-perm/index.js';
|
|
|
28
28
|
export { default as storeComponents } from './store/index.js';
|
|
29
29
|
export { default as importArchive } from './import-archive/index.js';
|
|
30
30
|
export { default as exportArchive } from './export-archive/index.js';
|
|
31
|
+
export { default as exportRC } from './export-rc/index.js';
|
|
31
32
|
export { default as importComponent } from './import-comp/index.js';
|
|
32
33
|
export { default as updateComponent } from './update/index.js';
|
|
33
34
|
export { default as validate } from './validator/index.js';
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"delete": "custom-dx-components delete",
|
|
26
26
|
"deleteAll": "custom-dx-components deleteAll",
|
|
27
27
|
"importComponent": "custom-dx-components importComponent",
|
|
28
|
+
"exportRC" : "custom-dx-components exportRC",
|
|
28
29
|
"help": "custom-dx-components showHelp",
|
|
29
30
|
"publish": "custom-dx-components publish",
|
|
30
31
|
"_***Component_mode_only***": "Component only commands",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"@babel/preset-react": "^7.27.1",
|
|
108
109
|
"@babel/preset-typescript": "^7.27.1",
|
|
109
110
|
"@pega/configs": "^0.16.3",
|
|
110
|
-
"@pega/custom-dx-components": "~0.25.
|
|
111
|
+
"@pega/custom-dx-components": "~0.25.62",
|
|
111
112
|
"@pega/pcore-pconnect-typedefs": "^4.1.0",
|
|
112
113
|
"@storybook/addon-actions": "^8.6.14",
|
|
113
114
|
"@storybook/addon-essentials": "^8.6.14",
|
package/src/util.js
CHANGED
|
@@ -47,7 +47,6 @@ import {
|
|
|
47
47
|
} from './constants.js';
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
|
|
51
50
|
const access = promisify(fs.access);
|
|
52
51
|
|
|
53
52
|
let showDebug = false;
|
|
@@ -2651,10 +2650,14 @@ if (showDebug) addDebugLog("deleteArchives", ``, "");
|
|
|
2651
2650
|
}
|
|
2652
2651
|
}
|
|
2653
2652
|
|
|
2654
|
-
export const checkLibraryAndArchives = async () => {
|
|
2653
|
+
export const checkLibraryAndArchives = async (checkArch = true) => {
|
|
2655
2654
|
if (showDebug) addDebugLog("checkLibraryAndArchives", ``, "");
|
|
2656
2655
|
const isLibraryBased = getLibraryBased();
|
|
2657
|
-
|
|
2656
|
+
let hasArch = true;
|
|
2657
|
+
if (checkArch) {
|
|
2658
|
+
hasArch = await hasArchives();
|
|
2659
|
+
|
|
2660
|
+
}
|
|
2658
2661
|
|
|
2659
2662
|
if (isLibraryBased && !hasArch) {
|
|
2660
2663
|
console.log(chalk.yellow('\nPlease create/import a library before proceeding.'));
|