template / files / IMPROVEMENTS.md
IMPROVEMENTS.md
6e0dbce3 2026-05-01 Pavel Safronov | 1 | # Improvement Plan |
| 2 | ||
| 3 | Ordered roughly by effort, lowest first. Each section lists the concrete changes needed. | |
| 4 | ||
| 5 | --- | |
| 6 | ||
37160b89 2026-05-01 Pavel Safronov | 7 | ## ✅ 1. Drop `golang.org/x/exp` dependency |
6e0dbce3 2026-05-01 Pavel Safronov | 8 | |
37160b89 2026-05-01 Pavel Safronov | 9 | Replaced `golang.org/x/exp/slices` with the stdlib `slices` package in |
| 10 | [config.go](internal/core/config.go), [profile.go](internal/core/profile.go), and | |
| 11 | [name_pattern_test.go](internal/core/name_pattern_test.go). Removed the dependency | |
| 12 | from [go.mod](go.mod) via `go mod tidy`. | |
6e0dbce3 2026-05-01 Pavel Safronov | 13 | |
| 14 | --- | |
| 15 | ||
37160b89 2026-05-01 Pavel Safronov | 16 | ## ✅ 2. Upgrade Go version |
6e0dbce3 2026-05-01 Pavel Safronov | 17 | |
37160b89 2026-05-01 Pavel Safronov | 18 | [go.mod](go.mod) now declares `go 1.25.0`, driven by the project's actual transitive |
| 19 | deps. The GitLab CI image (`golang:1.25`) is aligned. | |
6e0dbce3 2026-05-01 Pavel Safronov | 20 | |
| 21 | --- | |
| 22 | ||
37160b89 2026-05-01 Pavel Safronov | 23 | ## ✅ 3. Reorganize source files into a nested directory |
6e0dbce3 2026-05-01 Pavel Safronov | 24 | |
37160b89 2026-05-01 Pavel Safronov | 25 | All source files moved out of the repo root into: |
6e0dbce3 2026-05-01 Pavel Safronov | 26 | |
| 27 | ```text | |
| 28 | cmd/ | |
| 29 | template/ | |
37160b89 2026-05-01 Pavel Safronov | 30 | main.go ← 14-line entry point; sets Version, calls core.Run() |
6e0dbce3 2026-05-01 Pavel Safronov | 31 | internal/ |
37160b89 2026-05-01 Pavel Safronov | 32 | core/ |
| 33 | app.go ← CLI wiring + all orchestration logic | |
6e0dbce3 2026-05-01 Pavel Safronov | 34 | config.go |
37160b89 2026-05-01 Pavel Safronov | 35 | profile.go |
| 36 | ... (all other files) | |
6e0dbce3 2026-05-01 Pavel Safronov | 37 | ``` |
| 38 | ||
37160b89 2026-05-01 Pavel Safronov | 39 | [Makefile](Makefile) build and install targets updated to `./cmd/template/`. |
| 40 | [.goreleaser.yaml](.goreleaser.yaml) updated with `main: ./cmd/template/`. | |
6e0dbce3 2026-05-01 Pavel Safronov | 41 | |
37160b89 2026-05-01 Pavel Safronov | 42 | --- |
| 43 | ||
| 44 | ## ✅ 4. Tool management via separate module | |
6e0dbce3 2026-05-01 Pavel Safronov | 45 | |
37160b89 2026-05-01 Pavel Safronov | 46 | Dev tools (golangci-lint, gomarklint, goreleaser) are now version-pinned in |
| 47 | [tools/go.mod](tools/go.mod), keeping their hundreds of transitive dependencies | |
| 48 | out of the main [go.mod](go.mod). The [Makefile](Makefile) installs them via | |
| 49 | `cd tools && go install ...` and exposes `make lint` and `make lint-docs` targets. | |
6e0dbce3 2026-05-01 Pavel Safronov | 50 | |
| 51 | --- | |
| 52 | ||
37160b89 2026-05-01 Pavel Safronov | 53 | ## ✅ 5. Reduce `main.go` size |
6e0dbce3 2026-05-01 Pavel Safronov | 54 | |
37160b89 2026-05-01 Pavel Safronov | 55 | [cmd/template/main.go](cmd/template/main.go) is now 14 lines. All CLI wiring, |
| 56 | settings construction (`createSettings`), profile resolution (`findProfile`), and | |
| 57 | orchestration (`runMain`) live in [internal/core/app.go](internal/core/app.go) | |
| 58 | where they are reachable by tests without going through the CLI layer. | |
| 59 | ||
| 60 | --- | |
6e0dbce3 2026-05-01 Pavel Safronov | 61 | |
ecad2935 2026-05-01 Pavel Safronov | 62 | ## ✅ 6. Improve test coverage |
| 63 | ||
| 64 | Coverage raised from ~56% to 67.7%. Threshold gate in [Makefile](Makefile) raised | |
| 65 | to 65%. | |
| 66 | ||
| 67 | New tests added across: | |
| 68 | ||
| 69 | - **[app_test.go](internal/core/app_test.go)** — `readEnvVars` (all env var | |
| 70 | branches), `loadAndMergeUserConfig` (file not found, valid merge, invalid YAML, | |
| 71 | merge error from invalid global config), `findProfile` (named profile, default | |
| 72 | profile, no-profile error) | |
| 73 | - **[file_test.go](internal/core/file_test.go)** — `createFile` error paths | |
| 74 | (`OSCreate` failure, `OSWriteFile` failure in template and empty-template paths), | |
| 75 | `readFile` (happy path and missing file) | |
| 76 | - **[profile_test.go](internal/core/profile_test.go)** — `createEntity` error | |
| 77 | paths (mkdir failure, chdir failure, invalid file-name pattern inside folder, | |
| 78 | subdir mkdir failure, `createFile` failure for both `FolderType` and `FileType`), | |
| 79 | `processProfile` edge cases (target-dir mkdir/chdir failures, `createEntity` | |
| 80 | error with and without `RunPostscriptOnFailure` swallow, invalid post-script | |
| 81 | template, post script with no output, post script that exits non-zero), | |
| 82 | `ScriptType` profile | |
| 83 | - **[profile_test.go](internal/core/profile_test.go)** — new | |
| 84 | `TestCreateNewNameForPatternsGetVersionError`: `getVersion` used in a non-last | |
| 85 | pattern returns an error | |
| 86 | ||
| 87 | Remaining uncovered paths are inherently untestable in unit tests: CLI wiring | |
| 88 | (`Run`, `createSettings`, `runMain`), the Windows branch of `shellCommandAndArgs`, | |
| 89 | and error branches in `yaml.Marshal` / `bufio.Writer` that the library panics on | |
| 90 | rather than returning errors. | |
6e0dbce3 2026-05-01 Pavel Safronov | 91 | |
| 92 | --- | |
| 93 | ||
51fece6b 2026-05-01 Pavel Safronov | 94 | ## ✅ 7. Clean up `default_config.go` |
6e0dbce3 2026-05-01 Pavel Safronov | 95 | |
51fece6b 2026-05-01 Pavel Safronov | 96 | [default_config.go](internal/core/default_config.go) shrunk from 396 lines to 18 |
| 97 | by switching to `//go:embed defaults.yaml`. All 14 profiles now live in | |
| 98 | [defaults.yaml](internal/core/defaults.yaml) as plain YAML, editable without | |
| 99 | touching Go code. | |
6e0dbce3 2026-05-01 Pavel Safronov | 100 | |
51fece6b 2026-05-01 Pavel Safronov | 101 | Added `omitempty` to the `IsDefault` and `IsDisabled` bool fields in `Profile` |
| 102 | so marshaling produces clean output (zero values omitted). | |
6e0dbce3 2026-05-01 Pavel Safronov | 103 | |
| 104 | --- | |
| 105 | ||
51fece6b 2026-05-01 Pavel Safronov | 106 | ## ✅ 8. Minor housekeeping |
37160b89 2026-05-01 Pavel Safronov | 107 | |
51fece6b 2026-05-01 Pavel Safronov | 108 | - **Empty `src/` directory** — removed. |
| 109 | - **`.DS_Store`** — `**/.DS_Store` added to [.gitignore](.gitignore). | |
98e28fa3 2026-10-27 Pavel Safronov | 110 | - **CI image pinning** — [.fw-ci.yml](.fw-ci.yml) pinned to |
51fece6b 2026-05-01 Pavel Safronov | 111 | `golang:1.25.4`. |