@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
@@ -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 publish and deleteAll local: ${serverDir} - ${compType}`, () => {
16
- it('initial delete/cleanup', async () => {
17
- const script = `npm run deleteAll Local Y --prefix ../../..`;
23
+ describe(`create publish 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));
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 text', async () => {
@@ -84,7 +129,7 @@ describe(`create publish and deleteAll local: ${serverDir} - ${compType}`, () =>
84
129
  // // remove it
85
130
  // fs.rmdirSync(fileDir, { recursive: true });
86
131
  // }
87
- }, 10000);
132
+ }, 20000);
88
133
 
89
134
  it('npm run create Local details', async () => {
90
135
  const fileName = 'MyTestDetails';
@@ -122,61 +167,23 @@ describe(`create publish and deleteAll local: ${serverDir} - ${compType}`, () =>
122
167
  const script = `npm run publishAll LoanV2 01-01-01 N noFetch --prefix ../../..`;
123
168
  const { stdout, stderr } = await exec(script);
124
169
 
125
- if (isLibraryBased) {
126
- expect(stdout).toContain('Command only supported for non library based components.');
127
- }
128
- else {
129
- // console.log(stdout);
130
- expect(stdout).not.toBeNull();
131
- expect(stderr).not.toBeNull();
132
-
133
- // expect(stdout).toContain('Compiled successfully.');
134
- // expect(stdout).not.toContain('Compiled with warnings.');
135
- expect(stdout).not.toContain('error');
136
- expect(stdout).not.toContain('Error');
137
-
138
- expect(stdout).toContain('Pega_DXIL_MyTestText');
139
- expect(stdout).toContain('Pega_DXIL_MyTestPage');
140
- expect(stdout).toContain('Pega_DXIL_MyTestDetails');
141
- }
142
-
143
- // done();
144
- }, 70000);
145
-
146
- // simple test, no publish to server
147
- it(`npm run publishLibrary PROD - ${isLibraryBased}`, async() => {
148
-
149
- const script = `npm run publishLibrary Pega_DXIL 0.0.1 noPublish --prefix ../../..`;
150
- const { stdout, stderr } = await exec(script);
151
-
152
- if (isLibraryBased) {
153
- expect(stdout).not.toBeNull();
154
- expect(stderr).not.toBeNull();
155
-
156
- expect(stdout).toContain('PRODUCTION, no publish');
157
- }
158
- else {
159
- expect(stdout).toContain('Command only supported for library based components.');
160
- }
170
+ // console.log(stdout);
171
+ expect(stdout).not.toBeNull();
172
+ expect(stderr).not.toBeNull();
161
173
 
162
- }, 30000);
174
+ // expect(stdout).toContain('Compiled successfully.');
175
+ // expect(stdout).not.toContain('Compiled with warnings.');
176
+ expect(stdout).not.toContain('error');
177
+ expect(stdout).not.toContain('Error');
163
178
 
164
- it(`npm run publishLibrary - ${isLibraryBased}`, async() => {
179
+ expect(stdout).toContain('Pega_DXIL_MyTestText');
180
+ expect(stdout).toContain('Pega_DXIL_MyTestPage');
181
+ expect(stdout).toContain('Pega_DXIL_MyTestDetails');
165
182
 
166
- const script = `npm run publishLibrary Pega_DXIL 0.0.1-dev noPublish --prefix ../../..`;
167
- const { stdout, stderr } = await exec(script);
168
183
 
169
- if (isLibraryBased) {
170
- expect(stdout).not.toBeNull();
171
- expect(stderr).not.toBeNull();
172
-
173
- expect(stdout).toContain('OK to publish');
174
- }
175
- else {
176
- expect(stdout).toContain('Command only supported for library based components.');
177
- }
184
+ // done();
185
+ }, 70000);
178
186
 
179
- }, 30000);
180
187
 
181
188
 
182
189
  it('npm run deleteAll Local', async () => {
@@ -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
+ });