@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.
- package/package.json +1 -1
- package/src/cli.js +12 -0
- package/src/constants.js +1 -0
- package/src/tasks/build-lib/helper.js +0 -1
- package/src/tasks/create-lib/index.js +5 -3
- package/src/tasks/create-version/index.js +12 -1
- package/src/tasks/delete-lib/index.js +4 -1
- package/src/tasks/delete-version/index.js +3 -1
- package/src/tasks/export-archive/index.js +58 -41
- package/src/tasks/import-archive/index.js +5 -1
- package/src/tasks/import-comp/helper.js +47 -0
- package/src/tasks/import-comp/index.js +320 -0
- package/src/tasks/index.js +2 -0
- package/src/tasks/init/template/package.json.mustache +5 -3
- package/src/tasks/list-lib/index.js +25 -16
- package/src/tasks/list-pub/index.js +18 -14
- package/src/tasks/move/helper.js +6 -3
- package/src/tasks/move/index.js +99 -58
- package/src/tasks/publish/helper.js +8 -5
- package/src/tasks/publish/index.js +4 -4
- package/src/tasks/publish-all/helper.js +16 -10
- package/src/tasks/quarantine/index.js +84 -0
- package/src/tasks/rename-lib/index.js +0 -1
- package/src/tasks/revert-webpack/index.js +0 -2
- package/src/tasks/set-perm/index.js +18 -2
- package/src/tasks/show-help/index.js +6 -4
- package/src/tasks/store/index.js +4 -1
- package/src/tasks/switch-lib/index.js +3 -1
- package/src/tasks/switch-version/index.js +11 -1
- package/src/util.js +84 -25
- package/tests/functional/localCreateAllListDeleteAll.test.js +56 -10
- package/tests/functional/localCreateBuildAllDeleteAll.test.js +56 -48
- package/tests/functional/localCreateBuildDelete.test.js +57 -10
- package/tests/functional/localCreateListDelete.test.js +55 -102
- package/tests/functional/localCreatePublishAllDeleteAll.test.js +68 -61
- package/tests/functional/localCreatePublishDelete.test.js +62 -21
- package/tests/functional/localCreateRenameDelete.test.js +55 -140
- package/tests/functional/localLibCreateLibAlreadyDeleteLib.test.js +118 -0
- package/tests/functional/localLibCreateLibBuildLibDeleteLib.test.js +241 -0
- package/tests/functional/localLibCreateLibBuildLibListPubDeleteLib.test.js +246 -0
- package/tests/functional/localLibCreateLibDeleteLib.test.js +109 -0
- package/tests/functional/localLibCreateLibExportImportLib.test.js +242 -0
- package/tests/functional/localLibCreateLibExportLib.test.js +219 -0
- package/tests/functional/localLibCreateLibImportCompDeleteLib.test.js +131 -0
- package/tests/functional/localLibCreateLibListDeleteLib.test.js +261 -0
- package/tests/functional/localLibCreateLibListMoveDeleteLib.test.js +236 -0
- package/tests/functional/localLibCreateLibListSwitchDeleteLib.test.js +237 -0
- package/tests/functional/localLibCreateLibPermDeleteLib.test.js +144 -0
- package/tests/functional/localLibCreateLibStatusDeleteLib.test.js +194 -0
- package/tests/functional/localLibCreateLibVersionDeleteLib.test.js +453 -0
- package/tests/functional/localPromoteRevertWP.test.js +83 -38
|
@@ -0,0 +1,453 @@
|
|
|
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 createAll list createLibVersion(with copy) switchLibe list deleteLibVersion(all) : ${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
|
+
const script = `npm run createLib DXIL 0.0.1 N --prefix ../../..`;
|
|
86
|
+
const compConf = path.join("store", "Pega_DXIL","0.0.1-dev", "componentsconfig.json");
|
|
87
|
+
|
|
88
|
+
const { stdout, stderr } = await exec(script);
|
|
89
|
+
expect(stdout).toContain('Library Pega_DXIL/0.0.1-dev has been created!');
|
|
90
|
+
|
|
91
|
+
const doesExist = fs.existsSync(path.resolve('../../..', compConf));
|
|
92
|
+
|
|
93
|
+
expect(doesExist).toBeTruthy();
|
|
94
|
+
|
|
95
|
+
}, 30000);
|
|
96
|
+
|
|
97
|
+
it('npm run createAll', async () => {
|
|
98
|
+
const script = `npm run createAll "My" 0.0.1 DXIL "" Pega Jest --prefix ../../..`;
|
|
99
|
+
|
|
100
|
+
const { stdout, stderr } = await exec(script);
|
|
101
|
+
// console.log(stdout);
|
|
102
|
+
expect(stdout).not.toBeNull();
|
|
103
|
+
expect(stderr).not.toBeNull();
|
|
104
|
+
|
|
105
|
+
// want message to contain component name
|
|
106
|
+
expect(stdout).toContain('created Pega_DXIL_My');
|
|
107
|
+
|
|
108
|
+
// don't want message with already exists
|
|
109
|
+
expect(stdout).not.toContain('already exists');
|
|
110
|
+
|
|
111
|
+
// check to see file exists
|
|
112
|
+
|
|
113
|
+
// pick one
|
|
114
|
+
const newFileName = 'Pega_DXIL_MyBoolean';
|
|
115
|
+
|
|
116
|
+
// const fileDir = path.resolve(`src/components/${newFileName}`);
|
|
117
|
+
const createFile = path.resolve(
|
|
118
|
+
'../../..',
|
|
119
|
+
path.join(`src/components/${newFileName}`, 'index.tsx')
|
|
120
|
+
);
|
|
121
|
+
const doesExist = fs.existsSync(createFile);
|
|
122
|
+
expect(doesExist).toBeTruthy();
|
|
123
|
+
|
|
124
|
+
// if (doesExist) {
|
|
125
|
+
// // remove it
|
|
126
|
+
// fs.rmdirSync(fileDir, { recursive: true });
|
|
127
|
+
// }
|
|
128
|
+
}, 10000);
|
|
129
|
+
|
|
130
|
+
it('npm run list', async () => {
|
|
131
|
+
const script = 'npm run list --prefix ../../..';
|
|
132
|
+
const { stdout, stderr } = await exec(script);
|
|
133
|
+
|
|
134
|
+
expect(stderr).not.toBeNull();
|
|
135
|
+
|
|
136
|
+
// console.log(stdout);
|
|
137
|
+
expect(stdout).not.toBeNull();
|
|
138
|
+
expect(stdout).toContain('Pega_DXIL_MyText');
|
|
139
|
+
expect(stdout).toContain('Pega_DXIL_MyTextInput');
|
|
140
|
+
expect(stdout).toContain('Pega_DXIL_MyParagraph');
|
|
141
|
+
expect(stdout).toContain('Pega_DXIL_MyEmail');
|
|
142
|
+
expect(stdout).toContain('Pega_DXIL_MyPhone');
|
|
143
|
+
expect(stdout).toContain('Pega_DXIL_MyURL');
|
|
144
|
+
expect(stdout).toContain('Pega_DXIL_MyInteger');
|
|
145
|
+
expect(stdout).toContain('Pega_DXIL_MyDecimal');
|
|
146
|
+
expect(stdout).toContain('Pega_DXIL_MyCurrency');
|
|
147
|
+
expect(stdout).toContain('Pega_DXIL_MyPercentage');
|
|
148
|
+
expect(stdout).toContain('Pega_DXIL_MyBoolean');
|
|
149
|
+
expect(stdout).toContain('Pega_DXIL_MyDate');
|
|
150
|
+
expect(stdout).toContain('Pega_DXIL_MyDateTime');
|
|
151
|
+
expect(stdout).toContain('Pega_DXIL_MyTimeOfDay');
|
|
152
|
+
expect(stdout).toContain('Pega_DXIL_MyPicklist');
|
|
153
|
+
expect(stdout).toContain('Pega_DXIL_MySearchbox');
|
|
154
|
+
expect(stdout).toContain('Pega_DXIL_MyRadiobuttons');
|
|
155
|
+
expect(stdout).toContain('Pega_DXIL_MyDetails');
|
|
156
|
+
expect(stdout).toContain('Pega_DXIL_MyTwoColumnDetails');
|
|
157
|
+
expect(stdout).toContain('Pega_DXIL_MyForm');
|
|
158
|
+
expect(stdout).toContain('Pega_DXIL_MyTwoColumnForm');
|
|
159
|
+
expect(stdout).toContain('Pega_DXIL_MyPage');
|
|
160
|
+
expect(stdout).toContain('Pega_DXIL_MyCaseWidget');
|
|
161
|
+
expect(stdout).toContain('Pega_DXIL_MyPageWidget');
|
|
162
|
+
expect(stdout).toContain('Pega_DXIL_MyPageCaseWidget');
|
|
163
|
+
// done();
|
|
164
|
+
}, 10000);
|
|
165
|
+
|
|
166
|
+
it('compare created to default', async () => {
|
|
167
|
+
const compList = [
|
|
168
|
+
'Pega_DXIL_MyText',
|
|
169
|
+
'Pega_DXIL_MyTextInput',
|
|
170
|
+
'Pega_DXIL_MyParagraph',
|
|
171
|
+
'Pega_DXIL_MyEmail',
|
|
172
|
+
'Pega_DXIL_MyPhone',
|
|
173
|
+
'Pega_DXIL_MyURL',
|
|
174
|
+
'Pega_DXIL_MyInteger',
|
|
175
|
+
'Pega_DXIL_MyDecimal',
|
|
176
|
+
'Pega_DXIL_MyCurrency',
|
|
177
|
+
'Pega_DXIL_MyPercentage',
|
|
178
|
+
'Pega_DXIL_MyBoolean',
|
|
179
|
+
'Pega_DXIL_MyDate',
|
|
180
|
+
'Pega_DXIL_MyDateTime',
|
|
181
|
+
'Pega_DXIL_MyTimeOfDay',
|
|
182
|
+
'Pega_DXIL_MyPicklist',
|
|
183
|
+
'Pega_DXIL_MySearchbox',
|
|
184
|
+
'Pega_DXIL_MyRadiobuttons',
|
|
185
|
+
'Pega_DXIL_MyDetails',
|
|
186
|
+
'Pega_DXIL_MyTwoColumnDetails',
|
|
187
|
+
'Pega_DXIL_MyForm',
|
|
188
|
+
'Pega_DXIL_MyTwoColumnForm',
|
|
189
|
+
'Pega_DXIL_MyPage',
|
|
190
|
+
'Pega_DXIL_MyCaseWidget',
|
|
191
|
+
'Pega_DXIL_MyPageWidget',
|
|
192
|
+
'Pega_DXIL_MyPageCaseWidget'
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
compList.forEach(component => {
|
|
196
|
+
const componentDir = path.resolve('../../..', `src/components/${component}`);
|
|
197
|
+
const assetDir = path.resolve(`tests/assets/${compType}/components/createAll/${serverDir}/${component}`);
|
|
198
|
+
// get files of directory
|
|
199
|
+
const componentFiles = fs.readdirSync(componentDir);
|
|
200
|
+
|
|
201
|
+
// get files of assets
|
|
202
|
+
// const assetFiles = fs.readdirSync(assetDir);
|
|
203
|
+
|
|
204
|
+
// compare
|
|
205
|
+
componentFiles.forEach(file => {
|
|
206
|
+
const componentFilePath = path.join(componentDir, file);
|
|
207
|
+
const assetFilePath = path.join(assetDir, file);
|
|
208
|
+
|
|
209
|
+
let componentFileData = fs.readFileSync(componentFilePath, { encoding: 'utf8' });
|
|
210
|
+
let assetFileData = fs.readFileSync(assetFilePath, { encoding: 'utf8' });
|
|
211
|
+
|
|
212
|
+
// so that we don't have to generate all new assets, change "version"
|
|
213
|
+
// from 0.0.1-dev to 0.0.1 for now
|
|
214
|
+
if (file === "config.json") {
|
|
215
|
+
expect(componentFileData).toContain("0.0.1-dev");
|
|
216
|
+
componentFileData = componentFileData.replace("0.0.1-dev", "0.0.1");
|
|
217
|
+
|
|
218
|
+
// normalize
|
|
219
|
+
componentFileData = JSON.stringify(JSON.parse(componentFileData));
|
|
220
|
+
assetFileData = JSON.stringify(JSON.parse(assetFileData));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
expect(componentFileData).toEqual(assetFileData);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}, 10000);
|
|
227
|
+
|
|
228
|
+
it(`npm run createLibVersion and copy - ${isLibraryBased}`, async() => {
|
|
229
|
+
|
|
230
|
+
const script = `npm run createLibVersion 0.0.2 N Y NoAbout --prefix ../../..`;
|
|
231
|
+
const { stdout, stderr } = await exec(script);
|
|
232
|
+
|
|
233
|
+
expect(stdout).toContain('Library Pega_DXIL/0.0.1-dev has been stored.');
|
|
234
|
+
expect(stdout).toContain('Library Pega_DXIL/0.0.2-dev has been created!');
|
|
235
|
+
|
|
236
|
+
}, 30000);
|
|
237
|
+
|
|
238
|
+
it('npm run list of new version', async () => {
|
|
239
|
+
const script = 'npm run list --prefix ../../..';
|
|
240
|
+
const { stdout, stderr } = await exec(script);
|
|
241
|
+
|
|
242
|
+
expect(stderr).not.toBeNull();
|
|
243
|
+
|
|
244
|
+
// console.log(stdout);
|
|
245
|
+
expect(stdout).not.toBeNull();
|
|
246
|
+
expect(stdout).toContain('Pega_DXIL_MyText');
|
|
247
|
+
expect(stdout).toContain('Pega_DXIL_MyTextInput');
|
|
248
|
+
expect(stdout).toContain('Pega_DXIL_MyParagraph');
|
|
249
|
+
expect(stdout).toContain('Pega_DXIL_MyEmail');
|
|
250
|
+
expect(stdout).toContain('Pega_DXIL_MyPhone');
|
|
251
|
+
expect(stdout).toContain('Pega_DXIL_MyURL');
|
|
252
|
+
expect(stdout).toContain('Pega_DXIL_MyInteger');
|
|
253
|
+
expect(stdout).toContain('Pega_DXIL_MyDecimal');
|
|
254
|
+
expect(stdout).toContain('Pega_DXIL_MyCurrency');
|
|
255
|
+
expect(stdout).toContain('Pega_DXIL_MyPercentage');
|
|
256
|
+
expect(stdout).toContain('Pega_DXIL_MyBoolean');
|
|
257
|
+
expect(stdout).toContain('Pega_DXIL_MyDate');
|
|
258
|
+
expect(stdout).toContain('Pega_DXIL_MyDateTime');
|
|
259
|
+
expect(stdout).toContain('Pega_DXIL_MyTimeOfDay');
|
|
260
|
+
expect(stdout).toContain('Pega_DXIL_MyPicklist');
|
|
261
|
+
expect(stdout).toContain('Pega_DXIL_MySearchbox');
|
|
262
|
+
expect(stdout).toContain('Pega_DXIL_MyRadiobuttons');
|
|
263
|
+
expect(stdout).toContain('Pega_DXIL_MyDetails');
|
|
264
|
+
expect(stdout).toContain('Pega_DXIL_MyTwoColumnDetails');
|
|
265
|
+
expect(stdout).toContain('Pega_DXIL_MyForm');
|
|
266
|
+
expect(stdout).toContain('Pega_DXIL_MyTwoColumnForm');
|
|
267
|
+
expect(stdout).toContain('Pega_DXIL_MyPage');
|
|
268
|
+
expect(stdout).toContain('Pega_DXIL_MyCaseWidget');
|
|
269
|
+
expect(stdout).toContain('Pega_DXIL_MyPageWidget');
|
|
270
|
+
expect(stdout).toContain('Pega_DXIL_MyPageCaseWidget');
|
|
271
|
+
// done();
|
|
272
|
+
}, 10000);
|
|
273
|
+
|
|
274
|
+
it('compare created to default', async () => {
|
|
275
|
+
const compList = [
|
|
276
|
+
'Pega_DXIL_MyText',
|
|
277
|
+
'Pega_DXIL_MyTextInput',
|
|
278
|
+
'Pega_DXIL_MyParagraph',
|
|
279
|
+
'Pega_DXIL_MyEmail',
|
|
280
|
+
'Pega_DXIL_MyPhone',
|
|
281
|
+
'Pega_DXIL_MyURL',
|
|
282
|
+
'Pega_DXIL_MyInteger',
|
|
283
|
+
'Pega_DXIL_MyDecimal',
|
|
284
|
+
'Pega_DXIL_MyCurrency',
|
|
285
|
+
'Pega_DXIL_MyPercentage',
|
|
286
|
+
'Pega_DXIL_MyBoolean',
|
|
287
|
+
'Pega_DXIL_MyDate',
|
|
288
|
+
'Pega_DXIL_MyDateTime',
|
|
289
|
+
'Pega_DXIL_MyTimeOfDay',
|
|
290
|
+
'Pega_DXIL_MyPicklist',
|
|
291
|
+
'Pega_DXIL_MySearchbox',
|
|
292
|
+
'Pega_DXIL_MyRadiobuttons',
|
|
293
|
+
'Pega_DXIL_MyDetails',
|
|
294
|
+
'Pega_DXIL_MyTwoColumnDetails',
|
|
295
|
+
'Pega_DXIL_MyForm',
|
|
296
|
+
'Pega_DXIL_MyTwoColumnForm',
|
|
297
|
+
'Pega_DXIL_MyPage',
|
|
298
|
+
'Pega_DXIL_MyCaseWidget',
|
|
299
|
+
'Pega_DXIL_MyPageWidget',
|
|
300
|
+
'Pega_DXIL_MyPageCaseWidget'
|
|
301
|
+
];
|
|
302
|
+
|
|
303
|
+
compList.forEach(component => {
|
|
304
|
+
const componentDir = path.resolve('../../..', `src/components/${component}`);
|
|
305
|
+
const assetDir = path.resolve(`tests/assets/${compType}/components/createAll/${serverDir}/${component}`);
|
|
306
|
+
// get files of directory
|
|
307
|
+
const componentFiles = fs.readdirSync(componentDir);
|
|
308
|
+
|
|
309
|
+
// get files of assets
|
|
310
|
+
// const assetFiles = fs.readdirSync(assetDir);
|
|
311
|
+
|
|
312
|
+
// compare
|
|
313
|
+
componentFiles.forEach(file => {
|
|
314
|
+
const componentFilePath = path.join(componentDir, file);
|
|
315
|
+
const assetFilePath = path.join(assetDir, file);
|
|
316
|
+
|
|
317
|
+
let componentFileData = fs.readFileSync(componentFilePath, { encoding: 'utf8' });
|
|
318
|
+
let assetFileData = fs.readFileSync(assetFilePath, { encoding: 'utf8' });
|
|
319
|
+
|
|
320
|
+
// so that we don't have to generate all new assets, change "version"
|
|
321
|
+
// from 0.0.2-dev to 0.0.1 for now
|
|
322
|
+
if (file === "config.json") {
|
|
323
|
+
expect(componentFileData).toContain("0.0.2-dev");
|
|
324
|
+
componentFileData = componentFileData.replace("0.0.2-dev", "0.0.1");
|
|
325
|
+
|
|
326
|
+
// normalize
|
|
327
|
+
componentFileData = JSON.stringify(JSON.parse(componentFileData));
|
|
328
|
+
assetFileData = JSON.stringify(JSON.parse(assetFileData));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
expect(componentFileData).toEqual(assetFileData);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
}, 10000);
|
|
335
|
+
|
|
336
|
+
it(`npm run switchLibVersion - ${isLibraryBased}`, async() => {
|
|
337
|
+
// we are at version 0.0.2, switch to 0.0.1
|
|
338
|
+
const script = `npm run switchLibVersion Y 0.0.1-dev NoAbout --prefix ../../..`;
|
|
339
|
+
const { stdout, stderr } = await exec(script);
|
|
340
|
+
|
|
341
|
+
expect(stdout).toContain('Switched to Pega_DXIL/0.0.1-dev!');
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
}, 30000);
|
|
345
|
+
|
|
346
|
+
it('npm run list of original version', async () => {
|
|
347
|
+
const script = 'npm run list --prefix ../../..';
|
|
348
|
+
const { stdout, stderr } = await exec(script);
|
|
349
|
+
|
|
350
|
+
expect(stderr).not.toBeNull();
|
|
351
|
+
|
|
352
|
+
// console.log(stdout);
|
|
353
|
+
expect(stdout).not.toBeNull();
|
|
354
|
+
expect(stdout).toContain('Pega_DXIL_MyText');
|
|
355
|
+
expect(stdout).toContain('Pega_DXIL_MyTextInput');
|
|
356
|
+
expect(stdout).toContain('Pega_DXIL_MyParagraph');
|
|
357
|
+
expect(stdout).toContain('Pega_DXIL_MyEmail');
|
|
358
|
+
expect(stdout).toContain('Pega_DXIL_MyPhone');
|
|
359
|
+
expect(stdout).toContain('Pega_DXIL_MyURL');
|
|
360
|
+
expect(stdout).toContain('Pega_DXIL_MyInteger');
|
|
361
|
+
expect(stdout).toContain('Pega_DXIL_MyDecimal');
|
|
362
|
+
expect(stdout).toContain('Pega_DXIL_MyCurrency');
|
|
363
|
+
expect(stdout).toContain('Pega_DXIL_MyPercentage');
|
|
364
|
+
expect(stdout).toContain('Pega_DXIL_MyBoolean');
|
|
365
|
+
expect(stdout).toContain('Pega_DXIL_MyDate');
|
|
366
|
+
expect(stdout).toContain('Pega_DXIL_MyDateTime');
|
|
367
|
+
expect(stdout).toContain('Pega_DXIL_MyTimeOfDay');
|
|
368
|
+
expect(stdout).toContain('Pega_DXIL_MyPicklist');
|
|
369
|
+
expect(stdout).toContain('Pega_DXIL_MySearchbox');
|
|
370
|
+
expect(stdout).toContain('Pega_DXIL_MyRadiobuttons');
|
|
371
|
+
expect(stdout).toContain('Pega_DXIL_MyDetails');
|
|
372
|
+
expect(stdout).toContain('Pega_DXIL_MyTwoColumnDetails');
|
|
373
|
+
expect(stdout).toContain('Pega_DXIL_MyForm');
|
|
374
|
+
expect(stdout).toContain('Pega_DXIL_MyTwoColumnForm');
|
|
375
|
+
expect(stdout).toContain('Pega_DXIL_MyPage');
|
|
376
|
+
expect(stdout).toContain('Pega_DXIL_MyCaseWidget');
|
|
377
|
+
expect(stdout).toContain('Pega_DXIL_MyPageWidget');
|
|
378
|
+
expect(stdout).toContain('Pega_DXIL_MyPageCaseWidget');
|
|
379
|
+
// done();
|
|
380
|
+
}, 10000);
|
|
381
|
+
|
|
382
|
+
it('compare created to default', async () => {
|
|
383
|
+
const compList = [
|
|
384
|
+
'Pega_DXIL_MyText',
|
|
385
|
+
'Pega_DXIL_MyTextInput',
|
|
386
|
+
'Pega_DXIL_MyParagraph',
|
|
387
|
+
'Pega_DXIL_MyEmail',
|
|
388
|
+
'Pega_DXIL_MyPhone',
|
|
389
|
+
'Pega_DXIL_MyURL',
|
|
390
|
+
'Pega_DXIL_MyInteger',
|
|
391
|
+
'Pega_DXIL_MyDecimal',
|
|
392
|
+
'Pega_DXIL_MyCurrency',
|
|
393
|
+
'Pega_DXIL_MyPercentage',
|
|
394
|
+
'Pega_DXIL_MyBoolean',
|
|
395
|
+
'Pega_DXIL_MyDate',
|
|
396
|
+
'Pega_DXIL_MyDateTime',
|
|
397
|
+
'Pega_DXIL_MyTimeOfDay',
|
|
398
|
+
'Pega_DXIL_MyPicklist',
|
|
399
|
+
'Pega_DXIL_MySearchbox',
|
|
400
|
+
'Pega_DXIL_MyRadiobuttons',
|
|
401
|
+
'Pega_DXIL_MyDetails',
|
|
402
|
+
'Pega_DXIL_MyTwoColumnDetails',
|
|
403
|
+
'Pega_DXIL_MyForm',
|
|
404
|
+
'Pega_DXIL_MyTwoColumnForm',
|
|
405
|
+
'Pega_DXIL_MyPage',
|
|
406
|
+
'Pega_DXIL_MyCaseWidget',
|
|
407
|
+
'Pega_DXIL_MyPageWidget',
|
|
408
|
+
'Pega_DXIL_MyPageCaseWidget'
|
|
409
|
+
];
|
|
410
|
+
|
|
411
|
+
compList.forEach(component => {
|
|
412
|
+
const componentDir = path.resolve('../../..', `src/components/${component}`);
|
|
413
|
+
const assetDir = path.resolve(`tests/assets/${compType}/components/createAll/${serverDir}/${component}`);
|
|
414
|
+
// get files of directory
|
|
415
|
+
const componentFiles = fs.readdirSync(componentDir);
|
|
416
|
+
|
|
417
|
+
// get files of assets
|
|
418
|
+
// const assetFiles = fs.readdirSync(assetDir);
|
|
419
|
+
|
|
420
|
+
// compare
|
|
421
|
+
componentFiles.forEach(file => {
|
|
422
|
+
const componentFilePath = path.join(componentDir, file);
|
|
423
|
+
const assetFilePath = path.join(assetDir, file);
|
|
424
|
+
|
|
425
|
+
let componentFileData = fs.readFileSync(componentFilePath, { encoding: 'utf8' });
|
|
426
|
+
let assetFileData = fs.readFileSync(assetFilePath, { encoding: 'utf8' });
|
|
427
|
+
|
|
428
|
+
// so that we don't have to generate all new assets, change "version"
|
|
429
|
+
// from 0.0.1-dev to 0.0.1 for now
|
|
430
|
+
if (file === "config.json") {
|
|
431
|
+
expect(componentFileData).toContain("0.0.1-dev");
|
|
432
|
+
componentFileData = componentFileData.replace("0.0.1-dev", "0.0.1");
|
|
433
|
+
// normalize
|
|
434
|
+
componentFileData = JSON.stringify(JSON.parse(componentFileData));
|
|
435
|
+
assetFileData = JSON.stringify(JSON.parse(assetFileData));
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
expect(componentFileData).toEqual(assetFileData);
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
}, 10000);
|
|
442
|
+
|
|
443
|
+
it(`npm run deleteLibVersion ALL - ${isLibraryBased}`, async() => {
|
|
444
|
+
|
|
445
|
+
const script = `npm run deleteLibVersion ALL --prefix ../../..`;
|
|
446
|
+
const { stdout, stderr } = await exec(script);
|
|
447
|
+
|
|
448
|
+
expect(stdout).toContain('Pega_DXIL is deleted from Local.');
|
|
449
|
+
|
|
450
|
+
}, 30000);
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
});
|
|
@@ -6,13 +6,67 @@ 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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
21
|
+
let compType = isLibraryBased ? "library" : "original";
|
|
22
|
+
|
|
23
|
+
describe(`promote revert webpack: ${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));
|
|
67
|
+
|
|
68
|
+
});
|
|
14
69
|
|
|
15
|
-
describe(`promote and revert webpack: ${serverDir} - ${compType}`, () => {
|
|
16
70
|
it('npm run promoteWebPack', async () => {
|
|
17
71
|
const script = `npm run promoteWebPack --prefix ../../..`;
|
|
18
72
|
|
|
@@ -21,28 +75,23 @@ describe(`promote and revert webpack: ${serverDir} - ${compType}`, () => {
|
|
|
21
75
|
expect(stdout).not.toBeNull();
|
|
22
76
|
expect(stderr).not.toBeNull();
|
|
23
77
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
else {
|
|
78
|
+
// want message to contain component name
|
|
79
|
+
expect(stdout).toContain('Bundler now using');
|
|
80
|
+
expect(stdout).toContain('webpack.config.js');
|
|
28
81
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
expect(stdout).toContain('webpack.config.js');
|
|
82
|
+
// utilize
|
|
83
|
+
expect(stdout).toContain('Utilize this file for webpack modifications.');
|
|
32
84
|
|
|
33
|
-
|
|
34
|
-
|
|
85
|
+
// verify new file exists
|
|
86
|
+
const webPackFile = path.resolve('../../..', 'webpack.config.js');
|
|
35
87
|
|
|
36
|
-
|
|
37
|
-
const webPackFile = path.resolve('../../..', 'webpack.config.js');
|
|
88
|
+
expect(fs.existsSync(webPackFile)).toBeTruthy();
|
|
38
89
|
|
|
39
|
-
|
|
90
|
+
// if (doesExist) {
|
|
91
|
+
// // remove it
|
|
92
|
+
// fs.rmdirSync(fileDir, { recursive: true });
|
|
93
|
+
// }
|
|
40
94
|
|
|
41
|
-
// if (doesExist) {
|
|
42
|
-
// // remove it
|
|
43
|
-
// fs.rmdirSync(fileDir, { recursive: true });
|
|
44
|
-
// }
|
|
45
|
-
}
|
|
46
95
|
}, 10000);
|
|
47
96
|
|
|
48
97
|
it('npm run revertWebPack', async () => {
|
|
@@ -53,27 +102,23 @@ describe(`promote and revert webpack: ${serverDir} - ${compType}`, () => {
|
|
|
53
102
|
expect(stdout).not.toBeNull();
|
|
54
103
|
expect(stderr).not.toBeNull();
|
|
55
104
|
|
|
56
|
-
if (isLibraryBased) {
|
|
57
|
-
expect(stdout).toContain('Command only supported for non library based components.');
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
105
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
106
|
+
// want message to contain component name
|
|
107
|
+
expect(stdout).toContain('marked as not used.');
|
|
108
|
+
expect(stdout).toContain('webpack.config.js');
|
|
64
109
|
|
|
65
|
-
|
|
66
|
-
|
|
110
|
+
// message with bundler
|
|
111
|
+
expect(stdout).toContain('Bundler reverted to using internal webpack.config.js.');
|
|
67
112
|
|
|
68
|
-
|
|
69
|
-
|
|
113
|
+
// verify file marked as not used
|
|
114
|
+
const webPackFile = path.resolve('../../..', 'webpack.config.js.notused');
|
|
70
115
|
|
|
71
|
-
|
|
116
|
+
expect(fs.existsSync(webPackFile)).toBeTruthy();
|
|
117
|
+
|
|
118
|
+
// if (doesExist) {
|
|
119
|
+
// // remove it
|
|
120
|
+
// fs.rmdirSync(fileDir, { recursive: true });
|
|
121
|
+
// }
|
|
72
122
|
|
|
73
|
-
// if (doesExist) {
|
|
74
|
-
// // remove it
|
|
75
|
-
// fs.rmdirSync(fileDir, { recursive: true });
|
|
76
|
-
// }
|
|
77
|
-
}
|
|
78
123
|
}, 10000);
|
|
79
124
|
});
|