You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 6, 2025. It is now read-only.
All events expose an identical interface with two functions that can be handled by the plugin and responsible for a different step in the lifecycle of the event. One for “before” the event is emitted and another for “after” the event is emitted.
10
+
All events expose an identical interface with two functions that can be handled by the plugin and responsible for a different step in the lifecycle of the event. One for "before" the event is emitted and another for "after" the event is emitted.
In the `before` and `after` functions, we have an access to the context and the event params.
37
51
The [context](docs\plugins\context.md) is used to gather common parts between events.
38
52
The event params manipulate the default behavior by passing different values.
39
53
40
-
In the `after` function, we also have access to the generated modules. An example of using this parameter is when you want to restructure the generated modules in a different folder structure.
54
+
## Accessing and Modifying Generated Files
55
+
56
+
In the `after` function, we also have access to the generated files. An example of using this parameter is when you want to restructure the generated files in a different folder structure.
57
+
58
+
:::info
59
+
In the `after` function for .NET plugins, we use a [`FileMap`](https://github.com/amplication/amplication/blob/master/libs/util/code-gen-types/src/files/file-map.ts). For Node.js plugins' `after` function we use a [`ModuleMap`](https://github.com/amplication/amplication/blob/master/libs/util/code-gen-types/src/code-gen-types.ts#L149).
60
+
:::
61
+
62
+
## Function Examples
63
+
64
+
Most of the functions include examples. But, if you're looking for more comprehensive and real-world examples, you can explore the [code of the Amplication plugins](https://github.com/amplication/plugins/tree/master/plugins) directly. These plugins showcase various implementations and use cases for the before and after lifecycle functions.
41
65
42
-
## Cautionary Guidelines
66
+
## Best Practices and Cautions
43
67
44
68
1. In the `after` function, avoid unintentionally overriding the entire generated file. Opt for smaller changes instead.
45
69
2. In the `before` function, take care when modifying templates to not unintentionally affect code generation.
0 commit comments