@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.30

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 (189) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +99 -162
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +156 -34
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/config.d.ts +2 -5
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +5 -5
  9. package/dist/config.js.map +1 -1
  10. package/dist/core/browser-service.js +5 -5
  11. package/dist/core/browser-service.js.map +1 -1
  12. package/dist/core/gatherer.d.ts +4 -8
  13. package/dist/core/gatherer.d.ts.map +1 -1
  14. package/dist/core/gatherer.js +46 -14
  15. package/dist/core/gatherer.js.map +1 -1
  16. package/dist/core/index.d.ts +5 -1
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +23 -11
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/logger.d.ts +0 -1
  21. package/dist/core/logger.d.ts.map +1 -1
  22. package/dist/core/logger.js +3 -16
  23. package/dist/core/logger.js.map +1 -1
  24. package/dist/core/runner.d.ts +21 -65
  25. package/dist/core/runner.d.ts.map +1 -1
  26. package/dist/core/runner.js +211 -93
  27. package/dist/core/runner.js.map +1 -1
  28. package/dist/dsl/journey.d.ts +7 -3
  29. package/dist/dsl/journey.d.ts.map +1 -1
  30. package/dist/dsl/journey.js +22 -6
  31. package/dist/dsl/journey.js.map +1 -1
  32. package/{src/reporters/reporter.ts → dist/dsl/locations.d.ts} +12 -10
  33. package/dist/dsl/locations.d.ts.map +1 -0
  34. package/dist/dsl/locations.js +41 -0
  35. package/dist/dsl/locations.js.map +1 -0
  36. package/dist/dsl/monitor.d.ts +65 -0
  37. package/dist/dsl/monitor.d.ts.map +1 -0
  38. package/dist/dsl/monitor.js +63 -0
  39. package/dist/dsl/monitor.js.map +1 -0
  40. package/dist/dsl/step.d.ts +3 -2
  41. package/dist/dsl/step.d.ts.map +1 -1
  42. package/dist/dsl/step.js +2 -1
  43. package/dist/dsl/step.js.map +1 -1
  44. package/dist/formatter/javascript.d.ts +98 -0
  45. package/dist/formatter/javascript.d.ts.map +1 -0
  46. package/dist/formatter/javascript.js +295 -0
  47. package/dist/formatter/javascript.js.map +1 -0
  48. package/dist/generator/index.d.ts +21 -0
  49. package/dist/generator/index.d.ts.map +1 -0
  50. package/dist/generator/index.js +169 -0
  51. package/dist/generator/index.js.map +1 -0
  52. package/dist/{reporters/reporter.d.ts → generator/utils.d.ts} +4 -9
  53. package/dist/generator/utils.d.ts.map +1 -0
  54. package/dist/generator/utils.js +57 -0
  55. package/dist/generator/utils.js.map +1 -0
  56. package/dist/helpers.d.ts +20 -1
  57. package/dist/helpers.d.ts.map +1 -1
  58. package/dist/helpers.js +98 -18
  59. package/dist/helpers.js.map +1 -1
  60. package/dist/index.d.ts +5 -6
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +5 -26
  63. package/dist/index.js.map +1 -1
  64. package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
  65. package/dist/loader.d.ts.map +1 -0
  66. package/dist/loader.js +144 -0
  67. package/dist/loader.js.map +1 -0
  68. package/dist/options.d.ts +34 -0
  69. package/dist/options.d.ts.map +1 -0
  70. package/dist/options.js +162 -0
  71. package/dist/options.js.map +1 -0
  72. package/dist/plugins/browser-console.d.ts +5 -4
  73. package/dist/plugins/browser-console.d.ts.map +1 -1
  74. package/dist/plugins/browser-console.js +27 -8
  75. package/dist/plugins/browser-console.js.map +1 -1
  76. package/dist/plugins/network.d.ts +20 -33
  77. package/dist/plugins/network.d.ts.map +1 -1
  78. package/dist/plugins/network.js +173 -214
  79. package/dist/plugins/network.js.map +1 -1
  80. package/dist/plugins/performance.d.ts +4 -19
  81. package/dist/plugins/performance.d.ts.map +1 -1
  82. package/dist/plugins/performance.js +5 -5
  83. package/dist/plugins/performance.js.map +1 -1
  84. package/dist/plugins/plugin-manager.d.ts +9 -5
  85. package/dist/plugins/plugin-manager.d.ts.map +1 -1
  86. package/dist/plugins/plugin-manager.js +44 -29
  87. package/dist/plugins/plugin-manager.js.map +1 -1
  88. package/dist/plugins/tracing.d.ts +6 -6
  89. package/dist/plugins/tracing.d.ts.map +1 -1
  90. package/dist/plugins/tracing.js +8 -7
  91. package/dist/plugins/tracing.js.map +1 -1
  92. package/dist/push/bundler.d.ts +34 -0
  93. package/dist/push/bundler.d.ts.map +1 -0
  94. package/dist/push/bundler.js +114 -0
  95. package/dist/push/bundler.js.map +1 -0
  96. package/dist/{reporters/reporter.js → push/index.d.ts} +4 -3
  97. package/dist/push/index.d.ts.map +1 -0
  98. package/dist/push/index.js +55 -0
  99. package/dist/push/index.js.map +1 -0
  100. package/dist/push/monitor.d.ts +32 -0
  101. package/dist/push/monitor.d.ts.map +1 -0
  102. package/dist/push/monitor.js +62 -0
  103. package/dist/push/monitor.js.map +1 -0
  104. package/dist/push/plugin.d.ts +33 -0
  105. package/dist/push/plugin.d.ts.map +1 -0
  106. package/dist/push/plugin.js +124 -0
  107. package/dist/push/plugin.js.map +1 -0
  108. package/dist/push/request.d.ts +42 -0
  109. package/dist/push/request.d.ts.map +1 -0
  110. package/dist/push/request.js +84 -0
  111. package/dist/push/request.js.map +1 -0
  112. package/dist/reporters/base.d.ts +14 -6
  113. package/dist/reporters/base.d.ts.map +1 -1
  114. package/dist/reporters/base.js +54 -48
  115. package/dist/reporters/base.js.map +1 -1
  116. package/dist/reporters/index.d.ts +18 -8
  117. package/dist/reporters/index.d.ts.map +1 -1
  118. package/dist/reporters/index.js.map +1 -1
  119. package/dist/reporters/json.d.ts +18 -67
  120. package/dist/reporters/json.d.ts.map +1 -1
  121. package/dist/reporters/json.js +153 -175
  122. package/dist/reporters/json.js.map +1 -1
  123. package/dist/reporters/junit.d.ts +7 -1
  124. package/dist/reporters/junit.d.ts.map +1 -1
  125. package/dist/reporters/junit.js +94 -89
  126. package/dist/reporters/junit.js.map +1 -1
  127. package/dist/sdk/lh-trace-processor.d.ts +35 -9
  128. package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
  129. package/dist/sdk/lh-trace-processor.js +114 -53
  130. package/dist/sdk/lh-trace-processor.js.map +1 -1
  131. package/dist/sdk/trace-metrics.d.ts +4 -4
  132. package/dist/sdk/trace-metrics.d.ts.map +1 -1
  133. package/dist/sdk/trace-metrics.js +5 -6
  134. package/dist/sdk/trace-metrics.js.map +1 -1
  135. package/dist/sdk/trace-processor.d.ts +11 -3
  136. package/dist/sdk/trace-processor.d.ts.map +1 -1
  137. package/dist/sdk/trace-processor.js +17 -9
  138. package/dist/sdk/trace-processor.js.map +1 -1
  139. package/dist/tsconfig.tsbuildinfo +1 -1888
  140. package/package.json +31 -19
  141. package/src/cli.ts +187 -154
  142. package/src/common_types.ts +188 -34
  143. package/src/config.ts +2 -5
  144. package/src/core/gatherer.ts +55 -27
  145. package/src/core/index.ts +36 -15
  146. package/src/core/logger.ts +1 -12
  147. package/src/core/runner.ts +216 -152
  148. package/src/dsl/journey.ts +29 -5
  149. package/src/dsl/locations.ts +38 -0
  150. package/src/dsl/monitor.ts +87 -0
  151. package/src/dsl/step.ts +9 -2
  152. package/src/formatter/javascript.ts +367 -0
  153. package/src/generator/index.ts +212 -0
  154. package/src/generator/utils.ts +54 -0
  155. package/src/helpers.ts +106 -10
  156. package/src/index.ts +21 -22
  157. package/src/loader.ts +162 -0
  158. package/src/options.ts +173 -0
  159. package/src/plugins/browser-console.ts +30 -8
  160. package/src/plugins/network.ts +208 -267
  161. package/src/plugins/performance.ts +6 -22
  162. package/src/plugins/plugin-manager.ts +49 -31
  163. package/src/plugins/tracing.ts +8 -9
  164. package/src/push/bundler.ts +95 -0
  165. package/src/push/index.ts +59 -0
  166. package/src/push/monitor.ts +68 -0
  167. package/src/push/plugin.ts +114 -0
  168. package/src/push/request.ts +111 -0
  169. package/src/reporters/base.ts +63 -52
  170. package/src/reporters/index.ts +26 -3
  171. package/src/reporters/json.ts +203 -206
  172. package/src/reporters/junit.ts +98 -93
  173. package/src/sdk/lh-trace-processor.ts +132 -68
  174. package/src/sdk/trace-metrics.ts +10 -6
  175. package/src/sdk/trace-processor.ts +28 -13
  176. package/templates/.github/workflows/run-synthetics.yml +26 -0
  177. package/templates/README.md +21 -0
  178. package/templates/journeys/advanced-example-helpers.ts +54 -0
  179. package/templates/journeys/advanced-example.journey.ts +43 -0
  180. package/templates/journeys/example.journey.ts +18 -0
  181. package/templates/synthetics.config.ts +26 -0
  182. package/CHANGELOG.md +0 -102
  183. package/NOTICE.txt +0 -221
  184. package/dist/parse_args.d.ts.map +0 -1
  185. package/dist/parse_args.js +0 -89
  186. package/dist/parse_args.js.map +0 -1
  187. package/dist/reporters/reporter.d.ts.map +0 -1
  188. package/dist/reporters/reporter.js.map +0 -1
  189. package/src/parse_args.ts +0 -127
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.LocationsMap = void 0;
28
+ // DO NOT EDIT - UPDATE WITH `npm run build:locations`
29
+ exports.LocationsMap = {
30
+ japan: 'asia-northeast1-a',
31
+ india: 'asia-south1-a',
32
+ singapore: 'asia-southeast1-a',
33
+ australia_east: 'australia-southeast1-a',
34
+ united_kingdom: 'europe-west2-a',
35
+ germany: 'europe-west3-a',
36
+ canada_east: 'northamerica-northeast1-a',
37
+ brazil: 'southamerica-east1-a',
38
+ us_east: 'us-east4-a',
39
+ us_west: 'us-west1-a',
40
+ };
41
+ //# sourceMappingURL=locations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locations.js","sourceRoot":"","sources":["../../src/dsl/locations.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,sDAAsD;AACzC,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE,mBAAmB;IAC1B,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,mBAAmB;IAC9B,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,gBAAgB;IAChC,OAAO,EAAE,gBAAgB;IACzB,WAAW,EAAE,2BAA2B;IACxC,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,YAAY;CACtB,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present, Elastic NV
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ */
25
+ import { ThrottlingOptions, Location, ScreenshotOptions, Params, PlaywrightOptions } from '../common_types';
26
+ import { LocationsMap } from './locations';
27
+ export declare type SyntheticsLocationsType = keyof typeof LocationsMap;
28
+ export declare const SyntheticsLocations: ("japan" | "india" | "singapore" | "australia_east" | "united_kingdom" | "germany" | "canada_east" | "brazil" | "us_east" | "us_west")[];
29
+ export declare type MonitorConfig = {
30
+ id?: string;
31
+ name?: string;
32
+ tags?: string[];
33
+ schedule?: number;
34
+ enabled?: boolean;
35
+ locations?: SyntheticsLocationsType[];
36
+ throttling?: ThrottlingOptions;
37
+ screenshot?: ScreenshotOptions;
38
+ params?: Params;
39
+ playwrightOptions?: PlaywrightOptions;
40
+ };
41
+ declare type MonitorFilter = {
42
+ match: string;
43
+ tags?: string[];
44
+ };
45
+ export declare class Monitor {
46
+ config: MonitorConfig;
47
+ source?: Location;
48
+ filter: MonitorFilter;
49
+ constructor(config?: MonitorConfig);
50
+ /**
51
+ * Treat the creation time config with `monitor.use` as source of truth by
52
+ * merging the values coming from CLI and Synthetics config file
53
+ */
54
+ update(globalOpts?: MonitorConfig): void;
55
+ setSource(source: Location): void;
56
+ /**
57
+ * If journey files are colocated within the same file during
58
+ * push command, when we invoke synthetics from HB we rely on
59
+ * this filter for running that specific journey alone instead of
60
+ * all journeys on the file
61
+ */
62
+ setFilter(filter: MonitorFilter): void;
63
+ }
64
+ export {};
65
+ //# sourceMappingURL=monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/dsl/monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,MAAM,EACN,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,oBAAY,uBAAuB,GAAG,MAAM,OAAO,YAAY,CAAC;AAChE,eAAO,MAAM,mBAAmB,0IAEF,CAAC;AAE/B,oBAAY,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACtC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEF,aAAK,aAAa,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,qBAAa,OAAO;IAGC,MAAM,EAAE,aAAa;IAFxC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;gBACH,MAAM,GAAE,aAAkB;IAC7C;;;OAGG;IACH,MAAM,CAAC,UAAU,GAAE,aAAkB;IAQrC,SAAS,CAAC,MAAM,EAAE,QAAQ;IAG1B;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,aAAa;CAGhC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.Monitor = exports.SyntheticsLocations = void 0;
31
+ const deepmerge_1 = __importDefault(require("deepmerge"));
32
+ const locations_1 = require("./locations");
33
+ exports.SyntheticsLocations = Object.keys(locations_1.LocationsMap);
34
+ class Monitor {
35
+ constructor(config = {}) {
36
+ this.config = config;
37
+ }
38
+ /**
39
+ * Treat the creation time config with `monitor.use` as source of truth by
40
+ * merging the values coming from CLI and Synthetics config file
41
+ */
42
+ update(globalOpts = {}) {
43
+ this.config = (0, deepmerge_1.default)(globalOpts, this.config, {
44
+ arrayMerge(target, source) {
45
+ return [...new Set(source)];
46
+ },
47
+ });
48
+ }
49
+ setSource(source) {
50
+ this.source = source;
51
+ }
52
+ /**
53
+ * If journey files are colocated within the same file during
54
+ * push command, when we invoke synthetics from HB we rely on
55
+ * this filter for running that specific journey alone instead of
56
+ * all journeys on the file
57
+ */
58
+ setFilter(filter) {
59
+ this.filter = filter;
60
+ }
61
+ }
62
+ exports.Monitor = Monitor;
63
+ //# sourceMappingURL=monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/dsl/monitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,0DAA8B;AAQ9B,2CAA2C;AAG9B,QAAA,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAC5C,wBAAY,CACgB,CAAC;AAoB/B,MAAa,OAAO;IAGlB,YAAmB,SAAwB,EAAE;QAA1B,WAAM,GAAN,MAAM,CAAoB;IAAG,CAAC;IACjD;;;OAGG;IACH,MAAM,CAAC,aAA4B,EAAE;QACnC,IAAI,CAAC,MAAM,GAAG,IAAA,mBAAK,EAAC,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE;YAC3C,UAAU,CAAC,MAAM,EAAE,MAAM;gBACvB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,SAAS,CAAC,MAAgB;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACD;;;;;OAKG;IACH,SAAS,CAAC,MAAqB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AA5BD,0BA4BC"}
@@ -22,11 +22,12 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { VoidCallback } from '../common_types';
25
+ import { Location, VoidCallback } from '../common_types';
26
26
  export declare class Step {
27
27
  name: string;
28
28
  index: number;
29
29
  callback: VoidCallback;
30
- constructor(name: string, index: number, callback: VoidCallback);
30
+ location?: Location;
31
+ constructor(name: string, index: number, callback: VoidCallback, location: Location);
31
32
  }
