This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8432a27
commit 87d0370
Showing
4 changed files
with
36 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
import fetch from "node-fetch"; | ||
import { loadPlugin } from "."; | ||
import axios, { AxiosError } from 'axios'; | ||
|
||
const pluginNames = process.argv.slice(2) | ||
.filter(file => file.startsWith("src/plugins/") && file.endsWith(".ts")) | ||
.map(file => file.slice("src/plugins/".length, -".ts".length)); | ||
const plugins = process.argv.slice(2) | ||
.filter(file => file.match(/^src\/plugins\/.*\.ts$/)) | ||
.map(file => { | ||
const js = import(file.replace(/^src/, ".").replace(/\.ts$/, ".js")) | ||
return js.then(plugin => plugin.default) | ||
}); | ||
|
||
Promise.all(pluginNames.map(name => loadPlugin(name))).then(plugins => { | ||
fetch("https://api.fig.io/plugins/update", { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${process.env.PLUGINS_UPDATE_TOKEN}`, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ plugins }) | ||
}).then(res => process.exit(res.ok ? 0 : 1)); | ||
Promise.all(plugins).then(plugins => { | ||
axios.post( | ||
"https://api.fig.io/plugins/update", | ||
{ plugins }, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${process.env.PLUGINS_UPDATE_TOKEN}`, | ||
"Content-Type": "application/json" | ||
} | ||
} | ||
).then((res) => { | ||
console.log("Updated successfully"); | ||
process.exit(0); | ||
}).catch((err: AxiosError) => { | ||
console.log("Failed to update:", err.message); | ||
process.exit(1); | ||
}); | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": ["node_modules/"] | ||
} |