Skip to content

Commit cad81f1

Browse files
committed
Initial commit
0 parents  commit cad81f1

File tree

6 files changed

+175
-0
lines changed

6 files changed

+175
-0
lines changed

.github/workflows/update-index.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Update Library Index Task
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '42 * * * *'
7+
8+
jobs:
9+
exporter:
10+
runs-on: ubuntu-20.04
11+
name: Update Library Index
12+
steps:
13+
- name: Check out repository
14+
uses: actions/checkout@v2
15+
- name: Install NPM dependencies
16+
run: npm ci
17+
- name: Fetch library index
18+
run: npm start
19+
- name: Commit changes
20+
run: |
21+
git add -A
22+
git config user.email "[email protected]"
23+
git config user.name "Wokwi Update"
24+
git commit -m "sync $(date -u +%Y-%m-%dT%H:%M:%SZ)"
25+
- name: Push changes
26+
run: git push

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

docs/arduino.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "wokwi-library-index",
3+
"version": "1.0.0",
4+
"main": "src/update.js",
5+
"type": "module",
6+
"scripts": {
7+
"start": "node src/update.js"
8+
},
9+
"keywords": [],
10+
"author": "Uri Shaked",
11+
"license": "ISC",
12+
"description": "",
13+
"dependencies": {
14+
"node-fetch": "^3.1.0"
15+
}
16+
}

src/update.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-FileCopyrightText: © 2022 Uri Shaked <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
import { writeFileSync } from 'fs';
5+
import fetch from 'node-fetch';
6+
7+
async function main() {
8+
const req = await fetch('http://downloads.arduino.cc/libraries/library_index.json');
9+
const { libraries } = await req.json();
10+
const result = {
11+
libraries: Array.from(new Set(libraries.map((lib) => lib.name))),
12+
};
13+
writeFileSync('docs/arduino.json', JSON.stringify(result));
14+
}
15+
16+
main().catch(console.error);

0 commit comments

Comments
 (0)