Skip to content

Commit 8362337

Browse files
committed
chore: initial commit
Signed-off-by: Xe Iaso <me@xeiaso.net>
0 parents  commit 8362337

32 files changed

+9885
-0
lines changed

.commitlintrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": [
3+
"@commitlint/config-conventional"
4+
],
5+
"rules": {
6+
"body-max-line-length": [
7+
2,
8+
"always",
9+
99999
10+
],
11+
"footer-max-line-length": [
12+
2,
13+
"always",
14+
99999
15+
],
16+
"signed-off-by": [
17+
2,
18+
"always"
19+
]
20+
}
21+
}

.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ghcr.io/xe/devcontainer-base/pre/go
2+
3+
RUN apt update \
4+
&& apt -y install redis postgresql-client
5+
6+
CMD ["/usr/bin/sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Dev",
3+
"dockerComposeFile": ["./docker-compose.yaml"],
4+
"service": "workspace",
5+
"workspaceFolder": "/workspace/alexandria",
6+
"postStartCommand": "bash ./.devcontainer/poststart.sh",
7+
"initializeCommand": "mkdir -p ${localEnv:HOME}${localEnv:USERPROFILE}/.local/share/atuin",
8+
"features": {
9+
"ghcr.io/devcontainers-extra/features/act:1": {}
10+
},
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"esbenp.prettier-vscode",
15+
"ms-azuretools.vscode-containers",
16+
"golang.go",
17+
"a-h.templ",
18+
"redhat.vscode-yaml",
19+
"ms-vsliveshare.vsliveshare",
20+
"ms-azuretools.vscode-docker",
21+
"dbaeumer.vscode-eslint",
22+
"GitHub.vscode-github-actions",
23+
"jinliming2.vscode-go-template",
24+
"DavidAnson.vscode-markdownlint",
25+
"ms-vscode.wordcount",
26+
"hashicorp.hcl",
27+
"docker.docker",
28+
"fredwangwang.vscode-hcl-format",
29+
"EditorConfig.EditorConfig",
30+
"otovo-oss.htmx-tags"
31+
]
32+
}
33+
}
34+
}

.devcontainer/docker-compose.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
services:
2+
# postgres:
3+
# image: postgres:16
4+
# environment: &postgres-env
5+
# POSTGRES_USER: admin
6+
# POSTGRES_PASSWORD: hunter2
7+
# POSTGRES_DB: project
8+
9+
# PGUSER: admin
10+
# PGPASSWORD: hunter2
11+
# PGDATABASE: project
12+
# PGHOST: postgres
13+
# PGPORT: 5432
14+
# volumes:
15+
# - postgres-data:/var/lib/postgresql/data
16+
17+
# valkey:
18+
# image: valkey/valkey:8
19+
# pull_policy: always
20+
# environment:
21+
# VALKEY_EXTRA_FLAGS: "--save 60 1 --loglevel warning"
22+
# volumes:
23+
# - valkey-data:/data
24+
25+
# VS Code workspace service
26+
workspace:
27+
image: ghcr.io/techarohq/alexandria/devcontainer:latest
28+
build:
29+
context: ..
30+
dockerfile: .devcontainer/Dockerfile
31+
platforms:
32+
- linux/amd64
33+
- linux/arm64
34+
volumes:
35+
- ../:/workspace/alexandria:cached
36+
- node-modules:/workspace/alexandria/node_modules
37+
# entrypoint: ["/usr/bin/sleep", "infinity"]
38+
user: vscode
39+
# environment:
40+
# <<: *postgres-env
41+
# DATABASE_URL: postgresql://admin:hunter2@postgres/project?sslmode=disable
42+
# REDIS_URL: redis://valkey:6379/0
43+
44+
volumes:
45+
# postgres-data:
46+
# valkey-data:
47+
node-modules:

