Documentation
¶
Index ¶
- Constants
- func CleanupOrphanedGeneratedFiles(root string, previous, current GeneratedManifest) ([]string, error)
- func DeploymentFilePath(id string) string
- func DeploymentsDir() string
- func IsGeneratedFile(path string) bool
- func LocalAgentConnectionsFilePath() string
- func LocalAgentDSNFilePath() string
- func LocalAgentDriverFilePath() string
- func LocalAgentTokenFilePath() string
- func LocalAgentUUIDFilePath() string
- func MigrateLegacyAgentFiles() error
- func MigrateLegacyTokenFile() error
- func TokenFilePath() string
- type GeneratedManifest
Constants ¶
const GeneratedManifestFileName = ".nuzur-codegen-manifest.json"
GeneratedManifestFileName is the manifest a generator writes at the root of its output, listing every file it produced. The CLI uses it to remove files that were generated by a previous run but are no longer produced, without touching files the user added.
It is keyed off the manifest's presence rather than a specific extension, so any extension that emits this manifest gets stale-file cleanup for free.
Variables ¶
This section is empty.
Functions ¶
func CleanupOrphanedGeneratedFiles ¶ added in v0.0.59
func CleanupOrphanedGeneratedFiles(root string, previous, current GeneratedManifest) ([]string, error)
CleanupOrphanedGeneratedFiles removes files that were produced by a previous generation (listed in previous) but are no longer produced by the current one (absent from current). A file is removed only when it still carries the generated marker, so:
- files the user added (never in a manifest, never marked) are never touched;
- files the user took over by editing out the marker are never touched;
- files still generated by the current run are kept (already overwritten).
Directories left empty by the removals are pruned. It returns the list of removed paths (output-root-relative), and is best-effort: an error removing one file is returned but does not undo prior removals.
func DeploymentFilePath ¶ added in v1.1.0
DeploymentFilePath returns the path to a single deployment's state file.
func DeploymentsDir ¶ added in v1.1.0
func DeploymentsDir() string
DeploymentsDir returns the persistent per-user directory where the CLI records deployments created by `nuzur-cli deploy`, nested under configBaseDir (e.g. ~/.config/nuzur/deployments). Each deployment is one JSON file, read by `nuzur-cli destroy` / `nuzur-cli deploy list`.
Falls back to /tmp/nuzur-cli/ when UserConfigDir fails, matching the agent state helpers.
func IsGeneratedFile ¶ added in v0.0.59
IsGeneratedFile reports whether the file at path still carries a generated marker. It recognizes this generator's marker as well as the standard Go "Code generated ... DO NOT EDIT." convention used by tools such as sqlc and protoc. A file the user has taken over (and from which the marker was removed) returns false, so it is never deleted.
func LocalAgentConnectionsFilePath ¶ added in v0.0.50
func LocalAgentConnectionsFilePath() string
LocalAgentConnectionsFilePath stores the per-connection registry: a JSON array of {uuid, name, driver, db_type, default_schema}. DSNs are NOT in this file — they live in the OS keychain.
func LocalAgentDSNFilePath ¶ added in v0.0.50
func LocalAgentDSNFilePath() string
LocalAgentDSNFilePath is where the CLI persists the legacy fallback DSN the user supplied on first `agent start`. Held in plaintext for now; the per-connection registry's DSNs live in the OS keychain.
func LocalAgentDriverFilePath ¶ added in v0.0.50
func LocalAgentDriverFilePath() string
LocalAgentDriverFilePath stores the driver name (mysql / postgres) that pairs with the saved DSN.
func LocalAgentTokenFilePath ¶ added in v0.0.50
func LocalAgentTokenFilePath() string
LocalAgentTokenFilePath is where the CLI stores the paired local agent's plaintext token. (Keychain move tracked separately; phase-keychain-1 only covered DSNs.)
func LocalAgentUUIDFilePath ¶ added in v0.0.50
func LocalAgentUUIDFilePath() string
LocalAgentUUIDFilePath is where the CLI stores the paired local agent's UUID.
func MigrateLegacyAgentFiles ¶ added in v0.0.50
func MigrateLegacyAgentFiles() error
MigrateLegacyAgentFiles relocates any files that still live at the old /tmp/nuzur-cli/ path. Called once at the start of every agent-related command so users who upgrade past this change don't have to re-pair. Idempotent: if the new location already has a file, the legacy copy is left in place untouched (we never overwrite).
func MigrateLegacyTokenFile ¶ added in v0.0.55
func MigrateLegacyTokenFile() error
MigrateLegacyTokenFile relocates the user's auth token from the old /tmp/nuzur-cli/ location to the persistent per-user config dir so an upgrade doesn't force a re-login. Best-effort and idempotent: no legacy token, an already-migrated token, or the /tmp fallback being active are all no-ops.
func TokenFilePath ¶
func TokenFilePath() string
TokenFilePath is where the CLI stores the user's auth (login) token. It lives in the persistent per-user config dir — $XDG_CONFIG_HOME/nuzur on Linux, ~/Library/Application Support/nuzur on macOS, %AppData%\nuzur on Windows — falling back to /tmp/nuzur-cli when UserConfigDir is unavailable. Previously this was hardcoded under /tmp, which is wiped on reboot and resolves to a drive-root path on Windows; see MigrateLegacyTokenFile for the one-time move.
Types ¶
type GeneratedManifest ¶ added in v0.0.59
type GeneratedManifest struct {
Version int `json:"version"`
Generator string `json:"generator"`
GeneratedAt string `json:"generated_at"`
// Files are output-root-relative, forward-slash paths.
Files []string `json:"files"`
}
GeneratedManifest is the on-disk manifest format written by a generator.
func FindGeneratedManifest ¶ added in v1.4.3
func FindGeneratedManifest(outputPath string) (string, GeneratedManifest, bool, error)
FindGeneratedManifest locates the manifest at or just below outputPath and returns the directory that CONTAINS it — which is the root the manifest's paths are relative to.
This indirection exists because the extraction root and the manifest root are not the same directory. A generator nests its whole output under one folder named after the project identifier, so extracting into `nuzur-chorus/` yields `nuzur-chorus/chorus/...` with the manifest at `nuzur-chorus/chorus/` and its entries relative to THAT ("core/module/...", not "chorus/core/module/..."). Reading the manifest at outputPath itself therefore finds nothing, and stale files are never pruned.
Only outputPath and its immediate subdirectories are considered: that is the generator's nesting contract, and a deeper walk risks finding the manifest of an unrelated project a user happens to keep inside the workspace. If several subdirectories carry a manifest the layout is ambiguous (more than one generated project under one root), and it reports not-found rather than guess — cleanup is skipped instead of possibly deleting from the wrong tree.
func ReadGeneratedManifest ¶ added in v0.0.59
func ReadGeneratedManifest(root string) (GeneratedManifest, bool, error)
ReadGeneratedManifest reads the manifest from root. The bool reports whether a manifest was present; a missing manifest is not an error (a generator that doesn't emit one simply opts out of cleanup).