Compare commits

...

4 Commits

Author SHA1 Message Date
ge
718665e520 make: replace Makefile with make.vsh 2025-05-29 23:28:49 +03:00
ge
480a407b9e ci: add tests CI 2025-04-22 19:35:34 +03:00
ge
d0e9c04326 upd doc, version 2025-04-22 19:27:53 +03:00
ge
3ab92ee93a all: stop using src/ dir, update licenses.json 2025-04-22 19:21:20 +03:00
9 changed files with 7438 additions and 7414 deletions

View File

@ -1,9 +1,7 @@
name: CI name: Docs
on: on:
push: push:
branches: [ "master" ] branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch: workflow_dispatch:
jobs: jobs:

24
.github/workflows/test.yaml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Tests
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup V
run: |
wget -qO /tmp/v.zip https://github.com/vlang/v/releases/latest/download/v_linux.zip
unzip -q /tmp/v.zip -d /tmp
echo /tmp/v >> "$GITHUB_PATH"
- name: Run tests
run: |
v -stats test .

View File

@ -1,23 +0,0 @@
SRC_DIR = src
DOC_DIR = doc
SPDX_LICENSE_LIST_FILE = src/licenselist.json
SPDX_LICENSE_LIST_FILE_MIN = src/licenselist.min.json
SPDX_LICENSE_LIST_FILE_TMP = /tmp/licenselist.json.new
SPDX_LICENSE_LIST_JSON_URL = https://spdx.org/licenses/licenses.json
licenselist:
wget -q -O $(SPDX_LICENSE_LIST_FILE_TMP) $(SPDX_LICENSE_LIST_JSON_URL)
if ! diff $(SPDX_LICENSE_LIST_FILE) $(SPDX_LICENSE_LIST_FILE_TMP) >/dev/null 2>&1; \
then mv -v $(SPDX_LICENSE_LIST_FILE_TMP) $(SPDX_LICENSE_LIST_FILE); \
fi
jq -c . < $(SPDX_LICENSE_LIST_FILE) > $(SPDX_LICENSE_LIST_FILE_MIN)
doc:
v doc -f html -m ./$(SRC_DIR) -o $(DOC_DIR)
serve: clean doc
v -e "import net.http.file; file.serve(folder: '$(DOC_DIR)')"
clean:
rm -r $(DOC_DIR) || true

View File

@ -1,4 +1,4 @@
## Query the SPDX license list and licenses information # Query the SPDX license list
`licenseid` module embeds the SPDX license list data file taken from `licenseid` module embeds the SPDX license list data file taken from
https://spdx.org/licenses/licenses.json and allows you to obtain basic https://spdx.org/licenses/licenses.json and allows you to obtain basic

View File

@ -3,7 +3,7 @@ module licenseid
import json import json
import net.http import net.http
const licenses_file = $embed_file('licenselist.min.json') const licenses_file = $embed_file('licenses.min.json')
const licenses = json.decode(LicenseList, licenses_file.to_string()) or { LicenseList{} } const licenses = json.decode(LicenseList, licenses_file.to_string()) or { LicenseList{} }
struct LicenseList { struct LicenseList {
@ -47,7 +47,7 @@ pub:
} }
// details fetches the license details object from SPDX data file using the // details fetches the license details object from SPDX data file using the
// details_url. Requires access to public network. // details_url. Requires access to internet.
pub fn (l License) details() !LicenseDetails { pub fn (l License) details() !LicenseDetails {
response := http.get(l.details_url)! response := http.get(l.details_url)!
details := json.decode(LicenseDetails, response.body)! details := json.decode(LicenseDetails, response.body)!

File diff suppressed because it is too large Load Diff

25
make.vsh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env -S v run
import build
import net.http
const source_url = 'https://spdx.org/licenses/licenses.json'
mut context := build.context(default: 'licenses.min.json')
context.artifact(
name: 'licenses.json'
help: 'SPDX licenses list in JSON format'
should_run: |self| true
run: |self| http.download_file(source_url, self.name)!
)
context.artifact(
name: 'licenses.min.json'
help: 'The minified licenses.json ready for embedding (requires jq util)'
depends: ['licenses.json']
should_run: |self| true
run: |self| system('jq -c . < licenses.json > ${self.name}')
)
context.run()

2
v.mod
View File

@ -1,7 +1,7 @@
Module{ Module{
name: 'licenseid' name: 'licenseid'
description: 'Query the SPDX license list and licenses information' description: 'Query the SPDX license list and licenses information'
version: '0.0.1' version: '0.0.2'
license: 'Unlicense' license: 'Unlicense'
dependencies: [] dependencies: []
} }