@financial-times/n-concept
Version:
n-concept provides a card for concepts (e.g. topic, author) and their articles
158 lines (119 loc) • 6.42 kB
Plain Text
# Warning, don't edit this file, it's maintained on GitHub and updated by running `make update-tools`
# Submit PR's here: https://www.github.com/Financial-Times/n-makefile
# Setup environment variables
sinclude .env
export $(shell [ -f .env ] && sed 's/=.*//' .env)
# ./node_modules/.bin on the PATH
export PATH := ./node_modules/.bin:$(PATH)
# Use bash not sh
SHELL := /bin/bash
# Some handy utilities
GLOB = git ls-files -z $1 | tr '\0' '\n' | xargs -I {} find {} ! -type l
NPM_INSTALL = npm prune --production=false && npm install
BOWER_INSTALL = bower prune && bower install --config.registry.search=http://registry.origami.ft.com --config.registry.search=https://bower.herokuapp.com
JSON_GET_VALUE = grep $1 | head -n 1 | sed 's/[," ]//g' | cut -d : -f 2
IS_GIT_IGNORED = grep -q $(if $1, $1, $@) .gitignore
VERSION = v1.4.11
APP_NAME = $(shell cat package.json 2>/dev/null | $(call JSON_GET_VALUE,name))
DONE = echo ✓ $@ done
CONFIG_VARS = curl -fsL https://ft-next-config-vars.herokuapp.com/$1/$(call APP_NAME)$(if $2,.$2,) -H "Authorization: `heroku config:get APIKEY --app ft-next-config-vars`"
#
# META TASKS
#
.PHONY: test
#
# COMMON TASKS
#
# clean
clea%:
# HACK: Can't use -e option here because it's not supported by our Jenkins
# install
instal%: node_modules bower_components _install_scss_lint .editorconfig .eslintrc.js .scss-lint.yml .env webpack.config.js heroku-cli
# deploy
deplo%: _deploy_apex
# verify
verif%: _verify_lintspaces _verify_eslint _verify_scss_lint
# assets (includes assets-production)
asset%:
# build (includes build-production)
buil%: public/__about.json
# watch
watc%:
#
# SUB-TASKS
#
# INSTALL SUB-TASKS
# Regular npm install
node_modules: package.json
# Regular bower install
bower_components: bower.json
# These tasks have been intentionally left blank
package.json:
bower.json:
# node_modules for Lambda functions
functions/%/node_modules:
# bower_components for Lambda functions
functions/%/bower_components:
_install_scss_lint:
# Manage various dot/config files if they're in the .gitignore
.editorconfig .eslintrc.js .scss-lint.yml webpack.config.js: n.Makefile
ENV_MSG_CANT_GET = "Cannot get config vars for this service. Check you are added to the ft-next-config-vars service on Heroku with operate permissions. Do that here - https://docs.google.com/spreadsheets/d/1mbJQYJOgXAH2KfgKUM1Vgxq8FUIrahumb39wzsgStu0 (or ask someone to do it for you). Check that your package.json's name property is correct. Check that your project has config-vars set up in models/development.js."
.env:
MSG_HEROKU_CLI = "Please make sure the Heroku CLI toolbelt is installed - see https://toolbelt.heroku.com/. And make sure you are authenticated by running ‘heroku login’. If this is not an app, delete Procfile."
heroku-cli:
# VERIFY SUB-TASKS
_verify_eslint:
_verify_lintspaces:
_verify_scss_lint:
# HACK: Use backticks rather than xargs because xargs swallow exit codes (everything becomes 1 and stoopidly scss-lint exits with 1 if warnings, 2 if errors)
# DEPLOY SUB-TASKS
APEX_PROD_ENV_FILE = .env.prod.json
_deploy_apex:
npm-publis%:
npm-prepublish --verbose
npm publish --access public
# BUILD SUB-TASKS
# Only apply to Heroku apps for now
public/__about.json:
# UPDATE TASK
update-tools:
$(eval LATEST = $(shell curl -fs https://api.github.com/repos/Financial-Times/n-makefile/tags | $(call JSON_GET_VALUE,name)))
$(if $(filter $(LATEST), $(VERSION)), $(error Cannot update n-makefile, as it is already up to date!))
if [ $$Y == "y" ]; then git add n.Makefile && git commit -m "Updated tools to $(LATEST)" && git push origin HEAD; fi
# Wrapper for make deploy which prevents it running when build is a nightly
deploy-by-day:
ifeq ($(FT_NIGHTLY_BUILD),)
$(MAKE) deploy
else
echo "Nightly build - exiting before deploy"
endif