Skip to content

Commit

Permalink
refactor(core): structure code to standard (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed Sep 17, 2024
1 parent b4891c1 commit 387716e
Show file tree
Hide file tree
Showing 82 changed files with 1,863 additions and 649 deletions.
48 changes: 48 additions & 0 deletions .ci/config/.terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
formatter: "markdown" # this is required
version: ""

header-from: main.tf
footer-from: ""

recursive:
enabled: false
path: modules

sections:
hide: []
show: []

content: ""

output:
file: "docs/include/terraform.md"
mode: replace
template: |-
<!-- markdown-link-check-disable -->
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
<!-- markdown-link-check-enable -->
output-values:
enabled: false
from: ""

sort:
enabled: true
by: name

settings:
anchor: false
color: true
default: true
description: false
escape: true
hide-empty: false
html: true
indent: 2
lockfile: true
read-comments: true
required: true
sensitive: true
type: true
7 changes: 7 additions & 0 deletions .ci/linters/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
warn_list:
- '204' # Lines should be less than 160 characters
- '701' # meta/main.yml should contain relevant info
skip_list:
- '106' # Role name must match ^[a-z][a-z0-9_]+$ pattern
- 'yaml'
- 'role-name'
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions .ci/linters/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
parser: "@typescript-eslint/parser",
env: {
node: true,
es2021: true
},
parserOptions: {
ecmaVersion: 6,
sourceType: "module" // Allows for the use of imports
},
extends: [
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:import/warnings"
],
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/semicolon": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "off",
"no-throw-literal": "warn",
curly: "warn",
eqeqeq: "warn",
semi: "off"
},
ignorePatterns: ["**/*.d.ts"]
}
51 changes: 26 additions & 25 deletions .github/linters/.gitleaks.toml → .ci/linters/.gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,16 @@ title = "gitleaks config"

[[rules]]
description = "Env Var"
regex = '''(?i)(apikey|secret|key|api|password|pass)=[0-9a-zA-Z-_.{}]{4,120}'''
regex = '''(?i)(apikey|secret|key|api|password|pass|pw|host)=[0-9a-zA-Z-_.{}]{4,120}'''
tags = ["env"]
[rules.allowlist]
description = "ignore value fake"
regexes = [
'''host=HOST''',
'''--private-key={{.PRIVATE_KEY_FILE}}''',
'''PASSWORD=XXXXXX''',
]

[[rules]]
description = "Email"
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
tags = ["email"]
[rules.allowlist]
description = "ignore emails"
regexes = [
'''[a-zA-Z0-9._%+-][email protected]''',
'''[a-zA-Z0-9._%+-][email protected]''',
'''[email protected]''',
'''[email protected]''',
'''[email protected]''',
'''[email protected]''',
'''[email protected]''',
'''[email protected]''',
'''[email protected]''',
'''[email protected]''',
'''[email protected]''',
]

