@aptre/common 0.23.0 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aptre/common",
3
3
  "description": "Common project configuration files and dependencies.",
4
- "version": "0.23.0",
4
+ "version": "0.26.2",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Aperture Robotics LLC.",
@@ -30,7 +30,6 @@
30
30
  "!**/*.tsbuildinfo",
31
31
  ".eslintrc.cjs",
32
32
  ".gitignore",
33
- "Makefile",
34
33
  "dist",
35
34
  "go.mod",
36
35
  "go.sum",
@@ -49,23 +48,25 @@
49
48
  "ci": "npm run build && npm run lint:js && npm run lint:go",
50
49
  "format": "npm run format:go && npm run format:js && npm run format:config",
51
50
  "format:config": "prettier --write tsconfig.json package.json",
52
- "format:go": "make format",
51
+ "format:go": "npm run go:aptre -- format",
53
52
  "format:js": "npm run format:js:changed",
54
53
  "format:js:changed": "git diff --name-only --diff-filter=d HEAD | grep '\\(\\.ts\\|\\.tsx\\|\\.html\\|\\.css\\|\\.scss\\)$' | xargs -I {} prettier --write {}",
55
54
  "format:js:all": "prettier --write './!(vendor|dist)/**/(*.ts|*.tsx|*.js|*.html|*.css)'",
56
- "gen": "rimraf ./.tools && go mod tidy && cd ./tools && go mod tidy && cd ../ && bash embed.bash && npm run format && make genproto",
57
- "demo": "make demo",
55
+ "gen": "rimraf ./.tools && go mod tidy && cd ./tools && go mod tidy && cd ../ && bash embed.bash && npm run format && npm run go:aptre:gen",
56
+ "gen:force": "rimraf ./.tools && go mod tidy && cd ./tools && go mod tidy && cd ../ && bash embed.bash && npm run format && npm run go:aptre:gen --force",
57
+ "go:aptre:gen": "go run github.com/aperturerobotics/common/cmd/aptre generate",
58
+ "go:aptre": "go run github.com/aperturerobotics/common/cmd/aptre",
58
59
  "test": "npm run test:js && npm run test:go",
59
60
  "test:js": "vitest run && npm run typecheck",
60
- "test:go": "make test",
61
+ "test:go": "npm run go:aptre -- test",
61
62
  "lint": "npm run lint:go && npm run lint:js",
62
- "lint:go": "make lint",
63
+ "lint:go": "npm run go:aptre -- lint",
63
64
  "lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint -c .eslintrc.cjs ./",
64
65
  "prepare": "go mod vendor && bash embed.bash",
65
66
  "release:version": "npm version patch -m \"release: v%s\" --no-git-tag-version",
66
67
  "release:version:minor": "npm version minor -m \"release: v%s\" --no-git-tag-version",
67
- "release:commit": "git reset && git add package.json && git commit -s -m \"release: v$npm_package_version\" && git tag v$npm_package_version",
68
- "release:publish": "git push && git push --tags && npm run build && npm publish",
68
+ "release:commit": "git reset && git add package.json && git commit -s -m \"release: v$(node -p \"require('./package.json').version\")\" && git tag v$(node -p \"require('./package.json').version\")",
69
+ "release:publish": "git push && git push --tags",
69
70
  "release": "npm run release:version && npm run release:commit",
70
71
  "release:minor": "npm run release:version:minor && npm run release:commit"
71
72
  },
@@ -83,7 +84,7 @@
83
84
  "eslint-config-prettier": "^10.0.0",
84
85
  "eslint-plugin-react-hooks": "^7.0.0",
85
86
  "eslint-plugin-unused-imports": "^4.0.0",
86
- "starpc": "^0.40.0",
87
+ "starpc": "^0.42.0",
87
88
  "vitest": "^4.0.0"
88
89
  },
89
90
  "peerDependencies": {
package/tsconfig.json CHANGED
@@ -19,5 +19,5 @@
19
19
  "strict": true,
20
20
  "lib": ["webworker", "dom"]
21
21
  },
