@fatsolutions/ganchos 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ [package]
2
+ name = "fmt_hook"
3
+ version = "0.1.0"
4
+
5
+ [tool.fmt]
6
+ sort-module-level-items = true
7
+ max-line-length = 100
8
+ tab-size = 4
9
+ breaking-behaviour = { tuple = "LineByLine", fixed_array = "SingleBreakPoint", macro_call = "SingleBreakPoint" }
10
+ merge-use-items = true
11
+ allow-duplicate-uses = false
@@ -0,0 +1,7 @@
1
+ export const dependencies = {};
2
+ export const configFiles = [
3
+ "Scarb.fmt.toml",
4
+ ];
5
+ export function getInstallCommand(_deps, _projectRoot) {
6
+ return "echo \"Installed cairo deps\"";
7
+ }
@@ -0,0 +1,10 @@
1
+ export const dependencies: Record<string, string> = {
2
+ };
3
+
4
+ export const configFiles: string[] = [
5
+ "Scarb.fmt.toml",
6
+ ];
7
+
8
+ export function getInstallCommand(_deps: Record<string, string>, _projectRoot: string): string {
9
+ return "echo \"Installed cairo deps\""
10
+ }
@@ -11,7 +11,7 @@ interface FatHooksConfig {
11
11
  version: string;
12
12
  languages: LanguageConfig[];
13
13
  }
14
- declare const SUPPORTED_LANGUAGES: readonly ["javascript", "typescript", "python"];
14
+ declare const SUPPORTED_LANGUAGES: readonly ["javascript", "typescript", "python", "cairo"];
15
15
  type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
16
16
  declare const DEFAULT_CONFIG: FatHooksConfig;
17
17
 
@@ -1,10 +1,11 @@
1
- const SUPPORTED_LANGUAGES = ["javascript", "typescript", "python"];
1
+ const SUPPORTED_LANGUAGES = ["javascript", "typescript", "python", "cairo"];
2
2
  const DEFAULT_CONFIG = {
3
3
  version: "1.0.0",
4
4
  languages: [
5
5
  { name: "javascript", enabled: false },
6
6
  { name: "typescript", enabled: false },
7
- { name: "python", enabled: false }
7
+ { name: "python", enabled: false },
8
+ { name: "cairo", enabled: false }
8
9
  ]
9
10
  };
10
11
  export {
@@ -0,0 +1,71 @@
1
+ # Cairo pre-commit hook
2
+ echo "Running Cairo checks..."
3
+
4
+ SCARB_FMT_MANIFEST="Scarb.fmt.toml"
5
+
6
+ # Check if scarb is installed
7
+ if ! command -v scarb >/dev/null 2>&1; then
8
+ echo "Error: scarb is not installed. Please install it from https://docs.swmansion.com/scarb/"
9
+ exit 1
10
+ fi
11
+
12
+ # Check if there are any Cairo files to check
13
+ CAIRO_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.cairo$' || true)
14
+ if [ -n "$CAIRO_FILES" ]; then
15
+ echo "Checking Cairo files: $CAIRO_FILES"
16
+
17
+ # Get unique package directories from modified files
18
+ PACKAGES=$(echo "$CAIRO_FILES" | grep '^packages/' | cut -d'/' -f1-2 | sort -u || true)
19
+
20
+ # Check if we have root-level Cairo files
21
+ ROOT_CAIRO_FILES=$(echo "$CAIRO_FILES" | grep -v '^packages/' || true)
22
+
23
+ # Run scarb fmt per package directory (if they have Scarb.toml)
24
+ for package_dir in $PACKAGES; do
25
+ PACKAGE_CAIRO_FILES=$(echo "$CAIRO_FILES" | grep "^$package_dir/" || true)
26
+ if [ -n "$PACKAGE_CAIRO_FILES" ]; then
27
+ if [ -f "$package_dir/Scarb.toml" ]; then
28
+ # Get relative paths for files in this package
29
+ RELATIVE_FILES=$(echo "$PACKAGE_CAIRO_FILES" | sed "s|^$package_dir/||")
30
+
31
+ echo " Running scarb fmt in $package_dir..."
32
+ (cd "$package_dir" && echo "$RELATIVE_FILES" | xargs scarb --manifest-path "$SCARB_FMT_MANIFEST" fmt) || {
33
+ echo "scarb fmt failed in $package_dir. Please fix the issues before committing."
34
+ exit 1
35
+ }
36
+
37
+ echo " Running scarb lint in $package_dir..."
38
+ (cd "$package_dir" && scarb lint) || {
39
+ echo "scarb lint failed in $package_dir. Run 'cd $package_dir && scarb lint --fix' to fix lint issues."
40
+ exit 1
41
+ }
42
+ fi
43
+ fi
44
+ done
45
+
46
+ # Run scarb fmt and lint from root for root-level Cairo files (if Scarb.toml exists at root)
47
+ if [ -n "$ROOT_CAIRO_FILES" ] && [ -f "Scarb.toml" ]; then
48
+ echo " Running scarb fmt in root..."
49
+ echo "$ROOT_CAIRO_FILES" | xargs scarb --manifest-path "$SCARB_FMT_MANIFEST" fmt || {
50
+ echo "scarb fmt failed. Please fix the issues before committing."
51
+ exit 1
52
+ }
53
+
54
+ echo " Running scarb lint in root..."
55
+ scarb lint || {
56
+ echo "scarb lint failed. Run 'scarb lint --fix' to fix lint issues."
57
+ exit 1
58
+ }
59
+ fi
60
+
61
+ # Check if files were modified by auto-fix
62
+ MODIFIED=$(echo "$CAIRO_FILES" | xargs git diff --name-only)
63
+ if [ -n "$MODIFIED" ]; then
64
+ echo ""
65
+ echo "The following files were auto-fixed:"
66
+ echo "$MODIFIED" | sed 's/^/ /'
67
+ echo ""
68
+ echo "Please review the changes and commit again."
69
+ exit 1
70
+ fi
71
+ fi
@@ -29,4 +29,15 @@ if [ -n "$JS_FILES" ]; then
29
29
  exit 1
30
30
  }
31
31
  fi
32
+
33
+ # Check if files were modified by auto-fix
34
+ MODIFIED=$(echo "$JS_FILES" | xargs git diff --name-only)
35
+ if [ -n "$MODIFIED" ]; then
36
+ echo ""
37
+ echo "The following files were auto-fixed:"
38
+ echo "$MODIFIED" | sed 's/^/ /'
39
+ echo ""
40
+ echo "Please review the changes and commit again."
41
+ exit 1
42
+ fi
32
43
  fi
@@ -47,4 +47,15 @@ if [ -n "$TS_FILES" ]; then
47
47
  exit 1
48
48
  }
49
49
  fi
50
+
51
+ # Check if files were modified by auto-fix
52
+ MODIFIED=$(echo "$TS_FILES" | xargs git diff --name-only)
53
+ if [ -n "$MODIFIED" ]; then
54
+ echo ""
55
+ echo "The following files were auto-fixed:"
56
+ echo "$MODIFIED" | sed 's/^/ /'
57
+ echo ""
58
+ echo "Please review the changes and commit again."
59
+ exit 1
60
+ fi
50
61
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fatsolutions/ganchos",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Git Hook Manager for Polyglot Monorepos, developed in house by FatSolutions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",