Skip to content

Commit 5392b6e

Browse files
committed
feat: auto-detect project name from manifest files
- Add --name flag to override auto-detected project name - Add RenameNode method to DAG for renaming __project__ root - Extract project name from manifests: - Cargo.toml: [package].name - go.mod: module directive - package.json: name field - composer.json: name field - pom.xml: groupId:artifactId - poetry.lock/requirements.txt: pyproject.toml (sibling) - Gemfile: *.gemspec (sibling) - Add example pyproject.toml and gemspec files
1 parent 319c9ff commit 5392b6e

22 files changed

Lines changed: 924 additions & 932 deletions

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ stacktower parse go examples/manifest/go.mod -o deps.json
7878

7979
When the argument exists on disk or matches a known manifest filename, Stacktower automatically parses it as a manifest.
8080

81+
The project name (root node) is auto-detected from the manifest or a sibling file:
82+
- **Cargo.toml**: `[package].name`
83+
- **go.mod**: `module` directive
84+
- **package.json**: `name` field
85+
- **composer.json**: `name` field
86+
- **pom.xml**: `groupId:artifactId`
87+
- **poetry.lock / requirements.txt**: `pyproject.toml` (sibling)
88+
- **Gemfile**: `*.gemspec` (sibling)
89+
90+
Use `--name` to override the auto-detected name:
91+
92+
```bash
93+
stacktower parse python requirements.txt --name="my-project" -o deps.json
94+
stacktower parse ruby Gemfile -n my-rails-app -o deps.json
95+
```
96+
8197
#### Explicit Mode
8298

8399
Force registry or manifest parsing when auto-detection isn't enough:
@@ -165,6 +181,7 @@ stacktower render examples/test/diamond.json -o diamond.svg
165181
| Flag | Description |
166182
|------|-------------|
167183
| `-o`, `--output` | Output file (stdout if empty) |
184+
| `-n`, `--name` | Project name for manifest parsing (auto-detected from manifest if not set) |
168185
| `--max-depth N` | Maximum dependency depth (default: 10) |
169186
| `--max-nodes N` | Maximum packages to fetch (default: 5000) |
170187
| `--enrich` | Enrich with GitHub metadata (default: true, requires `GITHUB_TOKEN`) |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Gem::Specification.new do |spec|
2+
spec.name = "example-ruby-app"
3+
spec.version = "1.0.0"
4+
spec.authors = ["Example Author"]
5+
spec.summary = "Example Ruby application for testing stacktower"
6+
7+
spec.files = Dir["lib/**/*"]
8+
spec.require_paths = ["lib"]
9+
10+
spec.add_dependency "rails", "~> 7.1"
11+
spec.add_dependency "pg", "~> 1.1"
12+
end
13+

examples/manifest/pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[project]
2+
name = "example-python-project"
3+
version = "0.1.0"
4+
description = "Example project for testing stacktower manifest parsing"
5+
requires-python = ">=3.9"
6+
dependencies = [
7+
"requests>=2.28.0",
8+
"click>=8.0.0",
9+
"pydantic>=2.0.0",
10+
"httpx>=0.24.0",
11+
"rich>=13.0.0",
12+
]
13+
14+
[tool.poetry]
15+
name = "example-python-project"
16+
version = "0.1.0"
17+
description = "Example project for testing stacktower manifest parsing"
18+
19+
[tool.poetry.dependencies]
20+
python = "^3.9"
21+
requests = "^2.28.0"
22+
click = "^8.0.0"
23+
pydantic = "^2.0.0"
24+
httpx = "^0.24.0"
25+
rich = "^13.0.0"
26+

0 commit comments

Comments
 (0)