@pega/custom-dx-components 0.242.34 → 0.242.36

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +12 -0
  3. package/src/constants.js +1 -0
  4. package/src/tasks/build-lib/helper.js +0 -1
  5. package/src/tasks/create-lib/index.js +5 -3
  6. package/src/tasks/create-version/index.js +12 -1
  7. package/src/tasks/delete-lib/index.js +4 -1
  8. package/src/tasks/delete-version/index.js +3 -1
  9. package/src/tasks/export-archive/index.js +58 -41
  10. package/src/tasks/import-archive/index.js +5 -1
  11. package/src/tasks/import-comp/helper.js +47 -0
  12. package/src/tasks/import-comp/index.js +320 -0
  13. package/src/tasks/index.js +2 -0
  14. package/src/tasks/init/template/package.json.mustache +5 -3
  15. package/src/tasks/list-lib/index.js +25 -16
  16. package/src/tasks/list-pub/index.js +18 -14
  17. package/src/tasks/move/helper.js +6 -3
  18. package/src/tasks/move/index.js +99 -58
  19. package/src/tasks/publish/helper.js +8 -5
  20. package/src/tasks/publish/index.js +4 -4
  21. package/src/tasks/publish-all/helper.js +16 -10
  22. package/src/tasks/quarantine/index.js +84 -0
  23. package/src/tasks/rename-lib/index.js +0 -1
  24. package/src/tasks/revert-webpack/index.js +0 -2
  25. package/src/tasks/set-perm/index.js +18 -2
  26. package/src/tasks/show-help/index.js +6 -4
  27. package/src/tasks/store/index.js +4 -1
  28. package/src/tasks/switch-lib/index.js +3 -1
  29. package/src/tasks/switch-version/index.js +11 -1
  30. package/src/util.js +84 -25
  31. package/tests/functional/localCreateAllListDeleteAll.test.js +56 -10
  32. package/tests/functional/localCreateBuildAllDeleteAll.test.js +56 -48
  33. package/tests/functional/localCreateBuildDelete.test.js +57 -10
  34. package/tests/functional/localCreateListDelete.test.js +55 -102
  35. package/tests/functional/localCreatePublishAllDeleteAll.test.js +68 -61
  36. package/tests/functional/localCreatePublishDelete.test.js +62 -21
  37. package/tests/functional/localCreateRenameDelete.test.js +55 -140
  38. package/tests/functional/localLibCreateLibAlreadyDeleteLib.test.js +118 -0
  39. package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +241 -0
  40. package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +246 -0
  41. package/tests/functional/localLibCreateLibDeleteLib.test.js +109 -0
  42. package/tests/functional/localLibCreateLibExportImportLib.test.js +242 -0
  43. package/tests/functional/localLibCreateLibExportLib.test.js +219 -0
  44. package/tests/functional/localLibCreateLibImportCompDeleteLib.test.js +131 -0
  45. package/tests/functional/localLibCreateLibListDeleteLib.test.js +261 -0
  46. package/tests/functional/localLibCreateLibListMoveDeleteLib.test.js +236 -0
  47. package/tests/functional/localLibCreateLibListSwitchDeleteLib.test.js +237 -0
  48. package/tests/functional/localLibCreateLibPermDeleteLib.test.js +144 -0
  49. package/tests/functional/localLibCreateLibStatusDeleteLib.test.js +194 -0
  50. package/tests/functional/localLibCreateLibVersionDeleteLib.test.js +453 -0
  51. package/tests/functional/localPromoteRevertWP.test.js +83 -38
package/src/util.js CHANGED
@@ -33,7 +33,8 @@ import {
33
33
  SHOW_DEBUG,
34
34
  COMPONENTS_PATH,
35
35
  ARCHIVES_PATH,
36
- TEMP_PATH
36
+ TEMP_PATH,
37
+ JEST_TESTS_FUNCTIONAL_PATH
37
38
  } from './constants.js';
38
39
 
39
40
 
@@ -42,6 +43,8 @@ const access = promisify(fs.access);
42
43
  let showDebug = false;
43
44
  let debugLevel = 1;
44
45
  let haveDependencyDifference = false;
46
+ let addAboutData = true;
47
+
45
48
 
46
49
  // updated upon start
