build: adding lefthook for hook management

This commit is contained in:
Dylan R. E. Moonfire 2022-04-02 17:17:23 -05:00
parent 8945aa89dc
commit 8ac6b3b514
12 changed files with 41 additions and 66 deletions

1
.gitignore vendored
View file

@ -15,3 +15,4 @@ node_modules/
coverage
TestResults/
tests/artifacts/
.lefthook*

View file

@ -11,7 +11,7 @@
let pkgs = nixpkgs.legacyPackages.${system};
in {
devShell = pkgs.mkShell {
buildInputs = [ pkgs.dotnet-sdk pkgs.nixfmt ];
buildInputs = [ pkgs.dotnet-sdk pkgs.lefthook pkgs.convco pkgs.nixfmt ];
};
});
}

View file

@ -1,34 +1,12 @@
# EXAMPLE USAGE
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/full_guide.md
#
# pre-push:
# commands:
# packages-audit:
# tags: frontend security
# run: yarn audit
# gems-audit:
# tags: backend security
# run: bundle audit
#
# pre-commit:
# parallel: true
# commands:
# eslint:
# glob: "*.{js,ts}"
# run: yarn eslint {staged_files}
# rubocop:
# tags: backend style
# glob: "*.rb"
# exclude: "application.rb|routes.rb"
# run: bundle exec rubocop --force-exclusion {all_files}
# govet:
# tags: backend style
# files: git ls-files -m
# glob: "*.go"
# run: go vet {files}
# scripts:
# "hello.js":
# runner: node
# "any.go":
# runner: go run
pre-push:
parallel: true
commands:
commit-check:
run: convco check -n 30
pre-commit:
parallel: true
commands:
dotnet-format:
glob: "*.cs"
run: dotnet format

View file

@ -1,23 +0,0 @@
{
"name": "mfgames-toolbuilder",
"version": "2.0.1",
"private": true,
"scripts": {
"prepare": "husky install",
"build": "dotnet build",
"test": "dotnet test"
},
"devDependencies": {
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^7.0.4",
"@semantic-release/npm": "^8.0.3",
"commitlint-gitlab-ci": "^0.0.4",
"husky": "^7.0.2",
"semantic-release": "^18.0.1",
"semantic-release-dotnet": "^1.0.0",
"semantic-release-nuget": "^1.1.1"
}
}

8
scripts/format.sh Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env sh
# Normalize our environment.
cd $(dirname $0)/..
./scripts/setup.sh || exit 1
# Format the .NET code
dotnet format || exit 1

View file

@ -2,10 +2,21 @@
cd $(dirname $0)/..
# Make sure we have .NET installed
# Make sure we have .NET installed.
if ! which dotnet >& /dev/null
then
echo "Cannot find 'dotnet' in the path"
exit 1
fi
# Make sure we have lefthook.and it is installed.
if ! which lefthook >& /dev/null
then
echo "Cannot find 'lefthook' in the path"
exit 1
fi
lefthook install
# Everything is good.
exit 0

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Parsing;
using System.Linq;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;

View file

@ -1,4 +1,4 @@
using Autofac;
using Autofac;
using MfGames.ToolBuilder.Services;

View file

@ -17,7 +17,7 @@ namespace SampleTool
{
this.Handler = this;
this.messyOption = new Option<bool>("--messy");
this.AddOption(this.messyOption);
}

View file

@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using Autofac;

View file

@ -1,4 +1,4 @@
using System.CommandLine;
using System.CommandLine;
using Autofac;