Skip to content

Commit

Permalink
Merge "ui: Only import plugins with an index.ts" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegolton authored and Gerrit Code Review committed Oct 24, 2024
2 parents b4cdc50 + 3f8589a commit aff1a0c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/gen_ui_imports
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ def to_camel_case(s):
return first + ''.join(x.title() for x in rest)


def is_plugin_dir(dir):
# Ensure plugins contain a file called index.ts. This avoids the issue empty
# dirs are detected as plugins.
return os.path.isdir(dir) and os.path.exists(os.path.join(dir, 'index.ts'))


def gen_imports(input_dir, output_path):
paths = [os.path.join(input_dir, p) for p in os.listdir(input_dir)]
paths = [p for p in paths if os.path.isdir(p)]
paths = [p for p in paths if is_plugin_dir(p)]
paths.sort()

output_dir = os.path.dirname(output_path)
Expand All @@ -60,6 +66,7 @@ def gen_imports(input_dir, output_path):
imports = []
registrations = []
for path in paths:
# Get out if
rel_path = os.path.relpath(path, output_dir)
snake_name = os.path.basename(path)
camel_name = to_camel_case(snake_name)
Expand Down

0 comments on commit aff1a0c

Please sign in to comment.