@pega/custom-dx-components 0.242.35 → 0.242.37

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 (52) hide show
  1. package/package.json +2 -2
  2. package/src/cli.js +6 -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 +3 -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 +2 -4
  12. package/src/tasks/import-comp/index.js +1 -2
  13. package/src/tasks/index.js +1 -0
  14. package/src/tasks/init/template/package.json.mustache +6 -5
  15. package/src/tasks/list/helper.js +8 -0
  16. package/src/tasks/list-lib/index.js +27 -11
  17. package/src/tasks/list-pub/index.js +18 -14
  18. package/src/tasks/move/helper.js +6 -3
  19. package/src/tasks/move/index.js +86 -17
  20. package/src/tasks/publish/helper.js +8 -5
  21. package/src/tasks/publish/index.js +4 -4
  22. package/src/tasks/publish-all/helper.js +16 -10
  23. package/src/tasks/quarantine/index.js +84 -0
  24. package/src/tasks/rename-lib/index.js +0 -1
  25. package/src/tasks/revert-webpack/index.js +0 -2
  26. package/src/tasks/set-perm/index.js +18 -2
  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 +3 -1
  30. package/src/util.js +50 -6
  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 +161 -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/localLibCreateLibValidateDeleteLib.test.js +217 -0
  51. package/tests/functional/localLibCreateLibVersionDeleteLib.test.js +453 -0
  52. package/tests/functional/localPromoteRevertWP.test.js +83 -38
@@ -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 publish and delete local: ${serverDir} - ${compType}`, () => {
16
- it('initial delete/cleanup', async () => {
17
- const script = `npm run deleteAll Local Y --prefix ../../..`;
23
+ describe(`create publish delete 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', async () => {
26
72
  const fileName = 'MyTestText';
27
73
  const newFileName = `Pega_DXIL_${fileName}`;
@@ -58,20 +104,15 @@ describe(`create publish and delete local: ${serverDir} - ${compType}`, () => {
58
104
  const script = `npm run publish ${newFileName} LoanV2 01-01-01 N noFetch --prefix ../../..`;
59
105
  const { stdout, stderr } = await exec(script);
60
106
 
107
+ // console.log(stdout);
108
+ expect(stdout).not.toBeNull();
109
+ expect(stderr).not.toBeNull();
61
110
 
62
- if (isLibraryBased) {
63
- expect(stdout).toContain('Command only supported for non library based components.');
64
- }
65
- else {
66
- // console.log(stdout);
67
- expect(stdout).not.toBeNull();
68
- expect(stderr).not.toBeNull();
111
+ expect(stdout).toContain(`${newFileName} schema is valid`);
112
+ // expect(stdout).toContain('Compiled successfully.');
69
113
 
70
- expect(stdout).toContain(`${newFileName} schema is valid`);
71
- // expect(stdout).toContain('Compiled successfully.');
114
+ // done();
72
115
 
73
- // done();
74
- }
75
116
 
76
117
  }, 30000);
77
118
 
