Skip to content

Commit

Permalink
Add and improve data fetching and processing
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Oct 27, 2022
1 parent e40a5cc commit 34f9ff3
Show file tree
Hide file tree
Showing 10 changed files with 1,544 additions and 34 deletions.
24 changes: 14 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Custom

!.gitkeep

.rbenv-version
.rvmrc
.bundle
vendor/bundle
*.plist
.jekyll-cache/

_data/faq/src
_data/releases/src

# ---> macOS
*.DS_Store
.AppleDouble
Expand All @@ -6,7 +20,6 @@
# Icon must end with two \r
Icon


# Thumbnails
._*

Expand Down Expand Up @@ -54,12 +67,3 @@ _theme_packages
_res

Thumbs.db

!.gitkeep

.rbenv-version
.rvmrc
.bundle
vendor/bundle
*.plist
.jekyll-cache/
38 changes: 38 additions & 0 deletions _data/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Fetch and process FAQs, releases and versions.

.PHONY: faq-data releases-data versions-data clean

all: faq/all.json releases/all.json versions-data

update: clean all

faq/all.json: faq-data
jq -s 'add | map({title, url, body}) | map(.keywords = (.body | capture("Keywords: (?<c>[^\r\n]+)").c | split(", "))) | map(.categories = (.body | capture("Categories: (?<c>[^\r\n]+)").c | split(", "))) | sort_by(.title)' faq/src/* > $@

faq-data: faq/src/portmaster.json faq/src/portmaster-ui.json faq/src/spn.json faq/src/faqs.json

faq/src/%.json:
mkdir -p faq/src
cd faq/src
wget -O $@ "https://api.github.com/repos/safing/$*/issues?labels=faq&per_page=100"

releases/all.json: releases-data
jq -s 'add | map({name, tag_name, body, prerelease, html_url, created_at}) | map(.date = .created_at[:10]) | map(.body = (.body | gsub("Changelog:"; "") | gsub("[a-f0-9]{40}"; "-"))) | map(.repo = (.html_url | capture("github.com/safing/(?<repo>[^/]+)/").repo)) | sort_by(.created_at) | reverse' releases/src/* > $@

releases-data: releases/src/portmaster.json releases/src/portmaster-ui.json releases/src/spn.json

releases/src/%.json:
mkdir -p releases/src
cd faq/src
wget -O $@ "https://api.github.com/repos/safing/$*/releases"

versions-data: versions/stable.json versions/beta.json

versions/%.json:
cd versions
wget -O $@ "https://updates.safing.io/$*.v2.json"

