Skip to content

Commit eefeb03

Browse files
committed
refactor: repm to devfiles
1 parent de5b6ed commit eefeb03

17 files changed

Lines changed: 162 additions & 82 deletions

.envrc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,46 +60,46 @@ fi
6060

6161

6262
#################
63-
# REPM
63+
# DEVF
6464
# Bin script installation
6565
# The installation is done by cloning the repo to a well-known location.
6666
#################
6767
echo ""
6868
echo "Repo manager: "
69-
export REPM_PREFIX="REPM"
70-
REPM_DIR_VAR_NAME="${REPM_PREFIX}_${ORGANISATION_ENV_NAME}_DIR"
71-
export REPM_DIR
72-
REPM_DIR="${!REPM_DIR_VAR_NAME:-}"
73-
if [ "$REPM_DIR" != "" ]; then
74-
echo " Repo Directory : $REPM_DIR (from var $REPM_DIR_VAR_NAME)"
69+
export DEVF_PREFIX="DEVF"
70+
DEVF_DIR_VAR_NAME="${DEVF_PREFIX}_${ORGANISATION_ENV_NAME}_DIR"
71+
export DEVF_DIR
72+
DEVF_DIR="${!DEVF_DIR_VAR_NAME:-}"
73+
if [ "$DEVF_DIR" != "" ]; then
74+
echo " Repo Directory : $DEVF_DIR (from var $DEVF_DIR_VAR_NAME)"
7575
else
76-
REPM_DIR=$(realpath "$PWD/../repo-manager")
77-
echo " Repo Directory : $REPM_DIR (default)"
76+
DEVF_DIR=$(realpath "$PWD/../devfiles")
77+
echo " Repo Directory : $DEVF_DIR (default)"
7878
fi
79-
if [ ! -d "$REPM_DIR" ]; then
79+
if [ ! -d "$DEVF_DIR" ]; then
8080

81-
repm_echo_yellow "REPM_DIR ($REPM_DIR) does not exist."
82-
REPM_REPO_URI_VAR_NAME="${REPM_PREFIX}_${ORGANISATION_ENV_NAME}_URI"
83-
REPM_REPO_URI="${!REPM_REPO_URI_VAR_NAME:-https://github.com/combostrap/repo-manager}"
84-
repm_echo_yellow "Clone $REPM_REPO_URI to $REPM_DIR? Y(Yes-Default)/N(No)"
81+
repm_echo_yellow "DEVF_DIR ($DEVF_DIR) does not exist."
82+
DEVF_REPO_URI_VAR_NAME="${DEVF_PREFIX}_${ORGANISATION_ENV_NAME}_URI"
83+
DEVF_REPO_URI="${!DEVF_REPO_URI_VAR_NAME:-https://github.com/combostrap/devfiles}"
84+
repm_echo_yellow "Clone $DEVF_REPO_URI to $DEVF_DIR? Y(Yes-Default)/N(No)"
8585
read -r CLONE
8686
if [ "$CLONE" == "" ] || [ "$CLONE" == "Y" ]; then
87-
git clone "$REPM_REPO_URI" "$REPM_DIR"
87+
git clone "$DEVF_REPO_URI" "$DEVF_DIR"
8888
repm_echo_yellow "Repo Manager repo cloned"
8989
fi
9090

9191
fi
9292

9393
# Exit if the repo was not installed
94-
if [ -d "$REPM_DIR" ]; then
94+
if [ -d "$DEVF_DIR" ]; then
9595

9696
#################
9797
# Bin
9898
#################
99-
BIN_PATH="$REPM_DIR/bin"
99+
BIN_PATH="$DEVF_DIR/bin"
100100
export PATH="$BIN_PATH:$PATH" # bin path first as it has a higher priority
101101
echo " Common Scripts Path : $BIN_PATH"
102-
BIN_PACKAGE_MANAGER_PATH="$REPM_DIR/bin/package-manager/none"
102+
BIN_PACKAGE_MANAGER_PATH="$DEVF_DIR/bin/package-manager/none"
103103
export PATH="$BIN_PACKAGE_MANAGER_PATH:$PATH" # bin path first as it has a higher priority
104104
echo " Package Manager Scripts Path : $BIN_PACKAGE_MANAGER_PATH"
105105

