Simplify index update script
All checks were successful
Update Plugin Index / update-index (push) Successful in 7s
All checks were successful
Update Plugin Index / update-index (push) Successful in 7s
This commit is contained in:
28
.gitea/scripts/update-index.js
Normal file
28
.gitea/scripts/update-index.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { readdir, readFile, writeFile } from 'fs/promises';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
const pluginsDir = './plugins';
|
||||||
|
|
||||||
|
async function updateIndex() {
|
||||||
|
const files = await readdir(pluginsDir);
|
||||||
|
const pluginIds = files
|
||||||
|
.filter(f => f.endsWith('.json') && f !== 'index.json')
|
||||||
|
.map(f => f.replace('.json', ''))
|
||||||
|
.sort();
|
||||||
|
|
||||||
|
const index = {
|
||||||
|
version: '1.0.0',
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
plugins: pluginIds
|
||||||
|
};
|
||||||
|
|
||||||
|
await writeFile(
|
||||||
|
join(pluginsDir, 'index.json'),
|
||||||
|
JSON.stringify(index, null, 2) + '\n'
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`✅ Updated index.json with ${pluginIds.length} plugins`);
|
||||||
|
console.log('Plugins:', pluginIds.join(', '));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateIndex().catch(console.error);
|
||||||
@@ -13,29 +13,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
|
||||||
- name: Generate index.json
|
- name: Generate index.json
|
||||||
run: |
|
run: node .gitea/scripts/update-index.js
|
||||||
cd plugins
|
|
||||||
echo '{' > index.json
|
|
||||||
echo ' "version": "1.0.0",' >> index.json
|
|
||||||
echo ' "updatedAt": "'$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")'",' >> index.json
|
|
||||||
echo ' "plugins": [' >> index.json
|
|
||||||
|
|
||||||
first=true
|
|
||||||
for file in *.json; do
|
|
||||||
if [ "$file" != "index.json" ]; then
|
|
||||||
plugin_id="${file%.json}"
|
|
||||||
if [ "$first" = true ]; then
|
|
||||||
echo " \"$plugin_id\"" >> index.json
|
|
||||||
first=false
|
|
||||||
else
|
|
||||||
echo ", \"$plugin_id\"" >> index.json
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done | sed '$ s/,$//'
|
|
||||||
|
|
||||||
echo ' ]' >> index.json
|
|
||||||
echo '}' >> index.json
|
|
||||||
|
|
||||||
- name: Commit index.json
|
- name: Commit index.json
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"updatedAt": "2026-04-17T00:00:00.000Z",
|
"updatedAt": "2026-04-16T16:31:13.860Z",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"example-plugin"
|
"example-plugin",
|
||||||
|
"example-plugin-2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user