.devcontainer/personalize.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# 1. Determine repo root and name
5+
repo_root="$(git rev-parse --show-toplevel)"
6+
cd "$repo_root"
7+
repo_name="$(basename "$repo_root")"
8+
9+
# 2. Read & normalize remote.origin.url, extract owner & repo
10+
remote_url="$(git config --get remote.origin.url)"
11+
remote_url="${remote_url%.git}" # strip trailing .git if present
12+
13+
if [[ "$remote_url" =~ ^git@([^:]+):([^/]+)/(.+)$ ]]; then
14+
# SSH form: git@domain:owner/repo
15+
domain="${BASH_REMATCH[1]}"
16+
owner="${BASH_REMATCH[2]}"
17+
name_remote="${BASH_REMATCH[3]}"
18+
elif [[ "$remote_url" =~ ^https?://([^/]+)/([^/]+)/(.+)$ ]]; then
19+
# HTTPS form: https://domain/owner/repo
20+
domain="${BASH_REMATCH[1]}"
21+
owner="${BASH_REMATCH[2]}"
22+
name_remote="${BASH_REMATCH[3]}"
23+
else
24+
echo "❌ Error: Unrecognized remote URL: $remote_url" >&2
25+
exit 1
26+
fi
27+
28+
# (Optionally) force domain if you always want github.com:
29+
domain="github.com"
30+
rename_arg="$domain/$owner/$name_remote"
31+
32+
echo "✅ Parsed remote → domain=$domain, owner=$owner, repo=$name_remote"
33+
34+
# 3. Update devcontainer.json
35+
json_file=".devcontainer/devcontainer.json"
36+
if [[ -f "$json_file" ]]; then
37+
tmp="${json_file}.tmp"
38+
jq --arg wf "/workspace/$name_remote" \
39+
'.workspaceFolder = $wf' \
40+
"$json_file" > "$tmp" && mv "$tmp" "$json_file"
41+
echo "✅ Set workspaceFolder to /workspace/$name_remote in $json_file"
42+
else
43+
echo "ℹ️ Skipping: $json_file not found"
44+
fi
45+
46+
# 4. Update docker-compose.yaml volume
47+
dc=".devcontainer/docker-compose.yaml"
48+
if [[ -f "$dc" ]]; then
49+
# match the literal "../:/workspace/<old>:cached"
50+
# capture the prefix "../:/workspace/" as \1 and the suffix ":cached" as \2
51+
sed -i.bak -E \
52+
"s@(\.\./:/workspace/)[^:]+(:cached)@\1$name_remote\2@g" \
53+
"$dc"
54+
rm -f "${dc}.bak"
55+
echo "✅ Volume mapping updated in $dc → ../:/workspace/$name_remote:cached"
56+
else
57+
echo "ℹ️ Skipping: $dc not found"
58+
fi
59+
60+
# 5. Run npm rename
61+
echo "➡️ npm run setup:rename $domain/$owner/$name_remote"
62+
npm run setup:rename "$domain/$owner/$name_remote"
63+
64+
# 6. Patch package.json (name, version, and remove setup:rename)
65+
pkg="package.json"
66+
if [[ -f "$pkg" ]]; then
67+
tmp="${pkg}.tmp"
68+
jq --arg n "@$owner/$name_remote" \
69+
--arg v "0.0.0" \
70+
'.name = $n
71+
| .version = $v
72+
| del(.scripts["setup:rename"])' \
73+
"$pkg" > "$tmp" && mv "$tmp" "$pkg"
74+
echo "✅ package.json → name=\"@$owner/$name_remote\", version=\"0.0.0\", removed scripts.setup:rename"
75+
else
76+
echo "ℹ️ Skipping: $pkg not found"
77+
fi
78+
79+
# 7. Delete CHANGELOG.md
80+
if [[ -f "CHANGELOG.md" ]]; then
81+
rm -f CHANGELOG.md
82+
echo "✅ Deleted CHANGELOG.md"
83+
else
84+
echo "ℹ️ No CHANGELOG.md to delete"
85+
fi
86+
87+
# 8. Edit docker-bake.hcl registry paths
88+
hcl="docker-bake.hcl"
89+
if [[ -f "$hcl" ]]; then
90+
sed -i.bak -E \
91+
-e "s@ghcr\.io/xe/project-template:latest@ghcr.io/$owner/$name_remote@g" \
92+
"$hcl"
93+
rm -f "${hcl}.bak"
94+
echo "✅ Updated registry paths in $hcl to $owner/$name_remote"
95+
else
96+
echo "ℹ️ Skipping: $hcl not found"
97+
fi
98+
99+
# 9. Remove gomvp tool
100+
go get -tool github.com/abenz1267/gomvp@none
101+
102+
# 10. Run formatting
103+
npm run format
104+
105+
echo "✅ You're all set! Commit and push your repo to have CI run on it."
106+
rm .devcontainer/personalize.sh

.devcontainer/poststart.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
sudo chown -R vscode:vscode /workspace/alexandria/node_modules
4+
5+
go mod download &
6+
npm ci &
7+
8+
wait

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
quote_type = double
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
max_line_length = 80

.github/copilot-instructions.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copilot Instructions
2+
3+
When undertaking a task, take a moment to pause and ask the user what the intent of the task is. Use this to write the best code to fix the problem or implement the feature.
4+
5+
## Code formatting
6+
7+
We always write JavaScript with double quotes and two spaces for indentation, so when your responses include JavaScript code, please follow those conventions.
8+
9+
Go code is written in the style of the standard library. When possible, tests are table-driven tests.
10+
11+
All code is formatted with prettier on save, but to run formatting yourself:
12+
13+
```
14+
npm run format
15+
```
16+
17+
## Commit Message Format
18+
19+
Always use conventional commit format for all commit messages. The format should be:
20+
21+
```
22+
<type>[optional scope]: <description>
23+
24+
[optional body]
25+
26+
[optional footer(s)]
27+
```
28+
29+
### Types
30+
31+
- `feat`: A new feature
32+
- `fix`: A bug fix
33+
- `docs`: Documentation only changes
34+
- `style`: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
35+
- `refactor`: A code change that neither fixes a bug nor adds a feature
36+
- `perf`: A code change that improves performance
37+
- `test`: Adding missing tests or correcting existing tests
38+
- `build`: Changes that affect the build system or external dependencies
39+
- `ci`: Changes to our CI configuration files and scripts
40+
- `chore`: Other changes that don't modify src or test files
41+
- `revert`: Reverts a previous commit
42+
43+
### Examples
44+
45+
- `feat: add user authentication`
46+
- `fix: resolve memory leak in data processing`
47+
- `docs: update API documentation`
48+
- `ci: update GitHub Actions workflows`
49+
- `refactor: simplify user service logic`
50+
51+
### Breaking Changes
52+
53+
For breaking changes, add `!` after the type/scope:
54+
55+
- `feat!: change API response format`
56+
- `fix(api)!: remove deprecated endpoint`
57+
58+
Or add `BREAKING CHANGE:` in the footer:
59+
60+
```
61+
feat: add new user service
62+
63+
BREAKING CHANGE: User API now requires authentication tokens
64+
```
65+
66+
### How to commit
67+
68+
When committing, make sure to use double quotes around your commit message, sign off the commit as:
69+
70+
```
71+
Mimi Yasomi <mimi@xeserv.us>
72+
```
73+
74+
Make sure Mimi is the author too.
75+
76+
Write your commit to a temporary file before committing. Be sure to use the printf command because you're in fish.
77+
78+
```
79+
printf "<type>[optional scope]: <description>\n\n[optional body]\n\nSigned-off-by: Mimi Yasomi <mimi@xeserv.us>"
80+
```
81+
82+
## Additional Guidelines
83+
84+
- Keep the description concise and in imperative mood
85+
- Use lowercase for the description
86+
- Do not end the description with a period
87+
- Reference issues and pull requests in the footer when applicable

.github/workflows/commitlint.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Commitlint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
commitlint:
7+
runs-on: ubuntu-latest
8+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
9+
10+
steps:
11+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12+
with:
13+
fetch-depth: 0
14+
15+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
16+
with:
17+
node-version: 22
18+
19+
- name: Install deps
20+
run: npm ci
21+
22+
- name: Validate current commit (last commit) with commitlint
23+
if: github.event_name == 'push'
24+
run: npx --no-install commitlint --last --verbose
25+
26+
- name: Validate PR commits with commitlint
27+
if: github.event_name == 'pull_request'
28+
run: npx --no-install commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

0 commit comments

Comments
 (0)