Skip to content

Commit 72f524e

Browse files
authored
Merge branch 'main' into fix-hover-efect
2 parents 126cdb5 + 0b1bc4a commit 72f524e

File tree

31 files changed

+1440
-197
lines changed

31 files changed

+1440
-197
lines changed

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# This file required to override .gitignore when publishing to npm
1+
# This file required to override .gitignore when publishing to npm
2+
website/
3+
plugins/

config.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
"description": "Flag to enable CSRF protections for UI",
3737
"type": "boolean"
3838
},
39+
"plugins": {
40+
"type": "array",
41+
"description": "List of plugins to integrate on GitProxy's push or pull actions. Each value is either a file path or a module name.",
42+
"items": {
43+
"type": "string"
44+
}
45+
},
3946
"authorisedList": {
4047
"description": "List of repositories that are authorised to be pushed to through the proxy.",
4148
"type": "array",

package-lock.json

Lines changed: 142 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@finos/git-proxy",
3-
"version": "1.3.8",
3+
"version": "1.3.10",
44
"description": "Deploy custom push protections and policies on top of Git.",
55
"scripts": {
66
"cli": "node ./packages/git-proxy-cli/index.js",
@@ -23,6 +23,11 @@
2323
"git-proxy": "./index.js",
2424
"git-proxy-all": "concurrently 'npm run server' 'npm run client'"
2525
},
26+
"exports": {
27+
"./plugin": "./src/plugin.js",
28+
"./proxy/actions": "./src/proxy/actions/index.js",
29+
"./src/config/env": "./src/config/env.js"
30+
},
2631
"workspaces": [
2732
"./packages/git-proxy-cli"
2833
],
@@ -91,6 +96,7 @@
9196
"mocha": "^10.2.0",
9297
"nyc": "^17.0.0",
9398
"prettier": "^3.0.0",
99+
"sinon": "^19.0.2",
94100
"vite": "^4.4.2"
95101
},
96102
"optionalDependencies": {

packages/git-proxy-notify-hello/index.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

plugins/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
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+
6+
## Included plugins
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+
10+
- `git-proxy-plugin-samples`: "hello world" examples of the GitProxy plugin system
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* This is a sample plugin that logs a message when the pull action is called. It is written using
3+
* CommonJS modules to demonstrate the use of CommonJS in plugins.
4+
*/
5+
6+
// Peer dependencies; its expected that these deps exist on Node module path if you've installed @finos/git-proxy
7+
const { PushActionPlugin } = require('@finos/git-proxy/plugin');
8+
const { Step } = require('@finos/git-proxy/proxy/actions');
9+
'use strict';
10+
11+
/**
12+
*
13+
* @param {object} req Express Request object
14+
* @param {Action} action GitProxy Action
15+
* @return {Promise<Action>} Promise that resolves to an Action
16+
*/
17+
async function logMessage(req, action) {
18+
const step = new Step('LogRequestPlugin');
19+
action.addStep(step);
20+
console.log(`LogRequestPlugin: req url ${req.url}`);
21+
console.log(`LogRequestPlugin: req user-agent ${req.header('User-Agent')}`);
22+
console.log('LogRequestPlugin: action', JSON.stringify(action));
23+
return action;
24+
}
25+
26+
class LogRequestPlugin extends PushActionPlugin {
27+
constructor() {
28+
super(logMessage)
29+
}
30+
}
31+
32+
33+
module.exports = {
34+
// Plugins can be written inline as new instances of Push/PullActionPlugin
35+
// A custom class is not required
36+
hello: new PushActionPlugin(async (req, action) => {
37+
const step = new Step('HelloPlugin');
38+
action.addStep(step);
39+
console.log('Hello world from the hello plugin!');
40+
return action;
41+
}),
42+
// Sub-classing is fine too if you require more control over the plugin
43+
logRequest: new LogRequestPlugin(),
44+
someOtherValue: 'foo', // This key will be ignored by the plugin loader
45+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* This is a sample plugin that logs a message when the pull action is called. It is written using
3+
* ES modules to demonstrate the use of ESM in plugins.
4+
*/
5+
6+
// Peer dependencies; its expected that these deps exist on Node module path if you've installed @finos/git-proxy
7+
import { PullActionPlugin } from "@finos/git-proxy/plugin";
8+
import { Step } from "@finos/git-proxy/proxy/actions";
9+
10+
class RunOnPullPlugin extends PullActionPlugin {
11+
constructor() {
12+
super(function logMessage(req, action) {
13+
const step = new Step('RunOnPullPlugin');
14+
action.addStep(step);
15+
console.log('RunOnPullPlugin: Received fetch request', req.url);
16+
return action;
17+
})
18+
}
19+
}
20+
21+
// Default exports are supported and will be loaded by the plugin loader
22+
export default new RunOnPullPlugin();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@finos/git-proxy-plugin-samples",
3+
"version": "0.1.0-alpha.0",
4+
"description": "A set of sample (dummy) plugins for GitProxy to demonstrate how plugins are authored.",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"author": "Thomas Cooper",
9+
"license": "Apache-2.0",
10+
"type": "module",
11+
"exports": {
12+
".": "./index.js",
13+
"./example": "./example.cjs"
14+
},
15+
"dependencies": {
16+
"express": "^4.18.2"
17+
},
18+
"peerDependencies": {
19+
"@finos/git-proxy": "1.3.5-alpha.5"
20+
}
21+
}

proxy.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,6 @@
9595
"privateOrganizations": [],
9696
"urlShortener": "",
9797
"contactEmail": "",
98-
"csrfProtection": true
98+
"csrfProtection": true,
99+
"plugins": []
99100
}

0 commit comments

Comments
 (0)