@pega/custom-dx-components 0.242.35 → 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 +6 -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 +3 -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 +2 -4
- package/src/tasks/import-comp/index.js +1 -2
- package/src/tasks/index.js +1 -0
- package/src/tasks/init/template/package.json.mustache +3 -2
- package/src/tasks/list-lib/index.js +3 -1
- package/src/tasks/list-pub/index.js +18 -14
- package/src/tasks/move/helper.js +6 -3
- package/src/tasks/move/index.js +86 -17
- 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/store/index.js +4 -1
- package/src/tasks/switch-lib/index.js +3 -1
- package/src/tasks/switch-version/index.js +3 -1
- package/src/util.js +50 -6
- 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,246 @@
|
|
|
1
|
+
// import { exec } from 'child_process';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const util = require('node:util');
|
|
5
|
+
const error = require('console');
|
|
6
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
7
|
+
|
|
8
|
+
const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
|
|
9
|
+
const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
|
|
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
|
+
|
|
20
|
+
const serverType = tasksConfigJSON['server-config'].serverType;
|
|
21
|
+
const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
|
|
22
|
+
let compType = isLibraryBased ? "library" : "original";
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
describe(`createLib create buildLib deleteLib deletePublishedLib: ${serverDir} - ${compType}` , () => {
|
|
26
|
+
|
|
27
|
+
beforeAll( async() => {
|
|
28
|
+
|
|
29
|
+
// make libraryBased
|
|
30
|
+
isLibraryBased = true;
|
|
31
|
+
tasksConfigJSON['libraryMode'] = isLibraryBased;
|
|
32
|
+
compType = isLibraryBased ? "library" : "original";
|
|
33
|
+
fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
|
|
34
|
+
|
|
35
|
+
const storeDir = path.join(path.resolve('../../..'), 'store');
|
|
36
|
+
if (fs.existsSync(storeDir)) {
|
|
37
|
+
fs.rmSync(storeDir, { recursive: true, force: true, maxRetries: 2 });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// make organzation Pega
|
|
41
|
+
packageJSON.organization = "Pega";
|
|
42
|
+
fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const componentsDir = path.join(path.resolve('../../..'), 'src/components');
|
|
46
|
+
if (fs.existsSync(componentsDir)) {
|
|
47
|
+
fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
|
|
48
|
+
fs.mkdirSync(componentsDir, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterAll( async() => {
|
|
57
|
+
|
|
58
|
+
//restore
|
|
59
|
+
isLibraryBased = savedLibraryBased
|
|
60
|
+
tasksConfigJSON['libraryMode'] = isLibraryBased;
|
|
61
|
+
|
|
62
|
+
fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
|
|
63
|
+
|
|
64
|
+
// return organzation
|
|
65
|
+
packageJSON.organization = savedOrganization;
|
|
66
|
+
fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
|
|
67
|
+
|
|
68
|
+
const componentsDir = path.join(path.resolve('../../..'), 'src/components');
|
|
69
|
+
if (fs.existsSync(componentsDir)) {
|
|
70
|
+
fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
|
|
71
|
+
fs.mkdirSync(componentsDir, { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
75
|
+
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
it(`npm run createLib - ${isLibraryBased}`, async() => {
|
|
80
|
+
|
|
81
|
+
const script = `npm run createLib DXIL 0.0.1 N --prefix ../../..`;
|
|
82
|
+
const compConf = path.join("store", "Pega_DXIL","0.0.1-dev", "componentsconfig.json");
|
|
83
|
+
|
|
84
|
+
const { stdout, stderr } = await exec(script);
|
|
85
|
+
expect(stdout).toContain('Library Pega_DXIL/0.0.1-dev has been created!');
|
|
86
|
+
|
|
87
|
+
const doesExist = fs.existsSync(path.resolve('../../..', compConf));
|
|
88
|
+
|
|
89
|
+
expect(doesExist).toBeTruthy();
|
|
90
|
+
|
|
91
|
+
}, 30000);
|
|
92
|
+
|
|
93
|
+
it('npm run create Local text', async () => {
|
|
94
|
+
const fileName = 'MyTestText';
|
|
95
|
+
const newFileName = `Pega_DXIL_${fileName}`;
|
|
96
|
+
const script = `npm run create Field Text ${fileName} "My Test Text" 0.0.1 DXIL "" "My Test Text Description" Pega --prefix ../../..`;
|
|
97
|
+
|
|
98
|
+
const { stdout, stderr } = await exec(script);
|
|
99
|
+
// console.log(stdout);
|
|
100
|
+
expect(stdout).not.toBeNull();
|
|
101
|
+
expect(stderr).not.toBeNull();
|
|
102
|
+
|
|
103
|
+
// want message to contain component name
|
|
104
|
+
expect(stdout).toContain(newFileName);
|
|
105
|
+
|
|
106
|
+
// don't want message with already exists
|
|
107
|
+
expect(stdout).not.toContain('already exists');
|
|
108
|
+
|
|
109
|
+
// check to see file exists
|
|
110
|
+
|
|
111
|
+
// const fileDir = path.resolve(`src/components/${newFileName}`);
|
|
112
|
+
const createFile = path.resolve(
|
|
113
|
+
'../../..',
|
|
114
|
+
path.join(`src/components/${newFileName}`, 'index.tsx')
|
|
115
|
+
);
|
|
116
|
+
const doesExist = fs.existsSync(createFile);
|
|
117
|
+
expect(doesExist).toBeTruthy();
|
|
118
|
+
|
|
119
|
+
// if (doesExist) {
|
|
120
|
+
// // remove it
|
|
121
|
+
// fs.rmdirSync(fileDir, { recursive: true });
|
|
122
|
+
// }
|
|
123
|
+
}, 10000);
|
|
124
|
+
|
|
125
|
+
it('npm run create Local page', async () => {
|
|
126
|
+
const fileName = 'MyTestPage';
|
|
127
|
+
const newFileName = `Pega_DXIL_${fileName}`;
|
|
128
|
+
const script = `npm run create Widget PAGE ${fileName} "My Test Page" 0.0.1 DXIL "" "My Test Page Description" Pega --prefix ../../..`;
|
|
129
|
+
|
|
130
|
+
const { stdout, stderr } = await exec(script);
|
|
131
|
+
// console.log(stdout);
|
|
132
|
+
expect(stdout).not.toBeNull();
|
|
133
|
+
expect(stderr).not.toBeNull();
|
|
134
|
+
|
|
135
|
+
// want message to contain component name
|
|
136
|
+
expect(stdout).toContain(newFileName);
|
|
137
|
+
|
|
138
|
+
// don't want message with already exists
|
|
139
|
+
expect(stdout).not.toContain('already exists');
|
|
140
|
+
|
|
141
|
+
// check to see file exists
|
|
142
|
+
|
|
143
|
+
// const fileDir = path.resolve(`src/components/${newFileName}`);
|
|
144
|
+
const createFile = path.resolve(
|
|
145
|
+
'../../..',
|
|
146
|
+
path.join(`src/components/${newFileName}`, 'index.tsx')
|
|
147
|
+
);
|
|
148
|
+
const doesExist = fs.existsSync(createFile);
|
|
149
|
+
expect(doesExist).toBeTruthy();
|
|
150
|
+
|
|
151
|
+
// if (doesExist) {
|
|
152
|
+
// // remove it
|
|
153
|
+
// fs.rmdirSync(fileDir, { recursive: true });
|
|
154
|
+
// }
|
|
155
|
+
}, 10000);
|
|
156
|
+
|
|
157
|
+
it('npm run create Local details', async () => {
|
|
158
|
+
const fileName = 'MyTestDetails';
|
|
159
|
+
const newFileName = `Pega_DXIL_${fileName}`;
|
|
160
|
+
const script = `npm run create Template DETAILS ${fileName} "My Test Details" 0.0.1 DXIL "" "My Test Details Description" Pega --prefix ../../..`;
|
|
161
|
+
|
|
162
|
+
const { stdout, stderr } = await exec(script);
|
|
163
|
+
// console.log(stdout);
|
|
164
|
+
expect(stdout).not.toBeNull();
|
|
165
|
+
expect(stderr).not.toBeNull();
|
|
166
|
+
|
|
167
|
+
// want message to contain component name
|
|
168
|
+
expect(stdout).toContain(newFileName);
|
|
169
|
+
|
|
170
|
+
// don't want message with already exists
|
|
171
|
+
expect(stdout).not.toContain('already exists');
|
|
172
|
+
|
|
173
|
+
// check to see file exists
|
|
174
|
+
|
|
175
|
+
// const fileDir = path.resolve(`src/components/${newFileName}`);
|
|
176
|
+
const createFile = path.resolve(
|
|
177
|
+
'../../..',
|
|
178
|
+
path.join(`src/components/${newFileName}`, 'index.tsx')
|
|
179
|
+
);
|
|
180
|
+
const doesExist = fs.existsSync(createFile);
|
|
181
|
+
expect(doesExist).toBeTruthy();
|
|
182
|
+
|
|
183
|
+
// if (doesExist) {
|
|
184
|
+
// // remove it
|
|
185
|
+
// fs.rmdirSync(fileDir, { recursive: true });
|
|
186
|
+
// }
|
|
187
|
+
}, 10000);
|
|
188
|
+
|
|
189
|
+
it(`npm run buildLib (internal) - ${isLibraryBased}`, async() => {
|
|
190
|
+
|
|
191
|
+
const script = `npm run _internal-buildLibrary 0.0.1 Y --prefix ../../..`;
|
|
192
|
+
const { stdout, stderr } = await exec(script);
|
|
193
|
+
|
|
194
|
+
expect(stdout).not.toContain('JWT token has expired, please reauthenticate.');
|
|
195
|
+
expect(stdout).toContain('Pega_DXIL_MyTestText schema is valid');
|
|
196
|
+
expect(stdout).toContain('Pega_DXIL_MyTestPage schema is valid');
|
|
197
|
+
expect(stdout).toContain('Pega_DXIL_MyTestDetails schema is valid');
|
|
198
|
+
|
|
199
|
+
expect(stdout).toContain('Building Library...');
|
|
200
|
+
expect(stdout).toContain('Compile check...');
|
|
201
|
+
|
|
202
|
+
expect(stdout).toContain('Webpacked library Pega_DXIL:0.0.1-dev successfully!!');
|
|
203
|
+
expect(stdout).toContain('== Creating manifest for the library version - completed ==');
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
}, 200000);
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
it(`npm run listPublishedLib - ${isLibraryBased}`, async() => {
|
|
211
|
+
|
|
212
|
+
const script = `npm run listPublishedLib Local Pega_DXIL 0.0.1-dev --prefix ../../..`;
|
|
213
|
+
const { stdout, stderr } = await exec(script);
|
|
214
|
+
|
|
215
|
+
expect(stdout).toContain('Pega_DXIL_MyTestText');
|
|
216
|
+
expect(stdout).toContain('Pega_DXIL_MyTestPage');
|
|
217
|
+
expect(stdout).toContain('Pega_DXIL_MyTestDetails');
|
|
218
|
+
|
|
219
|
+
expect(stdout).toContain('0.0.1-dev');
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
}, 30000);
|
|
223
|
+
|
|
224
|
+
it(`npm run deleteLib - ${isLibraryBased}`, async() => {
|
|
225
|
+
|
|
226
|
+
const script = `npm run deleteLib Pega_DXIL 0.0.1-dev --prefix ../../..`;
|
|
227
|
+
const { stdout, stderr } = await exec(script);
|
|
228
|
+
expect(stdout).toContain('Pega_DXIL is deleted from Local.');
|
|
229
|
+
|
|
230
|
+
}, 30000);
|
|
231
|
+
|
|
232
|
+
it(`npm run deletePublishedLib - ${isLibraryBased}`, async() => {
|
|
233
|
+
|
|
234
|
+
const script = `npm run deletePublishedLib Local ALL --prefix ../../..`;
|
|
235
|
+
const { stdout, stderr } = await exec(script);
|
|
236
|
+
expect(stdout).toContain('Library: Pega_DXIL is deleted from Local');
|
|
237
|
+
|
|
238
|
+
const localLib = path.resolve('../../..', `Pega_DXIL`);
|
|
239
|
+
expect(fs.existsSync(localLib)).not.toBeTruthy();
|
|
240
|
+
|
|
241
|
+
}, 30000);
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
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 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
|
+
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
|
+
|
|
98
|
+
it(`npm run deleteLib- ${isLibraryBased}`, async() => {
|
|
99
|
+
|
|
100
|
+
const script = `npm run deleteLib Pega_DXIL 0.0.1-dev --prefix ../../..`;
|
|
101
|
+
const { stdout, stderr } = await exec(script);
|
|
102
|
+
|
|
103
|
+
expect(stdout).toContain('Pega_DXIL is deleted from Local.');
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
}, 30000);
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
});
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
// import { exec } from 'child_process';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const util = require('node:util');
|
|
5
|
+
const { default: def } = require('ajv/dist/vocabularies/discriminator');
|
|
6
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
7
|
+
|
|
8
|
+
const tasksConfigDir = path.resolve('../../..', 'tasks.config.json');
|
|
9
|
+
const tasksConfigData = fs.readFileSync(tasksConfigDir, { encoding: 'utf8' });
|
|
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
|
+
|
|
20
|
+
const serverType = tasksConfigJSON['server-config'].serverType;
|
|
21
|
+
const serverDir = serverType === 'launchpad' ? 'Launchpad' : 'Constellation';
|
|
22
|
+
let compType = isLibraryBased ? "library" : "original";
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
describe(`createLib createAll exportStore importStore deleteLib: ${serverDir} - ${compType}` , () => {
|
|
26
|
+
|
|
27
|
+
beforeAll( async() => {
|
|
28
|
+
|
|
29
|
+
// make libraryBased
|
|
30
|
+
isLibraryBased = true;
|
|
31
|
+
tasksConfigJSON['libraryMode'] = isLibraryBased;
|
|
32
|
+
compType = isLibraryBased ? "library" : "original";
|
|
33
|
+
fs.writeFileSync(tasksConfigDir, JSON.stringify(tasksConfigJSON, null, 4), { encoding: 'utf8' });
|
|
34
|
+
|
|
35
|
+
const storeDir = path.join(path.resolve('../../..'), 'store');
|
|
36
|
+
if (fs.existsSync(storeDir)) {
|
|
37
|
+
fs.rmSync(storeDir, { recursive: true, force: true, maxRetries: 2 });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// make organzation Pega
|
|
41
|
+
packageJSON.organization = "Pega";
|
|
42
|
+
fs.writeFileSync(packageJSONDir, JSON.stringify(packageJSON, null, 4), { encoding: 'utf8' });
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const componentsDir = path.join(path.resolve('../../..'), 'src/components');
|
|
46
|
+
if (fs.existsSync(componentsDir)) {
|
|
47
|
+
fs.rmSync(componentsDir, { recursive: true, force: true, maxRetries: 2 });
|
|
48
|
+
fs.mkdirSync(componentsDir, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
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
|
+
|
|
167
|
+
it(`npm run export lib - ${isLibraryBased}`, async() => {
|
|
168
|
+
|
|
169
|
+
const currentDirectory = process.cwd();
|
|
170
|
+
const arPathParts = currentDirectory.split(path.sep);
|
|
171
|
+
let defaultPath = path.join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
|
|
172
|
+
if (path.sep === "/") {
|
|
173
|
+
defaultPath = "/".concat(defaultPath);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const script = `npm run exportLibVersion Pega_DXIL 0.0.1-dev ${defaultPath} Current --prefix ../../..`;
|
|
177
|
+
const { stdout, stderr } = await exec(script);
|
|
178
|
+
|
|
179
|
+
expect(stdout).toContain('Pega_DXIL_0.0.1-dev.zip has been exported');
|
|
180
|
+
const zipFile = path.join(defaultPath, "Pega_DXIL_0.0.1-dev.zip");
|
|
181
|
+
expect(fs.existsSync(zipFile)).toBeTruthy();
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
}, 30000);
|
|
185
|
+
|
|
186
|
+
it(`npm run import lib (delete zip) - ${isLibraryBased}`, async() => {
|
|
187
|
+
|
|
188
|
+
const currentDirectory = process.cwd();
|
|
189
|
+
const arPathParts = currentDirectory.split(path.sep);
|
|
190
|
+
let defaultPath = path.join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
|
|
191
|
+
if (path.sep === "/") {
|
|
192
|
+
defaultPath = "/".concat(defaultPath);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const script = `npm run importLibVersion ${defaultPath} Pega_DXIL_0.0.1-dev.zip --prefix ../../..`;
|
|
196
|
+
const { stdout, stderr } = await exec(script);
|
|
197
|
+
|
|
198
|
+
expect(stdout).toContain('Pega_DXIL_0.0.1-dev.zip has been imported!');
|
|
199
|
+
expect(stdout).toContain('You can switch to Pega_DXIL/0.0.1-dev via npm run switchLib.');
|
|
200
|
+
|
|
201
|
+
const zipFile = path.join(defaultPath, "Pega_DXIL_0.0.1-dev.zip");
|
|
202
|
+
expect(fs.existsSync(zipFile)).toBeTruthy();
|
|
203
|
+
|
|
204
|
+
// delete zip file
|
|
205
|
+
// fs.rmSync(zipFile, {recursive: true});
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
}, 30000);
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
it(`npm run delete import - ${isLibraryBased}`, async() => {
|
|
212
|
+
|
|
213
|
+
const currentDirectory = process.cwd();
|
|
214
|
+
const arPathParts = currentDirectory.split(path.sep);
|
|
215
|
+
let defaultPath = path.join(arPathParts[0], arPathParts[1], arPathParts[2], "Downloads");
|
|
216
|
+
if (path.sep === "/") {
|
|
217
|
+
defaultPath = "/".concat(defaultPath);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const zipFile = path.join(defaultPath, "Pega_DXIL_0.0.1-dev.zip");
|
|
221
|
+
expect(fs.existsSync(zipFile)).toBeTruthy();
|
|
222
|
+
|
|
223
|
+
// delete zip file
|
|
224
|
+
fs.rmSync(zipFile, {recursive: true});
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
}, 30000);
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
it(`npm run deleteLib - ${isLibraryBased}`, async() => {
|
|
232
|
+
|
|
233
|
+
const script = `npm run deleteLib Pega_DXIL 0.0.1-dev --prefix ../../..`;
|
|
234
|
+
const { stdout, stderr } = await exec(script);
|
|
235
|
+
|
|
236
|
+
expect(stdout).toContain('Pega_DXIL is deleted from Local.');
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
}, 30000);
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
});
|