Add install/uninstall safety check via --signature flag
Automated-By: Claude Sonnet 4.6
This commit is contained in:
@@ -1,13 +1,27 @@
|
|||||||
PREFIX ?= $(HOME)/.local/bin
|
PREFIX ?= $(HOME)/.local/bin
|
||||||
|
TARGET := $(PREFIX)/CodeMapper
|
||||||
|
SIG := CODEMAPPER-SIGNATURE-izackp
|
||||||
|
|
||||||
.PHONY: build install uninstall
|
.PHONY: build install uninstall _check_existing
|
||||||
|
|
||||||
build:
|
build:
|
||||||
swift build -c release
|
swift build -c release
|
||||||
|
|
||||||
install: build
|
_check_existing:
|
||||||
install -d $(PREFIX)
|
@if [ -f "$(TARGET)" ]; then \
|
||||||
install .build/release/CodeMapper $(PREFIX)/CodeMapper
|
GOT=$$("$(TARGET)" --signature 2>/dev/null || true); \
|
||||||
|
if [ "$$GOT" != "$(SIG)" ]; then \
|
||||||
|
if [ "$(FORCE)" != "1" ]; then \
|
||||||
|
echo "ERROR: $(TARGET) exists but is not this CodeMapper build."; \
|
||||||
|
echo " Pass FORCE=1 to override."; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi \
|
||||||
|
fi
|
||||||
|
|
||||||
uninstall:
|
install: build _check_existing
|
||||||
rm -f $(PREFIX)/CodeMapper
|
install -d $(PREFIX)
|
||||||
|
install .build/release/CodeMapper $(TARGET)
|
||||||
|
|
||||||
|
uninstall: _check_existing
|
||||||
|
rm -f $(TARGET)
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
|
|
||||||
|
let buildSignature = "CODEMAPPER-SIGNATURE-izackp"
|
||||||
|
|
||||||
struct CodeMapper: ParsableCommand {
|
struct CodeMapper: ParsableCommand {
|
||||||
static let configuration = CommandConfiguration(
|
static let configuration = CommandConfiguration(
|
||||||
commandName: "CodeMapper",
|
commandName: "CodeMapper",
|
||||||
abstract: "Generate LLM-friendly architectural maps from Swift source files."
|
abstract: "Generate LLM-friendly architectural maps from Swift source files."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@Option(name: .long, help: "Root of the Swift package to analyze.")
|
@Option(name: .long, help: "Root of the Swift package to analyze.")
|
||||||
var sources: String
|
var sources: String
|
||||||
|
|
||||||
@@ -103,4 +106,10 @@ struct CodeMapper: ParsableCommand {
|
|||||||
|
|
||||||
// Ignore SIGPIPE so LSP subprocess death returns an error instead of killing this process
|
// Ignore SIGPIPE so LSP subprocess death returns an error instead of killing this process
|
||||||
signal(SIGPIPE, SIG_IGN)
|
signal(SIGPIPE, SIG_IGN)
|
||||||
|
|
||||||
|
if CommandLine.arguments.contains("--signature") {
|
||||||
|
print(buildSignature)
|
||||||
|
exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
CodeMapper.main()
|
CodeMapper.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user