clean:
rm -f faq/src/*
rm -f releases/src/*
rm -f versions/*
29 changes: 9 additions & 20 deletions _data/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
# Data
# Sourced Data

### Update faq-data.json

1. Check if the current list has new entries

https://github.com/issues?q=archived%3Afalse+user%3Asafing+sort%3Aupdated-desc+label%3Afaq

2. Get the current list with these commands (you might need to add new ones for additional repos)
### Update all data

```
gh issue list --label faq --repo safing/portmaster --json title,url,body > faq-data.json
gh issue list --label faq --repo safing/portmaster-ui --json title,url,body >> faq-data.json
make update
```

3. Fix JSON format.
### Create faq/all.json

```
sed -i ':a;N;$!ba;s/\]\n\[/,/g;s/},{/},\n{/g;s/\[{/\[\n{/g;s/}\]/}\n\]/g' faq-data.json
make faq/all.json
```

4. Sort and make pretty
### Create releases/all.json

```
cat faq-data.json | jq 'sort_by(.title)' | tee faq-data.json
make releases/all.json
```

Here is everything together:
### Create versions/*

```
gh issue list --label faq --repo safing/portmaster --json title,url,body > faq-data.json && \
gh issue list --label faq --repo safing/portmaster-ui --json title,url,body >> faq-data.json && \
gh issue list --label faq --repo safing/spn --json title,url,body >> faq-data.json && \
sed -i ':a;N;$!ba;s/\]\n\[/,/g;s/},{/},\n{/g;s/\[{/\[\n{/g;s/}\]/}\n\]/g' faq-data.json && \
cat faq-data.json | jq 'sort_by(.title)' | tee faq-data.json
make versions-data
```
444 changes: 444 additions & 0 deletions _data/faq/all.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions _data/faq-config.yml → _data/faq/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ categories:
- Starting and Stopping
- Compatibility
- Leaks
- Windows
- Linux
- Other
28 changes: 24 additions & 4 deletions _data/faq-data.json → _data/faq/data.json

Large diffs are not rendered by default.

902 changes: 902 additions & 0 deletions _data/releases/all.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions _data/releases/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- id: portmaster
name: "Portmaster"
resource: "windows_amd64/core/portmaster-core.exe"
- id: spn
name: "SPN"
resource: "linux_amd64/hub/spn-hub"
- id: portmaster-ui
tag-names:
portmaster: "UI"
notifier: "Notifier"
assets: "UI Assets"
app-electron: "UI App"
tag-resources:
portmaster: "all/ui/modules/portmaster.zip"
notifier: "windows_amd64/notifier/portmaster-notifier.exe"
assets: "all/ui/modules/assets.zip"
app-electron: "windows_amd64/app/portmaster-app.zip"
39 changes: 39 additions & 0 deletions _data/versions/beta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"Channel": "beta",
"Published": "2022-10-19T12:43:20Z",
"Releases": {
"all/ui/modules/assets.zip": "0.3.1",
"all/ui/modules/portmaster.zip": "0.4.2",
"darwin_amd64/core/portmaster-core": "1.0.0",
"darwin_amd64/jess/jess": "0.3.1",
"darwin_amd64/start/portmaster-start": "1.0.0",
"darwin_arm64/core/portmaster-core": "1.0.0",
"darwin_arm64/jess/jess": "0.3.1",
"darwin_arm64/start/portmaster-start": "1.0.0",
"linux_all/packages/install.sh": "1.0.0",
"linux_all/packages/installer-assets.tar.gz": "1.0.0",
"linux_amd64/core/portmaster-core": "1.0.0",
"linux_amd64/jess/jess": "0.3.1",
"linux_amd64/notifier/portmaster-notifier": "0.3.5",
"linux_amd64/packages/portmaster-installer.deb": "1.0.0",
"linux_amd64/packages/portmaster-installer.rpm": "1.0.0",
"linux_amd64/start/portmaster-start": "1.0.0",
"linux_arm64/core/portmaster-core": "1.0.0",
"linux_arm64/jess/jess": "0.3.1",
"linux_arm64/notifier/portmaster-notifier": "0.3.5",
"linux_arm64/start/portmaster-start": "1.0.0",
"windows_amd64/core/portmaster-core.exe": "1.0.0",
"windows_amd64/jess/jess.exe": "0.3.1",
"windows_amd64/kext/portmaster-kext.dll": "1.0.14",
"windows_amd64/kext/portmaster-kext.pdb": "1.0.14",
"windows_amd64/kext/portmaster-kext.sys": "1.0.14",
"windows_amd64/notifier/portmaster-notifier.exe": "0.3.5",
"windows_amd64/notifier/portmaster-wintoast.dll": "0.1.4",
"windows_amd64/packages/portmaster-installer.exe": "1.0.0",
"windows_amd64/start/portmaster-start.exe": "1.0.0",
"windows_arm64/core/portmaster-core.exe": "1.0.0",
"windows_arm64/jess/jess.exe": "0.3.1",
"windows_arm64/notifier/portmaster-notifier.exe": "0.3.5",
"windows_arm64/start/portmaster-start.exe": "1.0.0"
}
}
54 changes: 54 additions & 0 deletions _data/versions/stable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"Channel": "stable",
"Published": "2022-10-20T06:37:10Z",
"Releases": {
"all/intel/geoip/geoipv4.mmdb.gz": "20220804.11.58",
"all/intel/geoip/geoipv6.mmdb.gz": "20220804.12.24",
"all/ui/modules/assets.zip": "0.3.1",
"all/ui/modules/base.zip": "0.2.11",
"all/ui/modules/console.zip": "0.1.11",
"all/ui/modules/monitor.zip": "0.2.4",
"all/ui/modules/portmaster.zip": "0.4.2",
"all/ui/modules/profilemgr.zip": "0.1.7",
"all/ui/modules/settings.zip": "0.1.8",
"darwin_amd64/core/portmaster-core": "1.0.0",
"darwin_amd64/hub/spn-hub": "0.5.1",
"darwin_amd64/jess/jess": "0.3.1",
"darwin_amd64/start/portmaster-start": "1.0.0",
"darwin_arm64/core/portmaster-core": "1.0.0",
"darwin_arm64/jess/jess": "0.3.1",
"darwin_arm64/start/portmaster-start": "1.0.0",
"linux_all/packages/install.sh": "1.0.0",
"linux_all/packages/installer-assets.tar.gz": "1.0.0",
"linux_amd64/app/portmaster-app.zip": "0.2.5",
"linux_amd64/core/portmaster-core": "1.0.0",
"linux_amd64/hub/spn-hub": "0.5.1",
"linux_amd64/jess/jess": "0.3.1",
"linux_amd64/notifier/portmaster-notifier": "0.3.5",
"linux_amd64/packages/portmaster-installer.deb": "1.0.0",
"linux_amd64/packages/portmaster-installer.rpm": "1.0.0",
"linux_amd64/start/portmaster-start": "1.0.0",
"linux_arm64/app/portmaster-app.zip": "0.2.5",
"linux_arm64/core/portmaster-core": "1.0.0",
"linux_arm64/jess/jess": "0.3.1",
"linux_arm64/notifier/portmaster-notifier": "0.3.5",
"linux_arm64/start/portmaster-start": "1.0.0",
"windows_amd64/app/portmaster-app.zip": "0.2.5",
"windows_amd64/core/portmaster-core.exe": "1.0.0",
"windows_amd64/hub/spn-hub.exe": "0.5.1",
"windows_amd64/jess/jess.exe": "0.3.1",
"windows_amd64/kext/portmaster-kext.dll": "1.0.14",
"windows_amd64/kext/portmaster-kext.pdb": "1.0.14",
"windows_amd64/kext/portmaster-kext.sys": "1.0.14",
"windows_amd64/notifier/portmaster-notifier.exe": "0.3.5",
"windows_amd64/notifier/portmaster-snoretoast.exe": "0.6.0",
"windows_amd64/notifier/portmaster-wintoast.dll": "0.1.4",
"windows_amd64/packages/portmaster-installer.exe": "1.0.0",
"windows_amd64/start/portmaster-start.exe": "1.0.0",
"windows_arm64/app/portmaster-app.zip": "0.2.5",
"windows_arm64/core/portmaster-core.exe": "1.0.0",
"windows_arm64/jess/jess.exe": "0.3.1",
"windows_arm64/notifier/portmaster-notifier.exe": "0.3.5",
"windows_arm64/start/portmaster-start.exe": "1.0.0"
}
}

0 comments on commit 34f9ff3

Please sign in to comment.