aviation-model
Version:
Public methods for querying the information from aviation-pg
101 lines (80 loc) • 3.15 kB
Plain Text
SHELL = /bin/bash
MAKEFLAGS += --no-print-directory --silent
export PATH := ./node_modules/.bin:$(PATH):./bin
# linting directories
LINT_DIR = $(wildcard src/**/*.js src/*.js test/*.js)
DOCS_DIR_SOURCE = $(wildcard src/**/)
DOCS_DIR_DEST = ./docs/
SQL_FILES = $(wildcard ./sql/*.sql)
# database config information
DB_NAME = $(shell node -pe "require('./database.json').database")
DB_USER = $(shell node -pe "require('./database.json').user")
default: setup check-config check-connection install-pg-formulas test
setup:
npm install
check-config:
@if test -e database.json; then \
exit 0; \
else echo "Error: database.json not found"; exit 1 ; fi
check-connection: check-config
@if psql -lqt | cut -d \| -f 1 | grep -qw $(DB_NAME); then\
exit 0;\
else\
echo "Please start up the postgres database and create the db with aviation-pg";\
exit 1 ;\
fi
lint:
echo "eslint started..."
eslint $(LINT_DIR)
echo "eslint finished."
test: check-connection lint
mocha test
dev: check-connection
mocha test -w
test-coverage-report: check-connection
echo "Generating coverage report, please stand by"
test -d node_modules/nyc/ || npm install nyc
nyc mocha && nyc report --reporter=html
open coverage/index.html
docs: include-code-links
echo "generating the docs..."
jsdoc $(DOCS_DIR_SOURCE) -d $(DOCS_DIR_DEST) -t ./node_modules/ink-docstrap/template -R README.md
make remove-code-links
echo "docs generated."
pages: include-code-links
echo "generating the docs..."
jsdoc $(DOCS_DIR_SOURCE) -d ./ -t ./node_modules/ink-docstrap/template -R README.md
make remove-code-links
echo "docs generated."
echo
echo "next steps to use the files generated to update the gh-pages:"
echo "1. 'git status' to check that there are not modified files to be commited, only new files to add."
echo "2. 'git add .'"
echo "3. 'git stash' save the files for apply them later."
echo "4. 'git checkout gh-pages'"
echo "5. 'git status' to check that status is clean."
echo "6. 'git stash apply' "
echo "7. 'git stash drop'"
echo "8. 'git status' only the new files should appear."
echo "9. 'mv [new_file] [old_file]' this way we overwrite the old files with the new ones."
echo "10. when finished we can commit and push."
open-docs:
echo "opening docs..."
open ./docs/index.html
install-pg-formulas: check-connection
echo "installing extensions and formulas needed..."
for file in $(SQL_FILES) ; do \
psql aviation -f $$file ; \
done
echo "installed."
uninstall-pg-formulas:
echo "uninstalling formulas and extensions..."
psql -U aviator -d aviation -c "DROP EXTENSION cube CASCADE;"
psql -U aviator -d aviation -c "DROP FUNCTION dms2dd (strdegminsec varchar);"
echo "uninstalled"
include-code-links:
patch -Ns node_modules/ink-docstrap/template/tmpl/layout.tmpl docs/index.diff || true
patch -Ns node_modules/ink-docstrap/template/static/styles/sunlight.default.css docs/css.diff || true
remove-code-links:
patch -Ns node_modules/ink-docstrap/template/tmpl/layout.tmpl docs/undo_index.diff || true
patch -Ns node_modules/ink-docstrap/template/static/styles/sunlight.default.css docs/undo_css.diff || true