-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: Add conflict
command to differentiate versioning
#292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
eba184b
feat: add deps and update config file
zhravan 16a4b53
feat: register the command conflict
zhravan f308257
feat: add messages and test cases to handle errors | core business lo…
zhravan 3d1e12f
feat: add all commands
zhravan 2e7ea8b
feat: remove duplicates and refine the commands
zhravan 5f1f047
chore: resolve conflicts
zhravan 707951a
self-review: claenup logic and commands
zhravan 1352f0b
test-case: refactoring and add test cases
zhravan 754b250
self-review: use existing outputformatter
zhravan e0d6144
feat:review comments
zhravan cc2f81a
chores: address review comments
zhravan e9e98fe
chores: address review comments
zhravan 7c77fa6
chores: address review comments | test cases fixed
zhravan 7fd957e
Merge branch 'feat/cli' into feat/cli_/conflict
raghavyuva 55830f1
Merge branch 'feat/cli' of github.com:raghavyuva/nixopus into feat/cl…
zhravan 0c6373e
Merge branch 'feat/cli_/conflict' of github.com:shravan20/nixopus int…
zhravan 8ed4187
chores: refactoring the code
zhravan 986dabf
chores: update .gitignore
zhravan fd85279
chore: resolve conflicts
zhravan 8721a35
chore: resolve conflicts
zhravan 902fd85
feat: development configs and prod configs separations
zhravan 44946e0
chores: addressed review comments
zhravan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,6 @@ htmlcov/ | |
|
||
# Poetry | ||
poetry.lock | ||
|
||
**/.DS_Store | ||
.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,73 @@ | ||
.PHONY: help install install-dev test test-cov lint clean format check build publish dev run | ||
.PHONY: help setup test test-cov lint clean format check build publish dev nixopus | ||
|
||
help: | ||
@echo "Available commands:" | ||
help: ## Show available commands | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
||
install: | ||
poetry install | ||
setup: ## Setup Python environment and install dependencies | ||
@if command -v poetry >/dev/null 2>&1; then \ | ||
echo "Poetry found. Installing dependencies..."; \ | ||
poetry install --with dev --quiet; \ | ||
echo "Environment ready! Use: make nixopus ARGS=\"command\""; \ | ||
else \ | ||
echo "Poetry not found. Installing Poetry..."; \ | ||
curl -sSL https://install.python-poetry.org | python3 - >/dev/null 2>&1; \ | ||
echo "Poetry installed. Please restart your shell or run: source ~/.bashrc (or ~/.zshrc)"; \ | ||
echo "Then run 'make setup' again to install dependencies."; \ | ||
fi | ||
|
||
install-dev: | ||
poetry install --with dev --no-root | ||
test: ## Run tests | ||
@poetry run pytest | ||
|
||
test: | ||
poetry run pytest | ||
test-cov: ## Run tests with coverage | ||
@poetry run pytest --cov=app --cov-report=term-missing --cov-report=html | ||
|
||
test-cov: | ||
poetry run pytest --cov=core --cov=utils --cov-report=term-missing --cov-report=html | ||
lint: ## Run linting | ||
@poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
@poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
|
||
test-watch: | ||
poetry run pytest-watch | ||
format: ## Format code | ||
@poetry run black . --quiet | ||
@poetry run isort . --quiet | ||
|
||
lint: | ||
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
check: ## Run linting and tests | ||
$(MAKE) lint && $(MAKE) test | ||
|
||
format: | ||
poetry run black . | ||
poetry run isort . | ||
clean: ## Clean build artifacts | ||
@rm -rf build/ dist/ *.egg-info/ .pytest_cache/ htmlcov/ .coverage | ||
@find . -type d -name __pycache__ -delete | ||
@find . -type f -name "*.pyc" -delete | ||
|
||
check: | ||
$(MAKE) lint | ||
$(MAKE) test | ||
build: ## Build the package | ||
@poetry build | ||
|
||
clean: | ||
rm -rf build/ | ||
rm -rf dist/ | ||
rm -rf *.egg-info/ | ||
rm -rf .pytest_cache/ | ||
rm -rf htmlcov/ | ||
rm -rf .coverage | ||
find . -type d -name __pycache__ -delete | ||
find . -type f -name "*.pyc" -delete | ||
publish: ## Publish to PyPI | ||
@poetry publish | ||
|
||
build: | ||
poetry build | ||
dev: ## Activate development shell | ||
@poetry shell | ||
|
||
publish: | ||
poetry publish | ||
|
||
dev: | ||
poetry shell | ||
# ----------------------------------------------------------------------------- | ||
# Nixopus test CLI commands | ||
# ----------------------------------------------------------------------------- | ||
nixopus: ## Run nixopus CLI | ||
@if [ -z "$(ARGS)" ]; then \ | ||
poetry run nixopus --help; \ | ||
else \ | ||
poetry run nixopus $(ARGS); \ | ||
fi | ||
|
||
run: | ||
conflict: ## Run conflict command | ||
@poetry run nixopus conflict $(ARGS) | ||
|
||
preflight: ## Run preflight command | ||
@poetry run nixopus preflight $(ARGS) | ||
|
||
version: ## Show version | ||
@poetry run nixopus version | ||
|
||
run: ## Run nixopus CLI directly | ||
poetry run nixopus | ||
|
||
generate-docs: | ||
typer app.main utils docs --output | ||
../docs/cli/cli-reference.md --name | ||
nixopus | ||
generate-docs: ## Generate CLI documentation | ||
typer app.main utils docs --output ../docs/cli/cli-reference.md --name nixopus |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import typer | ||
from .conflict import ConflictConfig, ConflictService | ||
from .messages import ( | ||
conflict_check_help, | ||
error_checking_conflicts, | ||
conflicts_found_warning, | ||
no_conflicts_info, | ||
checking_conflicts_info, | ||
) | ||
from app.utils.logger import Logger | ||
from app.utils.timeout import TimeoutWrapper | ||
|
||
conflict_app = typer.Typer(help=conflict_check_help, no_args_is_help=False) | ||
|
||
|
||
@conflict_app.callback(invoke_without_command=True) | ||
def conflict_callback( | ||
ctx: typer.Context, | ||
config_file: str = typer.Option("helpers/config.prod.yaml", "--config-file", "-c", help="Path to configuration file"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use config to load this default option |
||
timeout: int = typer.Option(5, "--timeout", "-t", help="Timeout for tool checks in seconds"), | ||
verbose: bool = typer.Option(False, "--verbose", "-v", help="Verbose output"), | ||
output: str = typer.Option("text", "--output", "-o", help="Output format (text/json)"), | ||
) -> None: | ||
"""Check for tool version conflicts""" | ||
if ctx.invoked_subcommand is None: | ||
# Initialize logger once and reuse throughout | ||
logger = Logger(verbose=verbose) | ||
|
||
try: | ||
logger.info(checking_conflicts_info) | ||
|
||
config = ConflictConfig( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make use of the timeout wrapper here like other commands instead of passing the timeout variable |
||
config_file=config_file, | ||
verbose=verbose, | ||
output=output, | ||
) | ||
|
||
service = ConflictService(config, logger=logger) | ||
|
||
with TimeoutWrapper(timeout): | ||
result = service.check_and_format(output) | ||
# Check if there are any conflicts and exit with appropriate code | ||
results = service.check_conflicts() | ||
conflicts = [r for r in results if r.conflict] | ||
|
||
if conflicts: | ||
logger.error(result) | ||
logger.warning(conflicts_found_warning.format(count=len(conflicts))) | ||
raise typer.Exit(1) | ||
else: | ||
logger.success(result) | ||
logger.info(no_conflicts_info) | ||
|
||
except TimeoutError as e: | ||
logger.error(str(e)) | ||
raise typer.Exit(1) | ||
except Exception as e: | ||
logger.error(error_checking_conflicts.format(error=str(e))) | ||
raise typer.Exit(1) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.