🧹 Dependency Scanner and Pruner
go dependency dependencies
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Initial commit

Fuwn 5b0be377

+871
+1
.gitignore
··· 1 + deppa
+202
LICENSE-APACHE
··· 1 + 2 + Apache License 3 + Version 2.0, January 2004 4 + http://www.apache.org/licenses/ 5 + 6 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 + 8 + 1. Definitions. 9 + 10 + "License" shall mean the terms and conditions for use, reproduction, 11 + and distribution as defined by Sections 1 through 9 of this document. 12 + 13 + "Licensor" shall mean the copyright owner or entity authorized by 14 + the copyright owner that is granting the License. 15 + 16 + "Legal Entity" shall mean the union of the acting entity and all 17 + other entities that control, are controlled by, or are under common 18 + control with that entity. For the purposes of this definition, 19 + "control" means (i) the power, direct or indirect, to cause the 20 + direction or management of such entity, whether by contract or 21 + otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 + outstanding shares, or (iii) beneficial ownership of such entity. 23 + 24 + "You" (or "Your") shall mean an individual or Legal Entity 25 + exercising permissions granted by this License. 26 + 27 + "Source" form shall mean the preferred form for making modifications, 28 + including but not limited to software source code, documentation 29 + source, and configuration files. 30 + 31 + "Object" form shall mean any form resulting from mechanical 32 + transformation or translation of a Source form, including but 33 + not limited to compiled object code, generated documentation, 34 + and conversions to other media types. 35 + 36 + "Work" shall mean the work of authorship, whether in Source or 37 + Object form, made available under the License, as indicated by a 38 + copyright notice that is included in or attached to the work 39 + (an example is provided in the Appendix below). 40 + 41 + "Derivative Works" shall mean any work, whether in Source or Object 42 + form, that is based on (or derived from) the Work and for which the 43 + editorial revisions, annotations, elaborations, or other modifications 44 + represent, as a whole, an original work of authorship. For the purposes 45 + of this License, Derivative Works shall not include works that remain 46 + separable from, or merely link (or bind by name) to the interfaces of, 47 + the Work and Derivative Works thereof. 48 + 49 + "Contribution" shall mean any work of authorship, including 50 + the original version of the Work and any modifications or additions 51 + to that Work or Derivative Works thereof, that is intentionally 52 + submitted to Licensor for inclusion in the Work by the copyright owner 53 + or by an individual or Legal Entity authorized to submit on behalf of 54 + the copyright owner. For the purposes of this definition, "submitted" 55 + means any form of electronic, verbal, or written communication sent 56 + to the Licensor or its representatives, including but not limited to 57 + communication on electronic mailing lists, source code control systems, 58 + and issue tracking systems that are managed by, or on behalf of, the 59 + Licensor for the purpose of discussing and improving the Work, but 60 + excluding communication that is conspicuously marked or otherwise 61 + designated in writing by the copyright owner as "Not a Contribution." 62 + 63 + "Contributor" shall mean Licensor and any individual or Legal Entity 64 + on behalf of whom a Contribution has been received by Licensor and 65 + subsequently incorporated within the Work. 66 + 67 + 2. Grant of Copyright License. Subject to the terms and conditions of 68 + this License, each Contributor hereby grants to You a perpetual, 69 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 + copyright license to reproduce, prepare Derivative Works of, 71 + publicly display, publicly perform, sublicense, and distribute the 72 + Work and such Derivative Works in Source or Object form. 73 + 74 + 3. Grant of Patent License. Subject to the terms and conditions of 75 + this License, each Contributor hereby grants to You a perpetual, 76 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 + (except as stated in this section) patent license to make, have made, 78 + use, offer to sell, sell, import, and otherwise transfer the Work, 79 + where such license applies only to those patent claims licensable 80 + by such Contributor that are necessarily infringed by their 81 + Contribution(s) alone or by combination of their Contribution(s) 82 + with the Work to which such Contribution(s) was submitted. If You 83 + institute patent litigation against any entity (including a 84 + cross-claim or counterclaim in a lawsuit) alleging that the Work 85 + or a Contribution incorporated within the Work constitutes direct 86 + or contributory patent infringement, then any patent licenses 87 + granted to You under this License for that Work shall terminate 88 + as of the date such litigation is filed. 89 + 90 + 4. Redistribution. You may reproduce and distribute copies of the 91 + Work or Derivative Works thereof in any medium, with or without 92 + modifications, and in Source or Object form, provided that You 93 + meet the following conditions: 94 + 95 + (a) You must give any other recipients of the Work or 96 + Derivative Works a copy of this License; and 97 + 98 + (b) You must cause any modified files to carry prominent notices 99 + stating that You changed the files; and 100 + 101 + (c) You must retain, in the Source form of any Derivative Works 102 + that You distribute, all copyright, patent, trademark, and 103 + attribution notices from the Source form of the Work, 104 + excluding those notices that do not pertain to any part of 105 + the Derivative Works; and 106 + 107 + (d) If the Work includes a "NOTICE" text file as part of its 108 + distribution, then any Derivative Works that You distribute must 109 + include a readable copy of the attribution notices contained 110 + within such NOTICE file, excluding those notices that do not 111 + pertain to any part of the Derivative Works, in at least one 112 + of the following places: within a NOTICE text file distributed 113 + as part of the Derivative Works; within the Source form or 114 + documentation, if provided along with the Derivative Works; or, 115 + within a display generated by the Derivative Works, if and 116 + wherever such third-party notices normally appear. The contents 117 + of the NOTICE file are for informational purposes only and 118 + do not modify the License. You may add Your own attribution 119 + notices within Derivative Works that You distribute, alongside 120 + or as an addendum to the NOTICE text from the Work, provided 121 + that such additional attribution notices cannot be construed 122 + as modifying the License. 123 + 124 + You may add Your own copyright statement to Your modifications and 125 + may provide additional or different license terms and conditions 126 + for use, reproduction, or distribution of Your modifications, or 127 + for any such Derivative Works as a whole, provided Your use, 128 + reproduction, and distribution of the Work otherwise complies with 129 + the conditions stated in this License. 130 + 131 + 5. Submission of Contributions. Unless You explicitly state otherwise, 132 + any Contribution intentionally submitted for inclusion in the Work 133 + by You to the Licensor shall be under the terms and conditions of 134 + this License, without any additional terms or conditions. 135 + Notwithstanding the above, nothing herein shall supersede or modify 136 + the terms of any separate license agreement you may have executed 137 + with Licensor regarding such Contributions. 138 + 139 + 6. Trademarks. This License does not grant permission to use the trade 140 + names, trademarks, service marks, or product names of the Licensor, 141 + except as required for reasonable and customary use in describing the 142 + origin of the Work and reproducing the content of the NOTICE file. 143 + 144 + 7. Disclaimer of Warranty. Unless required by applicable law or 145 + agreed to in writing, Licensor provides the Work (and each 146 + Contributor provides its Contributions) on an "AS IS" BASIS, 147 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 + implied, including, without limitation, any warranties or conditions 149 + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 + PARTICULAR PURPOSE. You are solely responsible for determining the 151 + appropriateness of using or redistributing the Work and assume any 152 + risks associated with Your exercise of permissions under this License. 153 + 154 + 8. Limitation of Liability. In no event and under no legal theory, 155 + whether in tort (including negligence), contract, or otherwise, 156 + unless required by applicable law (such as deliberate and grossly 157 + negligent acts) or agreed to in writing, shall any Contributor be 158 + liable to You for damages, including any direct, indirect, special, 159 + incidental, or consequential damages of any character arising as a 160 + result of this License or out of the use or inability to use the 161 + Work (including but not limited to damages for loss of goodwill, 162 + work stoppage, computer failure or malfunction, or any and all 163 + other commercial damages or losses), even if such Contributor 164 + has been advised of the possibility of such damages. 165 + 166 + 9. Accepting Warranty or Additional Liability. While redistributing 167 + the Work or Derivative Works thereof, You may choose to offer, 168 + and charge a fee for, acceptance of support, warranty, indemnity, 169 + or other liability obligations and/or rights consistent with this 170 + License. However, in accepting such obligations, You may act only 171 + on Your own behalf and on Your sole responsibility, not on behalf 172 + of any other Contributor, and only if You agree to indemnify, 173 + defend, and hold each Contributor harmless for any liability 174 + incurred by, or claims asserted against, such Contributor by reason 175 + of your accepting any such warranty or additional liability. 176 + 177 + END OF TERMS AND CONDITIONS 178 + 179 + APPENDIX: How to apply the Apache License to your work. 180 + 181 + To apply the Apache License to your work, attach the following 182 + boilerplate notice, with the fields enclosed by brackets "[]" 183 + replaced with your own identifying information. (Don't include 184 + the brackets!) The text should be enclosed in the appropriate 185 + comment syntax for the file format. We also recommend that a 186 + file or class name and description of purpose be included on the 187 + same "printed page" as the copyright notice for easier 188 + identification within third-party archives. 189 + 190 + Copyright [yyyy] [name of copyright owner] 191 + 192 + Licensed under the Apache License, Version 2.0 (the "License"); 193 + you may not use this file except in compliance with the License. 194 + You may obtain a copy of the License at 195 + 196 + http://www.apache.org/licenses/LICENSE-2.0 197 + 198 + Unless required by applicable law or agreed to in writing, software 199 + distributed under the License is distributed on an "AS IS" BASIS, 200 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 + See the License for the specific language governing permissions and 202 + limitations under the License.
+5
LICENSE-MIT
··· 1 + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 2 + 3 + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 4 + 5 + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+55
README.md
··· 1 + 2 + # 🧹 Deppa 3 + 4 + > Dependency scanner and pruner 5 + 6 + Deppa finds and deletes dependency and build output directories (`node_modules`, `target`, `.next`, etc.) that accumulate across your projects and silently consume disk space. 7 + 8 + Deppa is written in [Go](https://go.dev) and uses [Bubble Tea](https://github.com/charmbracelet/bubbletea) for its terminal interface. 9 + 10 + ## Usage 11 + 12 + ```bash 13 + deppa # Scan from the current directory 14 + deppa ~/Developer # Scan from a specific path 15 + ``` 16 + 17 + ## Installation 18 + 19 + ```bash 20 + go install github.com/Fuwn/deppa@latest 21 + ``` 22 + 23 + Or build from source: 24 + 25 + ```bash 26 + git clone https://github.com/Fuwn/deppa.git 27 + cd deppa 28 + task build 29 + task install 30 + ``` 31 + 32 + ## Keybindings 33 + 34 + | Key | Action | 35 + |-----|--------| 36 + | `j/k` | Navigate down/up | 37 + | `space` | Toggle selection | 38 + | `a` | Toggle all | 39 + | `enter` | Delete selected | 40 + | `q` | Quit | 41 + 42 + ## Detected Directories 43 + 44 + `node_modules`, `target`, `.next`, `.nuxt`, `__pycache__`, `.venv`, `venv`, `.gradle`, `Pods`, `zig-cache`, `zig-out`, `_build`, `.dart_tool` 45 + 46 + Want to add a new detected or ignored directory? Open a PR to [`scanner.go`](https://github.com/Fuwn/deppa/blob/main/scanner.go) after testing. 47 + 48 + ## Licence 49 + 50 + Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or 51 + [MIT license](LICENSE-MIT) at your option. 52 + 53 + Unless you explicitly state otherwise, any contribution intentionally submitted 54 + for inclusion in this crate by you, as defined in the Apache-2.0 license, shall 55 + be dual licensed as above, without any additional terms or conditions.
+47
Taskfile.yaml
··· 1 + version: "3" 2 + 3 + vars: 4 + BINARY: deppa 5 + 6 + tasks: 7 + default: 8 + desc: Build the application 9 + cmds: 10 + - task: build 11 + 12 + build: 13 + desc: Build the binary with optimisations 14 + cmds: 15 + - go build -ldflags="-s -w" -o {{.BINARY}} . 16 + sources: 17 + - ./**/*.go 18 + generates: 19 + - ./{{.BINARY}} 20 + 21 + run: 22 + desc: Build and run the application 23 + deps: [build] 24 + cmds: 25 + - ./{{.BINARY}} 26 + 27 + install: 28 + desc: Install the binary to GOPATH/bin 29 + deps: [build] 30 + cmds: 31 + - cp {{.BINARY}} ${GOPATH:-~/go}/bin/{{.BINARY}} 32 + 33 + clean: 34 + desc: Remove build artifacts 35 + cmds: 36 + - rm -f {{.BINARY}} 37 + - go clean 38 + 39 + fmt: 40 + desc: Format code 41 + cmds: 42 + - iku -w . || go fmt ./... 43 + 44 + lint: 45 + desc: Run linter 46 + cmds: 47 + - golangci-lint run
+32
go.mod
··· 1 + module github.com/Fuwn/deppa 2 + 3 + go 1.25.6 4 + 5 + require ( 6 + github.com/charmbracelet/bubbles v0.21.1 7 + github.com/charmbracelet/bubbletea v1.3.10 8 + github.com/charmbracelet/lipgloss v1.1.0 9 + ) 10 + 11 + require ( 12 + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect 13 + github.com/charmbracelet/colorprofile v0.4.1 // indirect 14 + github.com/charmbracelet/x/ansi v0.11.5 // indirect 15 + github.com/charmbracelet/x/cellbuf v0.0.15 // indirect 16 + github.com/charmbracelet/x/term v0.2.2 // indirect 17 + github.com/clipperhouse/displaywidth v0.9.0 // indirect 18 + github.com/clipperhouse/stringish v0.1.1 // indirect 19 + github.com/clipperhouse/uax29/v2 v2.5.0 // indirect 20 + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect 21 + github.com/lucasb-eyer/go-colorful v1.3.0 // indirect 22 + github.com/mattn/go-isatty v0.0.20 // indirect 23 + github.com/mattn/go-localereader v0.0.1 // indirect 24 + github.com/mattn/go-runewidth v0.0.19 // indirect 25 + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect 26 + github.com/muesli/cancelreader v0.2.2 // indirect 27 + github.com/muesli/termenv v0.16.0 // indirect 28 + github.com/rivo/uniseg v0.4.7 // indirect 29 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect 30 + golang.org/x/sys v0.38.0 // indirect 31 + golang.org/x/text v0.3.8 // indirect 32 + )
+50
go.sum
··· 1 + github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= 2 + github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= 3 + github.com/charmbracelet/bubbles v0.21.1 h1:nj0decPiixaZeL9diI4uzzQTkkz1kYY8+jgzCZXSmW0= 4 + github.com/charmbracelet/bubbles v0.21.1/go.mod h1:HHvIYRCpbkCJw2yo0vNX1O5loCwSr9/mWS8GYSg50Sk= 5 + github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= 6 + github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= 7 + github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= 8 + github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk= 9 + github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= 10 + github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= 11 + github.com/charmbracelet/x/ansi v0.11.5 h1:NBWeBpj/lJPE3Q5l+Lusa4+mH6v7487OP8K0r1IhRg4= 12 + github.com/charmbracelet/x/ansi v0.11.5/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= 13 + github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= 14 + github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= 15 + github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= 16 + github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= 17 + github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA= 18 + github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA= 19 + github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= 20 + github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= 21 + github.com/clipperhouse/uax29/v2 v2.5.0 h1:x7T0T4eTHDONxFJsL94uKNKPHrclyFI0lm7+w94cO8U= 22 + github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= 23 + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= 24 + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= 25 + github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= 26 + github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= 27 + github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 28 + github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 29 + github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= 30 + github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= 31 + github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= 32 + github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= 33 + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= 34 + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= 35 + github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= 36 + github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= 37 + github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= 38 + github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= 39 + github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= 40 + github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 41 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= 42 + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= 43 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= 44 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= 45 + golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 46 + golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 47 + golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= 48 + golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= 49 + golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= 50 + golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
+46
main.go
··· 1 + package main 2 + 3 + import ( 4 + "fmt" 5 + tea "github.com/charmbracelet/bubbletea" 6 + "os" 7 + "path/filepath" 8 + ) 9 + 10 + func main() { 11 + rootPath, pathError := resolveRootPath() 12 + 13 + if pathError != nil { 14 + fmt.Fprintf(os.Stderr, "error: %s\n", pathError) 15 + os.Exit(1) 16 + } 17 + 18 + finalModel, runError := tea.NewProgram( 19 + initialModel(rootPath), 20 + tea.WithAltScreen(), 21 + ).Run() 22 + 23 + if runError != nil { 24 + fmt.Fprintf(os.Stderr, "error: %s\n", runError) 25 + os.Exit(1) 26 + } 27 + 28 + if model, isApplicationModel := finalModel.(applicationModel); isApplicationModel { 29 + if model.scanError != nil { 30 + fmt.Fprintf(os.Stderr, "error: %s\n", model.scanError) 31 + os.Exit(1) 32 + } 33 + 34 + if model.deletedCount > 0 { 35 + fmt.Printf("deleted %d directories, freed %s\n", model.deletedCount, formatBytes(model.freedBytes)) 36 + } 37 + } 38 + } 39 + 40 + func resolveRootPath() (string, error) { 41 + if len(os.Args) > 1 { 42 + return filepath.Abs(os.Args[1]) 43 + } 44 + 45 + return os.Getwd() 46 + }
+300
model.go
··· 1 + package main 2 + 3 + import ( 4 + "fmt" 5 + "sort" 6 + "strings" 7 + "github.com/charmbracelet/bubbles/spinner" 8 + tea "github.com/charmbracelet/bubbletea" 9 + "github.com/charmbracelet/lipgloss" 10 + ) 11 + 12 + type applicationPhase int 13 + 14 + const ( 15 + phaseScanning applicationPhase = iota 16 + phaseBrowsing 17 + phaseDeleting 18 + phaseDone 19 + ) 20 + 21 + type scanCompleteMessage struct { 22 + dependencies []DependencyDirectory 23 + scanError error 24 + } 25 + 26 + type deletionCompleteMessage struct { 27 + freedBytes int64 28 + deletedCount int 29 + } 30 + 31 + type applicationModel struct { 32 + phase applicationPhase 33 + rootPath string 34 + dependencies []DependencyDirectory 35 + selected map[int]bool 36 + cursorPosition int 37 + loadingSpinner spinner.Model 38 + terminalWidth int 39 + terminalHeight int 40 + freedBytes int64 41 + deletedCount int 42 + scanError error 43 + } 44 + 45 + var ( 46 + accentStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("205")) 47 + dimStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")) 48 + sizeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("39")) 49 + typeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("178")) 50 + ) 51 + 52 + func initialModel(rootPath string) applicationModel { 53 + loadingSpinner := spinner.New() 54 + loadingSpinner.Spinner = spinner.Dot 55 + loadingSpinner.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205")) 56 + 57 + return applicationModel{ 58 + phase: phaseScanning, 59 + rootPath: rootPath, 60 + selected: make(map[int]bool), 61 + loadingSpinner: loadingSpinner, 62 + } 63 + } 64 + 65 + func (model applicationModel) Init() tea.Cmd { 66 + return tea.Batch(model.loadingSpinner.Tick, startScan(model.rootPath)) 67 + } 68 + 69 + func startScan(rootPath string) tea.Cmd { 70 + return func() tea.Msg { 71 + dependencies, scanError := scanForDependencies(rootPath) 72 + 73 + return scanCompleteMessage{dependencies: dependencies, scanError: scanError} 74 + } 75 + } 76 + 77 + func startDeletion(dependencies []DependencyDirectory, selected map[int]bool) tea.Cmd { 78 + return func() tea.Msg { 79 + freedBytes, deletedCount := deleteDependencies(dependencies, selected) 80 + 81 + return deletionCompleteMessage{freedBytes: freedBytes, deletedCount: deletedCount} 82 + } 83 + } 84 + 85 + func (model applicationModel) Update(message tea.Msg) (tea.Model, tea.Cmd) { 86 + switch typedMessage := message.(type) { 87 + case tea.KeyMsg: 88 + return model.handleKeyPress(typedMessage) 89 + case tea.WindowSizeMsg: 90 + model.terminalWidth = typedMessage.Width 91 + model.terminalHeight = typedMessage.Height 92 + 93 + return model, nil 94 + case spinner.TickMsg: 95 + var spinnerCommand tea.Cmd 96 + 97 + model.loadingSpinner, spinnerCommand = model.loadingSpinner.Update(message) 98 + 99 + return model, spinnerCommand 100 + case scanCompleteMessage: 101 + if typedMessage.scanError != nil { 102 + model.scanError = typedMessage.scanError 103 + model.phase = phaseDone 104 + 105 + return model, tea.Quit 106 + } 107 + 108 + sort.Slice(typedMessage.dependencies, func(firstIndex, secondIndex int) bool { 109 + return typedMessage.dependencies[firstIndex].SizeBytes > typedMessage.dependencies[secondIndex].SizeBytes 110 + }) 111 + 112 + model.dependencies = typedMessage.dependencies 113 + model.phase = phaseBrowsing 114 + 115 + if len(model.dependencies) == 0 { 116 + model.phase = phaseDone 117 + 118 + return model, tea.Quit 119 + } 120 + 121 + return model, nil 122 + case deletionCompleteMessage: 123 + model.freedBytes = typedMessage.freedBytes 124 + model.deletedCount = typedMessage.deletedCount 125 + model.phase = phaseDone 126 + 127 + return model, tea.Quit 128 + } 129 + 130 + return model, nil 131 + } 132 + 133 + func (model applicationModel) handleKeyPress(keyMessage tea.KeyMsg) (tea.Model, tea.Cmd) { 134 + if keyMessage.String() == "ctrl+c" { 135 + return model, tea.Quit 136 + } 137 + 138 + if model.phase != phaseBrowsing { 139 + return model, nil 140 + } 141 + 142 + switch keyMessage.String() { 143 + case "q": 144 + return model, tea.Quit 145 + case "up", "k": 146 + if model.cursorPosition > 0 { 147 + model.cursorPosition-- 148 + } 149 + case "down", "j": 150 + if model.cursorPosition < len(model.dependencies)-1 { 151 + model.cursorPosition++ 152 + } 153 + case " ": 154 + if model.selected[model.cursorPosition] { 155 + delete(model.selected, model.cursorPosition) 156 + } else { 157 + model.selected[model.cursorPosition] = true 158 + } 159 + case "a": 160 + allCurrentlySelected := true 161 + 162 + for dependencyIndex := range model.dependencies { 163 + if !model.selected[dependencyIndex] { 164 + allCurrentlySelected = false 165 + 166 + break 167 + } 168 + } 169 + 170 + if allCurrentlySelected { 171 + model.selected = make(map[int]bool) 172 + } else { 173 + for dependencyIndex := range model.dependencies { 174 + model.selected[dependencyIndex] = true 175 + } 176 + } 177 + case "enter": 178 + if len(model.selected) == 0 { 179 + return model, nil 180 + } 181 + 182 + model.phase = phaseDeleting 183 + 184 + return model, startDeletion(model.dependencies, model.selected) 185 + } 186 + 187 + return model, nil 188 + } 189 + 190 + func (model applicationModel) selectedSize() int64 { 191 + var totalSize int64 192 + 193 + for dependencyIndex, isSelected := range model.selected { 194 + if isSelected { 195 + totalSize += model.dependencies[dependencyIndex].SizeBytes 196 + } 197 + } 198 + 199 + return totalSize 200 + } 201 + 202 + func (model applicationModel) View() string { 203 + switch model.phase { 204 + case phaseScanning: 205 + return fmt.Sprintf("\n %s scanning %s\n", model.loadingSpinner.View(), model.rootPath) 206 + case phaseBrowsing: 207 + return model.viewBrowsing() 208 + case phaseDeleting: 209 + return fmt.Sprintf("\n %s deleting selected directories\n", model.loadingSpinner.View()) 210 + case phaseDone: 211 + return model.viewDone() 212 + } 213 + 214 + return "" 215 + } 216 + 217 + func (model applicationModel) viewBrowsing() string { 218 + var builder strings.Builder 219 + 220 + builder.WriteString(accentStyle.Render("\n deppa")) 221 + builder.WriteString(dimStyle.Render(fmt.Sprintf(" — %d directories found\n\n", len(model.dependencies)))) 222 + 223 + visibleHeight := model.terminalHeight - 6 224 + 225 + if visibleHeight < 1 { 226 + visibleHeight = 10 227 + } 228 + 229 + startIndex := 0 230 + 231 + if model.cursorPosition >= startIndex+visibleHeight { 232 + startIndex = model.cursorPosition - visibleHeight + 1 233 + } 234 + 235 + endIndex := min(startIndex+visibleHeight, len(model.dependencies)) 236 + 237 + for displayIndex := startIndex; displayIndex < endIndex; displayIndex++ { 238 + dependency := model.dependencies[displayIndex] 239 + cursor := " " 240 + 241 + if displayIndex == model.cursorPosition { 242 + cursor = accentStyle.Bold(true).Render("> ") 243 + } 244 + 245 + checkbox := dimStyle.Render("[ ]") 246 + 247 + if model.selected[displayIndex] { 248 + checkbox = accentStyle.Render("[x]") 249 + } 250 + 251 + formattedSize := sizeStyle.Render(fmt.Sprintf("%8s", formatBytes(dependency.SizeBytes))) 252 + formattedType := typeStyle.Render(fmt.Sprintf("%-14s", dependency.DirectoryType)) 253 + 254 + builder.WriteString(fmt.Sprintf( 255 + "%s%s %s %s %s\n", 256 + cursor, checkbox, formattedSize, formattedType, dimStyle.Render(dependency.RelativePath), 257 + )) 258 + } 259 + 260 + builder.WriteString(dimStyle.Render(fmt.Sprintf( 261 + "\n space toggle • a all • enter delete %s • q quit", 262 + accentStyle.Render(formatBytes(model.selectedSize())), 263 + ))) 264 + 265 + return builder.String() 266 + } 267 + 268 + func (model applicationModel) viewDone() string { 269 + if model.scanError != nil { 270 + return fmt.Sprintf("\n error: %s\n", model.scanError) 271 + } 272 + 273 + if len(model.dependencies) == 0 { 274 + return "\n no dependency directories found\n" 275 + } 276 + 277 + return fmt.Sprintf( 278 + "\n deleted %d directories, freed %s\n", 279 + model.deletedCount, formatBytes(model.freedBytes), 280 + ) 281 + } 282 + 283 + func formatBytes(bytes int64) string { 284 + const ( 285 + kilobyte = 1024 286 + megabyte = 1024 * kilobyte 287 + gigabyte = 1024 * megabyte 288 + ) 289 + 290 + switch { 291 + case bytes >= gigabyte: 292 + return fmt.Sprintf("%.1f GB", float64(bytes)/float64(gigabyte)) 293 + case bytes >= megabyte: 294 + return fmt.Sprintf("%.1f MB", float64(bytes)/float64(megabyte)) 295 + case bytes >= kilobyte: 296 + return fmt.Sprintf("%.1f KB", float64(bytes)/float64(kilobyte)) 297 + default: 298 + return fmt.Sprintf("%d B", bytes) 299 + } 300 + }
+133
scanner.go
··· 1 + package main 2 + 3 + import ( 4 + "io/fs" 5 + "os" 6 + "path/filepath" 7 + "runtime" 8 + "sync" 9 + ) 10 + 11 + var knownDependencyDirectories = map[string]bool{ 12 + "node_modules": true, 13 + "target": true, 14 + ".next": true, 15 + ".nuxt": true, 16 + "__pycache__": true, 17 + ".venv": true, 18 + "venv": true, 19 + ".gradle": true, 20 + "Pods": true, 21 + "zig-cache": true, 22 + "zig-out": true, 23 + "_build": true, 24 + ".dart_tool": true, 25 + } 26 + var ignoredDirectories = map[string]bool{ 27 + ".git": true, 28 + ".hg": true, 29 + ".svn": true, 30 + } 31 + 32 + type DependencyDirectory struct { 33 + Path string 34 + RelativePath string 35 + SizeBytes int64 36 + DirectoryType string 37 + } 38 + 39 + func scanForDependencies(rootPath string) ([]DependencyDirectory, error) { 40 + var foundDirectories []DependencyDirectory 41 + 42 + walkError := filepath.WalkDir(rootPath, func(currentPath string, entry fs.DirEntry, accessError error) error { 43 + if accessError != nil { 44 + return filepath.SkipDir 45 + } 46 + 47 + if !entry.IsDir() { 48 + return nil 49 + } 50 + 51 + if ignoredDirectories[entry.Name()] { 52 + return filepath.SkipDir 53 + } 54 + 55 + if knownDependencyDirectories[entry.Name()] { 56 + relativePath, _ := filepath.Rel(rootPath, currentPath) 57 + foundDirectories = append(foundDirectories, DependencyDirectory{ 58 + Path: currentPath, 59 + RelativePath: relativePath, 60 + DirectoryType: entry.Name(), 61 + }) 62 + 63 + return filepath.SkipDir 64 + } 65 + 66 + return nil 67 + }) 68 + 69 + if walkError != nil { 70 + return nil, walkError 71 + } 72 + 73 + var waitGroup sync.WaitGroup 74 + 75 + semaphore := make(chan struct{}, runtime.NumCPU()) 76 + 77 + for directoryIndex := range foundDirectories { 78 + waitGroup.Add(1) 79 + 80 + go func(targetIndex int) { 81 + defer waitGroup.Done() 82 + 83 + semaphore <- struct{}{} 84 + 85 + defer func() { <-semaphore }() 86 + 87 + foundDirectories[targetIndex].SizeBytes = calculateDirectorySize(foundDirectories[targetIndex].Path) 88 + }(directoryIndex) 89 + } 90 + 91 + waitGroup.Wait() 92 + 93 + return foundDirectories, nil 94 + } 95 + 96 + func calculateDirectorySize(directoryPath string) int64 { 97 + var totalSize int64 98 + 99 + _ = filepath.WalkDir(directoryPath, func(_ string, entry fs.DirEntry, walkError error) error { 100 + if walkError != nil || entry.IsDir() { 101 + return nil 102 + } 103 + 104 + fileInformation, informationError := entry.Info() 105 + 106 + if informationError == nil { 107 + totalSize += fileInformation.Size() 108 + } 109 + 110 + return nil 111 + }) 112 + 113 + return totalSize 114 + } 115 + 116 + func deleteDependencies(dependencies []DependencyDirectory, selected map[int]bool) (int64, int) { 117 + var freedBytes int64 118 + var deletedCount int 119 + 120 + for dependencyIndex, dependency := range dependencies { 121 + if !selected[dependencyIndex] { 122 + continue 123 + } 124 + 125 + if removeError := os.RemoveAll(dependency.Path); removeError == nil { 126 + freedBytes += dependency.SizeBytes 127 + 128 + deletedCount++ 129 + } 130 + } 131 + 132 + return freedBytes, deletedCount 133 + }