@@ -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 rename and delete local: ${serverDir} - ${compType}`, () => {
16
- it('initial delete/cleanup', async () => {
17
- const script = `npm run deleteAll Local Y --prefix ../../..`;
23
+ describe(`create rename delete 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));
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 () => {
@@ -90,136 +135,6 @@ describe(`create rename and delete local: ${serverDir} - ${compType}`, () => {
90
135
  expect(doesExist).not.toBeTruthy();
91
136
  }, 10000);
92
137
 
93
- // test rename library need to createAll, renameLibrary, deleteAll
94
- it('npm run createAll Local', async () => {
95
- const script = `npm run createAll "My" 0.0.1 DXIL "" Pega Jest --prefix ../../..`;
96
-
97
- const { stdout, stderr } = await exec(script);
98
- // console.log(stdout);
99
- expect(stdout).not.toBeNull();
100
- expect(stderr).not.toBeNull();
101
-
102
- // want message to contain component name
103
- expect(stdout).toContain('created Pega_DXIL_My');
104
-
105
- // don't want message with already exists
106
- expect(stdout).not.toContain('already exists');
107
-
108
- // check to see file exists
109
-
110
- // pick one
111
- const newFileName = 'Pega_DXIL_MyBoolean';
112
-
113
- // const fileDir = path.resolve(`src/components/${newFileName}`);
114
- const createFile = path.resolve(
115
- '../../..',
116
- path.join(`src/components/${newFileName}`, 'index.tsx')
117
- );
118
- const doesExist = fs.existsSync(createFile);
119
- expect(doesExist).toBeTruthy();
120
-
121
- // if (doesExist) {
122
- // // remove it
123
- // fs.rmdirSync(fileDir, { recursive: true });
124
- // }
125
- }, 10000);
126
-
127
- it(`npm run buildLibrary - ${isLibraryBased}`, async() => {
128
-
129
- const script = `npm run buildLibrary 0.0.1 Y --prefix ../../..`;
130
- const { stdout, stderr } = await exec(script);
131
-
132
- if (isLibraryBased) {
133
- expect(stdout).not.toBeNull();
134
- expect(stderr).not.toBeNull();
135
-
136
- expect(stdout).not.toContain('error');
137
- expect(stdout).not.toContain('Error');
138
-
139
- expect(stdout).toContain('Building Pega_DXIL_MyBoolean');
140
- expect(stdout).toContain('Building Pega_DXIL_MyPage');
141
- expect(stdout).toContain('Building Pega_DXIL_MyPageWidget');
142
-
143
- expect(stdout).toContain('Library Build - Starting');
144
- expect(stdout).toContain('Webpack - Starting');
145
- expect(stdout).toContain('successfully');
146
-
147
- expect(stdout).toContain('== Creating manifest for the library version - completed ==');
148
- }
149
- else {
150
- expect(stdout).toContain('Command only supported for library based components.');
151
- }
152
-
153
- }, 100000);
154
-
155
- it(`npm run renameLibrary - ${isLibraryBased}`, async() => {
156
-
157
- const script = `npm run renameLibrary Acme Ext --prefix ../../..`;
158
- const { stdout, stderr } = await exec(script);
159
-
160
- if (isLibraryBased) {
161
- expect(stdout).not.toBeNull();
162
- expect(stderr).not.toBeNull();
163
-
164
- expect(stdout).not.toContain('error');
165
- expect(stdout).not.toContain('Error');
166
-
167
- expect(stdout).toContain('Component Pega_DXIL_MyBoolean renamed to Acme_Ext_MyBoolean');
168
- expect(stdout).toContain('Component Pega_DXIL_MyPage renamed to Acme_Ext_MyPage');
169
- expect(stdout).toContain('Component Pega_DXIL_MyPageWidget renamed to Acme_Ext_MyPageWidget');
170
-
171
- expect(stdout).toContain('Library Build - Starting');
172
- expect(stdout).toContain('Webpack - Starting');
173
- expect(stdout).toContain('successfully');
174
-
175
- expect(stdout).toContain('== Creating manifest for the library version - completed ==');
176
- }
177
- else {
178
- expect(stdout).toContain('Command only supported for library based components.');
179
- }
180
-
181
- }, 100000);
182
-
183
- // rename it back so package and task config return
184
- it(`npm run renameLibrary - ${isLibraryBased}`, async() => {
185
-
186
- const script = `npm run renameLibrary Pega DXIL --prefix ../../..`;
187
- const { stdout, stderr } = await exec(script);
188
-
189
- if (isLibraryBased) {
190
- expect(stdout).not.toBeNull();
191
- expect(stderr).not.toBeNull();
192
-
193
- expect(stdout).not.toContain('error');
194
- expect(stdout).not.toContain('Error');
195
-
196
- expect(stdout).toContain('Component Acme_Ext_MyBoolean renamed to Pega_DXIL_MyBoolean');
197
-
198
- expect(stdout).toContain('Library Build - Starting');
199
- expect(stdout).toContain('Webpack - Starting');
200
- expect(stdout).toContain('successfully');
201
-
202
- expect(stdout).toContain('== Creating manifest for the library version - completed ==');
203
- }
204
- else {
205
- expect(stdout).toContain('Command only supported for library based components.');
206
- }
207
-
208
- }, 100000);
209
-
210
-
211
- it(`npm run deleteLibrary - ${isLibraryBased}`, async() => {
212
-
213
- const script = `npm run deleteLibrary Local ALL --prefix ../../..`;
214
- const { stdout, stderr } = await exec(script);
215
-
216
- if (isLibraryBased) {
217
- expect(stdout).toContain('Library: Pega_DXIL is deleted from Local');
218
- }
219
- else {
220
- expect(stdout).toContain('Command only supported for library based components.');
221
- }
222
- }, 30000);
223
138
 
224
139
 
225
140
  });
