Skip to content

Commit d9ca027

Browse files
fix: correct __main__.py entry point to import cli instead of nonexistent main (#23)
# Conflicts: # README.md
2 parents 65e0ea4 + 9a866fa commit d9ca027

8 files changed

Lines changed: 82 additions & 50 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ on:
77
pull_request:
88
branches: [master]
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
test:
1215
runs-on: ubuntu-latest
1316
strategy:
1417
matrix:
15-
python-version: ["3.11", "3.12"]
18+
python-version: ["3.11", "3.12", "3.13"]
1619

1720
steps:
1821
- uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
1924

2025
- name: Set up Python ${{ matrix.python-version }}
2126
uses: actions/setup-python@v5
@@ -42,6 +47,8 @@ jobs:
4247

4348
steps:
4449
- uses: actions/checkout@v4
50+
with:
51+
persist-credentials: false
4552

4653
- name: Set up Python
4754
uses: actions/setup-python@v5

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
id-token: write
1414

1515
steps:
16-
- uses: actions/checkout@v6
16+
- uses: actions/checkout@v4
1717

1818
- name: Set up Python
19-
uses: actions/setup-python@v6
19+
uses: actions/setup-python@v5
2020
with:
2121
python-version: '3.12'
2222

CHANGELOG.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,42 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.1.0] - 2025-05-17
8+
## [Unreleased]
99

1010
### Added
11-
- Initial beta release
12-
- Core functionality
13-
- CLI interface
14-
- Test suite
15-
- CI/CD workflows with ruff lint and pytest
16-
- CONTRIBUTING.md
11+
12+
- MCP server integration via `mcp` subcommand
13+
- `__main__.py` for `python -m deadcode` support
14+
- CLI test suite covering all subcommands
15+
- npm wrapper (`package.json` + `cli.js`) for npm publishing
16+
- GitHub Actions: npm publish workflow (release or manual dispatch)
17+
- GitHub Actions: PyPI publish workflow
18+
- GitHub Actions: GitHub Pages deployment workflow
19+
- `CONTRIBUTING.md` with development setup and PR guidelines
20+
- `SECURITY.md` with security policy
21+
- Homebrew and Scoop install methods
22+
- Directory listing badges: Open Source Alternative, LibHunt, Awesome Python
23+
- `revenueholdings-license` gating on all CLI commands
24+
- Beta badge and star CTA in README header
25+
- npm keywords optimized for discoverability (15 terms)
26+
27+
### Changed
28+
29+
- npm package renamed for consistency
30+
- CI test matrix expanded to include Python 3.13
31+
- CI security hardened: `persist-credentials: false`, restricted permissions
32+
- Documentation branding updated from DevForge to Revenue Holdings
33+
- README tool count updated (8 → 11)
34+
- `project.urls` metadata added to `pyproject.toml`
35+
36+
### Fixed
37+
38+
- CI badge updated to reference correct workflow file
39+
- UTF-8 encoding (mojibake) in file output
40+
- Ruff lint issues: `datetime.UTC`, `X | None` syntax, `E501`, `B904`, `F821`
41+
- Missing `ruff` dev dependency in `pyproject.toml`
42+
- Duplicate `test.yml` workflow removed
43+
- `revenueholdings-license` import made optional (fixes CI failures on open-source PRs)
44+
- Dependencies bumped via Dependabot (checkout@v6, setup-node@v6, setup-python@v6, rich, pyyaml)
45+
- Orphaned npm install section removed from README
46+
- Scanner category count corrected (3 → 4)

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
# DeadCode
22

