Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/doc-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Documentation Check

on:
pull_request:

permissions:
contents: read

jobs:
format-check:
name: Markdown Format Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install prettier
run: npm install -g prettier

- name: Check Markdown formatting
run: prettier --check "**/*.md"
44 changes: 33 additions & 11 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
name: Go
on: [push]
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
build:
name: Build
test:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.24
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24
id: go
go-version: '1.24'

- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Download dependencies
run: go mod download

- name: Build
run: go build -v -o gitplm .

- name: Test
- name: Run tests
run: go test -v ./...

- name: Check formatting
run: |
go test ./...
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "Go code is not formatted. Please run 'gofmt -s -w .'"
gofmt -s -l .
exit 1
fi

- name: Run go vet
run: go vet ./...
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean --release-notes .release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56 changes: 26 additions & 30 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go mod tidy
- go generate ./...
changelog:
skip: true
# Extract changelog section for this version and save to file
- bash -c './scripts/extract-changelog.sh $(git describe --tags --abbrev=0) > .release-notes.md'

builds:
- main: .
id: gitplm
binary: gitplm
env:
- CGO_ENABLED=0
goos:
Expand All @@ -29,32 +28,29 @@ builds:
ignore:
- goos: darwin
goarch: 386
hooks:
pre:
#- /bin/sh -c '. ./envsetup.sh && siot_setup && siot_build_dependencies'

archives:
- name_template: >-
{{- .ProjectName }}-
- formats: ['binary']
name_template: >-
{{ .ProjectName }}-
{{- .Tag }}-
{{- if eq .Os "darwin" }}macos
{{- else }}{{ .Os }}{{ end }}-
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}{{ .Arm }}{{ end }}
wrap_in_directory: true
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE
- CHANGELOG.md

checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
#env_files:
#github_token: GITHUB_TOKEN

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
footer: >-

---

To update, run: `gitplm -update`
6 changes: 6 additions & 0 deletions .harper-dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
GitPLM
IPN
MCUs
MPN
PLM
partmaster
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ For more details or to discuss releases, please visit the

## [Unreleased]

- Support 3 and 4 digit NNN/NNNN in part numbers
- KiCad HTTP Library API (WIP - not yet complete)
- Switch goreleaser to upload raw binaries instead of archives
- Add Windows install instructions
- Fix CSV delimiter documentation to match current convention
- Add self-update feature (`gitplm -update`)

## [[0.7.1] - 2025-07-11](https://github.com/git-plm/gitplm/releases/tag/v0.7.1)

- rename release to more friendly names
- Rename release to more friendly names

## [[0.7.0] - 2025-07-11](https://github.com/git-plm/gitplm/releases/tag/v0.7.0)

Expand Down Expand Up @@ -45,8 +52,8 @@ For more details or to discuss releases, please visit the

## [[0.6.1] - 2025-06-26](https://github.com/git-plm/gitplm/releases/tag/v0.6.1)

- add `-pmDir` command line parameter to specify parts database directory
- add support for loading multiple partmaster CSV files from a directory
- Add `-pmDir` command line parameter to specify parts database directory
- Add support for loading multiple partmaster CSV files from a directory
- **breaking changes**
- changed CSV column heading "qnty" to "qty"
- breaking change: switched to using ',' in CSV files for delimiter instead of
Expand Down
83 changes: 83 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with
code in this repository.

## Build and Test Commands

```bash
go build . # Build binary
go run . # Run from source
go test ./... # Run all tests
go test -run TestFunctionName ./... # Run a single test
```

No Makefile or linter is configured. CI runs `go test ./...` on every push.

Cross-platform releases use GoReleaser (see `envsetup.sh` for helper functions).

## Architecture

GitPLM is a single-package (`package main`) Go CLI tool for managing hardware
product lifecycle data using CSV files in Git (no database). All source files
are in the repository root.

### CLI Modes (entry point: `main.go`)

- **Release** (`-release CCC-NNN-VVVV`): Core workflow in `release.go`. Finds
source BOM CSV and YAML release script, applies BOM modifications, runs hooks,
copies files, merges partmaster data, and outputs a versioned release BOM. For
assemblies (PCA/ASY), recursively expands sub-assembly BOMs and creates a
combined `-all.csv`.
- **TUI** (no args): Interactive Bubbletea terminal UI (`tui_new.go`) for
browsing partmaster CSV data. Split-pane: file list + data table.
- **HTTP** (`-http`): KiCad HTTP Library API server (`kicad_api.go`) exposing
partmaster data as REST JSON.
- **Simplify/Combine** (`-simplify`/`-combine`): BOM consolidation utilities.

### Key Types

- **`ipn`** (`ipn.go`): Internal Part Number string type, format `CCC-NNN-VVVV`.
Methods for parsing, extracting base (`CCC-NNN`), and classifying category
(purchased vs manufactured).
- **`bom` / `bomLine`** (`bom.go`): Bill of Materials. Supports merging with
partmaster, recursive sub-assembly expansion, sorting by IPN.
- **`partmaster` / `partmasterLine`** (`partmaster.go`): Part database loaded
from CSV files. Can load a directory of CSVs (`-pmDir`). Priority field
controls which entry wins for duplicate IPNs (lower = higher priority).
- **`relScript`** (`rel-script.go`): Release script parsed from YAML. Defines
BOM add/remove rules, file copies, shell hooks (Go template vars:
`{{ .SrcDir }}`, `{{ .RelDir }}`, `{{ .IPN }}`), and required file checks.
- **`Config`** (`config.go`): YAML config loaded from `gitplm.yml`/`.gitplm.yml`
(cwd) or `~/.gitplm.yml`.
- **`CSVFileCollection`** (`csv_data.go`): Schema-flexible raw CSV loading used
by TUI and KiCad API.

### IPN Categories

Manufactured: `PCA` (circuit assembly), `PCB`, `ASY` (assembly), `DOC`, `DFW`
(firmware), `DSW` (software), `DCL` (calibration), `FIX` (fixtures). Only PCA
and ASY have recursive BOMs.

Purchased: `RES`, `CAP`, `DIO`, `LED`, etc.

Format: `CCC-NNN-VVVV` where N is 3-4 digits, V is always 4 digits.

### Data Flow for Release Processing

1. Search directory tree for `CCC-NNN.csv` and `CCC-NNN.yml` source files
2. Create release directory `CCC-NNN-VVVV/`
3. Load partmaster (directory of CSVs or single `partmaster.csv`)
4. Apply YAML release script (remove/add BOM lines, run hooks, copy files, check
required)
5. Merge partmaster data into BOM, sort, save output CSV
6. For PCA/ASY: recursively expand sub-assemblies, create symlinks, generate
combined BOM

### Notable Conventions

- CSV delimiter is comma; reference designators are space-separated
- Quantity is `float64` (supports fractional)
- File search uses `fs.WalkDir` from `./` and does NOT follow symlinks
- Hooks use `/bin/sh -c` (Linux/macOS only)
- `gocsv` library handles CSV marshal/unmarshal via struct tags
Loading