32
33
  //# sourceMappingURL=step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,qBAAa,IAAI;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;gBAEX,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY;CAKhE"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,qBAAa,IAAI;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBAGlB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ;CAOrB"}
package/dist/dsl/step.js CHANGED
@@ -26,10 +26,11 @@
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.Step = void 0;
28
28
  class Step {
29
- constructor(name, index, callback) {
29
+ constructor(name, index, callback, location) {
30
30
  this.name = name;
31
31
  this.index = index;
32
32
  this.callback = callback;
33
+ this.location = location;
33
34
  }
34
35
  }
35
36
  exports.Step = Step;
@@ -1 +1 @@
1
- {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIH,MAAa,IAAI;IAKf,YAAY,IAAY,EAAE,KAAa,EAAE,QAAsB;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAVD,oBAUC"}
1
+ {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIH,MAAa,IAAI;IAMf,YACE,IAAY,EACZ,KAAa,EACb,QAAsB,EACtB,QAAkB;QAElB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAjBD,oBAiBC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present, Elastic NV
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ */
25
+ import { JavaScriptLanguageGenerator } from 'playwright-core/lib/server/supplements/recorder/javascript';
26
+ export declare type Step = {
27
+ actions: ActionInContext[];
28
+ name?: string;
29
+ };
30
+ export declare type Steps = Step[];
31
+ export declare type ActionInContext = {
32
+ pageAlias: string;
33
+ frameName?: string;
34
+ frameUrl: string;
35
+ isMainFrame: boolean;
36
+ action: Action;
37
+ committed?: boolean;
38
+ modified?: boolean;
39
+ title?: string;
40
+ };
41
+ export declare type Action = {
42
+ name: string;
43
+ selector?: string;
44
+ url?: string;
45
+ key?: string;
46
+ signals: Signal[];
47
+ modifiers?: number;
48
+ button?: 'left' | 'middle' | 'right';
49
+ clickCount?: number;
50
+ text?: string;
51
+ value?: string;
52
+ isAssert?: boolean;
53
+ command?: string;
54
+ files?: string[];
55
+ options?: string[];
56
+ };
57
+ export declare type Signal = {
58
+ name: string;
59
+ url?: string;
60
+ isAsync?: boolean;
61
+ popupAlias?: string;
62
+ downloadAlias?: string;
63
+ dialogAlias?: string;
64
+ };
65
+ export declare class SyntheticsGenerator extends JavaScriptLanguageGenerator {
66
+ private isSuite;
67
+ private previousContext;
68
+ private insideStep;
69
+ constructor(isSuite: boolean);
70
+ /**
71
+ * Generate code for an action.
72
+ * @param actionInContext The action to create code for.
73
+ * @returns the strings generated for the action.
74
+ */
75
+ generateAction(actionInContext: ActionInContext): any;
76
+ isNewStep(actioninContext: ActionInContext): boolean;
77
+ generateStepStart(name: any): any;
78
+ generateStepEnd(): any;
79
+ generateHeader(): any;
80
+ generateFooter(): string;
81
+ /**
82
+ * Generates JavaScript code from a custom set of steps and nested actions.
83
+ *
84
+ * This function makes no assumptions about where steps should be created,
85
+ * and instead follows the step definitions the caller has defined.
86
+ * @param steps IR to use for code generation
87
+ * @returns a list of the code strings outputted by the generator
88
+ */
89
+ generateFromSteps(steps: Steps): string;
90
+ }
91
+ export declare function quote(text: string, char?: string): string;
92
+ /**
93
+ * Generates an appropriate title string based on the action type/data.
94
+ * @param action Playwright action IR
95
+ * @returns title string
96
+ */
97
+ export declare function actionTitle(action: Action): string;
98
+ //# sourceMappingURL=javascript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/formatter/javascript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,2BAA2B,EAE5B,MAAM,4DAA4D,CAAC;AAEpE,oBAAY,IAAI,GAAG;IACjB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,KAAK,GAAG,IAAI,EAAE,CAAC;AAE3B,oBAAY,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAA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1,295 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.actionTitle = exports.quote = exports.SyntheticsGenerator = void 0;
28
+ const javascript_1 = require("playwright-core/lib/server/supplements/recorder/javascript");
29
+ class SyntheticsGenerator extends javascript_1.JavaScriptLanguageGenerator {
30
+ constructor(isSuite) {
31
+ super(true);
32
+ this.isSuite = isSuite;
33
+ this.insideStep = false;
34
+ this.previousContext = undefined;
35
+ }
36
+ /**
37
+ * Generate code for an action.
38
+ * @param actionInContext The action to create code for.
39
+ * @returns the strings generated for the action.
40
+ */
41
+ generateAction(actionInContext) {
42
+ const { action, pageAlias } = actionInContext;
43
+ if (action.name === 'openPage') {
44
+ return '';
45
+ }
46
+ // Don't cleanup page object managed by Synthetics
47
+ const isCleanUp = action.name === 'closePage' && pageAlias === 'page';
48
+ if (isCleanUp) {
49
+ return '';
50
+ }
51
+ const stepIndent = this.insideStep ? 2 : 0;
52
+ const offset = this.isSuite ? 2 + stepIndent : 0 + stepIndent;
53
+ const formatter = new javascript_1.JavaScriptFormatter(offset);
54
+ const subject = actionInContext.isMainFrame
55
+ ? pageAlias
56
+ : actionInContext.frameName
57
+ ? `${pageAlias}.frame(${formatObject({
58
+ name: actionInContext.frameName,
59
+ })})`
60
+ : `${pageAlias}.frame(${formatObject({
61
+ url: actionInContext.frameUrl,
62
+ })})`;
63
+ const signals = toSignalMap(action);
64
+ if (signals.dialog) {
65
+ formatter.add(` ${pageAlias}.once('dialog', dialog => {
66
+ console.log(\`Dialog message: $\{dialog.message()}\`);
67
+ dialog.dismiss().catch(() => {});
68
+ });`);
69
+ }
70
+ const emitPromiseAll = signals.waitForNavigation || signals.popup || signals.download;
71
+ if (emitPromiseAll) {
72
+ // Generate either await Promise.all([]) or
73
+ // const [popup1] = await Promise.all([]).
74
+ let leftHandSide = '';
75
+ if (signals.popup)
76
+ leftHandSide = `const [${signals.popup.popupAlias}] = `;
77
+ else if (signals.download)
78
+ leftHandSide = `const [download] = `;
79
+ formatter.add(`${leftHandSide}await Promise.all([`);
80
+ }
81
+ // Popup signals.
82
+ if (signals.popup)
83
+ formatter.add(`${pageAlias}.waitForEvent('popup'),`);
84
+ // Navigation signal.
85
+ if (signals.waitForNavigation)
86
+ formatter.add(`${pageAlias}.waitForNavigation(/*{ url: ${quote(signals.waitForNavigation.url)} }*/),`);
87
+ // Download signals.
88
+ if (signals.download)
89
+ formatter.add(`${pageAlias}.waitForEvent('download'),`);
90
+ const prefix = signals.popup || signals.waitForNavigation || signals.download
91
+ ? ''
92
+ : 'await ';
93
+ const actionCall = super._generateActionCall(action);
94
+ // Add assertion from Synthetics.
95
+ const isAssert = action.name === 'assert' && action.isAssert;
96
+ if (!isAssert) {
97
+ const suffix = signals.waitForNavigation || emitPromiseAll ? '' : ';';
98
+ formatter.add(`${prefix}${subject}.${actionCall}${suffix}`);
99
+ if (emitPromiseAll) {
100
+ formatter.add(`]);`);
101
+ }
102
+ else if (signals.assertNavigation) {
103
+ formatter.add(` expect(${pageAlias}.url()).toBe(${quote(signals.assertNavigation.url)});`);
104
+ }
105
+ }
106
+ else if (action.command) {
107
+ formatter.add(toAssertCall(pageAlias, action));
108
+ }
109
+ this.previousContext = actionInContext;
110
+ return formatter.format();
111
+ }
112
+ isNewStep(actioninContext) {
113
+ const { action, frameUrl } = actioninContext;
114
+ if (action.name === 'navigate') {
115
+ return true;
116
+ }
117
+ else if (action.name === 'click') {
118
+ return (this.previousContext?.frameUrl === frameUrl && action.signals.length > 0);
119
+ }
120
+ return false;
121
+ }
122
+ generateStepStart(name) {
123
+ this.insideStep = true;
124
+ const formatter = new javascript_1.JavaScriptFormatter(this.isSuite ? 2 : 0);
125
+ formatter.add(`step(${quote(name)}, async () => {`);
126
+ return formatter.format();
127
+ }
128
+ generateStepEnd() {
129
+ if (!this.insideStep) {
130
+ return '';
131
+ }
132
+ this.insideStep = false;
133
+ const formatter = new javascript_1.JavaScriptFormatter(this.isSuite ? 2 : 0);
134
+ formatter.add(`});`);
135
+ return formatter.format();
136
+ }
137
+ generateHeader() {
138
+ const formatter = new javascript_1.JavaScriptFormatter(0);
139
+ formatter.add(`
140
+ const { journey, step, expect } = require('@elastic/synthetics');
141
+
142
+ journey('Recorded journey', async ({ page, context }) => {`);
143
+ return formatter.format();
144
+ }
145
+ generateFooter() {
146
+ return `});`;
147
+ }
148
+ /**
149
+ * Generates JavaScript code from a custom set of steps and nested actions.
150
+ *
151
+ * This function makes no assumptions about where steps should be created,
152
+ * and instead follows the step definitions the caller has defined.
153
+ * @param steps IR to use for code generation
154
+ * @returns a list of the code strings outputted by the generator
155
+ */
156
+ generateFromSteps(steps) {
157
+ const text = [];
158
+ if (this.isSuite) {
159
+ text.push(this.generateHeader());
160
+ }
161
+ for (const step of steps) {
162
+ if (step.actions.length === 0)
163
+ throw Error('Cannot process an empty step');
164
+ text.push(this.generateStepStart(step.name ??
165
+ step.actions[0].title ??
166
+ actionTitle(step.actions[0].action)));
167
+ for (const action of step.actions) {
168
+ const actionText = this.generateAction(action);
169
+ if (actionText.length)
170
+ text.push(actionText);
171
+ }
172
+ text.push(this.generateStepEnd());
173
+ }
174
+ if (this.isSuite) {
175
+ text.push(this.generateFooter());
176
+ }
177
+ return text.filter(s => !!s).join('\n');
178
+ }
179
+ }
180
+ exports.SyntheticsGenerator = SyntheticsGenerator;
181
+ // TODO: Replace once Playwright releases new version
182
+ function quote(text, char = "'") {
183
+ const stringified = JSON.stringify(text);
184
+ const escapedText = stringified
185
+ .substring(1, stringified.length - 1)
186
+ .replace(/\\"/g, '"');
187
+ if (char === "'")
188
+ return char + escapedText.replace(/[']/g, "\\'") + char;
189
+ if (char === '"')
190
+ return char + escapedText.replace(/["]/g, '\\"') + char;
191
+ if (char === '`')
192
+ return char + escapedText.replace(/[`]/g, '`') + char;
193
+ throw new Error('Invalid escape char');
194
+ }
195
+ exports.quote = quote;
196
+ function toSignalMap(action) {
197
+ let waitForNavigation;
198
+ let assertNavigation;
199
+ let popup;
200
+ let download;
201
+ let dialog;
202
+ for (const signal of action.signals) {
203
+ if (signal.name === 'navigation' && signal.isAsync)
204
+ waitForNavigation = signal;
205
+ else if (signal.name === 'navigation' && !signal.isAsync)
206
+ assertNavigation = signal;
207
+ else if (signal.name === 'popup')
208
+ popup = signal;
209
+ else if (signal.name === 'download')
210
+ download = signal;
211
+ else if (signal.name === 'dialog')
212
+ dialog = signal;
213
+ }
214
+ return {
215
+ waitForNavigation,
216
+ assertNavigation,
217
+ popup,
218
+ download,
219
+ dialog,
220
+ };
221
+ }
222
+ function toAssertCall(pageAlias, action) {
223
+ const { command, selector, value } = action;
224
+ switch (command) {
225
+ case 'textContent':
226
+ case 'innerText':
227
+ return `expect(await ${pageAlias}.${command}(${quote(selector)})).toMatch(${quote(value)});`;
228
+ case 'isVisible':
229
+ case 'isHidden':
230
+ case 'isChecked':
231
+ case 'isEditable':
232
+ case 'isEnabled':
233
+ case 'isDisabled':
234
+ return `expect(await ${pageAlias}.${command}(${quote(selector)})).toBeTruthy();`;
235
+ }
236
+ }
237
+ function formatObject(value, indent = ' ') {
238
+ if (typeof value === 'string')
239
+ return quote(value);
240
+ if (Array.isArray(value))
241
+ return `[${value.map(o => formatObject(o)).join(', ')}]`;
242
+ if (typeof value === 'object') {
243
+ const keys = Object.keys(value);
244
+ if (!keys.length)
245
+ return '{}';
246
+ const tokens = [];
247
+ for (const key of keys)
248
+ tokens.push(`${key}: ${formatObject(value[key])}`);
249
+ return `{\n${indent}${tokens.join(`,\n${indent}`)}\n}`;
250
+ }
251
+ return String(value);
252
+ }
253
+ /**
254
+ * Generates an appropriate title string based on the action type/data.
255
+ * @param action Playwright action IR
256
+ * @returns title string
257
+ */
258
+ function actionTitle(action) {
259
+ switch (action.name) {
260
+ case 'openPage':
261
+ return `Open new page`;
262
+ case 'closePage':
263
+ return `Close page`;
264
+ case 'check':
265
+ return `Check ${action.selector}`;
266
+ case 'uncheck':
267
+ return `Uncheck ${action.selector}`;
268
+ case 'click': {
269
+ if (action.clickCount === 1)
270
+ return `Click ${action.selector}`;
271
+ if (action.clickCount === 2)
272
+ return `Double click ${action.selector}`;
273
+ if (action.clickCount === 3)
274
+ return `Triple click ${action.selector}`;
275
+ return `${action.clickCount}× click`;
276
+ }
277
+ case 'fill':
278
+ return `Fill ${action.selector}`;
279
+ case 'setInputFiles':
280
+ if (action.files.length === 0)
281
+ return `Clear selected files`;
282
+ else
283
+ return `Upload ${action.files.join(', ')}`;
284
+ case 'navigate':
285
+ return `Go to ${action.url}`;
286
+ case 'press':
287
+ return (`Press ${action.key}` + (action.modifiers ? ' with modifiers' : ''));
288
+ case 'select':
289
+ return `Select ${action.options.join(', ')}`;
290
+ case 'assert':
291
+ return `Assert ${action.selector} ${action.command}`;
292
+ }
293
+ }
294
+ exports.actionTitle = actionTitle;
295
+ //# sourceMappingURL=javascript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../src/formatter/javascript.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,2FAGoE;AA8CpE,MAAa,mBAAoB,SAAQ,wCAA2B;IAIlE,YAAoB,OAAgB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;QADM,YAAO,GAAP,OAAO,CAAS;QAElC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,eAAgC;QAC7C,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC;QAC9C,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;YAC9B,OAAO,EAAE,CAAC;SACX;QACD,kDAAkD;QAClD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,SAAS,KAAK,MAAM,CAAC;QACtE,IAAI,SAAS,EAAE;YACb,OAAO,EAAE,CAAC;SACX;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;QAC9D,MAAM,SAAS,GAAG,IAAI,gCAAmB,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,OAAO,GAAG,eAAe,CAAC,WAAW;YACzC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,eAAe,CAAC,SAAS;gBAC3B,CAAC,CAAC,GAAG,SAAS,UAAU,YAAY,CAAC;oBACjC,IAAI,EAAE,eAAe,CAAC,SAAS;iBAChC,CAAC,GAAG;gBACP,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CC"}
@@ -0,0 +1,21 @@
1
+ declare type PromptOptions = {
2
+ locations: string;
3
+ schedule: number;
4
+ };
5
+ export declare const regularFiles: string[];
6
+ export declare class Generator {
7
+ projectDir: string;
8
+ pkgManager: string;
9
+ constructor(projectDir: string);
10
+ directory(): Promise<void>;
11
+ questions(): Promise<any>;
12
+ files(answers: PromptOptions): Promise<void>;
13
+ createFile(relativePath: string, content: string, override?: boolean): Promise<void>;
14
+ package(): Promise<void>;
15
+ patchPkgJSON(): Promise<void>;
16
+ patchGitIgnore(): Promise<void>;
17
+ banner(): void;
18
+ setup(): Promise<void>;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAsCA,aAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,eAAO,MAAM,YAAY,UAMxB,CAAC;AAEF,qBAAa,SAAS;IAED,UAAU,EAAE,MAAM;IADrC,UAAU,SAAS;gBACA,UAAU,EAAE,MAAM;IAE/B,SAAS;IAMT,SAAS;IAqBT,KAAK,CAAC,OAAO,EAAE,aAAa;IA2B5B,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,UAAQ;IASlE,OAAO;IA4BP,YAAY;IAuBZ,cAAc;IAcpB,MAAM;IAkBA,KAAK;CASZ"}