-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce presence of licensing info for npm modules (fixes brave/brave…
- Loading branch information
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/components/resources/BUILD.gn b/components/resources/BUILD.gn | ||
index d1645a13a358b64cefb80cfe1c8f0691a68e3204..8e07af1390e9d1a5999aa543e6537f5daa8b096b 100644 | ||
--- a/components/resources/BUILD.gn | ||
+++ b/components/resources/BUILD.gn | ||
@@ -73,6 +73,7 @@ grit("components_scaled_resources") { | ||
} | ||
|
||
action("about_credits") { | ||
+ deps = [ "//brave/components/resources:about_credits" ] | ||
script = "//tools/licenses.py" | ||
depfile = "$target_gen_dir/$target_name.d" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import argparse | ||
import json | ||
import os | ||
import sys | ||
|
||
from lib.config import SOURCE_ROOT | ||
|
||
|
||
EXCLUSIONS = [ | ||
# Already covered by brave/third_party/npm-types | ||
'@types/jszip', | ||
'@types/parse-torrent', | ||
'@types/webtorrent', | ||
] | ||
|
||
|
||
def check_dependency(module_name): | ||
if module_name in EXCLUSIONS: | ||
return True | ||
|
||
third_party_dir = os.path.join(os.path.dirname(SOURCE_ROOT), 'brave', 'third_party') | ||
readme_path = os.path.join(third_party_dir, 'npm_%s' % module_name, 'README.chromium') | ||
if not os.path.isfile(readme_path): | ||
print('npm module %s needs licensing information in %s' % (module_name, readme_path)) | ||
return False | ||
|
||
return True | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('output_file', nargs='?') | ||
args = parser.parse_args() | ||
|
||
return_code = 0 | ||
package_json = os.path.join(os.path.dirname(SOURCE_ROOT), 'brave', 'package.json') | ||
with open(package_json) as file_handle: | ||
dependencies = json.loads(file_handle.read())["dependencies"] | ||
for module_name in dependencies: | ||
if not check_dependency(module_name): | ||
return_code = 1 | ||
|
||
if args.output_file: | ||
with open(args.output_file, 'wt') as file_handle: | ||
file_handle.write('') | ||
|
||
return return_code | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |