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
Git Proxy supports extensibility in the form of plugins. These plugins are specified via [configuration](/docs/category/configuration) as NPM packages or JavaScript code on disk. For each plugin configured, Git Proxy will attempt to load each package or file as a standard [Node module](https://nodejs.org/api/modules.html). Plugin authors will create instances of the extension classes exposed by Git Proxy and use these objects to implement custom functionality.
1
+
# GitProxy plugins & samples
2
+
GitProxy supports extensibility in the form of plugins. These plugins are specified via [configuration](/docs/category/configuration) as NPM packages or JavaScript code on disk. For each plugin configured, GitProxy will attempt to load each package or file as a standard [Node module](https://nodejs.org/api/modules.html). Plugin authors will create instances of the extension classes exposed by GitProxy and use these objects to implement custom functionality.
3
3
4
-
For detailed documentation, please refer to the [Git Proxy development resources on the project's site](https://git-proxy.finos.org/docs/development/plugins)
4
+
For detailed documentation, please refer to the [GitProxy development resources on the project's site](https://git-proxy.finos.org/docs/development/plugins)
5
5
6
6
## Included plugins
7
-
These plugins are maintained by the core Git Proxy team. As a future roadmap item, organizations can choose to omit
8
-
certain features of Git Proxy by simply removing the dependency from a deployed version of the application.
7
+
These plugins are maintained by the core GitProxy team. As a future roadmap item, organizations can choose to omit
8
+
certain features of GitProxy by simply removing the dependency from a deployed version of the application.
9
9
10
-
-`git-proxy-plugin-samples`: "hello world" examples of the Git Proxy plugin system
10
+
-`git-proxy-plugin-samples`: "hello world" examples of the GitProxy plugin system
Copy file name to clipboardExpand all lines: website/docs/development/plugins.mdx
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,24 +3,24 @@ title: Plugins
3
3
---
4
4
5
5
## How plugins work
6
-
Git Proxy supports extensibility in the form of plugins. These plugins are specified via [configuration](/docs/category/configuration) as NPM packages or JavaScript code on disk. For each plugin configured, Git Proxy will attempt to load each package or file as a standard [Node module](https://nodejs.org/api/modules.html). Plugin authors will create instances of the extension classes exposed by Git Proxy and use these objects to implement custom functionality.
6
+
GitProxy supports extensibility in the form of plugins. These plugins are specified via [configuration](/docs/category/configuration) as NPM packages or JavaScript code on disk. For each plugin configured, GitProxy will attempt to load each package or file as a standard [Node module](https://nodejs.org/api/modules.html). Plugin authors will create instances of the extension classes exposed by GitProxy and use these objects to implement custom functionality.
7
7
8
-
For each loaded "plugin object", it is inserted into Git Proxy's chain of actions which are triggered on a given Git action received by Git Proxy such as `git push` or `git fetch`.
8
+
For each loaded "plugin object", it is inserted into GitProxy's chain of actions which are triggered on a given Git action received by GitProxy such as `git push` or `git fetch`.
9
9
10
10
:::caution
11
-
The order that plugins are configured matters! Plugins execute _before_Git Proxy's builtin steps and in the order that they are configured in `proxy.config.json`. If you wish to use a combination of features, ensure that your custom plugins do not conflict or interfere with later steps in the processing chain.
11
+
The order that plugins are configured matters! Plugins execute _before_GitProxy's builtin steps and in the order that they are configured in `proxy.config.json`. If you wish to use a combination of features, ensure that your custom plugins do not conflict or interfere with later steps in the processing chain.
12
12
:::
13
13
14
-
Git Proxy uses the [load-plugin package](https://www.npmjs.com/package/load-plugin) to provide the Node module resolution.
14
+
GitProxy uses the [load-plugin package](https://www.npmjs.com/package/load-plugin) to provide the Node module resolution.
15
15
16
16
## Limitations
17
17
- Plugins are only supported on the Git HTTP proxy server. There is no similar extensibility today for the dashboard UI or its backing API.
18
-
- Extensions are defined as JavaScript classes which are [quite limited](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain#inheritance_with_the_prototype_chain). Git Proxy has a rather naive system for determining if a provided module has any objects which it recognizes as "Git Proxy plugin types". A conversion of the project to TypeScript will provide more flexible options for enforcing API contracts via strict interfaces & types in a future release. [Use of TypeScript is a roadmap item](https://github.com/finos/git-proxy/issues/276).
18
+
- Extensions are defined as JavaScript classes which are [quite limited](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain#inheritance_with_the_prototype_chain). GitProxy has a rather naive system for determining if a provided module has any objects which it recognizes as "GitProxy plugin types". A conversion of the project to TypeScript will provide more flexible options for enforcing API contracts via strict interfaces & types in a future release. [Use of TypeScript is a roadmap item](https://github.com/finos/git-proxy/issues/276).
19
19
20
20
## Using plugins
21
21
The primary goals of the plugin system is to:
22
22
23
-
- Allow users deploying Git Proxy to do so via the distributed binary package. ie. `npx -- @finos/git-proxy`
23
+
- Allow users deploying GitProxy to do so via the distributed binary package. ie. `npx -- @finos/git-proxy`
24
24
- Allow users to consume plugins that packaged using standard tools (npm) and optionally distributed via npm themselves.
25
25
- Reuse as much native Node functionality as possible for calling 3rd-party code (plugins) from the main application (git-proxy).
26
26
@@ -32,7 +32,7 @@ The below instructions are using the [`@finos/git-proxy-plugin-samples`](https:/
32
32
1. Install both `@finos/git-proxy` and the `@finos/git-proxy-plugin-samples` package to the local `node_modules/` directory using the following command:
This section is considered highly experimental and not recommended for general use. Even when authoring local plugins that are not distributed, it is best to use `node_modules/` and not rely on bespoke system setup or layout of files. Use `npm pack` and `npm install path/to/plugin.tgz` if you must use local plugin code to ensure Git Proxy's plugin manager can properly load your plugins.
74
+
This section is considered highly experimental and not recommended for general use. Even when authoring local plugins that are not distributed, it is best to use `node_modules/` and not rely on bespoke system setup or layout of files. Use `npm pack` and `npm install path/to/plugin.tgz` if you must use local plugin code to ensure GitProxy's plugin manager can properly load your plugins.
75
75
:::
76
76
77
-
Plugins written as standalone JavaScript files are used similarly to npm packages. The main difference is that file-based module loading requires additional steps to ensure that the given JavaScript files (written as Node CommonJS or ES modules) have all the necessary dependencies to be imported. Since Git Proxy plugin system relies on class-based inheritence, the module will require at least a dependency to `@finos/git-proxy` to be able to import the required classes. Plugins do not have to be distributed by NPM to be used in this fashion which may be advantageous in certain environments.
77
+
Plugins written as standalone JavaScript files are used similarly to npm packages. The main difference is that file-based module loading requires additional steps to ensure that the given JavaScript files (written as Node CommonJS or ES modules) have all the necessary dependencies to be imported. Since GitProxy plugin system relies on class-based inheritence, the module will require at least a dependency to `@finos/git-proxy` to be able to import the required classes. Plugins do not have to be distributed by NPM to be used in this fashion which may be advantageous in certain environments.
78
78
79
79
1. To use a plugin that is written as a standalone JavaScript file, ensure that the JS code has all its necessary dependencies:
80
80
@@ -128,7 +128,7 @@ To develop a new plugin, you must add `@finos/git-proxy` as a [peer dependency](
128
128
-`@finos/git-proxy/plugin/PullActionPlugin`: execute as an action in the proxy chain during a `git fetch`
129
129
-`@finos/git-proxy/proxy/actions/Step` and `@finos/git-proxy/proxy/actions/Action`: internal classes which act as carriers for `git` state during proxying. Plugins should modify the passed in `action` for affecting any global state of the git operation and add its own custom `Step` object to capture the plugin's own internal state (logs, errored/blocked status, etc.)
130
130
131
-
Git Proxy will load your plugin only if it extends one of the two plugin classes above. It is also important that your package has [`exports`](https://nodejs.org/api/packages.html#exports) defined for the plugin loader to properly load your module(s).
131
+
GitProxy will load your plugin only if it extends one of the two plugin classes above. It is also important that your package has [`exports`](https://nodejs.org/api/packages.html#exports) defined for the plugin loader to properly load your module(s).
132
132
133
133
Please see the [sample plugin package included in the repo](https://github.com/finos/git-proxy/tree/main/plugins/git-proxy-plugin-samples) for details on how to structure your plugin package.
134
134
@@ -141,7 +141,7 @@ class FooPlugin extends PushActionPlugin {
141
141
constructor() {
142
142
super(); // don't pass any function to the parent class - let the parent's this.exec function be undefined
143
143
this.displayName='FooPlugin';
144
-
// overwrite the parent's exec function which is executed as part of Git Proxy's action chain.
144
+
// overwrite the parent's exec function which is executed as part of GitProxy's action chain.
145
145
// use an arrow function if you require access to the instances's state (properties, methods, etc.)
146
146
this.exec=async (req, action) => {
147
147
console.log(this.displayName);
@@ -162,7 +162,7 @@ class FooPlugin extends PushActionPlugin {
0 commit comments