[[rules]]
description = "High Entropy"
Expand Down Expand Up @@ -222,19 +205,27 @@ title = "gitleaks config"
description = "Files with keys and credentials"
file = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass)$'''
tags = ["key", "files"]
[rules.allowlist]
description = "ignore some"
files = ['''(.*pub|env)$''']

[[rules]]
description = "Extension Files with keys and credentials"
file = '''(.*?)(pub|pem|ppk|key)$'''
tags = ["key", "files"]
[rules.allowlist]
description = "ignore file test"
files = [
'''.*-test.*$''',
]

# Global allowlist
[allowlist]
description = "Whitelisted files"
paths = [
'''^vendor/''',
'''^bower_components/''',
'''^public/js/bower_components/''',
'''^public/''',
'''^node_modules/''',
'''^theme/''',
]
Expand All @@ -247,18 +238,28 @@ title = "gitleaks config"
'''^sonar-project.properties$''',
'''^node_modules/(.*?)$''',
]
commits = [
'''5530b41269a24a0a680e78f0281eb28ef7cee591''',
]

[whitelist]
description = "image and html allowlists"
paths = [
'''^vendor/''',
'''^bower_components/''',
'''^public/''',
'''^node_modules/''',
'''^theme/''',
]

files = [
'''(.*?)(jpg|gif|png|doc|pdf|bin|mp3|mp4|mov|ttf|woff|woff2|eot|lock)$''',
'''^\.gitignore$''',
'''^\.gitleaks.toml$''',
'''^\.gitignore$''',
'''^yarn.lock$''',
'''^sonar-project.properties$''',
'''^test/fixtures/keys/.*-test.*$''',
]
paths = [
'''^vendor/(.*?)$''',
'''^node_modules/(.*?)$''',
]

commits = []
14 changes: 13 additions & 1 deletion .github/linters/.golangci.yml → .ci/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/luismayta/
local-prefixes: github.com/hadenlabs/

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
Expand Down Expand Up @@ -99,6 +99,7 @@ linters:
- unconvert
- misspell
- nakedret
- unused

presets:
- bugs
Expand All @@ -113,6 +114,17 @@ linters:
- goerr113
- scopelint
- golint
- bodyclose
- contextcheck
- nilerr
- noctx
- rowserrcheck
- sqlclosecheck
- structcheck
- unparam
- deadcode
- varcheck
- asasalint

# Drives todos nuts
- godox
Expand Down
73 changes: 73 additions & 0 deletions .ci/linters/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: base-learn-template
env:
- GO111MODULE=on
- REPO=github.com/luismayta/base-learn-template
before:
hooks:
- go mod download
- go mod tidy
- go mod vendor
- go generate ./...

# https://goreleaser.com/build/
builds:
# Defaults to the project name.
- id: default
# ID of the build.
env:
- CGO_ENABLED=0
ldflags:
- -s -w
- -X "{{.Env.REPO}}/cmd.Version={{.Version}}"
- -X "{{.Env.REPO}}/cmd.Commit={{.FullCommit}}"
- -X "{{.Env.REPO}}/cmd.RepoURL={{.GitURL}}"
- -X "{{.Env.REPO}}/cmd.BuildDate={{.Date}}"
- -X "{{.Env.REPO}}/cmd.BuiltWithGoVersion={{.Env.GO_VERSION}}"
- -X "{{.Env.REPO}}/cmd.BuiltBy={{.Env.BUILT_BY}}"
goos:
- darwin
- linux
goarch:
- amd64
archives:
- replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
builds:
- default
wrap_in_directory: true
name_template: "{{.ProjectName}}-{{.Os}}-{{.Arch}}"
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- README.md
- CHANGELOG.md
- config/**/*
- systemd/*
# https://goreleaser.com/snapshots/
snapshot:
name_template: "dev@{{.ShortCommit}}"

# https://goreleaser.com/checksum/
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
algorithm: sha256
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
github:
owner: hadenlabs
name: base-learn-template
draft: true
prerelease: auto
name_template: "{{.ProjectName}}-v{{.Version}}-{{.ShortCommit}}-{{.Date}}"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const escape = require('shell-quote').quote
const escape = require("shell-quote").quote

module.exports = {
'*.{ts,tsx,js,json,css}': (filenames) => [
"*.{ts,tsx,js,json,css}": (filenames) => [
...filenames.map((filename) => `prettier --check "${escape([filename])}"`),
...filenames.map((filename) => `git add "${filename}"`)
],
'*.{ts,tsx,js,jsx}': ['eslint'],
'*.{ts,tsx,css}': ['stylelint']
"*.{ts,tsx,js,jsx}": ["eslint"],
"*.{ts,tsx,css}": ["stylelint"]
}
10 changes: 9 additions & 1 deletion .github/linters/.prettierignore → .ci/linters/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ coverage
.mypy_cache/
.build
.terraform
.github/linters/.cache/*
.ci/linters/.cache/*
.cache/*
terraform.md
*.tpl.md
*.enc.yaml
vendor
public
staticfiles
out
.vscode-test
.cache
.venv
contrib/
site/
.external_modules
CHANGELOG.md
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions .github/linters/.tflint.hcl → .ci/linters/.tflint.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
plugin "aws" {
enabled = true
version = "0.27.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
rule "terraform_deprecated_index" {
enabled = true
}
Expand Down
7 changes: 7 additions & 0 deletions .ci/linters/.yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
extends: default

rules:
line-length:
max: 200
level: warning
11 changes: 11 additions & 0 deletions .ci/linters/checkov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
download-external-modules: true
evaluate-variables: true
external-modules-download-path: .external_modules
framework:
- all
no-guide: true
output: cli
quiet: true
skip-fixes: true
skip-suppressions: true
soft-fail: true
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
"ignorePatterns": [
{
"pattern": "^https://hadenlabs.com"
},
{
"pattern": "^https://github.com/luismayta/base-learn-template/compare"
}
],
"replacementPatterns": [
{
"pattern": "^/docs",
"replacement": "{{BASEURL}}/docs"
},
{
"pattern": "^/",
"replacement": "{{BASEURL}}/"
}
],
"timeout": "20s",
Expand Down
Loading

0 comments on commit 387716e

Please sign in to comment.