diff --git a/oarepo_ui/cli.py b/oarepo_ui/cli.py index aeab9473..59f33dbc 100644 --- a/oarepo_ui/cli.py +++ b/oarepo_ui/cli.py @@ -1,7 +1,7 @@ import json as json_lib import sys from pathlib import Path - +import os import click from flask.cli import with_appcontext from oarepo_runtime.cli import oarepo @@ -13,6 +13,19 @@ def ui(): """UI commands""" +@ui.command("components") +def components(): + + component_data = [] + script_directory = os.path.dirname(os.path.abspath(__file__ or '')) + components_directory = os.path.join(script_directory, 'templates', 'components') + + file_names = os.listdir(components_directory) + + for file_name in file_names: + component_data.append({"key": file_name.lower(), "component": file_name.replace(".jinja", "")}) + + print(component_data) @ui.command("renderers") @click.option("-v", "--verbose", is_flag=True, help="Verbose output") diff --git a/oarepo_ui/resources/templating.py b/oarepo_ui/resources/templating.py index 21713124..9d52e6ee 100644 --- a/oarepo_ui/resources/templating.py +++ b/oarepo_ui/resources/templating.py @@ -56,20 +56,3 @@ def jinja_env(self): def id_filter(x): return id(x) - -def get_components(): - - component_data = [] - directory = os.path.dirname(os.path.abspath(__file__ or '')) - parent_directory = os.path.dirname(directory) - components_directory = os.path.join(parent_directory, 'templates', 'components') - - - file_names = os.listdir(components_directory) - - for file_name in file_names: - component_data.append({"key": file_name.replace(".jinja", "").lower(), "component": file_name.replace(".jinja", "")}) - - - return component_data -