Skip to content

Commit

Permalink
🔧 スクリプトと設定ファイルのリファクタリングおよびドキュメントの更新 (#9)
Browse files Browse the repository at this point in the history
* スクリプトと設定ファイルのリファクタリングおよびドキュメントの更新

* スクリプトと設定ファイルのリファクタリングおよびドキュメントの更新

* Refactor script and configuration files, and update documentation

* Refactor git aliases in bashrc and zshrc

* Refactor git aliases and add new feature branch alias

* Add renovate.json configuration file

* Add auto-assign workflow and configuration files

* Add CODEOWNERS file for global owners and assign @tqer39 as the default owner for all files.

* Add PULL_REQUEST_TEMPLATE.md file

* Add cspell.json configuration file

* Refactor auto-assign workflow configuration

* Add .pre-commit-config.yaml file with pre-commit hooks for code quality checks and formatting

* Add pre-commit workflow for code quality checks and formatting

* Add .textlintrc configuration file for textlint rules

* Add .textlintignore file to ignore certain files and directories for textlint rules

* Refactor pre-commit configuration

* Add support for JSON files in pre-commit hooks

* Add .prettierrc configuration file for code formatting

* Add .prettierignore file to exclude certain directories from code formatting

* Refactor setup documentation and add high-level architecture diagram

* Refactor bashrc and zshrc to use double quotes for file paths

* Refactor setup script to use double quotes for file paths

* Refactor cspell.json to add new words

* Refactor cspell.json to add new words

* Refactor cspell.json to add new words

* Refactor generate_pr_description.py to add warning for breaking changes

* Refactor setup script to fix installation of HackGenNerd Font

* Fix symlink creation in setup script
  • Loading branch information
tqer39 authored Oct 27, 2024
1 parent 7d90a2d commit 94896a5
Show file tree
Hide file tree
Showing 19 changed files with 366 additions and 58 deletions.
4 changes: 3 additions & 1 deletion .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ if [[ $(command -v git) ]]; then
alias gl='git log --oneline'
alias gbm='git branch --merged'
alias gbm-all='git branch --merged|egrep -v "\*|develop|main"|xargs git branch' # -d で削除, -D で完全削除
alias gchp='git cherry-pick'
alias gnewb='git new-feature-branch'
fi

# anyenv
Expand All @@ -206,7 +208,7 @@ fi
if [[ $(command -v brew) ]]; then
if [ "$(brew list | grep -c "^fzf@*.*$")" -gt 0 ]; then
# shellcheck source=/dev/null
[ -f "$HOME/.fzf.bash" ] && . $HOME/.fzf.bash
[ -f "$HOME/.fzf.bash" ] && . "$HOME/.fzf.bash"
fi
fi

Expand Down
2 changes: 2 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
[alias]
new-feature = "!f() { \\\n TITLE=\"$1\"; \\\n DATE=$(date +%Y%m%d); \\\n git checkout main && \\\n git fetch origin -p && \\\n git reset --hard origin/main && \\\n git checkout -b \"feature/${TITLE}-${DATE}\"; \\\n}; f"
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# global owners

* @tqer39
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# About

SSIA
2 changes: 2 additions & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
addAssignees: author
20 changes: 20 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Auto Assign

on:
pull_request:
types: [opened, ready_for_review]

jobs:
add-reviews:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Auto Assign
uses: kentaro-m/[email protected]
if: ${{ github.event.pull_request.assignee == null && join(github.event.pull_request.assignees) == '' }}
with:
configuration-path: .github/auto_assign.yml
24 changes: 24 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: pre-commit

on:
push:
branches:
- main
pull_request:

jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: pre-commit
uses: pre-commit/[email protected]
with:
extra_args: -a --show-diff-on-failure
65 changes: 65 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
# see https://pre-commit.com

exclude: |
(?x)^(
.+/package.*.json
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: ['--maxkb=512']
- id: check-json
- id: check-yaml
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v6.31.0
hooks:
- id: cspell

- repo: local
hooks:
- id: textlint
name: textlint
language: node
types: [file]
files: \.(txt|md|mdown|markdown)$
entry: textlint
require_serial: false
additional_dependencies:
- '[email protected]'
- '[email protected]'
- '[email protected]'
- '[email protected]'
- '[email protected]'
- '[email protected]'

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
hooks:
- id: prettier
name: Format GitHub Actions workflow files
types:
- yaml
- json

- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 36.51.2
hooks:
- id: renovate-config-validator
files: renovate\.json
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/.git/
**/tmp/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2
}
10 changes: 10 additions & 0 deletions .textlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.editorconfig
.git/
.github/
.gitignore
.pre-commit-config.yaml
.textlintcache
.yamllint.yml
cspell.json
renovate.json
tmp/
10 changes: 10 additions & 0 deletions .textlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"filters": {
"comments": true
},
"rules": {
"no-dropping-the-ra": true,
"textlint-rule-ja-no-space-between-full-width": true,
"textlint-rule-no-dropping-the-ra": true
}
}
21 changes: 2 additions & 19 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ is_macos() {
fi
}

# Ubuntuを判定する関数
is_ubuntu() {
if [ -f /etc/os-release ]; then
. /etc/os-release
if [ "$ID" = "ubuntu" ]; then
return 0 # 成功(真)
fi
fi
return 1 # 失敗(偽)
}

