@pega/custom-dx-components 0.25.22 → 0.25.24
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/tasks/build-jest-assets/index.js +0 -1
- package/src/tasks/build-lib/helper.js +0 -2
- package/src/tasks/build-lib/index.js +3 -3
- package/src/tasks/create/index.js +5 -1
- package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Icon-Button-URL/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +1 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Field/Icon-Button-URL/config.json.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/CASE/config.json.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE/config.json.mustache +1 -0
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/config.json.mustache +1 -0
- package/src/tasks/create-all/index.js +5 -1
- package/src/tasks/delete/helper.js +0 -1
- package/src/tasks/delete/index.js +5 -1
- package/src/tasks/delete-lib/helper.js +0 -1
- package/src/tasks/delete-pub/helper.js +7 -2
- package/src/tasks/delete-version/index.js +0 -1
- package/src/tasks/export-archive/helper.js +7 -1
- package/src/tasks/export-archive/index.js +10 -34
- package/src/tasks/import-archive/helper.js +19 -5
- package/src/tasks/import-archive/index.js +247 -35
- package/src/tasks/import-comp/helper.js +0 -2
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/init/template/tasks.config.json +1 -1
- package/src/tasks/list/helper.js +17 -2
- package/src/tasks/list-lib/index.js +10 -1
- package/src/tasks/list-pub/helper.js +2 -4
- package/src/tasks/list-pub/index.js +15 -2
- package/src/tasks/publish/helper.js +0 -1
- package/src/tasks/publish/index.js +13 -1
- package/src/tasks/publish-all/index.js +10 -1
- package/src/tasks/publish-archive/index.js +53 -83
- package/src/tasks/publish-lib/index.js +0 -23
- package/src/tasks/rename/index.js +9 -1
- package/src/tasks/restore/index.js +19 -13
- package/src/tasks/set-perm/index.js +0 -2
- package/src/tasks/show-help/index.js +1 -5
- package/src/tasks/show-status/index.js +19 -6
- package/src/tasks/store/index.js +39 -18
- package/src/tasks/switch-lib/helper.js +0 -1
- package/src/tasks/validator/index.js +10 -5
- package/src/util.js +21 -77
- package/tests/assets/library/components/create/Pega_DXIL_MyTestText/config.json +1 -0
- package/tests/assets/library/components/create/shared/create-nonce.ts +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyBoolean/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyCurrency/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDate/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDate/date.ts +0 -24
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDateTime/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDecimal/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDetails/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyEmail/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyForm/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyInteger/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPage/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageWidget/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyParagraph/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPercentage/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPhone/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPicklist/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyRadiobuttons/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MySearchbox/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MySearchbox/repeat-utils.ts +0 -4
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyText/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTextInput/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyURL/config.json +1 -0
- package/tests/assets/library/components/createAll/Constellation/shared/create-nonce.ts +1 -0
- package/tests/assets/original/components/create/Pega_DXIL_MyTestText/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyBoolean/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyCaseWidget/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyCurrency/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDate/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDateTime/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDecimal/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDetails/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyEmail/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyForm/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyIconButtonURL/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyInteger/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPage/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPageWidget/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyParagraph/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPercentage/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPhone/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPicklist/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyRadiobuttons/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MySearchbox/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyText/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTextInput/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/config.json +1 -0
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyURL/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyBoolean/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyCaseWidget/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyCurrency/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDate/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDateTime/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDecimal/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDetails/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyEmail/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyForm/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyIconButtonURL/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyInteger/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPage/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageWidget/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyParagraph/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPercentage/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPhone/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPicklist/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyRadiobuttons/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MySearchbox/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyText/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTextInput/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/config.json +1 -0
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyURL/config.json +1 -0
- package/tests/functional/localCreateBuildAllDeleteAll.test.js +8 -8
- package/tests/functional/localCreateBuildDelete.test.js +8 -8
- package/tests/functional/localCreateListDelete.test.js +8 -8
- package/tests/functional/localCreatePublishAllDeleteAll.test.js +8 -8
- package/tests/functional/localCreatePublishDelete.test.js +8 -8
- package/tests/functional/localCreateRenameDelete.test.js +8 -8
- package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +1 -1
- package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +1 -1
- package/tests/functional/localLibCreateLibStoreRestoreDeleteLib.test.js +376 -0
|
@@ -6,7 +6,6 @@ import inquirer from 'inquirer';
|
|
|
6
6
|
import ncp from 'ncp';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import { Listr } from 'listr2';
|
|
9
|
-
import archiver from 'archiver';
|
|
10
9
|
|
|
11
10
|
import StreamZip from 'node-stream-zip';
|
|
12
11
|
|
|
@@ -19,7 +18,6 @@ import {
|
|
|
19
18
|
getDirectoryFiles,
|
|
20
19
|
addDebugLog,
|
|
21
20
|
checkAccessTokenExpiration,
|
|
22
|
-
checkLibraryAndArchives,
|
|
23
21
|
getConfigDefaults,
|
|
24
22
|
getLibraryBased,
|
|
25
23
|
unZipFromArchive,
|
|
@@ -233,16 +231,193 @@ export const moveComp = async(componentKey, orgLibName, version, copyShared, opt
|
|
|
233
231
|
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
|
|
234
232
|
}
|
|
235
233
|
|
|
234
|
+
|
|
236
235
|
export const importArch = async(filePath, fileName, hadArchive) => {
|
|
236
|
+
addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
237
|
+
|
|
238
|
+
const currentDirectory = process.cwd();
|
|
239
|
+
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
const zipFilePath = join(filePath, fileName);
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
// we are going to use node stream zip to list contents of archive first,
|
|
246
|
+
// before we un archive to a temp directory. If pass, then un archive
|
|
247
|
+
let passCount = 0;
|
|
248
|
+
|
|
249
|
+
// check to see if have a tasks.config.json and package,json file, if not, archive not good
|
|
250
|
+
const tempTasksConfig = join(tempDirectory, "tasks.config.json");
|
|
251
|
+
const tempPackage = join(tempDirectory, "package.json");
|
|
252
|
+
const tasksConfig = "tasks.config.json";
|
|
253
|
+
const packageJson = "package.json";
|
|
254
|
+
try {
|
|
255
|
+
const testZip = new StreamZip.async({ file: zipFilePath});
|
|
256
|
+
const entries = await testZip.entries();
|
|
257
|
+
|
|
258
|
+
for (const entry of Object.values(entries)) {
|
|
259
|
+
if ( entry.name.indexOf(packageJson) >= 0 || entry.name.indexOf(tasksConfig) >= 0) {
|
|
260
|
+
passCount++;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Do not forget to close the file once you're done
|
|
265
|
+
await testZip.close();
|
|
266
|
+
}
|
|
267
|
+
catch (ex) {
|
|
268
|
+
passCount = 0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
if (passCount < 2) {
|
|
273
|
+
console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
|
|
274
|
+
process.exit(1);
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
await unZipFromArchive(zipFilePath);
|
|
279
|
+
|
|
280
|
+
// need to get info from tasks.config and package.json
|
|
281
|
+
// we won't rely on name of file, as owner can change it
|
|
282
|
+
|
|
283
|
+
let organization = await getPackgeOrg(tempPackage);
|
|
284
|
+
let localConfig = await getLocalConfigData(tempTasksConfig);
|
|
285
|
+
|
|
286
|
+
let libName = localConfig.library;
|
|
287
|
+
let orgLibName = `${organization}_${libName}`;
|
|
288
|
+
const version = localConfig.buildVersion;
|
|
289
|
+
const devBuild = localConfig.devBuild;
|
|
290
|
+
|
|
291
|
+
const configDef = getConfigDefaults();
|
|
292
|
+
|
|
293
|
+
if (organization !== configDef.organization) {
|
|
294
|
+
console.log(`\nImported ${chalk.yellow(`${orgLibName}/${version}`)} is not the same organization as your current organization: ${chalk.yellow(`${configDef.organization}`)}.`);
|
|
295
|
+
console.log(`\nTo import, the organization of the components will be changed to match your organization.`);
|
|
296
|
+
console.log(`\n\t>>> If you don't want this to happen, then end and create a new project with an organization`);
|
|
297
|
+
console.log(`\t of ${chalk.yellow(`${organization}`)} and import there.\n`);
|
|
298
|
+
|
|
299
|
+
const proceedAnswers = await inquirer.prompt([
|
|
300
|
+
|
|
301
|
+
{
|
|
302
|
+
name: 'okToContinue',
|
|
303
|
+
type: 'confirm',
|
|
304
|
+
message: `Ok to proceed ?`,
|
|
305
|
+
default: true
|
|
306
|
+
}
|
|
307
|
+
]);
|
|
308
|
+
|
|
309
|
+
if (proceedAnswers.okToContinue) {
|
|
310
|
+
// check if new version matches existing
|
|
311
|
+
// -dev is already on version, if present, so "false", for devBuild here
|
|
312
|
+
const alreadyExists = await hasLibraryAndVersion(libName, version, false);
|
|
313
|
+
if (alreadyExists) {
|
|
314
|
+
console.log(`${chalk.yellow(`${configDef.organization}_${libName}/${version}`)} already exists.`);
|
|
315
|
+
const archDirectories = await getLibraryArchiveDirectories();
|
|
316
|
+
const newLibNameAnswers = await inquirer.prompt([
|
|
317
|
+
{
|
|
318
|
+
name: 'libraryName',
|
|
319
|
+
message: 'Enter new libray name',
|
|
320
|
+
validate: value => {
|
|
321
|
+
/* value should not be empty
|
|
322
|
+
It should not have spaces
|
|
323
|
+
It should not start with a number
|
|
324
|
+
Only case-insensitive alphanumeric values are allowed
|
|
325
|
+
*/
|
|
326
|
+
if (value && !/^\d/.test(value) && value === sanitize(value)) {
|
|
327
|
+
if (archDirectories && archDirectories.length > 0) {
|
|
328
|
+
const newOrgLib = `${configDef.organization}_${value}`;
|
|
329
|
+
if (archDirectories.includes(newOrgLib)) {
|
|
330
|
+
return `Library ${value} already exists.`;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
return 'Only alphanumeric values are allowed, starting with alphabets, no spaces.';
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
]);
|
|
347
|
+
|
|
348
|
+
libName = newLibNameAnswers.libraryName;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// rename orgLibName
|
|
352
|
+
orgLibName = `${configDef.organization}_${libName}`;
|
|
353
|
+
|
|
354
|
+
// update temp with new info
|
|
355
|
+
await updateTempArchive(libName, version, devBuild);
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
process.exit();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// rearchive temp directory
|
|
366
|
+
await zipVersionAndArchive(orgLibName, version, tempDirectory);
|
|
367
|
+
|
|
368
|
+
// delete temp directory
|
|
369
|
+
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
if (hadArchive) {
|
|
373
|
+
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
374
|
+
console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.`);
|
|
375
|
+
console.log("");
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
const switchToFileName = `${orgLibName}_${version}.arch.zip`;
|
|
379
|
+
|
|
380
|
+
const tasks = new Listr(
|
|
381
|
+
[
|
|
382
|
+
{
|
|
383
|
+
title: `Restoring ${orgLibName}/${version}`,
|
|
384
|
+
task: async () => {
|
|
385
|
+
await restoreFromArchive(switchToFileName, orgLibName, version);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
],
|
|
389
|
+
{ concurrent: false, exitOnError: true }
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
393
|
+
|
|
394
|
+
await tasks.run().catch(err => {
|
|
395
|
+
console.log(chalk.bold.red(err.toString()));
|
|
396
|
+
process.exit(1);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
console.log(`${chalk.bold.green(`\nSwitched to ${orgLibName}/${version}!\n`)}`);
|
|
400
|
+
|
|
401
|
+
await forceDefaultsUpdate();
|
|
402
|
+
await showCurrentStatus();
|
|
403
|
+
|
|
404
|
+
console.log('\n***************************************************************');
|
|
405
|
+
console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
|
|
406
|
+
console.log(`>>> PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
|
|
407
|
+
console.log('***************************************************************\n');
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export const importArchServer = async(filePath, fileName, hadArchive) => {
|
|
237
414
|
addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
238
415
|
|
|
239
416
|
const currentDirectory = process.cwd();
|
|
240
417
|
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
241
418
|
|
|
242
|
-
|
|
243
419
|
const zipFilePath = join(filePath, fileName);
|
|
244
420
|
|
|
245
|
-
|
|
246
421
|
// we are going to use node stream zip to list contents of archive first,
|
|
247
422
|
// before we un archive to a temp directory. If pass, then un archive
|
|
248
423
|
let passCount = 0;
|
|
@@ -252,8 +427,9 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
252
427
|
const tempPackage = join(tempDirectory, "package.json");
|
|
253
428
|
const tasksConfig = "tasks.config.json";
|
|
254
429
|
const packageJson = "package.json";
|
|
430
|
+
let testZip;
|
|
255
431
|
try {
|
|
256
|
-
|
|
432
|
+
testZip = new StreamZip.async({ file: zipFilePath});
|
|
257
433
|
const entries = await testZip.entries();
|
|
258
434
|
|
|
259
435
|
for (const entry of Object.values(entries)) {
|
|
@@ -262,32 +438,34 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
262
438
|
}
|
|
263
439
|
}
|
|
264
440
|
|
|
265
|
-
// Do not forget to close the file once you're done
|
|
266
|
-
await testZip.close();
|
|
267
441
|
}
|
|
268
442
|
catch (ex) {
|
|
269
443
|
passCount = 0;
|
|
270
444
|
}
|
|
271
445
|
|
|
272
|
-
|
|
273
446
|
if (passCount < 2) {
|
|
274
447
|
console.log(chalk.red.bold(`Zip file: ${fileName} not a compatible DX Component archive.`));
|
|
448
|
+
// Do not forget to close the file once you're done
|
|
449
|
+
await testZip.close();
|
|
450
|
+
|
|
275
451
|
process.exit(1);
|
|
276
452
|
|
|
277
453
|
}
|
|
278
454
|
|
|
279
|
-
|
|
455
|
+
// make directory in temp dir, can NOT be the same directory as the zip file is in
|
|
456
|
+
const dirName = fileName.replaceAll(".zip", "");
|
|
457
|
+
const newDirPath = join(TEMP_PATH, dirName);
|
|
458
|
+
fs.mkdirSync(newDirPath);
|
|
280
459
|
|
|
460
|
+
const count = await testZip.extract(null, newDirPath);
|
|
281
461
|
|
|
462
|
+
// Do not forget to close the file once you're done
|
|
463
|
+
await testZip.close();
|
|
282
464
|
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
// console.log(chalk.red.bold("Cleaning up..."));
|
|
286
|
-
// fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 5 });
|
|
287
|
-
// console.log(chalk.red.bold("Done."));
|
|
288
|
-
// process.exit(1);
|
|
465
|
+
// we want file contents to be in the TEMP_PATH (copying, but temp directory eventually will be deleted)
|
|
466
|
+
fs.cpSync(newDirPath, TEMP_PATH, {recursive: true});
|
|
289
467
|
|
|
290
|
-
//
|
|
468
|
+
// await unZipFromArchive(zipFilePath);
|
|
291
469
|
|
|
292
470
|
// need to get info from tasks.config and package.json
|
|
293
471
|
// we won't rely on name of file, as owner can change it
|
|
@@ -383,7 +561,8 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
383
561
|
|
|
384
562
|
if (hadArchive) {
|
|
385
563
|
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
386
|
-
console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib
|
|
564
|
+
console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.`);
|
|
565
|
+
console.log("");
|
|
387
566
|
}
|
|
388
567
|
else {
|
|
389
568
|
const switchToFileName = `${orgLibName}_${version}.arch.zip`;
|
|
@@ -451,19 +630,11 @@ export const writeZipBuffer = async(fileName, fileBuffer) => {
|
|
|
451
630
|
const currentDirectory = process.cwd();
|
|
452
631
|
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
453
632
|
|
|
454
|
-
// have to decode it and then re-encode it.
|
|
455
|
-
let decodedString;
|
|
456
|
-
try {
|
|
457
|
-
decodedString = atob(fileBuffer);
|
|
458
|
-
} catch (error) {
|
|
459
|
-
}
|
|
460
|
-
|
|
461
633
|
if (!fs.existsSync (tempDirectory)) {
|
|
462
634
|
fs.mkdirSync(tempDirectory);
|
|
463
635
|
}
|
|
464
636
|
|
|
465
637
|
const filePath = join(tempDirectory, fileName);
|
|
466
|
-
|
|
467
638
|
fs.writeFileSync(filePath, fileBuffer, 'base64');
|
|
468
639
|
|
|
469
640
|
}
|
|
@@ -539,18 +710,39 @@ export default async options => {
|
|
|
539
710
|
|
|
540
711
|
const arArchData = archiveData.split(",");
|
|
541
712
|
let fileName = `${arArchData[1]}.${arArchData[2]}`;
|
|
713
|
+
let fileData;
|
|
714
|
+
|
|
715
|
+
console.log("");
|
|
542
716
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
717
|
+
const tasks = new Listr(
|
|
718
|
+
[
|
|
719
|
+
{
|
|
720
|
+
title: 'Fetching archive from server',
|
|
721
|
+
task: async () => {
|
|
722
|
+
// get archive
|
|
723
|
+
fileData = await getServerLibraryArchive(arArchData[0],arArchData[1], arArchData[2], arArchData[3], arArchData[4]);
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
title: 'Saving archive in store',
|
|
728
|
+
task: async () => {
|
|
729
|
+
await writeZipBuffer(fileName, fileData.pyFileSource);
|
|
730
|
+
|
|
731
|
+
// import archive
|
|
732
|
+
const currentDirectory = process.cwd();
|
|
733
|
+
const tempDirectory = join(currentDirectory, TEMP_PATH);
|
|
546
734
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
735
|
+
await importArchServer( tempDirectory, fileName, hasArch);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
],
|
|
739
|
+
{ concurrent: false, exitOnError: true }
|
|
740
|
+
);
|
|
550
741
|
|
|
551
|
-
await
|
|
552
|
-
|
|
553
|
-
|
|
742
|
+
await tasks.run().catch(err => {
|
|
743
|
+
console.log(chalk.bold.red(err.toString()));
|
|
744
|
+
process.exit(1);
|
|
745
|
+
});
|
|
554
746
|
|
|
555
747
|
}
|
|
556
748
|
|
|
@@ -595,8 +787,28 @@ export default async options => {
|
|
|
595
787
|
const fileNameAnswers = await inquirer.prompt(fileNameQuestions);
|
|
596
788
|
const {fileName} = fileNameAnswers;
|
|
597
789
|
|
|
790
|
+
console.log("");
|
|
791
|
+
|
|
792
|
+
const tasks = new Listr(
|
|
793
|
+
[
|
|
794
|
+
{
|
|
795
|
+
title: `Importing archive`,
|
|
796
|
+
task: async () => {
|
|
797
|
+
await importArch( filePath, fileName, hasArch);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
],
|
|
801
|
+
{ concurrent: false, exitOnError: true }
|
|
802
|
+
);
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
await tasks.run().catch(err => {
|
|
806
|
+
console.log(chalk.bold.red(err.toString()));
|
|
807
|
+
process.exit(1);
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
console.log("");
|
|
598
811
|
|
|
599
|
-
await importArch( filePath, fileName, hasArch);
|
|
600
812
|
|
|
601
813
|
// reapply to save if changed, because imported task.config may have overriden and we want
|
|
602
814
|
// to keep what was entered as the latest
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@babel/preset-react": "^7.26.3",
|
|
108
108
|
"@babel/preset-typescript": "^7.26.0",
|
|
109
109
|
"@pega/configs": "^0.16.2",
|
|
110
|
-
"@pega/custom-dx-components": "~0.25.
|
|
110
|
+
"@pega/custom-dx-components": "~0.25.24",
|
|
111
111
|
"@pega/pcore-pconnect-typedefs": "^4.1.0-alpha.1",
|
|
112
112
|
"@storybook/addon-actions": "^7.6.19",
|
|
113
113
|
"@storybook/addon-essentials": "^7.6.19",
|
package/src/tasks/list/helper.js
CHANGED
|
@@ -4,8 +4,23 @@ import chalk from 'chalk';
|
|
|
4
4
|
import fetch from 'node-fetch';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
LIST_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
9
|
+
LP_LIST_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
10
|
+
TOKEN_PATH, COMPONENT_SCHEMA,
|
|
11
|
+
TASKS_CONFIG_JSON_FILENAME,
|
|
12
|
+
COMPONENTS_DIRECTORY_PATH,
|
|
13
|
+
COMPONENTS_PATH } from '../../constants.js';
|
|
14
|
+
import {
|
|
15
|
+
constructCompleteUrl,
|
|
16
|
+
getComponents,
|
|
17
|
+
getPegaServerConfig,
|
|
18
|
+
getHttpsAgent,
|
|
19
|
+
addDebugLog,
|
|
20
|
+
getLibraryBased,
|
|
21
|
+
getComponentsConfigs,
|
|
22
|
+
getConfigDefaults,
|
|
23
|
+
checkAccessTokenExpiration } from '../../util.js';
|
|
9
24
|
|
|
10
25
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
11
26
|
SERVER: 'Server',
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
showVersion,
|
|
6
|
+
getLibraryBased,
|
|
7
|
+
addDebugLog,
|
|
8
|
+
checkLibraryAndArchives,
|
|
9
|
+
getLibraryArchivesVersions,
|
|
10
|
+
getConfigDefaults,
|
|
11
|
+
getLocalArchivedLibrraryVersionData,
|
|
12
|
+
getComponentsConfigs,
|
|
13
|
+
cleanUpTemp } from '../../util.js';
|
|
5
14
|
import { getArchiveLibraryQuestions } from './helper.js';
|
|
6
15
|
|
|
7
16
|
export default async (options) => {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import fetch from 'node-fetch';
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
|
|
8
7
|
import {
|
|
9
8
|
getPegaServerConfig,
|
|
@@ -11,8 +10,7 @@ import {
|
|
|
11
10
|
getC11NB2STokenAndStaticServer,
|
|
12
11
|
getApplicationAndVersionFromToken,
|
|
13
12
|
constructCompleteUrl,
|
|
14
|
-
getHttpsAgent
|
|
15
|
-
getConfigDefaults
|
|
13
|
+
getHttpsAgent
|
|
16
14
|
} from '../../util.js';
|
|
17
15
|
|
|
18
16
|
import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
showVersion,
|
|
6
|
+
getC11NB2STokenAndStaticServer,
|
|
7
|
+
getLocalLibraries,
|
|
8
|
+
getLocalLibraryVersions,
|
|
9
|
+
getLocalLibraryVersionData,
|
|
10
|
+
getLibraryBased,
|
|
11
|
+
addDebugLog,
|
|
12
|
+
checkLibraryAndArchives,
|
|
13
|
+
getConfigDefaults,
|
|
14
|
+
cleanUpTemp,
|
|
15
|
+
getPegaServerConfig,
|
|
16
|
+
getLibraryBasedCL,
|
|
17
|
+
getApplicationAndVersionFromToken } from '../../util.js';
|
|
5
18
|
|
|
6
19
|
import { listLibJSONResponse } from '@pega/constellation-dx-components-build-utils/index.js';
|
|
7
20
|
|
|
8
|
-
import {
|
|
21
|
+
import { SOURCE_OF_COMPONENT_TYPES, getServerLibraries, getInfinityLibraries, getServerLocalQuestion } from './helper.js';
|
|
9
22
|
|
|
10
23
|
|
|
11
24
|
|
|
@@ -6,7 +6,19 @@ import fs from 'fs';
|
|
|
6
6
|
import validate from '../validator/index.js';
|
|
7
7
|
import bundleComponent from '../bundle/index.js';
|
|
8
8
|
import { lintComponent } from '../linter/index.js';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
getComponentDirectoryPath,
|
|
11
|
+
getPegaServerConfig,
|
|
12
|
+
showVersion,
|
|
13
|
+
getLibraryBased,
|
|
14
|
+
addDebugLog,
|
|
15
|
+
updateServerConfigRuleSetAndVersion,
|
|
16
|
+
checkLibraryAndArchives,
|
|
17
|
+
getConfigDevBuild,
|
|
18
|
+
checkAccessTokenExpiration,
|
|
19
|
+
checkJWTExpiration,
|
|
20
|
+
getConfigDefaults,
|
|
21
|
+
getLibraryBasedCL } from '../../util.js';
|
|
10
22
|
|
|
11
23
|
import { getPublishComponentQuestions, publishComponentToServer, zipComponent } from './helper.js';
|
|
12
24
|
import { default as buildLibrary } from '../build-lib/index.js';
|
|
@@ -5,7 +5,16 @@ import chalk from 'chalk';
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
6
|
import bundleComponent from '../bundle/index.js';
|
|
7
7
|
import { lintComponent } from '../linter/index.js';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
getComponents,
|
|
10
|
+
getComponentDirectoryPath,
|
|
11
|
+
checkAccessTokenExpiration,
|
|
12
|
+
showVersion,
|
|
13
|
+
getLibraryBased,
|
|
14
|
+
addDebugLog,
|
|
15
|
+
getPegaServerConfig,
|
|
16
|
+
updateServerConfigRuleSetAndVersion,
|
|
17
|
+
checkLibraryAndArchives } from '../../util.js';
|
|
9
18
|
|
|
10
19
|
import {
|
|
11
20
|
getPublishComponentQuestions,
|