diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 65598a6..0000000 --- a/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -root = true - -[*.*] -end_of_line = lf -insert_final_newline = true -charset = utf-8 - -[**{.js,.scss,.html,.mustache,Makefile,.vcl}] -indent_style = tab -trim_trailing_whitespace = true - -[**{.json}] -indent_style = space -indent_size = 2 -trim_trailing_whitespace = true diff --git a/Makefile b/Makefile index db28a75..d84fd4c 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,11 @@ -# TODO n.Makefile & nht +node_modules/@financial-times/n-gage/index.mk: + npm install --no-save --no-package-lock @financial-times/n-gage + touch $@ -.PHONY: test - -clean: - git clean -fxd - -install: - @echo "Installing…" - @npm install - -verify: - @echo "Verifying…" - @find ./src ./test -type f -exec lintspaces -e .editorconfig -i js-comments {} + &&\ - eslint -c ./.eslintrc.js ./src ./test +-include node_modules/@financial-times/n-gage/index.mk unit-test: @echo "Unit Testing…" @mocha --require test/setup --recursive --reporter spec test test: verify unit-test - -build: $(shell find src -type f) - @echo "Building…" - @rm -rf build - @babel -d build src - -npm-publish: - npm-prepublish --verbose - npm publish --access public \ No newline at end of file diff --git a/Procfile b/Procfile deleted file mode 100644 index f5740ad..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: forever server/app.js diff --git a/n.Makefile b/n.Makefile deleted file mode 100644 index 35233aa..0000000 --- a/n.Makefile +++ /dev/null @@ -1,134 +0,0 @@ -# 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 - - -# ./node_modules/.bin on the PATH -export PATH := ./node_modules/.bin:$(PATH) - -# Use bash not sh -SHELL := /bin/bash - -# -# META TASKS -# - -.PHONY: test - -# -# COMMON TASKS -# - -# clean -clea%: -# HACK: Can't use -e option here because it's not supported by our Jenkins - @git clean -fxd - @$(DONE) - -# install -instal%: node_modules bower_components _install_scss_lint .editorconfig .eslintrc.js .scss-lint.yml .env webpack.config.js - @$(MAKE) $(foreach f, $(shell find functions/* -type d -maxdepth 0 2>/dev/null), $f/node_modules) - @$(DONE) - -# deploy -deplo%: _deploy_apex - @$(DONE) - -# verify -verif%: _verify_lintspaces _verify_eslint _verify_scss_lint - @$(DONE) - -# build (includes build-production) -buil%: public/__about.json - @if [ -e webpack.config.js ]; then webpack $(if $(findstring build-production,$@),--bail,--dev); fi - @if [ -e Procfile ] && [ "$(findstring build-production,$@)" == "build-production" ]; then haikro build; fi - @$(DONE) - -# watch -watc%: - @if [ -e webpack.config.js ]; then webpack --watch --dev; fi - @$(DONE) - -# -# SUB-TASKS -# - -# INSTALL SUB-TASKS - -# Regular npm install -node_modules: package.json - @if [ -e package.json ]; then $(NPM_INSTALL) && $(DONE); fi - -# Regular bower install -bower_components: bower.json - @if [ -e bower.json ]; then bower install --config.registry.search=http://registry.origami.ft.com --config.registry.search=https://bower.herokuapp.com && $(DONE); fi - -# These tasks have been intentionally left blank -package.json: -bower.json: - -# node_modules for Lambda functions -functions/%/node_modules: - @cd $(dir $@) && if [ -e package.json ]; then $(NPM_INSTALL) && $(DONE); fi - -_install_scss_lint: - @if [ ! -x "$(shell which scss-lint)" ] && [ "$(shell $(call GLOB,'*.scss'))" != "" ]; then gem install scss-lint -v 0.35.0 && $(DONE); fi - -# Manage various dot/config files if they're in the .gitignore -.editorconfig .eslintrc.js .scss-lint.yml webpack.config.js: n.Makefile - @if $(call IS_GIT_IGNORED); then curl -sL https://raw.githubusercontent.com/Financial-Times/n-makefile/$(VERSION)/config/$@ > $@ && $(DONE); fi - -.env: - @if $(call IS_GIT_IGNORED); then heroku auth:whoami &>/dev/null || (echo Please make sure the Heroku CLI is installed and authenticated by running ‘heroku auth:token’. See more https://toolbelt.heroku.com/. && exit 1); fi - @if $(call IS_GIT_IGNORED) && [ -e package.json ]; then ($(call CONFIG_VARS,development) > .env && $(DONE)) || (echo "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." && exit 1); fi - -# VERIFY SUB-TASKS - -_verify_eslint: - @if [ -e .eslintrc.js ]; then $(call GLOB,'*.js') | xargs eslint && $(DONE); fi - -_verify_lintspaces: - @if [ -e .editorconfig ] && [ -e package.json ]; then $(call GLOB) | xargs lintspaces -e .editorconfig -i js-comments,html-comments && $(DONE); fi - -_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) - @if [ -e .scss-lint.yml ]; then { scss-lint -c ./.scss-lint.yml `$(call GLOB,'*.scss')`; if [ $$? -ne 0 -a $$? -ne 1 ]; then exit 1; fi; $(DONE); } fi - -# DEPLOY SUB-TASKS - -_deploy_apex: - @if [ -e project.json ]; then $(call CONFIG_VARS,production) | sed 's/\(.*\)/-s \1/' | tr '\n' ' ' | xargs apex deploy && $(DONE); fi - -# BUILD SUB-TASKS - -# Only apply to Heroku apps for now -public/__about.json: - @if [ -e Procfile ]; then mkdir -p public && echo '{"description":"$(call APP_NAME)","support":"next.team@ft.com","supportStatus":"active","appVersion":"$(shell git rev-parse HEAD | xargs echo -n)","buildCompletionTime":"$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")"}' > $@ && $(DONE); fi - -# Some handy utilities -GLOB = git ls-files $1 | xargs -I {} find {} ! -type l -NPM_INSTALL = npm prune --production=false && npm install -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 = v0.0.86 -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/$(if $2,$2,$(call APP_NAME)).env -H "Authorization: `heroku config:get APIKEY --app ft-next-config-vars`" - -# UPDATE TASK - -update-tools: - $(eval LATEST = $(shell curl -s 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!)) - @curl -sL https://raw.githubusercontent.com/Financial-Times/n-makefile/$(LATEST)/Makefile > n.Makefile - @sed -i "" "s/^VERSION = master/VERSION = $(LATEST)/" n.Makefile - @read -p "Updated tools from $(VERSION) to $(LATEST). Do you want to commit and push? [y/N] " Y;\ - if [ $$Y == "y" ]; then git add n.Makefile && git commit -m "Updated tools to $(LATEST)" && git push origin HEAD; fi - @$(DONE) - -# 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 diff --git a/nodemon.json b/nodemon.json deleted file mode 100644 index 64e0341..0000000 --- a/nodemon.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "watch": [ - "server" - ] -} diff --git a/package.json b/package.json index 8f498ef..ca8c8a9 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "license": "MIT", "devDependencies": { + "@financial-times/n-gage": "^1.8.21", "babel-cli": "^6.5.1", "babel-plugin-transform-object-assign": "^6.5.0", "babel-preset-es2015": "^6.5.0", @@ -29,6 +30,9 @@ }, "version": "0.0.0", "scripts": { - "prepublish": "make build" + "prepublish": "make build", + "precommit": "node_modules/.bin/secret-squirrel", + "commitmsg": "node_modules/.bin/secret-squirrel-commitmsg", + "prepush": "make verify -j3" } } diff --git a/src/slack.js b/src/slack.js index 37d7473..16adc47 100644 --- a/src/slack.js +++ b/src/slack.js @@ -8,17 +8,12 @@ module.exports = function sendSlackNotification ({ init, error, reports, - // packageJson, verbose, compact, appName = 'Regression', suite - // appLogo = 'https://next-geebee.ft.com/assets/brand-ft/icons/favicon-32x32.png' }={}) { - // const appGithub = packageJson && packageJson.repository ? packageJson.repository.url : ''; - // const appHerokuName = packageJson ? packageJson.name : ''; - logger.info('compact? ', compact); if (init && verbose) { @@ -97,17 +92,8 @@ module.exports = function sendSlackNotification ({ const attachmentSuccess = { 'fallback': 'All tests passed', - // 'pretext': 'All regression tests passed!', - // 'author_name': 'Saucelabs Dashboard', - // 'author_link': 'https://saucelabs.com/beta/dashboard/tests', - // 'author_icon': 'https://marketplace-cdn.atlassian.com/files/images/2fdb6577-55eb-4d53-a5f5-87771ea85929.png', - // 'title': `${appHerokuName}`, - // 'title_link': appGithub, 'color': 'good', - 'fields': successFields, - // 'footer': `${appName}`, - // 'footer_icon': appLogo, - // 'ts': Date.now() / 1000 + 'fields': successFields } const successBody = { @@ -125,7 +111,6 @@ module.exports = function sendSlackNotification ({ if (failuresFound === 0) { successBody.body = JSON.stringify(successBody.body); - // logger.info('sending success body') logger.info(successBody) fetch(SLACK_URL, successBody); } @@ -133,16 +118,12 @@ module.exports = function sendSlackNotification ({ const attachmentFailure = JSON.parse(JSON.stringify(attachmentSuccess)); attachmentFailure.color = '#f00'; attachmentFailure.fields = failedFields; - // attachmentFailure.pretext = `${failuresFound} tests failed:`; - // attachmentFailure.text = SLACK_MENTIONS; - // attachmentSuccess.pretext = 'These tests have passed:' const failureBody = JSON.parse(JSON.stringify(successBody)); failureBody.body.attachments = [attachmentFailure, attachmentSuccess]; failureBody.body.text = `${failuresFound} test cases failed, ${SLACK_MENTIONS}`; failureBody.body = JSON.stringify(failureBody.body); - // logger.info('sending failure body') logger.info(failureBody) fetch(SLACK_URL, failureBody); }