├── LICENSE ├── MANIFEST.in ├── README.md ├── cocoapods-graph-runner.py ├── cocoapodsgraph ├── __init__.py ├── __main__.py └── executor.py ├── docs └── wordpress_example.gif └── setup.py /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Erick Jung 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include README.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cocoapods-graph 2 | ================ 3 | 4 | This tool generates a dependencies graph report, printing on console or saving on a json or creating a html with a interactive disc to navigate through it. 5 | 6 | ## Example for Wordpress iOS app dependencies link ## 7 | 8 | 9 |  10 | 11 | ## Installing ## 12 | ```shell 13 | [sudo] pip install cocoapods-graph 14 | ``` 15 | 16 | ## How to use ## 17 | ```shell 18 | cocoapods-graph -f Podfile.lock --html 19 | ``` 20 | 21 | ## Thanks ## 22 | 23 | All html rendering is done with: 24 | * d3.js 25 | * Dependency Wheel 26 | 27 | -------------------------------------------------------------------------------- /cocoapods-graph-runner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from cocoapodsgraph.executor import main 4 | 5 | if __name__ == '__main__': 6 | main() 7 | -------------------------------------------------------------------------------- /cocoapodsgraph/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erickjung/cocoapods-graph/fa337d6cd497f4735128835cda4106661e7ecf65/cocoapodsgraph/__init__.py -------------------------------------------------------------------------------- /cocoapodsgraph/__main__.py: -------------------------------------------------------------------------------- 1 | from .executor import main 2 | main() 3 | -------------------------------------------------------------------------------- /cocoapodsgraph/executor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Erick Jung 2 | 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | import os 22 | import sys 23 | import json 24 | from optparse import OptionParser 25 | 26 | __version__ = "0.1.2" 27 | 28 | PROJECT_NAME = "cocoapods-graph" 29 | PROJECT_DESCRIPTION = "cocoapods dependencies graph generator" 30 | PROJECT_AUTHOR = "erick jung (erickjung@gmail.com)" 31 | 32 | class PodClass: 33 | name = '' 34 | version = '' 35 | dependencies = [] 36 | 37 | def __init__(self, name, version, dependencies): 38 | self.name = name 39 | self.version = version 40 | self.dependencies = dependencies 41 | 42 | def printObject(self): 43 | print(self.name + " " + self.version) 44 | for dep in self.dependencies: 45 | print(" " + dep.name + " " + dep.version) 46 | 47 | # --------- 48 | 49 | def parse_lock_file(fileName): 50 | def parse_lock_pods_line(line): 51 | try: 52 | name = line[line.index("-")+1:line.index("(")].strip() 53 | except Exception: 54 | name = line[line.index("-")+1:].strip() 55 | 56 | try: 57 | version = line[line.index("(")+1:line.index(")")].strip() 58 | except Exception: 59 | version = "" 60 | 61 | return PodClass(name, version, []) 62 | 63 | with open(fileName, 'r+') as inFile: 64 | contentFile = [x.replace('\n', '').replace('"', '') for x in inFile.readlines()] 65 | 66 | resultList = [] 67 | pod = PodClass("", "", []) 68 | for line in contentFile: 69 | if line.startswith(' -'): 70 | if len(pod.name) > 0: 71 | resultList.append(pod) 72 | pod = parse_lock_pods_line(line) 73 | elif line.startswith(' -'): 74 | pod.dependencies.append(parse_lock_pods_line(line)) 75 | elif line.startswith('DEPENDENCIES'): 76 | if len(pod.name) > 0: 77 | resultList.append(pod) 78 | break 79 | 80 | return resultList 81 | 82 | 83 | def generate_json(resultList): 84 | def generate_json_deps(resultList): 85 | data = '{' 86 | for result in resultList: 87 | data += '"%s":"%s",' % (result.name, result.version) 88 | 89 | data = data[:len(data)-1] 90 | return data + '}' 91 | 92 | json = '{"packages": [' 93 | deps = generate_json_deps(resultList) 94 | json += '{"name":"app","require":%s},' % deps 95 | 96 | for pod in resultList: 97 | if len(pod.dependencies) > 0: 98 | podDeps = generate_json_deps(pod.dependencies) 99 | json += '{"name":"%s","require":%s},' % (pod.name, podDeps) 100 | else: 101 | json += '{"name":"%s","require":{}},' % pod.name 102 | 103 | return json[:len(json)-1] + ']}' 104 | 105 | def save_json_file(data, fileName): 106 | with open(fileName + '.json', 'w') as outfile: 107 | outfile.write(generate_json(data)) 108 | 109 | def save_html_wheel_file(data, fileName): 110 | P_TEMPLATE = '