@@ -0,0 +1,118 @@
1
+ // import { exec } from 'child_process';
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+ const util = require('node:util');
5
+ const exec = util.promisify(require('node:child_process').exec);
6
+
7
+ const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
8
+ const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
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
+
19
+ const serverType = tasksConfigJSON['server-config'].serverType;
20
+ const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
21
+ let compType = isLibraryBased ? "library" : "original";
22
+
23
+
24
+ describe(`createLib createLib (already exists) deleteLib: ${serverDir} - ${compType}` , () => {
25
+
26
+ beforeAll( async() => {
27
+
28
+ // make libraryBased
29
+ isLibraryBased = true;
30
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
31
+ compType = isLibraryBased ? "library" : "original";
32
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
33
+
34
+ const storeDir = path.join(path.resolve('../../..'), 'store');
35
+ if (fs.existsSync(storeDir)) {
36
+ fs.rmSync(storeDir, { recursive: true, force: true, maxRetries: 2 });
37
+ }
38
+
39
+ // make organzation Pega
40
+ packageJSON.organization = "Pega";
41
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
42
+
43
+
44
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
45
+ if (fs.existsSync(componentsDir)) {
46
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
47
+ fs.mkdirSync(componentsDir, { recursive: true });
48
+ }
49
+
50
+ await new Promise((r) => setTimeout(r, 2000));
51
+
52
+
53
+ });
54
+
55
+ afterAll( async() => {
56
+
57
+ //restore
58
+ isLibraryBased = savedLibraryBased
59
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
60
+
61
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
62
+
63
+ // return organzation
64
+ packageJSON.organization = savedOrganization;
65
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
66
+
67
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
68
+ if (fs.existsSync(componentsDir)) {
69
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
70
+ fs.mkdirSync(componentsDir, { recursive: true });
71
+ }
72
+
73
+ const storeDir = path.join(path.resolve('../../..'), 'store');
74
+ if (fs.existsSync(storeDir)) {
75
+ fs.rmSync(storeDir, { recursive: true, force: true, maxRetries: 2 });
76
+ }
77
+
78
+ await new Promise((r) => setTimeout(r, 2000));
79
+
80
+ });
81
+
82
+
83
+ it(`npm run createLib - ${isLibraryBased}`, async() => {
84
+
85
+
86
+ const script = `npm run createLib DXIL 0.0.1 N --prefix ../../..`;
87
+ const compConf = path.join("store", "Pega_DXIL","0.0.1-dev", "componentsconfig.json");
88
+
89
+ const { stdout, stderr } = await exec(script);
90
+ expect(stdout).toContain('Library Pega_DXIL/0.0.1-dev has been created!');
91
+
92
+ const doesExist = fs.existsSync(path.resolve('../../..', compConf));
93
+
94
+ expect(doesExist).toBeTruthy();
95
+
96
+ }, 30000);
97
+
98
+ it(`npm run createLib (already exists) - ${isLibraryBased}`, async() => {
99
+
100
+ const script = `npm run createLib DXIL 0.0.1 N --prefix ../../..`;
101
+
102
+ const { stdout, stderr } = await exec(script);
103
+ expect(stdout).toContain('Library Pega_DXIL already exists.');
104
+
105
+ }, 30000);
106
+
107
+
108
+ it(`npm run deleteLib- ${isLibraryBased}`, async() => {
109
+
110
+ const script = `npm run deleteLib Pega_DXIL 0.0.1-dev --prefix ../../..`;
111
+ const { stdout, stderr } = await exec(script);
112
+
113
+ expect(stdout).toContain('Pega_DXIL is deleted from Local.');
114
+
115
+
116
+ }, 30000);
117
+
118
+ });
@@ -0,0 +1,241 @@
1
+ // import { exec } from 'child_process';
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+ const util = require('node:util');
5
+ const exec = util.promisify(require('node:child_process').exec);
6
+
7
+ const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
8
+ const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
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
+
19
+ const serverType = tasksConfigJSON['server-config'].serverType;
20
+ const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
21
+ let compType = isLibraryBased ? "library" : "original";
22
+
23
+
24
+ describe(`createLib create buildLib deleteLib deletePublishedLib: ${serverDir} - ${compType}` , () => {
25
+
26
+ beforeAll( async() => {
27
+
28
+ // make libraryBased
29
+ isLibraryBased = true;
30
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
31
+ compType = isLibraryBased ? "library" : "original";
32
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
33
+
34
+ const storeDir = path.join(path.resolve('../../..'), 'store');
35
+ if (fs.existsSync(storeDir)) {
36
+ fs.rmSync(storeDir, { recursive: true, force: true, maxRetries: 2 });
37
+ }
38
+
39
+ // make organzation Pega
40
+ packageJSON.organization = "Pega";
41
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
42
+
43
+
44
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
45
+ if (fs.existsSync(componentsDir)) {
46
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
47
+ fs.mkdirSync(componentsDir, { recursive: true });
48
+ }
49
+
50
+ await new Promise((r) => setTimeout(r, 2000));
51
+
52
+ });
53
+
54
+ afterAll( async() => {
55
+
56
+ //restore
57
+ isLibraryBased = savedLibraryBased
58
+ tasksConfigJSON['libraryMode'] = isLibraryBased;
59
+
60
+ fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
61
+
62
+ // return organzation
63
+ packageJSON.organization = savedOrganization;
64
+ fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
65
+
66
+ const componentsDir = path.join(path.resolve('../../..'), 'src/components');
67
+ if (fs.existsSync(componentsDir)) {
68
+ fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
69
+ fs.mkdirSync(componentsDir, { recursive: true });
70
+ }
71
+
72
+ const storeDir = path.join(path.resolve('../../..'), 'store');
73
+ if (fs.existsSync(storeDir)) {
74
+ fs.rmSync(storeDir, { recursive: true, force: true, maxRetries: 2 });
75
+ }
76
+
77
+
78
+ await new Promise((r) => setTimeout(r, 2000));
79
+
80
+ });
81
+
82
+ // it('initial delete/cleanup', async () => {
83
+
84
+ // const storePath = join(path.resolve('../../..'), 'store');
85
+ // if (fs.existsSync(storePath)) {
86
+ // fs.rmSync(storePath, { recursive: true, force: true, maxRetries: 2 });
87
+ // }
88
+ // });
89
+
90
+ it(`npm run createLib - ${isLibraryBased}`, async() => {
91
+
92
+ const script = `npm run createLib DXIL 0.0.1 N --prefix ../../..`;
93
+ const compConf = path.join("store", "Pega_DXIL","0.0.1-dev", "componentsconfig.json");
94
+
95
+ const { stdout, stderr } = await exec(script);
96
+ expect(stdout).toContain('Library Pega_DXIL/0.0.1-dev has been created!');
97
+
98
+ const doesExist = fs.existsSync(path.resolve('../../..', compConf));
99
+
100
+ expect(doesExist).toBeTruthy();
101
+
102
+ }, 30000);
103
+
104
+ it('npm run create Local text', async () => {
105
+ const fileName = 'MyTestText';
106
+ const newFileName = `Pega_DXIL_${fileName}`;
107
+ const script = `npm run create Field Text ${fileName} "My Test Text" 0.0.1 DXIL "" "My Test Text Description" Pega --prefix ../../..`;
108
+
109
+ const { stdout, stderr } = await exec(script);
110
+ // console.log(stdout);
111
+ expect(stdout).not.toBeNull();
112
+ expect(stderr).not.toBeNull();
113
+
114
+ // want message to contain component name
115
+ expect(stdout).toContain(newFileName);
116
+
117
+ // don't want message with already exists
118
+ expect(stdout).not.toContain('already exists');
119
+
120
+ // check to see file exists
121
+
122
+ // const fileDir = path.resolve(`src/components/${newFileName}`);
123
+ const createFile = path.resolve(
124
+ '../../..',
125
+ path.join(`src/components/${newFileName}`, 'index.tsx')
126
+ );
127
+ const doesExist = fs.existsSync(createFile);
128
+ expect(doesExist).toBeTruthy();
129
+
130
+ // if (doesExist) {
131
+ // // remove it
132
+ // fs.rmdirSync(fileDir, { recursive: true });
133
+ // }
134
+ }, 10000);
135
+
136
+ it('npm run create Local page', async () => {
137
+ const fileName = 'MyTestPage';
138
+ const newFileName = `Pega_DXIL_${fileName}`;
139
+ const script = `npm run create Widget PAGE ${fileName} "My Test Page" 0.0.1 DXIL "" "My Test Page Description" Pega --prefix ../../..`;
140
+
141
+ const { stdout, stderr } = await exec(script);
142
+ // console.log(stdout);
143
+ expect(stdout).not.toBeNull();
144
+ expect(stderr).not.toBeNull();
145
+
146
+ // want message to contain component name
147
+ expect(stdout).toContain(newFileName);
148
+
149
+ // don't want message with already exists
150
+ expect(stdout).not.toContain('already exists');
151
+
152
+ // check to see file exists
153
+
154
+ // const fileDir = path.resolve(`src/components/${newFileName}`);
155
+ const createFile = path.resolve(
156
+ '../../..',
157
+ path.join(`src/components/${newFileName}`, 'index.tsx')
158
+ );
159
+ const doesExist = fs.existsSync(createFile);
160
+ expect(doesExist).toBeTruthy();
161
+
162
+ // if (doesExist) {
163
+ // // remove it
164
+ // fs.rmdirSync(fileDir, { recursive: true });
165
+ // }
166
+ }, 10000);
167
+
168
+ it('npm run create Local details', async () => {
169
+ const fileName = 'MyTestDetails';
170
+ const newFileName = `Pega_DXIL_${fileName}`;
171
+ const script = `npm run create Template DETAILS ${fileName} "My Test Details" 0.0.1 DXIL "" "My Test Details Description" Pega --prefix ../../..`;
172
+
173
+ const { stdout, stderr } = await exec(script);
174
+ // console.log(stdout);
175
+ expect(stdout).not.toBeNull();
176
+ expect(stderr).not.toBeNull();
177
+
178
+ // want message to contain component name
179
+ expect(stdout).toContain(newFileName);
180
+
181
+ // don't want message with already exists
182
+ expect(stdout).not.toContain('already exists');
183
+
184
+ // check to see file exists
185
+
186
+ // const fileDir = path.resolve(`src/components/${newFileName}`);
187
+ const createFile = path.resolve(
188
+ '../../..',
189
+ path.join(`src/components/${newFileName}`, 'index.tsx')
190
+ );
191
+ const doesExist = fs.existsSync(createFile);
192
+ expect(doesExist).toBeTruthy();
193
+
194
+ // if (doesExist) {
195
+ // // remove it
196
+ // fs.rmdirSync(fileDir, { recursive: true });
197
+ // }
198
+ }, 10000);
199
+
200
+ it(`npm run buildLib (internal) - ${isLibraryBased}`, async() => {
201
+
202
+ const script = `npm run _internal-buildLibrary 0.0.1 Y --prefix ../../..`;
203
+ const { stdout, stderr } = await exec(script);
204
+
205
+ expect(stdout).toContain('Pega_DXIL_MyTestText schema is valid');
206
+ expect(stdout).toContain('Pega_DXIL_MyTestPage schema is valid');
207
+ expect(stdout).toContain('Pega_DXIL_MyTestDetails schema is valid');
208
+
209
+ expect(stdout).toContain('Building Library...');
210
+ expect(stdout).toContain('Compile check...');
211
+
212
+ expect(stdout).toContain('Webpacked library Pega_DXIL:0.0.1-dev successfully!!');
213
+ expect(stdout).toContain('== Creating manifest for the library version - completed ==');
214
+
215
+
216
+
217
+ }, 200000);
218
+
219
+ it(`npm run deleteLib - ${isLibraryBased}`, async() => {
220
+
221
+ const script = `npm run deleteLib Pega_DXIL 0.0.1-dev --prefix ../../..`;
222
+ const { stdout, stderr } = await exec(script);
223
+ expect(stdout).toContain('Pega_DXIL is deleted from Local.');
224
+
225
+ }, 30000);
226
+
227
+ it(`npm run deletePublishedLib - ${isLibraryBased}`, async() => {
228
+
229
+ const script = `npm run deletePublishedLib Local ALL --prefix ../../..`;
230
+ const { stdout, stderr } = await exec(script);
231
+ expect(stdout).toContain('Library: Pega_DXIL is deleted from Local');
232
+
233
+ const localLib = path.resolve('../../..', `Pega_DXIL`);
234
+ expect(fs.existsSync(localLib)).not.toBeTruthy();
235
+
236
+ }, 30000);
237
+
238
+
239
+
240
+
241
+ });