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

Commit

Permalink
use commonjs instead of esnext to support node backend
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivan-sean committed Mar 4, 2022
1 parent 23c8eac commit 2e2989e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Rebuild Index
run: curl https://api.fig.io/plugins/rebuild-index
run: npm run update-plugins -- $(git diff --name-only origin/main HEAD -- src/plugins/**/*.ts)
env:
PLUGINS_UPDATE_TOKEN: ${{ secrets.PLUGINS_UPDATE_TOKEN }}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"scripts": {
"test": "tsc --noEmit",
"build": "tsc --build",
"clean": "rm -rf build"
"clean": "rm -rf build",
"update-plugins": "ts-node src/update-plugins.ts"
},
"repository": {
"type": "git",
Expand All @@ -24,6 +25,8 @@
},
"homepage": "https://github.com/withfig/plugins",
"devDependencies": {
"typescript": "^3.5.3"
"typescript": "^3.5.3",
"node-fetch": "^3.2.1",
"ts-node": "^10.6.0"
}
}
17 changes: 17 additions & 0 deletions src/update-plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { loadPlugin } from ".";

const pluginNames = process.argv.slice(2)
.filter(file => file.startsWith("src/plugins/") && file.endsWith(".ts"))
.map(file => file.slice("src/plugins/".length, -".ts".length));

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));
})

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"moduleResolution": "node",
"outDir": "./build",
"target": "ES6",
"module": "ESNext",
"module": "commonjs",
"lib": ["ESNext", "DOM"],
"strict": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"declaration": true
},
"exclude": ["node_modules/"],
"exclude": ["node_modules/", "src/update-plugins.ts"],
"include": ["src/**/*", "index.d.ts"],
"types": ["index.d.ts"]
}

0 comments on commit 2e2989e

Please sign in to comment.