|
1 | 1 | # dependency-resolver |
2 | 2 |
|
3 | 3 | A tool for creating snapshots of installed packages on specified target environments. The project provides both a command-line interface and a Python library for programmatic use. |
4 | | -Its main focus is dependency resolving of Docker containers, but it also supports dependency resolving on the host system. |
5 | | -The output is a structured JSON that includes information about all the installed packages from supported sources with their version and unique hash values. |
| 4 | + |
| 5 | +Its main focus is dependency resolving of Docker containers, but it also supports dependency resolving on the host system. The output is a structured JSON that includes information about all the installed packages from supported sources with their version and unique hash values. |
6 | 6 |
|
7 | 7 | ## Installation |
8 | 8 |
|
9 | 9 | ```bash |
10 | | -# Clone and install |
11 | 10 | git clone https://github.com/green-coding-solutions/dependency-resolver |
12 | 11 | cd dependency-resolver |
13 | 12 | pip install . |
14 | 13 | ``` |
15 | 14 |
|
16 | | -## Usage |
17 | | - |
18 | | -The dependency-resolver can be used in two ways: |
19 | | - |
20 | | -1. **Command Line Interface (CLI)** - For direct terminal usage |
21 | | -2. **Programmatic Interface** - As a Python library in other projects |
22 | | - |
23 | | -### Command Line Interface |
| 15 | +## Quick Start |
24 | 16 |
|
25 | 17 | ```bash |
26 | | -# Analyze host system (default behavior) |
| 18 | +# Analyze host system |
27 | 19 | python3 -m dependency_resolver |
28 | 20 |
|
29 | | -# Explicitly specify host environment |
30 | | -python3 -m dependency_resolver host |
31 | | - |
32 | | -# Analyze Docker container by name |
| 21 | +# Analyze Docker container |
33 | 22 | python3 -m dependency_resolver docker nginx |
34 | 23 |
|
35 | | -# Analyze Docker container by ID |
36 | | -python3 -m dependency_resolver docker a1b2c3d4e5f6 |
37 | | - |
38 | | -# Get only container metadata (skip dependency detection) |
39 | | -python3 -m dependency_resolver docker nginx --only-container-info |
40 | | - |
41 | | -# Enable debug output |
42 | | -python3 -m dependency_resolver --debug |
43 | | - |
44 | | -# Set working directory |
45 | | -python3 -m dependency_resolver --working-dir /path/to/project |
46 | | - |
47 | | -# Skip system scope package managers |
48 | | -python3 -m dependency_resolver --skip-system-scope |
49 | | - |
50 | | -# Pretty print JSON output |
| 24 | +# Pretty print output |
51 | 25 | python3 -m dependency_resolver --pretty-print |
52 | | -``` |
53 | | - |
54 | | -### Programmatic Interface |
55 | | - |
56 | | -The dependency-resolver can also be used as a Python library in other projects. Here are some examples: |
57 | 26 |
|
58 | | -```python |
59 | | -import dependency_resolver |
60 | | - |
61 | | -# Simple host system analysis |
62 | | -deps_json = dependency_resolver.resolve_host_dependencies() |
63 | | - |
64 | | -# Get results as Python dictionary for further processing |
65 | | -deps_dict = dependency_resolver.resolve_dependencies_as_dict( |
66 | | - environment_type="host", |
67 | | - skip_system_scope=True |
68 | | -) |
69 | | - |
70 | | -# Docker container analysis |
71 | | -docker_deps = dependency_resolver.resolve_docker_dependencies( |
72 | | - container_identifier="nginx", |
73 | | - working_dir="/app" |
74 | | -) |
75 | | - |
76 | | -# Advanced usage with direct access to core classes |
77 | | -from dependency_resolver import Orchestrator, HostExecutor, OutputFormatter |
78 | | - |
79 | | -executor = HostExecutor() |
80 | | -orchestrator = Orchestrator(debug=True, skip_system_scope=True) |
81 | | -dependencies = orchestrator.resolve_dependencies(executor) |
82 | | -formatter = OutputFormatter() |
83 | | -json_output = formatter.format_json(dependencies, pretty_print=True) |
| 27 | +# Get help with all options |
| 28 | +python3 -m dependency_resolver -h |
84 | 29 | ``` |
85 | 30 |
|
86 | | -**Available convenience functions:** |
| 31 | +## Supported Package Managers |
| 32 | + |
| 33 | +- **apt/dpkg** - System packages Ubuntu/Debian |
| 34 | +- **apk** - System packages of Alpine |
| 35 | +- **pip** - Python packages |
| 36 | +- **npm** - Node.js packages |
87 | 37 |
|
88 | | -- `resolve_host_dependencies()` - Analyze host system, returns JSON string |
89 | | -- `resolve_docker_dependencies()` - Analyze Docker container, returns JSON string |
90 | | -- `resolve_docker_dependencies_as_dict()` - Analyze Docker container, returns Python dictionary |
91 | | -- `resolve_dependencies_as_dict()` - Generic analysis, returns Python dictionary |
| 38 | +Also captures **Docker container metadata** when analyzing containers. |
92 | 39 |
|
93 | | -**Available classes for advanced usage:** |
| 40 | +## Usage Options |
94 | 41 |
|
95 | | -- `Orchestrator` - Main dependency resolution coordinator |
96 | | -- `HostExecutor`, `DockerExecutor` - Environment adapters |
97 | | -- `OutputFormatter` - JSON formatting utilities |
| 42 | +### Command Line Interface |
98 | 43 |
|
99 | | -### Supported Environments |
| 44 | +For terminal usage with full control over options and environments. |
100 | 45 |
|
101 | | -- **host** - Host system analysis (default) |
102 | | -- **docker** - Docker container analysis (requires container ID or name) |
| 46 | +### Programmatic Interface |
103 | 47 |
|
104 | | -### Supported Detectors |
| 48 | +Use as a Python library in other projects: |
105 | 49 |
|
106 | | -**Package Managers:** |
| 50 | +```python |
| 51 | +import dependency_resolver |
107 | 52 |
|
108 | | -- **apt/dpkg** - System packages Ubuntu/Debian |
109 | | -- **apk** - System packages of Alpine |
110 | | -- **pip** - Python packages |
111 | | -- **npm** - Node.js packages |
| 53 | +# Analyze host system |
| 54 | +deps = dependency_resolver.resolve_host_dependencies() |
112 | 55 |
|
113 | | -**Container Information:** |
114 | | - |
115 | | -- **docker-info** - Docker container metadata and base image details |
116 | | - |
117 | | -### Output Format |
118 | | - |
119 | | -The tool outputs JSON with the following structure: |
120 | | - |
121 | | -```json |
122 | | -{ |
123 | | - "_container-info": { |
124 | | - "name": "nginx-container", |
125 | | - "image": "nginx:latest", |
126 | | - "hash": "sha256:2cd1d97f893f..." |
127 | | - }, |
128 | | - "dpkg": { |
129 | | - "scope": "system", |
130 | | - "dependencies": { |
131 | | - "package-name": { |
132 | | - "version": "1.2.3 amd64", |
133 | | - "hash": "abc123..." |
134 | | - } |
135 | | - } |
136 | | - }, |
137 | | - "pip": { |
138 | | - "scope": "project", |
139 | | - "location": "/path/to/venv/lib/python3.12/site-packages", |
140 | | - "hash": "def456...", |
141 | | - "dependencies": { |
142 | | - "package-name": { |
143 | | - "version": "1.2.3" |
144 | | - } |
145 | | - } |
146 | | - } |
147 | | -} |
| 56 | +# Analyze Docker container |
| 57 | +docker_deps = dependency_resolver.resolve_docker_dependencies("nginx") |
148 | 58 | ``` |
149 | 59 |
|
150 | 60 | ## Documentation |
151 | 61 |
|
152 | | -### Architecture & Detector Documentation |
153 | | - |
154 | | -For detailed information about architectural decisions and package manager implementations: |
155 | | - |
156 | | -- **Architecture Decision Records**: See [docs/adr/](./docs/adr/) for architectural decisions |
157 | | -- **Detector Documentation**: See [docs/detectors/](./docs/detectors/) for detailed implementation information: |
158 | | - - [APK Detector](./docs/detectors/apk_detector.md) - Alpine Linux package detection |
159 | | - - [DPKG Detector](./docs/detectors/dpkg_detector.md) - Debian/Ubuntu package detection |
160 | | - - [NPM Detector](./docs/detectors/npm_detector.md) - Node.js package detection |
161 | | - - [PIP Detector](./docs/detectors/pip_detector.md) - Python package detection |
162 | | - - [Docker Info Detector](./docs/detectors/docker_info_detector.md) - Individual container metadata |
163 | | - |
164 | | -See the complete [SPECIFICATION.md](./SPECIFICATION.md) for detailed requirements and implementation constraints. |
| 62 | +- **[Quick Start Guide](./docs/guides/quick-start.md)** - Get up and running |
| 63 | +- **[CLI Usage Guide](./docs/usage/cli-guide.md)** - Complete command line reference |
| 64 | +- **[Python API Guide](./docs/usage/programmatic-api.md)** - Programmatic usage |
| 65 | +- **[Output Format Guide](./docs/usage/output-format.md)** - Understanding the JSON results |
| 66 | +- **[Troubleshooting](./docs/guides/troubleshooting.md)** - Common issues and solutions |
| 67 | +- **[Technical Documentation](./docs/technical/)** - Architecture and implementation details |
165 | 68 |
|
166 | 69 | ## Contributing |
167 | 70 |
|
168 | 71 | For development setup, contribution guidelines, and information about running tests and code quality checks, please see [CONTRIBUTING.md](./CONTRIBUTING.md). |
| 72 | + |
| 73 | +## Requirements and Design |
| 74 | + |
| 75 | +See the complete [SPECIFICATION.md](./SPECIFICATION.md) for detailed requirements and implementation constraints. |
0 commit comments