Skip to content

Commit a817780

Browse files
chore: init repo with pre-commit hooks, secret masking, auto compile checks
1 parent d99818d commit a817780

24 files changed

Lines changed: 4075 additions & 245 deletions

.env

Lines changed: 0 additions & 20 deletions
This file was deleted.

.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# .env.example -- copy to .env and fill in real values
2+
# NEVER commit .env to git
3+
4+
FIREBASE_API_KEY=******
5+
FIREBASE_AUTH_DOMAIN=******
6+
FIREBASE_PROJECT_ID=******
7+
FIREBASE_STORAGE_BUCKET=******
8+
FIREBASE_MESSAGING_SENDER_ID=******
9+
FIREBASE_APP_ID=******
10+
FIREBASE_MEASUREMENT_ID=******
11+
12+
API_KEY=******
13+
SECRET_KEY=******
14+
DATABASE_URL=******
15+
JWT_SECRET=******
16+
ACCESS_TOKEN=******
17+
REFRESH_TOKEN=******

.github/workflows/ci.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,59 @@
1-
name: CI
1+
name: CI -- Lint, Compile and Secret Check
22

33
on:
44
push:
5-
branches: [ 'main', 'dev' ]
5+
branches: ["main", "dev"]
66
pull_request:
77

88
jobs:
9-
lint_and_check:
9+
lint_compile_check:
1010
runs-on: ubuntu-latest
1111

1212
steps:
1313
- uses: actions/checkout@v4
1414

15-
# Install Python
1615
- name: Set up Python
1716
uses: actions/setup-python@v4
1817
with:
19-
python-version: '3.11'
18+
python-version: "3.11"
2019

21-
- name: Install pre-commit and flake8
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "20"
24+
25+
- name: Set up Java
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: "17"
29+
distribution: "temurin"
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: "1.21"
35+
36+
- name: Install Python tools
2237
run: |
2338
python -m pip install --upgrade pip
2439
pip install pre-commit flake8
2540
26-
# Run pre-commit hooks on all files (any folder, any language)
27-
- name: Run pre-commit hooks
41+
- name: Install Node tools
42+
run: npm install -g @babel/parser
43+
44+
- name: Run all pre-commit hooks
2845
run: pre-commit run --all-files
46+
47+
- name: Check for raw secrets in source
48+
run: |
49+
if grep -rE \
50+
"(API_KEY|SECRET_KEY|PRIVATE_KEY|PASSWORD|AUTH_TOKEN)=[^*[:space:]]+" \
51+
--include="*.js" --include="*.ts" \
52+
--include="*.jsx" --include="*.tsx" \
53+
--include="*.py" --include="*.java" --include="*.go" \
54+
--exclude-dir=node_modules --exclude-dir=.git .; then
55+
echo "[FAIL] Raw secrets detected!"
56+
exit 1
57+
else
58+
echo "[OK] No raw secrets found."
59+
fi

.gitignore

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,64 @@ __pycache__/
66
.env/
77
venv/
88
env/
9+
*.egg-info/
10+
dist/
11+
build/
912

10-
# Node
13+
# Node / JS / TS
1114
node_modules/
15+
dist/
16+
.next/
17+
.nuxt/
18+
*.tsbuildinfo
1219

13-
# IDE/editor
20+
# Java / Kotlin
21+
*.class
22+
*.jar
23+
*.war
24+
target/
25+
.gradle/
26+
27+
# C / C++
28+
*.o
29+
*.out
30+
*.a
31+
*.so
32+
*.exe
33+
34+
# Go
35+
vendor/
36+
37+
# Rust
38+
target/
39+
40+
# Ruby
41+
.bundle/
42+
vendor/bundle/
43+
44+
# Dart / Flutter
45+
.dart_tool/
46+
.flutter-plugins
47+
48+
# IDE
1449
.vscode/
50+
.idea/
1551
*.swp
1652
.DS_Store
1753

1854
# Logs
1955
*.log
2056

2157
# Secrets
58+
.env
59+
.env.local
60+
.env.production
61+
.env.development
62+
.env.staging
63+
google-services.json
64+
GoogleService-Info.plist
2265
*.secret
66+
*.pem
67+
*.key
68+
*.p12
69+
*.keystore

.pre-commit-config.yaml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,63 @@
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- id: check-added-large-files
8+
args: ["--maxkb=1000"]
89
- id: check-yaml
910
- id: check-json
11+
- id: check-merge-conflict
12+
- id: detect-private-key
13+
- id: no-commit-to-branch
14+
args: ["--branch", "production"]
1015

1116
- repo: https://github.com/pycqa/flake8
1217
rev: 7.0.0
1318
hooks:
1419
- id: flake8
15-
additional_dependencies: [flake8]
16-
args: ['--max-line-length=100']
17-
files: \.py$ # <-- check all Python files globally
20+
args: ["--max-line-length=100"]
21+
files: \.py$
1822
exclude: ^(venv|env|\.git)/
1923

2024
- repo: https://github.com/codespell-project/codespell
2125
rev: v2.2.2
2226
hooks:
2327
- id: codespell
28+
exclude: ^(package-lock\.json|yarn\.lock|\.expo/)
29+
args: ["--skip=*.lock,*.min.js,*.json"]
2430

2531
- repo: local
2632
hooks:
27-
- id: mask-env
28-
name: Mask secrets in all files
33+
- id: mask-secrets
34+
name: Mask secrets in staged files
2935
entry: python scripts/mask_keys.py
3036
language: system
37+
pass_filenames: true
3138
types: [text]
39+
exclude: >-
40+
(?x)^(
41+
scripts/mask_keys\.py|
42+
\.pre-commit-config\.yaml|
43+
.*\.lock|.*\.png|.*\.jpg|
44+
.*\.svg|.*\.exe|.*\.bin
45+
)$
46+
47+
- id: compile-check
48+
name: Syntax and compile check (auto language detection)
49+
entry: python scripts/compile_check.py
50+
language: system
51+
pass_filenames: true
52+
types: [text]
53+
exclude: >-
54+
(?x)^(
55+
.*\.lock|.*\.md|.*\.txt|
56+
.*\.png|.*\.jpg|.*\.svg|
57+
.*\.json|.*\.yaml|.*\.yml|
58+
.*\.env.*|.*\.gitignore|
59+
.*\.css|.*\.scss|.*\.html
60+
)$
3261
3362
- id: check-requirements
3463
name: Check requirements file syntax
3564
entry: python scripts/check_requirements.py
3665
language: system
37-
types: [file]
66+
pass_filenames: false
3867
files: ^requirements\.txt$

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# React + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## React Compiler
11+
12+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13+
14+
## Expanding the ESLint configuration
15+
16+
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.

backend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit f11e966771919af066563f8f394497e72ab78775

eslint.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import { defineConfig, globalIgnores } from 'eslint/config'
6+
7+
export default defineConfig([
8+
globalIgnores(['dist']),
9+
{
10+
files: ['**/*.{js,jsx}'],
11+
extends: [
12+
js.configs.recommended,
13+
reactHooks.configs.flat.recommended,
14+
reactRefresh.configs.vite,
15+
],
16+
languageOptions: {
17+
ecmaVersion: 2020,
18+
globals: globals.browser,
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
ecmaFeatures: { jsx: true },
22+
sourceType: 'module',
23+
},
24+
},
25+
rules: {
26+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
27+
},
28+
},
29+
])

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>plantguard</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

modules/test.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)