repo 0.14.13

An opinionated tool for repo management.
.PHONY: build
build:
	cargo build --release

.PHONY: setup
setup: setup-js

.PHONY: check
check: lint test build

.PHONY: setup-js
setup-js:
	bun install --frozen-lockfile

.PHONY: test
test: cargo-test cargo-test-help

.PHONY: cargo-test
cargo-test:
	cargo test

.PHONY: cargo-test-help
cargo-test-help:
	cargo run -- --help > /dev/null

.PHONY: publish
publish: test clean publish-rust publish-js

.PHONY: publish-rust
publish-rust:
	# TODO: Remove `--no-verify`: https://github.com/rust-lang/cargo/issues/15951
	cargo publish --no-verify # Dogfood our own `publish` command

.PHONY: publish-js
publish-js: setup-js
	bun run -- ./script/publish-npm.ts

.PHONY: build-debug
build-debug: ./target/debug/repo/

.PHONY: ./target/debug/repo/
./target/debug/repo/:
	cargo build

.PHONY: lint
lint: lint-biome lint-typescript lint-readme-cli-check lint-clippy

.PHONY: lint-biome
lint-biome: setup-js
	bun x -- bun-dx --package @biomejs/biome biome -- check

.PHONY: lint-typescript
lint-typescript: setup-js
	bun x -- bun-dx --package @typescript/native-preview tsgo -- --project .

.PHONY: lint-clippy
lint-clippy:
	cargo clippy

.PHONY: lint-readme-cli-check
lint-readme-cli-check: setup-js ./target/debug/repo/
	bun x -- bun-dx --package readme-cli-help readme-cli-help -- check

.PHONY: format
format: setup-js format-readme-cli-update
	bun x -- bun-dx --package @biomejs/biome biome -- check --write

.PHONY: format-readme-cli-update
format-readme-cli-update: ./target/debug/repo/
	bun x -- bun-dx --package readme-cli-help readme-cli-help -- update

.PHONY: install
install:
	cargo install --path .

.PHONY: uninstall
uninstall:
	cargo uninstall repo

RM_RF = bun -e 'process.argv.slice(1).map(p => process.getBuiltinModule("node:fs").rmSync(p, {recursive: true, force: true, maxRetries: 5}))' --

.PHONY: clean
clean:
	${RM_RF} ./.temp/
	${RM_RF} \
		./src/js/@lgarron-bin/repo/package.json \
		./src/js/@lgarron-bin/repo/schemas/ \
		./src/js/@lgarron-bin/repo/types/ \
		./src/js/@lgarron-bin/repo-*

.PHONY: reset
reset: clean
	${RM_RF} ./node_modules/
	${RM_RF} ./target/

.PHONY: build-release
build-release:
	cargo build --release

.PHONY: test-published-package
test-published-package:
	# `bun` is not available on all platforms, so we use `npx`.
	# Further, GitHub Actions has a shim for `npm` that requires additional workarounds inside a script.
	# So we just perform simple checks here.
	npm install --save @lgarron-bin/repo
	npx @lgarron-bin/repo --help
	npx @lgarron-bin/repo workspace root
	ls -al ./node_modules/@lgarron-bin/