Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
update tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivan-sean committed Mar 4, 2022
1 parent 8432a27 commit 87d0370
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"test": "tsc --noEmit",
"build": "tsc --build",
"clean": "rm -rf build",
"update-plugins": "ts-node src/update-plugins.ts"
"preupdate-plugins": "tsc --build tsconfig.update.json",
"update-plugins": "node build/update-plugins.js",
"postupdate-plugins": "npm run clean"
},
"repository": {
"type": "git",
Expand All @@ -25,8 +27,8 @@
},
"homepage": "https://github.com/withfig/plugins",
"devDependencies": {
"typescript": "^3.5.3",
"node-fetch": "^3.2.1",
"ts-node": "^10.6.0"
"axios": "^0.26.0",
"ts-node": "^10.6.0",
"typescript": "^3.5.3"
}
}
39 changes: 24 additions & 15 deletions src/update-plugins.ts
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);
});
})

10 changes: 2 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{
"ts-node": {
"transpileOnly": true,
"files": true,
"compilerOptions": {
"module": "commonjs"
}
},
"compilerOptions": {
"moduleResolution": "node",
"outDir": "./build",
"target": "ES6",
"module": "commonjs",
"lib": ["ESNext", "DOM"],
"esModuleInterop": true,
"moduleResolution": "node",
"strict": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules/"]
}

0 comments on commit 87d0370

Please sign in to comment.