@pega/custom-dx-components 0.242.66 → 0.242.67
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/constants.js +1 -0
- package/src/tasks/export-archive/helper.js +14 -0
- package/src/tasks/export-archive/index.js +151 -28
- package/src/tasks/init/template/package.json.mustache +5 -4
- package/src/util.js +64 -14
- package/tests/functional/localLibCreateLibExportImportLib.test.js +1 -1
- package/tests/functional/localLibCreateLibExportLib.test.js +1 -1
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -15,6 +15,7 @@ export const LIBRARY_BASED = 'libraryMode';
|
|
|
15
15
|
export const SHARED_DIRECTORY = 'shared';
|
|
16
16
|
export const SHOW_DEBUG = 'showDebug';
|
|
17
17
|
export const ARCHIVES_PATH = 'store';
|
|
18
|
+
export const BIN_ARCHIVES_PATH = 'bin-arch';
|
|
18
19
|
export const TEMP_PATH = 'store/temp';
|
|
19
20
|
export const COMPONENTS_CONFIG_FILE_NAME = 'componentsconfig.json';
|
|
20
21
|
|
|
@@ -86,6 +86,20 @@ addDebugLog("getLibraryVersionQuestion", "", "");
|
|
|
86
86
|
];
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
export const getFullArchiveQuestions = async () => {
|
|
90
|
+
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
name: 'fullArchive',
|
|
94
|
+
type: 'rawlist',
|
|
95
|
+
message: 'Type of export',
|
|
96
|
+
choices: [{name: 'Full Archive (code)', value: 'Full'}, {name: 'CL Binary (runtime only)', value: 'Binary'}],
|
|
97
|
+
default: 'Full'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
|
|
89
103
|
export const updateSavedExportFilePath = async(filePath) => {
|
|
90
104
|
const currentDirectory = process.cwd();
|
|
91
105
|
const arPathParts = currentDirectory.split(path.sep);
|
|
@@ -15,11 +15,12 @@ import {
|
|
|
15
15
|
getConfigDefaults,
|
|
16
16
|
getLibraryBased,
|
|
17
17
|
zipVersionAndArchive,
|
|
18
|
+
zipVersionAndArchiveCL,
|
|
18
19
|
cleanUpTemp
|
|
19
20
|
} from '../../util.js';
|
|
20
|
-
import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH } from '../../constants.js';
|
|
21
|
-
import { getFilePathQuestions, getLibraryQuestion, getLibraryVersionQuestion, updateSavedExportFilePath } from './helper.js';
|
|
22
|
-
import {
|
|
21
|
+
import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, BIN_ARCHIVES_PATH } from '../../constants.js';
|
|
22
|
+
import { getFilePathQuestions, getLibraryQuestion, getLibraryVersionQuestion, updateSavedExportFilePath, getFullArchiveQuestions } from './helper.js';
|
|
23
|
+
import { localBuildLibrary } from '../build-lib/index.js';
|
|
23
24
|
|
|
24
25
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
25
26
|
const currentDirectory = process.cwd();
|
|
@@ -75,9 +76,95 @@ addDebugLog("updateFile", `fileName: ${fileName}, oldComponentKeyPC: ${oldCompon
|
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
|
|
79
|
+
export const exportCLArch = async(exportPath, orgLibName, selectedVersion) => {
|
|
80
|
+
addDebugLog("exportCLArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName}, selectedVersion: ${selectedVersion}`, "");
|
|
81
|
+
const currentDirectory = process.cwd();
|
|
82
|
+
const archiveDirectory = join (currentDirectory, BIN_ARCHIVES_PATH);
|
|
83
|
+
const fileName = `${orgLibName}_${selectedVersion}.zip`;
|
|
84
|
+
const archFileName = join(archiveDirectory, fileName);
|
|
85
|
+
const configDef = await getConfigDefaults();
|
|
86
|
+
|
|
87
|
+
const exportFile = join(exportPath, fileName);
|
|
88
|
+
let output;
|
|
89
|
+
|
|
90
|
+
// need to build the libary
|
|
91
|
+
console.log(chalk.green(`\nBuilding binaries...\n`));
|
|
92
|
+
const arOrgLib = orgLibName.split("_")
|
|
93
|
+
const arVersion = selectedVersion.split("-");
|
|
94
|
+
const devBuild = arVersion.length > 1 ? true : false;
|
|
95
|
+
|
|
96
|
+
await localBuildLibrary(arOrgLib[0], arOrgLib[1], arVersion[0], devBuild);
|
|
97
|
+
|
|
98
|
+
const libraryDir = join(currentDirectory, orgLibName, selectedVersion );
|
|
99
|
+
if (fs.existsSync(libraryDir)) {
|
|
100
|
+
console.log(chalk.green(`\nExporting binaries...\n`));
|
|
101
|
+
|
|
102
|
+
if (!fs.existsSync(exportPath)) {
|
|
103
|
+
console.log(`\Path: ${chalk.yellow(`${exportPath}`)} doesn't exist.`);
|
|
104
|
+
const newPathAnswer = await inquirer.prompt([
|
|
105
|
+
{
|
|
106
|
+
name: 'createNewPath',
|
|
107
|
+
type: 'confirm',
|
|
108
|
+
message: 'Create path',
|
|
109
|
+
default: true
|
|
110
|
+
},
|
|
111
|
+
]);
|
|
112
|
+
const createNewPath = newPathAnswer.createNewPath;
|
|
113
|
+
if (createNewPath) {
|
|
114
|
+
fs.mkdirSync(exportPath, { recursive: true });
|
|
115
|
+
|
|
116
|
+
await updateSavedExportFilePath(exportPath);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
console.log(chalk.green("Store not exported."));
|
|
120
|
+
process.exit();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (fs.existsSync(exportFile)) {
|
|
125
|
+
console.log(`\nFile: ${chalk.yellow(`${fileName}`)} already exists in ${chalk.yellow(`${exportPath}`)}.`);
|
|
126
|
+
const overwriteQuestion = await inquirer.prompt([
|
|
127
|
+
{
|
|
128
|
+
name: 'overWriteFile',
|
|
129
|
+
type: 'confirm',
|
|
130
|
+
message: 'Overrwrite',
|
|
131
|
+
default: true
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
|
|
135
|
+
if (!overwriteQuestion.overWriteFile) {
|
|
136
|
+
console.log(chalk.green("Store not exported."));
|
|
137
|
+
process.exit();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
// archive it
|
|
144
|
+
output = await zipVersionAndArchiveCL(configDef.currentOrgLib, configDef.buildVersion);
|
|
145
|
+
|
|
146
|
+
// if archiving, need to wait before copying
|
|
147
|
+
output.on('close', function() {
|
|
148
|
+
fs.copyFileSync(archFileName, exportFile );
|
|
149
|
+
|
|
150
|
+
console.log(`\n${chalk.green(`${fileName}`)} has been exported to ${chalk.green(`${exportPath}`)}`);
|
|
151
|
+
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
console.log.chalk.green(`\nBinary does not exist.`);
|
|
157
|
+
}
|
|
158
|
+
|
|
78
159
|
|
|
79
160
|
|
|
80
|
-
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
export const exportArch = async(exportPath, orgLibName, selectedVersion, fullArchive = "Full", currentOrArchive = "" ) => {
|
|
81
168
|
addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName}, selectedVersion: ${selectedVersion}`, "");
|
|
82
169
|
const currentDirectory = process.cwd();
|
|
83
170
|
const archiveDirectory = join (currentDirectory, ARCHIVES_PATH, `${orgLibName}`, `${selectedVersion}`);
|
|
@@ -91,6 +178,11 @@ addDebugLog("exportArch", `exportPath: ${exportPath}, orgLibName: ${orgLibName},
|
|
|
91
178
|
|
|
92
179
|
let archiveBeforeStore = false;
|
|
93
180
|
|
|
181
|
+
if (fullArchive != "Full") {
|
|
182
|
+
await exportCLArch(exportPath, orgLibName, selectedVersion);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
94
186
|
|
|
95
187
|
if (orgLibName === configDef.currentOrgLib && selectedVersion === configDef.buildVersion) {
|
|
96
188
|
|
|
@@ -210,46 +302,77 @@ export default async options => {
|
|
|
210
302
|
addDebugLog("exportArchive", "", "+");
|
|
211
303
|
|
|
212
304
|
|
|
213
|
-
if (options.params.length >=
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
const
|
|
305
|
+
if (options.params.length >= 8) {
|
|
306
|
+
let fullArchive = options.params[3];
|
|
307
|
+
const libraryName = options.params[4];
|
|
308
|
+
const libraryVersion = options.params[5];
|
|
309
|
+
const filePath = options.params[6];
|
|
310
|
+
|
|
218
311
|
|
|
219
|
-
|
|
312
|
+
const currentOrArchive = options.params[7];
|
|
313
|
+
|
|
314
|
+
await exportArch(filePath, libraryName, libraryVersion, fullArchive, currentOrArchive );
|
|
220
315
|
|
|
221
316
|
}
|
|
222
317
|
else {
|
|
223
318
|
let orgLibName = "";
|
|
224
319
|
let selectedVersion = "";
|
|
320
|
+
let fullArchive = "";
|
|
225
321
|
|
|
226
|
-
if (options.params.length >=
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
322
|
+
if (options.params.length >= 5) {
|
|
323
|
+
fullArchive = options.params[3];
|
|
324
|
+
orgLibName = options.params[4];
|
|
325
|
+
if (options.params.length >= 6) {
|
|
326
|
+
selectedVersion = options.params[5];
|
|
230
327
|
}
|
|
231
328
|
}
|
|
232
329
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
({ orgLibName } = libraryAnswers);
|
|
330
|
+
if (fullArchive === "" ) {
|
|
331
|
+
const fullArchiveQuestions = await getFullArchiveQuestions();
|
|
332
|
+
const fullArchiveAnswers = await inquirer.prompt(fullArchiveQuestions);
|
|
333
|
+
({ fullArchive } = fullArchiveAnswers);
|
|
238
334
|
}
|
|
239
335
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
336
|
+
let filePathQuestions;
|
|
337
|
+
let filePathAnswers;
|
|
338
|
+
let filePath;
|
|
339
|
+
|
|
340
|
+
// if Binary, then we need to just build the current library, get the results and
|
|
341
|
+
// and export an archive as zip
|
|
342
|
+
if (fullArchive === "Binary") {
|
|
343
|
+
filePathQuestions = await getFilePathQuestions();
|
|
344
|
+
filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
345
|
+
({ filePath } = filePathAnswers);
|
|
346
|
+
|
|
347
|
+
await updateSavedExportFilePath(filePath);
|
|
348
|
+
|
|
349
|
+
const configDef = getConfigDefaults();
|
|
350
|
+
orgLibName = configDef.currentOrgLib;
|
|
351
|
+
selectedVersion = configDef.buildVersion;
|
|
352
|
+
|
|
353
|
+
|
|
244
354
|
}
|
|
355
|
+
else {
|
|
356
|
+
if (orgLibName === "") {
|
|
357
|
+
const libraryQuestion = await getLibraryQuestion();
|
|
358
|
+
const libraryAnswers = await inquirer.prompt(libraryQuestion);
|
|
359
|
+
({ orgLibName } = libraryAnswers);
|
|
360
|
+
}
|
|
245
361
|
|
|
362
|
+
if (selectedVersion === "") {
|
|
363
|
+
const libraryVersionQuestion = await getLibraryVersionQuestion(orgLibName);
|
|
364
|
+
const libraryVersionAnswer = await inquirer.prompt(libraryVersionQuestion);
|
|
365
|
+
({ selectedVersion } = libraryVersionAnswer);
|
|
366
|
+
}
|
|
246
367
|
|
|
247
|
-
const filePathQuestions = await getFilePathQuestions();
|
|
248
|
-
const filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
249
|
-
let { filePath } = filePathAnswers;
|
|
250
368
|
|
|
251
|
-
|
|
369
|
+
filePathQuestions = await getFilePathQuestions();
|
|
370
|
+
filePathAnswers = await inquirer.prompt(filePathQuestions);
|
|
371
|
+
({ filePath } = filePathAnswers);
|
|
252
372
|
|
|
373
|
+
await updateSavedExportFilePath(filePath);
|
|
374
|
+
|
|
375
|
+
}
|
|
253
376
|
|
|
254
377
|
// if (path.sep === "/") {
|
|
255
378
|
// if (filePath.lastIndexOf(path.sep) != filePath.length - 1) {
|
|
@@ -257,7 +380,7 @@ export default async options => {
|
|
|
257
380
|
// }
|
|
258
381
|
// }
|
|
259
382
|
|
|
260
|
-
await exportArch( filePath, orgLibName, selectedVersion);
|
|
383
|
+
await exportArch( filePath, orgLibName, selectedVersion, fullArchive);
|
|
261
384
|
|
|
262
385
|
}
|
|
263
386
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "{{projectName}}",
|
|
3
3
|
"description": "{{description}}",
|
|
4
4
|
"organization": "{{organization}}",
|
|
5
|
+
"version": "1.0.0",
|
|
5
6
|
"main": "src/index.js",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"scripts": {
|
|
@@ -77,9 +78,9 @@
|
|
|
77
78
|
"author": "",
|
|
78
79
|
"license": "Enter License",
|
|
79
80
|
"dependencies": {
|
|
80
|
-
"@pega/cosmos-react-condition-builder": "
|
|
81
|
-
"@pega/cosmos-react-core": "
|
|
82
|
-
"@pega/cosmos-react-work": "
|
|
81
|
+
"@pega/cosmos-react-condition-builder": "^7.1.2",
|
|
82
|
+
"@pega/cosmos-react-core": "^7.1.2",
|
|
83
|
+
"@pega/cosmos-react-work": "^7.1.2",
|
|
83
84
|
"@pega/eslint-config": "^0.10.2",
|
|
84
85
|
"@pega/tsconfig": "^0.15.1",
|
|
85
86
|
"babel-loader": "^9.1.3",
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
103
|
"@pega/configs": "^0.15.1",
|
|
103
|
-
"@pega/custom-dx-components": "~0.242.
|
|
104
|
+
"@pega/custom-dx-components": "~0.242.67",
|
|
104
105
|
"@pega/pcore-pconnect-typedefs": "3.2.1",
|
|
105
106
|
"@storybook/addon-actions": "^7.6.19",
|
|
106
107
|
"@storybook/addon-essentials": "^7.6.19",
|
package/src/util.js
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
SHOW_DEBUG,
|
|
34
34
|
COMPONENTS_PATH,
|
|
35
35
|
ARCHIVES_PATH,
|
|
36
|
+
BIN_ARCHIVES_PATH,
|
|
36
37
|
TEMP_PATH,
|
|
37
38
|
JEST_TESTS_FUNCTIONAL_PATH,
|
|
38
39
|
IMPORT_RELATIVE_PATH,
|
|
@@ -1633,17 +1634,6 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
|
|
|
1633
1634
|
}
|
|
1634
1635
|
}
|
|
1635
1636
|
|
|
1636
|
-
// // Add config.json file
|
|
1637
|
-
// if (fs.existsSync(tasksConfig)) {
|
|
1638
|
-
// archive.file(tasksConfig, { name: path.basename(tasksConfig) });
|
|
1639
|
-
// }
|
|
1640
|
-
|
|
1641
|
-
// // Add package.json file
|
|
1642
|
-
// if (fs.existsSync(packageJson)) {
|
|
1643
|
-
// archive.file(packageJson, { name: path.basename(packageJson) });
|
|
1644
|
-
// }
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
1637
|
// pipe archive data to the file
|
|
1648
1638
|
archive.pipe(output);
|
|
1649
1639
|
|
|
@@ -1669,11 +1659,71 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
|
|
|
1669
1659
|
|
|
1670
1660
|
await archive.finalize();
|
|
1671
1661
|
|
|
1662
|
+
return output;
|
|
1663
|
+
|
|
1664
|
+
};
|
|
1665
|
+
|
|
1666
|
+
export const zipVersionAndArchiveCL = async (orgLibName, version, currentDirectory = "") => {
|
|
1667
|
+
if (showDebug) addDebugLog("zipVersionAndArchiveCL", `orgLibName: ${orgLibName}, version: ${version}, currentDirectory: ${currentDirectory}`, "");
|
|
1668
|
+
// const srcDirectoryPath = await getSrcDirectoryPath();
|
|
1669
|
+
if (currentDirectory === "") {
|
|
1670
|
+
currentDirectory = process.cwd();
|
|
1671
|
+
}
|
|
1672
|
+
const libDirectoryPath = join(currentDirectory, orgLibName, version);
|
|
1673
|
+
const tasksConfig = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
1674
|
+
const packageJson = join(currentDirectory, PACKAGE_JSON_FILENAME);
|
|
1675
|
+
const archiveFileName = `${orgLibName}_${version}.zip`;
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
// const configContent = Buffer.from(fs.readFileSync(configJson)).toString();
|
|
1679
|
+
const mainDirectory = process.cwd();
|
|
1680
|
+
const archiveDirectory = join (mainDirectory, BIN_ARCHIVES_PATH);
|
|
1681
|
+
if (!fs.existsSync(archiveDirectory)) {
|
|
1682
|
+
fs.mkdirSync(archiveDirectory, { recursive: true });
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1672
1685
|
|
|
1686
|
+
const archiveFile = join(archiveDirectory, archiveFileName);
|
|
1687
|
+
if (fs.existsSync(orgLibName)) {
|
|
1688
|
+
|
|
1689
|
+
}
|
|
1673
1690
|
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1691
|
+
const output = fs.createWriteStream(archiveFile);
|
|
1692
|
+
const archive = archiver('zip', {
|
|
1693
|
+
zlib: { level: 9 } // Sets the compression level.
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1696
|
+
const zipChunks = [];
|
|
1697
|
+
archive.on('data', chunk => zipChunks.push(chunk));
|
|
1698
|
+
|
|
1699
|
+
// Add src directory
|
|
1700
|
+
archive.directory(libDirectoryPath, false);
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
// pipe archive data to the file
|
|
1704
|
+
archive.pipe(output);
|
|
1705
|
+
|
|
1706
|
+
output.on('end', function() {
|
|
1707
|
+
console.log('Data has been drained');
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
// good practice to catch warnings (ie stat failures and other non-blocking errors)
|
|
1712
|
+
archive.on('warning', function(err) {
|
|
1713
|
+
if (err.code === 'ENOENT') {
|
|
1714
|
+
// log warning
|
|
1715
|
+
} else {
|
|
1716
|
+
// throw error
|
|
1717
|
+
throw err;
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
|
|
1721
|
+
// good practice to catch this error explicitly
|
|
1722
|
+
archive.on('error', function(err) {
|
|
1723
|
+
throw err;
|
|
1724
|
+
});
|
|
1725
|
+
|
|
1726
|
+
await archive.finalize();
|
|
1677
1727
|
|
|
1678
1728
|
return output;
|
|
1679
1729
|
|
|
@@ -173,7 +173,7 @@ describe(`createLib createAll exportStore importStore deleteLib: ${serverDir} -
|
|
|
173
173
|
defaultPath = "/".concat(defaultPath);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
const script = `npm run exportLibVersion Pega_DXIL 0.0.1-dev ${defaultPath} Current --prefix ../../..`;
|
|
176
|
+
const script = `npm run exportLibVersion Full Pega_DXIL 0.0.1-dev ${defaultPath} Current --prefix ../../..`;
|
|
177
177
|
const { stdout, stderr } = await exec(script);
|
|
178
178
|
|
|
179
179
|
expect(stdout).toContain('Pega_DXIL_0.0.1-dev.zip has been exported');
|
|
@@ -173,7 +173,7 @@ describe(`createLib createAll exportStore deleteLib: ${serverDir} - ${compType}`
|
|
|
173
173
|
defaultPath = "/".concat(defaultPath);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
const script = `npm run exportLibVersion Pega_DXIL 0.0.1-dev ${defaultPath} Current --prefix ../../..`;
|
|
176
|
+
const script = `npm run exportLibVersion Full Pega_DXIL 0.0.1-dev ${defaultPath} Current --prefix ../../..`;
|
|
177
177
|
const { stdout, stderr } = await exec(script);
|
|
178
178
|
|
|
179
179
|
expect(stdout).toContain('Pega_DXIL_0.0.1-dev.zip has been exported');
|