33
[![GitHub stars](https://img.shields.io/github/stars/Coding-Dev-Tools/deadcode?style=social)](https://github.com/Coding-Dev-Tools/deadcode/stargazers)
4-
[![Awesome DevOps](https://img.shields.io/badge/Awesome_DevOps-Submitted-grey?logo=github)](https://github.com/wmariuss/awesome-devops)<!-- PR #433 -->
54

65
**Detect and remove unused exports, dead routes, orphaned CSS, and unreferenced components in TypeScript/React/Next.js projects.**
76

87
> **Star this repo** if you care about bundle size — it helps other devs find DeadCode!
98
10-
[![PyPI](https://img.shields.io/pypi/v/deadcode)](https://pypi.org/project/deadcode/)
11-
[![Python](https://img.shields.io/pypi/pyversions/deadcode)](https://pypi.org/project/deadcode/)
12-
[![License](https://img.shields.io/pypi/l/deadcode)](https://github.com/Coding-Dev-Tools/deadcode/blob/main/LICENSE)
9+
[![PyPI](https://img.shields.io/pypi/v/deadcode-cli)](https://pypi.org/project/deadcode-cli/)
10+
[![Python](https://img.shields.io/pypi/pyversions/deadcode-cli)](https://pypi.org/project/deadcode-cli/)
11+
[![License](https://img.shields.io/pypi/l/deadcode-cli)](https://github.com/Coding-Dev-Tools/deadcode/blob/main/LICENSE)
1312
[![CI](https://github.com/Coding-Dev-Tools/deadcode/actions/workflows/ci.yml/badge.svg)](https://github.com/Coding-Dev-Tools/deadcode/actions/workflows/ci.yml)
1413
[![Open Source Alternative](https://img.shields.io/badge/Open_Source_Alternative-%E2%87%92-blue?logo=opensourceinitiative)](https://www.opensourcealternative.to/project/deadcode)
1514
[![LibHunt](https://img.shields.io/badge/LibHunt-%E2%87%92-blue?logo=codeigniter)](https://www.libhunt.com/r/Coding-Dev-Tools/deadcode)
16-
[![Awesome Python](https://img.shields.io/badge/Awesome_Python-%E2%87%92-blue?logo=python)](https://github.com/uhub/awesome-python)
1715

18-
**Why DeadCode?** Dead code silently bloats your bundle, slows your CI, and confuses new developers. Linters catch unused variables — but they miss orphaned React components, CSS classes nobody references, API routes with zero traffic, and exported functions called from nowhere. DeadCode finds all of it. It maps your entire dependency graph, marks what's reachable, and flags everything else for removal. Run it in CI to prevent dead code from shipping in the first place.
19-
20-
## Quick Start
16+
## Installation
2117

2218
```bash
2319
pip install deadcode
@@ -114,7 +110,7 @@ DeadCode is one of 11 tools in the DevForge suite. One license covers all CLI to
114110
| Feature | Free | Individual | Suite | Team | Enterprise |
115111
|---------|:----:|:----------:|:-----:|:----:|:----------:|
116112
| CLI: scan, stats ||||||
117-
| All 3 scanner categories ||||||
113+
| All 4 scanner categories ||||||
118114
| Auto-removal (`deadcode remove`) ||||||
119115
| Unlimited file scanning ||||||
120116
| CI/CD integration (JSON output) ||||||
@@ -127,7 +123,7 @@ DeadCode is one of 11 tools in the DevForge suite. One license covers all CLI to
127123
---
128124

129125
<p align="center">
130-
<sub>Part of <a href="https://coding-dev-tools.github.io/devforge.dev/">DevForge</a> — CLI tools built by autonomous AI.</sub>
126+
<sub>Part of <a href="https://coding-dev-tools.github.io/revenueholdings.dev/">Revenue Holdings</a> — CLI tools built by autonomous AI.</sub>
131127
</p>
132128

133129
## CI/CD Integration

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ requires = ["setuptools>=68.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "deadcode"
6+
name = "deadcode-cli"
77
version = "0.1.1"
88
description = "CLI tool to detect and auto-remove unused exports, dead routes, orphaned CSS in TS/React/Next.js projects"
99
readme = "README.md"
1010
requires-python = ">=3.10"
1111
license = "MIT"
1212
authors = [{name = "Revenue Holdings"}]
13-
urls = {Homepage = "https://github.com/Coding-Dev-Tools/deadcode", Repository = "https://github.com/Coding-Dev-Tools/deadcode"}
1413
keywords = ["dead-code", "unused-exports", "typescript", "react", "nextjs", "cli", "css", "tree-shaking"]
1514
classifiers = [
1615
"Development Status :: 4 - Beta",
@@ -38,6 +37,13 @@ dev = [
3837
"ruff>=0.4.0",
3938
]
4039

40+
[project.urls]
41+
Homepage = "https://github.com/Coding-Dev-Tools/deadcode"
42+
Documentation = "https://coding-dev-tools.github.io/deadcode"
43+
Repository = "https://github.com/Coding-Dev-Tools/deadcode"
44+
Issues = "https://github.com/Coding-Dev-Tools/deadcode/issues"
45+
Changelog = "https://github.com/Coding-Dev-Tools/deadcode/releases"
46+
4147
[project.scripts]
4248
deadcode = "deadcode.cli:cli"
4349

src/deadcode/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Allow running deadcode as: python -m deadcode"""
2+
from deadcode.cli import cli
3+
4+
if __name__ == "__main__":
5+
cli()

tests/test_scanner.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
from deadcode.cli import cli
88
from deadcode.scanner import DeadCodeScanner
9+
from pathlib import Path
910

1011

1112
@pytest.fixture
@@ -292,3 +293,18 @@ def test_stats_command(self, runner, sample_project):
292293
assert result.exit_code == 0
293294
assert "Files scanned" in result.output
294295
assert "Unused exports" in result.output
296+
297+
def test_main_module_entry_point(self, runner):
298+
"""Test that python -m deadcode works (__main__ entry point fix)."""
299+
import subprocess
300+
import sys
301+
result = subprocess.run(
302+
[sys.executable, "-m", "deadcode", "--help"],
303+
capture_output=True, text=True,
304+
cwd=str(Path(__file__).parent.parent / "src"),
305+
)
306+
assert result.returncode == 0
307+
assert "DeadCode" in result.stdout
308+
assert "scan" in result.stdout
309+
assert "remove" in result.stdout
310+
assert "stats" in result.stdout

0 commit comments

Comments
 (0)