Add plugin system
erxclau opened this issue · 0 comments
Motivation
For fetching or for deployment. There are a wide number of options for data sources and deployment platforms to sync with. However, not all of these strategies should be included in sink
by default. Create a plugin system to allow for a greater number of potential options, without bloating the core library.
Fetching and deployment are fairly open entry points but I can imagine lifecycle entries such as pre- or post- fetch or deployment. For example, it may be useful to send a message to a Slack channel whenever sometimes deploys to AWS.
Examples
// sink.config.js
import notion from "@michigandaily/sink-plugin-notion";
import firebase from "@michigandaily/sink-plugin-firebase";
export default {
fetch: [
{
"type": "notion",
"id": "000000000",
"auth": "./credentials.json"
}
],
deployment: {
project: "",
path: ""
},
plugins: [notion(), firebase()]
}
Fetch plugins should be integrated into sink-fetch.js
, and run through yarn sink fetch <plugin-name>
. This will require adding an optional argument to the fetch
command.
// notion plugin
export default function notionPlugin() {
return {
name: "notion",
fetch: (details) {
console.log(details.id, details.auth);
}
}
}
Deployment plugins should be integrated into sink-deploy.js
, and run through yarn sink deploy <deployment-strategy>
.
// firebase plugin
export default function firebasePlugin() {
return {
name: "firebase",
fetch: () {
},
deploy: () {
}
}
}