@eventra_dev/eventra-cli 0.2.3 → 0.3.1
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/README.md +154 -32
- package/dist/analysis/cache/evaluationCache.js +21 -0
- package/dist/analysis/cache/resolvedCallCache.js +21 -0
- package/dist/analysis/cache/resolvedExportCache.js +21 -0
- package/dist/analysis/cache/semanticDependencyGraph.js +25 -0
- package/dist/analysis/cache/symbolInvalidation.js +20 -0
- package/dist/analysis/extractor/extractor.js +47 -0
- package/dist/analysis/extractor/propagationExtractor.js +52 -0
- package/dist/analysis/pipeline/semanticPass.js +2 -0
- package/dist/analysis/resolver/callResolver.js +125 -0
- package/dist/analysis/resolver/exportResolver.js +75 -0
- package/dist/analysis/resolver/resolver.js +133 -0
- package/dist/analysis/scanner/analyzer/propagationAnalyzer.js +193 -0
- package/dist/analysis/scanner/analyzer/returnPropagationAnalyzer.js +105 -0
- package/dist/analysis/scanner/scanner.js +117 -0
- package/dist/analysis/scanner/sinkDetector.js +91 -0
- package/dist/analysis/shared/evaluationContext.js +9 -0
- package/dist/analysis/shared/propagation.js +3 -0
- package/dist/analysis/shared/returnPropagation.js +2 -0
- package/dist/analysis/shared/types.js +2 -0
- package/dist/analysis/shared/utils.js +62 -0
- package/dist/analysis/symbols/symbolUtils.js +68 -0
- package/dist/analysis/symbols/wrapperRegistry.js +55 -0
- package/dist/cli/check.js +73 -0
- package/dist/{commands → cli}/init.js +1 -1
- package/dist/{commands → cli}/send.js +1 -1
- package/dist/cli/sync.js +56 -0
- package/dist/{commands → cli}/watch.js +41 -25
- package/dist/compiler/compilerContext.js +204 -0
- package/dist/compiler/documentRegistry.js +78 -0
- package/dist/compiler/importGraph.js +83 -0
- package/dist/compiler/scheduler.js +29 -0
- package/dist/core/EventraEngine.js +234 -0
- package/dist/core/projectScanner.js +73 -0
- package/dist/{utils → filesystem}/getVirtualFile.js +1 -3
- package/dist/filesystem/processFile.js +38 -0
- package/dist/index.js +5 -5
- package/dist/shared/buildSyntheticTsx.js +20 -0
- package/dist/shared/templateExpressionExtractor.js +22 -0
- package/package.json +32 -9
- package/.github/workflows/release.yml +0 -43
- package/ARCHITECTURE.md +0 -88
- package/assets/eventra-icon-animated.svg +0 -19
- package/dist/commands/check.js +0 -78
- package/dist/commands/sync.js +0 -79
- package/dist/engine/boundary.js +0 -14
- package/dist/engine/callResolver.js +0 -58
- package/dist/engine/engine.js +0 -154
- package/dist/engine/exportResolver.js +0 -46
- package/dist/engine/functionAnalyzer.js +0 -71
- package/dist/engine/graph.js +0 -168
- package/dist/engine/languageService.js +0 -162
- package/dist/engine/resolver.js +0 -149
- package/dist/engine/scanner.js +0 -230
- package/dist/utils/processFile.js +0 -28
- package/dist/utils/universal.js +0 -190
- package/src/commands/check.ts +0 -91
- package/src/commands/init.ts +0 -174
- package/src/commands/send.ts +0 -213
- package/src/commands/sync.ts +0 -106
- package/src/commands/watch.ts +0 -144
- package/src/engine/boundary.ts +0 -12
- package/src/engine/callResolver.ts +0 -65
- package/src/engine/engine.ts +0 -227
- package/src/engine/exportResolver.ts +0 -56
- package/src/engine/functionAnalyzer.ts +0 -81
- package/src/engine/graph.ts +0 -193
- package/src/engine/hash.ts +0 -5
- package/src/engine/languageService.ts +0 -209
- package/src/engine/resolver.ts +0 -177
- package/src/engine/scanner.ts +0 -298
- package/src/index.ts +0 -49
- package/src/types.ts +0 -35
- package/src/utils/config.ts +0 -53
- package/src/utils/getVirtualFile.ts +0 -5
- package/src/utils/processFile.ts +0 -29
- package/src/utils/universal.ts +0 -249
- package/tests/fixtures/backend/express/app.ts +0 -233
- package/tests/fixtures/backend/nest/service.ts +0 -70
- package/tests/fixtures/backend/node/index.ts +0 -63
- package/tests/fixtures/frontend/next/page.tsx +0 -101
- package/tests/fixtures/frontend/react/App.tsx +0 -104
- package/tests/fixtures/frontend/vue/App.vue +0 -83
- package/tests/fixtures/wrappers/component/test.tsx +0 -62
- package/tests/fixtures/wrappers/function/test.ts +0 -60
- package/tests/run.ts +0 -106
- package/tsconfig.json +0 -14
- /package/dist/{utils → config}/config.js +0 -0
- /package/dist/{engine → shared}/hash.js +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
declare function track(event: string): void;
|
|
4
|
-
|
|
5
|
-
function Injectable(): any {
|
|
6
|
-
return () => {};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function Controller(): any {
|
|
10
|
-
return () => {};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function Get(): any {
|
|
14
|
-
return () => {};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function Post(): any {
|
|
18
|
-
return () => {};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// ===== service =====
|
|
22
|
-
@Injectable()
|
|
23
|
-
export class TestService {
|
|
24
|
-
run() {
|
|
25
|
-
track("nest_event");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async asyncRun() {
|
|
29
|
-
track("async_event");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
arrow = () => {
|
|
33
|
-
track("arrow_event");
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ===== controller =====
|
|
38
|
-
@Controller()
|
|
39
|
-
export class TestController {
|
|
40
|
-
@Get()
|
|
41
|
-
get() {
|
|
42
|
-
track("get_event");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Post()
|
|
46
|
-
post() {
|
|
47
|
-
track("post_event");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
nested() {
|
|
51
|
-
if (true) {
|
|
52
|
-
track("nested_event");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ===== function =====
|
|
58
|
-
function service() {
|
|
59
|
-
track("function_event");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ===== class =====
|
|
63
|
-
class AnotherService {
|
|
64
|
-
run() {
|
|
65
|
-
track("class_event");
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ===== direct =====
|
|
70
|
-
track("direct_event");
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
declare function track(event: string): void;
|
|
4
|
-
|
|
5
|
-
const eventName = "variable_event";
|
|
6
|
-
|
|
7
|
-
// ===== direct =====
|
|
8
|
-
track("node_event");
|
|
9
|
-
|
|
10
|
-
// ===== multiline =====
|
|
11
|
-
track(
|
|
12
|
-
"multiline_event"
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
// ===== template string =====
|
|
16
|
-
track(`template_event`);
|
|
17
|
-
|
|
18
|
-
// ===== conditional =====
|
|
19
|
-
if (true) {
|
|
20
|
-
track("conditional_event");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ===== ternary =====
|
|
24
|
-
true
|
|
25
|
-
? track("ternary_a")
|
|
26
|
-
: track("ternary_b");
|
|
27
|
-
|
|
28
|
-
// ===== variable =====
|
|
29
|
-
track(eventName);
|
|
30
|
-
|
|
31
|
-
// ===== function =====
|
|
32
|
-
function run() {
|
|
33
|
-
track("function_event");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// ===== arrow =====
|
|
37
|
-
const handler = () => {
|
|
38
|
-
track("arrow_event");
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// ===== class =====
|
|
42
|
-
class Service {
|
|
43
|
-
run() {
|
|
44
|
-
track("class_event");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// ===== nested =====
|
|
49
|
-
function outer() {
|
|
50
|
-
function inner() {
|
|
51
|
-
track("nested_event");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ===== async =====
|
|
56
|
-
async function asyncRun() {
|
|
57
|
-
track("async_event");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ===== promise =====
|
|
61
|
-
Promise.resolve().then(() => {
|
|
62
|
-
track("promise_event");
|
|
63
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
declare function track(event: string): void;
|
|
4
|
-
declare function trackFeature(event: string): void;
|
|
5
|
-
|
|
6
|
-
declare const analytics: any;
|
|
7
|
-
declare const Button: any;
|
|
8
|
-
declare const TrackedButton: any;
|
|
9
|
-
declare const MyButton: any;
|
|
10
|
-
|
|
11
|
-
const eventName = "variable_event";
|
|
12
|
-
|
|
13
|
-
export default function Page() {
|
|
14
|
-
// ===== direct =====
|
|
15
|
-
track("next_event");
|
|
16
|
-
|
|
17
|
-
// ===== multiline =====
|
|
18
|
-
track(
|
|
19
|
-
"multiline_event"
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// ===== template string =====
|
|
23
|
-
track(`template_event`);
|
|
24
|
-
|
|
25
|
-
// ===== wrapper function =====
|
|
26
|
-
trackFeature("wrapper_function");
|
|
27
|
-
|
|
28
|
-
// ===== object =====
|
|
29
|
-
analytics.track("object_track");
|
|
30
|
-
|
|
31
|
-
// ===== nested object =====
|
|
32
|
-
analytics.events.track("nested_track");
|
|
33
|
-
|
|
34
|
-
// ===== variable =====
|
|
35
|
-
track(eventName);
|
|
36
|
-
|
|
37
|
-
// ===== conditional =====
|
|
38
|
-
if (true) {
|
|
39
|
-
track("conditional_event");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// ===== ternary =====
|
|
43
|
-
true
|
|
44
|
-
? track("ternary_a")
|
|
45
|
-
: track("ternary_b");
|
|
46
|
-
|
|
47
|
-
// ===== arrow function =====
|
|
48
|
-
const run = () => {
|
|
49
|
-
track("arrow_event");
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// ===== function =====
|
|
53
|
-
function test() {
|
|
54
|
-
track("function_event");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ===== class =====
|
|
58
|
-
class Service {
|
|
59
|
-
run() {
|
|
60
|
-
track("class_event");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<>
|
|
66
|
-
{/* basic */}
|
|
67
|
-
<Button event="next_button" />
|
|
68
|
-
|
|
69
|
-
{/* expression */}
|
|
70
|
-
<Button event={"expression_event"} />
|
|
71
|
-
|
|
72
|
-
{/* wrapper component */}
|
|
73
|
-
<TrackedButton event="tracked_button" />
|
|
74
|
-
|
|
75
|
-
{/* another wrapper */}
|
|
76
|
-
<MyButton event="my_button" />
|
|
77
|
-
|
|
78
|
-
{/* nested */}
|
|
79
|
-
<div>
|
|
80
|
-
<Button event="nested_button" />
|
|
81
|
-
</div>
|
|
82
|
-
|
|
83
|
-
{/* conditional */}
|
|
84
|
-
{true && (
|
|
85
|
-
<Button event="conditional_button" />
|
|
86
|
-
)}
|
|
87
|
-
|
|
88
|
-
{/* ternary */}
|
|
89
|
-
{true
|
|
90
|
-
? <Button event="ternary_a_button" />
|
|
91
|
-
: <Button event="ternary_b_button" />
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
{/* array */}
|
|
95
|
-
{[
|
|
96
|
-
<Button key="1" event="array_1" />,
|
|
97
|
-
<Button key="2" event="array_2" />
|
|
98
|
-
]}
|
|
99
|
-
</>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
declare function track(event: string): void;
|
|
4
|
-
declare function trackFeature(event: string): void;
|
|
5
|
-
|
|
6
|
-
declare const analytics: any;
|
|
7
|
-
declare const Button: any;
|
|
8
|
-
declare const TrackedButton: any;
|
|
9
|
-
declare const MyButton: any;
|
|
10
|
-
|
|
11
|
-
const eventName = "variable_event";
|
|
12
|
-
|
|
13
|
-
// ===== direct =====
|
|
14
|
-
track("direct_event");
|
|
15
|
-
|
|
16
|
-
// ===== multiline =====
|
|
17
|
-
track(
|
|
18
|
-
"multiline_event"
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
// ===== template string =====
|
|
22
|
-
track(`template_event`);
|
|
23
|
-
|
|
24
|
-
// ===== conditional =====
|
|
25
|
-
if (true) {
|
|
26
|
-
track("conditional_event");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ===== ternary =====
|
|
30
|
-
true
|
|
31
|
-
? track("ternary_a")
|
|
32
|
-
: track("ternary_b");
|
|
33
|
-
|
|
34
|
-
// ===== wrapper function =====
|
|
35
|
-
trackFeature("wrapper_function");
|
|
36
|
-
|
|
37
|
-
// ===== object function =====
|
|
38
|
-
analytics.track("object_track");
|
|
39
|
-
|
|
40
|
-
// ===== nested object =====
|
|
41
|
-
analytics.events.track("nested_track");
|
|
42
|
-
|
|
43
|
-
// ===== variable (optional support) =====
|
|
44
|
-
track(eventName);
|
|
45
|
-
|
|
46
|
-
// ===== function =====
|
|
47
|
-
function test() {
|
|
48
|
-
track("function_event");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// ===== arrow function =====
|
|
52
|
-
const run = () => {
|
|
53
|
-
track("arrow_event");
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// ===== class =====
|
|
57
|
-
class TestService {
|
|
58
|
-
run() {
|
|
59
|
-
track("class_event");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ===== component return =====
|
|
64
|
-
export default function Page() {
|
|
65
|
-
track("page_event");
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<>
|
|
69
|
-
{/* basic */}
|
|
70
|
-
<Button event="button_event" />
|
|
71
|
-
|
|
72
|
-
{/* wrapper component */}
|
|
73
|
-
<TrackedButton event="tracked_button" />
|
|
74
|
-
|
|
75
|
-
{/* another wrapper */}
|
|
76
|
-
<MyButton event="my_button" />
|
|
77
|
-
|
|
78
|
-
{/* expression */}
|
|
79
|
-
<Button event={"expression_event"} />
|
|
80
|
-
|
|
81
|
-
{/* nested */}
|
|
82
|
-
<div>
|
|
83
|
-
<Button event="nested_button" />
|
|
84
|
-
</div>
|
|
85
|
-
|
|
86
|
-
{/* conditional */}
|
|
87
|
-
{true && (
|
|
88
|
-
<Button event="conditional_button" />
|
|
89
|
-
)}
|
|
90
|
-
|
|
91
|
-
{/* ternary */}
|
|
92
|
-
{true
|
|
93
|
-
? <Button event="ternary_a_button" />
|
|
94
|
-
: <Button event="ternary_b_button" />
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
{/* array */}
|
|
98
|
-
{[
|
|
99
|
-
<Button key="1" event="array_1" />,
|
|
100
|
-
<Button key="2" event="array_2" />
|
|
101
|
-
]}
|
|
102
|
-
</>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
declare function track(event: string): void
|
|
5
|
-
declare function trackFeature(event: string): void
|
|
6
|
-
|
|
7
|
-
declare const analytics: any
|
|
8
|
-
|
|
9
|
-
const eventName = "variable_event"
|
|
10
|
-
|
|
11
|
-
// ===== direct =====
|
|
12
|
-
track("vue_event")
|
|
13
|
-
|
|
14
|
-
// ===== multiline =====
|
|
15
|
-
track(
|
|
16
|
-
"multiline_event"
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
// ===== template string =====
|
|
20
|
-
track(`template_event`)
|
|
21
|
-
|
|
22
|
-
// ===== wrapper function =====
|
|
23
|
-
trackFeature("wrapper_function")
|
|
24
|
-
|
|
25
|
-
// ===== object =====
|
|
26
|
-
analytics.track("object_track")
|
|
27
|
-
|
|
28
|
-
// ===== nested object =====
|
|
29
|
-
analytics.events.track("nested_track")
|
|
30
|
-
|
|
31
|
-
// ===== variable =====
|
|
32
|
-
track(eventName)
|
|
33
|
-
|
|
34
|
-
// ===== conditional =====
|
|
35
|
-
if (true) {
|
|
36
|
-
track("conditional_event")
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ===== ternary =====
|
|
40
|
-
true
|
|
41
|
-
? track("ternary_a")
|
|
42
|
-
: track("ternary_b")
|
|
43
|
-
|
|
44
|
-
// ===== function =====
|
|
45
|
-
function test() {
|
|
46
|
-
track("function_event")
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ===== arrow =====
|
|
50
|
-
const run = () => {
|
|
51
|
-
track("arrow_event")
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ===== class =====
|
|
55
|
-
class Service {
|
|
56
|
-
run() {
|
|
57
|
-
track("class_event")
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<template>
|
|
63
|
-
<!-- basic -->
|
|
64
|
-
<Button event="vue_button" />
|
|
65
|
-
|
|
66
|
-
<!-- expression -->
|
|
67
|
-
<Button event="expression_event" />
|
|
68
|
-
|
|
69
|
-
<!-- nested -->
|
|
70
|
-
<div>
|
|
71
|
-
<Button event="nested_button" />
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
<!-- conditional -->
|
|
75
|
-
<Button
|
|
76
|
-
v-if="true"
|
|
77
|
-
event="conditional_button"
|
|
78
|
-
/>
|
|
79
|
-
|
|
80
|
-
<!-- array -->
|
|
81
|
-
<Button event="array_1" />
|
|
82
|
-
<Button event="array_2" />
|
|
83
|
-
</template>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
declare const Button: any;
|
|
4
|
-
declare const TrackedButton: any;
|
|
5
|
-
declare const MyButton: any;
|
|
6
|
-
|
|
7
|
-
const eventName = "variable_event";
|
|
8
|
-
|
|
9
|
-
export default function WrapperTest() {
|
|
10
|
-
return (
|
|
11
|
-
<>
|
|
12
|
-
{/* basic */}
|
|
13
|
-
<Button event="wrapper_button" />
|
|
14
|
-
|
|
15
|
-
{/* expression */}
|
|
16
|
-
<Button event={"expression_button"} />
|
|
17
|
-
|
|
18
|
-
{/* nested */}
|
|
19
|
-
<div>
|
|
20
|
-
<Button event="nested_button" />
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
{/* fragment */}
|
|
24
|
-
<>
|
|
25
|
-
<Button event="fragment_button" />
|
|
26
|
-
</>
|
|
27
|
-
|
|
28
|
-
{/* conditional */}
|
|
29
|
-
{true && (
|
|
30
|
-
<Button event="conditional_button" />
|
|
31
|
-
)}
|
|
32
|
-
|
|
33
|
-
{/* ternary */}
|
|
34
|
-
{true
|
|
35
|
-
? <Button event="ternary_a_button" />
|
|
36
|
-
: <Button event="ternary_b_button" />
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
{/* array */}
|
|
40
|
-
{[
|
|
41
|
-
<Button key="1" event="array_1" />,
|
|
42
|
-
<Button key="2" event="array_2" />
|
|
43
|
-
]}
|
|
44
|
-
|
|
45
|
-
{/* wrapper components */}
|
|
46
|
-
<TrackedButton event={eventName} />
|
|
47
|
-
<MyButton event="my_button" />
|
|
48
|
-
|
|
49
|
-
{/* multiline */}
|
|
50
|
-
<Button
|
|
51
|
-
event="multiline_button"
|
|
52
|
-
/>
|
|
53
|
-
|
|
54
|
-
{/* deep nested */}
|
|
55
|
-
<div>
|
|
56
|
-
<section>
|
|
57
|
-
<Button event="deep_nested" />
|
|
58
|
-
</section>
|
|
59
|
-
</div>
|
|
60
|
-
</>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
declare function trackFeature(event: string): void;
|
|
4
|
-
declare const analytics: any;
|
|
5
|
-
|
|
6
|
-
const eventName = "variable_event";
|
|
7
|
-
|
|
8
|
-
// ===== basic =====
|
|
9
|
-
trackFeature("wrapper_function");
|
|
10
|
-
|
|
11
|
-
// ===== multiline =====
|
|
12
|
-
trackFeature(
|
|
13
|
-
"multiline_function"
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
// ===== template string =====
|
|
17
|
-
trackFeature(`template_function`);
|
|
18
|
-
|
|
19
|
-
// ===== conditional =====
|
|
20
|
-
if (true) {
|
|
21
|
-
trackFeature("conditional_function");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ===== ternary =====
|
|
25
|
-
true
|
|
26
|
-
? trackFeature("ternary_a")
|
|
27
|
-
: trackFeature("ternary_b");
|
|
28
|
-
|
|
29
|
-
// ===== variable =====
|
|
30
|
-
trackFeature(eventName);
|
|
31
|
-
|
|
32
|
-
// ===== function =====
|
|
33
|
-
function run() {
|
|
34
|
-
trackFeature("function_event");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ===== arrow =====
|
|
38
|
-
const test = () => {
|
|
39
|
-
trackFeature("arrow_event");
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// ===== class =====
|
|
43
|
-
class Service {
|
|
44
|
-
run() {
|
|
45
|
-
trackFeature("class_event");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ===== nested function =====
|
|
50
|
-
function outer() {
|
|
51
|
-
function inner() {
|
|
52
|
-
trackFeature("nested_function");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ===== object wrapper =====
|
|
57
|
-
analytics.trackFeature("object_wrapper");
|
|
58
|
-
|
|
59
|
-
// ===== nested object wrapper =====
|
|
60
|
-
analytics.events.trackFeature("nested_object_wrapper");
|
package/tests/run.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "child_process";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import * as fs from "fs";
|
|
4
|
-
|
|
5
|
-
const ROOT = path.resolve(__dirname, "..");
|
|
6
|
-
const CLI = path.resolve(ROOT, "dist/index.js");
|
|
7
|
-
|
|
8
|
-
const fixtures = [
|
|
9
|
-
"frontend/react",
|
|
10
|
-
"frontend/vue",
|
|
11
|
-
"frontend/next",
|
|
12
|
-
|
|
13
|
-
"backend/node",
|
|
14
|
-
"backend/express",
|
|
15
|
-
"backend/nest",
|
|
16
|
-
|
|
17
|
-
"wrappers/component",
|
|
18
|
-
"wrappers/function"
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
function runCLI(args: string[], cwd: string): string {
|
|
22
|
-
const result = spawnSync(
|
|
23
|
-
process.execPath,
|
|
24
|
-
[CLI, ...args],
|
|
25
|
-
{
|
|
26
|
-
cwd,
|
|
27
|
-
encoding: "utf-8",
|
|
28
|
-
input: "\n"
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
return (result.stdout ?? "") + (result.stderr ?? "");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function ensureTestConfig(dir: string) {
|
|
36
|
-
const configPath = path.join(dir, "eventra.json");
|
|
37
|
-
|
|
38
|
-
const config = {
|
|
39
|
-
apiKey: "",
|
|
40
|
-
events: [],
|
|
41
|
-
wrappers: [],
|
|
42
|
-
functionWrappers: [],
|
|
43
|
-
sync: {
|
|
44
|
-
include: [
|
|
45
|
-
"**/*.{ts,tsx,js,jsx,vue,svelte,astro}"
|
|
46
|
-
],
|
|
47
|
-
exclude: [
|
|
48
|
-
"node_modules",
|
|
49
|
-
"dist",
|
|
50
|
-
".next",
|
|
51
|
-
".git"
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
fs.writeFileSync(
|
|
57
|
-
configPath,
|
|
58
|
-
JSON.stringify(config, null, 2)
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function cleanup(dir: string) {
|
|
63
|
-
const configPath = path.join(dir, "eventra.json");
|
|
64
|
-
|
|
65
|
-
if (fs.existsSync(configPath)) {
|
|
66
|
-
fs.unlinkSync(configPath);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function runFixture(name: string) {
|
|
71
|
-
const dir = path.resolve(
|
|
72
|
-
__dirname,
|
|
73
|
-
"fixtures",
|
|
74
|
-
name
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
console.log(`\nRunning: ${name}`);
|
|
78
|
-
|
|
79
|
-
ensureTestConfig(dir);
|
|
80
|
-
|
|
81
|
-
const output = runCLI(["sync"], dir);
|
|
82
|
-
|
|
83
|
-
const match =
|
|
84
|
-
output.match(/Found (\d+) events/);
|
|
85
|
-
|
|
86
|
-
const count = match ? match[1] : "0";
|
|
87
|
-
|
|
88
|
-
console.log(
|
|
89
|
-
`✓ ${name} OK (${count} events)`
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// cleanup
|
|
93
|
-
cleanup(dir);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function run() {
|
|
97
|
-
for (const fixture of fixtures) {
|
|
98
|
-
runFixture(fixture);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
console.log(
|
|
102
|
-
"\nAll fixtures passed"
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
run();
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"outDir": "dist",
|
|
7
|
-
"resolveJsonModule": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"types": ["node"]
|
|
12
|
-
},
|
|
13
|
-
"include": ["src"]
|
|
14
|
-
}
|
|
File without changes
|
|
File without changes
|