@@ -135,7 +135,7 @@ echo ""
135135
echo "Env: "
136136
echo " PROJECT_ROOT : $PROJECT_ROOT"
137137
echo " ORGANISATION_NAME : $ORGANISATION_NAME"
138-
echo " REPM_DIR : $REPM_DIR"
138+
echo " DEVF_DIR : $DEVF_DIR"
139139

140140
# Last EOL before direnv output
141141
echo ""

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
stages: [ commit-msg ]
3636
additional_dependencies: [ '@commitlint/config-conventional' ]
3737
args: [ "--verbose" , "--config", ".config/commitlint.config.js" ]
38-
- repo: https://github.com/combostrap/repo-manager
38+
- repo: https://github.com/combostrap/devfiles
3939
rev: v0.1.0
4040
hooks:
4141
- id: prevent-out-of-sync-commit

README.md

Lines changed: 112 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
# Repo Manager (repm): Dynamic Repository Management
1+
# Combostrap Dev files - development flow
22

33
## About
44

5-
This repository helps to init and update git combostrap repositories.
5+
This repository contains `devfiles`.
66

7-
## Concept / How it works
7+
`dotfiles` configure application files, `devfiles` configure a development flow.
88

9-
It uses the following software to manage common repositories stuff:
9+
With them, you can:
10+
* init a new repo
11+
* update an existing one
12+
and get instantly a consistent development environment across git repositories.
13+
14+
15+
## QuickStart in three commands
16+
17+
```bash
18+
cd your-git-repo
19+
copier copy https://github.com/combostrap/devfiles .
20+
direnv reload
21+
```
22+
23+
For a step by step, see [the detailed steps](#steps)
24+
25+
## How it works
26+
27+
### Core Component
28+
29+
It uses the following core components to manage common repositories stuff:
1030

1131
* [copier](https://copier.readthedocs.io/) for project templating and upgrade
12-
* [direnv](https://direnv.net/) for project setup and environment
13-
* [pre-commit](https://pre-commit.com/) for files check and normalization
14-
* [common scripts](#common-scripts) are made available by cloning this repo and putting them in the `PATH`.
32+
* [direnv](https://direnv.net/) for setup (project and environment)
33+
* [dev scripts](#dev-scripts) for development flow
34+
35+
### Utility components
1536

16-
## Where are the artifacts
37+
The utility components are used in the scripts or as configuration:
1738

18-
* The `copier` template is located at [copier template](copier-template)
19-
* The `pre-commit`
20-
* config is part of the template at [.pre-commit-config.yaml](copier-template/.pre-commit-config.yaml)
21-
* setup is performed with direnv via [.envrc](copier-template/.envrc.jinja)
22-
* extra `git hooks` are available at [git-hooks](git-hooks)
23-
* The common dev scripts are in the [bin](bin)
39+
* [pre-commit](https://pre-commit.com/) for files check and normalization
40+
* [jreleaser](#jreleaser ) for release management
41+
* [pass](#pass---local-secret-management) for secrets management
42+
* [git-cliff](https://git-cliff.org/) for change log and version bump
43+
* [go task](#task-distribution) for common tasks distribution
44+
* [editorconfig](#code-styling-editor-config) for code styling
45+
* [commitlint](#commit-message-validation-commitlint) for commit message validation
46+
* [markdown-link-check](#markdown-link-check) for Markdown link validation
2447

2548
## Steps
2649

@@ -35,15 +58,14 @@ Install:
3558

3659
### Copy or update this copier template
3760

38-
* for a new git repo
61+
* to install the latest `devfiles` in a git repo (empty or not)
3962

4063
```bash
41-
# Optionally
42-
# cd your_repo && git init
43-
copier copy https://github.com/combostrap/repo-manager .
64+
# Optionally cd your_repo && git init
65+
copier copy https://github.com/combostrap/devfiles .
4466
```
4567

46-
* to update a git repo
68+
* to update a git repo with the last `devfiles` version
4769

4870
```bash
4971
copier update .
@@ -55,8 +77,8 @@ The [.envrc](copier-template/.envrc.jinja) file is the main entry for `setup` an
5577

5678
It will:
5779

58-
* install the git hooks with `pre-commit`
59-
* [install the common scripts](#common-scripts)
80+
* install the git hooks with [pre-commit](#git-hooks-and-pre-commit)
81+
* [install the common scripts](#dev-scripts)
6082

6183
If you open your terminal, `direnv` should execute `.envrc`.
6284
If not:
@@ -67,20 +89,61 @@ direnv reload
6789

6890
## Features and configuration
6991

92+
### Copier Template
93+
94+
The `copier` template is located at [copier template](copier-template)
95+
96+
### Pass - Local Secret Management
97+
98+
Pass ([pass](https://www.passwordstore.org/) or [gopass](https://www.gopass.pw/)) is used for secret management.
99+
100+
All secrets are located under the organization name.
101+
102+
Example for a GitHub token:
103+
104+
```bash
105+
pass "$ORGANISATION_PATH_NAME/github/release-token"
106+
```
107+
108+
The secrets are not stored as global shell variables.
109+
We create wrapper scripts so that the secret is only available while running the script.
110+
111+
Example of wrappers:
112+
113+
* [jreleaser](dev-scripts/common/jreleaser)
114+
* [mvnw (maven)](dev-scripts/package-manager/maven/mvnw)
115+
116+
### JReleaser
117+
118+
For release management, we use [jreleaser](https://jreleaser.org/).
119+
120+
We distribute with this template, a [jreleaser](dev-scripts/common/jreleaser) wrapper script
121+
to pass the needed secrets with [pass](#pass---local-secret-management)
122+
70123
### Git User Configuration
71124

72125
To set the git user, you can set in your `.bashrc` the following env:
73126

74127
| Env |
75128
|-----------------------------------------|
76-
| `REPM_${ORGANIZATION_NAME}_EMAIL` |
77-
| `REPM_${ORGANIZATION_NAME}_SIGNING_KEY` |
129+
| `DEVF_${ORGANIZATION_NAME}_EMAIL` |
130+
| `DEVF_${ORGANIZATION_NAME}_SIGNING_KEY` |
131+
132+
See the [Git User Configuration Script](dev-scripts/common/git-config-user)
78133

79-
See the [Git User Configuration Script](bin/git-config-user)
134+
### Code Styling (Editor Config)
80135

81-
### Editor Config for code styling
136+
The [editorconfig](https://editorconfig.org/) file is [.editorconfig](copier-template/.editorconfig)
82137

83-
Install the [root editor config](copier-template/.editorconfig)
138+
### Commit Message Validation (CommitLint)
139+
140+
[commitlint](https://commitlint.js.org/) configuration is located
141+
at [commitlint.config.js](copier-template/.config/commitlint.config.js)
142+
143+
### Markdown Link-Check
144+
145+
[markdown-link-check](https://github.com/tcort/markdown-link-check) for Markdown link validation
146+
configuration is located at [markdown-link-check.config.json](copier-template/.config/markdown-link-check.config.json)
84147

85148
### Copy .gitignore and .gitattributes if not found
86149

@@ -97,20 +160,24 @@ A License is installed
97160
For project only configuration, you can add your own `direnv` scripts in the `PROJECT_ROOT/direnv.d` directory.
98161
All `.sh` files present in this directory will be sourced.
99162

100-
#### Common Scripts
163+
#### Dev Scripts
101164

102-
Common scripts located in the [bin](bin) directory are made available:
165+
Dev scripts located in the [dev-scripts](dev-scripts) directory.
166+
167+
They are made available:
103168

104169
* by cloning this repo
105-
* and put the [bin](bin) in the `PATH`
170+
* and put in the PATH:
171+
* the [common-scripts directory](dev-scripts/common)
172+
* the [package-manager directory](dev-scripts/package-manager)
106173

107174
The code is in the [envrc](copier-template/.envrc.jinja) and can be configured by setting the
108175
following variable in your shell profile, `~/.bashrc`, or `~/.config/direnv/direnvrc`, or `~/.envrc.local`.
109176

110-
| Environment | Default Value | Description |
111-
|---------------------------------|--------------------------------------------|-------------------------------------------------------------------------|
112-
| `REPM_${ORGANIZATION_NAME}_DIR` | `$PROJET_ROOT/../repo-manager` | The local file system location of the resource manager repository clone |
113-
| `REPM_${ORGANIZATION_NAME}_URI` | https://github.com/combostrap/repo-manager | The URI location of the resource manager repository |
177+
| Environment | Default Value | Description |
178+
|---------------------------------|----------------------------------------|-----------------------------------------------------------------|
179+
| `DEVF_${ORGANIZATION_NAME}_DIR` | `$PROJET_ROOT/../devfiles` | The local file system location of the devfiles repository clone |
180+
| `DEVF_${ORGANIZATION_NAME}_URI` | https://github.com/combostrap/devfiles | The URI location of the devfiles repository |
114181

115182
#### Scripts Environment variable
116183

@@ -123,6 +190,14 @@ In your scripts, you can use the following env:
123190
| `ORGANISATION_ENV_NAME` | The organization name in a env format |
124191
| `ORGANISATION_PATH_NAME` | The organization name in a file path format |
125192

193+
### Git Hooks and Pre-commit
194+
195+
The `pre-commit`:
196+
197+
* config is part of the template at [.pre-commit-config.yaml](copier-template/.pre-commit-config.yaml)
198+
* setup is performed with direnv via [.envrc](copier-template/.envrc.jinja)
199+
* extra `git hooks` are available at [git-hooks](git-hooks)
200+
126201
### Prepare your next commit
127202

128203
You can check the files in you next commit with:
@@ -144,3 +219,7 @@ task update
144219
# equivalent to
145220
copier update .
146221
```
222+
223+
### Task Distribution
224+
225+
The [go task](https://github.com/go-task/task) file is [Taskfile.yaml](copier-template/Taskfile.yaml)
File renamed without changes.

copier-template/.envrc.jinja

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,48 +60,49 @@ fi
6060

6161

6262
#################
63-
# REPM
63+
# DEVF
6464
# Bin script installation
6565
# The installation is done by cloning the repo to a well-known location.
6666
#################
6767
echo ""
6868
echo "Repo manager: "
69-
export REPM_PREFIX="REPM"
70-
REPM_DIR_VAR_NAME="${REPM_PREFIX}_${ORGANISATION_ENV_NAME}_DIR"
71-
export REPM_DIR
72-
REPM_DIR="${!REPM_DIR_VAR_NAME:-}"
73-
if [ "$REPM_DIR" != "" ]; then
74-
echo " Repo Directory : $REPM_DIR (from var $REPM_DIR_VAR_NAME)"
69+
export DEVF_PREFIX="DEVF"
70+
DEVF_DIR_VAR_NAME="${DEVF_PREFIX}_${ORGANISATION_ENV_NAME}_DIR"
71+
export DEVF_DIR
72+
DEVF_DIR="${!DEVF_DIR_VAR_NAME:-}"
73+
if [ "$DEVF_DIR" != "" ]; then
74+
echo " Repo Directory : $DEVF_DIR (from var $DEVF_DIR_VAR_NAME)"
7575
else
76-
REPM_DIR=$(realpath "$PWD/../repo-manager")
77-
echo " Repo Directory : $REPM_DIR (default)"
76+
DEVF_DIR=$(realpath "$PWD/../devfiles")
77+
echo " Repo Directory : $DEVF_DIR (default)"
7878
fi
79-
if [ ! -d "$REPM_DIR" ]; then
79+
if [ ! -d "$DEVF_DIR" ]; then
8080

81-
repm_echo_yellow "REPM_DIR ($REPM_DIR) does not exist."
82-
REPM_REPO_URI_VAR_NAME="${REPM_PREFIX}_${ORGANISATION_ENV_NAME}_URI"
83-
REPM_REPO_URI="${!REPM_REPO_URI_VAR_NAME:-https://github.com/combostrap/repo-manager}"
84-
repm_echo_yellow "Clone $REPM_REPO_URI to $REPM_DIR? Y(Yes-Default)/N(No)"
81+
repm_echo_yellow "DEVF_DIR ($DEVF_DIR) does not exist."
82+
DEVF_REPO_URI_VAR_NAME="${DEVF_PREFIX}_${ORGANISATION_ENV_NAME}_URI"
83+
DEVF_REPO_URI="${!DEVF_REPO_URI_VAR_NAME:-https://github.com/combostrap/devfiles}"
84+
repm_echo_yellow "Clone $DEVF_REPO_URI to $DEVF_DIR? Y(Yes-Default)/N(No)"
8585
read -r CLONE
8686
if [ "$CLONE" == "" ] || [ "$CLONE" == "Y" ]; then
87-
git clone "$REPM_REPO_URI" "$REPM_DIR"
87+
git clone "$DEVF_REPO_URI" "$DEVF_DIR"
8888
repm_echo_yellow "Repo Manager repo cloned"
8989
fi
9090

9191
fi
9292

9393
# Exit if the repo was not installed
94-
if [ -d "$REPM_DIR" ]; then
94+
if [ -d "$DEVF_DIR" ]; then
9595

9696
#################
9797
# Bin
9898
#################
99-
BIN_PATH="$REPM_DIR/bin"
100-
export PATH="$BIN_PATH:$PATH" # bin path first as it has a higher priority
101-
echo " Common Scripts Path : $BIN_PATH"
102-
BIN_PACKAGE_MANAGER_PATH="$REPM_DIR/bin/package-manager/{{ package_manager }}"
103-
export PATH="$BIN_PACKAGE_MANAGER_PATH:$PATH" # bin path first as it has a higher priority
104-
echo " Package Manager Scripts Path : $BIN_PACKAGE_MANAGER_PATH"
99+
DEV_SCRIPT_PATH="$DEVF_DIR/dev-scripts"
100+
COMMON_SCRIPT_PATH="$DEV_SCRIPT_PATH/common"
101+
export PATH="$COMMON_SCRIPT_PATH:$PATH" # script path first as it has a higher priority
102+
echo " Common Scripts Path : $COMMON_SCRIPT_PATH"
103+
PACKAGE_MANAGER_PATH="$DEV_SCRIPT_PATH/package-manager/{{ package_manager }}"
104+
export PATH="$PACKAGE_MANAGER_PATH:$PATH" # script path first as it has a higher priority
105+
echo " Package Manager Scripts Path : $PACKAGE_MANAGER_PATH"
105106

106107
echo ""
107108
echo "Git: "
@@ -135,7 +136,7 @@ echo ""
135136
echo "Env: "
136137
echo " PROJECT_ROOT : $PROJECT_ROOT"
137138
echo " ORGANISATION_NAME : $ORGANISATION_NAME"
138-
echo " REPM_DIR : $REPM_DIR"
139+
echo " DEVF_DIR : $DEVF_DIR"
139140

140141
# Last EOL before direnv output
141142
echo ""

copier-template/.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
hooks:
2525
- id: markdown-link-check
2626
name: markdown link check
27-
args: [ --quiet, "--config", ".config/markdown-lint-config.json" ]
27+
args: [ --quiet, "--config", ".config/markdown-link-check.config.json" ]
2828
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
2929
rev: e46582c # v9.23.0
3030
hooks:
@@ -35,7 +35,7 @@ repos:
3535
stages: [ commit-msg ]
3636
additional_dependencies: [ '@commitlint/config-conventional' ]
3737
args: [ "--verbose" , "--config", ".config/commitlint.config.js" ]
38-
- repo: https://github.com/combostrap/repo-manager
38+
- repo: https://github.com/combostrap/devfiles
3939
rev: v0.1.0
4040
hooks:
4141
- id: prevent-out-of-sync-commit

0 commit comments

Comments
 (0)