record-replay-req-res-scenario 16.5.14 → 16.5.15
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/assets/shared/shared_folder_info.txt +1 -1
- package/browser/esm2022/lib/index.mjs +3 -2
- package/browser/fesm2022/record-replay-req-res-scenario.mjs +2 -18
- package/browser/fesm2022/record-replay-req-res-scenario.mjs.map +1 -1
- package/browser/lib/index.d.ts +1 -1
- package/client/esm2022/lib/index.mjs +3 -2
- package/client/fesm2022/record-replay-req-res-scenario.mjs +2 -18
- package/client/fesm2022/record-replay-req-res-scenario.mjs.map +1 -1
- package/client/lib/index.d.ts +1 -1
- package/client/package.json +37 -34
- package/lib/index.d.ts +1 -3
- package/lib/index.js +9 -8
- package/lib/index.js.map +1 -1
- package/lib/record-replay-req-res-scenario.d.ts +0 -52
- package/lib/record-replay-req-res-scenario.js +371 -365
- package/lib/record-replay-req-res-scenario.js.map +1 -1
- package/lib/scenario.backend.d.ts +0 -42
- package/lib/scenario.backend.js +231 -250
- package/lib/scenario.backend.js.map +1 -1
- package/lib/start.backend.d.ts +0 -1
- package/lib/start.backend.js +19 -46
- package/lib/start.backend.js.map +1 -1
- package/lib/tape.backend.d.ts +0 -15
- package/lib/tape.backend.js +27 -20
- package/lib/tape.backend.js.map +1 -1
- package/package.json +8 -5
- package/package.json_tnp.json5 +3 -0
- package/tmp-environment.json +41 -45
- package/websql/esm2022/lib/index.mjs +3 -2
- package/websql/fesm2022/record-replay-req-res-scenario.mjs +2 -18
- package/websql/fesm2022/record-replay-req-res-scenario.mjs.map +1 -1
- package/websql/lib/index.d.ts +1 -1
- package/browser/esm2022/lib/record-replay-req-res-scenario.mjs +0 -18
- package/browser/lib/record-replay-req-res-scenario.d.ts +0 -19
- package/client/esm2022/lib/record-replay-req-res-scenario.mjs +0 -18
- package/client/lib/record-replay-req-res-scenario.d.ts +0 -19
- package/websql/esm2022/lib/record-replay-req-res-scenario.mjs +0 -18
- package/websql/lib/record-replay-req-res-scenario.d.ts +0 -19
|
@@ -1,366 +1,372 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
1
|
+
// //#region imports
|
|
2
|
+
// //#region @backend
|
|
3
|
+
// import * as _ from 'lodash';
|
|
4
|
+
// import * as path from 'path';
|
|
5
|
+
// import { Helpers, BaseProject as Project } from 'tnp-helpers';
|
|
6
|
+
// import { URL } from 'url';
|
|
7
|
+
// import { config } from 'tnp-config';
|
|
8
|
+
// import * as moment from 'moment';
|
|
9
|
+
// import { talkback, Options, RecordMode } from 'ng-talkback';
|
|
10
|
+
// import * as glob from 'glob';
|
|
11
|
+
// import { Scenario, ScenarioParam, ScenarioParams, ScenarioParamsReturn } from './scenario.backend';
|
|
12
|
+
// import chalk from 'chalk';
|
|
13
|
+
// import * as inquirer from 'inquirer';
|
|
14
|
+
// // import { Models } from 'tnp-models';
|
|
15
|
+
// //#endregion
|
|
16
|
+
// //#endregion
|
|
17
|
+
// //#region models
|
|
18
|
+
// export type RecordData = { host: number | string | URL; talkbackProxyPort?: number | string; }
|
|
19
|
+
// export type RecorderConfigMeta = {
|
|
20
|
+
// [recordHostName: string]: RecordData;
|
|
21
|
+
// } & { scenarioName: string; }
|
|
22
|
+
// export type ReplayConfigMeta = {
|
|
23
|
+
// [recordHostName: string]: { talkbackProxyPort?: number | string; }
|
|
24
|
+
// } & { scenarioPath: string; }
|
|
25
|
+
// type ArgsOptReplayRecordArgType = { port: string | string[]; hostName: string | string[]; };
|
|
26
|
+
// interface RecordArgType {
|
|
27
|
+
// record: {
|
|
28
|
+
// /**
|
|
29
|
+
// * url with host to record
|
|
30
|
+
// */
|
|
31
|
+
// url: URL;
|
|
32
|
+
// /**
|
|
33
|
+
// * Identifier of what was the name or id of server.
|
|
34
|
+
// * this metadata is usefull to replay back multiple servers
|
|
35
|
+
// * on different talkback ports
|
|
36
|
+
// */
|
|
37
|
+
// name: string;
|
|
38
|
+
// };
|
|
39
|
+
// /**
|
|
40
|
+
// * talkback port for localhost proxy
|
|
41
|
+
// */
|
|
42
|
+
// talkbackProxyPort: number;
|
|
43
|
+
// }
|
|
44
|
+
// //#endregion
|
|
45
|
+
// export class RecordReplayReqResScenario {
|
|
46
|
+
// //#region @backend
|
|
47
|
+
// //#region consts
|
|
48
|
+
// /**
|
|
49
|
+
// * by pinging to http://localhost:5544/path/to/something
|
|
50
|
+
// * you are actually recording request from
|
|
51
|
+
// * by pinging to http://< host for recording >/path/to/something
|
|
52
|
+
// */
|
|
53
|
+
// readonly DEFAULT_TALKBACK_PROXY_SERVER_PORT = 5544;
|
|
54
|
+
// //#endregion
|
|
55
|
+
// //#region singleton
|
|
56
|
+
// private static _instances = {};
|
|
57
|
+
// private constructor(
|
|
58
|
+
// protected readonly cwd = process.cwd()
|
|
59
|
+
// ) {
|
|
60
|
+
// const pathToScenarios = path.join(cwd, config.folder.scenarios);
|
|
61
|
+
// const pathToScenariosTemp = path.join(cwd, config.folder.tmpScenarios);
|
|
62
|
+
// if (!Helpers.exists(pathToScenarios)) {
|
|
63
|
+
// Helpers.createSymLink(pathToScenariosTemp, pathToScenarios,
|
|
64
|
+
// { continueWhenExistedFolderDoesntExists: true })
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
// public static Instance(cwd = process.cwd()) {
|
|
68
|
+
// if (!RecordReplayReqResScenario._instances[cwd]) {
|
|
69
|
+
// RecordReplayReqResScenario._instances[cwd] = new RecordReplayReqResScenario(cwd);
|
|
70
|
+
// }
|
|
71
|
+
// return RecordReplayReqResScenario._instances[cwd] as RecordReplayReqResScenario;
|
|
72
|
+
// }
|
|
73
|
+
// //#endregion
|
|
74
|
+
// //#region resolve recoard args
|
|
75
|
+
// private resolveArgsRecord(serverHostOrPort: string | string[] | RecorderConfigMeta)
|
|
76
|
+
// : { args: RecordArgType[]; scenarioName: string; } {
|
|
77
|
+
// const results = [] as RecordArgType[];
|
|
78
|
+
// const configMeta = ((_.isObject(serverHostOrPort) && !_.isArray(serverHostOrPort))
|
|
79
|
+
// ? serverHostOrPort : void 0) as RecorderConfigMeta;
|
|
80
|
+
// let scenarioName = '' as string;
|
|
81
|
+
// let talkbackPorts = [this.DEFAULT_TALKBACK_PROXY_SERVER_PORT];
|
|
82
|
+
// if (configMeta) {
|
|
83
|
+
// //#region by config
|
|
84
|
+
// scenarioName = configMeta.scenarioName;
|
|
85
|
+
// _.keys(configMeta)
|
|
86
|
+
// .filter(key => _.isObject(configMeta[key]))
|
|
87
|
+
// .forEach((name, i) => {
|
|
88
|
+
// const url = Helpers.urlParse(configMeta[name].host);
|
|
89
|
+
// results.push({
|
|
90
|
+
// record: {
|
|
91
|
+
// name,
|
|
92
|
+
// url
|
|
93
|
+
// },
|
|
94
|
+
// talkbackProxyPort: Number(configMeta[name].talkbackProxyPort) + i
|
|
95
|
+
// })
|
|
96
|
+
// })
|
|
97
|
+
// //#endregion
|
|
98
|
+
// } else {
|
|
99
|
+
// //#region by command line argument
|
|
100
|
+
// const { commandString, resolved } = Helpers.cliTool.argsFromBegin<URL>(
|
|
101
|
+
// serverHostOrPort as string,
|
|
102
|
+
// a => Helpers.urlParse(a)
|
|
103
|
+
// );
|
|
104
|
+
// scenarioName = commandString;
|
|
105
|
+
// let options = Helpers.cliTool.argsFrom<{ port: string; hostName: string; }>(scenarioName);
|
|
106
|
+
// scenarioName = Helpers.cliTool.cleanCommand(scenarioName, options);
|
|
107
|
+
// if (_.isArray(options.port)) {
|
|
108
|
+
// talkbackPorts = options.port;
|
|
109
|
+
// } else if (!isNaN(Number(options.port))) {
|
|
110
|
+
// talkbackPorts = [Number(options.port)];
|
|
111
|
+
// }
|
|
112
|
+
// const hostName = _.isString(options.hostName) ? [options.hostName]
|
|
113
|
+
// : (_.isArray(options.hostName) ? options.hostName : [])
|
|
114
|
+
// if (talkbackPorts.length === 0) {
|
|
115
|
+
// Helpers.error(`[rec-scenario-rep-rec] Incorrect configuration of ports:
|
|
116
|
+
// recordHosts = ${resolved.map(c => Helpers.urlParse(c)).join(', ')}
|
|
117
|
+
// talkback ports = ${talkbackPorts.join(', ')}
|
|
118
|
+
// `, false, true);
|
|
119
|
+
// }
|
|
120
|
+
// if (talkbackPorts.length < resolved.length) {
|
|
121
|
+
// const lastN = talkbackPorts[talkbackPorts.length - 1];
|
|
122
|
+
// _.times((resolved.length - talkbackPorts.length), (i) => talkbackPorts.push(lastN + (i + 1)));
|
|
123
|
+
// }
|
|
124
|
+
// resolved.forEach((recordHost, i) => {
|
|
125
|
+
// results.push({
|
|
126
|
+
// record: {
|
|
127
|
+
// name: hostName[i] ? hostName[i] : '',
|
|
128
|
+
// url: recordHost
|
|
129
|
+
// },
|
|
130
|
+
// talkbackProxyPort: talkbackPorts[i]
|
|
131
|
+
// })
|
|
132
|
+
// });
|
|
133
|
+
// //#endregion
|
|
134
|
+
// }
|
|
135
|
+
// return { args: results, scenarioName };
|
|
136
|
+
// }
|
|
137
|
+
// //#endregion
|
|
138
|
+
// //#region command from config
|
|
139
|
+
// public recordAsWorker(config: RecorderConfigMeta, cwd: string = process.cwd()) {
|
|
140
|
+
// const hosts = Object
|
|
141
|
+
// .keys(config)
|
|
142
|
+
// .filter(hostName => _.isObject(config[hostName]))
|
|
143
|
+
// .map(hostName => {
|
|
144
|
+
// const v = config[hostName] as RecordData;
|
|
145
|
+
// return (v.host as URL).origin;
|
|
146
|
+
// });
|
|
147
|
+
// const portName = Object
|
|
148
|
+
// .keys(config)
|
|
149
|
+
// .filter(hostName => _.isObject(config[hostName]))
|
|
150
|
+
// .map(hostName => {
|
|
151
|
+
// const v = config[hostName] as RecordData;
|
|
152
|
+
// return `--port ${v.talkbackProxyPort} --hostName ${hostName}`
|
|
153
|
+
// })
|
|
154
|
+
// let command = `record-replay-req-res-scenario record ${hosts.join(' ')} '${config.scenarioName}' ${portName.join(' ')}`;
|
|
155
|
+
// Helpers.run(command, { cwd }).async();
|
|
156
|
+
// }
|
|
157
|
+
// //#endregion
|
|
158
|
+
// //#region record
|
|
159
|
+
// /**
|
|
160
|
+
// * rest-scenario-rep-rec record http://localhost:4444 Recording localhost data
|
|
161
|
+
// * rest-scenario-rep-rec record http://192.168.10.22:4444 Test scenario
|
|
162
|
+
// * rest-scenario-rep-rec record 4444 local setup test
|
|
163
|
+
// * rest-scenario-rep-rec record 4444 5555 http://192.168.12.3 "my super scenario"
|
|
164
|
+
// * rest-scenario-rep-rec record 4444 5555 http://192.168.12.3 192.158.32.3 'my super scenario --port 6767'
|
|
165
|
+
// * <port or host for record > <scenario name > < talkbback server ports for proxy >
|
|
166
|
+
// * rest-scenario-rep-rec record 4444 5555 http://my.api.com 'my super scenario --port 6767 --port 7777 --port 8888'
|
|
167
|
+
// * ins.record( { portOrHost: http://192.129.23.12; name: 'localApiProxy' }, 'super scenario')
|
|
168
|
+
// */
|
|
169
|
+
// async record(serverHostOrPort: string | string[] | RecorderConfigMeta, debug = false) {
|
|
170
|
+
// return new Promise((resolve, reject) => {
|
|
171
|
+
// const currentDate = new Date();
|
|
172
|
+
// let { args, scenarioName } = this.resolveArgsRecord(serverHostOrPort);
|
|
173
|
+
// //#region prepare main scenario folder
|
|
174
|
+
// let description = scenarioName;
|
|
175
|
+
// if (!_.isString(scenarioName) || scenarioName.trim() === '') {
|
|
176
|
+
// scenarioName = `new-scenario-${_.kebabCase(moment(currentDate).format('MMMM Do YYYY, h:mm:ss a'))}`;;
|
|
177
|
+
// description = _.startCase(scenarioName);
|
|
178
|
+
// }
|
|
179
|
+
// const scenarioNameKebabKase = _.kebabCase(scenarioName);
|
|
180
|
+
// const scenariosFolder = path.join(this.cwd, config.folder.tmpScenarios);
|
|
181
|
+
// const scenarioKebabPath = path.join(scenariosFolder, scenarioNameKebabKase);
|
|
182
|
+
// const packageJsonFroScenario = path.join(scenarioKebabPath, config.file.package_json);
|
|
183
|
+
// if (!Helpers.exists(scenariosFolder)) {
|
|
184
|
+
// Helpers.mkdirp(scenariosFolder);
|
|
185
|
+
// }
|
|
186
|
+
// Helpers.removeFolderIfExists(scenarioKebabPath);
|
|
187
|
+
// //#endregion
|
|
188
|
+
// //#region write package.json
|
|
189
|
+
// Helpers.writeFile(packageJsonFroScenario, {
|
|
190
|
+
// name: scenarioNameKebabKase,
|
|
191
|
+
// description,
|
|
192
|
+
// version: '0.0.0',
|
|
193
|
+
// creationDate: currentDate.toDateString(),
|
|
194
|
+
// scripts: {
|
|
195
|
+
// start: 'firedev serve',
|
|
196
|
+
// },
|
|
197
|
+
// tnp: {
|
|
198
|
+
// type: 'scenario',
|
|
199
|
+
// } as any,
|
|
200
|
+
// } as Partial<Models.npm.IPackageJSON>);
|
|
201
|
+
// //#endregion
|
|
202
|
+
// args.forEach(recData => {
|
|
203
|
+
// Helpers.log(`RECORD FROM: ${recData.record.url.href}`)
|
|
204
|
+
// const scenarioPath = path.join(
|
|
205
|
+
// this.cwd,
|
|
206
|
+
// config.folder.tmpScenarios,
|
|
207
|
+
// scenarioNameKebabKase,
|
|
208
|
+
// `${(_.kebabCase(recData.record.url.href)).toString()}__${_.camelCase(recData.record.name)}`
|
|
209
|
+
// );
|
|
210
|
+
// Helpers.remove(scenarioPath);
|
|
211
|
+
// const talkbackHost = recData.record.url.origin;
|
|
212
|
+
// debug && Helpers.info(`Talkback host: ${talkbackHost}`)
|
|
213
|
+
// const server = talkback({
|
|
214
|
+
// host: talkbackHost,
|
|
215
|
+
// record: RecordMode.NEW,
|
|
216
|
+
// port: recData.talkbackProxyPort,
|
|
217
|
+
// path: scenarioPath,
|
|
218
|
+
// silent: true,
|
|
219
|
+
// // debug: true
|
|
220
|
+
// } as Options);
|
|
221
|
+
// server.start(() => {
|
|
222
|
+
// Helpers.info(`"Talkback Started" on port ${recData.talkbackProxyPort} `
|
|
223
|
+
// + `( click for test ${chalk.bold(recData.record?.name ? recData.record.name : '')} `
|
|
224
|
+
// + `http://localhost:${recData.talkbackProxyPort}/ng-talkback-test ) => proxy to ${recData.record.url.href}`);
|
|
225
|
+
// resolve(void 0);
|
|
226
|
+
// });
|
|
227
|
+
// })
|
|
228
|
+
// });
|
|
229
|
+
// }
|
|
230
|
+
// //#endregion
|
|
231
|
+
// //#region all scenaroios
|
|
232
|
+
// public get allScenarios() {
|
|
233
|
+
// return glob.sync(`${path.join(this.cwd, config.folder.tmpScenarios)}/*`)
|
|
234
|
+
// .filter(f => !!Project.ins.From(f))
|
|
235
|
+
// .map(f => Scenario.From(f))
|
|
236
|
+
// .filter(f => !!f)
|
|
237
|
+
// }
|
|
238
|
+
// //#endregion
|
|
239
|
+
// //#region select scenario
|
|
240
|
+
// async selectScenario(goBackButtonOnList?: boolean): Promise<Scenario> {
|
|
241
|
+
// const mainMessage = `Select scenario from list:`;
|
|
242
|
+
// const choices = Scenario.allCurrent.map(c => {
|
|
243
|
+
// return { name: `"${c.description}"`, value: c }
|
|
244
|
+
// });
|
|
245
|
+
// if (goBackButtonOnList) {
|
|
246
|
+
// choices.push({ name: '<= Go back', value: void 0 });
|
|
247
|
+
// }
|
|
248
|
+
// const res = await inquirer.prompt({
|
|
249
|
+
// type: 'list',
|
|
250
|
+
// name: 'value',
|
|
251
|
+
// message: mainMessage,
|
|
252
|
+
// choices
|
|
253
|
+
// } as any) as any;
|
|
254
|
+
// return res.value;
|
|
255
|
+
// }
|
|
256
|
+
// //#endregion
|
|
257
|
+
// //#region resolve replay args
|
|
258
|
+
// private async resolveReplayData(
|
|
259
|
+
// nameOrPathOrDescription: string | string[] | ReplayConfigMeta,
|
|
260
|
+
// showListIfNotMatch = false,
|
|
261
|
+
// goBackButtonOnList = false,
|
|
262
|
+
// ) {
|
|
263
|
+
// const returnValue = { scenarios: [] as Scenario[], params: void 0 as ScenarioParamsReturn }
|
|
264
|
+
// if (_.isObject(nameOrPathOrDescription) && !_.isArray(nameOrPathOrDescription)) {
|
|
265
|
+
// //#region config
|
|
266
|
+
// const configMeta = nameOrPathOrDescription as ReplayConfigMeta;
|
|
267
|
+
// const scenario = Scenario.From(configMeta.scenarioPath)
|
|
268
|
+
// if (!scenario) {
|
|
269
|
+
// Helpers.error(`[rest-scenario...] Scenario not found in "${configMeta.scenarioPath}"`
|
|
270
|
+
// , false, true)
|
|
271
|
+
// }
|
|
272
|
+
// returnValue.scenarios = [scenario];
|
|
273
|
+
// returnValue.params = _.pickBy(configMeta, _.isObject) as ScenarioParamsReturn;
|
|
274
|
+
// //#endregion
|
|
275
|
+
// } else {
|
|
276
|
+
// //#region from command line
|
|
277
|
+
// nameOrPathOrDescription = (_.isArray(nameOrPathOrDescription)
|
|
278
|
+
// ? nameOrPathOrDescription.join(' ') : nameOrPathOrDescription) as string;
|
|
279
|
+
// const options = Helpers.cliTool.argsFrom<ArgsOptReplayRecordArgType>(nameOrPathOrDescription);
|
|
280
|
+
// nameOrPathOrDescription = Helpers.cliTool.cleanCommand(nameOrPathOrDescription, options);
|
|
281
|
+
// const { resolved, commandString } = Helpers.cliTool
|
|
282
|
+
// .argsFromBegin<Scenario>(nameOrPathOrDescription, possiblePathToScenario => {
|
|
283
|
+
// const scenarioFromPath = (
|
|
284
|
+
// path.isAbsolute(possiblePathToScenario || '') &&
|
|
285
|
+
// Helpers.exists(possiblePathToScenario))
|
|
286
|
+
// ? possiblePathToScenario
|
|
287
|
+
// : path.join(
|
|
288
|
+
// this.cwd,
|
|
289
|
+
// config.folder.tmpScenarios,
|
|
290
|
+
// (possiblePathToScenario || '').trim());
|
|
291
|
+
// return Scenario.From(scenarioFromPath);
|
|
292
|
+
// });
|
|
293
|
+
// nameOrPathOrDescription = commandString;
|
|
294
|
+
// let scenarios = resolved;
|
|
295
|
+
// if (scenarios.length === 0 && commandString.trim() !== '') {
|
|
296
|
+
// const list = this.allScenarios;
|
|
297
|
+
// const { matches, results } = Helpers
|
|
298
|
+
// .arrays
|
|
299
|
+
// .fuzzy<Scenario>(nameOrPathOrDescription, list, (m) => m.description);
|
|
300
|
+
// scenarios = scenarios.concat(results);
|
|
301
|
+
// }
|
|
302
|
+
// const hostName = _.isString(options.hostName) ? [options.hostName]
|
|
303
|
+
// : (_.isArray(options.hostName) ? options.hostName : []);
|
|
304
|
+
// const portsOrUrlsForReplayServer = (_.isString(options.port) ? [Helpers.urlParse(options.port)]
|
|
305
|
+
// : (_.isArray(options.port) ? options.port.map(p => Helpers.urlParse(p))
|
|
306
|
+
// : [Helpers.urlParse(this.DEFAULT_TALKBACK_PROXY_SERVER_PORT)])).filter(u => u instanceof URL);
|
|
307
|
+
// if (portsOrUrlsForReplayServer.length === 0) {
|
|
308
|
+
// Helpers.error(`Please provide correct number or ports and hostnames
|
|
309
|
+
// host names = ${hostName.map(c => Helpers.urlParse(c)).join(', ')}
|
|
310
|
+
// talkback ports = ${portsOrUrlsForReplayServer.join(', ')}
|
|
311
|
+
// `, false, true);
|
|
312
|
+
// }
|
|
313
|
+
// let params = portsOrUrlsForReplayServer;
|
|
314
|
+
// if (hostName.length > 0) {
|
|
315
|
+
// if (hostName.length > portsOrUrlsForReplayServer.length) {
|
|
316
|
+
// const maxPort = _.maxBy(portsOrUrlsForReplayServer, p => Number(p.port));
|
|
317
|
+
// _.times(hostName.length - portsOrUrlsForReplayServer.length, n => {
|
|
318
|
+
// portsOrUrlsForReplayServer.push(Helpers.urlParse(Number(maxPort.port) + (n + 1)))
|
|
319
|
+
// });
|
|
320
|
+
// }
|
|
321
|
+
// params = hostName.reduce((prev, name, i) => {
|
|
322
|
+
// return _.merge(prev, { [name]: portsOrUrlsForReplayServer[i] })
|
|
323
|
+
// }, {}) as any;
|
|
324
|
+
// }
|
|
325
|
+
// returnValue.params = params as any;
|
|
326
|
+
// returnValue.scenarios = scenarios;
|
|
327
|
+
// //#endregion
|
|
328
|
+
// }
|
|
329
|
+
// //#region select menu scenraios
|
|
330
|
+
// if (returnValue.scenarios.length === 0) {
|
|
331
|
+
// if (showListIfNotMatch) {
|
|
332
|
+
// const selectedScenario = await this.selectScenario(goBackButtonOnList);
|
|
333
|
+
// returnValue.scenarios.push(selectedScenario);
|
|
334
|
+
// }
|
|
335
|
+
// }
|
|
336
|
+
// //#endregion
|
|
337
|
+
// return returnValue;
|
|
338
|
+
// }
|
|
339
|
+
// //#endregion
|
|
340
|
+
// //#region replay
|
|
341
|
+
// public async resolveScenariosData(
|
|
342
|
+
// nameOrPathOrDescription: string | string[] | ReplayConfigMeta,
|
|
343
|
+
// showListIfNotMatch = false,
|
|
344
|
+
// goBackButtonOnList = false,
|
|
345
|
+
// ) {
|
|
346
|
+
// const { scenarios, params } = await this.resolveReplayData(
|
|
347
|
+
// nameOrPathOrDescription,
|
|
348
|
+
// showListIfNotMatch,
|
|
349
|
+
// goBackButtonOnList,
|
|
350
|
+
// );
|
|
351
|
+
// if (scenarios.length === 0) {
|
|
352
|
+
// Helpers.error(`[record - replay - req - res - scenario]`
|
|
353
|
+
// + `Not able to find scenario by name or path "${nameOrPathOrDescription}"`, false, true);
|
|
354
|
+
// }
|
|
355
|
+
// // const tmpScenarioInfo = (s: Scenario) => {
|
|
356
|
+
// // const paramsTmpls = _.isArray(params) ? params.map(p => ` replay on ${p}`).join(',')
|
|
357
|
+
// // : _.keys(params).reduce((a, b) => {
|
|
358
|
+
// // return `${a}\n\t${chalk.bold(b)}:${params[b].href}`
|
|
359
|
+
// // }, '')
|
|
360
|
+
// // return `> ${chalk.bold(s.basename)} "${s.description}"` +
|
|
361
|
+
// // paramsTmpls;
|
|
362
|
+
// // };
|
|
363
|
+
// // Helpers.info(`
|
|
364
|
+
// // (${chalk.bold(scenarios.length.toString())}) scenario(s) to replay: `
|
|
365
|
+
// // + `${scenarios.map(s => tmpScenarioInfo(s)).join('\n')}`
|
|
366
|
+
// // );
|
|
367
|
+
// return { scenario: _.first(scenarios), scenarios, params };
|
|
368
|
+
// }
|
|
369
|
+
// //#endregion
|
|
370
|
+
// //#endregion
|
|
371
|
+
// }
|
|
366
372
|
//# sourceMappingURL=record-replay-req-res-scenario.js.map
|