diff --git a/build/build.sh b/build/build.sh deleted file mode 100755 index 0f23d630..00000000 --- a/build/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# create json directory if not already present -mkdir -p ../json -# parse API README and print (minified) JSON to stdout, redirect to /json -./md2json.py ../README.md > ../json/entries.min.json -# beautify the previously created JSON file, redirect to /json -python -m json.tool ../json/entries.min.json > ../json/entries.json diff --git a/build/deploy.sh b/build/deploy.sh deleted file mode 100755 index f90e967d..00000000 --- a/build/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -o errexit -o nounset - -rev=$(git rev-parse --short HEAD) - -mkdir deploy -cd deploy - -git init -git config --global user.name $GH_USER -git config --global user.email $GH_EMAIL - -git remote add upstream "https://$GH_TOKEN@github.com/toddmotto/public-apis.git" -git fetch upstream -git reset upstream/master - -mv ../../json . - -git add json/ -git commit -m "rebuild JSON at ${rev}" -m "[ci skip]" -git push upstream HEAD:master - diff --git a/build/main.sh b/build/main.sh index ade67324..86e08291 100755 --- a/build/main.sh +++ b/build/main.sh @@ -8,21 +8,11 @@ if [[ $? != 0 ]]; then exit 1 fi echo "format validation passed!" -./build.sh -if [[ $? != 0 ]]; then - echo "JSON build failed!" -else - echo "JSON build success!" -fi -if [ "$TRAVIS_BRANCH" == "master" ] -then - echo "Master build - deploying JSON" - ./deploy.sh -fi if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "running on $TRAVIS_BRANCH branch - skipping Pull Request logic" exit 0 fi + echo "running on Pull Request #$TRAVIS_PULL_REQUEST" DIFF_URL="https://patch-diff.githubusercontent.com/raw/toddmotto/public-apis/pull/$TRAVIS_PULL_REQUEST.diff" curl $DIFF_URL > diff.txt @@ -35,16 +25,6 @@ cat additions.txt echo "------- END ADDITIONS ------" LINK_FILE=additions.txt -echo "checking if /json was changed..." -if egrep "\+{3}\s.\/json\/" diff.txt > json.txt; then - echo "JSON files are auto-generated! Please do not update these files:" - cat json.txt - exit 1 -else - echo "/json check passed!" - rm json.txt -fi - echo "running link validation..." ./validate_links.py $LINK_FILE if [[ $? != 0 ]]; then diff --git a/build/md2json.py b/build/md2json.py deleted file mode 100755 index c2a345da..00000000 --- a/build/md2json.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -import json -import sys - - -def markdown_to_json(filename, anchor): - """Convert a Markdown file into a JSON string""" - category = "" - entries = [] - with open(filename) as fp: - lines = (line.rstrip() for line in fp) - lines = list(line for line in lines if line and - line.startswith(anchor) or line.startswith('| ')) - for line in lines: - if line.startswith(anchor): - category = line.split(anchor)[1].strip() - continue - chunks = [x.strip() for x in line.split('|')[1:-1]] - entry = { - 'API': chunks[0], - 'Description': chunks[1], - 'Auth': None if chunks[2].upper() == 'NO' else chunks[2].strip('`'), - 'HTTPS': True if chunks[3].upper() == 'YES' else False, - 'CORS': chunks[4].strip('`'), - 'Link': chunks[5].replace('[Go!]', '')[1:-1], - 'Category': category, - } - entries.append(entry) - final = { - 'count': len(entries), - 'entries': entries, - } - return json.dumps(final) - - -def main(): - num_args = len(sys.argv) - if num_args < 2: - print("No .md file passed") - sys.exit(1) - if num_args < 3: - anchor = '###' - else: - anchor = sys.argv[2] - print(markdown_to_json(sys.argv[1], anchor)) - - -if __name__ == "__main__": - main()