From 71f26f48abcf1fdcef0233ee3b0de17c4a4fd263 Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 9 Apr 2025 15:56:40 -0600 Subject: [PATCH] update to cli --- cli/.cursor/prds.mdc | 122 ------------------ cli/CLAUDE.md | 34 +++++ cli/Cargo.toml | 37 +++--- cli/cli/Cargo.toml | 48 +++++++ cli/{ => cli}/build.rs | 0 cli/{ => cli}/src/assets/mod.rs | 0 cli/{ => cli}/src/commands/auth.rs | 0 cli/{ => cli}/src/commands/deploy.rs | 0 cli/{ => cli}/src/commands/generate.rs | 0 cli/{ => cli}/src/commands/init.rs | 0 cli/{ => cli}/src/commands/mod.rs | 0 cli/{ => cli}/src/commands/update.rs | 0 cli/{ => cli}/src/commands/version.rs | 0 cli/{ => cli}/src/error.rs | 0 cli/{ => cli}/src/lib.rs | 0 cli/{ => cli}/src/main.rs | 0 cli/{ => cli}/src/types/mod.rs | 0 cli/{ => cli}/src/utils/buster/api.rs | 0 cli/{ => cli}/src/utils/buster/mod.rs | 0 cli/{ => cli}/src/utils/buster/types.rs | 0 cli/{ => cli}/src/utils/dbt/command.rs | 0 cli/{ => cli}/src/utils/dbt/mod.rs | 0 cli/{ => cli}/src/utils/exclusion.rs | 0 .../src/utils/file/buster_credentials.rs | 0 cli/{ => cli}/src/utils/file/mod.rs | 0 cli/{ => cli}/src/utils/file/model_files.rs | 0 cli/{ => cli}/src/utils/file/profiles.rs | 0 cli/{ => cli}/src/utils/file/project_files.rs | 0 cli/{ => cli}/src/utils/formatting/mod.rs | 0 cli/{ => cli}/src/utils/formatting/text.rs | 0 cli/{ => cli}/src/utils/mod.rs | 0 cli/{ => cli}/src/utils/yaml_diff_merger.rs | 0 cli/logs/dbt.log | 15 --- cli/test_excluded_tags.sql | 9 -- 34 files changed, 100 insertions(+), 165 deletions(-) delete mode 100644 cli/.cursor/prds.mdc create mode 100644 cli/CLAUDE.md create mode 100644 cli/cli/Cargo.toml rename cli/{ => cli}/build.rs (100%) rename cli/{ => cli}/src/assets/mod.rs (100%) rename cli/{ => cli}/src/commands/auth.rs (100%) rename cli/{ => cli}/src/commands/deploy.rs (100%) rename cli/{ => cli}/src/commands/generate.rs (100%) rename cli/{ => cli}/src/commands/init.rs (100%) rename cli/{ => cli}/src/commands/mod.rs (100%) rename cli/{ => cli}/src/commands/update.rs (100%) rename cli/{ => cli}/src/commands/version.rs (100%) rename cli/{ => cli}/src/error.rs (100%) rename cli/{ => cli}/src/lib.rs (100%) rename cli/{ => cli}/src/main.rs (100%) rename cli/{ => cli}/src/types/mod.rs (100%) rename cli/{ => cli}/src/utils/buster/api.rs (100%) rename cli/{ => cli}/src/utils/buster/mod.rs (100%) rename cli/{ => cli}/src/utils/buster/types.rs (100%) rename cli/{ => cli}/src/utils/dbt/command.rs (100%) rename cli/{ => cli}/src/utils/dbt/mod.rs (100%) rename cli/{ => cli}/src/utils/exclusion.rs (100%) rename cli/{ => cli}/src/utils/file/buster_credentials.rs (100%) rename cli/{ => cli}/src/utils/file/mod.rs (100%) rename cli/{ => cli}/src/utils/file/model_files.rs (100%) rename cli/{ => cli}/src/utils/file/profiles.rs (100%) rename cli/{ => cli}/src/utils/file/project_files.rs (100%) rename cli/{ => cli}/src/utils/formatting/mod.rs (100%) rename cli/{ => cli}/src/utils/formatting/text.rs (100%) rename cli/{ => cli}/src/utils/mod.rs (100%) rename cli/{ => cli}/src/utils/yaml_diff_merger.rs (100%) delete mode 100644 cli/logs/dbt.log delete mode 100644 cli/test_excluded_tags.sql diff --git a/cli/.cursor/prds.mdc b/cli/.cursor/prds.mdc deleted file mode 100644 index 3360e2b45..000000000 --- a/cli/.cursor/prds.mdc +++ /dev/null @@ -1,122 +0,0 @@ ---- -description: This is helpful for building and designing prds for our application and how to write them. Refer -globs: prds/* -alwaysApply: false ---- -# PRD (Product Requirements Document) Guidelines - -## Overview -This document provides guidelines for creating and managing Product Requirements Documents (PRDs) in our codebase. All PRDs should follow the standardized template located at [template.md](mdc:prds/template.md) - -## PRD Structure - -### Location -All PRDs should be stored in the `/prds` directory with the following structure: -``` -/prds -├── template.md # The master template for all PRDs -├── active/ # Active/In-progress PRDs -│ ├── feature_auth.md -│ └── api_deployment.md -├── completed/ # Completed PRDs that have been shipped -│ ├── feature_user_auth.md -│ └── api_deployment.md -└── archived/ # Archived/Deprecated PRDs -``` - -### Naming Convention -- Use snake_case for file names -- Include a prefix for the type of change: - - `feature_` for new features - - `enhancement_` for improvements - - `fix_` for bug fixes - - `refactor_` for code refactoring - - `api_` for API changes - -## Using the Template - -### Getting Started -1. Copy [template.md](mdc:prds/template.md) to create a new PRD -2. Place it in the `/prds/active` directory -3. Fill out each section following the template's comments and guidelines - -### Key Sections to Focus On -The template [template.md](mdc:prds/template.md) provides comprehensive sections. Pay special attention to: - -1. **Problem Statement** - - Must clearly articulate the current state - - Include measurable impact - - Reference any relevant metrics or data - -2. **Technical Design** - - Include all affected components - - Document ALL file changes (new/modified/deleted) - - Provide actual code examples - - Include database migrations if needed - -3. **Implementation Plan** - - Break down into deployable phases - - Include clear success criteria - - List dependencies between phases - - Provide testing strategy for each phase - -4. **Testing Strategy** - - Unit test requirements - - Integration test scenarios - -## Best Practices - -### Documentation -1. Use clear, concise language -2. Include code examples where relevant -3. Document assumptions and dependencies -4. Keep diagrams up to date -5. Use Mermaid for diagrams when possible - -### Lifecycle Management -1. Move PRDs between directories based on status: - - New PRDs → `/prds/active` - - Shipped PRDs → `/prds/completed` - - Deprecated PRDs → `/prds/archived` - -2. Update status section regularly: - - ✅ Completed items - - ⏳ In Progress items - - 🔜 Upcoming items - - ❌ Known Issues - -### Review Process -1. Technical review - - Architecture alignment - - Security considerations - - Performance implications - - Testing coverage - -2. Product review - - Feature completeness - - User impact - - Business value - - Success metrics - -## Common Pitfalls to Avoid -1. Incomplete technical specifications -2. Missing file change documentation -3. Unclear success criteria -4. Insufficient testing strategy -5. No rollback plan -6. Missing security considerations -7. Undefined monitoring metrics - -## Example PRDs -Reference these example PRDs for guidance: -[template.md](mdc:prds/template.md) - -## Checklist Before Submission -- [ ] All template sections completed -- [ ] Technical design is detailed and complete -- [ ] File changes are documented -- [ ] Implementation phases are clear -- [ ] Testing strategy is defined -- [ ] Security considerations addressed -- [ ] Dependencies and Files listed -- [ ] File References included diff --git a/cli/CLAUDE.md b/cli/CLAUDE.md new file mode 100644 index 000000000..efb985308 --- /dev/null +++ b/cli/CLAUDE.md @@ -0,0 +1,34 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Build Commands +- Build: `cargo build` +- Release build: `cargo build --release` +- Run tests: `cargo test` +- Run specific test: `cargo test test_name` +- Run tests in file: `cargo test --test filename` +- Run package tests: `cargo test -p ` +- Format: `cargo fmt` +- Lint: `cargo clippy` + +## Code Style Guidelines +- **Imports**: Group by std, external crates, internal modules; alphabetical order +- **Formatting**: 4-space indentation (standard Rust) +- **Error Handling**: Use `thiserror` for error types, `anyhow` for general propagation +- **Naming**: Follow Rust conventions (`snake_case` for variables/functions, `PascalCase` for types) +- **Types**: Define custom error types with descriptive messages +- **Dependencies**: Use workspace dependencies with `{ workspace = true }` +- **Testing**: Place in separate `/tests` directory; use `tempfile` for test directories +- **Never log secrets or sensitive data** + +## Project Info +- CLI for managing semantic models in Buster +- Uses semantic versioning (PR title conventions for bumps) + - Major: PR title with "BREAKING CHANGE" or "major", or PR with "major" label + - Minor: PR title with "feat", "feature", or "minor", or PR with "minor" label + - Patch: Default for all other PRs +- Cross-project references supported +- Config defined in `buster.yml` +- File and tag exclusions for deployment +- Row limit of 5000 is enforced for database queries by default \ No newline at end of file diff --git a/cli/Cargo.toml b/cli/Cargo.toml index ded2525f2..6fa8b981d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,20 +1,21 @@ -[package] -name = "buster-cli" -version = "0.0.7" -edition = "2021" -build = "build.rs" +[workspace] +members = [ + "cli", + # Add "libs/*" or specific lib crates here later +] -[lib] -name = "buster_cli" -path = "src/lib.rs" +[profile.release] +lto = true +strip = true +opt-level = "z" +codegen-units = 1 +panic = "abort" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] +[workspace.dependencies] anyhow = "1.0.79" clap = { version = "4.4.18", features = ["derive", "env"] } confy = "0.6.0" -dirs = "5.0.1" +dirs = "6.0.0" futures = "0.3.29" indicatif = "0.17.8" inquire = "0.7.5" @@ -38,11 +39,9 @@ url = "2.5.0" zip = "2.2.2" glob = "0.3.1" walkdir = "2.5.0" -# Add the shared query engine library -query_engine = { path = "../api/libs/query_engine" } +# The query_engine dependency needs a workspace-relative path +query_engine = { path = "../api/libs/query_engine" } # Adjusted path +chrono = "0.4" # Moved from build-dependencies -[dev-dependencies] -tempfile = "3.16.0" - -[build-dependencies] -chrono = "0.4" +# Keep dev-dependencies separate if they aren't shared +# tempfile = "3.16.0" \ No newline at end of file diff --git a/cli/cli/Cargo.toml b/cli/cli/Cargo.toml new file mode 100644 index 000000000..65aaf4544 --- /dev/null +++ b/cli/cli/Cargo.toml @@ -0,0 +1,48 @@ +[package] +name = "buster-cli" +version = "0.0.7" +edition = "2021" +build = "build.rs" + +[lib] +name = "buster_cli" +path = "src/lib.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = { workspace = true } +clap = { workspace = true, features = ["derive", "env"] } +confy = { workspace = true } +dirs = { workspace = true } +futures = { workspace = true } +indicatif = { workspace = true } +inquire = { workspace = true } +lazy_static = { workspace = true } +ratatui = { workspace = true } +regex = { workspace = true } +reqwest = { workspace = true, features = ["json", "rustls-tls", "stream"] } +rpassword = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +serde_yaml = { workspace = true } +tempfile = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true, features = ["full"] } +tokio-util = { workspace = true, features = ["io"] } +futures-util = { workspace = true } +uuid = { workspace = true, features = ["v4", "serde"] } +colored = { workspace = true } +rustls = { workspace = true, features = ["tls12"] } +url = { workspace = true } +zip = { workspace = true } +glob = { workspace = true } +walkdir = { workspace = true } +# Add the shared query engine library +query_engine = { workspace = true } + +[build-dependencies] +chrono = { workspace = true } + +[dev-dependencies] +tempfile = "3.16.0" diff --git a/cli/build.rs b/cli/cli/build.rs similarity index 100% rename from cli/build.rs rename to cli/cli/build.rs diff --git a/cli/src/assets/mod.rs b/cli/cli/src/assets/mod.rs similarity index 100% rename from cli/src/assets/mod.rs rename to cli/cli/src/assets/mod.rs diff --git a/cli/src/commands/auth.rs b/cli/cli/src/commands/auth.rs similarity index 100% rename from cli/src/commands/auth.rs rename to cli/cli/src/commands/auth.rs diff --git a/cli/src/commands/deploy.rs b/cli/cli/src/commands/deploy.rs similarity index 100% rename from cli/src/commands/deploy.rs rename to cli/cli/src/commands/deploy.rs diff --git a/cli/src/commands/generate.rs b/cli/cli/src/commands/generate.rs similarity index 100% rename from cli/src/commands/generate.rs rename to cli/cli/src/commands/generate.rs diff --git a/cli/src/commands/init.rs b/cli/cli/src/commands/init.rs similarity index 100% rename from cli/src/commands/init.rs rename to cli/cli/src/commands/init.rs diff --git a/cli/src/commands/mod.rs b/cli/cli/src/commands/mod.rs similarity index 100% rename from cli/src/commands/mod.rs rename to cli/cli/src/commands/mod.rs diff --git a/cli/src/commands/update.rs b/cli/cli/src/commands/update.rs similarity index 100% rename from cli/src/commands/update.rs rename to cli/cli/src/commands/update.rs diff --git a/cli/src/commands/version.rs b/cli/cli/src/commands/version.rs similarity index 100% rename from cli/src/commands/version.rs rename to cli/cli/src/commands/version.rs diff --git a/cli/src/error.rs b/cli/cli/src/error.rs similarity index 100% rename from cli/src/error.rs rename to cli/cli/src/error.rs diff --git a/cli/src/lib.rs b/cli/cli/src/lib.rs similarity index 100% rename from cli/src/lib.rs rename to cli/cli/src/lib.rs diff --git a/cli/src/main.rs b/cli/cli/src/main.rs similarity index 100% rename from cli/src/main.rs rename to cli/cli/src/main.rs diff --git a/cli/src/types/mod.rs b/cli/cli/src/types/mod.rs similarity index 100% rename from cli/src/types/mod.rs rename to cli/cli/src/types/mod.rs diff --git a/cli/src/utils/buster/api.rs b/cli/cli/src/utils/buster/api.rs similarity index 100% rename from cli/src/utils/buster/api.rs rename to cli/cli/src/utils/buster/api.rs diff --git a/cli/src/utils/buster/mod.rs b/cli/cli/src/utils/buster/mod.rs similarity index 100% rename from cli/src/utils/buster/mod.rs rename to cli/cli/src/utils/buster/mod.rs diff --git a/cli/src/utils/buster/types.rs b/cli/cli/src/utils/buster/types.rs similarity index 100% rename from cli/src/utils/buster/types.rs rename to cli/cli/src/utils/buster/types.rs diff --git a/cli/src/utils/dbt/command.rs b/cli/cli/src/utils/dbt/command.rs similarity index 100% rename from cli/src/utils/dbt/command.rs rename to cli/cli/src/utils/dbt/command.rs diff --git a/cli/src/utils/dbt/mod.rs b/cli/cli/src/utils/dbt/mod.rs similarity index 100% rename from cli/src/utils/dbt/mod.rs rename to cli/cli/src/utils/dbt/mod.rs diff --git a/cli/src/utils/exclusion.rs b/cli/cli/src/utils/exclusion.rs similarity index 100% rename from cli/src/utils/exclusion.rs rename to cli/cli/src/utils/exclusion.rs diff --git a/cli/src/utils/file/buster_credentials.rs b/cli/cli/src/utils/file/buster_credentials.rs similarity index 100% rename from cli/src/utils/file/buster_credentials.rs rename to cli/cli/src/utils/file/buster_credentials.rs diff --git a/cli/src/utils/file/mod.rs b/cli/cli/src/utils/file/mod.rs similarity index 100% rename from cli/src/utils/file/mod.rs rename to cli/cli/src/utils/file/mod.rs diff --git a/cli/src/utils/file/model_files.rs b/cli/cli/src/utils/file/model_files.rs similarity index 100% rename from cli/src/utils/file/model_files.rs rename to cli/cli/src/utils/file/model_files.rs diff --git a/cli/src/utils/file/profiles.rs b/cli/cli/src/utils/file/profiles.rs similarity index 100% rename from cli/src/utils/file/profiles.rs rename to cli/cli/src/utils/file/profiles.rs diff --git a/cli/src/utils/file/project_files.rs b/cli/cli/src/utils/file/project_files.rs similarity index 100% rename from cli/src/utils/file/project_files.rs rename to cli/cli/src/utils/file/project_files.rs diff --git a/cli/src/utils/formatting/mod.rs b/cli/cli/src/utils/formatting/mod.rs similarity index 100% rename from cli/src/utils/formatting/mod.rs rename to cli/cli/src/utils/formatting/mod.rs diff --git a/cli/src/utils/formatting/text.rs b/cli/cli/src/utils/formatting/text.rs similarity index 100% rename from cli/src/utils/formatting/text.rs rename to cli/cli/src/utils/formatting/text.rs diff --git a/cli/src/utils/mod.rs b/cli/cli/src/utils/mod.rs similarity index 100% rename from cli/src/utils/mod.rs rename to cli/cli/src/utils/mod.rs diff --git a/cli/src/utils/yaml_diff_merger.rs b/cli/cli/src/utils/yaml_diff_merger.rs similarity index 100% rename from cli/src/utils/yaml_diff_merger.rs rename to cli/cli/src/utils/yaml_diff_merger.rs diff --git a/cli/logs/dbt.log b/cli/logs/dbt.log deleted file mode 100644 index 83e52daf4..000000000 --- a/cli/logs/dbt.log +++ /dev/null @@ -1,15 +0,0 @@ -10:11:41.254969 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'start', 'context': [, , ]} -10:11:41.258532 [debug] [MainThread]: An error was encountered while trying to send an event - - -============================== 10:11:41.258772 | 8c4dc64d-ac69-441f-a617-03e73c0e10ba ============================== -10:11:41.258772 [info ] [MainThread]: Running with dbt=1.9.1 -10:11:41.259035 [debug] [MainThread]: running dbt with arguments {'printer_width': '80', 'indirect_selection': 'eager', 'write_json': 'True', 'log_cache_events': 'False', 'partial_parse': 'True', 'cache_selected_only': 'False', 'warn_error': 'None', 'version_check': 'True', 'debug': 'False', 'log_path': 'logs', 'profiles_dir': '/Users/dallin/.dbt', 'fail_fast': 'False', 'use_colors': 'True', 'use_experimental_parser': 'False', 'empty': 'None', 'quiet': 'False', 'no_print': 'None', 'log_format': 'default', 'invocation_command': 'dbt ', 'static_parser': 'True', 'warn_error_options': 'WarnErrorOptions(include=[], exclude=[])', 'target_path': 'None', 'introspect': 'True', 'send_anonymous_usage_stats': 'True'} -10:11:41.259522 [error] [MainThread]: Encountered an error: -Runtime Error - dbt_project.yml does not parse to a dictionary -10:11:41.264844 [debug] [MainThread]: Resource report: {"command_name": "deps", "command_success": false, "command_wall_clock_time": 0.0560595, "process_in_blocks": "0", "process_kernel_time": 0.111403, "process_mem_max_rss": "107298816", "process_out_blocks": "0", "process_user_time": 0.711051} -10:11:41.265321 [debug] [MainThread]: Command `cli deps` failed at 10:11:41.265251 after 0.06 seconds -10:11:41.265532 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'end', 'context': [, , ]} -10:11:41.265670 [debug] [MainThread]: An error was encountered while trying to send an event -10:11:41.265786 [debug] [MainThread]: Flushing usage events diff --git a/cli/test_excluded_tags.sql b/cli/test_excluded_tags.sql deleted file mode 100644 index 31dfe755a..000000000 --- a/cli/test_excluded_tags.sql +++ /dev/null @@ -1,9 +0,0 @@ -{{ config( - materialized = "table", - tags = ["test", "exclude_me", "development"] -) }} - -SELECT - 1 as id, - 'test' as name, - current_timestamp() as created_at \ No newline at end of file