Skip to content

Commit a16b7aa

Browse files
authored
Merge pull request #4 from LGE-OSS/develop
Release v3.0.5
2 parents 57dc182 + 321e643 commit a16b7aa

File tree

5 files changed

+117
-6
lines changed

5 files changed

+117
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Currently, it supports the following package managers.
1010
* [NPM](https://www.npmjs.com/) (Node.js)
1111
* [PIP](https://pip.pypa.io/) (Python)
1212
* [Pub](https://pub.dev/) (Dart with flutter)
13+
* [Cocoapods](https://cocoapods.org/) (Swift/Obj-C)
1314

1415

1516
## User Guide

ReleaseNote.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ReleaseNote
22

3+
### V3.0.5 (2021.03.19)
4+
- Support the cocoapods package manager.
5+
36
### V3.0.4 (2021.03.13)
47
- Modify to include binaries that analyze license text.
58

docs/user-guide.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ $ flutter pub global activate flutter_oss_licenses
9696
$ flutter pub global run flutter_oss_licenses:generate.dart
9797
```
9898

99+
100+
### Cocoapods (required)
101+
1. Install the pod package through Podfile.
102+
```
103+
$ pod install
104+
```
105+
99106
<br>
100107

101108
## 2. How to install
@@ -124,7 +131,7 @@ $ fosslight_dependency
124131
```
125132
| Options | Description | Value |
126133
| --------- | ------------- | ------- |
127-
| -m | (optional) <br> package manager for your project | npm, maven, gradle, pip, pub |
134+
| -m | (optional) <br> package manager for your project | npm, maven, gradle, pip, pub, cocoapods |
128135
| -p | (optional) <br> input directory | (path) |
129136
| -o | (optional) <br> output file directory | (path) |
130137
| -a | (pypi only required) <br> virtual environment activate command | conda example: 'conda activate (venv name)' |
@@ -145,11 +152,13 @@ FOSSLight dependency creates the result file that has xlsx extension (Microsoft
145152

146153
It prints the OSS information based on manifest file(package.json, pom.xml) of dependencies (including transitive dependenices).
147154
For a unique OSS name, OSS name is printed such as (package_manager):(oss name) or (group id):(artifact id).
155+
(The oss name of cocoapods is printed just oss name of pod spec information. Because cocoapods doesn't manage the source code of packages itself.)
148156

149157
| Package manager | OSS Name | Download Location | Homepage |
150158
| --------------- | ------------------ | ----------------- | -------- |
151159
| Npm | npm:(oss name) | Priority1. repository in package.json <br> Priority2. www.npmjs.com/package/(oss_name) | www.npmjs.com/package/(oss_name) |
152160
| Pip | pypi:(oss name) | https://pypi.org/project/(oss_name)/(version) | homepage in (pip show) information |
153161
| Maven (Gradle) | (group_id):(artifact_id) | https://mvnrepository.com/artifact/(group_id)/(artifact_id)/(version) | https://mvnrepository.com/artifact/(group_id)/(artifact_id) |
154162
| Pub | pub:(oss name) | https://pub.dev/packages/(oss_name)/versions/(version) | homepage in (pub information) |
163+
| Cocoapods | oss name | source in (pod spec information) | homepage in (pod spec information) |
155164

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if __name__ == "__main__":
1414
setup(
1515
name = 'fosslight_dependency',
16-
version = '3.0.4',
16+
version = '3.0.5',
1717
packages = find_packages(),
1818
description = 'FOSSLight Dependency',
1919
long_description = 'It is a script file to scan dependencies through package manager file and generate a result report.',

unified_script/dependency_unified.py

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
import logging
2020
import requests
2121
import pkg_resources
22+
import yaml
2223

23-
VERSION = "3.0.4"
24+
VERSION = "3.0.5"
2425

2526
# Check the manifest file
2627
manifest_array = [["pip", "requirements.txt"], ["npm", "package.json"], ["maven", "pom.xml"],
27-
["gradle", "build.gradle"], ["pub", "pubspec.yaml"]]
28+
["gradle", "build.gradle"], ["pub", "pubspec.yaml"], ["cocoapods", "Podfile.lock"]]
2829

2930
# binary url to check license text
3031
license_scanner_url_linux = "third_party/nomos/nomossa"
@@ -897,6 +898,80 @@ def parse_and_generate_output_pub(tmp_file_name):
897898
os.remove(tmp_license_txt_file_name)
898899

899900

901+
def compile_pods_item(pods_item, spec_repo_list, pod_in_sepc_list):
902+
pods_item_re = re.findall(r'(\S*)\s{1}\((.*)\)', pods_item)
903+
904+
oss_name = pods_item_re[0][0]
905+
oss_version = pods_item_re[0][1]
906+
907+
oss_info = []
908+
if oss_name in spec_repo_list:
909+
oss_info.append(oss_name)
910+
oss_info.append(oss_version)
911+
pod_in_sepc_list.append(oss_info)
912+
913+
return pod_in_sepc_list
914+
915+
916+
def parse_and_generate_output_cocoapods(input_fp):
917+
global source_type
918+
919+
pod_in_sepc_list = []
920+
spec_repo_list = []
921+
podfile_yaml = yaml.load(input_fp, Loader=yaml.FullLoader)
922+
923+
for spec_item_key in podfile_yaml['SPEC REPOS']:
924+
for spec_item in podfile_yaml['SPEC REPOS'][spec_item_key]:
925+
spec_repo_list.append(spec_item)
926+
927+
for pods_list in podfile_yaml['PODS']:
928+
if not isinstance(pods_list, str):
929+
for pods_list_key, pods_list_item in pods_list.items():
930+
pod_in_sepc_list = compile_pods_item(pods_list_key, spec_repo_list, pod_in_sepc_list)
931+
else:
932+
pod_in_sepc_list = compile_pods_item(pods_list, spec_repo_list, pod_in_sepc_list)
933+
934+
wb = generate_oss_report()
935+
936+
idx = 1
937+
for pod_oss in pod_in_sepc_list:
938+
tmp_file_name = 'tmp_spec.json'
939+
940+
command = 'pod spec cat ' + pod_oss[0] + ' > ' + tmp_file_name
941+
command_ret = subprocess.call(command, shell=True)
942+
if command_ret != 0:
943+
logging.error("### Error Message ###")
944+
logging.error("This command(" + command + ") returns an error")
945+
sys.exit(1)
946+
947+
with open(tmp_file_name, 'r', encoding='utf8') as json_file:
948+
json_data = json.load(json_file)
949+
950+
keys = [key for key in json_data]
951+
952+
oss_name = json_data['name']
953+
oss_version = json_data['version']
954+
homepage = json_data['homepage']
955+
956+
if not isinstance(json_data['license'], str):
957+
if 'type' in json_data['license']:
958+
license_name = json_data['license']['type']
959+
else:
960+
license_name = json_data['license']
961+
962+
source_keys = [key for key in json_data['source']]
963+
for src_type_i in source_type:
964+
if src_type_i in source_keys:
965+
dn_loc = json_data['source'][src_type_i]
966+
967+
insert_oss_report(wb.active,
968+
[str(idx), 'Podfile.lock', oss_name, oss_version, license_name, dn_loc, homepage, '', '', '', ''])
969+
idx += 1
970+
971+
save_oss_report(wb)
972+
973+
974+
900975
###########################################
901976
# Main functions for each package manager #
902977
###########################################
@@ -967,10 +1042,20 @@ def main_pub():
9671042
close_input_file(input_fp)
9681043

9691044

1045+
def main_cocoapods():
1046+
1047+
# open Podfile.lock
1048+
input_fp = open_input_file()
1049+
1050+
parse_and_generate_output_cocoapods(input_fp)
1051+
1052+
close_input_file(input_fp)
1053+
1054+
9701055
def main():
9711056
# Global variables
9721057
global PACKAGE, output_file_name, input_file_name, CUR_PATH, OUTPUT_RESULT_DIR, MANUAL_DETECT, OUTPUT_CUSTOM_DIR, dn_url, PIP_ACTIVATE, PIP_DEACTIVATE
973-
global license_scanner_url, license_scanner_bin, venv_tmp_dir, pom_backup, is_maven_first_try, tmp_license_txt_file_name
1058+
global license_scanner_url, license_scanner_bin, venv_tmp_dir, pom_backup, is_maven_first_try, tmp_license_txt_file_name, source_type
9741059

9751060
# Init logging
9761061
logging.basicConfig(level=logging.INFO, format='%(message)s')
@@ -1012,10 +1097,16 @@ def main():
10121097
output_file_name = "pub_dependency_output.xlsx"
10131098
tmp_license_txt_file_name = "tmp_license.txt"
10141099

1100+
elif PACKAGE == "cocoapods":
1101+
dn_url = "https://cocoapods/org/"
1102+
input_file_name = "Podfile.lock"
1103+
output_file_name = "cocoapods_dependency_output.xlsx"
1104+
source_type = ['git', 'http', 'svn', 'hg']
1105+
10151106
else:
10161107
logging.error("### Error Message ###")
10171108
logging.error("You enter the wrong first argument.")
1018-
logging.error("Please enter the package manager into (pip, npm, maven, gradle)")
1109+
logging.error("Please enter the supported package manager. (Check the help message with (-h) option.)")
10191110
sys.exit(1)
10201111

10211112
if PACKAGE == "pip":
@@ -1028,6 +1119,13 @@ def main():
10281119
main_gradle()
10291120
elif PACKAGE == "pub":
10301121
main_pub()
1122+
elif PACKAGE == "cocoapods":
1123+
main_cocoapods()
1124+
else:
1125+
logging.error("### Error Message ###")
1126+
logging.error("Please enter the supported package manager. (Check the help message with (-h) option.)")
1127+
sys.exit(1)
1128+
10311129

10321130
logging.info("### FINISH!! ###")
10331131

0 commit comments

Comments
 (0)