22
- "exclude": ["node_modules", "vendor", "dist", "tools/vendor"]
22
+ "exclude": ["node_modules", "vendor", "dist", "tools/vendor", "build"]
23
23
  }
package/Makefile DELETED
@@ -1,227 +0,0 @@
1
- # https://github.com/aperturerobotics/template
2
-
3
- # Projects can override PROJECT_DIR with the path to their project.
4
- COMMON_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
5
- PROJECT_DIR := $(COMMON_DIR)
6
- PROJECT_DIR_REL = $(shell realpath --relative-to $(COMMON_DIR) $(PROJECT_DIR))
7
-
8
- TOOLS_DIR := .tools
9
- TOOLS_BIN := $(TOOLS_DIR)/bin
10
-
11
- PROJECT_TOOLS_DIR := $(PROJECT_DIR)/$(TOOLS_DIR)
12
- PROJECT_TOOLS_DIR_REL = $(shell realpath --relative-to $(COMMON_DIR) $(PROJECT_TOOLS_DIR))
13
-
14
- SHELL:=bash
15
- MAKEFLAGS += --no-print-directory
16
-
17
- export GO111MODULE=on
18
- undefine GOARCH
19
- undefine GOOS
20
-
21
- .PHONY: all
22
- all: protodeps
23
-
24
- # Setup node_modules
25
- $(PROJECT_DIR)/node_modules:
26
- cd $(PROJECT_DIR_REL); yarn install
27
-
28
- # Setup the .tools directory to hold the build tools in the project repo
29
- $(PROJECT_TOOLS_DIR):
30
- @cd $(PROJECT_DIR); go run -v github.com/aperturerobotics/common $(TOOLS_DIR)
31
-
32
- .PHONY: tools
33
- tools: $(PROJECT_TOOLS_DIR)
34
-
35
- # Build tool rule
36
- define build_tool
37
- $(PROJECT_DIR)/$(1): $(PROJECT_TOOLS_DIR)
38
- cd $(PROJECT_TOOLS_DIR_REL); \
39
- go build -mod=readonly -v \
40
- -o ./bin/$(shell basename $(1)) \
41
- $(2)
42
-
43
- .PHONY: $(1)
44
- $(1): $(PROJECT_DIR)/$(1)
45
- endef
46
-
47
- # List of available Go tool binaries
48
- PROTOWRAP=$(TOOLS_BIN)/protowrap
49
- PROTOC_GEN_GO=$(TOOLS_BIN)/protoc-gen-go-lite
50
- PROTOC_GEN_GO_STARPC=$(TOOLS_BIN)/protoc-gen-go-starpc
51
- GOIMPORTS=$(TOOLS_BIN)/goimports
52
- GOFUMPT=$(TOOLS_BIN)/gofumpt
53
- GOLANGCI_LINT=$(TOOLS_BIN)/golangci-lint
54
- GO_MOD_OUTDATED=$(TOOLS_BIN)/go-mod-outdated
55
- GORELEASER=$(TOOLS_BIN)/goreleaser
56
- WASMBROWSERTEST=$(TOOLS_BIN)/wasmbrowsertest
57
- # GOSCRIPT=$(TOOLS_BIN)/goscript
58
-
59
- # Mappings for build tool to Go import path
60
- $(eval $(call build_tool,$(PROTOC_GEN_GO),github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite))
61
- $(eval $(call build_tool,$(PROTOC_GEN_GO_STARPC),github.com/aperturerobotics/starpc/cmd/protoc-gen-go-starpc))
62
- $(eval $(call build_tool,$(GOIMPORTS),golang.org/x/tools/cmd/goimports))
63
- $(eval $(call build_tool,$(GOFUMPT),mvdan.cc/gofumpt))
64
- $(eval $(call build_tool,$(PROTOWRAP),github.com/aperturerobotics/goprotowrap/cmd/protowrap))
65
- $(eval $(call build_tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint))
66
- $(eval $(call build_tool,$(GO_MOD_OUTDATED),github.com/psampaz/go-mod-outdated))
67
- $(eval $(call build_tool,$(GORELEASER),github.com/goreleaser/goreleaser/v2))
68
- $(eval $(call build_tool,$(WASMBROWSERTEST),github.com/agnivade/wasmbrowsertest))
69
- # $(eval $(call build_tool,$(GOSCRIPT),github.com/aperturerobotics/goscript/cmd/goscript))
70
-
71
- .PHONY: protodeps
72
- protodeps: $(GOFUMPT) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_STARPC) $(PROJECT_DIR)/node_modules
73
-
74
- # Default protogen targets and arguments
75
- PROTOGEN_TARGETS ?= ./*.proto
76
- PROTOGEN_ARGS ?=
77
- GO_LITE_OPT_FEATURES ?= marshal+unmarshal+size+equal+json+clone+text
78
-
79
- .PHONY: genproto
80
- genproto: protodeps
81
- @shopt -s globstar; \
82
- set -eo pipefail; \
83
- cd $(PROJECT_DIR); \
84
- export PROTOBUF_GO_TYPES_PKG=github.com/aperturerobotics/protobuf-go-lite/types; \
85
- export PROJECT=$$(go list -m); \
86
- export OUT=./vendor; \
87
- mkdir -p $${OUT}/$$(dirname $${PROJECT}); \
88
- rm -f ./vendor/$${PROJECT}; \
89
- ln -s $$(pwd) ./vendor/$${PROJECT}; \
90
- protogen() { \
91
- PROTO_FILES=$$(git ls-files "$$1"); \
92
- FMT_GO_FILES=(); \
93
- FMT_TS_FILES=(); \
94
- PROTOWRAP_OPTS=(); \
95
- if [ -f "go.mod" ]; then \
96
- PROTOWRAP_OPTS+=( \
97
- --plugin=$(PROTOC_GEN_GO) \
98
- --plugin=$(PROTOC_GEN_GO_STARPC) \
99
- --go-lite_out=$${OUT} \
100
- --go-lite_opt=features=$(GO_LITE_OPT_FEATURES) \
101
- --go-starpc_out=$${OUT} \
102
- ); \
103
- fi; \
104
- if [ -f "package.json" ]; then \
105
- PROTOWRAP_OPTS+=( \
106
- --plugin=./node_modules/.bin/protoc-gen-es \
107
- --plugin=./node_modules/.bin/protoc-gen-es-starpc \
108
- --es-lite_out=$${OUT} \
109
- --es-lite_opt target=ts \
110
- --es-lite_opt ts_nocheck=false \
111
- --es-starpc_out=$${OUT} \
112
- --es-starpc_opt target=ts \
113
- --es-starpc_opt ts_nocheck=false \
114
- ); \
115
- fi; \
116
- $(PROTOWRAP) \
117
- -I $${OUT} \
118
- "$${PROTOWRAP_OPTS[@]}" \
119
- --proto_path $${OUT} \
120
- --print_structure \
121
- --only_specified_files \
122
- $(PROTOGEN_ARGS) \
123
- $$(echo "$$PROTO_FILES" | xargs printf -- "./vendor/$${PROJECT}/%s "); \
124
- for proto_file in $${PROTO_FILES}; do \
125
- proto_dir=$$(dirname $$proto_file); \
126
- proto_name=$${proto_file%".proto"}; \
127
- GO_FILES=$$(git ls-files ":(glob)$${proto_dir}/${proto_name}*.pb.go"); \
128
- if [ -n "$$GO_FILES" ]; then FMT_GO_FILES+=($${GO_FILES[@]}); fi; \
129
- TS_FILES=$$(git ls-files ":(glob)$${proto_dir}/${proto_name}*.pb.ts"); \
130
- if [ -n "$$TS_FILES" ]; then FMT_TS_FILES+=($${TS_FILES[@]}); fi; \
131
- if [ -z "$$TS_FILES" ]; then continue; fi; \
132
- for ts_file in $${TS_FILES}; do \
133
- ts_file_dir=$$(dirname $$ts_file); \
134
- relative_path=$${ts_file_dir#"./"}; \
135
- depth=$$(echo $$relative_path | awk -F/ '{print NF+1}'); \
136
- prefix=$$(printf '../%0.s' $$(seq 1 $$depth)); \
137
- istmts=$$(grep -oE "from\s+\"$$prefix[^\"]+\"" $$ts_file) || continue; \
138
- if [ -z "$$istmts" ]; then continue; fi; \
139
- ipaths=$$(echo "$$istmts" | awk -F'"' '{print $$2}'); \
140
- for import_path in $$ipaths; do \
141
- rel_import_path=$$(realpath -s --relative-to=./vendor \
142
- "./vendor/$${PROJECT}/$${ts_file_dir}/$${import_path}"); \
143
- go_import_path=$$(echo $$rel_import_path | sed -e "s|^|@go/|"); \
144
- sed -i -e "s|$$import_path|$$go_import_path|g" $$ts_file; \
145
- done; \
146
- done; \
147
- done; \
148
- if [ -n "$${FMT_GO_FILES}" ]; then \
149
- $(GOFUMPT) -w $${FMT_GO_FILES[@]}; \
150
- fi; \
151
- if [ -n "$${FMT_TS_FILES}" ]; then \
152
- prettier --config $(TOOLS_DIR)/.prettierrc.yaml -w $${FMT_TS_FILES[@]}; \
153
- fi; \
154
- }; \
155
- protogen "$(PROTOGEN_TARGETS)"; \
156
- rm -f ./vendor/$${PROJECT}
157
-
158
- .PHONY: gen
159
- gen: genproto
160
-
161
- .PHONY: outdated
162
- outdated: $(GO_MOD_OUTDATED)
163
- cd $(PROJECT_DIR); \
164
- go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED) -update -direct
165
-
166
- .PHONY: list
167
- list: $(GO_MOD_OUTDATED)
168
- cd $(PROJECT_DIR); \
169
- go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED)
170
-
171
- .PHONY: lint
172
- lint: $(GOLANGCI_LINT)
173
- cd $(PROJECT_DIR); \
174
- $(GOLANGCI_LINT) run
175
-
176
- .PHONY: fix
177
- fix: $(GOLANGCI_LINT)
178
- cd $(PROJECT_DIR); \
179
- $(GOLANGCI_LINT) run --fix
180
-
181
- .PHONY: test
182
- test:
183
- cd $(PROJECT_DIR); \
184
- go test -v ./...
185
-
186
- .PHONY: test-browser
187
- test-browser: $(WASMBROWSERTEST)
188
- cd $(PROJECT_DIR); \
189
- GOOS=js GOARCH=wasm GOTOOLCHAIN=local \
190
- go test -exec $$(realpath $(WASMBROWSERTEST)) \
191
- -tags "webtests" \
192
- -v ./...
193
-
194
- .PHONY: format
195
- format: gofumpt
196
-
197
- .PHONY: gofumpt
198
- gofumpt: $(GOFUMPT)
199
- cd $(PROJECT_DIR); \
200
- $(GOFUMPT) -w ./
201
-
202
- .PHONY: goimports
203
- goimports: $(GOIMPORTS)
204
- cd $(PROJECT_DIR); \
205
- $(GOIMPORTS) -w ./
206
-
207
- .PHONY: release
208
- release: $(GORELEASER)
209
- cd $(PROJECT_DIR); \
210
- $(GORELEASER) release $(GORELEASER_OPTS)
211
-
212
- .PHONY: release-bundl\e
213
- release-bundle: $(GORELEASER)
214
- cd $(PROJECT_DIR); \
215
- $(GORELEASER) check; \
216
- $(GORELEASER) release --snapshot --clean --skip-publish $(GORELEASER_OPTS)
217
-
218
- .PHONY: release-build
219
- release-build: $(GORELEASER)
220
- cd $(PROJECT_DIR); \
221
- $(GORELEASER) check; \
222
- $(GORELEASER) build --single-target --snapshot --clean $(GORELEASER_OPTS)
223
-
224
- .PHONY: release-check
225
- release-check: $(GORELEASER)
226
- cd $(PROJECT_DIR); \
227
- $(GORELEASER) check