Add dev tooling to use precious

This commit is contained in:
Dave Rolsky 2023-03-05 15:15:31 -06:00
parent aa7ccd3cba
commit b34ced72c6
No known key found for this signature in database
5 changed files with 115 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/node_modules
/package-lock.json
/package.json
.\#*
\#*\#

43
dev/bin/install-dev-tools.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
set -eo pipefail
function run () {
echo $1
eval $1
}
function install_tools () {
curl --silent --location \
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
sh
run "rustup component add clippy"
run "ubi --project houseabsolute/precious --in ~/bin"
run "npm install prettier"
}
if [ "$1" == "-v" ]; then
set -x
fi
mkdir -p $HOME/bin
set +e
echo ":$PATH:" | grep --extended-regexp ":$HOME/bin:" >& /dev/null
if [ "$?" -eq "0" ]; then
path_has_home_bin=1
fi
set -e
if [ -z "$path_has_home_bin" ]; then
PATH=$HOME/bin:$PATH
fi
install_tools
echo "Tools were installed into $HOME/bin."
if [ -z "$path_has_home_bin" ]; then
echo "You should add $HOME/bin to your PATH."
fi
exit 0

15
git/hooks/pre-commit.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
status=0
PRECIOUS=$(which precious)
if [[ -z $PRECIOUS ]]; then
PRECIOUS=./bin/precious
fi
"$PRECIOUS" lint -s
if (( $? != 0 )); then
status+=1
fi
exit $status

26
git/setup.pl Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Cwd qw( abs_path );
symlink_hook('pre-commit');
sub symlink_hook {
my $hook = shift;
my $dot = ".git/hooks/$hook";
my $file = "git/hooks/$hook.sh";
my $link = "../../$file";
if ( -e $dot ) {
if ( -l $dot ) {
return if readlink $dot eq $link;
}
warn "You already have a hook at $dot!\n";
return;
}
symlink $link, $dot;
}

26
precious.toml Normal file
View File

@ -0,0 +1,26 @@
exclude = [
"target",
]
[commands.prettier]
type = "both"
include = [ "**/*.md", "**/*.yml" ]
cmd = [ "./node_modules/.bin/prettier", "--no-config" ]
lint_flags = "--check"
tidy_flags = "--write"
ok_exit_codes = 0
lint_failure_exit_codes = 1
ignore_stderr = [ "Code style issues" ]
[commands.omegasort-gitignore]
type = "both"
include = "**/.gitignore"
cmd = [ "omegasort", "--sort", "path", "--unique" ]
lint_flags = "--check"
tidy_flags = "--in-place"
ok_exit_codes = 0
lint_failure_exit_codes = 1
ignore_stderr = [
"The .+ file is not sorted",
"The .+ file is not unique",
]