From bf9e40daddb428eb5a6b054577904da642db109e Mon Sep 17 00:00:00 2001 From: "Dylan R. E. Moonfire" Date: Sat, 2 Apr 2022 17:30:41 -0500 Subject: [PATCH] build: adding some automatic formatting on commits --- .editorconfig | 2 +- .gitlab-ci.yml | 2 +- .prettierignore | 6 ++++++ TASKS.md | 10 +++++----- flake.nix | 10 ++++++++-- lefthook.yml | 22 +++++++++++++--------- scripts/setup.sh | 24 +++++++++++------------- src/GitVersion.yml | 18 ++++++++++-------- 8 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 .prettierignore diff --git a/.editorconfig b/.editorconfig index fc1b7bd..2b7d34d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -103,7 +103,7 @@ tab_width=2 [*.{cs,js,json,jsx,proto,resjson,ts,tsx}] indent_style=space -indent_size=space +indent_size=4 tab_width=4 [*.{asax,ascx,aspx,cshtml,css,htm,html,master,razor,skin,vb,xaml,xamlx,xoml}] diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9d9571..864e18c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ include: - - template: Security/SAST.gitlab-ci.yml + - template: Security/SAST.gitlab-ci.yml stages: - build diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..56c7a40 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +*~ +flake.* + +node_modules/ +.direnv/ +.config/ diff --git a/TASKS.md b/TASKS.md index 00e9c20..f31aaea 100644 --- a/TASKS.md +++ b/TASKS.md @@ -1,5 +1,5 @@ -- [ ] Split out tables into an assembly -- [ ] Switch to GitVersion for release -- [ ] Switch to scripts instead of Node for targets -- [ ] Clean up the Gitlab setup - - [ ] Change configuration back to default +- [ ] Split out tables into an assembly +- [ ] Switch to GitVersion for release +- [ ] Switch to scripts instead of Node for targets +- [ ] Clean up the Gitlab setup + - [ ] Change configuration back to default diff --git a/flake.nix b/flake.nix index 18ce3b0..a112eda 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "A .NET core library for building tools"; + description = "A .NET core library for easily building CLI tools"; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; @@ -11,7 +11,13 @@ let pkgs = nixpkgs.legacyPackages.${system}; in { devShell = pkgs.mkShell { - buildInputs = [ pkgs.dotnet-sdk pkgs.lefthook pkgs.convco pkgs.nixfmt ]; + buildInputs = [ + pkgs.dotnet-sdk + pkgs.lefthook + pkgs.convco + pkgs.nodePackages.prettier + pkgs.nixfmt + ]; }; }); } diff --git a/lefthook.yml b/lefthook.yml index 78ce6de..795ae24 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,12 +1,16 @@ pre-push: - parallel: true - commands: - commit-check: - run: convco check -n 30 + parallel: true + commands: + commit-check: + run: convco check -n 30 pre-commit: - parallel: true - commands: - dotnet-format: - glob: "*.cs" - run: dotnet format + parallel: true + commands: + dotnet-format: + glob: "*.cs" + run: dotnet format + prettier: + run: prettier . --write --loglevel warn + nixfmt: + run: nixfmt flake.nix diff --git a/scripts/setup.sh b/scripts/setup.sh index de738fd..5bbfbf8 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,21 +1,19 @@ #!/usr/bin/env sh +# Normalize our environment. cd $(dirname $0)/.. -# 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 +# Make sure we have the needed executables installed. +for e in dotnet lefthook prettier nixfmt +do + if ! which $e >& /dev/null + then + echo "Cannot find '$e' in the path" + exit 1 + fi +done +# Make sure we have lefthook is installed. lefthook install # Everything is good. diff --git a/src/GitVersion.yml b/src/GitVersion.yml index 5eae0d2..5dc355f 100644 --- a/src/GitVersion.yml +++ b/src/GitVersion.yml @@ -1,11 +1,13 @@ -mode: MainLine -major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)" -minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:" -patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:" -assembly-versioning-scheme: MajorMinorPatch -assembly-file-versioning-scheme: MajorMinorPatch -assembly-informational-format: '{InformationalVersion}' mode: ContinuousDelivery increment: Inherit continuous-delivery-fallback-tag: ci -tag-prefix: '[vV]' + +major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)" +minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:" +patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:" + +assembly-versioning-scheme: MajorMinorPatch +assembly-file-versioning-scheme: MajorMinorPatch +assembly-informational-format: "{InformationalVersion}" + +tag-prefix: "[vV]"