# その他のLinuxディストリビューションを判定する関数
is_linux() {
if [ "$(uname)" = "Linux" ]; then
Expand All @@ -77,14 +66,6 @@ is_linux() {
fi
}

# ubuntu なら実行する
if [[ is_ubuntu ]]; then
alias update='sudo apt update && sudo apt upgrade -y'
alias install='sudo apt install'
alias remove='sudo apt remove'
alias search='apt search'
fi

# ------------------------------------------------------------------------------
# \shellcheck
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -172,6 +153,8 @@ if [[ $(command -v git) ]]; then
alias gl='git log --oneline'
alias gbm='git branch --merged'
alias gbm-all='git branch --merged|egrep -v "\*|develop|main"|xargs git branch' # -d で削除, -D で完全削除
alias gchp='git cherry-pick'
alias gnewb='git new-feature-branch'
fi

# anyenv
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@ This repository contains a shell script for provisioning a local development env
curl -sL https://setup.tqer39.dev | bash
```

## High-Level Architecture

1. Acquire the `tqer39.dev` domain on Google Cloud Platform (GCP) Cloud Domains
2. Define the `tqer39.dev` domain in Cloudflare
1. SSL/TLS is automatically issued
2. Issue an NS record and set it in Cloud Domains
3. Add rules to Cloudflare and redirect to `setup` when accessing `https://setup.tqer39.dev/*`
4. When accessing `https://setup.tqer39.dev` with cURL, the `setup.sh` in this repository is loaded as plain text and executed with bash

### Sequence Diagram

```mermaid
sequenceDiagram
participant User
participant Cloudflare
participant CloudDomains
participant GitHub
participant GCP
participant setup.tqer39.dev
participant bash
User->>Cloudflare: https://setup.tqer39.dev
Cloudflare->>Cloudflare: Add rules
Cloudflare->>setup.tqer39.dev: Redirect
setup.tqer39.dev->>GitHub: setup.sh
GitHub->>setup.tqer39.dev: setup.sh
setup.tqer39.dev->>bash: setup.sh
bash->>CloudDomains: Acquire
CloudDomains->>Cloudflare: Define
Cloudflare->>Cloudflare: SSL/TLS
Cloudflare->>Cloudflare: NS record
Cloudflare->>User: Complete
```

## Setup Contents

### Installed Software
Expand Down
91 changes: 91 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"files": [
"**",
".*/**"
],
"ignorePaths": [
".git",
".gitignore"
],
"words": [
"aahl",
"anyenv",
"apdisk",
"autoload",
"automerge",
"awscli",
"checkwinsize",
"chsh",
"Consolas",
"dearmor",
"deskpad",
"difftool",
"dircolors",
"direnv",
"donotpresent",
"dpkg",
"ehthumbs",
"elif",
"encryptable",
"esktop",
"EUID",
"fgrep",
"fseventsd",
"gchp",
"gnewb",
"GOPATH",
"gpso",
"gsts",
"gstt",
"gswc",
"hackgen",
"HACKGEN",
"histappend",
"hyperpower",
"icns",
"ignoredups",
"ignorespace",
"kentaro",
"keymaps",
"Keymaps",
"keyrings",
"lesspipe",
"libcrypt",
"libnotify",
"linuxbrew",
"Lucida",
"Menlo",
"msix",
"nodenv",
"oneline",
"pcra",
"pyenv",
"rxvt",
"SAVEHIST",
"schelp",
"setaf",
"setf",
"setopt",
"shellcheck",
"shellenv",
"shlvl",
"spctl",
"SSIA",
"stackdump",
"statusline",
"textlint",
"textlintcache",
"tfaa",
"tfenv",
"tfsl",
"timemachine",
"tqer",
"vdir",
"xclip",
"xsel",
"ZDHARMA",
"zinit",
"Zinit's"
]
}
35 changes: 35 additions & 0 deletions docs/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,41 @@
curl -sL https://setup.tqer39.dev | bash
```

## ハイレベルアーキテクチャ

1. Google Cloud Platform (GCP) の Cloud Domains で `tqer39.dev` のドメインを取得
2. Cloudflare で tqer39.dev のドメインを定義
1. SSL/TLS が自動的に発行される
2. NS レコードを発行して Cloud Domains に設定
3. Cloudflare のルールを追加し、`https://setup.tqer39.dev/*` へアクセスすると `setup` へリダイレクトさせる
4. cURL で `https://setup.tqer39.dev` へアクセスすると、このリポジトリの `setup.sh` プレーンテキストで読み込まれ、bash で実行される

### シーケンス図

```mermaid
sequenceDiagram
participant User
participant Cloudflare
participant CloudDomains
participant GitHub
participant GCP
participant setup.tqer39.dev
participant bash
User->>Cloudflare: https://setup.tqer39.dev
Cloudflare->>Cloudflare: ルール追加
Cloudflare->>setup.tqer39.dev: リダイレクト
setup.tqer39.dev->>GitHub: setup.sh
GitHub->>setup.tqer39.dev: setup.sh
setup.tqer39.dev->>bash: setup.sh
bash->>CloudDomains: 取得
CloudDomains->>Cloudflare: 定義
Cloudflare->>Cloudflare: SSL/TLS
Cloudflare->>Cloudflare: NS レコード
Cloudflare->>User: 完了
```


## セットアップ内容

### インストールされるソフトウェア
Expand Down
Loading

0 comments on commit 94896a5

Please sign in to comment.