make: cleaning up targets and add pre-commit hooks
This commit is contained in:
parent
6df1d14049
commit
b35027d34a
9
Makefile
9
Makefile
@ -1,9 +1,14 @@
|
|||||||
.PHONY: check
|
.PHONY: check
|
||||||
check:
|
check:
|
||||||
|
@yarn install --prefer-offline
|
||||||
@./bin/setup
|
@./bin/setup
|
||||||
|
|
||||||
|
.PHONY: setup
|
||||||
|
setup: .git/hooks/pre-commit
|
||||||
|
@cp bin/pre-commit.hook .git/hooks/pre-commit
|
||||||
|
|
||||||
SUBDIRS := $(shell find -maxdepth 2 -mindepth 2 -name 'Makefile' -printf '%h/.\n')
|
SUBDIRS := $(shell find -maxdepth 2 -mindepth 2 -name 'Makefile' -printf '%h/.\n')
|
||||||
TARGETS := clean install test # whatever else, but must not contain '/'
|
TARGETS := install clean test lint # whatever else, but must not contain '/'
|
||||||
|
|
||||||
# foo/.all bar/.all foo/.clean bar/.clean
|
# foo/.all bar/.all foo/.clean bar/.clean
|
||||||
SUBDIRS_TARGETS := \
|
SUBDIRS_TARGETS := \
|
||||||
@ -21,4 +26,4 @@ $(TARGETS): %: $(addsuffix %,$(SUBDIRS))
|
|||||||
# $(@F) is .all, with leading period
|
# $(@F) is .all, with leading period
|
||||||
# $(@F:.%=%) is just all
|
# $(@F:.%=%) is just all
|
||||||
$(SUBDIRS_TARGETS):
|
$(SUBDIRS_TARGETS):
|
||||||
$(MAKE) -C $(@D) $(@F:.%=%)
|
$(MAKE) --no-print-directory -C $(@D) $(@F:.%=%)
|
||||||
|
16
bin/deploy
16
bin/deploy
@ -6,20 +6,26 @@
|
|||||||
#
|
#
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
INCLUDE=$(dirname $(readlink -f $0))
|
# Beware of CDPATH gotchas causing cd not to work correctly when a user
|
||||||
. $INCLUDE/setup_tools
|
# has set this in their environment
|
||||||
|
# https://bosker.wordpress.com/2012/02/12/bash-scripters-beware-of-the-cdpath/
|
||||||
|
unset CDPATH
|
||||||
|
|
||||||
|
readonly INCLUDE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
# shellcheck source=bin/setup-tools
|
||||||
|
. "${INCLUDE}"/setup-tools
|
||||||
|
|
||||||
echo ">> Logging into $_DOCKER_REGISTRY"
|
echo ">> Logging into $_DOCKER_REGISTRY"
|
||||||
docker login -e="." -u="$_DOCKER_LOGIN_USERNAME" -p="$_DOCKER_LOGIN_PASSWORD" $_DOCKER_REGISTRY
|
docker login -e="." -u="$_DOCKER_LOGIN_USERNAME" -p="$_DOCKER_LOGIN_PASSWORD" "$_DOCKER_REGISTRY"
|
||||||
echo ">> Installing captain"
|
echo ">> Installing captain"
|
||||||
curl -sSL https://raw.githubusercontent.com/tomgco/captain/master/install.sh | bash
|
curl -sSL https://raw.githubusercontent.com/tomgco/captain/master/install.sh | bash
|
||||||
export PATH=$HOME/.captain/bin:$PATH
|
export PATH=$HOME/.captain/bin:$PATH
|
||||||
|
|
||||||
git stash -u
|
git stash -u
|
||||||
echo ">> running captain build"
|
echo ">> running captain build"
|
||||||
captain build -N $_DOCKER_REGISTRY/yldio/joyent-dashboard-
|
captain build -N "$_DOCKER_REGISTRY/yldio/joyent-dashboard-"
|
||||||
echo ">> running captain push"
|
echo ">> running captain push"
|
||||||
captain push -N $_DOCKER_REGISTRY/yldio/joyent-dashboard-
|
captain push -N "$_DOCKER_REGISTRY/yldio/joyent-dashboard-"
|
||||||
git stash apply
|
git stash apply
|
||||||
|
|
||||||
|
|
||||||
|
60
bin/pre-commit.hook
Executable file
60
bin/pre-commit.hook
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Prelude - make bash behave sanely
|
||||||
|
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Make pushd & popd silent
|
||||||
|
pushd () {
|
||||||
|
command pushd "$@" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
popd () {
|
||||||
|
command popd "$@" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
export EXIT_CODE=0
|
||||||
|
|
||||||
|
|
||||||
|
function lint_changed() {
|
||||||
|
# Allow lint to be ran from outside of the root directory
|
||||||
|
local git_root
|
||||||
|
git_root=$(git rev-parse --show-cdup)
|
||||||
|
git_root=${git_root:-./}
|
||||||
|
|
||||||
|
local subdirs
|
||||||
|
subdirs=$(find "$git_root" -maxdepth 2 -mindepth 2 -name 'Makefile' -printf '%h\n')
|
||||||
|
|
||||||
|
|
||||||
|
for directory in $subdirs
|
||||||
|
do
|
||||||
|
pushd "$directory"
|
||||||
|
|
||||||
|
local npm_bin="node_modules/.bin"
|
||||||
|
local eslint="$npm_bin/eslint"
|
||||||
|
|
||||||
|
function lint() {
|
||||||
|
local to_lint
|
||||||
|
to_lint=$(git diff --staged --diff-filter=ACMTUXB --name-only -- '*.j'{s,sx})
|
||||||
|
echo $to_lint
|
||||||
|
echo $eslint
|
||||||
|
|
||||||
|
if [ "$to_lint" ]; then
|
||||||
|
$eslint "$to_lint" -c ".eslintrc" || EXIT_CODE=$?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
lint
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
lint_changed
|
||||||
|
if [[ "$EXIT_CODE" -gt "0" ]]; then
|
||||||
|
exit $EXIT_CODE
|
||||||
|
fi
|
||||||
|
make test
|
||||||
|
|
||||||
|
echo "⚡️ changed files pass eslint! ⚡️"
|
@ -11,7 +11,8 @@ IFS=$'\n\t'
|
|||||||
unset CDPATH
|
unset CDPATH
|
||||||
|
|
||||||
readonly INCLUDE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
readonly INCLUDE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
. "${INCLUDE}"/setup_tools
|
# shellcheck source=bin/setup-tools
|
||||||
|
. "${INCLUDE}"/setup-tools
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main
|
# Main
|
||||||
|
@ -17,3 +17,7 @@ test:
|
|||||||
.PHONY: start
|
.PHONY: start
|
||||||
start:
|
start:
|
||||||
npm run start
|
npm run start
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint:
|
||||||
|
@$(shell npm bin)/eslint src
|
||||||
|
@ -5,7 +5,7 @@ const bunyan = require('bunyan');
|
|||||||
const pkg = require('../../package.json');
|
const pkg = require('../../package.json');
|
||||||
|
|
||||||
var log = bunyan.createLogger({
|
var log = bunyan.createLogger({
|
||||||
name: pkg.name,
|
name: pkg.name
|
||||||
});
|
});
|
||||||
|
|
||||||
var client = cloudapi.createClient({
|
var client = cloudapi.createClient({
|
||||||
|
@ -5,4 +5,4 @@ module.exports = graphqlHTTP(() => ({
|
|||||||
schema: schema,
|
schema: schema,
|
||||||
graphiql: true,
|
graphiql: true,
|
||||||
pretty: true
|
pretty: true
|
||||||
}));
|
}));
|
||||||
|
@ -77,15 +77,15 @@ module.exports = new GraphQLObjectType({
|
|||||||
description: {
|
description: {
|
||||||
type: GraphQLString,
|
type: GraphQLString,
|
||||||
description: 'Human-readable description for the rule'
|
description: 'Human-readable description for the rule'
|
||||||
|
},
|
||||||
|
machines: {
|
||||||
|
type: new GraphQLList(MachineType),
|
||||||
|
description: 'Lists all instances a firewall rule is applied to',
|
||||||
|
resolve: (root) => {
|
||||||
|
return api.firewallRules.listMachines({
|
||||||
|
id: root.id
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// machines: {
|
|
||||||
// type: new GraphQLList(MachineType),
|
|
||||||
// description: 'Lists all instances a firewall rule is applied to',
|
|
||||||
// resolve: (root) => {
|
|
||||||
// return api.firewallRules.listMachines({
|
|
||||||
// id: root.id
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -21,3 +21,7 @@ compile: install
|
|||||||
.PHONY: start
|
.PHONY: start
|
||||||
start:
|
start:
|
||||||
npm run production
|
npm run production
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint:
|
||||||
|
@$(shell npm bin)/eslint src
|
||||||
|
24
package.json
Normal file
24
package.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "joyent-dashboard",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "## Project Management",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "make test",
|
||||||
|
"precommit": "make -j4 lint",
|
||||||
|
"prepush": "make test"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/yldio/joyent-dashboard.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/yldio/joyent-dashboard/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/yldio/joyent-dashboard#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"husky": "^0.11.9"
|
||||||
|
}
|
||||||
|
}
|
@ -13,3 +13,7 @@ install-production:
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
@rm -rf node_modules
|
@rm -rf node_modules
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint:
|
||||||
|
@$(shell npm bin)/eslint src
|
||||||
|
@ -38,7 +38,7 @@ const getClasses = (props) => {
|
|||||||
|
|
||||||
const bps = (() => {
|
const bps = (() => {
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
return breakpoints
|
return breakpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
|
56
ui/yarn.lock
56
ui/yarn.lock
@ -2198,34 +2198,7 @@ escope@^3.6.0:
|
|||||||
esrecurse "^4.1.0"
|
esrecurse "^4.1.0"
|
||||||
estraverse "^4.1.1"
|
estraverse "^4.1.1"
|
||||||
|
|
||||||
eslint-config-semistandard@^7.0.0:
|
eslint:
|
||||||
version "7.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/eslint-config-semistandard/-/eslint-config-semistandard-7.0.0.tgz#f803493f56a5172f7f59c35ae648360b41f2ff71"
|
|
||||||
|
|
||||||
eslint-config-standard@^6.2.0:
|
|
||||||
version "6.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-6.2.0.tgz#1d2384ee074de6f6b6c0f2bbe976863032565aee"
|
|
||||||
|
|
||||||
eslint-plugin-babel@^3.3.0:
|
|
||||||
version "3.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-3.3.0.tgz#2f494aedcf6f4aa4e75b9155980837bc1fbde193"
|
|
||||||
|
|
||||||
eslint-plugin-promise@^3.3.0:
|
|
||||||
version "3.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.3.0.tgz#20a1ef58b4243ffdaef82ee9360a02353a7cca89"
|
|
||||||
|
|
||||||
eslint-plugin-react@^6.4.1:
|
|
||||||
version "6.4.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.4.1.tgz#7d1aade747db15892f71eee1fea4addf97bcfa2b"
|
|
||||||
dependencies:
|
|
||||||
doctrine "^1.2.2"
|
|
||||||
jsx-ast-utils "^1.3.1"
|
|
||||||
|
|
||||||
eslint-plugin-standard@^2.0.1:
|
|
||||||
version "2.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-2.0.1.tgz#3589699ff9c917f2c25f76a916687f641c369ff3"
|
|
||||||
|
|
||||||
eslint@^3.8.1:
|
|
||||||
version "3.8.1"
|
version "3.8.1"
|
||||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.8.1.tgz#7d02db44cd5aaf4fa7aa489e1f083baa454342ba"
|
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.8.1.tgz#7d02db44cd5aaf4fa7aa489e1f083baa454342ba"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -2263,6 +2236,33 @@ eslint@^3.8.1:
|
|||||||
text-table "~0.2.0"
|
text-table "~0.2.0"
|
||||||
user-home "^2.0.0"
|
user-home "^2.0.0"
|
||||||
|
|
||||||
|
eslint-config-semistandard@^7.0.0:
|
||||||
|
version "7.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-config-semistandard/-/eslint-config-semistandard-7.0.0.tgz#f803493f56a5172f7f59c35ae648360b41f2ff71"
|
||||||
|
|
||||||
|
eslint-config-standard@^6.2.0:
|
||||||
|
version "6.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-6.2.0.tgz#1d2384ee074de6f6b6c0f2bbe976863032565aee"
|
||||||
|
|
||||||
|
eslint-plugin-babel@^3.3.0:
|
||||||
|
version "3.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-3.3.0.tgz#2f494aedcf6f4aa4e75b9155980837bc1fbde193"
|
||||||
|
|
||||||
|
eslint-plugin-promise@^3.3.0:
|
||||||
|
version "3.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.3.0.tgz#20a1ef58b4243ffdaef82ee9360a02353a7cca89"
|
||||||
|
|
||||||
|
eslint-plugin-react@^6.4.1:
|
||||||
|
version "6.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.4.1.tgz#7d1aade747db15892f71eee1fea4addf97bcfa2b"
|
||||||
|
dependencies:
|
||||||
|
doctrine "^1.2.2"
|
||||||
|
jsx-ast-utils "^1.3.1"
|
||||||
|
|
||||||
|
eslint-plugin-standard@^2.0.1:
|
||||||
|
version "2.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-2.0.1.tgz#3589699ff9c917f2c25f76a916687f641c369ff3"
|
||||||
|
|
||||||
espower-location-detector@^0.1.1:
|
espower-location-detector@^0.1.1:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/espower-location-detector/-/espower-location-detector-0.1.2.tgz#d43be738af3e0b18197eeb5c22b95512dee6b83c"
|
resolved "https://registry.yarnpkg.com/espower-location-detector/-/espower-location-detector-0.1.2.tgz#d43be738af3e0b18197eeb5c22b95512dee6b83c"
|
||||||
|
23
yarn.lock
Normal file
23
yarn.lock
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
ci-info@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534"
|
||||||
|
|
||||||
|
husky:
|
||||||
|
version "0.11.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/husky/-/husky-0.11.9.tgz#28cd1dc16bffdca1d4d93592814e5f3c327b38ee"
|
||||||
|
dependencies:
|
||||||
|
is-ci "^1.0.9"
|
||||||
|
normalize-path "^1.0.0"
|
||||||
|
|
||||||
|
is-ci@^1.0.9:
|
||||||
|
version "1.0.10"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e"
|
||||||
|
dependencies:
|
||||||
|
ci-info "^1.0.0"
|
||||||
|
|
||||||
|
normalize-path@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user