From eef87be7a8d60470128e08e6f2d7d7c09eec3de0 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 5 Jun 2016 19:47:14 +0100 Subject: [PATCH] MAKEFILE! --- Makefile | 53 ++++++++++++++++++++++++++++++++++++++++ README.md | 13 +++++++++- build | 27 -------------------- circle.yml | 6 ++--- package.json | 9 +------ requirements.txt | 1 - runtests | 40 ------------------------------ scripts/generate-site.sh | 14 ----------- 8 files changed, 69 insertions(+), 94 deletions(-) create mode 100644 Makefile delete mode 100755 build delete mode 100755 runtests delete mode 100755 scripts/generate-site.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1be2664 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +ENV=env/bin +NODE_BIN=node_modules/.bin +PELICAN=$(ENV)/pelican + +BASEDIR=$(PWD) +OUTPUTDIR=$(BASEDIR)/output + +FLAKE8_IGNORE=--ignore=E128,E501,E401,E402 + +build: install + @echo ">> Building static data..." + mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css + cp -R node_modules/font-awesome/fonts theme/static/build/ + npm run build-js + npm run build-scss + @echo ">> Building pelican..." + $(PELICAN) -o $(OUTPUTDIR) -v + +clean: + rm -rf $(OUTPUTDIR)/* + rm -rf $(BASEDIR)/env/ + rm -rf $(BASEDIR)/node_modules/ + rm -rf $(BASEDIR)/pelican_plugins/ + + +install: env node_modules pelican_plugins + +pelican_plugins: + git clone --recursive https://github.com/getpelican/pelican-plugins --depth=1 pelican_plugins/ + @echo ">> Hotfixing..." + rm -rf pelican_plugins/pelican-jinja2content + git clone https://github.com/RealOrangeOne/pelican-jinja2content -b patch-1 --depth=1 pelican_plugins/pelican-jinja2content + +env: + pyvenv env + $(ENV)/pip install -r requirements.txt + +node_modules: + @source ~/.nvm/nvm.sh && nvm install + npm install + + +test: lint + +lint: + $(NODE_BIN)/eslint 'theme/static/src/js/' + $(NODE_BIN)/sass-lint -vqc .sass-lint.yml + $(ENV)/flake8 $(BASEDIR)/plugins/ $(FLAKE8_IGNORE) + $(ENV)/flake8 $(BASEDIR)/scripts/ $(FLAKE8_IGNORE) + $(ENV)/flake8 $(BASEDIR)/pelicanconf.py $(FLAKE8_IGNORE) + + +.PHONY: build clean test lint install diff --git a/README.md b/README.md index 03e4a69..6c84003 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ -# My Website +# My Website [![Circle CI](https://circleci.com/gh/RealOrangeOne/theorangeone.net.svg?style=svg)](https://circleci.com/gh/RealOrangeOne/theorangeone.net) + + +## Installation +```bash +make +``` + +## Run Tests +```bash +make test +``` diff --git a/build b/build deleted file mode 100755 index cfade39..0000000 --- a/build +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -if [ -z "$NVM_DIR" ] -then - NVM_DIR="$HOME/.nvm" -fi - -. $NVM_DIR/nvm.sh -nvm install -nvm use - -set -e - -pyvenv env -env/bin/pip install -r requirements.txt - -echo ">> Cleaning plugins..." -rm -rf pelican_plugins - -echo ">> Installing Plugins" -git clone --recursive https://github.com/getpelican/pelican-plugins --depth=1 pelican_plugins/ - -echo ">> Hot fixing..." -rm -rf pelican_plugins/pelican-jinja2content -git clone https://github.com/RealOrangeOne/pelican-jinja2content -b patch-1 --depth=1 pelican_plugins/pelican-jinja2content - -npm install diff --git a/circle.yml b/circle.yml index d1bc6d4..43ba6d2 100644 --- a/circle.yml +++ b/circle.yml @@ -8,12 +8,12 @@ machine: dependencies: pre: - - ./build + - make cache_directories: - env - node_modules - - plugins + - pelican_plugins test: override: - - ./runtests + - make test diff --git a/package.json b/package.json index 287a639..e4340c0 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,8 @@ "version": "4.0.0", "description": " Source code for TheOrangeOne.net", "scripts": { - "lint-js": "eslint 'theme/static/src/js/'", - "lint-scss": "sass-lint -vqc .sass-lint.yml", - "build": "npm run create-build-dirs && npm run build-fonts && npm run build-js && npm run build-scss", "build-js": "./scripts/build-js.sh", - "build-scss": "./scripts/build-scss.sh", - "build-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/", - "create-build-dirs": "mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css", - "test": "npm run lint-js && npm run lint-scss", - "spellcheck": "mdspell --en-gb -ranx \"templates/**/*.*\"" + "build-scss": "./scripts/build-scss.sh" }, "repository": { "type": "git", diff --git a/requirements.txt b/requirements.txt index bd1d353..c0bb63f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ beautifulsoup4==4.4.1 -colorama==0.3.6 flake8==2.5.0 fontawesome_markdown==0.2.5 gitpython==2.0.3 diff --git a/runtests b/runtests deleted file mode 100755 index 4d3bfa4..0000000 --- a/runtests +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 -import os, sys -import subprocess -from colorama import Fore, init - - -init(autoreset=True) - - -bin_dir = os.path.abspath(os.path.join(sys.executable, os.path.pardir)) -EXIT_CODE = 0 - - -def check_if_exit_code(): - if EXIT_CODE != 0: - print("\n{}Tests Failed. {}Please check messages above and then re-run the command.".format(Fore.RED, Fore.YELLOW)) - print("{}Exit Code: {}".format(Fore.RED, EXIT_CODE)) - exit(1) - -print("{}Linting...".format(Fore.YELLOW)) - - -FLAKE8_IGNORE = '--ignore=E128,E501,E401,E402' -try: - subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'theme', FLAKE8_IGNORE]) - subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'scripts', FLAKE8_IGNORE]) - subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'pelicanconf.py', FLAKE8_IGNORE]) - subprocess.check_output([os.path.join(bin_dir, 'flake8'), sys.argv[0], FLAKE8_IGNORE]) # Test this file -except subprocess.CalledProcessError as e: - print(Fore.RED, e.output.decode()) - EXIT_CODE = 1 - -check_if_exit_code() -print("{}All Python tests passed! {}Testing Static Files...".format(Fore.GREEN, Fore.YELLOW)) - - -EXIT_CODE = os.system('npm test') -check_if_exit_code() - -print("{}All Tests Passed!".format(Fore.GREEN)) diff --git a/scripts/generate-site.sh b/scripts/generate-site.sh deleted file mode 100755 index 5a9f6ad..0000000 --- a/scripts/generate-site.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -e - -echo "> Creating Site..." - -# Build the static data -echo ">> Building static data..." -npm run build - -echo ">> Compiling site pages..." -pelican -v - -echo "> Build complete."