47
50
  let defaultConfigs = {
@@ -62,6 +65,11 @@ let pegaData = null;
62
65
  let sPegaData;
63
66
  let sPegaServerConfig;
64
67
 
68
+ export const modAddAboutData = (addInAboutData) => {
69
+ // used by jest to not put in to match assets without aboutData
70
+ addAboutData = addInAboutData;
71
+ }
72
+
65
73
  export const addDebugLog = (sFunctionName, sLogData, sIncDec) => {
66
74
 
67
75
  let sLog;
@@ -703,33 +711,42 @@ if (showDebug) addDebugLog("updateConfigVersion", `componentKey: ${componentKey}
703
711
  }
704
712
  }
705
713
 
706
- if (foundProp) {
707
- foundProp.label = aboutData;
708
- }
709
- else {
710
- // don't have "About"
711
- const aboutLabelJSON = {
712
- "format": "LABEL",
713
- "label": "About",
714
- "name": "PegaAboutLabel",
715
- "variant": "h3"
716
- };
717
- const aboutDataJSON = {
718
- "format": "LABEL",
719
- "label": aboutData,
720
- "name": "PegaAboutData",
721
- "variant": "primary"
714
+ if (addAboutData) {
715
+ if (foundProp) {
716
+ foundProp.label = aboutData;
717
+ }
718
+ else {
719
+ // don't have "About"
720
+ const aboutLabelJSON = {
721
+ "format": "LABEL",
722
+ "label": "About",
723
+ "name": "PegaAboutLabel",
724
+ "variant": "h3"
725
+ };
726
+ const aboutDataJSON = {
727
+ "format": "LABEL",
728
+ "label": aboutData,
729
+ "name": "PegaAboutData",
730
+ "variant": "primary"
731
+ }
732
+ properties.push(aboutLabelJSON);
733
+ properties.push(aboutDataJSON);
722
734
  }
723
- properties.push(aboutLabelJSON);
724
- properties.push(aboutDataJSON);
725
735
  }
736
+
737
+
726
738
  }
727
739
  } catch (er) {
728
740
  throw new Error(`Invalid schema json in config.json: ${er}`);
729
741
  }
730
742
 
731
743
  data.version = buildVersion;
732
- data.buildDate = dateStamp;
744
+
745
+ if (addAboutData) {
746
+ data.buildDate = dateStamp;
747
+ }
748
+
749
+
733
750
 
734
751
  // write back file
735
752
  fs.writeFileSync(configFile, JSON.stringify(data, null, 4), { encoding: 'utf8' });
@@ -1296,17 +1313,22 @@ if (showDebug) addDebugLog("deletePublishExtras", `libraryName: ${libraryName},
1296
1313
 
1297
1314
  export const cleanUp = async () => {
1298
1315
  if (showDebug) addDebugLog("cleanUp", "", "");
1316
+ if (fs.existsSync('dist/components')) {
1299
1317
  fs.rm('dist/components', { recursive: true }, err => {
1300
1318
  if (err) {
1301
1319
  throw err;
1302
1320
  }
1303
1321
  });
1322
+ }
1304
1323
 
1324
+ if (fs.existsSync('lib')) {
1305
1325
  fs.rm('lib', { recursive: true }, err => {
1306
1326
  if (err) {
1307
1327
  throw err;
1308
1328
  }
1309
1329
  });
1330
+ }
1331
+
1310
1332
  };
1311
1333
 
1312
1334
  export const getComponentsConfigs = async (compDir = null) => {
@@ -1398,6 +1420,7 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
1398
1420
  console.log('Data has been drained');
1399
1421
  });
1400
1422
 
1423
+
1401
1424
  // good practice to catch warnings (ie stat failures and other non-blocking errors)
1402
1425
  archive.on('warning', function(err) {
1403
1426
  if (err.code === 'ENOENT') {
@@ -1421,7 +1444,7 @@ if (showDebug) addDebugLog("zipVersionAndArchive", `orgLibName: ${orgLibName}, v
1421
1444
  // console.log(chalk.green(`component zipped with size: ${Math.ceil(zipBuffer.length / 1024)} KB`));
1422
1445
  // const zipContent = zipBuffer.toString('base64');
1423
1446
 
1424
-
1447
+ return output;
1425
1448
 
1426
1449
  };
1427
1450
 
@@ -1665,6 +1688,7 @@ if (showDebug) addDebugLog("getLibraryArchiveDirectories", "", "");
1665
1688
  const currentDirectory = process.cwd();
1666
1689
  const archiveDirectory = join (currentDirectory, ARCHIVES_PATH);
1667
1690
 
1691
+
1668
1692
  if (!fs.existsSync(archiveDirectory)) {
1669
1693
  return [];
1670
1694
  }
@@ -1749,11 +1773,10 @@ export const deleteLocalArchiveLibrary = async(libraryName) => {
1749
1773
  fs.rmSync(archiveDirectory, { recursive: true });
1750
1774
  console.log(`${chalk.green.bold(libraryName)} is deleted from Local.`);
1751
1775
  } catch (err) {
1752
- console.log(`${chalk.green.red(`No such file ${libraryName}/${version}`)}`);
1753
- throw new Error(`No such file ${libraryName}`);
1776
+ console.log(`${chalk.green.red(`No such file ${libraryName}`)}`);
1777
+ // throw new Error(`No such file ${libraryName}`);
1754
1778
  }
1755
1779
 
1756
-
1757
1780
  }
1758
1781
 
1759
1782
  export const deleteLocalArchiveLibraryVersion = async(libraryName, version) => {
@@ -1768,9 +1791,45 @@ export const deleteLocalArchiveLibraryVersion = async(libraryName, version) => {
1768
1791
 
1769
1792
  } catch (err) {
1770
1793
  console.log(`${chalk.green.red(`No such file ${libraryName}/${version}`)}`);
1771
- throw new Error(`No such file ${libraryName}/${version}`);
1794
+ // throw new Error(`No such file ${libraryName}/${version}`);
1795
+ }
1796
+
1797
+ }
1798
+
1799
+ export const cleanUpTemp = async() => {
1800
+ const currentDirectory = process.cwd();
1801
+ const tempDirectory = join (currentDirectory, TEMP_PATH);
1802
+
1803
+ if (fs.existsSync(tempDirectory)) {
1804
+ fs.rmSync(tempDirectory, { recursive: true });
1805
+ }
1806
+
1807
+ }
1808
+
1809
+
1810
+ export const getJestFunctionalTestList = async(whichTests) => {
1811
+ const functionalDir = path.join(path.resolve(), JEST_TESTS_FUNCTIONAL_PATH);
1812
+ const libFilter = "localLib";
1813
+
1814
+ switch (whichTests) {
1815
+ case "ALL" :
1816
+ return fs
1817
+ .readdirSync(functionalDir, { withFileTypes: true })
1818
+ .filter(dirent => !dirent.isDirectory() )
1819
+ .map(dirent => dirent.name);
1820
+ case "Original":
1821
+ return fs
1822
+ .readdirSync(functionalDir, { withFileTypes: true })
1823
+ .filter(dirent => !dirent.isDirectory() && !dirent.name.startsWith(libFilter))
1824
+ .map(dirent => dirent.name);
1825
+ case "Library" :
1826
+ return fs
1827
+ .readdirSync(functionalDir, { withFileTypes: true })
1828
+ .filter(dirent => !dirent.isDirectory() && dirent.name.startsWith(libFilter))
1829
+ .map(dirent => dirent.name);
1772
1830
  }
1773
1831
 
1832
+
1774
1833
  }
1775
1834
 
1776
1835
 
@@ -6,23 +6,69 @@ const exec = util.promisify(require('node:child_process').exec);
6
6
 
7
7
  const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
8
8
  const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
9
- const tasksConfigJSON = JSON.parse(tasksConfigData);
10
- const isLibraryBased = tasksConfigJSON['libraryBased'];
9
+ let tasksConfigJSON = JSON.parse(tasksConfigData);
10
+
11
+ const packageJSONDir = path.resolve('../../..', 'package.json');
12
+ const packageJSONData = fs.readFileSync(packageJSONDir, { encoding: 'utf8'});
13
+ let packageJSON = JSON.parse(packageJSONData);
14
+
15
+ let isLibraryBased = tasksConfigJSON['libraryMode'];
16
+ const savedLibraryBased = isLibraryBased;
17
+ const savedOrganization = packageJSON.organization;
18
+
11
19
  const serverType = tasksConfigJSON['server-config'].serverType;
12
20
  const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
13
- const compType = isLibraryBased ? "library" : "original";
21
+ let compType = isLibraryBased ? "library" : "original";
14
22
 
15
23
 
16
- describe(`createAll list and deleteAll local: ${serverDir} - ${compType}` , () => {
17
- it('initial delete/cleanup', async () => {
18
- const script = `npm run deleteAll Local Y --prefix ../../..`;
24
+ describe(`createAll list deleteAll local: ${serverDir} - ${compType}` , () => {
25
+
26
+ beforeAll( async() => {
27
+
28
+ // make non libraryBased
29
+ isLibraryBased = false;
30
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
31
+ compType = isLibraryBased ? "library" : "original";
32
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
33
+
34
+ // make organzation Pega
35
+ packageJSON.organization = "Pega";
36
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
37
+
38
+
39
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
40
+ if (fs.existsSync(componentsDir)) {
41
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
42
+ fs.mkdirSync(componentsDir, { recursive: true });
43
+ }
44
+
45
+ await new Promise((r) => setTimeout(r, 2000));
19
46
 
20
- const { stdout, stderr } = await exec(script);
21
- // console.log(stdout);
22
- expect(stdout).not.toBeNull();
23
- expect(stderr).not.toBeNull();
24
47
  });
25
48
 
49
+ afterAll( async() => {
50
+
51
+ //restore
52
+ isLibraryBased = savedLibraryBased
53
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
54
+
55
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
56
+
57
+ // return organzation
58
+ packageJSON.organization = savedOrganization;
59
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
60
+
61
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
62
+ if (fs.existsSync(componentsDir)) {
63
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
64
+ fs.mkdirSync(componentsDir, { recursive: true });
65
+ }
66
+
67
+ await new Promise((r) => setTimeout(r, 2000));
68
+
69
+ });
70
+
71
+
26
72
  it('npm run createAll Local', async () => {
27
73
  const script = `npm run createAll "My" 0.0.1 DXIL "" Pega Jest --prefix ../../..`;
28
74
 
@@ -6,22 +6,68 @@ const exec = util.promisify(require('node:child_process').exec);
6
6
 
7
7
  const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
8
8
  const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
9
- const tasksConfigJSON = JSON.parse(tasksConfigData);
10
- const isLibraryBased = tasksConfigJSON['libraryBased'];
9
+ let tasksConfigJSON = JSON.parse(tasksConfigData);
10
+
11
+ const packageJSONDir = path.resolve('../../..', 'package.json');
12
+ const packageJSONData = fs.readFileSync(packageJSONDir, { encoding: 'utf8'});
13
+ let packageJSON = JSON.parse(packageJSONData);
14
+
15
+ let isLibraryBased = tasksConfigJSON['libraryMode'];
16
+ const savedLibraryBased = isLibraryBased;
17
+ const savedOrganization = packageJSON.organization;
18
+
11
19
  const serverType = tasksConfigJSON['server-config'].serverType;
12
20
  const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
13
- const compType = isLibraryBased ? "library" : "original";
21
+ let compType = isLibraryBased ? "library" : "original";
14
22
 
15
- describe(`create buildAll and deleteAll local: ${serverDir} - ${compType}`, () => {
16
- it('initial delete/cleanup', async () => {
17
- const script = `npm run deleteAll Local Y --prefix ../../..`;
23
+ describe(`create buildAll deleteAll local: ${serverDir} - ${compType}`, () => {
24
+
25
+ beforeAll( async() => {
26
+
27
+ // make non libraryBased
28
+ isLibraryBased = false;
29
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
30
+ compType = isLibraryBased ? "library" : "original";
31
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
+
33
+ // make organzation Pega
34
+ packageJSON.organization = "Pega";
35
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
36
+
37
+
38
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
39
+ if (fs.existsSync(componentsDir)) {
40
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
41
+ fs.mkdirSync(componentsDir, { recursive: true });
42
+ }
43
+
44
+ await new Promise((r) => setTimeout(r, 2000));
18
45
 
19
- const { stdout, stderr } = await exec(script);
20
- // console.log(stdout);
21
- expect(stdout).not.toBeNull();
22
- expect(stderr).not.toBeNull();
23
46
  });
24
47
 
48
+ afterAll( async() => {
49
+
50
+ //restore
51
+ isLibraryBased = savedLibraryBased
52
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
53
+
54
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
55
+
56
+ // return organzation
57
+ packageJSON.organization = savedOrganization;
58
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
59
+
60
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
61
+ if (fs.existsSync(componentsDir)) {
62
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
63
+ fs.mkdirSync(componentsDir, { recursive: true });
64
+ }
65
+
66
+ await new Promise((r) => setTimeout(r, 2000));
67
+
68
+ });
69
+
70
+
25
71
  it('npm run create Local text', async () => {
26
72
  const fileName = 'MyTestText';
27
73
  const newFileName = `Pega_DXIL_${fileName}`;
@@ -136,33 +182,6 @@ describe(`create buildAll and deleteAll local: ${serverDir} - ${compType}`, () =
136
182
  // done();
137
183
  }, 70000);
138
184
 
139
- it(`npm run buildLibrary - ${isLibraryBased}`, async() => {
140
-
141
- const script = `npm run buildLibrary 0.0.1 Y --prefix ../../..`;
142
- const { stdout, stderr } = await exec(script);
143
-
144
- if (isLibraryBased) {
145
- expect(stdout).not.toBeNull();
146
- expect(stderr).not.toBeNull();
147
-
148
- expect(stdout).not.toContain('error');
149
- expect(stdout).not.toContain('Error');
150
-
151
- expect(stdout).toContain('Building Pega_DXIL_MyTestText');
152
- expect(stdout).toContain('Building Pega_DXIL_MyTestPage');
153
- expect(stdout).toContain('Building Pega_DXIL_MyTestDetails');
154
-
155
- expect(stdout).toContain('Library Build - Starting');
156
- expect(stdout).toContain('Webpack - Starting');
157
- expect(stdout).toContain('successfully');
158
-
159
- expect(stdout).toContain('== Creating manifest for the library version - completed ==');
160
- }
161
- else {
162
- expect(stdout).toContain('Command only supported for library based components.');
163
- }
164
-
165
- }, 100000);
166
185
 
167
186
  it('npm run deleteAll Local', async () => {
168
187
  const script = `npm run deleteAll Local Y --prefix ../../..`;
@@ -191,17 +210,6 @@ describe(`create buildAll and deleteAll local: ${serverDir} - ${compType}`, () =
191
210
  // expect(doesExist).not.toBeTruthy();
192
211
  }, 20000);
193
212
 
194
- it(`npm run deleteLibrary - ${isLibraryBased}`, async() => {
195
213
 
196
- const script = `npm run deleteLibrary Local ALL --prefix ../../..`;
197
- const { stdout, stderr } = await exec(script);
198
-
199
- if (isLibraryBased) {
200
- expect(stdout).toContain('Library: Pega_DXIL is deleted from Local');
201
- }
202
- else {
203
- expect(stdout).toContain('Command only supported for library based components.');
204
- }
205
- }, 30000);
206
214
 
207
215
  });
@@ -2,24 +2,71 @@
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
4
  const util = require('node:util');
5
+ const { transpileModule } = require('typescript');
5
6
  const exec = util.promisify(require('node:child_process').exec);
6
7
 
7
8
  const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
8
9
  const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
9
- const tasksConfigJSON = JSON.parse(tasksConfigData);
10
- const isLibraryBased = tasksConfigJSON['libraryBased'];
10
+ let tasksConfigJSON = JSON.parse(tasksConfigData);
11
+
12
+ const packageJSONDir = path.resolve('../../..', 'package.json');
13
+ const packageJSONData = fs.readFileSync(packageJSONDir, { encoding: 'utf8'});
14
+ let packageJSON = JSON.parse(packageJSONData);
15
+
16
+ let isLibraryBased = tasksConfigJSON['libraryMode'];
17
+ const savedLibraryBased = isLibraryBased;
18
+ const savedOrganization = packageJSON.organization;
19
+
11
20
  const serverType = tasksConfigJSON['server-config'].serverType;
12
21
  const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
13
- const compType = isLibraryBased ? "library" : "original";
22
+ let compType = isLibraryBased ? "library" : "original";
14
23
 
15
- describe(`create build and delete local: ${serverDir} - ${compType}`, () => {
16
- it('initial delete/cleanup', async () => {
17
- const script = `npm run deleteAll Local Y --prefix ../../..`;
18
24
 
19
- const { stdout, stderr } = await exec(script);
20
- // console.log(stdout);
21
- expect(stdout).not.toBeNull();
22
- expect(stderr).not.toBeNull();
25
+ describe(`create library delete Library: ${serverDir} - ${compType}`, () => {
26
+
27
+ beforeAll( async() => {
28
+
29
+ // make non libraryBased
30
+ isLibraryBased = false;
31
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
32
+ compType = isLibraryBased ? "library" : "original";
33
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
34
+
35
+ // make organzation Pega
36
+ packageJSON.organization = "Pega";
37
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
38
+
39
+
40
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
41
+ if (fs.existsSync(componentsDir)) {
42
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
43
+ fs.mkdirSync(componentsDir, { recursive: true });
44
+ }
45
+
46
+ await new Promise((r) => setTimeout(r, 2000));
47
+
48
+ });
49
+
50
+ afterAll( async() => {
51
+
52
+ //restore
53
+ isLibraryBased = savedLibraryBased
54
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
55
+
56
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
57
+
58
+ // return organzation
59
+ packageJSON.organization = savedOrganization;
60
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
61
+
62
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
63
+ if (fs.existsSync(componentsDir)) {
64
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
65
+ fs.mkdirSync(componentsDir, { recursive: true });
66
+ }
67
+
68
+ await new Promise((r) => setTimeout(r, 2000));
69
+
23
70
  });
24
71
 
25
72
  it('npm run create Local', async () => {
@@ -6,20 +6,65 @@ const exec = util.promisify(require('node:child_process').exec);
6
6
 
7
7
  const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
8
8
  const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
9
- const tasksConfigJSON = JSON.parse(tasksConfigData);
10
- const isLibraryBased = tasksConfigJSON['libraryBased'];
9
+ let tasksConfigJSON = JSON.parse(tasksConfigData);
10
+
11
+ const packageJSONDir = path.resolve('../../..', 'package.json');
12
+ const packageJSONData = fs.readFileSync(packageJSONDir, { encoding: 'utf8'});
13
+ let packageJSON = JSON.parse(packageJSONData);
14
+
15
+ let isLibraryBased = tasksConfigJSON['libraryMode'];
16
+ const savedLibraryBased = isLibraryBased;
17
+ const savedOrganization = packageJSON.organization;
18
+
11
19
  const serverType = tasksConfigJSON['server-config'].serverType;
12
20
  const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
13
- const compType = isLibraryBased ? "library" : "original";
21
+ let compType = isLibraryBased ? "library" : "original";
14
22
 
15
- describe(`create list and delete local: ${serverDir} - ${compType}`, () => {
16
- it('initial delete/cleanup', async () => {
17
- const script = `npm run deleteAll Local Y --prefix ../../..`;
23
+ describe(`createLib createAll list deleteLib: ${serverDir} - ${compType}`, () => {
24
+
25
+ beforeAll( async() => {
26
+
27
+ // make non libraryBased
28
+ isLibraryBased = false;
29
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
30
+ compType = isLibraryBased ? "library" : "original";
31
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
32
+
33
+ // make organzation Pega
34
+ packageJSON.organization = "Pega";
35
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
36
+
37
+
38
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
39
+ if (fs.existsSync(componentsDir)) {
40
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
41
+ fs.mkdirSync(componentsDir, { recursive: true });
42
+ }
43
+
44
+ await new Promise((r) => setTimeout(r, 2000));
45
+
46
+ });
47
+
48
+ afterAll( async() => {
49
+
50
+ //restore
51
+ isLibraryBased = savedLibraryBased
52
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
53
+
54
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
55
+
56
+ // return organzation
57
+ packageJSON.organization = savedOrganization;
58
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
59
+
60
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
61
+ if (fs.existsSync(componentsDir)) {
62
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
63
+ fs.mkdirSync(componentsDir, { recursive: true });
64
+ }
65
+
66
+ await new Promise((r) => setTimeout(r, 2000));
18
67
 
19
- const { stdout, stderr } = await exec(script);
20
- // console.log(stdout);
21
- expect(stdout).not.toBeNull();
22
- expect(stderr).not.toBeNull();
23
68
  });
24
69
 
25
70
  it('npm run create Local', async () => {
@@ -114,99 +159,7 @@ describe(`create list and delete local: ${serverDir} - ${compType}`, () => {
114
159
  expect(doesExist).not.toBeTruthy();
115
160
  }, 10000);
116
161
 
117
- // test list library need to createAll, buildLibrary, listLibrary
118
- it('npm run createAll Local', async () => {
119
- const script = `npm run createAll "My" 0.0.1 DXIL "" Pega Jest --prefix ../../..`;
120
-
121
- const { stdout, stderr } = await exec(script);
122
- // console.log(stdout);
123
- expect(stdout).not.toBeNull();
124
- expect(stderr).not.toBeNull();
125
-
126
- // want message to contain component name
127
- expect(stdout).toContain('created Pega_DXIL_My');
128
-
129
- // don't want message with already exists
130
- expect(stdout).not.toContain('already exists');
131
-
132
- // check to see file exists
133
162
 
134
- // pick one
135
- const newFileName = 'Pega_DXIL_MyBoolean';
136
163
 
137
- // const fileDir = path.resolve(`src/components/${newFileName}`);
138
- const createFile = path.resolve(
139
- '../../..',
140
- path.join(`src/components/${newFileName}`, 'index.tsx')
141
- );
142
- const doesExist = fs.existsSync(createFile);
143
- expect(doesExist).toBeTruthy();
144
-
145
- // if (doesExist) {
146
- // // remove it
147
- // fs.rmdirSync(fileDir, { recursive: true });
148
- // }
149
- }, 10000);
150
-
151
- it(`npm run buildLibrary - ${isLibraryBased}`, async() => {
152
-
153
- const script = `npm run buildLibrary 0.0.1 Y --prefix ../../..`;
154
- const { stdout, stderr } = await exec(script);
155
-
156
- if (isLibraryBased) {
157
- expect(stdout).not.toBeNull();
158
- expect(stderr).not.toBeNull();
159
-
160
- expect(stdout).not.toContain('error');
161
- expect(stdout).not.toContain('Error');
162
-
163
- expect(stdout).toContain('Building Pega_DXIL_MyBoolean');
164
- expect(stdout).toContain('Building Pega_DXIL_MyPage');
165
- expect(stdout).toContain('Building Pega_DXIL_MyPageWidget');
166
-
167
- expect(stdout).toContain('Library Build - Starting');
168
- expect(stdout).toContain('Webpack - Starting');
169
- expect(stdout).toContain('successfully');
170
-
171
- expect(stdout).toContain('== Creating manifest for the library version - completed ==');
172
- }
173
- else {
174
- expect(stdout).toContain('Command only supported for library based components.');
175
- }
176
-
177
- }, 100000);
178
-
179
-
180
- it(`npm run listLibrary - ${isLibraryBased}`, async() => {
181
-
182
- const script = `npm run listLibrary Local 0.0.1-dev --prefix ../../..`;
183
- const { stdout, stderr } = await exec(script);
184
-
185
- if (isLibraryBased) {
186
- expect(stdout).not.toBeNull();
187
- expect(stderr).not.toBeNull();
188
-
189
- expect(stdout).toContain('Pega_DXIL_MyURL');
190
- expect(stdout).toContain('Field');
191
- expect(stdout).toContain('Text-URL');
192
- expect(stdout).toContain('0.0.1-dev');
193
- }
194
- else {
195
- expect(stdout).toContain('Command only supported for library based components.');
196
- }
197
- }, 30000);
198
-
199
- it(`npm run deleteLibrary - ${isLibraryBased}`, async() => {
200
-
201
- const script = `npm run deleteLibrary Local ALL --prefix ../../..`;
202
- const { stdout, stderr } = await exec(script);
203
-
204
- if (isLibraryBased) {
205
- expect(stdout).toContain('Library: Pega_DXIL is deleted from Local');
206
- }
207
- else {
208
- expect(stdout).toContain('Command only supported for library based components.');
209
- }
210
- }, 30000);
211
164
 
212
165
  });